@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,201 @@
1
+ ---
2
+ name: orchid-decompose
3
+ description: "Phases 3-5 of the orchid pipeline. Create GH EPIC + sub-issues, build file ownership matrix, decompose into parallel lanes, write .ralph/ task files with code skeletons. Triggers on 'decompose', 'create issues', 'plan lanes', 'write ralph files'."
4
+ ---
5
+
6
+ # orchid-decompose — Issues + Lanes + Task Files
7
+
8
+ **Parent**: `orchid`
9
+ **Phases**: 3-5
10
+ **Agents used**: planner (primary)
11
+ **Ralph loop**: No (one-shot planning)
12
+
13
+ ## ⛔ Naming Convention (THIS IS WHERE AGENTS SCREW UP)
14
+
15
+ Ralph appends `.md` automatically. You NEVER include `.md` in the name.
16
+
17
+ | ❌ Creates empty template | ✅ Uses existing content |
18
+ |--------------------------|------------------------|
19
+ | `/ralph start lane-a.md` | `/ralph start lane-a` |
20
+ | `ralph_start({ name: "lane-a.md" })` | `ralph_start({ name: "lane-a" })` |
21
+
22
+ Cleanup if broken:
23
+ ```bash
24
+ rm .ralph/lane-a.md.md .ralph/lane-a_md.state.json
25
+ ```
26
+
27
+ ## Phase 3: Issues
28
+
29
+ ### Create EPIC
30
+
31
+ ```bash
32
+ gh issue create --repo <org/repo> \
33
+ --title "EPIC: <Project> Rewrite/Feature for <Scale/Benefit>" \
34
+ --label "EPIC,P1,<tech>,<domain>,architecture" \
35
+ --body "## Context
36
+ <From investigation tracking doc>
37
+
38
+ ## Scope
39
+ ### In Scope
40
+ - <items>
41
+ ### Out of Scope
42
+ - <items>
43
+
44
+ ## Stack
45
+ | Component | Tech |
46
+ |-----------|------|
47
+
48
+ ## Acceptance Criteria
49
+ - <from tracking doc>
50
+
51
+ ## Sub-Issues
52
+ | # | Title | Priority | Phase |
53
+ |---|-------|----------|-------|
54
+ "
55
+ ```
56
+
57
+ ### Create Sub-Issues (one per module/work-item)
58
+
59
+ ```bash
60
+ gh issue create --repo <org/repo> \
61
+ --title "<Tech>: <Action Verb> — <Specific Deliverable>" \
62
+ --label "P0|P1|P2,<tech>,<domain>,phase-N" \
63
+ --body "## Parent EPIC: #NNN
64
+
65
+ ## Current State
66
+ <what exists now>
67
+
68
+ ## Tasks
69
+ - [ ] <specific implementation task>
70
+ - [ ] <tests>
71
+ - [ ] <documentation>
72
+
73
+ ## Files
74
+ <expected file changes>
75
+
76
+ ## Dependencies
77
+ <Blocked by / blocks>
78
+
79
+ ## Acceptance Criteria
80
+ <verifiable conditions>
81
+ "
82
+ ```
83
+
84
+ ### Cross-Link
85
+
86
+ - EPIC body lists all sub-issues in a table
87
+ - Each sub-issue links back to EPIC
88
+ - Tracking doc links to EPIC + all sub-issues
89
+
90
+ ## Phase 4: Decompose into Lanes
91
+
92
+ ### File Ownership Matrix
93
+
94
+ Build a table where every file is assigned to exactly ONE lane:
95
+
96
+ | File | Owner | Lane | Action |
97
+ |------|-------|------|--------|
98
+ | `src/a.rs` | Lane A | A | CREATE |
99
+ | `src/b.rs` | Lane B | B | EDIT |
100
+ | `src/lib.rs` | Orchestrator | — | Wire at convergence |
101
+
102
+ **Validation**: No file appears in more than one lane.
103
+
104
+ ### Lane Design
105
+
106
+ | Lane | Issues | Depends On | Files |
107
+ |------|--------|------------|-------|
108
+ | Lane A | #AAA, #BBB | None | isolated set |
109
+ | Lane B | #CCC, #DDD | None | isolated set |
110
+ | Lane C | #EEE | A+B converged | depends on A+B types |
111
+
112
+ Lanes A+B have ZERO shared files → can run concurrently.
113
+ Lane C depends on A+B → runs after convergence.
114
+
115
+ ## Phase 5: Write .ralph/ Task Files
116
+
117
+ ### Master Orchestrator File
118
+
119
+ `.ralph/master-<project>.md`:
120
+
121
+ ```markdown
122
+ # <Project> — Orchestrator Master
123
+
124
+ ## ⛔ ORCHESTRATOR RULES
125
+ (From orchid master SKILL.md — delegation rules, model policy)
126
+
127
+ ## Launch Commands
128
+ /ralph resume lane-a-<name>
129
+ /ralph resume lane-b-<name>
130
+
131
+ ## File Ownership Matrix
132
+ (Table from Phase 4)
133
+
134
+ ## Lanes Summary
135
+ Lane A: ...
136
+ Lane B: ...
137
+ Lane C: ... (blocked on convergence)
138
+
139
+ ## Coordination Protocol
140
+ - Claim files on #general channel
141
+ - Commit + push after each task
142
+ - Report done with commit SHA
143
+
144
+ ## Verification
145
+ cargo check && cargo test
146
+ ```
147
+
148
+ ### Lane Task Files (per lane)
149
+
150
+ `.ralph/lane-<x>-<name>.md`:
151
+
152
+ ```markdown
153
+ # Lane X: <Name>
154
+
155
+ **Parent**: `.ralph/master-<project>.md`
156
+ **EPIC**: #NNN
157
+ **Issues**: #AAA, #BBB
158
+
159
+ ## Files You Own (ONLY these)
160
+ | File | Action | Issue |
161
+
162
+ ## Files You MUST NOT Touch
163
+ (list every file owned by other lanes)
164
+
165
+ ## Checklist
166
+ - [ ] #AAA: specific task + tests
167
+ - [ ] #BBB: specific task + tests
168
+ - [ ] cargo check passes
169
+ - [ ] cargo test passes
170
+ - [ ] Commit + push to main
171
+ - [ ] Report on #general with SHA
172
+
173
+ ## Code Skeletons
174
+ (provide function signatures with doc comments — not just "implement X")
175
+
176
+ ## Verification
177
+ (exact commands)
178
+
179
+ ## Notes
180
+ (gotchas, type hints, Go reference paths)
181
+ ```
182
+
183
+ **KEY**: Each lane file MUST contain explicit code skeletons — function signatures with doc comments.
184
+ This gives the lane agent everything it needs without guessing.
185
+
186
+ ## Completion Criteria
187
+
188
+ - [ ] EPIC created with full body
189
+ - [ ] 10-15 sub-issues created, cross-linked
190
+ - [ ] File ownership matrix built (zero overlaps validated)
191
+ - [ ] 2-3 parallel lanes defined + 1 convergence lane
192
+ - [ ] Master .ralph/ file written
193
+ - [ ] Per-lane .ralph/ files written with code skeletons
194
+ - [ ] Ready to proceed to orchid-launch
195
+
196
+ ## Handoff
197
+
198
+ Pass to `orchid-launch` with:
199
+ - Lane definitions and file ownership
200
+ - .ralph/ file paths
201
+ - Expected parallelism (which lanes concurrent, which sequential)
@@ -0,0 +1,162 @@
1
+ ---
2
+ name: orchid-doctor
3
+ description: "Pre-flight health check for orchid pipeline. Verifies all agents, skills, tools, and connectivity are available before starting any orchestration phase. Triggers on 'run doctor', 'check deps', 'verify pipeline', 'health check'. Run this FIRST before any orchid phase."
4
+ ---
5
+
6
+ # orchid-doctor — Dependency Health Check
7
+
8
+ **Parent**: `orchid`
9
+ **Phases**: Pre-flight (before Phase 1)
10
+ **Agents used**: None (orchestrator runs directly)
11
+
12
+ ## What This Does
13
+
14
+ Verifies all dependencies are available before starting the pipeline.
15
+ Fail fast, fail clear — don't discover missing deps mid-pipeline.
16
+
17
+ ## Checklist
18
+
19
+ Run each check and report status:
20
+
21
+ ### 1. Agent Availability
22
+
23
+ Check each required agent exists in the subagent registry:
24
+
25
+ ```
26
+ subagent({ action: "list" })
27
+ ```
28
+
29
+ Verify present:
30
+ - [ ] scout — codebase recon
31
+ - [ ] researcher — web research
32
+ - [ ] planner — implementation planning
33
+ - [ ] worker — implementation execution
34
+ - [ ] dev-1 — focused coding
35
+ - [ ] reviewer — code review
36
+ - [ ] tester — test verification
37
+ - [ ] brain — architecture reasoning
38
+ - [ ] delegate — lightweight passthrough
39
+
40
+ ### 2. Skill Availability
41
+
42
+ Check each required skill is loadable:
43
+
44
+ - [ ] `pi-ralph-wiggum` — Ralph loops (npm)
45
+ - [ ] `pi-subagents` — Subagent dispatch (npm)
46
+ - [ ] `create-taskplane-task` — Task authoring (npm)
47
+ - [ ] `multi-lane-orchestration` — Lane coordination (local)
48
+
49
+ ### 3. Project-Specific Skills
50
+
51
+ Detect project language and check:
52
+
53
+ - [ ] If Rust project: `ms-rust` and `rustic-prompt` available
54
+ - [ ] If TypeScript project: (future: ts-specific skills)
55
+ - [ ] If Python project: (future: py-specific skills)
56
+
57
+ Detection: look for `Cargo.toml`, `package.json`, `pyproject.toml`, etc.
58
+
59
+ ### 4. Tool Availability
60
+
61
+ ```bash
62
+ git --version # Required
63
+ gh auth status # Required for issue creation
64
+ cargo --version # Required for Rust projects
65
+ ```
66
+
67
+ ### 5. Telepathine Bus
68
+
69
+ ```
70
+ agent_memory_telepath_list({ project: "<project-name>" })
71
+ ```
72
+
73
+ - [ ] Bus is reachable
74
+ - [ ] At least 1 agent connected (or orchestrator alone if pre-launch)
75
+
76
+ ### 6. Git State
77
+
78
+ ```bash
79
+ git status --porcelain # Check for uncommitted changes
80
+ git branch --show-current # Verify correct branch
81
+ git remote -v # Verify remote
82
+ ```
83
+
84
+ - [ ] Repo is clean or changes are intentional
85
+ - [ ] On correct branch
86
+ - [ ] Remote configured
87
+
88
+ ### 7. Build State
89
+
90
+ ```bash
91
+ # Rust
92
+ cargo check --workspace 2>&1 | tail -5
93
+
94
+ # TypeScript (future)
95
+ # npm run build 2>&1 | tail -5
96
+ ```
97
+
98
+ - [ ] Build passes (or document known failures)
99
+
100
+ ## Output Format
101
+
102
+ ```
103
+ 🔍 orchid Doctor — Dependency Health Check
104
+
105
+ AGENTS:
106
+ ✅ scout — available (glm-5.1-claude)
107
+ ✅ researcher — available (glm-5.1-claude)
108
+ ✅ planner — available (deepseek-v4-pro)
109
+ ✅ worker — available (deepseek-v4-flash)
110
+ ✅ dev-1 — available (deepseek-v4-flash)
111
+ ✅ reviewer — available (glm-5.1-claude)
112
+ ✅ tester — available (deepseek-v4-flash)
113
+ ✅ brain — available (inherit)
114
+ ✅ delegate — available (inherit)
115
+
116
+ SKILLS:
117
+ ✅ pi-ralph-wiggum — npm
118
+ ✅ pi-subagents — npm
119
+ ✅ create-taskplane-task — npm
120
+ ✅ multi-lane-orchestration — local
121
+
122
+ PROJECT SKILLS (Rust detected):
123
+ ✅ ms-rust — local
124
+ ✅ rustic-prompt — local
125
+
126
+ TOOLS:
127
+ ✅ git 2.47.1
128
+ ✅ gh 2.67.0 (authenticated)
129
+ ✅ cargo 1.85.0
130
+
131
+ CONNECTIVITY:
132
+ ✅ Telepathine bus — 2 agents connected
133
+
134
+ PROJECT:
135
+ ✅ Git clean (main branch)
136
+ ✅ Build green
137
+
138
+ ⚠️ WARNINGS: None
139
+ ❌ MISSING: None
140
+
141
+ → Pipeline ready. All 9 phases available.
142
+ ```
143
+
144
+ Or on failure:
145
+
146
+ ```
147
+ ❌ MISSING:
148
+ - planner agent not found in subagent registry
149
+ - gh CLI not authenticated (run: gh auth login)
150
+
151
+ ⚠️ WARNINGS:
152
+ - Telepathine bus: 0 agents connected (lanes won't coordinate)
153
+ - 78 clippy warnings (non-blocking)
154
+
155
+ → Pipeline NOT ready. Fix 2 missing before proceeding.
156
+ ```
157
+
158
+ ## Decision
159
+
160
+ - **All ✅**: Proceed with orchid-investigate
161
+ - **⚠️ only**: Proceed with caution, document warnings
162
+ - **❌ any**: STOP. Fix missing deps before continuing.
@@ -0,0 +1,102 @@
1
+ ---
2
+ name: orchid-investigate
3
+ description: "Phases 1-2 of the orchid pipeline. Scout the codebase, map module structure, identify gaps, write comprehensive tracking document. Delegates to scout and researcher agents. Triggers on 'investigate codebase', 'scout the project', 'map modules', 'phase 1'."
4
+ ---
5
+
6
+ # orchid-investigate — Scout + Document
7
+
8
+ **Parent**: `orchid`
9
+ **Phases**: 1-2
10
+ **Agents used**: scout (primary), researcher (supplementary)
11
+ **Ralph loop**: No (one-shot investigation)
12
+
13
+ ## What This Does
14
+
15
+ Reads every source file, maps module structure, identifies gaps vs reference implementations, and produces a comprehensive tracking document.
16
+
17
+ ## Phase 1: Investigate
18
+
19
+ ### Delegation
20
+
21
+ ```
22
+ subagent({
23
+ agent: "scout",
24
+ task: "Read all source files in <target>. Map module structure, identify gaps vs <reference>. Report: file list, module purposes, test coverage, parity status per file, compiler warnings."
25
+ })
26
+ ```
27
+
28
+ ### What to Collect
29
+
30
+ - [ ] Full file listing (per crate/package)
31
+ - [ ] Module structure (file → purpose → dependencies)
32
+ - [ ] Public API surface (exports, traits, types)
33
+ - [ ] Test coverage status per module
34
+ - [ ] Build warnings and errors
35
+ - [ ] Gaps vs reference implementation (if applicable)
36
+ - [ ] Cross-references to existing issues
37
+
38
+ ### Tools
39
+
40
+ - `bash`: `find`, `grep`, `wc -l` for file discovery
41
+ - `read`: Deep-read each source file
42
+ - `gh issue list`: Check existing issues
43
+
44
+ ## Phase 2: Document
45
+
46
+ ### Output
47
+
48
+ Write a tracking document at `docs/<topic>/<PROJECT>-<TECH>.md`
49
+
50
+ ### Template
51
+
52
+ ```markdown
53
+ # <Project> — <Tech> Implementation Plan
54
+
55
+ **Date**: YYYY-MM-DD
56
+ **Status**: 🟡 Investigation complete
57
+ **EPIC**: (to be created in orchid-decompose)
58
+
59
+ ## Executive Summary
60
+ (3-5 sentences: what, why, current state)
61
+
62
+ ## Architecture Decisions
63
+
64
+ | # | Question | Decision | Rationale | Decided |
65
+ |---|----------|----------|-----------|---------|
66
+
67
+ ## Module Status
68
+
69
+ | Module | File | Status | Tests | Parity | Issues |
70
+ |--------|------|--------|-------|--------|--------|
71
+
72
+ ## Missing Modules
73
+
74
+ | Reference Module | Purpose | Priority | Proposed Location |
75
+ |-----------------|---------|----------|-------------------|
76
+
77
+ ## File Ownership Matrix (placeholder — filled in orchid-decompose)
78
+
79
+ | File | Owner | Lane | Action |
80
+ |------|-------|------|--------|
81
+
82
+ ## Acceptance Criteria
83
+
84
+ ## Build Commands
85
+
86
+ ## Related Documentation
87
+ ```
88
+
89
+ ## Completion Criteria
90
+
91
+ - [ ] Every source file has been read
92
+ - [ ] Module map is complete
93
+ - [ ] Gaps are identified and prioritized
94
+ - [ ] Tracking doc is written and committed
95
+ - [ ] Ready to proceed to orchid-decompose
96
+
97
+ ## Handoff
98
+
99
+ Pass to `orchid-decompose` with:
100
+ - Tracking doc path
101
+ - Gap list with priorities
102
+ - Suggested lane decomposition
@@ -0,0 +1,147 @@
1
+ ---
2
+ name: orchid-launch
3
+ description: "Phase 6 of the orchid pipeline. Launch lane agents via subagent() with Ralph loops. Parallel dispatch, model selection, Telepath coordination, progress monitoring. Triggers on 'launch lanes', 'start agents', 'fire lanes', 'dispatch workers'."
4
+ ---
5
+
6
+ # orchid-launch — Dispatch Lane Agents
7
+
8
+ **Parent**: `orchid`
9
+ **Phase**: 6
10
+ **Agents used**: worker, dev-1 (per lane)
11
+ **Ralph loop**: YES (per lane — each lane runs its own Ralph loop)
12
+ **Coordination**: Telepathine bus
13
+
14
+ ## ⛔ Delegation Method
15
+
16
+ **subagent(async) is the ONLY acceptable method for launching lane agents.**
17
+
18
+ ```
19
+ interactive_shell is PROHIBITED for coding tasks.
20
+ ```
21
+
22
+ See orchid master SKILL.md for the full delegation rules.
23
+
24
+ ## Model Selection
25
+
26
+ | Scenario | Action |
27
+ |----------|--------|
28
+ | User specified a model | Use exactly what they said |
29
+ | User said "optimize cost" | ASK which model for workers |
30
+ | No model specified | **Omit `model` param** → inherits orchestrator's model |
31
+ | Agent has model preference | Check `.agents/*.md` — respect it |
32
+
33
+ **NEVER hardcode a model.** The model decision belongs to the user or the agent definition.
34
+
35
+ ## Launch Pattern
36
+
37
+ ### Parallel Lanes (A + B simultaneously)
38
+
39
+ ```
40
+ // Lane A
41
+ subagent({
42
+ agent: "worker",
43
+ task: "Read .ralph/lane-a-<name> completely. Work through every item in the checklist sequentially. Update the file as you progress. When finished with all items, run the verification commands listed, commit to main, push, and report done on #general with commit SHA.",
44
+ async: true,
45
+ skill: "ms-rust,pi-subagents" // project-specific skills injected
46
+ })
47
+
48
+ // Lane B (parallel — fire immediately)
49
+ subagent({
50
+ agent: "worker",
51
+ task: "Read .ralph/lane-b-<name> completely. Work through every item in the checklist sequentially. Update the file as you progress. When finished with all items, run the verification commands listed, commit to main, push, and report done on #general with commit SHA.",
52
+ async: true,
53
+ skill: "ms-rust,pi-subagents"
54
+ })
55
+ ```
56
+
57
+ ### Why subagent(async) beats interactive_shell
58
+
59
+ | Dimension | interactive_shell | subagent(async) |
60
+ |-----------|-------------------|-----------------|
61
+ | Context cost | Polls TUI output (burns tokens) | Zero — fire and forget |
62
+ | Model control | Whatever pi launches with | Explicit per-task or inherit |
63
+ | Output capture | Must query/poll | `output` file, `subagent status` |
64
+ | Overhead | TUI render, terminal emulation | Pure text in/out |
65
+ | Parallelism | One per terminal tab | Unlimited async spawns |
66
+
67
+ ### Task Prompt Requirements
68
+
69
+ Each task prompt MUST include:
70
+ 1. "Read .ralph/<lane-file> completely" — subagents don't auto-load Ralph state
71
+ 2. "Work through the checklist sequentially" — ordered execution
72
+ 3. "Update the file as you progress" — progress tracking
73
+ 4. "Verify, commit, push" — quality gate
74
+ 5. "Report done on #general" — Telepath coordination
75
+
76
+ ### Sequential/Convergence Lane (after A+B done)
77
+
78
+ Only after parallel lanes confirm completion:
79
+
80
+ ```
81
+ subagent({
82
+ agent: "worker",
83
+ task: "Read .ralph/lane-c-<name> completely. Lanes A and B are done and merged. Work through the checklist, verify, commit, push.",
84
+ async: true,
85
+ skill: "ms-rust,pi-subagents"
86
+ })
87
+ ```
88
+
89
+ ## Monitoring
90
+
91
+ ### Subagent Status
92
+
93
+ ```
94
+ subagent({ action: "status", id: "<run-id-prefix>" })
95
+ ```
96
+
97
+ ### Telepathine Bus
98
+
99
+ ```
100
+ // Check who's online
101
+ agent_memory_telepath_list({ project: "<project>" })
102
+
103
+ // Read lane progress
104
+ agent_memory_telepath_inbox({ project: "<project>", channel: "general", limit: 20 })
105
+
106
+ // Send steering message if stuck
107
+ agent_memory_telepath_send({
108
+ channel: "general",
109
+ message: "Lane A: status check — how far along?",
110
+ project: "<project>"
111
+ })
112
+ ```
113
+
114
+ ### Before Launch — Telepath Announcement
115
+
116
+ ```
117
+ agent_memory_telepath_send({
118
+ channel: "general",
119
+ message: "🟢 Orchestrator online. Lanes launching: A (<files>), B (<files>). File matrix in .ralph/master-<project>.md",
120
+ project: "<project>"
121
+ })
122
+ ```
123
+
124
+ ## Gap-Closure Mini-Lanes
125
+
126
+ For trivial post-merge cleanup, write a short `.ralph/close-gaps.md` and fire:
127
+
128
+ ```
129
+ subagent({
130
+ agent: "worker",
131
+ task: "Read .ralph/close-gaps.md. Execute every item exactly as written. Verify with cargo check && cargo test && cargo clippy. Commit + push to main.",
132
+ async: true
133
+ })
134
+ ```
135
+
136
+ Note: Model is inherited — no override unless user specified one.
137
+
138
+ ## Completion Criteria
139
+
140
+ - [ ] Parallel lanes launched (async subagents)
141
+ - [ ] Telepath announcement sent
142
+ - [ ] Monitoring in place (bus + subagent status)
143
+ - [ ] Waiting for lane completion reports on #general
144
+
145
+ ## Handoff
146
+
147
+ When all parallel lanes report ✅ with commit SHAs → proceed to `orchid-converge`.
@@ -0,0 +1,73 @@
1
+ ---
2
+ name: pi-ralph-wiggum
3
+ description: Long-running iterative development loops with pacing control and verifiable progress. Use when tasks require multiple iterations, many discrete steps, or periodic reflection with clear checkpoints; avoid for simple one-shot tasks or quick fixes.
4
+ ---
5
+
6
+ # Ralph Wiggum - Long-Running Development Loops
7
+
8
+ Use the `ralph_start` tool to begin a loop:
9
+
10
+ ```
11
+ ralph_start({
12
+ name: "loop-name",
13
+ taskContent: "# Task\n\n## Goals\n- Goal 1\n\n## Checklist\n- [ ] Item 1\n- [ ] Item 2",
14
+ maxIterations: 50, // Default: 50
15
+ itemsPerIteration: 3, // Optional: suggest N items per turn
16
+ reflectEvery: 10 // Optional: reflect every N iterations
17
+ })
18
+ ```
19
+
20
+ ## Loop Behavior
21
+
22
+ 1. **Write the task file**: Create `.ralph/<name>.md` with the task content. The tool does NOT create this file—you must write it yourself using the Write tool.
23
+ 2. Work on the task and update the file each iteration.
24
+ 3. Record verification evidence (commands run, file paths, outputs) in the task file.
25
+ 4. Call `ralph_done` to proceed to the next iteration.
26
+ 5. Output `<promise>COMPLETE</promise>` when finished.
27
+ 6. Stop when complete or when max iterations is reached (default 50).
28
+
29
+ ## User Commands
30
+
31
+ - `/ralph start <name|path>` - Start a new loop.
32
+ - `/ralph resume <name>` - Resume loop.
33
+ - `/ralph stop` - Pause loop (when agent idle).
34
+ - `/ralph-stop` - Stop active loop (idle only).
35
+ - `/ralph status` - Show loops.
36
+ - `/ralph list --archived` - Show archived loops.
37
+ - `/ralph archive <name>` - Move loop to archive.
38
+ - `/ralph clean [--all]` - Clean completed loops.
39
+ - `/ralph cancel <name>` - Delete loop.
40
+ - `/ralph nuke [--yes]` - Delete all .ralph data.
41
+
42
+ Press ESC to interrupt streaming, send a normal message to resume, and run `/ralph-stop` when idle to end the loop.
43
+
44
+ ## Task File Format
45
+
46
+ ```markdown
47
+ # Task Title
48
+
49
+ Brief description.
50
+
51
+ ## Goals
52
+ - Goal 1
53
+ - Goal 2
54
+
55
+ ## Checklist
56
+ - [ ] Item 1
57
+ - [ ] Item 2
58
+ - [x] Completed item
59
+
60
+ ## Verification
61
+ - Evidence, commands run, or file paths
62
+
63
+ ## Notes
64
+ (Update with progress, decisions, blockers)
65
+ ```
66
+
67
+ ## Best Practices
68
+
69
+ 1. Write a clear checklist with discrete items.
70
+ 2. Update checklist and notes as you go.
71
+ 3. Capture verification evidence for completed items.
72
+ 4. Reflect when stuck to reassess approach.
73
+ 5. Output the completion marker only when truly done.