specdx 0.4.0-alpha.2 → 0.4.0-alpha.20
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/LICENSE +21 -0
- package/README.md +477 -0
- package/dist/{check-PZFBVQIP.js → check-GGQB3SHI.js} +36 -10
- package/dist/check-GGQB3SHI.js.map +1 -0
- package/dist/chunk-5WRI5ZAA.js +31 -0
- package/dist/chunk-CI7KYTC7.js +103 -0
- package/dist/chunk-CI7KYTC7.js.map +1 -0
- package/dist/chunk-FBMYBYFB.js +182 -0
- package/dist/chunk-FBMYBYFB.js.map +1 -0
- package/dist/{chunk-FZWT4HVX.js → chunk-MM325DR6.js} +156 -2
- package/dist/chunk-MM325DR6.js.map +1 -0
- package/dist/chunk-RY5CDUNN.js +2846 -0
- package/dist/chunk-RY5CDUNN.js.map +1 -0
- package/dist/{chunk-YRDOYUKF.js → chunk-T232GZ2L.js} +124 -19
- package/dist/chunk-T232GZ2L.js.map +1 -0
- package/dist/{chunk-PHWUK7TH.js → chunk-UZKOJL2N.js} +288 -50
- package/dist/chunk-UZKOJL2N.js.map +1 -0
- package/dist/{chunk-QEUZJWBY.js → chunk-ZB5R5SK5.js} +364 -59
- package/dist/chunk-ZB5R5SK5.js.map +1 -0
- package/dist/{chunk-YDU26YTH.js → chunk-ZIPGRLYE.js} +120 -16
- package/dist/chunk-ZIPGRLYE.js.map +1 -0
- package/dist/diff-PHEX3HUT.js +188 -0
- package/dist/diff-PHEX3HUT.js.map +1 -0
- package/dist/{dist-2B2MR5AM.js → dist-DQ6NNKZO.js} +53 -14
- package/dist/dist-DQ6NNKZO.js.map +1 -0
- package/dist/dist-RT3MTIUW.js +16 -0
- package/dist/dist-RT3MTIUW.js.map +1 -0
- package/dist/generate-5VO6M4PB.js +21 -0
- package/dist/generate-5VO6M4PB.js.map +1 -0
- package/dist/{generate-story-AOALIKSD.js → generate-story-CJMV2F5K.js} +48 -20
- package/dist/generate-story-CJMV2F5K.js.map +1 -0
- package/dist/{generate-test-plan-34L6RGOB.js → generate-test-plan-XBAFJKJI.js} +63 -10
- package/dist/generate-test-plan-XBAFJKJI.js.map +1 -0
- package/dist/graph-UZJMLX4J.js +103 -0
- package/dist/graph-UZJMLX4J.js.map +1 -0
- package/dist/index.d.ts +171 -0
- package/dist/index.js +2635 -386
- package/dist/index.js.map +1 -1
- package/dist/{lint-XGVQ6LCP.js → lint-TVL2ILOQ.js} +20 -8
- package/dist/lint-TVL2ILOQ.js.map +1 -0
- package/dist/main.js +11 -146
- package/dist/main.js.map +1 -1
- package/dist/mcp-F7LJBZ4X.js +35 -0
- package/dist/mcp-F7LJBZ4X.js.map +1 -0
- package/dist/{migrate-KDJZQKP7.js → migrate-DEFCNOAH.js} +20 -8
- package/dist/migrate-DEFCNOAH.js.map +1 -0
- package/dist/{pack-OJ3CDZHD.js → pack-PNLD5AYW.js} +36 -11
- package/dist/pack-PNLD5AYW.js.map +1 -0
- package/dist/ready-2PHBPWJD.js +257 -0
- package/dist/ready-2PHBPWJD.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} +5 -1
- 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} +17 -2
- package/dist/skills-LHFTTEJ7.js +121 -0
- package/dist/skills-LHFTTEJ7.js.map +1 -0
- package/dist/{status-JVIXK73H.js → status-UKLQV4AI.js} +48 -34
- package/dist/status-UKLQV4AI.js.map +1 -0
- package/dist/{update-HFLDULNJ.js → update-KLDLDQZM.js} +6 -5
- package/dist/update-KLDLDQZM.js.map +1 -0
- package/dist/validate-FXD5WS4C.js +87 -0
- package/dist/validate-FXD5WS4C.js.map +1 -0
- package/hooks/hooks.json +12 -6
- package/hooks/session-start +35 -3
- package/package.json +68 -21
- package/dist/changelog-G6XDIAZP.js +0 -86
- package/dist/changelog-G6XDIAZP.js.map +0 -1
- package/dist/check-PZFBVQIP.js.map +0 -1
- package/dist/chunk-7C3BAVCP.js +0 -1147
- package/dist/chunk-7C3BAVCP.js.map +0 -1
- package/dist/chunk-FZWT4HVX.js.map +0 -1
- package/dist/chunk-PHWUK7TH.js.map +0 -1
- package/dist/chunk-QEUZJWBY.js.map +0 -1
- package/dist/chunk-YDU26YTH.js.map +0 -1
- package/dist/chunk-YRDOYUKF.js.map +0 -1
- package/dist/diff-BEZARP53.js +0 -100
- package/dist/diff-BEZARP53.js.map +0 -1
- package/dist/dist-2B2MR5AM.js.map +0 -1
- package/dist/dist-WIK7F2PJ.js +0 -11
- package/dist/explain-PCZKDEM4.js +0 -102
- package/dist/explain-PCZKDEM4.js.map +0 -1
- package/dist/generate-OMEBJQFQ.js +0 -13
- package/dist/generate-OMEBJQFQ.js.map +0 -1
- package/dist/generate-story-AOALIKSD.js.map +0 -1
- package/dist/generate-test-plan-34L6RGOB.js.map +0 -1
- package/dist/graph-RR5UTY3R.js +0 -54
- package/dist/graph-RR5UTY3R.js.map +0 -1
- package/dist/lint-XGVQ6LCP.js.map +0 -1
- package/dist/mcp-GUFW37BE.js +0 -17
- package/dist/mcp-GUFW37BE.js.map +0 -1
- package/dist/migrate-KDJZQKP7.js.map +0 -1
- package/dist/pack-OJ3CDZHD.js.map +0 -1
- package/dist/ready-WTNO5W7C.js +0 -165
- package/dist/ready-WTNO5W7C.js.map +0 -1
- package/dist/skills-3GBBWZW2.js +0 -93
- package/dist/skills-3GBBWZW2.js.map +0 -1
- package/dist/status-JVIXK73H.js.map +0 -1
- package/dist/update-HFLDULNJ.js.map +0 -1
- package/dist/validate-O7W5YLR6.js +0 -34
- package/dist/validate-O7W5YLR6.js.map +0 -1
- /package/dist/{dist-WIK7F2PJ.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-MM325DR6.js";
|
|
7
|
+
import "./chunk-ZIPGRLYE.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,12 +112,30 @@ ${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
|
-
meta: {
|
|
135
|
+
meta: {
|
|
136
|
+
name: "test-plan",
|
|
137
|
+
description: "Generate a test plan stub from user stories"
|
|
138
|
+
},
|
|
119
139
|
args: {
|
|
120
140
|
from: {
|
|
121
141
|
type: "string",
|
|
@@ -125,6 +145,11 @@ var generate_test_plan_default = defineCommand({
|
|
|
125
145
|
out: {
|
|
126
146
|
type: "string",
|
|
127
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
|
|
128
153
|
}
|
|
129
154
|
},
|
|
130
155
|
async run({ args }) {
|
|
@@ -136,11 +161,38 @@ var generate_test_plan_default = defineCommand({
|
|
|
136
161
|
process.exit(1);
|
|
137
162
|
}
|
|
138
163
|
try {
|
|
164
|
+
const configDir = process.cwd();
|
|
139
165
|
const result = await generateTestPlan({
|
|
140
|
-
configDir
|
|
141
|
-
outPath: args.out
|
|
166
|
+
configDir,
|
|
167
|
+
outPath: args.out,
|
|
168
|
+
force: args.force
|
|
142
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
|
+
}
|
|
143
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
|
+
}
|
|
144
196
|
} catch (err) {
|
|
145
197
|
console.error(`
|
|
146
198
|
\u2717 ${err.message}
|
|
@@ -151,6 +203,7 @@ var generate_test_plan_default = defineCommand({
|
|
|
151
203
|
});
|
|
152
204
|
export {
|
|
153
205
|
generate_test_plan_default as default,
|
|
154
|
-
generateTestPlan
|
|
206
|
+
generateTestPlan,
|
|
207
|
+
registeredKeyFor
|
|
155
208
|
};
|
|
156
|
-
//# sourceMappingURL=generate-test-plan-
|
|
209
|
+
//# sourceMappingURL=generate-test-plan-XBAFJKJI.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,WAAW,QAAW,SAAS;AAEpD,QAAM,gBAAkC,CAAC;AAEzC,aAAW,CAAC,EAAE,KAAK,KAAK,OAAO,QAAQ,OAAO,KAAK,GA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C;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"]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sharedArgs
|
|
3
|
+
} from "./chunk-GAM4MXPC.js";
|
|
4
|
+
import {
|
|
5
|
+
GraphError,
|
|
6
|
+
buildGraph,
|
|
7
|
+
collectReferenceEdges,
|
|
8
|
+
findUnreflectedReferences,
|
|
9
|
+
loadConfig,
|
|
10
|
+
parseSpec,
|
|
11
|
+
resolveGlob
|
|
12
|
+
} from "./chunk-MM325DR6.js";
|
|
13
|
+
import "./chunk-ZIPGRLYE.js";
|
|
14
|
+
import "./chunk-5WRI5ZAA.js";
|
|
15
|
+
|
|
16
|
+
// src/commands/core/graph.ts
|
|
17
|
+
import { defineCommand } from "citty";
|
|
18
|
+
var graph_default = defineCommand({
|
|
19
|
+
meta: { name: "graph", description: "Print the spec dependency graph" },
|
|
20
|
+
args: { ...sharedArgs },
|
|
21
|
+
async run({ args }) {
|
|
22
|
+
let config;
|
|
23
|
+
const configDir = process.cwd();
|
|
24
|
+
try {
|
|
25
|
+
config = await loadConfig(void 0, configDir);
|
|
26
|
+
} catch (err) {
|
|
27
|
+
console.error(`
|
|
28
|
+
\u2717 ${err.message}
|
|
29
|
+
`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const graph = buildGraph(config);
|
|
34
|
+
const sorted = graph.topologicalSort();
|
|
35
|
+
const idToEntry = /* @__PURE__ */ new Map();
|
|
36
|
+
const specs = [];
|
|
37
|
+
for (const [key, entry] of Object.entries(config.specs)) {
|
|
38
|
+
const paths = await resolveGlob(entry.path, configDir);
|
|
39
|
+
for (const p of paths) {
|
|
40
|
+
const spec = await parseSpec(p);
|
|
41
|
+
specs.push(spec);
|
|
42
|
+
if (typeof spec.frontmatter.id === "string") {
|
|
43
|
+
idToEntry.set(spec.frontmatter.id, key);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const referenceEdges = collectReferenceEdges(specs);
|
|
48
|
+
const unreflected = findUnreflectedReferences(referenceEdges, idToEntry, graph);
|
|
49
|
+
if (args.format === "dot") {
|
|
50
|
+
console.log("digraph specs {");
|
|
51
|
+
for (const edge of graph.edges) console.log(` "${edge.from}" -> "${edge.to}";`);
|
|
52
|
+
for (const ref of referenceEdges) {
|
|
53
|
+
console.log(
|
|
54
|
+
` "${ref.fromId}" -> "${ref.toId}" [style=dashed, label="${ref.relationship}"];`
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
console.log("}");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
console.log("\n Spec Dependency Graph:\n");
|
|
61
|
+
for (const node of sorted) {
|
|
62
|
+
const downstream = graph.getDownstream(node);
|
|
63
|
+
const arrow = downstream.length > 0 ? ` \u2192 ${downstream.join(", ")}` : "";
|
|
64
|
+
console.log(` ${node}${arrow}`);
|
|
65
|
+
}
|
|
66
|
+
if (referenceEdges.length > 0) {
|
|
67
|
+
console.log("\n Reference edges (frontmatter):\n");
|
|
68
|
+
for (const ref of referenceEdges) {
|
|
69
|
+
console.log(` ${ref.fromId} \u2014${ref.relationship}\u2192 ${ref.toId}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const suggestions = unreflected.filter((u) => !u.createsCycle);
|
|
73
|
+
const conflicts = unreflected.filter((u) => u.createsCycle);
|
|
74
|
+
if (suggestions.length > 0) {
|
|
75
|
+
console.log("\n \u26A0 References not reflected in config requires:\n");
|
|
76
|
+
for (const { edge, requiringEntry, requiredEntry } of suggestions) {
|
|
77
|
+
console.log(
|
|
78
|
+
` ${edge.fromId} ${edge.relationship} ${edge.toId} \u2014 add "requires: [${requiredEntry}]" to the "${requiringEntry}" entry in spec.config.yaml`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (conflicts.length > 0) {
|
|
83
|
+
console.log("\n \u26A0 References that conflict with the requires chain:\n");
|
|
84
|
+
for (const { edge, requiringEntry, requiredEntry } of conflicts) {
|
|
85
|
+
console.log(
|
|
86
|
+
` ${edge.fromId} ${edge.relationship} ${edge.toId} \u2014 implies "${requiringEntry}" requires "${requiredEntry}", but that would create a cycle; review the reference or the config requires`
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
console.log("");
|
|
91
|
+
} catch (err) {
|
|
92
|
+
if (err instanceof GraphError) {
|
|
93
|
+
console.error(` \u2717 ${err.message}`);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
throw err;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
export {
|
|
101
|
+
graph_default as default
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=graph-UZJMLX4J.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 } from \"../../shared-args.js\";\n\nexport default defineCommand({\n meta: { name: \"graph\", description: \"Print the spec dependency graph\" },\n args: { ...sharedArgs },\n async run({ args }) {\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 (args.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 console.log(\"\\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 console.log(` ${node}${arrow}`);\n }\n\n if (referenceEdges.length > 0) {\n console.log(\"\\n Reference edges (frontmatter):\\n\");\n for (const ref of referenceEdges) {\n console.log(` ${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;AAa9B,IAAO,gBAAQ,cAAc;AAAA,EAC3B,MAAM,EAAE,MAAM,SAAS,aAAa,kCAAkC;AAAA,EACtE,MAAM,EAAE,GAAG,WAAW;AAAA,EACtB,MAAM,IAAI,EAAE,KAAK,GAAG;AAClB,QAAI;AACJ,UAAM,YAAY,QAAQ,IAAI;AAC9B,QAAI;AACF,eAAS,MAAM,WAAW,QAAW,SAAS;AAAA,IAChD,SAAS,KAAK;AACZ,cAAQ,MAAM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,QAAI;AACF,YAAM,QAAQ,WAAW,MAAM;AAC/B,YAAM,SAAS,MAAM,gBAAgB;AAKrC,YAAM,YAAY,oBAAI,IAAoB;AAC1C,YAAM,QAAsB,CAAC;AAC7B,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,KAAK,GAAG;AACvD,cAAM,QAAQ,MAAM,YAAY,MAAM,MAAM,SAAS;AACrD,mBAAW,KAAK,OAAO;AACrB,gBAAM,OAAO,MAAM,UAAU,CAAC;AAC9B,gBAAM,KAAK,IAAI;AACf,cAA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,KAAK,IAAI,2BAAsB,aAAa,cAAc,cAAc;AAAA,UACnH;AAAA,QACF;AAAA,MACF;AAEA,UAAI,UAAU,SAAS,GAAG;AACxB,gBAAQ,IAAI,gEAA2D;AACvE,mBAAW,EAAE,MAAM,gBAAgB,cAAc,KAAK,WAAW;AAC/D,kBAAQ;AAAA,YACN,KAAK,KAAK,MAAM,IAAI,KAAK,YAAY,IAAI,KAAK,IAAI,oBAAe,cAAc,eAAe,aAAa;AAAA,UAC7G;AAAA,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,171 @@
|
|
|
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
|
+
type Severity = "error" | "warn" | "info";
|
|
10
|
+
interface Diagnostic {
|
|
11
|
+
ruleId: string;
|
|
12
|
+
severity: Severity;
|
|
13
|
+
message: string;
|
|
14
|
+
filePath: string;
|
|
15
|
+
line?: number;
|
|
16
|
+
section?: string;
|
|
17
|
+
}
|
|
18
|
+
interface LintResults {
|
|
19
|
+
diagnostics: Diagnostic[];
|
|
20
|
+
hasErrors: boolean;
|
|
21
|
+
hasWarnings: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface RunLintOptions {
|
|
25
|
+
configDir: string;
|
|
26
|
+
specPath?: string;
|
|
27
|
+
preset?: "minimal" | "recommended" | "strict";
|
|
28
|
+
}
|
|
29
|
+
/** Lint results plus whether anything was actually linted (vacuous-pass audit). */
|
|
30
|
+
interface RunLintResults extends LintResults {
|
|
31
|
+
/** Number of specs linted. */
|
|
32
|
+
specCount: number;
|
|
33
|
+
/** False when no specs resolved — "no diagnostics" is then not a pass. */
|
|
34
|
+
assessed: boolean;
|
|
35
|
+
}
|
|
36
|
+
declare function runLint(options: RunLintOptions): Promise<RunLintResults>;
|
|
37
|
+
|
|
38
|
+
/** Statistics about how the budget was allocated. */
|
|
39
|
+
interface PackStats {
|
|
40
|
+
/** Total token budget. */
|
|
41
|
+
budget: number;
|
|
42
|
+
/** Tokens actually used. */
|
|
43
|
+
used: number;
|
|
44
|
+
/** Number of specs included in the output. */
|
|
45
|
+
specsIncluded: number;
|
|
46
|
+
/** Number of specs excluded due to budget or relevance. */
|
|
47
|
+
specsExcluded: number;
|
|
48
|
+
/** Number of sections that were compressed. */
|
|
49
|
+
sectionsCompressed: number;
|
|
50
|
+
/** Number of sections omitted entirely to fit the budget. */
|
|
51
|
+
sectionsOmitted: number;
|
|
52
|
+
/** Per-spec allocation details. */
|
|
53
|
+
allocations: SpecAllocation[];
|
|
54
|
+
}
|
|
55
|
+
/** Result returned by the pack operation. */
|
|
56
|
+
interface PackResult {
|
|
57
|
+
/** The formatted output string. */
|
|
58
|
+
output: string;
|
|
59
|
+
/** Statistics about the pack run. */
|
|
60
|
+
stats: PackStats;
|
|
61
|
+
}
|
|
62
|
+
/** Token allocation detail for a single spec. */
|
|
63
|
+
interface SpecAllocation {
|
|
64
|
+
/** Identifier of the spec. */
|
|
65
|
+
specId: string;
|
|
66
|
+
/** Spec type (e.g. "adr", "rfc", "runbook"). */
|
|
67
|
+
type: string;
|
|
68
|
+
/** Computed relevance score (0-1). */
|
|
69
|
+
relevance: number;
|
|
70
|
+
/** Tokens allocated to this spec. */
|
|
71
|
+
tokens: number;
|
|
72
|
+
/** Whether this spec was compressed. */
|
|
73
|
+
compressed: boolean;
|
|
74
|
+
/** Whether this spec was included in the output. */
|
|
75
|
+
included: boolean;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface RunPackOptions {
|
|
79
|
+
configDir: string;
|
|
80
|
+
task?: string;
|
|
81
|
+
specs?: string[];
|
|
82
|
+
budget?: number;
|
|
83
|
+
format?: "xml" | "markdown" | "json";
|
|
84
|
+
full?: boolean;
|
|
85
|
+
dryRun?: boolean;
|
|
86
|
+
}
|
|
87
|
+
declare function runPack(options: RunPackOptions): Promise<PackResult & {
|
|
88
|
+
specsResolved: number;
|
|
89
|
+
}>;
|
|
90
|
+
|
|
91
|
+
type FieldChangeType = "added" | "removed" | "modified" | "broken-reference";
|
|
92
|
+
interface FieldChange {
|
|
93
|
+
field: string;
|
|
94
|
+
type: FieldChangeType;
|
|
95
|
+
before?: unknown;
|
|
96
|
+
after?: unknown;
|
|
97
|
+
}
|
|
98
|
+
interface SectionChange {
|
|
99
|
+
heading: string;
|
|
100
|
+
type: "added" | "removed" | "modified";
|
|
101
|
+
contentDiff?: string;
|
|
102
|
+
}
|
|
103
|
+
interface SpecDiff {
|
|
104
|
+
specId: string;
|
|
105
|
+
filePath: string;
|
|
106
|
+
frontmatter: FieldChange[];
|
|
107
|
+
sections: SectionChange[];
|
|
108
|
+
summary: string;
|
|
109
|
+
}
|
|
110
|
+
interface DownstreamImpact {
|
|
111
|
+
specId: string;
|
|
112
|
+
filePath: string;
|
|
113
|
+
distance: number;
|
|
114
|
+
lastUpdated: string | null;
|
|
115
|
+
staleness: number;
|
|
116
|
+
reason: string;
|
|
117
|
+
}
|
|
118
|
+
interface ImpactAnalysis {
|
|
119
|
+
changedSpec: string;
|
|
120
|
+
downstream: DownstreamImpact[];
|
|
121
|
+
totalAffected: number;
|
|
122
|
+
}
|
|
123
|
+
interface DiffResult {
|
|
124
|
+
diffs: SpecDiff[];
|
|
125
|
+
added: string[];
|
|
126
|
+
removed: string[];
|
|
127
|
+
impact: ImpactAnalysis[];
|
|
128
|
+
summary: string;
|
|
129
|
+
/**
|
|
130
|
+
* Spec files changed in the working tree but not covered by the comparison.
|
|
131
|
+
*
|
|
132
|
+
* A ref-to-ref diff cannot see uncommitted work, so reporting "no changes"
|
|
133
|
+
* without this would be a false all-clear. Always empty in working mode,
|
|
134
|
+
* where those changes are part of the comparison.
|
|
135
|
+
*/
|
|
136
|
+
uncommittedSpecFiles: string[];
|
|
137
|
+
}
|
|
138
|
+
interface StatusResult {
|
|
139
|
+
project: string;
|
|
140
|
+
specCount: number;
|
|
141
|
+
byStatus: Record<string, number>;
|
|
142
|
+
lintHealth: {
|
|
143
|
+
errors: number;
|
|
144
|
+
warnings: number;
|
|
145
|
+
passing: number;
|
|
146
|
+
};
|
|
147
|
+
staleSpecs: {
|
|
148
|
+
specId: string;
|
|
149
|
+
daysSinceUpdate: number;
|
|
150
|
+
owner?: string;
|
|
151
|
+
}[];
|
|
152
|
+
integrityIssues: string[];
|
|
153
|
+
/** "unassessed" when the suite resolved to zero specs — never a vacuous "healthy". */
|
|
154
|
+
verdict: "healthy" | "warnings" | "errors" | "unassessed";
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
interface RunDiffOptions {
|
|
158
|
+
base?: string;
|
|
159
|
+
head?: string;
|
|
160
|
+
spec?: string;
|
|
161
|
+
format?: string;
|
|
162
|
+
/** Compare the base ref against the working tree instead of a head ref. */
|
|
163
|
+
working?: boolean;
|
|
164
|
+
}
|
|
165
|
+
declare function runDiff(options: RunDiffOptions): Promise<DiffResult>;
|
|
166
|
+
|
|
167
|
+
declare function runStatus(_options?: {
|
|
168
|
+
format?: string;
|
|
169
|
+
}): Promise<StatusResult>;
|
|
170
|
+
|
|
171
|
+
export { runDiff, runLint, runPack, runStatus, scaffoldProject };
|