specdx 0.4.0-alpha.2 → 0.4.0-alpha.21

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 (112) hide show
  1. package/.claude-plugin/plugin.json +7 -2
  2. package/LICENSE +21 -0
  3. package/README.md +477 -0
  4. package/dist/{check-PZFBVQIP.js → check-GGGHTDTH.js} +37 -11
  5. package/dist/check-GGGHTDTH.js.map +1 -0
  6. package/dist/{chunk-QEUZJWBY.js → chunk-3YXRWQGX.js} +373 -63
  7. package/dist/chunk-3YXRWQGX.js.map +1 -0
  8. package/dist/chunk-5WRI5ZAA.js +31 -0
  9. package/dist/chunk-6IVWJKMQ.js +103 -0
  10. package/dist/chunk-6IVWJKMQ.js.map +1 -0
  11. package/dist/{chunk-YDU26YTH.js → chunk-HCJDCS26.js} +121 -17
  12. package/dist/chunk-HCJDCS26.js.map +1 -0
  13. package/dist/chunk-IEW62WR2.js +185 -0
  14. package/dist/chunk-IEW62WR2.js.map +1 -0
  15. package/dist/chunk-PXQML7NE.js +2846 -0
  16. package/dist/chunk-PXQML7NE.js.map +1 -0
  17. package/dist/{chunk-PHWUK7TH.js → chunk-QOP2KHW3.js} +290 -52
  18. package/dist/chunk-QOP2KHW3.js.map +1 -0
  19. package/dist/{chunk-FZWT4HVX.js → chunk-SNQNQ2MP.js} +157 -3
  20. package/dist/chunk-SNQNQ2MP.js.map +1 -0
  21. package/dist/{chunk-YRDOYUKF.js → chunk-YRQPY5NF.js} +124 -19
  22. package/dist/chunk-YRQPY5NF.js.map +1 -0
  23. package/dist/diff-VHVSXLKU.js +188 -0
  24. package/dist/diff-VHVSXLKU.js.map +1 -0
  25. package/dist/{dist-2B2MR5AM.js → dist-QRCEQ5WI.js} +53 -14
  26. package/dist/dist-QRCEQ5WI.js.map +1 -0
  27. package/dist/dist-ROHCFKYT.js +16 -0
  28. package/dist/dist-ROHCFKYT.js.map +1 -0
  29. package/dist/generate-WMJ37LCN.js +21 -0
  30. package/dist/generate-WMJ37LCN.js.map +1 -0
  31. package/dist/{generate-story-AOALIKSD.js → generate-story-ORJX24P7.js} +48 -20
  32. package/dist/generate-story-ORJX24P7.js.map +1 -0
  33. package/dist/{generate-test-plan-34L6RGOB.js → generate-test-plan-Z46W3N3B.js} +63 -10
  34. package/dist/generate-test-plan-Z46W3N3B.js.map +1 -0
  35. package/dist/graph-TG2CONHV.js +103 -0
  36. package/dist/graph-TG2CONHV.js.map +1 -0
  37. package/dist/index.d.ts +171 -0
  38. package/dist/index.js +2648 -390
  39. package/dist/index.js.map +1 -1
  40. package/dist/{lint-XGVQ6LCP.js → lint-ZFG6ALIT.js} +23 -8
  41. package/dist/lint-ZFG6ALIT.js.map +1 -0
  42. package/dist/main.js +11 -146
  43. package/dist/main.js.map +1 -1
  44. package/dist/mcp-WBHZANS5.js +35 -0
  45. package/dist/mcp-WBHZANS5.js.map +1 -0
  46. package/dist/{migrate-KDJZQKP7.js → migrate-FKFC7UAO.js} +20 -8
  47. package/dist/migrate-FKFC7UAO.js.map +1 -0
  48. package/dist/{pack-OJ3CDZHD.js → pack-VDEO7GRF.js} +39 -11
  49. package/dist/pack-VDEO7GRF.js.map +1 -0
  50. package/dist/ready-VDOH3XCV.js +257 -0
  51. package/dist/ready-VDOH3XCV.js.map +1 -0
  52. package/dist/skills/{specdx-author-spec.md → core/specdx-author-spec/SKILL.md} +10 -6
  53. package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-01-frontmatter.md +1 -1
  54. package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-02-sections.md +41 -0
  55. package/dist/skills/{specdx-onboard.md → core/specdx-onboard/SKILL.md} +8 -3
  56. package/dist/skills/{specdx-plan-from-spec.md → core/specdx-plan-from-spec/SKILL.md} +5 -1
  57. package/dist/skills/{specdx-pre-commit.md → core/specdx-pre-commit/SKILL.md} +16 -2
  58. package/dist/skills/{specdx-review-spec.md → core/specdx-review-spec/SKILL.md} +5 -1
  59. package/dist/skills/core/specdx-router/SKILL.md +67 -0
  60. package/dist/skills/{specdx-sprint-review.md → core/specdx-sprint-review/SKILL.md} +5 -1
  61. package/dist/skills/{specdx-start-task.md → core/specdx-start-task/SKILL.md} +5 -1
  62. package/dist/skills/{specdx-check-drift.md → experimental/specdx-check-drift/SKILL.md} +10 -4
  63. package/dist/skills/{specdx-verify.md → experimental/specdx-verify/SKILL.md} +17 -2
  64. package/dist/skills-36SRUEMR.js +121 -0
  65. package/dist/skills-36SRUEMR.js.map +1 -0
  66. package/dist/{status-JVIXK73H.js → status-JIQUF6MX.js} +48 -34
  67. package/dist/status-JIQUF6MX.js.map +1 -0
  68. package/dist/{update-HFLDULNJ.js → update-DNXF5Q64.js} +10 -9
  69. package/dist/update-DNXF5Q64.js.map +1 -0
  70. package/dist/validate-TSAMI65E.js +87 -0
  71. package/dist/validate-TSAMI65E.js.map +1 -0
  72. package/hooks/hooks.json +12 -6
  73. package/hooks/session-start +35 -3
  74. package/package.json +68 -21
  75. package/dist/changelog-G6XDIAZP.js +0 -86
  76. package/dist/changelog-G6XDIAZP.js.map +0 -1
  77. package/dist/check-PZFBVQIP.js.map +0 -1
  78. package/dist/chunk-7C3BAVCP.js +0 -1147
  79. package/dist/chunk-7C3BAVCP.js.map +0 -1
  80. package/dist/chunk-FZWT4HVX.js.map +0 -1
  81. package/dist/chunk-PHWUK7TH.js.map +0 -1
  82. package/dist/chunk-QEUZJWBY.js.map +0 -1
  83. package/dist/chunk-YDU26YTH.js.map +0 -1
  84. package/dist/chunk-YRDOYUKF.js.map +0 -1
  85. package/dist/diff-BEZARP53.js +0 -100
  86. package/dist/diff-BEZARP53.js.map +0 -1
  87. package/dist/dist-2B2MR5AM.js.map +0 -1
  88. package/dist/dist-WIK7F2PJ.js +0 -11
  89. package/dist/explain-PCZKDEM4.js +0 -102
  90. package/dist/explain-PCZKDEM4.js.map +0 -1
  91. package/dist/generate-OMEBJQFQ.js +0 -13
  92. package/dist/generate-OMEBJQFQ.js.map +0 -1
  93. package/dist/generate-story-AOALIKSD.js.map +0 -1
  94. package/dist/generate-test-plan-34L6RGOB.js.map +0 -1
  95. package/dist/graph-RR5UTY3R.js +0 -54
  96. package/dist/graph-RR5UTY3R.js.map +0 -1
  97. package/dist/lint-XGVQ6LCP.js.map +0 -1
  98. package/dist/mcp-GUFW37BE.js +0 -17
  99. package/dist/mcp-GUFW37BE.js.map +0 -1
  100. package/dist/migrate-KDJZQKP7.js.map +0 -1
  101. package/dist/pack-OJ3CDZHD.js.map +0 -1
  102. package/dist/ready-WTNO5W7C.js +0 -165
  103. package/dist/ready-WTNO5W7C.js.map +0 -1
  104. package/dist/skills-3GBBWZW2.js +0 -93
  105. package/dist/skills-3GBBWZW2.js.map +0 -1
  106. package/dist/status-JVIXK73H.js.map +0 -1
  107. package/dist/update-HFLDULNJ.js.map +0 -1
  108. package/dist/validate-O7W5YLR6.js +0 -34
  109. package/dist/validate-O7W5YLR6.js.map +0 -1
  110. /package/dist/{dist-WIK7F2PJ.js.map → chunk-5WRI5ZAA.js.map} +0 -0
  111. /package/dist/skills/{spec-type-reference.md → core/specdx-author-spec/references/spec-type-reference.md} +0 -0
  112. /package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-03-finalize.md +0 -0
@@ -1,6 +1,9 @@
1
+ import {
2
+ buildRelationResolver
3
+ } from "./chunk-SNQNQ2MP.js";
1
4
  import {
2
5
  REQUIRED_SECTIONS
3
- } from "./chunk-YDU26YTH.js";
6
+ } from "./chunk-HCJDCS26.js";
4
7
 
5
8
  // ../lint/dist/engine.js
6
9
  function createLintEngine(options) {
@@ -15,7 +18,9 @@ function createLintEngine(options) {
15
18
  config: options.config,
16
19
  graph: options.graph
17
20
  });
18
- diagnostics.push(...results);
21
+ for (const diagnostic of results) {
22
+ diagnostics.push({ ...diagnostic, severity: rule.severity });
23
+ }
19
24
  }
20
25
  }
21
26
  return {
@@ -27,7 +32,165 @@ function createLintEngine(options) {
27
32
  };
28
33
  }
29
34
 
35
+ // ../lint/dist/rules/story-coverage.js
36
+ var STOPWORDS = /* @__PURE__ */ new Set([
37
+ "a",
38
+ "an",
39
+ "the",
40
+ "and",
41
+ "or",
42
+ "of",
43
+ "to",
44
+ "for",
45
+ "with",
46
+ "its",
47
+ "it",
48
+ "in",
49
+ "on",
50
+ "at",
51
+ "by",
52
+ "from",
53
+ "into",
54
+ "every",
55
+ "each",
56
+ "that",
57
+ "this",
58
+ "be",
59
+ "is",
60
+ "are",
61
+ "as",
62
+ "can",
63
+ "will",
64
+ "must",
65
+ "so",
66
+ "their",
67
+ "them",
68
+ "when",
69
+ "which",
70
+ "who"
71
+ ]);
72
+ var OVERLAP_THRESHOLD = 0.5;
73
+ var REFERENCED_THRESHOLD = 0.34;
74
+ function tokenise(text) {
75
+ const words = text.toLowerCase().replace(/[^a-z0-9\s-]/g, " ").split(/\s+/).filter((w) => w.length > 2 && !STOPWORDS.has(w)).map((w) => w.length > 3 && w.endsWith("s") && !w.endsWith("ss") ? w.slice(0, -1) : w);
76
+ return new Set(words);
77
+ }
78
+ function extractFeatureSection(content) {
79
+ const lines = content.split("\n");
80
+ const start = lines.findIndex((l) => /^##\s+Features\s*$/.test(l.trim()));
81
+ if (start === -1)
82
+ return null;
83
+ const body = [];
84
+ for (let i = start + 1; i < lines.length; i++) {
85
+ if (/^##\s/.test(lines[i]))
86
+ break;
87
+ body.push(lines[i]);
88
+ }
89
+ return body.join("\n");
90
+ }
91
+ function parseFeatures(content) {
92
+ return parseFeatureEntries(content).map((f) => f.text);
93
+ }
94
+ function parseFeatureEntries(content) {
95
+ const section = extractFeatureSection(content);
96
+ if (section === null)
97
+ return [];
98
+ const ID_PREFIX = /^\*{0,2}F(\d+)\*{0,2}\s*[:.-]\s*/i;
99
+ const features = [];
100
+ for (const rawLine of section.split("\n")) {
101
+ const line = rawLine.trim();
102
+ if (!line)
103
+ continue;
104
+ const bullet = /^[-*]\s+(.*)$/.exec(line);
105
+ const text = bullet ? (bullet[1] ?? "").trim() : ID_PREFIX.test(line) ? line : "";
106
+ if (!text)
107
+ continue;
108
+ const idMatch = ID_PREFIX.exec(text);
109
+ const stripped = text.replace(ID_PREFIX, "").trim();
110
+ if (stripped)
111
+ features.push({ text: stripped, num: idMatch?.[1] });
112
+ }
113
+ return features;
114
+ }
115
+ function overlap(featureTokens, storyTokens) {
116
+ if (featureTokens.size === 0)
117
+ return 0;
118
+ let shared = 0;
119
+ for (const token of featureTokens)
120
+ if (storyTokens.has(token))
121
+ shared++;
122
+ return shared / featureTokens.size;
123
+ }
124
+ function referencesSpec(story, specId) {
125
+ const refs = story.frontmatter.references;
126
+ if (!Array.isArray(refs))
127
+ return false;
128
+ return refs.some((r) => r?.id === specId);
129
+ }
130
+ function uncoveredFeatures(features, stories, prdId) {
131
+ const scored = stories.map((story) => ({
132
+ tokens: tokenise(`${String(story.frontmatter.title ?? "")} ${story.content}`),
133
+ threshold: referencesSpec(story, prdId) ? REFERENCED_THRESHOLD : OVERLAP_THRESHOLD
134
+ }));
135
+ const tokenised = features.map(tokenise);
136
+ return features.filter((_feature, i) => {
137
+ const featureTokens = tokenised[i];
138
+ const distinctive = distinctiveTokens(featureTokens, tokenised, i);
139
+ return !scored.some((s) => overlap(featureTokens, s.tokens) >= s.threshold && covers(distinctive, featureTokens, s.tokens));
140
+ });
141
+ }
142
+ function covers(distinctive, featureTokens, storyTokens) {
143
+ if (distinctive.size === 0 || distinctive.size === featureTokens.size)
144
+ return true;
145
+ let matched = 0;
146
+ for (const token of distinctive)
147
+ if (storyTokens.has(token))
148
+ matched++;
149
+ return matched > distinctive.size / 2;
150
+ }
151
+ function distinctiveTokens(featureTokens, allFeatureTokens, index) {
152
+ const distinctive = new Set(featureTokens);
153
+ for (let i = 0; i < allFeatureTokens.length; i++) {
154
+ if (i === index)
155
+ continue;
156
+ for (const token of allFeatureTokens[i])
157
+ distinctive.delete(token);
158
+ }
159
+ return distinctive;
160
+ }
161
+ var storyCoverageRule = {
162
+ id: "completeness/story-coverage",
163
+ description: "Every feature listed in a PRD has at least one corresponding user story",
164
+ severity: "warn",
165
+ run(context) {
166
+ if (context.spec.frontmatter.type !== "prd")
167
+ return [];
168
+ const features = parseFeatures(context.spec.content);
169
+ if (features.length === 0)
170
+ return [];
171
+ const stories = context.allSpecs.filter((s) => s.frontmatter.type === "user-story");
172
+ return uncoveredFeatures(features, stories, context.spec.frontmatter.id).map((feature) => ({
173
+ ruleId: "completeness/story-coverage",
174
+ severity: "warn",
175
+ message: `Feature "${feature}" has no corresponding user story`,
176
+ filePath: context.spec.filePath
177
+ }));
178
+ }
179
+ };
180
+
30
181
  // ../lint/dist/rules/valid-frontmatter.js
182
+ function readablePath(instancePath) {
183
+ return instancePath.split("/").filter(Boolean).map((segment) => /^\d+$/.test(segment) ? `[${segment}]` : `.${segment}`).join("").replace(/^\./, "");
184
+ }
185
+ function describeValidationError(err) {
186
+ const path = readablePath(err.instancePath ?? "");
187
+ const allowed = err.params?.allowedValues;
188
+ let detail = err.message ?? JSON.stringify(err);
189
+ if (Array.isArray(allowed) && allowed.length > 0) {
190
+ detail += `: ${allowed.map((v) => JSON.stringify(v)).join(", ")}`;
191
+ }
192
+ return path ? `${path} ${detail}` : detail;
193
+ }
31
194
  var validFrontmatterRule = {
32
195
  id: "structure/valid-frontmatter",
33
196
  description: "Frontmatter matches the schema for the declared spec type",
@@ -39,7 +202,7 @@ var validFrontmatterRule = {
39
202
  return errors.map((err) => ({
40
203
  ruleId: "structure/valid-frontmatter",
41
204
  severity: "error",
42
- message: `Invalid frontmatter: ${err.message ?? JSON.stringify(err)}`,
205
+ message: `Invalid frontmatter: ${describeValidationError(err)}`,
43
206
  filePath: context.spec.filePath
44
207
  }));
45
208
  }
@@ -98,59 +261,58 @@ var noCircularDepsRule = {
98
261
  }
99
262
  };
100
263
 
101
- // ../lint/dist/rules/story-coverage.js
102
- var FEATURE_PATTERN = /\*\*F\d+\*\*:\s*(.+)/g;
103
- var storyCoverageRule = {
104
- id: "completeness/story-coverage",
105
- description: "Every feature listed in a PRD has at least one corresponding user story",
106
- severity: "warn",
107
- run(context) {
108
- if (context.spec.frontmatter.type !== "prd")
109
- return [];
110
- const features = [];
111
- let match;
112
- const re = new RegExp(FEATURE_PATTERN.source, "g");
113
- while ((match = re.exec(context.spec.content)) !== null) {
114
- features.push(match[1].trim());
264
+ // ../lint/dist/rules/staleness-check.js
265
+ function groupByEntry(config, specs) {
266
+ const byEntry = /* @__PURE__ */ new Map();
267
+ for (const key of Object.keys(config.specs))
268
+ byEntry.set(key, []);
269
+ for (const spec of specs) {
270
+ let bestKey;
271
+ let bestLen = -1;
272
+ for (const [key, entry] of Object.entries(config.specs)) {
273
+ const prefix = entry.path.split("*")[0] ?? "";
274
+ const normalized = spec.filePath.replace(/\\/g, "/");
275
+ if (normalized.includes(prefix) && prefix.length > bestLen) {
276
+ bestKey = key;
277
+ bestLen = prefix.length;
278
+ }
115
279
  }
116
- if (features.length === 0)
117
- return [];
118
- const stories = context.allSpecs.filter((s) => s.frontmatter.type === "user-story");
119
- const storyContent = stories.map((s) => s.content + " " + s.frontmatter.title).join(" ");
120
- return features.filter((feature) => !storyContent.toLowerCase().includes(feature.toLowerCase())).map((feature) => ({
121
- ruleId: "completeness/story-coverage",
122
- severity: "warn",
123
- message: `Feature "${feature}" has no corresponding user story`,
124
- filePath: context.spec.filePath
125
- }));
280
+ if (bestKey)
281
+ byEntry.get(bestKey).push(spec);
126
282
  }
127
- };
128
-
129
- // ../lint/dist/rules/staleness-check.js
283
+ return byEntry;
284
+ }
285
+ function lastUpdated(spec) {
286
+ return spec.frontmatter.updated ?? spec.frontmatter.created ?? "";
287
+ }
130
288
  var stalenessCheckRule = {
131
289
  id: "freshness/staleness-check",
132
290
  description: "Warns if a spec hasn't been updated since its upstream dependency changed",
133
291
  severity: "warn",
134
292
  run(context) {
135
- const refs = context.spec.frontmatter.references;
136
- if (!refs || refs.length === 0)
293
+ const specId = context.spec.frontmatter.id;
294
+ if (typeof specId !== "string")
295
+ return [];
296
+ const specUpdated = lastUpdated(context.spec);
297
+ if (!specUpdated)
137
298
  return [];
138
- const specUpdated = context.spec.frontmatter.updated ?? context.spec.frontmatter.created;
139
299
  const specDate = new Date(specUpdated);
300
+ const byEntry = context.config ? groupByEntry(context.config, context.allSpecs) : /* @__PURE__ */ new Map([["", context.allSpecs]]);
301
+ const relations = buildRelationResolver(context.config, byEntry);
302
+ const upstreamIds = relations.getUpstream(specId);
140
303
  const diagnostics = [];
141
- for (const ref of refs) {
142
- if (ref.relationship !== "depends-on" && ref.relationship !== "implemented-by")
143
- continue;
144
- const upstream = context.allSpecs.find((s) => s.frontmatter.id === ref.id);
304
+ for (const upstreamId of upstreamIds) {
305
+ const upstream = context.allSpecs.find((s) => s.frontmatter.id === upstreamId);
145
306
  if (!upstream)
146
307
  continue;
147
- const upstreamUpdated = upstream.frontmatter.updated ?? upstream.frontmatter.created;
148
- const upstreamDate = new Date(upstreamUpdated);
149
- if (upstreamDate > specDate) {
308
+ const upstreamUpdated = lastUpdated(upstream);
309
+ if (!upstreamUpdated)
310
+ continue;
311
+ if (new Date(upstreamUpdated) > specDate) {
150
312
  diagnostics.push({
151
313
  ruleId: "freshness/staleness-check",
152
314
  severity: "warn",
153
- message: `Potentially stale: upstream "${upstream.frontmatter.id}" was updated on ${upstreamUpdated}, but this spec was last updated on ${specUpdated}`,
315
+ message: `Potentially stale: upstream "${upstreamId}" was updated on ${upstreamUpdated}, but this spec was last updated on ${specUpdated}`,
154
316
  filePath: context.spec.filePath
155
317
  });
156
318
  }
@@ -292,13 +454,27 @@ var EDGE_CASE_KEYWORDS = [
292
454
  "reject",
293
455
  "unauthorized",
294
456
  "forbidden",
295
- "404",
296
- "500",
297
457
  "missing",
298
458
  "malformed",
299
459
  "overflow",
300
- "duplicate"
460
+ "duplicate",
461
+ "graceful",
462
+ "fall back",
463
+ "fallback",
464
+ "crash",
465
+ "nonexistent",
466
+ "corrupt",
467
+ // Vocabulary that names a failure without using any of the words above.
468
+ "conflict",
469
+ "denied",
470
+ "expired",
471
+ "not found",
472
+ "retry",
473
+ "rate limit",
474
+ "unavailable",
475
+ "unprocessable"
301
476
  ];
477
+ var ERROR_STATUS_CODE = /\b[45]\d{2}\b/;
302
478
  var edgeCaseCoverageRule = {
303
479
  id: "completeness/edge-case-coverage",
304
480
  description: "Flag user stories or test plans that don't mention error states or edge cases",
@@ -308,7 +484,7 @@ var edgeCaseCoverageRule = {
308
484
  if (type !== "user-story" && type !== "test-plan")
309
485
  return [];
310
486
  const content = context.spec.content.toLowerCase();
311
- const hasEdgeCases = EDGE_CASE_KEYWORDS.some((kw) => content.includes(kw));
487
+ const hasEdgeCases = EDGE_CASE_KEYWORDS.some((kw) => content.includes(kw)) || ERROR_STATUS_CODE.test(content);
312
488
  if (hasEdgeCases)
313
489
  return [];
314
490
  return [
@@ -379,7 +555,7 @@ var namingConventionsRule = {
379
555
  };
380
556
 
381
557
  // ../lint/dist/rules/threat-coverage.js
382
- var STOPWORDS = /* @__PURE__ */ new Set(["the", "and", "for", "with", "from", "that", "this", "into", "via"]);
558
+ var STOPWORDS2 = /* @__PURE__ */ new Set(["the", "and", "for", "with", "from", "that", "this", "into", "via"]);
383
559
  function extractThreats(content) {
384
560
  const parts = content.split(/^(?=## )/m);
385
561
  const threats = [];
@@ -392,7 +568,7 @@ function extractThreats(content) {
392
568
  return threats;
393
569
  }
394
570
  function extractKeyTerms(text) {
395
- return text.toLowerCase().split(/\W+/).filter((w) => w.length > 3).filter((w) => !STOPWORDS.has(w));
571
+ return text.toLowerCase().split(/\W+/).filter((w) => w.length > 3).filter((w) => !STOPWORDS2.has(w));
396
572
  }
397
573
  var threatCoverageRule = {
398
574
  id: "security/threat-coverage",
@@ -439,20 +615,78 @@ var ambiguityScoreAiRule = {
439
615
  {
440
616
  ruleId: "clarity/ambiguity-score-ai",
441
617
  severity: "info",
442
- message: "AI ambiguity analysis available \u2014 run `sdx check --ai` for LLM-powered ambiguity detection",
618
+ message: "AI ambiguity analysis available \u2014 run `specdx check --ai` for LLM-powered ambiguity detection",
443
619
  filePath: context.spec.filePath
444
620
  }
445
621
  ];
446
622
  }
447
623
  };
448
624
 
625
+ // ../lint/dist/rules/no-placeholder-sections.js
626
+ var PLACEHOLDER_BODIES = /^(todo|tbd|fixme|n\/a|na|none|xxx|\.{2,}|-|\*)$/i;
627
+ function meaningfulContent(content) {
628
+ return content.replace(/<!--[\s\S]*?-->/g, "").split("\n").map((line) => line.replace(/^\s*[-*+]\s+/, "").trim()).filter((line) => line.length > 0 && !/^-{3,}$/.test(line)).join("\n").trim();
629
+ }
630
+ var noPlaceholderSectionsRule = {
631
+ id: "completeness/no-placeholder-sections",
632
+ description: "Spec sections contain content, not scaffolding placeholders",
633
+ severity: "warn",
634
+ run(context) {
635
+ return context.spec.parsedSections.filter((section) => section.heading !== "").filter((section) => {
636
+ const body = meaningfulContent(section.content);
637
+ return body === "" || PLACEHOLDER_BODIES.test(body);
638
+ }).map((section) => ({
639
+ ruleId: "completeness/no-placeholder-sections",
640
+ severity: "warn",
641
+ message: `Section "${section.heading}" is still a placeholder \u2014 write its content or remove the section`,
642
+ filePath: context.spec.filePath,
643
+ section: section.heading
644
+ }));
645
+ }
646
+ };
647
+
648
+ // ../lint/dist/rules/id-matches-config-key.js
649
+ import { basename } from "path";
650
+ var idMatchesConfigKeyRule = {
651
+ id: "structure/id-matches-config-key",
652
+ description: "A spec's frontmatter id should match the key it is registered under in the config",
653
+ severity: "warn",
654
+ run(context) {
655
+ const { spec, config } = context;
656
+ if (!config)
657
+ return [];
658
+ const id = spec.frontmatter.id;
659
+ if (typeof id !== "string" || id.length === 0)
660
+ return [];
661
+ const specFile = basename(spec.filePath);
662
+ const candidates = Object.entries(config.specs).filter(([, entry]) => {
663
+ const target = basename(entry.path);
664
+ return !target.includes("*") && target === specFile;
665
+ });
666
+ if (candidates.length !== 1)
667
+ return [];
668
+ const key = candidates[0][0];
669
+ if (key === id)
670
+ return [];
671
+ return [
672
+ {
673
+ ruleId: "structure/id-matches-config-key",
674
+ severity: "warn",
675
+ message: `Spec declares id "${id}" but is registered in spec.config.yaml as "${key}". Frontmatter references resolve against "${id}" and config requires against "${key}", so the dependency graph shows them as two things. Rename one so they agree.`,
676
+ filePath: spec.filePath
677
+ }
678
+ ];
679
+ }
680
+ };
681
+
449
682
  // ../lint/dist/rules/index.js
450
683
  var structureRules = [
451
684
  validFrontmatterRule,
452
685
  requiredSectionsRule,
453
686
  validReferencesRule,
454
687
  noCircularDepsRule,
455
- singleProjectContextRule
688
+ singleProjectContextRule,
689
+ idMatchesConfigKeyRule
456
690
  ];
457
691
  var contentRules = [
458
692
  storyCoverageRule,
@@ -462,7 +696,8 @@ var contentRules = [
462
696
  edgeCaseCoverageRule,
463
697
  namingConventionsRule,
464
698
  threatCoverageRule,
465
- ambiguityScoreAiRule
699
+ ambiguityScoreAiRule,
700
+ noPlaceholderSectionsRule
466
701
  ];
467
702
  var allBuiltinRules = [...structureRules, ...contentRules];
468
703
 
@@ -474,7 +709,7 @@ function getPreset(name) {
474
709
  case "recommended":
475
710
  return allBuiltinRules;
476
711
  case "strict":
477
- return allBuiltinRules.map((rule) => ({ ...rule, severity: "error" }));
712
+ return allBuiltinRules.map((rule) => rule.severity === "warn" ? { ...rule, severity: "error" } : rule);
478
713
  default:
479
714
  throw new Error(`Unknown preset: "${name}". Use "minimal", "recommended", or "strict", or resolve external presets via resolvePreset() from @specdx/core.`);
480
715
  }
@@ -485,6 +720,9 @@ import { pathToFileURL } from "url";
485
720
 
486
721
  export {
487
722
  createLintEngine,
723
+ parseFeatures,
724
+ parseFeatureEntries,
725
+ uncoveredFeatures,
488
726
  getPreset
489
727
  };
490
- //# sourceMappingURL=chunk-PHWUK7TH.js.map
728
+ //# sourceMappingURL=chunk-QOP2KHW3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../lint/src/engine.ts","../../lint/src/rules/story-coverage.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/staleness-check.ts","../../lint/src/rules/no-vague-language.ts","../../lint/src/rules/single-project-context.ts","../../lint/src/rules/terminology.ts","../../lint/src/rules/edge-case-coverage.ts","../../lint/src/rules/naming-conventions.ts","../../lint/src/rules/threat-coverage.ts","../../lint/src/rules/ambiguity-score-ai.ts","../../lint/src/rules/no-placeholder-sections.ts","../../lint/src/rules/id-matches-config-key.ts","../../lint/src/rules/index.ts","../../lint/src/presets.ts","../../lint/src/custom-rule-loader.ts"],"sourcesContent":["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 // The rule object's `severity` is the authority, not the severity a\n // rule happens to write into the diagnostic it returns.\n //\n // Every built-in rule emits exactly one severity -- its own -- but ten\n // of them hardcoded it as a literal in the diagnostic. Presets rewrite\n // `rule.severity`, so nothing downstream read what `strict` set, and\n // `--preset strict` produced output byte-identical to `recommended` on\n // the CLI, in `extends:`, in the Action's `preset` input and in\n // `runLint({ preset })`. Stamping it here is what makes a preset mean\n // anything.\n for (const diagnostic of results) {\n diagnostics.push({ ...diagnostic, severity: rule.severity });\n }\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\";\nimport type { ParsedSpec } from \"@specdx/core\";\n\n/** Words carrying no signal about what a feature is. */\nconst STOPWORDS = new Set([\n \"a\",\n \"an\",\n \"the\",\n \"and\",\n \"or\",\n \"of\",\n \"to\",\n \"for\",\n \"with\",\n \"its\",\n \"it\",\n \"in\",\n \"on\",\n \"at\",\n \"by\",\n \"from\",\n \"into\",\n \"every\",\n \"each\",\n \"that\",\n \"this\",\n \"be\",\n \"is\",\n \"are\",\n \"as\",\n \"can\",\n \"will\",\n \"must\",\n \"so\",\n \"their\",\n \"them\",\n \"when\",\n \"which\",\n \"who\",\n]);\n\n/** Share of a feature's words a story must echo to count as covering it. */\nconst OVERLAP_THRESHOLD = 0.5;\n\n/** Lower bar for a story that explicitly references the PRD. */\nconst REFERENCED_THRESHOLD = 0.34;\n\nfunction tokenise(text: string): Set<string> {\n const words = text\n .toLowerCase()\n .replace(/[^a-z0-9\\s-]/g, \" \")\n .split(/\\s+/)\n .filter((w) => w.length > 2 && !STOPWORDS.has(w))\n // Crude singularisation, so \"actions\" matches \"action\".\n .map((w) => (w.length > 3 && w.endsWith(\"s\") && !w.endsWith(\"ss\") ? w.slice(0, -1) : w));\n return new Set(words);\n}\n\nfunction extractFeatureSection(content: string): string | null {\n // Scanned line by line rather than with one regex: `$` and `\\Z` behave\n // differently enough across multiline modes to make the regex form a trap.\n const lines = content.split(\"\\n\");\n const start = lines.findIndex((l) => /^##\\s+Features\\s*$/.test(l.trim()));\n if (start === -1) return null;\n const body: string[] = [];\n for (let i = start + 1; i < lines.length; i++) {\n if (/^##\\s/.test(lines[i]!)) break;\n body.push(lines[i]!);\n }\n return body.join(\"\\n\");\n}\n\n/**\n * Feature descriptions from a PRD's Features section.\n *\n * Previously only `- **F1**: text` was recognised, so a PRD written any other\n * way parsed to zero features and the rule passed vacuously -- which `ready`\n * then reported as \"all features have stories\" over an empty set.\n */\nexport function parseFeatures(content: string): string[] {\n return parseFeatureEntries(content).map((f) => f.text);\n}\n\n/** A PRD feature, with its `F<N>` number when the author gave it one. */\nexport interface FeatureEntry {\n /** The feature description, with any ID prefix removed. */\n text: string;\n /** The `N` from `**F<N>**:`, when present. */\n num?: string;\n}\n\n/**\n * The single source of truth for what counts as a feature in a PRD.\n *\n * `generate story` used to carry its own regex requiring `**F<N>**:`, so on a\n * PRD without those IDs the lint rule reported three features and the generator\n * reported none -- two commands in the same suite contradicting each other over\n * one file. Anything that needs to know what a PRD's features are calls this.\n */\nexport function parseFeatureEntries(content: string): FeatureEntry[] {\n const section = extractFeatureSection(content);\n if (section === null) return [];\n\n /** `**F1**:`, `F1:`, `F1 -` — an optional feature ID prefix. */\n const ID_PREFIX = /^\\*{0,2}F(\\d+)\\*{0,2}\\s*[:.-]\\s*/i;\n\n const features: FeatureEntry[] = [];\n for (const rawLine of section.split(\"\\n\")) {\n const line = rawLine.trim();\n if (!line) continue;\n\n const bullet = /^[-*]\\s+(.*)$/.exec(line);\n // A bullet is a feature whether or not it carries an ID. A non-bullet line\n // counts only when it does, so ordinary prose in the section is not\n // mistaken for a feature list.\n const text = bullet ? (bullet[1] ?? \"\").trim() : ID_PREFIX.test(line) ? line : \"\";\n if (!text) continue;\n\n const idMatch = ID_PREFIX.exec(text);\n const stripped = text.replace(ID_PREFIX, \"\").trim();\n if (stripped) features.push({ text: stripped, num: idMatch?.[1] });\n }\n return features;\n}\n\nfunction overlap(featureTokens: Set<string>, storyTokens: Set<string>): number {\n if (featureTokens.size === 0) return 0;\n let shared = 0;\n for (const token of featureTokens) if (storyTokens.has(token)) shared++;\n return shared / featureTokens.size;\n}\n\nfunction referencesSpec(story: ParsedSpec, specId: unknown): boolean {\n const refs = story.frontmatter.references;\n if (!Array.isArray(refs)) return false;\n return refs.some((r) => (r as { id?: unknown })?.id === specId);\n}\n\n/**\n * Features from `features` that no story in `stories` appears to cover.\n *\n * Exported so the linter and `generate story` share one definition of\n * \"covered\". They had two, which is why the rule warned about features that\n * had stories while the generator re-stubbed features that already had them.\n */\nexport function uncoveredFeatures(\n features: string[],\n stories: ParsedSpec[],\n prdId: unknown,\n): string[] {\n const scored = stories.map((story) => ({\n tokens: tokenise(`${String(story.frontmatter.title ?? \"\")} ${story.content}`),\n threshold: referencesSpec(story, prdId) ? REFERENCED_THRESHOLD : OVERLAP_THRESHOLD,\n }));\n\n const tokenised = features.map(tokenise);\n\n return features.filter((_feature, i) => {\n const featureTokens = tokenised[i]!;\n // What makes *this* feature different from its siblings. Share of words\n // alone is not enough: \"Export the payroll report as PDF\" and \"Export the\n // invoice report as CSV\" agree on half their words, so a story covering one\n // was read as covering both -- and `ready` then asserted that every feature\n // had a story while one plainly had none. A story only covers a feature if\n // it also mentions something that sets that feature apart.\n const distinctive = distinctiveTokens(featureTokens, tokenised, i);\n return !scored.some(\n (s) =>\n overlap(featureTokens, s.tokens) >= s.threshold &&\n covers(distinctive, featureTokens, s.tokens),\n );\n });\n}\n\n/**\n * Whether a story picks up more than half of what sets a feature apart from its\n * siblings.\n *\n * One distinctive word is not enough on its own. \"List customers for the\n * finance console\" is set apart by *finance* and *console*, and a story about\n * amending invoices that opens \"as a member of finance\" hits one of the two —\n * enough to be waved through by a \"matches something distinctive\" test, and\n * plainly not a story about the finance console.\n *\n * Two cases hand the decision back to the overlap threshold alone, because in\n * both of them distinctiveness carries no information:\n *\n * - Nothing is distinctive. Two features written in near-identical words are\n * genuinely indistinguishable to a word-overlap rule.\n * - Everything is distinctive. No sibling shares a word, so no sibling's\n * vocabulary inflated the overlap score in the first place — and demanding\n * half of a long feature description would reject the short, accurate story\n * titles this rule exists to accept.\n */\nfunction covers(\n distinctive: Set<string>,\n featureTokens: Set<string>,\n storyTokens: Set<string>,\n): boolean {\n if (distinctive.size === 0 || distinctive.size === featureTokens.size) return true;\n let matched = 0;\n for (const token of distinctive) if (storyTokens.has(token)) matched++;\n return matched > distinctive.size / 2;\n}\n\n/**\n * The tokens of `features[index]` that no sibling feature uses.\n */\nfunction distinctiveTokens(\n featureTokens: Set<string>,\n allFeatureTokens: Set<string>[],\n index: number,\n): Set<string> {\n const distinctive = new Set(featureTokens);\n for (let i = 0; i < allFeatureTokens.length; i++) {\n if (i === index) continue;\n for (const token of allFeatureTokens[i]!) distinctive.delete(token);\n }\n return distinctive;\n}\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\n const features = parseFeatures(context.spec.content);\n if (features.length === 0) return [];\n\n const stories = context.allSpecs.filter((s) => s.frontmatter.type === \"user-story\");\n\n return uncoveredFeatures(features, stories, context.spec.frontmatter.id).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\n/**\n * The shape of an ajv error, described structurally.\n *\n * Typed here rather than imported so the lint package does not take a\n * dependency on ajv for a single type.\n */\ninterface ValidationError {\n instancePath?: string;\n message?: string;\n params?: Record<string, unknown>;\n}\n\n/** `/references/0/relationship` -> `references[0].relationship`. */\nfunction readablePath(instancePath: string): string {\n return instancePath\n .split(\"/\")\n .filter(Boolean)\n .map((segment) => (/^\\d+$/.test(segment) ? `[${segment}]` : `.${segment}`))\n .join(\"\")\n .replace(/^\\./, \"\");\n}\n\n/**\n * Turn one ajv error into something a spec author can act on.\n *\n * ajv only names the offending field inside `message` for `required`\n * violations. For `enum`, `const` and `type` the field lives in `instancePath`\n * and the acceptable values in `params`, so a bare `err.message` reads\n * \"must be equal to one of the allowed values\" and identifies nothing -- which\n * is what every `references:` entry produced.\n */\nexport function describeValidationError(err: ValidationError): string {\n const path = readablePath(err.instancePath ?? \"\");\n const allowed = (err.params as { allowedValues?: unknown[] } | undefined)?.allowedValues;\n\n let detail = err.message ?? JSON.stringify(err);\n if (Array.isArray(allowed) && allowed.length > 0) {\n detail += `: ${allowed.map((v) => JSON.stringify(v)).join(\", \")}`;\n }\n\n return path ? `${path} ${detail}` : detail;\n}\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: ${describeValidationError(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 { buildRelationResolver } from \"@specdx/core\";\nimport type { ParsedSpec } from \"@specdx/core\";\nimport type { SdxConfig } from \"@specdx/schema\";\nimport type { LintRule } from \"../types.js\";\n\n/**\n * Group specs by the config entry whose glob they came from, so config\n * `requires` edges can be mapped into spec id space. Matching is by the entry\n * path's directory prefix, which is enough for the resolver: an id that maps\n * to no entry simply contributes no `requires` edges.\n */\nfunction groupByEntry(config: SdxConfig, specs: ParsedSpec[]): Map<string, ParsedSpec[]> {\n const byEntry = new Map<string, ParsedSpec[]>();\n for (const key of Object.keys(config.specs)) byEntry.set(key, []);\n\n for (const spec of specs) {\n let bestKey: string | undefined;\n let bestLen = -1;\n for (const [key, entry] of Object.entries(config.specs)) {\n const prefix = entry.path.split(\"*\")[0] ?? \"\";\n const normalized = spec.filePath.replace(/\\\\/g, \"/\");\n if (normalized.includes(prefix) && prefix.length > bestLen) {\n bestKey = key;\n bestLen = prefix.length;\n }\n }\n if (bestKey) byEntry.get(bestKey)!.push(spec);\n }\n return byEntry;\n}\n\nfunction lastUpdated(spec: ParsedSpec): string {\n return (\n (spec.frontmatter.updated as string | undefined) ?? (spec.frontmatter.created as string) ?? \"\"\n );\n}\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 specId = context.spec.frontmatter.id;\n if (typeof specId !== \"string\") return [];\n\n const specUpdated = lastUpdated(context.spec);\n if (!specUpdated) return [];\n const specDate = new Date(specUpdated);\n\n // Upstream comes from config `requires` and frontmatter `references`\n // unioned, so a suite declaring dependencies either way gets the same\n // answer (ADR: references/requires unification).\n const byEntry = context.config\n ? groupByEntry(context.config, context.allSpecs)\n : new Map([[\"\", context.allSpecs]]);\n const relations = buildRelationResolver(context.config, byEntry);\n const upstreamIds = relations.getUpstream(specId);\n\n const diagnostics = [];\n for (const upstreamId of upstreamIds) {\n const upstream = context.allSpecs.find((s) => s.frontmatter.id === upstreamId);\n if (!upstream) continue;\n const upstreamUpdated = lastUpdated(upstream);\n if (!upstreamUpdated) continue;\n\n if (new Date(upstreamUpdated) > specDate) {\n diagnostics.push({\n ruleId: \"freshness/staleness-check\",\n severity: \"warn\" as const,\n message: `Potentially stale: upstream \"${upstreamId}\" 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 type { LintRule } from \"../types.js\";\n\nexport const singleProjectContextRule: LintRule = {\n id: \"structure/single-project-context\",\n description: \"Only one project-context spec should exist per suite\",\n severity: \"warn\",\n run(context) {\n if (context.spec.frontmatter.type !== \"project-context\") return [];\n\n const contextSpecs = context.allSpecs.filter((s) => s.frontmatter.type === \"project-context\");\n\n if (contextSpecs.length > 1) {\n return [\n {\n ruleId: \"structure/single-project-context\",\n severity: \"warn\" as const,\n message: `Multiple project-context specs found (${contextSpecs.length}). Only one should exist per suite.`,\n filePath: context.spec.filePath,\n },\n ];\n }\n\n return [];\n },\n};\n","import type { LintRule } from \"../types.js\";\n\nfunction normalizeCompound(term: string): string {\n // Split camelCase: \"UserProfile\" → \"user profile\"\n // Split hyphens/underscores: \"user-profile\" → \"user profile\"\n return term\n .replace(/([a-z])([A-Z])/g, \"$1 $2\")\n .replace(/[-_]/g, \" \")\n .toLowerCase()\n .trim();\n}\n\nfunction extractCompoundTerms(content: string): string[] {\n const terms: string[] = [];\n\n // Extract camelCase words (e.g., UserProfile, userProfile)\n const camelCaseRegex = /\\b[a-zA-Z]*[a-z][A-Z][a-zA-Z]*\\b/g;\n let match;\n while ((match = camelCaseRegex.exec(content)) !== null) {\n terms.push(match[0]);\n }\n\n // Extract hyphenated words (e.g., user-profile, my-component)\n const hyphenatedRegex = /\\b[a-z][a-z0-9]*(?:-[a-z][a-z0-9]*)+\\b/g;\n while ((match = hyphenatedRegex.exec(content)) !== null) {\n terms.push(match[0]);\n }\n\n return terms;\n}\n\nexport const terminologyRule: LintRule = {\n id: \"consistency/terminology\",\n description:\n \"Detects terminology drift (e.g., user-profile vs UserProfile vs user profile) across specs\",\n severity: \"warn\",\n run(context) {\n // Only run on the first spec to avoid duplicate diagnostics\n if (context.spec !== context.allSpecs[0]) return [];\n\n // Build a map: normalized form → Set of original forms found across all specs\n const termMap = new Map<string, Set<string>>();\n\n for (const spec of context.allSpecs) {\n if (!spec.content) continue;\n const terms = extractCompoundTerms(spec.content);\n for (const term of terms) {\n const normalized = normalizeCompound(term);\n // Only track multi-word normalized forms (skip single words)\n if (!normalized.includes(\" \")) continue;\n if (!termMap.has(normalized)) {\n termMap.set(normalized, new Set());\n }\n termMap.get(normalized)!.add(term);\n }\n }\n\n const diagnostics = [];\n\n for (const [normalized, variants] of termMap) {\n if (variants.size >= 2) {\n const variantList = [...variants].join(\", \");\n diagnostics.push({\n ruleId: \"consistency/terminology\",\n severity: \"warn\" as const,\n message: `Inconsistent terminology for \"${normalized}\": found variants [${variantList}]. Standardize terminology across specs.`,\n filePath: context.spec.filePath,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { LintRule } from \"../types.js\";\n\nconst EDGE_CASE_KEYWORDS = [\n \"error\",\n \"invalid\",\n \"empty\",\n \"timeout\",\n \"fails\",\n \"failure\",\n \"boundary\",\n \"edge case\",\n \"null\",\n \"undefined\",\n \"reject\",\n \"unauthorized\",\n \"forbidden\",\n \"missing\",\n \"malformed\",\n \"overflow\",\n \"duplicate\",\n \"graceful\",\n \"fall back\",\n \"fallback\",\n \"crash\",\n \"nonexistent\",\n \"corrupt\",\n // Vocabulary that names a failure without using any of the words above.\n \"conflict\",\n \"denied\",\n \"expired\",\n \"not found\",\n \"retry\",\n \"rate limit\",\n \"unavailable\",\n \"unprocessable\",\n];\n\n/**\n * Any 4xx or 5xx status code counts as naming an error path.\n *\n * The list above held `404` and `500` and no other code, so a story whose only\n * error case was a 409 read as having no error handling at all -- changing that\n * one token to 404 silenced the warning with nothing else altered. Enumerating\n * codes was always going to be arbitrary; matching the class is not.\n */\nconst ERROR_STATUS_CODE = /\\b[45]\\d{2}\\b/;\n\nexport const edgeCaseCoverageRule: LintRule = {\n id: \"completeness/edge-case-coverage\",\n description: \"Flag user stories or test plans that don't mention error states or edge cases\",\n severity: \"warn\",\n run(context) {\n const type = context.spec.frontmatter.type as string;\n if (type !== \"user-story\" && type !== \"test-plan\") return [];\n\n const content = context.spec.content.toLowerCase();\n const hasEdgeCases =\n EDGE_CASE_KEYWORDS.some((kw) => content.includes(kw)) || ERROR_STATUS_CODE.test(content);\n\n if (hasEdgeCases) return [];\n\n return [\n {\n ruleId: \"completeness/edge-case-coverage\",\n severity: \"warn\" as const,\n message:\n \"No error states or edge cases mentioned. Consider adding error handling, boundary conditions, or failure mode scenarios.\",\n filePath: context.spec.filePath,\n },\n ];\n },\n};\n","import type { LintRule } from \"../types.js\";\n\nexport const namingConventionsRule: LintRule = {\n id: \"consistency/naming-conventions\",\n description: \"Enforce consistent naming conventions across specs\",\n severity: \"warn\",\n run(context) {\n const { spec } = context;\n const type = spec.frontmatter.type as string;\n const diagnostics = [];\n\n if (type === \"prd\") {\n // Split content into sections and find the Features section\n const sectionParts = spec.content.split(/^(?=## )/m);\n const featuresSection = sectionParts.find((p) => /^## Features\\b/.test(p));\n if (featuresSection) {\n const bullets = featuresSection.match(/^- .+$/gm) ?? [];\n for (const bullet of bullets) {\n if (bullet.match(/^- \\*\\*F\\d+\\*\\*:/) === null && bullet.trim().length > 2) {\n diagnostics.push({\n ruleId: \"consistency/naming-conventions\",\n severity: \"warn\" as const,\n message: `PRD feature missing feature ID pattern (**F<N>**:): \"${bullet.slice(0, 60)}\"`,\n filePath: spec.filePath,\n });\n }\n }\n }\n }\n\n if (type === \"user-story\") {\n const id = spec.frontmatter.id as string;\n if (!id.startsWith(\"story-\")) {\n diagnostics.push({\n ruleId: \"consistency/naming-conventions\",\n severity: \"warn\" as const,\n message: `User story ID \"${id}\" should start with \"story-\" (e.g., \"story-${id}\")`,\n filePath: spec.filePath,\n });\n }\n }\n\n if (type === \"api-contract\") {\n // Check endpoints for camelCase path segments\n const endpointRe = /^###\\s+(GET|POST|PUT|PATCH|DELETE)\\s+(\\S+)/gm;\n let match;\n while ((match = endpointRe.exec(spec.content)) !== null) {\n const path = match[2]!;\n if (/\\/[a-z]+[A-Z]/.test(path)) {\n diagnostics.push({\n ruleId: \"consistency/naming-conventions\",\n severity: \"warn\" as const,\n message: `Endpoint path \"${path}\" uses camelCase — use kebab-case instead (e.g., \"${path.replace(/([a-z])([A-Z])/g, \"$1-$2\").toLowerCase()}\")`,\n filePath: spec.filePath,\n });\n }\n }\n }\n\n return diagnostics;\n },\n};\n","import type { LintRule } from \"../types.js\";\n\nconst STOPWORDS = new Set([\"the\", \"and\", \"for\", \"with\", \"from\", \"that\", \"this\", \"into\", \"via\"]);\n\nfunction extractThreats(content: string): string[] {\n // Split into sections at each ## heading, then filter for Threats/Security\n const parts = content.split(/^(?=## )/m);\n const threats: string[] = [];\n for (const part of parts) {\n if (!/^##\\s+(Threats|Security)\\b/i.test(part)) continue;\n const bullets = part.match(/^- .+$/gm) ?? [];\n threats.push(...bullets.map((b) => b.slice(2).trim()));\n }\n return threats;\n}\n\nfunction extractKeyTerms(text: string): string[] {\n return text\n .toLowerCase()\n .split(/\\W+/)\n .filter((w) => w.length > 3)\n .filter((w) => !STOPWORDS.has(w));\n}\n\nexport const threatCoverageRule: LintRule = {\n id: \"security/threat-coverage\",\n description: \"Technical design specs must address threats identified in other specs\",\n severity: \"warn\",\n run(context) {\n if (context.spec.frontmatter.type !== \"technical-design\") return [];\n\n const allThreats: string[] = [];\n for (const spec of context.allSpecs) {\n if (spec.filePath === context.spec.filePath) continue;\n allThreats.push(...extractThreats(spec.content));\n }\n\n if (allThreats.length === 0) return [];\n\n const techContent = context.spec.content.toLowerCase();\n const diagnostics = [];\n\n for (const threat of allThreats) {\n const keyTerms = extractKeyTerms(threat);\n const covered = keyTerms.some((term) => techContent.includes(term));\n if (!covered) {\n diagnostics.push({\n ruleId: \"security/threat-coverage\",\n severity: \"warn\" as const,\n message: `Threat not addressed in technical design: \"${threat}\". Ensure the design covers this threat.`,\n filePath: context.spec.filePath,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { LintRule } from \"../types.js\";\n\nexport const ambiguityScoreAiRule: LintRule = {\n id: \"clarity/ambiguity-score-ai\",\n description: \"AI-powered ambiguity detection (requires ANTHROPIC_API_KEY)\",\n severity: \"info\",\n run(context) {\n if (!process.env[\"ANTHROPIC_API_KEY\"]) return [];\n\n return [\n {\n ruleId: \"clarity/ambiguity-score-ai\",\n severity: \"info\" as const,\n message:\n \"AI ambiguity analysis available — run `specdx check --ai` for LLM-powered ambiguity detection\",\n filePath: context.spec.filePath,\n },\n ];\n },\n};\n","import type { LintRule } from \"../types.js\";\n\n/**\n * Bodies that say \"nothing has been written here yet\".\n *\n * Matched against the whole section body, never as a substring: prose that\n * mentions a TODO is real content, a body that *is* \"TODO\" is not.\n */\nconst PLACEHOLDER_BODIES = /^(todo|tbd|fixme|n\\/a|na|none|xxx|\\.{2,}|-|\\*)$/i;\n\n/** Strip HTML comments, list bullets and separators to expose the real body. */\nfunction meaningfulContent(content: string): string {\n return content\n .replace(/<!--[\\s\\S]*?-->/g, \"\")\n .split(\"\\n\")\n .map((line) => line.replace(/^\\s*[-*+]\\s+/, \"\").trim())\n .filter((line) => line.length > 0 && !/^-{3,}$/.test(line))\n .join(\"\\n\")\n .trim();\n}\n\n/**\n * Flags sections that exist only as scaffolding.\n *\n * `structure/required-sections` checks that a heading is present, never that\n * anything was written under it. Without this rule a freshly scaffolded suite\n * of `<!-- placeholder -->` stubs lints clean, reports healthy, and is declared\n * ready for implementation -- the vacuous-pass failure mode, reached on a new\n * user's first command.\n *\n * Warning rather than error: an untouched scaffold should be visibly incomplete\n * without failing the very first `specdx lint` a user runs. `ready` enforces\n * the harder gate.\n */\nexport const noPlaceholderSectionsRule: LintRule = {\n id: \"completeness/no-placeholder-sections\",\n description: \"Spec sections contain content, not scaffolding placeholders\",\n severity: \"warn\",\n run(context) {\n return (\n context.spec.parsedSections\n // The preamble carries no heading and is not a section a user must fill.\n .filter((section) => section.heading !== \"\")\n .filter((section) => {\n const body = meaningfulContent(section.content);\n return body === \"\" || PLACEHOLDER_BODIES.test(body);\n })\n .map((section) => ({\n ruleId: \"completeness/no-placeholder-sections\",\n severity: \"warn\" as const,\n message: `Section \"${section.heading}\" is still a placeholder — write its content or remove the section`,\n filePath: context.spec.filePath,\n section: section.heading,\n }))\n );\n },\n};\n","import { basename } from \"node:path\";\nimport type { LintRule } from \"../types.js\";\n\n/**\n * A spec's frontmatter `id` must match the key it is registered under.\n *\n * When they disagree, nothing used to say so. `validate` passed, because the\n * config itself is well-formed and the file exists. `lint` reported dangling\n * references -- but blamed every spec that referenced the id, none of which was\n * at fault. And `graph` listed nodes by config key while drawing edges by\n * frontmatter id, so it rendered a node with no edges beside edges from a node\n * that did not exist.\n *\n * One diagnostic on the spec that actually diverged replaces all of that.\n *\n * A warning rather than an error: both names resolve, in different places --\n * frontmatter `references` match the id, config `requires` match the key -- so\n * a suite that keeps them apart still works. What it cannot do is produce a\n * coherent graph, or a useful message when a reference goes stale.\n */\nexport const idMatchesConfigKeyRule: LintRule = {\n id: \"structure/id-matches-config-key\",\n description: \"A spec's frontmatter id should match the key it is registered under in the config\",\n severity: \"warn\",\n run(context) {\n const { spec, config } = context;\n if (!config) return [];\n\n const id = spec.frontmatter.id;\n if (typeof id !== \"string\" || id.length === 0) return [];\n\n // Find the entry this file was loaded from. Paths may be globs, so match on\n // the filename the config points at rather than re-resolving every glob.\n const specFile = basename(spec.filePath);\n const candidates = Object.entries(config.specs).filter(([, entry]) => {\n const target = basename(entry.path);\n // A glob entry (`specs/stories/*.md`) claims a directory, not a filename,\n // and cannot be checked this way -- its key names a group, not a spec.\n return !target.includes(\"*\") && target === specFile;\n });\n\n if (candidates.length !== 1) return [];\n const key = candidates[0]![0];\n if (key === id) return [];\n\n return [\n {\n ruleId: \"structure/id-matches-config-key\",\n severity: \"warn\" as const,\n message:\n `Spec declares id \"${id}\" but is registered in spec.config.yaml as \"${key}\". ` +\n `Frontmatter references resolve against \"${id}\" and config requires against \"${key}\", ` +\n \"so the dependency graph shows them as two things. Rename one so they agree.\",\n filePath: spec.filePath,\n },\n ];\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 { singleProjectContextRule } from \"./single-project-context.js\";\nimport { terminologyRule } from \"./terminology.js\";\nimport { edgeCaseCoverageRule } from \"./edge-case-coverage.js\";\nimport { namingConventionsRule } from \"./naming-conventions.js\";\nimport { threatCoverageRule } from \"./threat-coverage.js\";\nimport { ambiguityScoreAiRule } from \"./ambiguity-score-ai.js\";\nimport { noPlaceholderSectionsRule } from \"./no-placeholder-sections.js\";\nimport { idMatchesConfigKeyRule } from \"./id-matches-config-key.js\";\nimport type { LintRule } from \"../types.js\";\n\nexport const structureRules: LintRule[] = [\n validFrontmatterRule,\n requiredSectionsRule,\n validReferencesRule,\n noCircularDepsRule,\n singleProjectContextRule,\n idMatchesConfigKeyRule,\n];\n\nexport const contentRules: LintRule[] = [\n storyCoverageRule,\n stalenessCheckRule,\n noVagueLanguageRule,\n terminologyRule,\n edgeCaseCoverageRule,\n namingConventionsRule,\n threatCoverageRule,\n ambiguityScoreAiRule,\n noPlaceholderSectionsRule,\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 singleProjectContextRule,\n terminologyRule,\n edgeCaseCoverageRule,\n namingConventionsRule,\n threatCoverageRule,\n ambiguityScoreAiRule,\n noPlaceholderSectionsRule,\n idMatchesConfigKeyRule,\n};\n","import type { LintRule } from \"./types.js\";\nimport { structureRules, allBuiltinRules } from \"./rules/index.js\";\n\nexport function getPreset(name: string): LintRule[] {\n switch (name) {\n case \"minimal\":\n return structureRules;\n case \"recommended\":\n return allBuiltinRules;\n case \"strict\":\n // Promote warnings only. An info-class rule is an advisory the author\n // cannot satisfy by editing specs (ambiguity-score-ai fires whenever\n // ANTHROPIC_API_KEY is set), so promoting it would fail every suite\n // linted in an environment that carries the key.\n return allBuiltinRules.map((rule) =>\n rule.severity === \"warn\" ? { ...rule, severity: \"error\" as const } : rule,\n );\n default:\n throw new Error(\n `Unknown preset: \"${name}\". Use \"minimal\", \"recommended\", or \"strict\", or resolve external presets via resolvePreset() from @specdx/core.`,\n );\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"],"mappings":";;;;;;;;AAcM,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;AAWD,qBAAW,cAAc,SAAS;AAChC,wBAAY,KAAK,EAAE,GAAG,YAAY,UAAU,KAAK,SAAQ,CAAE;UAC7D;QACF;MACF;AACA,aAAO;QACL;QACA,WAAW,YAAY,KAAK,CAAC,MAAM,EAAE,aAAa,OAAO;QACzD,aAAa,YAAY,KAAK,CAAC,MAAM,EAAE,aAAa,MAAM;;IAE9D;;AAEJ;;;AC5CA,IAAM,YAAY,oBAAI,IAAI;EACxB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AAGD,IAAM,oBAAoB;AAG1B,IAAM,uBAAuB;AAE7B,SAAS,SAAS,MAAY;AAC5B,QAAM,QAAQ,KACX,YAAW,EACX,QAAQ,iBAAiB,GAAG,EAC5B,MAAM,KAAK,EACX,OAAO,CAAC,MAAM,EAAE,SAAS,KAAK,CAAC,UAAU,IAAI,CAAC,CAAC,EAE/C,IAAI,CAAC,MAAO,EAAE,SAAS,KAAK,EAAE,SAAS,GAAG,KAAK,CAAC,EAAE,SAAS,IAAI,IAAI,EAAE,MAAM,GAAG,EAAE,IAAI,CAAE;AACzF,SA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