FE-1054: unify agent bodies under src/.pi/agents/<id>/ + renames (D90-L migration)#256
Conversation
…-L migration) Slice 3b of subagent-reconciliation (D90-L one agent-body layout): - Move background bodies to src/.pi/agents/<id>/SYSTEM.md (frontmatter kept as DX) - Rename scout->explorer, proposer->projector; reclassify reviewer fg->bg - BACKGROUND_SUBAGENT_IDS = [explorer, researcher, projector, reviewer] - Loader resolves from unified home; no readdir (D39-L code-owned discovery) - Oracle 2 carried forward: planted unlisted <id>/SYSTEM.md not spawnable - Side-task reviewer drain (D15-L/D25-L) untouched - build:pi-assets copies the six agent dirs from the unified home - SPEC/PLAN terminology reconciled to the new home (I29-L invariant + D91-L seal flip NOT touched — reserved for slice 3) Verified: full vitest 1030 pass / 0 fail; npm run check clean.
…ed prompt (D91-L) Slice 3 of subagent-reconciliation (D91-L): - New prompt-assembly.ts: assembled background prompt (control header + injected world snapshot + <brunch-skills> + router), minus foreground elicitation block - Thread injected parent world (GraphReaders scoped to parent specId, spec/workspace seed, session digest via getBranch()) app root -> pi-subagents.ts -> runSubagent - Extract createReadGraphTool; grant explorer read_graph when graph readers injected - Isolation by construction: graphReadersForSpec(graph, specId) binds parent specId; child cannot reach a sibling spec - Oracle 3: assembled prompt carries world snapshot; graph via tool not baked; sibling-spec excluded; ambient seal preserved (in-memory services, no ~/.pi) - FLIP I29-L invariant + glossary to semi-permeable; D91-L Supersedes reconciled - Fix: guard pi.appendEntry.bind in createReadGraphTool call (eager bind threw for mock pi without appendEntry — 6 graph-tool tests) Subagent registration stays dev-gated (context.dev); slice 6 wires the runnable path. Verified: full vitest 1032 pass / 0 fail; npm run check clean; tsc build clean.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Slice 4 of subagent-reconciliation. The op_mode-keyed, code-owned delegatable-set allowlist is now the subagent write-safety boundary: registration/advertisement and execution are restricted to definitions ∩ the foreground agent's canDelegate set, so frontmatter can never self-author delegation. elicit.canDelegate carries the read-only background roster; sovereign child-tool grants are exposed via createSubagentToolCatalog. Narrowed the architecture guard to per-file forbidden needles: reviewer now legitimately appears in runtime-policy.ts's canDelegate (a non-write delegation target), while pi-coder stays out of the foreground registry. Verified: full vitest 1039 passed / 0 failed; npm run check clean. Co-authored-by: Cursor <cursoragent@cursor.com>
PR SummaryLow Risk Overview
Two completed scope cards are added: agent-home unify (slice 3b) and delegatable-set gate (slice 4). Remaining live frontiers in PLAN are narrowed to Reviewed by Cursor Bugbot for commit 712e90a. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 78bf623. Configure here.
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Pull request overview
This PR advances the subagent-reconciliation frontier by unifying background agent bodies under src/.pi/agents/<id>/SYSTEM.md, renaming/background-roster updates, and implementing D91-L’s semi-permeable seal: background subagents receive an assembled prompt with an injected parent-world snapshot plus spec-bound read_graph when provided, and are wired into the dev-gated runtime path.
Changes:
- Migrate background agent bodies to the unified
src/.pi/agents/<id>/SYSTEM.mdhome and renamescout→explorer,proposer→projector, plus reclassifyrevieweras a background manifest. - Inject parent-world snapshot + spec-bound graph readers into subagent execution, and assemble a background system prompt (control header + world snapshot + router rules).
- Refactor graph
read_graphtool creation into a reusable factory and update build/docs/tests to match the new topology and behavior.
Reviewed changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/app/pi-subagents.ts | Adds optional injected world wiring and session-digest rendering for subagents. |
| src/app/brunch-tui.ts | Dev-gated loading of subagents with injected world snapshot + spec-bound graph readers. |
| src/.pi/README.md | Updates topology README to include D90-L/D91-L and new agent body entries. |
| src/.pi/extensions/subagents/subagents.test.ts | Updates subagent tests for new IDs/home and adds semi-permeable seal + read_graph coverage. |
| src/.pi/extensions/subagents/session.ts | Threads injected world into tool planning and assembles the background system prompt. |
| src/.pi/extensions/subagents/README.md | Reconciles extension README to the new home, dev gating, and D91-L semi-permeable seal. |
| src/.pi/extensions/subagents/prompt-assembly.ts | New module to assemble the background subagent prompt (control + snapshot + routing). |
| src/.pi/extensions/subagents/index.ts | Exports injected-world type surface. |
| src/.pi/extensions/subagents/agents.ts | Updates registry IDs and loads SYSTEM.md from unified agent home. |
| src/.pi/extensions/README.md | Notes subagents now include assembled prompts + injected world reads. |
| src/.pi/extensions/graph/index.ts | Extracts createReadGraphTool factory and reuses it in registrar and subagents. |
| src/.pi/agents/reviewer/SYSTEM.md | Converts reviewer into a background frontmatter-bearing agent body. |
| src/.pi/agents/researcher/SYSTEM.md | Adds researcher background agent body under unified home. |
| src/.pi/agents/README.md | Reconciles agent-body topology + discovery model (registry-listed backgrounds only). |
| src/.pi/agents/projector/SYSTEM.md | Renames proposer→projector in the agent body. |
| src/.pi/agents/explorer/SYSTEM.md | Renames scout→explorer and adds read_graph to tools list. |
| src/.pi/tests/prompt-shape-readmes.test.ts | Updates assertions for the revised agents README prompt-shape section. |
| src/.pi/tests/architecture.test.ts | Updates architecture expectations for unified agent bodies and new background agents. |
| package.json | Updates build:pi-assets to copy the unified agent directories into dist/.pi/agents. |
| memory/SPEC.md | Reconciles D44-L/I29-L text and glossary rows to D90-L/D91-L changes and new roster terminology. |
| memory/PLAN.md | Marks slices 2b/3 done and updates acceptance wording to match unified home + D91-L. |
| memory/cards/subagent-reconciliation--world-inject-seal.md | New completed scope card capturing D91-L world-injection + assembled prompt slice. |
| memory/cards/subagent-reconciliation--agent-home-unify.md | New completed scope card capturing unified agent-home + rename migration slice. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export function renderSubagentSessionDigest(entries: readonly unknown[], maxEntries = 6): string { | ||
| if (entries.length === 0) return '- recent entries: none'; | ||
| const recent = entries.slice(-maxEntries); | ||
| const omitted = entries.length - recent.length; |
Make `execute` a live operational mode mapped to a new `orchestrator` foreground agent, granted a code-owned `orchestrator_stub` tool (read-only plus the stub; bash/edit/write blocked). `code`/`pi-coder` stays planned. The orchestrator + stub register on the normal product extension path (not dev-gated); canDelegate is [] so no worker lands this branch. Retires HANDOFF.md and reconciles SPEC/PLAN + topology READMEs. Co-authored-by: Cursor <cursoragent@cursor.com>


FE-1054: unify agent bodies under src/.pi/agents// + renames (D90-L migration)
Slice 3b of subagent-reconciliation (D90-L one agent-body layout):
seal flip NOT touched — reserved for slice 3)
Verified: full vitest 1030 pass / 0 fail; npm run check clean.
FE-1054: semi-permeable subagent seal — inject parent world + assembled prompt (D91-L)
Slice 3 of subagent-reconciliation (D91-L):
world snapshot + + router), minus foreground elicitation block
seed, session digest via getBranch()) app root -> pi-subagents.ts -> runSubagent
child cannot reach a sibling spec
sibling-spec excluded; ambient seal preserved (in-memory services, no ~/.pi)
mock pi without appendEntry — 6 graph-tool tests)
Subagent registration stays dev-gated (context.dev); slice 6 wires the runnable path.
Verified: full vitest 1032 pass / 0 fail; npm run check clean; tsc build clean.