@pi-agents/orchid 0.1.0-beta.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 (163) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/LICENSE +21 -0
  3. package/README.md +246 -0
  4. package/agents/AGENTS-MANIFEST.md +42 -0
  5. package/agents/brain.md +42 -0
  6. package/agents/context-builder.md +46 -0
  7. package/agents/delegate.md +12 -0
  8. package/agents/dev-1.md +42 -0
  9. package/agents/oracle.md +73 -0
  10. package/agents/planner.md +55 -0
  11. package/agents/researcher.md +52 -0
  12. package/agents/reviewer.md +79 -0
  13. package/agents/scout.md +50 -0
  14. package/agents/tester.md +45 -0
  15. package/agents/worker.md +55 -0
  16. package/extensions/ralph.ts +1 -0
  17. package/extensions/reviewer-extension.ts +125 -0
  18. package/extensions/task-orchestrator.ts +28 -0
  19. package/package.json +63 -0
  20. package/prompts/gather-context-and-clarify.md +13 -0
  21. package/prompts/parallel-cleanup.md +59 -0
  22. package/prompts/parallel-context-build.md +53 -0
  23. package/prompts/parallel-handoff-plan.md +59 -0
  24. package/prompts/parallel-research.md +50 -0
  25. package/prompts/parallel-review.md +54 -0
  26. package/prompts/review-loop.md +41 -0
  27. package/skills/orchid/SKILL.md +214 -0
  28. package/skills/orchid/orchid-cleanup/SKILL.md +122 -0
  29. package/skills/orchid/orchid-converge/SKILL.md +124 -0
  30. package/skills/orchid/orchid-decompose/SKILL.md +201 -0
  31. package/skills/orchid/orchid-doctor/SKILL.md +162 -0
  32. package/skills/orchid/orchid-investigate/SKILL.md +102 -0
  33. package/skills/orchid/orchid-launch/SKILL.md +147 -0
  34. package/skills/ralph/SKILL.md +73 -0
  35. package/skills/subagents/pi-subagents/SKILL.md +813 -0
  36. package/src/index.ts +7 -0
  37. package/src/orchestrator/abort.ts +534 -0
  38. package/src/orchestrator/agent-bridge-extension.ts +1020 -0
  39. package/src/orchestrator/agent-host.ts +954 -0
  40. package/src/orchestrator/cleanup.ts +776 -0
  41. package/src/orchestrator/config-loader.ts +1412 -0
  42. package/src/orchestrator/config-schema.ts +690 -0
  43. package/src/orchestrator/config.ts +81 -0
  44. package/src/orchestrator/context-window.ts +66 -0
  45. package/src/orchestrator/diagnostic-reports.ts +475 -0
  46. package/src/orchestrator/diagnostics.ts +394 -0
  47. package/src/orchestrator/discovery.ts +1833 -0
  48. package/src/orchestrator/engine-worker.ts +415 -0
  49. package/src/orchestrator/engine.ts +5940 -0
  50. package/src/orchestrator/execution.ts +3104 -0
  51. package/src/orchestrator/extension.ts +5934 -0
  52. package/src/orchestrator/formatting.ts +785 -0
  53. package/src/orchestrator/git.ts +88 -0
  54. package/src/orchestrator/index.ts +28 -0
  55. package/src/orchestrator/lane-runner.ts +1787 -0
  56. package/src/orchestrator/mailbox.ts +780 -0
  57. package/src/orchestrator/merge.ts +3414 -0
  58. package/src/orchestrator/messages.ts +1062 -0
  59. package/src/orchestrator/migrations.ts +278 -0
  60. package/src/orchestrator/naming.ts +117 -0
  61. package/src/orchestrator/path-resolver.ts +275 -0
  62. package/src/orchestrator/persistence.ts +2625 -0
  63. package/src/orchestrator/process-registry.ts +452 -0
  64. package/src/orchestrator/quality-gate.ts +1085 -0
  65. package/src/orchestrator/resume.ts +3488 -0
  66. package/src/orchestrator/sessions.ts +57 -0
  67. package/src/orchestrator/settings-loader.ts +136 -0
  68. package/src/orchestrator/settings-tui.ts +2208 -0
  69. package/src/orchestrator/sidecar-telemetry.ts +267 -0
  70. package/src/orchestrator/supervisor.ts +4548 -0
  71. package/src/orchestrator/task-executor-core.ts +675 -0
  72. package/src/orchestrator/tmux-compat.ts +37 -0
  73. package/src/orchestrator/tool-allowlist-constants.ts +37 -0
  74. package/src/orchestrator/types.ts +4465 -0
  75. package/src/orchestrator/verification.ts +547 -0
  76. package/src/orchestrator/waves.ts +1564 -0
  77. package/src/orchestrator/workspace.ts +707 -0
  78. package/src/orchestrator/worktree.ts +2725 -0
  79. package/src/ralph/index.ts +825 -0
  80. package/src/subagents/agents/agent-management.ts +648 -0
  81. package/src/subagents/agents/agent-scope.ts +6 -0
  82. package/src/subagents/agents/agent-selection.ts +23 -0
  83. package/src/subagents/agents/agent-serializer.ts +86 -0
  84. package/src/subagents/agents/agents.ts +832 -0
  85. package/src/subagents/agents/chain-serializer.ts +137 -0
  86. package/src/subagents/agents/frontmatter.ts +29 -0
  87. package/src/subagents/agents/identity.ts +30 -0
  88. package/src/subagents/agents/skills.ts +632 -0
  89. package/src/subagents/extension/config.ts +16 -0
  90. package/src/subagents/extension/control-notices.ts +92 -0
  91. package/src/subagents/extension/doctor.ts +199 -0
  92. package/src/subagents/extension/fanout-child.ts +170 -0
  93. package/src/subagents/extension/index.ts +573 -0
  94. package/src/subagents/extension/schemas.ts +168 -0
  95. package/src/subagents/intercom/intercom-bridge.ts +379 -0
  96. package/src/subagents/intercom/result-intercom.ts +377 -0
  97. package/src/subagents/runs/background/async-execution.ts +712 -0
  98. package/src/subagents/runs/background/async-job-tracker.ts +310 -0
  99. package/src/subagents/runs/background/async-resume.ts +345 -0
  100. package/src/subagents/runs/background/async-status.ts +325 -0
  101. package/src/subagents/runs/background/completion-dedupe.ts +63 -0
  102. package/src/subagents/runs/background/notify.ts +108 -0
  103. package/src/subagents/runs/background/parallel-groups.ts +45 -0
  104. package/src/subagents/runs/background/result-watcher.ts +307 -0
  105. package/src/subagents/runs/background/run-id-resolver.ts +83 -0
  106. package/src/subagents/runs/background/run-status.ts +269 -0
  107. package/src/subagents/runs/background/stale-run-reconciler.ts +336 -0
  108. package/src/subagents/runs/background/subagent-runner.ts +1808 -0
  109. package/src/subagents/runs/background/top-level-async.ts +13 -0
  110. package/src/subagents/runs/foreground/chain-clarify.ts +1333 -0
  111. package/src/subagents/runs/foreground/chain-execution.ts +938 -0
  112. package/src/subagents/runs/foreground/execution.ts +918 -0
  113. package/src/subagents/runs/foreground/subagent-executor.ts +2527 -0
  114. package/src/subagents/runs/shared/completion-guard.ts +147 -0
  115. package/src/subagents/runs/shared/long-running-guard.ts +175 -0
  116. package/src/subagents/runs/shared/mcp-direct-tool-allowlist.ts +365 -0
  117. package/src/subagents/runs/shared/model-fallback.ts +103 -0
  118. package/src/subagents/runs/shared/nested-events.ts +819 -0
  119. package/src/subagents/runs/shared/nested-path.ts +52 -0
  120. package/src/subagents/runs/shared/nested-render.ts +115 -0
  121. package/src/subagents/runs/shared/parallel-utils.ts +109 -0
  122. package/src/subagents/runs/shared/pi-args.ts +220 -0
  123. package/src/subagents/runs/shared/pi-spawn.ts +115 -0
  124. package/src/subagents/runs/shared/run-history.ts +60 -0
  125. package/src/subagents/runs/shared/single-output.ts +164 -0
  126. package/src/subagents/runs/shared/subagent-control.ts +226 -0
  127. package/src/subagents/runs/shared/subagent-prompt-runtime.ts +170 -0
  128. package/src/subagents/runs/shared/worktree.ts +577 -0
  129. package/src/subagents/shared/artifacts.ts +98 -0
  130. package/src/subagents/shared/atomic-json.ts +16 -0
  131. package/src/subagents/shared/file-coalescer.ts +40 -0
  132. package/src/subagents/shared/fork-context.ts +76 -0
  133. package/src/subagents/shared/formatters.ts +133 -0
  134. package/src/subagents/shared/jsonl-writer.ts +81 -0
  135. package/src/subagents/shared/model-info.ts +78 -0
  136. package/src/subagents/shared/post-exit-stdio-guard.ts +85 -0
  137. package/src/subagents/shared/session-identity.ts +10 -0
  138. package/src/subagents/shared/session-tokens.ts +44 -0
  139. package/src/subagents/shared/settings.ts +397 -0
  140. package/src/subagents/shared/status-format.ts +49 -0
  141. package/src/subagents/shared/types.ts +822 -0
  142. package/src/subagents/shared/utils.ts +450 -0
  143. package/src/subagents/slash/prompt-template-bridge.ts +397 -0
  144. package/src/subagents/slash/slash-bridge.ts +174 -0
  145. package/src/subagents/slash/slash-commands.ts +528 -0
  146. package/src/subagents/slash/slash-live-state.ts +292 -0
  147. package/src/subagents/tui/render-helpers.ts +80 -0
  148. package/src/subagents/tui/render.ts +1358 -0
  149. package/templates/agents/local/supervisor.md +33 -0
  150. package/templates/agents/local/task-merger.md +27 -0
  151. package/templates/agents/local/task-reviewer.md +30 -0
  152. package/templates/agents/local/task-worker.md +34 -0
  153. package/templates/agents/supervisor-routing.md +92 -0
  154. package/templates/agents/supervisor.md +229 -0
  155. package/templates/agents/task-merger.md +214 -0
  156. package/templates/agents/task-reviewer.md +260 -0
  157. package/templates/agents/task-worker-segment.md +44 -0
  158. package/templates/agents/task-worker.md +557 -0
  159. package/templates/tasks/CONTEXT.md +30 -0
  160. package/templates/tasks/EXAMPLE-001-hello-world/PROMPT.md +98 -0
  161. package/templates/tasks/EXAMPLE-001-hello-world/STATUS.md +73 -0
  162. package/templates/tasks/EXAMPLE-002-parallel-smoke/PROMPT.md +97 -0
  163. package/templates/tasks/EXAMPLE-002-parallel-smoke/STATUS.md +73 -0
@@ -0,0 +1,59 @@
1
+ ---
2
+ description: Parallel research/context builders into an implementation handoff plan
3
+ ---
4
+
5
+ Use parallel subagents to understand the request, compare any external references, inspect the local codebase, and produce a grounded implementation handoff plan with a final implementation-ready meta-prompt.
6
+
7
+ Primary request, target, or focus:
8
+
9
+ $@
10
+
11
+ Use `context: "fresh"` unless I explicitly ask for forked context. First read or fetch any URLs, issue links, PRs, screenshots, plans, docs, or local files mentioned in the request. Treat them as primary scope, not optional context.
12
+
13
+ Use the `subagent` tool in chain mode:
14
+
15
+ 1. First step: a parallel group.
16
+ - `researcher`, when the request includes external references, APIs, libraries, docs, current best practices, or prompt-guidance research.
17
+ - `context-builder` for local codebase context.
18
+ - Add a second `context-builder` only when the scope is large enough to benefit from a separate implementation-strategy pass.
19
+
20
+ 2. Second step: a synthesis `context-builder` that reads the parallel findings and writes the final handoff plan and meta-prompt.
21
+
22
+ Use distinct output paths under the chain directory. Example outputs:
23
+ - `handoff/external-reference.md`
24
+ - `handoff/local-context.md`
25
+ - `handoff/implementation-strategy.md`
26
+ - `handoff/final-handoff-plan.md`
27
+
28
+ Do not write these artifacts into the repository unless I explicitly ask for persistent files.
29
+
30
+ Role guidance:
31
+
32
+ External reference researcher:
33
+ - Study linked projects, docs, issues, examples, source code, or prompt guidance.
34
+ - Identify the behavior, API, implementation files, constraints, and transferable ideas.
35
+ - Conduct web research if needed. Use `web_search` if it is available; otherwise use whatever equivalent research capability is available.
36
+ - Return source links, repo paths, key evidence, risks, and what matters for this implementation.
37
+
38
+ Local context-builder:
39
+ - Read all files needed to fully understand the local issue, not just the first match.
40
+ - Follow imports, callers, tests, fixtures, configuration, docs, and adjacent patterns until the local problem, solution space, and validation path are clear.
41
+ - Return relevant file paths and line ranges, current architecture, constraints, tests, risks, and open questions.
42
+
43
+ Implementation-strategy context-builder, when used:
44
+ - Compare the external evidence against the local architecture.
45
+ - Propose the safest implementation shape, files likely to change, edge cases, validation commands, and decisions that need approval.
46
+ - Stay review/planning-only unless I explicitly ask for implementation.
47
+
48
+ Final synthesis context-builder:
49
+ - Read the parallel outputs and produce one concise handoff plan.
50
+ - Include what the feature/change should do, what the external reference teaches, what the local codebase implies, the recommended approach, likely files to change, constraints, non-goals, validation, risks, and unresolved questions.
51
+ - End with a compact implementation-ready meta-prompt for the next worker/planner.
52
+
53
+ After the chain returns, synthesize the result for me with:
54
+ - the recommended approach;
55
+ - artifact paths;
56
+ - the final meta-prompt;
57
+ - any questions or assumptions that remain.
58
+
59
+ Do not start implementation from this command unless I explicitly ask for it.
@@ -0,0 +1,50 @@
1
+ ---
2
+ description: Parallel subagents research
3
+ ---
4
+
5
+ Launch parallel research subagents to build a grounded answer to the current question or decision.
6
+
7
+ Use fresh context, not forked context, unless I explicitly ask for forked context. Researchers and scouts should inspect sources directly instead of relying on the main conversation history.
8
+
9
+ Use a combination of `researcher` and `scout` subagents:
10
+ - Use `researcher` for web, docs, standards, ecosystem, recent changes, benchmarks, and primary-source evidence.
11
+ - Use `scout` for local codebase context, existing implementation patterns, repo constraints, and files that would be affected.
12
+
13
+ Give each subagent a distinct angle. Unless I specify angles, use these three:
14
+
15
+ 1. External evidence
16
+ Use `researcher` to find current, authoritative sources: official docs, specs, release notes, benchmarks, issue threads, or primary explanations.
17
+
18
+ 2. Local code context
19
+ Use `scout` to inspect the repository for relevant files, existing patterns, constraints, tests, and likely integration points.
20
+
21
+ 3. Practical tradeoffs
22
+ Use `researcher` or `scout`, whichever fits the question, to compare options, risks, edge cases, maintenance cost, and what would be easiest to validate.
23
+
24
+ Adapt the angles when the question calls for it:
25
+ - Library/API questions: include official docs and recent examples.
26
+ - Architecture decisions: include local module boundaries, dependency direction, and migration cost.
27
+ - Debugging questions: include likely failure modes, local call paths, and exact error evidence.
28
+ - UI/product questions: include user flow, accessibility, design precedent, and implementation constraints.
29
+ - Time-sensitive topics: include a recent-developments angle and prefer 2026/2025 sources.
30
+
31
+ Prefer two or three strong subagents over many vague ones. The parent agent should frame the question and assign angles; the child agents should research or scout, not invent broad plans.
32
+
33
+ Ask each subagent to return concise findings with evidence:
34
+ - file paths and line ranges for local findings
35
+ - source links for external findings
36
+ - confidence level and gaps
37
+ - recommended next step or decision implication
38
+
39
+ Do not ask subagents to edit files. This is a research pass only unless I explicitly ask for implementation.
40
+
41
+ After the subagents return, synthesize the answer into:
42
+ - what we know
43
+ - what the local codebase implies
44
+ - tradeoffs and risks
45
+ - gaps or assumptions
46
+ - the recommended next move
47
+
48
+ If findings disagree, call out the disagreement instead of smoothing it over.
49
+
50
+ $@
@@ -0,0 +1,54 @@
1
+ ---
2
+ description: Parallel subagents review
3
+ ---
4
+
5
+ Launch parallel reviewers for an adversarial review of the current work.
6
+
7
+ Use fresh context, not forked context, unless I explicitly ask for forked context. Reviewers should inspect the repository, relevant instructions, and current diff directly from files and commands. Do not rely on the main conversation history.
8
+
9
+ Give each reviewer a distinct angle. Generate the angles dynamically from the user's intent, the plan, the implemented code, and the current diff. If I specify angles, use mine. Otherwise, choose the highest-value review angles for this specific work.
10
+
11
+ These are examples, not fixed defaults:
12
+
13
+ 1. Correctness and regressions
14
+ Check whether the change satisfies the request, preserves existing behavior, handles edge cases, and avoids hidden runtime failures.
15
+
16
+ 2. Tests and validation
17
+ Check whether tests or validation were added at the right layer, whether assertions are meaningful, and whether the chosen verification commands are enough.
18
+
19
+ 3. Simplicity and maintainability
20
+ Check for unnecessary complexity, duplicate structure, single-use wrappers, brittle abstractions, confusing names, verbosity, and cleanup that is clearly worth doing.
21
+
22
+ Choose or adapt angles when the work calls for it:
23
+ - TypeScript-heavy changes: include type safety, source-of-truth types, casts, and error-boundary discipline.
24
+ - UI-heavy changes: include UX, accessibility, copy, and visual quality.
25
+ - Security-sensitive changes: include unsafe input/output handling, auth boundaries, privacy, and data exposure.
26
+ - Docs-heavy changes: include clarity, accuracy, completeness, reader flow, and non-robotic prose.
27
+ - Large multi-file changes: consider a fourth reviewer for structural friction, module boundaries, and testability.
28
+
29
+ Prefer three strong reviewers over many vague reviewers.
30
+
31
+ Give every reviewer a specific task prompt naming its angle. Ask reviewers to return concise, evidence-backed findings with file/line references and suggested fixes. The response should be review feedback, not a context summary. Reviewers must not edit files unless I explicitly ask for a writer pass.
32
+
33
+ While reviewers run, do your own narrow inspection if useful. After they return, synthesize the feedback into:
34
+ - fixes worth doing now
35
+ - optional improvements
36
+ - feedback to ignore or defer, with a short reason
37
+
38
+ Do not blindly apply every reviewer suggestion.
39
+
40
+ Autofix mode: if the invocation contains the exact word `autofix`, treat it as workflow control, not review scope. Remove it before deciding the review target. After synthesis, apply only fixes worth doing now, validate, and summarize. Do not apply optional improvements unless explicitly requested. If there are no fixes worth doing now, do not edit.
41
+
42
+ Without autofix mode, ask before applying fixes unless I already told you to address review feedback. When you ask, end with a compact numbered menu so I can respond with a number. Use wording suited to the findings, but include these choices when applicable:
43
+
44
+ ```text
45
+ Reply with [1], [2], or further instructions:
46
+ [1] Apply only the fixes worth doing now.
47
+ [2] Apply the fixes worth doing now plus optional improvements.
48
+ ```
49
+
50
+ Additional review target or focus from the slash command invocation:
51
+
52
+ $@
53
+
54
+ If the invocation provides a URL, issue link, file path, plan path, or freeform focus, treat it as the primary review scope. Read or fetch that target before assigning reviewer angles, and pass the target explicitly into each reviewer task.
@@ -0,0 +1,41 @@
1
+ ---
2
+ description: Review/fix loop until clean
3
+ ---
4
+
5
+ Run a parent-orchestrated review loop for the requested work.
6
+
7
+ Use the `subagent` tool. Keep the parent session as the loop controller and final decision-maker. Child subagents must receive concrete role-specific tasks; they must not run subagents or manage the loop themselves unless the parent intentionally selected an explicit fanout agent whose builtin `tools` includes `subagent` for that assigned fanout.
8
+
9
+ Default to a maximum of 3 review rounds unless I specify a different cap. Count a review round each time fresh-context reviewers inspect the current diff after a worker pass. Stop early when reviewers find no blockers or fixes worth doing now.
10
+
11
+ If the invocation includes an implementation request, first launch one async `worker` to implement the approved scope. If the current diff is already the target, start with review. The sequence can be launched up front as an async/background chain when the workflow is already clear, or continued as follow-up subagent runs after each async completion. For an initial chain, pass `async: true` so the main chat is unblocked; do not set `clarify: true` unless I explicitly want the foreground clarify UI. Use only one writer against the active worktree at a time unless I explicitly ask for isolated worktrees.
12
+
13
+ For each review round, launch fresh-context `reviewer` agents in parallel. Reviewers must inspect the repository, relevant instructions, and current diff directly from files and commands. They must not rely on the main conversation history and must not edit files.
14
+
15
+ Choose review angles from the actual change. Common angles are correctness/regressions, tests/validation, and simplicity/maintainability. Add security, performance, docs/API contracts, or user-flow validation when the work calls for it. Prefer three strong reviewers over many vague reviewers.
16
+
17
+ After reviewers return, synthesize their feedback into:
18
+ - blockers or scope/product/architecture decisions that need user approval;
19
+ - fixes worth doing now;
20
+ - optional improvements;
21
+ - feedback to ignore or defer, with a short reason.
22
+
23
+ Do not blindly apply every reviewer suggestion. If reviewers surface an unapproved product, scope, or architecture decision, pause and ask me before launching a fix worker.
24
+
25
+ When an async implementation worker completes, treat its handoff as the transition into review, not as final completion, unless I explicitly asked for worker-only work, review-only output, or to stop after implementation.
26
+
27
+ When there are fixes worth doing now and the workflow is implementation-authorized, launch one async forked `worker` to apply only those synthesized fixes. Ask it to preserve the approved scope, run focused validation, and report changed files, commands run with exit codes, validation evidence, surprises, and anything left undone.
28
+
29
+ After a fix worker returns, run another review round only when it made material changes or addressed non-trivial findings. Do not keep looping for optional polish, speculative improvements, or findings already deferred by the parent.
30
+
31
+ Stop and summarize when one of these is true:
32
+ - reviewers find no blockers or fixes worth doing now;
33
+ - remaining feedback is optional, speculative, or intentionally deferred;
34
+ - reviewers surface an unapproved decision that needs me;
35
+ - the max review-round cap is reached.
36
+
37
+ On completion, inspect the final diff yourself, run or confirm focused validation where appropriate, and summarize the loop: rounds run, fixes applied, validation, remaining deferred items, and why the loop stopped.
38
+
39
+ Additional target, implementation request, max-iteration cap, or review focus from the slash command invocation:
40
+
41
+ $@
@@ -0,0 +1,214 @@
1
+ ---
2
+ name: orchid
3
+ description: "Modular orchestration pipeline — 9-phase workflow for multi-agent development. Investigate → Decompose → Launch → Converge → Review → Cleanup. Each phase is a composable sub-skill with its own agents, Ralph loops, and dependencies. Triggers on 'pipeline', 'orchestration', 'orchid', 'decompose and launch', 'run the pipeline', 'start a sprint', 'run the orchid'. Always run orchid-doctor first."
4
+ ---
5
+
6
+ # orchid — Orchestration Identification Pipeline
7
+
8
+ **Version**: 2.0.0 (modular — sub-skills)
9
+ **Role**: Orchestrator/PM meta-skill
10
+ **Depends on**: See DEPENDENCIES section below.
11
+
12
+ ## ⛔ Orchestrator Identity (Non-Negotiable)
13
+
14
+ ```
15
+ You DO NOT implement. You DO NOT edit code files.
16
+ You investigate, document, decompose, delegate, and review.
17
+ ```
18
+
19
+ | ✅ Your Job | ❌ NOT Your Job |
20
+ |------------|----------------|
21
+ | Read code, understand architecture | Write `.rs`, `.ts`, `.py` files |
22
+ | Create GH EPIC + sub-issues | Debug compiler errors yourself |
23
+ | Author `.ralph/` task files for lanes | Refactor code yourself |
24
+ | Launch lane agents via `subagent()` dispatch | Fix failing tests yourself |
25
+ | Wire `lib.rs` module declarations at convergence | Implement features yourself |
26
+ | Run `cargo check && cargo test` to verify convergence | Write unit tests yourself |
27
+ | Review lane output, request revisions | Make code changes beyond wiring |
28
+
29
+ **Exception**: 1-2 line config edits (`lib.rs` module declarations, `Cargo.toml` dep additions) are allowed when wiring convergence.
30
+
31
+ ## ⛔ Delegation Rules (Non-Negotiable)
32
+
33
+ ### subagent() — Internal Work (USE THIS)
34
+
35
+ For ALL coding, investigation, review, and testing delegation:
36
+
37
+ ```javascript
38
+ subagent({
39
+ agent: "worker",
40
+ task: "Implement X...",
41
+ async: true,
42
+ skill: "ms-rust" // project-specific skills injected here
43
+ })
44
+ ```
45
+
46
+ ### interactive_shell — External Eval ONLY (DO NOT USE for work)
47
+
48
+ `interactive_shell` is PROHIBITED for any implementation, debugging, review, or testing task.
49
+ It is EXCLUSIVELY for launching external coding agent CLIs for evaluation/benchmarking:
50
+
51
+ ```javascript
52
+ interactive_shell({ command: 'claude "Review the diffs"', mode: "dispatch" })
53
+ ```
54
+
55
+ | Dimension | subagent() | interactive_shell |
56
+ |-----------|-----------|-------------------|
57
+ | Token cost | One agent | Two agents (you + child) |
58
+ | Model control | Explicit per-task | Whatever pi launches with |
59
+ | Context | Clean fork | TUI overlay burns context |
60
+ | Progress | Structured output | Must poll/parse terminal |
61
+ | Parallelism | Unlimited async | One per terminal tab |
62
+ | Chaining | chain/parallel support | Manual glue |
63
+ | Skills | Inject per-task | Inherit from parent |
64
+
65
+ ## Model Policy
66
+
67
+ 1. **Default**: Omit `model` param → subagent inherits orchestrator's model
68
+ 2. **User-specified**: Use exactly what the user requested
69
+ 3. **Ask if needed**: If user wants cost optimization, ask which model for workers
70
+ 4. **Agent-defined**: `.agents/*.md` files already declare model preferences — respect those
71
+
72
+ **NEVER hardcode a model.** The model decision belongs to the user or the agent definition.
73
+
74
+ ## Pipeline Phases
75
+
76
+ ```
77
+ PHASE 1-2: INVESTIGATE + DOCUMENT → orchid-investigate
78
+
79
+ PHASE 3-5: ISSUES + DECOMPOSE + .ralph/ FILES → orchid-decompose
80
+
81
+ PHASE 6: LAUNCH LANES → orchid-launch
82
+
83
+ PHASE 7-8: CONVERGE + REVIEW → orchid-converge
84
+
85
+ PHASE 9: GAP CLOSURE + CLEANUP → orchid-cleanup
86
+ ```
87
+
88
+ **Before starting ANY phase — run orchid-doctor.**
89
+
90
+ ## Decision Trees
91
+
92
+ ### Which phase to load when?
93
+
94
+ ```
95
+ User says "start pipeline" or "orchestrate X"
96
+
97
+ ├─→ Is this the first time? → orchid-doctor → orchid-investigate
98
+
99
+ ├─→ Do you have an investigation doc but no lanes? → orchid-decompose
100
+
101
+ ├─→ Do you have .ralph/ lane files but no running agents? → orchid-launch
102
+
103
+ ├─→ Are lanes running but reporting done? → orchid-converge
104
+
105
+ └─→ Is convergence done but review found issues? → orchid-cleanup
106
+ ```
107
+
108
+ ### What to do when a phase fails?
109
+
110
+ ```
111
+ Phase fails
112
+
113
+ ├─→ Doctor fails → Fix missing deps. Do NOT proceed.
114
+
115
+ ├─→ Investigate fails → Likely permission or access issue. Check git/gh.
116
+
117
+ ├─→ Decompose fails → Lane overlap detected. Re-do ownership matrix.
118
+
119
+ ├─→ Launch fails → Subagent API down. Retry after 2 min. If persistent, implement directly as last resort.
120
+
121
+ ├─→ Converge fails → Build broken after merge. Identify which lane caused it. Send back to that lane's worker.
122
+
123
+ └─→ Cleanup fails → Gaps too large for single pass. Write additional lane file, re-launch.
124
+ ```
125
+
126
+ ### When to abort vs recover?
127
+
128
+ | Situation | Action |
129
+ |-----------|--------|
130
+ | 1-2 lanes failed, rest green | Re-launch failed lanes only |
131
+ | Build broken at convergence | Send specific fix task to offending lane's worker |
132
+ | All lanes failed | Abort. Re-investigate. Root cause is likely in decomposition. |
133
+ | Subagent API down >10 min | Abort. Queue for retry when API recovers. |
134
+ | User requests stop | Abort gracefully. Archive .ralph/ state for resume. |
135
+ | Reviewer finds critical issues | Do NOT proceed. Send fix task, re-review. |
136
+ | Reviewer finds minor issues | Proceed to cleanup, include fixes in gap-closure. |
137
+
138
+ ## Sub-Skills
139
+
140
+ | Sub-Skill | Phases | Primary Agent | Ralph Loop | Input | Output |
141
+ |-----------|--------|---------------|------------|-------|--------|
142
+ | `orchid-doctor` | Pre-flight | (orchestrator) | No | Project directory | ✅/⚠️/❌ health report |
143
+ | `orchid-investigate` | 1-2 | scout, researcher | No (one-shot) | Project directory, GH repo | Architecture map, tracking doc, gap list |
144
+ | `orchid-decompose` | 3-5 | planner | No (one-shot) | Tracking doc, gap list | EPIC + issues, .ralph/ lane files |
145
+ | `orchid-launch` | 6 | worker, dev-1 | Yes (per lane) | .ralph/ lane files | Running subagents, commit SHAs |
146
+ | `orchid-converge` | 7-8 | reviewer, tester | No | Commit SHAs, changed files | Green build, review report |
147
+ | `orchid-cleanup` | 9 | worker | Yes (gap closure) | Review report, gap list | Clean repo, closed EPIC |
148
+
149
+ ## Dependencies
150
+
151
+ ### Required Agents
152
+
153
+ | Agent | Role | Used By | Model Default |
154
+ |-------|------|---------|---------------|
155
+ | scout | Codebase recon | orchid-investigate | (inherit) |
156
+ | researcher | Web research | orchid-investigate | (inherit) |
157
+ | planner | Implementation planning | orchid-decompose | (inherit) |
158
+ | worker | Implementation execution | orchid-launch, orchid-cleanup | (inherit) |
159
+ | dev-1 | Focused coding | orchid-launch | (inherit) |
160
+ | reviewer | Code review | orchid-converge | (inherit) |
161
+ | tester | Test verification | orchid-converge | (inherit) |
162
+ | brain | Architecture reasoning | Escalation | (inherit) |
163
+ | delegate | Lightweight passthrough | Simple tasks | (inherit) |
164
+
165
+ ### Required Skills
166
+
167
+ | Skill | Source | Version | Used By |
168
+ |-------|--------|---------|---------|
169
+ | pi-ralph-wiggum | npm (@tmustier) | ≥0.2.0 | orchid-launch, orchid-cleanup |
170
+ | pi-subagents | npm | ≥0.25.0 | orchid-launch (all delegation) |
171
+ | create-taskplane-task | npm (taskplane) | ≥0.30.0 | orchid-decompose |
172
+ | multi-lane-orchestration | local | — | orchid-decompose, orchid-launch |
173
+
174
+ ### Project-Specific Skills (auto-detected)
175
+
176
+ | Skill | When | Detection | Source |
177
+ |-------|------|-----------|--------|
178
+ | ms-rust | Rust projects | `Cargo.toml` present | ~/.pi/agent/skills/ms-rust-guidelines |
179
+ | rustic-prompt | Rust projects | `Cargo.toml` present | ~/.pi/agent/skills/rustic-prompt |
180
+
181
+ ### Required Tools
182
+
183
+ | Tool | Check | Required By | Fallback |
184
+ |------|-------|-------------|----------|
185
+ | git | `git --version` | All phases | None — mandatory |
186
+ | gh | `gh auth status` | orchid-decompose | Create issues manually |
187
+ | cargo | `cargo --version` | Rust projects | None — mandatory for Rust |
188
+ | Telepathine bus | `agent_memory_telepath_list()` | orchid-launch, orchid-converge | Coordinate via git commits |
189
+
190
+ ## Quick-Start
191
+
192
+ ```
193
+ 1. /skill orchid-doctor ← Verify all deps
194
+ 2. /skill orchid-investigate ← Scout the codebase
195
+ 3. /skill orchid-decompose ← Plan lanes + write .ralph/ files
196
+ 4. /skill orchid-launch ← Fire lane agents
197
+ 5. /skill orchid-converge ← Merge + review
198
+ 6. /skill orchid-cleanup ← Close gaps + archive
199
+ ```
200
+
201
+ ## Real-World Example: RustAPI Pilot (May 2026)
202
+
203
+ The patterns in OrchID were proven on the RustAPI project — a Go→Rust API gateway rewrite:
204
+
205
+ - **3 parallel lanes** closed 26 issues in a single session
206
+ - Lane 1: Clippy cleanup + E2E tests (12 tests)
207
+ - Lane 2: Provider auth hardening
208
+ - Lane 3: Claude SSE format conversion
209
+ - Full reviewer gate with clippy verification and Go→Rust fidelity audits
210
+ - Build was green at convergence with zero conflicts (file ownership matrix worked)
211
+
212
+ **What worked**: Parallel dispatch with zero file overlap, Telepath coordination, reviewer gates.
213
+ **What failed**: Initial attempt without ownership matrix caused merge conflicts; re-do with matrix resolved it.
214
+ **Key lesson**: The file ownership matrix is not optional. It is the law.
@@ -0,0 +1,122 @@
1
+ ---
2
+ name: orchid-cleanup
3
+ description: "Phase 9 of the orchid pipeline. Close remaining gaps from review, fire cheap gap-closure subagent, archive .ralph/ files, final verification. Triggers on 'cleanup', 'close gaps', 'archive', 'finalize'."
4
+ ---
5
+
6
+ # orchid-cleanup — Gap Closure + Archive
7
+
8
+ **Parent**: `orchid`
9
+ **Phase**: 9
10
+ **Agents used**: worker (gap closure)
11
+ **Ralph loop**: YES (gap closure is iterative)
12
+
13
+ ## What This Does
14
+
15
+ After review, there will be gaps (missing docs, clippy lints, minor fixes).
16
+ Don't bloat your window fixing them — delegate to a gap-closure subagent.
17
+
18
+ ## Step 1: Write Gap Closure File
19
+
20
+ Create `.ralph/close-gaps.md` with concrete, copy-paste-able fixes:
21
+
22
+ ```markdown
23
+ # Final Gap Closure — <Project>
24
+
25
+ **EPIC**: #NNN
26
+ **All lanes complete**: ✅ merged
27
+
28
+ ## Remaining Gaps
29
+
30
+ ### Gap 1: <description>
31
+ - **File**: path/to/file.rs
32
+ - **Fix**: <exact change needed>
33
+ - **Severity**: minor
34
+
35
+ ### Gap 2: <description>
36
+ - **File**: path/to/other.rs
37
+ - **Fix**: <exact change needed>
38
+ - **Severity**: clippy
39
+
40
+ ## Verification
41
+ cargo check && cargo test && cargo clippy --workspace --all-targets -- -D warnings
42
+ ```
43
+
44
+ ## Step 2: Fire Gap-Closure Subagent
45
+
46
+ ```
47
+ subagent({
48
+ agent: "worker",
49
+ task: "Read .ralph/close-gaps.md. Execute every item exactly as written. Verify with the commands listed in the Verification section. Commit + push to main after each fix.",
50
+ async: true
51
+ })
52
+ ```
53
+
54
+ Note: Model is inherited — no override unless user specified one.
55
+
56
+ ## Step 3: Archive .ralph/ Files
57
+
58
+ ```bash
59
+ mkdir -p .ralph/archive
60
+ mv .ralph/lane-* .ralph/*.state.json .ralph/*-output.md .ralph/archive/ 2>/dev/null
61
+ mv .ralph/close-gaps.md .ralph/archive/ 2>/dev/null
62
+ ```
63
+
64
+ **What remains in .ralph/:**
65
+ - `.ralph/master-<project>.md` ← orchestrator master (keep forever)
66
+
67
+ **What goes to archive:**
68
+ - All lane task files
69
+ - All state JSONs
70
+ - All output captures
71
+ - Close-gaps file
72
+
73
+ **Rule**: Only `master-<project>.md` stays in `.ralph/`. Everything else goes to `archive/` on completion.
74
+ This prevents accidentally re-launching completed lanes.
75
+
76
+ ## Step 4: Final Verification
77
+
78
+ ```bash
79
+ cargo fmt --check
80
+ cargo check --workspace
81
+ cargo test --workspace
82
+ cargo clippy --workspace --all-targets -- -D warnings
83
+ ```
84
+
85
+ ## Step 5: Close EPIC
86
+
87
+ ```bash
88
+ # Verify all sub-issues are closed
89
+ gh issue list --repo <org/repo> --state open --label "EPIC" | grep "#NNN"
90
+
91
+ # Close EPIC if all sub-issues resolved
92
+ gh issue close #NNN --repo <org/repo> --comment "All sub-issues resolved. Build green. Tests pass."
93
+ ```
94
+
95
+ ## Completion Criteria
96
+
97
+ - [ ] All review gaps fixed and committed
98
+ - [ ] Build green, 0 warnings, all tests pass
99
+ - [ ] .ralph/ files archived (only master remains)
100
+ - [ ] All sub-issues closed
101
+ - [ ] EPIC closed with summary
102
+ - [ ] Tracking doc updated to final state
103
+ - [ ] Project memory updated with decisions and changes
104
+
105
+ ## Final Output
106
+
107
+ ```
108
+ ✅ orchid Pipeline Complete
109
+
110
+ Project: <name>
111
+ EPIC: #NNN
112
+ Issues closed: <N>
113
+ Lanes executed: A, B, (C)
114
+ Tests: <N> passing
115
+ Build: green
116
+ Clippy: clean
117
+ Review: all findings addressed
118
+ Archive: .ralph/archive/
119
+ Master: .ralph/master-<project>.md
120
+
121
+ Pipeline duration: <time>
122
+ ```
@@ -0,0 +1,124 @@
1
+ ---
2
+ name: orchid-converge
3
+ description: "Phases 7-8 of the orchid pipeline. Pull all changes, wire module declarations, verify build, run reviewer gate. Triggers on 'converge', 'merge lanes', 'review code', 'wire modules'."
4
+ ---
5
+
6
+ # orchid-converge — Merge + Review Gate
7
+
8
+ **Parent**: `orchid`
9
+ **Phases**: 7-8
10
+ **Agents used**: reviewer, tester
11
+ **Ralph loop**: No (convergence is orchestrator-directed)
12
+
13
+ ## Phase 7: Convergence
14
+
15
+ ### When
16
+
17
+ All parallel lanes report ✅ done with commit SHAs on #general.
18
+
19
+ ### Orchestrator Actions
20
+
21
+ #### 1. Pull All Changes
22
+
23
+ ```bash
24
+ git pull origin main
25
+ ```
26
+
27
+ #### 2. Wire Module Declarations
28
+
29
+ This is the ONLY code the orchestrator touches — adding `pub mod` declarations in shared files:
30
+
31
+ ```rust
32
+ // In lib.rs — add new module declarations from completed lanes
33
+ pub mod buffer; // from Lane A
34
+ pub mod naming; // from Lane A
35
+ pub mod handlers; // from Lane B
36
+ ```
37
+
38
+ #### 3. Run Verification
39
+
40
+ ```bash
41
+ cargo fmt --check
42
+ cargo check --workspace
43
+ cargo test --workspace
44
+ cargo clippy --workspace --all-targets -- -D warnings
45
+ ```
46
+
47
+ #### 4. Decision
48
+
49
+ - **Green** → Launch Lane C (if sequential lane exists) via orchid-launch
50
+ - **Red** → Report failure to specific lane:
51
+
52
+ ```
53
+ ❌ Convergence failed:
54
+ Lane B: specific error in <file> — please fix and re-push
55
+ ```
56
+
57
+ ## Phase 8: Review
58
+
59
+ ### Launch Reviewer
60
+
61
+ ```
62
+ subagent({
63
+ agent: "reviewer",
64
+ task: "Review all changes from the <project> implementation.
65
+
66
+ Files: <list all files changed>
67
+ Criteria:
68
+ - All code has language-appropriate guideline markers
69
+ - Canonical docs on public items
70
+ - No unsafe code (or justified)
71
+ - 0 compiler warnings
72
+ - All tests pass
73
+ - File ownership matrix was respected (no cross-lane edits)
74
+ - Go→Rust fidelity (if applicable)
75
+ - No hardcoded secrets or internal paths
76
+
77
+ Report: issues found, severity (critical/major/minor), and recommended fixes."
78
+ })
79
+ ```
80
+
81
+ ### Launch Tester
82
+
83
+ ```
84
+ subagent({
85
+ agent: "tester",
86
+ task: "Run full test suite for <project>.
87
+
88
+ Commands:
89
+ cargo fmt --check
90
+ cargo check --workspace
91
+ cargo test --workspace
92
+ cargo clippy --workspace --all-targets -- -D warnings
93
+
94
+ Report: pass/fail counts, any regressions, coverage gaps."
95
+ })
96
+ ```
97
+
98
+ ### Review Gate Checklist
99
+
100
+ - [ ] `cargo check -- -D warnings` → 0 warnings
101
+ - [ ] `cargo test` → all green
102
+ - [ ] `cargo clippy` → clean
103
+ - [ ] All public items have canonical docs
104
+ - [ ] No `unsafe` code (or justified with safety comment)
105
+ - [ ] File ownership respected (git diff shows expected file owners)
106
+ - [ ] All sub-issues closed or linked to commit
107
+ - [ ] EPIC acceptance criteria met
108
+ - [ ] No hardcoded secrets or internal paths
109
+ - [ ] Go→Rust fidelity verified (if applicable)
110
+
111
+ ## Completion Criteria
112
+
113
+ - [ ] All lanes merged (green build)
114
+ - [ ] Sequential lane (if any) launched and completed
115
+ - [ ] Reviewer reports delivered
116
+ - [ ] Tester reports delivered
117
+ - [ ] All review issues addressed or escalated
118
+
119
+ ## Handoff
120
+
121
+ Pass to `orchid-cleanup` with:
122
+ - Review findings (critical/major/minor)
123
+ - Remaining gaps list
124
+ - Files needing fixes