Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Default target
.PHONY: test test-shells test-sdk test-cli test-lint test-e2e test-fast help setup pre-commit sandbox-build sandbox-run
.PHONY: test test-shells test-sdk test-cli test-lint test-e2e test-fast help setup env pre-commit sandbox-build sandbox-run

test:
./tests/test-all.sh
Expand Down Expand Up @@ -72,6 +72,10 @@ setup:
@echo " 2. For persistence, add to your shell RC file:"
@echo " cat setup.sh >> ~/.bashrc # or ~/.zshrc"

env:
@echo 'export AGENTIZE_HOME="$(CURDIR)"'
@echo 'export PYTHONPATH="$(CURDIR)/python:$$PYTHONPATH"'

help:
@echo "Available targets:"
@echo " make test - Run all tests (bash only)"
Expand All @@ -82,6 +86,7 @@ help:
@echo " make test-e2e - Run end-to-end integration tests"
@echo " make test-fast - Run fast tests (sdk + cli + lint)"
@echo " make setup - Generate local setup.sh for development"
@echo " make env - Print environment exports (use: eval $$(make env))"
@echo " make sandbox-build - Build/rebuild the agentize-sandbox image"
@echo " make sandbox-run - Run sandbox with volume passthrough (auto-builds if needed)"
@echo ""
Expand Down
3 changes: 3 additions & 0 deletions templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ All the templates have:
- A `Makefile` in the root folder, which defines the following commands:
- `make setup`: Generates a `setup.sh` script (per-project) to set up environment variables for the SDK.
- This differs from the agentize repo's `make setup` which generates a cross-project `setup.sh` for `wt` and `agentize` CLI functions.
- `make env`: Prints environment export statements to stdout. Usage: `eval $(make env)` to set up the environment in the current shell without generating a file.
- `make env-script`: Generates/regenerates `setup.sh` with current paths using `$(CURDIR)` for proper `make -C` handling.
- `make build`: Builds the SDK.
- `make clean`: Cleans all the build files.
- `make test`: Runs the test cases.
- `make help`: Displays available targets and usage instructions.

- A `bootstrap.sh` script in the root folder, which initializes the SDK from the template.
- This makes `make agentize` (see ../Makefile) as simple as copying this script to the target folder and run this script.
Expand Down
33 changes: 32 additions & 1 deletion templates/c/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: setup build clean test pre-commit
.PHONY: setup build clean test pre-commit env env-script help

pre-commit:
@if [ -f scripts/pre-commit ]; then \
Expand Down Expand Up @@ -28,6 +28,27 @@ setup:
@chmod +x setup.sh
@echo "setup.sh generated successfully"

# ============================================================================
# Environment Setup
# ============================================================================

env:
@echo 'export PROJECT_ROOT="$(CURDIR)"'
@echo 'export PATH="$(CURDIR)/build/bin:$$PATH"'
@echo 'export C_INCLUDE_PATH="$(CURDIR)/include:$$C_INCLUDE_PATH"'
@echo 'export LIBRARY_PATH="$(CURDIR)/build/lib:$$LIBRARY_PATH"'

env-script:
@echo "Generating setup.sh..."
@echo '#!/bin/bash' > setup.sh
@echo '# Generated by make env-script' >> setup.sh
@echo 'export PROJECT_ROOT="$(CURDIR)"' >> setup.sh
@echo 'export PATH="$$PROJECT_ROOT/build/bin:$$PATH"' >> setup.sh
@echo 'export C_INCLUDE_PATH="$$PROJECT_ROOT/include:$$C_INCLUDE_PATH"' >> setup.sh
@echo 'export LIBRARY_PATH="$$PROJECT_ROOT/build/lib:$$LIBRARY_PATH"' >> setup.sh
@chmod +x setup.sh
@echo "Generated setup.sh - run: source setup.sh"

build:
cmake -S . -B build && cmake --build build

Expand All @@ -36,3 +57,13 @@ clean:

test: build
cd build && ctest --output-on-failure

help:
@echo "Available targets:"
@echo " make pre-commit - Install pre-commit hook"
@echo " make setup - Generate setup.sh (legacy)"
@echo " make env - Print environment exports (use: eval \$$(make env))"
@echo " make env-script - Generate setup.sh script"
@echo " make build - Build the project"
@echo " make clean - Clean build artifacts"
@echo " make test - Run tests"
33 changes: 32 additions & 1 deletion templates/cxx/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: setup build clean test pre-commit
.PHONY: setup build clean test pre-commit env env-script help

pre-commit:
@if [ -f scripts/pre-commit ]; then \
Expand Down Expand Up @@ -28,6 +28,27 @@ setup:
@chmod +x setup.sh
@echo "setup.sh generated successfully"

# ============================================================================
# Environment Setup
# ============================================================================

env:
@echo 'export PROJECT_ROOT="$(CURDIR)"'
@echo 'export PATH="$(CURDIR)/build/bin:$$PATH"'
@echo 'export CPLUS_INCLUDE_PATH="$(CURDIR)/include:$$CPLUS_INCLUDE_PATH"'
@echo 'export LIBRARY_PATH="$(CURDIR)/build/lib:$$LIBRARY_PATH"'

env-script:
@echo "Generating setup.sh..."
@echo '#!/bin/bash' > setup.sh
@echo '# Generated by make env-script' >> setup.sh
@echo 'export PROJECT_ROOT="$(CURDIR)"' >> setup.sh
@echo 'export PATH="$$PROJECT_ROOT/build/bin:$$PATH"' >> setup.sh
@echo 'export CPLUS_INCLUDE_PATH="$$PROJECT_ROOT/include:$$CPLUS_INCLUDE_PATH"' >> setup.sh
@echo 'export LIBRARY_PATH="$$PROJECT_ROOT/build/lib:$$LIBRARY_PATH"' >> setup.sh
@chmod +x setup.sh
@echo "Generated setup.sh - run: source setup.sh"

build:
cmake -S . -B build && cmake --build build

Expand All @@ -36,3 +57,13 @@ clean:

test: build
cd build && ctest --output-on-failure

help:
@echo "Available targets:"
@echo " make pre-commit - Install pre-commit hook"
@echo " make setup - Generate setup.sh (legacy)"
@echo " make env - Print environment exports (use: eval \$$(make env))"
@echo " make env-script - Generate setup.sh script"
@echo " make build - Build the project"
@echo " make clean - Clean build artifacts"
@echo " make test - Run tests"
31 changes: 30 additions & 1 deletion templates/python/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: setup build clean test pre-commit
.PHONY: setup build clean test pre-commit env env-script help

pre-commit:
@if [ -f scripts/pre-commit ]; then \
Expand Down Expand Up @@ -26,6 +26,25 @@ setup:
@chmod +x setup.sh
@echo "setup.sh generated successfully"

# ============================================================================
# Environment Setup
# ============================================================================

env:
@echo 'export PROJECT_ROOT="$(CURDIR)"'
@echo 'export PATH="$(CURDIR)/build/bin:$$PATH"'
@echo 'export PYTHONPATH="$(CURDIR)/src:$$PYTHONPATH"'

env-script:
@echo "Generating setup.sh..."
@echo '#!/bin/bash' > setup.sh
@echo '# Generated by make env-script' >> setup.sh
@echo 'export PROJECT_ROOT="$(CURDIR)"' >> setup.sh
@echo 'export PATH="$$PROJECT_ROOT/build/bin:$$PATH"' >> setup.sh
@echo 'export PYTHONPATH="$$PROJECT_ROOT/src:$$PYTHONPATH"' >> setup.sh
@chmod +x setup.sh
Comment on lines +33 to +45
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PYTHONPATH is being set to $(CURDIR)/src, but this template doesn't have a src/ directory (it has the package directory at the repo root, e.g. project_name/). As a result, eval $(make env) / make env-script won't actually put the SDK on PYTHONPATH. Update the export to match the template layout (likely $(CURDIR) or a configurable source path).

Copilot uses AI. Check for mistakes.
@echo "Generated setup.sh - run: source setup.sh"

build:
@echo "No build needed for Python SDK"

Expand All @@ -39,3 +58,13 @@ clean:
test:
@echo "Running Python tests..."
@python3 tests/test_main.py

help:
@echo "Available targets:"
@echo " make pre-commit - Install pre-commit hook"
@echo " make setup - Generate setup.sh (legacy)"
@echo " make env - Print environment exports (use: eval \$$(make env))"
@echo " make env-script - Generate setup.sh script"
@echo " make build - Build the project"
@echo " make clean - Clean build artifacts"
@echo " make test - Run tests"
37 changes: 37 additions & 0 deletions tests/lint/test-makefile-env-target.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# Test: Makefile env target prints correct environment exports

source "$(dirname "$0")/../common.sh"

test_info "Makefile env target prints correct environment exports"

cd "$PROJECT_ROOT"

# Clear MAKEFLAGS to avoid jobserver inheritance issues when invoked via make
unset MAKEFLAGS MAKELEVEL

# Capture make env output
ENV_OUTPUT=$(make env 2>&1)

# Verify AGENTIZE_HOME export is present with $(CURDIR) resolved
if ! echo "$ENV_OUTPUT" | grep -q 'export AGENTIZE_HOME='; then
test_fail "make env missing AGENTIZE_HOME export"
fi

# Verify PYTHONPATH export is present
if ! echo "$ENV_OUTPUT" | grep -q 'export PYTHONPATH='; then
test_fail "make env missing PYTHONPATH export"
fi

# Verify the output is valid shell (can be eval'd without error)
eval "$ENV_OUTPUT" 2>/dev/null
if [ $? -ne 0 ]; then
test_fail "make env output is not valid shell syntax"
fi

# Verify AGENTIZE_HOME was actually set after eval
if [ -z "$AGENTIZE_HOME" ]; then
test_fail "AGENTIZE_HOME not set after eval \$(make env)"
fi
Comment on lines +26 to +35
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test asserts AGENTIZE_HOME is set after eval, but AGENTIZE_HOME is already exported by tests/common.sh, so this check can pass even if make env failed to set it. Consider unset AGENTIZE_HOME (and possibly PYTHONPATH) before eval, then assert the variables are set to the expected values afterwards.

Copilot uses AI. Check for mistakes.

test_pass "make env prints valid environment exports"
26 changes: 26 additions & 0 deletions tests/lint/test-makefile-help-env-targets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# Test: Makefile help target documents env targets

source "$(dirname "$0")/../common.sh"

test_info "Makefile help target documents env targets"

cd "$PROJECT_ROOT"

# Clear MAKEFLAGS to avoid jobserver inheritance issues when invoked via make
unset MAKEFLAGS MAKELEVEL

# Capture make help output
HELP_OUTPUT=$(make help 2>&1)

# Verify env target is documented in help
if ! echo "$HELP_OUTPUT" | grep -q "make env"; then
test_fail "make help missing 'make env' documentation"
fi

# Verify eval usage hint is present
if ! echo "$HELP_OUTPUT" | grep -q "eval"; then
test_fail "make help missing eval usage hint for env target"
fi

test_pass "make help documents env targets"
80 changes: 80 additions & 0 deletions tests/sdk/test-template-env-targets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env bash
# Test: Template Makefiles have env, env-script, and help targets

source "$(dirname "$0")/../common.sh"

test_info "Template Makefiles have env, env-script, and help targets"

TEMPLATES_DIR="$PROJECT_ROOT/templates"
FAILED=0

for lang in python c cxx; do
MAKEFILE="$TEMPLATES_DIR/$lang/Makefile"

if [ ! -f "$MAKEFILE" ]; then
echo "FAIL: $MAKEFILE not found"
FAILED=1
continue
fi

# Check env target exists
if ! grep -q '^env:' "$MAKEFILE"; then
echo "FAIL: $lang/Makefile missing env target"
FAILED=1
fi

# Check env-script target exists
if ! grep -q '^env-script:' "$MAKEFILE"; then
echo "FAIL: $lang/Makefile missing env-script target"
FAILED=1
fi

# Check help target exists
if ! grep -q '^help:' "$MAKEFILE"; then
echo "FAIL: $lang/Makefile missing help target"
FAILED=1
fi

# Check env target exports PROJECT_ROOT
if ! grep -q 'PROJECT_ROOT' "$MAKEFILE"; then
echo "FAIL: $lang/Makefile env target missing PROJECT_ROOT"
FAILED=1
fi

# Check env-script generates setup.sh
if ! grep -q 'setup.sh' "$MAKEFILE"; then
echo "FAIL: $lang/Makefile env-script doesn't generate setup.sh"
FAILED=1
fi

# Check .PHONY includes new targets
if ! grep -q 'env' "$MAKEFILE" | head -1; then
echo "FAIL: $lang/Makefile .PHONY missing env"
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .PHONY check is broken: grep -q produces no output, so piping it to head -1 makes the pipeline succeed regardless of whether the match exists. This can cause the test to miss missing .PHONY entries. Suggest checking the .PHONY: line explicitly (e.g., grep for ^\.PHONY: containing env env-script help) without piping.

Suggested change
if ! grep -q 'env' "$MAKEFILE" | head -1; then
echo "FAIL: $lang/Makefile .PHONY missing env"
if ! grep -q '^\.PHONY:.*\benv\b.*\benv-script\b.*\bhelp\b' "$MAKEFILE"; then
echo "FAIL: $lang/Makefile .PHONY missing env, env-script, or help"

Copilot uses AI. Check for mistakes.
FAILED=1
fi
done

# Verify language-specific exports
# Python: PYTHONPATH
if ! grep -q 'PYTHONPATH' "$TEMPLATES_DIR/python/Makefile"; then
echo "FAIL: python/Makefile missing PYTHONPATH in env target"
FAILED=1
fi

# C: C_INCLUDE_PATH
if ! grep -q 'C_INCLUDE_PATH' "$TEMPLATES_DIR/c/Makefile"; then
echo "FAIL: c/Makefile missing C_INCLUDE_PATH in env target"
FAILED=1
fi

# C++: CPLUS_INCLUDE_PATH
if ! grep -q 'CPLUS_INCLUDE_PATH' "$TEMPLATES_DIR/cxx/Makefile"; then
echo "FAIL: cxx/Makefile missing CPLUS_INCLUDE_PATH in env target"
FAILED=1
fi

if [ $FAILED -ne 0 ]; then
test_fail "Some template Makefiles missing env/env-script/help targets"
fi

test_pass "All template Makefiles have env, env-script, and help targets with language-specific exports"