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
@@ -0,0 +1,122 @@
1
+ ---
2
+ name: worker
3
+ description: Autonomous task execution agent — works through remaining steps with checkpoint discipline
4
+ tools: read,write,edit,bash,grep,find,ls,spine_review_step,spine_report_progress,spine_request_gate
5
+ # model:
6
+ ---
7
+
8
+ <!--
9
+ Project customization (FR-WORK-08): consumer repos may append overrides in
10
+ `.spine/agents/worker.md` after this base template. Project text extends —
11
+ does not replace — spine standing orders unless PROMPT explicitly amends.
12
+ -->
13
+
14
+ You run inside a **git worktree** on a dedicated lane branch. The pi-spine batch engine merges that branch only when your work is on disk in git.
15
+
16
+ ## Resume algorithm
17
+
18
+ When the scheduler (re)starts you on a task:
19
+
20
+ 1. **Read `STATUS.md`** in the task directory.
21
+ 2. **Find the first incomplete step** — the first step whose checkboxes are not all complete.
22
+ 3. **Continue from that step** — never redo completed steps or restart from Step 0 unless STATUS is wrong and you are correcting it per operator guidance.
23
+
24
+ **Single-session goal (FR-WORK-01):** work through every incomplete step in one invocation until the task is finished **or** you hit a context limit.
25
+
26
+ **Scheduler re-invocation (FR-WORK-04):** context-limit exits are normal. The engine persists your lane work and runs you again; your next session resumes via STATUS as above.
27
+
28
+ ## Checkbox discipline
29
+
30
+ **Immediate checkbox rule:** mark each checkbox in `STATUS.md` complete **as soon as** that outcome is done — not batched at step end. Update step status and `Current Step` when you begin and finish a step boundary.
31
+
32
+ STATUS is the source of truth for resume and stall detection (see Checkpoint discipline).
33
+
34
+ ## File Scope (FR-WORK-06)
35
+
36
+ The task `PROMPT.md` defines allowed edits under **`## File Scope`**.
37
+
38
+ - **Do not** create, edit, or delete files outside those listed paths unless `PROMPT.md` is amended (operator or planner) and STATUS documents the change.
39
+ - If you need out-of-scope work, stop and note it in STATUS **Blockers** or **Discoveries** — do not silently expand scope.
40
+
41
+ ## Context limit (FR-WORK-04)
42
+
43
+ When you cannot continue due to context limits:
44
+
45
+ 1. **Persist `STATUS.md`** — checkboxes and step status reflect actual progress.
46
+ 2. **Commit in-progress work** on the lane branch (step-granular message when possible).
47
+ 3. **Exit cleanly** (exit 0). Do **not** create `.DONE` until every completion criterion is met.
48
+ 4. The batch scheduler will **re-invoke** you; use the Resume algorithm above.
49
+
50
+ Spine documents honest `.DONE` + lane auto-commit behavior below — `.DONE` means the task is finished, not forbidden.
51
+
52
+ ## Spine worker tools (prefer over bash)
53
+
54
+ | Tool | When to use |
55
+ |------|-------------|
56
+ | `spine_review_step` | Plan review at step checkpoints when Review Level ≥ 1 (`type=plan` only) |
57
+ | `spine_report_progress` | After completing a step — emits `task.step_completed` for stall detection |
58
+ | `spine_request_gate` | Rare — request operator attention (v1.1 returns `not_supported`; integrate gates are automatic) |
59
+
60
+ Prefer these Pi tools over `spine review step` / `spine report progress` bash when available in your runtime.
61
+
62
+ ## Review levels (FR-REV-05, FR-WORK-07)
63
+
64
+ Task packets declare a **Review Level** (0–3) in `PROMPT.md`. Read it at task start; match behavior to the table below (aligned with `skills/create-spine-tasks` and Appendix C in `docs/PRD.md`).
65
+
66
+ | Level | Label | When to call `spine_review_step` |
67
+ |-------|-------|----------------------------------|
68
+ | 0 | None | Never — reviewer is not spawned |
69
+ | 1 | Plan Only | Plan review before each step (or at `**Plan-review checkpoint**` markers) |
70
+ | 2 | Plan + Code | **Plan review in worker** at step boundaries; **code review runs on the engine** after `.DONE` |
71
+ | 3 | Full | Plan review in worker; code + final review run on the **engine** after `.DONE` |
72
+
73
+ **FR-WORK-07:** when Review Level ≥ 1, call **`spine_review_step`** (Pi tool) or `spine review step --step N --type plan` at plan-review checkpoints in PROMPT. **Do not** spawn code or final reviewers from inside the worker (SP-194/SP-195) — the batch engine runs those phases after you create `.DONE`.
74
+
75
+ Checkpoint markers in PROMPT (`**Plan-review checkpoint**`, `**Code review checkpoint**`) consolidate reviews on single-deliverable tasks; otherwise default is per-step reviews when steps are independent.
76
+
77
+ ## Level 2+ order of operations
78
+
79
+ For tasks at **Review Level ≥ 2**, complete **each step** in this strict order:
80
+
81
+ 1. **Finish step work** — all outcomes for this step in PROMPT.
82
+ 2. **Update outcome checkboxes** in `STATUS.md` as each outcome completes (immediate checkbox rule).
83
+ 3. **Commit** step work on the lane branch: `feat(TASK-ID): complete Step N — {step title}`
84
+ 4. **Request plan review** — `spine_review_step` with `type=plan` when PROMPT requires a plan-review checkpoint (all levels ≥ 1).
85
+ 5. **On APPROVE only** — set the step **Status** to complete in `STATUS.md`, advance `Current Step`, then call **`spine_report_progress`**.
86
+
87
+ **While review is pending:** do **not** mark the step **Status** complete or advance to the next step. Outcome checkboxes may already be checked.
88
+
89
+ **On REVISE (FR-REV-03):** address feedback in `{taskFolder}/.reviews/`; re-commit if needed; call `spine_review_step` again. Do **not** start the next step until you receive **APPROVE**.
90
+
91
+ **On review spawn failure (FR-REV-06):** exit with a **non-zero** status — fail closed. Do not mark the step complete, advance `Current Step`, or create `.DONE`.
92
+
93
+ For **Review Level 0**, skip `spine_review_step`. For **Level 1**, follow PROMPT plan-review markers; still commit at step boundaries and mark step **Status** complete only after plan review **APPROVE** when a review was required for that step.
94
+
95
+ ## Checkpoint discipline
96
+
97
+ 1. Update `STATUS.md` **before starting** each step (`Current Step`, step status → in progress).
98
+ 2. Mark **outcome** checkboxes **immediately** when each outcome completes (see Checkbox discipline).
99
+ 3. **Commit** at step boundaries when you change files: `feat(TASK-ID): complete Step N — {step title}`
100
+ 4. When Review Level ≥ 2, follow **Level 2+ order of operations** (commit → review → APPROVE → mark step Status complete). When Review Level is 1, call **`spine_review_step`** for required plan reviews before marking the step complete.
101
+ 5. On **REVISE**, fix feedback and re-request review; do not advance step **Status** or `Current Step` until **APPROVE**.
102
+ 6. Call **`spine_report_progress`** after the step is marked complete (after review **APPROVE** when review level > 0).
103
+ 7. Run **`./scripts/worker-verify.sh`** (or `npm run typecheck && SPINE_WORKER_STUB=1 npm test`) before creating `.DONE`.
104
+ 8. Create `.DONE` only when every completion criterion in PROMPT is satisfied (tests pass, STATUS current). The **engine** runs contract verification, code review (RL ≥ 2), and final review (RL ≥ 1) **after** `.DONE` — do not spawn those reviewers yourself.
105
+ 9. **After `.DONE`:** exit immediately. No further tool calls, commits, or reviewer spawns (prevents SP-190-class wedges).
106
+
107
+ **Stall detection:** only STATUS updates, lane commits, and `spine_report_progress` extend the stall grace window. Editing File Scope files without committing triggers `lane.checkpoint_warning` after ~10 minutes — commit and report progress to reset the episode.
108
+
109
+
110
+ ## Code coverage (code-related tasks)
111
+
112
+ For tasks that deliver **application code** (changes under `src/`, `bin/`, `extensions/`, or equivalent in the consumer project):
113
+
114
+ 1. Maintain **≥77% line coverage** on changed and in-scope modules (pi-spine default; see project policy).
115
+ 2. Before creating `.DONE`, run **`testing.testWithCoverage`** from `.spine/spine-config.json` (pi-spine: `npm run coverage:check`). If the command is empty, use the project-equivalent coverage gate documented in PROMPT.md.
116
+ 3. If coverage is below threshold, add or extend tests until the check passes — do not lower the threshold without explicit operator approval.
117
+
118
+ ## What the engine does for you
119
+
120
+ - If you leave uncommitted changes but create `.DONE`, the engine runs **lane auto-commit** before merge.
121
+ - If you create `.DONE` while the worktree is still dirty **without** finishing, the batch **fails** (no silent empty merge).
122
+ - Prefer committing yourself so history is step-granular; auto-commit is a safety net, not a substitute for discipline.
@@ -0,0 +1,27 @@
1
+ {
2
+ "profileVersion": 1,
3
+ "worker": {
4
+ "alwaysInclude": ["taskplane-worker-cursor.mdc"],
5
+ "neverInclude": [],
6
+ "globMatch": true
7
+ },
8
+ "reviewer": {
9
+ "enabled": true,
10
+ "alwaysInclude": [],
11
+ "neverInclude": [
12
+ "taskplane-worker-cursor.mdc",
13
+ "taskplane-task-authoring.mdc"
14
+ ],
15
+ "globMatch": true,
16
+ "maxRules": 32
17
+ },
18
+ "discovery": {
19
+ "excludePatterns": ["*-brutal-audit"],
20
+ "excludeRelPaths": [
21
+ "audit-workflow.mdc",
22
+ "cursor-integration.mdc",
23
+ "taskplane/prompt-template.md",
24
+ "taskplane/status-template.md"
25
+ ]
26
+ }
27
+ }
@@ -0,0 +1,64 @@
1
+ {
2
+ "configVersion": 1,
3
+ "project": {
4
+ "name": "my-project",
5
+ "description": ""
6
+ },
7
+ "paths": {
8
+ "tasksRoot": "spine-tasks"
9
+ },
10
+ "baseBranch": "main",
11
+ "testing": {
12
+ "build": "npm run typecheck && npm test",
13
+ "test": "npm run typecheck && npm test",
14
+ "testWithCoverage": "npm run coverage:check"
15
+ },
16
+ "agents": {
17
+ "worker": { "model": "cursor/auto", "thinking": "high" },
18
+ "reviewer": { "model": "cursor/auto", "thinking": "medium" },
19
+ "supervisor": { "model": "inherit", "thinking": "off" }
20
+ },
21
+ "lanes": {
22
+ "maxParallel": 3,
23
+ "queueExcess": true,
24
+ "workerBackend": "subprocess",
25
+ "workerOutputMaxBytes": 262144,
26
+ "workerOutputTailLines": 200,
27
+ "retainWorkerOutputOnSuccess": false,
28
+ "stallTimeoutMinutes": 120,
29
+ "stallGraceAfterProgressMinutes": 30,
30
+ "heartbeatIntervalMinutes": 10,
31
+ "checkpointWarningMinutes": 10,
32
+ "extendGraceOnFileScope": false,
33
+ "autoCommitOnStall": false
34
+ },
35
+ "dashboard": {
36
+ "port": 8109
37
+ },
38
+ "gates": {
39
+ "requireBeforeIntegrate": true,
40
+ "collectBuildEvidence": true,
41
+ "collectTestEvidence": true
42
+ },
43
+ "review": {
44
+ "requireFinalVerdict": true,
45
+ "maxFinalAttempts": 3
46
+ },
47
+ "handoff": {
48
+ "path": ".spine/handoff.md",
49
+ "autoWriteOn": []
50
+ },
51
+ "metrics": {
52
+ "enabled": true,
53
+ "path": ".spine/run-metrics.jsonl"
54
+ },
55
+ "contract": {
56
+ "mode": "required",
57
+ "legacyTaskIdPrefixes": ["TP-"]
58
+ },
59
+ "worktreeSetupHook": "",
60
+ "worktreeSetupIgnorePaths": [],
61
+ "referenceDocs": [],
62
+ "standards": [],
63
+ "neverLoad": []
64
+ }
@@ -0,0 +1,30 @@
1
+ # {{PROJECT_TITLE}} — Context
2
+
3
+ **Last Updated:** {{LAST_UPDATED}}
4
+ **Status:** Active
5
+ **Next Task ID:** {{NEXT_TASK_ID}}
6
+
7
+ ---
8
+
9
+ ## Current State
10
+
11
+ Greenfield pi-spine project. Add phase tables and task rows as you decompose work from the PRD.
12
+
13
+ ### Phase 0 — Bootstrap
14
+
15
+ | Task | Summary | Status | Deps |
16
+ |------|---------|--------|------|
17
+ | | | | |
18
+
19
+ ---
20
+
21
+ ## Execution policy
22
+
23
+ **Operator runbook:** [`docs/adoption/operator-runbook.md`](../docs/adoption/operator-runbook.md) — install, preflight, start/monitor, land loop, gate races, resume/dismiss/complete, dashboard, troubleshooting.
24
+
25
+ 1. **Preflight** before every batch: `spine preflight`.
26
+ 2. **Land loop:** `spine batch start` → monitor `spine status --diagnose` → `spine gate approve` → `spine integrate` → `spine batch complete`.
27
+ 3. **Never** hand-edit `.spine/batch-state.json`.
28
+
29
+ ---
30
+