specdx 0.3.0-alpha.1 → 0.3.0-alpha.3
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-NPN34DIO.js → changelog-OUP2RXWN.js} +4 -4
- package/dist/check-3XQYO3HU.js +109 -0
- package/dist/check-3XQYO3HU.js.map +1 -0
- package/dist/chunk-6BWZEAST.js +1051 -0
- package/dist/chunk-6BWZEAST.js.map +1 -0
- package/dist/{chunk-AO3ZQKLJ.js → chunk-DDFLMRPC.js} +4 -4
- package/dist/{chunk-AO3ZQKLJ.js.map → chunk-DDFLMRPC.js.map} +1 -1
- package/dist/{chunk-276J7LR6.js → chunk-PHR7AV6I.js} +2 -2
- package/dist/{chunk-6DTOYCZ6.js → chunk-WTFWNYJA.js} +29 -3
- package/dist/chunk-WTFWNYJA.js.map +1 -0
- package/dist/{chunk-XLEN6ZYM.js → chunk-ZX4HVL5M.js} +92 -4
- package/dist/chunk-ZX4HVL5M.js.map +1 -0
- package/dist/{diff-GWJONALU.js → diff-275PLXYH.js} +4 -4
- package/dist/dist-PQCG2XXF.js +11 -0
- package/dist/dist-PQCG2XXF.js.map +1 -0
- package/dist/{explain-YXUILNEA.js → explain-I7AQMEEH.js} +3 -3
- package/dist/generate-PC7BIB7G.js +13 -0
- package/dist/generate-PC7BIB7G.js.map +1 -0
- package/dist/generate-story-7WHPPFHY.js +192 -0
- package/dist/generate-story-7WHPPFHY.js.map +1 -0
- package/dist/generate-test-plan-U5LMWGKX.js +154 -0
- package/dist/generate-test-plan-U5LMWGKX.js.map +1 -0
- package/dist/{graph-OWQJWVSN.js → graph-RCAPF55A.js} +3 -3
- package/dist/index.js +162 -15
- package/dist/index.js.map +1 -1
- package/dist/{lint-CHWVBUV5.js → lint-6Z2TVWAQ.js} +4 -4
- package/dist/main.js +22 -13
- package/dist/main.js.map +1 -1
- package/dist/migrate-L7W5RHSS.js +56 -0
- package/dist/migrate-L7W5RHSS.js.map +1 -0
- package/dist/{pack-OJAC7JF2.js → pack-PI6V6OR2.js} +52 -9
- package/dist/{pack-OJAC7JF2.js.map → pack-PI6V6OR2.js.map} +1 -1
- package/dist/ready-B7IFPL3S.js +159 -0
- package/dist/ready-B7IFPL3S.js.map +1 -0
- package/dist/skills/specdx-author-spec/step-01-frontmatter.md +66 -0
- package/dist/skills/specdx-author-spec/step-02-sections.md +70 -0
- package/dist/skills/specdx-author-spec/step-03-finalize.md +48 -0
- package/dist/skills/specdx-author-spec.md +13 -113
- package/dist/skills/specdx-check-drift.md +71 -0
- package/dist/skills/specdx-review-spec.md +77 -0
- package/dist/skills/specdx-verify.md +70 -0
- package/dist/{skills-XJYTWGDK.js → skills-3GBBWZW2.js} +5 -2
- package/dist/skills-3GBBWZW2.js.map +1 -0
- package/dist/{status-VMALGNS5.js → status-AV5GSWVI.js} +5 -5
- package/dist/update-HIWDDEZQ.js +132 -0
- package/dist/update-HIWDDEZQ.js.map +1 -0
- package/dist/{validate-DOZZEZFC.js → validate-N2WSG75W.js} +3 -3
- package/package.json +2 -1
- package/dist/chunk-6DTOYCZ6.js.map +0 -1
- package/dist/chunk-XLEN6ZYM.js.map +0 -1
- package/dist/skills-XJYTWGDK.js.map +0 -1
- /package/dist/{changelog-NPN34DIO.js.map → changelog-OUP2RXWN.js.map} +0 -0
- /package/dist/{chunk-276J7LR6.js.map → chunk-PHR7AV6I.js.map} +0 -0
- /package/dist/{diff-GWJONALU.js.map → diff-275PLXYH.js.map} +0 -0
- /package/dist/{explain-YXUILNEA.js.map → explain-I7AQMEEH.js.map} +0 -0
- /package/dist/{graph-OWQJWVSN.js.map → graph-RCAPF55A.js.map} +0 -0
- /package/dist/{lint-CHWVBUV5.js.map → lint-6Z2TVWAQ.js.map} +0 -0
- /package/dist/{status-VMALGNS5.js.map → status-AV5GSWVI.js.map} +0 -0
- /package/dist/{validate-DOZZEZFC.js.map → validate-N2WSG75W.js.map} +0 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createLogger,
|
|
3
|
+
loadConfig,
|
|
4
|
+
parseSpec,
|
|
5
|
+
resolveGlob
|
|
6
|
+
} from "./chunk-PHR7AV6I.js";
|
|
7
|
+
import "./chunk-ZX4HVL5M.js";
|
|
8
|
+
|
|
9
|
+
// src/commands/generate-test-plan.ts
|
|
10
|
+
import { defineCommand } from "citty";
|
|
11
|
+
import { writeFile } from "fs/promises";
|
|
12
|
+
import { join } from "path";
|
|
13
|
+
function extractSection(content, heading) {
|
|
14
|
+
const escapedHeading = heading.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
15
|
+
const headingPattern = new RegExp(`^##\\s+${escapedHeading}\\s*$`, "im");
|
|
16
|
+
const match = headingPattern.exec(content);
|
|
17
|
+
if (!match) return null;
|
|
18
|
+
const start = match.index + match[0].length;
|
|
19
|
+
const rest = content.slice(start);
|
|
20
|
+
const nextSection = /^##\s+/m.exec(rest);
|
|
21
|
+
return nextSection ? rest.slice(0, nextSection.index) : rest;
|
|
22
|
+
}
|
|
23
|
+
function parseAcceptanceCriteria(section) {
|
|
24
|
+
const cases = [];
|
|
25
|
+
for (const rawLine of section.split("\n")) {
|
|
26
|
+
const line = rawLine.trim();
|
|
27
|
+
const bulletMatch = /^-\s+(?:\[[ xX]\]\s+)?(.+)/.exec(line);
|
|
28
|
+
if (bulletMatch) {
|
|
29
|
+
const text = bulletMatch[1].trim();
|
|
30
|
+
if (text) {
|
|
31
|
+
cases.push(text);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return cases;
|
|
36
|
+
}
|
|
37
|
+
async function generateTestPlan(options) {
|
|
38
|
+
const { configDir, outPath } = options;
|
|
39
|
+
const config = await loadConfig(void 0, configDir);
|
|
40
|
+
const storiesBySpec = [];
|
|
41
|
+
for (const [, entry] of Object.entries(config.specs)) {
|
|
42
|
+
if (entry.type !== "user-story") continue;
|
|
43
|
+
const files = await resolveGlob(entry.path, configDir);
|
|
44
|
+
for (const file of files) {
|
|
45
|
+
const parsed = await parseSpec(file);
|
|
46
|
+
const frontmatter2 = parsed.frontmatter;
|
|
47
|
+
const storyId = frontmatter2["id"] ?? file;
|
|
48
|
+
const title = frontmatter2["title"] ?? storyId;
|
|
49
|
+
const authors = frontmatter2["authors"] ?? [];
|
|
50
|
+
const acSection = extractSection(parsed.content, "Acceptance Criteria");
|
|
51
|
+
const cases = acSection ? parseAcceptanceCriteria(acSection) : [];
|
|
52
|
+
storiesBySpec.push({ storyId, title, authors, cases });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
storiesBySpec.sort((a, b) => a.storyId.localeCompare(b.storyId));
|
|
56
|
+
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
57
|
+
const allAuthors = Array.from(new Set(storiesBySpec.flatMap((s) => s.authors)));
|
|
58
|
+
const storyRefs = storiesBySpec.map((s) => ` - id: "${s.storyId}"
|
|
59
|
+
relationship: "related-to"`);
|
|
60
|
+
const totalTestCases = storiesBySpec.reduce((sum, s) => sum + s.cases.length, 0);
|
|
61
|
+
const authorsYaml = allAuthors.length > 0 ? `[${allAuthors.map((a) => `"${a}"`).join(", ")}]` : '["generated"]';
|
|
62
|
+
const refsYaml = storyRefs.length > 0 ? `
|
|
63
|
+
references:
|
|
64
|
+
${storyRefs.join("\n")}` : "";
|
|
65
|
+
const frontmatter = [
|
|
66
|
+
"---",
|
|
67
|
+
'id: "generated-test-plan"',
|
|
68
|
+
'type: "test-plan"',
|
|
69
|
+
'title: "Generated Test Plan"',
|
|
70
|
+
'status: "draft"',
|
|
71
|
+
'version: "0.1"',
|
|
72
|
+
`created: "${today}"`,
|
|
73
|
+
`authors: ${authorsYaml}`,
|
|
74
|
+
refsYaml.length > 0 ? refsYaml.trimStart() : null,
|
|
75
|
+
"---"
|
|
76
|
+
].filter((line) => line !== null).join("\n");
|
|
77
|
+
const scopeLines = storiesBySpec.length > 0 ? storiesBySpec.map((s) => `- ${s.storyId}: ${s.title}`).join("\n") : "_No user stories found._";
|
|
78
|
+
const testCaseBlocks = storiesBySpec.map((s) => {
|
|
79
|
+
const caseBullets = s.cases.length > 0 ? s.cases.map((c) => `- [ ] ${c}`).join("\n") : "_No acceptance criteria found._";
|
|
80
|
+
return `### ${s.storyId}
|
|
81
|
+
|
|
82
|
+
${caseBullets}`;
|
|
83
|
+
}).join("\n\n");
|
|
84
|
+
const testCasesBody = storiesBySpec.length > 0 ? testCaseBlocks : "_No user stories found._";
|
|
85
|
+
const matrixHeader = "| Story | Test Cases |";
|
|
86
|
+
const matrixSep = "| ----- | ---------- |";
|
|
87
|
+
const matrixRows = storiesBySpec.map((s) => `| ${s.storyId} | ${s.cases.length} |`);
|
|
88
|
+
const coverageMatrix = [matrixHeader, matrixSep, ...matrixRows].join("\n");
|
|
89
|
+
const edgeCasesPlaceholder = "<!-- Add edge cases and boundary conditions here -->";
|
|
90
|
+
const body = [
|
|
91
|
+
`## Scope`,
|
|
92
|
+
"",
|
|
93
|
+
scopeLines,
|
|
94
|
+
"",
|
|
95
|
+
`## Test Cases`,
|
|
96
|
+
"",
|
|
97
|
+
testCasesBody,
|
|
98
|
+
"",
|
|
99
|
+
`## Coverage Matrix`,
|
|
100
|
+
"",
|
|
101
|
+
coverageMatrix,
|
|
102
|
+
"",
|
|
103
|
+
`## Edge Cases`,
|
|
104
|
+
"",
|
|
105
|
+
edgeCasesPlaceholder,
|
|
106
|
+
""
|
|
107
|
+
].join("\n");
|
|
108
|
+
const fileContent = `${frontmatter}
|
|
109
|
+
|
|
110
|
+
${body}`;
|
|
111
|
+
const targetPath = outPath ?? join(configDir, "specs", "test-plan.md");
|
|
112
|
+
await writeFile(targetPath, fileContent, "utf-8");
|
|
113
|
+
return { filePath: targetPath, testCases: totalTestCases };
|
|
114
|
+
}
|
|
115
|
+
var generate_test_plan_default = defineCommand({
|
|
116
|
+
meta: { name: "generate-test-plan", description: "Generate a test plan stub from user stories" },
|
|
117
|
+
args: {
|
|
118
|
+
from: {
|
|
119
|
+
type: "string",
|
|
120
|
+
description: "Source to generate from (currently only 'stories' is supported)",
|
|
121
|
+
default: "stories"
|
|
122
|
+
},
|
|
123
|
+
out: {
|
|
124
|
+
type: "string",
|
|
125
|
+
description: "Output file path (default: specs/test-plan.md)"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
async run({ args }) {
|
|
129
|
+
const logger = createLogger({ quiet: false, verbose: false });
|
|
130
|
+
if (args.from !== "stories") {
|
|
131
|
+
console.error(`
|
|
132
|
+
\u2717 --from must be 'stories' (got: ${args.from})
|
|
133
|
+
`);
|
|
134
|
+
process.exit(1);
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
const result = await generateTestPlan({
|
|
138
|
+
configDir: process.cwd(),
|
|
139
|
+
outPath: args.out
|
|
140
|
+
});
|
|
141
|
+
logger.info(`Generated test plan with ${result.testCases} test cases \u2192 ${result.filePath}`);
|
|
142
|
+
} catch (err) {
|
|
143
|
+
console.error(`
|
|
144
|
+
\u2717 ${err.message}
|
|
145
|
+
`);
|
|
146
|
+
process.exit(1);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
export {
|
|
151
|
+
generate_test_plan_default as default,
|
|
152
|
+
generateTestPlan
|
|
153
|
+
};
|
|
154
|
+
//# sourceMappingURL=generate-test-plan-U5LMWGKX.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((s) => ` - id: \"${s.storyId}\"\\n relationship: \"related-to\"`);\n\n const totalTestCases = storiesBySpec.reduce((sum, s) => sum + s.cases.length, 0);\n\n // Build frontmatter\n const authorsYaml =\n allAuthors.length > 0\n ? `[${allAuthors.map((a) => `\"${a}\"`).join(\", \")}]`\n : '[\"generated\"]';\n\n const refsYaml =\n storyRefs.length > 0\n ? `\\nreferences:\\n${storyRefs.join(\"\\n\")}`\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 =\n 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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AM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;","names":["frontmatter"]}
|
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
GraphError,
|
|
6
6
|
buildGraph,
|
|
7
7
|
loadConfig
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-PHR7AV6I.js";
|
|
9
|
+
import "./chunk-ZX4HVL5M.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-RCAPF55A.js.map
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,10 @@ var REQUIRED_SECTIONS = {
|
|
|
18
18
|
"user-story": ["Description", "Acceptance Criteria", "Dependencies", "Notes"],
|
|
19
19
|
"test-plan": ["Scope", "Test Cases", "Coverage Matrix", "Edge Cases"],
|
|
20
20
|
adr: ["Context", "Decision", "Status", "Consequences"],
|
|
21
|
-
"api-contract": ["Endpoints", "Request/Response Schemas", "Auth", "Error Codes"]
|
|
21
|
+
"api-contract": ["Endpoints", "Request/Response Schemas", "Auth", "Error Codes"],
|
|
22
|
+
epic: ["Overview", "Stories", "Acceptance Criteria", "Dependencies"],
|
|
23
|
+
"quick-spec": ["Intent", "Boundaries", "Tasks"],
|
|
24
|
+
"project-context": ["Technology Stack", "Critical Implementation Rules", "Coding Patterns"]
|
|
22
25
|
};
|
|
23
26
|
|
|
24
27
|
// ../schema/dist/validator.js
|
|
@@ -31,7 +34,7 @@ var base_spec_default = {
|
|
|
31
34
|
type: "object",
|
|
32
35
|
properties: {
|
|
33
36
|
id: { type: "string", minLength: 1 },
|
|
34
|
-
type: { type: "string", enum: ["prd", "technical-design", "user-story", "test-plan", "adr", "api-contract"] },
|
|
37
|
+
type: { type: "string", enum: ["prd", "technical-design", "user-story", "test-plan", "adr", "api-contract", "epic", "quick-spec", "project-context"] },
|
|
35
38
|
title: { type: "string", minLength: 1 },
|
|
36
39
|
status: { type: "string", enum: ["draft", "review", "approved", "superseded"] },
|
|
37
40
|
version: { type: "string" },
|
|
@@ -141,6 +144,24 @@ var config_default = {
|
|
|
141
144
|
}
|
|
142
145
|
},
|
|
143
146
|
additionalProperties: false
|
|
147
|
+
},
|
|
148
|
+
check: {
|
|
149
|
+
type: "object",
|
|
150
|
+
properties: {
|
|
151
|
+
framework: {
|
|
152
|
+
type: "string",
|
|
153
|
+
enum: ["auto", "express", "hono", "nextjs"]
|
|
154
|
+
},
|
|
155
|
+
routes_dir: { type: "string" },
|
|
156
|
+
app_dir: { type: "string" },
|
|
157
|
+
types_dir: { type: "string" },
|
|
158
|
+
tests_dir: { type: "string" },
|
|
159
|
+
ignore: {
|
|
160
|
+
type: "array",
|
|
161
|
+
items: { type: "string" }
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
additionalProperties: false
|
|
144
165
|
}
|
|
145
166
|
},
|
|
146
167
|
required: ["version", "specs"],
|
|
@@ -216,6 +237,56 @@ var api_contract_default = {
|
|
|
216
237
|
]
|
|
217
238
|
};
|
|
218
239
|
|
|
240
|
+
// ../schema/dist/schemas/epic.json
|
|
241
|
+
var epic_default = {
|
|
242
|
+
$id: "epic",
|
|
243
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
244
|
+
allOf: [
|
|
245
|
+
{ $ref: "base-spec" },
|
|
246
|
+
{
|
|
247
|
+
type: "object",
|
|
248
|
+
properties: {
|
|
249
|
+
type: { const: "epic" },
|
|
250
|
+
epic_id: { type: "string", minLength: 1 },
|
|
251
|
+
priority: { type: "string", enum: ["critical", "high", "medium", "low"] }
|
|
252
|
+
},
|
|
253
|
+
required: ["type", "epic_id", "priority"]
|
|
254
|
+
}
|
|
255
|
+
]
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
// ../schema/dist/schemas/quick-spec.json
|
|
259
|
+
var quick_spec_default = {
|
|
260
|
+
$id: "quick-spec",
|
|
261
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
262
|
+
allOf: [
|
|
263
|
+
{ $ref: "base-spec" },
|
|
264
|
+
{
|
|
265
|
+
type: "object",
|
|
266
|
+
properties: {
|
|
267
|
+
type: { const: "quick-spec" }
|
|
268
|
+
},
|
|
269
|
+
required: ["type"]
|
|
270
|
+
}
|
|
271
|
+
]
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
// ../schema/dist/schemas/project-context.json
|
|
275
|
+
var project_context_default = {
|
|
276
|
+
$id: "project-context",
|
|
277
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
278
|
+
allOf: [
|
|
279
|
+
{ $ref: "base-spec" },
|
|
280
|
+
{
|
|
281
|
+
type: "object",
|
|
282
|
+
properties: {
|
|
283
|
+
type: { const: "project-context" }
|
|
284
|
+
},
|
|
285
|
+
required: ["type"]
|
|
286
|
+
}
|
|
287
|
+
]
|
|
288
|
+
};
|
|
289
|
+
|
|
219
290
|
// ../schema/dist/validator.js
|
|
220
291
|
import * as addFormatsNs from "ajv-formats";
|
|
221
292
|
var addFormats = addFormatsNs.default ?? addFormatsNs;
|
|
@@ -228,7 +299,10 @@ var specValidators = {
|
|
|
228
299
|
"user-story": ajv.compile(user_story_default),
|
|
229
300
|
"test-plan": ajv.compile(test_plan_default),
|
|
230
301
|
adr: ajv.compile(adr_default),
|
|
231
|
-
"api-contract": ajv.compile(api_contract_default)
|
|
302
|
+
"api-contract": ajv.compile(api_contract_default),
|
|
303
|
+
epic: ajv.compile(epic_default),
|
|
304
|
+
"quick-spec": ajv.compile(quick_spec_default),
|
|
305
|
+
"project-context": ajv.compile(project_context_default)
|
|
232
306
|
};
|
|
233
307
|
var configValidator = ajv.compile(config_default);
|
|
234
308
|
function validateSpec(type, data) {
|
|
@@ -259,12 +333,16 @@ var TEMPLATE_SPECS = {
|
|
|
259
333
|
{ filename: "technical-design.md", type: "technical-design" },
|
|
260
334
|
{ filename: "api-contract.md", type: "api-contract" },
|
|
261
335
|
{ filename: "test-plan.md", type: "test-plan" }
|
|
262
|
-
]
|
|
336
|
+
],
|
|
337
|
+
quick: [{ filename: "quick-spec.md", type: "quick-spec" }],
|
|
338
|
+
context: [{ filename: "project-context.md", type: "project-context" }]
|
|
263
339
|
};
|
|
264
340
|
var TEMPLATE_EXTRA_DIRS = {
|
|
265
341
|
lightweight: [],
|
|
266
342
|
bmad: ["specs/stories", "specs/adr"],
|
|
267
|
-
"api-first": []
|
|
343
|
+
"api-first": [],
|
|
344
|
+
quick: [],
|
|
345
|
+
context: []
|
|
268
346
|
};
|
|
269
347
|
function specIdFromFilename(filename) {
|
|
270
348
|
return filename.replace(/\.md$/, "");
|
|
@@ -347,7 +425,7 @@ var init_default = defineCommand({
|
|
|
347
425
|
},
|
|
348
426
|
async run({ args }) {
|
|
349
427
|
const { name, template, dir } = args;
|
|
350
|
-
const validTemplates = ["lightweight", "bmad", "api-first"];
|
|
428
|
+
const validTemplates = ["lightweight", "bmad", "api-first", "quick", "context"];
|
|
351
429
|
if (!validTemplates.includes(template)) {
|
|
352
430
|
console.error(`Unknown template: ${template}. Choose from: ${validTemplates.join(", ")}`);
|
|
353
431
|
process.exit(1);
|
|
@@ -841,12 +919,36 @@ var noVagueLanguageRule = {
|
|
|
841
919
|
}
|
|
842
920
|
};
|
|
843
921
|
|
|
922
|
+
// ../lint/dist/rules/single-project-context.js
|
|
923
|
+
var singleProjectContextRule = {
|
|
924
|
+
id: "structure/single-project-context",
|
|
925
|
+
description: "Only one project-context spec should exist per suite",
|
|
926
|
+
severity: "warn",
|
|
927
|
+
run(context) {
|
|
928
|
+
if (context.spec.frontmatter.type !== "project-context")
|
|
929
|
+
return [];
|
|
930
|
+
const contextSpecs = context.allSpecs.filter((s) => s.frontmatter.type === "project-context");
|
|
931
|
+
if (contextSpecs.length > 1) {
|
|
932
|
+
return [
|
|
933
|
+
{
|
|
934
|
+
ruleId: "structure/single-project-context",
|
|
935
|
+
severity: "warn",
|
|
936
|
+
message: `Multiple project-context specs found (${contextSpecs.length}). Only one should exist per suite.`,
|
|
937
|
+
filePath: context.spec.filePath
|
|
938
|
+
}
|
|
939
|
+
];
|
|
940
|
+
}
|
|
941
|
+
return [];
|
|
942
|
+
}
|
|
943
|
+
};
|
|
944
|
+
|
|
844
945
|
// ../lint/dist/rules/index.js
|
|
845
946
|
var structureRules = [
|
|
846
947
|
validFrontmatterRule,
|
|
847
948
|
requiredSectionsRule,
|
|
848
949
|
validReferencesRule,
|
|
849
|
-
noCircularDepsRule
|
|
950
|
+
noCircularDepsRule,
|
|
951
|
+
singleProjectContextRule
|
|
850
952
|
];
|
|
851
953
|
var contentRules = [
|
|
852
954
|
storyCoverageRule,
|
|
@@ -864,6 +966,8 @@ function getPreset(name) {
|
|
|
864
966
|
return allBuiltinRules;
|
|
865
967
|
case "strict":
|
|
866
968
|
return allBuiltinRules.map((rule) => ({ ...rule, severity: "error" }));
|
|
969
|
+
default:
|
|
970
|
+
throw new Error(`Unknown preset: "${name}". Use "minimal", "recommended", or "strict", or resolve external presets via resolvePreset() from @specdx/core.`);
|
|
867
971
|
}
|
|
868
972
|
}
|
|
869
973
|
|
|
@@ -1475,29 +1579,72 @@ function pack(specs, options, packConfig, graph) {
|
|
|
1475
1579
|
const full = options.full ?? false;
|
|
1476
1580
|
const compression = buildCompressionOptions(packConfig);
|
|
1477
1581
|
const resolvedGraph = graph ?? emptyGraph();
|
|
1478
|
-
const
|
|
1582
|
+
const projectContextSpecs = [];
|
|
1583
|
+
const regularSpecs = [];
|
|
1479
1584
|
for (const spec of specs) {
|
|
1585
|
+
if (spec.frontmatter.type === "project-context") {
|
|
1586
|
+
projectContextSpecs.push(spec);
|
|
1587
|
+
} else {
|
|
1588
|
+
regularSpecs.push(spec);
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
let reservedTokens = 0;
|
|
1592
|
+
let reservedCompressed = [];
|
|
1593
|
+
if (projectContextSpecs.length > 0) {
|
|
1594
|
+
const maxReserved = Math.min(budget, 2e3);
|
|
1595
|
+
const ctxScores = projectContextSpecs.map((s) => ({
|
|
1596
|
+
specId: s.frontmatter.id,
|
|
1597
|
+
score: 1,
|
|
1598
|
+
rawScore: 1,
|
|
1599
|
+
matchedKeywords: [],
|
|
1600
|
+
graphBoosted: false
|
|
1601
|
+
}));
|
|
1602
|
+
const ctxResult = allocate(projectContextSpecs, ctxScores, {
|
|
1603
|
+
budget: maxReserved,
|
|
1604
|
+
full: true,
|
|
1605
|
+
compression
|
|
1606
|
+
});
|
|
1607
|
+
reservedCompressed = ctxResult.specs;
|
|
1608
|
+
reservedTokens = ctxResult.stats.used;
|
|
1609
|
+
}
|
|
1610
|
+
const regularBudget = Math.max(0, budget - reservedTokens);
|
|
1611
|
+
const specMap = /* @__PURE__ */ new Map();
|
|
1612
|
+
for (const spec of regularSpecs) {
|
|
1480
1613
|
specMap.set(spec.frontmatter.id, spec);
|
|
1481
1614
|
}
|
|
1482
1615
|
const scores = options.specs ? scoreSpecsByIds(specMap, options.specs, resolvedGraph) : scoreSpecs(specMap, options.task, resolvedGraph);
|
|
1483
|
-
const { specs: compressedSpecs, stats } = allocate(
|
|
1484
|
-
budget,
|
|
1616
|
+
const { specs: compressedSpecs, stats } = allocate(regularSpecs, scores, {
|
|
1617
|
+
budget: regularBudget,
|
|
1485
1618
|
full,
|
|
1486
1619
|
compression
|
|
1487
1620
|
});
|
|
1621
|
+
const allCompressed = [...reservedCompressed, ...compressedSpecs];
|
|
1622
|
+
stats.budget = budget;
|
|
1623
|
+
stats.used += reservedTokens;
|
|
1624
|
+
stats.specsIncluded += reservedCompressed.length;
|
|
1625
|
+
for (const ctx of reservedCompressed) {
|
|
1626
|
+
stats.allocations.unshift({
|
|
1627
|
+
specId: ctx.specId,
|
|
1628
|
+
type: ctx.type,
|
|
1629
|
+
relevance: 1,
|
|
1630
|
+
tokens: reservedTokens,
|
|
1631
|
+
compressed: false,
|
|
1632
|
+
included: true
|
|
1633
|
+
});
|
|
1634
|
+
}
|
|
1488
1635
|
if (options.dryRun) {
|
|
1489
1636
|
return { output: "", stats };
|
|
1490
1637
|
}
|
|
1491
1638
|
let output;
|
|
1492
1639
|
switch (format) {
|
|
1493
1640
|
case "markdown":
|
|
1494
|
-
output = formatMarkdown(
|
|
1641
|
+
output = formatMarkdown(allCompressed, stats);
|
|
1495
1642
|
break;
|
|
1496
1643
|
case "json":
|
|
1497
|
-
output = formatJson2(
|
|
1644
|
+
output = formatJson2(allCompressed, stats);
|
|
1498
1645
|
break;
|
|
1499
1646
|
default:
|
|
1500
|
-
output = formatXml(
|
|
1647
|
+
output = formatXml(allCompressed, stats);
|
|
1501
1648
|
break;
|
|
1502
1649
|
}
|
|
1503
1650
|
return { output, stats };
|
|
@@ -2514,7 +2661,7 @@ function diffSections(before, after) {
|
|
|
2514
2661
|
for (const section of after) {
|
|
2515
2662
|
afterMap.set(section.heading, section);
|
|
2516
2663
|
}
|
|
2517
|
-
for (const [heading
|
|
2664
|
+
for (const [heading] of beforeMap) {
|
|
2518
2665
|
if (!afterMap.has(heading)) {
|
|
2519
2666
|
changes.push({ heading, type: "removed" });
|
|
2520
2667
|
}
|
|
@@ -2594,7 +2741,7 @@ function analyzeImpact(changedSpecId, diff2, graph, allSpecs, thresholdDays = 14
|
|
|
2594
2741
|
const spec = specById.get(specId);
|
|
2595
2742
|
const lastUpdated = spec?.frontmatter.updated ?? spec?.frontmatter.created ?? null;
|
|
2596
2743
|
const filePath = spec?.filePath ?? `specs/${specId}.md`;
|
|
2597
|
-
let staleness
|
|
2744
|
+
let staleness;
|
|
2598
2745
|
if (lastUpdated) {
|
|
2599
2746
|
const daysSinceUpdate = daysBetween(lastUpdated);
|
|
2600
2747
|
staleness = clamp(0, 1, daysSinceUpdate / thresholdDays * 0.5 + structuralSectionsChanged / totalSections * 0.3 + 1 / distance * 0.2);
|