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

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 (49) hide show
  1. package/.claude-plugin/plugin.json +6 -0
  2. package/dist/changelog-NPN34DIO.js +86 -0
  3. package/dist/changelog-NPN34DIO.js.map +1 -0
  4. package/dist/{chunk-NTNH2EPU.js → chunk-276J7LR6.js} +22 -18
  5. package/dist/chunk-276J7LR6.js.map +1 -0
  6. package/dist/{lint-3WMYPOU4.js → chunk-6DTOYCZ6.js} +4 -102
  7. package/dist/chunk-6DTOYCZ6.js.map +1 -0
  8. package/dist/chunk-AO3ZQKLJ.js +1147 -0
  9. package/dist/chunk-AO3ZQKLJ.js.map +1 -0
  10. package/dist/chunk-GAM4MXPC.js +15 -0
  11. package/dist/chunk-GAM4MXPC.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-GWJONALU.js +100 -0
  15. package/dist/diff-GWJONALU.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-GOJ4EJED.js → graph-OWQJWVSN.js} +7 -5
  19. package/dist/{graph-GOJ4EJED.js.map → graph-OWQJWVSN.js.map} +1 -1
  20. package/dist/index.js +1593 -11
  21. package/dist/index.js.map +1 -1
  22. package/dist/lint-CHWVBUV5.js +111 -0
  23. package/dist/lint-CHWVBUV5.js.map +1 -0
  24. package/dist/main.js +10 -6
  25. package/dist/main.js.map +1 -1
  26. package/dist/{pack-T4SVXU5B.js → pack-OJAC7JF2.js} +40 -8
  27. package/dist/pack-OJAC7JF2.js.map +1 -0
  28. package/dist/skills/spec-type-reference.md +57 -0
  29. package/dist/skills/{specdx-author-spec/SKILL.md → specdx-author-spec.md} +15 -1
  30. package/dist/skills/specdx-onboard.md +49 -0
  31. package/dist/skills/specdx-plan-from-spec.md +72 -0
  32. package/dist/skills/specdx-pre-commit.md +56 -0
  33. package/dist/skills/specdx-sprint-review.md +69 -0
  34. package/dist/skills/{specdx-start-task/SKILL.md → specdx-start-task.md} +1 -1
  35. package/dist/{skills-FVSFWYHN.js → skills-XJYTWGDK.js} +15 -9
  36. package/dist/skills-XJYTWGDK.js.map +1 -0
  37. package/dist/status-VMALGNS5.js +145 -0
  38. package/dist/status-VMALGNS5.js.map +1 -0
  39. package/dist/{validate-TGMAJAPX.js → validate-DOZZEZFC.js} +7 -5
  40. package/dist/{validate-TGMAJAPX.js.map → validate-DOZZEZFC.js.map} +1 -1
  41. package/hooks/hooks.json +8 -0
  42. package/hooks/run-hook.cmd +46 -0
  43. package/hooks/session-start +77 -0
  44. package/package.json +6 -3
  45. package/dist/chunk-CV2CHFFG.js.map +0 -1
  46. package/dist/chunk-NTNH2EPU.js.map +0 -1
  47. package/dist/lint-3WMYPOU4.js.map +0 -1
  48. package/dist/pack-T4SVXU5B.js.map +0 -1
  49. package/dist/skills-FVSFWYHN.js.map +0 -1
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: specdx-pre-commit
3
+ description: "Use when the user is about to commit, mentions committing, or says 'let's commit', 'ready to commit', 'wrap up', or 'commit this'. Checks spec health and flags drift before committing."
4
+ allowed-tools: Bash(npx specdx *)
5
+ ---
6
+
7
+ # Pre-Commit Spec Check
8
+
9
+ Run spec health checks before committing to catch drift early.
10
+
11
+ <HARD-GATE>
12
+ Do NOT skip the diff step. Even if the user says "just commit", run the checks and surface the results before proceeding. Silent skipping leads to undetected spec drift.
13
+ </HARD-GATE>
14
+
15
+ ## Workflow
16
+
17
+ ### Step 1: Lint
18
+
19
+ ```bash
20
+ npx specdx lint
21
+ ```
22
+
23
+ If lint errors are found, report them and ask the user to fix before committing.
24
+
25
+ ### Step 2: Diff
26
+
27
+ ```bash
28
+ npx specdx diff
29
+ ```
30
+
31
+ If the command fails (e.g. no git history), skip this step and note it.
32
+
33
+ ### Step 3: Present results
34
+
35
+ **If no spec changes detected:**
36
+ > "No spec changes — safe to commit."
37
+
38
+ **If changes detected, present a summary:**
39
+ - Which specs changed and what sections were modified
40
+ - Downstream specs that may need updating (with staleness scores)
41
+ - Whether any downstream specs are flagged as stale
42
+
43
+ ### Step 4: Ask the user
44
+
45
+ > "Do you want to update downstream specs before committing, or proceed as-is?"
46
+
47
+ Respect the user's decision either way.
48
+
49
+ ## Rationalizations to Resist
50
+
51
+ | Thought | Reality |
52
+ |---------|---------|
53
+ | "The user just wants to commit quickly" | A 5-second check prevents hours of drift debugging. |
54
+ | "There are no spec files in the diff" | Code changes can still drift from specs. Run the check. |
55
+ | "I already ran lint earlier" | Specs may have changed since. Run it again. |
56
+ | "The diff command failed, so skip everything" | Report the lint results at minimum. |
@@ -0,0 +1,69 @@
1
+ ---
2
+ name: specdx-sprint-review
3
+ description: "Use when the user asks for a summary, sprint review, spec health report, progress update, or says 'how are specs looking', 'spec health', or 'what changed'. Generates a shareable spec health report."
4
+ allowed-tools: Bash(npx specdx *)
5
+ ---
6
+
7
+ # Sprint Review — Spec Health Report
8
+
9
+ Generate a shareable summary of spec suite health and recent changes.
10
+
11
+ ## Workflow
12
+
13
+ ### Step 1: Get current health
14
+
15
+ ```bash
16
+ npx specdx status --format json
17
+ ```
18
+
19
+ Parse the JSON output to understand: project name, spec count, lint health (errors/warnings), stale specs, verdict.
20
+
21
+ ### Step 2: Get recent changes
22
+
23
+ ```bash
24
+ npx specdx diff --format json
25
+ ```
26
+
27
+ If this fails (e.g. no git history or no baseline branch), skip and note "diff unavailable".
28
+
29
+ Parse the JSON to understand: which specs changed, sections modified, downstream impact.
30
+
31
+ ### Step 3: Synthesise the report
32
+
33
+ Present a markdown report covering:
34
+
35
+ 1. **Health verdict** — healthy/warnings/errors with spec count
36
+ 2. **Lint status** — errors and warnings count
37
+ 3. **Recent changes** — specs added, modified, or removed (from diff)
38
+ 4. **Downstream impact** — which specs may need attention, staleness scores
39
+ 5. **Stale specs** — any specs not updated past the threshold
40
+ 6. **Recommended actions** — concrete suggestions (e.g. "technical-design hasn't been updated since prd changed 5 days ago")
41
+
42
+ ### Step 4: Format for sharing
43
+
44
+ Present the report in clean markdown that can be pasted directly into Slack, a PR description, or a standup document.
45
+
46
+ ## Reading the output
47
+
48
+ The `status --format json` output looks like:
49
+ ```json
50
+ {
51
+ "project": "my-project",
52
+ "specCount": 3,
53
+ "byStatus": {"approved": 2, "draft": 1},
54
+ "lintHealth": {"errors": 0, "warnings": 2, "passing": 3},
55
+ "staleSpecs": [{"specId": "tech", "daysSinceUpdate": 15}],
56
+ "verdict": "warnings"
57
+ }
58
+ ```
59
+
60
+ The `diff --format json` output looks like:
61
+ ```json
62
+ {
63
+ "diffs": [{"specId": "prd", "summary": "prd: 1 field(s) changed, 1 section(s) changed"}],
64
+ "added": [],
65
+ "removed": [],
66
+ "impact": [{"changedSpec": "prd", "downstream": [{"specId": "tech", "staleness": 0.7}]}],
67
+ "summary": "1 spec changed, 1 downstream affected"
68
+ }
69
+ ```
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: specdx-start-task
3
- description: Load relevant spec context before starting a coding task. Run this when the user describes work they're about to do, mentions implementing a feature, or asks to start a task. Packs project specs into the session so you have requirements, architecture, and constraints.
3
+ description: Use when the user describes work they're about to do, mentions implementing a feature, asks to start a task, or says 'implement', 'build', 'add', 'fix', or 'refactor'. Loads relevant spec context before coding.
4
4
  allowed-tools: Bash(npx specdx *)
5
5
  ---
6
6
 
@@ -7,7 +7,14 @@ import { statSync } from "fs";
7
7
  import { join, dirname } from "path";
8
8
  import { fileURLToPath } from "url";
9
9
  var __dirname = dirname(fileURLToPath(import.meta.url));
10
- var SKILL_DIRS = ["specdx-start-task", "specdx-author-spec"];
10
+ var SKILL_NAMES = [
11
+ "specdx-start-task",
12
+ "specdx-author-spec",
13
+ "specdx-pre-commit",
14
+ "specdx-sprint-review",
15
+ "specdx-plan-from-spec",
16
+ "specdx-onboard"
17
+ ];
11
18
  function getSkillSourceDir() {
12
19
  const bundledPath = join(__dirname, "skills");
13
20
  try {
@@ -19,13 +26,13 @@ function getSkillSourceDir() {
19
26
  }
20
27
  async function installSkills(projectDir) {
21
28
  const sourceDir = getSkillSourceDir();
22
- const skillsDir = join(projectDir, ".claude", "skills");
29
+ const commandsDir = join(projectDir, ".claude", "commands");
23
30
  const installed = [];
24
31
  const updated = [];
25
- for (const skillName of SKILL_DIRS) {
26
- const sourcePath = join(sourceDir, skillName, "SKILL.md");
27
- const targetDir = join(skillsDir, skillName);
28
- const targetPath = join(targetDir, "SKILL.md");
32
+ await mkdir(commandsDir, { recursive: true });
33
+ for (const skillName of SKILL_NAMES) {
34
+ const sourcePath = join(sourceDir, `${skillName}.md`);
35
+ const targetPath = join(commandsDir, `${skillName}.md`);
29
36
  const content = await readFile(sourcePath, "utf-8");
30
37
  let exists = false;
31
38
  try {
@@ -33,7 +40,6 @@ async function installSkills(projectDir) {
33
40
  exists = true;
34
41
  } catch {
35
42
  }
36
- await mkdir(targetDir, { recursive: true });
37
43
  await writeFile(targetPath, content, "utf-8");
38
44
  if (exists) {
39
45
  updated.push(skillName);
@@ -67,7 +73,7 @@ var skills_default = defineCommand({
67
73
  for (const file of result.installed) console.log(` \u2713 Installed ${file}`);
68
74
  for (const file of result.updated) console.log(` \u2713 Updated ${file}`);
69
75
  console.log(`
70
- Skills installed to .claude/skills/`);
76
+ Skills installed to .claude/commands/`);
71
77
  } catch (err) {
72
78
  console.error(`
73
79
  \u2717 ${err.message}
@@ -81,4 +87,4 @@ var skills_default = defineCommand({
81
87
  export {
82
88
  skills_default as default
83
89
  };
84
- //# sourceMappingURL=skills-FVSFWYHN.js.map
90
+ //# sourceMappingURL=skills-XJYTWGDK.js.map
@@ -0,0 +1 @@
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/commands/`);\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 file names (without .md extension) */\nexport const SKILL_NAMES = [\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];\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 commandsDir = join(projectDir, \".claude\", \"commands\");\n const installed: string[] = [];\n const updated: string[] = [];\n\n await mkdir(commandsDir, { recursive: true });\n\n for (const skillName of SKILL_NAMES) {\n const sourcePath = join(sourceDir, `${skillName}.md`);\n const targetPath = join(commandsDir, `${skillName}.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 writeFile(targetPath, content, \"utf-8\");\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,YAAY;AACjD,SAAS,gBAAgB;AACzB,SAAS,MAAM,eAAe;AAC9B,SAAS,qBAAqB;AAE9B,IAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AAGjD,IAAM,cAAc;EACzB;EACA;EACA;EACA;EACA;EACA;;AAQF,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;AAEA,eAAsB,cAAc,YAAkB;AACpD,QAAM,YAAY,kBAAiB;AACnC,QAAM,cAAc,KAAK,YAAY,WAAW,UAAU;AAC1D,QAAM,YAAsB,CAAA;AAC5B,QAAM,UAAoB,CAAA;AAE1B,QAAM,MAAM,aAAa,EAAE,WAAW,KAAI,CAAE;AAE5C,aAAW,aAAa,aAAa;AACnC,UAAM,aAAa,KAAK,WAAW,GAAG,SAAS,KAAK;AACpD,UAAM,aAAa,KAAK,aAAa,GAAG,SAAS,KAAK;AAEtD,UAAM,UAAU,MAAM,SAAS,YAAY,OAAO;AAGlD,QAAI,SAAS;AACb,QAAI;AACF,YAAM,KAAK,UAAU;AACrB,eAAS;IACX,QAAQ;IAER;AAEA,UAAM,UAAU,YAAY,SAAS,OAAO;AAE5C,QAAI,QAAQ;AACV,cAAQ,KAAK,SAAS;IACxB,OAAO;AACL,gBAAU,KAAK,SAAS;IAC1B;EACF;AAEA,SAAO,EAAE,WAAW,QAAO;AAC7B;;;ADhEA,IAAO,iBAAQ,cAAc;AAAA,EAC3B,MAAM,EAAE,MAAM,UAAU,aAAa,2CAA2C;AAAA,EAChF,aAAa;AAAA,IACX,SAAS,cAAc;AAAA,MACrB,MAAM,EAAE,MAAM,WAAW,aAAa,kCAAkC;AAAA,MACxE,MAAM;AAAA,QACJ,KAAK;AAAA,UACH,MAAM;AAAA,UACN,aAAa;AAAA,UACb,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA,MAAM,IAAI,EAAE,KAAK,GAAG;AAClB,YAAI;AACF,gBAAM,SAAS,MAAM,cAAc,KAAK,GAAG;AAC3C,cAAI,OAAO,UAAU,WAAW,KAAK,OAAO,QAAQ,WAAW,GAAG;AAChE,oBAAQ,IAAI,8BAA8B;AAC1C;AAAA,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,wCAA2C;AAAA,QACzD,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":[]}
@@ -0,0 +1,145 @@
1
+ import {
2
+ createLintEngine,
3
+ getPreset
4
+ } from "./chunk-6DTOYCZ6.js";
5
+ import {
6
+ DEFAULT_DIFF_CONFIG
7
+ } from "./chunk-AO3ZQKLJ.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-VMALGNS5.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,YAAY;AACd,gBAAY,YAAY,KAAK;AAAA,MAC3B,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,SAAS;AAAA,MACT,UAAU;A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AAS,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-NTNH2EPU.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-TGMAJAPX.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.2",
3
+ "version": "0.3.0-alpha.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "specdx": "./dist/main.js"
@@ -12,11 +12,13 @@
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",
19
- "typecheck": "tsc --build --noEmit",
21
+ "typecheck": "tsc --noEmit",
20
22
  "test": "vitest run",
21
23
  "clean": "rm -rf dist *.tsbuildinfo"
22
24
  },
@@ -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,MA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