specdx 0.3.0-alpha.3 → 0.4.0-alpha.10
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/.claude-plugin/plugin.json +1 -1
- package/LICENSE +21 -0
- package/dist/{changelog-OUP2RXWN.js → changelog-GR53T6IG.js} +18 -11
- package/dist/{changelog-OUP2RXWN.js.map → changelog-GR53T6IG.js.map} +1 -1
- package/dist/{check-3XQYO3HU.js → check-OMWCIY5D.js} +37 -10
- package/dist/check-OMWCIY5D.js.map +1 -0
- package/dist/chunk-3GMYCATE.js +526 -0
- package/dist/chunk-3GMYCATE.js.map +1 -0
- package/dist/{chunk-6BWZEAST.js → chunk-N77RNV7J.js} +161 -26
- package/dist/chunk-N77RNV7J.js.map +1 -0
- package/dist/{pack-PI6V6OR2.js → chunk-SDDTD4R3.js} +97 -171
- package/dist/chunk-SDDTD4R3.js.map +1 -0
- package/dist/{chunk-ZX4HVL5M.js → chunk-SJCIM4TC.js} +119 -17
- package/dist/chunk-SJCIM4TC.js.map +1 -0
- package/dist/{chunk-DDFLMRPC.js → chunk-VMMTEGYN.js} +15 -11
- package/dist/chunk-VMMTEGYN.js.map +1 -0
- package/dist/{chunk-PHR7AV6I.js → chunk-Z77VQUZ3.js} +156 -2
- package/dist/chunk-Z77VQUZ3.js.map +1 -0
- package/dist/diff-AUBYOQWU.js +107 -0
- package/dist/diff-AUBYOQWU.js.map +1 -0
- package/dist/dist-BXYQB2UO.js +306 -0
- package/dist/dist-BXYQB2UO.js.map +1 -0
- package/dist/dist-RL2DT3ZE.js +15 -0
- package/dist/{explain-I7AQMEEH.js → explain-EUID6MZF.js} +35 -28
- package/dist/explain-EUID6MZF.js.map +1 -0
- package/dist/{generate-PC7BIB7G.js → generate-U3EFOCNS.js} +3 -3
- package/dist/{generate-story-7WHPPFHY.js → generate-story-U6FMQIYZ.js} +8 -4
- package/dist/generate-story-U6FMQIYZ.js.map +1 -0
- package/dist/{generate-test-plan-U5LMWGKX.js → generate-test-plan-HOCWDYKF.js} +11 -6
- package/dist/generate-test-plan-HOCWDYKF.js.map +1 -0
- package/dist/graph-TA54D4XA.js +102 -0
- package/dist/graph-TA54D4XA.js.map +1 -0
- package/dist/index.js +777 -158
- package/dist/index.js.map +1 -1
- package/dist/{lint-6Z2TVWAQ.js → lint-L5WOBD25.js} +17 -6
- package/dist/lint-L5WOBD25.js.map +1 -0
- package/dist/main.js +100 -15
- package/dist/main.js.map +1 -1
- package/dist/mcp-GNQQGD7X.js +17 -0
- package/dist/mcp-GNQQGD7X.js.map +1 -0
- package/dist/{migrate-L7W5RHSS.js → migrate-YEJQWIMX.js} +4 -4
- package/dist/migrate-YEJQWIMX.js.map +1 -0
- package/dist/pack-AQH5XQUF.js +168 -0
- package/dist/pack-AQH5XQUF.js.map +1 -0
- package/dist/ready-DB5ORK2E.js +229 -0
- package/dist/ready-DB5ORK2E.js.map +1 -0
- package/dist/skills/specdx-check-drift.md +1 -1
- package/dist/skills/specdx-verify.md +12 -1
- package/dist/{status-AV5GSWVI.js → status-3QUQMF4L.js} +46 -31
- package/dist/status-3QUQMF4L.js.map +1 -0
- package/dist/{update-HIWDDEZQ.js → update-PE2DPYDR.js} +5 -5
- package/dist/update-PE2DPYDR.js.map +1 -0
- package/dist/validate-YNZMV6KZ.js +86 -0
- package/dist/validate-YNZMV6KZ.js.map +1 -0
- package/hooks/session-start +0 -0
- package/package.json +49 -16
- package/dist/check-3XQYO3HU.js.map +0 -1
- package/dist/chunk-6BWZEAST.js.map +0 -1
- package/dist/chunk-DDFLMRPC.js.map +0 -1
- package/dist/chunk-PHR7AV6I.js.map +0 -1
- package/dist/chunk-WTFWNYJA.js +0 -261
- package/dist/chunk-WTFWNYJA.js.map +0 -1
- package/dist/chunk-ZX4HVL5M.js.map +0 -1
- package/dist/diff-275PLXYH.js +0 -100
- package/dist/diff-275PLXYH.js.map +0 -1
- package/dist/dist-PQCG2XXF.js +0 -11
- package/dist/explain-I7AQMEEH.js.map +0 -1
- package/dist/generate-story-7WHPPFHY.js.map +0 -1
- package/dist/generate-test-plan-U5LMWGKX.js.map +0 -1
- package/dist/graph-RCAPF55A.js +0 -54
- package/dist/graph-RCAPF55A.js.map +0 -1
- package/dist/lint-6Z2TVWAQ.js.map +0 -1
- package/dist/migrate-L7W5RHSS.js.map +0 -1
- package/dist/pack-PI6V6OR2.js.map +0 -1
- package/dist/ready-B7IFPL3S.js +0 -159
- package/dist/ready-B7IFPL3S.js.map +0 -1
- package/dist/status-AV5GSWVI.js.map +0 -1
- package/dist/update-HIWDDEZQ.js.map +0 -1
- package/dist/validate-N2WSG75W.js +0 -34
- package/dist/validate-N2WSG75W.js.map +0 -1
- /package/dist/{dist-PQCG2XXF.js.map → dist-RL2DT3ZE.js.map} +0 -0
- /package/dist/{generate-PC7BIB7G.js.map → generate-U3EFOCNS.js.map} +0 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sharedArgs
|
|
3
|
+
} from "./chunk-GAM4MXPC.js";
|
|
4
|
+
import {
|
|
5
|
+
createLintEngine,
|
|
6
|
+
getPreset
|
|
7
|
+
} from "./chunk-3GMYCATE.js";
|
|
8
|
+
import {
|
|
9
|
+
DEFAULT_DIFF_CONFIG
|
|
10
|
+
} from "./chunk-VMMTEGYN.js";
|
|
11
|
+
import {
|
|
12
|
+
buildGraph,
|
|
13
|
+
createLogger,
|
|
14
|
+
loadConfig,
|
|
15
|
+
parseSpec,
|
|
16
|
+
resolveGlob
|
|
17
|
+
} from "./chunk-Z77VQUZ3.js";
|
|
18
|
+
import "./chunk-SJCIM4TC.js";
|
|
19
|
+
|
|
20
|
+
// src/commands/ready.ts
|
|
21
|
+
import { defineCommand } from "citty";
|
|
22
|
+
async function runReady() {
|
|
23
|
+
const configDir = process.cwd();
|
|
24
|
+
const config = await loadConfig(void 0, configDir);
|
|
25
|
+
const checks = [];
|
|
26
|
+
const specs = [];
|
|
27
|
+
for (const [key, entry] of Object.entries(config.specs)) {
|
|
28
|
+
const paths = await resolveGlob(entry.path, configDir);
|
|
29
|
+
for (const p of paths) {
|
|
30
|
+
const spec = await parseSpec(p);
|
|
31
|
+
specs.push({
|
|
32
|
+
spec,
|
|
33
|
+
key,
|
|
34
|
+
entry
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
checks.push({
|
|
39
|
+
name: "Spec suite non-empty",
|
|
40
|
+
passed: specs.length > 0,
|
|
41
|
+
details: specs.length > 0 ? `${specs.length} specs resolved` : "no spec files resolved \u2014 check the spec paths in spec.config.yaml"
|
|
42
|
+
});
|
|
43
|
+
const requiredEntries = Object.entries(config.specs).filter(
|
|
44
|
+
([, entry]) => entry.required
|
|
45
|
+
);
|
|
46
|
+
const missingRequired = [];
|
|
47
|
+
for (const [key, entry] of requiredEntries) {
|
|
48
|
+
const paths = await resolveGlob(entry.path, configDir);
|
|
49
|
+
if (paths.length === 0) {
|
|
50
|
+
missingRequired.push(key);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (requiredEntries.length === 0) {
|
|
54
|
+
checks.push({
|
|
55
|
+
name: "Required specs present",
|
|
56
|
+
passed: true,
|
|
57
|
+
skipped: true,
|
|
58
|
+
details: "skipped (no specs marked required in config)"
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
checks.push({
|
|
62
|
+
name: "Required specs present",
|
|
63
|
+
passed: missingRequired.length === 0,
|
|
64
|
+
details: missingRequired.length === 0 ? `All ${requiredEntries.length} required specs found` : `Missing: ${missingRequired.join(", ")}`
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const presetName = config.lint?.extends ?? "recommended";
|
|
68
|
+
const rules = getPreset(presetName);
|
|
69
|
+
let graph;
|
|
70
|
+
let graphError;
|
|
71
|
+
try {
|
|
72
|
+
graph = buildGraph(config);
|
|
73
|
+
} catch (err) {
|
|
74
|
+
graphError = err.message;
|
|
75
|
+
}
|
|
76
|
+
const engine = createLintEngine({ rules, config, graph });
|
|
77
|
+
const lintResults = engine.lint(specs.map((s) => s.spec));
|
|
78
|
+
if (graphError) {
|
|
79
|
+
lintResults.diagnostics.push({
|
|
80
|
+
ruleId: "structure/no-circular-deps",
|
|
81
|
+
severity: "error",
|
|
82
|
+
message: graphError,
|
|
83
|
+
filePath: "spec.config.yaml"
|
|
84
|
+
});
|
|
85
|
+
lintResults.hasErrors = true;
|
|
86
|
+
}
|
|
87
|
+
const errors = lintResults.diagnostics.filter((d) => d.severity === "error").length;
|
|
88
|
+
const warnings = lintResults.diagnostics.filter((d) => d.severity === "warn").length;
|
|
89
|
+
if (specs.length === 0) {
|
|
90
|
+
checks.push({
|
|
91
|
+
name: "Lint health",
|
|
92
|
+
passed: true,
|
|
93
|
+
skipped: true,
|
|
94
|
+
details: "skipped (no specs to lint)"
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
checks.push({
|
|
98
|
+
name: "Lint health",
|
|
99
|
+
passed: errors === 0,
|
|
100
|
+
details: `${errors} errors, ${warnings} warnings`
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
const integrityIssues = [];
|
|
104
|
+
if (graphError) {
|
|
105
|
+
integrityIssues.push(graphError);
|
|
106
|
+
}
|
|
107
|
+
const refErrors = lintResults.diagnostics.filter(
|
|
108
|
+
(d) => d.ruleId === "structure/valid-references"
|
|
109
|
+
);
|
|
110
|
+
for (const d of refErrors) {
|
|
111
|
+
integrityIssues.push(d.message);
|
|
112
|
+
}
|
|
113
|
+
const hasDeclaredRelations = specs.some((s) => {
|
|
114
|
+
const refs = s.spec.frontmatter.references;
|
|
115
|
+
return Array.isArray(refs) && refs.length > 0;
|
|
116
|
+
}) || Object.values(config.specs).some(
|
|
117
|
+
(entry) => (entry.requires?.length ?? 0) > 0
|
|
118
|
+
);
|
|
119
|
+
if (integrityIssues.length === 0 && !hasDeclaredRelations) {
|
|
120
|
+
checks.push({
|
|
121
|
+
name: "No integrity issues",
|
|
122
|
+
passed: true,
|
|
123
|
+
skipped: true,
|
|
124
|
+
details: "skipped (no references or dependencies declared)"
|
|
125
|
+
});
|
|
126
|
+
} else {
|
|
127
|
+
checks.push({
|
|
128
|
+
name: "No integrity issues",
|
|
129
|
+
passed: integrityIssues.length === 0,
|
|
130
|
+
details: integrityIssues.length === 0 ? "References and dependencies valid" : integrityIssues.join("; ")
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
const thresholdDays = config.diff?.staleness_threshold_days ?? DEFAULT_DIFF_CONFIG.staleness_threshold_days;
|
|
134
|
+
const now = Date.now();
|
|
135
|
+
const staleSpecs = [];
|
|
136
|
+
for (const { spec } of specs) {
|
|
137
|
+
const dateStr = spec.frontmatter.updated || spec.frontmatter.created;
|
|
138
|
+
if (dateStr) {
|
|
139
|
+
const days = Math.floor((now - new Date(dateStr).getTime()) / (1e3 * 60 * 60 * 24));
|
|
140
|
+
if (days > thresholdDays) {
|
|
141
|
+
staleSpecs.push({ specId: spec.frontmatter.id, days });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (specs.length === 0) {
|
|
146
|
+
checks.push({
|
|
147
|
+
name: "No stale specs",
|
|
148
|
+
passed: true,
|
|
149
|
+
skipped: true,
|
|
150
|
+
details: "skipped (no specs to date-check)"
|
|
151
|
+
});
|
|
152
|
+
} else {
|
|
153
|
+
checks.push({
|
|
154
|
+
name: "No stale specs",
|
|
155
|
+
passed: staleSpecs.length === 0,
|
|
156
|
+
details: staleSpecs.length === 0 ? `All specs within ${thresholdDays}-day threshold` : staleSpecs.map((s) => `${s.specId} (${s.days}d)`).join(", ")
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
const hasPrd = specs.some((s) => s.spec.frontmatter.type === "prd");
|
|
160
|
+
const storyCoverageErrors = lintResults.diagnostics.filter(
|
|
161
|
+
(d) => d.ruleId === "completeness/story-coverage"
|
|
162
|
+
);
|
|
163
|
+
if (!hasPrd) {
|
|
164
|
+
checks.push({
|
|
165
|
+
name: "Story coverage",
|
|
166
|
+
passed: true,
|
|
167
|
+
skipped: true,
|
|
168
|
+
details: "skipped (no PRD in suite)"
|
|
169
|
+
});
|
|
170
|
+
} else {
|
|
171
|
+
checks.push({
|
|
172
|
+
name: "Story coverage",
|
|
173
|
+
passed: storyCoverageErrors.length === 0,
|
|
174
|
+
details: storyCoverageErrors.length === 0 ? "All PRD features have corresponding stories" : storyCoverageErrors.map((d) => d.message).join("; ")
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
const ready = checks.every((c) => c.passed);
|
|
178
|
+
return { project: config.project?.name ?? "project", ready, checks };
|
|
179
|
+
}
|
|
180
|
+
var ready_default = defineCommand({
|
|
181
|
+
meta: { name: "ready", description: "Check if spec suite is ready for implementation" },
|
|
182
|
+
args: {
|
|
183
|
+
...sharedArgs
|
|
184
|
+
},
|
|
185
|
+
async run({ args }) {
|
|
186
|
+
try {
|
|
187
|
+
const logger = createLogger({ quiet: args.quiet, verbose: args.verbose });
|
|
188
|
+
logger.debug("Running readiness checks...");
|
|
189
|
+
const result = await runReady();
|
|
190
|
+
if (args.format === "json") {
|
|
191
|
+
console.log(JSON.stringify(result, null, 2));
|
|
192
|
+
if (!result.ready) process.exit(1);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const icon = result.ready ? "\u2713" : "\u2717";
|
|
196
|
+
const label = result.ready ? "ready for implementation" : "not ready for implementation";
|
|
197
|
+
console.log(`
|
|
198
|
+
${icon} ${result.project} \u2014 ${label}
|
|
199
|
+
`);
|
|
200
|
+
for (const check of result.checks) {
|
|
201
|
+
const checkIcon = check.skipped ? "\u2013" : check.passed ? "\u2713" : "\u2717";
|
|
202
|
+
console.log(` ${checkIcon} ${check.name}: ${check.details}`);
|
|
203
|
+
}
|
|
204
|
+
const failCount = result.checks.filter((c) => !c.passed).length;
|
|
205
|
+
if (failCount > 0) {
|
|
206
|
+
console.log(
|
|
207
|
+
`
|
|
208
|
+
Verdict: NOT READY \u2014 ${failCount} issue${failCount > 1 ? "s" : ""} to resolve
|
|
209
|
+
`
|
|
210
|
+
);
|
|
211
|
+
} else {
|
|
212
|
+
console.log(`
|
|
213
|
+
Verdict: READY
|
|
214
|
+
`);
|
|
215
|
+
}
|
|
216
|
+
if (!result.ready) process.exit(1);
|
|
217
|
+
} catch (err) {
|
|
218
|
+
console.error(`
|
|
219
|
+
\u2717 ${err.message}
|
|
220
|
+
`);
|
|
221
|
+
process.exit(1);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
export {
|
|
226
|
+
ready_default as default,
|
|
227
|
+
runReady
|
|
228
|
+
};
|
|
229
|
+
//# sourceMappingURL=ready-DB5ORK2E.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/ready.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, resolveGlob, buildGraph, createLogger } from \"@specdx/core\";\nimport { createLintEngine, getPreset } from \"@specdx/lint\";\nimport type { ParsedSpec } from \"@specdx/core\";\nimport { DEFAULT_DIFF_CONFIG } from \"@specdx/diff\";\nimport { sharedArgs } from \"../shared-args.js\";\n\nexport interface ReadyCheck {\n name: string;\n passed: boolean;\n /** True when the check had nothing to verify — reported as skipped, not as a pass. */\n skipped?: boolean;\n details: string;\n}\n\nexport interface ReadyResult {\n project: string;\n ready: boolean;\n checks: ReadyCheck[];\n}\n\nexport async function runReady(): Promise<ReadyResult> {\n const configDir = process.cwd();\n const config = await loadConfig(undefined, configDir);\n\n const checks: ReadyCheck[] = [];\n\n // Resolve and parse all specs\n const specs: {\n spec: ParsedSpec;\n key: string;\n entry: { path: string; required?: boolean; owner?: string };\n }[] = [];\n for (const [key, entry] of Object.entries(config.specs)) {\n const paths = await resolveGlob(entry.path, configDir);\n for (const p of paths) {\n const spec = await parseSpec(p);\n specs.push({\n spec,\n key,\n entry: entry as { path: string; required?: boolean; owner?: string },\n });\n }\n }\n\n // Check 0: The suite has specs at all. Without this, every check below\n // ticks over an empty set and READY means nothing (vacuous-pass audit).\n checks.push({\n name: \"Spec suite non-empty\",\n passed: specs.length > 0,\n details:\n specs.length > 0\n ? `${specs.length} specs resolved`\n : \"no spec files resolved — check the spec paths in spec.config.yaml\",\n });\n\n // Check 1: Required specs exist\n const requiredEntries = Object.entries(config.specs).filter(\n ([, entry]) => (entry as { required?: boolean }).required,\n );\n const missingRequired: string[] = [];\n for (const [key, entry] of requiredEntries) {\n const paths = await resolveGlob(entry.path, configDir);\n if (paths.length === 0) {\n missingRequired.push(key);\n }\n }\n if (requiredEntries.length === 0) {\n checks.push({\n name: \"Required specs present\",\n passed: true,\n skipped: true,\n details: \"skipped (no specs marked required in config)\",\n });\n } else {\n checks.push({\n name: \"Required specs present\",\n passed: missingRequired.length === 0,\n details:\n missingRequired.length === 0\n ? `All ${requiredEntries.length} required specs found`\n : `Missing: ${missingRequired.join(\", \")}`,\n });\n }\n\n // Check 2: Lint health (no errors)\n const presetName = config.lint?.extends ?? \"recommended\";\n const rules = getPreset(presetName);\n\n let graph;\n let graphError: string | undefined;\n try {\n graph = buildGraph(config);\n } catch (err) {\n graphError = (err as Error).message;\n }\n\n const engine = createLintEngine({ rules, config, graph });\n const lintResults = engine.lint(specs.map((s) => s.spec));\n\n if (graphError) {\n lintResults.diagnostics.push({\n ruleId: \"structure/no-circular-deps\",\n severity: \"error\",\n message: graphError,\n filePath: \"spec.config.yaml\",\n });\n lintResults.hasErrors = true;\n }\n\n const errors = lintResults.diagnostics.filter((d) => d.severity === \"error\").length;\n const warnings = lintResults.diagnostics.filter((d) => d.severity === \"warn\").length;\n if (specs.length === 0) {\n checks.push({\n name: \"Lint health\",\n passed: true,\n skipped: true,\n details: \"skipped (no specs to lint)\",\n });\n } else {\n checks.push({\n name: \"Lint health\",\n passed: errors === 0,\n details: `${errors} errors, ${warnings} warnings`,\n });\n }\n\n // Check 3: No integrity issues (broken refs, circular deps)\n const integrityIssues: string[] = [];\n if (graphError) {\n integrityIssues.push(graphError);\n }\n const refErrors = lintResults.diagnostics.filter(\n (d) => d.ruleId === \"structure/valid-references\",\n );\n for (const d of refErrors) {\n integrityIssues.push(d.message);\n }\n const hasDeclaredRelations =\n specs.some((s) => {\n const refs = s.spec.frontmatter.references;\n return Array.isArray(refs) && refs.length > 0;\n }) ||\n Object.values(config.specs).some(\n (entry) => ((entry as { requires?: string[] }).requires?.length ?? 0) > 0,\n );\n if (integrityIssues.length === 0 && !hasDeclaredRelations) {\n checks.push({\n name: \"No integrity issues\",\n passed: true,\n skipped: true,\n details: \"skipped (no references or dependencies declared)\",\n });\n } else {\n checks.push({\n name: \"No integrity issues\",\n passed: integrityIssues.length === 0,\n details:\n integrityIssues.length === 0\n ? \"References and dependencies valid\"\n : integrityIssues.join(\"; \"),\n });\n }\n\n // Check 4: No stale specs\n const thresholdDays =\n config.diff?.staleness_threshold_days ?? DEFAULT_DIFF_CONFIG.staleness_threshold_days;\n const now = Date.now();\n const staleSpecs: { specId: string; days: number }[] = [];\n for (const { spec } of specs) {\n const dateStr =\n (spec.frontmatter.updated as string | undefined) ||\n (spec.frontmatter.created as string | undefined);\n if (dateStr) {\n const days = Math.floor((now - new Date(dateStr).getTime()) / (1000 * 60 * 60 * 24));\n if (days > thresholdDays) {\n staleSpecs.push({ specId: spec.frontmatter.id as string, days });\n }\n }\n }\n if (specs.length === 0) {\n checks.push({\n name: \"No stale specs\",\n passed: true,\n skipped: true,\n details: \"skipped (no specs to date-check)\",\n });\n } else {\n checks.push({\n name: \"No stale specs\",\n passed: staleSpecs.length === 0,\n details:\n staleSpecs.length === 0\n ? `All specs within ${thresholdDays}-day threshold`\n : staleSpecs.map((s) => `${s.specId} (${s.days}d)`).join(\", \"),\n });\n }\n\n // Check 5: Story coverage — every PRD feature has a user story\n const hasPrd = specs.some((s) => s.spec.frontmatter.type === \"prd\");\n const storyCoverageErrors = lintResults.diagnostics.filter(\n (d) => d.ruleId === \"completeness/story-coverage\",\n );\n if (!hasPrd) {\n checks.push({\n name: \"Story coverage\",\n passed: true,\n skipped: true,\n details: \"skipped (no PRD in suite)\",\n });\n } else {\n checks.push({\n name: \"Story coverage\",\n passed: storyCoverageErrors.length === 0,\n details:\n storyCoverageErrors.length === 0\n ? \"All PRD features have corresponding stories\"\n : storyCoverageErrors.map((d) => d.message).join(\"; \"),\n });\n }\n\n const ready = checks.every((c) => c.passed);\n return { project: config.project?.name ?? \"project\", ready, checks };\n}\n\nexport default defineCommand({\n meta: { name: \"ready\", description: \"Check if spec suite is ready for implementation\" },\n args: {\n ...sharedArgs,\n },\n async run({ args }) {\n try {\n const logger = createLogger({ quiet: args.quiet, verbose: args.verbose });\n logger.debug(\"Running readiness checks...\");\n\n const result = await runReady();\n\n if (args.format === \"json\") {\n console.log(JSON.stringify(result, null, 2));\n if (!result.ready) process.exit(1);\n return;\n }\n\n // Pretty format\n const icon = result.ready ? \"✓\" : \"✗\";\n const label = result.ready ? \"ready for implementation\" : \"not ready for implementation\";\n\n console.log(`\\n ${icon} ${result.project} — ${label}\\n`);\n\n for (const check of result.checks) {\n const checkIcon = check.skipped ? \"–\" : check.passed ? \"✓\" : \"✗\";\n console.log(` ${checkIcon} ${check.name}: ${check.details}`);\n }\n\n const failCount = result.checks.filter((c) => !c.passed).length;\n if (failCount > 0) {\n console.log(\n `\\n Verdict: NOT READY — ${failCount} issue${failCount > 1 ? \"s\" : \"\"} to resolve\\n`,\n );\n } else {\n console.log(`\\n Verdict: READY\\n`);\n }\n\n if (!result.ready) process.exit(1);\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAqB9B,eAAsB,WAAiC;AACrD,QAAM,YAAY,QAAQ,IAAI;AAC9B,QAAM,SAAS,MAAM,WAAW,QAAW,SAAS;AAEpD,QAAM,SAAuB,CAAC;AAG9B,QAAM,QAIA,CAAC;AACP,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,Q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AAO,EAAE;AAAA,MAChE;AAEA,YAAM,YAAY,OAAO,OAAO,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE;AACzD,UAAI,YAAY,GAAG;AACjB,gBAAQ;AAAA,UACN;AAAA,8BAA4B,SAAS,SAAS,YAAY,IAAI,MAAM,EAAE;AAAA;AAAA,QACxE;AAAA,MACF,OAAO;AACL,gBAAQ,IAAI;AAAA;AAAA,CAAsB;AAAA,MACpC;AAEA,UAAI,CAAC,OAAO,MAAO,SAAQ,KAAK,CAAC;AAAA,IACnC,SAAS,KAAK;AACZ,cAAQ,MAAM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: specdx-check-drift
|
|
3
|
-
description: "Use when the user says 'check drift', 'did I drift from spec', 'am I still aligned', or as part of a pre-commit check. Compares recent code changes against spec definitions."
|
|
3
|
+
description: "[experimental — built on sdx check, whose static analysis can be noisy] Use when the user says 'check drift', 'did I drift from spec', 'am I still aligned', or as part of a pre-commit check. Compares recent code changes against spec definitions."
|
|
4
4
|
allowed-tools: Bash(npx specdx *), Read
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: specdx-verify
|
|
3
|
-
description: "Use when the user says 'verify', 'check against spec', 'does this match the spec', 'review implementation', or after completing a feature. Runs spec-to-implementation analysis and reviews findings."
|
|
3
|
+
description: "[experimental — built on sdx check, whose static analysis can be noisy] Use when the user says 'verify', 'check against spec', 'does this match the spec', 'review implementation', or after completing a feature. Runs spec-to-implementation analysis and reviews findings."
|
|
4
4
|
allowed-tools: Bash(npx specdx *), Read
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -20,6 +20,17 @@ If the command fails with "ts-morph is required", tell the user to install it: `
|
|
|
20
20
|
|
|
21
21
|
If it fails with "No spec.config.yaml found", the project isn't set up with specdx. Stop and inform the user.
|
|
22
22
|
|
|
23
|
+
If it exits 3 ("coverage not assessed — no checkable surfaces"), the project has no extractable routes/types/tests — common outside Express/Hono/Next.js. Suggest declaring checkable artifacts in the relevant spec's frontmatter so check has something real to verify:
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
artifacts:
|
|
27
|
+
- path: "middleware.ts"
|
|
28
|
+
- path: "src/lib/bots.ts"
|
|
29
|
+
exports: ["BOT_SIGNATURES"]
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Declaring artifacts for work that is not built yet is safe: while the spec is `draft` or `review`, absent files report as *pending* (info, exit 0). They become enforceable errors when the spec status is `approved`. So write the declaration when you write the spec — do not wait for the implementation.
|
|
33
|
+
|
|
23
34
|
### Step 2: Load spec context
|
|
24
35
|
|
|
25
36
|
```bash
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createLintEngine,
|
|
3
3
|
getPreset
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3GMYCATE.js";
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_DIFF_CONFIG
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-VMMTEGYN.js";
|
|
8
8
|
import {
|
|
9
9
|
buildGraph,
|
|
10
10
|
loadConfig,
|
|
11
11
|
parseSpec,
|
|
12
12
|
resolveGlob
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-Z77VQUZ3.js";
|
|
14
|
+
import "./chunk-SJCIM4TC.js";
|
|
15
15
|
|
|
16
16
|
// src/commands/status.ts
|
|
17
17
|
import { defineCommand } from "citty";
|
|
@@ -84,6 +84,7 @@ async function runStatus(_options = {}) {
|
|
|
84
84
|
let verdict = "healthy";
|
|
85
85
|
if (errors > 0) verdict = "errors";
|
|
86
86
|
else if (warnings > 0 || staleSpecs.length > 0) verdict = "warnings";
|
|
87
|
+
else if (specs.length === 0) verdict = "unassessed";
|
|
87
88
|
return {
|
|
88
89
|
project: config.project?.name ?? "unknown",
|
|
89
90
|
specCount: specs.length,
|
|
@@ -104,42 +105,56 @@ var status_default = defineCommand({
|
|
|
104
105
|
}
|
|
105
106
|
},
|
|
106
107
|
async run({ args }) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (args.format === "github") {
|
|
113
|
-
for (const s of result.staleSpecs) {
|
|
114
|
-
console.log(
|
|
115
|
-
`::warning::Spec "${s.specId}" is stale (${s.daysSinceUpdate} days since update)`
|
|
116
|
-
);
|
|
108
|
+
try {
|
|
109
|
+
const result = await runStatus({ format: args.format });
|
|
110
|
+
if (args.format === "json") {
|
|
111
|
+
console.log(JSON.stringify(result, null, 2));
|
|
112
|
+
return;
|
|
117
113
|
}
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
if (args.format === "github") {
|
|
115
|
+
for (const s of result.staleSpecs) {
|
|
116
|
+
console.log(
|
|
117
|
+
`::warning::Spec "${s.specId}" is stale (${s.daysSinceUpdate} days since update)`
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
for (const issue of result.integrityIssues) {
|
|
121
|
+
console.log(`::error::${issue}`);
|
|
122
|
+
}
|
|
123
|
+
return;
|
|
120
124
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const icon = result.verdict === "healthy" ? "\u2713" : result.verdict === "warnings" ? "\u26A0" : "\u2717";
|
|
124
|
-
console.log(`
|
|
125
|
+
const icon = result.verdict === "healthy" ? "\u2713" : result.verdict === "warnings" || result.verdict === "unassessed" ? "\u26A0" : "\u2717";
|
|
126
|
+
console.log(`
|
|
125
127
|
${icon} ${result.project} \u2014 ${result.verdict}`);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
if (result.verdict === "unassessed") {
|
|
129
|
+
console.log(
|
|
130
|
+
" No specs resolved \u2014 nothing was assessed. Check the spec paths in spec.config.yaml."
|
|
131
|
+
);
|
|
132
|
+
}
|
|
131
133
|
console.log(
|
|
132
|
-
`
|
|
134
|
+
` ${result.specCount} specs: ${Object.entries(result.byStatus).map(([k, v]) => `${v} ${k}`).join(", ")}`
|
|
133
135
|
);
|
|
136
|
+
console.log(
|
|
137
|
+
` Lint: ${result.lintHealth.errors} errors, ${result.lintHealth.warnings} warnings`
|
|
138
|
+
);
|
|
139
|
+
if (result.staleSpecs.length > 0) {
|
|
140
|
+
console.log(
|
|
141
|
+
` Stale: ${result.staleSpecs.map((s) => `${s.specId} (${s.daysSinceUpdate}d)`).join(", ")}`
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
if (result.integrityIssues.length > 0) {
|
|
145
|
+
console.log(` Issues: ${result.integrityIssues.join("; ")}`);
|
|
146
|
+
}
|
|
147
|
+
console.log();
|
|
148
|
+
} catch (err) {
|
|
149
|
+
console.error(`
|
|
150
|
+
\u2717 ${err.message}
|
|
151
|
+
`);
|
|
152
|
+
process.exit(1);
|
|
134
153
|
}
|
|
135
|
-
if (result.integrityIssues.length > 0) {
|
|
136
|
-
console.log(` Issues: ${result.integrityIssues.join("; ")}`);
|
|
137
|
-
}
|
|
138
|
-
console.log();
|
|
139
154
|
}
|
|
140
155
|
});
|
|
141
156
|
export {
|
|
142
157
|
status_default as default,
|
|
143
158
|
runStatus
|
|
144
159
|
};
|
|
145
|
-
//# sourceMappingURL=status-
|
|
160
|
+
//# sourceMappingURL=status-3QUQMF4L.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/status.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, buildGraph, resolveGlob } from \"@specdx/core\";\nimport { createLintEngine, getPreset } from \"@specdx/lint\";\nimport { DEFAULT_DIFF_CONFIG } from \"@specdx/diff\";\nimport type { StatusResult } from \"@specdx/diff\";\nimport type { ParsedSpec } from \"@specdx/core\";\n\nexport async function runStatus(_options: { format?: string } = {}): Promise<StatusResult> {\n const configDir = process.cwd();\n const config = await loadConfig(undefined, configDir);\n\n // Resolve and parse all specs\n const specs: { spec: ParsedSpec; entry: { path: string; owner?: string } }[] = [];\n for (const [, entry] of Object.entries(config.specs)) {\n const paths = await resolveGlob(entry.path, configDir);\n for (const p of paths) {\n const spec = await parseSpec(p);\n specs.push({ spec, entry: entry as { path: string; owner?: string } });\n }\n }\n\n // Count by status\n const byStatus: Record<string, number> = {};\n for (const { spec } of specs) {\n const status = (spec.frontmatter.status as string) || \"unknown\";\n byStatus[status] = (byStatus[status] ?? 0) + 1;\n }\n\n // Lint health\n const presetName = config.lint?.extends ?? \"recommended\";\n const rules = getPreset(presetName);\n\n let graph;\n let graphError: string | undefined;\n try {\n graph = buildGraph(config);\n } catch (err) {\n graphError = (err as Error).message;\n }\n\n const engine = createLintEngine({ rules, config, graph });\n const lintResults = engine.lint(specs.map((s) => s.spec));\n\n if (graphError) {\n lintResults.diagnostics.push({\n ruleId: \"structure/no-circular-deps\",\n severity: \"error\",\n message: graphError,\n filePath: \"spec.config.yaml\",\n });\n lintResults.hasErrors = true;\n }\n\n const errors = lintResults.diagnostics.filter((d) => d.severity === \"error\").length;\n const warnings = lintResults.diagnostics.filter((d) => d.severity === \"warn\").length;\n\n // Staleness\n const thresholdDays =\n config.diff?.staleness_threshold_days ?? DEFAULT_DIFF_CONFIG.staleness_threshold_days;\n const now = Date.now();\n const staleSpecs: { specId: string; daysSinceUpdate: number; owner?: string }[] = [];\n for (const { spec, entry } of specs) {\n const dateStr =\n (spec.frontmatter.updated as string | undefined) ||\n (spec.frontmatter.created as string | undefined);\n if (dateStr) {\n const daysSinceUpdate = Math.floor(\n (now - new Date(dateStr).getTime()) / (1000 * 60 * 60 * 24),\n );\n if (daysSinceUpdate > thresholdDays) {\n staleSpecs.push({\n specId: spec.frontmatter.id as string,\n daysSinceUpdate,\n owner: entry.owner,\n });\n }\n }\n }\n\n // Integrity issues\n const integrityIssues: string[] = [];\n if (graphError) {\n integrityIssues.push(graphError);\n }\n const refErrors = lintResults.diagnostics.filter(\n (d) => d.ruleId === \"structure/valid-references\",\n );\n for (const d of refErrors) {\n integrityIssues.push(d.message);\n }\n\n // Verdict — an empty suite is unassessed, never a vacuous \"healthy\"\n let verdict: StatusResult[\"verdict\"] = \"healthy\";\n if (errors > 0) verdict = \"errors\";\n else if (warnings > 0 || staleSpecs.length > 0) verdict = \"warnings\";\n else if (specs.length === 0) verdict = \"unassessed\";\n\n return {\n project: config.project?.name ?? \"unknown\",\n specCount: specs.length,\n byStatus,\n lintHealth: { errors, warnings, passing: specs.length - errors },\n staleSpecs,\n integrityIssues,\n verdict,\n };\n}\n\nexport default defineCommand({\n meta: { name: \"status\", description: \"Show spec suite health overview\" },\n args: {\n format: {\n type: \"string\",\n description: \"Output format: pretty, json, github\",\n default: \"pretty\",\n },\n },\n async run({ args }) {\n try {\n const result = await runStatus({ format: args.format });\n\n if (args.format === \"json\") {\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n if (args.format === \"github\") {\n for (const s of result.staleSpecs) {\n console.log(\n `::warning::Spec \"${s.specId}\" is stale (${s.daysSinceUpdate} days since update)`,\n );\n }\n for (const issue of result.integrityIssues) {\n console.log(`::error::${issue}`);\n }\n return;\n }\n\n // Pretty format\n const icon =\n result.verdict === \"healthy\"\n ? \"✓\"\n : result.verdict === \"warnings\" || result.verdict === \"unassessed\"\n ? \"⚠\"\n : \"✗\";\n console.log(`\\n ${icon} ${result.project} — ${result.verdict}`);\n if (result.verdict === \"unassessed\") {\n console.log(\n \" No specs resolved — nothing was assessed. Check the spec paths in spec.config.yaml.\",\n );\n }\n console.log(\n ` ${result.specCount} specs: ${Object.entries(result.byStatus)\n .map(([k, v]) => `${v} ${k}`)\n .join(\", \")}`,\n );\n console.log(\n ` Lint: ${result.lintHealth.errors} errors, ${result.lintHealth.warnings} warnings`,\n );\n\n if (result.staleSpecs.length > 0) {\n console.log(\n ` Stale: ${result.staleSpecs.map((s) => `${s.specId} (${s.daysSinceUpdate}d)`).join(\", \")}`,\n );\n }\n if (result.integrityIssues.length > 0) {\n console.log(` Issues: ${result.integrityIssues.join(\"; \")}`);\n }\n console.log();\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAO9B,eAAsB,UAAU,WAAgC,CAAC,GAA0B;AACzF,QAAM,YAAY,QAAQ,IAAI;AAC9B,QAAM,SAAS,MAAM,WAAW,QAAW,SAAS;AAGpD,QAAM,QAAyE,CAAC;AAChF,aAAW,CAAC,EAAE,KAAK,KAAK,OAAO,QAAQ,OAAO,KAAK,GAAG;AACpD,UAAM,QAAQ,MAAM,YAAY,MAAM,MAAM,SAAS;AACrD,eAAW,KAAK,OAAO;AACrB,YAAM,OAAO,MAAM,UAAU,CAAC;AAC9B,YAAM,KAAK,EAAE,MAAM,MAAiD,CAAC;AAAA,IACvE;AAAA,EACF;AAGA,QAAM,WAAmC,CAAC;AAC1C,aAAW,EAAE,KAAK,KAAK,OAAO;AAC5B,UAAM,SAAU,KAAK,YAAY,UAAqB;AACtD,aAAS,MAAM,KAAK,SAAS,MAAM,KAAK,KAAK;AAAA,EAC/C;AAGA,QAAM,aAAa,OAAO,MAAM,WAAW;AAC3C,QAAM,QAAQ,UAAU,UAAU;AAElC,MAAI;AACJ,MAAI;AACJ,MAAI;AACF,YAAQ,WAAW,MAAM;AAAA,EAC3B,SAAS,KAAK;AACZ,iBAAc,IAAc;AAAA,EAC9B;AAEA,QAAM,SAAS,iBAAiB,EAAE,OAAO,QAAQ,MAAM,CAAC;AACxD,QAAM,cAAc,OAAO,KAAK,MAAM,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;AAExD,MAAI,YAAY;AACd,gBAAY,YAAY,KAAK;AAAA,MAC3B,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,SAAS;AAAA,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AAA,UACN,cAAc,OAAO,WAAW,IAAI,CAAC,MAAM,GAAG,EAAE,MAAM,KAAK,EAAE,eAAe,IAAI,EAAE,KAAK,IAAI,CAAC;AAAA,QAC9F;AAAA,MACF;AACA,UAAI,OAAO,gBAAgB,SAAS,GAAG;AACrC,gBAAQ,IAAI,eAAe,OAAO,gBAAgB,KAAK,IAAI,CAAC,EAAE;AAAA,MAChE;AACA,cAAQ,IAAI;AAAA,IACd,SAAS,KAAK;AACZ,cAAQ,MAAM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runCheck
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-N77RNV7J.js";
|
|
4
4
|
import {
|
|
5
5
|
sharedArgs
|
|
6
6
|
} from "./chunk-GAM4MXPC.js";
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
loadConfig,
|
|
10
10
|
parseSpec,
|
|
11
11
|
resolveGlob
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-Z77VQUZ3.js";
|
|
13
|
+
import "./chunk-SJCIM4TC.js";
|
|
14
14
|
|
|
15
15
|
// src/commands/update.ts
|
|
16
16
|
import { defineCommand } from "citty";
|
|
@@ -85,7 +85,7 @@ function printSuggestionsPretty(suggestions) {
|
|
|
85
85
|
var update_default = defineCommand({
|
|
86
86
|
meta: {
|
|
87
87
|
name: "update",
|
|
88
|
-
description: "Suggest spec updates based on sdx check findings (--from-code)"
|
|
88
|
+
description: "[experimental] Suggest spec updates based on sdx check findings (--from-code)"
|
|
89
89
|
},
|
|
90
90
|
args: {
|
|
91
91
|
...sharedArgs,
|
|
@@ -129,4 +129,4 @@ export {
|
|
|
129
129
|
update_default as default,
|
|
130
130
|
generateUpdates
|
|
131
131
|
};
|
|
132
|
-
//# sourceMappingURL=update-
|
|
132
|
+
//# sourceMappingURL=update-PE2DPYDR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/update.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, resolveGlob, createLogger } from \"@specdx/core\";\nimport { runCheck } from \"@specdx/check\";\nimport type { Finding } from \"@specdx/check\";\nimport type { ParsedSpec } from \"@specdx/core\";\nimport { sharedArgs } from \"../shared-args.js\";\n\nexport interface UpdateSuggestion {\n specId: string;\n section: string;\n addition: string;\n reason: string;\n}\n\nexport interface GenerateUpdatesInput {\n findings: Finding[];\n}\n\nexport interface GenerateUpdatesResult {\n suggestions: UpdateSuggestion[];\n}\n\nfunction buildRouteAddition(actual: string): string {\n const parts = actual.trim().split(/\\s+/);\n const method = parts[0] ?? \"GET\";\n const path = parts[1] ?? actual;\n return `### ${method} ${path}\\nDescription placeholder.`;\n}\n\nfunction buildTypeAddition(actual: string): string {\n return `- ${actual}`;\n}\n\nfunction buildTestAddition(actual: string): string {\n return `- ${actual}`;\n}\n\nexport function generateUpdates({ findings }: GenerateUpdatesInput): GenerateUpdatesResult {\n const suggestions: UpdateSuggestion[] = [];\n\n for (const finding of findings) {\n // Only act on extra findings — code has something the spec doesn't know about.\n // missing = code is wrong, spec is correct → skip.\n // mismatch = ambiguous → skip for now, let the user decide.\n if (finding.type !== \"extra\") continue;\n\n const actual = finding.actual ?? \"\";\n\n if (finding.category === \"route\") {\n suggestions.push({\n specId: finding.specId,\n section: \"Endpoints\",\n addition: buildRouteAddition(actual),\n reason: `Route ${actual} exists in code but is not documented in the spec.`,\n });\n } else if (finding.category === \"type\") {\n suggestions.push({\n specId: finding.specId,\n section: \"Data Model\",\n addition: buildTypeAddition(actual),\n reason: `${actual} exists in code but is not documented in the spec.`,\n });\n } else if (finding.category === \"test\") {\n suggestions.push({\n specId: finding.specId,\n section: \"Test Cases\",\n addition: buildTestAddition(actual),\n reason: `Test case \"${actual}\" exists in code but is not listed in the spec.`,\n });\n }\n }\n\n return { suggestions };\n}\n\nfunction printSuggestionsPretty(suggestions: UpdateSuggestion[]): void {\n if (suggestions.length === 0) {\n console.log(\"\\n sdx update — no spec updates suggested\\n\");\n return;\n }\n\n console.log(`\\n sdx update — ${suggestions.length} suggested spec update(s)\\n`);\n\n // Group by specId\n const bySpec = new Map<string, UpdateSuggestion[]>();\n for (const s of suggestions) {\n const list = bySpec.get(s.specId) ?? [];\n list.push(s);\n bySpec.set(s.specId, list);\n }\n\n for (const [specId, items] of bySpec) {\n console.log(` ${specId}:`);\n for (const item of items) {\n console.log(` [${item.section}] ${item.reason}`);\n console.log(` Add:\\n ${item.addition.replace(/\\n/g, \"\\n \")}`);\n }\n console.log();\n }\n\n console.log(\" Note: --apply is not implemented in v1. Apply changes manually.\\n\");\n}\n\nexport default defineCommand({\n meta: {\n name: \"update\",\n description: \"[experimental] Suggest spec updates based on sdx check findings (--from-code)\",\n },\n args: {\n ...sharedArgs,\n \"from-code\": {\n type: \"boolean\",\n description: \"Generate suggestions from code drift (sdx check findings)\",\n default: true,\n },\n spec: { type: \"string\", description: \"Limit to a specific spec ID\" },\n framework: { type: \"string\", description: \"Framework override: express, hono, nextjs\" },\n },\n async run({ args }) {\n const logger = createLogger({ quiet: args.quiet, verbose: args.verbose });\n const configDir = process.cwd();\n const config = await loadConfig(undefined, configDir);\n\n logger.debug(\"Loading specs...\");\n\n const specs: ParsedSpec[] = [];\n for (const [, entry] of Object.entries(config.specs)) {\n const paths = await resolveGlob(entry.path, configDir);\n for (const p of paths) {\n const spec = await parseSpec(p);\n if (args.spec && spec.frontmatter.id !== args.spec) continue;\n specs.push(spec);\n }\n }\n\n logger.debug(`Running check on ${specs.length} specs...`);\n\n const checkConfig = {\n ...config.check,\n ...(args.framework\n ? { framework: args.framework as \"auto\" | \"express\" | \"hono\" | \"nextjs\" }\n : {}),\n };\n\n const checkResult = await runCheck(specs, configDir, checkConfig);\n const { suggestions } = generateUpdates({ findings: checkResult.findings });\n\n if (args.format === \"json\") {\n console.log(JSON.stringify({ suggestions }, null, 2));\n } else {\n printSuggestionsPretty(suggestions);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAsB9B,SAAS,mBAAmB,QAAwB;AAClD,QAAM,QAAQ,OAAO,KAAK,EAAE,MAAM,KAAK;AACvC,QAAM,SAAS,MAAM,CAAC,KAAK;AAC3B,QAAM,OAAO,MAAM,CAAC,KAAK;AACzB,SAAO,OAAO,MAAM,IAAI,IAAI;AAAA;AAC9B;AAEA,SAAS,kBAAkB,QAAwB;AACjD,SAAO,KAAK,MAAM;AACpB;AAEA,SAAS,kBAAkB,QAAwB;AACjD,SAAO,KAAK,MAAM;AACpB;AAEO,SAAS,gBAAgB,EAAE,SAAS,GAAgD;AACzF,QAAM,cAAkC,CAAC;AAEzC,aAAW,WAAW,UAAU;AAI9B,QAAI,QAAQ,SAAS,QAAS;AAE9B,UAAM,SAAS,QAAQ,UAAU;AAEjC,QAAI,QAAQ,aAAa,SAAS;AAChC,kBAAY,KAAK;AAAA,QACf,QAAQ,QAAQ;AAAA,QAChB,SAAS;AAAA,QACT,UAAU,mBAAmB,MAAM;AAAA,QACnC,QAAQ,SAAS,MAAM;AAAA,MACzB,CAAC;AAAA,IACH,WAAW,QAAQ,aAAa,QAAQ;AACtC,kBAAY,KAAK;AAAA,QACf,QAAQ,QAAQ;AAAA,QAChB,SAAS;AAAA,QACT,UAAU,kBAAkB,MAAM;AAAA,QAClC,QAAQ,GAAG,MAAM;AAAA,MACnB,CAAC;AAAA,IACH,WAAW,QAAQ,aAAa,QAAQ;AACtC,kBAAY,KAAK;AAAA,QACf,QAAQ,QAAQ;AAAA,QAChB,SAAS;AAAA,QACT,UAAU,kBAAkB,MAAM;AAAA,QAClC,QAAQ,cAAc,MAAM;AAAA,MAC9B,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO,EAAE,YAAY;AACvB;AAEA,SAA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AW,CAAC,EAAE,KAAK,KAAK,OAAO,QAAQ,OAAO,KAAK,GAAG;AACpD,YAAM,QAAQ,MAAM,YAAY,MAAM,MAAM,SAAS;AACrD,iBAAW,KAAK,OAAO;AACrB,cAAM,OAAO,MAAM,UAAU,CAAC;AAC9B,YAAI,KAAK,QAAQ,KAAK,YAAY,OAAO,KAAK,KAAM;AACpD,cAAM,KAAK,IAAI;AAAA,MACjB;AAAA,IACF;AAEA,WAAO,MAAM,oBAAoB,MAAM,MAAM,WAAW;AAExD,UAAM,cAAc;AAAA,MAClB,GAAG,OAAO;AAAA,MACV,GAAI,KAAK,YACL,EAAE,WAAW,KAAK,UAAoD,IACtE,CAAC;AAAA,IACP;AAEA,UAAM,cAAc,MAAM,SAAS,OAAO,WAAW,WAAW;AAChE,UAAM,EAAE,YAAY,IAAI,gBAAgB,EAAE,UAAU,YAAY,SAAS,CAAC;AAE1E,QAAI,KAAK,WAAW,QAAQ;AAC1B,cAAQ,IAAI,KAAK,UAAU,EAAE,YAAY,GAAG,MAAM,CAAC,CAAC;AAAA,IACtD,OAAO;AACL,6BAAuB,WAAW;AAAA,IACpC;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sharedArgs
|
|
3
|
+
} from "./chunk-GAM4MXPC.js";
|
|
4
|
+
import {
|
|
5
|
+
ConfigError,
|
|
6
|
+
GraphError,
|
|
7
|
+
buildGraph,
|
|
8
|
+
loadConfig,
|
|
9
|
+
resolveGlob
|
|
10
|
+
} from "./chunk-Z77VQUZ3.js";
|
|
11
|
+
import "./chunk-SJCIM4TC.js";
|
|
12
|
+
|
|
13
|
+
// src/commands/validate.ts
|
|
14
|
+
import { defineCommand } from "citty";
|
|
15
|
+
async function runValidate(configDir) {
|
|
16
|
+
const warnings = [];
|
|
17
|
+
try {
|
|
18
|
+
const config = await loadConfig(void 0, configDir);
|
|
19
|
+
buildGraph(config);
|
|
20
|
+
let specFileCount = 0;
|
|
21
|
+
const missingRequired = [];
|
|
22
|
+
for (const [key, entry] of Object.entries(config.specs)) {
|
|
23
|
+
const files = await resolveGlob(entry.path, configDir);
|
|
24
|
+
specFileCount += files.length;
|
|
25
|
+
if (files.length > 0) continue;
|
|
26
|
+
if (entry.required) {
|
|
27
|
+
missingRequired.push(`"${key}" (${entry.path})`);
|
|
28
|
+
} else {
|
|
29
|
+
warnings.push(`spec entry "${key}" resolves to no files: ${entry.path}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (missingRequired.length > 0) {
|
|
33
|
+
return {
|
|
34
|
+
valid: false,
|
|
35
|
+
specCount: Object.keys(config.specs).length,
|
|
36
|
+
specFileCount,
|
|
37
|
+
warnings,
|
|
38
|
+
error: `required spec entry resolves to no files: ${missingRequired.join(", ")}`
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (specFileCount === 0) {
|
|
42
|
+
warnings.push(
|
|
43
|
+
"no spec files found \u2014 every downstream check (lint, status, ready) would pass vacuously"
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
valid: true,
|
|
48
|
+
specCount: Object.keys(config.specs).length,
|
|
49
|
+
specFileCount,
|
|
50
|
+
warnings
|
|
51
|
+
};
|
|
52
|
+
} catch (err) {
|
|
53
|
+
if (err instanceof ConfigError) {
|
|
54
|
+
return { valid: false, warnings, error: err.message, details: err.errors ?? void 0 };
|
|
55
|
+
}
|
|
56
|
+
if (err instanceof GraphError) {
|
|
57
|
+
return { valid: false, warnings, error: err.message };
|
|
58
|
+
}
|
|
59
|
+
throw err;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
var validate_default = defineCommand({
|
|
63
|
+
meta: { name: "validate", description: "Validate spec.config.yaml" },
|
|
64
|
+
args: { ...sharedArgs },
|
|
65
|
+
async run() {
|
|
66
|
+
const result = await runValidate(process.cwd());
|
|
67
|
+
if (result.valid) {
|
|
68
|
+
console.log(
|
|
69
|
+
` \u2713 Config valid. ${result.specCount} spec entries, ${result.specFileCount} spec files.`
|
|
70
|
+
);
|
|
71
|
+
for (const w of result.warnings) console.log(` \u26A0 ${w}`);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
console.error(` \u2717 Config invalid: ${result.error}`);
|
|
75
|
+
for (const w of result.warnings) console.error(` \u26A0 ${w}`);
|
|
76
|
+
if (result.details) {
|
|
77
|
+
for (const e of result.details) console.error(` - ${JSON.stringify(e)}`);
|
|
78
|
+
}
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
export {
|
|
83
|
+
validate_default as default,
|
|
84
|
+
runValidate
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=validate-YNZMV6KZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/validate.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, buildGraph, resolveGlob, ConfigError, GraphError } from \"@specdx/core\";\nimport { sharedArgs } from \"../shared-args.js\";\n\nexport interface ValidateResult {\n valid: boolean;\n /** Number of spec entries declared in the config. */\n specCount?: number;\n /** Number of spec files those entries actually resolve to. */\n specFileCount?: number;\n /** Non-fatal honesty notes: entries resolving to nothing, empty suite. */\n warnings: string[];\n error?: string;\n details?: unknown[];\n}\n\n/**\n * Validate spec.config.yaml: a schema-valid config, a buildable dependency\n * graph (issue #13), and declared spec paths that actually resolve. An entry\n * that matches no files makes every downstream verdict vacuous, so it is\n * reported here rather than silently flowing into lint/status/ready.\n */\nexport async function runValidate(configDir: string): Promise<ValidateResult> {\n const warnings: string[] = [];\n try {\n const config = await loadConfig(undefined, configDir);\n buildGraph(config);\n\n let specFileCount = 0;\n const missingRequired: string[] = [];\n for (const [key, entry] of Object.entries(config.specs)) {\n const files = await resolveGlob(entry.path, configDir);\n specFileCount += files.length;\n if (files.length > 0) continue;\n\n if ((entry as { required?: boolean }).required) {\n missingRequired.push(`\"${key}\" (${entry.path})`);\n } else {\n warnings.push(`spec entry \"${key}\" resolves to no files: ${entry.path}`);\n }\n }\n\n if (missingRequired.length > 0) {\n return {\n valid: false,\n specCount: Object.keys(config.specs).length,\n specFileCount,\n warnings,\n error: `required spec entry resolves to no files: ${missingRequired.join(\", \")}`,\n };\n }\n\n if (specFileCount === 0) {\n warnings.push(\n \"no spec files found — every downstream check (lint, status, ready) would pass vacuously\",\n );\n }\n\n return {\n valid: true,\n specCount: Object.keys(config.specs).length,\n specFileCount,\n warnings,\n };\n } catch (err) {\n if (err instanceof ConfigError) {\n return { valid: false, warnings, error: err.message, details: err.errors ?? undefined };\n }\n if (err instanceof GraphError) {\n return { valid: false, warnings, error: err.message };\n }\n throw err;\n }\n}\n\nexport default defineCommand({\n meta: { name: \"validate\", description: \"Validate spec.config.yaml\" },\n args: { ...sharedArgs },\n async run() {\n const result = await runValidate(process.cwd());\n\n if (result.valid) {\n console.log(\n ` ✓ Config valid. ${result.specCount} spec entries, ${result.specFileCount} spec files.`,\n );\n for (const w of result.warnings) console.log(` ⚠ ${w}`);\n return;\n }\n\n console.error(` ✗ Config invalid: ${result.error}`);\n for (const w of result.warnings) console.error(` ⚠ ${w}`);\n if (result.details) {\n for (const e of result.details) console.error(` - ${JSON.stringify(e)}`);\n }\n process.exit(1);\n },\n});\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAsB9B,eAAsB,YAAY,WAA4C;AAC5E,QAAM,WAAqB,CAAC;AAC5B,MAAI;AACF,UAAM,SAAS,MAAM,WAAW,QAAW,SAAS;AACpD,eAAW,MAAM;AAEjB,QAAI,gBAAgB;AACpB,UAAM,kBAA4B,CAAC;AACnC,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,KAAK,GAAG;AACvD,YAAM,QAAQ,MAAM,YAAY,MAAM,MAAM,SAAS;AACrD,uBAAiB,MAAM;AACvB,UAAI,MAAM,SAAS,EAAG;AAEtB,UAAK,MAAiC,UAAU;AAC9C,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