specdx 0.4.0-alpha.9 → 0.4.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/.claude-plugin/plugin.json +7 -2
- package/README.md +259 -0
- package/dist/{check-4FSSC6HN.js → check-PHXXA7VY.js} +68 -30
- package/dist/check-PHXXA7VY.js.map +1 -0
- package/dist/chunk-2BZIG7OE.js +185 -0
- package/dist/chunk-2BZIG7OE.js.map +1 -0
- package/dist/{chunk-N77RNV7J.js → chunk-3YXRWQGX.js} +217 -42
- package/dist/chunk-3YXRWQGX.js.map +1 -0
- package/dist/chunk-5WRI5ZAA.js +31 -0
- package/dist/chunk-DMGABJ6T.js +41 -0
- package/dist/chunk-DMGABJ6T.js.map +1 -0
- package/dist/{chunk-7JXW2GTJ.js → chunk-HCJDCS26.js} +9 -2
- package/dist/chunk-HCJDCS26.js.map +1 -0
- package/dist/chunk-LJTLNXGV.js +835 -0
- package/dist/chunk-LJTLNXGV.js.map +1 -0
- package/dist/chunk-NAWYG4VV.js +2846 -0
- package/dist/chunk-NAWYG4VV.js.map +1 -0
- package/dist/chunk-NHD44ZYN.js +20 -0
- package/dist/chunk-NHD44ZYN.js.map +1 -0
- package/dist/chunk-OVIKIIR4.js +103 -0
- package/dist/chunk-OVIKIIR4.js.map +1 -0
- package/dist/{chunk-IHTYAW7C.js → chunk-SNQNQ2MP.js} +111 -7
- package/dist/chunk-SNQNQ2MP.js.map +1 -0
- package/dist/{chunk-AKNPCB37.js → chunk-YRQPY5NF.js} +32 -12
- package/dist/chunk-YRQPY5NF.js.map +1 -0
- package/dist/diff-6C5LJ7SH.js +200 -0
- package/dist/diff-6C5LJ7SH.js.map +1 -0
- package/dist/{dist-4DIRTBJH.js → dist-PK52GA7M.js} +43 -20
- package/dist/dist-PK52GA7M.js.map +1 -0
- package/dist/{dist-RL2DT3ZE.js → dist-ROHCFKYT.js} +3 -2
- package/dist/dist-ROHCFKYT.js.map +1 -0
- package/dist/generate-K72WD455.js +21 -0
- package/dist/generate-K72WD455.js.map +1 -0
- package/dist/{generate-story-EFHGINHA.js → generate-story-NUCNYL3I.js} +43 -19
- package/dist/generate-story-NUCNYL3I.js.map +1 -0
- package/dist/{generate-test-plan-BO7444RG.js → generate-test-plan-Z46W3N3B.js} +61 -11
- package/dist/generate-test-plan-Z46W3N3B.js.map +1 -0
- package/dist/{graph-5XINV7PT.js → graph-4RNURBNP.js} +49 -11
- package/dist/graph-4RNURBNP.js.map +1 -0
- package/dist/index.d.ts +275 -0
- package/dist/index.js +2660 -371
- package/dist/index.js.map +1 -1
- package/dist/{lint-PTMWMLDQ.js → lint-2VZPNLE3.js} +46 -18
- package/dist/lint-2VZPNLE3.js.map +1 -0
- package/dist/main.js +10 -229
- package/dist/main.js.map +1 -1
- package/dist/mcp-E6PJWBDQ.js +35 -0
- package/dist/mcp-E6PJWBDQ.js.map +1 -0
- package/dist/{migrate-4KF6GHLO.js → migrate-FKFC7UAO.js} +21 -9
- package/dist/migrate-FKFC7UAO.js.map +1 -0
- package/dist/{pack-DSOODXAN.js → pack-DE4UBTCC.js} +41 -13
- package/dist/pack-DE4UBTCC.js.map +1 -0
- package/dist/{ready-6DNKIHP6.js → ready-K74SLQ24.js} +55 -14
- package/dist/ready-K74SLQ24.js.map +1 -0
- package/dist/skills/{specdx-author-spec.md → core/specdx-author-spec/SKILL.md} +10 -6
- package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-01-frontmatter.md +1 -1
- package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-02-sections.md +41 -0
- package/dist/skills/{specdx-onboard.md → core/specdx-onboard/SKILL.md} +8 -3
- package/dist/skills/{specdx-plan-from-spec.md → core/specdx-plan-from-spec/SKILL.md} +5 -1
- package/dist/skills/{specdx-pre-commit.md → core/specdx-pre-commit/SKILL.md} +16 -2
- package/dist/skills/{specdx-review-spec.md → core/specdx-review-spec/SKILL.md} +5 -1
- package/dist/skills/core/specdx-router/SKILL.md +67 -0
- package/dist/skills/{specdx-sprint-review.md → core/specdx-sprint-review/SKILL.md} +6 -2
- package/dist/skills/{specdx-start-task.md → core/specdx-start-task/SKILL.md} +5 -1
- package/dist/skills/{specdx-check-drift.md → experimental/specdx-check-drift/SKILL.md} +10 -4
- package/dist/skills/{specdx-verify.md → experimental/specdx-verify/SKILL.md} +6 -2
- package/dist/skills-36SRUEMR.js +121 -0
- package/dist/skills-36SRUEMR.js.map +1 -0
- package/dist/{status-WZK247CI.js → status-IAE3BB77.js} +63 -32
- package/dist/status-IAE3BB77.js.map +1 -0
- package/dist/{update-JTNSYX3B.js → update-UFOHZEAK.js} +22 -12
- package/dist/update-UFOHZEAK.js.map +1 -0
- package/dist/{validate-LBDYWUDX.js → validate-EZHUB5TW.js} +36 -17
- package/dist/validate-EZHUB5TW.js.map +1 -0
- package/hooks/hooks.json +12 -6
- package/hooks/session-start +35 -3
- package/package.json +28 -13
- package/dist/changelog-XUVHY3QK.js +0 -93
- package/dist/changelog-XUVHY3QK.js.map +0 -1
- package/dist/check-4FSSC6HN.js.map +0 -1
- package/dist/chunk-7JXW2GTJ.js.map +0 -1
- package/dist/chunk-AKNPCB37.js.map +0 -1
- package/dist/chunk-DAZCOUVK.js +0 -496
- package/dist/chunk-DAZCOUVK.js.map +0 -1
- package/dist/chunk-GAM4MXPC.js +0 -15
- package/dist/chunk-GAM4MXPC.js.map +0 -1
- package/dist/chunk-IHTYAW7C.js.map +0 -1
- package/dist/chunk-N77RNV7J.js.map +0 -1
- package/dist/chunk-SRZ33RJP.js +0 -1147
- package/dist/chunk-SRZ33RJP.js.map +0 -1
- package/dist/diff-OXZ34NU4.js +0 -107
- package/dist/diff-OXZ34NU4.js.map +0 -1
- package/dist/dist-4DIRTBJH.js.map +0 -1
- package/dist/explain-QBV3AESQ.js +0 -109
- package/dist/explain-QBV3AESQ.js.map +0 -1
- package/dist/generate-7GNPT2WJ.js +0 -13
- package/dist/generate-7GNPT2WJ.js.map +0 -1
- package/dist/generate-story-EFHGINHA.js.map +0 -1
- package/dist/generate-test-plan-BO7444RG.js.map +0 -1
- package/dist/graph-5XINV7PT.js.map +0 -1
- package/dist/lint-PTMWMLDQ.js.map +0 -1
- package/dist/mcp-BGFAPM6G.js +0 -17
- package/dist/mcp-BGFAPM6G.js.map +0 -1
- package/dist/migrate-4KF6GHLO.js.map +0 -1
- package/dist/pack-DSOODXAN.js.map +0 -1
- package/dist/ready-6DNKIHP6.js.map +0 -1
- package/dist/skills-3GBBWZW2.js +0 -93
- package/dist/skills-3GBBWZW2.js.map +0 -1
- package/dist/status-WZK247CI.js.map +0 -1
- package/dist/update-JTNSYX3B.js.map +0 -1
- package/dist/validate-LBDYWUDX.js.map +0 -1
- /package/dist/{dist-RL2DT3ZE.js.map → chunk-5WRI5ZAA.js.map} +0 -0
- /package/dist/skills/{spec-type-reference.md → core/specdx-author-spec/references/spec-type-reference.md} +0 -0
- /package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-03-finalize.md +0 -0
|
@@ -3,13 +3,15 @@ import {
|
|
|
3
3
|
loadConfig,
|
|
4
4
|
parseSpec,
|
|
5
5
|
resolveGlob
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-SNQNQ2MP.js";
|
|
7
|
+
import "./chunk-HCJDCS26.js";
|
|
8
|
+
import "./chunk-5WRI5ZAA.js";
|
|
8
9
|
|
|
9
|
-
// src/commands/generate-test-plan.ts
|
|
10
|
+
// src/commands/experimental/generate-test-plan.ts
|
|
10
11
|
import { defineCommand } from "citty";
|
|
11
12
|
import { writeFile } from "fs/promises";
|
|
12
|
-
import {
|
|
13
|
+
import { existsSync } from "fs";
|
|
14
|
+
import { join, relative, resolve } from "path";
|
|
13
15
|
function extractSection(content, heading) {
|
|
14
16
|
const escapedHeading = heading.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
15
17
|
const headingPattern = new RegExp(`^##\\s+${escapedHeading}\\s*$`, "im");
|
|
@@ -35,7 +37,7 @@ function parseAcceptanceCriteria(section) {
|
|
|
35
37
|
return cases;
|
|
36
38
|
}
|
|
37
39
|
async function generateTestPlan(options) {
|
|
38
|
-
const { configDir, outPath } = options;
|
|
40
|
+
const { configDir, outPath, force = false } = options;
|
|
39
41
|
const config = await loadConfig(void 0, configDir);
|
|
40
42
|
const storiesBySpec = [];
|
|
41
43
|
for (const [, entry] of Object.entries(config.specs)) {
|
|
@@ -110,14 +112,29 @@ ${caseBullets}`;
|
|
|
110
112
|
const fileContent = `${frontmatter}
|
|
111
113
|
|
|
112
114
|
${body}`;
|
|
115
|
+
if (storiesBySpec.length === 0) {
|
|
116
|
+
return { testCases: 0 };
|
|
117
|
+
}
|
|
113
118
|
const targetPath = outPath ?? join(configDir, "specs", "test-plan.md");
|
|
119
|
+
if (!force && existsSync(targetPath)) {
|
|
120
|
+
return { testCases: totalTestCases, blockedBy: targetPath };
|
|
121
|
+
}
|
|
114
122
|
await writeFile(targetPath, fileContent, "utf-8");
|
|
115
123
|
return { filePath: targetPath, testCases: totalTestCases };
|
|
116
124
|
}
|
|
125
|
+
async function registeredKeyFor(configDir, filePath) {
|
|
126
|
+
const config = await loadConfig(void 0, configDir);
|
|
127
|
+
for (const [key, entry] of Object.entries(config.specs)) {
|
|
128
|
+
for (const resolved of await resolveGlob(entry.path, configDir)) {
|
|
129
|
+
if (resolve(resolved) === resolve(filePath)) return key;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return void 0;
|
|
133
|
+
}
|
|
117
134
|
var generate_test_plan_default = defineCommand({
|
|
118
135
|
meta: {
|
|
119
|
-
name: "
|
|
120
|
-
description: "
|
|
136
|
+
name: "test-plan",
|
|
137
|
+
description: "Generate a test plan stub from user stories"
|
|
121
138
|
},
|
|
122
139
|
args: {
|
|
123
140
|
from: {
|
|
@@ -128,6 +145,11 @@ var generate_test_plan_default = defineCommand({
|
|
|
128
145
|
out: {
|
|
129
146
|
type: "string",
|
|
130
147
|
description: "Output file path (default: specs/test-plan.md)"
|
|
148
|
+
},
|
|
149
|
+
force: {
|
|
150
|
+
type: "boolean",
|
|
151
|
+
description: "Overwrite the file if it already exists",
|
|
152
|
+
default: false
|
|
131
153
|
}
|
|
132
154
|
},
|
|
133
155
|
async run({ args }) {
|
|
@@ -139,11 +161,38 @@ var generate_test_plan_default = defineCommand({
|
|
|
139
161
|
process.exit(1);
|
|
140
162
|
}
|
|
141
163
|
try {
|
|
164
|
+
const configDir = process.cwd();
|
|
142
165
|
const result = await generateTestPlan({
|
|
143
|
-
configDir
|
|
144
|
-
outPath: args.out
|
|
166
|
+
configDir,
|
|
167
|
+
outPath: args.out,
|
|
168
|
+
force: args.force
|
|
145
169
|
});
|
|
170
|
+
if (result.blockedBy) {
|
|
171
|
+
console.error(
|
|
172
|
+
`
|
|
173
|
+
\u2717 ${result.blockedBy} already exists \u2014 not overwriting it.
|
|
174
|
+
Pass --force to replace it, or --out <path> to write elsewhere.
|
|
175
|
+
`
|
|
176
|
+
);
|
|
177
|
+
process.exit(1);
|
|
178
|
+
}
|
|
179
|
+
if (!result.filePath) {
|
|
180
|
+
logger.info("No user stories found \u2014 no test plan generated.");
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
146
183
|
logger.info(`Generated test plan with ${result.testCases} test cases \u2192 ${result.filePath}`);
|
|
184
|
+
const existingKey = await registeredKeyFor(configDir, result.filePath);
|
|
185
|
+
if (existingKey) {
|
|
186
|
+
logger.info(`Already registered in spec.config.yaml as "${existingKey}".`);
|
|
187
|
+
} else {
|
|
188
|
+
const rel = relative(configDir, result.filePath) || result.filePath;
|
|
189
|
+
logger.info(
|
|
190
|
+
`Add it to spec.config.yaml so lint, status and pack can see it:
|
|
191
|
+
test-plan:
|
|
192
|
+
path: ${rel}
|
|
193
|
+
type: test-plan`
|
|
194
|
+
);
|
|
195
|
+
}
|
|
147
196
|
} catch (err) {
|
|
148
197
|
console.error(`
|
|
149
198
|
\u2717 ${err.message}
|
|
@@ -154,6 +203,7 @@ var generate_test_plan_default = defineCommand({
|
|
|
154
203
|
});
|
|
155
204
|
export {
|
|
156
205
|
generate_test_plan_default as default,
|
|
157
|
-
generateTestPlan
|
|
206
|
+
generateTestPlan,
|
|
207
|
+
registeredKeyFor
|
|
158
208
|
};
|
|
159
|
-
//# sourceMappingURL=generate-test-plan-
|
|
209
|
+
//# sourceMappingURL=generate-test-plan-Z46W3N3B.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/experimental/generate-test-plan.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, resolveGlob, createLogger } from \"@specdx/core\";\nimport { writeFile } from \"node:fs/promises\";\nimport { existsSync } from \"node:fs\";\nimport { join, relative, resolve } from \"node:path\";\n\nexport interface GenerateTestPlanOptions {\n configDir: string;\n outPath?: string;\n /** Overwrite an existing file. Off by default -- the file may be hand-written. */\n force?: boolean;\n}\n\nexport interface GenerateTestPlanResult {\n /** Undefined when there was nothing to generate, so no file was written. */\n filePath?: string;\n testCases: number;\n /** Set when a file exists at the target path and `force` was not given. */\n blockedBy?: string;\n}\n\ninterface StoryTestCases {\n storyId: string;\n title: string;\n authors: string[];\n cases: string[];\n}\n\n/**\n * Extracts the content of a `## Heading` section from a markdown string.\n * Returns the text between that heading and the next `## ` heading (or end of string).\n */\nfunction extractSection(content: string, heading: string): string | null {\n const escapedHeading = heading.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const headingPattern = new RegExp(`^##\\\\s+${escapedHeading}\\\\s*$`, \"im\");\n const match = headingPattern.exec(content);\n if (!match) return null;\n\n const start = match.index + match[0].length;\n const rest = content.slice(start);\n\n const nextSection = /^##\\s+/m.exec(rest);\n return nextSection ? rest.slice(0, nextSection.index) : rest;\n}\n\n/**\n * Parses acceptance criteria bullet points from a section string.\n * Handles `- [ ] text`, `- [x] text`, and plain `- text` formats.\n */\nfunction parseAcceptanceCriteria(section: string): string[] {\n const cases: string[] = [];\n for (const rawLine of section.split(\"\\n\")) {\n const line = rawLine.trim();\n // Match bullet lines: `- [ ] text`, `- [x] text`, `- text`\n const bulletMatch = /^-\\s+(?:\\[[ xX]\\]\\s+)?(.+)/.exec(line);\n if (bulletMatch) {\n const text = bulletMatch[1]!.trim();\n if (text) {\n cases.push(text);\n }\n }\n }\n return cases;\n}\n\nexport async function generateTestPlan(\n options: GenerateTestPlanOptions,\n): Promise<GenerateTestPlanResult> {\n const { configDir, outPath, force = false } = options;\n const config = await loadConfig(undefined, configDir);\n\n const storiesBySpec: StoryTestCases[] = [];\n\n for (const [, entry] of Object.entries(config.specs)) {\n if (entry.type !== \"user-story\") continue;\n\n const files = await resolveGlob(entry.path, configDir);\n for (const file of files) {\n const parsed = await parseSpec(file);\n const frontmatter = parsed.frontmatter;\n const storyId = (frontmatter[\"id\"] as string | undefined) ?? file;\n const title = (frontmatter[\"title\"] as string | undefined) ?? storyId;\n const authors = (frontmatter[\"authors\"] as string[] | undefined) ?? [];\n\n const acSection = extractSection(parsed.content, \"Acceptance Criteria\");\n const cases = acSection ? parseAcceptanceCriteria(acSection) : [];\n\n storiesBySpec.push({ storyId, title, authors, cases });\n }\n }\n\n // Sort stories by ID for deterministic output\n storiesBySpec.sort((a, b) => a.storyId.localeCompare(b.storyId));\n\n const today = new Date().toISOString().slice(0, 10);\n\n // Aggregate authors from all stories (deduplicated)\n const allAuthors = Array.from(new Set(storiesBySpec.flatMap((s) => s.authors)));\n\n // Build references to all stories\n const storyRefs = storiesBySpec.map(\n (s) => ` - id: \"${s.storyId}\"\\n relationship: \"related-to\"`,\n );\n\n const totalTestCases = storiesBySpec.reduce((sum, s) => sum + s.cases.length, 0);\n\n // Build frontmatter\n const authorsYaml =\n allAuthors.length > 0 ? `[${allAuthors.map((a) => `\"${a}\"`).join(\", \")}]` : '[\"generated\"]';\n\n const refsYaml = storyRefs.length > 0 ? `\\nreferences:\\n${storyRefs.join(\"\\n\")}` : \"\";\n\n const frontmatter = [\n \"---\",\n 'id: \"generated-test-plan\"',\n 'type: \"test-plan\"',\n 'title: \"Generated Test Plan\"',\n 'status: \"draft\"',\n 'version: \"0.1\"',\n `created: \"${today}\"`,\n `authors: ${authorsYaml}`,\n refsYaml.length > 0 ? refsYaml.trimStart() : null,\n \"---\",\n ]\n .filter((line) => line !== null)\n .join(\"\\n\");\n\n // ## Scope\n const scopeLines =\n storiesBySpec.length > 0\n ? storiesBySpec.map((s) => `- ${s.storyId}: ${s.title}`).join(\"\\n\")\n : \"_No user stories found._\";\n\n // ## Test Cases — grouped by story\n const testCaseBlocks = storiesBySpec\n .map((s) => {\n const caseBullets =\n s.cases.length > 0\n ? s.cases.map((c) => `- [ ] ${c}`).join(\"\\n\")\n : \"_No acceptance criteria found._\";\n return `### ${s.storyId}\\n\\n${caseBullets}`;\n })\n .join(\"\\n\\n\");\n\n const testCasesBody = storiesBySpec.length > 0 ? testCaseBlocks : \"_No user stories found._\";\n\n // ## Coverage Matrix\n const matrixHeader = \"| Story | Test Cases |\";\n const matrixSep = \"| ----- | ---------- |\";\n const matrixRows = storiesBySpec.map((s) => `| ${s.storyId} | ${s.cases.length} |`);\n const coverageMatrix = [matrixHeader, matrixSep, ...matrixRows].join(\"\\n\");\n\n // ## Edge Cases\n const edgeCasesPlaceholder = \"<!-- Add edge cases and boundary conditions here -->\";\n\n const body = [\n `## Scope`,\n \"\",\n scopeLines,\n \"\",\n `## Test Cases`,\n \"\",\n testCasesBody,\n \"\",\n `## Coverage Matrix`,\n \"\",\n coverageMatrix,\n \"\",\n `## Edge Cases`,\n \"\",\n edgeCasesPlaceholder,\n \"\",\n ].join(\"\\n\");\n\n const fileContent = `${frontmatter}\\n\\n${body}`;\n\n // Nothing to build a plan from. Writing a spec whose every section reads\n // \"_No user stories found._\" would add a file the linter then flags and the\n // suite has to carry -- `generate story` already declines in this case.\n if (storiesBySpec.length === 0) {\n return { testCases: 0 };\n }\n\n const targetPath = outPath ?? join(configDir, \"specs\", \"test-plan.md\");\n\n // A generator must not destroy hand-written work. This overwrote an approved\n // spec -- registered in the config, with a filled-in coverage matrix -- and\n // replaced it with a draft stub, silently and with exit 0. The only reason it\n // was recoverable was that the project happened to use git.\n if (!force && existsSync(targetPath)) {\n return { testCases: totalTestCases, blockedBy: targetPath };\n }\n\n await writeFile(targetPath, fileContent, \"utf-8\");\n\n return { filePath: targetPath, testCases: totalTestCases };\n}\n\n/**\n * The config key, if any, already pointing at `filePath`.\n *\n * Telling an author to register a file the config already knows about invites a\n * duplicate entry for one path -- which is how a frontmatter id and its key\n * come to disagree.\n */\nexport async function registeredKeyFor(\n configDir: string,\n filePath: string,\n): Promise<string | undefined> {\n const config = await loadConfig(undefined, configDir);\n for (const [key, entry] of Object.entries(config.specs)) {\n for (const resolved of await resolveGlob(entry.path, configDir)) {\n if (resolve(resolved) === resolve(filePath)) return key;\n }\n }\n return undefined;\n}\n\nexport default defineCommand({\n meta: {\n name: \"test-plan\",\n description: \"Generate a test plan stub from user stories\",\n },\n args: {\n from: {\n type: \"string\",\n description: \"Source to generate from (currently only 'stories' is supported)\",\n default: \"stories\",\n },\n out: {\n type: \"string\",\n description: \"Output file path (default: specs/test-plan.md)\",\n },\n force: {\n type: \"boolean\",\n description: \"Overwrite the file if it already exists\",\n default: false,\n },\n },\n async run({ args }) {\n const logger = createLogger({ quiet: false, verbose: false });\n\n if (args.from !== \"stories\") {\n console.error(`\\n ✗ --from must be 'stories' (got: ${args.from})\\n`);\n process.exit(1);\n }\n\n try {\n const configDir = process.cwd();\n const result = await generateTestPlan({\n configDir,\n outPath: args.out,\n force: args.force,\n });\n\n if (result.blockedBy) {\n console.error(\n `\\n ✗ ${result.blockedBy} already exists — not overwriting it.\\n` +\n \" Pass --force to replace it, or --out <path> to write elsewhere.\\n\",\n );\n process.exit(1);\n }\n\n if (!result.filePath) {\n logger.info(\"No user stories found — no test plan generated.\");\n return;\n }\n\n logger.info(`Generated test plan with ${result.testCases} test cases → ${result.filePath}`);\n\n // Only worth saying when it is actually unregistered. Advising a key for\n // a path the config already maps produces two entries for one file.\n const existingKey = await registeredKeyFor(configDir, result.filePath);\n if (existingKey) {\n logger.info(`Already registered in spec.config.yaml as \"${existingKey}\".`);\n } else {\n const rel = relative(configDir, result.filePath) || result.filePath;\n logger.info(\n \"Add it to spec.config.yaml so lint, status and pack can see it:\\n\" +\n ` test-plan:\\n path: ${rel}\\n type: test-plan`,\n );\n }\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n },\n});\n"],"mappings":";;;;;;;;;;AAAA,SAAS,qBAAqB;AAE9B,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,MAAM,UAAU,eAAe;AA4BxC,SAAS,eAAe,SAAiB,SAAgC;AACvE,QAAM,iBAAiB,QAAQ,QAAQ,uBAAuB,MAAM;AACpE,QAAM,iBAAiB,IAAI,OAAO,UAAU,cAAc,SAAS,IAAI;AACvE,QAAM,QAAQ,eAAe,KAAK,OAAO;AACzC,MAAI,CAAC,MAAO,QAAO;AAEnB,QAAM,QAAQ,MAAM,QAAQ,MAAM,CAAC,EAAE;AACrC,QAAM,OAAO,QAAQ,MAAM,KAAK;AAEhC,QAAM,cAAc,UAAU,KAAK,IAAI;AACvC,SAAO,cAAc,KAAK,MAAM,GAAG,YAAY,KAAK,IAAI;AAC1D;AAMA,SAAS,wBAAwB,SAA2B;AAC1D,QAAM,QAAkB,CAAC;AACzB,aAAW,WAAW,QAAQ,MAAM,IAAI,GAAG;AACzC,UAAM,OAAO,QAAQ,KAAK;AAE1B,UAAM,cAAc,6BAA6B,KAAK,IAAI;AAC1D,QAAI,aAAa;AACf,YAAM,OAAO,YAAY,CAAC,EAAG,KAAK;AAClC,UAAI,MAAM;AACR,cAAM,KAAK,IAAI;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEA,eAAsB,iBACpB,SACiC;AACjC,QAAM,EAAE,WAAW,SAAS,QAAQ,MAAM,IAAI;AAC9C,QAAM,SAAS,MAAM,W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OAAO,WAAW;AACpB,gBAAQ;AAAA,UACN;AAAA,WAAS,OAAO,SAAS;AAAA;AAAA;AAAA,QAE3B;AACA,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAEA,UAAI,CAAC,OAAO,UAAU;AACpB,eAAO,KAAK,sDAAiD;AAC7D;AAAA,MACF;AAEA,aAAO,KAAK,4BAA4B,OAAO,SAAS,sBAAiB,OAAO,QAAQ,EAAE;AAI1F,YAAM,cAAc,MAAM,iBAAiB,WAAW,OAAO,QAAQ;AACrE,UAAI,aAAa;AACf,eAAO,KAAK,8CAA8C,WAAW,IAAI;AAAA,MAC3E,OAAO;AACL,cAAM,MAAM,SAAS,WAAW,OAAO,QAAQ,KAAK,OAAO;AAC3D,eAAO;AAAA,UACL;AAAA;AAAA,YAC6B,GAAG;AAAA;AAAA,QAClC;AAAA,MACF;AAAA,IACF,SAAS,KAAK;AACZ,cAAQ,MAAM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;","names":["frontmatter"]}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
+
createOutput
|
|
3
|
+
} from "./chunk-NHD44ZYN.js";
|
|
4
|
+
import {
|
|
5
|
+
resolveFormat,
|
|
2
6
|
sharedArgs
|
|
3
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-DMGABJ6T.js";
|
|
4
8
|
import {
|
|
5
9
|
GraphError,
|
|
6
10
|
buildGraph,
|
|
@@ -9,15 +13,25 @@ import {
|
|
|
9
13
|
loadConfig,
|
|
10
14
|
parseSpec,
|
|
11
15
|
resolveGlob
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-SNQNQ2MP.js";
|
|
17
|
+
import "./chunk-HCJDCS26.js";
|
|
18
|
+
import "./chunk-5WRI5ZAA.js";
|
|
14
19
|
|
|
15
|
-
// src/commands/graph.ts
|
|
20
|
+
// src/commands/core/graph.ts
|
|
16
21
|
import { defineCommand } from "citty";
|
|
22
|
+
var FORMATS = ["pretty", "json", "dot"];
|
|
17
23
|
var graph_default = defineCommand({
|
|
18
24
|
meta: { name: "graph", description: "Print the spec dependency graph" },
|
|
19
|
-
args: { ...sharedArgs },
|
|
25
|
+
args: { ...sharedArgs(FORMATS) },
|
|
20
26
|
async run({ args }) {
|
|
27
|
+
const format = resolveFormat(args.format, FORMATS);
|
|
28
|
+
if (!format.ok) {
|
|
29
|
+
console.error(`
|
|
30
|
+
\u2717 ${format.message}
|
|
31
|
+
`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
const output = createOutput({ quiet: args.quiet });
|
|
21
35
|
let config;
|
|
22
36
|
const configDir = process.cwd();
|
|
23
37
|
try {
|
|
@@ -45,7 +59,31 @@ var graph_default = defineCommand({
|
|
|
45
59
|
}
|
|
46
60
|
const referenceEdges = collectReferenceEdges(specs);
|
|
47
61
|
const unreflected = findUnreflectedReferences(referenceEdges, idToEntry, graph);
|
|
48
|
-
if (
|
|
62
|
+
if (format.format === "json") {
|
|
63
|
+
console.log(
|
|
64
|
+
JSON.stringify(
|
|
65
|
+
{
|
|
66
|
+
nodes: sorted,
|
|
67
|
+
edges: graph.edges,
|
|
68
|
+
referenceEdges,
|
|
69
|
+
unreflectedReferences: unreflected.map(
|
|
70
|
+
({ edge, requiringEntry, requiredEntry, createsCycle }) => ({
|
|
71
|
+
from: edge.fromId,
|
|
72
|
+
to: edge.toId,
|
|
73
|
+
relationship: edge.relationship,
|
|
74
|
+
requiringEntry,
|
|
75
|
+
requiredEntry,
|
|
76
|
+
createsCycle
|
|
77
|
+
})
|
|
78
|
+
)
|
|
79
|
+
},
|
|
80
|
+
null,
|
|
81
|
+
2
|
|
82
|
+
)
|
|
83
|
+
);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (format.format === "dot") {
|
|
49
87
|
console.log("digraph specs {");
|
|
50
88
|
for (const edge of graph.edges) console.log(` "${edge.from}" -> "${edge.to}";`);
|
|
51
89
|
for (const ref of referenceEdges) {
|
|
@@ -56,16 +94,16 @@ var graph_default = defineCommand({
|
|
|
56
94
|
console.log("}");
|
|
57
95
|
return;
|
|
58
96
|
}
|
|
59
|
-
|
|
97
|
+
output.info("\n Spec Dependency Graph:\n");
|
|
60
98
|
for (const node of sorted) {
|
|
61
99
|
const downstream = graph.getDownstream(node);
|
|
62
100
|
const arrow = downstream.length > 0 ? ` \u2192 ${downstream.join(", ")}` : "";
|
|
63
|
-
|
|
101
|
+
output.out(` ${node}${arrow}`);
|
|
64
102
|
}
|
|
65
103
|
if (referenceEdges.length > 0) {
|
|
66
|
-
|
|
104
|
+
output.info("\n Reference edges (frontmatter):\n");
|
|
67
105
|
for (const ref of referenceEdges) {
|
|
68
|
-
|
|
106
|
+
output.out(` ${ref.fromId} \u2014${ref.relationship}\u2192 ${ref.toId}`);
|
|
69
107
|
}
|
|
70
108
|
}
|
|
71
109
|
const suggestions = unreflected.filter((u) => !u.createsCycle);
|
|
@@ -99,4 +137,4 @@ var graph_default = defineCommand({
|
|
|
99
137
|
export {
|
|
100
138
|
graph_default as default
|
|
101
139
|
};
|
|
102
|
-
//# sourceMappingURL=graph-
|
|
140
|
+
//# sourceMappingURL=graph-4RNURBNP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/core/graph.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport {\n loadConfig,\n buildGraph,\n GraphError,\n parseSpec,\n resolveGlob,\n collectReferenceEdges,\n findUnreflectedReferences,\n} from \"@specdx/core\";\nimport type { ParsedSpec } from \"@specdx/core\";\nimport { sharedArgs, resolveFormat } from \"../../shared-args.js\";\nimport { createOutput } from \"../../output.js\";\n\nconst FORMATS = [\"pretty\", \"json\", \"dot\"] as const;\n\nexport default defineCommand({\n meta: { name: \"graph\", description: \"Print the spec dependency graph\" },\n args: { ...sharedArgs(FORMATS) },\n async run({ args }) {\n const format = resolveFormat(args.format, FORMATS);\n if (!format.ok) {\n console.error(`\\n ✗ ${format.message}\\n`);\n process.exit(1);\n }\n const output = createOutput({ quiet: args.quiet });\n\n let config;\n const configDir = process.cwd();\n try {\n config = await loadConfig(undefined, configDir);\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n try {\n const graph = buildGraph(config);\n const sorted = graph.topologicalSort();\n\n // Frontmatter references are a second, richer source of relationships;\n // surface them alongside config requires instead of silently ignoring\n // them (issue #8).\n const idToEntry = new Map<string, string>();\n const specs: ParsedSpec[] = [];\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(spec);\n if (typeof spec.frontmatter.id === \"string\") {\n idToEntry.set(spec.frontmatter.id, key);\n }\n }\n }\n const referenceEdges = collectReferenceEdges(specs);\n const unreflected = findUnreflectedReferences(referenceEdges, idToEntry, graph);\n\n if (format.format === \"json\") {\n console.log(\n JSON.stringify(\n {\n nodes: sorted,\n edges: graph.edges,\n referenceEdges,\n unreflectedReferences: unreflected.map(\n ({ edge, requiringEntry, requiredEntry, createsCycle }) => ({\n from: edge.fromId,\n to: edge.toId,\n relationship: edge.relationship,\n requiringEntry,\n requiredEntry,\n createsCycle,\n }),\n ),\n },\n null,\n 2,\n ),\n );\n return;\n }\n\n if (format.format === \"dot\") {\n console.log(\"digraph specs {\");\n for (const edge of graph.edges) console.log(` \"${edge.from}\" -> \"${edge.to}\";`);\n for (const ref of referenceEdges) {\n console.log(\n ` \"${ref.fromId}\" -> \"${ref.toId}\" [style=dashed, label=\"${ref.relationship}\"];`,\n );\n }\n console.log(\"}\");\n return;\n }\n\n output.info(\"\\n Spec Dependency Graph:\\n\");\n for (const node of sorted) {\n const downstream = graph.getDownstream(node);\n const arrow = downstream.length > 0 ? ` → ${downstream.join(\", \")}` : \"\";\n output.out(` ${node}${arrow}`);\n }\n\n if (referenceEdges.length > 0) {\n output.info(\"\\n Reference edges (frontmatter):\\n\");\n for (const ref of referenceEdges) {\n output.out(` ${ref.fromId} —${ref.relationship}→ ${ref.toId}`);\n }\n }\n\n const suggestions = unreflected.filter((u) => !u.createsCycle);\n const conflicts = unreflected.filter((u) => u.createsCycle);\n\n if (suggestions.length > 0) {\n console.log(\"\\n ⚠ References not reflected in config requires:\\n\");\n for (const { edge, requiringEntry, requiredEntry } of suggestions) {\n console.log(\n ` ${edge.fromId} ${edge.relationship} ${edge.toId} — add \"requires: [${requiredEntry}]\" to the \"${requiringEntry}\" entry in spec.config.yaml`,\n );\n }\n }\n\n if (conflicts.length > 0) {\n console.log(\"\\n ⚠ References that conflict with the requires chain:\\n\");\n for (const { edge, requiringEntry, requiredEntry } of conflicts) {\n console.log(\n ` ${edge.fromId} ${edge.relationship} ${edge.toId} — implies \"${requiringEntry}\" requires \"${requiredEntry}\", but that would create a cycle; review the reference or the config requires`,\n );\n }\n }\n\n console.log(\"\");\n } catch (err) {\n if (err instanceof GraphError) {\n console.error(` ✗ ${err.message}`);\n process.exit(1);\n }\n throw err;\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAc9B,IAAM,UAAU,CAAC,UAAU,QAAQ,KAAK;AAExC,IAAO,gBAAQ,cAAc;AAAA,EAC3B,MAAM,EAAE,MAAM,SAAS,aAAa,kCAAkC;AAAA,EACtE,MAAM,EAAE,GAAG,WAAW,OAAO,EAAE;AAAA,EAC/B,MAAM,IAAI,EAAE,KAAK,GAAG;AAClB,UAAM,SAAS,cAAc,KAAK,QAAQ,OAAO;AACjD,QAAI,CAAC,OAAO,IAAI;AACd,cAAQ,MAAM;AAAA,WAAS,OAAO,OAAO;AAAA,CAAI;AACzC,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,UAAM,SAAS,aAAa,EAAE,OAAO,KAAK,MAAM,CAAC;AAEjD,QAAI;AACJ,UAAM,YAAY,QAAQ,IAAI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,QACF;AAAA,MACF;AAEA,cAAQ,IAAI,EAAE;AAAA,IAChB,SAAS,KAAK;AACZ,UAAI,eAAe,YAAY;AAC7B,gBAAQ,MAAM,YAAO,IAAI,OAAO,EAAE;AAClC,gBAAQ,KAAK,CAAC;AAAA,MAChB;AACA,YAAM;AAAA,IACR;AAAA,EACF;AACF,CAAC;","names":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
type Template = "lightweight" | "bmad" | "api-first" | "quick" | "context";
|
|
2
|
+
interface ScaffoldOptions {
|
|
3
|
+
projectName: string;
|
|
4
|
+
template: Template;
|
|
5
|
+
targetDir: string;
|
|
6
|
+
}
|
|
7
|
+
declare function scaffoldProject({ projectName, template, targetDir, }: ScaffoldOptions): Promise<void>;
|
|
8
|
+
|
|
9
|
+
declare const SPEC_TYPES: readonly ["prd", "technical-design", "user-story", "test-plan", "adr", "api-contract", "epic", "quick-spec", "project-context"];
|
|
10
|
+
type SpecType = (typeof SPEC_TYPES)[number];
|
|
11
|
+
interface SpecEntry {
|
|
12
|
+
path: string;
|
|
13
|
+
type: SpecType;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
requires?: string[];
|
|
16
|
+
owner?: string;
|
|
17
|
+
}
|
|
18
|
+
interface PackCompressionConfig {
|
|
19
|
+
strip_boilerplate?: boolean;
|
|
20
|
+
stable_days?: number;
|
|
21
|
+
collapse_resolved_adrs?: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface PackConfig {
|
|
24
|
+
max_tokens?: number;
|
|
25
|
+
format?: "xml" | "markdown" | "json";
|
|
26
|
+
compression?: PackCompressionConfig;
|
|
27
|
+
boilerplate_sections?: string[];
|
|
28
|
+
}
|
|
29
|
+
interface SdxConfig {
|
|
30
|
+
version: string;
|
|
31
|
+
project?: {
|
|
32
|
+
name?: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
};
|
|
35
|
+
specs: Record<string, SpecEntry>;
|
|
36
|
+
lint?: {
|
|
37
|
+
extends?: string;
|
|
38
|
+
rules?: Record<string, unknown>;
|
|
39
|
+
ignore?: string[];
|
|
40
|
+
};
|
|
41
|
+
pack?: PackConfig;
|
|
42
|
+
diff?: {
|
|
43
|
+
baseline_ref?: string;
|
|
44
|
+
staleness_threshold_days?: number;
|
|
45
|
+
ignore_paths?: string[];
|
|
46
|
+
};
|
|
47
|
+
ci?: {
|
|
48
|
+
block_on?: ("error" | "warn" | "info")[];
|
|
49
|
+
post_comment?: boolean;
|
|
50
|
+
update_badge?: boolean;
|
|
51
|
+
trigger_paths?: string[];
|
|
52
|
+
};
|
|
53
|
+
check?: {
|
|
54
|
+
framework?: "auto" | "express" | "hono" | "nextjs";
|
|
55
|
+
routes_dir?: string;
|
|
56
|
+
app_dir?: string;
|
|
57
|
+
types_dir?: string;
|
|
58
|
+
tests_dir?: string;
|
|
59
|
+
ignore?: string[];
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
type Severity = "error" | "warn" | "info";
|
|
64
|
+
interface Diagnostic {
|
|
65
|
+
ruleId: string;
|
|
66
|
+
severity: Severity;
|
|
67
|
+
message: string;
|
|
68
|
+
filePath: string;
|
|
69
|
+
line?: number;
|
|
70
|
+
section?: string;
|
|
71
|
+
}
|
|
72
|
+
interface LintResults {
|
|
73
|
+
diagnostics: Diagnostic[];
|
|
74
|
+
hasErrors: boolean;
|
|
75
|
+
hasWarnings: boolean;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface RunLintOptions {
|
|
79
|
+
configDir: string;
|
|
80
|
+
specPath?: string;
|
|
81
|
+
preset?: "minimal" | "recommended" | "strict";
|
|
82
|
+
}
|
|
83
|
+
/** Lint results plus whether anything was actually linted (vacuous-pass audit). */
|
|
84
|
+
interface RunLintResults extends LintResults {
|
|
85
|
+
/** Number of spec files linted. Named for what it counts, not "count". */
|
|
86
|
+
specFiles: number;
|
|
87
|
+
/** False when no specs resolved — "no diagnostics" is then not a pass. */
|
|
88
|
+
assessed: boolean;
|
|
89
|
+
}
|
|
90
|
+
declare function runLint(options: RunLintOptions): Promise<RunLintResults>;
|
|
91
|
+
|
|
92
|
+
/** Options for the pack command. */
|
|
93
|
+
interface PackOptions {
|
|
94
|
+
/** Specific task or context to optimise relevance for. */
|
|
95
|
+
task?: string;
|
|
96
|
+
/** Glob patterns or spec IDs to include. */
|
|
97
|
+
specs?: string[];
|
|
98
|
+
/** Maximum token budget for the output. */
|
|
99
|
+
budget?: number;
|
|
100
|
+
/** Output format (e.g. "xml", "json", "markdown"). */
|
|
101
|
+
format?: string;
|
|
102
|
+
/** Include all specs without budget trimming. */
|
|
103
|
+
full?: boolean;
|
|
104
|
+
/** Preview what would be packed without writing output. */
|
|
105
|
+
dryRun?: boolean;
|
|
106
|
+
}
|
|
107
|
+
/** Statistics about how the budget was allocated. */
|
|
108
|
+
interface PackStats {
|
|
109
|
+
/** Total token budget. */
|
|
110
|
+
budget: number;
|
|
111
|
+
/** Tokens actually used. */
|
|
112
|
+
used: number;
|
|
113
|
+
/** Number of specs included in the output. */
|
|
114
|
+
specsIncluded: number;
|
|
115
|
+
/** Number of specs excluded due to budget or relevance. */
|
|
116
|
+
specsExcluded: number;
|
|
117
|
+
/** Number of sections that were compressed. */
|
|
118
|
+
sectionsCompressed: number;
|
|
119
|
+
/** Number of sections omitted entirely to fit the budget. */
|
|
120
|
+
sectionsOmitted: number;
|
|
121
|
+
/** Per-spec allocation details. */
|
|
122
|
+
allocations: SpecAllocation[];
|
|
123
|
+
}
|
|
124
|
+
/** Result returned by the pack operation. */
|
|
125
|
+
interface PackResult {
|
|
126
|
+
/** The formatted output string. */
|
|
127
|
+
output: string;
|
|
128
|
+
/** Statistics about the pack run. */
|
|
129
|
+
stats: PackStats;
|
|
130
|
+
}
|
|
131
|
+
/** Token allocation detail for a single spec. */
|
|
132
|
+
interface SpecAllocation {
|
|
133
|
+
/** Identifier of the spec. */
|
|
134
|
+
specId: string;
|
|
135
|
+
/** Spec type (e.g. "adr", "rfc", "runbook"). */
|
|
136
|
+
type: string;
|
|
137
|
+
/** Computed relevance score (0-1). */
|
|
138
|
+
relevance: number;
|
|
139
|
+
/** Tokens allocated to this spec. */
|
|
140
|
+
tokens: number;
|
|
141
|
+
/** Whether this spec was compressed. */
|
|
142
|
+
compressed: boolean;
|
|
143
|
+
/** Whether this spec was included in the output. */
|
|
144
|
+
included: boolean;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
interface RunPackOptions {
|
|
148
|
+
configDir: string;
|
|
149
|
+
task?: string;
|
|
150
|
+
specs?: string[];
|
|
151
|
+
budget?: number;
|
|
152
|
+
format?: "xml" | "markdown" | "json";
|
|
153
|
+
full?: boolean;
|
|
154
|
+
dryRun?: boolean;
|
|
155
|
+
}
|
|
156
|
+
declare function runPack(options: RunPackOptions): Promise<PackResult & {
|
|
157
|
+
specsResolved: number;
|
|
158
|
+
}>;
|
|
159
|
+
|
|
160
|
+
type FieldChangeType = "added" | "removed" | "modified" | "broken-reference";
|
|
161
|
+
interface FieldChange {
|
|
162
|
+
field: string;
|
|
163
|
+
type: FieldChangeType;
|
|
164
|
+
before?: unknown;
|
|
165
|
+
after?: unknown;
|
|
166
|
+
}
|
|
167
|
+
interface SectionChange {
|
|
168
|
+
heading: string;
|
|
169
|
+
type: "added" | "removed" | "modified";
|
|
170
|
+
contentDiff?: string;
|
|
171
|
+
}
|
|
172
|
+
interface SpecDiff {
|
|
173
|
+
specId: string;
|
|
174
|
+
filePath: string;
|
|
175
|
+
frontmatter: FieldChange[];
|
|
176
|
+
sections: SectionChange[];
|
|
177
|
+
summary: string;
|
|
178
|
+
}
|
|
179
|
+
interface DownstreamImpact {
|
|
180
|
+
specId: string;
|
|
181
|
+
filePath: string;
|
|
182
|
+
distance: number;
|
|
183
|
+
lastUpdated: string | null;
|
|
184
|
+
staleness: number;
|
|
185
|
+
reason: string;
|
|
186
|
+
}
|
|
187
|
+
interface ImpactAnalysis {
|
|
188
|
+
changedSpec: string;
|
|
189
|
+
downstream: DownstreamImpact[];
|
|
190
|
+
totalAffected: number;
|
|
191
|
+
}
|
|
192
|
+
interface DiffResult {
|
|
193
|
+
diffs: SpecDiff[];
|
|
194
|
+
added: string[];
|
|
195
|
+
removed: string[];
|
|
196
|
+
impact: ImpactAnalysis[];
|
|
197
|
+
summary: string;
|
|
198
|
+
/**
|
|
199
|
+
* Spec files changed in the working tree but not covered by the comparison.
|
|
200
|
+
*
|
|
201
|
+
* A ref-to-ref diff cannot see uncommitted work, so reporting "no changes"
|
|
202
|
+
* without this would be a false all-clear. Always empty in working mode,
|
|
203
|
+
* where those changes are part of the comparison.
|
|
204
|
+
*/
|
|
205
|
+
uncommittedSpecFiles: string[];
|
|
206
|
+
}
|
|
207
|
+
interface StatusResult {
|
|
208
|
+
project: string;
|
|
209
|
+
/**
|
|
210
|
+
* Spec *files* resolved, not config entries — one glob entry can resolve to
|
|
211
|
+
* many files. The old name `specCount` did not say which, and meant the
|
|
212
|
+
* other thing in `runValidate` (audit run 5, F4).
|
|
213
|
+
*/
|
|
214
|
+
specFiles: number;
|
|
215
|
+
byStatus: Record<string, number>;
|
|
216
|
+
lintHealth: {
|
|
217
|
+
errors: number;
|
|
218
|
+
warnings: number;
|
|
219
|
+
passing: number;
|
|
220
|
+
};
|
|
221
|
+
staleSpecs: {
|
|
222
|
+
specId: string;
|
|
223
|
+
daysSinceUpdate: number;
|
|
224
|
+
owner?: string;
|
|
225
|
+
}[];
|
|
226
|
+
integrityIssues: string[];
|
|
227
|
+
/** "unassessed" when the suite resolved to zero specs — never a vacuous "healthy". */
|
|
228
|
+
verdict: "healthy" | "warnings" | "errors" | "unassessed";
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
interface RunDiffOptions {
|
|
232
|
+
base?: string;
|
|
233
|
+
head?: string;
|
|
234
|
+
spec?: string;
|
|
235
|
+
format?: string;
|
|
236
|
+
/** Compare the base ref against the working tree instead of a head ref. */
|
|
237
|
+
working?: boolean;
|
|
238
|
+
/**
|
|
239
|
+
* Directory holding spec.config.yaml. Defaults to the process cwd; a library
|
|
240
|
+
* consumer needs to point it elsewhere (audit run 5, F8).
|
|
241
|
+
*/
|
|
242
|
+
configDir?: string;
|
|
243
|
+
}
|
|
244
|
+
declare function runDiff(options: RunDiffOptions): Promise<DiffResult>;
|
|
245
|
+
|
|
246
|
+
interface RunStatusOptions {
|
|
247
|
+
/**
|
|
248
|
+
* Directory holding spec.config.yaml. Defaults to the process cwd, which is
|
|
249
|
+
* right for the CLI and useless to a library consumer — `runLint` and
|
|
250
|
+
* `runPack` take one, so this does too (audit run 5, F8).
|
|
251
|
+
*/
|
|
252
|
+
configDir?: string;
|
|
253
|
+
}
|
|
254
|
+
declare function runStatus(options?: RunStatusOptions): Promise<StatusResult>;
|
|
255
|
+
|
|
256
|
+
interface ValidateResult {
|
|
257
|
+
valid: boolean;
|
|
258
|
+
/** Number of spec entries declared in the config. */
|
|
259
|
+
specEntries?: number;
|
|
260
|
+
/** Number of spec files those entries actually resolve to. */
|
|
261
|
+
specFiles?: number;
|
|
262
|
+
/** Non-fatal honesty notes: entries resolving to nothing, empty suite. */
|
|
263
|
+
warnings: string[];
|
|
264
|
+
error?: string;
|
|
265
|
+
details?: unknown[];
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Validate spec.config.yaml: a schema-valid config, a buildable dependency
|
|
269
|
+
* graph (issue #13), and declared spec paths that actually resolve. An entry
|
|
270
|
+
* that matches no files makes every downstream verdict vacuous, so it is
|
|
271
|
+
* reported here rather than silently flowing into lint/status/ready.
|
|
272
|
+
*/
|
|
273
|
+
declare function runValidate(configDir: string): Promise<ValidateResult>;
|
|
274
|
+
|
|
275
|
+
export { type Diagnostic, type DiffResult, type LintResults, type PackOptions, type PackResult, type RunDiffOptions, type RunLintOptions, type RunLintResults, type RunPackOptions, type RunStatusOptions, type ScaffoldOptions, type SdxConfig, type SpecType, type StatusResult, type Template, type ValidateResult, runDiff, runLint, runPack, runStatus, runValidate, scaffoldProject };
|