specdx 0.3.0-alpha.3 → 0.4.0-alpha.2
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/dist/{changelog-OUP2RXWN.js → changelog-G6XDIAZP.js} +4 -4
- package/dist/{check-3XQYO3HU.js → check-PZFBVQIP.js} +8 -6
- package/dist/check-PZFBVQIP.js.map +1 -0
- package/dist/{chunk-DDFLMRPC.js → chunk-7C3BAVCP.js} +2 -2
- package/dist/chunk-7C3BAVCP.js.map +1 -0
- package/dist/{chunk-PHR7AV6I.js → chunk-FZWT4HVX.js} +2 -2
- package/dist/{chunk-PHR7AV6I.js.map → chunk-FZWT4HVX.js.map} +1 -1
- package/dist/{chunk-WTFWNYJA.js → chunk-PHWUK7TH.js} +232 -3
- package/dist/chunk-PHWUK7TH.js.map +1 -0
- package/dist/{chunk-6BWZEAST.js → chunk-QEUZJWBY.js} +1 -1
- package/dist/chunk-QEUZJWBY.js.map +1 -0
- package/dist/{chunk-ZX4HVL5M.js → chunk-YDU26YTH.js} +2 -2
- package/dist/chunk-YDU26YTH.js.map +1 -0
- package/dist/{pack-PI6V6OR2.js → chunk-YRDOYUKF.js} +4 -163
- package/dist/chunk-YRDOYUKF.js.map +1 -0
- package/dist/{diff-275PLXYH.js → diff-BEZARP53.js} +4 -4
- package/dist/dist-2B2MR5AM.js +279 -0
- package/dist/dist-2B2MR5AM.js.map +1 -0
- package/dist/{dist-PQCG2XXF.js → dist-WIK7F2PJ.js} +2 -2
- package/dist/{explain-I7AQMEEH.js → explain-PCZKDEM4.js} +3 -3
- package/dist/{generate-PC7BIB7G.js → generate-OMEBJQFQ.js} +3 -3
- package/dist/{generate-story-7WHPPFHY.js → generate-story-AOALIKSD.js} +3 -3
- package/dist/generate-story-AOALIKSD.js.map +1 -0
- package/dist/{generate-test-plan-U5LMWGKX.js → generate-test-plan-34L6RGOB.js} +7 -5
- package/dist/generate-test-plan-34L6RGOB.js.map +1 -0
- package/dist/{graph-RCAPF55A.js → graph-RR5UTY3R.js} +3 -3
- package/dist/index.js +236 -5
- package/dist/index.js.map +1 -1
- package/dist/{lint-6Z2TVWAQ.js → lint-XGVQ6LCP.js} +4 -4
- package/dist/main.js +15 -14
- package/dist/main.js.map +1 -1
- package/dist/mcp-GUFW37BE.js +17 -0
- package/dist/mcp-GUFW37BE.js.map +1 -0
- package/dist/{migrate-L7W5RHSS.js → migrate-KDJZQKP7.js} +3 -3
- package/dist/pack-OJ3CDZHD.js +167 -0
- package/dist/pack-OJ3CDZHD.js.map +1 -0
- package/dist/{ready-B7IFPL3S.js → ready-WTNO5W7C.js} +14 -8
- package/dist/ready-WTNO5W7C.js.map +1 -0
- package/dist/{status-AV5GSWVI.js → status-JVIXK73H.js} +8 -6
- package/dist/{status-AV5GSWVI.js.map → status-JVIXK73H.js.map} +1 -1
- package/dist/{update-HIWDDEZQ.js → update-HFLDULNJ.js} +4 -4
- package/dist/{validate-N2WSG75W.js → validate-O7W5YLR6.js} +3 -3
- package/package.json +2 -1
- 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-WTFWNYJA.js.map +0 -1
- package/dist/chunk-ZX4HVL5M.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/pack-PI6V6OR2.js.map +0 -1
- package/dist/ready-B7IFPL3S.js.map +0 -1
- /package/dist/{changelog-OUP2RXWN.js.map → changelog-G6XDIAZP.js.map} +0 -0
- /package/dist/{diff-275PLXYH.js.map → diff-BEZARP53.js.map} +0 -0
- /package/dist/{dist-PQCG2XXF.js.map → dist-WIK7F2PJ.js.map} +0 -0
- /package/dist/{explain-I7AQMEEH.js.map → explain-PCZKDEM4.js.map} +0 -0
- /package/dist/{generate-PC7BIB7G.js.map → generate-OMEBJQFQ.js.map} +0 -0
- /package/dist/{graph-RCAPF55A.js.map → graph-RR5UTY3R.js.map} +0 -0
- /package/dist/{lint-6Z2TVWAQ.js.map → lint-XGVQ6LCP.js.map} +0 -0
- /package/dist/{migrate-L7W5RHSS.js.map → migrate-KDJZQKP7.js.map} +0 -0
- /package/dist/{update-HIWDDEZQ.js.map → update-HFLDULNJ.js.map} +0 -0
- /package/dist/{validate-N2WSG75W.js.map → validate-O7W5YLR6.js.map} +0 -0
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
loadConfig,
|
|
4
4
|
parseSpec,
|
|
5
5
|
resolveGlob
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-FZWT4HVX.js";
|
|
7
7
|
import {
|
|
8
8
|
REQUIRED_SECTIONS
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YDU26YTH.js";
|
|
10
10
|
|
|
11
11
|
// src/commands/generate-story.ts
|
|
12
12
|
import { defineCommand } from "citty";
|
|
@@ -189,4 +189,4 @@ export {
|
|
|
189
189
|
defineCommandExport,
|
|
190
190
|
generateStories
|
|
191
191
|
};
|
|
192
|
-
//# sourceMappingURL=generate-story-
|
|
192
|
+
//# sourceMappingURL=generate-story-AOALIKSD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/generate-story.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { writeFile, mkdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { loadConfig, parseSpec, resolveGlob, createLogger } from \"@specdx/core\";\nimport { REQUIRED_SECTIONS } from \"@specdx/schema\";\n\nexport interface GenerateStoriesOptions {\n configDir: string;\n from: string;\n outDir?: string;\n}\n\nexport interface GenerateStoriesResult {\n generated: string[];\n}\n\nfunction slugify(text: string): string {\n return text\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")\n .slice(0, 40);\n}\n\nfunction detectStoriesDir(\n configDir: string,\n config: Awaited<ReturnType<typeof loadConfig>>,\n): string {\n for (const entry of Object.values(config.specs)) {\n if (entry.type === \"user-story\") {\n // Use the directory portion of the glob path\n const dirPart = entry.path.replace(/\\/[^/]*\\*.*$/, \"\").replace(/\\/[^/]*$/, \"\");\n // If path ends with *.md at a directory level, take that dir\n const match = entry.path.match(/^(.+?)\\/\\*/);\n if (match) {\n return join(configDir, match[1]!);\n }\n return join(configDir, dirPart);\n }\n }\n return join(configDir, \"specs/stories\");\n}\n\nfunction buildStoryFile(options: {\n featureNum: string;\n featureText: string;\n prdId: string;\n prdAuthors: string[];\n today: string;\n sections: string[];\n}): string {\n const { featureNum, featureText, prdId, prdAuthors, today, sections } = options;\n const storyId = `story-f${featureNum}`;\n const title = featureText.trim();\n const authorsYaml = JSON.stringify(prdAuthors);\n\n const frontmatter = [\n \"---\",\n `id: \"${storyId}\"`,\n `type: \"user-story\"`,\n `title: \"${title}\"`,\n `status: \"draft\"`,\n `version: \"0.1\"`,\n `created: \"${today}\"`,\n `authors: ${authorsYaml}`,\n `story_id: \"${storyId}\"`,\n `priority: \"medium\"`,\n `estimate: \"TBD\"`,\n `references:`,\n ` - id: \"${prdId}\"`,\n ` relationship: \"decomposed-into\"`,\n \"---\",\n ].join(\"\\n\");\n\n const bodyParts = sections.map((section) => {\n if (section === \"Description\") {\n return `\\n## ${section}\\n\\n${featureText.trim()}`;\n }\n if (section === \"Acceptance Criteria\") {\n return `\\n## ${section}\\n\\n- [ ] <!-- acceptance criterion -->`;\n }\n if (section === \"Dependencies\") {\n return `\\n## ${section}\\n\\nF${featureNum} from ${prdId}`;\n }\n return `\\n## ${section}\\n\\n<!-- placeholder -->`;\n });\n\n return `${frontmatter}\\n${bodyParts.join(\"\\n\")}\\n`;\n}\n\nexport async function generateStories(\n options: GenerateStoriesOptions,\n): Promise<GenerateStoriesResult> {\n const { configDir, from, outDir } = options;\n const config = await loadConfig(undefined, configDir);\n\n // Find the PRD spec file by ID\n let prdFilePath: string | undefined;\n for (const entry of Object.values(config.specs)) {\n const files = await resolveGlob(entry.path, configDir);\n for (const file of files) {\n const parsed = await parseSpec(file);\n if (parsed.frontmatter.id === from) {\n prdFilePath = file;\n break;\n }\n }\n if (prdFilePath) break;\n }\n\n if (!prdFilePath) {\n throw new Error(`No spec with id \"${from}\" found in config.`);\n }\n\n const prd = await parseSpec(prdFilePath);\n\n // Find the Features section content\n const featuresSection = prd.parsedSections.find((s) => s.heading === \"Features\");\n if (!featuresSection) {\n return { generated: [] };\n }\n\n // Parse features using the required regex pattern\n const featureRegex = /\\*\\*F(\\d+)\\*\\*:\\s*(.+)/g;\n const features: Array<{ num: string; text: string }> = [];\n let match: RegExpExecArray | null;\n while ((match = featureRegex.exec(featuresSection.content)) !== null) {\n features.push({ num: match[1]!, text: match[2]! });\n }\n\n if (features.length === 0) {\n return { generated: [] };\n }\n\n const storiesDir = outDir ?? detectStoriesDir(configDir, config);\n await mkdir(storiesDir, { recursive: true });\n\n const today = new Date().toISOString().slice(0, 10);\n const prdAuthors = (prd.frontmatter.authors as string[] | undefined) ?? [];\n const sections = REQUIRED_SECTIONS[\"user-story\"];\n\n const generated: string[] = [];\n\n for (const feature of features) {\n const slug = slugify(feature.text);\n const filename = `story-f${feature.num}-${slug}.md`;\n const filePath = join(storiesDir, filename);\n\n const content = buildStoryFile({\n featureNum: feature.num,\n featureText: feature.text,\n prdId: from,\n prdAuthors,\n today,\n sections,\n });\n\n await writeFile(filePath, content, \"utf-8\");\n generated.push(filePath);\n }\n\n return { generated };\n}\n\nexport const defineCommandExport = defineCommand({\n meta: {\n name: \"generate story\",\n description: \"Generate user story stub files from a PRD's Features section\",\n },\n args: {\n from: {\n type: \"string\",\n description: \"Spec ID of the PRD to generate stories from\",\n required: true,\n },\n out: {\n type: \"string\",\n description: \"Output directory for story files (default: auto-detected from config)\",\n },\n quiet: {\n type: \"boolean\",\n description: \"Suppress output\",\n default: false,\n },\n verbose: {\n type: \"boolean\",\n description: \"Verbose output\",\n default: false,\n },\n },\n async run({ args }) {\n const logger = createLogger({ quiet: args.quiet, verbose: args.verbose });\n\n try {\n const result = await generateStories({\n configDir: process.cwd(),\n from: args.from,\n outDir: args.out,\n });\n\n if (result.generated.length === 0) {\n logger.info(\"No features found in PRD — no story stubs generated.\");\n } else {\n logger.info(`Generated ${result.generated.length} story stub(s):`);\n for (const filePath of result.generated) {\n logger.info(` ${filePath}`);\n }\n }\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n },\n});\n\nexport default defineCommandExport;\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,WAAW,aAAa;AACjC,SAAS,YAAY;AAcrB,SAAS,QAAQ,MAAsB;AACrC,SAAO,KACJ,YAAY,EACZ,QAAQ,eAAe,GAAG,EAC1B,QAAQ,YAAY,EAAE,EACtB,MAAM,GAAG,EAAE;AAChB;AAEA,SAAS,iBACP,WACA,QACQ;AACR,aAAW,SAAS,OAAO,OAAO,OAAO,KAAK,GAAG;AAC/C,QAAI,MAAM,SAAS,cAAc;AAE/B,YAAM,UAAU,MAAM,KAAK,QAAQ,gBAAgB,EAAE,EAAE,QAAQ,YAAY,EAAE;AAE7E,YAAM,QAAQ,MAAM,KAAK,MAAM,YAAY;AAC3C,UAAI,OAAO;AACT,eAAO,KAAK,WAAW,MAAM,CAAC,CAAE;AAAA,MAClC;AACA,aAAO,KAAK,WAAW,OAAO;AAAA,IAChC;AAAA,EACF;AACA,SAAO,KAAK,WAAW,eAAe;AACxC;AAEA,SAAS,eAAe,SAOb;AACT,QAAM,EAAE,YAAY,aAAa,OAAO,YAAY,OAAO,SAAS,IAAI;AACxE,QAAM,UAAU,UAAU,UAAU;AACpC,QAAM,QAAQ,YAAY,KAAK;AAC/B,QAAM,cAAc,KAAK,UAAU,UAAU;AAE7C,QAAM,cAAc;AAAA,IAClB;AAAA,IACA,QAAQ,OAAO;AAAA,IACf;AAAA,IACA,WAAW,KAAK;AAAA,IAChB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AAK;AAAA,MACH,MAAM;AAAA,MACN,aAAa;AAAA,IACf;AAAA,IACA,OAAO;AAAA,MACL,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,IACA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,MAAM,IAAI,EAAE,KAAK,GAAG;AAClB,UAAM,SAAS,aAAa,EAAE,OAAO,KAAK,OAAO,SAAS,KAAK,QAAQ,CAAC;AAExE,QAAI;AACF,YAAM,SAAS,MAAM,gBAAgB;AAAA,QACnC,WAAW,QAAQ,IAAI;AAAA,QACvB,MAAM,KAAK;AAAA,QACX,QAAQ,KAAK;AAAA,MACf,CAAC;AAED,UAAI,OAAO,UAAU,WAAW,GAAG;AACjC,eAAO,KAAK,2DAAsD;AAAA,MACpE,OAAO;AACL,eAAO,KAAK,aAAa,OAAO,UAAU,MAAM,iBAAiB;AACjE,mBAAW,YAAY,OAAO,WAAW;AACvC,iBAAO,KAAK,KAAK,QAAQ,EAAE;AAAA,QAC7B;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;AAED,IAAO,yBAAQ;","names":[]}
|
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
loadConfig,
|
|
4
4
|
parseSpec,
|
|
5
5
|
resolveGlob
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-FZWT4HVX.js";
|
|
7
|
+
import "./chunk-YDU26YTH.js";
|
|
8
8
|
|
|
9
9
|
// src/commands/generate-test-plan.ts
|
|
10
10
|
import { defineCommand } from "citty";
|
|
@@ -55,8 +55,10 @@ async function generateTestPlan(options) {
|
|
|
55
55
|
storiesBySpec.sort((a, b) => a.storyId.localeCompare(b.storyId));
|
|
56
56
|
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
57
57
|
const allAuthors = Array.from(new Set(storiesBySpec.flatMap((s) => s.authors)));
|
|
58
|
-
const storyRefs = storiesBySpec.map(
|
|
59
|
-
|
|
58
|
+
const storyRefs = storiesBySpec.map(
|
|
59
|
+
(s) => ` - id: "${s.storyId}"
|
|
60
|
+
relationship: "related-to"`
|
|
61
|
+
);
|
|
60
62
|
const totalTestCases = storiesBySpec.reduce((sum, s) => sum + s.cases.length, 0);
|
|
61
63
|
const authorsYaml = allAuthors.length > 0 ? `[${allAuthors.map((a) => `"${a}"`).join(", ")}]` : '["generated"]';
|
|
62
64
|
const refsYaml = storyRefs.length > 0 ? `
|
|
@@ -151,4 +153,4 @@ export {
|
|
|
151
153
|
generate_test_plan_default as default,
|
|
152
154
|
generateTestPlan
|
|
153
155
|
};
|
|
154
|
-
//# sourceMappingURL=generate-test-plan-
|
|
156
|
+
//# sourceMappingURL=generate-test-plan-34L6RGOB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/generate-test-plan.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, resolveGlob, createLogger } from \"@specdx/core\";\nimport { writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nexport interface GenerateTestPlanOptions {\n configDir: string;\n outPath?: string;\n}\n\nexport interface GenerateTestPlanResult {\n filePath: string;\n testCases: number;\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 } = 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 const targetPath = outPath ?? join(configDir, \"specs\", \"test-plan.md\");\n await writeFile(targetPath, fileContent, \"utf-8\");\n\n return { filePath: targetPath, testCases: totalTestCases };\n}\n\nexport default defineCommand({\n meta: { name: \"generate-test-plan\", description: \"Generate a test plan stub from user stories\" },\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 },\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 result = await generateTestPlan({\n configDir: process.cwd(),\n outPath: args.out,\n });\n\n logger.info(`Generated test plan with ${result.testCases} test cases → ${result.filePath}`);\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,YAAY;AAuBrB,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,U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k-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-FZWT4HVX.js";
|
|
9
|
+
import "./chunk-YDU26YTH.js";
|
|
10
10
|
|
|
11
11
|
// src/commands/graph.ts
|
|
12
12
|
import { defineCommand } from "citty";
|
|
@@ -51,4 +51,4 @@ var graph_default = defineCommand({
|
|
|
51
51
|
export {
|
|
52
52
|
graph_default as default
|
|
53
53
|
};
|
|
54
|
-
//# sourceMappingURL=graph-
|
|
54
|
+
//# sourceMappingURL=graph-RR5UTY3R.js.map
|
package/dist/index.js
CHANGED
|
@@ -81,7 +81,7 @@ var config_default = {
|
|
|
81
81
|
type: "object",
|
|
82
82
|
properties: {
|
|
83
83
|
path: { type: "string" },
|
|
84
|
-
type: { type: "string", enum: ["prd", "technical-design", "user-story", "test-plan", "adr", "api-contract"] },
|
|
84
|
+
type: { type: "string", enum: ["prd", "technical-design", "user-story", "test-plan", "adr", "api-contract", "epic", "quick-spec", "project-context"] },
|
|
85
85
|
required: { type: "boolean", default: false },
|
|
86
86
|
requires: { type: "array", items: { type: "string" } },
|
|
87
87
|
owner: { type: "string" }
|
|
@@ -942,6 +942,230 @@ var singleProjectContextRule = {
|
|
|
942
942
|
}
|
|
943
943
|
};
|
|
944
944
|
|
|
945
|
+
// ../lint/dist/rules/terminology.js
|
|
946
|
+
function normalizeCompound(term) {
|
|
947
|
+
return term.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[-_]/g, " ").toLowerCase().trim();
|
|
948
|
+
}
|
|
949
|
+
function extractCompoundTerms(content) {
|
|
950
|
+
const terms = [];
|
|
951
|
+
const camelCaseRegex = /\b[a-zA-Z]*[a-z][A-Z][a-zA-Z]*\b/g;
|
|
952
|
+
let match;
|
|
953
|
+
while ((match = camelCaseRegex.exec(content)) !== null) {
|
|
954
|
+
terms.push(match[0]);
|
|
955
|
+
}
|
|
956
|
+
const hyphenatedRegex = /\b[a-z][a-z0-9]*(?:-[a-z][a-z0-9]*)+\b/g;
|
|
957
|
+
while ((match = hyphenatedRegex.exec(content)) !== null) {
|
|
958
|
+
terms.push(match[0]);
|
|
959
|
+
}
|
|
960
|
+
return terms;
|
|
961
|
+
}
|
|
962
|
+
var terminologyRule = {
|
|
963
|
+
id: "consistency/terminology",
|
|
964
|
+
description: "Detects terminology drift (e.g., user-profile vs UserProfile vs user profile) across specs",
|
|
965
|
+
severity: "warn",
|
|
966
|
+
run(context) {
|
|
967
|
+
if (context.spec !== context.allSpecs[0])
|
|
968
|
+
return [];
|
|
969
|
+
const termMap = /* @__PURE__ */ new Map();
|
|
970
|
+
for (const spec of context.allSpecs) {
|
|
971
|
+
if (!spec.content)
|
|
972
|
+
continue;
|
|
973
|
+
const terms = extractCompoundTerms(spec.content);
|
|
974
|
+
for (const term of terms) {
|
|
975
|
+
const normalized = normalizeCompound(term);
|
|
976
|
+
if (!normalized.includes(" "))
|
|
977
|
+
continue;
|
|
978
|
+
if (!termMap.has(normalized)) {
|
|
979
|
+
termMap.set(normalized, /* @__PURE__ */ new Set());
|
|
980
|
+
}
|
|
981
|
+
termMap.get(normalized).add(term);
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
const diagnostics = [];
|
|
985
|
+
for (const [normalized, variants] of termMap) {
|
|
986
|
+
if (variants.size >= 2) {
|
|
987
|
+
const variantList = [...variants].join(", ");
|
|
988
|
+
diagnostics.push({
|
|
989
|
+
ruleId: "consistency/terminology",
|
|
990
|
+
severity: "warn",
|
|
991
|
+
message: `Inconsistent terminology for "${normalized}": found variants [${variantList}]. Standardize terminology across specs.`,
|
|
992
|
+
filePath: context.spec.filePath
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
return diagnostics;
|
|
997
|
+
}
|
|
998
|
+
};
|
|
999
|
+
|
|
1000
|
+
// ../lint/dist/rules/edge-case-coverage.js
|
|
1001
|
+
var EDGE_CASE_KEYWORDS = [
|
|
1002
|
+
"error",
|
|
1003
|
+
"invalid",
|
|
1004
|
+
"empty",
|
|
1005
|
+
"timeout",
|
|
1006
|
+
"fails",
|
|
1007
|
+
"failure",
|
|
1008
|
+
"boundary",
|
|
1009
|
+
"edge case",
|
|
1010
|
+
"null",
|
|
1011
|
+
"undefined",
|
|
1012
|
+
"reject",
|
|
1013
|
+
"unauthorized",
|
|
1014
|
+
"forbidden",
|
|
1015
|
+
"404",
|
|
1016
|
+
"500",
|
|
1017
|
+
"missing",
|
|
1018
|
+
"malformed",
|
|
1019
|
+
"overflow",
|
|
1020
|
+
"duplicate"
|
|
1021
|
+
];
|
|
1022
|
+
var edgeCaseCoverageRule = {
|
|
1023
|
+
id: "completeness/edge-case-coverage",
|
|
1024
|
+
description: "Flag user stories or test plans that don't mention error states or edge cases",
|
|
1025
|
+
severity: "warn",
|
|
1026
|
+
run(context) {
|
|
1027
|
+
const type = context.spec.frontmatter.type;
|
|
1028
|
+
if (type !== "user-story" && type !== "test-plan")
|
|
1029
|
+
return [];
|
|
1030
|
+
const content = context.spec.content.toLowerCase();
|
|
1031
|
+
const hasEdgeCases = EDGE_CASE_KEYWORDS.some((kw) => content.includes(kw));
|
|
1032
|
+
if (hasEdgeCases)
|
|
1033
|
+
return [];
|
|
1034
|
+
return [
|
|
1035
|
+
{
|
|
1036
|
+
ruleId: "completeness/edge-case-coverage",
|
|
1037
|
+
severity: "warn",
|
|
1038
|
+
message: "No error states or edge cases mentioned. Consider adding error handling, boundary conditions, or failure mode scenarios.",
|
|
1039
|
+
filePath: context.spec.filePath
|
|
1040
|
+
}
|
|
1041
|
+
];
|
|
1042
|
+
}
|
|
1043
|
+
};
|
|
1044
|
+
|
|
1045
|
+
// ../lint/dist/rules/naming-conventions.js
|
|
1046
|
+
var namingConventionsRule = {
|
|
1047
|
+
id: "consistency/naming-conventions",
|
|
1048
|
+
description: "Enforce consistent naming conventions across specs",
|
|
1049
|
+
severity: "warn",
|
|
1050
|
+
run(context) {
|
|
1051
|
+
const { spec } = context;
|
|
1052
|
+
const type = spec.frontmatter.type;
|
|
1053
|
+
const diagnostics = [];
|
|
1054
|
+
if (type === "prd") {
|
|
1055
|
+
const sectionParts = spec.content.split(/^(?=## )/m);
|
|
1056
|
+
const featuresSection = sectionParts.find((p) => /^## Features\b/.test(p));
|
|
1057
|
+
if (featuresSection) {
|
|
1058
|
+
const bullets = featuresSection.match(/^- .+$/gm) ?? [];
|
|
1059
|
+
for (const bullet of bullets) {
|
|
1060
|
+
if (bullet.match(/^- \*\*F\d+\*\*:/) === null && bullet.trim().length > 2) {
|
|
1061
|
+
diagnostics.push({
|
|
1062
|
+
ruleId: "consistency/naming-conventions",
|
|
1063
|
+
severity: "warn",
|
|
1064
|
+
message: `PRD feature missing feature ID pattern (**F<N>**:): "${bullet.slice(0, 60)}"`,
|
|
1065
|
+
filePath: spec.filePath
|
|
1066
|
+
});
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
if (type === "user-story") {
|
|
1072
|
+
const id = spec.frontmatter.id;
|
|
1073
|
+
if (!id.startsWith("story-")) {
|
|
1074
|
+
diagnostics.push({
|
|
1075
|
+
ruleId: "consistency/naming-conventions",
|
|
1076
|
+
severity: "warn",
|
|
1077
|
+
message: `User story ID "${id}" should start with "story-" (e.g., "story-${id}")`,
|
|
1078
|
+
filePath: spec.filePath
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
if (type === "api-contract") {
|
|
1083
|
+
const endpointRe = /^###\s+(GET|POST|PUT|PATCH|DELETE)\s+(\S+)/gm;
|
|
1084
|
+
let match;
|
|
1085
|
+
while ((match = endpointRe.exec(spec.content)) !== null) {
|
|
1086
|
+
const path = match[2];
|
|
1087
|
+
if (/\/[a-z]+[A-Z]/.test(path)) {
|
|
1088
|
+
diagnostics.push({
|
|
1089
|
+
ruleId: "consistency/naming-conventions",
|
|
1090
|
+
severity: "warn",
|
|
1091
|
+
message: `Endpoint path "${path}" uses camelCase \u2014 use kebab-case instead (e.g., "${path.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase()}")`,
|
|
1092
|
+
filePath: spec.filePath
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
return diagnostics;
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
|
|
1101
|
+
// ../lint/dist/rules/threat-coverage.js
|
|
1102
|
+
var STOPWORDS = /* @__PURE__ */ new Set(["the", "and", "for", "with", "from", "that", "this", "into", "via"]);
|
|
1103
|
+
function extractThreats(content) {
|
|
1104
|
+
const parts = content.split(/^(?=## )/m);
|
|
1105
|
+
const threats = [];
|
|
1106
|
+
for (const part of parts) {
|
|
1107
|
+
if (!/^##\s+(Threats|Security)\b/i.test(part))
|
|
1108
|
+
continue;
|
|
1109
|
+
const bullets = part.match(/^- .+$/gm) ?? [];
|
|
1110
|
+
threats.push(...bullets.map((b) => b.slice(2).trim()));
|
|
1111
|
+
}
|
|
1112
|
+
return threats;
|
|
1113
|
+
}
|
|
1114
|
+
function extractKeyTerms(text) {
|
|
1115
|
+
return text.toLowerCase().split(/\W+/).filter((w) => w.length > 3).filter((w) => !STOPWORDS.has(w));
|
|
1116
|
+
}
|
|
1117
|
+
var threatCoverageRule = {
|
|
1118
|
+
id: "security/threat-coverage",
|
|
1119
|
+
description: "Technical design specs must address threats identified in other specs",
|
|
1120
|
+
severity: "warn",
|
|
1121
|
+
run(context) {
|
|
1122
|
+
if (context.spec.frontmatter.type !== "technical-design")
|
|
1123
|
+
return [];
|
|
1124
|
+
const allThreats = [];
|
|
1125
|
+
for (const spec of context.allSpecs) {
|
|
1126
|
+
if (spec.filePath === context.spec.filePath)
|
|
1127
|
+
continue;
|
|
1128
|
+
allThreats.push(...extractThreats(spec.content));
|
|
1129
|
+
}
|
|
1130
|
+
if (allThreats.length === 0)
|
|
1131
|
+
return [];
|
|
1132
|
+
const techContent = context.spec.content.toLowerCase();
|
|
1133
|
+
const diagnostics = [];
|
|
1134
|
+
for (const threat of allThreats) {
|
|
1135
|
+
const keyTerms = extractKeyTerms(threat);
|
|
1136
|
+
const covered = keyTerms.some((term) => techContent.includes(term));
|
|
1137
|
+
if (!covered) {
|
|
1138
|
+
diagnostics.push({
|
|
1139
|
+
ruleId: "security/threat-coverage",
|
|
1140
|
+
severity: "warn",
|
|
1141
|
+
message: `Threat not addressed in technical design: "${threat}". Ensure the design covers this threat.`,
|
|
1142
|
+
filePath: context.spec.filePath
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
return diagnostics;
|
|
1147
|
+
}
|
|
1148
|
+
};
|
|
1149
|
+
|
|
1150
|
+
// ../lint/dist/rules/ambiguity-score-ai.js
|
|
1151
|
+
var ambiguityScoreAiRule = {
|
|
1152
|
+
id: "clarity/ambiguity-score-ai",
|
|
1153
|
+
description: "AI-powered ambiguity detection (requires ANTHROPIC_API_KEY)",
|
|
1154
|
+
severity: "info",
|
|
1155
|
+
run(context) {
|
|
1156
|
+
if (!process.env["ANTHROPIC_API_KEY"])
|
|
1157
|
+
return [];
|
|
1158
|
+
return [
|
|
1159
|
+
{
|
|
1160
|
+
ruleId: "clarity/ambiguity-score-ai",
|
|
1161
|
+
severity: "info",
|
|
1162
|
+
message: "AI ambiguity analysis available \u2014 run `sdx check --ai` for LLM-powered ambiguity detection",
|
|
1163
|
+
filePath: context.spec.filePath
|
|
1164
|
+
}
|
|
1165
|
+
];
|
|
1166
|
+
}
|
|
1167
|
+
};
|
|
1168
|
+
|
|
945
1169
|
// ../lint/dist/rules/index.js
|
|
946
1170
|
var structureRules = [
|
|
947
1171
|
validFrontmatterRule,
|
|
@@ -953,7 +1177,12 @@ var structureRules = [
|
|
|
953
1177
|
var contentRules = [
|
|
954
1178
|
storyCoverageRule,
|
|
955
1179
|
stalenessCheckRule,
|
|
956
|
-
noVagueLanguageRule
|
|
1180
|
+
noVagueLanguageRule,
|
|
1181
|
+
terminologyRule,
|
|
1182
|
+
edgeCaseCoverageRule,
|
|
1183
|
+
namingConventionsRule,
|
|
1184
|
+
threatCoverageRule,
|
|
1185
|
+
ambiguityScoreAiRule
|
|
957
1186
|
];
|
|
958
1187
|
var allBuiltinRules = [...structureRules, ...contentRules];
|
|
959
1188
|
|
|
@@ -1077,7 +1306,7 @@ var lint_default = defineCommand2({
|
|
|
1077
1306
|
import { defineCommand as defineCommand3 } from "citty";
|
|
1078
1307
|
|
|
1079
1308
|
// ../pack/dist/resolver.js
|
|
1080
|
-
var
|
|
1309
|
+
var STOPWORDS2 = /* @__PURE__ */ new Set([
|
|
1081
1310
|
"a",
|
|
1082
1311
|
"an",
|
|
1083
1312
|
"and",
|
|
@@ -1154,7 +1383,7 @@ var STOPWORDS = /* @__PURE__ */ new Set([
|
|
|
1154
1383
|
"your"
|
|
1155
1384
|
]);
|
|
1156
1385
|
function tokenize(task) {
|
|
1157
|
-
return task.split(/[\s\-_/.,;:!?()[\]{}'"]+/).map((t) => t.toLowerCase()).filter((t) => t.length > 1 && !
|
|
1386
|
+
return task.split(/[\s\-_/.,;:!?()[\]{}'"]+/).map((t) => t.toLowerCase()).filter((t) => t.length > 1 && !STOPWORDS2.has(t));
|
|
1158
1387
|
}
|
|
1159
1388
|
var WEIGHT_TAGS = 3;
|
|
1160
1389
|
var WEIGHT_TITLE = 3;
|
|
@@ -3131,7 +3360,9 @@ var status_default = defineCommand5({
|
|
|
3131
3360
|
console.log(
|
|
3132
3361
|
` ${result.specCount} specs: ${Object.entries(result.byStatus).map(([k, v]) => `${v} ${k}`).join(", ")}`
|
|
3133
3362
|
);
|
|
3134
|
-
console.log(
|
|
3363
|
+
console.log(
|
|
3364
|
+
` Lint: ${result.lintHealth.errors} errors, ${result.lintHealth.warnings} warnings`
|
|
3365
|
+
);
|
|
3135
3366
|
if (result.staleSpecs.length > 0) {
|
|
3136
3367
|
console.log(
|
|
3137
3368
|
` Stale: ${result.staleSpecs.map((s) => `${s.specId} (${s.daysSinceUpdate}d)`).join(", ")}`
|