pi-spine 2.5.0 → 2.7.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 (33) hide show
  1. package/bin/spine-plan.mjs +2 -1
  2. package/bin/spine-tasks.mjs +2 -1
  3. package/bin/spine.mjs +22 -0
  4. package/package.json +1 -1
  5. package/src/batch/attached-runner-promote.mjs +95 -11
  6. package/src/batch/diagnosis-alternatives.mjs +18 -0
  7. package/src/batch/diagnosis-gate-ready.mjs +23 -0
  8. package/src/batch/diagnosis-pending-lane.mjs +63 -0
  9. package/src/batch/diagnosis-retry-command.mjs +23 -0
  10. package/src/batch/diagnosis-tail-state.mjs +68 -0
  11. package/src/batch/diagnosis.mjs +69 -52
  12. package/src/batch/engine-lanes/commit.mjs +2 -0
  13. package/src/batch/engine-lanes.mjs +2 -3
  14. package/src/batch/evidence-command.mjs +241 -16
  15. package/src/batch/lane-commit.mjs +77 -8
  16. package/src/batch/lifecycle-archive.mjs +71 -0
  17. package/src/batch/lifecycle.mjs +27 -67
  18. package/src/batch/orphan-detect.mjs +68 -5
  19. package/src/batch/post-merge-limbo.mjs +137 -22
  20. package/src/batch/reconcile-batch.mjs +40 -43
  21. package/src/batch/reconcile-diagnosis-context.mjs +88 -0
  22. package/src/batch/reconcile-diagnosis.mjs +14 -32
  23. package/src/batch/resume-multi-validate.mjs +51 -9
  24. package/src/batch/retry.mjs +18 -2
  25. package/src/config/missing-config-hint.mjs +19 -0
  26. package/src/config/pi-spine-root.mjs +22 -0
  27. package/src/config/preflight/discovery.mjs +6 -4
  28. package/src/config/spine-config-load.mjs +30 -2
  29. package/src/config/spine-init-constants.mjs +7 -3
  30. package/src/doctor/duplicate-install.mjs +100 -0
  31. package/src/doctor/run-doctor-checks.mjs +10 -1
  32. package/src/doctor/worktree-health.mjs +4 -0
  33. package/templates/spine-config.json +5 -4
@@ -7,11 +7,8 @@ import { buildStalePathDoctorCheck } from "../doctor/stale-path.mjs";
7
7
  import { PACKAGE_ROOT } from "../config/spine-init-constants.mjs";
8
8
  import { loadGateRecord } from "./gate-evidence-read.mjs";
9
9
  import { deriveMacroPhase, macroPhaseLabel } from "./macro-phase.mjs";
10
- import {
11
- buildDiagnosisOutput,
12
- inferMergeGitignoredFailure,
13
- isGateReadyHeadlineContext,
14
- } from "./diagnosis.mjs";
10
+ import { buildDiagnosisOutput, inferMergeGitignoredFailure } from "./diagnosis.mjs";
11
+ import { isGateReadyHeadlineContext } from "./diagnosis-gate-ready.mjs";
15
12
  import {
16
13
  classifyTasks,
17
14
  inspectGitState,
@@ -47,6 +44,7 @@ import {
47
44
  } from "./batch-state-io.mjs";
48
45
  import { readBatchEnginePid } from "./state.mjs";
49
46
  import {
47
+ buildReconcileDiagnosisContext,
50
48
  deriveDiagnosis,
51
49
  enrichLaunchFailureFromWorkerOutput,
52
50
  enrichWorkerDoneMissingContext,
@@ -395,49 +393,48 @@ export function reconcileBatch(ctx, _lightRetry = false) {
395
393
  const enginePid = readBatchEnginePid(batch.raw);
396
394
  const staleEnginePid =
397
395
  enginePid != null && !isProcessAlive(enginePid);
396
+ const engineStillRunning = enginePid != null && !staleEnginePid;
398
397
  const engineOrphanCause =
399
398
  diagnosis === "engine_orphaned"
400
399
  ? inferEngineOrphanCause({ journalEvents, staleEnginePid })
401
400
  : null;
402
401
 
403
- const output = buildDiagnosisOutput(diagnosis, {
404
- batchId: batch.batchId,
405
- phase: batch.phase,
406
- failedTasks: signals.failedTasks,
407
- failedTaskId,
408
- driftTaskStatus,
409
- exitReason,
410
- launchFailureKind: resolvedLaunchFailureKind,
411
- gitMerged: git.orchMergedToBase,
412
- pendingTaskCount,
413
- salvageChangedFileCount,
414
- salvageRetryCommand,
415
- ghostRunningCluster,
416
- postMergeLimbo: signals.postMergeLimbo === true,
417
- integrateGateOpen,
418
- stalePathSpine,
419
- planReviewNestedSpawnBlocked,
420
- mergeGitignoredFailure,
421
- mergeFailed: mergeFailedForHeadline,
422
- failedWaveIndex: mergeFailureSummary.failedWaveIndex,
423
- failedLane: mergeFailureSummary.failedLane,
424
- lastError: mergeFailureSummary.lastError,
425
- succeededTasks: batch.succeededTasks,
426
- totalTasks: batch.totalTasks,
427
- taskBranch,
428
- gitignoredPaths,
429
- hasRunningTasks,
430
- hasPendingTasks,
431
- allTasksTerminalSuccess: signals.allTasksTerminalSuccess,
432
- tasksRoot,
433
- macroPhase,
434
- reviewHonorSignal,
435
- ...(doneMissingContext ?? {}),
436
- engineOrphanCause,
437
- staleEnginePid,
438
- humanBaseSync,
439
- overlapPaths: humanBaseSync?.overlapPaths ?? [],
440
- });
402
+ const output = buildDiagnosisOutput(
403
+ diagnosis,
404
+ buildReconcileDiagnosisContext({
405
+ batch,
406
+ git,
407
+ signals,
408
+ classifiedTasks,
409
+ diagnosis,
410
+ failedTaskId,
411
+ driftTaskStatus,
412
+ exitReason,
413
+ resolvedLaunchFailureKind,
414
+ pendingTaskCount,
415
+ salvageChangedFileCount,
416
+ salvageRetryCommand,
417
+ ghostRunningCluster,
418
+ integrateGateOpen,
419
+ stalePathSpine,
420
+ planReviewNestedSpawnBlocked,
421
+ mergeGitignoredFailure,
422
+ mergeFailedForHeadline,
423
+ mergeFailureSummary,
424
+ taskBranch,
425
+ gitignoredPaths,
426
+ hasRunningTasks,
427
+ hasPendingTasks,
428
+ macroPhase,
429
+ reviewHonorSignal,
430
+ doneMissingContext,
431
+ engineOrphanCause,
432
+ staleEnginePid,
433
+ enginePid,
434
+ engineStillRunning,
435
+ humanBaseSync,
436
+ }),
437
+ );
441
438
 
442
439
  if (humanBaseSync && (diagnosis === "human_base_diverged" || diagnosis === "integrate_isolated_ok")) {
443
440
  output.headline = humanBaseSync.headline;
@@ -0,0 +1,88 @@
1
+ // @ts-nocheck
2
+ /** Diagnosis output context after reconcile signal enrichment (#201 / SP-645). */
3
+
4
+ import { findPendingLaneLandTasks } from "./diagnosis-pending-lane.mjs";
5
+
6
+ /**
7
+ * @param {object} params
8
+ */
9
+ export function buildReconcileDiagnosisContext(params) {
10
+ const {
11
+ batch,
12
+ git,
13
+ signals,
14
+ classifiedTasks,
15
+ diagnosis: _diagnosis,
16
+ failedTaskId,
17
+ driftTaskStatus,
18
+ exitReason,
19
+ resolvedLaunchFailureKind,
20
+ pendingTaskCount,
21
+ salvageChangedFileCount,
22
+ salvageRetryCommand,
23
+ ghostRunningCluster,
24
+ integrateGateOpen,
25
+ stalePathSpine,
26
+ planReviewNestedSpawnBlocked,
27
+ mergeGitignoredFailure,
28
+ mergeFailedForHeadline,
29
+ mergeFailureSummary,
30
+ taskBranch,
31
+ gitignoredPaths,
32
+ hasRunningTasks,
33
+ hasPendingTasks,
34
+ macroPhase,
35
+ reviewHonorSignal,
36
+ doneMissingContext,
37
+ engineOrphanCause,
38
+ staleEnginePid,
39
+ enginePid,
40
+ engineStillRunning,
41
+ humanBaseSync,
42
+ } = params;
43
+
44
+ const pendingLaneLandTasks = findPendingLaneLandTasks(classifiedTasks);
45
+
46
+ return {
47
+ batchId: batch.batchId,
48
+ baseBranch: batch.baseBranch ?? git.baseBranch ?? "main",
49
+ pendingLaneLandTasks,
50
+ phase: batch.phase,
51
+ failedTasks: signals.failedTasks,
52
+ failedTaskId,
53
+ driftTaskStatus,
54
+ exitReason,
55
+ launchFailureKind: resolvedLaunchFailureKind,
56
+ gitMerged: git.orchMergedToBase,
57
+ pendingTaskCount,
58
+ salvageChangedFileCount,
59
+ salvageRetryCommand,
60
+ ghostRunningCluster,
61
+ postMergeLimbo: signals.postMergeLimbo === true,
62
+ integrateGateOpen,
63
+ stalePathSpine,
64
+ planReviewNestedSpawnBlocked,
65
+ mergeGitignoredFailure,
66
+ mergeFailed: mergeFailedForHeadline,
67
+ failedWaveIndex: mergeFailureSummary.failedWaveIndex,
68
+ failedLane: mergeFailureSummary.failedLane,
69
+ lastError: mergeFailureSummary.lastError,
70
+ succeededTasks: batch.succeededTasks,
71
+ totalTasks: batch.totalTasks,
72
+ taskBranch,
73
+ gitignoredPaths,
74
+ hasRunningTasks,
75
+ hasPendingTasks,
76
+ allTasksTerminalSuccess: signals.allTasksTerminalSuccess,
77
+ tasksRoot: signals.tasksRoot,
78
+ macroPhase,
79
+ reviewHonorSignal,
80
+ ...(doneMissingContext ?? {}),
81
+ engineOrphanCause,
82
+ staleEnginePid,
83
+ enginePid,
84
+ engineStillRunning,
85
+ humanBaseSync,
86
+ overlapPaths: humanBaseSync?.overlapPaths ?? [],
87
+ };
88
+ }
@@ -2,21 +2,20 @@
2
2
  /** Diagnosis derivation (SP-596/SP-606 / #192). */
3
3
 
4
4
  import fs from "node:fs";
5
+ import { inferLaunchFailureFromWorkerOutputTail, inferLaunchFailureKind } from "./diagnosis.mjs";
5
6
  import {
6
- inferLaunchFailureFromWorkerOutputTail,
7
- inferLaunchFailureKind,
8
- } from "./diagnosis.mjs";
7
+ findPendingLaneLandTasks,
8
+ shouldDiagnosePendingLaneLand,
9
+ } from "./diagnosis-pending-lane.mjs";
9
10
  import { inferWorkerDoneMissingFailure } from "./diagnosis-worker-done-missing.mjs";
10
11
  import { inferStubExitReasonForTask } from "./diagnosis-stub.mjs";
11
12
  import { workerOutputLogPath, workerOutputLogRef } from "./worker-output.mjs";
12
- import { journalEventsSinceResume } from "./orphan-detect.mjs";
13
13
  import { isPostMergeLimbo } from "./limbo-detect.mjs";
14
- import { isProcessAlive } from "../process/liveness.mjs";
15
- import { readBatchEnginePid } from "./state.mjs";
16
14
  import {
17
15
  LIMBO_PHASES,
18
16
  RUNNING_PHASES,
19
17
  } from "./reconcile-light-cache.mjs";
18
+ export { buildReconcileDiagnosisContext } from "./reconcile-diagnosis-context.mjs";
20
19
 
21
20
  /**
22
21
  * @param {unknown} rawTasks
@@ -241,22 +240,6 @@ function withFailureContext(diagnosis, failedTaskId, signals, exitReason = null)
241
240
  };
242
241
  }
243
242
 
244
- /**
245
- * @param {object[]} journalEvents
246
- * @param {Record<string, unknown>|null|undefined} raw
247
- * @param {string|null} taskId
248
- */
249
- function journalIndicatesResumeRulesStall(journalEvents, raw, taskId) {
250
- const scoped = journalEventsSinceResume(journalEvents, raw);
251
- const hasRulesSelected = scoped.some((event) => {
252
- if (event.type !== "worker.rules_selected") return false;
253
- const eventTaskId = event.taskId ?? event.payload?.taskId;
254
- return !taskId || !eventTaskId || eventTaskId === taskId;
255
- });
256
- const hasBatchResumed = scoped.some((event) => event.type === "batch.resumed");
257
- return hasRulesSelected && hasBatchResumed;
258
- }
259
-
260
243
  /**
261
244
  * @param {object} signals
262
245
  */
@@ -300,21 +283,20 @@ export function deriveDiagnosis(signals) {
300
283
 
301
284
  if (orphanRunning) {
302
285
  if (orphanRunning.kind === "lane" && orphanRunning.taskId) {
303
- const enginePid = readBatchEnginePid(signals.raw);
304
- const engineDead = enginePid == null || !isProcessAlive(enginePid);
305
- const resumeRulesStall = journalIndicatesResumeRulesStall(
306
- signals.journalEvents ?? [],
307
- signals.raw,
308
- orphanRunning.taskId,
309
- );
310
- if (engineDead && resumeRulesStall) {
311
- return withFailureContext("engine_orphaned", orphanRunning.taskId, signals);
312
- }
313
286
  return withFailureContext("worker_orphaned", orphanRunning.taskId, signals);
314
287
  }
315
288
  return withFailureContext("engine_orphaned", orphanRunning.taskId ?? null, signals);
316
289
  }
317
290
 
291
+ if (shouldDiagnosePendingLaneLand(signals)) {
292
+ const pendingLaneLandTasks = findPendingLaneLandTasks(signals.tasks);
293
+ return withFailureContext(
294
+ "pending_lane_land",
295
+ pendingLaneLandTasks[0]?.taskId ?? null,
296
+ signals,
297
+ );
298
+ }
299
+
318
300
  if (signals.stateDrift?.drifted) {
319
301
  const driftTask = signals.stateDrift.entries.find((entry) => entry.taskId !== "*");
320
302
  return withFailureContext("state_drift", driftTask?.taskId ?? null, signals);
@@ -61,24 +61,66 @@ export function detectPostMergeLimboForResume({ projectRoot, state }) {
61
61
  export { hasPendingWaveMerge } from "./merge/wave-merge-state.mjs";
62
62
 
63
63
  /**
64
- * Whether every task is terminal-success (or skipped) for #196 drift recovery.
64
+ * Terminal-success evidence for force-resume eligibility (#196 / #197).
65
+ * Prefer classification / done* markers over raw `status === "succeeded"` only —
66
+ * diagnose and salvage use the same signals when the status cache lags.
67
+ *
68
+ * @param {object|null|undefined} task
69
+ */
70
+ function isTerminalSuccessForResume(task) {
71
+ const status = String(task?.status ?? "").toLowerCase();
72
+ if (status === "succeeded" || status === "skipped") return true;
73
+ if (task?.doneInLane === true || task?.doneFileFound === true || task?.doneOnMain === true) {
74
+ return true;
75
+ }
76
+ return String(task?.classification ?? "").toLowerCase() === "terminal-success";
77
+ }
78
+
79
+ /**
80
+ * Whether every task is terminal-success (or skipped) for drift recovery (#196 / #197).
65
81
  *
66
82
  * @param {object|null|undefined} state
67
83
  */
68
84
  function allTasksTerminalSuccessForResume(state) {
69
85
  const tasks = state?.tasks ?? [];
70
86
  if (tasks.length < 1) return false;
71
- return tasks.every((task) => {
72
- const status = String(task?.status ?? "").toLowerCase();
73
- return status === "succeeded" || status === "skipped";
74
- });
87
+ return tasks.every((task) => isTerminalSuccessForResume(task));
88
+ }
89
+
90
+ /**
91
+ * Pending wave merge for resume eligibility.
92
+ *
93
+ * Status-only `hasPendingWaveMerge` misses #197 when tasks are still `status: running`
94
+ * but classification / doneInLane already show terminal success. In that case treat any
95
+ * wave without a succeeded mergeResults row as pending merge (same intent as
96
+ * findFirstWaveNeedingMerge, without widening wave-merge-state blast radius).
97
+ *
98
+ * @param {object|null|undefined} state
99
+ */
100
+ function hasPendingWaveMergeForResume(state) {
101
+ if (hasPendingWaveMerge(state)) return true;
102
+ if (!allTasksTerminalSuccessForResume(state)) return false;
103
+ const wavePlan = state?.wavePlan ?? [];
104
+ if (wavePlan.length < 1) return false;
105
+ const mergeResults = state?.mergeResults ?? [];
106
+ const succeeded = new Set(
107
+ mergeResults
108
+ .filter((entry) => String(entry?.status ?? "").toLowerCase() === "succeeded")
109
+ .map((entry) => Number(entry.waveIndex))
110
+ .filter((waveIndex) => Number.isFinite(waveIndex)),
111
+ );
112
+ for (let waveIndex = 0; waveIndex < wavePlan.length; waveIndex++) {
113
+ if (!succeeded.has(waveIndex)) return true;
114
+ }
115
+ return false;
75
116
  }
76
117
 
77
118
  /**
78
119
  * Assess whether a running-phase batch may resume after a dead detached engine (SP-296).
79
120
  *
80
- * Also covers SP-613 / #196: pidless engine + all tasks terminal-success + pending wave
81
- * merge (doneInLane healed, enginePid cleared) must not dead-end on phase=running.
121
+ * Also covers SP-613 / #196 and SP-635 / #197: pidless engine + all tasks terminal-success
122
+ * (status healed or classification/doneInLane) + pending wave merge must not dead-end on
123
+ * phase=running.
82
124
  *
83
125
  * @param {object} params
84
126
  * @param {string} params.projectRoot
@@ -101,11 +143,11 @@ export function assessRunningPhaseResumeEligibility({ projectRoot, state }) {
101
143
  const enginePid = readBatchEnginePid(state);
102
144
  const enginePidDead = enginePid != null && !isProcessAlive(enginePid);
103
145
  const pidlessEngineOrphan = enginePid == null && orphanRunning?.kind === "engine";
104
- // Dead/missing engine with work finished but merge not landed — agent-safe detached resume (#196).
146
+ // Dead/missing engine with work finished but merge not landed — agent-safe detached resume (#196 / #197).
105
147
  const pidlessTerminalSuccessPendingMerge =
106
148
  enginePid == null &&
107
149
  allTasksTerminalSuccessForResume(state) &&
108
- hasPendingWaveMerge(state);
150
+ hasPendingWaveMergeForResume(state);
109
151
  const engineConfirmedDead =
110
152
  enginePidDead || pidlessEngineOrphan || pidlessTerminalSuccessPendingMerge;
111
153
 
@@ -18,6 +18,16 @@ import {
18
18
  const RETRY_ALLOWED_PHASES = new Set(["paused", "failed"]);
19
19
  const RETRY_BLOCKED_PHASES = new Set(["running", "planning"]);
20
20
 
21
+ /**
22
+ * Fail running tasks and clear dead engine/worker PIDs before retry/skip (#203 / SP-647).
23
+ *
24
+ * @param {string} projectRoot
25
+ * @param {object} state
26
+ */
27
+ function reconcileOrphanBeforeTaskMutation(projectRoot, state) {
28
+ return reconcileOrphanRunningState({ projectRoot, state });
29
+ }
30
+
21
31
  /**
22
32
  * @param {object} state
23
33
  * @param {string} taskId
@@ -115,7 +125,7 @@ export function retryTask({ projectRoot, taskId }) {
115
125
  return { ok: false, exitCode: 1, error: "no_active_batch", output: "No active pi-spine batch.\n" };
116
126
  }
117
127
 
118
- reconcileOrphanRunningState({ projectRoot, state: loaded.raw });
128
+ reconcileOrphanBeforeTaskMutation(projectRoot, loaded.raw);
119
129
 
120
130
  const reloaded = loadSpineBatchState(projectRoot);
121
131
  const state = reloaded.raw;
@@ -255,7 +265,13 @@ export function skipTask({ projectRoot, taskId }) {
255
265
  return { ok: false, exitCode: 1, error: "no_active_batch", output: "No active pi-spine batch.\n" };
256
266
  }
257
267
 
258
- const state = loaded.raw;
268
+ reconcileOrphanBeforeTaskMutation(projectRoot, loaded.raw);
269
+
270
+ const reloaded = loadSpineBatchState(projectRoot);
271
+ const state = reloaded.raw;
272
+ if (!state) {
273
+ return { ok: false, exitCode: 1, error: "no_active_batch", output: "No active pi-spine batch.\n" };
274
+ }
259
275
  const phase = String(state.phase ?? "");
260
276
 
261
277
  if (RETRY_BLOCKED_PHASES.has(phase)) {
@@ -0,0 +1,19 @@
1
+ // @ts-check
2
+ import path from "node:path";
3
+
4
+ /**
5
+ * Honest missing-config / wrong-cwd hint (FR-REL270-01 / FR-REL270-02 / #202).
6
+ * Single source of truth for message + suggestedCommand when `.spine/spine-config.json`
7
+ * is absent under the resolved project root.
8
+ *
9
+ * @param {string} projectRoot
10
+ * @returns {{ resolvedRoot: string, message: string, suggestedCommand: string }}
11
+ */
12
+ export function missingConfigHint(projectRoot) {
13
+ const resolvedRoot = path.resolve(projectRoot);
14
+ return {
15
+ resolvedRoot,
16
+ message: `.spine/spine-config.json not found under ${resolvedRoot} (cwd/$PWD). Change to your project root, or run spine init here if this directory should be initialized.`,
17
+ suggestedCommand: `cd ${resolvedRoot} # if wrong directory — or run: spine init`,
18
+ };
19
+ }
@@ -30,6 +30,28 @@ function realpathOrResolve(root) {
30
30
  }
31
31
  }
32
32
 
33
+ /**
34
+ * Default `PI_SPINE_ROOT` to cwd when unset/empty so CLI doctor/preflight
35
+ * do not require a manual export (SP-643 / #203). Does not override an
36
+ * explicit env value. Worker package-root resolution stays in
37
+ * {@link resolvePiSpineRoot}.
38
+ *
39
+ * @param {NodeJS.ProcessEnv} [env]
40
+ * @param {string} [cwd]
41
+ * @returns {string} Effective `PI_SPINE_ROOT` after ensure
42
+ */
43
+ export function ensureDefaultPiSpineRootEnv(
44
+ env = process.env,
45
+ cwd = process.cwd(),
46
+ ) {
47
+ const current = env.PI_SPINE_ROOT;
48
+ if (typeof current === "string" && current.trim()) {
49
+ return current.trim();
50
+ }
51
+ env.PI_SPINE_ROOT = cwd;
52
+ return cwd;
53
+ }
54
+
33
55
  /**
34
56
  * @param {object} [config]
35
57
  * @param {string} [projectRoot]
@@ -3,6 +3,7 @@ import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import { spawnSync } from "node:child_process";
5
5
  import { loadSpineConfig } from "../spine-config-load.mjs";
6
+ import { missingConfigHint } from "../missing-config-hint.mjs";
6
7
  import { resolveTasksRootPath } from "../env-overrides.mjs";
7
8
  import { validateWorktreeSetupHookConfig } from "../worktree-setup-hook.mjs";
8
9
  import { discoverTasks } from "../../tasks/packet/discover.mjs";
@@ -61,7 +62,7 @@ export function checkTasksRoot(ctx) {
61
62
 
62
63
  if (!tasksRootPath) {
63
64
  return makeCheck("tasks-root", false, "tasks root not configured", {
64
- suggestedCommand: "spine init",
65
+ suggestedCommand: missingConfigHint(ctx.projectRoot).suggestedCommand,
65
66
  });
66
67
  }
67
68
 
@@ -108,7 +109,7 @@ export function checkDependenciesJson(ctx) {
108
109
 
109
110
  if (!tasksRootPath) {
110
111
  return makeCheck("dependencies-json", false, "tasks root not configured", {
111
- suggestedCommand: "spine init",
112
+ suggestedCommand: missingConfigHint(ctx.projectRoot).suggestedCommand,
112
113
  });
113
114
  }
114
115
 
@@ -255,15 +256,16 @@ export function checkTasksValidate(ctx) {
255
256
  const config = configResult?.config;
256
257
 
257
258
  if (!config || configResult?.error) {
259
+ const hint = missingConfigHint(projectRoot);
258
260
  return makeCheck("tasks-validate", false, "cannot validate tasks without spine config", {
259
- suggestedCommand: "spine init",
261
+ suggestedCommand: hint.suggestedCommand,
260
262
  });
261
263
  }
262
264
 
263
265
  const tasksRootPath = resolveTasksRoot(projectRoot, configResult);
264
266
  if (!tasksRootPath) {
265
267
  return makeCheck("tasks-validate", false, "tasks root not configured", {
266
- suggestedCommand: "spine init",
268
+ suggestedCommand: missingConfigHint(projectRoot).suggestedCommand,
267
269
  });
268
270
  }
269
271
 
@@ -11,9 +11,33 @@ import { validateWorkerContextConfig } from "./worker-context.mjs";
11
11
  import { validateWorkerLaunchScriptConfig } from "./worker-launch-script.mjs";
12
12
  import { validateWorktreeSetupHookConfig } from "./worktree-setup-hook.mjs";
13
13
  import { validateOrchestratorConfig } from "./spine-config-schema.mjs";
14
+ import { missingConfigHint } from "./missing-config-hint.mjs";
14
15
 
15
16
  export { resolveGatePostureConfig } from "./gate-posture-config.mjs";
16
17
 
18
+ /**
19
+ * Default hook paths skipped at lane commit when config omits ignore paths (SP-640 / #200).
20
+ * Worktree setup hooks commonly `ln -s` `.venv` into lane worktrees; do not stage that symlink.
21
+ */
22
+ export const DEFAULT_WORKTREE_SETUP_IGNORE_PATHS = Object.freeze([".venv"]);
23
+
24
+ /**
25
+ * Resolve effective `worktreeSetupIgnorePaths`, always unioning defaults so hook `.venv`
26
+ * stays ignored. Opt in to committing an ignore path via task `fileScope`, not by clearing config.
27
+ *
28
+ * @param {Record<string, unknown> | null | undefined} config
29
+ * @returns {string[]}
30
+ */
31
+ export function resolveWorktreeSetupIgnorePaths(config) {
32
+ const raw = config?.worktreeSetupIgnorePaths;
33
+ const configured = Array.isArray(raw)
34
+ ? raw
35
+ .filter((/** @type {unknown} */ entry) => typeof entry === "string" && entry.trim())
36
+ .map((/** @type {unknown} */ entry) => /** @type {string} */ (entry).trim())
37
+ : [];
38
+ return [...new Set([...DEFAULT_WORKTREE_SETUP_IGNORE_PATHS, ...configured])];
39
+ }
40
+
17
41
  const REQUIRED_TOP_LEVEL = [
18
42
  "configVersion",
19
43
  "project",
@@ -35,13 +59,14 @@ export function loadSpineConfigFile(projectRoot) {
35
59
  const configPath = path.join(projectRoot, ".spine", "spine-config.json");
36
60
 
37
61
  if (!fs.existsSync(configPath)) {
62
+ const hint = missingConfigHint(projectRoot);
38
63
  return {
39
64
  configPath,
40
65
  config: null,
41
66
  error: {
42
67
  code: "CONFIG_MISSING",
43
- message: ".spine/spine-config.json not found",
44
- suggestedCommand: "spine init",
68
+ message: hint.message,
69
+ suggestedCommand: hint.suggestedCommand,
45
70
  },
46
71
  };
47
72
  }
@@ -91,6 +116,9 @@ export function loadSpineConfig(projectRoot) {
91
116
 
92
117
  const config = structuredClone(fileResult.config);
93
118
  applyConfigDefaults(config);
119
+ if (config.worktreeSetupIgnorePaths == null) {
120
+ config.worktreeSetupIgnorePaths = [...DEFAULT_WORKTREE_SETUP_IGNORE_PATHS];
121
+ }
94
122
 
95
123
  const contractError = validateContractConfig(config);
96
124
  if (contractError) {
@@ -43,8 +43,12 @@ export const TASKPLANE_COMPAT_TASKS_ROOT = "taskplane-tasks";
43
43
  export const TASKPLANE_COMPAT_PRESET = "taskplane-compat";
44
44
  export const LEGACY_TASKPLANE_PRESET_ALIASES = [TASKPLANE_COMPAT_PRESET];
45
45
 
46
- export const SPINE_INIT_TESTING_COMMAND = "npm run typecheck && npm test";
46
+ /** Phase-A-safe evidence argv (no shell metacharacters); matches templates/spine-config.json. */
47
+ export const SPINE_INIT_BUILD_COMMAND = "npm run typecheck";
48
+ export const SPINE_INIT_TEST_COMMAND = "npm test";
47
49
  export const SPINE_INIT_COVERAGE_COMMAND = "npm run coverage:check";
50
+ /** @deprecated Prefer SPINE_INIT_BUILD_COMMAND / SPINE_INIT_TEST_COMMAND. */
51
+ export const SPINE_INIT_TESTING_COMMAND = SPINE_INIT_TEST_COMMAND;
48
52
 
49
53
  export const SPINE_GITIGNORE_ENTRIES = [
50
54
  ".pi/",
@@ -166,8 +170,8 @@ export function parseInitArgs(args) {
166
170
 
167
171
  /** Apply production-ready defaults for every greenfield init. */
168
172
  export function applySpineInitDefaults(config) {
169
- config.testing.build = SPINE_INIT_TESTING_COMMAND;
170
- config.testing.test = SPINE_INIT_TESTING_COMMAND;
173
+ config.testing.build = SPINE_INIT_BUILD_COMMAND;
174
+ config.testing.test = SPINE_INIT_TEST_COMMAND;
171
175
  config.testing.testWithCoverage = SPINE_INIT_COVERAGE_COMMAND;
172
176
  config.dashboard = { ...(config.dashboard ?? {}), port: 8109 };
173
177
  config.gates = {