pi-spine 2.15.0 → 2.17.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 (50) hide show
  1. package/package.json +1 -1
  2. package/skills/create-spine-tasks/SKILL.md +3 -1
  3. package/skills/create-spine-tasks/references/contract-template.md +12 -12
  4. package/skills/create-spine-tasks/references/prompt-template.md +8 -6
  5. package/skills/spine-autonomous-operator/SKILL.md +2 -0
  6. package/skills/spine-autonomous-operator/references/agent-shell-batch-policy.md +1 -1
  7. package/skills/spine-orchestrate-waves/SKILL.md +6 -4
  8. package/skills/spine-orchestrate-waves/references/outer-loop.md +16 -1
  9. package/skills/spine-release-operator/SKILL.md +63 -7
  10. package/skills/spine-release-operator/references/issue-intake-checklist.md +1 -1
  11. package/skills/spine-release-operator/references/pi-async-orchestration.md +2 -1
  12. package/skills/spine-release-operator/references/post-integrate-regression-gate.md +15 -0
  13. package/src/batch/abort.mjs +82 -68
  14. package/src/batch/batch-guards.mjs +14 -0
  15. package/src/batch/batch-meta-reconstruct.mjs +5 -2
  16. package/src/batch/batch-state-lock.mjs +357 -0
  17. package/src/batch/contract-exec.mjs +12 -8
  18. package/src/batch/engine-lanes/merge.mjs +16 -11
  19. package/src/batch/engine-lanes/phase.mjs +45 -0
  20. package/src/batch/engine-lanes/queue.mjs +1 -1
  21. package/src/batch/engine-lanes/review-code.mjs +224 -0
  22. package/src/batch/engine-lanes/review-final.mjs +318 -0
  23. package/src/batch/engine-lanes/review-plan.mjs +315 -0
  24. package/src/batch/engine-lanes/review-poll.mjs +427 -0
  25. package/src/batch/engine-lanes/review-stub.mjs +146 -0
  26. package/src/batch/engine-lanes/review.mjs +4 -1532
  27. package/src/batch/engine-lanes.mjs +9 -37
  28. package/src/batch/engine.mjs +8 -16
  29. package/src/batch/lifecycle.mjs +106 -95
  30. package/src/batch/post-merge-finalize.mjs +128 -0
  31. package/src/batch/post-merge-limbo.mjs +14 -85
  32. package/src/batch/readers/spine-state.mjs +22 -1
  33. package/src/batch/readers/taskplane-state.mjs +22 -1
  34. package/src/batch/reconcile-batch.mjs +1 -1
  35. package/src/batch/resume-common.mjs +1 -1
  36. package/src/batch/resume-multi.mjs +6 -2
  37. package/src/batch/resume.mjs +1 -1
  38. package/src/batch/review-spawn.mjs +4 -3
  39. package/src/batch/state-io.mjs +55 -41
  40. package/src/cli/journal-follow.mjs +3 -1
  41. package/src/cli/lane-logs.mjs +3 -1
  42. package/src/cli/settings-slash.mjs +2 -1
  43. package/src/config/cursor-rules/profile.mjs +5 -1
  44. package/src/config/defaults.mjs +10 -1
  45. package/src/config/settings-fields.mjs +14 -0
  46. package/src/config/worker-context.mjs +2 -1
  47. package/src/planner/file-scope.mjs +109 -7
  48. package/src/tasks/analyze/index.mjs +16 -28
  49. package/src/tasks/packet/parse-prompt.mjs +138 -3
  50. package/src/tasks/validate-contract-warn.mjs +45 -0
@@ -8,7 +8,7 @@ import path from "node:path";
8
8
  import { DEFAULT_TASKS_ROOT } from "../config/spine-init-constants.mjs";
9
9
  import { appendJournalEvent } from "./journal.mjs";
10
10
  import { recomputeTaskCounters } from "./state.mjs";
11
- import { loadTaskFileScopePaths } from "./engine-lanes.mjs";
11
+ import { loadTaskFileScopePaths } from "./engine-lanes/queue.mjs";
12
12
  import { laneWorktreePath } from "./worktree.mjs";
13
13
 
14
14
  /**
@@ -7,10 +7,13 @@ import { loadSpineConfig } from "../config/spine-config-load.mjs";
7
7
  import { DEFAULT_TASKS_ROOT } from "../config/spine-init-constants.mjs";
8
8
  import { resolveTasksRoot } from "../config/spine-preflight-lib.mjs";
9
9
  import { assessWaveMergeEligibility } from "./engine-scope.mjs";
10
- import { mergeWaveLanesToOrch } from "./engine-lanes.mjs";
10
+ import { mergeWaveLanesToOrch } from "./engine-lanes/merge.mjs";
11
11
  import { recordResumePhaseTransition } from "./resume-common.mjs";
12
12
  import { appendJournalEvent, readJournalEvents } from "./journal.mjs";
13
- import { finalizeResumedBatchForIntegrate } from "./post-merge-limbo.mjs";
13
+ import {
14
+ finalizeResumedBatchForIntegrate,
15
+ maybeFinalizeAfterWaveMerge,
16
+ } from "./post-merge-limbo.mjs";
14
17
  import {
15
18
  succeededWaveMergeIndices,
16
19
  waveTasksAllTerminal,
@@ -211,6 +214,7 @@ export async function resumeMultiTaskBatch({ projectRoot, force = false, resumeC
211
214
  orchBranch,
212
215
  waveIndex,
213
216
  resumed: true,
217
+ finalizeAfterWaveMerge: maybeFinalizeAfterWaveMerge,
214
218
  });
215
219
  if (!mergeResult.ok) {
216
220
  return {
@@ -16,7 +16,7 @@ import { finalizeResumedBatchForIntegrate, isPostMergeLimbo } from "./post-merge
16
16
  import { prepareOrphanResumeHandoff } from "./resume-engine.mjs";
17
17
  import { appendJournalEvent, readJournalEvents } from "./journal.mjs";
18
18
  import { commitLaneWorktree, filterPorcelain, gitPorcelain } from "./lane-commit.mjs";
19
- import { mergeLaneToOrch } from "./engine-lanes.mjs";
19
+ import { mergeLaneToOrch } from "./engine-lanes/merge.mjs";
20
20
  import {
21
21
  loadResumeFileScopePaths,
22
22
  recordResumePhaseTransition,
@@ -181,8 +181,9 @@ export function isEarlyArtifactHonorAllowed(reviewType, contractVerifyResult) {
181
181
 
182
182
  /**
183
183
  * @param {object} params
184
+ * @returns {Promise<object>} Resolves with the reviewer spawn result (real async child-process wait).
184
185
  */
185
- export async function spawnReviewerPi({
186
+ export function spawnReviewerPi({
186
187
  worktreePath,
187
188
  taskFolder,
188
189
  reviewPrompt,
@@ -194,11 +195,11 @@ export async function spawnReviewerPi({
194
195
  contractVerifyResult = null,
195
196
  }) {
196
197
  if (!reviewerPiCommandExists("pi")) {
197
- return {
198
+ return Promise.resolve({
198
199
  spawnFailed: true,
199
200
  exitCode: 127,
200
201
  error: "pi not available for reviewer spawn",
201
- };
202
+ });
202
203
  }
203
204
 
204
205
  const piArgs = buildReviewerPiArgs({
@@ -6,6 +6,7 @@
6
6
  import fs from "node:fs";
7
7
  import path from "node:path";
8
8
  import { writeJsonAtomic } from "../fs/atomic-write.mjs";
9
+ import { withBatchStateLock } from "./batch-state-lock.mjs";
9
10
  import {
10
11
  clearBatchEnginePid,
11
12
  evaluateBatchStateWriteGuard,
@@ -52,27 +53,35 @@ function archivedBatchStatePath(projectRoot, batchId) {
52
53
  }
53
54
 
54
55
  /**
56
+ * Persist batch state under the global batch-state lock (SP-722 / #264).
57
+ *
58
+ * The guard evaluation and the write run inside one critical section so the
59
+ * check-then-act pair cannot race a concurrent writer from another process
60
+ * (engine vs. CLI complete/resume/abort).
61
+ *
55
62
  * @param {string} projectRoot
56
63
  * @param {object} state
57
64
  * @param {{ bypassWriteGuard?: boolean }} [options]
58
65
  */
59
66
  export function saveSpineBatchState(projectRoot, state, options = {}) {
60
- const guard = options.bypassWriteGuard
61
- ? { allowed: true }
62
- : evaluateBatchStateWriteGuard(projectRoot, state);
63
- if (!guard.allowed) {
64
- const loaded = loadSpineBatchState(projectRoot);
65
- return loaded.raw ?? state;
66
- }
67
+ return withBatchStateLock(projectRoot, () => {
68
+ const guard = options.bypassWriteGuard
69
+ ? { allowed: true }
70
+ : evaluateBatchStateWriteGuard(projectRoot, state);
71
+ if (!guard.allowed) {
72
+ const loaded = loadSpineBatchState(projectRoot);
73
+ return loaded.raw ?? state;
74
+ }
67
75
 
68
- const filePath = spineBatchStatePath(projectRoot);
69
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
70
- if (TERMINAL_BATCH_PHASES.has(String(state.phase ?? ""))) {
71
- clearBatchEnginePid(state);
72
- }
73
- const next = { ...state, updatedAt: Date.now() };
74
- writeJsonAtomic(filePath, next);
75
- return next;
76
+ const filePath = spineBatchStatePath(projectRoot);
77
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
78
+ if (TERMINAL_BATCH_PHASES.has(String(state.phase ?? ""))) {
79
+ clearBatchEnginePid(state);
80
+ }
81
+ const next = { ...state, updatedAt: Date.now() };
82
+ writeJsonAtomic(filePath, next);
83
+ return next;
84
+ });
76
85
  }
77
86
 
78
87
  /**
@@ -151,43 +160,48 @@ function quarantineCorruptBatchHistory(projectRoot, filePath, reason) {
151
160
  }
152
161
 
153
162
  /**
154
- * Append an entry to `.spine/batch-history.json` atomically.
163
+ * Append an entry to `.spine/batch-history.json` atomically under the
164
+ * global batch-state lock (SP-722 / #264).
155
165
  *
156
166
  * The write goes through `writeJsonAtomic` (temp file + rename) so a crash or
157
167
  * concurrent reader never observes a truncated history (#261). A corrupt
158
- * existing file is quarantined, never silently reset to `[]`.
168
+ * existing file is quarantined, never silently reset to `[]`. The full
169
+ * read-modify-write runs under the same lock as batch-state writes so
170
+ * concurrent processes cannot lose history entries.
159
171
  *
160
172
  * @param {string} projectRoot
161
173
  * @param {object} entry
162
174
  */
163
175
  export function appendBatchHistoryEntry(projectRoot, entry) {
164
- const filePath = batchHistoryPath(projectRoot);
165
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
166
-
167
- /** @type {object[]} */
168
- let history = [];
169
- if (fs.existsSync(filePath)) {
170
- try {
171
- const parsed = JSON.parse(fs.readFileSync(filePath, "utf-8"));
172
- if (Array.isArray(parsed)) {
173
- history = parsed;
174
- } else {
175
- if (quarantineCorruptBatchHistory(projectRoot, filePath, "root value is not an array") === null) {
176
- throw new Error(`Refusing to append batch history: ${filePath} is corrupt and could not be quarantined`);
176
+ return withBatchStateLock(projectRoot, () => {
177
+ const filePath = batchHistoryPath(projectRoot);
178
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
179
+
180
+ /** @type {object[]} */
181
+ let history = [];
182
+ if (fs.existsSync(filePath)) {
183
+ try {
184
+ const parsed = JSON.parse(fs.readFileSync(filePath, "utf-8"));
185
+ if (Array.isArray(parsed)) {
186
+ history = parsed;
187
+ } else {
188
+ if (quarantineCorruptBatchHistory(projectRoot, filePath, "root value is not an array") === null) {
189
+ throw new Error(`Refusing to append batch history: ${filePath} is corrupt and could not be quarantined`);
190
+ }
177
191
  }
178
- }
179
- } catch (err) {
180
- if (err instanceof SyntaxError) {
181
- if (quarantineCorruptBatchHistory(projectRoot, filePath, err.message) === null) {
182
- throw new Error(`Refusing to append batch history: ${filePath} is corrupt and could not be quarantined`);
192
+ } catch (err) {
193
+ if (err instanceof SyntaxError) {
194
+ if (quarantineCorruptBatchHistory(projectRoot, filePath, err.message) === null) {
195
+ throw new Error(`Refusing to append batch history: ${filePath} is corrupt and could not be quarantined`);
196
+ }
197
+ } else {
198
+ throw err;
183
199
  }
184
- } else {
185
- throw err;
186
200
  }
187
201
  }
188
- }
189
202
 
190
- history.push(entry);
191
- writeJsonAtomic(filePath, history);
192
- return filePath;
203
+ history.push(entry);
204
+ writeJsonAtomic(filePath, history);
205
+ return filePath;
206
+ });
193
207
  }
@@ -157,8 +157,10 @@ const defaultDeps = {
157
157
  * @param {string[]} [options.args]
158
158
  * @param {boolean} [options.follow]
159
159
  * @param {typeof defaultDeps} [options.deps]
160
+ * @returns {{ exitCode: number, output: string } | Promise<{ exitCode: number, output: string }>}
161
+ * Plain result for the non-follow path; a Promise that resolves on SIGINT/SIGTERM when following.
160
162
  */
161
- export async function runJournalFollow(options) {
163
+ export function runJournalFollow(options) {
162
164
  const { projectRoot, args = [], follow = true, deps = defaultDeps } = options;
163
165
  const { batchId: argBatchId, laneId, json } = parseJournalFollowArgs(args);
164
166
  let batchId = null;
@@ -190,8 +190,10 @@ const defaultDeps = {
190
190
  * @param {string[]} [options.args]
191
191
  * @param {boolean} [options.follow]
192
192
  * @param {typeof defaultDeps} [options.deps]
193
+ * @returns {{ exitCode: number, output: string } | Promise<{ exitCode: number, output: string }>}
194
+ * Plain result for the non-follow path; a Promise that resolves on SIGINT/SIGTERM when following.
193
195
  */
194
- export async function runLaneLogs(options) {
196
+ export function runLaneLogs(options) {
195
197
  const { projectRoot, args = [], follow: followOverride, deps = defaultDeps } = options;
196
198
  const { batchId: argBatchId, laneNumber, taskId: argTaskId, follow: argFollow } =
197
199
  parseLaneLogsArgs(args);
@@ -66,8 +66,9 @@ function parseSetArgs(argsText) {
66
66
  * @param {string} args
67
67
  * @param {{ notify: (message: string, level: string) => void }} ui
68
68
  * @param {string} [cwd]
69
+ * @returns {void}
69
70
  */
70
- export async function runSpineSettingsSlash(args, ui, cwd = process.cwd()) {
71
+ export function runSpineSettingsSlash(args, ui, cwd = process.cwd()) {
71
72
  const trimmed = args.trim();
72
73
 
73
74
  if (trimmed === "set" || trimmed.startsWith("set ")) {
@@ -374,11 +374,15 @@ export function mergeRulesProfile(defaults, fileProfile) {
374
374
  function normalizeRulePaths(paths) {
375
375
  /** @type {string[]} */
376
376
  const seen = [];
377
+ // Set-backed membership so dedup is O(1) per entry instead of O(N) (#271);
378
+ // `seen` keeps first-seen order for the return value.
379
+ const seenSet = new Set();
377
380
  for (const entry of paths) {
378
381
  const normalized = entry.trim().replace(/\\/g, "/").replace(/^\.\/+/, "");
379
- if (!normalized || seen.includes(normalized)) {
382
+ if (!normalized || seenSet.has(normalized)) {
380
383
  continue;
381
384
  }
385
+ seenSet.add(normalized);
382
386
  seen.push(normalized);
383
387
  }
384
388
  return seen;
@@ -5,10 +5,19 @@
5
5
 
6
6
  import { ORCHESTRATOR_DEFAULTS } from "./spine-config-schema.mjs";
7
7
 
8
- /** @type {Readonly<{ requireFinalVerdict: boolean; maxFinalAttempts: number }>} */
8
+ /**
9
+ * `maxCodeReviewAttempts` / `maxPlanReviewAttempts` default to `null` (= unset), which
10
+ * falls back to `maxFinalAttempts` at the phase runners (SP-725 / #265). Numeric defaults
11
+ * here would be merged into every loaded config by `applyConfigDefaults` and silently
12
+ * clobber a custom `maxFinalAttempts`, so `null` keeps existing configs behavior-identical.
13
+ *
14
+ * @type {Readonly<{ requireFinalVerdict: boolean; maxFinalAttempts: number; maxCodeReviewAttempts: number | null; maxPlanReviewAttempts: number | null }>}
15
+ */
9
16
  export const REVIEW_DEFAULTS = Object.freeze({
10
17
  requireFinalVerdict: true,
11
18
  maxFinalAttempts: 3,
19
+ maxCodeReviewAttempts: null,
20
+ maxPlanReviewAttempts: null,
12
21
  });
13
22
 
14
23
  /** @type {Readonly<{ path: string; autoWriteOn: readonly string[] }>} */
@@ -48,6 +48,20 @@ export const SETTINGS_FIELDS = Object.freeze([
48
48
  label: "Require gate before integrate",
49
49
  type: "boolean",
50
50
  },
51
+ {
52
+ path: "review.maxCodeReviewAttempts",
53
+ label: "Max code review attempts (unset inherits maxFinalAttempts)",
54
+ type: "number",
55
+ min: 1,
56
+ max: 10,
57
+ },
58
+ {
59
+ path: "review.maxPlanReviewAttempts",
60
+ label: "Max plan review attempts (unset inherits maxFinalAttempts)",
61
+ type: "number",
62
+ min: 1,
63
+ max: 10,
64
+ },
51
65
  {
52
66
  path: "agents.worker.model",
53
67
  label: "Worker model",
@@ -223,8 +223,9 @@ export function emitWorkerRulesSelected(journal, payload) {
223
223
  * @param {string[]} [params.taskFileScope]
224
224
  * @param {number} [params.byteCap]
225
225
  * @param {WorkerRulesJournalContext} [params.journal]
226
+ * @returns {{ text: string, entries: object[], truncated: boolean, skipped: string[], bytesUsed: number, byteCap: number, selection: object, error?: string, blockedPath?: string }}
226
227
  */
227
- export async function buildWorkerContextAsync({
228
+ export function buildWorkerContextAsync({
228
229
  config = {},
229
230
  projectRoot = process.cwd(),
230
231
  taskFileScope = [],
@@ -15,6 +15,7 @@ const PROBE_BASENAME = '__probe__';
15
15
  const SYNTHETIC_PROBE_EXTENSIONS = Object.freeze([
16
16
  '.mjs',
17
17
  '.js',
18
+ '.cjs',
18
19
  '.ts',
19
20
  '.tsx',
20
21
  '.swift',
@@ -23,8 +24,90 @@ const SYNTHETIC_PROBE_EXTENSIONS = Object.freeze([
23
24
  '.java',
24
25
  '.rs',
25
26
  '.md',
27
+ '.json',
28
+ '.yaml',
29
+ '.yml',
26
30
  ]);
27
31
 
32
+ /**
33
+ * Cap on brace-expanded variants per scope entry. Bounds the synthetic probe
34
+ * count so wide `{a,b,c,...}` scopes cannot cause probe storms on large repos.
35
+ */
36
+ const MAX_BRACE_EXPANSIONS = 32;
37
+
38
+ /**
39
+ * Expand `{a,b}` brace groups into concrete entry variants (micromatch-style).
40
+ * Nested groups are expanded recursively; expansion stops at
41
+ * MAX_BRACE_EXPANSIONS so probe generation stays bounded.
42
+ *
43
+ * @param {string} entry
44
+ * @returns {string[]}
45
+ */
46
+ function expandBracePattern(entry) {
47
+ /** @type {string[]} */
48
+ const results = [];
49
+
50
+ /** @param {string} text */
51
+ const visit = (text) => {
52
+ if (results.length >= MAX_BRACE_EXPANSIONS) return;
53
+
54
+ const start = text.indexOf('{');
55
+ if (start === -1) {
56
+ results.push(text);
57
+ return;
58
+ }
59
+
60
+ // Find the matching closing brace for the first group.
61
+ let depth = 0;
62
+ let end = -1;
63
+ for (let i = start; i < text.length; i++) {
64
+ if (text[i] === '{') depth++;
65
+ else if (text[i] === '}') {
66
+ depth--;
67
+ if (depth === 0) {
68
+ end = i;
69
+ break;
70
+ }
71
+ }
72
+ }
73
+ if (end === -1) {
74
+ // Unbalanced brace — treat as a literal character.
75
+ results.push(text);
76
+ return;
77
+ }
78
+
79
+ // Split the group body on top-level commas.
80
+ /** @type {string[]} */
81
+ const parts = [];
82
+ let last = start + 1;
83
+ depth = 0;
84
+ for (let i = start + 1; i < end; i++) {
85
+ const ch = text[i];
86
+ if (ch === '{') depth++;
87
+ else if (ch === '}') depth--;
88
+ else if (ch === ',' && depth === 0) {
89
+ parts.push(text.slice(last, i));
90
+ last = i + 1;
91
+ }
92
+ }
93
+ parts.push(text.slice(last, end));
94
+
95
+ if (parts.length <= 1) {
96
+ // `{a}` is not a brace set — keep the text as-is.
97
+ results.push(text);
98
+ return;
99
+ }
100
+
101
+ for (const part of parts) {
102
+ visit(text.slice(0, start) + part + text.slice(end + 1));
103
+ if (results.length >= MAX_BRACE_EXPANSIONS) return;
104
+ }
105
+ };
106
+
107
+ visit(entry);
108
+ return results;
109
+ }
110
+
28
111
  /**
29
112
  * @param {string} raw: raw File Scope path or glob from PROMPT.md
30
113
  * @returns {string|null}
@@ -66,15 +149,12 @@ function normalizeScopeEntry(raw) {
66
149
  }
67
150
 
68
151
  /**
69
- * Expand a single File Scope entry into concrete paths for glob overlap probes.
152
+ * Expand one brace-free scope entry into concrete probe paths.
70
153
  *
71
- * @param {string} raw
154
+ * @param {string} entry: normalized scope entry (no leading `./`)
72
155
  * @returns {string[]}
73
156
  */
74
- function expandScopeEntryProbes(raw) {
75
- const entry = normalizeScopeEntry(raw);
76
- if (!entry) return [];
77
-
157
+ function expandSingleEntryProbes(entry) {
78
158
  /** @type {Set<string>} */
79
159
  const probes = new Set([entry]);
80
160
 
@@ -110,6 +190,28 @@ function expandScopeEntryProbes(raw) {
110
190
  return [...probes];
111
191
  }
112
192
 
193
+ /**
194
+ * Expand a single File Scope entry into concrete paths for glob overlap probes.
195
+ * Brace groups (`{a,b}`) are expanded first so probes cover every alternative.
196
+ *
197
+ * @param {string} raw
198
+ * @returns {string[]}
199
+ */
200
+ function expandScopeEntryProbes(raw) {
201
+ const entry = normalizeScopeEntry(raw);
202
+ if (!entry) return [];
203
+
204
+ /** @type {Set<string>} */
205
+ const probes = new Set();
206
+ for (const variant of expandBracePattern(entry)) {
207
+ for (const probe of expandSingleEntryProbes(variant)) {
208
+ probes.add(probe);
209
+ }
210
+ }
211
+
212
+ return [...probes];
213
+ }
214
+
113
215
  /**
114
216
  * @param {string[]} fileScope
115
217
  * @returns {string[]}
@@ -136,7 +238,7 @@ export function expandFileScopeProbes(fileScope) {
136
238
  * @returns {boolean}
137
239
  */
138
240
  function patternHasGlobMeta(pattern) {
139
- return /[*?[\\]/.test(pattern);
241
+ return /[*?[\\]{}]/.test(pattern);
140
242
  }
141
243
 
142
244
  /**
@@ -17,6 +17,10 @@ import path from 'node:path';
17
17
  import { resolveTasksRootPath } from '../../config/env-overrides.mjs';
18
18
  import { loadSpineConfig } from '../../config/spine-config-load.mjs';
19
19
  import { findCyclePath } from '../../planner/cycles.mjs';
20
+ import {
21
+ fileScopesOverlap as plannerFileScopesOverlap,
22
+ pathsOverlap as plannerPathsOverlap,
23
+ } from '../../planner/file-scope.mjs';
20
24
  import { buildGraph, topoWaves } from '../../planner/graph.mjs';
21
25
  import { parseScope } from '../../planner/scope.mjs';
22
26
  import {
@@ -39,46 +43,28 @@ import {
39
43
  * }} AnalyzeFinding
40
44
  */
41
45
 
42
- function normalizeFileScopePath(p) {
43
- let s = String(p ?? '').trim();
44
- if (!s) return null;
45
-
46
- s = s.replace(/\\/g, '/');
47
- if (s.startsWith('./')) s = s.slice(2);
48
- s = s.replace(/\/+$/g, '');
49
-
50
- if (s.endsWith('/*')) s = s.slice(0, -2);
51
- if (s.endsWith('/**')) s = s.slice(0, -3);
52
-
53
- return s || null;
54
- }
55
-
56
46
  /**
47
+ * Re-exported from the planner so `spine tasks analyze` uses the same
48
+ * glob-aware overlap detection (brace globs and extension probes, #269).
49
+ *
57
50
  * @param {string} a
58
51
  * @param {string} b
59
52
  * @returns {boolean}
60
53
  */
61
54
  export function pathsOverlap(a, b) {
62
- if (a === b) return true;
63
- return a.startsWith(b + '/') || b.startsWith(a + '/');
55
+ return plannerPathsOverlap(a, b);
64
56
  }
65
57
 
66
58
  /**
59
+ * Re-exported from the planner so `spine tasks analyze` flags the same brace
60
+ * glob and extension collisions as the wave planner (#269).
61
+ *
67
62
  * @param {string[]} left
68
63
  * @param {string[]} right
69
64
  * @returns {boolean}
70
65
  */
71
66
  export function fileScopesOverlap(left, right) {
72
- const leftPaths = left.map(normalizeFileScopePath).filter(Boolean);
73
- const rightPaths = right.map(normalizeFileScopePath).filter(Boolean);
74
-
75
- for (const a of leftPaths) {
76
- for (const b of rightPaths) {
77
- if (pathsOverlap(a, b)) return true;
78
- }
79
- }
80
-
81
- return false;
67
+ return plannerFileScopesOverlap(left, right);
82
68
  }
83
69
 
84
70
  /**
@@ -274,7 +260,8 @@ export function collectPromptJsonDepsDriftFindings(tasksById, depsJson) {
274
260
  continue;
275
261
  }
276
262
 
277
- const missing = promptDeps.filter((depId) => !jsonDeps.includes(depId));
263
+ const jsonDepSet = new Set(jsonDeps);
264
+ const missing = promptDeps.filter((depId) => !jsonDepSet.has(depId));
278
265
  if (missing.length === 0) continue;
279
266
 
280
267
  findings.push({
@@ -347,8 +334,9 @@ function throwAnalyzeError(message, { suggestedCommand, exitCode = 2 } = {}) {
347
334
 
348
335
  /**
349
336
  * @param {{ projectRoot?: string, scope?: string }} [args]
337
+ * @returns {{ scope: ReturnType<typeof parseScope>, result: object, output: string, exitCode: number }}
350
338
  */
351
- export async function analyzeTasksScope({ projectRoot = process.cwd(), scope = 'all' } = {}) {
339
+ export function analyzeTasksScope({ projectRoot = process.cwd(), scope = 'all' } = {}) {
352
340
  const configResult = loadSpineConfig(projectRoot);
353
341
  if (configResult.error) {
354
342
  throwAnalyzeError(configResult.error.message, {