gsdd-cli 0.18.4 → 0.19.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/LICENSE +21 -21
- package/README.md +625 -607
- package/agents/DISTILLATION.md +421 -421
- package/agents/README.md +62 -62
- package/agents/approach-explorer.md +361 -361
- package/agents/debugger.md +82 -82
- package/agents/executor.md +394 -394
- package/agents/integration-checker.md +318 -318
- package/agents/mapper.md +103 -103
- package/agents/planner.md +313 -313
- package/agents/researcher.md +84 -84
- package/agents/roadmapper.md +296 -296
- package/agents/synthesizer.md +236 -236
- package/agents/verifier.md +337 -337
- package/bin/adapters/agents.mjs +34 -34
- package/bin/adapters/claude.mjs +191 -191
- package/bin/adapters/codex.mjs +85 -85
- package/bin/adapters/index.mjs +20 -20
- package/bin/adapters/opencode.mjs +278 -278
- package/bin/gsdd.mjs +123 -116
- package/bin/lib/cli-utils.mjs +28 -28
- package/bin/lib/evidence-contract.mjs +112 -112
- package/bin/lib/file-ops.mjs +209 -161
- package/bin/lib/health-truth.mjs +181 -178
- package/bin/lib/health.mjs +265 -235
- package/bin/lib/init-flow.mjs +252 -236
- package/bin/lib/init-prompts.mjs +248 -247
- package/bin/lib/init-runtime.mjs +225 -212
- package/bin/lib/init.mjs +17 -17
- package/bin/lib/lifecycle-preflight.mjs +360 -333
- package/bin/lib/lifecycle-state.mjs +351 -267
- package/bin/lib/manifest.mjs +116 -114
- package/bin/lib/models.mjs +411 -411
- package/bin/lib/phase.mjs +397 -378
- package/bin/lib/plan-constants.mjs +30 -30
- package/bin/lib/provenance.mjs +109 -106
- package/bin/lib/rendering.mjs +178 -130
- package/bin/lib/runtime-freshness.mjs +221 -219
- package/bin/lib/templates.mjs +225 -224
- package/bin/lib/workspace-root.mjs +132 -0
- package/distilled/DESIGN.md +2347 -2327
- package/distilled/EVIDENCE-INDEX.md +397 -394
- package/distilled/README.md +196 -193
- package/distilled/SKILL.md +86 -85
- package/distilled/templates/agents.block.md +21 -21
- package/distilled/templates/agents.md +6 -6
- package/distilled/templates/approach.md +232 -232
- package/distilled/templates/auth-matrix.md +78 -78
- package/distilled/templates/brownfield-change/CHANGE.md +99 -0
- package/distilled/templates/brownfield-change/HANDOFF.md +38 -0
- package/distilled/templates/brownfield-change/VERIFICATION.md +56 -0
- package/distilled/templates/codebase/architecture.md +110 -110
- package/distilled/templates/codebase/concerns.md +95 -95
- package/distilled/templates/codebase/conventions.md +193 -193
- package/distilled/templates/codebase/stack.md +96 -96
- package/distilled/templates/delegates/approach-explorer.md +25 -25
- package/distilled/templates/delegates/mapper-arch.md +26 -26
- package/distilled/templates/delegates/mapper-concerns.md +27 -27
- package/distilled/templates/delegates/mapper-quality.md +28 -28
- package/distilled/templates/delegates/mapper-tech.md +25 -25
- package/distilled/templates/delegates/plan-checker.md +68 -68
- package/distilled/templates/delegates/researcher-architecture.md +30 -30
- package/distilled/templates/delegates/researcher-features.md +30 -30
- package/distilled/templates/delegates/researcher-pitfalls.md +30 -30
- package/distilled/templates/delegates/researcher-stack.md +30 -30
- package/distilled/templates/delegates/researcher-synthesizer.md +31 -31
- package/distilled/templates/research/architecture.md +57 -57
- package/distilled/templates/research/features.md +23 -23
- package/distilled/templates/research/pitfalls.md +46 -46
- package/distilled/templates/research/stack.md +45 -45
- package/distilled/templates/research/summary.md +67 -67
- package/distilled/templates/roadmap.md +74 -62
- package/distilled/templates/spec.md +110 -110
- package/distilled/workflows/audit-milestone.md +275 -271
- package/distilled/workflows/complete-milestone.md +336 -332
- package/distilled/workflows/execute.md +454 -449
- package/distilled/workflows/map-codebase.md +253 -253
- package/distilled/workflows/new-milestone.md +242 -238
- package/distilled/workflows/new-project.md +398 -398
- package/distilled/workflows/pause.md +160 -156
- package/distilled/workflows/plan-milestone-gaps.md +183 -183
- package/distilled/workflows/plan.md +451 -447
- package/distilled/workflows/progress.md +227 -223
- package/distilled/workflows/quick.md +351 -347
- package/distilled/workflows/resume.md +220 -212
- package/distilled/workflows/verify-work.md +260 -260
- package/distilled/workflows/verify.md +431 -429
- package/docs/BROWNFIELD-PROOF.md +95 -95
- package/docs/RUNTIME-SUPPORT.md +93 -75
- package/docs/USER-GUIDE.md +440 -399
- package/docs/VERIFICATION-DISCIPLINE.md +59 -59
- package/docs/claude/context-monitor.md +98 -98
- package/docs/proof/consumer-node-cli/README.md +37 -37
- package/docs/proof/consumer-node-cli/ROADMAP.md +14 -14
- package/docs/proof/consumer-node-cli/SPEC.md +17 -17
- package/docs/proof/consumer-node-cli/brief.md +9 -9
- package/docs/proof/consumer-node-cli/phases/01-foundation/01-01-PLAN.md +34 -34
- package/docs/proof/consumer-node-cli/phases/01-foundation/01-01-SUMMARY.md +10 -10
- package/docs/proof/consumer-node-cli/phases/01-foundation/01-VERIFICATION.md +30 -30
- package/package.json +62 -61
|
@@ -1,333 +1,360 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from 'fs';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import { output } from './cli-utils.mjs';
|
|
4
|
-
import { describeEvidenceSurface } from './evidence-contract.mjs';
|
|
5
|
-
import { evaluateLifecycleState, normalizePhaseToken } from './lifecycle-state.mjs';
|
|
6
|
-
import { checkDrift } from './session-fingerprint.mjs';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
if (
|
|
200
|
-
blockers.push(
|
|
201
|
-
blocker(
|
|
202
|
-
'
|
|
203
|
-
`Phase ${phaseToken}
|
|
204
|
-
|
|
205
|
-
)
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
-
|
|
247
|
-
|
|
248
|
-
);
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
.
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
1
|
+
import { existsSync, readFileSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { output } from './cli-utils.mjs';
|
|
4
|
+
import { describeEvidenceSurface } from './evidence-contract.mjs';
|
|
5
|
+
import { evaluateLifecycleState, normalizePhaseToken } from './lifecycle-state.mjs';
|
|
6
|
+
import { checkDrift } from './session-fingerprint.mjs';
|
|
7
|
+
import { resolveWorkspaceContext } from './workspace-root.mjs';
|
|
8
|
+
|
|
9
|
+
const SURFACE_POLICIES = {
|
|
10
|
+
progress: {
|
|
11
|
+
classification: 'read_only',
|
|
12
|
+
ownedWrites: [],
|
|
13
|
+
explicitLifecycleMutation: 'none',
|
|
14
|
+
},
|
|
15
|
+
execute: {
|
|
16
|
+
classification: 'owned_write',
|
|
17
|
+
ownedWrites: ['summary'],
|
|
18
|
+
explicitLifecycleMutation: 'phase-status',
|
|
19
|
+
phaseRequired: true,
|
|
20
|
+
},
|
|
21
|
+
verify: {
|
|
22
|
+
classification: 'owned_write',
|
|
23
|
+
ownedWrites: ['verification'],
|
|
24
|
+
explicitLifecycleMutation: 'phase-status',
|
|
25
|
+
phaseRequired: true,
|
|
26
|
+
},
|
|
27
|
+
'audit-milestone': {
|
|
28
|
+
classification: 'owned_write',
|
|
29
|
+
ownedWrites: ['milestone-audit'],
|
|
30
|
+
explicitLifecycleMutation: 'none',
|
|
31
|
+
},
|
|
32
|
+
'complete-milestone': {
|
|
33
|
+
classification: 'owned_write',
|
|
34
|
+
ownedWrites: ['milestone-archives', 'milestones-ledger', 'spec', 'roadmap'],
|
|
35
|
+
explicitLifecycleMutation: 'none',
|
|
36
|
+
},
|
|
37
|
+
'new-milestone': {
|
|
38
|
+
classification: 'owned_write',
|
|
39
|
+
ownedWrites: ['spec', 'roadmap', 'phase-directories'],
|
|
40
|
+
explicitLifecycleMutation: 'none',
|
|
41
|
+
},
|
|
42
|
+
resume: {
|
|
43
|
+
classification: 'owned_write',
|
|
44
|
+
ownedWrites: ['checkpoint-cleanup'],
|
|
45
|
+
explicitLifecycleMutation: 'none',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export function evaluateLifecyclePreflight({
|
|
50
|
+
planningDir,
|
|
51
|
+
surface,
|
|
52
|
+
phaseNumber = null,
|
|
53
|
+
expectsMutation = 'none',
|
|
54
|
+
} = {}) {
|
|
55
|
+
if (!planningDir) {
|
|
56
|
+
throw new Error('planningDir is required');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const policy = SURFACE_POLICIES[surface];
|
|
60
|
+
if (!policy) {
|
|
61
|
+
throw new Error(`Unsupported lifecycle surface: ${surface}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const lifecycle = evaluateLifecycleState({ planningDir });
|
|
65
|
+
const normalizedPhase = phaseNumber ? normalizePhaseToken(phaseNumber) : null;
|
|
66
|
+
const checkpointPath = join(planningDir, '.continue-here.md');
|
|
67
|
+
const specPath = join(planningDir, 'SPEC.md');
|
|
68
|
+
const milestonesPath = join(planningDir, 'MILESTONES.md');
|
|
69
|
+
const blockers = [];
|
|
70
|
+
|
|
71
|
+
if (!existsSync(planningDir)) {
|
|
72
|
+
blockers.push(blocker('missing_planning_dir', '.planning/ does not exist yet.', ['.planning/']));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (expectsMutation !== 'none' && expectsMutation !== policy.explicitLifecycleMutation) {
|
|
76
|
+
blockers.push(
|
|
77
|
+
blocker(
|
|
78
|
+
'illegal_lifecycle_mutation',
|
|
79
|
+
`${surface} is classified as ${policy.classification} and cannot mutate lifecycle state via ${expectsMutation}.`,
|
|
80
|
+
[]
|
|
81
|
+
)
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (policy.phaseRequired && !normalizedPhase) {
|
|
86
|
+
blockers.push(blocker('missing_phase_argument', `${surface} requires an explicit phase number.`, []));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (normalizedPhase) {
|
|
90
|
+
blockers.push(...buildPhaseBlockers({ lifecycle, phaseToken: normalizedPhase, surface }));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (surface === 'audit-milestone') {
|
|
94
|
+
blockers.push(...buildRoadmapAlignmentBlockers(lifecycle));
|
|
95
|
+
blockers.push(...buildAuditBlockers(lifecycle));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (surface === 'complete-milestone') {
|
|
99
|
+
blockers.push(...buildRoadmapAlignmentBlockers(lifecycle));
|
|
100
|
+
blockers.push(...buildAuditBlockers(lifecycle, { allowArchivedBlocker: true }));
|
|
101
|
+
blockers.push(...buildCompletionBlockers(planningDir, lifecycle));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (surface === 'new-milestone') {
|
|
105
|
+
blockers.push(...buildRoadmapAlignmentBlockers(lifecycle));
|
|
106
|
+
if (!existsSync(specPath)) {
|
|
107
|
+
blockers.push(blocker('missing_spec', 'SPEC.md is required before starting a new milestone.', ['.planning/SPEC.md']));
|
|
108
|
+
}
|
|
109
|
+
if (!existsSync(milestonesPath)) {
|
|
110
|
+
blockers.push(blocker('missing_milestones', 'MILESTONES.md is required before starting a new milestone.', ['.planning/MILESTONES.md']));
|
|
111
|
+
}
|
|
112
|
+
if (lifecycle.currentMilestone.version && lifecycle.currentMilestone.archiveState !== 'archived') {
|
|
113
|
+
blockers.push(
|
|
114
|
+
blocker(
|
|
115
|
+
'active_milestone_in_progress',
|
|
116
|
+
`Milestone ${lifecycle.currentMilestone.version} is still active. Archive or remove the active roadmap before starting the next milestone.`,
|
|
117
|
+
['.planning/ROADMAP.md']
|
|
118
|
+
)
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (surface === 'resume' && !existsSync(checkpointPath) && lifecycle.nonPhaseState !== 'active_brownfield_change') {
|
|
124
|
+
blockers.push(blocker('missing_checkpoint', 'resume requires .planning/.continue-here.md unless an active .planning/brownfield-change/CHANGE.md continuity anchor exists.', ['.planning/.continue-here.md', '.planning/brownfield-change/CHANGE.md']));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const warnings = [];
|
|
128
|
+
|
|
129
|
+
if (existsSync(planningDir)) {
|
|
130
|
+
const drift = checkDrift(planningDir);
|
|
131
|
+
if (drift.drifted) {
|
|
132
|
+
warnings.push({
|
|
133
|
+
code: 'planning_state_drift',
|
|
134
|
+
message: `Planning state has drifted since the last recorded session: ${drift.details.join('; ')}`,
|
|
135
|
+
artifacts: ['.planning/ROADMAP.md', '.planning/SPEC.md', '.planning/config.json'],
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (lifecycle.phaseStatusAlignment.mismatches.length > 0) {
|
|
141
|
+
warnings.push({
|
|
142
|
+
code: 'roadmap_phase_status_mismatch',
|
|
143
|
+
message: `ROADMAP.md overview/detail phase statuses disagree: ${lifecycle.phaseStatusAlignment.mismatches.join('; ')}`,
|
|
144
|
+
artifacts: ['.planning/ROADMAP.md'],
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
surface,
|
|
150
|
+
phase: normalizedPhase,
|
|
151
|
+
classification: policy.classification,
|
|
152
|
+
ownedWrites: policy.ownedWrites,
|
|
153
|
+
explicitLifecycleMutation: policy.explicitLifecycleMutation,
|
|
154
|
+
closureEvidence: describeEvidenceSurface(surface),
|
|
155
|
+
mutationRequest: expectsMutation,
|
|
156
|
+
allowed: blockers.length === 0,
|
|
157
|
+
status: blockers.length === 0 ? 'allowed' : 'blocked',
|
|
158
|
+
reason: blockers[0]?.code ?? null,
|
|
159
|
+
blockers,
|
|
160
|
+
warnings,
|
|
161
|
+
lifecycle: {
|
|
162
|
+
currentMilestone: lifecycle.currentMilestone,
|
|
163
|
+
currentPhase: lifecycle.currentPhase ? lifecycle.currentPhase.number : null,
|
|
164
|
+
nextPhase: lifecycle.nextPhase ? lifecycle.nextPhase.number : null,
|
|
165
|
+
counts: lifecycle.counts,
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function buildPhaseBlockers({ lifecycle, phaseToken, surface }) {
|
|
171
|
+
const blockers = [];
|
|
172
|
+
const phaseEntry = lifecycle.phases.find((phase) => phase.number === phaseToken);
|
|
173
|
+
if (!phaseEntry) {
|
|
174
|
+
blockers.push(
|
|
175
|
+
blocker(
|
|
176
|
+
'missing_phase',
|
|
177
|
+
`Phase ${phaseToken} was not found in the active roadmap.`,
|
|
178
|
+
['.planning/ROADMAP.md']
|
|
179
|
+
)
|
|
180
|
+
);
|
|
181
|
+
return blockers;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const planArtifacts = lifecycle.phaseArtifacts.filter((artifact) => artifact.phaseToken === phaseToken && artifact.kind === 'plan');
|
|
185
|
+
const summaryArtifacts = lifecycle.phaseArtifacts.filter((artifact) => artifact.phaseToken === phaseToken && artifact.kind === 'summary');
|
|
186
|
+
const pendingPlans = planArtifacts.filter(
|
|
187
|
+
(artifact) => !summaryArtifacts.some((candidate) => candidate.dir === artifact.dir && candidate.baseId === artifact.baseId)
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
if (surface === 'execute') {
|
|
191
|
+
if (planArtifacts.length === 0) {
|
|
192
|
+
blockers.push(
|
|
193
|
+
blocker(
|
|
194
|
+
'missing_plan',
|
|
195
|
+
`Phase ${phaseToken} cannot execute because no PLAN artifact exists.`,
|
|
196
|
+
['.planning/phases/']
|
|
197
|
+
)
|
|
198
|
+
);
|
|
199
|
+
} else if (pendingPlans.length === 0) {
|
|
200
|
+
blockers.push(
|
|
201
|
+
blocker(
|
|
202
|
+
'no_pending_plan',
|
|
203
|
+
`Phase ${phaseToken} has no pending PLAN artifacts left to execute.`,
|
|
204
|
+
planArtifacts.map((artifact) => artifact.displayPath)
|
|
205
|
+
)
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (surface === 'verify') {
|
|
211
|
+
if (planArtifacts.length === 0) {
|
|
212
|
+
blockers.push(
|
|
213
|
+
blocker(
|
|
214
|
+
'missing_plan',
|
|
215
|
+
`Phase ${phaseToken} cannot be verified because no PLAN artifact exists.`,
|
|
216
|
+
['.planning/phases/']
|
|
217
|
+
)
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
if (summaryArtifacts.length === 0) {
|
|
221
|
+
blockers.push(
|
|
222
|
+
blocker(
|
|
223
|
+
'missing_summary',
|
|
224
|
+
`Phase ${phaseToken} cannot be verified because no SUMMARY artifact exists yet.`,
|
|
225
|
+
['.planning/phases/']
|
|
226
|
+
)
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return blockers;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function buildRoadmapAlignmentBlockers(lifecycle) {
|
|
235
|
+
if (lifecycle.phaseStatusAlignment.mismatches.length === 0) return [];
|
|
236
|
+
return [
|
|
237
|
+
blocker(
|
|
238
|
+
'roadmap_phase_status_mismatch',
|
|
239
|
+
`ROADMAP.md overview/detail phase statuses disagree: ${lifecycle.phaseStatusAlignment.mismatches.join('; ')}`,
|
|
240
|
+
['.planning/ROADMAP.md']
|
|
241
|
+
),
|
|
242
|
+
];
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function buildAuditBlockers(lifecycle, { allowArchivedBlocker = false } = {}) {
|
|
246
|
+
const blockers = [];
|
|
247
|
+
if (!lifecycle.currentMilestone.version) {
|
|
248
|
+
blockers.push(blocker('missing_milestone', 'No active or retained milestone could be derived from ROADMAP.md.', ['.planning/ROADMAP.md']));
|
|
249
|
+
return blockers;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (lifecycle.currentMilestone.archiveState === 'archived') {
|
|
253
|
+
blockers.push(
|
|
254
|
+
blocker(
|
|
255
|
+
allowArchivedBlocker ? 'milestone_already_archived' : 'milestone_already_archived',
|
|
256
|
+
`Milestone ${lifecycle.currentMilestone.version} is already archived-with-ROADMAP.md evidence.`,
|
|
257
|
+
['.planning/ROADMAP.md', '.planning/MILESTONES.md']
|
|
258
|
+
)
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (lifecycle.counts.total === 0) {
|
|
263
|
+
blockers.push(blocker('missing_phases', 'No active milestone phases were found in ROADMAP.md.', ['.planning/ROADMAP.md']));
|
|
264
|
+
} else if (lifecycle.counts.completed !== lifecycle.counts.total) {
|
|
265
|
+
blockers.push(
|
|
266
|
+
blocker(
|
|
267
|
+
'incomplete_phases',
|
|
268
|
+
`Milestone ${lifecycle.currentMilestone.version} still has incomplete phases (${lifecycle.counts.completed}/${lifecycle.counts.total} complete).`,
|
|
269
|
+
['.planning/ROADMAP.md']
|
|
270
|
+
)
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const phasesMissingVerification = lifecycle.phases
|
|
275
|
+
.filter((phase) => phase.status === 'done')
|
|
276
|
+
.filter((phase) => !phase.artifacts.some((artifact) => artifact.kind === 'verification'))
|
|
277
|
+
.map((phase) => phase.number);
|
|
278
|
+
|
|
279
|
+
if (phasesMissingVerification.length > 0) {
|
|
280
|
+
blockers.push(
|
|
281
|
+
blocker(
|
|
282
|
+
'missing_verification',
|
|
283
|
+
`Completed phases are missing VERIFICATION artifacts (${phasesMissingVerification.join(', ')}).`,
|
|
284
|
+
['.planning/phases/']
|
|
285
|
+
)
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return blockers;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function buildCompletionBlockers(planningDir, lifecycle) {
|
|
293
|
+
const auditPath = join(planningDir, `${lifecycle.currentMilestone.version}-MILESTONE-AUDIT.md`);
|
|
294
|
+
if (!existsSync(auditPath)) {
|
|
295
|
+
return [
|
|
296
|
+
blocker(
|
|
297
|
+
'missing_milestone_audit',
|
|
298
|
+
`Milestone ${lifecycle.currentMilestone.version} cannot be completed without a milestone audit artifact.`,
|
|
299
|
+
[auditPath]
|
|
300
|
+
),
|
|
301
|
+
];
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const auditContent = readFileSync(auditPath, 'utf-8');
|
|
305
|
+
const statusMatch = auditContent.match(/^status:\s*(.+)$/m);
|
|
306
|
+
if (!statusMatch || statusMatch[1].trim() !== 'passed') {
|
|
307
|
+
return [
|
|
308
|
+
blocker(
|
|
309
|
+
'audit_not_passed',
|
|
310
|
+
`Milestone ${lifecycle.currentMilestone.version} requires a passed audit before completion.`,
|
|
311
|
+
[auditPath]
|
|
312
|
+
),
|
|
313
|
+
];
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return [];
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function blocker(code, message, artifacts) {
|
|
320
|
+
return { code, message, artifacts };
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export function cmdLifecyclePreflight(...args) {
|
|
324
|
+
const { args: normalizedArgs, planningDir, invalid, error } = resolveWorkspaceContext(args);
|
|
325
|
+
if (invalid) {
|
|
326
|
+
console.error(error);
|
|
327
|
+
process.exitCode = 1;
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
const [surface, maybePhase, ...rest] = normalizedArgs;
|
|
331
|
+
|
|
332
|
+
if (!surface) {
|
|
333
|
+
console.error('Usage: node .planning/bin/gsdd.mjs lifecycle-preflight <surface> [phase] [--expects-mutation <none|phase-status>]');
|
|
334
|
+
process.exitCode = 1;
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
let phaseNumber = maybePhase && !maybePhase.startsWith('--') ? maybePhase : null;
|
|
339
|
+
let expectsMutation = 'none';
|
|
340
|
+
|
|
341
|
+
const flagArgs = phaseNumber ? rest : [maybePhase, ...rest].filter(Boolean);
|
|
342
|
+
for (let index = 0; index < flagArgs.length; index += 1) {
|
|
343
|
+
const arg = flagArgs[index];
|
|
344
|
+
if (arg === '--expects-mutation') {
|
|
345
|
+
expectsMutation = flagArgs[index + 1] ?? 'none';
|
|
346
|
+
index += 1;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
try {
|
|
351
|
+
const result = evaluateLifecyclePreflight({ planningDir, surface, phaseNumber, expectsMutation });
|
|
352
|
+
output(result);
|
|
353
|
+
if (!result.allowed) {
|
|
354
|
+
process.exitCode = 1;
|
|
355
|
+
}
|
|
356
|
+
} catch (error) {
|
|
357
|
+
console.error(error.message);
|
|
358
|
+
process.exitCode = 1;
|
|
359
|
+
}
|
|
360
|
+
}
|