specdx 0.2.0-alpha.3 → 0.3.0-alpha.2

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 (54) hide show
  1. package/.claude-plugin/plugin.json +6 -0
  2. package/dist/changelog-URU2TFNM.js +86 -0
  3. package/dist/changelog-URU2TFNM.js.map +1 -0
  4. package/dist/{chunk-JLK2NNAF.js → chunk-276J7LR6.js} +12 -16
  5. package/dist/chunk-276J7LR6.js.map +1 -0
  6. package/dist/{lint-V42NAO3U.js → chunk-ATLVRGHI.js} +6 -102
  7. package/dist/chunk-ATLVRGHI.js.map +1 -0
  8. package/dist/chunk-GAM4MXPC.js +15 -0
  9. package/dist/chunk-GAM4MXPC.js.map +1 -0
  10. package/dist/chunk-LU6M5O63.js +1147 -0
  11. package/dist/chunk-LU6M5O63.js.map +1 -0
  12. package/dist/{chunk-CV2CHFFG.js → chunk-XLEN6ZYM.js} +29 -5
  13. package/dist/chunk-XLEN6ZYM.js.map +1 -0
  14. package/dist/diff-55PTEVB3.js +100 -0
  15. package/dist/diff-55PTEVB3.js.map +1 -0
  16. package/dist/explain-YXUILNEA.js +102 -0
  17. package/dist/explain-YXUILNEA.js.map +1 -0
  18. package/dist/{graph-G3ILOAV6.js → graph-OWQJWVSN.js} +7 -5
  19. package/dist/{graph-G3ILOAV6.js.map → graph-OWQJWVSN.js.map} +1 -1
  20. package/dist/index.js +1552 -6
  21. package/dist/index.js.map +1 -1
  22. package/dist/lint-U7VLGS75.js +111 -0
  23. package/dist/lint-U7VLGS75.js.map +1 -0
  24. package/dist/main.js +11 -6
  25. package/dist/main.js.map +1 -1
  26. package/dist/{pack-RWWFJSPV.js → pack-OJAC7JF2.js} +7 -5
  27. package/dist/{pack-RWWFJSPV.js.map → pack-OJAC7JF2.js.map} +1 -1
  28. package/dist/ready-3OIF4QHM.js +159 -0
  29. package/dist/ready-3OIF4QHM.js.map +1 -0
  30. package/dist/skills/spec-type-reference.md +57 -0
  31. package/dist/skills/specdx-author-spec/step-01-frontmatter.md +66 -0
  32. package/dist/skills/specdx-author-spec/step-02-sections.md +70 -0
  33. package/dist/skills/specdx-author-spec/step-03-finalize.md +48 -0
  34. package/dist/skills/specdx-author-spec.md +29 -0
  35. package/dist/skills/specdx-onboard.md +49 -0
  36. package/dist/skills/specdx-plan-from-spec.md +72 -0
  37. package/dist/skills/specdx-pre-commit.md +56 -0
  38. package/dist/skills/specdx-sprint-review.md +69 -0
  39. package/dist/skills/{specdx-start-task/SKILL.md → specdx-start-task.md} +1 -1
  40. package/dist/{skills-5XHJEKA2.js → skills-XJYTWGDK.js} +15 -9
  41. package/dist/skills-XJYTWGDK.js.map +1 -0
  42. package/dist/status-LYZUO6AJ.js +145 -0
  43. package/dist/status-LYZUO6AJ.js.map +1 -0
  44. package/dist/{validate-XZWUCAWU.js → validate-DOZZEZFC.js} +7 -5
  45. package/dist/{validate-XZWUCAWU.js.map → validate-DOZZEZFC.js.map} +1 -1
  46. package/hooks/hooks.json +8 -0
  47. package/hooks/run-hook.cmd +46 -0
  48. package/hooks/session-start +77 -0
  49. package/package.json +5 -2
  50. package/dist/chunk-CV2CHFFG.js.map +0 -1
  51. package/dist/chunk-JLK2NNAF.js.map +0 -1
  52. package/dist/lint-V42NAO3U.js.map +0 -1
  53. package/dist/skills/specdx-author-spec/SKILL.md +0 -115
  54. package/dist/skills-5XHJEKA2.js.map +0 -1
@@ -0,0 +1,145 @@
1
+ import {
2
+ createLintEngine,
3
+ getPreset
4
+ } from "./chunk-ATLVRGHI.js";
5
+ import {
6
+ DEFAULT_DIFF_CONFIG
7
+ } from "./chunk-LU6M5O63.js";
8
+ import {
9
+ buildGraph,
10
+ loadConfig,
11
+ parseSpec,
12
+ resolveGlob
13
+ } from "./chunk-276J7LR6.js";
14
+ import "./chunk-XLEN6ZYM.js";
15
+
16
+ // src/commands/status.ts
17
+ import { defineCommand } from "citty";
18
+ async function runStatus(_options = {}) {
19
+ const configDir = process.cwd();
20
+ const config = await loadConfig(void 0, configDir);
21
+ const specs = [];
22
+ for (const [, entry] of Object.entries(config.specs)) {
23
+ const paths = await resolveGlob(entry.path, configDir);
24
+ for (const p of paths) {
25
+ const spec = await parseSpec(p);
26
+ specs.push({ spec, entry });
27
+ }
28
+ }
29
+ const byStatus = {};
30
+ for (const { spec } of specs) {
31
+ const status = spec.frontmatter.status || "unknown";
32
+ byStatus[status] = (byStatus[status] ?? 0) + 1;
33
+ }
34
+ const presetName = config.lint?.extends ?? "recommended";
35
+ const rules = getPreset(presetName);
36
+ let graph;
37
+ let graphError;
38
+ try {
39
+ graph = buildGraph(config);
40
+ } catch (err) {
41
+ graphError = err.message;
42
+ }
43
+ const engine = createLintEngine({ rules, config, graph });
44
+ const lintResults = engine.lint(specs.map((s) => s.spec));
45
+ if (graphError) {
46
+ lintResults.diagnostics.push({
47
+ ruleId: "structure/no-circular-deps",
48
+ severity: "error",
49
+ message: graphError,
50
+ filePath: "spec.config.yaml"
51
+ });
52
+ lintResults.hasErrors = true;
53
+ }
54
+ const errors = lintResults.diagnostics.filter((d) => d.severity === "error").length;
55
+ const warnings = lintResults.diagnostics.filter((d) => d.severity === "warn").length;
56
+ const thresholdDays = config.diff?.staleness_threshold_days ?? DEFAULT_DIFF_CONFIG.staleness_threshold_days;
57
+ const now = Date.now();
58
+ const staleSpecs = [];
59
+ for (const { spec, entry } of specs) {
60
+ const dateStr = spec.frontmatter.updated || spec.frontmatter.created;
61
+ if (dateStr) {
62
+ const daysSinceUpdate = Math.floor(
63
+ (now - new Date(dateStr).getTime()) / (1e3 * 60 * 60 * 24)
64
+ );
65
+ if (daysSinceUpdate > thresholdDays) {
66
+ staleSpecs.push({
67
+ specId: spec.frontmatter.id,
68
+ daysSinceUpdate,
69
+ owner: entry.owner
70
+ });
71
+ }
72
+ }
73
+ }
74
+ const integrityIssues = [];
75
+ if (graphError) {
76
+ integrityIssues.push(graphError);
77
+ }
78
+ const refErrors = lintResults.diagnostics.filter(
79
+ (d) => d.ruleId === "structure/valid-references"
80
+ );
81
+ for (const d of refErrors) {
82
+ integrityIssues.push(d.message);
83
+ }
84
+ let verdict = "healthy";
85
+ if (errors > 0) verdict = "errors";
86
+ else if (warnings > 0 || staleSpecs.length > 0) verdict = "warnings";
87
+ return {
88
+ project: config.project?.name ?? "unknown",
89
+ specCount: specs.length,
90
+ byStatus,
91
+ lintHealth: { errors, warnings, passing: specs.length - errors },
92
+ staleSpecs,
93
+ integrityIssues,
94
+ verdict
95
+ };
96
+ }
97
+ var status_default = defineCommand({
98
+ meta: { name: "status", description: "Show spec suite health overview" },
99
+ args: {
100
+ format: {
101
+ type: "string",
102
+ description: "Output format: pretty, json, github",
103
+ default: "pretty"
104
+ }
105
+ },
106
+ async run({ args }) {
107
+ const result = await runStatus({ format: args.format });
108
+ if (args.format === "json") {
109
+ console.log(JSON.stringify(result, null, 2));
110
+ return;
111
+ }
112
+ if (args.format === "github") {
113
+ for (const s of result.staleSpecs) {
114
+ console.log(
115
+ `::warning::Spec "${s.specId}" is stale (${s.daysSinceUpdate} days since update)`
116
+ );
117
+ }
118
+ for (const issue of result.integrityIssues) {
119
+ console.log(`::error::${issue}`);
120
+ }
121
+ return;
122
+ }
123
+ const icon = result.verdict === "healthy" ? "\u2713" : result.verdict === "warnings" ? "\u26A0" : "\u2717";
124
+ console.log(`
125
+ ${icon} ${result.project} \u2014 ${result.verdict}`);
126
+ console.log(
127
+ ` ${result.specCount} specs: ${Object.entries(result.byStatus).map(([k, v]) => `${v} ${k}`).join(", ")}`
128
+ );
129
+ console.log(` Lint: ${result.lintHealth.errors} errors, ${result.lintHealth.warnings} warnings`);
130
+ if (result.staleSpecs.length > 0) {
131
+ console.log(
132
+ ` Stale: ${result.staleSpecs.map((s) => `${s.specId} (${s.daysSinceUpdate}d)`).join(", ")}`
133
+ );
134
+ }
135
+ if (result.integrityIssues.length > 0) {
136
+ console.log(` Issues: ${result.integrityIssues.join("; ")}`);
137
+ }
138
+ console.log();
139
+ }
140
+ });
141
+ export {
142
+ status_default as default,
143
+ runStatus
144
+ };
145
+ //# sourceMappingURL=status-LYZUO6AJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/status.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, buildGraph, resolveGlob } from \"@specdx/core\";\nimport { createLintEngine, getPreset } from \"@specdx/lint\";\nimport { DEFAULT_DIFF_CONFIG } from \"@specdx/diff\";\nimport type { StatusResult } from \"@specdx/diff\";\nimport type { ParsedSpec } from \"@specdx/core\";\n\nexport async function runStatus(_options: { format?: string } = {}): Promise<StatusResult> {\n const 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 = 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 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 // 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\n let verdict: \"healthy\" | \"warnings\" | \"errors\" = \"healthy\";\n if (errors > 0) verdict = \"errors\";\n else if (warnings > 0 || staleSpecs.length > 0) verdict = \"warnings\";\n\n return {\n project: config.project?.name ?? \"unknown\",\n specCount: specs.length,\n byStatus,\n lintHealth: { errors, warnings, passing: specs.length - errors },\n staleSpecs,\n integrityIssues,\n verdict,\n };\n}\n\nexport default defineCommand({\n meta: { name: \"status\", description: \"Show spec suite health overview\" },\n args: {\n format: {\n type: \"string\",\n description: \"Output format: pretty, json, github\",\n default: \"pretty\",\n },\n },\n async run({ args }) {\n const result = await runStatus({ format: args.format });\n\n if (args.format === \"json\") {\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n if (args.format === \"github\") {\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 = result.verdict === \"healthy\" ? \"✓\" : result.verdict === \"warnings\" ? \"⚠\" : \"✗\";\n console.log(`\\n ${icon} ${result.project} — ${result.verdict}`);\n console.log(\n ` ${result.specCount} specs: ${Object.entries(result.byStatus)\n .map(([k, v]) => `${v} ${k}`)\n .join(\", \")}`,\n );\n console.log(` Lint: ${result.lintHealth.errors} errors, ${result.lintHealth.warnings} warnings`);\n\n if (result.staleSpecs.length > 0) {\n console.log(\n ` Stale: ${result.staleSpecs.map((s) => `${s.specId} (${s.daysSinceUpdate}d)`).join(\", \")}`,\n );\n }\n if (result.integrityIssues.length > 0) {\n console.log(` Issues: ${result.integrityIssues.join(\"; \")}`);\n }\n console.log();\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAO9B,eAAsB,UAAU,WAAgC,CAAC,GAA0B;AACzF,QAAM,YAAY,QAAQ,IAAI;AAC9B,QAAM,SAAS,MAAM,WAAW,QAAW,SAAS;AAGpD,QAAM,QAAyE,CAAC;AAChF,aAAW,CAAC,EAAE,KAAK,KAAK,OAAO,QAAQ,OAAO,KAAK,GAAG;AACpD,UAAM,QAAQ,MAAM,YAAY,MAAM,MAAM,SAAS;AACrD,eAAW,KAAK,OAAO;AACrB,YAAM,OAAO,MAAM,UAAU,CAAC;AAC9B,YAAM,KAAK,EAAE,MAAM,MAAiD,CAAC;AAAA,IACvE;AAAA,EACF;AAGA,QAAM,WAAmC,CAAC;AAC1C,aAAW,EAAE,KAAK,KAAK,OAAO;AAC5B,UAAM,SAAU,KAAK,YAAY,UAAqB;AACtD,aAAS,MAAM,KAAK,SAAS,MAAM,KAAK,KAAK;AAAA,EAC/C;AAGA,QAAM,aAAa,OAAO,MAAM,WAAW;AAC3C,QAAM,QAAQ,UAAU,UAAU;AAElC,MAAI;AACJ,MAAI;AACJ,MAAI;AACF,YAAQ,WAAW,MAAM;AAAA,EAC3B,SAAS,KAAK;AACZ,iBAAc,IAAc;AAAA,EAC9B;AAEA,QAAM,SAAS,iBAAiB,EAAE,OAAO,QAAQ,MAAM,CAAC;AACxD,QAAM,cAAc,OAAO,KAAK,MAAM,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;AAExD,MAAI,Y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M,KAAK,EAAE,eAAe,IAAI,EAAE,KAAK,IAAI,CAAC;AAAA,MAC9F;AAAA,IACF;AACA,QAAI,OAAO,gBAAgB,SAAS,GAAG;AACrC,cAAQ,IAAI,eAAe,OAAO,gBAAgB,KAAK,IAAI,CAAC,EAAE;AAAA,IAChE;AACA,YAAQ,IAAI;AAAA,EACd;AACF,CAAC;","names":[]}
@@ -1,9 +1,11 @@
1
1
  import {
2
- ConfigError,
3
- loadConfig,
4
2
  sharedArgs
5
- } from "./chunk-JLK2NNAF.js";
6
- import "./chunk-CV2CHFFG.js";
3
+ } from "./chunk-GAM4MXPC.js";
4
+ import {
5
+ ConfigError,
6
+ loadConfig
7
+ } from "./chunk-276J7LR6.js";
8
+ import "./chunk-XLEN6ZYM.js";
7
9
 
8
10
  // src/commands/validate.ts
9
11
  import { defineCommand } from "citty";
@@ -29,4 +31,4 @@ var validate_default = defineCommand({
29
31
  export {
30
32
  validate_default as default
31
33
  };
32
- //# sourceMappingURL=validate-XZWUCAWU.js.map
34
+ //# sourceMappingURL=validate-DOZZEZFC.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/commands/validate.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, ConfigError } from \"@specdx/core\";\nimport { sharedArgs } from \"../shared-args.js\";\n\nexport default defineCommand({\n meta: { name: \"validate\", description: \"Validate spec.config.yaml\" },\n args: { ...sharedArgs },\n async run() {\n try {\n const config = await loadConfig(undefined, process.cwd());\n console.log(` ✓ Config valid. ${Object.keys(config.specs).length} specs defined.`);\n } catch (err) {\n if (err instanceof ConfigError) {\n console.error(` ✗ Config invalid: ${err.message}`);\n if (err.errors) {\n for (const e of err.errors) console.error(` - ${JSON.stringify(e)}`);\n }\n process.exit(1);\n }\n throw err;\n }\n },\n});\n"],"mappings":";;;;;;;;AAAA,SAAS,qBAAqB;AAI9B,IAAO,mBAAQ,cAAc;AAAA,EAC3B,MAAM,EAAE,MAAM,YAAY,aAAa,4BAA4B;AAAA,EACnE,MAAM,EAAE,GAAG,WAAW;AAAA,EACtB,MAAM,MAAM;AACV,QAAI;AACF,YAAM,SAAS,MAAM,WAAW,QAAW,QAAQ,IAAI,CAAC;AACxD,cAAQ,IAAI,0BAAqB,OAAO,KAAK,OAAO,KAAK,EAAE,MAAM,iBAAiB;AAAA,IACpF,SAAS,KAAK;AACZ,UAAI,eAAe,aAAa;AAC9B,gBAAQ,MAAM,4BAAuB,IAAI,OAAO,EAAE;AAClD,YAAI,IAAI,QAAQ;AACd,qBAAW,KAAK,IAAI,OAAQ,SAAQ,MAAM,SAAS,KAAK,UAAU,CAAC,CAAC,EAAE;AAAA,QACxE;AACA,gBAAQ,KAAK,CAAC;AAAA,MAChB;AACA,YAAM;AAAA,IACR;AAAA,EACF;AACF,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/commands/validate.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, ConfigError } from \"@specdx/core\";\nimport { sharedArgs } from \"../shared-args.js\";\n\nexport default defineCommand({\n meta: { name: \"validate\", description: \"Validate spec.config.yaml\" },\n args: { ...sharedArgs },\n async run() {\n try {\n const config = await loadConfig(undefined, process.cwd());\n console.log(` ✓ Config valid. ${Object.keys(config.specs).length} specs defined.`);\n } catch (err) {\n if (err instanceof ConfigError) {\n console.error(` ✗ Config invalid: ${err.message}`);\n if (err.errors) {\n for (const e of err.errors) console.error(` - ${JSON.stringify(e)}`);\n }\n process.exit(1);\n }\n throw err;\n }\n },\n});\n"],"mappings":";;;;;;;;;;AAAA,SAAS,qBAAqB;AAI9B,IAAO,mBAAQ,cAAc;AAAA,EAC3B,MAAM,EAAE,MAAM,YAAY,aAAa,4BAA4B;AAAA,EACnE,MAAM,EAAE,GAAG,WAAW;AAAA,EACtB,MAAM,MAAM;AACV,QAAI;AACF,YAAM,SAAS,MAAM,WAAW,QAAW,QAAQ,IAAI,CAAC;AACxD,cAAQ,IAAI,0BAAqB,OAAO,KAAK,OAAO,KAAK,EAAE,MAAM,iBAAiB;AAAA,IACpF,SAAS,KAAK;AACZ,UAAI,eAAe,aAAa;AAC9B,gBAAQ,MAAM,4BAAuB,IAAI,OAAO,EAAE;AAClD,YAAI,IAAI,QAAQ;AACd,qBAAW,KAAK,IAAI,OAAQ,SAAQ,MAAM,SAAS,KAAK,UAAU,CAAC,CAAC,EAAE;AAAA,QACxE;AACA,gBAAQ,KAAK,CAAC;AAAA,MAChB;AACA,YAAM;AAAA,IACR;AAAA,EACF;AACF,CAAC;","names":[]}
@@ -0,0 +1,8 @@
1
+ {
2
+ "hooks": [
3
+ {
4
+ "event": "SessionStart",
5
+ "command": "./hooks/session-start"
6
+ }
7
+ ]
8
+ }
@@ -0,0 +1,46 @@
1
+ : << 'CMDBLOCK'
2
+ @echo off
3
+ REM Cross-platform polyglot wrapper for hook scripts.
4
+ REM On Windows: cmd.exe runs the batch portion, which finds and calls bash.
5
+ REM On Unix: the shell interprets this as a script (: is a no-op in bash).
6
+ REM
7
+ REM Hook scripts use extensionless filenames (e.g. "session-start" not
8
+ REM "session-start.sh") so Claude Code's Windows auto-detection -- which
9
+ REM prepends "bash" to any command containing .sh -- doesn't interfere.
10
+ REM
11
+ REM Usage: run-hook.cmd <script-name> [args...]
12
+
13
+ if "%~1"=="" (
14
+ echo run-hook.cmd: missing script name >&2
15
+ exit /b 1
16
+ )
17
+
18
+ set "HOOK_DIR=%~dp0"
19
+
20
+ REM Try Git for Windows bash in standard locations
21
+ if exist "C:\Program Files\Git\bin\bash.exe" (
22
+ "C:\Program Files\Git\bin\bash.exe" "%HOOK_DIR%%~1" %2 %3 %4 %5 %6 %7 %8 %9
23
+ exit /b %ERRORLEVEL%
24
+ )
25
+ if exist "C:\Program Files (x86)\Git\bin\bash.exe" (
26
+ "C:\Program Files (x86)\Git\bin\bash.exe" "%HOOK_DIR%%~1" %2 %3 %4 %5 %6 %7 %8 %9
27
+ exit /b %ERRORLEVEL%
28
+ )
29
+
30
+ REM Try bash on PATH (e.g. user-installed Git Bash, MSYS2, Cygwin)
31
+ where bash >nul 2>nul
32
+ if %ERRORLEVEL% equ 0 (
33
+ bash "%HOOK_DIR%%~1" %2 %3 %4 %5 %6 %7 %8 %9
34
+ exit /b %ERRORLEVEL%
35
+ )
36
+
37
+ REM No bash found - exit silently rather than error
38
+ REM (plugin still works, just without SessionStart context injection)
39
+ exit /b 0
40
+ CMDBLOCK
41
+
42
+ # Unix: run the named script directly
43
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
44
+ SCRIPT_NAME="$1"
45
+ shift
46
+ exec bash "${SCRIPT_DIR}/${SCRIPT_NAME}" "$@"
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env bash
2
+ # SessionStart hook for specdx plugin
3
+ # Detects if the current project uses specdx and injects a lightweight summary.
4
+
5
+ set -euo pipefail
6
+
7
+ # Search upward from $PWD for spec.config.yaml
8
+ find_config() {
9
+ local dir="$PWD"
10
+ while [ "$dir" != "/" ]; do
11
+ if [ -f "$dir/spec.config.yaml" ]; then
12
+ echo "$dir"
13
+ return 0
14
+ fi
15
+ dir="$(dirname "$dir")"
16
+ done
17
+ return 1
18
+ }
19
+
20
+ PROJECT_ROOT="$(find_config 2>/dev/null)" || exit 0
21
+
22
+ # Escape string for JSON embedding using bash parameter substitution.
23
+ escape_for_json() {
24
+ local s="$1"
25
+ s="${s//\\/\\\\}"
26
+ s="${s//\"/\\\"}"
27
+ s="${s//$'\n'/\\n}"
28
+ s="${s//$'\r'/\\r}"
29
+ s="${s//$'\t'/\\t}"
30
+ printf '%s' "$s"
31
+ }
32
+
33
+ # Determine specdx invocation: prefer local binary, fall back to npx
34
+ if command -v specdx >/dev/null 2>&1; then
35
+ SPECDX="specdx"
36
+ elif command -v npx >/dev/null 2>&1; then
37
+ SPECDX="npx --yes specdx"
38
+ else
39
+ # No way to run specdx — exit silently
40
+ exit 0
41
+ fi
42
+
43
+ # Run validate and graph from the project root; capture output gracefully.
44
+ # Filter npm warn lines (noise from pnpm workspace roots when using npx).
45
+ run_specdx() {
46
+ (cd "$1" && $SPECDX "${@:2}" 2>&1) | grep -v '^npm warn' || true
47
+ }
48
+
49
+ validate_out="$(run_specdx "$PROJECT_ROOT" validate)" || validate_out="(validate failed)"
50
+ graph_out="$(run_specdx "$PROJECT_ROOT" graph)" || graph_out="(graph failed)"
51
+
52
+ # Build a compact summary (target: under 500 tokens)
53
+ summary="<specdx-context>
54
+ Project root: ${PROJECT_ROOT}
55
+
56
+ Validation:
57
+ ${validate_out}
58
+
59
+ Dependency graph:
60
+ ${graph_out}
61
+ </specdx-context>"
62
+
63
+ session_context="$(escape_for_json "$summary")"
64
+
65
+ # Output context injection as JSON.
66
+ # Claude Code hooks expect hookSpecificOutput.additionalContext.
67
+ # Cursor hooks expect additional_context.
68
+ # Emit only the field consumed by the current platform.
69
+ if [ -n "${CURSOR_PLUGIN_ROOT:-}" ]; then
70
+ printf '{\n "additional_context": "%s"\n}\n' "$session_context"
71
+ elif [ -n "${CLAUDE_PLUGIN_ROOT:-}" ]; then
72
+ printf '{\n "hookSpecificOutput": {\n "hookEventName": "SessionStart",\n "additionalContext": "%s"\n }\n}\n' "$session_context"
73
+ else
74
+ printf '{\n "additional_context": "%s"\n}\n' "$session_context"
75
+ fi
76
+
77
+ exit 0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "specdx",
3
- "version": "0.2.0-alpha.3",
3
+ "version": "0.3.0-alpha.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "specdx": "./dist/main.js"
@@ -12,7 +12,9 @@
12
12
  }
13
13
  },
14
14
  "files": [
15
- "dist"
15
+ "dist",
16
+ ".claude-plugin",
17
+ "hooks"
16
18
  ],
17
19
  "scripts": {
18
20
  "build": "tsup",
@@ -35,6 +37,7 @@
35
37
  },
36
38
  "devDependencies": {
37
39
  "@specdx/core": "workspace:*",
40
+ "@specdx/diff": "workspace:*",
38
41
  "@specdx/lint": "workspace:*",
39
42
  "@specdx/pack": "workspace:*",
40
43
  "@specdx/schema": "workspace:*",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../schema/src/sections.ts","../../schema/src/validator.ts","../../schema/dist/schemas/base-spec.json","../../schema/dist/schemas/config.json","../../schema/dist/schemas/prd.json","../../schema/dist/schemas/technical-design.json","../../schema/dist/schemas/user-story.json","../../schema/dist/schemas/test-plan.json","../../schema/dist/schemas/adr.json","../../schema/dist/schemas/api-contract.json"],"sourcesContent":["import type { SpecType } from \"./types.js\";\n\nexport const REQUIRED_SECTIONS: Record<SpecType, string[]> = {\n prd: [\"Problem Statement\", \"Goals\", \"Non-Goals\", \"Features\", \"Success Criteria\"],\n \"technical-design\": [\n \"Overview\",\n \"Architecture\",\n \"Data Model\",\n \"API Design\",\n \"Dependencies\",\n \"Risks\",\n \"Open Questions\",\n ],\n \"user-story\": [\"Description\", \"Acceptance Criteria\", \"Dependencies\", \"Notes\"],\n \"test-plan\": [\"Scope\", \"Test Cases\", \"Coverage Matrix\", \"Edge Cases\"],\n adr: [\"Context\", \"Decision\", \"Status\", \"Consequences\"],\n \"api-contract\": [\"Endpoints\", \"Request/Response Schemas\", \"Auth\", \"Error Codes\"],\n};\n","import { Ajv as AjvClass, type ErrorObject } from \"ajv\";\nimport type { SpecType } from \"./types.js\";\n\nimport baseSpecSchema from \"./schemas/base-spec.json\" with { type: \"json\" };\nimport configSchema from \"./schemas/config.json\" with { type: \"json\" };\nimport prdSchema from \"./schemas/prd.json\" with { type: \"json\" };\nimport technicalDesignSchema from \"./schemas/technical-design.json\" with { type: \"json\" };\nimport userStorySchema from \"./schemas/user-story.json\" with { type: \"json\" };\nimport testPlanSchema from \"./schemas/test-plan.json\" with { type: \"json\" };\nimport adrSchema from \"./schemas/adr.json\" with { type: \"json\" };\nimport apiContractSchema from \"./schemas/api-contract.json\" with { type: \"json\" };\n\n// addFormats is CJS-only; access via the namespace default at runtime\n// The type cast is needed because TypeScript's NodeNext resolution exposes\n// the CJS module as a namespace without a callable default signature.\nimport * as addFormatsNs from \"ajv-formats\";\ntype AddFormatsPlugin = (ajv: AjvClass, formats?: unknown) => AjvClass;\nconst addFormats = ((addFormatsNs as unknown as { default?: AddFormatsPlugin }).default ??\n (addFormatsNs as unknown as AddFormatsPlugin)) as AddFormatsPlugin;\n\nexport interface ValidationResult {\n valid: boolean;\n errors: ErrorObject[] | null;\n}\n\nconst ajv = new AjvClass({ allErrors: true, strict: true });\naddFormats(ajv, [\"date\"]);\najv.addSchema(baseSpecSchema);\n\nconst specValidators: Record<string, ReturnType<typeof ajv.compile>> = {\n prd: ajv.compile(prdSchema),\n \"technical-design\": ajv.compile(technicalDesignSchema),\n \"user-story\": ajv.compile(userStorySchema),\n \"test-plan\": ajv.compile(testPlanSchema),\n adr: ajv.compile(adrSchema),\n \"api-contract\": ajv.compile(apiContractSchema),\n};\n\nconst configValidator = ajv.compile(configSchema);\n\nexport function validateSpec(type: SpecType, data: Record<string, unknown>): ValidationResult {\n const validate = specValidators[type];\n if (!validate) {\n return { valid: false, errors: [{ message: `Unknown spec type: \"${type}\"` } as ErrorObject] };\n }\n const valid = validate(data);\n return { valid: !!valid, errors: valid ? null : (validate.errors ?? null) };\n}\n\nexport function validateConfig(data: Record<string, unknown>): ValidationResult {\n const valid = configValidator(data);\n return { valid: !!valid, errors: valid ? null : (configValidator.errors ?? null) };\n}\n","{\n \"$id\": \"base-spec\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"type\": \"object\",\n \"properties\": {\n \"id\": { \"type\": \"string\", \"minLength\": 1 },\n \"type\": { \"type\": \"string\", \"enum\": [\"prd\", \"technical-design\", \"user-story\", \"test-plan\", \"adr\", \"api-contract\"] },\n \"title\": { \"type\": \"string\", \"minLength\": 1 },\n \"status\": { \"type\": \"string\", \"enum\": [\"draft\", \"review\", \"approved\", \"superseded\"] },\n \"version\": { \"type\": \"string\" },\n \"created\": { \"type\": \"string\", \"format\": \"date\" },\n \"updated\": { \"type\": \"string\", \"format\": \"date\" },\n \"authors\": { \"type\": \"array\", \"items\": { \"type\": \"string\" }, \"minItems\": 1 },\n \"tags\": { \"type\": \"array\", \"items\": { \"type\": \"string\" }, \"default\": [] },\n \"references\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": { \"type\": \"string\" },\n \"relationship\": { \"type\": \"string\", \"enum\": [\"implemented-by\", \"decomposed-into\", \"depends-on\", \"supersedes\", \"related-to\"] }\n },\n \"required\": [\"id\", \"relationship\"],\n \"additionalProperties\": false\n },\n \"default\": []\n }\n },\n \"required\": [\"id\", \"type\", \"title\", \"status\", \"version\", \"created\", \"authors\"],\n \"additionalProperties\": true\n}\n","{\n \"$id\": \"sdx-config\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"type\": \"object\",\n \"properties\": {\n \"version\": { \"type\": \"string\" },\n \"project\": {\n \"type\": \"object\",\n \"properties\": {\n \"name\": { \"type\": \"string\" },\n \"description\": { \"type\": \"string\" }\n },\n \"additionalProperties\": false\n },\n \"specs\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"object\",\n \"properties\": {\n \"path\": { \"type\": \"string\" },\n \"type\": { \"type\": \"string\", \"enum\": [\"prd\", \"technical-design\", \"user-story\", \"test-plan\", \"adr\", \"api-contract\"] },\n \"required\": { \"type\": \"boolean\", \"default\": false },\n \"requires\": { \"type\": \"array\", \"items\": { \"type\": \"string\" } }\n },\n \"required\": [\"path\", \"type\"],\n \"additionalProperties\": false\n }\n },\n \"lint\": {\n \"type\": \"object\",\n \"properties\": {\n \"extends\": { \"type\": \"string\", \"enum\": [\"minimal\", \"recommended\", \"strict\"] },\n \"rules\": { \"type\": \"object\" },\n \"ignore\": { \"type\": \"array\", \"items\": { \"type\": \"string\" } }\n },\n \"additionalProperties\": false\n },\n \"pack\": {\n \"type\": \"object\",\n \"properties\": {\n \"max_tokens\": { \"type\": \"integer\", \"minimum\": 1 },\n \"format\": { \"type\": \"string\", \"enum\": [\"xml\", \"markdown\", \"json\"] },\n \"compression\": {\n \"type\": \"object\",\n \"properties\": {\n \"strip_boilerplate\": { \"type\": \"boolean\" },\n \"stable_days\": { \"type\": \"integer\", \"minimum\": 0 },\n \"collapse_resolved_adrs\": { \"type\": \"boolean\" }\n },\n \"additionalProperties\": false\n },\n \"boilerplate_sections\": {\n \"type\": \"array\",\n \"items\": { \"type\": \"string\" }\n }\n },\n \"additionalProperties\": false\n },\n \"diff\": { \"type\": \"object\" },\n \"ci\": { \"type\": \"object\" }\n },\n \"required\": [\"version\", \"specs\"],\n \"additionalProperties\": false\n}\n","{\n \"$id\": \"prd\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n { \"type\": \"object\", \"properties\": { \"type\": { \"const\": \"prd\" } }, \"required\": [\"type\"] }\n ]\n}\n","{\n \"$id\": \"technical-design\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n { \"type\": \"object\", \"properties\": { \"type\": { \"const\": \"technical-design\" } }, \"required\": [\"type\"] }\n ]\n}\n","{\n \"$id\": \"user-story\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n {\n \"type\": \"object\",\n \"properties\": {\n \"type\": { \"const\": \"user-story\" },\n \"story_id\": { \"type\": \"string\", \"minLength\": 1 },\n \"priority\": { \"type\": \"string\", \"enum\": [\"critical\", \"high\", \"medium\", \"low\"] },\n \"estimate\": { \"type\": \"string\" }\n },\n \"required\": [\"type\", \"story_id\", \"priority\", \"estimate\"]\n }\n ]\n}\n","{\n \"$id\": \"test-plan\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n { \"type\": \"object\", \"properties\": { \"type\": { \"const\": \"test-plan\" } }, \"required\": [\"type\"] }\n ]\n}\n","{\n \"$id\": \"adr\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n { \"type\": \"object\", \"properties\": { \"type\": { \"const\": \"adr\" } }, \"required\": [\"type\"] }\n ]\n}\n","{\n \"$id\": \"api-contract\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n { \"type\": \"object\", \"properties\": { \"type\": { \"const\": \"api-contract\" } }, \"required\": [\"type\"] }\n ]\n}\n"],"mappings":";AAEO,IAAM,oBAAgD;EAC3D,KAAK,CAAC,qBAAqB,SAAS,aAAa,YAAY,kBAAkB;EAC/E,oBAAoB;IAClB;IACA;IACA;IACA;IACA;IACA;IACA;;EAEF,cAAc,CAAC,eAAe,uBAAuB,gBAAgB,OAAO;EAC5E,aAAa,CAAC,SAAS,cAAc,mBAAmB,YAAY;EACpE,KAAK,CAAC,WAAW,YAAY,UAAU,cAAc;EACrD,gBAAgB,CAAC,aAAa,4BAA4B,QAAQ,aAAa;;;;AChBjF,SAAS,OAAO,gBAAkC;;;ACAlD;AAAA,EACI,KAAO;AAAA,EACP,SAAW;AAAA,EACX,MAAQ;AAAA,EACR,YAAc;AAAA,IACV,IAAM,EAAE,MAAQ,UAAU,WAAa,EAAE;AAAA,IACzC,MAAQ,EAAE,MAAQ,UAAU,MAAQ,CAAC,OAAO,oBAAoB,cAAc,aAAa,OAAO,cAAc,EAAE;AAAA,IAClH,OAAS,EAAE,MAAQ,UAAU,WAAa,EAAE;AAAA,IAC5C,QAAU,EAAE,MAAQ,UAAU,MAAQ,CAAC,SAAS,UAAU,YAAY,YAAY,EAAE;AAAA,IACpF,SAAW,EAAE,MAAQ,SAAS;AAAA,IAC9B,SAAW,EAAE,MAAQ,UAAU,QAAU,OAAO;AAAA,IAChD,SAAW,EAAE,MAAQ,UAAU,QAAU,OAAO;AAAA,IAChD,SAAW,EAAE,MAAQ,SAAS,OAAS,EAAE,MAAQ,SAAS,GAAG,UAAY,EAAE;AAAA,IAC3E,MAAQ,EAAE,MAAQ,SAAS,O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kBAAkB;AAE9B,IAAM,aAA0E,wBAC7E;AAOH,IAAM,MAAM,IAAI,SAAS,EAAE,WAAW,MAAM,QAAQ,KAAI,CAAE;AAC1D,WAAW,KAAK,CAAC,MAAM,CAAC;AACxB,IAAI,UAAU,iBAAc;AAE5B,IAAM,iBAAiE;EACrE,KAAK,IAAI,QAAQ,WAAS;EAC1B,oBAAoB,IAAI,QAAQ,wBAAqB;EACrD,cAAc,IAAI,QAAQ,kBAAe;EACzC,aAAa,IAAI,QAAQ,iBAAc;EACvC,KAAK,IAAI,QAAQ,WAAS;EAC1B,gBAAgB,IAAI,QAAQ,oBAAiB;;AAG/C,IAAM,kBAAkB,IAAI,QAAQ,cAAY;AAE1C,SAAU,aAAa,MAAgB,MAA6B;AACxE,QAAM,WAAW,eAAe,IAAI;AACpC,MAAI,CAAC,UAAU;AACb,WAAO,EAAE,OAAO,OAAO,QAAQ,CAAC,EAAE,SAAS,uBAAuB,IAAI,IAAG,CAAiB,EAAC;EAC7F;AACA,QAAM,QAAQ,SAAS,IAAI;AAC3B,SAAO,EAAE,OAAO,CAAC,CAAC,OAAO,QAAQ,QAAQ,OAAQ,SAAS,UAAU,KAAK;AAC3E;AAEM,SAAU,eAAe,MAA6B;AAC1D,QAAM,QAAQ,gBAAgB,IAAI;AAClC,SAAO,EAAE,OAAO,CAAC,CAAC,OAAO,QAAQ,QAAQ,OAAQ,gBAAgB,UAAU,KAAK;AAClF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../core/src/config.ts","../../core/src/parser.ts","../../core/src/tokens.ts","../../core/src/graph.ts","../../core/src/glob.ts","../../core/src/logger.ts","../src/shared-args.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { join, dirname } from \"node:path\";\nimport { parse as parseYaml } from \"yaml\";\nimport { validateConfig, type SdxConfig } from \"@specdx/schema\";\n\nexport class ConfigError extends Error {\n constructor(\n message: string,\n public readonly errors?: unknown[],\n ) {\n super(message);\n this.name = \"ConfigError\";\n }\n}\n\nconst CONFIG_FILENAME = \"spec.config.yaml\";\n\nexport async function loadConfig(filePath?: string, searchFrom?: string): Promise<SdxConfig> {\n const resolvedPath = filePath ?? (await findConfig(searchFrom ?? process.cwd()));\n if (!resolvedPath) {\n throw new ConfigError(`No ${CONFIG_FILENAME} found. Run 'sdx init' to create one.`);\n }\n\n let raw: string;\n try {\n raw = await readFile(resolvedPath, \"utf-8\");\n } catch {\n throw new ConfigError(`Cannot read config file: ${resolvedPath}`);\n }\n\n let data: Record<string, unknown>;\n try {\n data = parseYaml(raw) as Record<string, unknown>;\n } catch (err) {\n throw new ConfigError(`Invalid YAML in ${resolvedPath}: ${(err as Error).message}`);\n }\n\n const result = validateConfig(data);\n if (!result.valid) {\n throw new ConfigError(`Invalid config in ${resolvedPath}`, result.errors ?? undefined);\n }\n\n return data as unknown as SdxConfig;\n}\n\nasync function findConfig(from: string): Promise<string | undefined> {\n let dir = from;\n while (true) {\n const candidate = join(dir, CONFIG_FILENAME);\n try {\n await readFile(candidate, \"utf-8\");\n return candidate;\n } catch {\n const parent = dirname(dir);\n if (parent === dir) return undefined;\n dir = parent;\n }\n }\n}\n","import { readFile } from \"node:fs/promises\";\nimport { extname } from \"node:path\";\nimport * as grayMatterNs from \"gray-matter\";\nimport { parse as parseYaml } from \"yaml\";\nimport { unified } from \"unified\";\nimport remarkParse from \"remark-parse\";\nimport { visit } from \"unist-util-visit\";\nimport { validateSpec, type ValidationResult } from \"@specdx/schema\";\nimport type { BaseSpec, SpecType } from \"@specdx/schema\";\nimport { countTokens } from \"./tokens.js\";\n\n// gray-matter is CJS — its callable default is exposed via .default in an ESM context\ntype GrayMatterFn = (input: string) => { data: Record<string, unknown>; content: string };\nconst matter = ((grayMatterNs as unknown as { default?: GrayMatterFn }).default ??\n (grayMatterNs as unknown as GrayMatterFn)) as GrayMatterFn;\n\nexport class ParseError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ParseError\";\n }\n}\n\nexport interface ParsedSection {\n heading: string;\n content: string;\n tokens: number;\n}\n\nexport interface ParsedSpec {\n filePath: string;\n frontmatter: BaseSpec & Record<string, unknown>;\n content: string;\n sections: string[];\n parsedSections: ParsedSection[];\n valid: boolean;\n validationErrors: ValidationResult[\"errors\"];\n}\n\nexport async function parseSpec(filePath: string): Promise<ParsedSpec> {\n let raw: string;\n try {\n raw = await readFile(filePath, \"utf-8\");\n } catch {\n throw new ParseError(`Cannot read spec file: ${filePath}`);\n }\n\n const ext = extname(filePath).toLowerCase();\n if (ext === \".yaml\" || ext === \".yml\") {\n return parseYamlSpec(filePath, raw);\n }\n return parseMarkdownSpec(filePath, raw);\n}\n\nfunction parseMarkdownSpec(filePath: string, raw: string): ParsedSpec {\n const { data, content } = matter(raw);\n const parsedSections = extractParsedSections(content);\n const sections = parsedSections.map((s) => s.heading).filter(Boolean);\n const frontmatter = data as BaseSpec & Record<string, unknown>;\n const specType = frontmatter.type as SpecType | undefined;\n\n let valid = false;\n let validationErrors: ValidationResult[\"errors\"] = null;\n if (specType) {\n const result = validateSpec(specType, data);\n valid = result.valid;\n validationErrors = result.errors;\n }\n\n return { filePath, frontmatter, content, sections, parsedSections, valid, validationErrors };\n}\n\nfunction parseYamlSpec(filePath: string, raw: string): ParsedSpec {\n let data: Record<string, unknown>;\n try {\n data = parseYaml(raw) as Record<string, unknown>;\n } catch (err) {\n throw new ParseError(`Invalid YAML in ${filePath}: ${(err as Error).message}`);\n }\n\n const frontmatter = data as BaseSpec & Record<string, unknown>;\n const specType = frontmatter.type as SpecType | undefined;\n\n let valid = false;\n let validationErrors: ValidationResult[\"errors\"] = null;\n if (specType) {\n const result = validateSpec(specType, data);\n valid = result.valid;\n validationErrors = result.errors;\n }\n\n return {\n filePath,\n frontmatter,\n content: \"\",\n sections: [],\n parsedSections: [],\n valid,\n validationErrors,\n };\n}\n\nfunction extractParsedSections(markdown: string): ParsedSection[] {\n const tree = unified().use(remarkParse).parse(markdown);\n\n const h2s: { heading: string; startOffset: number; endOffset: number }[] = [];\n\n visit(tree, \"heading\", (node) => {\n if (node.depth === 2) {\n const text = (node.children as Array<{ type: string; value?: string }>)\n .filter((c) => c.type === \"text\")\n .map((c) => c.value ?? \"\")\n .join(\"\");\n h2s.push({\n heading: text,\n startOffset: node.position!.start.offset as number,\n endOffset: node.position!.end.offset as number,\n });\n }\n });\n\n const sections: ParsedSection[] = [];\n\n // Preamble: content before first H2\n const firstH2 = h2s[0];\n const firstOffset = firstH2 ? firstH2.startOffset : markdown.length;\n const preamble = markdown.slice(0, firstOffset).trim();\n if (preamble) {\n sections.push({ heading: \"\", content: preamble, tokens: countTokens(preamble) });\n }\n\n // Each H2 section: content AFTER the heading line, up to the next H2 (or end)\n for (let i = 0; i < h2s.length; i++) {\n const current = h2s[i]!;\n const next = h2s[i + 1];\n const end = next ? next.startOffset : markdown.length;\n const content = markdown.slice(current.endOffset, end).trim();\n sections.push({\n heading: current.heading,\n content,\n tokens: countTokens(content),\n });\n }\n\n return sections;\n}\n","import { encodingForModel } from \"js-tiktoken\";\n\nlet encoder: ReturnType<typeof encodingForModel> | undefined;\n\nfunction getEncoder() {\n if (!encoder) encoder = encodingForModel(\"gpt-4o\");\n return encoder;\n}\n\nexport function countTokens(text: string): number {\n if (!text) return 0;\n return getEncoder().encode(text).length;\n}\n","import type { SdxConfig } from \"@specdx/schema\";\n\nexport class GraphError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"GraphError\";\n }\n}\n\nexport interface Edge {\n from: string;\n to: string;\n}\n\nexport interface DependencyGraph {\n nodes: string[];\n edges: Edge[];\n topologicalSort(): string[];\n getDownstream(nodeId: string): string[];\n getUpstream(nodeId: string): string[];\n}\n\nexport function buildGraph(config: SdxConfig): DependencyGraph {\n const specNames = Object.keys(config.specs);\n const adjacency = new Map<string, string[]>();\n const reverseAdj = new Map<string, string[]>();\n const edges: Edge[] = [];\n\n for (const name of specNames) {\n adjacency.set(name, []);\n reverseAdj.set(name, []);\n }\n\n for (const [name, entry] of Object.entries(config.specs)) {\n if (!entry.requires) continue;\n for (const dep of entry.requires) {\n if (!adjacency.has(dep)) {\n throw new GraphError(\n `Spec \"${name}\" requires \"${dep}\", which does not exist in the config.`,\n );\n }\n adjacency.get(dep)!.push(name);\n reverseAdj.get(name)!.push(dep);\n edges.push({ from: dep, to: name });\n }\n }\n\n // Kahn's algorithm for cycle detection + topological sort\n const inDegree = new Map<string, number>();\n for (const name of specNames) inDegree.set(name, reverseAdj.get(name)!.length);\n\n const queue: string[] = [];\n for (const [name, degree] of inDegree) {\n if (degree === 0) queue.push(name);\n }\n\n const sorted: string[] = [];\n while (queue.length > 0) {\n const node = queue.shift()!;\n sorted.push(node);\n for (const neighbor of adjacency.get(node)!) {\n const newDegree = inDegree.get(neighbor)! - 1;\n inDegree.set(neighbor, newDegree);\n if (newDegree === 0) queue.push(neighbor);\n }\n }\n\n if (sorted.length !== specNames.length) {\n const remaining = specNames.filter((n) => !sorted.includes(n));\n throw new GraphError(`Circular dependency detected involving: ${remaining.join(\", \")}`);\n }\n\n return {\n nodes: specNames,\n edges,\n topologicalSort: () => [...sorted],\n getDownstream(nodeId: string): string[] {\n const visited = new Set<string>();\n const stack = [nodeId];\n while (stack.length > 0) {\n const current = stack.pop()!;\n for (const neighbor of adjacency.get(current) ?? []) {\n if (!visited.has(neighbor)) {\n visited.add(neighbor);\n stack.push(neighbor);\n }\n }\n }\n return [...visited];\n },\n getUpstream(nodeId: string): string[] {\n const visited = new Set<string>();\n const stack = [nodeId];\n while (stack.length > 0) {\n const current = stack.pop()!;\n for (const dep of reverseAdj.get(current) ?? []) {\n if (!visited.has(dep)) {\n visited.add(dep);\n stack.push(dep);\n }\n }\n }\n return [...visited];\n },\n };\n}\n","import { glob } from \"tinyglobby\";\nimport { join, isAbsolute } from \"node:path\";\n\nexport async function resolveGlob(pattern: string, baseDir: string): Promise<string[]> {\n const absolutePattern = isAbsolute(pattern) ? pattern : join(baseDir, pattern);\n return glob([absolutePattern], { absolute: true });\n}\n","import { createConsola, type ConsolaInstance } from \"consola\";\n\nexport type LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\nexport interface LoggerOptions {\n quiet?: boolean;\n verbose?: boolean;\n}\n\nexport interface Logger extends ConsolaInstance {\n level: number;\n}\n\nexport function createLogger(options?: LoggerOptions): Logger {\n let level = 3; // info\n if (options?.quiet) level = 1; // only errors\n if (options?.verbose) level = 4; // debug\n return createConsola({ level }) as Logger;\n}\n","export const sharedArgs = {\n quiet: { type: \"boolean\" as const, description: \"Suppress info output\", alias: [\"q\"] },\n verbose: { type: \"boolean\" as const, description: \"Enable debug output\", alias: [\"V\"] },\n format: {\n type: \"string\" as const,\n description: \"Output format (pretty, json, github)\",\n default: \"pretty\",\n },\n};\n"],"mappings":";;;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,MAAM,eAAe;AAC9B,SAAS,SAAS,iBAAiB;AAG7B,IAAO,cAAP,cAA2B,MAAK;EAGlB;EAFlB,YACE,SACgB,QAAkB;AAElC,UAAM,OAAO;AAFG,SAAA,SAAA;AAGhB,SAAK,OAAO;EACd;;AAGF,IAAM,kBAAkB;AAExB,eAAsB,WAAW,UAAmB,YAAmB;AACrE,QAAM,eAAe,YAAa,MAAM,WAAW,cAAc,QAAQ,IAAG,CAAE;AAC9E,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI,YAAY,MAAM,eAAe,uCAAuC;EACpF;AAEA,MAAI;AACJ,MAAI;AACF,UAAM,MAAM,SAAS,cAAc,OAAO;EAC5C,QAAQ;AACN,UAAM,IAAI,YAAY,4BAA4B,YAAY,EAAE;EAClE;AAEA,MAAI;AACJ,MAAI;AACF,WAAO,UAAU,GAAG;EACtB,SAAS,KAAK;AACZ,UAAM,IAAI,YAAY,mBAAmB,YAAY,KAAM,IAAc,OAAO,EAAE;EACpF;AAEA,QAAM,SAAS,eAAe,IAAI;AAClC,MAAI,CAAC,OAAO,OAAO;AACjB,UAAM,IAAI,YAAY,qBAAqB,YAAY,IAAI,OAAO,UAAU,MAAS;EACvF;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AAM,IAAG;AACzB,mBAAW,OAAO,WAAW,IAAI,OAAO,KAAK,CAAA,GAAI;AAC/C,cAAI,CAAC,QAAQ,IAAI,GAAG,GAAG;AACrB,oBAAQ,IAAI,GAAG;AACf,kBAAM,KAAK,GAAG;UAChB;QACF;MACF;AACA,aAAO,CAAC,GAAG,OAAO;IACpB;;AAEJ;;;ACzGA,SAAS,YAAY;AACrB,SAAS,QAAAC,OAAM,kBAAkB;AAEjC,eAAsB,YAAY,SAAiB,SAAe;AAChE,QAAM,kBAAkB,WAAW,OAAO,IAAI,UAAUA,MAAK,SAAS,OAAO;AAC7E,SAAO,KAAK,CAAC,eAAe,GAAG,EAAE,UAAU,KAAI,CAAE;AACnD;;;ACNA,SAAS,qBAA2C;AAa9C,SAAU,aAAa,SAAuB;AAClD,MAAI,QAAQ;AACZ,MAAI,SAAS;AAAO,YAAQ;AAC5B,MAAI,SAAS;AAAS,YAAQ;AAC9B,SAAO,cAAc,EAAE,MAAK,CAAE;AAChC;;;AClBO,IAAM,aAAa;AAAA,EACxB,OAAO,EAAE,MAAM,WAAoB,aAAa,wBAAwB,OAAO,CAAC,GAAG,EAAE;AAAA,EACrF,SAAS,EAAE,MAAM,WAAoB,aAAa,uBAAuB,OAAO,CAAC,GAAG,EAAE;AAAA,EACtF,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AACF;","names":["readFile","parseYaml","readFile","parseYaml","join"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/lint.ts","../../lint/src/engine.ts","../../lint/src/rules/valid-frontmatter.ts","../../lint/src/rules/required-sections.ts","../../lint/src/rules/valid-references.ts","../../lint/src/rules/no-circular-deps.ts","../../lint/src/rules/story-coverage.ts","../../lint/src/rules/staleness-check.ts","../../lint/src/rules/no-vague-language.ts","../../lint/src/rules/index.ts","../../lint/src/presets.ts","../../lint/src/custom-rule-loader.ts","../src/formatters/pretty.ts","../src/formatters/json.ts","../src/formatters/github.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, resolveGlob, buildGraph, createLogger } from \"@specdx/core\";\nimport { createLintEngine, getPreset, type LintResults } from \"@specdx/lint\";\nimport type { ParsedSpec } from \"@specdx/core\";\nimport { sharedArgs } from \"../shared-args.js\";\nimport { formatPretty } from \"../formatters/pretty.js\";\nimport { formatJson } from \"../formatters/json.js\";\nimport { formatGithub } from \"../formatters/github.js\";\n\nexport interface RunLintOptions {\n configDir: string;\n specPath?: string;\n preset?: \"minimal\" | \"recommended\" | \"strict\";\n}\n\nexport async function runLint(options: RunLintOptions): Promise<LintResults> {\n const config = await loadConfig(undefined, options.configDir);\n const preset = options.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, options.configDir);\n for (const file of files) {\n if (options.specPath && !file.includes(options.specPath)) continue;\n specs.push(await parseSpec(file));\n }\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 });\n const results = engine.lint(specs);\n\n if (graphError) {\n results.diagnostics.push({\n ruleId: \"structure/no-circular-deps\",\n severity: \"error\",\n message: graphError,\n filePath: \"spec.config.yaml\",\n });\n results.hasErrors = true;\n }\n\n return results;\n}\n\nexport default defineCommand({\n meta: { name: \"lint\", description: \"Lint all specs in the suite\" },\n args: {\n ...sharedArgs,\n fix: { type: \"boolean\", description: \"Auto-fix issues where possible\" },\n path: { type: \"positional\", description: \"Lint a specific spec file\", required: false },\n preset: { type: \"string\", description: \"Lint preset (minimal, recommended, strict)\" },\n },\n async run({ args }) {\n const logger = createLogger({ quiet: args.quiet, verbose: args.verbose });\n\n if (args.fix) {\n logger.info(\"No auto-fixable issues supported yet.\");\n }\n\n try {\n const results = await runLint({\n configDir: process.cwd(),\n specPath: args.path,\n preset: args.preset as \"minimal\" | \"recommended\" | \"strict\" | undefined,\n });\n\n const formatter =\n args.format === \"json\"\n ? formatJson\n : args.format === \"github\"\n ? formatGithub\n : formatPretty;\n console.log(formatter(results.diagnostics));\n\n if (results.hasErrors) process.exit(1);\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n },\n});\n","import type { ParsedSpec, DependencyGraph } from \"@specdx/core\";\nimport type { SdxConfig } from \"@specdx/schema\";\nimport type { LintRule, LintResults, Diagnostic } from \"./types.js\";\n\nexport interface LintEngineOptions {\n rules: LintRule[];\n config?: SdxConfig;\n graph?: DependencyGraph;\n}\n\nexport interface LintEngine {\n lint(specs: ParsedSpec[]): LintResults;\n}\n\nexport function createLintEngine(options: LintEngineOptions): LintEngine {\n return {\n lint(specs: ParsedSpec[]): LintResults {\n const diagnostics: Diagnostic[] = [];\n for (const spec of specs) {\n for (const rule of options.rules) {\n const results = rule.run({\n spec,\n allSpecs: specs,\n config: options.config,\n graph: options.graph,\n });\n diagnostics.push(...results);\n }\n }\n return {\n diagnostics,\n hasErrors: diagnostics.some((d) => d.severity === \"error\"),\n hasWarnings: diagnostics.some((d) => d.severity === \"warn\"),\n };\n },\n };\n}\n","import type { LintRule } from \"../types.js\";\n\nexport const validFrontmatterRule: LintRule = {\n id: \"structure/valid-frontmatter\",\n description: \"Frontmatter matches the schema for the declared spec type\",\n severity: \"error\",\n run(context) {\n if (context.spec.valid) return [];\n const errors = context.spec.validationErrors ?? [];\n return errors.map((err) => ({\n ruleId: \"structure/valid-frontmatter\",\n severity: \"error\" as const,\n message: `Invalid frontmatter: ${err.message ?? JSON.stringify(err)}`,\n filePath: context.spec.filePath,\n }));\n },\n};\n","import type { LintRule } from \"../types.js\";\nimport { REQUIRED_SECTIONS } from \"@specdx/schema\";\nimport type { SpecType } from \"@specdx/schema\";\n\nexport const requiredSectionsRule: LintRule = {\n id: \"structure/required-sections\",\n description: \"Spec body contains all required sections for its type\",\n severity: \"error\",\n run(context) {\n // Skip YAML specs (no markdown body)\n const ext = context.spec.filePath.split(\".\").pop()?.toLowerCase();\n if (ext === \"yaml\" || ext === \"yml\") return [];\n\n const specType = context.spec.frontmatter.type as SpecType;\n const required = REQUIRED_SECTIONS[specType];\n if (!required) return [];\n\n const missing = required.filter((s) => !context.spec.sections.includes(s));\n return missing.map((section) => ({\n ruleId: \"structure/required-sections\",\n severity: \"error\" as const,\n message: `Missing required section: \"${section}\"`,\n filePath: context.spec.filePath,\n section,\n }));\n },\n};\n","import type { LintRule } from \"../types.js\";\n\nexport const validReferencesRule: LintRule = {\n id: \"structure/valid-references\",\n description: \"All references in frontmatter point to specs that exist in the suite\",\n severity: \"error\",\n run(context) {\n const refs = context.spec.frontmatter.references;\n if (!refs || refs.length === 0) return [];\n const allIds = new Set(context.allSpecs.map((s) => s.frontmatter.id));\n return refs\n .filter((ref) => !allIds.has(ref.id))\n .map((ref) => ({\n ruleId: \"structure/valid-references\",\n severity: \"error\" as const,\n message: `Reference \"${ref.id}\" does not match any spec in the suite`,\n filePath: context.spec.filePath,\n }));\n },\n};\n","import type { LintRule } from \"../types.js\";\n\nexport const noCircularDepsRule: LintRule = {\n id: \"structure/no-circular-deps\",\n description: \"The dependency graph has no cycles\",\n severity: \"error\",\n run() {\n // Cycle detection happens in buildGraph() — if graph construction succeeds, it's acyclic.\n // GraphErrors are surfaced as diagnostics by the lint command, not by this rule.\n return [];\n },\n};\n","import type { LintRule } from \"../types.js\";\n\nconst FEATURE_PATTERN = /\\*\\*F\\d+\\*\\*:\\s*(.+)/g;\n\nexport const storyCoverageRule: LintRule = {\n id: \"completeness/story-coverage\",\n description: \"Every feature listed in a PRD has at least one corresponding user story\",\n severity: \"warn\",\n run(context) {\n if (context.spec.frontmatter.type !== \"prd\") return [];\n const features: string[] = [];\n let match;\n const re = new RegExp(FEATURE_PATTERN.source, \"g\");\n while ((match = re.exec(context.spec.content)) !== null) {\n features.push(match[1]!.trim());\n }\n if (features.length === 0) return [];\n const stories = context.allSpecs.filter((s) => s.frontmatter.type === \"user-story\");\n const storyContent = stories.map((s) => s.content + \" \" + s.frontmatter.title).join(\" \");\n return features\n .filter((feature) => !storyContent.toLowerCase().includes(feature.toLowerCase()))\n .map((feature) => ({\n ruleId: \"completeness/story-coverage\",\n severity: \"warn\" as const,\n message: `Feature \"${feature}\" has no corresponding user story`,\n filePath: context.spec.filePath,\n }));\n },\n};\n","import type { LintRule } from \"../types.js\";\n\nexport const stalenessCheckRule: LintRule = {\n id: \"freshness/staleness-check\",\n description: \"Warns if a spec hasn't been updated since its upstream dependency changed\",\n severity: \"warn\",\n run(context) {\n const refs = context.spec.frontmatter.references;\n if (!refs || (refs as unknown[]).length === 0) return [];\n const specUpdated =\n (context.spec.frontmatter.updated as string | undefined) ??\n (context.spec.frontmatter.created as string);\n const specDate = new Date(specUpdated);\n const diagnostics = [];\n for (const ref of refs as Array<{ id: string; relationship: string }>) {\n if (ref.relationship !== \"depends-on\" && ref.relationship !== \"implemented-by\") continue;\n const upstream = context.allSpecs.find((s) => s.frontmatter.id === ref.id);\n if (!upstream) continue;\n const upstreamUpdated =\n (upstream.frontmatter.updated as string | undefined) ??\n (upstream.frontmatter.created as string);\n const upstreamDate = new Date(upstreamUpdated);\n if (upstreamDate > specDate) {\n diagnostics.push({\n ruleId: \"freshness/staleness-check\",\n severity: \"warn\" as const,\n message: `Potentially stale: upstream \"${upstream.frontmatter.id}\" was updated on ${upstreamUpdated}, but this spec was last updated on ${specUpdated}`,\n filePath: context.spec.filePath,\n });\n }\n }\n return diagnostics;\n },\n};\n","import type { LintRule } from \"../types.js\";\n\nconst DEFAULT_VAGUE_PATTERNS = [\n \"as appropriate\",\n \"handle edge cases\",\n \"as needed\",\n \"etc\\\\.\",\n \"TBD\",\n \"TODO\",\n \"and so on\",\n \"various\",\n \"somehow\",\n \"straightforward\",\n \"obviously\",\n \"simply\",\n \"just need to\",\n];\n\nexport const noVagueLanguageRule: LintRule = {\n id: \"clarity/no-vague-language\",\n description: \"Flags known ambiguous phrases\",\n severity: \"warn\",\n run(context) {\n if (!context.spec.content) return [];\n const diagnostics = [];\n for (const pattern of DEFAULT_VAGUE_PATTERNS) {\n const regex = new RegExp(`\\\\b${pattern}`, \"gi\");\n let match;\n while ((match = regex.exec(context.spec.content)) !== null) {\n diagnostics.push({\n ruleId: \"clarity/no-vague-language\",\n severity: \"warn\" as const,\n message: `Vague language: \"${match[0]}\"`,\n filePath: context.spec.filePath,\n });\n }\n }\n return diagnostics;\n },\n};\n","import { validFrontmatterRule } from \"./valid-frontmatter.js\";\nimport { requiredSectionsRule } from \"./required-sections.js\";\nimport { validReferencesRule } from \"./valid-references.js\";\nimport { noCircularDepsRule } from \"./no-circular-deps.js\";\nimport { storyCoverageRule } from \"./story-coverage.js\";\nimport { stalenessCheckRule } from \"./staleness-check.js\";\nimport { noVagueLanguageRule } from \"./no-vague-language.js\";\nimport type { LintRule } from \"../types.js\";\n\nexport const structureRules: LintRule[] = [\n validFrontmatterRule,\n requiredSectionsRule,\n validReferencesRule,\n noCircularDepsRule,\n];\n\nexport const contentRules: LintRule[] = [\n storyCoverageRule,\n stalenessCheckRule,\n noVagueLanguageRule,\n];\n\nexport const allBuiltinRules: LintRule[] = [...structureRules, ...contentRules];\n\nexport {\n validFrontmatterRule,\n requiredSectionsRule,\n validReferencesRule,\n noCircularDepsRule,\n storyCoverageRule,\n stalenessCheckRule,\n noVagueLanguageRule,\n};\n","import type { LintRule } from \"./types.js\";\nimport { structureRules, allBuiltinRules } from \"./rules/index.js\";\n\nexport function getPreset(name: \"minimal\" | \"recommended\" | \"strict\"): LintRule[] {\n switch (name) {\n case \"minimal\":\n return structureRules;\n case \"recommended\":\n return allBuiltinRules;\n case \"strict\":\n return allBuiltinRules.map((rule) => ({ ...rule, severity: \"error\" as const }));\n }\n}\n","import { pathToFileURL } from \"node:url\";\nimport type { LintRule } from \"./types.js\";\n\nexport async function loadCustomRule(filePath: string): Promise<LintRule> {\n const module = await import(pathToFileURL(filePath).href);\n const rule = module.default ?? module.rule;\n if (!rule || !rule.id || !rule.run) {\n throw new Error(\n `Custom rule at ${filePath} must export a default LintRule with id and run function`,\n );\n }\n return rule as LintRule;\n}\n","import type { Diagnostic } from \"@specdx/lint\";\n\nexport function formatPretty(diagnostics: Diagnostic[]): string {\n if (diagnostics.length === 0) return \" ✓ All specs pass lint checks.\\n\";\n return diagnostics\n .map((d) => {\n const icon = d.severity === \"error\" ? \"✗\" : d.severity === \"warn\" ? \"⚠\" : \"ℹ\";\n return ` ${icon} ${d.severity} ${d.message} (${d.ruleId})\\n ${d.filePath}${d.line ? `:${d.line}` : \"\"}`;\n })\n .join(\"\\n\");\n}\n","import type { Diagnostic } from \"@specdx/lint\";\nexport function formatJson(diagnostics: Diagnostic[]): string {\n return JSON.stringify(diagnostics, null, 2);\n}\n","import type { Diagnostic } from \"@specdx/lint\";\nexport function formatGithub(diagnostics: Diagnostic[]): string {\n return diagnostics\n .map((d) => {\n const level = d.severity === \"error\" ? \"error\" : \"warning\";\n const line = d.line ? `,line=${d.line}` : \"\";\n return `::${level} file=${d.filePath}${line}::${d.message} (${d.ruleId})`;\n })\n .join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAS,qBAAqB;;;ACcxB,SAAU,iBAAiB,SAA0B;AACzD,SAAO;IACL,KAAK,OAAmB;AACtB,YAAM,cAA4B,CAAA;AAClC,iBAAW,QAAQ,OAAO;AACxB,mBAAW,QAAQ,QAAQ,OAAO;AAChC,gBAAM,UAAU,KAAK,IAAI;YACvB;YACA,UAAU;YACV,QAAQ,QAAQ;YAChB,OAAO,QAAQ;WAChB;AACD,sBAAY,KAAK,GAAG,OAAO;QAC7B;MACF;AACA,aAAO;QACL;QACA,WAAW,YAAY,KAAK,CAAC,MAAM,EAAE,aAAa,OAAO;QACzD,aAAa,YAAY,KAAK,CAAC,MAAM,EAAE,aAAa,MAAM;;IAE9D;;AAEJ;;;AClCO,IAAM,uBAAiC;EAC5C,IAAI;EACJ,a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,OAAO;AAAA,CAAI;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;","names":[]}
@@ -1,115 +0,0 @@
1
- ---
2
- name: specdx-author-spec
3
- description: Guided spec authoring with iterative linting. Use when the user wants to create a new spec, write a PRD, document a technical design, record an architecture decision, or add a user story.
4
- allowed-tools: Bash(npx specdx *), Read, Write, Edit
5
- ---
6
-
7
- # Author a Spec
8
-
9
- Guide the user through writing a spec. Walk through sections one at a time, lint iteratively, and produce a spec that passes `npx specdx lint`.
10
-
11
- ## Step 1: Determine the type
12
-
13
- Ask what kind of spec they need:
14
-
15
- | Type | Use when | Required sections |
16
- |---|---|---|
17
- | `prd` | Defining what to build | Problem Statement, Goals, Non-Goals, Features, Success Criteria |
18
- | `technical-design` | Describing how it works | Overview, Architecture, Data Model, API Design, Dependencies, Risks, Open Questions |
19
- | `user-story` | Capturing a user workflow | Description, Acceptance Criteria, Dependencies, Notes |
20
- | `test-plan` | Planning test coverage | Scope, Test Cases, Coverage Matrix, Edge Cases |
21
- | `adr` | Recording a decision | Context, Decision, Status, Consequences |
22
- | `api-contract` | Defining an API | Endpoints, Request/Response Schemas, Auth, Error Codes |
23
-
24
- ## Step 2: Check existing specs
25
-
26
- ```bash
27
- npx specdx validate
28
- npx specdx graph
29
- ```
30
-
31
- This shows what specs exist and their dependency relationships.
32
-
33
- ## Step 3: Create the file with frontmatter
34
-
35
- ```yaml
36
- ---
37
- id: "<type>-<short-name>"
38
- type: "<spec-type>"
39
- title: "<clear title>"
40
- status: "draft"
41
- version: "0.1"
42
- created: "<YYYY-MM-DD>"
43
- authors: ["<name>"]
44
- tags: ["<keyword>", "<keyword>"]
45
- references:
46
- - id: "<other-spec-id>"
47
- relationship: "depends-on"
48
- ---
49
- ```
50
-
51
- Rules:
52
- - **Always quote dates**: `"2026-03-18"` — unquoted YAML dates fail validation
53
- - **authors must have at least one entry** — `authors: []` fails validation
54
- - **id** must be unique across the spec suite
55
- - **type** must be one of: `prd`, `technical-design`, `user-story`, `test-plan`, `adr`, `api-contract`
56
- - **status** must be one of: `draft`, `review`, `approved`, `superseded`
57
- - **references.relationship** must be one of: `implemented-by`, `decomposed-into`, `depends-on`, `supersedes`, `related-to`
58
-
59
- ## Step 4: Write sections one at a time
60
-
61
- For each required section:
62
- 1. Explain what the section should contain
63
- 2. Ask the user for their thoughts
64
- 3. Draft the section
65
- 4. Refine based on feedback
66
-
67
- ### PRD tips
68
- - Use **F1**, **F2** etc. for features — the `story-coverage` lint rule checks each has a user story
69
- - Be specific in Non-Goals — this prevents scope creep
70
-
71
- ### Technical Design tips
72
- - Include concrete field names and types in Data Model
73
- - List specific risks with likelihood and mitigation
74
-
75
- ### ADR tips
76
- - State the decision in one clear sentence, then elaborate
77
- - List both positive AND negative consequences
78
-
79
- ## Step 5: Lint after every 2-3 sections
80
-
81
- ```bash
82
- npx specdx lint --path <file>
83
- ```
84
-
85
- Common issues:
86
-
87
- | Issue | Fix |
88
- |---|---|
89
- | Vague language ("as appropriate", "etc.", "TBD") | Replace with concrete language |
90
- | Missing required section | Add it, even if minimal |
91
- | Broken reference | Check the referenced spec ID exists |
92
-
93
- ## Step 6: Register in spec.config.yaml
94
-
95
- If this is a new spec, add it to `spec.config.yaml`:
96
-
97
- ```yaml
98
- specs:
99
- new-spec:
100
- path: specs/new-spec.md
101
- type: technical-design
102
- requires: ["prd"]
103
- ```
104
-
105
- The `requires` field establishes dependency relationships used by `specdx graph` and `specdx pack`.
106
-
107
- ## Step 7: Final validation
108
-
109
- ```bash
110
- npx specdx lint --path <file> --preset strict
111
- npx specdx lint
112
- npx specdx validate
113
- ```
114
-
115
- Report: spec type, file path, lint status, and any remaining warnings.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/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 },\n async run({ args }) {\n try {\n const result = await installSkills(args.dir);\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 } from \"node:fs/promises\";\nimport { statSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\n/** Skill directory names — each contains a SKILL.md file */\nexport const SKILL_DIRS = [\"specdx-start-task\", \"specdx-author-spec\"];\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\nexport async function installSkills(projectDir: string): Promise<InstallResult> {\n const sourceDir = getSkillSourceDir();\n const skillsDir = join(projectDir, \".claude\", \"skills\");\n const installed: string[] = [];\n const updated: string[] = [];\n\n for (const skillName of SKILL_DIRS) {\n const sourcePath = join(sourceDir, skillName, \"SKILL.md\");\n const targetDir = join(skillsDir, skillName);\n const targetPath = join(targetDir, \"SKILL.md\");\n\n const content = await readFile(sourcePath, \"utf-8\");\n\n // Check if target already exists\n let exists = false;\n try {\n await stat(targetPath);\n exists = true;\n } catch {\n // File doesn't exist\n }\n\n await mkdir(targetDir, { recursive: true });\n await writeFile(targetPath, content, \"utf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