pi-spine 2.15.0 → 2.16.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/package.json +1 -1
- package/skills/spine-release-operator/SKILL.md +60 -7
- package/skills/spine-release-operator/references/issue-intake-checklist.md +1 -1
- package/skills/spine-release-operator/references/post-integrate-regression-gate.md +1 -0
- package/src/batch/abort.mjs +82 -68
- package/src/batch/batch-state-lock.mjs +357 -0
- package/src/batch/contract-exec.mjs +12 -8
- package/src/batch/engine-lanes/review-code.mjs +224 -0
- package/src/batch/engine-lanes/review-final.mjs +318 -0
- package/src/batch/engine-lanes/review-plan.mjs +315 -0
- package/src/batch/engine-lanes/review-poll.mjs +427 -0
- package/src/batch/engine-lanes/review-stub.mjs +146 -0
- package/src/batch/engine-lanes/review.mjs +4 -1532
- package/src/batch/lifecycle.mjs +106 -95
- package/src/batch/state-io.mjs +55 -41
- package/src/config/cursor-rules/profile.mjs +5 -1
- package/src/config/defaults.mjs +10 -1
- package/src/config/settings-fields.mjs +14 -0
- package/src/planner/file-scope.mjs +109 -7
- package/src/tasks/analyze/index.mjs +14 -27
- package/src/tasks/packet/parse-prompt.mjs +138 -3
package/src/batch/lifecycle.mjs
CHANGED
|
@@ -21,6 +21,7 @@ import { appendJournalEvent } from "./journal.mjs";
|
|
|
21
21
|
import { recordBatchTerminalMetric } from "./metrics.mjs";
|
|
22
22
|
import { writeBatchPostMortem } from "./postmortem.mjs";
|
|
23
23
|
import { appendBatchHistoryEntry, clearBatchEnginePid, saveSpineBatchState } from "./state.mjs";
|
|
24
|
+
import { withBatchStateLock } from "./batch-state-lock.mjs";
|
|
24
25
|
import { loadBatchStateFile, parseBatchState, reconcileBatch } from "./reconcile.mjs";
|
|
25
26
|
import { readAliveBatchEnginePid } from "./batch-state-io.mjs";
|
|
26
27
|
import { terminateLaneWorkers } from "./worker-host.mjs";
|
|
@@ -206,55 +207,60 @@ export function dismissBatch(ctx) {
|
|
|
206
207
|
force,
|
|
207
208
|
});
|
|
208
209
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
endedAt
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
210
|
+
// Terminal dismiss write section under the global batch-state lock
|
|
211
|
+
// (SP-722 / #264): archive, history entry, and clearing the active state
|
|
212
|
+
// must not interleave with a concurrent engine save or resume writer.
|
|
213
|
+
return withBatchStateLock(projectRoot, () => {
|
|
214
|
+
const archivePath = archiveBatchState(projectRoot, batchId, loaded.raw);
|
|
215
|
+
const postMortemPath = writeBatchPostMortem({
|
|
216
|
+
projectRoot,
|
|
217
|
+
batchState: loaded.raw,
|
|
218
|
+
reconciliation,
|
|
219
|
+
});
|
|
220
|
+
const endedAt = Date.now();
|
|
221
|
+
appendBatchHistoryEntry(projectRoot, {
|
|
222
|
+
batchId,
|
|
223
|
+
action: "dismissed",
|
|
224
|
+
endedAt,
|
|
225
|
+
diagnosis,
|
|
226
|
+
reason: reason ?? null,
|
|
227
|
+
archivePath: path.relative(projectRoot, archivePath),
|
|
228
|
+
postMortemPath,
|
|
229
|
+
});
|
|
230
|
+
appendJournalEvent(projectRoot, batchId, "batch.dismissed", {
|
|
231
|
+
diagnosis,
|
|
232
|
+
reason: reason ?? null,
|
|
233
|
+
archivePath: path.relative(projectRoot, archivePath),
|
|
234
|
+
});
|
|
235
|
+
const configResult = loadSpineConfig(projectRoot);
|
|
236
|
+
const config = configResult.config ?? {};
|
|
237
|
+
recordBatchTerminalMetric({
|
|
238
|
+
projectRoot,
|
|
239
|
+
batchId,
|
|
240
|
+
batchState: { ...loaded.raw, endedAt },
|
|
241
|
+
diagnosis: diagnosis ?? "dismissed",
|
|
242
|
+
config,
|
|
243
|
+
});
|
|
244
|
+
cleanupBatchLaneWorktrees({
|
|
245
|
+
projectRoot,
|
|
246
|
+
batchId,
|
|
247
|
+
batchState: loaded.raw,
|
|
248
|
+
config,
|
|
249
|
+
});
|
|
250
|
+
clearCompletedBatchState(loaded.path, batchId);
|
|
251
|
+
bumpDashboardInvalidateSignal(projectRoot, "batch_dismiss", batchId);
|
|
247
252
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
253
|
+
return {
|
|
254
|
+
ok: true,
|
|
255
|
+
exitCode: 0,
|
|
256
|
+
batchId,
|
|
257
|
+
diagnosis,
|
|
258
|
+
headline: `Batch ${batchId} dismissed and archived`,
|
|
259
|
+
suggestedCommand: "spine preflight",
|
|
260
|
+
alternatives: ["spine plan all"],
|
|
261
|
+
archivePath,
|
|
262
|
+
};
|
|
263
|
+
});
|
|
258
264
|
}
|
|
259
265
|
|
|
260
266
|
/**
|
|
@@ -407,52 +413,57 @@ export function completeBatch(ctx) {
|
|
|
407
413
|
|
|
408
414
|
terminateSupervisorIfRunning(projectRoot, batchId, "batch_complete");
|
|
409
415
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
endedAt
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
416
|
+
// Terminal complete write section under the global batch-state lock
|
|
417
|
+
// (SP-722 / #264): archive, history entry, and clearing the active state
|
|
418
|
+
// must not interleave with a concurrent engine save or resume writer.
|
|
419
|
+
return withBatchStateLock(projectRoot, () => {
|
|
420
|
+
const archivePath = archiveBatchState(projectRoot, batchId, loaded.raw);
|
|
421
|
+
const postMortemPath = writeBatchPostMortem({
|
|
422
|
+
projectRoot,
|
|
423
|
+
batchState: loaded.raw,
|
|
424
|
+
reconciliation,
|
|
425
|
+
});
|
|
426
|
+
const endedAt = Date.now();
|
|
427
|
+
appendBatchHistoryEntry(projectRoot, {
|
|
428
|
+
batchId,
|
|
429
|
+
action: "completed",
|
|
430
|
+
endedAt,
|
|
431
|
+
diagnosis: "completed",
|
|
432
|
+
detectManualMerge,
|
|
433
|
+
archivePath: path.relative(projectRoot, archivePath),
|
|
434
|
+
postMortemPath,
|
|
435
|
+
});
|
|
436
|
+
appendJournalEvent(projectRoot, batchId, "batch.completed", {
|
|
437
|
+
detectManualMerge,
|
|
438
|
+
archivePath: path.relative(projectRoot, archivePath),
|
|
439
|
+
lifecycle: "complete",
|
|
440
|
+
});
|
|
441
|
+
const configResult = loadSpineConfig(projectRoot);
|
|
442
|
+
const config = configResult.config ?? {};
|
|
443
|
+
recordBatchTerminalMetric({
|
|
444
|
+
projectRoot,
|
|
445
|
+
batchId,
|
|
446
|
+
batchState: { ...loaded.raw, endedAt },
|
|
447
|
+
diagnosis: "completed",
|
|
448
|
+
config,
|
|
449
|
+
});
|
|
450
|
+
cleanupBatchLaneWorktrees({
|
|
451
|
+
projectRoot,
|
|
452
|
+
batchId,
|
|
453
|
+
batchState: loaded.raw,
|
|
454
|
+
config,
|
|
455
|
+
});
|
|
456
|
+
clearCompletedBatchState(loaded.path, batchId);
|
|
447
457
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
+
return {
|
|
459
|
+
ok: true,
|
|
460
|
+
exitCode: 0,
|
|
461
|
+
batchId,
|
|
462
|
+
diagnosis: "completed",
|
|
463
|
+
headline: `Batch ${batchId} completed and archived`,
|
|
464
|
+
suggestedCommand: "spine preflight",
|
|
465
|
+
alternatives: ["spine plan all"],
|
|
466
|
+
archivePath,
|
|
467
|
+
};
|
|
468
|
+
});
|
|
458
469
|
}
|
package/src/batch/state-io.mjs
CHANGED
|
@@ -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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
203
|
+
history.push(entry);
|
|
204
|
+
writeJsonAtomic(filePath, history);
|
|
205
|
+
return filePath;
|
|
206
|
+
});
|
|
193
207
|
}
|
|
@@ -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 ||
|
|
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;
|
package/src/config/defaults.mjs
CHANGED
|
@@ -5,10 +5,19 @@
|
|
|
5
5
|
|
|
6
6
|
import { ORCHESTRATOR_DEFAULTS } from "./spine-config-schema.mjs";
|
|
7
7
|
|
|
8
|
-
/**
|
|
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",
|
|
@@ -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
|
|
152
|
+
* Expand one brace-free scope entry into concrete probe paths.
|
|
70
153
|
*
|
|
71
|
-
* @param {string}
|
|
154
|
+
* @param {string} entry: normalized scope entry (no leading `./`)
|
|
72
155
|
* @returns {string[]}
|
|
73
156
|
*/
|
|
74
|
-
function
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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({
|