specdx 0.4.0-alpha.15 → 0.4.0-alpha.17
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 +2 -2
- package/dist/{check-6ULNLONS.js → check-Q3QKTN2D.js} +4 -4
- package/dist/check-Q3QKTN2D.js.map +1 -0
- package/dist/{chunk-SDDTD4R3.js → chunk-TF7WSPFV.js} +31 -11
- package/dist/chunk-TF7WSPFV.js.map +1 -0
- package/dist/chunk-TJPPBM24.js +179 -0
- package/dist/chunk-TJPPBM24.js.map +1 -0
- package/dist/{diff-AWFDXYX4.js → diff-IEN6W4OG.js} +3 -3
- package/dist/diff-IEN6W4OG.js.map +1 -0
- package/dist/{dist-2YMKBA6A.js → dist-DVROIZAO.js} +2 -2
- package/dist/generate-GQPOLFP7.js +21 -0
- package/dist/generate-GQPOLFP7.js.map +1 -0
- package/dist/{generate-story-OV3PFJN6.js → generate-story-UJS37FHA.js} +2 -2
- package/dist/generate-story-UJS37FHA.js.map +1 -0
- package/dist/{generate-test-plan-OGWEIXR2.js → generate-test-plan-RQTSGQLR.js} +3 -3
- package/dist/generate-test-plan-RQTSGQLR.js.map +1 -0
- package/dist/{graph-KZDCVMLT.js → graph-OKUMHR3Q.js} +2 -2
- package/dist/graph-OKUMHR3Q.js.map +1 -0
- package/dist/index.js +39 -120
- package/dist/index.js.map +1 -1
- package/dist/{lint-A5AXYDSO.js → lint-VB5PV32N.js} +3 -3
- package/dist/lint-VB5PV32N.js.map +1 -0
- package/dist/main.js +7 -143
- package/dist/main.js.map +1 -1
- package/dist/{mcp-CWJKX27S.js → mcp-DADOVCEV.js} +3 -3
- package/dist/mcp-DADOVCEV.js.map +1 -0
- package/dist/{migrate-76BXVREF.js → migrate-LAMRDT3V.js} +3 -3
- package/dist/migrate-LAMRDT3V.js.map +1 -0
- package/dist/{pack-I5WFM6B6.js → pack-B3KYRKUR.js} +3 -3
- package/dist/pack-B3KYRKUR.js.map +1 -0
- package/dist/{ready-2M5HXTRZ.js → ready-C6YXJ47W.js} +2 -2
- package/dist/ready-C6YXJ47W.js.map +1 -0
- package/dist/skills/{specdx-author-spec → core/specdx-author-spec}/SKILL.md +4 -0
- package/dist/skills/{specdx-onboard → core/specdx-onboard}/SKILL.md +7 -2
- package/dist/skills/{specdx-plan-from-spec → core/specdx-plan-from-spec}/SKILL.md +4 -0
- package/dist/skills/{specdx-pre-commit → core/specdx-pre-commit}/SKILL.md +4 -0
- package/dist/skills/{specdx-review-spec → core/specdx-review-spec}/SKILL.md +4 -0
- package/dist/skills/core/specdx-router/SKILL.md +67 -0
- package/dist/skills/{specdx-sprint-review → core/specdx-sprint-review}/SKILL.md +4 -0
- package/dist/skills/{specdx-start-task → core/specdx-start-task}/SKILL.md +4 -0
- package/dist/skills/{specdx-check-drift → experimental/specdx-check-drift}/SKILL.md +4 -0
- package/dist/skills/{specdx-verify → experimental/specdx-verify}/SKILL.md +4 -0
- package/dist/{skills-N7ZDWOJM.js → skills-LHFTTEJ7.js} +21 -11
- package/dist/skills-LHFTTEJ7.js.map +1 -0
- package/dist/{status-QLG3ZKS7.js → status-BRLCD7NY.js} +2 -2
- package/dist/status-BRLCD7NY.js.map +1 -0
- package/dist/{update-HGZVLKSL.js → update-P6TQUI6H.js} +3 -3
- package/dist/update-P6TQUI6H.js.map +1 -0
- package/dist/{validate-HMOCZJ2M.js → validate-WIB246IE.js} +2 -2
- package/dist/validate-WIB246IE.js.map +1 -0
- package/package.json +5 -5
- package/dist/check-6ULNLONS.js.map +0 -1
- package/dist/chunk-SDDTD4R3.js.map +0 -1
- package/dist/diff-AWFDXYX4.js.map +0 -1
- package/dist/explain-M2VXXXGP.js +0 -113
- package/dist/explain-M2VXXXGP.js.map +0 -1
- package/dist/generate-XG52JCWH.js +0 -15
- package/dist/generate-XG52JCWH.js.map +0 -1
- package/dist/generate-story-OV3PFJN6.js.map +0 -1
- package/dist/generate-test-plan-OGWEIXR2.js.map +0 -1
- package/dist/graph-KZDCVMLT.js.map +0 -1
- package/dist/lint-A5AXYDSO.js.map +0 -1
- package/dist/mcp-CWJKX27S.js.map +0 -1
- package/dist/migrate-76BXVREF.js.map +0 -1
- package/dist/pack-I5WFM6B6.js.map +0 -1
- package/dist/ready-2M5HXTRZ.js.map +0 -1
- package/dist/skills-N7ZDWOJM.js.map +0 -1
- package/dist/status-QLG3ZKS7.js.map +0 -1
- package/dist/update-HGZVLKSL.js.map +0 -1
- package/dist/validate-HMOCZJ2M.js.map +0 -1
- /package/dist/{dist-2YMKBA6A.js.map → dist-DVROIZAO.js.map} +0 -0
- /package/dist/skills/{specdx-author-spec → core/specdx-author-spec}/references/spec-type-reference.md +0 -0
- /package/dist/skills/{specdx-author-spec → core/specdx-author-spec}/references/step-01-frontmatter.md +0 -0
- /package/dist/skills/{specdx-author-spec → core/specdx-author-spec}/references/step-02-sections.md +0 -0
- /package/dist/skills/{specdx-author-spec → core/specdx-author-spec}/references/step-03-finalize.md +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/experimental/generate-test-plan.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, resolveGlob, createLogger } from \"@specdx/core\";\nimport { writeFile } from \"node:fs/promises\";\nimport { 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: {\n name: \"generate-test-plan\",\n description: \"Generate a test plan stub from user stories\",\n },\n args: {\n from: {\n type: \"string\",\n description: \"Source to generate from (currently only 'stories' is supported)\",\n default: \"stories\",\n },\n out: {\n type: \"string\",\n description: \"Output file path (default: specs/test-plan.md)\",\n },\n },\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,UAAM,cAA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15
|
|
|
16
|
-
// src/commands/graph.ts
|
|
16
|
+
// src/commands/core/graph.ts
|
|
17
17
|
import { defineCommand } from "citty";
|
|
18
18
|
var graph_default = defineCommand({
|
|
19
19
|
meta: { name: "graph", description: "Print the spec dependency graph" },
|
|
@@ -100,4 +100,4 @@ var graph_default = defineCommand({
|
|
|
100
100
|
export {
|
|
101
101
|
graph_default as default
|
|
102
102
|
};
|
|
103
|
-
//# sourceMappingURL=graph-
|
|
103
|
+
//# sourceMappingURL=graph-OKUMHR3Q.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/core/graph.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport {\n loadConfig,\n buildGraph,\n GraphError,\n parseSpec,\n resolveGlob,\n collectReferenceEdges,\n findUnreflectedReferences,\n} from \"@specdx/core\";\nimport type { ParsedSpec } from \"@specdx/core\";\nimport { sharedArgs } from \"../../shared-args.js\";\n\nexport default defineCommand({\n meta: { name: \"graph\", description: \"Print the spec dependency graph\" },\n args: { ...sharedArgs },\n async run({ args }) {\n let config;\n const configDir = process.cwd();\n try {\n config = await loadConfig(undefined, configDir);\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n try {\n const graph = buildGraph(config);\n const sorted = graph.topologicalSort();\n\n // Frontmatter references are a second, richer source of relationships;\n // surface them alongside config requires instead of silently ignoring\n // them (issue #8).\n const idToEntry = new Map<string, string>();\n const specs: ParsedSpec[] = [];\n for (const [key, entry] of Object.entries(config.specs)) {\n const paths = await resolveGlob(entry.path, configDir);\n for (const p of paths) {\n const spec = await parseSpec(p);\n specs.push(spec);\n if (typeof spec.frontmatter.id === \"string\") {\n idToEntry.set(spec.frontmatter.id, key);\n }\n }\n }\n const referenceEdges = collectReferenceEdges(specs);\n const unreflected = findUnreflectedReferences(referenceEdges, idToEntry, graph);\n\n if (args.format === \"dot\") {\n console.log(\"digraph specs {\");\n for (const edge of graph.edges) console.log(` \"${edge.from}\" -> \"${edge.to}\";`);\n for (const ref of referenceEdges) {\n console.log(\n ` \"${ref.fromId}\" -> \"${ref.toId}\" [style=dashed, label=\"${ref.relationship}\"];`,\n );\n }\n console.log(\"}\");\n return;\n }\n\n console.log(\"\\n Spec Dependency Graph:\\n\");\n for (const node of sorted) {\n const downstream = graph.getDownstream(node);\n const arrow = downstream.length > 0 ? ` → ${downstream.join(\", \")}` : \"\";\n console.log(` ${node}${arrow}`);\n }\n\n if (referenceEdges.length > 0) {\n console.log(\"\\n Reference edges (frontmatter):\\n\");\n for (const ref of referenceEdges) {\n console.log(` ${ref.fromId} —${ref.relationship}→ ${ref.toId}`);\n }\n }\n\n const suggestions = unreflected.filter((u) => !u.createsCycle);\n const conflicts = unreflected.filter((u) => u.createsCycle);\n\n if (suggestions.length > 0) {\n console.log(\"\\n ⚠ References not reflected in config requires:\\n\");\n for (const { edge, requiringEntry, requiredEntry } of suggestions) {\n console.log(\n ` ${edge.fromId} ${edge.relationship} ${edge.toId} — add \"requires: [${requiredEntry}]\" to the \"${requiringEntry}\" entry in spec.config.yaml`,\n );\n }\n }\n\n if (conflicts.length > 0) {\n console.log(\"\\n ⚠ References that conflict with the requires chain:\\n\");\n for (const { edge, requiringEntry, requiredEntry } of conflicts) {\n console.log(\n ` ${edge.fromId} ${edge.relationship} ${edge.toId} — implies \"${requiringEntry}\" requires \"${requiredEntry}\", but that would create a cycle; review the reference or the config requires`,\n );\n }\n }\n\n console.log(\"\");\n } catch (err) {\n if (err instanceof GraphError) {\n console.error(` ✗ ${err.message}`);\n process.exit(1);\n }\n throw err;\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAa9B,IAAO,gBAAQ,cAAc;AAAA,EAC3B,MAAM,EAAE,MAAM,SAAS,aAAa,kCAAkC;AAAA,EACtE,MAAM,EAAE,GAAG,WAAW;AAAA,EACtB,MAAM,IAAI,EAAE,KAAK,GAAG;AAClB,QAAI;AACJ,UAAM,YA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AAI,KAAK,IAAI,GAAG,KAAK,EAAE;AAAA,MACjC;AAEA,UAAI,eAAe,SAAS,GAAG;AAC7B,gBAAQ,IAAI,sCAAsC;AAClD,mBAAW,OAAO,gBAAgB;AAChC,kBAAQ,IAAI,KAAK,IAAI,MAAM,UAAK,IAAI,YAAY,UAAK,IAAI,IAAI,EAAE;AAAA,QACjE;AAAA,MACF;AAEA,YAAM,cAAc,YAAY,OAAO,CAAC,MAAM,CAAC,EAAE,YAAY;AAC7D,YAAM,YAAY,YAAY,OAAO,CAAC,MAAM,EAAE,YAAY;AAE1D,UAAI,YAAY,SAAS,GAAG;AAC1B,gBAAQ,IAAI,2DAAsD;AAClE,mBAAW,EAAE,MAAM,gBAAgB,cAAc,KAAK,aAAa;AACjE,kBAAQ;AAAA,YACN,KAAK,KAAK,MAAM,IAAI,KAAK,YAAY,IAAI,KAAK,IAAI,2BAAsB,aAAa,cAAc,cAAc;AAAA,UACnH;AAAA,QACF;AAAA,MACF;AAEA,UAAI,UAAU,SAAS,GAAG;AACxB,gBAAQ,IAAI,gEAA2D;AACvE,mBAAW,EAAE,MAAM,gBAAgB,cAAc,KAAK,WAAW;AAC/D,kBAAQ;AAAA,YACN,KAAK,KAAK,MAAM,IAAI,KAAK,YAAY,IAAI,KAAK,IAAI,oBAAe,cAAc,eAAe,aAAa;AAAA,UAC7G;AAAA,QACF;AAAA,MACF;AAEA,cAAQ,IAAI,EAAE;AAAA,IAChB,SAAS,KAAK;AACZ,UAAI,eAAe,YAAY;AAC7B,gBAAQ,MAAM,YAAO,IAAI,OAAO,EAAE;AAClC,gBAAQ,KAAK,CAAC;AAAA,MAChB;AACA,YAAM;AAAA,IACR;AAAA,EACF;AACF,CAAC;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -1542,7 +1542,7 @@ var require_picomatch2 = __commonJS({
|
|
|
1542
1542
|
}
|
|
1543
1543
|
});
|
|
1544
1544
|
|
|
1545
|
-
// src/commands/init.ts
|
|
1545
|
+
// src/commands/core/init.ts
|
|
1546
1546
|
import { defineCommand } from "citty";
|
|
1547
1547
|
import { mkdir, writeFile } from "fs/promises";
|
|
1548
1548
|
import { join } from "path";
|
|
@@ -1976,7 +1976,7 @@ function validateConfig(data) {
|
|
|
1976
1976
|
return { valid: !!valid, errors: valid ? null : configValidator.errors ?? null };
|
|
1977
1977
|
}
|
|
1978
1978
|
|
|
1979
|
-
// src/commands/init.ts
|
|
1979
|
+
// src/commands/core/init.ts
|
|
1980
1980
|
var TEMPLATE_SPECS = {
|
|
1981
1981
|
lightweight: [
|
|
1982
1982
|
{ filename: "prd.md", type: "prd" },
|
|
@@ -2094,7 +2094,7 @@ var init_default = defineCommand({
|
|
|
2094
2094
|
}
|
|
2095
2095
|
});
|
|
2096
2096
|
|
|
2097
|
-
// src/commands/lint.ts
|
|
2097
|
+
// src/commands/core/lint.ts
|
|
2098
2098
|
import { defineCommand as defineCommand2 } from "citty";
|
|
2099
2099
|
|
|
2100
2100
|
// ../core/dist/config.js
|
|
@@ -3059,7 +3059,7 @@ function formatGithub(diagnostics) {
|
|
|
3059
3059
|
}).join("\n");
|
|
3060
3060
|
}
|
|
3061
3061
|
|
|
3062
|
-
// src/commands/lint.ts
|
|
3062
|
+
// src/commands/core/lint.ts
|
|
3063
3063
|
async function runLint(options) {
|
|
3064
3064
|
const config = await loadConfig(void 0, options.configDir);
|
|
3065
3065
|
const preset = options.preset ?? config.lint?.extends ?? "recommended";
|
|
@@ -3134,7 +3134,7 @@ var lint_default = defineCommand2({
|
|
|
3134
3134
|
}
|
|
3135
3135
|
});
|
|
3136
3136
|
|
|
3137
|
-
// src/commands/pack.ts
|
|
3137
|
+
// src/commands/core/pack.ts
|
|
3138
3138
|
import { defineCommand as defineCommand3 } from "citty";
|
|
3139
3139
|
|
|
3140
3140
|
// ../pack/dist/resolver.js
|
|
@@ -3495,12 +3495,18 @@ function allocate(specs, scores, options) {
|
|
|
3495
3495
|
for (const spec of specs) {
|
|
3496
3496
|
specMap.set(spec.frontmatter.id, spec);
|
|
3497
3497
|
}
|
|
3498
|
+
function tokensOf(compressed) {
|
|
3499
|
+
if (compressed.collapsed)
|
|
3500
|
+
return countTokens(compressed.collapsedSummary ?? "");
|
|
3501
|
+
return compressed.sections.reduce((sum, section) => sum + section.tokens, 0);
|
|
3502
|
+
}
|
|
3498
3503
|
const items = [];
|
|
3499
3504
|
for (const score of scores) {
|
|
3500
3505
|
const spec = specMap.get(score.specId);
|
|
3501
3506
|
if (!spec)
|
|
3502
3507
|
continue;
|
|
3503
3508
|
let compressed;
|
|
3509
|
+
let stale;
|
|
3504
3510
|
if (options.full) {
|
|
3505
3511
|
compressed = {
|
|
3506
3512
|
specId: score.specId,
|
|
@@ -3516,20 +3522,34 @@ function allocate(specs, scores, options) {
|
|
|
3516
3522
|
collapsed: false
|
|
3517
3523
|
};
|
|
3518
3524
|
} else {
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
tokens += section.tokens;
|
|
3525
|
+
const compress = (compression) => compressSpec(score.specId, String(spec.frontmatter.type), String(spec.frontmatter.title), spec.frontmatter.status, spec.frontmatter.updated, spec.parsedSections, compression);
|
|
3526
|
+
compressed = compress({ ...options.compression, stableDays: 0 });
|
|
3527
|
+
if (options.compression.stableDays > 0) {
|
|
3528
|
+
const collapsed = compress(options.compression);
|
|
3529
|
+
const collapsedTokens = tokensOf(collapsed);
|
|
3530
|
+
if (collapsedTokens < tokensOf(compressed)) {
|
|
3531
|
+
stale = { spec: collapsed, tokens: collapsedTokens };
|
|
3532
|
+
}
|
|
3528
3533
|
}
|
|
3529
3534
|
}
|
|
3530
|
-
items.push({
|
|
3535
|
+
items.push({
|
|
3536
|
+
compressed,
|
|
3537
|
+
relevance: score.score,
|
|
3538
|
+
tokens: tokensOf(compressed),
|
|
3539
|
+
idMatched: score.idMatched ?? false,
|
|
3540
|
+
stale
|
|
3541
|
+
});
|
|
3531
3542
|
}
|
|
3532
3543
|
items.sort((a, b) => b.relevance - a.relevance || Number(b.idMatched) - Number(a.idMatched));
|
|
3544
|
+
let projected = items.reduce((sum, item) => sum + item.tokens, 0);
|
|
3545
|
+
for (let i = items.length - 1; i >= 0 && projected > options.budget; i--) {
|
|
3546
|
+
const item = items[i];
|
|
3547
|
+
if (!item.stale)
|
|
3548
|
+
continue;
|
|
3549
|
+
projected -= item.tokens - item.stale.tokens;
|
|
3550
|
+
item.compressed = item.stale.spec;
|
|
3551
|
+
item.tokens = item.stale.tokens;
|
|
3552
|
+
}
|
|
3533
3553
|
const totalTokens = items.reduce((sum, item) => sum + item.tokens, 0);
|
|
3534
3554
|
const withinBudget = totalTokens <= options.budget;
|
|
3535
3555
|
const included = [];
|
|
@@ -3796,7 +3816,7 @@ function pack(specs, options, packConfig, graph) {
|
|
|
3796
3816
|
return { output, stats };
|
|
3797
3817
|
}
|
|
3798
3818
|
|
|
3799
|
-
// src/commands/pack.ts
|
|
3819
|
+
// src/commands/core/pack.ts
|
|
3800
3820
|
import { writeFile as writeFile2 } from "fs/promises";
|
|
3801
3821
|
import { execSync } from "child_process";
|
|
3802
3822
|
function copyToClipboard(text) {
|
|
@@ -3966,7 +3986,7 @@ var pack_default = defineCommand3({
|
|
|
3966
3986
|
}
|
|
3967
3987
|
});
|
|
3968
3988
|
|
|
3969
|
-
// src/commands/diff.ts
|
|
3989
|
+
// src/commands/core/diff.ts
|
|
3970
3990
|
import { defineCommand as defineCommand4 } from "citty";
|
|
3971
3991
|
import { join as join5 } from "path";
|
|
3972
3992
|
|
|
@@ -5324,7 +5344,7 @@ function formatChangelog(result, baseRef, headRef) {
|
|
|
5324
5344
|
return lines.join("\n");
|
|
5325
5345
|
}
|
|
5326
5346
|
|
|
5327
|
-
// src/commands/diff.ts
|
|
5347
|
+
// src/commands/core/diff.ts
|
|
5328
5348
|
async function runDiff(options) {
|
|
5329
5349
|
const configDir = process.cwd();
|
|
5330
5350
|
const config = await loadConfig(void 0, configDir);
|
|
@@ -5444,7 +5464,7 @@ var diff_default = defineCommand4({
|
|
|
5444
5464
|
}
|
|
5445
5465
|
});
|
|
5446
5466
|
|
|
5447
|
-
// src/commands/status.ts
|
|
5467
|
+
// src/commands/core/status.ts
|
|
5448
5468
|
import { defineCommand as defineCommand5 } from "citty";
|
|
5449
5469
|
async function runStatus(_options = {}) {
|
|
5450
5470
|
const configDir = process.cwd();
|
|
@@ -5584,109 +5604,8 @@ var status_default = defineCommand5({
|
|
|
5584
5604
|
}
|
|
5585
5605
|
}
|
|
5586
5606
|
});
|
|
5587
|
-
|
|
5588
|
-
// src/commands/explain.ts
|
|
5589
|
-
import { defineCommand as defineCommand6 } from "citty";
|
|
5590
|
-
async function runExplain(_options = {}) {
|
|
5591
|
-
const configDir = process.cwd();
|
|
5592
|
-
const config = await loadConfig(void 0, configDir);
|
|
5593
|
-
const specs = [];
|
|
5594
|
-
for (const [, entry] of Object.entries(config.specs)) {
|
|
5595
|
-
const paths = await resolveGlob(entry.path, configDir);
|
|
5596
|
-
for (const p of paths) {
|
|
5597
|
-
specs.push(await parseSpec(p));
|
|
5598
|
-
}
|
|
5599
|
-
}
|
|
5600
|
-
const byType = {};
|
|
5601
|
-
const byStatus = {};
|
|
5602
|
-
for (const spec of specs) {
|
|
5603
|
-
const type = spec.frontmatter.type || "unknown";
|
|
5604
|
-
const status = spec.frontmatter.status || "unknown";
|
|
5605
|
-
byType[type] = (byType[type] ?? 0) + 1;
|
|
5606
|
-
byStatus[status] = (byStatus[status] ?? 0) + 1;
|
|
5607
|
-
}
|
|
5608
|
-
const specSummaries = specs.map((spec) => {
|
|
5609
|
-
const firstSection = spec.parsedSections[0];
|
|
5610
|
-
const firstLine = firstSection?.content?.split("\n").find((l) => l.trim().length > 0)?.trim() ?? "";
|
|
5611
|
-
const truncated = firstLine.slice(0, 120) + (firstLine.length > 120 ? "..." : "");
|
|
5612
|
-
return {
|
|
5613
|
-
id: spec.frontmatter.id,
|
|
5614
|
-
type: spec.frontmatter.type,
|
|
5615
|
-
title: spec.frontmatter.title,
|
|
5616
|
-
status: spec.frontmatter.status,
|
|
5617
|
-
firstLine: truncated
|
|
5618
|
-
};
|
|
5619
|
-
});
|
|
5620
|
-
const graph = buildGraph(config);
|
|
5621
|
-
const graphLines = [];
|
|
5622
|
-
for (const node of graph.nodes) {
|
|
5623
|
-
const downstream = graph.edges.filter((e) => e.from === node).map((e) => e.to);
|
|
5624
|
-
if (downstream.length > 0) {
|
|
5625
|
-
graphLines.push(`${node} \u2192 ${downstream.join(", ")}`);
|
|
5626
|
-
} else {
|
|
5627
|
-
graphLines.push(node);
|
|
5628
|
-
}
|
|
5629
|
-
}
|
|
5630
|
-
return {
|
|
5631
|
-
project: config.project?.name ?? "unknown",
|
|
5632
|
-
description: config.project?.description,
|
|
5633
|
-
specCount: specs.length,
|
|
5634
|
-
byType,
|
|
5635
|
-
byStatus,
|
|
5636
|
-
specs: specSummaries,
|
|
5637
|
-
graph: graphLines
|
|
5638
|
-
};
|
|
5639
|
-
}
|
|
5640
|
-
var explain_default = defineCommand6({
|
|
5641
|
-
meta: {
|
|
5642
|
-
name: "explain",
|
|
5643
|
-
description: "[experimental] Explain the spec suite for onboarding"
|
|
5644
|
-
},
|
|
5645
|
-
args: {
|
|
5646
|
-
format: { type: "string", description: "Output format: pretty, json", default: "pretty" }
|
|
5647
|
-
},
|
|
5648
|
-
async run({ args }) {
|
|
5649
|
-
try {
|
|
5650
|
-
const result = await runExplain({ format: args.format });
|
|
5651
|
-
if (args.format === "json") {
|
|
5652
|
-
console.log(JSON.stringify(result, null, 2));
|
|
5653
|
-
return;
|
|
5654
|
-
}
|
|
5655
|
-
console.log(`
|
|
5656
|
-
${result.project}`);
|
|
5657
|
-
if (result.description) {
|
|
5658
|
-
console.log(` ${result.description}`);
|
|
5659
|
-
}
|
|
5660
|
-
console.log(
|
|
5661
|
-
`
|
|
5662
|
-
${result.specCount} specs: ${Object.entries(result.byType).map(([k, v]) => `${v} ${k}`).join(", ")}`
|
|
5663
|
-
);
|
|
5664
|
-
console.log(
|
|
5665
|
-
` Status: ${Object.entries(result.byStatus).map(([k, v]) => `${v} ${k}`).join(", ")}`
|
|
5666
|
-
);
|
|
5667
|
-
console.log("\n Specs:");
|
|
5668
|
-
for (const spec of result.specs) {
|
|
5669
|
-
console.log(` ${spec.id} (${spec.type}, ${spec.status}) \u2014 ${spec.title}`);
|
|
5670
|
-
if (spec.firstLine) {
|
|
5671
|
-
console.log(` ${spec.firstLine}`);
|
|
5672
|
-
}
|
|
5673
|
-
}
|
|
5674
|
-
console.log("\n Dependencies:");
|
|
5675
|
-
for (const line of result.graph) {
|
|
5676
|
-
console.log(` ${line}`);
|
|
5677
|
-
}
|
|
5678
|
-
console.log();
|
|
5679
|
-
} catch (err) {
|
|
5680
|
-
console.error(`
|
|
5681
|
-
\u2717 ${err.message}
|
|
5682
|
-
`);
|
|
5683
|
-
process.exit(1);
|
|
5684
|
-
}
|
|
5685
|
-
}
|
|
5686
|
-
});
|
|
5687
5607
|
export {
|
|
5688
5608
|
runDiff,
|
|
5689
|
-
runExplain,
|
|
5690
5609
|
runLint,
|
|
5691
5610
|
runPack,
|
|
5692
5611
|
runStatus,
|