@planu/cli 5.7.6 → 5.7.8
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/CHANGELOG.md +31 -0
- package/dist/.planu-build.json +1 -1
- package/dist/config/hook-templates/planu-review-panel-trigger.sh +2 -3
- package/dist/config/skill-templates/planu-multi-teammate-review.md +7 -11
- package/dist/engine/evidence-gates/evidence-skeletons.js +3 -1
- package/dist/engine/execution/job-runtime.d.ts +7 -3
- package/dist/engine/execution/job-runtime.js +18 -6
- package/dist/engine/execution/validate-job-executor.d.ts +2 -0
- package/dist/engine/execution/validate-job-executor.js +25 -0
- package/dist/engine/readiness-checker.js +17 -6
- package/dist/engine/reconcile/propagate-mirrors.js +6 -6
- package/dist/engine/spec-format/lean-spec-generator.js +2 -2
- package/dist/engine/spec-grounding/contract.d.ts +3 -3
- package/dist/engine/spec-grounding/contract.js +23 -76
- package/dist/engine/spec-grounding/grounding-entry-parser.d.ts +5 -0
- package/dist/engine/spec-grounding/grounding-entry-parser.js +185 -0
- package/dist/storage/runtime-db.d.ts +4 -2
- package/dist/storage/runtime-db.js +50 -12
- package/dist/storage/spec-store.d.ts +2 -1
- package/dist/storage/spec-store.js +28 -3
- package/dist/tools/bump-spec-version.js +5 -5
- package/dist/tools/create-spec.js +4 -1
- package/dist/tools/init-project/skills-multi-teammate-review-writer.js +1 -1
- package/dist/tools/jobs/handlers.js +18 -11
- package/dist/tools/list-specs.js +33 -15
- package/dist/tools/multi-teammate-review.js +1 -14
- package/dist/tools/register-platform-tools/design-stack-tools.js +3 -3
- package/dist/tools/register-spec-tools/analysis-tools.js +22 -9
- package/dist/tools/register-spec-tools/core-spec-tools.js +97 -43
- package/dist/tools/schemas/output-schemas.d.ts +14 -0
- package/dist/tools/schemas/output-schemas.js +14 -0
- package/dist/tools/schemas/package-handoff-output-schema.d.ts +1 -0
- package/dist/tools/schemas/package-handoff-output-schema.js +3 -1
- package/dist/tools/schemas/validate-output-schema.d.ts +1 -0
- package/dist/tools/schemas/validate-output-schema.js +3 -1
- package/dist/tools/sync-spec-state-handler.js +92 -23
- package/dist/tools/tool-registry/core-tools.js +71 -24
- package/dist/tools/tool-registry/group-quality-compliance.js +11 -14
- package/dist/tools/tool-registry-helpers.js +6 -2
- package/dist/types/durable-job.d.ts +1 -0
- package/dist/types/spec/core.d.ts +4 -0
- package/dist/types/spec-grounding.d.ts +14 -0
- package/package.json +3 -3
- package/planu-plugin.json +1 -1
- package/dist/tools/tool-registry/deprecated-stubs.d.ts +0 -19
- package/dist/tools/tool-registry/deprecated-stubs.js +0 -65
|
@@ -67,17 +67,17 @@ export function registerDesignStackTools(server) {
|
|
|
67
67
|
description: t('tools.challenge_spec.description'),
|
|
68
68
|
annotations: { readOnlyHint: true },
|
|
69
69
|
inputSchema: {
|
|
70
|
-
specId: SpecIdSchema.describe('Spec ID to challenge'),
|
|
70
|
+
specId: SpecIdSchema.describe('Spec ID to challenge. Must match pattern ^SPEC-\\d+$, max 50 characters.'),
|
|
71
71
|
projectId: z
|
|
72
72
|
.string()
|
|
73
73
|
.max(500)
|
|
74
74
|
.optional()
|
|
75
|
-
.describe('Project ID hash. Prefer projectPath — stays correct after context compaction.'),
|
|
75
|
+
.describe('Project ID hash. Prefer projectPath — stays correct after context compaction. Max 500 characters.'),
|
|
76
76
|
projectPath: z
|
|
77
77
|
.string()
|
|
78
78
|
.max(4096)
|
|
79
79
|
.optional()
|
|
80
|
-
.describe('Absolute path to project root. Derives projectId automatically — always correct even after context compaction.'),
|
|
80
|
+
.describe('Max 4096 characters. Absolute path to project root. Derives projectId automatically — always correct even after context compaction.'),
|
|
81
81
|
focus: z
|
|
82
82
|
.array(ChallengeSpecFocusEnum)
|
|
83
83
|
.max(100)
|
|
@@ -26,7 +26,7 @@ export const DeclaredDriftInputSchema = z.object({
|
|
|
26
26
|
.string()
|
|
27
27
|
.min(100)
|
|
28
28
|
.max(10_000)
|
|
29
|
-
.describe('Why the implementation drifted from the approved architectural premise
|
|
29
|
+
.describe('Min 100, max 10000 characters. Why the implementation drifted from the approved architectural premise — becomes the reconciliation transition reason.'),
|
|
30
30
|
});
|
|
31
31
|
import { handleSsrBackMigration } from '../ssr-back-migration.js';
|
|
32
32
|
import { registerMigrateLegacySpecTool } from '../migrate-legacy-spec.js';
|
|
@@ -115,13 +115,17 @@ export function registerAnalysisTools(server) {
|
|
|
115
115
|
server.registerTool('reconcile_spec', {
|
|
116
116
|
description: t('tools.reconcile_spec.description'),
|
|
117
117
|
inputSchema: {
|
|
118
|
-
specId: SpecIdSchema.describe('Spec ID to reconcile'),
|
|
119
|
-
projectId: z
|
|
118
|
+
specId: SpecIdSchema.describe('Spec ID to reconcile. Must match pattern ^SPEC-\\d+$, max 50 characters.'),
|
|
119
|
+
projectId: z
|
|
120
|
+
.string()
|
|
121
|
+
.max(500)
|
|
122
|
+
.optional()
|
|
123
|
+
.describe('Project ID hash. Prefer projectPath. Max 500 characters.'),
|
|
120
124
|
projectPath: z
|
|
121
125
|
.string()
|
|
122
126
|
.max(4096)
|
|
123
127
|
.optional()
|
|
124
|
-
.describe('Absolute path to project root. Derives projectId automatically.'),
|
|
128
|
+
.describe('Absolute path to project root. Derives projectId automatically. Max 4096 characters.'),
|
|
125
129
|
autoDetect: z
|
|
126
130
|
.boolean()
|
|
127
131
|
.optional()
|
|
@@ -132,11 +136,20 @@ export function registerAnalysisTools(server) {
|
|
|
132
136
|
.describe('Enable living spec mode: compare acceptance criteria against codebase, auto-mark criteria as met/pending/drift, update the ## Progress section of spec.md (default: false)'),
|
|
133
137
|
changes: z
|
|
134
138
|
.array(z.object({
|
|
135
|
-
section: z
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
section: z
|
|
140
|
+
.string()
|
|
141
|
+
.max(500)
|
|
142
|
+
.describe('Max 500 characters. Spec section the change applies to.'),
|
|
143
|
+
originalValue: z
|
|
144
|
+
.string()
|
|
145
|
+
.max(10_000)
|
|
146
|
+
.describe('Max 10000 characters. Current text being replaced.'),
|
|
147
|
+
newValue: z.string().max(10_000).describe('Max 10000 characters. Replacement text.'),
|
|
148
|
+
reason: z
|
|
149
|
+
.string()
|
|
150
|
+
.max(10_000)
|
|
151
|
+
.describe('Max 10000 characters. Why the change is needed.'),
|
|
152
|
+
approved: z.boolean().describe('Whether the user approved this change.'),
|
|
140
153
|
}))
|
|
141
154
|
.max(1000)
|
|
142
155
|
.optional()
|
|
@@ -18,7 +18,10 @@ import { handleTypeSafetyGate } from '../type-safety-gate.js';
|
|
|
18
18
|
import { runWithTrustedLocalMcpContext } from '../../engine/lifecycle-reconciliation.js';
|
|
19
19
|
/** init_project inputSchema — extracted to keep registerCoreSpecTools within line budget. */
|
|
20
20
|
const INIT_PROJECT_INPUT_SCHEMA = {
|
|
21
|
-
projectPath: z
|
|
21
|
+
projectPath: z
|
|
22
|
+
.string()
|
|
23
|
+
.max(4096)
|
|
24
|
+
.describe('Absolute path to the project root. Max 4096 characters.'),
|
|
22
25
|
mode: z
|
|
23
26
|
.enum(['existing_project', 'new_project'])
|
|
24
27
|
.optional()
|
|
@@ -27,18 +30,40 @@ const INIT_PROJECT_INPUT_SCHEMA = {
|
|
|
27
30
|
.string()
|
|
28
31
|
.max(4096)
|
|
29
32
|
.optional()
|
|
30
|
-
.describe('Parent workspace path for explicit new_project onboarding'),
|
|
31
|
-
appName: z
|
|
33
|
+
.describe('Parent workspace path for explicit new_project onboarding. Max 4096 characters.'),
|
|
34
|
+
appName: z
|
|
35
|
+
.string()
|
|
36
|
+
.max(500)
|
|
37
|
+
.optional()
|
|
38
|
+
.describe('Human-readable app name for new_project. Max 500 characters.'),
|
|
32
39
|
appSlug: z
|
|
33
40
|
.string()
|
|
34
41
|
.max(200)
|
|
35
42
|
.optional()
|
|
36
|
-
.describe('Safe folder slug for new_project; must not contain path separators'),
|
|
37
|
-
projectType: z
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
.describe('Safe folder slug for new_project; must not contain path separators. Max 200 characters.'),
|
|
44
|
+
projectType: z
|
|
45
|
+
.string()
|
|
46
|
+
.max(500)
|
|
47
|
+
.optional()
|
|
48
|
+
.describe('Type of project being initialized. Max 500 characters.'),
|
|
49
|
+
platform: z
|
|
50
|
+
.string()
|
|
51
|
+
.max(500)
|
|
52
|
+
.optional()
|
|
53
|
+
.describe('Runtime/deployment platform. Max 500 characters.'),
|
|
54
|
+
language: z.string().max(500).optional().describe('User-confirmed language. Max 500 characters.'),
|
|
55
|
+
framework: z
|
|
56
|
+
.string()
|
|
57
|
+
.max(500)
|
|
58
|
+
.nullable()
|
|
59
|
+
.optional()
|
|
60
|
+
.describe('Max 500 characters. User-confirmed framework.'),
|
|
61
|
+
database: z
|
|
62
|
+
.string()
|
|
63
|
+
.max(500)
|
|
64
|
+
.nullable()
|
|
65
|
+
.optional()
|
|
66
|
+
.describe('Max 500 characters. User-confirmed database.'),
|
|
42
67
|
createDirectory: z
|
|
43
68
|
.boolean()
|
|
44
69
|
.optional()
|
|
@@ -162,7 +187,11 @@ export function registerCoreSpecTools(server) {
|
|
|
162
187
|
server.registerTool('create_spec', {
|
|
163
188
|
description: t('tools.create_spec.description'),
|
|
164
189
|
inputSchema: {
|
|
165
|
-
title: z
|
|
190
|
+
title: z
|
|
191
|
+
.string()
|
|
192
|
+
.min(1)
|
|
193
|
+
.max(500)
|
|
194
|
+
.describe('Title of the spec / user story. Max 500 characters.'),
|
|
166
195
|
description: z
|
|
167
196
|
.string()
|
|
168
197
|
.max(10_000)
|
|
@@ -176,21 +205,25 @@ export function registerCoreSpecTools(server) {
|
|
|
176
205
|
.max(128)
|
|
177
206
|
.regex(/^[A-Za-z0-9._:-]+$/)
|
|
178
207
|
.optional()
|
|
179
|
-
.describe('Stable caller key
|
|
208
|
+
.describe('Must match pattern ^[A-Za-z0-9._:-]+$, max 128 characters. Stable caller key — retries return the exact committed create_spec result.'),
|
|
180
209
|
projectPath: z
|
|
181
210
|
.string()
|
|
182
211
|
.max(4096)
|
|
183
212
|
.optional()
|
|
184
|
-
.describe('Absolute path to the project root. Auto-detected from git root when omitted.'),
|
|
213
|
+
.describe('Max 4096 characters. Absolute path to the project root. Auto-detected from git root when omitted.'),
|
|
185
214
|
type: SpecTypeEnum.optional().describe('Spec type (default: feature)'),
|
|
186
215
|
scope: SpecScopeEnum.optional().describe('Spec scope (default: feature)'),
|
|
187
216
|
target: SpecTargetEnum.optional().describe('Target area: frontend, backend, shared, fullstack, infrastructure, database'),
|
|
188
|
-
tags: z
|
|
217
|
+
tags: z
|
|
218
|
+
.array(z.string().max(500))
|
|
219
|
+
.max(100)
|
|
220
|
+
.optional()
|
|
221
|
+
.describe('Tags for categorization. Each tag max 500 characters.'),
|
|
189
222
|
feature: z
|
|
190
223
|
.string()
|
|
191
224
|
.max(500)
|
|
192
225
|
.optional()
|
|
193
|
-
.describe('Feature group tag (e.g. "Authentication", "Billing"). Added to tags for categorization. Flat structure — no subdirectories created.'),
|
|
226
|
+
.describe('Max 500 characters. Feature group tag (e.g. "Authentication", "Billing"). Added to tags for categorization. Flat structure — no subdirectories created.'),
|
|
194
227
|
acFormat: SpecAcFormatEnum.optional().describe('SPEC-224: Format for acceptance criteria in spec.md. ' +
|
|
195
228
|
'checkbox (default) — markdown checkboxes (- [ ] criterion). ' +
|
|
196
229
|
'bdd — Gherkin Given-When-Then scenarios for BDD workflows.'),
|
|
@@ -242,12 +275,12 @@ export function registerCoreSpecTools(server) {
|
|
|
242
275
|
.string()
|
|
243
276
|
.max(500)
|
|
244
277
|
.optional()
|
|
245
|
-
.describe('Project ID (hash). Prefer projectPath if unknown.'),
|
|
278
|
+
.describe('Max 500 characters. Project ID (hash). Prefer projectPath if unknown.'),
|
|
246
279
|
projectPath: z
|
|
247
280
|
.string()
|
|
248
281
|
.max(4096)
|
|
249
282
|
.optional()
|
|
250
|
-
.describe('Absolute path to the project root. Used to derive projectId automatically.'),
|
|
283
|
+
.describe('Max 4096 characters. Absolute path to the project root. Used to derive projectId automatically.'),
|
|
251
284
|
status: SpecStatusEnum.optional().describe('Filter by spec status'),
|
|
252
285
|
type: SpecTypeEnum.optional().describe('Filter by spec type'),
|
|
253
286
|
detail: z
|
|
@@ -275,28 +308,28 @@ export function registerCoreSpecTools(server) {
|
|
|
275
308
|
server.registerTool('update_status', {
|
|
276
309
|
description: t('tools.update_status.description'),
|
|
277
310
|
inputSchema: {
|
|
278
|
-
specId: SpecIdSchema.describe('Spec ID to update'),
|
|
311
|
+
specId: SpecIdSchema.describe('Spec ID to update. Must match pattern ^SPEC-\\d+$ (e.g. SPEC-042), max 50 characters.'),
|
|
279
312
|
projectId: z
|
|
280
313
|
.string()
|
|
281
314
|
.max(500)
|
|
282
315
|
.optional()
|
|
283
|
-
.describe('Project ID (hash). Prefer projectPath if unknown.'),
|
|
316
|
+
.describe('Project ID (hash). Prefer projectPath if unknown. Max 500 characters.'),
|
|
284
317
|
projectPath: z
|
|
285
318
|
.string()
|
|
286
319
|
.max(4096)
|
|
287
320
|
.optional()
|
|
288
|
-
.describe('Absolute path to the project root. Used to derive projectId automatically.'),
|
|
321
|
+
.describe('Absolute path to the project root. Used to derive projectId automatically. Max 4096 characters.'),
|
|
289
322
|
status: SpecStatusEnum.describe('New status'),
|
|
290
323
|
sessionId: z
|
|
291
324
|
.string()
|
|
292
325
|
.max(500)
|
|
293
326
|
.optional()
|
|
294
|
-
.describe('Agent/session ID performing this lifecycle transition.'),
|
|
327
|
+
.describe('Agent/session ID performing this lifecycle transition. Max 500 characters.'),
|
|
295
328
|
modelId: z
|
|
296
329
|
.string()
|
|
297
330
|
.max(500)
|
|
298
331
|
.optional()
|
|
299
|
-
.describe('Concrete model ID used for this transition. Can satisfy SDD model-routing evidence when it maps to the required tier.'),
|
|
332
|
+
.describe('Max 500 characters. Concrete model ID used for this transition. Can satisfy SDD model-routing evidence when it maps to the required tier.'),
|
|
300
333
|
modelTierUsed: z
|
|
301
334
|
.enum(['max', 'implementation', 'review'])
|
|
302
335
|
.optional()
|
|
@@ -305,27 +338,27 @@ export function registerCoreSpecTools(server) {
|
|
|
305
338
|
.string()
|
|
306
339
|
.max(500)
|
|
307
340
|
.optional()
|
|
308
|
-
.describe('SHA-256 hash of the persisted context package used to prove context continuity across agents.'),
|
|
341
|
+
.describe('Max 500 characters. SHA-256 hash of the persisted context package used to prove context continuity across agents.'),
|
|
309
342
|
handoffPath: z
|
|
310
343
|
.string()
|
|
311
344
|
.max(4096)
|
|
312
345
|
.optional()
|
|
313
|
-
.describe('Path to the persisted handoff package generated by package_handoff. Required for implementing/done unless handoffArtifactId is provided.'),
|
|
346
|
+
.describe('Max 4096 characters. Path to the persisted handoff package generated by package_handoff. Required for implementing/done unless handoffArtifactId is provided.'),
|
|
314
347
|
handoffArtifactId: z
|
|
315
348
|
.string()
|
|
316
349
|
.max(500)
|
|
317
350
|
.optional()
|
|
318
|
-
.describe('External handoff artifact ID when the host stores handoff evidence outside the filesystem.'),
|
|
351
|
+
.describe('Max 500 characters. External handoff artifact ID when the host stores handoff evidence outside the filesystem.'),
|
|
319
352
|
reviewedBy: z
|
|
320
353
|
.string()
|
|
321
354
|
.max(500)
|
|
322
355
|
.optional()
|
|
323
|
-
.describe('Reviewer identity/evidence required before status=done.'),
|
|
356
|
+
.describe('Reviewer identity/evidence required before status=done. Max 500 characters.'),
|
|
324
357
|
arbitratedBy: z
|
|
325
358
|
.string()
|
|
326
359
|
.max(500)
|
|
327
360
|
.optional()
|
|
328
|
-
.describe('Arbiter identity/evidence required before status=done.'),
|
|
361
|
+
.describe('Arbiter identity/evidence required before status=done. Max 500 characters.'),
|
|
329
362
|
reconcileRequired: z
|
|
330
363
|
.boolean()
|
|
331
364
|
.optional()
|
|
@@ -339,8 +372,16 @@ export function registerCoreSpecTools(server) {
|
|
|
339
372
|
apiCostUsd: z.number().min(0).optional(),
|
|
340
373
|
humanCostUsd: z.number().min(0).optional(),
|
|
341
374
|
totalCostUsd: z.number().min(0).optional(),
|
|
342
|
-
completedAt: z
|
|
343
|
-
|
|
375
|
+
completedAt: z
|
|
376
|
+
.string()
|
|
377
|
+
.max(500)
|
|
378
|
+
.optional()
|
|
379
|
+
.describe('ISO timestamp. Max 500 characters.'),
|
|
380
|
+
notes: z
|
|
381
|
+
.string()
|
|
382
|
+
.max(10_000)
|
|
383
|
+
.optional()
|
|
384
|
+
.describe('Free-text notes. Max 10000 characters.'),
|
|
344
385
|
})
|
|
345
386
|
.optional()
|
|
346
387
|
.describe('Actual metrics for status = done. All fields optional (SPEC-1356): missing numeric fields default to 0, completedAt/notes are auto-filled when omitted.'),
|
|
@@ -348,7 +389,7 @@ export function registerCoreSpecTools(server) {
|
|
|
348
389
|
.string()
|
|
349
390
|
.max(10_000)
|
|
350
391
|
.optional()
|
|
351
|
-
.describe('Feedback or observations when sending a spec back (e.g., review→draft). Stored in the spec for the implementer to address.'),
|
|
392
|
+
.describe('Max 10000 characters. Feedback or observations when sending a spec back (e.g., review→draft). Stored in the spec for the implementer to address.'),
|
|
352
393
|
force: z
|
|
353
394
|
.boolean()
|
|
354
395
|
.optional()
|
|
@@ -361,7 +402,7 @@ export function registerCoreSpecTools(server) {
|
|
|
361
402
|
.string()
|
|
362
403
|
.max(2000)
|
|
363
404
|
.optional()
|
|
364
|
-
.describe('SPEC-721: Required when forceStatus=true. ≥100 characters explaining why validate gate is bypassed.'),
|
|
405
|
+
.describe('SPEC-721: Required when forceStatus=true. ≥100 and <=2000 characters explaining why validate gate is bypassed.'),
|
|
365
406
|
dry_run: z
|
|
366
407
|
.boolean()
|
|
367
408
|
.optional()
|
|
@@ -370,18 +411,24 @@ export function registerCoreSpecTools(server) {
|
|
|
370
411
|
.string()
|
|
371
412
|
.max(2000)
|
|
372
413
|
.optional()
|
|
373
|
-
.describe('SPEC-733: Required for reverse transitions (done→implementing, discarded→draft)
|
|
414
|
+
.describe('Must be ≥30 and <=2000 chars. SPEC-733: Required for reverse transitions (done→implementing, discarded→draft), explaining why the spec is being reopened.'),
|
|
374
415
|
reconciliationRequestId: z
|
|
375
416
|
.string()
|
|
376
417
|
.regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u)
|
|
377
418
|
.optional()
|
|
378
|
-
.describe('
|
|
379
|
-
|
|
419
|
+
.describe('Must match pattern ^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$ (lowercase UUID). ' +
|
|
420
|
+
'Trusted local MCP only: idempotency key for implementing to review reconciliation.'),
|
|
421
|
+
expectedImplementingTransitionId: z
|
|
422
|
+
.string()
|
|
423
|
+
.max(500)
|
|
424
|
+
.optional()
|
|
425
|
+
.describe('Max 500 characters. Idempotency guard: the transitionId returned by the prior implementing transition.'),
|
|
380
426
|
implementationReviewDigest: z
|
|
381
427
|
.string()
|
|
382
428
|
.regex(/^sha256:[a-f0-9]{64}$/u)
|
|
383
429
|
.optional()
|
|
384
|
-
.describe('
|
|
430
|
+
.describe('Must match pattern ^sha256:[a-f0-9]{64}$ — the literal prefix "sha256:" followed by 64 lowercase hex characters. ' +
|
|
431
|
+
'SHA-256 of the exact validation-report.json bytes. Required implementation evidence for status=done; for status=review it is valid only inside the complete trusted local-MCP reconciliation tuple.'),
|
|
385
432
|
forceApprove: z
|
|
386
433
|
.boolean()
|
|
387
434
|
.optional()
|
|
@@ -391,20 +438,27 @@ export function registerCoreSpecTools(server) {
|
|
|
391
438
|
server.registerTool('update_status_batch', {
|
|
392
439
|
description: 'Batch update many specs to the same status in one MCP execution. Uses the same transition rules as update_status and reports updated/skipped/failed per spec.',
|
|
393
440
|
inputSchema: {
|
|
394
|
-
specIds: z
|
|
395
|
-
|
|
441
|
+
specIds: z
|
|
442
|
+
.array(SpecIdSchema)
|
|
443
|
+
.min(1)
|
|
444
|
+
.describe('Spec IDs to update. Each must match pattern ^SPEC-\\d+$, max 50 characters.'),
|
|
445
|
+
projectId: z
|
|
446
|
+
.string()
|
|
447
|
+
.max(500)
|
|
448
|
+
.optional()
|
|
449
|
+
.describe('Project ID, if known. Max 500 characters.'),
|
|
396
450
|
projectPath: z
|
|
397
451
|
.string()
|
|
398
452
|
.max(4096)
|
|
399
453
|
.optional()
|
|
400
|
-
.describe('Absolute project root. Preferred when projectId is unknown.'),
|
|
454
|
+
.describe('Absolute project root. Preferred when projectId is unknown. Max 4096 characters.'),
|
|
401
455
|
status: SpecStatusEnum.exclude(['done']).describe('New status for all specs. Batch supports draft, review, approved, implementing, and discarded; close done specs individually with full evidence.'),
|
|
402
456
|
dryRun: z.boolean().optional().describe('Preview the batch without mutating any spec.'),
|
|
403
457
|
reviewNotes: z
|
|
404
458
|
.string()
|
|
405
459
|
.max(10_000)
|
|
406
460
|
.optional()
|
|
407
|
-
.describe('Optional notes for each transition.'),
|
|
461
|
+
.describe('Optional notes for each transition. Max 10000 characters.'),
|
|
408
462
|
evidence: z
|
|
409
463
|
.record(z.string(), z.object({
|
|
410
464
|
modelTierUsed: z
|
|
@@ -429,8 +483,8 @@ export function registerCoreSpecTools(server) {
|
|
|
429
483
|
server.registerTool('estimate', {
|
|
430
484
|
description: t('tools.estimate.description'),
|
|
431
485
|
inputSchema: {
|
|
432
|
-
specId: SpecIdSchema.describe('Spec ID to estimate'),
|
|
433
|
-
projectId: z.string().max(500).describe('Project ID'),
|
|
486
|
+
specId: SpecIdSchema.describe('Spec ID to estimate. Must match pattern ^SPEC-\\d+$ (e.g. SPEC-042), max 50 characters.'),
|
|
487
|
+
projectId: z.string().max(500).describe('Project ID. Max 500 characters.'),
|
|
434
488
|
},
|
|
435
489
|
outputSchema: EstimateOutputSchema,
|
|
436
490
|
}, safeTracked('estimate', async (args) => handleEstimate(args)));
|
|
@@ -450,7 +504,7 @@ export function registerCoreSpecTools(server) {
|
|
|
450
504
|
server.registerTool('validate', {
|
|
451
505
|
description: t('tools.validate.description'),
|
|
452
506
|
inputSchema: {
|
|
453
|
-
specId: SpecIdSchema.describe('Spec ID to validate'),
|
|
507
|
+
specId: SpecIdSchema.describe('Spec ID to validate. Must match pattern ^SPEC-\\d+$ (e.g. SPEC-042), max 50 characters.'),
|
|
454
508
|
mode: z
|
|
455
509
|
.literal('submit')
|
|
456
510
|
.default('submit')
|
|
@@ -459,12 +513,12 @@ export function registerCoreSpecTools(server) {
|
|
|
459
513
|
.string()
|
|
460
514
|
.max(500)
|
|
461
515
|
.optional()
|
|
462
|
-
.describe('Project ID hash. Prefer projectPath — stays correct after context compaction.'),
|
|
516
|
+
.describe('Project ID hash. Prefer projectPath — stays correct after context compaction. Max 500 characters.'),
|
|
463
517
|
projectPath: z
|
|
464
518
|
.string()
|
|
465
519
|
.max(4096)
|
|
466
520
|
.optional()
|
|
467
|
-
.describe('Absolute path to project root. Derives projectId automatically — always correct even after context compaction.'),
|
|
521
|
+
.describe('Max 4096 characters. Absolute path to project root. Derives projectId automatically — always correct even after context compaction.'),
|
|
468
522
|
},
|
|
469
523
|
outputSchema: ValidateOutputSchema,
|
|
470
524
|
annotations: {
|
|
@@ -81,6 +81,13 @@ export declare const ListSpecsOutputSchema: {
|
|
|
81
81
|
directive: z.ZodLiteral<"migrate_legacy_spec">;
|
|
82
82
|
}, z.core.$strip>>>;
|
|
83
83
|
nextAction: z.ZodOptional<z.ZodString>;
|
|
84
|
+
ghosts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
85
|
+
id: z.ZodString;
|
|
86
|
+
title: z.ZodString;
|
|
87
|
+
status: z.ZodString;
|
|
88
|
+
specPath: z.ZodString;
|
|
89
|
+
nextAction: z.ZodString;
|
|
90
|
+
}, z.core.$strip>>>;
|
|
84
91
|
};
|
|
85
92
|
/** Canonical DTO inferred from the exact MCP output contract. */
|
|
86
93
|
export declare const ListSpecsOutputObjectSchema: z.ZodObject<{
|
|
@@ -165,6 +172,13 @@ export declare const ListSpecsOutputObjectSchema: z.ZodObject<{
|
|
|
165
172
|
directive: z.ZodLiteral<"migrate_legacy_spec">;
|
|
166
173
|
}, z.core.$strip>>>;
|
|
167
174
|
nextAction: z.ZodOptional<z.ZodString>;
|
|
175
|
+
ghosts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
176
|
+
id: z.ZodString;
|
|
177
|
+
title: z.ZodString;
|
|
178
|
+
status: z.ZodString;
|
|
179
|
+
specPath: z.ZodString;
|
|
180
|
+
nextAction: z.ZodString;
|
|
181
|
+
}, z.core.$strip>>>;
|
|
168
182
|
}, z.core.$strip>;
|
|
169
183
|
export type ListSpecsStructuredContent = z.infer<typeof ListSpecsOutputObjectSchema>;
|
|
170
184
|
export declare const EstimateOutputSchema: {
|
|
@@ -94,6 +94,20 @@ export const ListSpecsOutputSchema = {
|
|
|
94
94
|
}))
|
|
95
95
|
.optional(),
|
|
96
96
|
nextAction: z.string().optional(),
|
|
97
|
+
ghosts: z
|
|
98
|
+
.array(z.object({
|
|
99
|
+
id: z.string().describe('Spec identifier of the ghost store entry.'),
|
|
100
|
+
title: z.string().describe('Title recorded in the store for the ghost entry.'),
|
|
101
|
+
status: z.string().describe('Store status of the ghost entry.'),
|
|
102
|
+
specPath: z
|
|
103
|
+
.string()
|
|
104
|
+
.describe('Store-recorded specPath that could not be resolved to spec.md on disk.'),
|
|
105
|
+
nextAction: z
|
|
106
|
+
.string()
|
|
107
|
+
.describe('Recommended remediation: discard the entry or restore spec.md from git.'),
|
|
108
|
+
}))
|
|
109
|
+
.optional()
|
|
110
|
+
.describe('Store entries whose spec.md is missing or empty on disk, excluded from the normal listing.'),
|
|
97
111
|
};
|
|
98
112
|
/** Canonical DTO inferred from the exact MCP output contract. */
|
|
99
113
|
export const ListSpecsOutputObjectSchema = z.object(ListSpecsOutputSchema);
|
|
@@ -30,7 +30,9 @@ export const PackageHandoffOutputSchema = {
|
|
|
30
30
|
.regex(/^[a-f0-9]{64}$/)
|
|
31
31
|
.describe('Content-derived observation cursor.'),
|
|
32
32
|
queue: z.object({
|
|
33
|
-
status: z
|
|
33
|
+
status: z
|
|
34
|
+
.enum(['active', 'queued', 'stalled', 'terminal'])
|
|
35
|
+
.describe('Queue lifecycle bucket: active (a worker is running it), queued (waiting behind capacity), stalled (nothing is draining it; get_job will re-schedule it), terminal (reached a final state).'),
|
|
34
36
|
position: z
|
|
35
37
|
.number()
|
|
36
38
|
.int()
|
|
@@ -202,7 +202,9 @@ export const ValidateOutputSchema = {
|
|
|
202
202
|
.describe('True when this request attached to an already-running validation job instead of dispatching new work.'),
|
|
203
203
|
cursor: z.string().regex(/^[a-f0-9]{64}$/),
|
|
204
204
|
queue: z.object({
|
|
205
|
-
status: z
|
|
205
|
+
status: z
|
|
206
|
+
.enum(['active', 'queued', 'stalled', 'terminal'])
|
|
207
|
+
.describe('Queue lifecycle bucket: active (a worker is running it), queued (waiting behind capacity), stalled (nothing is draining it; get_job will re-schedule it), terminal (reached a final state).'),
|
|
206
208
|
position: z.number().int().positive().nullable(),
|
|
207
209
|
aheadCount: z.number().int().nonnegative(),
|
|
208
210
|
capacity: z.number().int().positive(),
|
|
@@ -13,6 +13,8 @@ import { verifyTerminalFrontmatter } from '../engine/frontmatter-sha/index.js';
|
|
|
13
13
|
import { appendTransitionEvent, streamJsonlLines, transitionLogPath, } from '../storage/transition-log.js';
|
|
14
14
|
import { cleanEphemeralArtifacts } from '../engine/housekeeping/index.js';
|
|
15
15
|
import { readFile, stat } from 'node:fs/promises';
|
|
16
|
+
import { resolve } from 'node:path';
|
|
17
|
+
import { resolvePortableSpecPath, PortablePathError } from '../storage/project-identity.js';
|
|
16
18
|
// ---------------------------------------------------------------------------
|
|
17
19
|
// Sync helpers (exported for startup use)
|
|
18
20
|
// ---------------------------------------------------------------------------
|
|
@@ -37,12 +39,14 @@ export async function syncSpecState(projectPath, projectId, options = {}) {
|
|
|
37
39
|
ghosts: [],
|
|
38
40
|
};
|
|
39
41
|
}
|
|
42
|
+
const resolvedPaths = await resolveSpecPaths(projectPath, dataEntries);
|
|
40
43
|
// SPEC-1351 (AC3): quarantine store entries whose spec.md is missing on
|
|
41
44
|
// disk — ghost registrations left behind by a create_spec attempt that
|
|
42
45
|
// reported success but never persisted (or whose file was later deleted).
|
|
43
|
-
const ghosts = await detectGhostSpecs(projectId, dataEntries);
|
|
46
|
+
const { ghosts, unresolvable } = await detectGhostSpecs(projectId, projectPath, dataEntries, resolvedPaths);
|
|
44
47
|
const { updates, report } = await detectSpecStateDivergences(projectPath, dataEntries);
|
|
45
48
|
report.ghosts = ghosts;
|
|
49
|
+
report.rejected.push(...unresolvable);
|
|
46
50
|
// SyncReport.rejected is always defined (SPEC-720)
|
|
47
51
|
const TERMINAL_STATUSES = ['done', 'discarded'];
|
|
48
52
|
for (const { specId, newStatus } of updates) {
|
|
@@ -50,10 +54,23 @@ export async function syncSpecState(projectPath, projectId, options = {}) {
|
|
|
50
54
|
const currentStoreStatus = dataEntry?.status;
|
|
51
55
|
// SPEC-723: If data-store status is terminal, verify SHA before any sync action
|
|
52
56
|
if (dataEntry && currentStoreStatus && TERMINAL_STATUSES.includes(currentStoreStatus)) {
|
|
53
|
-
const
|
|
54
|
-
|
|
57
|
+
const pathResolution = resolvedPaths.get(specId);
|
|
58
|
+
const resolvedSpecPath = pathResolution?.resolvedPath;
|
|
59
|
+
if (!resolvedSpecPath && dataEntry.specPath) {
|
|
60
|
+
report.rejected.push({
|
|
61
|
+
specId,
|
|
62
|
+
reason: `terminal_spec_path_unresolvable — code=${pathResolution?.failureCode ?? 'MISSING_SPEC_PATH'}; ` +
|
|
63
|
+
`store status '${currentStoreStatus}' is authoritative`,
|
|
64
|
+
});
|
|
65
|
+
const idx = report.divergences.findIndex((d) => d.specId === specId);
|
|
66
|
+
if (idx !== -1) {
|
|
67
|
+
report.divergences.splice(idx, 1);
|
|
68
|
+
}
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (resolvedSpecPath) {
|
|
55
72
|
try {
|
|
56
|
-
const content = await readFile(
|
|
73
|
+
const content = await readFile(resolvedSpecPath, 'utf-8');
|
|
57
74
|
const { metadata } = parseFrontmatter(content);
|
|
58
75
|
const verification = await verifyTerminalFrontmatter({
|
|
59
76
|
projectId,
|
|
@@ -166,38 +183,90 @@ async function collectQuarantinedSpecIds(projectId) {
|
|
|
166
183
|
}
|
|
167
184
|
return quarantined;
|
|
168
185
|
}
|
|
169
|
-
async function
|
|
186
|
+
async function resolveSpecPaths(projectPath, dataEntries) {
|
|
187
|
+
const resolved = new Map();
|
|
188
|
+
await Promise.all(dataEntries.map(async (entry) => {
|
|
189
|
+
if (!entry.specPath) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
try {
|
|
193
|
+
const resolvedPath = await resolvePortableSpecPath(entry.id, entry.specPath, projectPath);
|
|
194
|
+
resolved.set(entry.id, { resolvedPath });
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
if (error instanceof PortablePathError) {
|
|
198
|
+
resolved.set(entry.id, { failureCode: error.code });
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
resolved.set(entry.id, { failureCode: 'UNEXPECTED' });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}));
|
|
205
|
+
return resolved;
|
|
206
|
+
}
|
|
207
|
+
async function detectGhostSpecs(projectId, projectPath, dataEntries, resolvedPaths) {
|
|
170
208
|
const ghosts = [];
|
|
209
|
+
const unresolvable = [];
|
|
171
210
|
const alreadyQuarantined = await collectQuarantinedSpecIds(projectId);
|
|
172
211
|
await Promise.all(dataEntries.map(async (entry) => {
|
|
173
212
|
if (!entry.specPath) {
|
|
174
213
|
return;
|
|
175
214
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
215
|
+
const resolution = resolvedPaths.get(entry.id);
|
|
216
|
+
let absolutePath;
|
|
217
|
+
let isGhost;
|
|
218
|
+
if (resolution?.resolvedPath) {
|
|
219
|
+
absolutePath = resolution.resolvedPath;
|
|
220
|
+
try {
|
|
221
|
+
const fileStat = await stat(absolutePath);
|
|
222
|
+
isGhost = fileStat.size === 0;
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
const code = error instanceof Error && 'code' in error ? String(error.code) : undefined;
|
|
226
|
+
if (code !== 'ENOENT') {
|
|
227
|
+
unresolvable.push({
|
|
228
|
+
specId: entry.id,
|
|
229
|
+
reason: `spec_path_unresolvable — code=${code ?? 'UNEXPECTED'}`,
|
|
230
|
+
});
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
isGhost = true;
|
|
180
234
|
}
|
|
181
235
|
}
|
|
182
|
-
|
|
183
|
-
|
|
236
|
+
else if (resolution?.failureCode === 'NOT_FOUND') {
|
|
237
|
+
absolutePath = resolve(projectPath, entry.specPath);
|
|
238
|
+
isGhost = true;
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
unresolvable.push({
|
|
242
|
+
specId: entry.id,
|
|
243
|
+
reason: `spec_path_unresolvable — code=${resolution?.failureCode ?? 'UNEXPECTED'}`,
|
|
244
|
+
});
|
|
245
|
+
return;
|
|
184
246
|
}
|
|
185
|
-
|
|
186
|
-
|
|
247
|
+
if (!isGhost) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const reason = `Store entry ${entry.id} references spec.md at ${absolutePath}, which is missing or empty on disk. Recreate the spec via create_spec or restore spec.md from git/backup.`;
|
|
251
|
+
ghosts.push({ specId: entry.id, specPath: absolutePath, reason });
|
|
187
252
|
if (alreadyQuarantined.has(entry.id)) {
|
|
188
253
|
return;
|
|
189
254
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
255
|
+
alreadyQuarantined.add(entry.id);
|
|
256
|
+
try {
|
|
257
|
+
await appendTransitionEvent({
|
|
258
|
+
projectId,
|
|
259
|
+
specId: entry.id,
|
|
260
|
+
eventType: 'ghost_spec_quarantined',
|
|
261
|
+
actor: 'sync_spec_state',
|
|
262
|
+
reason,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
alreadyQuarantined.delete(entry.id);
|
|
267
|
+
}
|
|
199
268
|
}));
|
|
200
|
-
return ghosts;
|
|
269
|
+
return { ghosts, unresolvable };
|
|
201
270
|
}
|
|
202
271
|
/**
|
|
203
272
|
* Startup sync: iterates all registered projects and calls syncSpecState for each.
|