specdx 0.4.0-alpha.18 → 0.4.0-alpha.19

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.
Files changed (71) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +42 -0
  3. package/dist/{check-PQQGR4KP.js → check-PRQNMBOE.js} +5 -5
  4. package/dist/{chunk-RI2SFGMR.js → chunk-5MYELBKF.js} +44 -17
  5. package/dist/chunk-5MYELBKF.js.map +1 -0
  6. package/dist/{chunk-FX4NRQHE.js → chunk-BD6UDHYW.js} +58 -10
  7. package/dist/chunk-BD6UDHYW.js.map +1 -0
  8. package/dist/{chunk-33FELECG.js → chunk-ERRUYMZO.js} +21 -18
  9. package/dist/chunk-ERRUYMZO.js.map +1 -0
  10. package/dist/{chunk-Z77VQUZ3.js → chunk-MM325DR6.js} +2 -2
  11. package/dist/chunk-RDNEANZB.js +103 -0
  12. package/dist/chunk-RDNEANZB.js.map +1 -0
  13. package/dist/{chunk-AXCGMUU7.js → chunk-RY5CDUNN.js} +2 -2
  14. package/dist/{chunk-TF7WSPFV.js → chunk-T232GZ2L.js} +2 -2
  15. package/dist/{chunk-SJCIM4TC.js → chunk-ZIPGRLYE.js} +3 -1
  16. package/dist/chunk-ZIPGRLYE.js.map +1 -0
  17. package/dist/{diff-IOBAJMKU.js → diff-PHEX3HUT.js} +4 -4
  18. package/dist/{dist-HRY2V5MO.js → dist-M7X5RJB3.js} +12 -10
  19. package/dist/dist-M7X5RJB3.js.map +1 -0
  20. package/dist/{dist-WXT4UJ55.js → dist-X4CSVKKR.js} +2 -2
  21. package/dist/{generate-NSTYQOAV.js → generate-FIMBI2NW.js} +5 -5
  22. package/dist/{generate-story-RFAPULQY.js → generate-story-5TPTJA7B.js} +13 -15
  23. package/dist/generate-story-5TPTJA7B.js.map +1 -0
  24. package/dist/{generate-test-plan-M22PCW73.js → generate-test-plan-XBAFJKJI.js} +51 -12
  25. package/dist/generate-test-plan-XBAFJKJI.js.map +1 -0
  26. package/dist/{graph-OKUMHR3Q.js → graph-UZJMLX4J.js} +3 -3
  27. package/dist/index.d.ts +171 -0
  28. package/dist/index.js +72 -22
  29. package/dist/index.js.map +1 -1
  30. package/dist/{lint-ADR7L6AP.js → lint-PUAQ2UL6.js} +4 -4
  31. package/dist/main.js +5 -103
  32. package/dist/main.js.map +1 -1
  33. package/dist/{mcp-A6CCWSS2.js → mcp-WTO5PDIS.js} +6 -3
  34. package/dist/mcp-WTO5PDIS.js.map +1 -0
  35. package/dist/{migrate-LAMRDT3V.js → migrate-DEFCNOAH.js} +18 -7
  36. package/dist/migrate-DEFCNOAH.js.map +1 -0
  37. package/dist/{pack-B3KYRKUR.js → pack-PNLD5AYW.js} +4 -4
  38. package/dist/{ready-GH4YKVOX.js → ready-XIO2IPRE.js} +5 -5
  39. package/dist/skills/core/specdx-author-spec/SKILL.md +1 -1
  40. package/dist/skills/core/specdx-author-spec/references/step-02-sections.md +41 -0
  41. package/dist/skills/core/specdx-router/SKILL.md +2 -2
  42. package/dist/skills/experimental/specdx-check-drift/SKILL.md +1 -1
  43. package/dist/skills/experimental/specdx-verify/SKILL.md +1 -1
  44. package/dist/{status-PQKPTDP5.js → status-BXOYBOH6.js} +5 -5
  45. package/dist/{update-VAC6XV5E.js → update-ELXABLVS.js} +4 -4
  46. package/dist/{validate-WIB246IE.js → validate-FXD5WS4C.js} +3 -3
  47. package/hooks/session-start +35 -3
  48. package/package.json +5 -5
  49. package/dist/chunk-33FELECG.js.map +0 -1
  50. package/dist/chunk-FX4NRQHE.js.map +0 -1
  51. package/dist/chunk-RI2SFGMR.js.map +0 -1
  52. package/dist/chunk-SJCIM4TC.js.map +0 -1
  53. package/dist/dist-HRY2V5MO.js.map +0 -1
  54. package/dist/generate-story-RFAPULQY.js.map +0 -1
  55. package/dist/generate-test-plan-M22PCW73.js.map +0 -1
  56. package/dist/mcp-A6CCWSS2.js.map +0 -1
  57. package/dist/migrate-LAMRDT3V.js.map +0 -1
  58. /package/dist/{check-PQQGR4KP.js.map → check-PRQNMBOE.js.map} +0 -0
  59. /package/dist/{chunk-Z77VQUZ3.js.map → chunk-MM325DR6.js.map} +0 -0
  60. /package/dist/{chunk-AXCGMUU7.js.map → chunk-RY5CDUNN.js.map} +0 -0
  61. /package/dist/{chunk-TF7WSPFV.js.map → chunk-T232GZ2L.js.map} +0 -0
  62. /package/dist/{diff-IOBAJMKU.js.map → diff-PHEX3HUT.js.map} +0 -0
  63. /package/dist/{dist-WXT4UJ55.js.map → dist-X4CSVKKR.js.map} +0 -0
  64. /package/dist/{generate-NSTYQOAV.js.map → generate-FIMBI2NW.js.map} +0 -0
  65. /package/dist/{graph-OKUMHR3Q.js.map → graph-UZJMLX4J.js.map} +0 -0
  66. /package/dist/{lint-ADR7L6AP.js.map → lint-PUAQ2UL6.js.map} +0 -0
  67. /package/dist/{pack-B3KYRKUR.js.map → pack-PNLD5AYW.js.map} +0 -0
  68. /package/dist/{ready-GH4YKVOX.js.map → ready-XIO2IPRE.js.map} +0 -0
  69. /package/dist/{status-PQKPTDP5.js.map → status-BXOYBOH6.js.map} +0 -0
  70. /package/dist/{update-VAC6XV5E.js.map → update-ELXABLVS.js.map} +0 -0
  71. /package/dist/{validate-WIB246IE.js.map → validate-FXD5WS4C.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../mcp/src/server.ts","../../mcp/src/tools/validate.ts","../../mcp/src/tools/lint.ts","../../mcp/src/tools/pack.ts","../../mcp/src/tools/status.ts","../../mcp/src/tools/check.ts","../../mcp/src/tools/diff.ts","../../mcp/src/tools/graph.ts"],"sourcesContent":["import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport { handleValidate } from \"./tools/validate.js\";\nimport { handleLint } from \"./tools/lint.js\";\nimport { handlePack } from \"./tools/pack.js\";\nimport { handleStatus } from \"./tools/status.js\";\nimport { handleCheck } from \"./tools/check.js\";\nimport { handleDiff } from \"./tools/diff.js\";\nimport { handleGraph } from \"./tools/graph.js\";\n\n/**\n * Build the MCP server.\n *\n * `version` is passed in rather than hardcoded: a literal here advertised\n * `0.4.0` from every prerelease build, so every MCP client logged a version\n * that was never published. The CLI owns the real number and hands it over.\n */\nexport function createMcpServer(version = \"0.0.0-unknown\"): McpServer {\n const server = new McpServer({\n name: \"specdx\",\n version,\n });\n\n server.tool(\n \"sdx_validate\",\n \"Validate the spec.config.yaml configuration file\",\n { configPath: z.string().optional().describe(\"Path to config directory\") },\n async (params) => ({\n content: [{ type: \"text\" as const, text: await handleValidate(params) }],\n }),\n );\n\n server.tool(\n \"sdx_lint\",\n \"Run lint rules against the spec suite\",\n {\n preset: z.string().optional().describe(\"Lint preset: minimal, recommended, strict\"),\n specPath: z.string().optional().describe(\"Lint a specific spec file\"),\n },\n async (params) => ({\n content: [{ type: \"text\" as const, text: await handleLint(params) }],\n }),\n );\n\n server.tool(\n \"sdx_pack\",\n \"Pack spec context for LLM consumption within a token budget\",\n {\n task: z.string().optional().describe(\"Task description for relevance scoring\"),\n format: z.string().optional().describe(\"Output format: xml, markdown, json\"),\n budget: z.number().optional().describe(\"Token budget (default: 12000)\"),\n },\n async (params) => ({\n content: [{ type: \"text\" as const, text: await handlePack(params) }],\n }),\n );\n\n server.tool(\n \"sdx_status\",\n \"Get spec suite health overview (lint health, staleness, integrity)\",\n {},\n async () => ({\n content: [{ type: \"text\" as const, text: await handleStatus() }],\n }),\n );\n\n server.tool(\n \"sdx_check\",\n \"Run spec-to-implementation drift analysis\",\n {\n framework: z.string().optional().describe(\"Framework: express, hono, nextjs\"),\n specId: z.string().optional().describe(\"Check a specific spec by ID\"),\n },\n async (params) => ({\n content: [{ type: \"text\" as const, text: await handleCheck(params) }],\n }),\n );\n\n server.tool(\n \"sdx_diff\",\n \"Show spec changes and downstream impact between git refs\",\n {\n base: z.string().optional().describe(\"Base git ref (default: main)\"),\n head: z.string().optional().describe(\"Head git ref (default: HEAD)\"),\n working: z\n .boolean()\n .optional()\n .describe(\n \"Compare the base ref against the working tree, including uncommitted and untracked specs (default: false)\",\n ),\n },\n async (params) => ({\n content: [{ type: \"text\" as const, text: await handleDiff(params) }],\n }),\n );\n\n server.tool(\n \"sdx_graph\",\n \"Get the spec dependency graph\",\n {\n format: z.string().optional().describe(\"Output format: json (default) or dot\"),\n },\n async (params) => ({\n content: [{ type: \"text\" as const, text: await handleGraph(params) }],\n }),\n );\n\n return server;\n}\n","import { loadConfig, buildGraph, resolveGlob, ConfigError, GraphError } from \"@specdx/core\";\n\nexport async function handleValidate(params: { configPath?: string }): Promise<string> {\n try {\n const configDir = params.configPath ?? process.cwd();\n const config = await loadConfig(undefined, configDir);\n // A cyclic or dangling requires chain is an invalid config (issue #13).\n buildGraph(config);\n // `specEntries` and `specFiles` are distinct: one glob entry can resolve to\n // many files. Reporting either as a bare `specCount` put this tool and\n // sdx_status in direct contradiction for the same project.\n let specFiles = 0;\n for (const entry of Object.values(config.specs)) {\n specFiles += (await resolveGlob(entry.path, configDir)).length;\n }\n\n return JSON.stringify({\n valid: true,\n specEntries: Object.keys(config.specs).length,\n specFiles,\n project: config.project?.name ?? \"unknown\",\n });\n } catch (err) {\n if (err instanceof ConfigError) {\n return JSON.stringify({ valid: false, error: err.message, details: err.errors });\n }\n if (err instanceof GraphError) {\n return JSON.stringify({ valid: false, error: err.message });\n }\n throw err;\n }\n}\n","import { loadConfig, parseSpec, resolveGlob, buildGraph } from \"@specdx/core\";\nimport { createLintEngine, getPreset } from \"@specdx/lint\";\nimport type { ParsedSpec } from \"@specdx/core\";\n\nexport async function handleLint(params: { preset?: string; specPath?: string }): Promise<string> {\n const configDir = process.cwd();\n const config = await loadConfig(undefined, configDir);\n const preset = params.preset ?? config.lint?.extends ?? \"recommended\";\n const rules = getPreset(preset);\n\n const specs: ParsedSpec[] = [];\n for (const [, entry] of Object.entries(config.specs)) {\n const files = await resolveGlob(entry.path, configDir);\n for (const file of files) {\n if (params.specPath && !file.includes(params.specPath)) continue;\n specs.push(await parseSpec(file));\n }\n }\n\n let graph;\n try {\n graph = buildGraph(config);\n } catch {\n // non-fatal\n }\n\n const engine = createLintEngine({ rules, config, graph });\n const results = engine.lint(specs);\n\n return JSON.stringify({\n diagnostics: results.diagnostics,\n hasErrors: results.hasErrors,\n hasWarnings: results.hasWarnings,\n specsChecked: specs.length,\n });\n}\n","import { loadConfig, parseSpec, resolveGlob, buildGraph } from \"@specdx/core\";\nimport { pack } from \"@specdx/pack\";\nimport type { ParsedSpec } from \"@specdx/core\";\n\nexport async function handlePack(params: {\n task?: string;\n format?: string;\n budget?: number;\n}): Promise<string> {\n const configDir = process.cwd();\n const config = await loadConfig(undefined, configDir);\n\n const allSpecs: ParsedSpec[] = [];\n for (const [, entry] of Object.entries(config.specs)) {\n const files = await resolveGlob(entry.path, configDir);\n for (const file of files) {\n allSpecs.push(await parseSpec(file));\n }\n }\n\n let graph;\n try {\n graph = buildGraph(config);\n } catch {\n // non-fatal\n }\n\n const result = pack(\n allSpecs,\n {\n task: params.task,\n budget: params.budget,\n format: (params.format as \"xml\" | \"markdown\" | \"json\") ?? undefined,\n },\n config.pack,\n graph,\n );\n\n return result.output;\n}\n","import { loadConfig, parseSpec, resolveGlob, buildGraph } from \"@specdx/core\";\nimport { createLintEngine, getPreset } from \"@specdx/lint\";\nimport { DEFAULT_DIFF_CONFIG } from \"@specdx/diff\";\nimport type { ParsedSpec } from \"@specdx/core\";\n\nexport async function handleStatus(): Promise<string> {\n const configDir = process.cwd();\n const config = await loadConfig(undefined, configDir);\n\n const specs: { spec: ParsedSpec; entry: { path: string; owner?: string } }[] = [];\n for (const [, 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, entry: entry as { path: string; owner?: string } });\n }\n }\n\n const byStatus: Record<string, number> = {};\n for (const { spec } of specs) {\n const status = (spec.frontmatter.status as string) || \"unknown\";\n byStatus[status] = (byStatus[status] ?? 0) + 1;\n }\n\n const presetName = config.lint?.extends ?? \"recommended\";\n const rules = getPreset(presetName);\n\n let graph;\n let graphError: string | undefined;\n try {\n graph = buildGraph(config);\n } catch (err) {\n graphError = (err as Error).message;\n }\n\n const engine = createLintEngine({ rules, config, graph });\n const lintResults = engine.lint(specs.map((s) => s.spec));\n\n const errors = lintResults.diagnostics.filter((d) => d.severity === \"error\").length;\n const warnings = lintResults.diagnostics.filter((d) => d.severity === \"warn\").length;\n\n const thresholdDays =\n config.diff?.staleness_threshold_days ?? DEFAULT_DIFF_CONFIG.staleness_threshold_days;\n const now = Date.now();\n const staleSpecs: { specId: string; daysSinceUpdate: number; owner?: string }[] = [];\n for (const { spec, entry } of specs) {\n const dateStr =\n (spec.frontmatter.updated as string | undefined) ||\n (spec.frontmatter.created as string | undefined);\n if (dateStr) {\n const days = Math.floor((now - new Date(dateStr).getTime()) / (1000 * 60 * 60 * 24));\n if (days > thresholdDays) {\n staleSpecs.push({\n specId: spec.frontmatter.id as string,\n daysSinceUpdate: days,\n owner: entry.owner,\n });\n }\n }\n }\n\n // An empty suite is unassessed, never a vacuous \"healthy\" (vacuous-pass audit)\n let verdict: \"healthy\" | \"warnings\" | \"errors\" | \"unassessed\" = \"healthy\";\n if (errors > 0 || graphError) verdict = \"errors\";\n else if (warnings > 0 || staleSpecs.length > 0) verdict = \"warnings\";\n else if (specs.length === 0) verdict = \"unassessed\";\n\n return JSON.stringify({\n project: config.project?.name ?? \"unknown\",\n // `specFiles` only. A second field named `specCount` gives a consumer no\n // way to know whether it counts config entries or resolved files -- the\n // ambiguity `sdx_validate` was already cleaned up to avoid.\n specFiles: specs.length,\n byStatus,\n lintHealth: { errors, warnings, passing: specs.length - errors },\n staleSpecs,\n integrityIssues: graphError ? [graphError] : [],\n verdict,\n });\n}\n","import { loadConfig, parseSpec, resolveGlob } from \"@specdx/core\";\nimport { runCheck } from \"@specdx/check\";\nimport type { ParsedSpec } from \"@specdx/core\";\n\nexport async function handleCheck(params: {\n framework?: string;\n specId?: string;\n}): Promise<string> {\n const configDir = process.cwd();\n const config = await loadConfig(undefined, configDir);\n\n const specs: ParsedSpec[] = [];\n for (const [, 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 if (params.specId && spec.frontmatter.id !== params.specId) continue;\n specs.push(spec);\n }\n }\n\n const checkConfig = {\n ...config.check,\n ...(params.framework ? { framework: params.framework as \"express\" | \"hono\" | \"nextjs\" } : {}),\n };\n\n const result = await runCheck(specs, configDir, checkConfig);\n return JSON.stringify(result);\n}\n","import { join } from \"node:path\";\nimport { loadConfig } from \"@specdx/core\";\nimport { diffBetweenRefs, DEFAULT_DIFF_CONFIG, DiffError } from \"@specdx/diff\";\n\nexport async function handleDiff(params: {\n base?: string;\n head?: string;\n working?: boolean;\n}): Promise<string> {\n const configDir = process.cwd();\n const config = await loadConfig(undefined, configDir);\n const baseRef = params.base ?? config.diff?.baseline_ref ?? DEFAULT_DIFF_CONFIG.baseline_ref;\n const headRef = params.head ?? \"HEAD\";\n const configPath = join(configDir, \"spec.config.yaml\");\n\n try {\n const result = await diffBetweenRefs(configPath, baseRef, headRef, {\n working: params.working ?? false,\n });\n return JSON.stringify(result);\n } catch (err) {\n if (err instanceof DiffError) {\n return JSON.stringify({ error: err.message });\n }\n throw err;\n }\n}\n","import {\n loadConfig,\n buildGraph,\n GraphError,\n parseSpec,\n resolveGlob,\n collectReferenceEdges,\n findUnreflectedReferences,\n} from \"@specdx/core\";\nimport type { ParsedSpec } from \"@specdx/core\";\n\nexport async function handleGraph(params: { format?: string }): Promise<string> {\n const configDir = process.cwd();\n const config = await loadConfig(undefined, configDir);\n\n try {\n const graph = buildGraph(config);\n const sorted = graph.topologicalSort();\n\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 unreflectedReferences = findUnreflectedReferences(referenceEdges, idToEntry, graph);\n\n if (params.format === \"dot\") {\n const lines = [\"digraph specs {\"];\n for (const edge of graph.edges) lines.push(` \"${edge.from}\" -> \"${edge.to}\";`);\n for (const ref of referenceEdges) {\n lines.push(\n ` \"${ref.fromId}\" -> \"${ref.toId}\" [style=dashed, label=\"${ref.relationship}\"];`,\n );\n }\n lines.push(\"}\");\n return lines.join(\"\\n\");\n }\n\n return JSON.stringify({\n nodes: sorted,\n edges: graph.edges,\n downstream: Object.fromEntries(sorted.map((n) => [n, graph.getDownstream(n)])),\n referenceEdges,\n unreflectedReferences,\n });\n } catch (err) {\n if (err instanceof GraphError) {\n return JSON.stringify({ error: err.message });\n }\n throw err;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,SAAS;;;ACClB,eAAsB,eAAe,QAA+B;AAClE,MAAI;AACF,UAAM,YAAY,OAAO,cAAc,QAAQ,IAAG;AAClD,UAAM,SAAS,MAAM,WAAW,QAAW,SAAS;AAEpD,eAAW,MAAM;AAIjB,QAAI,YAAY;AAChB,eAAW,SAAS,OAAO,OAAO,OAAO,KAAK,GAAG;AAC/C,oBAAc,MAAM,YAAY,MAAM,MAAM,SAAS,GAAG;IAC1D;AAEA,WAAO,KAAK,UAAU;MACpB,OAAO;MACP,aAAa,OAAO,KAAK,OAAO,KAAK,EAAE;MACvC;MACA,SAAS,OAAO,SAAS,QAAQ;KAClC;EACH,SAAS,KAAK;AACZ,QAAI,eAAe,aAAa;AAC9B,aAAO,KAAK,UAAU,EAAE,OAAO,OAAO,OAAO,IAAI,SAAS,SAAS,IAAI,OAAM,CAAE;IACjF;AACA,QAAI,eAAe,YAAY;AAC7B,aAAO,KAAK,UAAU,EAAE,OAAO,OAAO,OAAO,IAAI,Q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W,MAAM,EAAC,CAAE;IACnE;AAGJ,SAAO,KACL,cACA,sEACA,CAAA,GACA,aAAa;IACX,SAAS,CAAC,EAAE,MAAM,QAAiB,MAAM,MAAM,aAAY,EAAE,CAAE;IAC/D;AAGJ,SAAO,KACL,aACA,6CACA;IACE,WAAW,EAAE,OAAM,EAAG,SAAQ,EAAG,SAAS,kCAAkC;IAC5E,QAAQ,EAAE,OAAM,EAAG,SAAQ,EAAG,SAAS,6BAA6B;KAEtE,OAAO,YAAY;IACjB,SAAS,CAAC,EAAE,MAAM,QAAiB,MAAM,MAAM,YAAY,MAAM,EAAC,CAAE;IACpE;AAGJ,SAAO,KACL,YACA,4DACA;IACE,MAAM,EAAE,OAAM,EAAG,SAAQ,EAAG,SAAS,8BAA8B;IACnE,MAAM,EAAE,OAAM,EAAG,SAAQ,EAAG,SAAS,8BAA8B;IACnE,SAAS,EACN,QAAO,EACP,SAAQ,EACR,SACC,2GAA2G;KAGjH,OAAO,YAAY;IACjB,SAAS,CAAC,EAAE,MAAM,QAAiB,MAAM,MAAM,WAAW,MAAM,EAAC,CAAE;IACnE;AAGJ,SAAO,KACL,aACA,iCACA;IACE,QAAQ,EAAE,OAAM,EAAG,SAAQ,EAAG,SAAS,sCAAsC;KAE/E,OAAO,YAAY;IACjB,SAAS,CAAC,EAAE,MAAM,QAAiB,MAAM,MAAM,YAAY,MAAM,EAAC,CAAE;IACpE;AAGJ,SAAO;AACT;","names":[]}
@@ -4,7 +4,7 @@ import {
4
4
  detectFramework,
5
5
  parseArtifacts,
6
6
  runCheck
7
- } from "./chunk-RI2SFGMR.js";
7
+ } from "./chunk-5MYELBKF.js";
8
8
  import "./chunk-5WRI5ZAA.js";
9
9
  export {
10
10
  analyzeWithAi,
@@ -13,4 +13,4 @@ export {
13
13
  parseArtifacts,
14
14
  runCheck
15
15
  };
16
- //# sourceMappingURL=dist-WXT4UJ55.js.map
16
+ //# sourceMappingURL=dist-X4CSVKKR.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  labelled
3
- } from "./chunk-33FELECG.js";
4
- import "./chunk-SJCIM4TC.js";
3
+ } from "./chunk-ERRUYMZO.js";
4
+ import "./chunk-ZIPGRLYE.js";
5
5
  import "./chunk-5WRI5ZAA.js";
6
6
 
7
7
  // src/commands/core/generate.ts
@@ -9,8 +9,8 @@ import { defineCommand } from "citty";
9
9
  var generate_default = defineCommand({
10
10
  meta: { name: "generate", description: "Generate spec stubs from existing specs" },
11
11
  subCommands: {
12
- story: () => import("./generate-story-RFAPULQY.js").then((m) => labelled("generate story", m.default)),
13
- "test-plan": () => import("./generate-test-plan-M22PCW73.js").then(
12
+ story: () => import("./generate-story-5TPTJA7B.js").then((m) => labelled("generate story", m.default)),
13
+ "test-plan": () => import("./generate-test-plan-XBAFJKJI.js").then(
14
14
  (m) => labelled("generate test-plan", m.default)
15
15
  )
16
16
  }
@@ -18,4 +18,4 @@ var generate_default = defineCommand({
18
18
  export {
19
19
  generate_default as default
20
20
  };
21
- //# sourceMappingURL=generate-NSTYQOAV.js.map
21
+ //# sourceMappingURL=generate-FIMBI2NW.js.map
@@ -1,15 +1,16 @@
1
1
  import {
2
+ parseFeatureEntries,
2
3
  uncoveredFeatures
3
- } from "./chunk-FX4NRQHE.js";
4
+ } from "./chunk-BD6UDHYW.js";
4
5
  import {
5
6
  createLogger,
6
7
  loadConfig,
7
8
  parseSpec,
8
9
  resolveGlob
9
- } from "./chunk-Z77VQUZ3.js";
10
+ } from "./chunk-MM325DR6.js";
10
11
  import {
11
12
  REQUIRED_SECTIONS
12
- } from "./chunk-SJCIM4TC.js";
13
+ } from "./chunk-ZIPGRLYE.js";
13
14
  import "./chunk-5WRI5ZAA.js";
14
15
 
15
16
  // src/commands/core/generate-story.ts
@@ -105,16 +106,13 @@ async function generateStories(options) {
105
106
  throw new Error(`No spec with id "${from}" found in config.`);
106
107
  }
107
108
  const prd = await parseSpec(prdFilePath);
108
- const featuresSection = prd.parsedSections.find((s) => s.heading === "Features");
109
- if (!featuresSection) {
110
- return { generated: [], skipped: [] };
111
- }
112
- const featureRegex = /\*\*F(\d+)\*\*:\s*(.+)/g;
113
- const features = [];
114
- let match;
115
- while ((match = featureRegex.exec(featuresSection.content)) !== null) {
116
- features.push({ num: match[1], text: match[2] });
117
- }
109
+ const entries = parseFeatureEntries(prd.content);
110
+ const features = entries.map((entry, i) => ({
111
+ // Un-numbered features still need a stable filename, so fall back to
112
+ // position. Authors who do use `**F<N>**:` keep their numbering.
113
+ num: entry.num ?? String(i + 1),
114
+ text: entry.text
115
+ }));
118
116
  if (features.length === 0) {
119
117
  return { generated: [], skipped: [] };
120
118
  }
@@ -158,7 +156,7 @@ async function generateStories(options) {
158
156
  }
159
157
  var defineCommandExport = defineCommand({
160
158
  meta: {
161
- name: "generate story",
159
+ name: "story",
162
160
  description: "Generate user story stub files from a PRD's Features section"
163
161
  },
164
162
  args: {
@@ -219,4 +217,4 @@ export {
219
217
  defineCommandExport,
220
218
  generateStories
221
219
  };
222
- //# sourceMappingURL=generate-story-RFAPULQY.js.map
220
+ //# sourceMappingURL=generate-story-5TPTJA7B.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/core/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 type { ParsedSpec } from \"@specdx/core\";\nimport { REQUIRED_SECTIONS } from \"@specdx/schema\";\nimport { uncoveredFeatures, parseFeatureEntries } from \"@specdx/lint\";\n\nexport interface GenerateStoriesOptions {\n configDir: string;\n from: string;\n outDir?: string;\n}\n\nexport interface GenerateStoriesResult {\n generated: string[];\n /** Features left alone because an existing story already covers them. */\n skipped: string[];\n}\n\nfunction slugify(text: string): string {\n const slug = text\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n if (slug.length <= 40) return slug;\n // Truncate on a word boundary so filenames don't end mid-word\n const cut = slug.slice(0, 40);\n const lastHyphen = cut.lastIndexOf(\"-\");\n return lastHyphen > 0 ? cut.slice(0, lastHyphen) : cut;\n}\n\nfunction detectStoriesDir(\n configDir: string,\n config: Awaited<ReturnType<typeof loadConfig>>,\n): string {\n for (const entry of Object.values(config.specs)) {\n if (entry.type === \"user-story\") {\n // Use the directory portion of the glob path\n const dirPart = entry.path.replace(/\\/[^/]*\\*.*$/, \"\").replace(/\\/[^/]*$/, \"\");\n // If path ends with *.md at a directory level, take that dir\n const match = entry.path.match(/^(.+?)\\/\\*/);\n if (match) {\n return join(configDir, match[1]!);\n }\n return join(configDir, dirPart);\n }\n }\n return join(configDir, \"specs/stories\");\n}\n\nfunction buildStoryFile(options: {\n featureNum: string;\n featureText: string;\n prdId: string;\n prdAuthors: string[];\n today: string;\n sections: string[];\n}): string {\n const { featureNum, featureText, prdId, prdAuthors, today, sections } = options;\n const storyId = `story-f${featureNum}`;\n const title = featureText.trim();\n const authorsYaml = JSON.stringify(prdAuthors);\n\n const frontmatter = [\n \"---\",\n `id: \"${storyId}\"`,\n `type: \"user-story\"`,\n `title: \"${title}\"`,\n `status: \"draft\"`,\n `version: \"0.1\"`,\n `created: \"${today}\"`,\n `authors: ${authorsYaml}`,\n `story_id: \"${storyId}\"`,\n `priority: \"medium\"`,\n `estimate: \"TBD\"`,\n `references:`,\n ` - id: \"${prdId}\"`,\n ` relationship: \"decomposed-into\"`,\n \"---\",\n ].join(\"\\n\");\n\n const bodyParts = sections.map((section) => {\n if (section === \"Description\") {\n return `\\n## ${section}\\n\\n${featureText.trim()}`;\n }\n if (section === \"Acceptance Criteria\") {\n return `\\n## ${section}\\n\\n- [ ] <!-- acceptance criterion -->`;\n }\n if (section === \"Dependencies\") {\n return `\\n## ${section}\\n\\nF${featureNum} from ${prdId}`;\n }\n return `\\n## ${section}\\n\\n<!-- placeholder -->`;\n });\n\n return `${frontmatter}\\n${bodyParts.join(\"\\n\")}\\n`;\n}\n\nexport async function generateStories(\n options: GenerateStoriesOptions,\n): Promise<GenerateStoriesResult> {\n const { configDir, from, outDir } = options;\n const config = await loadConfig(undefined, configDir);\n\n // Find the PRD spec file by ID\n let prdFilePath: string | undefined;\n for (const entry of Object.values(config.specs)) {\n const files = await resolveGlob(entry.path, configDir);\n for (const file of files) {\n const parsed = await parseSpec(file);\n if (parsed.frontmatter.id === from) {\n prdFilePath = file;\n break;\n }\n }\n if (prdFilePath) break;\n }\n\n if (!prdFilePath) {\n throw new Error(`No spec with id \"${from}\" found in config.`);\n }\n\n const prd = await parseSpec(prdFilePath);\n\n // The same parser the lint rule and `ready` use. Carrying a second one here\n // meant this command reported \"no features found\" for a PRD that lint was\n // simultaneously reporting three features in.\n const entries = parseFeatureEntries(prd.content);\n const features = entries.map((entry, i) => ({\n // Un-numbered features still need a stable filename, so fall back to\n // position. Authors who do use `**F<N>**:` keep their numbering.\n num: entry.num ?? String(i + 1),\n text: entry.text,\n }));\n\n if (features.length === 0) {\n return { generated: [], skipped: [] };\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 // Features an existing story already covers are left alone -- regenerating\n // them produces a second stub for the same feature to reconcile by hand.\n const existingStories: ParsedSpec[] = [];\n for (const entry of Object.values(config.specs)) {\n if (entry.type !== \"user-story\") continue;\n for (const p of await resolveGlob(entry.path, configDir)) {\n existingStories.push(await parseSpec(p));\n }\n }\n const uncovered = new Set(\n uncoveredFeatures(\n features.map((f) => f.text),\n existingStories,\n from,\n ),\n );\n const skipped = features.filter((f) => !uncovered.has(f.text)).map((f) => f.text);\n\n const generated: string[] = [];\n\n for (const feature of features.filter((f) => uncovered.has(f.text))) {\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, skipped };\n}\n\nexport const defineCommandExport = defineCommand({\n meta: {\n name: \"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 && result.skipped.length > 0) {\n logger.info(\n `Every feature already has a story — ${result.skipped.length} feature(s) skipped, nothing generated.`,\n );\n } else 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 if (result.skipped.length > 0) {\n logger.info(`Skipped ${result.skipped.length} feature(s) an existing story covers.`);\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;AAkBrB,SAAS,QAAQ,MAAsB;AACrC,QAAM,OAAO,KACV,YAAY,EACZ,QAAQ,eAAe,GAAG,EAC1B,QAAQ,YAAY,EAAE;AACzB,MAAI,KAAK,UAAU,GAAI,QAAO;AAE9B,QAAM,MAAM,KAAK,MAAM,GAAG,EAAE;AAC5B,QAAM,aAAa,IA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aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,IACA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,MAAM,IAAI,EAAE,KAAK,GAAG;AAClB,UAAM,SAAS,aAAa,EAAE,OAAO,KAAK,OAAO,SAAS,KAAK,QAAQ,CAAC;AAExE,QAAI;AACF,YAAM,SAAS,MAAM,gBAAgB;AAAA,QACnC,WAAW,QAAQ,IAAI;AAAA,QACvB,MAAM,KAAK;AAAA,QACX,QAAQ,KAAK;AAAA,MACf,CAAC;AAED,UAAI,OAAO,UAAU,WAAW,KAAK,OAAO,QAAQ,SAAS,GAAG;AAC9D,eAAO;AAAA,UACL,4CAAuC,OAAO,QAAQ,MAAM;AAAA,QAC9D;AAAA,MACF,WAAW,OAAO,UAAU,WAAW,GAAG;AACxC,eAAO,KAAK,2DAAsD;AAAA,MACpE,OAAO;AACL,eAAO,KAAK,aAAa,OAAO,UAAU,MAAM,iBAAiB;AACjE,mBAAW,YAAY,OAAO,WAAW;AACvC,iBAAO,KAAK,KAAK,QAAQ,EAAE;AAAA,QAC7B;AACA,YAAI,OAAO,QAAQ,SAAS,GAAG;AAC7B,iBAAO,KAAK,WAAW,OAAO,QAAQ,MAAM,uCAAuC;AAAA,QACrF;AAAA,MACF;AAAA,IACF,SAAS,KAAK;AACZ,cAAQ,MAAM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;AAED,IAAO,yBAAQ;","names":[]}
@@ -3,14 +3,15 @@ import {
3
3
  loadConfig,
4
4
  parseSpec,
5
5
  resolveGlob
6
- } from "./chunk-Z77VQUZ3.js";
7
- import "./chunk-SJCIM4TC.js";
6
+ } from "./chunk-MM325DR6.js";
7
+ import "./chunk-ZIPGRLYE.js";
8
8
  import "./chunk-5WRI5ZAA.js";
9
9
 
10
10
  // src/commands/experimental/generate-test-plan.ts
11
11
  import { defineCommand } from "citty";
12
12
  import { writeFile } from "fs/promises";
13
- import { join } from "path";
13
+ import { existsSync } from "fs";
14
+ import { join, relative, resolve } from "path";
14
15
  function extractSection(content, heading) {
15
16
  const escapedHeading = heading.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
16
17
  const headingPattern = new RegExp(`^##\\s+${escapedHeading}\\s*$`, "im");
@@ -36,7 +37,7 @@ function parseAcceptanceCriteria(section) {
36
37
  return cases;
37
38
  }
38
39
  async function generateTestPlan(options) {
39
- const { configDir, outPath } = options;
40
+ const { configDir, outPath, force = false } = options;
40
41
  const config = await loadConfig(void 0, configDir);
41
42
  const storiesBySpec = [];
42
43
  for (const [, entry] of Object.entries(config.specs)) {
@@ -115,12 +116,24 @@ ${body}`;
115
116
  return { testCases: 0 };
116
117
  }
117
118
  const targetPath = outPath ?? join(configDir, "specs", "test-plan.md");
119
+ if (!force && existsSync(targetPath)) {
120
+ return { testCases: totalTestCases, blockedBy: targetPath };
121
+ }
118
122
  await writeFile(targetPath, fileContent, "utf-8");
119
123
  return { filePath: targetPath, testCases: totalTestCases };
120
124
  }
125
+ async function registeredKeyFor(configDir, filePath) {
126
+ const config = await loadConfig(void 0, configDir);
127
+ for (const [key, entry] of Object.entries(config.specs)) {
128
+ for (const resolved of await resolveGlob(entry.path, configDir)) {
129
+ if (resolve(resolved) === resolve(filePath)) return key;
130
+ }
131
+ }
132
+ return void 0;
133
+ }
121
134
  var generate_test_plan_default = defineCommand({
122
135
  meta: {
123
- name: "generate-test-plan",
136
+ name: "test-plan",
124
137
  description: "Generate a test plan stub from user stories"
125
138
  },
126
139
  args: {
@@ -132,6 +145,11 @@ var generate_test_plan_default = defineCommand({
132
145
  out: {
133
146
  type: "string",
134
147
  description: "Output file path (default: specs/test-plan.md)"
148
+ },
149
+ force: {
150
+ type: "boolean",
151
+ description: "Overwrite the file if it already exists",
152
+ default: false
135
153
  }
136
154
  },
137
155
  async run({ args }) {
@@ -143,18 +161,38 @@ var generate_test_plan_default = defineCommand({
143
161
  process.exit(1);
144
162
  }
145
163
  try {
164
+ const configDir = process.cwd();
146
165
  const result = await generateTestPlan({
147
- configDir: process.cwd(),
148
- outPath: args.out
166
+ configDir,
167
+ outPath: args.out,
168
+ force: args.force
149
169
  });
170
+ if (result.blockedBy) {
171
+ console.error(
172
+ `
173
+ \u2717 ${result.blockedBy} already exists \u2014 not overwriting it.
174
+ Pass --force to replace it, or --out <path> to write elsewhere.
175
+ `
176
+ );
177
+ process.exit(1);
178
+ }
150
179
  if (!result.filePath) {
151
180
  logger.info("No user stories found \u2014 no test plan generated.");
152
181
  return;
153
182
  }
154
183
  logger.info(`Generated test plan with ${result.testCases} test cases \u2192 ${result.filePath}`);
155
- logger.info(
156
- "Add it to spec.config.yaml so lint, status and pack can see it:\n test-plan:\n path: specs/test-plan.md\n type: test-plan"
157
- );
184
+ const existingKey = await registeredKeyFor(configDir, result.filePath);
185
+ if (existingKey) {
186
+ logger.info(`Already registered in spec.config.yaml as "${existingKey}".`);
187
+ } else {
188
+ const rel = relative(configDir, result.filePath) || result.filePath;
189
+ logger.info(
190
+ `Add it to spec.config.yaml so lint, status and pack can see it:
191
+ test-plan:
192
+ path: ${rel}
193
+ type: test-plan`
194
+ );
195
+ }
158
196
  } catch (err) {
159
197
  console.error(`
160
198
  \u2717 ${err.message}
@@ -165,6 +203,7 @@ var generate_test_plan_default = defineCommand({
165
203
  });
166
204
  export {
167
205
  generate_test_plan_default as default,
168
- generateTestPlan
206
+ generateTestPlan,
207
+ registeredKeyFor
169
208
  };
170
- //# sourceMappingURL=generate-test-plan-M22PCW73.js.map
209
+ //# sourceMappingURL=generate-test-plan-XBAFJKJI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/experimental/generate-test-plan.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, resolveGlob, createLogger } from \"@specdx/core\";\nimport { writeFile } from \"node:fs/promises\";\nimport { existsSync } from \"node:fs\";\nimport { join, relative, resolve } from \"node:path\";\n\nexport interface GenerateTestPlanOptions {\n configDir: string;\n outPath?: string;\n /** Overwrite an existing file. Off by default -- the file may be hand-written. */\n force?: boolean;\n}\n\nexport interface GenerateTestPlanResult {\n /** Undefined when there was nothing to generate, so no file was written. */\n filePath?: string;\n testCases: number;\n /** Set when a file exists at the target path and `force` was not given. */\n blockedBy?: string;\n}\n\ninterface StoryTestCases {\n storyId: string;\n title: string;\n authors: string[];\n cases: string[];\n}\n\n/**\n * Extracts the content of a `## Heading` section from a markdown string.\n * Returns the text between that heading and the next `## ` heading (or end of string).\n */\nfunction extractSection(content: string, heading: string): string | null {\n const escapedHeading = heading.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const headingPattern = new RegExp(`^##\\\\s+${escapedHeading}\\\\s*$`, \"im\");\n const match = headingPattern.exec(content);\n if (!match) return null;\n\n const start = match.index + match[0].length;\n const rest = content.slice(start);\n\n const nextSection = /^##\\s+/m.exec(rest);\n return nextSection ? rest.slice(0, nextSection.index) : rest;\n}\n\n/**\n * Parses acceptance criteria bullet points from a section string.\n * Handles `- [ ] text`, `- [x] text`, and plain `- text` formats.\n */\nfunction parseAcceptanceCriteria(section: string): string[] {\n const cases: string[] = [];\n for (const rawLine of section.split(\"\\n\")) {\n const line = rawLine.trim();\n // Match bullet lines: `- [ ] text`, `- [x] text`, `- text`\n const bulletMatch = /^-\\s+(?:\\[[ xX]\\]\\s+)?(.+)/.exec(line);\n if (bulletMatch) {\n const text = bulletMatch[1]!.trim();\n if (text) {\n cases.push(text);\n }\n }\n }\n return cases;\n}\n\nexport async function generateTestPlan(\n options: GenerateTestPlanOptions,\n): Promise<GenerateTestPlanResult> {\n const { configDir, outPath, force = false } = options;\n const config = await loadConfig(undefined, configDir);\n\n const storiesBySpec: StoryTestCases[] = [];\n\n for (const [, entry] of Object.entries(config.specs)) {\n if (entry.type !== \"user-story\") continue;\n\n const files = await resolveGlob(entry.path, configDir);\n for (const file of files) {\n const parsed = await parseSpec(file);\n const frontmatter = parsed.frontmatter;\n const storyId = (frontmatter[\"id\"] as string | undefined) ?? file;\n const title = (frontmatter[\"title\"] as string | undefined) ?? storyId;\n const authors = (frontmatter[\"authors\"] as string[] | undefined) ?? [];\n\n const acSection = extractSection(parsed.content, \"Acceptance Criteria\");\n const cases = acSection ? parseAcceptanceCriteria(acSection) : [];\n\n storiesBySpec.push({ storyId, title, authors, cases });\n }\n }\n\n // Sort stories by ID for deterministic output\n storiesBySpec.sort((a, b) => a.storyId.localeCompare(b.storyId));\n\n const today = new Date().toISOString().slice(0, 10);\n\n // Aggregate authors from all stories (deduplicated)\n const allAuthors = Array.from(new Set(storiesBySpec.flatMap((s) => s.authors)));\n\n // Build references to all stories\n const storyRefs = storiesBySpec.map(\n (s) => ` - id: \"${s.storyId}\"\\n relationship: \"related-to\"`,\n );\n\n const totalTestCases = storiesBySpec.reduce((sum, s) => sum + s.cases.length, 0);\n\n // Build frontmatter\n const authorsYaml =\n allAuthors.length > 0 ? `[${allAuthors.map((a) => `\"${a}\"`).join(\", \")}]` : '[\"generated\"]';\n\n const refsYaml = storyRefs.length > 0 ? `\\nreferences:\\n${storyRefs.join(\"\\n\")}` : \"\";\n\n const frontmatter = [\n \"---\",\n 'id: \"generated-test-plan\"',\n 'type: \"test-plan\"',\n 'title: \"Generated Test Plan\"',\n 'status: \"draft\"',\n 'version: \"0.1\"',\n `created: \"${today}\"`,\n `authors: ${authorsYaml}`,\n refsYaml.length > 0 ? refsYaml.trimStart() : null,\n \"---\",\n ]\n .filter((line) => line !== null)\n .join(\"\\n\");\n\n // ## Scope\n const scopeLines =\n storiesBySpec.length > 0\n ? storiesBySpec.map((s) => `- ${s.storyId}: ${s.title}`).join(\"\\n\")\n : \"_No user stories found._\";\n\n // ## Test Cases — grouped by story\n const testCaseBlocks = storiesBySpec\n .map((s) => {\n const caseBullets =\n s.cases.length > 0\n ? s.cases.map((c) => `- [ ] ${c}`).join(\"\\n\")\n : \"_No acceptance criteria found._\";\n return `### ${s.storyId}\\n\\n${caseBullets}`;\n })\n .join(\"\\n\\n\");\n\n const testCasesBody = storiesBySpec.length > 0 ? testCaseBlocks : \"_No user stories found._\";\n\n // ## Coverage Matrix\n const matrixHeader = \"| Story | Test Cases |\";\n const matrixSep = \"| ----- | ---------- |\";\n const matrixRows = storiesBySpec.map((s) => `| ${s.storyId} | ${s.cases.length} |`);\n const coverageMatrix = [matrixHeader, matrixSep, ...matrixRows].join(\"\\n\");\n\n // ## Edge Cases\n const edgeCasesPlaceholder = \"<!-- Add edge cases and boundary conditions here -->\";\n\n const body = [\n `## Scope`,\n \"\",\n scopeLines,\n \"\",\n `## Test Cases`,\n \"\",\n testCasesBody,\n \"\",\n `## Coverage Matrix`,\n \"\",\n coverageMatrix,\n \"\",\n `## Edge Cases`,\n \"\",\n edgeCasesPlaceholder,\n \"\",\n ].join(\"\\n\");\n\n const fileContent = `${frontmatter}\\n\\n${body}`;\n\n // Nothing to build a plan from. Writing a spec whose every section reads\n // \"_No user stories found._\" would add a file the linter then flags and the\n // suite has to carry -- `generate story` already declines in this case.\n if (storiesBySpec.length === 0) {\n return { testCases: 0 };\n }\n\n const targetPath = outPath ?? join(configDir, \"specs\", \"test-plan.md\");\n\n // A generator must not destroy hand-written work. This overwrote an approved\n // spec -- registered in the config, with a filled-in coverage matrix -- and\n // replaced it with a draft stub, silently and with exit 0. The only reason it\n // was recoverable was that the project happened to use git.\n if (!force && existsSync(targetPath)) {\n return { testCases: totalTestCases, blockedBy: targetPath };\n }\n\n await writeFile(targetPath, fileContent, \"utf-8\");\n\n return { filePath: targetPath, testCases: totalTestCases };\n}\n\n/**\n * The config key, if any, already pointing at `filePath`.\n *\n * Telling an author to register a file the config already knows about invites a\n * duplicate entry for one path -- which is how a frontmatter id and its key\n * come to disagree.\n */\nexport async function registeredKeyFor(\n configDir: string,\n filePath: string,\n): Promise<string | undefined> {\n const config = await loadConfig(undefined, configDir);\n for (const [key, entry] of Object.entries(config.specs)) {\n for (const resolved of await resolveGlob(entry.path, configDir)) {\n if (resolve(resolved) === resolve(filePath)) return key;\n }\n }\n return undefined;\n}\n\nexport default defineCommand({\n meta: {\n name: \"test-plan\",\n description: \"Generate a test plan stub from user stories\",\n },\n args: {\n from: {\n type: \"string\",\n description: \"Source to generate from (currently only 'stories' is supported)\",\n default: \"stories\",\n },\n out: {\n type: \"string\",\n description: \"Output file path (default: specs/test-plan.md)\",\n },\n force: {\n type: \"boolean\",\n description: \"Overwrite the file if it already exists\",\n default: false,\n },\n },\n async run({ args }) {\n const logger = createLogger({ quiet: false, verbose: false });\n\n if (args.from !== \"stories\") {\n console.error(`\\n ✗ --from must be 'stories' (got: ${args.from})\\n`);\n process.exit(1);\n }\n\n try {\n const configDir = process.cwd();\n const result = await generateTestPlan({\n configDir,\n outPath: args.out,\n force: args.force,\n });\n\n if (result.blockedBy) {\n console.error(\n `\\n ✗ ${result.blockedBy} already exists — not overwriting it.\\n` +\n \" Pass --force to replace it, or --out <path> to write elsewhere.\\n\",\n );\n process.exit(1);\n }\n\n if (!result.filePath) {\n logger.info(\"No user stories found — no test plan generated.\");\n return;\n }\n\n logger.info(`Generated test plan with ${result.testCases} test cases → ${result.filePath}`);\n\n // Only worth saying when it is actually unregistered. Advising a key for\n // a path the config already maps produces two entries for one file.\n const existingKey = await registeredKeyFor(configDir, result.filePath);\n if (existingKey) {\n logger.info(`Already registered in spec.config.yaml as \"${existingKey}\".`);\n } else {\n const rel = relative(configDir, result.filePath) || result.filePath;\n logger.info(\n \"Add it to spec.config.yaml so lint, status and pack can see it:\\n\" +\n ` test-plan:\\n path: ${rel}\\n type: test-plan`,\n );\n }\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n },\n});\n"],"mappings":";;;;;;;;;;AAAA,SAAS,qBAAqB;AAE9B,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,MAAM,UAAU,eAAe;AA4BxC,SAAS,eAAe,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AAK,OAAO;AAC3D,eAAO;AAAA,UACL;AAAA;AAAA,YAC6B,GAAG;AAAA;AAAA,QAClC;AAAA,MACF;AAAA,IACF,SAAS,KAAK;AACZ,cAAQ,MAAM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;","names":["frontmatter"]}
@@ -9,8 +9,8 @@ import {
9
9
  loadConfig,
10
10
  parseSpec,
11
11
  resolveGlob
12
- } from "./chunk-Z77VQUZ3.js";
13
- import "./chunk-SJCIM4TC.js";
12
+ } from "./chunk-MM325DR6.js";
13
+ import "./chunk-ZIPGRLYE.js";
14
14
  import "./chunk-5WRI5ZAA.js";
15
15
 
16
16
  // src/commands/core/graph.ts
@@ -100,4 +100,4 @@ var graph_default = defineCommand({
100
100
  export {
101
101
  graph_default as default
102
102
  };
103
- //# sourceMappingURL=graph-OKUMHR3Q.js.map
103
+ //# sourceMappingURL=graph-UZJMLX4J.js.map
@@ -0,0 +1,171 @@
1
+ type Template = "lightweight" | "bmad" | "api-first" | "quick" | "context";
2
+ interface ScaffoldOptions {
3
+ projectName: string;
4
+ template: Template;
5
+ targetDir: string;
6
+ }
7
+ declare function scaffoldProject({ projectName, template, targetDir, }: ScaffoldOptions): Promise<void>;
8
+
9
+ type Severity = "error" | "warn" | "info";
10
+ interface Diagnostic {
11
+ ruleId: string;
12
+ severity: Severity;
13
+ message: string;
14
+ filePath: string;
15
+ line?: number;
16
+ section?: string;
17
+ }
18
+ interface LintResults {
19
+ diagnostics: Diagnostic[];
20
+ hasErrors: boolean;
21
+ hasWarnings: boolean;
22
+ }
23
+
24
+ interface RunLintOptions {
25
+ configDir: string;
26
+ specPath?: string;
27
+ preset?: "minimal" | "recommended" | "strict";
28
+ }
29
+ /** Lint results plus whether anything was actually linted (vacuous-pass audit). */
30
+ interface RunLintResults extends LintResults {
31
+ /** Number of specs linted. */
32
+ specCount: number;
33
+ /** False when no specs resolved — "no diagnostics" is then not a pass. */
34
+ assessed: boolean;
35
+ }
36
+ declare function runLint(options: RunLintOptions): Promise<RunLintResults>;
37
+
38
+ /** Statistics about how the budget was allocated. */
39
+ interface PackStats {
40
+ /** Total token budget. */
41
+ budget: number;
42
+ /** Tokens actually used. */
43
+ used: number;
44
+ /** Number of specs included in the output. */
45
+ specsIncluded: number;
46
+ /** Number of specs excluded due to budget or relevance. */
47
+ specsExcluded: number;
48
+ /** Number of sections that were compressed. */
49
+ sectionsCompressed: number;
50
+ /** Number of sections omitted entirely to fit the budget. */
51
+ sectionsOmitted: number;
52
+ /** Per-spec allocation details. */
53
+ allocations: SpecAllocation[];
54
+ }
55
+ /** Result returned by the pack operation. */
56
+ interface PackResult {
57
+ /** The formatted output string. */
58
+ output: string;
59
+ /** Statistics about the pack run. */
60
+ stats: PackStats;
61
+ }
62
+ /** Token allocation detail for a single spec. */
63
+ interface SpecAllocation {
64
+ /** Identifier of the spec. */
65
+ specId: string;
66
+ /** Spec type (e.g. "adr", "rfc", "runbook"). */
67
+ type: string;
68
+ /** Computed relevance score (0-1). */
69
+ relevance: number;
70
+ /** Tokens allocated to this spec. */
71
+ tokens: number;
72
+ /** Whether this spec was compressed. */
73
+ compressed: boolean;
74
+ /** Whether this spec was included in the output. */
75
+ included: boolean;
76
+ }
77
+
78
+ interface RunPackOptions {
79
+ configDir: string;
80
+ task?: string;
81
+ specs?: string[];
82
+ budget?: number;
83
+ format?: "xml" | "markdown" | "json";
84
+ full?: boolean;
85
+ dryRun?: boolean;
86
+ }
87
+ declare function runPack(options: RunPackOptions): Promise<PackResult & {
88
+ specsResolved: number;
89
+ }>;
90
+
91
+ type FieldChangeType = "added" | "removed" | "modified" | "broken-reference";
92
+ interface FieldChange {
93
+ field: string;
94
+ type: FieldChangeType;
95
+ before?: unknown;
96
+ after?: unknown;
97
+ }
98
+ interface SectionChange {
99
+ heading: string;
100
+ type: "added" | "removed" | "modified";
101
+ contentDiff?: string;
102
+ }
103
+ interface SpecDiff {
104
+ specId: string;
105
+ filePath: string;
106
+ frontmatter: FieldChange[];
107
+ sections: SectionChange[];
108
+ summary: string;
109
+ }
110
+ interface DownstreamImpact {
111
+ specId: string;
112
+ filePath: string;
113
+ distance: number;
114
+ lastUpdated: string | null;
115
+ staleness: number;
116
+ reason: string;
117
+ }
118
+ interface ImpactAnalysis {
119
+ changedSpec: string;
120
+ downstream: DownstreamImpact[];
121
+ totalAffected: number;
122
+ }
123
+ interface DiffResult {
124
+ diffs: SpecDiff[];
125
+ added: string[];
126
+ removed: string[];
127
+ impact: ImpactAnalysis[];
128
+ summary: string;
129
+ /**
130
+ * Spec files changed in the working tree but not covered by the comparison.
131
+ *
132
+ * A ref-to-ref diff cannot see uncommitted work, so reporting "no changes"
133
+ * without this would be a false all-clear. Always empty in working mode,
134
+ * where those changes are part of the comparison.
135
+ */
136
+ uncommittedSpecFiles: string[];
137
+ }
138
+ interface StatusResult {
139
+ project: string;
140
+ specCount: number;
141
+ byStatus: Record<string, number>;
142
+ lintHealth: {
143
+ errors: number;
144
+ warnings: number;
145
+ passing: number;
146
+ };
147
+ staleSpecs: {
148
+ specId: string;
149
+ daysSinceUpdate: number;
150
+ owner?: string;
151
+ }[];
152
+ integrityIssues: string[];
153
+ /** "unassessed" when the suite resolved to zero specs — never a vacuous "healthy". */
154
+ verdict: "healthy" | "warnings" | "errors" | "unassessed";
155
+ }
156
+
157
+ interface RunDiffOptions {
158
+ base?: string;
159
+ head?: string;
160
+ spec?: string;
161
+ format?: string;
162
+ /** Compare the base ref against the working tree instead of a head ref. */
163
+ working?: boolean;
164
+ }
165
+ declare function runDiff(options: RunDiffOptions): Promise<DiffResult>;
166
+
167
+ declare function runStatus(_options?: {
168
+ format?: string;
169
+ }): Promise<StatusResult>;
170
+
171
+ export { runDiff, runLint, runPack, runStatus, scaffoldProject };