Skip to content

[feat][#16] Re-implement mega-planner as standalone Python script#17

Open
Tonny-Gu wants to merge 4 commits intomainfrom
issue-16
Open

[feat][#16] Re-implement mega-planner as standalone Python script#17
Tonny-Gu wants to merge 4 commits intomainfrom
issue-16

Conversation

@Tonny-Gu
Copy link
Owner

@Tonny-Gu Tonny-Gu commented Feb 8, 2026

[feat][#16] Re-implement mega-planner as standalone Python script

Summary

Re-implemented the mega-planner (previously a Claude Code plugin command in .claude-plugin/commands/mega-planner.md) as a standalone Python script. The script orchestrates a 7-stage multi-agent debate pipeline using the agentize.workflow.api Session DSL, with co-located prompt files and full 4-mode CLI support.

Changes

  • Created scripts/mega-planner.py (~500 LOC) implementing the full 7-stage pipeline: understander -> (bold + paranoia in parallel) -> (critique + proposal-reducer + code-reducer in parallel) -> consensus
  • Supports 4 CLI modes: default (--feature-desc), --from-issue, --refine-issue, --resolve-issue
  • Copied 7 agent prompt files to scripts/prompts/ for co-location with the script
  • Created scripts/prompts/README.md documenting prompt file sources and synchronization
  • Created scripts/mega-planner.md documenting script interfaces, CLI modes, and internal helpers
  • Updated scripts/README.md with mega-planner section
  • Added python/tests/test_mega_planner.py with 12 tests covering pipeline stages, execution order, prompt rendering, resolve mode, skip_consensus, and feature name extraction
  • Deleted deprecated shim python/agentize/workflow/planner.py (dead code, shadowed by planner/ package directory, marked "TODO: Delete")
  • Deleted python/agentize/workflow/planner.md (docs for deprecated shim)

Testing

  • Added python/tests/test_mega_planner.py with 12 tests verifying:
    • All 7 stages return StageResult (test_returns_all_seven_stages)
    • skip_consensus returns 6 stages (test_skip_consensus)
    • Resolve mode skips debate and runs consensus only (test_resolve_mode_skips_debate)
    • Output artifacts created for each stage (test_output_artifacts_created)
    • Debate report saved with correct sections (test_debate_report_saved)
    • Understander runs before proposers (test_understander_runs_before_proposers)
    • Bold + paranoia dispatched in parallel (test_bold_paranoia_parallel)
    • Feature description appears in rendered prompts (test_feature_description_in_prompts)
    • Dual-input stages receive both proposals (test_dual_input_stages_have_both_proposals)
    • Feature name extraction: short, long truncation, multiline (3 tests)
  • All 277 project tests pass (12 new mega-planner + 22 existing planner + 243 other)

Related Issue

Closes #16

Add `make env` and `make env-script` targets for Makefile-centric
environment setup as alternative to `source setup.sh`.

- Makefile: add `env` target (exports AGENTIZE_HOME, PYTHONPATH)
  and document it in `make help` output.
- templates/python/Makefile: add `env` (PROJECT_ROOT, PATH, PYTHONPATH),
  `env-script` (generates setup.sh), and `help` targets.
- templates/c/Makefile: add `env` (PROJECT_ROOT, PATH, C_INCLUDE_PATH,
  LIBRARY_PATH), `env-script`, and `help` targets.
- templates/cxx/Makefile: add `env` (PROJECT_ROOT, PATH,
  CPLUS_INCLUDE_PATH, LIBRARY_PATH), `env-script`, and `help` targets.
- templates/README.md: document new env, env-script, and help targets.
- tests/lint/test-makefile-env-target.sh: verify make env output and
  eval correctness.
- tests/lint/test-makefile-help-env-targets.sh: verify make help
  documents env target.
- tests/sdk/test-template-env-targets.sh: verify all template Makefiles
  have env, env-script, help targets with language-specific exports.

Test status: 60/60 shell tests passed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Tonny-Gu Tonny-Gu added the agentize:pr PR created by agentize workflow label Feb 8, 2026
Copilot AI review requested due to automatic review settings February 8, 2026 12:04
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds make env / make env-script / make help targets to the main Makefile and SDK templates to standardize environment setup (either via eval $(make env) or generating setup.sh), and introduces shell tests to validate these targets.

Changes:

  • Add env, env-script, and help targets to the Python/C/C++ template Makefiles with language-specific exports.
  • Add env target (and help text) to the repo root Makefile.
  • Add lint/sdk shell tests to verify make env output and template target presence.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Makefile Adds env target and documents it in make help.
templates/python/Makefile Adds env, env-script, help targets for Python SDK template.
templates/c/Makefile Adds env, env-script, help targets for C SDK template.
templates/cxx/Makefile Adds env, env-script, help targets for C++ SDK template.
templates/README.md Documents new template Makefile targets and usage.
tests/lint/test-makefile-env-target.sh Validates make env prints eval-able exports.
tests/lint/test-makefile-help-env-targets.sh Validates make help documents make env usage.
tests/sdk/test-template-env-targets.sh Validates templates include the new Makefile targets and exports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 51 to 52
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.
Comment on lines +26 to +35
# 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
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.
Comment on lines +33 to +45
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
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.
Tonny-Gu and others added 3 commits February 8, 2026 15:10
Address code review findings:
- Makefile: fix shell escaping in help target so `make help` does not
  execute `make env` as a side effect (use `\$$` instead of `$$`).
- tests: add executable permission to all 3 new test files.
- tests/sdk/test-template-env-targets.sh: fix dead test check where
  `grep -q | head -1` always succeeds; use proper .PHONY line check.

Test status: 60/60 shell tests passed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…16)

scripts/mega-planner.py: new standalone 7-stage multi-agent debate pipeline script
  with full 4-mode CLI (default, --from-issue, --refine-issue, --resolve-issue).
  Uses only agentize.workflow.api (Session DSL, run_acw, prompt/path/gh utils).
scripts/mega-planner.md: documentation for the mega-planner script interfaces.
scripts/prompts/: co-located agent prompt files (7 files copied from .claude-plugin/).
scripts/prompts/README.md: directory documentation explaining prompt file sources.
scripts/README.md: added mega-planner section to scripts directory documentation.
python/tests/test_mega_planner.py: 12 tests covering pipeline stages, execution order,
  prompt rendering, resolve mode, skip_consensus, and feature name extraction.
python/agentize/workflow/planner.py: deleted deprecated backward-compat shim
  (shadowed by planner/ package directory, marked TODO:Delete).
python/agentize/workflow/planner.md: deleted documentation for deprecated shim.

All 34 tests pass (12 new mega-planner + 22 existing planner).
Implements the plan from issue #16.
scripts/mega-planner.py: fix debate report header to list only 5 perspectives
  (items 6-7 are appended dynamically by caller); pass full feature_desc to
  consensus prompt instead of truncated feature_name; narrow except clause to
  specific exception types; replace Optional[str] with str | None for
  consistency with PEP 604 style.
@Tonny-Gu Tonny-Gu changed the title [#16][feat] Add make env and env-script targets for environment setup [feat][#16] Re-implement mega-planner as standalone Python script Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentize:pr PR created by agentize workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[plan] Re-implement mega-planner as standalone Python script with copied prompts

1 participant