pi-spine 1.0.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 (156) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +563 -0
  3. package/bin/get-version.mjs +35 -0
  4. package/bin/spine-batch.mjs +425 -0
  5. package/bin/spine-cli/batch.mjs +47 -0
  6. package/bin/spine-cli/gate.mjs +10 -0
  7. package/bin/spine-cli/integrate.mjs +10 -0
  8. package/bin/spine-cli/plan.mjs +12 -0
  9. package/bin/spine-cli/shared.mjs +73 -0
  10. package/bin/spine-cli/status.mjs +18 -0
  11. package/bin/spine-cli/verify.mjs +199 -0
  12. package/bin/spine-config.mjs +212 -0
  13. package/bin/spine-dashboard.mjs +178 -0
  14. package/bin/spine-deps.mjs +69 -0
  15. package/bin/spine-doctor.mjs +468 -0
  16. package/bin/spine-gate.mjs +137 -0
  17. package/bin/spine-init.mjs +398 -0
  18. package/bin/spine-integrate.mjs +77 -0
  19. package/bin/spine-journal.mjs +198 -0
  20. package/bin/spine-migrate-from-taskplane.mjs +136 -0
  21. package/bin/spine-plan.mjs +83 -0
  22. package/bin/spine-preflight.mjs +700 -0
  23. package/bin/spine-report-progress.d.mts +28 -0
  24. package/bin/spine-report-progress.mjs +126 -0
  25. package/bin/spine-review-step.d.mts +24 -0
  26. package/bin/spine-review-step.mjs +124 -0
  27. package/bin/spine-rules.mjs +35 -0
  28. package/bin/spine-settings.mjs +186 -0
  29. package/bin/spine-state.mjs +110 -0
  30. package/bin/spine-status.mjs +79 -0
  31. package/bin/spine-tasks.mjs +293 -0
  32. package/bin/spine-worker-runner.mjs +314 -0
  33. package/bin/spine.mjs +404 -0
  34. package/extensions/spine/settings-slash.ts +20 -0
  35. package/extensions/spine/slash-commands.ts +806 -0
  36. package/extensions/spine/worker-tools.ts +279 -0
  37. package/extensions/spine-orchestrator.ts +12 -0
  38. package/package.json +72 -0
  39. package/skills/.gitkeep +0 -0
  40. package/skills/create-spine-tasks/SKILL.md +375 -0
  41. package/skills/create-spine-tasks/references/context-template.md +25 -0
  42. package/skills/create-spine-tasks/references/contract-template.md +98 -0
  43. package/skills/create-spine-tasks/references/explore-template.md +63 -0
  44. package/skills/create-spine-tasks/references/prompt-template.md +276 -0
  45. package/src/batch/abort.mjs +272 -0
  46. package/src/batch/agent-session-worker.mjs +297 -0
  47. package/src/batch/batch-state-io.mjs +53 -0
  48. package/src/batch/contract-verify.mjs +310 -0
  49. package/src/batch/detached-start.mjs +778 -0
  50. package/src/batch/diagnosis.mjs +378 -0
  51. package/src/batch/engine-lanes/merge.mjs +632 -0
  52. package/src/batch/engine-lanes/queue.mjs +208 -0
  53. package/src/batch/engine-lanes/review.mjs +970 -0
  54. package/src/batch/engine-lanes.mjs +388 -0
  55. package/src/batch/engine-scope.mjs +251 -0
  56. package/src/batch/engine.mjs +445 -0
  57. package/src/batch/evidence-command.mjs +157 -0
  58. package/src/batch/evidence.mjs +203 -0
  59. package/src/batch/gate.mjs +359 -0
  60. package/src/batch/git-commit-env.mjs +46 -0
  61. package/src/batch/git-exec.mjs +26 -0
  62. package/src/batch/heartbeat.mjs +430 -0
  63. package/src/batch/integrate.mjs +414 -0
  64. package/src/batch/journal-rebuild.mjs +388 -0
  65. package/src/batch/journal.mjs +373 -0
  66. package/src/batch/lane-commit.mjs +153 -0
  67. package/src/batch/lifecycle.mjs +364 -0
  68. package/src/batch/metrics.mjs +265 -0
  69. package/src/batch/orphan-detect.mjs +210 -0
  70. package/src/batch/post-merge-limbo.mjs +80 -0
  71. package/src/batch/postmortem.mjs +296 -0
  72. package/src/batch/readers/spine-state.mjs +95 -0
  73. package/src/batch/readers/taskplane-state.mjs +136 -0
  74. package/src/batch/reconcile.mjs +729 -0
  75. package/src/batch/resume-common.mjs +104 -0
  76. package/src/batch/resume-engine.mjs +66 -0
  77. package/src/batch/resume-multi-lanes.mjs +479 -0
  78. package/src/batch/resume-multi-validate.mjs +187 -0
  79. package/src/batch/resume-multi.mjs +254 -0
  80. package/src/batch/resume.mjs +475 -0
  81. package/src/batch/retry.mjs +257 -0
  82. package/src/batch/review-scope.mjs +136 -0
  83. package/src/batch/review.mjs +1045 -0
  84. package/src/batch/salvage.mjs +332 -0
  85. package/src/batch/state.mjs +680 -0
  86. package/src/batch/task-stall-budget.mjs +88 -0
  87. package/src/batch/worker-host.mjs +683 -0
  88. package/src/batch/worker-output.mjs +253 -0
  89. package/src/batch/worker-prompt.mjs +84 -0
  90. package/src/batch/worktree.mjs +290 -0
  91. package/src/cli/deps.mjs +141 -0
  92. package/src/cli/handoff.mjs +364 -0
  93. package/src/cli/rules.mjs +429 -0
  94. package/src/cli/settings-set.mjs +171 -0
  95. package/src/cli/settings-show.mjs +140 -0
  96. package/src/cli/settings-slash.mjs +107 -0
  97. package/src/config/contract.mjs +56 -0
  98. package/src/config/cursor-rules/discover.mjs +416 -0
  99. package/src/config/cursor-rules/index.mjs +39 -0
  100. package/src/config/cursor-rules/match-globs.mjs +132 -0
  101. package/src/config/cursor-rules/parse-frontmatter.mjs +222 -0
  102. package/src/config/cursor-rules/priority.mjs +26 -0
  103. package/src/config/cursor-rules/profile.mjs +403 -0
  104. package/src/config/cursor-rules/select.mjs +259 -0
  105. package/src/config/defaults.mjs +36 -0
  106. package/src/config/env-overrides.mjs +207 -0
  107. package/src/config/merge-defaults.mjs +47 -0
  108. package/src/config/pi-spine-root.mjs +93 -0
  109. package/src/config/reviewer-context.mjs +243 -0
  110. package/src/config/settings-fields.mjs +265 -0
  111. package/src/config/worker-backend.mjs +116 -0
  112. package/src/config/worker-context.mjs +402 -0
  113. package/src/config/worker-launch-script.mjs +130 -0
  114. package/src/config/worktree-setup-hook.mjs +122 -0
  115. package/src/dashboard/public/dashboard.css +77 -0
  116. package/src/dashboard/public/dashboard.js +349 -0
  117. package/src/dashboard/public/index.html +80 -0
  118. package/src/dashboard/server.mjs +155 -0
  119. package/src/dashboard/snapshot.mjs +414 -0
  120. package/src/dashboard/sse.mjs +15 -0
  121. package/src/dashboard/view.mjs +292 -0
  122. package/src/doctor/agent-model-inherit.mjs +101 -0
  123. package/src/doctor/batch-size-guidance.mjs +72 -0
  124. package/src/doctor/coexistence.mjs +312 -0
  125. package/src/doctor/rules-manifest.mjs +133 -0
  126. package/src/doctor/stale-path.mjs +156 -0
  127. package/src/doctor/stall-config.mjs +108 -0
  128. package/src/doctor/suggest-max-parallel.mjs +53 -0
  129. package/src/doctor/task-packet-size.mjs +110 -0
  130. package/src/doctor/worktree-health.mjs +71 -0
  131. package/src/migrate/taskplane-config.mjs +116 -0
  132. package/src/planner/cycles.mjs +63 -0
  133. package/src/planner/format-plan.mjs +132 -0
  134. package/src/planner/graph.mjs +99 -0
  135. package/src/planner/index.mjs +125 -0
  136. package/src/planner/lanes.mjs +111 -0
  137. package/src/planner/pending.mjs +39 -0
  138. package/src/planner/scope.mjs +142 -0
  139. package/src/process/liveness.mjs +21 -0
  140. package/src/tasks/packet/discover.mjs +40 -0
  141. package/src/tasks/packet/index.mjs +81 -0
  142. package/src/tasks/packet/merge-deps.mjs +79 -0
  143. package/src/tasks/packet/parse-prompt.mjs +445 -0
  144. package/src/tasks/packet/parse-status.mjs +118 -0
  145. package/src/tasks/packet/validate-contract.mjs +115 -0
  146. package/src/tasks/packet/validate-prompt.mjs +99 -0
  147. package/src/worker-tools/report-progress.d.mts +18 -0
  148. package/src/worker-tools/report-progress.mjs +59 -0
  149. package/src/worker-tools/request-gate.d.mts +17 -0
  150. package/src/worker-tools/request-gate.mjs +54 -0
  151. package/templates/agents/reviewer.md +123 -0
  152. package/templates/agents/supervisor.md +59 -0
  153. package/templates/agents/worker.md +122 -0
  154. package/templates/rules-profile.json +27 -0
  155. package/templates/spine-config.json +64 -0
  156. package/templates/tasks/CONTEXT.md +30 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Cesar Delgado
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,563 @@
1
+ # pi-spine
2
+
3
+ [![CI](https://github.com/beettlle/pi-spine/actions/workflows/ci.yml/badge.svg)](https://github.com/beettlle/pi-spine/actions/workflows/ci.yml)
4
+
5
+ **Orchestration spine for long-running pi development.**
6
+
7
+ pi-spine is a [pi](https://pi.dev) package that helps you run parallel, multi-day agent batches on real codebases. It combines the strongest ideas from [Taskplane](https://pi.dev/packages/taskplane), [Babysitter](https://github.com/a5c-ai/babysitter), and [pi-conductor](https://www.npmjs.com/package/@feniix/pi-conductor) without asking you to operate three separate orchestrators—or pick one and miss what the others do well.
8
+
9
+ ---
10
+
11
+ ## Why this exists
12
+
13
+ Long-running agent development fails for the same reasons repeatedly:
14
+
15
+ - **Context loss** when sessions compact or crash
16
+ - **Parallel collisions** when multiple agents edit one checkout
17
+ - **Opaque recovery** when a batch pauses and you cannot tell whether to resume, force-resume, or abort
18
+ - **Premature integration** when lane work merges without explicit approval or test evidence
19
+ - **Tool fragmentation** when each orchestrator owns state differently and none covers the full workflow
20
+
21
+ Taskplane, Babysitter, and pi-conductor each solve important slices of this problem. None of them, used alone, gives you **Taskplane-style task packets**, **Babysitter-grade audit history**, and **pi-conductor-style human gates** in one pi-native flow.
22
+
23
+ pi-spine exists to be that spine: a thin, composable layer you install once and run from your pi session.
24
+
25
+ ---
26
+
27
+ ## What pi-spine is (and is not)
28
+
29
+ | pi-spine is | pi-spine is not |
30
+ |-------------|-----------------|
31
+ | A pi extension + CLI (`spine`) for batch orchestration | A replacement for pi itself |
32
+ | Compatible with Taskplane `PROMPT.md` / `STATUS.md` packets | A fork of Taskplane |
33
+ | An append-only **orchestration journal** for control-plane events | A full Babysitter process-definition engine |
34
+ | **Human gates** before integrate/merge | A clone of pi-conductor's external control-plane DB |
35
+ | Worktree-isolated parallel lanes | Cross-harness routing (Cursor, Codex, etc.) in v1 |
36
+
37
+ Design philosophy: **compose, don't merge.** pi-spine adopts patterns; it does not reimplement three products as a fourth monolith.
38
+
39
+ ---
40
+
41
+ ## Advantages over using the others directly
42
+
43
+ ### vs Taskplane alone
44
+
45
+ Taskplane is the best pi-native batch orchestrator today: dependency waves, worktree lanes, cross-model review, dashboard, and orch-branch integration. pi-spine builds on that foundation rather than competing with it.
46
+
47
+ | You get with pi-spine | Gap when using Taskplane only |
48
+ |-----------------------|-------------------------------|
49
+ | **Orchestration journal** — append-only timeline of batch, lane, task, gate, and integrate events | Batch state and diagnostics exist, but post-mortem replay across lane death is harder to reconstruct |
50
+ | **Explicit integrate gates** — merge blocked until you approve an evidence bundle (tests, diff stat, task scorecard) | Integration is powerful; human approval is less formalized |
51
+ | **Journal-driven reconciliation** — resume hints grounded in event history | Resume works, but stale or partial lane recovery can be opaque in long batches |
52
+ | **Same task packets** — point `--tasks-root` at existing `taskplane-tasks/` | No migration rewrite required |
53
+
54
+ **When to stay on Taskplane only:** You are happy with its dashboard, supervisor, and merge flow and do not need formal gates or a dedicated audit journal.
55
+
56
+ ### vs Babysitter alone
57
+
58
+ Babysitter excels at **deterministic, event-sourced workflow orchestration** and cross-harness portability. Its pi plugin is experimental and thin; the heavy lifting lives in the SDK and harness adapters.
59
+
60
+ | You get with pi-spine | Gap when using Babysitter only |
61
+ |-----------------------|----------------------------------|
62
+ | **pi-native first-class UX** — slash commands, skills, worker sessions in pi | Pi integration is experimental; not the primary Babysitter surface |
63
+ | **File-based task packets** — `PROMPT.md` / `STATUS.md` as agent memory | Process definitions in JavaScript; different authoring model |
64
+ | **Git worktree lanes** tuned for coding batches | Not the core Babysitter story |
65
+ | **Lighter mental model** — journal at orchestration boundaries, not full process replay | Full replay engine is powerful but heavier for solo pi batch work |
66
+
67
+ **When to stay on Babysitter only:** You need one workflow engine across many harnesses (Codex, Cursor, Gemini) and want JS process definitions with full deterministic replay.
68
+
69
+ ### vs pi-conductor alone
70
+
71
+ pi-conductor is an actively developed **agent-native control plane**: durable workers, gates, artifacts, and PR-oriented flows via model-callable tools.
72
+
73
+ | You get with pi-spine | Gap when using pi-conductor only |
74
+ |-----------------------|----------------------------------|
75
+ | **Taskplane-compatible packets** — reuse existing `TP-*` / `SP-*` folders | Objectives and tool-native orchestration; different task contract |
76
+ | **Wave + lane batch model** — familiar `/spine-plan all` → parallel worktrees | Scheduler and conductor tools; different UX paradigm |
77
+ | **Opinionated worker/reviewer pipeline** — step checkpoints, `.DONE`, inline review | More flexible control plane; you assemble more yourself |
78
+ | **In-repo task folders** as the handoff artifact for humans and agents | State largely outside the repo |
79
+
80
+ **When to stay on pi-conductor only:** You want tool-driven orchestration (`conductor_run_work`, gate dashboard, PR readiness) and prefer objectives over folder-based packets.
81
+
82
+ ### The combined picture
83
+
84
+ ```text
85
+ Audit / replay clarity
86
+ ▲
87
+ │
88
+ Babysitter │ pi-spine
89
+ │
90
+ ──────────────────┼──────────────────► Batch orchestration
91
+ │
92
+ pi-conductor │ Taskplane
93
+ │
94
+ Gates │ Packets + dashboard
95
+ ```
96
+
97
+ pi-spine targets the upper-right: **batch orchestration with strong audit trail and human gates**, using task packets you may already have.
98
+
99
+ ---
100
+
101
+ ## Feature summary
102
+
103
+ - **Taskplane-compatible tasks** — `PROMPT.md`, `STATUS.md`, `dependencies.json`
104
+ - **Dependency waves** — topological scheduling with parallel lanes
105
+ - **Git worktree isolation** — one lane per worktree; orch branch for integration
106
+ - **STATUS-first workers** — checkpoint discipline and step-boundary commits
107
+ - **Cross-model review** — reviewer model configurable separately from worker
108
+ - **Orchestration journal** — JSONL event log for debugging and resume context
109
+ - **Human gates** — approve or reject integrate with test/build evidence
110
+ - **Local dashboard** — batch, lane, and gate visibility (SSE)
111
+ - **`create-spine-tasks` skill** — decompose PRDs into `spine-tasks/` packets (local install; no npm publish)
112
+
113
+ See `docs/PRD.md` for the full specification.
114
+
115
+ ---
116
+
117
+ ## Honest limits (v2.2)
118
+
119
+ pi-spine v2.2 ships operator-driven batch monitoring, not Taskplane-style autonomous supervision.
120
+
121
+ | Out of v2.2 | What to use instead |
122
+ |-------------|---------------------|
123
+ | **Supervisor mail** — conversational nudges between orchestrator and workers | `spine status --diagnose`, dashboard diagnosis banner, runbook recovery paths |
124
+ | **Autonomous monitor agent** — background Pi session polling batch health | Same CLI + dashboard surfaces; human operator runs suggested commands |
125
+
126
+ **Primary monitor surfaces:**
127
+
128
+ - **`spine status --diagnose`** — diagnosis, headline, `suggestedCommand`, lane health (use daily after detached start/resume)
129
+ - **Dashboard** — `spine dashboard` / `/spine-dashboard`; diagnosis banner and action chips match `--diagnose` reconciliation (default port 8109)
130
+ - **[Operator runbook](docs/adoption/operator-runbook.md)** — stall recovery, orphan handling, land loop, gate races
131
+
132
+ The `.spine/agents/supervisor.md` template (from `spine init`) documents this no-agent reality; the batch engine does not spawn it.
133
+
134
+ **Optional stretch (not blocking v2.2 publish):** a minimal supervisor session journaling `supervisor.nudge` events — deferred unless consumer pilot feedback shows dashboard + diagnose are insufficient ([FR-SHIP-11](docs/PRD-v2.2-ship-readiness-handoff.md#fr-ship-11-design-decision)).
135
+
136
+ ---
137
+
138
+ ## Prerequisites
139
+
140
+ | Dependency | Required |
141
+ |------------|----------|
142
+ | [Node.js](https://nodejs.org/) ≥ 22 | Yes |
143
+ | [pi](https://pi.dev) coding agent | Yes |
144
+ | Git (worktree support) | Yes |
145
+
146
+ ---
147
+
148
+ ## Adoption (pre-publish)
149
+
150
+ pi-spine is not on npm yet. To use it on a real project from a git checkout or local path (slash commands, `spine` CLI, file dependency), see **[docs/adoption/local-install.md](docs/adoption/local-install.md)**. After install, `spine doctor` warns when a stale global `spine` on PATH does not match your checkout.
151
+
152
+ | Doc | Purpose |
153
+ |-----|---------|
154
+ | [local-install.md](docs/adoption/local-install.md) | Git/path install before npm publish |
155
+ | [bootstrap-checklist.md](docs/adoption/bootstrap-checklist.md) | First-time consumer setup |
156
+ | [operator-runbook.md](docs/adoption/operator-runbook.md) | Daily operator procedures (preflight, land loop, recovery) |
157
+ | [real-project-readiness.md](docs/adoption/real-project-readiness.md) | Phase 9 adoption plan |
158
+
159
+ ### Task authoring (`create-spine-tasks` skill)
160
+
161
+ After `pi install /path/to/pi-spine -l`, the **`create-spine-tasks`** skill is available in pi. Use it to decompose a PRD or feature brief into `spine-tasks/<ID>-<slug>/` folders (`PROMPT.md`, `STATUS.md`, `dependencies.json` updates).
162
+
163
+ Example prompt in pi:
164
+
165
+ ```text
166
+ Use the create-spine-tasks skill to break docs/PRD.md into M-sized SP-* tasks
167
+ under spine-tasks/. Update CONTEXT.md and dependencies.json.
168
+ ```
169
+
170
+ Skill source: [`skills/create-spine-tasks/SKILL.md`](skills/create-spine-tasks/SKILL.md). See [bootstrap-checklist.md](docs/adoption/bootstrap-checklist.md) for the greenfield flow.
171
+
172
+ ### Cursor rules (contributors)
173
+
174
+ The repo ships [`.cursor/rules/`](.cursor/rules/) for Cursor IDE sessions. Rules are versioned in git (no secrets or machine-local paths).
175
+
176
+ **Primary subset for pi-spine** (Node.js CLI / `.mjs` codebase):
177
+
178
+ | Rule | Role |
179
+ |------|------|
180
+ | [`critical-rules-quick-reference.mdc`](.cursor/rules/critical-rules-quick-reference.mdc) | Always-on condensed anti-patterns |
181
+ | [`general-llm-anti-patterns.mdc`](.cursor/rules/general-llm-anti-patterns.mdc) | Universal LLM coding pitfalls |
182
+ | [`javascript-3-development-standards.mdc`](.cursor/rules/javascript-3-development-standards.mdc) | JS/TS/MJS standards (globs on `**/*.{js,mjs,cjs,ts,tsx}`) |
183
+ | [`owasp-secure-coding-practices.mdc`](.cursor/rules/owasp-secure-coding-practices.mdc) | Security baseline (evidence exec, CLI) |
184
+ | [`git-workflow-and-pr.mdc`](.cursor/rules/git-workflow-and-pr.mdc) | Commits, PRs, CI expectations |
185
+ | [`documentation-policy.mdc`](.cursor/rules/documentation-policy.mdc) | When to write docs vs task packets |
186
+ | [`taskplane-task-authoring.mdc`](.cursor/rules/taskplane-task-authoring.mdc) | Authoring `PROMPT.md` / `STATUS.md` |
187
+ | [`taskplane-worker-cursor.mdc`](.cursor/rules/taskplane-worker-cursor.mdc) | Executing task packets in Cursor |
188
+ | [`engineering-philosophy.mdc`](.cursor/rules/engineering-philosophy.mdc) | Design trade-offs |
189
+ | [`cursor-integration.mdc`](.cursor/rules/cursor-integration.mdc) | Rules vs skills in Cursor |
190
+
191
+ **Phase / milestone audits:** follow [`.cursor/rules/audit-workflow.mdc`](.cursor/rules/audit-workflow.mdc). For pi-spine, invoke the JavaScript audit ([`javascript-3-brutal-audit.mdc`](.cursor/rules/javascript-3-brutal-audit.mdc)) after major phases.
192
+
193
+ **Spine batch workers:** When `.cursor/rules/` exists, pi-spine auto-selects rules per task (PROMPT File Scope + committed manifest) and injects them into worker prompts (FR-WORK-05). Glob-triggered language packs (Swift, Python, Java, Go, Rust, AWS, iOS, Obsidian) load when File Scope matches their frontmatter globs. **`taskplane-worker-cursor.mdc`** is always included via the default rules profile. Explicit `config.standards` paths **append** after auto-selection. See [docs/design/cursor-rules-discovery.md](docs/design/cursor-rules-discovery.md).
194
+
195
+ **CLI:** `spine rules discover`, `spine rules sync`, `spine rules select --task <id>` — run `sync` after rule changes and commit `.spine/rules-manifest.json`.
196
+
197
+ ---
198
+
199
+ ## Quick start
200
+
201
+ ```bash
202
+ # Install the pi package (when published)
203
+ pi install npm:pi-spine
204
+
205
+ # In your project repo
206
+ cd my-project
207
+ spine init
208
+ spine doctor
209
+ spine plan all
210
+ spine preflight
211
+ ```
212
+
213
+ Run **`spine preflight`** before every batch (FR-BATCH-11). It verifies:
214
+
215
+ | Check | Requirement |
216
+ |-------|-------------|
217
+ | Doctor | `spine doctor` passes (Node, git, pi, config, agents, model provider) |
218
+ | Git clean | No uncommitted changes in the working tree |
219
+ | No active batch | No healthy active batch in `.spine/batch-state.json` (or Taskplane `.pi/batch-state.json`) |
220
+ | Tasks root | Configured tasks folder exists with discoverable `PROMPT.md` task folders |
221
+ | Dependencies | `{tasksRoot}/dependencies.json` parses and references valid task IDs |
222
+ | Wave plan | Dependency waves and lane assignment (same output as `spine plan all`) |
223
+
224
+ `spine doctor` also prints an advisory **lanes.maxParallel sizing** line when config is valid: configured value vs a conservative suggestion from CPU count (`floor(cpus/2)`, capped at 4). Lanes are parallel agents and git worktrees, not CPU threads — the hint never fails doctor; it may warn when `configured > suggested + 1` so you can lower `.spine/spine-config.json` → `lanes.maxParallel` if API cost or supervision feels high.
225
+
226
+ Use `spine preflight --json` for automation. Exit code is non-zero when any check fails.
227
+
228
+ ### Settings (FR-CFG-03)
229
+
230
+ Inspect and update registered `.spine/spine-config.json` fields:
231
+
232
+ ```bash
233
+ spine settings show # all editable fields
234
+ spine settings show lanes.maxParallel --json # single value
235
+ spine settings set lanes.maxParallel 2 # validate and persist
236
+ spine settings set dashboard.port 8110 --dry-run # preview without writing
237
+ ```
238
+
239
+ Only paths in the editable registry can be changed; invalid values exit non-zero with actionable errors. Writes use atomic tmp + rename.
240
+
241
+ ### Batch status and reconciliation
242
+
243
+ Reconciled batch diagnosis (FR-BATCH-12–14) derives operator-facing state from task records, git, `.DONE` files, and batch-state — not from raw `phase` alone:
244
+
245
+ ```bash
246
+ spine status # headline + suggested next command
247
+ spine status --diagnose # verbose signal breakdown
248
+ spine status --json # automation-friendly output
249
+ spine status --verbose # include segment frontier (NFR-OBS-05)
250
+ ```
251
+
252
+ Output includes `diagnosis`, `headline`, `suggestedCommand`, and optional `alternatives[]` per PRD §18.3. Diagnosis taxonomy (FR-BATCH-13): `running`, `paused`, `needs_retry`, `needs_merge`, `needs_integrate`, `completed`, `completed_manual`, `limbo_stale`, `failed`, `aborted`.
253
+
254
+ Reads `.spine/batch-state.json` first, then Taskplane `.pi/batch-state.json` during dogfood. When no batch exists, status reports a healthy idle state with `spine preflight` or `spine plan all` as the suggested next action.
255
+
256
+ ### Batch dismiss, complete, and next action
257
+
258
+ Archive-first lifecycle for terminal limbo (FR-BATCH-15–16, §18.6):
259
+
260
+ ```bash
261
+ spine batch dismiss --reason "manual recovery" # limbo_stale, completed_manual, aborted
262
+ spine batch complete --detect-manual-merge # after manual merge to main
263
+ spine batch complete --batch ID # orch on main + merge satisfied (FR-BATCH-16)
264
+ spine integrate [--dry-run] # merge orch branch → main (FR-INT-01)
265
+ spine next # print suggestedCommand from reconciliation
266
+ spine next --execute # run suggested command (dismiss, preflight, etc.)
267
+ ```
268
+
269
+ **Post-batch landing on `main`** (after `spine batch start` succeeds):
270
+
271
+ 1. `spine status --diagnose` — expect `needs_integrate` when orch has commits not on `main`
272
+ 2. `spine gate status` — review evidence under `.spine/runtime/{batchId}/evidence/`
273
+ 3. `spine gate approve` — required when `gates.requireBeforeIntegrate` is true
274
+ 4. `spine integrate` — local `--no-ff` merge of `orchBranch` → `baseBranch` (journal `integrate.started` / `integrate.completed`)
275
+ 5. `spine batch complete` — archive batch record (refuses if orch is ahead of `main` but not merged; refuses **empty orch** when `mergeResults` claim success)
276
+ 4. Push `main` to your remote when ready (pi-spine never auto-pushes)
277
+
278
+ `spine batch complete` validates orch integration using `countCommitsAhead` (same guard family as lane **EmptyMerge** at merge time). When `gates.requireBeforeIntegrate` is true, integrate is blocked until you approve the evidence bundle.
279
+
280
+ ```bash
281
+ spine gate status # pending integrate gate + evidence paths
282
+ spine gate approve # required before integrate (exit 2 if skipped)
283
+ spine gate reject --reason "…" # refuse merge; journals gate.rejected
284
+ spine integrate # merge after approval
285
+ spine integrate --force-integrate # bypass only with SPINE_ALLOW_FORCE=1 (journaled)
286
+ ```
287
+
288
+ Evidence is collected under `.spine/runtime/{batchId}/evidence/` (`summary.md` is an honest post-mortem per NFR-OBS-03, plus `diff-stat.txt` and optional test/build output from `spine-config.json` or `.pi/taskplane-config.json`). `spine batch dismiss` / `complete` also write `.spine/runtime/{batchId}/post-mortem.md` and record the path in `batch-history.json`.
289
+
290
+ In pi: `/spine-gate` and `/spine-integrate` delegate to `spine gate` and `spine integrate`.
291
+
292
+ **Limbo recovery playbook** (Taskplane batch red, all tasks green, empty `mergeResults`):
293
+
294
+ 1. `spine status --diagnose` — expect `limbo_stale` or `completed_manual`
295
+ 2. If work is already on `main`: `spine batch complete --detect-manual-merge`
296
+ 3. If batch should be cleared without claiming merge: `spine batch dismiss --reason …`
297
+ 4. Do not hand-edit `.pi/batch-state.json`; pi-spine archives to `.spine/runtime/{batchId}/archive/` first
298
+
299
+ In pi: `/spine-dismiss`, `/spine-next`, and `/spine` route to the same reconciliation (never suggest pause for terminal limbo).
300
+
301
+ ### Wave planning
302
+
303
+ Preview dependency waves and parallel lanes before starting a batch (FR-SCHED-01–06):
304
+
305
+ ```bash
306
+ spine plan all # all discovered tasks (full backlog)
307
+ spine plan pending # tasks without `.DONE` marker
308
+ spine plan TP-008 # explicit task ID(s)
309
+ spine plan 'taskplane-tasks/TP-008-*' # glob on task folder paths
310
+ spine plan pending --json # JSON plan; scope.mode pending + excluded count
311
+ ```
312
+
313
+ Each `spine plan` run writes a plan artifact to `.spine/runtime/plan-{timestamp}.json`.
314
+
315
+ **Waves, lanes, and ticks:** A **wave** is a dependency group — tasks in wave *N* start only after wave *N−1* merges. Within a wave, the planner assigns **virtual lanes** from file-scope overlap: disjoint scopes get separate lanes (parallel up to `lanes.maxParallel`); overlapping scopes share one lane (serialized on one worktree). A **tick** queues virtual lanes when there are more lanes than `maxParallel` (tick 0 runs lanes 0…`maxParallel−1`, tick 1 runs the rest, and so on). The batch engine runs **one worker at a time per physical lane/worktree** and parallelizes only across distinct lane numbers in the same tick. The dashboard **Lanes** table shows **Active tasks** (running/pending in the current wave on that lane) separately from **Batch assignment** (all tasks ever bound to the lane).
316
+
317
+ ### Running a batch (Phase 2–5)
318
+
319
+ pi-spine runs batches without Taskplane `/orch`. **Single-task** batches always work. **Multi-task** batches are allowed when the plan has one wave with multiple virtual lanes (disjoint file scopes), when scope is explicit (task IDs), or when scope is **`pending`** (unfinished tasks only). **`spine batch start all`** resolves to the same pending-filtered set as `pending` (unlike `spine plan all`, which previews the full backlog):
320
+
321
+ ```bash
322
+ spine preflight # required (FR-BATCH-11)
323
+ spine batch start TP-012 # one task (detached engine; returns immediately)
324
+ spine batch start TP-012 --attached # foreground engine (blocks until batch completes)
325
+ spine batch start TP-997 TP-998 # explicit multi-task (one wave, parallel lanes)
326
+ spine batch start pending # all tasks without `.DONE`, dependency order
327
+ spine batch start all # same as pending (not full backlog)
328
+ spine run pending # alias for batch start (PRD §15.2 automation)
329
+ spine run pending --dry-run --skip-preflight # flag passthrough
330
+ spine batch start TP-012 --dry-run # preflight + plan only
331
+ spine batch start TP-012 --json # machine-readable result
332
+ ```
333
+
334
+ If every discovered task has a `.DONE` marker, `pending` / `all` batch start fails fast: `No pending tasks (all discovered tasks have .DONE).` Tasks that already have `.DONE` on disk are skipped before the worker runs (journal event `task.skipped_done_on_disk`). Wave integrate / `batch complete` between waves is still manual — pi-spine does not auto-integrate mid-batch.
335
+
336
+ **What happens:** preflight → planner waves + lane ticks (`lanes.maxParallel`, FR-SCHED-03/04) → `.spine/batch-state.json` (schema v1, includes `segments[]`) → one git worktree per physical lane (`.worktrees/spine-{batchId}/lane-N`, branch `task/spine-lane-N-{batchId}`) → workers run in parallel across lanes per tick, serialized within a lane when multiple tasks share it → `.DONE` → **lane auto-commit** → after each wave, **sequential merges** into `orch/spine-{batchId}` (FR-BATCH-08) only when every wave task is `succeeded` or `skipped` (§17.4 mixed-outcome policy; GAP-MERGE-01).
337
+
338
+ **Detached by default:** `spine batch start` and `spine batch resume` spawn the batch engine in the background (like `/orch`) and return once `.spine/batch-state.json` shows the batch running again. Monitor with `spine status --diagnose`; engine logs append to `.spine/runtime/detached-engine.log`. Use `--attached` to run the engine in the foreground (previous behavior).
339
+
340
+ **Mixed outcomes:** if any task in a wave is `failed` or still `pending`, merge is blocked, phase becomes `failed`, and messaging names failed IDs with `/spine-retry-task` / `/spine-skip-task` hints (never “batch ran smoothly”). Operator override: `spine batch force-merge --wave 0` then `spine batch resume --force`.
341
+
342
+ Workers should still **commit at step boundaries** (see `.spine/agents/worker.md`); auto-commit is a safety net for pi sessions that finish with `.DONE` but forgot to commit.
343
+
344
+ ### Step review (FR-REV, TP-020)
345
+
346
+ When a task `PROMPT.md` has **Review Level > 0**, workers call the reviewer after step boundaries:
347
+
348
+ ```bash
349
+ spine review step --step 1 --type plan # level >= 1
350
+ spine review step --step 1 --type code # level >= 2 (optional --baseline <sha>)
351
+ ```
352
+
353
+ - Verdicts: structured JSON `{ "verdict": "APPROVE"|"REVISE", "feedback": "..." }` (also written in the review artifact)
354
+ - Artifacts: `{taskFolder}/.reviews/{step}-{timestamp}.md`
355
+ - Journal: `review.started`, `review.completed`, `review.failed`
356
+ - **Fail closed (FR-REV-06):** if review spawn fails at level > 0, the worker stops (non-zero exit) — no silent skip
357
+
358
+ Reviewer model is configured separately in `.spine/spine-config.json` (`agents.reviewer`).
359
+
360
+ ### Worker Pi tools (PRD §14.5)
361
+
362
+ Lane workers register three spine tools via `registerSpineWorkerTools`: `spine_review_step`, `spine_report_progress`, and `spine_request_gate`.
363
+
364
+ **`spine_request_gate` limitation (v2.2):** Permanent `not_supported` for all gate kinds (`integrate`, `manual`, `conflict`). Workers cannot open or refresh human gates; the tool returns structured JSON with `suggestedCommand: spine gate approve` so models do not invent host commands. **Operator workaround:** run `spine gate status` and `spine gate approve` from a **host shell** — not from inside a worker session. Integrate gates still open automatically when the batch engine completes a wave.
365
+
366
+ See [operator runbook §5.1](docs/adoption/operator-runbook.md#51-worker-spine_request_gate-fr-ship-13--v22) and [worker-gate-inventory.md](docs/design/worker-gate-inventory.md).
367
+
368
+ ### Pause and resume (Phase 3 — single and multi lane)
369
+
370
+ ```bash
371
+ spine batch pause # stop scheduling; journal batch.paused
372
+ spine batch resume # continue paused batch (detached; returns immediately)
373
+ spine batch resume --attached # foreground resume (blocks until batch completes)
374
+ spine batch resume --force # resume failed batch after stale lane state
375
+ spine batch pause --json
376
+ ```
377
+
378
+ Resume skips tasks already marked complete via `.DONE` or journal `task.completed`, respawns workers in existing lane worktrees for pending segments across all lanes, logs `batch.resumed` with `{ resumeForced, pendingSegments }`, then runs lane commit + merge per wave.
379
+
380
+ Multi-task batches (more than one task or lane) use the same commands; validation and execution resume pending tasks in parallel within each wave, then merge succeeded lane branches into the orch branch.
381
+
382
+ In pi: `/spine-pause` and `/spine-resume` delegate to `spine batch pause|resume`. When `spine status` reports `diagnosis: paused`, the suggested command is `spine batch resume` (not Taskplane pause).
383
+
384
+ ### Abort (Phase 3 — archive-first, §18.6)
385
+
386
+ Stop a batch without losing recoverable state (closes GAP-ABORT-01):
387
+
388
+ ```bash
389
+ spine batch abort # graceful: abort signal; worker may finish step boundary
390
+ spine batch abort --hard # SIGKILL lane workers; remove worktrees (configurable)
391
+ spine batch abort --reason "stall kill" # journal reason on batch.aborted
392
+ spine batch abort --hard --json
393
+ ```
394
+
395
+ **Archive-first:** pi-spine always writes `.spine/runtime/{batchId}/archive/batch-state.json` (including `segments[]`) **before** clearing `.spine/batch-state.json` or Taskplane `.pi/batch-state.json`. The journal append-only log is preserved; `batch.aborted` is appended with reason and prior tail metadata.
396
+
397
+ Graceful abort writes `.spine/runtime/{batchId}/abort-signal.json` (`hard: false`). The worker host polls this signal and sends SIGTERM so the worker can exit at the next poll boundary. Hard abort sets `hard: true`, kills `lane.workerPid` when recorded, and removes lane worktrees unless `lanes.cleanupWorktreesOnHardAbort` is `false` in `.spine/spine-config.json`.
398
+
399
+ In pi: `/spine-abort` and `/spine-abort --hard` delegate to `spine batch abort`. When a batch was aborted, `spine status` reports `diagnosis: aborted` — use `spine batch dismiss` to clear limbo if needed.
400
+
401
+ ### Retry and skip (Phase 3)
402
+
403
+ When a task fails or segment state drifts (Taskplane GAP-RETRY-01), reset task + segments atomically before resume:
404
+
405
+ ```bash
406
+ spine batch retry TP-012 # reset task + segments; journal pendingSegments
407
+ spine batch skip TP-012 # skip failed task; unblock wave merge (FR-BATCH-10)
408
+ spine batch force-merge --wave 0 # operator override for §17.4 (then resume --force)
409
+ spine batch retry TP-012 --json
410
+ ```
411
+
412
+ Retry clears task timestamps, resets all segment records for the task to `pending`, decrements `failedTasks`, and journals `task.retry_requested` with `{ taskId, previousClassification, pendingSegments }`. Resume refuses segment drift (`RetrySegmentDrift`) until retry or `--force`.
413
+
414
+ In pi: `/spine-retry-task <taskId>` and `/spine-skip-task <taskId>` delegate to `spine batch retry|skip`. When `spine status` reports `diagnosis: needs_retry`, the suggested command is `/spine-retry-task {id}`.
415
+
416
+ **Runtime layout:**
417
+
418
+ | Path | Purpose |
419
+ |------|---------|
420
+ | `.spine/batch-state.json` | Active batch (pi-spine native; not `.pi/batch-state.json`) |
421
+ | `.spine/batch-history.json` | Terminal batch summaries (complete/dismiss/aborted) |
422
+ | `.spine/runtime/{batchId}/archive/batch-state.json` | Archived batch snapshot after abort/dismiss/complete |
423
+ | `.spine/runtime/{batchId}/abort-signal.json` | In-flight abort request (graceful or hard) |
424
+ | `.spine/runtime/{batchId}/journal/events.jsonl` | Append-only journal |
425
+ | `.worktrees/spine-{batchId}/lane-N` | Lane worktree (N = 1 … `lanes.maxParallel`) |
426
+
427
+ **Recovery:** `spine status --diagnose` → `spine batch dismiss` or `spine batch complete` (same as Phase 1b lifecycle).
428
+
429
+ **Multi-task paused batch:** when more than one task is still pending, `spine status --diagnose` reports `diagnosis: paused` with a headline naming how many tasks remain (for example, “2 tasks pending — use spine batch resume (multi-task)”). Run `spine batch resume` (detached by default) to continue all lanes; use `--attached` to block until the batch finishes. This replaces the Phase 8 workaround of starting a fresh single-task batch after a multi-task pause (batch `20260602T181027`).
430
+
431
+ ### Journal replay and state validation (TP-014)
432
+
433
+ Audit orchestration timelines and validate batch-state cache integrity:
434
+
435
+ ```bash
436
+ spine journal replay --batch 20260601T120000 # human table: time | type | lane | task | summary
437
+ spine journal replay --batch 20260601T120000 --json
438
+ spine state validate # active .spine/batch-state.json
439
+ spine state validate --batch 20260601T120000 # archived runtime copy
440
+ spine state validate --diagnose # extra context on validation failure
441
+ ```
442
+
443
+ Journal events use **schema v1** (`schemaVersion`, `eventId`, ISO `timestamp`, optional `correlationId`, `payload`). Legacy JSONL lines without `schemaVersion` remain readable.
444
+
445
+ On **complete** or **dismiss**, pi-spine appends a summary entry to `.spine/batch-history.json` and writes terminal journal events (`batch.completed` / `batch.dismissed`).
446
+
447
+ **CI / tests without `pi`:** set `SPINE_WORKER_STUB=1` so the worker runner touches `.DONE` instead of spawning `pi` (see `bin/spine-worker-runner.mjs`). Use `SPINE_WORKER_STUB_FAIL_TASKS=TP-998` (comma-separated) to simulate task failure for mixed-outcome tests.
448
+
449
+ **Heartbeat and stall (TP-013):** during a batch, the engine polls lane progress (STATUS.md mtime, lane-branch commits) and appends `lane.heartbeat` to the journal on an interval (default 10 minutes). Stall kill uses §18.4 grace after progress. Configure in `.spine/spine-config.json`:
450
+
451
+ ```json
452
+ "lanes": {
453
+ "stallTimeoutMinutes": 60,
454
+ "stallGraceAfterProgressMinutes": 15,
455
+ "heartbeatIntervalMinutes": 10
456
+ }
457
+ ```
458
+
459
+ With `pi` on PATH, `spine batch start` runs `pi -p` against the task `PROMPT.md` (disable via `SPINE_WORKER_PI_AGENT=0`).
460
+
461
+ Do **not** run `spine batch start` and Taskplane `/orch` on the same repo concurrently.
462
+
463
+ In a pi session (`/spine` runs preflight before batch guidance; `/spine-plan` invokes the planner):
464
+
465
+ | Command | Status |
466
+ |---------|--------|
467
+ | `/spine` | Preflight + `spine batch start` for a **single** task ID (Phase 2) |
468
+ | `/spine-plan` | Preview waves and lanes (usage: `/spine-plan <all\|paths>`) |
469
+ | `/spine-status` | Reconciled batch diagnosis + lane health (FR-BATCH-14) |
470
+ | `/spine-dismiss` | `spine batch dismiss` (limbo / completed_manual) |
471
+ | `/spine-next` | `spine next` — suggested next command |
472
+ | `/spine-pause` | `spine batch pause` — stop scheduling |
473
+ | `/spine-resume` | `spine batch resume` — continue paused or failed batch |
474
+ | `/spine-abort` | `spine batch abort` — archive-first abort (`--hard` kills workers) |
475
+ | `/spine-gate` | Stub — gate inspection and resolution |
476
+ | `/spine-integrate` | Merge orch branch → `main` (`spine integrate`; gate stub in Phase 3) |
477
+ | `/spine-settings` | Editable config menu + inline `set` (delegates to `spine settings`) |
478
+ | `/spine-deps` | Show dependency graph (`spine deps`; usage: `/spine-deps <all\|paths>`) |
479
+ | `/spine-dashboard` | Start local SSE dashboard (`spine dashboard` in background) |
480
+
481
+ Most slash commands remain stubs; **`/spine`**, **`/spine-plan`**, **`/spine-status`**, **`/spine-dismiss`**, **`/spine-next`**, **`/spine-deps`**, **`/spine-settings`**, and **`/spine-dashboard`** are implemented. **`/spine <task-id>`** starts a Phase 2 single-task batch when preflight passes (stub worker unless `SPINE_WORKER_STUB=0` and `pi` is on PATH). Stubs reply with a notification pointing to `spine help` and a future phase. **`/spine`** runs `spine preflight` first and blocks batch guidance when preflight fails. Example flow:
482
+
483
+ ```text
484
+ spine preflight # required before batch (FR-BATCH-11)
485
+ /spine-plan all # preview waves and lanes
486
+ /spine all # run the batch
487
+ /spine-status # monitor progress
488
+ /spine-gate # review evidence before merge
489
+ /spine-integrate # merge orch branch (after gate approval)
490
+ ```
491
+
492
+ Optional: run the dashboard in another terminal or from pi with `/spine-dashboard`:
493
+
494
+ ```bash
495
+ spine dashboard # default http://127.0.0.1:8109
496
+ spine dashboard --port 8110 # override CLI port
497
+ ```
498
+
499
+ As soon as the server is listening, the CLI prints the browser URL, listen address, SSE note, suggested `spine status` / `spine batch start` commands, and API paths (keep the terminal open while the dashboard runs).
500
+
501
+ Set `dashboard.port` in `.spine/spine-config.json` (default **8109**, avoids Taskplane port 8099). Example from `spine init`:
502
+
503
+ ```json
504
+ "dashboard": {
505
+ "port": 8109
506
+ }
507
+ ```
508
+
509
+ The browser UI streams reconciled snapshots over SSE (`/api/events`, **2s** poll interval per NFR-OBS-02). Panels: batch summary, **diagnosis banner** (badge color from `diagnosis`, not raw `phase`), copyable CLI action chips (primary + `alternatives[]` — run commands in your terminal; no HTTP mutations), wave progress (with a lane ≠ wave reminder), lane table (**Active tasks** vs **Batch assignment**), integrate gate, and journal tail. Diagnosis fields match `spine status --json` and `buildDashboardSnapshot()` (NFR-OBS-04 / GAP-UX-03).
510
+
511
+ ---
512
+
513
+ ## Migrating from Taskplane
514
+
515
+ If you already use Taskplane task folders:
516
+
517
+ 1. Install pi-spine in the same or a new repo.
518
+ 2. `spine init` then `spine doctor`
519
+ 3. Migrate config from `.pi/taskplane-config.json` (see `spine migrate-from-taskplane`).
520
+ 4. Run `/spine-plan all` and compare to your last Taskplane plan.
521
+
522
+ Do **not** run Taskplane and pi-spine batches on the same repo at the same time.
523
+
524
+ ---
525
+
526
+ ## Project status
527
+
528
+ **Early development.** pi-spine is designed as a personal orchestration spine first, publishable as `npm:pi-spine` when stable. API and behavior may change before v1.0.
529
+
530
+ ## Continuous integration
531
+
532
+ Every push and pull request to `main` runs [GitHub Actions CI](.github/workflows/ci.yml): `npm ci`, `npm run typecheck`, `npm test` (when defined), **`npm run coverage:check`** (≥77% line coverage on `src/`, `bin/`, `extensions/`), and CLI smoke checks (`spine version`, `help`, `doctor`). `spine init` sets `testing.testWithCoverage` to the same command by default.
533
+
534
+ ---
535
+
536
+ ## Documentation
537
+
538
+ | Document | Purpose |
539
+ |----------|---------|
540
+ | [docs/PRD.md](docs/PRD.md) | Product requirements and implementation contract (v1.2) |
541
+ | [docs/PRD-v1.3-upstream-execution-bridge.md](docs/PRD-v1.3-upstream-execution-bridge.md) | v1.3 addendum: validate, explore, final verdict, handoff, metrics |
542
+ | [docs/adoption/upstream-execution-workflow.md](docs/adoption/upstream-execution-workflow.md) | Authoring → validation → batch (optional zero-pi upstream) |
543
+ | [docs/adoption/local-install.md](docs/adoption/local-install.md) | Git/path install before npm publish |
544
+ | [docs/adoption/operator-runbook.md](docs/adoption/operator-runbook.md) | Daily operator procedures |
545
+ | [docs/adoption/real-project-readiness.md](docs/adoption/real-project-readiness.md) | Phase 9 adoption plan |
546
+ | pi.dev package page | Install and package manifest (when published) |
547
+
548
+ ---
549
+
550
+ ## License
551
+
552
+ MIT (intended).
553
+
554
+ ---
555
+
556
+ ## Related projects
557
+
558
+ - [Taskplane](https://pi.dev/packages/taskplane) — parallel task orchestration for pi
559
+ - [Babysitter](https://github.com/a5c-ai/babysitter) — event-sourced workflow SDK
560
+ - [pi-conductor](https://www.npmjs.com/package/@feniix/pi-conductor) — durable agent control plane for pi
561
+ - [pi-subagents](https://www.npmjs.com/package/pi-subagents) — optional delegation layer (planned v1.1 backend)
562
+
563
+ pi-spine respects these tools: it composes their best patterns rather than replacing them outright.
@@ -0,0 +1,35 @@
1
+ import { spawnSync } from "node:child_process";
2
+
3
+ export function commandExists(cmd) {
4
+ let result;
5
+ try {
6
+ result = spawnSync("which", [cmd], {
7
+ encoding: "utf-8",
8
+ stdio: ["ignore", "pipe", "pipe"],
9
+ });
10
+ } catch {
11
+ return false;
12
+ }
13
+
14
+ return Boolean(result && !result.error && result.status === 0);
15
+ }
16
+
17
+ export function getVersion(cmd, flag = "--version") {
18
+ let result;
19
+ try {
20
+ result = spawnSync(cmd, [flag], {
21
+ encoding: "utf-8",
22
+ stdio: ["ignore", "pipe", "pipe"],
23
+ });
24
+ } catch {
25
+ return null;
26
+ }
27
+
28
+ if (!result || result.error || result.status !== 0) return null;
29
+
30
+ const stdout = (result.stdout ?? "").toString().trim();
31
+ const stderr = (result.stderr ?? "").toString().trim();
32
+ if (stdout) return stdout;
33
+ if (stderr) return stderr;
34
+ return null;
35
+ }