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
@@ -82,6 +82,106 @@ export function detectDuplicatePiSpineInstall({
82
82
  };
83
83
  }
84
84
 
85
+ /**
86
+ * Read pi-spine version from a checkout cwd when package.json name matches.
87
+ *
88
+ * @param {string} projectRoot
89
+ * @param {(p: string) => boolean} [exists]
90
+ */
91
+ export function readCheckoutPiSpineVersion(projectRoot, exists = fs.existsSync) {
92
+ const packageJsonPath = path.join(projectRoot, "package.json");
93
+ if (!exists(packageJsonPath)) return null;
94
+ try {
95
+ const pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
96
+ if (String(pkg.name ?? "").trim() !== PI_SPINE_PACKAGE_NAME) return null;
97
+ return String(pkg.version ?? "").trim() || null;
98
+ } catch {
99
+ return null;
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Detect when the running CLI package version differs from checkout package.json (#204 / SP-648).
105
+ *
106
+ * @param {object} [options]
107
+ * @param {string} [options.runningPackageRoot]
108
+ * @param {string} [options.runningVersion]
109
+ * @param {string} [options.projectRoot]
110
+ * @param {(p: string) => boolean} [options.exists]
111
+ */
112
+ export function detectPathSpineVersionSkew({
113
+ runningPackageRoot,
114
+ runningVersion,
115
+ projectRoot = process.cwd(),
116
+ exists = fs.existsSync,
117
+ } = {}) {
118
+ const cliVersion =
119
+ runningVersion ??
120
+ (runningPackageRoot ? readInstalledPackageVersion(runningPackageRoot) : null);
121
+ const checkoutVersion = readCheckoutPiSpineVersion(projectRoot, exists);
122
+ const checkoutPresent = checkoutVersion != null;
123
+ const skewed =
124
+ checkoutPresent && cliVersion != null && cliVersion !== checkoutVersion;
125
+
126
+ return {
127
+ cliVersion,
128
+ checkoutVersion,
129
+ checkoutPresent,
130
+ skewed,
131
+ projectRoot,
132
+ };
133
+ }
134
+
135
+ /**
136
+ * Remediation when PATH/global CLI skews checkout dogfood (#204).
137
+ */
138
+ export function formatCheckoutVersionSkewRemediation() {
139
+ return "node bin/spine.mjs # or: npm link";
140
+ }
141
+
142
+ /**
143
+ * @param {object} [options]
144
+ * @param {string} [options.runningPackageRoot]
145
+ * @param {string} [options.runningVersion]
146
+ * @param {string} [options.projectRoot]
147
+ * @param {(p: string) => boolean} [options.exists]
148
+ */
149
+ export function buildCheckoutVersionSkewDoctorCheck(options = {}) {
150
+ const assessment = detectPathSpineVersionSkew(options);
151
+
152
+ if (!assessment.checkoutPresent) {
153
+ return {
154
+ label: "pi-spine checkout version skew",
155
+ ok: true,
156
+ detail: "no pi-spine checkout package.json in cwd",
157
+ };
158
+ }
159
+
160
+ if (!assessment.cliVersion) {
161
+ return {
162
+ label: "pi-spine checkout version skew",
163
+ ok: true,
164
+ detail: `checkout v${assessment.checkoutVersion} (running CLI version unknown)`,
165
+ };
166
+ }
167
+
168
+ if (!assessment.skewed) {
169
+ return {
170
+ label: "pi-spine checkout version skew",
171
+ ok: true,
172
+ detail: `running and checkout both v${assessment.cliVersion}`,
173
+ };
174
+ }
175
+
176
+ return {
177
+ label: "pi-spine checkout version skew",
178
+ ok: true,
179
+ warning: true,
180
+ detail: `running v${assessment.cliVersion} vs checkout v${assessment.checkoutVersion}`,
181
+ suggestedCommand: formatCheckoutVersionSkewRemediation(),
182
+ };
183
+ }
184
+
85
185
  /**
86
186
  * Platform-aware remediation when duplicate installs diverge.
87
187
  */
@@ -33,7 +33,10 @@ import { buildAgentModelIdsDoctorCheck } from "./agent-models.mjs";
33
33
  import { buildPiExtensionConflictDoctorCheck } from "./pi-extension-conflict.mjs";
34
34
  import { buildSupervisorConfigDoctorCheck } from "./supervisor.mjs";
35
35
  import { buildAttachedOrphanRiskDoctorCheck } from "./attached-orphan-risk.mjs";
36
- import { buildDuplicateInstallDoctorCheck } from "./duplicate-install.mjs";
36
+ import {
37
+ buildCheckoutVersionSkewDoctorCheck,
38
+ buildDuplicateInstallDoctorCheck,
39
+ } from "./duplicate-install.mjs";
37
40
  import { buildPiCliResolutionDoctorCheck } from "./pi-cli-resolution.mjs";
38
41
  import { CURSOR_RULES_ROOT_REL } from "../config/cursor-rules/discover.mjs";
39
42
  import { RULES_PROFILE_REL_PATH } from "../config/cursor-rules/profile.mjs";
@@ -258,6 +261,12 @@ export function runDoctorChecks(projectRoot = process.cwd()) {
258
261
  record("pi installed", commandExists("pi"), { detail: getVersion("pi") });
259
262
  checks.push(buildPiCliResolutionDoctorCheck());
260
263
  checks.push(buildDuplicateInstallDoctorCheck());
264
+ checks.push(
265
+ buildCheckoutVersionSkewDoctorCheck({
266
+ runningPackageRoot: PACKAGE_ROOT,
267
+ projectRoot,
268
+ }),
269
+ );
261
270
  checks.push(buildPiExtensionConflictDoctorCheck({ projectRoot }));
262
271
  checks.push(buildAttachedOrphanRiskDoctorCheck());
263
272
 
@@ -5,6 +5,7 @@
5
5
 
6
6
  import fs from "node:fs";
7
7
  import path from "node:path";
8
+ import { ensureDefaultPiSpineRootEnv } from "../config/pi-spine-root.mjs";
8
9
 
9
10
  /**
10
11
  * @param {string} gitFilePath
@@ -51,6 +52,9 @@ export function buildWorktreeHealthDoctorCheck({ projectRoot, config = {} }) {
51
52
 
52
53
  const hook = config.worktreeSetupHook;
53
54
  const hookConfigured = typeof hook === "string" && hook.trim().length > 0;
55
+ // CLI defaults unset PI_SPINE_ROOT to cwd (SP-643); apply here so doctor
56
+ // library callers get the same behavior without requiring bin/spine.mjs.
57
+ ensureDefaultPiSpineRootEnv();
54
58
  if (!process.env.PI_SPINE_ROOT && hookConfigured) {
55
59
  issues.push("PI_SPINE_ROOT unset with worktreeSetupHook configured");
56
60
  }
@@ -9,8 +9,8 @@
9
9
  },
10
10
  "baseBranch": "main",
11
11
  "testing": {
12
- "build": "npm run typecheck && npm test",
13
- "test": "npm run typecheck && npm test",
12
+ "build": "npm run typecheck",
13
+ "test": "npm test",
14
14
  "testWithCoverage": "npm run coverage:check"
15
15
  },
16
16
  "agents": {
@@ -80,10 +80,11 @@
80
80
  },
81
81
  "_examples": {
82
82
  "worktreeSetupHook": "scripts/spine-worktree-setup-flutter.sh",
83
- "_worktreeSetupHookNote": "Optional Flutter: symlink gitignored pubspec assets from SPINE_PROJECT_ROOT into lane worktrees — see docs/adoption/flutter-worktree-guide.md"
83
+ "_worktreeSetupHookNote": "Optional Flutter: symlink gitignored pubspec assets from SPINE_PROJECT_ROOT into lane worktrees — see docs/adoption/flutter-worktree-guide.md",
84
+ "_testingScriptsNote": "testing.build/test/testWithCoverage may use a relative scripts/*.sh path (validated sandbox, no shell metacharacters); e.g. scripts/run-gate-evidence.sh"
84
85
  },
85
86
  "worktreeSetupHook": "",
86
- "worktreeSetupIgnorePaths": [],
87
+ "worktreeSetupIgnorePaths": [".venv"],
87
88
  "referenceDocs": ["docs/constitution.md"],
88
89
  "standards": [],
89
90
  "neverLoad": []