specdx 0.3.0-alpha.2 → 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-URU2TFNM.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-LU6M5O63.js → chunk-DDFLMRPC.js} +2 -2
- package/dist/{chunk-276J7LR6.js → chunk-PHR7AV6I.js} +2 -2
- package/dist/{chunk-ATLVRGHI.js → chunk-WTFWNYJA.js} +27 -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-55PTEVB3.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 +158 -13
- package/dist/index.js.map +1 -1
- package/dist/{lint-U7VLGS75.js → lint-6Z2TVWAQ.js} +4 -4
- package/dist/main.js +22 -14
- 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-3OIF4QHM.js → ready-B7IFPL3S.js} +5 -5
- 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-LYZUO6AJ.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-ATLVRGHI.js.map +0 -1
- package/dist/chunk-XLEN6ZYM.js.map +0 -1
- package/dist/skills-XJYTWGDK.js.map +0 -1
- /package/dist/{changelog-URU2TFNM.js.map → changelog-OUP2RXWN.js.map} +0 -0
- /package/dist/{chunk-LU6M5O63.js.map → chunk-DDFLMRPC.js.map} +0 -0
- /package/dist/{chunk-276J7LR6.js.map → chunk-PHR7AV6I.js.map} +0 -0
- /package/dist/{diff-55PTEVB3.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-U7VLGS75.js.map → lint-6Z2TVWAQ.js.map} +0 -0
- /package/dist/{ready-3OIF4QHM.js.map → ready-B7IFPL3S.js.map} +0 -0
- /package/dist/{status-LYZUO6AJ.js.map → status-AV5GSWVI.js.map} +0 -0
- /package/dist/{validate-DOZZEZFC.js.map → validate-N2WSG75W.js.map} +0 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createLogger,
|
|
3
|
+
loadConfig,
|
|
4
|
+
parseSpec,
|
|
5
|
+
resolveGlob
|
|
6
|
+
} from "./chunk-PHR7AV6I.js";
|
|
7
|
+
import {
|
|
8
|
+
REQUIRED_SECTIONS
|
|
9
|
+
} from "./chunk-ZX4HVL5M.js";
|
|
10
|
+
|
|
11
|
+
// src/commands/generate-story.ts
|
|
12
|
+
import { defineCommand } from "citty";
|
|
13
|
+
import { writeFile, mkdir } from "fs/promises";
|
|
14
|
+
import { join } from "path";
|
|
15
|
+
function slugify(text) {
|
|
16
|
+
return text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40);
|
|
17
|
+
}
|
|
18
|
+
function detectStoriesDir(configDir, config) {
|
|
19
|
+
for (const entry of Object.values(config.specs)) {
|
|
20
|
+
if (entry.type === "user-story") {
|
|
21
|
+
const dirPart = entry.path.replace(/\/[^/]*\*.*$/, "").replace(/\/[^/]*$/, "");
|
|
22
|
+
const match = entry.path.match(/^(.+?)\/\*/);
|
|
23
|
+
if (match) {
|
|
24
|
+
return join(configDir, match[1]);
|
|
25
|
+
}
|
|
26
|
+
return join(configDir, dirPart);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return join(configDir, "specs/stories");
|
|
30
|
+
}
|
|
31
|
+
function buildStoryFile(options) {
|
|
32
|
+
const { featureNum, featureText, prdId, prdAuthors, today, sections } = options;
|
|
33
|
+
const storyId = `story-f${featureNum}`;
|
|
34
|
+
const title = featureText.trim();
|
|
35
|
+
const authorsYaml = JSON.stringify(prdAuthors);
|
|
36
|
+
const frontmatter = [
|
|
37
|
+
"---",
|
|
38
|
+
`id: "${storyId}"`,
|
|
39
|
+
`type: "user-story"`,
|
|
40
|
+
`title: "${title}"`,
|
|
41
|
+
`status: "draft"`,
|
|
42
|
+
`version: "0.1"`,
|
|
43
|
+
`created: "${today}"`,
|
|
44
|
+
`authors: ${authorsYaml}`,
|
|
45
|
+
`story_id: "${storyId}"`,
|
|
46
|
+
`priority: "medium"`,
|
|
47
|
+
`estimate: "TBD"`,
|
|
48
|
+
`references:`,
|
|
49
|
+
` - id: "${prdId}"`,
|
|
50
|
+
` relationship: "decomposed-into"`,
|
|
51
|
+
"---"
|
|
52
|
+
].join("\n");
|
|
53
|
+
const bodyParts = sections.map((section) => {
|
|
54
|
+
if (section === "Description") {
|
|
55
|
+
return `
|
|
56
|
+
## ${section}
|
|
57
|
+
|
|
58
|
+
${featureText.trim()}`;
|
|
59
|
+
}
|
|
60
|
+
if (section === "Acceptance Criteria") {
|
|
61
|
+
return `
|
|
62
|
+
## ${section}
|
|
63
|
+
|
|
64
|
+
- [ ] <!-- acceptance criterion -->`;
|
|
65
|
+
}
|
|
66
|
+
if (section === "Dependencies") {
|
|
67
|
+
return `
|
|
68
|
+
## ${section}
|
|
69
|
+
|
|
70
|
+
F${featureNum} from ${prdId}`;
|
|
71
|
+
}
|
|
72
|
+
return `
|
|
73
|
+
## ${section}
|
|
74
|
+
|
|
75
|
+
<!-- placeholder -->`;
|
|
76
|
+
});
|
|
77
|
+
return `${frontmatter}
|
|
78
|
+
${bodyParts.join("\n")}
|
|
79
|
+
`;
|
|
80
|
+
}
|
|
81
|
+
async function generateStories(options) {
|
|
82
|
+
const { configDir, from, outDir } = options;
|
|
83
|
+
const config = await loadConfig(void 0, configDir);
|
|
84
|
+
let prdFilePath;
|
|
85
|
+
for (const entry of Object.values(config.specs)) {
|
|
86
|
+
const files = await resolveGlob(entry.path, configDir);
|
|
87
|
+
for (const file of files) {
|
|
88
|
+
const parsed = await parseSpec(file);
|
|
89
|
+
if (parsed.frontmatter.id === from) {
|
|
90
|
+
prdFilePath = file;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (prdFilePath) break;
|
|
95
|
+
}
|
|
96
|
+
if (!prdFilePath) {
|
|
97
|
+
throw new Error(`No spec with id "${from}" found in config.`);
|
|
98
|
+
}
|
|
99
|
+
const prd = await parseSpec(prdFilePath);
|
|
100
|
+
const featuresSection = prd.parsedSections.find((s) => s.heading === "Features");
|
|
101
|
+
if (!featuresSection) {
|
|
102
|
+
return { generated: [] };
|
|
103
|
+
}
|
|
104
|
+
const featureRegex = /\*\*F(\d+)\*\*:\s*(.+)/g;
|
|
105
|
+
const features = [];
|
|
106
|
+
let match;
|
|
107
|
+
while ((match = featureRegex.exec(featuresSection.content)) !== null) {
|
|
108
|
+
features.push({ num: match[1], text: match[2] });
|
|
109
|
+
}
|
|
110
|
+
if (features.length === 0) {
|
|
111
|
+
return { generated: [] };
|
|
112
|
+
}
|
|
113
|
+
const storiesDir = outDir ?? detectStoriesDir(configDir, config);
|
|
114
|
+
await mkdir(storiesDir, { recursive: true });
|
|
115
|
+
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
116
|
+
const prdAuthors = prd.frontmatter.authors ?? [];
|
|
117
|
+
const sections = REQUIRED_SECTIONS["user-story"];
|
|
118
|
+
const generated = [];
|
|
119
|
+
for (const feature of features) {
|
|
120
|
+
const slug = slugify(feature.text);
|
|
121
|
+
const filename = `story-f${feature.num}-${slug}.md`;
|
|
122
|
+
const filePath = join(storiesDir, filename);
|
|
123
|
+
const content = buildStoryFile({
|
|
124
|
+
featureNum: feature.num,
|
|
125
|
+
featureText: feature.text,
|
|
126
|
+
prdId: from,
|
|
127
|
+
prdAuthors,
|
|
128
|
+
today,
|
|
129
|
+
sections
|
|
130
|
+
});
|
|
131
|
+
await writeFile(filePath, content, "utf-8");
|
|
132
|
+
generated.push(filePath);
|
|
133
|
+
}
|
|
134
|
+
return { generated };
|
|
135
|
+
}
|
|
136
|
+
var defineCommandExport = defineCommand({
|
|
137
|
+
meta: {
|
|
138
|
+
name: "generate story",
|
|
139
|
+
description: "Generate user story stub files from a PRD's Features section"
|
|
140
|
+
},
|
|
141
|
+
args: {
|
|
142
|
+
from: {
|
|
143
|
+
type: "string",
|
|
144
|
+
description: "Spec ID of the PRD to generate stories from",
|
|
145
|
+
required: true
|
|
146
|
+
},
|
|
147
|
+
out: {
|
|
148
|
+
type: "string",
|
|
149
|
+
description: "Output directory for story files (default: auto-detected from config)"
|
|
150
|
+
},
|
|
151
|
+
quiet: {
|
|
152
|
+
type: "boolean",
|
|
153
|
+
description: "Suppress output",
|
|
154
|
+
default: false
|
|
155
|
+
},
|
|
156
|
+
verbose: {
|
|
157
|
+
type: "boolean",
|
|
158
|
+
description: "Verbose output",
|
|
159
|
+
default: false
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
async run({ args }) {
|
|
163
|
+
const logger = createLogger({ quiet: args.quiet, verbose: args.verbose });
|
|
164
|
+
try {
|
|
165
|
+
const result = await generateStories({
|
|
166
|
+
configDir: process.cwd(),
|
|
167
|
+
from: args.from,
|
|
168
|
+
outDir: args.out
|
|
169
|
+
});
|
|
170
|
+
if (result.generated.length === 0) {
|
|
171
|
+
logger.info("No features found in PRD \u2014 no story stubs generated.");
|
|
172
|
+
} else {
|
|
173
|
+
logger.info(`Generated ${result.generated.length} story stub(s):`);
|
|
174
|
+
for (const filePath of result.generated) {
|
|
175
|
+
logger.info(` ${filePath}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
} catch (err) {
|
|
179
|
+
console.error(`
|
|
180
|
+
\u2717 ${err.message}
|
|
181
|
+
`);
|
|
182
|
+
process.exit(1);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
var generate_story_default = defineCommandExport;
|
|
187
|
+
export {
|
|
188
|
+
generate_story_default as default,
|
|
189
|
+
defineCommandExport,
|
|
190
|
+
generateStories
|
|
191
|
+
};
|
|
192
|
+
//# sourceMappingURL=generate-story-7WHPPFHY.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(configDir: string, config: Awaited<ReturnType<typeof loadConfig>>): 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,iBAAiB,WAAmB,QAAwD;AACnG,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,SAA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
+
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;AAEhC,QAAM,cAAc,UAAU,KAAK,IAAI;AACvC,SAAO,cAAc,KAAK,MAAM,GAAG,YAAY,KAAK,IAAI;AAC1D;AAMA,SAAS,wBAAwB,SAA2B;AAC1D,QAAM,QAAkB,CAAC;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|
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,
|
|
@@ -1477,29 +1579,72 @@ function pack(specs, options, packConfig, graph) {
|
|
|
1477
1579
|
const full = options.full ?? false;
|
|
1478
1580
|
const compression = buildCompressionOptions(packConfig);
|
|
1479
1581
|
const resolvedGraph = graph ?? emptyGraph();
|
|
1480
|
-
const
|
|
1582
|
+
const projectContextSpecs = [];
|
|
1583
|
+
const regularSpecs = [];
|
|
1481
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) {
|
|
1482
1613
|
specMap.set(spec.frontmatter.id, spec);
|
|
1483
1614
|
}
|
|
1484
1615
|
const scores = options.specs ? scoreSpecsByIds(specMap, options.specs, resolvedGraph) : scoreSpecs(specMap, options.task, resolvedGraph);
|
|
1485
|
-
const { specs: compressedSpecs, stats } = allocate(
|
|
1486
|
-
budget,
|
|
1616
|
+
const { specs: compressedSpecs, stats } = allocate(regularSpecs, scores, {
|
|
1617
|
+
budget: regularBudget,
|
|
1487
1618
|
full,
|
|
1488
1619
|
compression
|
|
1489
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
|
+
}
|
|
1490
1635
|
if (options.dryRun) {
|
|
1491
1636
|
return { output: "", stats };
|
|
1492
1637
|
}
|
|
1493
1638
|
let output;
|
|
1494
1639
|
switch (format) {
|
|
1495
1640
|
case "markdown":
|
|
1496
|
-
output = formatMarkdown(
|
|
1641
|
+
output = formatMarkdown(allCompressed, stats);
|
|
1497
1642
|
break;
|
|
1498
1643
|
case "json":
|
|
1499
|
-
output = formatJson2(
|
|
1644
|
+
output = formatJson2(allCompressed, stats);
|
|
1500
1645
|
break;
|
|
1501
1646
|
default:
|
|
1502
|
-
output = formatXml(
|
|
1647
|
+
output = formatXml(allCompressed, stats);
|
|
1503
1648
|
break;
|
|
1504
1649
|
}
|
|
1505
1650
|
return { output, stats };
|