specdx 0.4.0-alpha.9 → 0.5.0

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 (115) hide show
  1. package/.claude-plugin/plugin.json +7 -2
  2. package/README.md +283 -0
  3. package/dist/{check-4FSSC6HN.js → check-RH5SCXWW.js} +68 -30
  4. package/dist/check-RH5SCXWW.js.map +1 -0
  5. package/dist/{chunk-N77RNV7J.js → chunk-3YXRWQGX.js} +217 -42
  6. package/dist/chunk-3YXRWQGX.js.map +1 -0
  7. package/dist/chunk-5WRI5ZAA.js +31 -0
  8. package/dist/chunk-6EQIDZ4D.js +185 -0
  9. package/dist/chunk-6EQIDZ4D.js.map +1 -0
  10. package/dist/chunk-6WFNZH7F.js +2846 -0
  11. package/dist/chunk-6WFNZH7F.js.map +1 -0
  12. package/dist/{chunk-AKNPCB37.js → chunk-BMOOLUPG.js} +32 -12
  13. package/dist/chunk-BMOOLUPG.js.map +1 -0
  14. package/dist/{chunk-IHTYAW7C.js → chunk-BP3SB35W.js} +111 -7
  15. package/dist/chunk-BP3SB35W.js.map +1 -0
  16. package/dist/chunk-CQETLJTZ.js +103 -0
  17. package/dist/chunk-CQETLJTZ.js.map +1 -0
  18. package/dist/chunk-DMGABJ6T.js +41 -0
  19. package/dist/chunk-DMGABJ6T.js.map +1 -0
  20. package/dist/chunk-NHD44ZYN.js +20 -0
  21. package/dist/chunk-NHD44ZYN.js.map +1 -0
  22. package/dist/{chunk-7JXW2GTJ.js → chunk-XRWLPU24.js} +18 -2
  23. package/dist/chunk-XRWLPU24.js.map +1 -0
  24. package/dist/chunk-ZIODMXST.js +1146 -0
  25. package/dist/chunk-ZIODMXST.js.map +1 -0
  26. package/dist/diff-QO7HMAK3.js +200 -0
  27. package/dist/diff-QO7HMAK3.js.map +1 -0
  28. package/dist/{dist-4DIRTBJH.js → dist-JPWHWMV2.js} +88 -26
  29. package/dist/dist-JPWHWMV2.js.map +1 -0
  30. package/dist/{dist-RL2DT3ZE.js → dist-ROHCFKYT.js} +3 -2
  31. package/dist/dist-ROHCFKYT.js.map +1 -0
  32. package/dist/generate-MS4BM7RU.js +21 -0
  33. package/dist/generate-MS4BM7RU.js.map +1 -0
  34. package/dist/{generate-story-EFHGINHA.js → generate-story-OMM322L7.js} +43 -19
  35. package/dist/generate-story-OMM322L7.js.map +1 -0
  36. package/dist/{generate-test-plan-BO7444RG.js → generate-test-plan-75W7SZIO.js} +61 -11
  37. package/dist/generate-test-plan-75W7SZIO.js.map +1 -0
  38. package/dist/{graph-5XINV7PT.js → graph-QOTMXENE.js} +49 -11
  39. package/dist/graph-QOTMXENE.js.map +1 -0
  40. package/dist/index.d.ts +302 -0
  41. package/dist/index.js +2996 -357
  42. package/dist/index.js.map +1 -1
  43. package/dist/lint-LPFLHVO4.js +184 -0
  44. package/dist/lint-LPFLHVO4.js.map +1 -0
  45. package/dist/main.js +10 -229
  46. package/dist/main.js.map +1 -1
  47. package/dist/mcp-OEC43SPF.js +35 -0
  48. package/dist/mcp-OEC43SPF.js.map +1 -0
  49. package/dist/{migrate-4KF6GHLO.js → migrate-CBP2AVLH.js} +21 -9
  50. package/dist/migrate-CBP2AVLH.js.map +1 -0
  51. package/dist/{pack-DSOODXAN.js → pack-X6FSWORJ.js} +41 -13
  52. package/dist/pack-X6FSWORJ.js.map +1 -0
  53. package/dist/{ready-6DNKIHP6.js → ready-7MJWRGLT.js} +55 -14
  54. package/dist/ready-7MJWRGLT.js.map +1 -0
  55. package/dist/skills/{specdx-author-spec.md → core/specdx-author-spec/SKILL.md} +10 -6
  56. package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-01-frontmatter.md +1 -1
  57. package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-02-sections.md +41 -0
  58. package/dist/skills/{specdx-onboard.md → core/specdx-onboard/SKILL.md} +8 -3
  59. package/dist/skills/{specdx-plan-from-spec.md → core/specdx-plan-from-spec/SKILL.md} +5 -1
  60. package/dist/skills/{specdx-pre-commit.md → core/specdx-pre-commit/SKILL.md} +16 -2
  61. package/dist/skills/{specdx-review-spec.md → core/specdx-review-spec/SKILL.md} +5 -1
  62. package/dist/skills/core/specdx-router/SKILL.md +67 -0
  63. package/dist/skills/{specdx-sprint-review.md → core/specdx-sprint-review/SKILL.md} +6 -2
  64. package/dist/skills/{specdx-start-task.md → core/specdx-start-task/SKILL.md} +5 -1
  65. package/dist/skills/{specdx-check-drift.md → experimental/specdx-check-drift/SKILL.md} +10 -4
  66. package/dist/skills/{specdx-verify.md → experimental/specdx-verify/SKILL.md} +6 -2
  67. package/dist/skills-36SRUEMR.js +121 -0
  68. package/dist/skills-36SRUEMR.js.map +1 -0
  69. package/dist/{status-WZK247CI.js → status-UUPZYX3J.js} +63 -32
  70. package/dist/status-UUPZYX3J.js.map +1 -0
  71. package/dist/{update-JTNSYX3B.js → update-EI7IJRHG.js} +22 -12
  72. package/dist/update-EI7IJRHG.js.map +1 -0
  73. package/dist/{validate-LBDYWUDX.js → validate-HTTZLQWI.js} +36 -17
  74. package/dist/validate-HTTZLQWI.js.map +1 -0
  75. package/hooks/hooks.json +12 -6
  76. package/hooks/session-start +35 -3
  77. package/package.json +28 -13
  78. package/dist/changelog-XUVHY3QK.js +0 -93
  79. package/dist/changelog-XUVHY3QK.js.map +0 -1
  80. package/dist/check-4FSSC6HN.js.map +0 -1
  81. package/dist/chunk-7JXW2GTJ.js.map +0 -1
  82. package/dist/chunk-AKNPCB37.js.map +0 -1
  83. package/dist/chunk-DAZCOUVK.js +0 -496
  84. package/dist/chunk-DAZCOUVK.js.map +0 -1
  85. package/dist/chunk-GAM4MXPC.js +0 -15
  86. package/dist/chunk-GAM4MXPC.js.map +0 -1
  87. package/dist/chunk-IHTYAW7C.js.map +0 -1
  88. package/dist/chunk-N77RNV7J.js.map +0 -1
  89. package/dist/chunk-SRZ33RJP.js +0 -1147
  90. package/dist/chunk-SRZ33RJP.js.map +0 -1
  91. package/dist/diff-OXZ34NU4.js +0 -107
  92. package/dist/diff-OXZ34NU4.js.map +0 -1
  93. package/dist/dist-4DIRTBJH.js.map +0 -1
  94. package/dist/explain-QBV3AESQ.js +0 -109
  95. package/dist/explain-QBV3AESQ.js.map +0 -1
  96. package/dist/generate-7GNPT2WJ.js +0 -13
  97. package/dist/generate-7GNPT2WJ.js.map +0 -1
  98. package/dist/generate-story-EFHGINHA.js.map +0 -1
  99. package/dist/generate-test-plan-BO7444RG.js.map +0 -1
  100. package/dist/graph-5XINV7PT.js.map +0 -1
  101. package/dist/lint-PTMWMLDQ.js +0 -122
  102. package/dist/lint-PTMWMLDQ.js.map +0 -1
  103. package/dist/mcp-BGFAPM6G.js +0 -17
  104. package/dist/mcp-BGFAPM6G.js.map +0 -1
  105. package/dist/migrate-4KF6GHLO.js.map +0 -1
  106. package/dist/pack-DSOODXAN.js.map +0 -1
  107. package/dist/ready-6DNKIHP6.js.map +0 -1
  108. package/dist/skills-3GBBWZW2.js +0 -93
  109. package/dist/skills-3GBBWZW2.js.map +0 -1
  110. package/dist/status-WZK247CI.js.map +0 -1
  111. package/dist/update-JTNSYX3B.js.map +0 -1
  112. package/dist/validate-LBDYWUDX.js.map +0 -1
  113. /package/dist/{dist-RL2DT3ZE.js.map → chunk-5WRI5ZAA.js.map} +0 -0
  114. /package/dist/skills/{spec-type-reference.md → core/specdx-author-spec/references/spec-type-reference.md} +0 -0
  115. /package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-03-finalize.md +0 -0
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: specdx-check-drift
3
- description: "[experimental — built on sdx check, whose static analysis can be noisy] Use when the user says 'check drift', 'did I drift from spec', 'am I still aligned', or as part of a pre-commit check. Compares recent code changes against spec definitions."
4
- allowed-tools: Bash(npx specdx *), Read
3
+ description: "[experimental — built on specdx check, whose static analysis can be noisy] Use when the user says 'check drift', 'did I drift from spec', 'am I still aligned', or as part of a pre-commit check. Compares recent code changes against spec definitions."
4
+ allowed-tools: Bash(npx specdx:*) Read
5
5
  ---
6
6
 
7
7
  # Check Spec Drift
@@ -13,10 +13,12 @@ Compare recent code changes against spec definitions to detect drift.
13
13
  ### Step 1: Check for spec changes
14
14
 
15
15
  ```bash
16
- npx specdx diff
16
+ npx specdx diff --working
17
17
  ```
18
18
 
19
- This shows which specs changed since the last commit. Note any upstream spec changes.
19
+ This shows which specs changed, including edits still in the working tree. Note any upstream spec changes.
20
+
21
+ Use `--working` here. Plain `npx specdx diff` compares committed refs only, so it cannot see uncommitted spec edits — the ones most likely to have caused the drift you are looking for.
20
22
 
21
23
  ### Step 2: Check implementation alignment
22
24
 
@@ -69,3 +71,7 @@ For each drift:
69
71
  | "No specs changed, so no drift" | Code can drift even when specs don't change. Run the check. |
70
72
  | "The check score is high enough" | Even 95% means 5% drift. Review the findings. |
71
73
  | "I'll check drift later" | Drift compounds. Check now. |
74
+
75
+ ## It's working if
76
+
77
+ You can say, for each finding, whether the code or the spec should change. A list of findings with no direction is a report, not a drift check.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: specdx-verify
3
- description: "[experimental — built on sdx check, whose static analysis can be noisy] Use when the user says 'verify', 'check against spec', 'does this match the spec', 'review implementation', or after completing a feature. Runs spec-to-implementation analysis and reviews findings."
4
- allowed-tools: Bash(npx specdx *), Read
3
+ description: "[experimental — built on specdx check, whose static analysis can be noisy] Use when the user says 'verify', 'check against spec', 'does this match the spec', 'review implementation', or after completing a feature. Runs spec-to-implementation analysis and reviews findings."
4
+ allowed-tools: Bash(npx specdx:*) Read
5
5
  ---
6
6
 
7
7
  # Verify Implementation Against Specs
@@ -79,3 +79,7 @@ Do NOT skip Step 1. Always run `npx specdx check` before reviewing. Do not rely
79
79
  | "There are too many findings to review" | Group by category, prioritize errors over warnings. Review all errors. |
80
80
  | "The check failed, so skip it" | Report the failure. Partial results are still valuable. |
81
81
  | "The user didn't ask for verification" | If you just finished implementing, verify. It's part of the job. |
82
+
83
+ ## It's working if
84
+
85
+ Every error-level finding is either resolved or consciously accepted with a reason. Warnings from prose-heavy test plans are expected noise — say so rather than treating the score as a grade.
@@ -0,0 +1,121 @@
1
+ import "./chunk-5WRI5ZAA.js";
2
+
3
+ // src/commands/core/skills.ts
4
+ import { defineCommand } from "citty";
5
+
6
+ // ../skills/dist/install.js
7
+ import { mkdir, writeFile, readFile, stat, readdir } from "fs/promises";
8
+ import { statSync } from "fs";
9
+ import { join, dirname, relative } from "path";
10
+ import { fileURLToPath } from "url";
11
+ var __dirname = dirname(fileURLToPath(import.meta.url));
12
+ var CORE_SKILL_NAMES = [
13
+ "specdx-router",
14
+ "specdx-start-task",
15
+ "specdx-author-spec",
16
+ "specdx-pre-commit",
17
+ "specdx-sprint-review",
18
+ "specdx-plan-from-spec",
19
+ "specdx-onboard",
20
+ "specdx-review-spec"
21
+ ];
22
+ var EXPERIMENTAL_SKILL_NAMES = ["specdx-verify", "specdx-check-drift"];
23
+ var SKILL_NAMES = [...CORE_SKILL_NAMES, ...EXPERIMENTAL_SKILL_NAMES];
24
+ function bucketOf(skillName) {
25
+ return EXPERIMENTAL_SKILL_NAMES.includes(skillName) ? "experimental" : "core";
26
+ }
27
+ function getSkillSourceDir() {
28
+ const bundledPath = join(__dirname, "skills");
29
+ try {
30
+ statSync(bundledPath);
31
+ return bundledPath;
32
+ } catch {
33
+ return join(__dirname, "..", "skills");
34
+ }
35
+ }
36
+ async function filesUnder(dir, base = dir) {
37
+ const entries = await readdir(dir, { withFileTypes: true });
38
+ const files = [];
39
+ for (const entry of entries) {
40
+ const full = join(dir, entry.name);
41
+ if (entry.isDirectory()) {
42
+ files.push(...await filesUnder(full, base));
43
+ } else {
44
+ files.push(relative(base, full));
45
+ }
46
+ }
47
+ return files;
48
+ }
49
+ async function installSkills(projectDir, options = {}) {
50
+ const sourceDir = getSkillSourceDir();
51
+ const skillsDir = join(projectDir, ".claude", "skills");
52
+ const installed = [];
53
+ const updated = [];
54
+ await mkdir(skillsDir, { recursive: true });
55
+ const names = options.experimental ? SKILL_NAMES : CORE_SKILL_NAMES;
56
+ for (const skillName of names) {
57
+ const sourcePath = join(sourceDir, bucketOf(skillName), skillName);
58
+ const targetPath = join(skillsDir, skillName);
59
+ let exists = false;
60
+ try {
61
+ await stat(join(targetPath, "SKILL.md"));
62
+ exists = true;
63
+ } catch {
64
+ }
65
+ for (const file of await filesUnder(sourcePath)) {
66
+ const target = join(targetPath, file);
67
+ await mkdir(dirname(target), { recursive: true });
68
+ await writeFile(target, await readFile(join(sourcePath, file), "utf-8"), "utf-8");
69
+ }
70
+ if (exists) {
71
+ updated.push(skillName);
72
+ } else {
73
+ installed.push(skillName);
74
+ }
75
+ }
76
+ return { installed, updated };
77
+ }
78
+
79
+ // src/commands/core/skills.ts
80
+ var skills_default = defineCommand({
81
+ meta: { name: "skills", description: "Manage specdx skills for AI coding tools" },
82
+ subCommands: {
83
+ install: defineCommand({
84
+ meta: { name: "install", description: "Install Claude Code skill files" },
85
+ args: {
86
+ dir: {
87
+ type: "string",
88
+ description: "Target directory (default: current directory)",
89
+ default: "."
90
+ },
91
+ experimental: {
92
+ type: "boolean",
93
+ description: "Also install experimental skills (built on the experimental check command)",
94
+ default: false
95
+ }
96
+ },
97
+ async run({ args }) {
98
+ try {
99
+ const result = await installSkills(args.dir, { experimental: args.experimental });
100
+ if (result.installed.length === 0 && result.updated.length === 0) {
101
+ console.log(" No skill files to install.");
102
+ return;
103
+ }
104
+ for (const file of result.installed) console.log(` \u2713 Installed ${file}`);
105
+ for (const file of result.updated) console.log(` \u2713 Updated ${file}`);
106
+ console.log(`
107
+ Skills installed to .claude/skills/`);
108
+ } catch (err) {
109
+ console.error(`
110
+ \u2717 ${err.message}
111
+ `);
112
+ process.exit(1);
113
+ }
114
+ }
115
+ })
116
+ }
117
+ });
118
+ export {
119
+ skills_default as default
120
+ };
121
+ //# sourceMappingURL=skills-36SRUEMR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/core/skills.ts","../../skills/src/install.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { installSkills } from \"@specdx/skills\";\n\nexport default defineCommand({\n meta: { name: \"skills\", description: \"Manage specdx skills for AI coding tools\" },\n subCommands: {\n install: defineCommand({\n meta: { name: \"install\", description: \"Install Claude Code skill files\" },\n args: {\n dir: {\n type: \"string\",\n description: \"Target directory (default: current directory)\",\n default: \".\",\n },\n experimental: {\n type: \"boolean\",\n description: \"Also install experimental skills (built on the experimental check command)\",\n default: false,\n },\n },\n async run({ args }) {\n try {\n const result = await installSkills(args.dir, { experimental: args.experimental });\n if (result.installed.length === 0 && result.updated.length === 0) {\n console.log(\" No skill files to install.\");\n return;\n }\n for (const file of result.installed) console.log(` ✓ Installed ${file}`);\n for (const file of result.updated) console.log(` ✓ Updated ${file}`);\n console.log(`\\n Skills installed to .claude/skills/`);\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n },\n }),\n },\n});\n","import { mkdir, writeFile, readFile, stat, readdir } from \"node:fs/promises\";\nimport { statSync } from \"node:fs\";\nimport { join, dirname, relative } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\n/**\n * Promoted skills — the set the Claude Code plugin ships and `skills install`\n * writes by default.\n *\n * Promotion is the directory a skill lives in, not an adjective in its\n * description. A string is easy to drift past; a folder is not.\n */\nexport const CORE_SKILL_NAMES = [\n \"specdx-router\",\n \"specdx-start-task\",\n \"specdx-author-spec\",\n \"specdx-pre-commit\",\n \"specdx-sprint-review\",\n \"specdx-plan-from-spec\",\n \"specdx-onboard\",\n \"specdx-review-spec\",\n];\n\n/** Skills built on `specdx check`, whose static analysis is noisy on prose specs. */\nexport const EXPERIMENTAL_SKILL_NAMES = [\"specdx-verify\", \"specdx-check-drift\"];\n\n/** Every skill that ships, promoted or not. */\nexport const SKILL_NAMES = [...CORE_SKILL_NAMES, ...EXPERIMENTAL_SKILL_NAMES];\n\n/** Bucket directory a skill lives in, under the skills root. */\nexport function bucketOf(skillName: string): \"core\" | \"experimental\" {\n return EXPERIMENTAL_SKILL_NAMES.includes(skillName) ? \"experimental\" : \"core\";\n}\n\nexport interface InstallResult {\n installed: string[];\n updated: string[];\n}\n\nfunction getSkillSourceDir(): string {\n // When bundled: skills at __dirname/skills (sibling of bundle)\n // In dev: skills at __dirname/../skills (sibling of src/)\n const bundledPath = join(__dirname, \"skills\");\n try {\n statSync(bundledPath);\n return bundledPath;\n } catch {\n return join(__dirname, \"..\", \"skills\");\n }\n}\n\n/** Every file under a directory, as paths relative to it. */\nasync function filesUnder(dir: string, base = dir): Promise<string[]> {\n const entries = await readdir(dir, { withFileTypes: true });\n const files: string[] = [];\n for (const entry of entries) {\n const full = join(dir, entry.name);\n if (entry.isDirectory()) {\n files.push(...(await filesUnder(full, base)));\n } else {\n files.push(relative(base, full));\n }\n }\n return files;\n}\n\n/**\n * Install skills into a project's `.claude/skills/`.\n *\n * The Agent Skills specification defines a skill as a *directory* containing a\n * `SKILL.md`, so the whole directory is copied -- `references/` and any other\n * bundled resources included. Skills previously shipped as flat files under\n * `.claude/commands/`, which made them slash commands rather than skills.\n */\nexport interface InstallOptions {\n /** Include experimental skills. Off by default: only promoted skills ship. */\n experimental?: boolean;\n}\n\nexport async function installSkills(\n projectDir: string,\n options: InstallOptions = {},\n): Promise<InstallResult> {\n const sourceDir = getSkillSourceDir();\n const skillsDir = join(projectDir, \".claude\", \"skills\");\n const installed: string[] = [];\n const updated: string[] = [];\n\n await mkdir(skillsDir, { recursive: true });\n\n const names = options.experimental ? SKILL_NAMES : CORE_SKILL_NAMES;\n\n for (const skillName of names) {\n const sourcePath = join(sourceDir, bucketOf(skillName), skillName);\n const targetPath = join(skillsDir, skillName);\n\n let exists = false;\n try {\n await stat(join(targetPath, \"SKILL.md\"));\n exists = true;\n } catch {\n // Not installed yet\n }\n\n for (const file of await filesUnder(sourcePath)) {\n const target = join(targetPath, file);\n await mkdir(dirname(target), { recursive: true });\n await writeFile(target, await readFile(join(sourcePath, file), \"utf-8\"), \"utf-8\");\n }\n\n if (exists) {\n updated.push(skillName);\n } else {\n installed.push(skillName);\n }\n }\n\n return { installed, updated };\n}\n"],"mappings":";;;AAAA,SAAS,qBAAqB;;;ACA9B,SAAS,OAAO,WAAW,UAAU,MAAM,eAAe;AAC1D,SAAS,gBAAgB;AACzB,SAAS,MAAM,SAAS,gBAAgB;AACxC,SAAS,qBAAqB;AAE9B,IAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AASjD,IAAM,mBAAmB;EAC9B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAIK,IAAM,2BAA2B,CAAC,iBAAiB,oBAAoB;AAGvE,IAAM,cAAc,CAAC,GAAG,kBAAkB,GAAG,wBAAwB;AAGtE,SAAU,SAAS,WAAiB;AACxC,SAAO,yBAAyB,SAAS,SAAS,IAAI,iBAAiB;AACzE;AAOA,SAAS,oBAAiB;AAGxB,QAAM,cAAc,KAAK,WAAW,QAAQ;AAC5C,MAAI;AACF,aAAS,WAAW;AACpB,WAAO;EACT,QAAQ;AACN,WAAO,KAAK,WAAW,MAAM,QAAQ;EACvC;AACF;AAGA,eAAe,WAAW,KAAa,OAAO,KAAG;AAC/C,QAAM,UAAU,MAAM,QAAQ,KAAK,EAAE,eAAe,KAAI,CAAE;AAC1D,QAAM,QAAkB,CAAA;AACxB,aAAW,SAAS,SAAS;AAC3B,UAAM,OAAO,KAAK,KAAK,MAAM,IAAI;AACjC,QAAI,MAAM,YAAW,GAAI;AACvB,YAAM,KAAK,GAAI,MAAM,WAAW,MAAM,IAAI,CAAE;IAC9C,OAAO;AACL,YAAM,KAAK,SAAS,MAAM,IAAI,CAAC;IACjC;EACF;AACA,SAAO;AACT;AAeA,eAAsB,cACpB,YACA,UAA0B,CAAA,GAAE;AAE5B,QAAM,YAAY,kBAAiB;AACnC,QAAM,YAAY,KAAK,YAAY,WAAW,QAAQ;AACtD,QAAM,YAAsB,CAAA;AAC5B,QAAM,UAAoB,CAAA;AAE1B,QAAM,M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AAA,UACF;AACA,qBAAW,QAAQ,OAAO,UAAW,SAAQ,IAAI,sBAAiB,IAAI,EAAE;AACxE,qBAAW,QAAQ,OAAO,QAAS,SAAQ,IAAI,oBAAe,IAAI,EAAE;AACpE,kBAAQ,IAAI;AAAA,sCAAyC;AAAA,QACvD,SAAS,KAAK;AACZ,kBAAQ,MAAM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,kBAAQ,KAAK,CAAC;AAAA,QAChB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF,CAAC;","names":[]}
@@ -1,22 +1,31 @@
1
1
  import {
2
2
  createLintEngine,
3
- getPreset
4
- } from "./chunk-DAZCOUVK.js";
3
+ resolveLintConfig
4
+ } from "./chunk-ZIODMXST.js";
5
5
  import {
6
6
  DEFAULT_DIFF_CONFIG
7
- } from "./chunk-SRZ33RJP.js";
7
+ } from "./chunk-6WFNZH7F.js";
8
+ import {
9
+ createOutput
10
+ } from "./chunk-NHD44ZYN.js";
11
+ import {
12
+ resolveFormat,
13
+ sharedArgs
14
+ } from "./chunk-DMGABJ6T.js";
8
15
  import {
9
16
  buildGraph,
10
17
  loadConfig,
11
18
  parseSpec,
12
19
  resolveGlob
13
- } from "./chunk-IHTYAW7C.js";
14
- import "./chunk-7JXW2GTJ.js";
20
+ } from "./chunk-BP3SB35W.js";
21
+ import "./chunk-XRWLPU24.js";
22
+ import "./chunk-5WRI5ZAA.js";
15
23
 
16
- // src/commands/status.ts
24
+ // src/commands/core/status.ts
17
25
  import { defineCommand } from "citty";
18
- async function runStatus(_options = {}) {
19
- const configDir = process.cwd();
26
+ var FORMATS = ["pretty", "json", "github"];
27
+ async function runStatus(options = {}) {
28
+ const configDir = options.configDir ?? process.cwd();
20
29
  const config = await loadConfig(void 0, configDir);
21
30
  const specs = [];
22
31
  for (const [, entry] of Object.entries(config.specs)) {
@@ -32,7 +41,11 @@ async function runStatus(_options = {}) {
32
41
  byStatus[status] = (byStatus[status] ?? 0) + 1;
33
42
  }
34
43
  const presetName = config.lint?.extends ?? "recommended";
35
- const rules = getPreset(presetName);
44
+ const { rules, ignore } = await resolveLintConfig({
45
+ config,
46
+ preset: presetName,
47
+ configDir
48
+ });
36
49
  let graph;
37
50
  let graphError;
38
51
  try {
@@ -40,7 +53,7 @@ async function runStatus(_options = {}) {
40
53
  } catch (err) {
41
54
  graphError = err.message;
42
55
  }
43
- const engine = createLintEngine({ rules, config, graph });
56
+ const engine = createLintEngine({ rules, config, graph, ignore });
44
57
  const lintResults = engine.lint(specs.map((s) => s.spec));
45
58
  if (graphError) {
46
59
  lintResults.diagnostics.push({
@@ -53,6 +66,10 @@ async function runStatus(_options = {}) {
53
66
  }
54
67
  const errors = lintResults.diagnostics.filter((d) => d.severity === "error").length;
55
68
  const warnings = lintResults.diagnostics.filter((d) => d.severity === "warn").length;
69
+ const specsWithErrors = new Set(
70
+ lintResults.diagnostics.filter((d) => d.severity === "error").map((d) => d.filePath)
71
+ );
72
+ const passing = specs.filter(({ spec }) => !specsWithErrors.has(spec.filePath)).length;
56
73
  const thresholdDays = config.diff?.staleness_threshold_days ?? DEFAULT_DIFF_CONFIG.staleness_threshold_days;
57
74
  const now = Date.now();
58
75
  const staleSpecs = [];
@@ -87,9 +104,9 @@ async function runStatus(_options = {}) {
87
104
  else if (specs.length === 0) verdict = "unassessed";
88
105
  return {
89
106
  project: config.project?.name ?? "unknown",
90
- specCount: specs.length,
107
+ specFiles: specs.length,
91
108
  byStatus,
92
- lintHealth: { errors, warnings, passing: specs.length - errors },
109
+ lintHealth: { errors, warnings, passing },
93
110
  staleSpecs,
94
111
  integrityIssues,
95
112
  verdict
@@ -97,21 +114,32 @@ async function runStatus(_options = {}) {
97
114
  }
98
115
  var status_default = defineCommand({
99
116
  meta: { name: "status", description: "Show spec suite health overview" },
100
- args: {
101
- format: {
102
- type: "string",
103
- description: "Output format: pretty, json, github",
104
- default: "pretty"
105
- }
106
- },
117
+ args: { ...sharedArgs(FORMATS) },
107
118
  async run({ args }) {
119
+ const format = resolveFormat(args.format, FORMATS);
120
+ if (!format.ok) {
121
+ console.error(`
122
+ \u2717 ${format.message}
123
+ `);
124
+ process.exit(1);
125
+ }
126
+ const output = createOutput({ quiet: args.quiet });
108
127
  try {
109
- const result = await runStatus({ format: args.format });
110
- if (args.format === "json") {
128
+ const result = await runStatus();
129
+ if (format.format === "json") {
111
130
  console.log(JSON.stringify(result, null, 2));
112
131
  return;
113
132
  }
114
- if (args.format === "github") {
133
+ if (format.format === "github") {
134
+ const level = result.verdict === "errors" ? "error" : result.verdict === "healthy" ? "notice" : "warning";
135
+ console.log(
136
+ `::${level}::specdx status \u2014 ${result.project} \u2014 ${result.verdict}: ${result.specFiles} spec file(s), ${result.lintHealth.errors} error(s), ${result.lintHealth.warnings} warning(s)`
137
+ );
138
+ if (result.verdict === "unassessed") {
139
+ console.log(
140
+ "::warning::No specs resolved \u2014 nothing was assessed. Check the spec paths in spec.config.yaml."
141
+ );
142
+ }
115
143
  for (const s of result.staleSpecs) {
116
144
  console.log(
117
145
  `::warning::Spec "${s.specId}" is stale (${s.daysSinceUpdate} days since update)`
@@ -123,28 +151,31 @@ var status_default = defineCommand({
123
151
  return;
124
152
  }
125
153
  const icon = result.verdict === "healthy" ? "\u2713" : result.verdict === "warnings" || result.verdict === "unassessed" ? "\u26A0" : "\u2717";
126
- console.log(`
127
- ${icon} ${result.project} \u2014 ${result.verdict}`);
154
+ const healthy = result.verdict === "healthy";
155
+ const headline = `
156
+ ${icon} ${result.project} \u2014 ${result.verdict}`;
157
+ if (healthy) output.info(headline);
158
+ else output.out(headline);
128
159
  if (result.verdict === "unassessed") {
129
- console.log(
160
+ output.out(
130
161
  " No specs resolved \u2014 nothing was assessed. Check the spec paths in spec.config.yaml."
131
162
  );
132
163
  }
133
- console.log(
134
- ` ${result.specCount} specs: ${Object.entries(result.byStatus).map(([k, v]) => `${v} ${k}`).join(", ")}`
164
+ output.info(
165
+ ` ${result.specFiles} specs: ${Object.entries(result.byStatus).map(([k, v]) => `${v} ${k}`).join(", ")}`
135
166
  );
136
- console.log(
167
+ output.info(
137
168
  ` Lint: ${result.lintHealth.errors} errors, ${result.lintHealth.warnings} warnings`
138
169
  );
139
170
  if (result.staleSpecs.length > 0) {
140
- console.log(
171
+ output.out(
141
172
  ` Stale: ${result.staleSpecs.map((s) => `${s.specId} (${s.daysSinceUpdate}d)`).join(", ")}`
142
173
  );
143
174
  }
144
175
  if (result.integrityIssues.length > 0) {
145
- console.log(` Issues: ${result.integrityIssues.join("; ")}`);
176
+ output.out(` Issues: ${result.integrityIssues.join("; ")}`);
146
177
  }
147
- console.log();
178
+ output.info();
148
179
  } catch (err) {
149
180
  console.error(`
150
181
  \u2717 ${err.message}
@@ -157,4 +188,4 @@ export {
157
188
  status_default as default,
158
189
  runStatus
159
190
  };
160
- //# sourceMappingURL=status-WZK247CI.js.map
191
+ //# sourceMappingURL=status-UUPZYX3J.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/core/status.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, buildGraph, resolveGlob } from \"@specdx/core\";\nimport { createLintEngine, resolveLintConfig } from \"@specdx/lint\";\nimport { DEFAULT_DIFF_CONFIG } from \"@specdx/diff\";\nimport type { StatusResult } from \"@specdx/diff\";\nimport type { ParsedSpec } from \"@specdx/core\";\nimport { sharedArgs, resolveFormat } from \"../../shared-args.js\";\nimport { createOutput } from \"../../output.js\";\n\nconst FORMATS = [\"pretty\", \"json\", \"github\"] as const;\n\nexport interface RunStatusOptions {\n /**\n * Directory holding spec.config.yaml. Defaults to the process cwd, which is\n * right for the CLI and useless to a library consumer — `runLint` and\n * `runPack` take one, so this does too (audit run 5, F8).\n */\n configDir?: string;\n}\n\nexport async function runStatus(options: RunStatusOptions = {}): Promise<StatusResult> {\n const configDir = options.configDir ?? process.cwd();\n const config = await loadConfig(undefined, configDir);\n\n // Resolve and parse all specs\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 // Count by status\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 // Lint health\n const presetName = config.lint?.extends ?? \"recommended\";\n const { rules, ignore } = await resolveLintConfig({\n config,\n preset: presetName,\n configDir,\n });\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, ignore });\n const lintResults = engine.lint(specs.map((s) => s.spec));\n\n if (graphError) {\n lintResults.diagnostics.push({\n ruleId: \"structure/no-circular-deps\",\n severity: \"error\",\n message: graphError,\n filePath: \"spec.config.yaml\",\n });\n lintResults.hasErrors = true;\n }\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 // Specs carrying no error-severity diagnostic.\n //\n // This was `specs.length - errors`, which subtracts a diagnostic count from a\n // spec count -- one spec with seven errors reported `passing: -6`. The units\n // only agree when `errors` is 0, which is every suite the fixtures use\n // (audit run 6, G2).\n const specsWithErrors = new Set(\n lintResults.diagnostics.filter((d) => d.severity === \"error\").map((d) => d.filePath),\n );\n const passing = specs.filter(({ spec }) => !specsWithErrors.has(spec.filePath)).length;\n\n // Staleness\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 daysSinceUpdate = Math.floor(\n (now - new Date(dateStr).getTime()) / (1000 * 60 * 60 * 24),\n );\n if (daysSinceUpdate > thresholdDays) {\n staleSpecs.push({\n specId: spec.frontmatter.id as string,\n daysSinceUpdate,\n owner: entry.owner,\n });\n }\n }\n }\n\n // Integrity issues\n const integrityIssues: string[] = [];\n if (graphError) {\n integrityIssues.push(graphError);\n }\n const refErrors = lintResults.diagnostics.filter(\n (d) => d.ruleId === \"structure/valid-references\",\n );\n for (const d of refErrors) {\n integrityIssues.push(d.message);\n }\n\n // Verdict — an empty suite is unassessed, never a vacuous \"healthy\"\n let verdict: StatusResult[\"verdict\"] = \"healthy\";\n if (errors > 0) verdict = \"errors\";\n else if (warnings > 0 || staleSpecs.length > 0) verdict = \"warnings\";\n else if (specs.length === 0) verdict = \"unassessed\";\n\n return {\n project: config.project?.name ?? \"unknown\",\n specFiles: specs.length,\n byStatus,\n lintHealth: { errors, warnings, passing },\n staleSpecs,\n integrityIssues,\n verdict,\n };\n}\n\nexport default defineCommand({\n meta: { name: \"status\", description: \"Show spec suite health overview\" },\n args: { ...sharedArgs(FORMATS) },\n async run({ args }) {\n const format = resolveFormat(args.format, FORMATS);\n if (!format.ok) {\n console.error(`\\n ✗ ${format.message}\\n`);\n process.exit(1);\n }\n const output = createOutput({ quiet: args.quiet });\n\n try {\n const result = await runStatus();\n\n if (format.format === \"json\") {\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n if (format.format === \"github\") {\n // A headline always, at the level the verdict reports.\n //\n // This block used to render stale specs and integrity issues and\n // nothing else, so a suite whose only problem was lint errors emitted\n // zero bytes and exited 0 -- a workflow step showing nothing, on a run\n // whose own JSON said `verdict: \"errors\"` (audit run 6, G1). `check`\n // was given a headline for exactly this reason; status renders the same\n // format and was left able to say nothing at all.\n //\n // The level tracks the pretty renderer's icon so the two renderers of\n // one command cannot disagree. Lint diagnostics are deliberately not\n // re-annotated here -- `lint --format github` owns those, and a\n // workflow running both should not get each one twice.\n const level =\n result.verdict === \"errors\"\n ? \"error\"\n : result.verdict === \"healthy\"\n ? \"notice\"\n : \"warning\";\n console.log(\n `::${level}::specdx status — ${result.project} — ${result.verdict}: ` +\n `${result.specFiles} spec file(s), ${result.lintHealth.errors} error(s), ` +\n `${result.lintHealth.warnings} warning(s)`,\n );\n if (result.verdict === \"unassessed\") {\n console.log(\n \"::warning::No specs resolved — nothing was assessed. Check the spec paths in spec.config.yaml.\",\n );\n }\n for (const s of result.staleSpecs) {\n console.log(\n `::warning::Spec \"${s.specId}\" is stale (${s.daysSinceUpdate} days since update)`,\n );\n }\n for (const issue of result.integrityIssues) {\n console.log(`::error::${issue}`);\n }\n return;\n }\n\n // Pretty format\n const icon =\n result.verdict === \"healthy\"\n ? \"✓\"\n : result.verdict === \"warnings\" || result.verdict === \"unassessed\"\n ? \"⚠\"\n : \"✗\";\n const healthy = result.verdict === \"healthy\";\n const headline = `\\n ${icon} ${result.project} — ${result.verdict}`;\n if (healthy) output.info(headline);\n else output.out(headline);\n\n if (result.verdict === \"unassessed\") {\n output.out(\n \" No specs resolved — nothing was assessed. Check the spec paths in spec.config.yaml.\",\n );\n }\n output.info(\n ` ${result.specFiles} specs: ${Object.entries(result.byStatus)\n .map(([k, v]) => `${v} ${k}`)\n .join(\", \")}`,\n );\n output.info(\n ` Lint: ${result.lintHealth.errors} errors, ${result.lintHealth.warnings} warnings`,\n );\n\n if (result.staleSpecs.length > 0) {\n output.out(\n ` Stale: ${result.staleSpecs.map((s) => `${s.specId} (${s.daysSinceUpdate}d)`).join(\", \")}`,\n );\n }\n if (result.integrityIssues.length > 0) {\n output.out(` Issues: ${result.integrityIssues.join(\"; \")}`);\n }\n output.info();\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAS9B,IAAM,UAAU,CAAC,UAAU,QAAQ,QAAQ;AAW3C,eAAsB,UAAU,UAA4B,CAAC,GAA0B;AACrF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AAA,IAAO,IAAI,IAAI,OAAO,OAAO,WAAM,OAAO,OAAO;AAClE,UAAI,QAAS,QAAO,KAAK,QAAQ;AAAA,UAC5B,QAAO,IAAI,QAAQ;AAExB,UAAI,OAAO,YAAY,cAAc;AACnC,eAAO;AAAA,UACL;AAAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,QACL,OAAO,OAAO,SAAS,WAAW,OAAO,QAAQ,OAAO,QAAQ,EAC7D,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,EAAE,EAC3B,KAAK,IAAI,CAAC;AAAA,MACf;AACA,aAAO;AAAA,QACL,aAAa,OAAO,WAAW,MAAM,YAAY,OAAO,WAAW,QAAQ;AAAA,MAC7E;AAEA,UAAI,OAAO,WAAW,SAAS,GAAG;AAChC,eAAO;AAAA,UACL,cAAc,OAAO,WAAW,IAAI,CAAC,MAAM,GAAG,EAAE,MAAM,KAAK,EAAE,eAAe,IAAI,EAAE,KAAK,IAAI,CAAC;AAAA,QAC9F;AAAA,MACF;AACA,UAAI,OAAO,gBAAgB,SAAS,GAAG;AACrC,eAAO,IAAI,eAAe,OAAO,gBAAgB,KAAK,IAAI,CAAC,EAAE;AAAA,MAC/D;AACA,aAAO,KAAK;AAAA,IACd,SAAS,KAAK;AACZ,cAAQ,MAAM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;","names":[]}
@@ -1,19 +1,22 @@
1
1
  import {
2
2
  runCheck
3
- } from "./chunk-N77RNV7J.js";
3
+ } from "./chunk-3YXRWQGX.js";
4
4
  import {
5
+ resolveFormat,
5
6
  sharedArgs
6
- } from "./chunk-GAM4MXPC.js";
7
+ } from "./chunk-DMGABJ6T.js";
7
8
  import {
8
9
  createLogger,
9
10
  loadConfig,
10
11
  parseSpec,
11
12
  resolveGlob
12
- } from "./chunk-IHTYAW7C.js";
13
- import "./chunk-7JXW2GTJ.js";
13
+ } from "./chunk-BP3SB35W.js";
14
+ import "./chunk-XRWLPU24.js";
15
+ import "./chunk-5WRI5ZAA.js";
14
16
 
15
- // src/commands/update.ts
17
+ // src/commands/experimental/update.ts
16
18
  import { defineCommand } from "citty";
19
+ var FORMATS = ["pretty", "json"];
17
20
  function buildRouteAddition(actual) {
18
21
  const parts = actual.trim().split(/\s+/);
19
22
  const method = parts[0] ?? "GET";
@@ -59,11 +62,11 @@ function generateUpdates({ findings }) {
59
62
  }
60
63
  function printSuggestionsPretty(suggestions) {
61
64
  if (suggestions.length === 0) {
62
- console.log("\n sdx update \u2014 no spec updates suggested\n");
65
+ console.log("\n specdx update \u2014 no spec updates suggested\n");
63
66
  return;
64
67
  }
65
68
  console.log(`
66
- sdx update \u2014 ${suggestions.length} suggested spec update(s)
69
+ specdx update \u2014 ${suggestions.length} suggested spec update(s)
67
70
  `);
68
71
  const bySpec = /* @__PURE__ */ new Map();
69
72
  for (const s of suggestions) {
@@ -85,19 +88,26 @@ function printSuggestionsPretty(suggestions) {
85
88
  var update_default = defineCommand({
86
89
  meta: {
87
90
  name: "update",
88
- description: "[experimental] Suggest spec updates based on sdx check findings (--from-code)"
91
+ description: "Suggest spec updates based on specdx check findings (--from-code)"
89
92
  },
90
93
  args: {
91
- ...sharedArgs,
94
+ ...sharedArgs(FORMATS),
92
95
  "from-code": {
93
96
  type: "boolean",
94
- description: "Generate suggestions from code drift (sdx check findings)",
97
+ description: "Generate suggestions from code drift (specdx check findings)",
95
98
  default: true
96
99
  },
97
100
  spec: { type: "string", description: "Limit to a specific spec ID" },
98
101
  framework: { type: "string", description: "Framework override: express, hono, nextjs" }
99
102
  },
100
103
  async run({ args }) {
104
+ const format = resolveFormat(args.format, FORMATS);
105
+ if (!format.ok) {
106
+ console.error(`
107
+ \u2717 ${format.message}
108
+ `);
109
+ process.exit(1);
110
+ }
101
111
  const logger = createLogger({ quiet: args.quiet, verbose: args.verbose });
102
112
  const configDir = process.cwd();
103
113
  const config = await loadConfig(void 0, configDir);
@@ -118,7 +128,7 @@ var update_default = defineCommand({
118
128
  };
119
129
  const checkResult = await runCheck(specs, configDir, checkConfig);
120
130
  const { suggestions } = generateUpdates({ findings: checkResult.findings });
121
- if (args.format === "json") {
131
+ if (format.format === "json") {
122
132
  console.log(JSON.stringify({ suggestions }, null, 2));
123
133
  } else {
124
134
  printSuggestionsPretty(suggestions);
@@ -129,4 +139,4 @@ export {
129
139
  update_default as default,
130
140
  generateUpdates
131
141
  };
132
- //# sourceMappingURL=update-JTNSYX3B.js.map
142
+ //# sourceMappingURL=update-EI7IJRHG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/experimental/update.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, resolveGlob, createLogger } from \"@specdx/core\";\nimport { runCheck } from \"@specdx/check\";\nimport type { Finding } from \"@specdx/check\";\nimport type { ParsedSpec } from \"@specdx/core\";\nimport { sharedArgs, resolveFormat } from \"../../shared-args.js\";\n\nconst FORMATS = [\"pretty\", \"json\"] as const;\n\nexport interface UpdateSuggestion {\n specId: string;\n section: string;\n addition: string;\n reason: string;\n}\n\nexport interface GenerateUpdatesInput {\n findings: Finding[];\n}\n\nexport interface GenerateUpdatesResult {\n suggestions: UpdateSuggestion[];\n}\n\nfunction buildRouteAddition(actual: string): string {\n const parts = actual.trim().split(/\\s+/);\n const method = parts[0] ?? \"GET\";\n const path = parts[1] ?? actual;\n return `### ${method} ${path}\\nDescription placeholder.`;\n}\n\nfunction buildTypeAddition(actual: string): string {\n return `- ${actual}`;\n}\n\nfunction buildTestAddition(actual: string): string {\n return `- ${actual}`;\n}\n\nexport function generateUpdates({ findings }: GenerateUpdatesInput): GenerateUpdatesResult {\n const suggestions: UpdateSuggestion[] = [];\n\n for (const finding of findings) {\n // Only act on extra findings — code has something the spec doesn't know about.\n // missing = code is wrong, spec is correct → skip.\n // mismatch = ambiguous → skip for now, let the user decide.\n if (finding.type !== \"extra\") continue;\n\n const actual = finding.actual ?? \"\";\n\n if (finding.category === \"route\") {\n suggestions.push({\n specId: finding.specId,\n section: \"Endpoints\",\n addition: buildRouteAddition(actual),\n reason: `Route ${actual} exists in code but is not documented in the spec.`,\n });\n } else if (finding.category === \"type\") {\n suggestions.push({\n specId: finding.specId,\n section: \"Data Model\",\n addition: buildTypeAddition(actual),\n reason: `${actual} exists in code but is not documented in the spec.`,\n });\n } else if (finding.category === \"test\") {\n suggestions.push({\n specId: finding.specId,\n section: \"Test Cases\",\n addition: buildTestAddition(actual),\n reason: `Test case \"${actual}\" exists in code but is not listed in the spec.`,\n });\n }\n }\n\n return { suggestions };\n}\n\nfunction printSuggestionsPretty(suggestions: UpdateSuggestion[]): void {\n if (suggestions.length === 0) {\n console.log(\"\\n specdx update — no spec updates suggested\\n\");\n return;\n }\n\n console.log(`\\n specdx update — ${suggestions.length} suggested spec update(s)\\n`);\n\n // Group by specId\n const bySpec = new Map<string, UpdateSuggestion[]>();\n for (const s of suggestions) {\n const list = bySpec.get(s.specId) ?? [];\n list.push(s);\n bySpec.set(s.specId, list);\n }\n\n for (const [specId, items] of bySpec) {\n console.log(` ${specId}:`);\n for (const item of items) {\n console.log(` [${item.section}] ${item.reason}`);\n console.log(` Add:\\n ${item.addition.replace(/\\n/g, \"\\n \")}`);\n }\n console.log();\n }\n\n console.log(\" Note: --apply is not implemented in v1. Apply changes manually.\\n\");\n}\n\nexport default defineCommand({\n meta: {\n name: \"update\",\n description: \"Suggest spec updates based on specdx check findings (--from-code)\",\n },\n args: {\n ...sharedArgs(FORMATS),\n \"from-code\": {\n type: \"boolean\",\n description: \"Generate suggestions from code drift (specdx check findings)\",\n default: true,\n },\n spec: { type: \"string\", description: \"Limit to a specific spec ID\" },\n framework: { type: \"string\", description: \"Framework override: express, hono, nextjs\" },\n },\n async run({ args }) {\n const format = resolveFormat(args.format, FORMATS);\n if (!format.ok) {\n console.error(`\\n ✗ ${format.message}\\n`);\n process.exit(1);\n }\n\n const logger = createLogger({ quiet: args.quiet, verbose: args.verbose });\n const configDir = process.cwd();\n const config = await loadConfig(undefined, configDir);\n\n logger.debug(\"Loading specs...\");\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 (args.spec && spec.frontmatter.id !== args.spec) continue;\n specs.push(spec);\n }\n }\n\n logger.debug(`Running check on ${specs.length} specs...`);\n\n const checkConfig = {\n ...config.check,\n ...(args.framework\n ? { framework: args.framework as \"auto\" | \"express\" | \"hono\" | \"nextjs\" }\n : {}),\n };\n\n const checkResult = await runCheck(specs, configDir, checkConfig);\n const { suggestions } = generateUpdates({ findings: checkResult.findings });\n\n if (format.format === \"json\") {\n console.log(JSON.stringify({ suggestions }, null, 2));\n } else {\n printSuggestionsPretty(suggestions);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAO9B,IAAM,UAAU,CAAC,UAAU,MAAM;AAiBjC,SAAS,mBAAmB,QAAwB;AAClD,QAAM,QAAQ,OAAO,KAAK,EAAE,MAAM,KAAK;AACvC,QAAM,SAAS,MAAM,CAAC,KAAK;AAC3B,QAAM,OAAO,MAAM,CAAC,KAAK;AACzB,SAAO,OAAO,MAAM,IAAI,IAAI;AAAA;AAC9B;AAEA,SAAS,kBAAkB,QAAwB;AACjD,SAAO,KAAK,MAAM;AACpB;AAEA,SAAS,kBAAkB,QAAwB;AACjD,SAAO,KAAK,MAAM;AACpB;AAEO,SAAS,gBAAgB,EAAE,SAAS,GAAgD;AACzF,QAAM,cAAkC,CAAC;AAEzC,aAAW,WAAW,UAAU;AAI9B,QAAI,QAAQ,SAAS,QAAS;AAE9B,UAAM,SAAS,QAAQ,UAAU;AAEjC,QAAI,QAAQ,aAAa,SAAS;AAChC,kBAAY,KAAK;AAAA,QACf,QAAQ,QAAQ;AAAA,QAChB,SAAS;AAAA,QACT,UAAU,mBAAmB,MAAM;A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;AAC5B,cAAQ,IAAI,KAAK,UAAU,EAAE,YAAY,GAAG,MAAM,CAAC,CAAC;AAAA,IACtD,OAAO;AACL,6BAAuB,WAAW;AAAA,IACpC;AAAA,EACF;AACF,CAAC;","names":[]}
@@ -1,27 +1,33 @@
1
1
  import {
2
+ createOutput
3
+ } from "./chunk-NHD44ZYN.js";
4
+ import {
5
+ resolveFormat,
2
6
  sharedArgs
3
- } from "./chunk-GAM4MXPC.js";
7
+ } from "./chunk-DMGABJ6T.js";
4
8
  import {
5
9
  ConfigError,
6
10
  GraphError,
7
11
  buildGraph,
8
12
  loadConfig,
9
13
  resolveGlob
10
- } from "./chunk-IHTYAW7C.js";
11
- import "./chunk-7JXW2GTJ.js";
14
+ } from "./chunk-BP3SB35W.js";
15
+ import "./chunk-XRWLPU24.js";
16
+ import "./chunk-5WRI5ZAA.js";
12
17
 
13
- // src/commands/validate.ts
18
+ // src/commands/core/validate.ts
14
19
  import { defineCommand } from "citty";
20
+ var FORMATS = ["pretty", "json"];
15
21
  async function runValidate(configDir) {
16
22
  const warnings = [];
17
23
  try {
18
24
  const config = await loadConfig(void 0, configDir);
19
25
  buildGraph(config);
20
- let specFileCount = 0;
26
+ let specFiles = 0;
21
27
  const missingRequired = [];
22
28
  for (const [key, entry] of Object.entries(config.specs)) {
23
29
  const files = await resolveGlob(entry.path, configDir);
24
- specFileCount += files.length;
30
+ specFiles += files.length;
25
31
  if (files.length > 0) continue;
26
32
  if (entry.required) {
27
33
  missingRequired.push(`"${key}" (${entry.path})`);
@@ -32,21 +38,21 @@ async function runValidate(configDir) {
32
38
  if (missingRequired.length > 0) {
33
39
  return {
34
40
  valid: false,
35
- specCount: Object.keys(config.specs).length,
36
- specFileCount,
41
+ specEntries: Object.keys(config.specs).length,
42
+ specFiles,
37
43
  warnings,
38
44
  error: `required spec entry resolves to no files: ${missingRequired.join(", ")}`
39
45
  };
40
46
  }
41
- if (specFileCount === 0) {
47
+ if (specFiles === 0) {
42
48
  warnings.push(
43
49
  "no spec files found \u2014 every downstream check (lint, status, ready) would pass vacuously"
44
50
  );
45
51
  }
46
52
  return {
47
53
  valid: true,
48
- specCount: Object.keys(config.specs).length,
49
- specFileCount,
54
+ specEntries: Object.keys(config.specs).length,
55
+ specFiles,
50
56
  warnings
51
57
  };
52
58
  } catch (err) {
@@ -61,14 +67,27 @@ async function runValidate(configDir) {
61
67
  }
62
68
  var validate_default = defineCommand({
63
69
  meta: { name: "validate", description: "Validate spec.config.yaml" },
64
- args: { ...sharedArgs },
65
- async run() {
70
+ args: { ...sharedArgs(FORMATS) },
71
+ async run({ args }) {
72
+ const format = resolveFormat(args.format, FORMATS);
73
+ if (!format.ok) {
74
+ console.error(`
75
+ \u2717 ${format.message}
76
+ `);
77
+ process.exit(1);
78
+ }
79
+ const output = createOutput({ quiet: args.quiet });
66
80
  const result = await runValidate(process.cwd());
81
+ if (format.format === "json") {
82
+ console.log(JSON.stringify(result, null, 2));
83
+ if (!result.valid) process.exit(1);
84
+ return;
85
+ }
67
86
  if (result.valid) {
68
- console.log(
69
- ` \u2713 Config valid. ${result.specCount} spec entries, ${result.specFileCount} spec files.`
87
+ output.info(
88
+ ` \u2713 Config valid. ${result.specEntries} spec entries, ${result.specFiles} spec files.`
70
89
  );
71
- for (const w of result.warnings) console.log(` \u26A0 ${w}`);
90
+ for (const w of result.warnings) output.out(` \u26A0 ${w}`);
72
91
  return;
73
92
  }
74
93
  console.error(` \u2717 Config invalid: ${result.error}`);
@@ -83,4 +102,4 @@ export {
83
102
  validate_default as default,
84
103
  runValidate
85
104
  };
86
- //# sourceMappingURL=validate-LBDYWUDX.js.map
105
+ //# sourceMappingURL=validate-HTTZLQWI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/core/validate.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, buildGraph, resolveGlob, ConfigError, GraphError } from \"@specdx/core\";\nimport { sharedArgs, resolveFormat } from \"../../shared-args.js\";\nimport { createOutput } from \"../../output.js\";\n\nconst FORMATS = [\"pretty\", \"json\"] as const;\n\nexport interface ValidateResult {\n valid: boolean;\n /** Number of spec entries declared in the config. */\n specEntries?: number;\n /** Number of spec files those entries actually resolve to. */\n specFiles?: number;\n /** Non-fatal honesty notes: entries resolving to nothing, empty suite. */\n warnings: string[];\n error?: string;\n details?: unknown[];\n}\n\n/**\n * Validate spec.config.yaml: a schema-valid config, a buildable dependency\n * graph (issue #13), and declared spec paths that actually resolve. An entry\n * that matches no files makes every downstream verdict vacuous, so it is\n * reported here rather than silently flowing into lint/status/ready.\n */\nexport async function runValidate(configDir: string): Promise<ValidateResult> {\n const warnings: string[] = [];\n try {\n const config = await loadConfig(undefined, configDir);\n buildGraph(config);\n\n let specFiles = 0;\n const missingRequired: string[] = [];\n for (const [key, entry] of Object.entries(config.specs)) {\n const files = await resolveGlob(entry.path, configDir);\n specFiles += files.length;\n if (files.length > 0) continue;\n\n if ((entry as { required?: boolean }).required) {\n missingRequired.push(`\"${key}\" (${entry.path})`);\n } else {\n warnings.push(`spec entry \"${key}\" resolves to no files: ${entry.path}`);\n }\n }\n\n if (missingRequired.length > 0) {\n return {\n valid: false,\n specEntries: Object.keys(config.specs).length,\n specFiles,\n warnings,\n error: `required spec entry resolves to no files: ${missingRequired.join(\", \")}`,\n };\n }\n\n if (specFiles === 0) {\n warnings.push(\n \"no spec files found — every downstream check (lint, status, ready) would pass vacuously\",\n );\n }\n\n return {\n valid: true,\n specEntries: Object.keys(config.specs).length,\n specFiles,\n warnings,\n };\n } catch (err) {\n if (err instanceof ConfigError) {\n return { valid: false, warnings, error: err.message, details: err.errors ?? undefined };\n }\n if (err instanceof GraphError) {\n return { valid: false, warnings, error: err.message };\n }\n throw err;\n }\n}\n\nexport default defineCommand({\n meta: { name: \"validate\", description: \"Validate spec.config.yaml\" },\n args: { ...sharedArgs(FORMATS) },\n async run({ args }) {\n const format = resolveFormat(args.format, FORMATS);\n if (!format.ok) {\n console.error(`\\n ✗ ${format.message}\\n`);\n process.exit(1);\n }\n const output = createOutput({ quiet: args.quiet });\n\n const result = await runValidate(process.cwd());\n\n if (format.format === \"json\") {\n console.log(JSON.stringify(result, null, 2));\n if (!result.valid) process.exit(1);\n return;\n }\n\n if (result.valid) {\n output.info(\n ` ✓ Config valid. ${result.specEntries} spec entries, ${result.specFiles} spec files.`,\n );\n for (const w of result.warnings) output.out(` ⚠ ${w}`);\n return;\n }\n\n console.error(` ✗ Config invalid: ${result.error}`);\n for (const w of result.warnings) console.error(` ⚠ ${w}`);\n if (result.details) {\n for (const e of result.details) console.error(` - ${JSON.stringify(e)}`);\n }\n process.exit(1);\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAK9B,IAAM,UAAU,CAAC,UAAU,MAAM;AAoBjC,eAAsB,YAAY,WAA4C;AAC5E,QAAM,WAAqB,CAAC;AAC5B,MAAI;AACF,UAAM,SAAS,MAAM,WAAW,QAAW,SAAS;AACpD,eAAW,MAAM;AAEjB,QAAI,YAAY;AAChB,UAAM,kBAA4B,CAAC;AACnC,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,KAAK,GAAG;AACvD,YAAM,QAAQ,MAAM,YAAY,MAAM,MAAM,SAAS;AACrD,mBAAa,MAAM;AACnB,UAAI,MAAM,SAAS,EAAG;AAEtB,UAAK,MAAiC,UAAU;AAC9C,wBAAgB,KAAK,IAAI,GAAG,MAAM,MAAM,IAAI,GAAG;AAAA,MACjD,OAAO;AACL,iBAAS,KAAK,eAAe,GAAG,2BAA2B,MAAM,IAAI,EAAE;AAAA,MACzE;AAAA,IACF;AAEA,QAAI,gBAAgB,SAAS,GAAG;AAC9B,aAAO;AAAA,QACL,OAAO;AAAA,QACP,aAAa,OAAO,KAAK,OAAO,KAAK,EAAE;AAAA,QACvC;AAAA,QACA;AAAA,QACA,OAAO,6CAA6C,gBAAgB,KAAK,IAAI,CAAC;AAAA,MAChF;AAAA,IACF;AAEA,QAAI,cAAc,GAAG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ACnD,eAAW,KAAK,OAAO,SAAU,SAAQ,MAAM,YAAO,CAAC,EAAE;AACzD,QAAI,OAAO,SAAS;AAClB,iBAAW,KAAK,OAAO,QAAS,SAAQ,MAAM,SAAS,KAAK,UAAU,CAAC,CAAC,EAAE;AAAA,IAC5E;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;","names":[]}
package/hooks/hooks.json CHANGED
@@ -1,8 +1,14 @@
1
1
  {
2
- "hooks": [
3
- {
4
- "event": "SessionStart",
5
- "command": "./hooks/session-start"
6
- }
7
- ]
2
+ "hooks": {
3
+ "SessionStart": [
4
+ {
5
+ "hooks": [
6
+ {
7
+ "type": "command",
8
+ "command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start"
9
+ }
10
+ ]
11
+ }
12
+ ]
13
+ }
8
14
  }