specdx 0.4.0-alpha.13 → 0.4.0-alpha.15

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 (31) hide show
  1. package/.claude-plugin/plugin.json +7 -2
  2. package/dist/{diff-DHU3OMNM.js → diff-AWFDXYX4.js} +60 -2
  3. package/dist/diff-AWFDXYX4.js.map +1 -0
  4. package/dist/{explain-EULHHRQC.js → explain-M2VXXXGP.js} +5 -2
  5. package/dist/explain-M2VXXXGP.js.map +1 -0
  6. package/dist/index.js +63 -84
  7. package/dist/index.js.map +1 -1
  8. package/dist/main.js +4 -5
  9. package/dist/main.js.map +1 -1
  10. package/dist/skills/{specdx-author-spec.md → specdx-author-spec/SKILL.md} +6 -6
  11. package/dist/skills/specdx-author-spec/{step-01-frontmatter.md → references/step-01-frontmatter.md} +1 -1
  12. package/dist/skills/{specdx-check-drift.md → specdx-check-drift/SKILL.md} +1 -1
  13. package/dist/skills/{specdx-onboard.md → specdx-onboard/SKILL.md} +1 -1
  14. package/dist/skills/{specdx-plan-from-spec.md → specdx-plan-from-spec/SKILL.md} +1 -1
  15. package/dist/skills/{specdx-pre-commit.md → specdx-pre-commit/SKILL.md} +1 -1
  16. package/dist/skills/{specdx-review-spec.md → specdx-review-spec/SKILL.md} +1 -1
  17. package/dist/skills/{specdx-sprint-review.md → specdx-sprint-review/SKILL.md} +1 -1
  18. package/dist/skills/{specdx-start-task.md → specdx-start-task/SKILL.md} +1 -1
  19. package/dist/skills/{specdx-verify.md → specdx-verify/SKILL.md} +1 -1
  20. package/dist/{skills-EQTVRLER.js → skills-N7ZDWOJM.js} +27 -11
  21. package/dist/skills-N7ZDWOJM.js.map +1 -0
  22. package/hooks/hooks.json +12 -6
  23. package/package.json +3 -3
  24. package/dist/changelog-COHY6ILK.js +0 -94
  25. package/dist/changelog-COHY6ILK.js.map +0 -1
  26. package/dist/diff-DHU3OMNM.js.map +0 -1
  27. package/dist/explain-EULHHRQC.js.map +0 -1
  28. package/dist/skills-EQTVRLER.js.map +0 -1
  29. /package/dist/skills/{spec-type-reference.md → specdx-author-spec/references/spec-type-reference.md} +0 -0
  30. /package/dist/skills/specdx-author-spec/{step-02-sections.md → references/step-02-sections.md} +0 -0
  31. /package/dist/skills/specdx-author-spec/{step-03-finalize.md → references/step-03-finalize.md} +0 -0
@@ -1,6 +1,11 @@
1
1
  {
2
2
  "name": "specdx",
3
- "version": "0.4.0-alpha.1",
3
+ "version": "0.4.0-alpha.15",
4
4
  "description": "Spec-driven development skills for Claude Code",
5
- "commands": "./dist/skills"
5
+ "author": {
6
+ "name": "umxr",
7
+ "url": "https://github.com/umxr"
8
+ },
9
+ "skills": "./dist/skills",
10
+ "hooks": "./hooks/hooks.json"
6
11
  }
@@ -12,6 +12,57 @@ import "./chunk-5WRI5ZAA.js";
12
12
  // src/commands/diff.ts
13
13
  import { defineCommand } from "citty";
14
14
  import { join } from "path";
15
+
16
+ // src/formatters/changelog.ts
17
+ function formatChangelog(result, baseRef, headRef) {
18
+ const lines = [];
19
+ lines.push(`## Spec Changes (${baseRef}..${headRef})
20
+ `);
21
+ if (result.diffs.length > 0) {
22
+ lines.push("### Modified");
23
+ for (const diff of result.diffs) {
24
+ const sections = diff.sections.map((s) => s.heading).join(", ");
25
+ const versionChange = diff.frontmatter.find((f) => f.field === "version");
26
+ const versionStr = versionChange ? ` (${String(versionChange.before)} \u2192 ${String(versionChange.after)})` : "";
27
+ lines.push(`- **${diff.specId}**${versionStr} \u2014 ${sections || "frontmatter only"}`);
28
+ }
29
+ lines.push("");
30
+ }
31
+ if (result.added.length > 0) {
32
+ lines.push("### Added");
33
+ for (const id of result.added) {
34
+ lines.push(`- **${id}**`);
35
+ }
36
+ lines.push("");
37
+ }
38
+ if (result.removed.length > 0) {
39
+ lines.push("### Removed");
40
+ for (const id of result.removed) {
41
+ lines.push(`- **${id}**`);
42
+ }
43
+ lines.push("");
44
+ }
45
+ const allDownstream = result.impact.flatMap((i) => i.downstream);
46
+ if (allDownstream.length > 0) {
47
+ lines.push("### Downstream Impact");
48
+ for (const d of allDownstream) {
49
+ lines.push(`- ${d.specId} may be stale (${d.reason})`);
50
+ }
51
+ lines.push("");
52
+ }
53
+ if (result.diffs.length === 0 && result.added.length === 0 && result.removed.length === 0) {
54
+ lines.push("No spec changes detected.\n");
55
+ }
56
+ if (result.uncommittedSpecFiles.length > 0) {
57
+ lines.push(
58
+ `> \u26A0 ${result.uncommittedSpecFiles.length} spec file(s) changed in the working tree are not covered by this range.
59
+ `
60
+ );
61
+ }
62
+ return lines.join("\n");
63
+ }
64
+
65
+ // src/commands/diff.ts
15
66
  async function runDiff(options) {
16
67
  const configDir = process.cwd();
17
68
  const config = await loadConfig(void 0, configDir);
@@ -40,7 +91,7 @@ var diff_default = defineCommand({
40
91
  spec: { type: "string", description: "Scope to a single spec ID" },
41
92
  format: {
42
93
  type: "string",
43
- description: "Output format: pretty, json",
94
+ description: "Output format: pretty, json, changelog",
44
95
  default: "pretty"
45
96
  }
46
97
  },
@@ -58,6 +109,13 @@ var diff_default = defineCommand({
58
109
  console.log(JSON.stringify(result, null, 2));
59
110
  return;
60
111
  }
112
+ if (args.format === "changelog") {
113
+ const baseRef = args.base ?? (await loadConfig(void 0, process.cwd())).diff?.baseline_ref ?? "main";
114
+ console.log(
115
+ formatChangelog(result, baseRef, args.working ? "working tree" : args.head ?? "HEAD")
116
+ );
117
+ return;
118
+ }
61
119
  const printUncommittedWarning = () => {
62
120
  if (result.uncommittedSpecFiles.length === 0) return;
63
121
  const count = result.uncommittedSpecFiles.length;
@@ -127,4 +185,4 @@ export {
127
185
  diff_default as default,
128
186
  runDiff
129
187
  };
130
- //# sourceMappingURL=diff-DHU3OMNM.js.map
188
+ //# sourceMappingURL=diff-AWFDXYX4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/diff.ts","../src/formatters/changelog.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { join } from \"node:path\";\nimport { diffBetweenRefs, DEFAULT_DIFF_CONFIG, DiffError } from \"@specdx/diff\";\nimport { loadConfig } from \"@specdx/core\";\nimport { formatChangelog } from \"../formatters/changelog.js\";\nimport type { DiffResult } from \"@specdx/diff\";\n\nexport interface RunDiffOptions {\n base?: string;\n head?: string;\n spec?: string;\n format?: string;\n /** Compare the base ref against the working tree instead of a head ref. */\n working?: boolean;\n}\n\nexport async function runDiff(options: RunDiffOptions): Promise<DiffResult> {\n const configDir = process.cwd();\n const config = await loadConfig(undefined, configDir);\n\n const baseRef = options.base ?? config.diff?.baseline_ref ?? DEFAULT_DIFF_CONFIG.baseline_ref;\n const headRef = options.head ?? \"HEAD\";\n\n const configPath = join(configDir, \"spec.config.yaml\");\n\n const result = await diffBetweenRefs(configPath, baseRef, headRef, {\n working: options.working ?? false,\n });\n\n if (options.spec) {\n result.diffs = result.diffs.filter((d) => d.specId === options.spec);\n result.impact = result.impact.filter((i) => i.changedSpec === options.spec);\n }\n\n return result;\n}\n\nexport default defineCommand({\n meta: { name: \"diff\", description: \"Show spec changes and downstream impact\" },\n args: {\n base: { type: \"string\", description: \"Base git ref (default: from config or 'main')\" },\n head: { type: \"string\", description: \"Head git ref (default: HEAD)\" },\n working: {\n type: \"boolean\",\n description: \"Compare the base ref against the working tree (includes uncommitted specs)\",\n default: false,\n },\n spec: { type: \"string\", description: \"Scope to a single spec ID\" },\n format: {\n type: \"string\",\n description: \"Output format: pretty, json, changelog\",\n default: \"pretty\",\n },\n },\n async run({ args }) {\n try {\n try {\n const result = await runDiff({\n base: args.base,\n head: args.head,\n spec: args.spec,\n format: args.format,\n working: args.working,\n });\n\n if (args.format === \"json\") {\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n if (args.format === \"changelog\") {\n const baseRef =\n args.base ?? (await loadConfig(undefined, process.cwd())).diff?.baseline_ref ?? \"main\";\n console.log(\n formatChangelog(result, baseRef, args.working ? \"working tree\" : (args.head ?? \"HEAD\")),\n );\n return;\n }\n\n // A ref-to-ref comparison cannot see the working tree, so an unqualified\n // \"no changes\" would be a false all-clear for anyone about to commit.\n const printUncommittedWarning = (): void => {\n if (result.uncommittedSpecFiles.length === 0) return;\n const count = result.uncommittedSpecFiles.length;\n console.log(\n `\\n \\u26a0 ${count} spec file(s) changed in the working tree are not covered by this comparison:`,\n );\n for (const file of result.uncommittedSpecFiles) {\n console.log(` ${file}`);\n }\n console.log(\" Run with --working to include them.\");\n };\n\n // Pretty format\n if (result.diffs.length === 0 && result.added.length === 0 && result.removed.length === 0) {\n console.log(\" \\u2713 No spec changes detected.\");\n printUncommittedWarning();\n return;\n }\n\n console.log(result.summary);\n console.log();\n\n for (const diff of result.diffs) {\n console.log(` ${diff.specId}:`);\n for (const fc of diff.frontmatter) {\n const detail =\n fc.before !== undefined || fc.after !== undefined\n ? ` (${String(fc.before)} \\u2192 ${String(fc.after)})`\n : \"\";\n console.log(` ${fc.type}: ${fc.field}${detail}`);\n }\n for (const sc of diff.sections) {\n console.log(` ${sc.type}: ${sc.heading}`);\n }\n }\n\n if (result.added.length > 0) {\n console.log(`\\n Added: ${result.added.join(\", \")}`);\n }\n if (result.removed.length > 0) {\n console.log(`\\n Removed: ${result.removed.join(\", \")}`);\n }\n\n if (result.impact.length > 0) {\n console.log(\"\\n Downstream Impact:\");\n for (const impact of result.impact) {\n for (const d of impact.downstream) {\n console.log(\n ` ${d.specId} \\u2014 staleness: ${d.staleness.toFixed(2)} \\u2014 ${d.reason}`,\n );\n }\n }\n }\n\n printUncommittedWarning();\n } catch (err) {\n if (err instanceof DiffError) {\n console.error(`\\n \\u2717 ${err.message}\\n`);\n process.exit(1);\n }\n throw err;\n }\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n },\n});\n","import type { DiffResult } from \"@specdx/diff\";\n\n/**\n * Render a diff as a markdown changelog.\n *\n * Formerly the `specdx changelog` command, which ran the same comparison as\n * `diff` and differed only in presentation. It is a format, not a second\n * question, so it lives as `diff --format changelog`.\n */\nexport function formatChangelog(result: DiffResult, baseRef: string, headRef: string): string {\n const lines: string[] = [];\n lines.push(`## Spec Changes (${baseRef}..${headRef})\\n`);\n\n if (result.diffs.length > 0) {\n lines.push(\"### Modified\");\n for (const diff of result.diffs) {\n const sections = diff.sections.map((s) => s.heading).join(\", \");\n const versionChange = diff.frontmatter.find((f) => f.field === \"version\");\n const versionStr = versionChange\n ? ` (${String(versionChange.before)} → ${String(versionChange.after)})`\n : \"\";\n lines.push(`- **${diff.specId}**${versionStr} — ${sections || \"frontmatter only\"}`);\n }\n lines.push(\"\");\n }\n\n if (result.added.length > 0) {\n lines.push(\"### Added\");\n for (const id of result.added) {\n lines.push(`- **${id}**`);\n }\n lines.push(\"\");\n }\n\n if (result.removed.length > 0) {\n lines.push(\"### Removed\");\n for (const id of result.removed) {\n lines.push(`- **${id}**`);\n }\n lines.push(\"\");\n }\n\n const allDownstream = result.impact.flatMap((i) => i.downstream);\n if (allDownstream.length > 0) {\n lines.push(\"### Downstream Impact\");\n for (const d of allDownstream) {\n lines.push(`- ${d.specId} may be stale (${d.reason})`);\n }\n lines.push(\"\");\n }\n\n if (result.diffs.length === 0 && result.added.length === 0 && result.removed.length === 0) {\n lines.push(\"No spec changes detected.\\n\");\n }\n\n // The uncommitted warning matters most here: a changelog is usually written\n // at release time, when unstaged spec edits are easy to miss.\n if (result.uncommittedSpecFiles.length > 0) {\n lines.push(\n `> ⚠ ${result.uncommittedSpecFiles.length} spec file(s) changed in the working tree are not covered by this range.\\n`,\n );\n }\n\n return lines.join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,YAAY;;;ACQd,SAAS,gBAAgB,QAAoB,SAAiB,SAAyB;AAC5F,QAAM,QAAkB,CAAC;AACzB,QAAM,KAAK,oBAAoB,OAAO,KAAK,OAAO;AAAA,CAAK;AAEvD,MAAI,OAAO,MAAM,SAAS,GAAG;AAC3B,UAAM,KAAK,cAAc;AACzB,eAAW,QAAQ,OAAO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A,UAC7C;AAAA,QACF;AAEA,YAAI,OAAO,MAAM,SAAS,GAAG;AAC3B,kBAAQ,IAAI;AAAA,WAAc,OAAO,MAAM,KAAK,IAAI,CAAC,EAAE;AAAA,QACrD;AACA,YAAI,OAAO,QAAQ,SAAS,GAAG;AAC7B,kBAAQ,IAAI;AAAA,aAAgB,OAAO,QAAQ,KAAK,IAAI,CAAC,EAAE;AAAA,QACzD;AAEA,YAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,kBAAQ,IAAI,wBAAwB;AACpC,qBAAW,UAAU,OAAO,QAAQ;AAClC,uBAAW,KAAK,OAAO,YAAY;AACjC,sBAAQ;AAAA,gBACN,OAAO,EAAE,MAAM,sBAAsB,EAAE,UAAU,QAAQ,CAAC,CAAC,WAAW,EAAE,MAAM;AAAA,cAChF;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAEA,gCAAwB;AAAA,MAC1B,SAAS,KAAK;AACZ,YAAI,eAAe,WAAW;AAC5B,kBAAQ,MAAM;AAAA,WAAc,IAAI,OAAO;AAAA,CAAI;AAC3C,kBAAQ,KAAK,CAAC;AAAA,QAChB;AACA,cAAM;AAAA,MACR;AAAA,IACF,SAAS,KAAK;AACZ,cAAQ,MAAM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;","names":[]}
@@ -60,7 +60,10 @@ async function runExplain(_options = {}) {
60
60
  };
61
61
  }
62
62
  var explain_default = defineCommand({
63
- meta: { name: "explain", description: "Explain the spec suite for onboarding" },
63
+ meta: {
64
+ name: "explain",
65
+ description: "[experimental] Explain the spec suite for onboarding"
66
+ },
64
67
  args: {
65
68
  format: { type: "string", description: "Output format: pretty, json", default: "pretty" }
66
69
  },
@@ -107,4 +110,4 @@ export {
107
110
  explain_default as default,
108
111
  runExplain
109
112
  };
110
- //# sourceMappingURL=explain-EULHHRQC.js.map
113
+ //# sourceMappingURL=explain-M2VXXXGP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/explain.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, buildGraph, resolveGlob } from \"@specdx/core\";\nimport type { ParsedSpec } from \"@specdx/core\";\n\ninterface ExplainResult {\n project: string;\n description?: string;\n specCount: number;\n byType: Record<string, number>;\n byStatus: Record<string, number>;\n specs: { id: string; type: string; title: string; status: string; firstLine: string }[];\n graph: string[];\n}\n\nexport async function runExplain(_options: { format?: string } = {}): Promise<ExplainResult> {\n const configDir = process.cwd();\n const config = await loadConfig(undefined, configDir);\n\n // Parse all specs\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 specs.push(await parseSpec(p));\n }\n }\n\n // Count by type and status\n const byType: Record<string, number> = {};\n const byStatus: Record<string, number> = {};\n for (const spec of specs) {\n const type = (spec.frontmatter.type as string) || \"unknown\";\n const status = (spec.frontmatter.status as string) || \"unknown\";\n byType[type] = (byType[type] ?? 0) + 1;\n byStatus[status] = (byStatus[status] ?? 0) + 1;\n }\n\n // Build spec summaries — first sentence of first section content\n const specSummaries = specs.map((spec) => {\n const firstSection = spec.parsedSections[0];\n const firstLine =\n firstSection?.content\n ?.split(\"\\n\")\n .find((l) => l.trim().length > 0)\n ?.trim() ?? \"\";\n const truncated = firstLine.slice(0, 120) + (firstLine.length > 120 ? \"...\" : \"\");\n return {\n id: spec.frontmatter.id as string,\n type: spec.frontmatter.type as string,\n title: spec.frontmatter.title as string,\n status: spec.frontmatter.status as string,\n firstLine: truncated,\n };\n });\n\n // Build dependency graph lines\n const graph = buildGraph(config);\n const graphLines: string[] = [];\n for (const node of graph.nodes) {\n const downstream = graph.edges.filter((e) => e.from === node).map((e) => e.to);\n if (downstream.length > 0) {\n graphLines.push(`${node} → ${downstream.join(\", \")}`);\n } else {\n graphLines.push(node);\n }\n }\n\n return {\n project: config.project?.name ?? \"unknown\",\n description: config.project?.description,\n specCount: specs.length,\n byType,\n byStatus,\n specs: specSummaries,\n graph: graphLines,\n };\n}\n\nexport default defineCommand({\n meta: {\n name: \"explain\",\n description: \"[experimental] Explain the spec suite for onboarding\",\n },\n args: {\n format: { type: \"string\", description: \"Output format: pretty, json\", default: \"pretty\" },\n },\n async run({ args }) {\n try {\n const result = await runExplain({ format: args.format });\n\n if (args.format === \"json\") {\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n // Pretty format\n console.log(`\\n ${result.project}`);\n if (result.description) {\n console.log(` ${result.description}`);\n }\n console.log(\n `\\n ${result.specCount} specs: ${Object.entries(result.byType)\n .map(([k, v]) => `${v} ${k}`)\n .join(\", \")}`,\n );\n console.log(\n ` Status: ${Object.entries(result.byStatus)\n .map(([k, v]) => `${v} ${k}`)\n .join(\", \")}`,\n );\n\n console.log(\"\\n Specs:\");\n for (const spec of result.specs) {\n console.log(` ${spec.id} (${spec.type}, ${spec.status}) — ${spec.title}`);\n if (spec.firstLine) {\n console.log(` ${spec.firstLine}`);\n }\n }\n\n console.log(\"\\n Dependencies:\");\n for (const line of result.graph) {\n console.log(` ${line}`);\n }\n console.log();\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n },\n});\n"],"mappings":";;;;;;;;;;AAAA,SAAS,qBAAqB;AAc9B,eAAsB,WAAW,WAAgC,CAAC,GAA2B;AAC3F,QAAM,YAAY,QAAQ,IAAI;AAC9B,QAAM,SAAS,MAAM,WAAW,QAAW,SAAS;AAGpD,QAAM,QAAsB,CAAC;AAC7B,aAAW,CAAC,EAAE,KAAK,KAAK,OAAO,QAAQ,OAAO,KAAK,GAAG;AACpD,UAAM,QAAQ,MAAM,YAAY,MAAM,MAAM,SAAS;AACrD,eAAW,KAAK,OAAO;AACrB,YAAM,KAAK,MAAM,UAAU,CAAC,CAAC;AAAA,IAC/B;AAAA,EACF;AAGA,QAAM,SAAiC,CAAC;AACxC,QAAM,WAAmC,CAAC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;AAAA,IACd,SAAS,KAAK;AACZ,cAAQ,MAAM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;","names":[]}
package/dist/index.js CHANGED
@@ -5275,6 +5275,55 @@ async function diffBetweenRefs(configPath, baseRef, headRef, options = {}) {
5275
5275
  return { diffs, added, removed, impact, summary, uncommittedSpecFiles };
5276
5276
  }
5277
5277
 
5278
+ // src/formatters/changelog.ts
5279
+ function formatChangelog(result, baseRef, headRef) {
5280
+ const lines = [];
5281
+ lines.push(`## Spec Changes (${baseRef}..${headRef})
5282
+ `);
5283
+ if (result.diffs.length > 0) {
5284
+ lines.push("### Modified");
5285
+ for (const diff2 of result.diffs) {
5286
+ const sections = diff2.sections.map((s) => s.heading).join(", ");
5287
+ const versionChange = diff2.frontmatter.find((f) => f.field === "version");
5288
+ const versionStr = versionChange ? ` (${String(versionChange.before)} \u2192 ${String(versionChange.after)})` : "";
5289
+ lines.push(`- **${diff2.specId}**${versionStr} \u2014 ${sections || "frontmatter only"}`);
5290
+ }
5291
+ lines.push("");
5292
+ }
5293
+ if (result.added.length > 0) {
5294
+ lines.push("### Added");
5295
+ for (const id of result.added) {
5296
+ lines.push(`- **${id}**`);
5297
+ }
5298
+ lines.push("");
5299
+ }
5300
+ if (result.removed.length > 0) {
5301
+ lines.push("### Removed");
5302
+ for (const id of result.removed) {
5303
+ lines.push(`- **${id}**`);
5304
+ }
5305
+ lines.push("");
5306
+ }
5307
+ const allDownstream = result.impact.flatMap((i) => i.downstream);
5308
+ if (allDownstream.length > 0) {
5309
+ lines.push("### Downstream Impact");
5310
+ for (const d of allDownstream) {
5311
+ lines.push(`- ${d.specId} may be stale (${d.reason})`);
5312
+ }
5313
+ lines.push("");
5314
+ }
5315
+ if (result.diffs.length === 0 && result.added.length === 0 && result.removed.length === 0) {
5316
+ lines.push("No spec changes detected.\n");
5317
+ }
5318
+ if (result.uncommittedSpecFiles.length > 0) {
5319
+ lines.push(
5320
+ `> \u26A0 ${result.uncommittedSpecFiles.length} spec file(s) changed in the working tree are not covered by this range.
5321
+ `
5322
+ );
5323
+ }
5324
+ return lines.join("\n");
5325
+ }
5326
+
5278
5327
  // src/commands/diff.ts
5279
5328
  async function runDiff(options) {
5280
5329
  const configDir = process.cwd();
@@ -5304,7 +5353,7 @@ var diff_default = defineCommand4({
5304
5353
  spec: { type: "string", description: "Scope to a single spec ID" },
5305
5354
  format: {
5306
5355
  type: "string",
5307
- description: "Output format: pretty, json",
5356
+ description: "Output format: pretty, json, changelog",
5308
5357
  default: "pretty"
5309
5358
  }
5310
5359
  },
@@ -5322,6 +5371,13 @@ var diff_default = defineCommand4({
5322
5371
  console.log(JSON.stringify(result, null, 2));
5323
5372
  return;
5324
5373
  }
5374
+ if (args.format === "changelog") {
5375
+ const baseRef = args.base ?? (await loadConfig(void 0, process.cwd())).diff?.baseline_ref ?? "main";
5376
+ console.log(
5377
+ formatChangelog(result, baseRef, args.working ? "working tree" : args.head ?? "HEAD")
5378
+ );
5379
+ return;
5380
+ }
5325
5381
  const printUncommittedWarning = () => {
5326
5382
  if (result.uncommittedSpecFiles.length === 0) return;
5327
5383
  const count = result.uncommittedSpecFiles.length;
@@ -5529,87 +5585,8 @@ var status_default = defineCommand5({
5529
5585
  }
5530
5586
  });
5531
5587
 
5532
- // src/commands/changelog.ts
5533
- import { defineCommand as defineCommand6 } from "citty";
5534
- import { join as join6 } from "path";
5535
- async function runChangelog(options) {
5536
- const configDir = process.cwd();
5537
- const config = await loadConfig(void 0, configDir);
5538
- const fromRef = options.from ?? config.diff?.baseline_ref ?? DEFAULT_DIFF_CONFIG.baseline_ref;
5539
- const toRef = options.to ?? "HEAD";
5540
- const configPath = join6(configDir, "spec.config.yaml");
5541
- const result = await diffBetweenRefs(configPath, fromRef, toRef);
5542
- const lines = [];
5543
- lines.push(`## Spec Changes (${fromRef}..${toRef})
5544
- `);
5545
- if (result.diffs.length > 0) {
5546
- lines.push("### Modified");
5547
- for (const diff2 of result.diffs) {
5548
- const sections = diff2.sections.map((s) => s.heading).join(", ");
5549
- const versionChange = diff2.frontmatter.find((f) => f.field === "version");
5550
- const versionStr = versionChange ? ` (${String(versionChange.before)} \u2192 ${String(versionChange.after)})` : "";
5551
- lines.push(`- **${diff2.specId}**${versionStr} \u2014 ${sections || "frontmatter only"}`);
5552
- }
5553
- lines.push("");
5554
- }
5555
- if (result.added.length > 0) {
5556
- lines.push("### Added");
5557
- for (const id of result.added) {
5558
- lines.push(`- **${id}**`);
5559
- }
5560
- lines.push("");
5561
- }
5562
- if (result.removed.length > 0) {
5563
- lines.push("### Removed");
5564
- for (const id of result.removed) {
5565
- lines.push(`- **${id}**`);
5566
- }
5567
- lines.push("");
5568
- }
5569
- const allDownstream = result.impact.flatMap((i) => i.downstream);
5570
- if (allDownstream.length > 0) {
5571
- lines.push("### Downstream Impact");
5572
- for (const d of allDownstream) {
5573
- lines.push(`- ${d.specId} may be stale (${d.reason})`);
5574
- }
5575
- lines.push("");
5576
- }
5577
- if (result.diffs.length === 0 && result.added.length === 0 && result.removed.length === 0) {
5578
- lines.push("No spec changes detected.\n");
5579
- }
5580
- return lines.join("\n");
5581
- }
5582
- var changelog_default = defineCommand6({
5583
- meta: { name: "changelog", description: "Generate changelog of spec changes between git refs" },
5584
- args: {
5585
- from: { type: "string", description: "Start git ref (default: from config or 'main')" },
5586
- to: { type: "string", description: "End git ref (default: HEAD)" }
5587
- },
5588
- async run({ args }) {
5589
- try {
5590
- try {
5591
- const output = await runChangelog(args);
5592
- console.log(output);
5593
- } catch (err) {
5594
- if (err instanceof DiffError) {
5595
- console.error(`
5596
- \u2717 ${err.message}
5597
- `);
5598
- process.exit(1);
5599
- }
5600
- throw err;
5601
- }
5602
- } catch (err) {
5603
- console.error(`
5604
- \u2717 ${err.message}
5605
- `);
5606
- process.exit(1);
5607
- }
5608
- }
5609
- });
5610
-
5611
5588
  // src/commands/explain.ts
5612
- import { defineCommand as defineCommand7 } from "citty";
5589
+ import { defineCommand as defineCommand6 } from "citty";
5613
5590
  async function runExplain(_options = {}) {
5614
5591
  const configDir = process.cwd();
5615
5592
  const config = await loadConfig(void 0, configDir);
@@ -5660,8 +5637,11 @@ async function runExplain(_options = {}) {
5660
5637
  graph: graphLines
5661
5638
  };
5662
5639
  }
5663
- var explain_default = defineCommand7({
5664
- meta: { name: "explain", description: "Explain the spec suite for onboarding" },
5640
+ var explain_default = defineCommand6({
5641
+ meta: {
5642
+ name: "explain",
5643
+ description: "[experimental] Explain the spec suite for onboarding"
5644
+ },
5665
5645
  args: {
5666
5646
  format: { type: "string", description: "Output format: pretty, json", default: "pretty" }
5667
5647
  },
@@ -5705,7 +5685,6 @@ var explain_default = defineCommand7({
5705
5685
  }
5706
5686
  });
5707
5687
  export {
5708
- runChangelog,
5709
5688
  runDiff,
5710
5689
  runExplain,
5711
5690
  runLint,