Skip to content

PLN-202: Add multi-repo support for planning and exploration - #45

Merged
aponamarev merged 46 commits into
mainfrom
symphony/pln-202
Apr 14, 2026
Merged

aponamarev merged 46 commits into
mainfrom
symphony/pln-202

Conversation

@aponamarev

@aponamarev aponamarev commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add --add-dir flag to run-loop.sh enabling multi-repository planning workflows. Secondary repos are passed via CLOSEDLOOP_ADD_DIRS and CLOSEDLOOP_REPO_MAP environment variables.
  • Extend pre-explorer agent to generate per-repo code maps (code-map-{name}.json) for secondary repositories, and plan-draft-writer to produce multi-repo plans with ## Repositories table and @{repo}:path file prefixes.
  • Enhance discover-repos.sh with Tier 0 explicit directory support, path deduplication helpers, and a local: true marker on peers added via --add-dir (consumed by cross-repo-prd-writer to exclude local peers from PRD generation).
  • Add repo field to plan schema for multi-repo task targeting and update cross-repo agents for enhanced context. Multi-repo behavior is owned by the agents themselves — the orchestrator prompt is unchanged.
  • Add tests for discover-repos.sh and setup-closedloop.sh scripts.
  • Added CLOSEDLOOP_STATE_DIR as a single source of truth for state directory name — .closedloop-ai.

Changed Files

Area Files
CLI / orchestration run-loop.sh, setup-closedloop.sh
Agents pre-explorer.md, plan-draft-writer.md, plan-evaluator.md, cross-repo-coordinator.md, cross-repo-prd-writer.md
Schema plan-schema.json
Discovery discover-repos.sh
Hooks subagent-start-hook.sh
Tests test_discover_repos.py, test_setup_closedloop.py, test_validate_plan.py (new)
Config plugin.json (version bump to 1.10.0)

Test plan

  • Run pytest plugins/code/tools/python/test_discover_repos.py — verify discover-repos tests pass

  • Run pytest plugins/code/tools/python/test_setup_closedloop.py — verify setup-closedloop tests pass

  • Run run-loop.sh --add-dir /path/to/secondary-repo --prd test.md — verify multi-repo env vars are exported

  • Verify pre-explorer generates code-map-{name}.json for secondary repos


Loop ID: 019d7291-c472-706c-bf30-19de89cc4afe
Artifact: https://app.closedloop.ai/implementation-plans/PLN-202

Add --add-dir flag to run-loop.sh enabling cross-repository planning.
When secondary repos are specified, the pre-explorer generates per-repo
code maps (code-map-{name}.json), the plan-draft-writer produces
multi-repo plans with @{repo} file prefixes, and discover-repos.sh
deduplicates peers across discovery tiers via CLOSEDLOOP_ADD_DIRS.

Key changes:
- run-loop.sh: --add-dir CLI flag, CLOSEDLOOP_ADD_DIRS/REPO_MAP env vars
- pre-explorer: multi-repo exploration with per-repo code-map output
- plan-draft-writer: ## Repositories table, @{repo}:path task prefixes
- discover-repos.sh: Tier 0 explicit dirs, dedup helpers, structured JSON
- plan-schema.json: repo field in tasks for multi-repo plans
- cross-repo agents: enhanced for multi-repo context
- New prompt-multi-repo.md orchestrator prompt
- Tests for discover-repos and setup-closedloop scripts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@aponamarev
aponamarev marked this pull request as draft April 9, 2026 15:15
aponamarev and others added 7 commits April 9, 2026 10:24
Previous commit erroneously bumped 1.6.0 to 1.12.0 for PLN-202 multi-repo
support. Per semver rules, a single MINOR bump to 1.7.0 is correct. Also
adds the missing CHANGELOG.md entry documenting the multi-repo feature.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The `type` field duplicated `isPrimary` and its enum constraint blocked
any future repurposing. Removed from schema, agent prompt examples, and
field contract. Consolidated repositories validation tests into a single
parametrized test covering single- and multi-entry canonical shapes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Keep prompt.md as the single source of truth and express the multi-repo
variant as a small append-only overlay assembled onto the base at runtime
by setup-closedloop.sh. Eliminates the drift risk of maintaining two
near-identical 540-line prompts.

- Add prompts/overlays/multi-repo.overlay.md with the three phase
  amendments (pre-explorer, plan-draft-writer, cross-repo-coordinator)
- Add prompts/overlays/README.md documenting the overlay mechanism,
  authoring rules, and runtime contract
- setup-closedloop.sh: resolve --prompt <name> as direct base file, else
  assemble base + overlay into \$WORKDIR/.closedloop/prompt-assembled.md,
  else fail loud. Auto-select "multi-repo" (not "prompt-multi-repo")
  when --add-dir is passed without explicit --prompt
- run-loop.sh: accept --prompt <name> when either prompts/<name>.md or
  prompts/overlays/<name>.overlay.md exists
- Delete prompts/prompt-multi-repo.md
- Update test_setup_closedloop.py to verify assembled file equals
  base + blank + overlay
- CLAUDE.md and plugins/code/README.md point at the overlays README

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… harness

Replace six near-identical Tier 0 test functions with a single parametrized
test driven by a declarative Tier0Scenario registry (RepoSpec + PeerExpect
dataclasses). Adding a new case is now one registry entry instead of a new
test function with duplicated setup. Work in progress — no version bump.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@aponamarev
aponamarev marked this pull request as ready for review April 9, 2026 19:36
aponamarev and others added 3 commits April 9, 2026 14:41
Comment thread plugins/code/scripts/setup-closedloop.sh
Comment thread plugins/code/scripts/setup-closedloop.sh
Comment thread plugins/code/prompts/overlays/README.md Outdated
aponamarev and others added 3 commits April 11, 2026 12:34
- Bump code plugin to v1.9.0 and correct CHANGELOG section header
- discover-repos.sh: root discoveryMethod now reports "add_dir" when only
  Tier 0 contributed peers (previously misreported "sibling_scan")
- run-loop.sh: replace unexpanded $CLOSEDLOOP_STATE_DIR inside single-quoted
  help heredoc with literal .closedloop-ai so copy-pasted MONITORING commands
  from --help work
- bootstrap-learnings.sh: use $CLOSEDLOOP_STATE_DIR in PROJECT_DIR suffix
  trim (completes SSOT migration)
- test_compute_success_rates.py: import CLOSEDLOOP_STATE_DIR from
  compute_success_rates instead of duplicating the constant

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…closedloop.sh

Tightens the overlays/README.md wording flagged in PR #45 review. The
previous phrasing ("run-loop.sh --add-dir auto-selects --prompt multi-repo")
was accurate from the user's vantage point but misleading for anyone
auditing run-loop.sh in isolation: the auto-selection actually happens
downstream in setup-closedloop.sh via PROMPT_NAME_EXPLICIT. Updated the
README to name the correct file and explain the forwarding chain through
the /code:code slash command.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@aponamarev
aponamarev requested a review from shafty023 April 11, 2026 17:58
Comment thread plugins/code/hooks/subagent-start-hook.sh
Comment thread plugins/code/scripts/run-loop.sh Outdated
@aponamarev
aponamarev requested a review from shafty023 April 13, 2026 20:23
Comment thread plugins/code/.claude-plugin/plugin.json Outdated
Comment thread plugins/code/agents/cross-repo-coordinator.md Outdated
Comment thread plugins/code/agents/cross-repo-coordinator.md Outdated
@shafty023

Copy link
Copy Markdown
Collaborator

@aponamarev

Spent some time tracing how the multi-repo context actually reaches the agents and want to flag a few concerns before this merges. Not bug blockers, but worth addressing while the surface is small.

  1. The overlay system looks like over-engineering

This PR introduces a new prompt-overlay abstraction (prompts/overlays/ dir, 65-line README, assembly branch in setup-closedloop.sh, auto-selection on --add-dir) to support exactly one consumer: multi-repo.overlay.md. And when you trace what that overlay actually does, all three of its amendments restate things the target agents' own system prompts already cover:

  • Amendment to Phase 0 tells the orchestrator to remind pre-explorer about CLOSEDLOOP_REPO_MAP, but pre-explorer.md already has a ~90-line "Multi-Repo Exploration" section that reads the env var directly, iterates entries, and writes code-map-{name}.json.
  • Amendment to Phase 1 tells the orchestrator to remind plan-draft-writer about the @{repo-name}:path convention, but plan-draft-writer.md already has a full "Multi-Repository Plans" section (M1-M5) with that convention, the ## Repositories table, and the repositories field in plan.json.
  • Amendment to Phase 1.4 is framed as a "NOTE" about local peers, but discover-repos.shcross-repo-coordinator Step 1.1 → cross-repo-prd-writer Step 2 already handle this deterministically via the local: true flag. The orchestrator never branches on it.

Net effect: we built an extension point, used it once, and the one use adds zero behavioral delta while spending ~38 lines of tokens per iteration and creating a drift risk (if the @repo:path convention in plan-draft-writer.md changes later, nothing catches a stale overlay).

If there's no second overlay lined up, my vote is to delete the overlay infrastructure entirely (overlays dir, README, the assembly and auto-select branches in setup-closedloop.sh) along with the overlay content. Multi-repo still works end-to-end because the agents own the behavior and read the env vars directly. It's trivial to restore from git if a real second consumer shows up later, and much easier to delete now than after it calcifies.

Side note: the PR description lists prompt-multi-repo.md (new) under Prompts, but what shipped is the overlay system. Worth updating so future archaeologists aren't looking for a file that doesn't exist.

  1. local vs discoveryMethod is a minor SSOT smell

discover-repos.sh:67 stamps add-dir peers with both "discoveryMethod": "add_dir" and "local": true, and no other discovery method produces local peers. cross-repo-coordinator.md Step 1.1 then has to manually preserve the local field when writing .cross-repo-needs.json. Two fields, one fact, with a hand-written preservation step in between.

The mechanism of tagging at discovery time is the right shape (much better than path-matching inside the agent), but the representation should pick one:

  • Drop local and filter downstream on discoveryMethod == "add_dir", or
  • Drop discoveryMethod: "add_dir" and keep local.

Either way, Step 1.1 in cross-repo-coordinator.md becomes unnecessary.

@shafty023 shafty023 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

finished review

…ethod field

Addresses PR #45 review:

1. Delete the prompt-overlay infrastructure (prompts/overlays/ directory and
   assembly/auto-select branches in setup-closedloop.sh). The sole overlay
   (multi-repo) only restated behavior that the target agents — pre-explorer,
   plan-draft-writer, cross-repo-prd-writer — already implement directly from
   CLOSEDLOOP_REPO_MAP / CLOSEDLOOP_ADD_DIRS. No behavioral delta from removal.

2. Drop the redundant "discoveryMethod": "add_dir" field from per-peer JSON in
   discover-repos.sh. "local": true is the single source of truth for
   identifying --add-dir peers. Remove the hand-written preservation step
   (Step 1.1) from cross-repo-coordinator.md.

3. Bump code plugin version 1.9.0 → 1.10.0 and consolidate unreleased
   changelog entries.
@aponamarev
aponamarev requested a review from shafty023 April 14, 2026 21:09
Comment thread CHANGELOG.md Outdated
@aponamarev
aponamarev merged commit 4df3c92 into main Apr 14, 2026
3 checks passed
@aponamarev
aponamarev deleted the symphony/pln-202 branch April 14, 2026 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants