pi-spine 2.20.0 → 2.21.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.
package/README.md CHANGED
@@ -43,11 +43,13 @@ Primary monitor surfaces: **`spine status --diagnose`**, **`spine dashboard`** /
43
43
 
44
44
  ## Prerequisites
45
45
 
46
- | Dependency | Required |
47
- |------------|----------|
48
- | [Node.js](https://nodejs.org/) ≥ 22 | Yes |
49
- | [pi](https://pi.dev) coding agent | Yes |
50
- | Git (worktree support) | Yes |
46
+ | Dependency | Minimum | Required |
47
+ |------------|---------|----------|
48
+ | [Node.js](https://nodejs.org/) | ≥ 22.19.0 (`engines.node`) | Yes |
49
+ | [pi](https://pi.dev) coding agent | ≥ 0.80.0 (`pi.minPiVersion`) | Yes |
50
+ | Git (worktree support) | — | Yes |
51
+
52
+ These are the Wave A floors ([#285](https://github.com/beettlle/pi-spine/issues/285)). `spine doctor` **warns** when the installed pi is below `pi.minPiVersion` ("pi version supported"). The optional peer `@earendil-works/pi-coding-agent` is developed and tested against `^0.85.1` (pinned in `devDependencies`; the `peerDependencies` range stays `*`).
51
53
 
52
54
  ## Install
53
55
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-spine",
3
- "version": "2.20.0",
3
+ "version": "2.21.0",
4
4
  "description": "Orchestration spine for long-running pi development",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -22,11 +22,11 @@
22
22
  "skills": [
23
23
  "./skills"
24
24
  ],
25
- "minPiVersion": "0.60.0"
25
+ "minPiVersion": "0.80.0"
26
26
  },
27
27
  "type": "module",
28
28
  "engines": {
29
- "node": ">=22.0.0"
29
+ "node": ">=22.19.0"
30
30
  },
31
31
  "scripts": {
32
32
  "doctor": "node bin/spine.mjs doctor",
@@ -72,12 +72,12 @@
72
72
  }
73
73
  },
74
74
  "devDependencies": {
75
- "@earendil-works/pi-coding-agent": "^0.80.3",
75
+ "@earendil-works/pi-coding-agent": "^0.85.1",
76
76
  "@types/node": "^22.19.18",
77
- "eslint": "^9.28.0",
78
- "globals": "^16.2.0",
79
- "typebox": "1.1.38",
80
- "typescript": "5.6.3"
77
+ "eslint": "^10.10.0",
78
+ "globals": "^17.12.0",
79
+ "typebox": "1.3.30",
80
+ "typescript": "6.0.3"
81
81
  },
82
82
  "license": "MIT",
83
83
  "dependencies": {
@@ -18,6 +18,8 @@ spine wait --until completed,needs_integrate,failed,aborted --timeout 4h # opt
18
18
 
19
19
  Detached start/resume returns when the engine **starts**, not when work completes.
20
20
 
21
+ > **Wait progress vs quiet-stdout hosts:** human-mode `spine wait` prints a start banner and a `Wait progress:` line per poll, but agent hosts that buffer stdout until process exit (MonitorCreate, non-TTY shells) only see the terminal line. For machine-readable output use `--json` — one JSON snapshot at the terminal state.
22
+
21
23
  ---
22
24
 
23
25
  ## Cursor Agent shell
@@ -119,6 +119,8 @@ Increment `WAVE` and repeat until `spine plan pending` shows no remaining waves.
119
119
 
120
120
  > **Wait recipe note:** With SP-683, gate-pending land loops report the taxonomy diagnosis `needs_integrate`, so the default `--until` list above wakes on that diagnosis. The operator runbook documents optional land-loop pseudo-diagnoses (`gate_open`, `needs_approval`, `post_merge_limbo`) as belt-and-suspenders waits when you need finer-grained blocking inside the land loop itself.
121
121
 
122
+ > **Wait liveness (SP-754):** human-mode `spine wait` shows liveness output — a start banner, a `Wait progress:` line per poll (diagnosis, phase, wave, elapsed), and a terminal `Wait matched:` / `Wait timed out` headline. A quiet wait between progress lines is alive, not hung; use `--json` for machine parsing.
123
+
122
124
  **Optional script template:** `spine run sequence pending --attached --dry-run` — execute each printed block with judgment; do **not** chain `--auto-approve-gate` with real pi workers.
123
125
 
124
126
  Full reference: [references/outer-loop.md](references/outer-loop.md).
@@ -47,6 +47,7 @@ Invoke explicitly: `/skill:spine-release-operator` or "run a spine release cycle
47
47
  - **Never** run `npm version` or `git push --tags` when `npm run release:check` exits non-zero on current `main` ([#175](https://github.com/beettlle/pi-spine/issues/175))
48
48
  - **Never** run `npm version` or `git push --tags` when the **CI** workflow is not green on current `HEAD` — release-safe profile: typecheck + lint + tests + coverage (parity with `ci.yml`) ([#156](https://github.com/beettlle/pi-spine/issues/156))
49
49
  - **Always** parse target version / bump type **before** task selection (Phase 2)
50
+ - **Always** record dependency drift in Phase 1 (`npm outdated` + `npm audit`) and apply include/defer thresholds — never auto-add a full “update all deps” task; see [issue-intake-checklist.md](references/issue-intake-checklist.md) § Dependency drift check
50
51
  - **Always** prioritize documentation issues over enhancements
51
52
  - **Always** run `spine gate approve` before `spine integrate`
52
53
  - **Always** run `npm install` on `main` after successful integrate
@@ -154,9 +155,18 @@ spine tasks analyze pending
154
155
  rg 'Closes #|Closes:|Partial #|Partial:' spine-tasks/*/PROMPT.md
155
156
  ```
156
157
 
158
+ **Dependency drift check** (every profile, including patch) — full thresholds in [issue-intake-checklist.md](references/issue-intake-checklist.md):
159
+
160
+ ```bash
161
+ npm outdated
162
+ npm audit
163
+ ```
164
+
165
+ Classify each signal as **include** or **defer** (security highs even in patch; peer ≥1-minor drift and toolchain majors for minor/major only). Prefer an existing open dep issue (e.g. title contains “Bump dependencies” / “pi-coding-agent”) over inventing a duplicate gap. Record a one-row summary in the intake output and the manifest **Dependency drift** section.
166
+
157
167
  Read `spine-tasks/CONTEXT.md` for `Next Task ID`.
158
168
 
159
- **Output:** intake table (issue #, labels, mapped SP-* or gap, bucket, profile fit).
169
+ **Output:** intake table (issue #, labels, mapped SP-* or gap, bucket, profile fit) **plus** deps mini-table (package, current, latest, include|defer).
160
170
 
161
171
  ---
162
172
 
@@ -173,9 +183,11 @@ Use [references/release-manifest-template.md](references/release-manifest-templa
173
183
  ### Selection order (strict)
174
184
 
175
185
  1. **Documentation first** — all feasible doc items before feature work
176
- 2. **Bug fixes** — target 3–5 with user impact
177
- 3. **Enhancements** — per profile (0 for patch, 1–2 for minor)
178
- 4. **Defer** everything else with one-line rationale
186
+ 2. **Bug fixes** — target 3–5 with user impact; include **security-high dep fixes** from the Phase 1 drift check here (hygiene, not a fourth unlimited bucket)
187
+ 3. **Enhancements** — per profile (0 for patch, 1–2 for minor); peer ≥1-minor drift / toolchain majors from the drift check consume an enh/hygiene slot when thresholds fire
188
+ 4. **Defer** everything else with one-line rationale (including “deps OK — deferred” when no threshold fires)
189
+
190
+ Dep hygiene from the drift check **inserts into** the bug or enh slot per [issue-intake-checklist.md](references/issue-intake-checklist.md) thresholds — it is not a separate uncapped bucket. Prefer one focused peer/security packet over “bump everything” when the enh slot is already full.
179
191
 
180
192
  ### Apply profile budgets
181
193
 
@@ -193,6 +205,7 @@ Present manifest summary:
193
205
 
194
206
  - Target version and profile
195
207
  - Selected SP-* / issues by bucket
208
+ - Dependency drift action (included SP-*/#NNN or deferred rationale)
196
209
  - Deferred count
197
210
  - Profile audit status
198
211
 
@@ -307,6 +320,8 @@ spine wait --until completed,failed,needs_integrate,needs_retry,aborted --timeou
307
320
 
308
321
  Optional pi watchdog: `LoopCreate` every 2m, `readOnly: true`, `maxFires: 50` — see pi-async-orchestration.
309
322
 
323
+ > **Wait progress (SP-754):** human-mode `spine wait` is not silent until exit — it prints a start banner, a `Wait progress:` line per poll (diagnosis, phase, wave, elapsed), and a terminal `Wait matched:` (stdout) or `Wait timed out` (stderr) headline. Quiet output between progress lines means the wait is between polls, not hung. Use `--json` when a machine parses the result.
324
+
310
325
  > **Wait recipe note:** With SP-683, gate-pending land loops report the taxonomy diagnosis `needs_integrate`, so the default `--until` lists above wake on that diagnosis. The operator runbook documents optional land-loop pseudo-diagnoses (`gate_open`, `needs_approval`, `post_merge_limbo`) as belt-and-suspenders waits when you need finer-grained blocking inside the land loop itself.
311
326
 
312
327
  **Do not** start wave N+1 until wave N is integrated on `main`.
@@ -551,12 +566,13 @@ Include the published version/tag in the close comment when closing at Phase 6 (
551
566
  1. **Release manifest** — path, target version, profile, composition table
552
567
  2. **Tasks completed** — SP-IDs, waves, issues closed (list `#NNN` CLOSED with close time or comment URL)
553
568
  3. **Deferred backlog** — count and top items for next release (issues left OPEN + rationale)
554
- 4. **Authoring changes** — new SP-* created, splits/fixes in Phase 3
555
- 5. **Issues filed** — pi-spine GitHub links or "none"
556
- 6. **Recovery actions** — aborts, retries, contract fixes
557
- 7. **Verification** — paste `spine preflight` tail, **`npm run release:check` output** (or log path), test/coverage output
558
- 8. **Publish** — version bumped (Y/N), tag pushed (Y/N), workflow URL, or "awaiting operator approval"
559
- 9. **Issue tracker hygiene** — confirm every release-scoped `Closes #NNN` is CLOSED (paste `gh issue view` states or list)
569
+ 4. **Dependency drift** — Phase 1 check outcome: included SP-*/#NNN or deferred rationale (and audit high/critical count)
570
+ 5. **Authoring changes** — new SP-* created, splits/fixes in Phase 3
571
+ 6. **Issues filed** — pi-spine GitHub links or "none"
572
+ 7. **Recovery actions** — aborts, retries, contract fixes
573
+ 8. **Verification** — paste `spine preflight` tail, **`npm run release:check` output** (or log path), test/coverage output
574
+ 9. **Publish** — version bumped (Y/N), tag pushed (Y/N), workflow URL, or "awaiting operator approval"
575
+ 10. **Issue tracker hygiene** — confirm every release-scoped `Closes #NNN` is CLOSED (paste `gh issue view` states or list)
560
576
 
561
577
  ---
562
578
 
@@ -86,6 +86,43 @@ Exclude when:
86
86
  - Disjoint `fileScopeMustChange` from bug tasks in same wave
87
87
  - P1/P2 over P3
88
88
 
89
+ ## Dependency drift check
90
+
91
+ Run during **Phase 1** for **every** profile (including patch). Always record results; only **include** a dep/hygiene task when a threshold fires — never auto-add “update all deps” to every minor.
92
+
93
+ ### Commands
94
+
95
+ ```bash
96
+ npm outdated
97
+ npm audit
98
+ ```
99
+
100
+ Optional: glance at GitHub Actions major pins in `.github/workflows/*.yml` (`actions/checkout`, `actions/setup-node`, `actions/upload-artifact`, `actions/github-script`) for toolchain major drift.
101
+
102
+ ### Include / defer thresholds
103
+
104
+ | Signal | Include in release? | Bucket |
105
+ |--------|---------------------|--------|
106
+ | `npm audit` high or critical | Yes — even **patch** if fix is S-sized | bug / hygiene |
107
+ | `@earendil-works/pi-coding-agent` behind by ≥1 0.x minor (e.g. 0.80 → 0.85) | Yes for **minor/major**; patch only if also audit-high | enh / hygiene (counts against enh budget on minor) |
108
+ | Same-major patch/minor drift only (eslint 9.x, `@types/node` 22.x) | Include only if enh budget has room **or** operator override; otherwise defer | hygiene |
109
+ | TypeScript / ESLint / Actions **major** | **minor/major** only — never default into patch | enh / hygiene |
110
+ | No overdue signal | Record “deps OK — deferred” in the manifest; **no new task** | — |
111
+
112
+ **Scope when included:** prefer one focused peer/security packet over “bump everything” when the enhancement slot is already full. Dep hygiene inserts into the bug or enh slot — it is not a fourth unlimited bucket.
113
+
114
+ ### Map before authoring a gap
115
+
116
+ Search open issues for an existing dep bump ticket before creating a new SP-*:
117
+
118
+ ```bash
119
+ gh issue list --repo beettlle/pi-spine --state open --limit 100 \
120
+ --json number,title,labels \
121
+ --jq '.[] | select(.title | test("dependenc|pi-coding-agent|npm audit|Bump dep"; "i"))'
122
+ ```
123
+
124
+ Prefer `Closes #NNN` on that issue over inventing duplicate work.
125
+
89
126
  ## Pending task inventory
90
127
 
91
128
  ```bash
@@ -105,3 +142,12 @@ Cross-reference pending SP-* with open issues. The release executes **manifest s
105
142
  |---------|--------|-------------|--------|-------------|-------|
106
143
  | #130 | bug | SP-483 | bug | patch ✓ | post-merge restore |
107
144
  | #90 | documentation | — (gap) | doc | minor ✓ | needs new SP-* |
145
+
146
+ ### Deps mini-table (required)
147
+
148
+ | Package | Current | Latest | Action |
149
+ |---------|---------|--------|--------|
150
+ | @earendil-works/pi-coding-agent | 0.80.3 | 0.85.1 | include (#285) / defer: … |
151
+ | (others from `npm outdated`) | … | … | include \| defer |
152
+
153
+ Also record: `npm audit` high/critical count and overall action for the manifest **Dependency drift** section.
@@ -24,6 +24,18 @@
24
24
 
25
25
  ---
26
26
 
27
+ ## Dependency drift
28
+
29
+ | Check | Result |
30
+ |-------|--------|
31
+ | `npm outdated` | (paste summary or path to intake snapshot) |
32
+ | `npm audit` highs/criticals | n |
33
+ | Action | include SP-### / #NNN \| deferred: {reason} |
34
+
35
+ Thresholds: [issue-intake-checklist.md](issue-intake-checklist.md) § Dependency drift check. Always record; include a task only when a threshold fires.
36
+
37
+ ---
38
+
27
39
  ## Selected tasks
28
40
 
29
41
  | SP-ID | Issue | Bucket | Size | Title | Notes |
@@ -72,8 +72,11 @@ Breaking changes and large migrations. Operator-defined epic scope.
72
72
  Apply in this order; stop when profile budget is full:
73
73
 
74
74
  1. **Documentation** — `label:documentation`, `skill:create-spine-tasks` doc issues, pending docs-only SP-* tasks
75
- 2. **Bug fixes** — open `label:bug` with user impact; prefer already-tasked or quick S
76
- 3. **Enhancements** — only if profile allows; one user-visible improvement per minor release
75
+ 2. **Bug fixes** — open `label:bug` with user impact; prefer already-tasked or quick S; **security-high dep fixes** from the Phase 1 drift check insert here before enhancements
76
+ 3. **Enhancements / dep hygiene** — only if profile allows; one user-visible improvement per minor release; peer ≥1-minor drift (`pi-coding-agent`) or toolchain majors from the drift check fill **one** enh/hygiene slot on minor/major when thresholds fire (see [issue-intake-checklist.md](issue-intake-checklist.md) § Dependency drift check)
77
+ 4. **Defer** the rest — including “deps OK — deferred” when no threshold fires
78
+
79
+ Never treat dependency updates as an uncapped fourth bucket. Prefer one focused peer/security packet over “bump everything” when the enh slot is already full.
77
80
 
78
81
  ## Profile audit (must pass before Phase 3)
79
82
 
@@ -86,6 +89,7 @@ Fill the composition audit table in the manifest. Fail or warn when:
86
89
  | Total tasks | >8 without override | >15 without override | — |
87
90
  | M/L tasks in patch | any without override | — | — |
88
91
  | Doc paths in File Scope | required for doc tasks (#144) | required | required |
92
+ | Dep drift check recorded | WARN if missing | **FAIL** without override if missing | **FAIL** without override if missing |
89
93
 
90
94
  Record `Profile audit: PASS` or `PASS with operator override` before proceeding.
91
95
 
@@ -67,5 +67,49 @@ else
67
67
  fi
68
68
  echo ""
69
69
 
70
+ echo "=== npm outdated ==="
71
+ # npm outdated exits 1 when updates exist — must not abort this script
72
+ npm outdated 2>/dev/null || true
73
+ echo ""
74
+
75
+ echo "=== npm audit (vulnerability counts) ==="
76
+ if command -v node >/dev/null 2>&1; then
77
+ # npm audit exits non-zero when vulns exist — capture JSON without aborting
78
+ AUDIT_JSON="$(npm audit --json 2>/dev/null || true)"
79
+ if [ -n "$AUDIT_JSON" ]; then
80
+ printf '%s' "$AUDIT_JSON" | node -e '
81
+ let s = "";
82
+ process.stdin.on("data", (c) => { s += c; });
83
+ process.stdin.on("end", () => {
84
+ try {
85
+ const d = JSON.parse(s || "{}");
86
+ const v = (d.metadata && d.metadata.vulnerabilities) || {};
87
+ const info = v.info || 0;
88
+ const low = v.low || 0;
89
+ const moderate = v.moderate || 0;
90
+ const high = v.high || 0;
91
+ const critical = v.critical || 0;
92
+ const total = v.total != null ? v.total : info + low + moderate + high + critical;
93
+ console.log(
94
+ "info=" + info +
95
+ " low=" + low +
96
+ " moderate=" + moderate +
97
+ " high=" + high +
98
+ " critical=" + critical +
99
+ " total=" + total
100
+ );
101
+ } catch {
102
+ console.log("(could not parse npm audit --json)");
103
+ }
104
+ });
105
+ '
106
+ else
107
+ echo "(npm audit --json produced no output)"
108
+ fi
109
+ else
110
+ npm audit 2>/dev/null || true
111
+ fi
112
+ echo ""
113
+
70
114
  echo "=== Next Task ID (from CONTEXT.md) ==="
71
115
  grep -E '^\*\*Next Task ID:\*\*' spine-tasks/CONTEXT.md 2>/dev/null || echo "(CONTEXT.md not found)"
package/src/cli/wait.mjs CHANGED
@@ -11,7 +11,12 @@ import fs from "node:fs";
11
11
  import path from "node:path";
12
12
 
13
13
  import { reconcileBatch } from "../batch/reconcile.mjs";
14
- import { parseUntilDiagnoses, reconciliationMatchesUntil } from "./spine-wait.mjs";
14
+ import {
15
+ deriveWaitPseudoDiagnoses,
16
+ diagnosisMatchesUntil,
17
+ parseUntilDiagnoses,
18
+ reconciliationMatchesUntil,
19
+ } from "./spine-wait.mjs";
15
20
  import {
16
21
  buildWatchSnapshot,
17
22
  DEFAULT_WATCH_INTERVAL_SEC,
@@ -95,6 +100,120 @@ export function parseWaitArgs(argv) {
95
100
  return args;
96
101
  }
97
102
 
103
+ /**
104
+ * Human duration for wait headlines (e.g. `12.0s`, `1m5s`). Returns null when the
105
+ * elapsed value is not representable so callers can omit the suffix instead of
106
+ * printing a garbage number (nowFn pairs are expected sane, this is defensive).
107
+ *
108
+ * @param {number} ms
109
+ * @returns {string | null}
110
+ */
111
+ function formatWaitElapsed(ms) {
112
+ if (!Number.isFinite(ms) || ms < 0) {
113
+ return null;
114
+ }
115
+ const seconds = ms / 1000;
116
+ if (seconds < 60) {
117
+ return `${seconds.toFixed(1)}s`;
118
+ }
119
+ const minutes = Math.floor(seconds / 60);
120
+ const remainder = Math.round(seconds % 60);
121
+ return `${minutes}m${remainder}s`;
122
+ }
123
+
124
+ /**
125
+ * Label for what actually matched the `--until` set: the literal taxonomy diagnosis
126
+ * when it matched, the `failed` token when the phase-based alias fired (#252), or the
127
+ * pseudo diagnosis (e.g. gate_open) that fired. Keeps headlines honest for pseudo
128
+ * matches where the raw diagnosis (e.g. "running") is not what woke the wait.
129
+ *
130
+ * @param {import("../batch/reconcile.mjs").ReconciliationResult} result
131
+ * @param {Set<string>} untilDiagnoses
132
+ * @returns {string}
133
+ */
134
+ function describeMatchedDiagnosis(result, untilDiagnoses) {
135
+ const diagnosis = result.diagnosis ?? null;
136
+ if (diagnosisMatchesUntil(diagnosis, untilDiagnoses)) {
137
+ return diagnosis;
138
+ }
139
+ if (untilDiagnoses.has("failed") && result.phase === "failed") {
140
+ return "failed";
141
+ }
142
+ for (const pseudo of deriveWaitPseudoDiagnoses(result)) {
143
+ if (untilDiagnoses.has(pseudo)) {
144
+ return pseudo;
145
+ }
146
+ }
147
+ return diagnosis ?? "matched";
148
+ }
149
+
150
+ /**
151
+ * @param {Set<string>} untilDiagnoses
152
+ * @returns {string}
153
+ */
154
+ function formatUntilList(untilDiagnoses) {
155
+ return [...untilDiagnoses].sort().join(",");
156
+ }
157
+
158
+ /**
159
+ * @param {string | null} scopedBatchId
160
+ * @returns {string}
161
+ */
162
+ function formatBatchSuffix(scopedBatchId) {
163
+ return scopedBatchId != null ? ` (batch ${scopedBatchId})` : "";
164
+ }
165
+
166
+ /**
167
+ * Start banner for human waits (#286, SP-754). Printed once, right before the first poll
168
+ * sleep, so the batch id captured on that poll is included when known. Instant matches
169
+ * never see a banner — their single-line output stays exactly one line.
170
+ *
171
+ * @param {object} options
172
+ * @param {Set<string>} options.untilDiagnoses
173
+ * @param {string | null} options.batchId
174
+ * @param {number} options.intervalSec
175
+ * @param {number | null} options.timeoutMs
176
+ * @returns {string}
177
+ */
178
+ function formatWaitBanner({ untilDiagnoses, batchId, intervalSec, timeoutMs }) {
179
+ const timeoutPart =
180
+ timeoutMs != null
181
+ ? `timeout ${formatWaitElapsed(timeoutMs) ?? `${timeoutMs}ms`}`
182
+ : "no timeout";
183
+ return `Waiting for ${formatUntilList(untilDiagnoses)}${formatBatchSuffix(batchId)} — polling every ${intervalSec}s, ${timeoutPart}`;
184
+ }
185
+
186
+ /**
187
+ * Interval-aligned liveness line (#286, SP-754). The poll loop sleeps exactly one
188
+ * `--interval` per iteration, so one progress line per non-matching poll is aligned by
189
+ * construction and can never spam micro-sleeps. Carries diagnosis/phase (plus wave and
190
+ * pending-task counts when reconcile surfaces them) and elapsed so agent hosts can prove
191
+ * the wait is alive between the start banner and the terminal headline.
192
+ *
193
+ * @param {import("../batch/reconcile.mjs").ReconciliationResult} result
194
+ * @param {string | null} scopedBatchId
195
+ * @param {number} elapsedMs
196
+ * @returns {string}
197
+ */
198
+ function formatWaitProgress(result, scopedBatchId, elapsedMs) {
199
+ /** @type {string[]} */
200
+ const parts = [result.diagnosis ?? "no diagnosis"];
201
+ if (result.phase != null) {
202
+ parts.push(`phase=${result.phase}`);
203
+ }
204
+ if (result.currentWaveIndex != null && result.waveCount != null) {
205
+ parts.push(`wave ${result.currentWaveIndex + 1}/${result.waveCount}`);
206
+ }
207
+ if (result.pendingTasks != null) {
208
+ parts.push(`pending tasks ${result.pendingTasks}`);
209
+ }
210
+ const elapsed = formatWaitElapsed(elapsedMs);
211
+ if (elapsed != null) {
212
+ parts.push(`elapsed ${elapsed}`);
213
+ }
214
+ return `Wait progress: ${parts.join(", ")}${formatBatchSuffix(scopedBatchId)}`;
215
+ }
216
+
98
217
  /** Exit code when the waited-on batch was archived or superseded by another session (#215). */
99
218
  export const WAIT_SUPERSEDED_EXIT_CODE = 2;
100
219
 
@@ -211,6 +330,15 @@ export async function runSpineWait(options) {
211
330
  let scopedBatchId = null;
212
331
  let scopedBatchIdCaptured = false;
213
332
 
333
+ /**
334
+ * Human start banner (#286, SP-754): flipped after the first poll that continues past
335
+ * the match/supersede/timeout checks, so the banner is printed exactly once and only
336
+ * when the wait actually waits. `--json` never prints it.
337
+ *
338
+ * @type {boolean}
339
+ */
340
+ let bannerPrinted = false;
341
+
214
342
  try {
215
343
  while (running) {
216
344
  const result = reconcileFn({ projectRoot });
@@ -266,6 +394,13 @@ export async function runSpineWait(options) {
266
394
  if (reconciliationMatchesUntil(result, untilDiagnoses)) {
267
395
  if (json) {
268
396
  writeStdout(`${JSON.stringify(buildWatchSnapshot(result, nowFn()))}\n`);
397
+ } else {
398
+ // Terminal headline (#286): long waits must not look hung on success. One
399
+ // stdout line naming what matched, the scoped batch, and elapsed time.
400
+ const elapsed = formatWaitElapsed(nowFn() - startedAt);
401
+ writeStdout(
402
+ `Wait matched: ${describeMatchedDiagnosis(result, untilDiagnoses)}${formatBatchSuffix(scopedBatchId)}${elapsed != null ? ` after ${elapsed}` : ""}\n`,
403
+ );
269
404
  }
270
405
  return {
271
406
  exitCode: 0,
@@ -279,6 +414,13 @@ export async function runSpineWait(options) {
279
414
  if (deadline != null && nowFn() >= deadline) {
280
415
  if (json) {
281
416
  writeStdout(`${JSON.stringify(buildWatchSnapshot(result, nowFn()))}\n`);
417
+ } else {
418
+ // Terminal headline (#286): stderr keeps the non-success terminal state off
419
+ // stdout and is clearly distinct from the match line.
420
+ const elapsed = formatWaitElapsed(nowFn() - startedAt);
421
+ writeStderr(
422
+ `Wait timed out${elapsed != null ? ` after ${elapsed}` : ""} waiting for ${formatUntilList(untilDiagnoses)}${formatBatchSuffix(scopedBatchId)} — last diagnosis: ${diagnosis ?? "none"}\n`,
423
+ );
282
424
  }
283
425
  return {
284
426
  exitCode: 1,
@@ -289,9 +431,29 @@ export async function runSpineWait(options) {
289
431
  };
290
432
  }
291
433
 
434
+ if (!json) {
435
+ if (!bannerPrinted) {
436
+ // Start banner (#286, SP-754): once, only when the wait actually continues —
437
+ // instant matches keep their single-line output. batchId was captured above.
438
+ bannerPrinted = true;
439
+ writeStdout(
440
+ `${formatWaitBanner({ untilDiagnoses, batchId: scopedBatchId, intervalSec, timeoutMs })}\n`,
441
+ );
442
+ } else {
443
+ // Interval-aligned progress (#286, SP-754): one line per non-matching poll.
444
+ writeStdout(`${formatWaitProgress(result, scopedBatchId, nowFn() - startedAt)}\n`);
445
+ }
446
+ }
447
+
292
448
  await sleepFn(intervalSec * 1000);
293
449
  }
294
450
 
451
+ if (!json) {
452
+ // Terminal headline (#286): SIGINT must not exit silently either.
453
+ writeStderr(
454
+ `Wait interrupted — exited without matching ${formatUntilList(untilDiagnoses)}${formatBatchSuffix(scopedBatchId)}\n`,
455
+ );
456
+ }
295
457
  return { exitCode: 130, matched: false, diagnosis: null, timedOut: false, interrupted: true };
296
458
  } finally {
297
459
  process.off("SIGINT", onSigInt);