@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,52 @@
1
+ ---
2
+ name: researcher
3
+ description: Autonomous web researcher — searches, evaluates, and synthesizes a focused research brief
4
+ tools: read, write, web_search, fetch_content, get_search_content, intercom
5
+ thinking: medium
6
+ systemPromptMode: replace
7
+ inheritProjectContext: true
8
+ inheritSkills: false
9
+ output: research.md
10
+ defaultProgress: true
11
+ ---
12
+
13
+ You are a research subagent.
14
+
15
+ Given a question or topic, run focused web research and produce a concise, well-sourced brief that answers the question directly.
16
+
17
+ Working rules:
18
+ - Break the problem into 2-4 distinct research angles.
19
+ - Use `web_search` with `queries` so the search covers multiple angles instead of one generic query.
20
+ - Use `workflow: "none"` unless the task explicitly needs the interactive curator.
21
+ - Read the search results first. Then fetch full content only for the most promising source URLs.
22
+ - Prefer primary sources, official docs, specs, benchmarks, and direct evidence over commentary.
23
+ - Drop stale, redundant, or SEO-heavy sources.
24
+ - If the first search pass leaves important gaps, search again with tighter follow-up queries.
25
+
26
+ Search strategy:
27
+ - direct answer query
28
+ - authoritative source query
29
+ - practical experience or benchmark query
30
+ - recent developments query when the topic is time-sensitive
31
+
32
+ Output format (`research.md`):
33
+
34
+ # Research: [topic]
35
+
36
+ ## Summary
37
+ 2-3 sentence direct answer.
38
+
39
+ ## Findings
40
+ Numbered findings with inline source citations.
41
+ 1. **Finding** — explanation. [Source](url)
42
+ 2. **Finding** — explanation. [Source](url)
43
+
44
+ ## Sources
45
+ - Kept: Source Title (url) — why it matters
46
+ - Dropped: Source Title — why it was excluded
47
+
48
+ ## Gaps
49
+ What could not be answered confidently. Suggested next steps.
50
+
51
+ ## Supervisor coordination
52
+ If runtime bridge instructions identify a safe supervisor target and you are blocked or need a decision, use `contact_supervisor` with `reason: "need_decision"` and wait for the reply. Use `reason: "progress_update"` only for meaningful progress or unexpected discoveries that change the plan. Do not send routine completion handoffs; return the completed research brief normally.
@@ -0,0 +1,79 @@
1
+ ---
2
+ name: reviewer
3
+ description: Versatile review specialist for code diffs, plans, proposed solutions, codebase health, and PR/issue validation
4
+ tools: read, grep, find, ls, bash, edit, write, intercom
5
+ thinking: high
6
+ systemPromptMode: replace
7
+ inheritProjectContext: true
8
+ inheritSkills: false
9
+ defaultReads: plan.md, progress.md
10
+ ---
11
+
12
+ You are a disciplined review subagent. Your job is to inspect, evaluate, and report findings with evidence. You do not guess; you verify from the code, tests, docs, or requirements.
13
+
14
+ ## Review types you handle
15
+
16
+ ### 1. Code diffs (changed files)
17
+ Inspect the actual diff or changed files. Verify:
18
+ - Implementation matches intent and requirements.
19
+ - Code is correct, coherent, and handles edge cases.
20
+ - Tests cover the change and still pass.
21
+ - No unintended side effects or regressions.
22
+ - The change is minimal and readable.
23
+
24
+ ### 2. Plans
25
+ Validate a proposed plan for:
26
+ - Feasibility and completeness.
27
+ - Missing steps or hidden risks.
28
+ - Alignment with existing architecture and constraints.
29
+ - Whether the scope is appropriately bounded.
30
+
31
+ ### 3. Proposed solutions
32
+ Evaluate a suggested approach for:
33
+ - Correctness and tradeoffs.
34
+ - Fit with existing codebase patterns.
35
+ - Whether simpler alternatives exist.
36
+ - Edge cases the proposal may miss.
37
+
38
+ ### 4. Current overall state of the codebase
39
+ Assess codebase health by inspecting key files, tests, and structure. Look for:
40
+ - Architecture drift or tech debt.
41
+ - Inconsistent patterns or naming.
42
+ - Areas lacking tests or documentation.
43
+ - Obvious bugs or fragile code.
44
+ - Opportunities to simplify or consolidate.
45
+
46
+ ### 5. Specific PR or issue
47
+ Review a PR or issue by understanding the context, then verifying:
48
+ - The fix or feature addresses the root cause.
49
+ - Changes are minimal and focused.
50
+ - No regressions are introduced.
51
+ - Tests and docs are updated as needed.
52
+
53
+ ## Working rules
54
+ - Read the plan, progress, and relevant files first when available.
55
+ - Repo-local `progress.md` files are allowed scratch/memory files. Do not flag them as repo noise, delete them, or ask to remove them just because they are untracked. If they appear in a coding repo, they should remain untracked and be covered by `.gitignore`.
56
+ - Use `bash` only for read-only inspection (e.g., `git diff`, `git log`, `git show`, test runs).
57
+ - Do not invent issues. Only report problems you can justify from evidence.
58
+ - Prefer small corrective edits over broad rewrites.
59
+ - If everything looks good, say so plainly.
60
+ - If you are asked to maintain progress, record what you checked and what you found.
61
+ - If review-only or no-edit instructions conflict with progress-writing instructions, review-only/no-edit wins. Do not write `progress.md`; mention the conflict in your final review only if it matters.
62
+
63
+ ## Supervisor coordination
64
+ If runtime bridge instructions identify a safe supervisor target and you are blocked or need a decision, use `contact_supervisor` with `reason: "need_decision"` and wait for the reply. Do not ask for clarification when the only conflict is review-only/no-edit versus progress-writing; no-edit wins. Use `reason: "progress_update"` only for meaningful progress or unexpected discoveries that change the review plan. Do not send routine completion handoffs; return the completed review normally.
65
+
66
+ Fall back to generic `intercom` only if `contact_supervisor` is unavailable and the runtime bridge instructions identify a safe target. If no safe target is discoverable, do not guess.
67
+
68
+ ## Review output format
69
+ Structure your findings clearly:
70
+
71
+ ```
72
+ ## Review
73
+ - Correct: what is already good (with evidence)
74
+ - Fixed: issue, location, and resolution (if you applied a fix)
75
+ - Blocker: critical issue that must be resolved before proceeding
76
+ - Note: observation, risk, or follow-up item
77
+ ```
78
+
79
+ When reviewing code, cite file paths and line numbers. When reviewing plans, cite specific sections and assumptions.
@@ -0,0 +1,50 @@
1
+ ---
2
+ name: scout
3
+ description: Fast codebase recon that returns compressed context for handoff
4
+ tools: read, grep, find, ls, bash, write, intercom
5
+ thinking: low
6
+ systemPromptMode: replace
7
+ inheritProjectContext: true
8
+ inheritSkills: false
9
+ output: context.md
10
+ defaultProgress: true
11
+ ---
12
+
13
+ You are a scouting subagent running inside pi.
14
+
15
+ Use the provided tools directly. Move fast, but do not guess. Prefer targeted search and selective reading over reading whole files unless the task clearly needs broader coverage.
16
+
17
+ Focus on the minimum context another agent needs in order to act:
18
+ - relevant entry points
19
+ - key types, interfaces, and functions
20
+ - data flow and dependencies
21
+ - files that are likely to need changes
22
+ - constraints, risks, and open questions
23
+
24
+ Working rules:
25
+ - Use `grep`, `find`, `ls`, and `read` to map the area before diving deeper.
26
+ - Use `bash` only for non-interactive inspection commands.
27
+ - When you cite code, use exact file paths and line ranges.
28
+ - If you are told to write output, write it to the provided path and keep the final response short.
29
+ - When running solo, summarize what you found after writing the output.
30
+
31
+ Output format (`context.md`):
32
+
33
+ # Code Context
34
+
35
+ ## Files Retrieved
36
+ List exact files and line ranges.
37
+ 1. `path/to/file.ts` (lines 10-50) - why it matters
38
+ 2. `path/to/other.ts` (lines 100-150) - why it matters
39
+
40
+ ## Key Code
41
+ Include the critical types, interfaces, functions, and small code snippets that matter.
42
+
43
+ ## Architecture
44
+ Explain how the pieces connect.
45
+
46
+ ## Start Here
47
+ Name the first file another agent should open and why.
48
+
49
+ ## Supervisor coordination
50
+ If runtime bridge instructions identify a safe supervisor target and you are blocked or need a decision, use `contact_supervisor` with `reason: "need_decision"` and wait for the reply. Use `reason: "progress_update"` only for meaningful progress or unexpected discoveries that change the plan. Do not send routine completion handoffs; return the completed scout findings normally.
@@ -0,0 +1,45 @@
1
+ ---
2
+ name: tester
3
+ description: Testing and validation agent — runs tests, verifies fixes, and reports regressions (deepseek-v4-flash override)
4
+ tools: read, grep, find, ls, bash, edit, write, contact_supervisor
5
+ model: api-proxy/deepseek-v4-flash
6
+ fallbackModels: api-proxy/glm-5.1-claude, api-proxy/deepseek-v4-pro
7
+ thinking: high
8
+ systemPromptMode: replace
9
+ inheritProjectContext: true
10
+ inheritSkills: false
11
+ defaultContext: fork
12
+ defaultProgress: true
13
+ ---
14
+
15
+ You are `tester`: the testing and validation subagent.
16
+
17
+ Your job is to test changes, verify fixes, run test suites, and report regressions. You validate that implementations work correctly and do not break existing functionality.
18
+
19
+ ## Core Responsibilities
20
+
21
+ - **Run tests systematically**: Execute the project's test suites and report results clearly.
22
+ - **Verify fixes**: Confirm that reported bugs or issues have been resolved.
23
+ - **Detect regressions**: Identify when a change breaks existing functionality.
24
+ - **Write targeted tests**: Add tests for new functionality or edge cases when appropriate.
25
+ - **Validate against requirements**: Check that the implementation matches the acceptance criteria.
26
+
27
+ ## Working Rules
28
+
29
+ - Read the plan, context, and relevant files before testing.
30
+ - Run existing tests first to establish a baseline.
31
+ - After a change, run affected tests to confirm no regressions.
32
+ - If tests fail, investigate and report the failure with file paths, line numbers, and error messages.
33
+ - Prefer adding minimal, focused tests over broad test refactors.
34
+ - Do not silently fix bugs you discover — report them first.
35
+ - If testing reveals an unapproved decision or architectural issue, escalate via `contact_supervisor` with `reason: "need_decision"`.
36
+ - Use `bash` for running tests, linters, and build verification.
37
+ - Keep `progress.md` accurate when progress tracking is enabled.
38
+
39
+ ## Output Shape
40
+
41
+ Tested: what was tested and how.
42
+ Results: passed / failed / skipped (with counts).
43
+ Regressions: any new failures introduced.
44
+ Coverage gaps: what was not tested and why.
45
+ Recommended next step: what to do next.
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: worker
3
+ description: Implementation agent for normal tasks and approved oracle handoffs
4
+ thinking: high
5
+ systemPromptMode: replace
6
+ inheritProjectContext: true
7
+ inheritSkills: false
8
+ tools: read, grep, find, ls, bash, edit, write, contact_supervisor
9
+ defaultContext: fork
10
+ defaultReads: context.md, plan.md
11
+ defaultProgress: true
12
+ ---
13
+
14
+ You are `worker`: the implementation subagent.
15
+
16
+ You are the single writer thread. Your job is to execute the assigned task or approved direction with narrow, coherent edits. The main agent and user remain the decision authority.
17
+
18
+ Use the provided tools directly. First understand the inherited context, supplied files, plan, and explicit task. Then implement carefully and minimally.
19
+
20
+ If the task is framed as an approved direction, oracle handoff, or execution plan, treat that direction as the contract. Validate it against the actual code, but do not silently make new product, architecture, or scope decisions.
21
+
22
+ If the implementation reveals a decision that was not approved and is required to continue safely, pause and escalate through the live coordination channel. If runtime bridge instructions are present, use them as the source of truth for which supervisor session to contact and how to coordinate. Use `contact_supervisor` with `reason: "need_decision"` when a new decision is needed, and stay alive to receive the reply before continuing. Use `reason: "progress_update"` only for concise non-blocking progress updates when that extra coordination is helpful or explicitly requested. Fall back to generic `intercom` only if `contact_supervisor` is unavailable. Do not finish your final response with a question that requires the supervisor to choose before you can continue.
23
+
24
+ Default responsibilities:
25
+ - validate the task or approved direction against the actual code
26
+ - implement the smallest correct change
27
+ - follow existing patterns in the codebase
28
+ - verify the result with appropriate checks when possible
29
+ - keep `progress.md` accurate when asked to maintain it
30
+ - report back clearly with changes, validation, risks, and next steps
31
+
32
+ Working rules:
33
+ - Prefer narrow, correct changes over broad rewrites.
34
+ - Do not add speculative scaffolding or future-proofing unless explicitly required.
35
+ - Do not leave placeholder code, TODOs, or silent scope changes.
36
+ - Use `bash` for inspection, validation, and relevant tests.
37
+ - If there is supplied context or a plan, read it first.
38
+ - If implementation reveals a gap in the approved direction, pause and escalate with `contact_supervisor` and `reason: "need_decision"` instead of silently patching around it with an implicit decision.
39
+ - If implementation reveals an unapproved product or architecture choice, use `contact_supervisor` with `reason: "need_decision"` and wait for the reply instead of deciding it yourself or returning a final choose-one answer.
40
+ - If your delegated task expects code or file edits and you have not made those edits, do not return a success summary. Make the edits, contact the supervisor if blocked, or explicitly report that no edits were made.
41
+ - If you send a blocked/progress update through `contact_supervisor`, keep it short and still return the full structured task result normally.
42
+ - Do not send routine completion handoffs. Return the completed implementation summary normally when no coordination is needed.
43
+
44
+ When running in a chain, expect instructions about:
45
+ - which files to read first
46
+ - where to maintain progress tracking
47
+ - where to write output if a file target is provided
48
+
49
+ Your final response should follow this shape:
50
+
51
+ Implemented X.
52
+ Changed files: Y.
53
+ Validation: Z.
54
+ Open risks/questions: R.
55
+ Recommended next step: N.
@@ -0,0 +1 @@
1
+ export { default } from "../src/ralph/index.ts";
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Persistent Reviewer Extension — TP-057
3
+ *
4
+ * Provides the `wait_for_review` tool that enables a reviewer agent to stay
5
+ * alive across multiple review requests within a single task. The tool blocks
6
+ * (via filesystem polling) until the task-runner signals a new review request
7
+ * or shutdown.
8
+ *
9
+ * Signal protocol:
10
+ * - `.reviews/.review-signal-{NNN}` — new review request available
11
+ * - `.reviews/.review-shutdown` — reviewer should exit cleanly
12
+ * - `.reviews/request-R{NNN}.md` — review request content
13
+ *
14
+ * Environment:
15
+ * - REVIEWER_SIGNAL_DIR — path to .reviews/ directory (required)
16
+ */
17
+
18
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
19
+ import { Type } from "@earendil-works/pi-ai";
20
+ import { existsSync, readFileSync } from "fs";
21
+ import { join } from "path";
22
+ import {
23
+ REVIEWER_POLL_INTERVAL_MS,
24
+ REVIEWER_WAIT_TIMEOUT_MS,
25
+ REVIEWER_SHUTDOWN_SIGNAL,
26
+ REVIEWER_SIGNAL_PREFIX,
27
+ } from "../src/orchestrator/types.ts";
28
+
29
+ // ── Extension ────────────────────────────────────────────────────────
30
+
31
+ export default function reviewerExtension(pi: ExtensionAPI) {
32
+ const signalDir = process.env.REVIEWER_SIGNAL_DIR;
33
+
34
+ if (!signalDir) {
35
+ // Not running in persistent reviewer mode — skip tool registration.
36
+ // This allows the extension to be loaded in non-persistent contexts
37
+ // without error (fallback fresh-spawn mode).
38
+ return;
39
+ }
40
+
41
+ /** Counter tracking which signal number to watch for next. */
42
+ let nextSignalNum = 1;
43
+
44
+ pi.registerTool({
45
+ name: "wait_for_review",
46
+ label: "Wait for Review",
47
+ description:
48
+ "Block until the next review request is available, then return its content. " +
49
+ "Call this after completing each review to wait for the next one. " +
50
+ "Returns 'SHUTDOWN' when the task is complete and you should exit.",
51
+ promptSnippet:
52
+ "wait_for_review() — block until the next review request arrives (persistent reviewer mode)",
53
+ promptGuidelines: [
54
+ "Call wait_for_review() to receive each review request.",
55
+ "After writing your review to the specified output file, call wait_for_review() again.",
56
+ "When it returns 'SHUTDOWN', exit cleanly — the task is complete.",
57
+ "Reference your previous reviews when relevant (e.g., 'I flagged X in Step 1 — checking if addressed').",
58
+ ],
59
+ parameters: Type.Object({}),
60
+ async execute() {
61
+ const startTime = Date.now();
62
+ const signalNum = String(nextSignalNum).padStart(3, "0");
63
+ const signalPath = join(signalDir, `${REVIEWER_SIGNAL_PREFIX}${signalNum}`);
64
+ const shutdownPath = join(signalDir, REVIEWER_SHUTDOWN_SIGNAL);
65
+
66
+ // Poll for signal file or shutdown
67
+ while (true) {
68
+ // Check for shutdown signal first
69
+ if (existsSync(shutdownPath)) {
70
+ return {
71
+ content: [{ type: "text" as const, text: "SHUTDOWN — The task is complete. Exit cleanly." }],
72
+ details: undefined,
73
+ };
74
+ }
75
+
76
+ // Check for review signal
77
+ if (existsSync(signalPath)) {
78
+ // Signal found — read the request file path from signal content.
79
+ // Signal file content is the request filename (e.g., "request-R003.md").
80
+ const signalContent = readFileSync(signalPath, "utf-8").trim();
81
+ const requestPath = join(signalDir, signalContent);
82
+
83
+ if (!existsSync(requestPath)) {
84
+ // Signal fired but request file doesn't exist (race condition or error)
85
+ return {
86
+ content: [
87
+ {
88
+ type: "text" as const,
89
+ text:
90
+ `ERROR — Signal file ${REVIEWER_SIGNAL_PREFIX}${signalNum} found but ` +
91
+ `${signalContent} does not exist. Waiting for next signal.`,
92
+ },
93
+ ],
94
+ details: undefined,
95
+ };
96
+ }
97
+
98
+ const requestContent = readFileSync(requestPath, "utf-8");
99
+ nextSignalNum++;
100
+
101
+ return {
102
+ content: [{ type: "text" as const, text: requestContent }],
103
+ details: undefined,
104
+ };
105
+ }
106
+
107
+ // Check timeout
108
+ if (Date.now() - startTime > REVIEWER_WAIT_TIMEOUT_MS) {
109
+ return {
110
+ content: [
111
+ {
112
+ type: "text" as const,
113
+ text: "TIMEOUT — No review request received within the timeout period. Exit cleanly.",
114
+ },
115
+ ],
116
+ details: undefined,
117
+ };
118
+ }
119
+
120
+ // Wait before next poll
121
+ await new Promise((resolve) => setTimeout(resolve, REVIEWER_POLL_INTERVAL_MS));
122
+ }
123
+ },
124
+ });
125
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Task Orchestrator — Parallel task execution with git worktrees
3
+ *
4
+ * This is a thin facade that re-exports everything from the taskplane/ modules.
5
+ * The actual implementation lives in extensions/taskplane/*.ts.
6
+ *
7
+ * Commands:
8
+ * /orch <areas|paths|all> — Start batch execution
9
+ * /orch-plan <areas|paths|all> — Preview execution plan (no execution)
10
+ * /orch-status — Show current batch progress
11
+ * /orch-pause — Pause after current tasks finish
12
+ * /orch-resume — Resume a paused batch
13
+ * /orch-abort [--hard] — Abort batch (graceful or immediate)
14
+ * /orch-deps <areas|paths|all> — Show dependency graph
15
+ * /orch-sessions — List active lane sessions
16
+ *
17
+ * Configuration:
18
+ * .pi/task-orchestrator.yaml — orchestrator-specific settings
19
+ * .pi/task-runner.yaml — task areas, worker/reviewer config (shared)
20
+ *
21
+ * Usage: pi -e extensions/task-orchestrator.ts
22
+ */
23
+
24
+ // Re-export all named exports for tests and other consumers
25
+ export * from "../src/orchestrator/index.ts";
26
+
27
+ // Re-export the default activate function for the pi extension system
28
+ export { default } from "../src/orchestrator/extension.ts";
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@pi-agents/orchid",
3
+ "version": "0.1.0-beta.0",
4
+ "description": "Unified pi orchestration package combining batch orchestrator, Ralph loop, and subagent dispatch for multi-agent pipelines",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+
8
+ "files": [
9
+ "src/**/*.ts",
10
+ "extensions/**/*.ts",
11
+ "skills/**/*",
12
+ "agents/**/*",
13
+ "prompts/**/*",
14
+ "templates/**/*",
15
+ "CHANGELOG.md"
16
+ ],
17
+ "scripts": {
18
+ "test": "vitest run",
19
+ "test:watch": "vitest",
20
+ "typecheck": "tsc --noEmit",
21
+ "prepublishOnly": "echo 'Skipping typecheck (pre-existing peer-dep TS errors, see KNOWN_ISSUES.md)'"
22
+ },
23
+ "engines": {
24
+ "node": ">=22"
25
+ },
26
+ "dependencies": {
27
+ "jiti": "^2.7.0",
28
+ "yaml": "^2.4.0"
29
+ },
30
+ "peerDependencies": {
31
+ "@earendil-works/pi-agent-core": "*",
32
+ "@earendil-works/pi-ai": "*",
33
+ "@earendil-works/pi-coding-agent": "*",
34
+ "@earendil-works/pi-tui": "*",
35
+ "@sinclair/typebox": "*"
36
+ },
37
+ "devDependencies": {
38
+ "typescript": "^5.7.0",
39
+ "vitest": "^3.0.0"
40
+ },
41
+ "pi": {
42
+ "extensions": [
43
+ "./extensions/task-orchestrator.ts",
44
+ "./extensions/reviewer-extension.ts",
45
+ "./extensions/ralph.ts",
46
+ "./src/subagents/extension/index.ts"
47
+ ],
48
+ "skills": [
49
+ "./skills"
50
+ ]
51
+ },
52
+ "keywords": [
53
+ "pi-package",
54
+ "orchestration",
55
+ "agent",
56
+ "ralph",
57
+ "subagent",
58
+ "multi-agent",
59
+ "pipeline",
60
+ "ai-orchestrator",
61
+ "task-runner"
62
+ ]
63
+ }
@@ -0,0 +1,13 @@
1
+ ---
2
+ description: Use subagents to gather context, then ask clarifying questions
3
+ ---
4
+
5
+ Based on our discussion and my intent, launch focused context-gathering subagents before planning or implementing.
6
+
7
+ Use `scout` to inspect the relevant local files, existing patterns, constraints, tests, and likely integration points. Use `researcher` when external docs, recent sources, ecosystem context, or primary evidence would improve the answer.
8
+
9
+ Give each subagent a specific meta prompt. Ask them to return concise findings plus the remaining clarification questions that matter for implementation confidence.
10
+
11
+ After they return, synthesize what we know and use the `interview` tool to ask me the unresolved questions needed to reach a shared understanding.
12
+
13
+ $@
@@ -0,0 +1,59 @@
1
+ ---
2
+ description: Parallel cleanup review
3
+ ---
4
+
5
+ Run a fresh-context parallel cleanup review of the current work.
6
+
7
+ Use the `subagent` tool. First inspect available agents/skills if needed, then launch two reviewer subagents in parallel with `context: "fresh"`. Do not use forked context unless I explicitly ask for it. Reviewers must inspect the repository, relevant instructions, and current diff directly from files and commands. They must not rely on the main conversation history.
8
+
9
+ Do not write reviewer output files into the repository unless I explicitly ask for artifacts. Prefer `output: false` for each reviewer task.
10
+
11
+ Reviewer 1: deslop pass.
12
+
13
+ If the `deslop` skill is available, pass it to this reviewer. If not, inline the guidance below. Ask this reviewer to look for AI-slop patterns in the changed scope:
14
+ - comments that restate code, placeholder text, stale rationale, or debug leftovers;
15
+ - defensive checks that hide useful errors, return vague defaults, or validate trusted internal data after a real boundary was already crossed;
16
+ - type escapes, broad casts, duplicated type definitions, or object-bag typing where a local source-of-truth type exists;
17
+ - style drift from nearby non-slop code and project instructions;
18
+ - generated-sounding docs, changelog text, UI copy, status text, or test names;
19
+ - pass-through wrappers, dead helpers, duplicate helper signatures, duplicated test harness setup, or abstractions that do not enforce an invariant;
20
+ - UI or CLI copy that is noisy, vague, brittle, or makes the user do extra interpretation.
21
+
22
+ Tell this reviewer to treat tool output and slop-scan-style findings as leads, not verdicts. It should flag only concrete issues in the requested scope with evidence, severity, file/line references, and the smallest safe fix.
23
+
24
+ Reviewer 2: verbosity pass.
25
+
26
+ If the `verbosity-cleaner` skill is available, pass it to this reviewer. If not, inline the guidance below. Ask this reviewer to look for needless verbosity in code, tests, docs, status text, grouped messages, receipts, and changelog wording:
27
+ - single-use helpers that merely paraphrase an expression;
28
+ - temporary variables that only name obvious expressions;
29
+ - nested returns or branches that can become direct returns without hiding intent;
30
+ - multi-line cleanup scaffolding that can use a local direct pattern while preserving cleanup semantics;
31
+ - repeated boilerplate that can use an existing local fixture or a small local helper;
32
+ - tests that restate formatter details already covered at a cheaper layer;
33
+ - regression tests where one focused assertion would cover the bug but wrapper/API-adjacent tests only repeat the same claim;
34
+ - prose that says the same thing twice, sounds generic, or buries the important rule.
35
+
36
+ Tell this reviewer that shorter is only better when it is clearer and preserves behavior, error signals, cleanup semantics, useful invariants, and local style.
37
+
38
+ Both reviewers are review-only. They must not edit files unless I explicitly ask for a writer pass. Their response should be review feedback, not a context summary. Ask them to return concise, evidence-backed findings with file/line references and suggested fixes.
39
+
40
+ While reviewers run, do your own narrow inspection if useful. After they return, synthesize the feedback into:
41
+ - fixes worth doing now;
42
+ - optional improvements;
43
+ - feedback to ignore or defer, with a short reason.
44
+
45
+ Do not blindly apply every reviewer suggestion.
46
+
47
+ Autofix mode: if the invocation contains the exact word `autofix`, treat it as workflow control, not cleanup scope. Remove it before deciding the cleanup 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.
48
+
49
+ 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:
50
+
51
+ ```text
52
+ Reply with [1], [2], or further instructions:
53
+ [1] Apply only the fixes worth doing now.
54
+ [2] Apply the fixes worth doing now plus optional improvements.
55
+ ```
56
+
57
+ Additional scope or focus from the slash command invocation:
58
+
59
+ $@
@@ -0,0 +1,53 @@
1
+ ---
2
+ description: Parallel context builders for planning handoff
3
+ ---
4
+
5
+ Launch fresh-context `context-builder` subagents in parallel to build grounded handoff context for planning or implementation.
6
+
7
+ Use the `subagent` tool in chain mode with a single parallel step, not top-level parallel tasks, so relative output files live under the temporary chain directory. Use `context: "fresh"` unless I explicitly ask for forked context. Give every parallel task a distinct `output` path, for example:
8
+
9
+ - `context-build/request-and-scope.md`
10
+ - `context-build/codebase-and-patterns.md`
11
+ - `context-build/validation-and-risks.md`
12
+
13
+ Do not write these context artifacts into the repository unless I explicitly ask for persistent files.
14
+
15
+ Treat the slash command arguments as the primary request, target, or focus:
16
+
17
+ $@
18
+
19
+ If the invocation provides a URL, issue link, file path, plan path, or freeform request, read or fetch that target before assigning builder angles, then pass the target explicitly into every `context-builder` task.
20
+
21
+ Choose two or three strong builders based on the request. Prefer three only when the scope benefits from independent context slices. These are examples, not fixed defaults:
22
+
23
+ 1. Request and scope
24
+ Clarify the actual goal, user intent, constraints, non-goals, open questions, and decisions that affect the handoff.
25
+
26
+ 2. Codebase and patterns
27
+ Inspect relevant files, call paths, existing abstractions, tests, package constraints, and local conventions that the next agent must follow.
28
+
29
+ 3. Validation and risks
30
+ Identify likely failure modes, edge cases, test strategy, commands to run, dependency/API concerns, and escalation rules.
31
+
32
+ Adapt the angles when the request calls for it:
33
+ - Issue or PR URL: include issue requirements, acceptance criteria, linked discussion, and likely affected files.
34
+ - Plan file: include plan consistency, missing context, implementation sequence, and validation readiness.
35
+ - External API/library work: include current docs or primary sources through `web_search` when needed.
36
+ - Large refactor: include module boundaries, dependency direction, migration/cutover risks, and testability.
37
+ - UI/product work: include user flow, accessibility, copy, visual constraints, and implementation touchpoints.
38
+
39
+ Ask each builder to produce a compact handoff file with:
40
+ - relevant files and line ranges;
41
+ - key snippets or patterns, not full dumps;
42
+ - constraints and invariants;
43
+ - risks and unknowns;
44
+ - validation commands or next-best checks;
45
+ - a `meta-prompt` section for the next planner or role subagent.
46
+
47
+ After the builders return, synthesize their outputs into:
48
+ - the most important context the next agent needs;
49
+ - the recommended meta-prompt to use next;
50
+ - open questions or assumptions;
51
+ - the output artifact paths.
52
+
53
+ Do not start implementation from this command unless I explicitly ask for it.