@soleri/forge 9.7.2 → 9.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/agent-schema.d.ts +177 -6
  2. package/dist/agent-schema.js +58 -0
  3. package/dist/agent-schema.js.map +1 -1
  4. package/dist/compose-claude-md.js +56 -3
  5. package/dist/compose-claude-md.js.map +1 -1
  6. package/dist/domain-manager.d.ts +1 -0
  7. package/dist/domain-manager.js +57 -1
  8. package/dist/domain-manager.js.map +1 -1
  9. package/dist/knowledge-installer.d.ts +2 -0
  10. package/dist/knowledge-installer.js +107 -1
  11. package/dist/knowledge-installer.js.map +1 -1
  12. package/dist/lib.d.ts +1 -1
  13. package/dist/lib.js +1 -1
  14. package/dist/lib.js.map +1 -1
  15. package/dist/scaffold-filetree.d.ts +12 -0
  16. package/dist/scaffold-filetree.js +356 -10
  17. package/dist/scaffold-filetree.js.map +1 -1
  18. package/dist/scaffolder.js +12 -0
  19. package/dist/scaffolder.js.map +1 -1
  20. package/dist/skills/subagent-driven-development/SKILL.md +87 -20
  21. package/dist/templates/setup-script.js +71 -0
  22. package/dist/templates/setup-script.js.map +1 -1
  23. package/dist/templates/shared-rules.js +163 -6
  24. package/dist/templates/shared-rules.js.map +1 -1
  25. package/package.json +1 -1
  26. package/src/__tests__/domain-manager.test.ts +140 -0
  27. package/src/__tests__/scaffold-filetree.test.ts +326 -1
  28. package/src/__tests__/scaffolder.test.ts +7 -5
  29. package/src/__tests__/shared-rules.test.ts +48 -0
  30. package/src/agent-schema.ts +66 -0
  31. package/src/compose-claude-md.ts +63 -3
  32. package/src/domain-manager.ts +74 -1
  33. package/src/knowledge-installer.ts +124 -1
  34. package/src/lib.ts +6 -1
  35. package/src/scaffold-filetree.ts +404 -10
  36. package/src/scaffolder.ts +17 -0
  37. package/src/skills/subagent-driven-development/SKILL.md +87 -20
  38. package/src/templates/setup-script.ts +71 -0
  39. package/src/templates/shared-rules.ts +166 -6
@@ -8,10 +8,37 @@ description: >
8
8
 
9
9
  # Subagent-Driven Development
10
10
 
11
- Decompose work into isolated units, dispatch subagents via the Agent tool, merge results back. You are the controller — you never implement, you orchestrate.
11
+ Decompose work into isolated units, dispatch subagents via the Agent tool, merge results back. You are the orchestrator — you make all decisions, subagents execute.
12
12
 
13
13
  **Announce at start:** "I'm using the subagent-driven-development skill to dispatch isolated agents."
14
14
 
15
+ ## The Orchestrator Contract
16
+
17
+ **You are the boss. Subagents are the crew.**
18
+
19
+ 1. **All decisions stay with the orchestrator.** Research the task, consult the vault, decide the approach. Subagents receive exact specs — scope, file boundaries, acceptance criteria. They execute, they don't decide.
20
+ 2. **Subagents MUST NOT create plans.** Only the orchestrator creates plans. Subagent prompts must explicitly state: "Do NOT create plans, do NOT call planning tools."
21
+ 3. **If a subagent hits ambiguity, it returns — it doesn't guess.** The orchestrator resolves, then re-dispatches.
22
+ 4. **The orchestrator reconciles all work.** After subagents return, the orchestrator reviews changes, merges, captures knowledge.
23
+
24
+ ## Hybrid Agent Routing
25
+
26
+ Not all subagents are equal. Route by complexity:
27
+
28
+ | Signal | Agent Type | Why |
29
+ | ------------------------------------- | ------------------------- | ----------------------------- |
30
+ | Single file, clear spec, no decisions | **Claude Code worker** | Fast, low overhead |
31
+ | Approach already in parent plan | **Claude Code worker** | Spec is decided |
32
+ | 3+ files, cross-cutting concerns | **Soleri agent instance** | Needs vault, brain, lifecycle |
33
+ | Unresolved design decisions | **Soleri agent instance** | Needs judgment |
34
+ | New dependencies or architecture | **Soleri agent instance** | Needs full context |
35
+
36
+ **User overrides:**
37
+
38
+ - "Use full agent for everything" → all Soleri agent instances
39
+ - "Just use workers" → all Claude Code workers
40
+ - Default: hybrid routing
41
+
15
42
  ## When to Dispatch
16
43
 
17
44
  | Signal | Dispatch? |
@@ -25,47 +52,87 @@ Decompose work into isolated units, dispatch subagents via the Agent tool, merge
25
52
 
26
53
  ## The Process
27
54
 
28
- ### Step 1: Decompose
55
+ ### Step 1: Research & Decide (Orchestrator only)
56
+
57
+ Read all relevant files. Consult the vault for patterns. Make every design decision. Define the exact spec for each subagent task: files to touch, approach to use, acceptance criteria.
29
58
 
30
- Break work into discrete units. For each, determine: files involved, dependencies on other units, conflict risk. Only units with no file overlap and no inter-dependency qualify for dispatch.
59
+ ### Step 2: Decompose & Route
31
60
 
32
- ### Step 2: Dispatch with Worktree Isolation
61
+ Break work into discrete units. For each, determine: files involved, dependencies on other units, conflict risk, complexity. Assign agent type per the routing table.
62
+
63
+ ### Step 3: Dispatch
64
+
65
+ Present the dispatch table to the user:
33
66
 
34
67
  ```
35
- Agent(prompt: "<task prompt>", isolation: "worktree")
68
+ ## Dispatching N tasks in parallel
69
+
70
+ | # | Task | Agent | Why |
71
+ |---|------|-------|-----|
72
+ | 1 | Description | Worker / Instance | Routing reason |
36
73
  ```
37
74
 
38
- Each subagent prompt must include: (1) task scope, (2) file boundaries, (3) acceptance criteria, (4) rules — no commits, no out-of-scope changes, run tests before reporting.
75
+ Each subagent prompt must include:
76
+
77
+ - Task scope and file boundaries
78
+ - Acceptance criteria
79
+ - "Do NOT create plans. Do NOT make design decisions. Execute this spec exactly."
80
+ - For Soleri instances: "Activate, execute, run orchestrate_complete when done."
39
81
 
40
82
  Launch all independent subagents in a **single message** so they run in parallel.
83
+ Use `isolation: "worktree"` for file-modifying tasks.
41
84
 
42
- ### Step 3: Review and Merge
85
+ ### Step 4: Review and Merge
43
86
 
44
87
  For each returning subagent:
45
88
 
46
89
  1. **Review** — read actual file changes (do not trust self-reports alone), verify tests pass, check scope compliance
47
90
  2. **Merge** — `git merge` or `git cherry-pick` from the worktree branch, one at a time
48
91
  3. **Test** — run the full suite after each merge; only proceed if green
49
- 4. **Conflicts** — resolve manually, re-run tests, capture as anti-pattern for future planning
92
+ 4. **Conflicts** — resolve manually, re-run tests, capture as anti-pattern
93
+
94
+ ### Step 5: Reconcile & Report
95
+
96
+ After all merges, report to the user:
50
97
 
51
- After all merges, capture learnings:
98
+ **Minimal (default):**
52
99
 
53
100
  ```
54
- YOUR_AGENT_core op:capture_quick params:{
55
- title: "subagent dispatch outcome",
56
- description: "<which tasks parallelized well, which conflicted>"
57
- }
101
+ N/N complete. M patterns captured to vault.
102
+ → Decisions: [any design decisions the orchestrator made]
103
+ ```
104
+
105
+ **Detailed (on request):**
106
+
58
107
  ```
108
+ | # | Task | Agent | Status | Knowledge |
109
+ |---|------|-------|--------|-----------|
110
+ | 1 | Desc | Worker | Done ✓ | — |
111
+ | 2 | Desc | Instance | Done ✓ | 2 patterns |
112
+ ```
113
+
114
+ Capture learnings to vault. Run `orchestrate_complete` for the parent plan.
115
+
116
+ ## Worktree Cleanup Guarantee
117
+
118
+ Three layers — nothing accumulates:
119
+
120
+ 1. **Per-task:** `finally` block in dispatcher removes worktree after each task
121
+ 2. **Per-batch:** `cleanupAll()` runs after all subagents complete
122
+ 3. **Per-session:** `SessionStart` hook prunes orphaned worktrees
59
123
 
60
124
  ## Anti-Patterns
61
125
 
62
- | Anti-Pattern | Why It Fails |
63
- | -------------------------------------------- | --------------------------------------------- |
64
- | Dispatching for a 5-line fix | Startup overhead exceeds the work |
65
- | Parallel dispatch of dependent tasks | Second agent works on stale assumptions |
66
- | Skipping worktree isolation for nearby files | Silent overwrites between agents |
67
- | Trusting self-reports without reading code | Agents miss edge cases or misunderstand scope |
68
- | Dispatching 10+ agents at once | Review bottleneck shifts to the controller |
126
+ | Anti-Pattern | Why It Fails |
127
+ | -------------------------------------------- | --------------------------------------------------- |
128
+ | Subagent creating its own plan | Stale plans accumulate, lifecycle never completes |
129
+ | Subagent making design decisions | Inconsistent approaches, orchestrator loses control |
130
+ | Dispatching for a 5-line fix | Startup overhead exceeds the work |
131
+ | Parallel dispatch of dependent tasks | Second agent works on stale assumptions |
132
+ | Skipping worktree isolation for nearby files | Silent overwrites between agents |
133
+ | Trusting self-reports without reading code | Agents miss edge cases or misunderstand scope |
134
+ | Dispatching 10+ agents at once | Review bottleneck shifts to the controller |
135
+ | Not cleaning up worktrees after merge | Disk bloat, stale branch accumulation |
69
136
 
70
137
  ## Merge Strategy
71
138
 
@@ -322,6 +322,77 @@ else
322
322
  echo "Note: Add $AGENT_DIR/scripts to PATH, or symlink $AGENT_DIR/scripts/$AGENT_NAME to /usr/local/bin/$AGENT_NAME"
323
323
  fi
324
324
  fi
325
+
326
+ # Configure OpenCode enforcement plugin (hooks)
327
+ OPENCODE_PLUGINS_DIR="$AGENT_DIR/.opencode/plugins"
328
+ ENFORCEMENT_PLUGIN="$OPENCODE_PLUGINS_DIR/soleri-enforcement.ts"
329
+
330
+ echo ""
331
+ echo "Configuring OpenCode enforcement plugin..."
332
+ mkdir -p "$OPENCODE_PLUGINS_DIR"
333
+
334
+ if [ -f "$ENFORCEMENT_PLUGIN" ]; then
335
+ echo "[ok] Enforcement plugin already exists — skipping"
336
+ else
337
+ cat > "$ENFORCEMENT_PLUGIN" << PLUGIN
338
+ /**
339
+ * Soleri enforcement plugin for OpenCode.
340
+ * Auto-generated by setup script — do not edit manually.
341
+ *
342
+ * Hooks:
343
+ * - tool.execute.before: block destructive commands (anti-deletion)
344
+ * - session.compacted: capture session summary before context compaction
345
+ * - session.created: clean stale git worktrees on session start
346
+ */
347
+
348
+ const DESTRUCTIVE_PATTERNS = [
349
+ /\\brm\\s+(-[rRf]+\\s+|--force\\s+|--recursive\\s+)/,
350
+ /\\brmdir\\b/,
351
+ /\\bgit\\s+push\\s+--force\\b/,
352
+ /\\bgit\\s+push\\s+-f\\b/,
353
+ /\\bgit\\s+reset\\s+--hard\\b/,
354
+ /\\bgit\\s+clean\\s+-[a-zA-Z]*f/,
355
+ ];
356
+
357
+ export default {
358
+ hooks: {
359
+ 'tool.execute.before': (ctx) => {
360
+ // Anti-deletion: intercept destructive commands
361
+ const input = JSON.stringify(ctx.input ?? '');
362
+ for (const pattern of DESTRUCTIVE_PATTERNS) {
363
+ if (pattern.test(input)) {
364
+ throw new Error(
365
+ '[soleri-anti-deletion] BLOCKED: Destructive command detected. ' +
366
+ 'Use explicit confirmation or a safer alternative.'
367
+ );
368
+ }
369
+ }
370
+ },
371
+ 'session.compacted': (ctx) => {
372
+ // Session capture: call op:session_capture before context compaction
373
+ console.info(
374
+ '[soleri-session-capture] Before context is compacted, capture a session summary ' +
375
+ 'by calling ${config.id}_core op:session_capture with a brief summary of what was ' +
376
+ 'accomplished, the topics covered, files modified, and tools used.'
377
+ );
378
+ },
379
+ 'session.created': (ctx) => {
380
+ // Worktree cleanup: clean stale git worktrees on session start
381
+ try {
382
+ const { execSync } = require('child_process');
383
+ execSync('sh $AGENT_DIR/scripts/clean-worktrees.sh', {
384
+ timeout: 10000,
385
+ stdio: 'pipe',
386
+ });
387
+ } catch (err) {
388
+ console.warn('[soleri-worktree-cleanup] Failed to clean worktrees:', err.message);
389
+ }
390
+ },
391
+ },
392
+ };
393
+ PLUGIN
394
+ echo "[ok] Created enforcement plugin at $ENFORCEMENT_PLUGIN"
395
+ fi
325
396
  `
326
397
  : '';
327
398
 
@@ -223,6 +223,42 @@ const ENGINE_RULES_LINES: string[] = [
223
223
  '```',
224
224
  '',
225
225
 
226
+ // ─── Workflow Overrides ──────────────────────────────────
227
+ '## Workflow Overrides',
228
+ '<!-- soleri:workflow-overrides -->',
229
+ '',
230
+ "The engine reads `gates.yaml` and `tools.yaml` from your agent's `workflows/` directory and merges them into plans.",
231
+ '',
232
+ '**Three files, three purposes:**',
233
+ '- `prompt.md` — Claude reads this as narrative guidance (what to do)',
234
+ '- `gates.yaml` — Engine enforces these as plan checkpoints (when to validate)',
235
+ '- `tools.yaml` — Engine merges these into plan steps (what tools to use)',
236
+ '',
237
+ '**Default mapping** (workflow name → orchestration intent):',
238
+ '| Workflow | Intent |',
239
+ '|----------|--------|',
240
+ '| `feature-dev` | BUILD |',
241
+ '| `bug-fix` | FIX |',
242
+ '| `code-review` | REVIEW |',
243
+ '| `context-handoff` | HANDOFF |',
244
+ '',
245
+ 'Override in `agent.yaml`:',
246
+ '```yaml',
247
+ 'workflowIntents:',
248
+ ' my-custom-workflow: BUILD',
249
+ ' security-review: REVIEW',
250
+ '```',
251
+ '',
252
+ '**How it works:**',
253
+ '1. You call `orchestrate_plan` with a task',
254
+ '2. Engine detects intent (e.g., REVIEW)',
255
+ '3. Engine checks if your agent has a matching workflow (e.g., `workflows/code-review/`)',
256
+ '4. If found: workflow gates are appended to plan gates, workflow tools are merged into plan steps',
257
+ '5. If not found: current behavior unchanged',
258
+ '',
259
+ '**Editing workflows changes engine behavior.** If you modify `gates.yaml` in `workflows/code-review/`, the next REVIEW plan will include your custom gates.',
260
+ '',
261
+
226
262
  // ─── YOLO Mode ──────────────────────────────────────────
227
263
  '## YOLO Mode',
228
264
  '<!-- soleri:yolo-mode -->',
@@ -341,13 +377,29 @@ const ENGINE_RULES_LINES: string[] = [
341
377
  '',
342
378
  '### The Non-Negotiable Rule',
343
379
  '',
344
- '`op:orchestrate_complete` runs for EVERY task — simple or complex. This captures:',
380
+ '`op:orchestrate_complete` runs for EVERY task — simple or complex. But it is **user-gated**: never auto-complete without confirmation.',
381
+ '',
382
+ 'This captures:',
345
383
  '- Knowledge to vault (patterns learned, decisions made)',
346
384
  '- Session summary (what was done, files changed)',
347
385
  "- Brain feedback (what worked, what didn't)",
348
386
  '',
349
387
  'Without completion, the knowledge trail is lost. The code is in git, but the WHY disappears.',
350
388
  '',
389
+ '### Reconciliation Triggers',
390
+ '',
391
+ '`op:orchestrate_complete` is triggered by one of three conditions — all require user confirmation before running.',
392
+ '',
393
+ '| Trigger | Condition | Agent Action |',
394
+ '|---------|-----------|--------------|',
395
+ '| **Explicit** | User says "done", "ship it", "looks good", "wrap up" | Call `op:orchestrate_complete` immediately |',
396
+ '| **Plan-complete** | All plan tasks reach terminal state (completed/skipped/failed) | Ask: "All tasks are complete. Want me to wrap up and capture what we learned, or is there more to fix?" |',
397
+ '| **Idle** | Plan in `executing` state with no recent task work | Ask: "We\'ve been idle on this plan. Ready to wrap up, or still working?" |',
398
+ '',
399
+ '**NEVER auto-complete without asking the user.** The agent detects readiness but the user decides when to finalize.',
400
+ '',
401
+ 'Use `op:orchestrate_status` to check plan readiness — it includes a `readiness` field with `allTasksTerminal`, `terminalCount`, `totalCount`, and `idleSince` for the active plan.',
402
+ '',
351
403
  '### Exceptions (skip assessment, execute directly)',
352
404
  '',
353
405
  '- Read-only operations (search, status, health check)',
@@ -588,6 +640,18 @@ const ENGINE_RULES_LINES: string[] = [
588
640
  '```',
589
641
  '',
590
642
  'The scaffolded agent is ready immediately — no build step, no npm install for the agent itself.',
643
+ 'Git is initialized by default (`git init` + initial commit). Use `--no-git` to skip. After scaffolding, the CLI offers to set up a remote via `gh repo create` (if gh CLI is available) or a manual remote URL. The `--yes` flag enables git init but skips the remote prompt.',
644
+ '',
645
+ '### Browsable Knowledge',
646
+ '',
647
+ "Your agent's vault is automatically synced to `knowledge/vault/` as markdown files. Browse them in VS Code, Obsidian, or any editor.",
648
+ '',
649
+ '```bash',
650
+ '# Export vault to a custom location (e.g., Obsidian)',
651
+ 'soleri vault export --path ~/obsidian-vault/soleri',
652
+ '```',
653
+ '',
654
+ 'The engine indexes entries in SQLite for fast search, but you always own the files.',
591
655
  '',
592
656
  '### Updating Soleri',
593
657
  '',
@@ -631,11 +695,14 @@ const ENGINE_RULES_LINES: string[] = [
631
695
  'The composition pipeline assembles CLAUDE.md from:',
632
696
  '',
633
697
  '1. **Agent identity** — from `agent.yaml`',
634
- '2. **Engine rules** — from `@soleri/forge` shared rules (this section)',
635
- '3. **User instructions** — from `instructions/*.md` (alphabetically sorted)',
636
- '4. **Tools table** — from engine registration',
637
- '5. **Workflow index** — from `workflows/`',
638
- '6. **Skills index** — from `skills/`',
698
+ '2. **Custom instructions** — from `instructions/user.md` (priority placement, before engine rules)',
699
+ '3. **Engine rules** — from `@soleri/forge` shared rules (this section)',
700
+ '4. **User instructions** — from `instructions/*.md` (alphabetically sorted, excluding `user.md` and `_engine.md`)',
701
+ '5. **Tools table** — from engine registration',
702
+ '6. **Workflow index** — from `workflows/`',
703
+ '7. **Skills index** — from `skills/`',
704
+ '',
705
+ '`instructions/user.md` is the recommended place for your most important agent-specific rules — it appears early in CLAUDE.md for maximum influence on model behavior. Other `instructions/*.md` files are included after engine rules.',
639
706
  '',
640
707
  'When the engine updates (`@soleri/core` or `@soleri/forge`), running `soleri agent refresh` regenerates CLAUDE.md with the latest shared rules. Your own `instructions/*.md` files are where agent-specific behavior lives — those survive regeneration.',
641
708
  '',
@@ -664,6 +731,14 @@ const ENGINE_RULES_LINES: string[] = [
664
731
  '| `soleri dev` | Run agent in development mode (stdio MCP) |',
665
732
  '| `soleri test` | Run agent tests (`--watch`, `--coverage`) |',
666
733
  '',
734
+ '### Vault',
735
+ '',
736
+ '| Command | What it does |',
737
+ '|---------|-------------|',
738
+ '| `soleri vault export` | Export vault entries as browsable markdown files |',
739
+ '| `soleri vault export --path <dir>` | Export to custom directory (e.g., Obsidian vault) |',
740
+ '| `soleri vault export --domain <name>` | Export entries from a specific domain |',
741
+ '',
667
742
  '### Knowledge & Packs',
668
743
  '',
669
744
  '| Command | What it does |',
@@ -687,6 +762,10 @@ const ENGINE_RULES_LINES: string[] = [
687
762
  '',
688
763
  '### Hooks & Skills',
689
764
  '',
765
+ 'Your agent ships with **essential skills** by default (agent-guide, agent-persona, vault-navigator, vault-capture, systematic-debugging, writing-plans, context-resume). Install more with `soleri skills install <name>`. List available skills with `soleri skills list`.',
766
+ '',
767
+ 'To scaffold all skills instead, set `skillsFilter: all` in `agent.yaml`.',
768
+ '',
690
769
  '| Command | What it does |',
691
770
  '|---------|-------------|',
692
771
  '| `soleri hooks list-packs` | Show available hook packs and their status |',
@@ -701,6 +780,7 @@ const ENGINE_RULES_LINES: string[] = [
701
780
  '|---------|-------------|',
702
781
  '| `soleri install` | Register agent as MCP server (`--target opencode\\|claude\\|codex\\|all`) |',
703
782
  '| `soleri uninstall` | Remove agent MCP server entry |',
783
+ '| `soleri create --no-git` | Scaffold agent without git initialization |',
704
784
  '| `soleri governance --show` | Show vault governance policy |',
705
785
  '| `soleri governance --preset <name>` | Set policy preset (strict\\|moderate\\|permissive) |',
706
786
  '| `soleri upgrade` | Upgrade @soleri/cli (`--check` to preview) |',
@@ -749,6 +829,28 @@ const ENGINE_RULES_LINES: string[] = [
749
829
  '- Any file inside `@soleri/core` or `@soleri/forge`',
750
830
  '',
751
831
 
832
+ // ─── Workspace Routing ─────────────────────────────────────
833
+ '## Workspace Routing',
834
+ '<!-- soleri:workspace-routing -->',
835
+ '',
836
+ 'Agents can define **workspaces** — scoped context areas with their own CONTEXT.md files — and a **routing table** that maps task patterns to workspaces.',
837
+ '',
838
+ '### How It Works',
839
+ '',
840
+ '1. When a task matches a routing pattern, navigate to that workspace.',
841
+ "2. Load the workspace's CONTEXT.md for task-specific instructions and context.",
842
+ '3. Activate only the skills listed in the routing entry.',
843
+ '4. If no pattern matches, use the default root context (agent-level CLAUDE.md).',
844
+ '',
845
+ '### Routing Rules',
846
+ '',
847
+ '- Patterns are matched by semantic similarity, not exact string match.',
848
+ '- The routing table is defined in `agent.yaml` under the `routing:` key.',
849
+ '- Workspaces are directories under `workspaces/{id}/` with a CONTEXT.md file.',
850
+ '- When entering a workspace, its CONTEXT.md supplements (not replaces) the root context.',
851
+ '- Skills listed in the routing entry are prioritized but do not prevent other skills from activating.',
852
+ '',
853
+
752
854
  // ─── Verification Protocol ─────────────────────────────────
753
855
  '## Verification Protocol',
754
856
  '<!-- soleri:verification-protocol -->',
@@ -775,5 +877,63 @@ const ENGINE_RULES_LINES: string[] = [
775
877
  '- Advisory only — flags warnings, never blocks execution',
776
878
  '',
777
879
 
880
+ // ─── Subagent Identity & Behavioral Contract ──────────────
881
+ '## Subagent Identity & Behavioral Contract',
882
+ '<!-- soleri:subagent-identity -->',
883
+ '',
884
+ 'When the orchestrator fans out work to subagents, two agent types are available. The orchestrator routes based on task complexity.',
885
+ '',
886
+ '### Agent Types',
887
+ '',
888
+ '| Type | When to use | Capabilities | Overhead |',
889
+ '|------|------------|--------------|----------|',
890
+ '| **Claude Code worker** | Mechanical tasks: single-file edits, test fixes, config changes, clear specs | File read/write/edit, git, shell, tests | Low — fast, stateless |',
891
+ '| **Soleri agent instance** | Complex tasks: design decisions, multi-file with cross-cutting concerns, new dependencies | Full agent lifecycle: vault, brain, planning, knowledge capture | High — full activation cycle |',
892
+ '',
893
+ '### Routing Table',
894
+ '',
895
+ '| Signal | Route to |',
896
+ '|--------|---------|',
897
+ '| Single file, clear acceptance criteria, spec fully decided | Claude Code worker |',
898
+ '| Approach already described in parent plan | Claude Code worker |',
899
+ '| Touches 3+ files with cross-cutting concerns | Soleri agent instance |',
900
+ '| Unresolved design decisions not in parent plan | Soleri agent instance |',
901
+ '| New dependencies or architectural choices needed | Soleri agent instance |',
902
+ '',
903
+ '### The Rules',
904
+ '',
905
+ '1. **Orchestrator owns all decisions.** Subagents execute specs — they do NOT make design decisions. If a subagent encounters ambiguity, it returns to the orchestrator with a question, not a guess.',
906
+ '2. **Subagents MUST NOT create plans.** Only the parent orchestrator creates plans. Subagents receive task prompts with exact scope, file boundaries, and acceptance criteria. They execute and return results.',
907
+ '3. **Worktree cleanup is guaranteed.** Three-layer defense: (a) `finally` block in dispatcher cleans per-task worktree, (b) `cleanupAll()` runs after batch completion, (c) `SessionStart` hook prunes orphaned worktrees on every session.',
908
+ '4. **Escalation protocol.** When a subagent hits ambiguity or a blocking issue, it MUST return to the orchestrator with a clear description of the blocker. The orchestrator decides — ask the user or resolve — then re-dispatches.',
909
+ '5. **No freelancing.** Subagents stay within their assigned file boundaries and acceptance criteria. No "while I\'m here" improvements, no scope creep, no out-of-scope commits.',
910
+ '6. **UX output contract.** The orchestrator communicates subagent work to the user at three verbosity levels:',
911
+ '',
912
+ '### UX Output Format',
913
+ '',
914
+ '**Minimal (default):**',
915
+ '```',
916
+ 'Dispatching N tasks in parallel...',
917
+ '',
918
+ '✓ N/N complete. M patterns captured to vault.',
919
+ ' → Decisions: [list any design decisions made]',
920
+ '```',
921
+ '',
922
+ '**Detailed (on request or for complex work):**',
923
+ '```',
924
+ '| # | Task | Agent | Status | Knowledge |',
925
+ '|---|------|-------|--------|-----------|',
926
+ '| 1 | Description | Worker/Instance | Done ✓ | — |',
927
+ '```',
928
+ '',
929
+ '**Verbose (debugging):** Full lifecycle state, vault entries, plan IDs.',
930
+ '',
931
+ '### User Overrides',
932
+ '',
933
+ '- "Use full agent for everything" → all subagents are Soleri agent instances',
934
+ '- "Just use workers" → all subagents are Claude Code workers (no lifecycle overhead)',
935
+ '- Default: hybrid routing based on complexity',
936
+ '',
937
+
778
938
  `<!-- /${ENGINE_MARKER} -->`,
779
939
  ];