specdx 0.4.0-alpha.9 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/.claude-plugin/plugin.json +7 -2
  2. package/README.md +283 -0
  3. package/dist/{check-4FSSC6HN.js → check-RH5SCXWW.js} +68 -30
  4. package/dist/check-RH5SCXWW.js.map +1 -0
  5. package/dist/{chunk-N77RNV7J.js → chunk-3YXRWQGX.js} +217 -42
  6. package/dist/chunk-3YXRWQGX.js.map +1 -0
  7. package/dist/chunk-5WRI5ZAA.js +31 -0
  8. package/dist/chunk-6EQIDZ4D.js +185 -0
  9. package/dist/chunk-6EQIDZ4D.js.map +1 -0
  10. package/dist/chunk-6WFNZH7F.js +2846 -0
  11. package/dist/chunk-6WFNZH7F.js.map +1 -0
  12. package/dist/{chunk-AKNPCB37.js → chunk-BMOOLUPG.js} +32 -12
  13. package/dist/chunk-BMOOLUPG.js.map +1 -0
  14. package/dist/{chunk-IHTYAW7C.js → chunk-BP3SB35W.js} +111 -7
  15. package/dist/chunk-BP3SB35W.js.map +1 -0
  16. package/dist/chunk-CQETLJTZ.js +103 -0
  17. package/dist/chunk-CQETLJTZ.js.map +1 -0
  18. package/dist/chunk-DMGABJ6T.js +41 -0
  19. package/dist/chunk-DMGABJ6T.js.map +1 -0
  20. package/dist/chunk-NHD44ZYN.js +20 -0
  21. package/dist/chunk-NHD44ZYN.js.map +1 -0
  22. package/dist/{chunk-7JXW2GTJ.js → chunk-XRWLPU24.js} +18 -2
  23. package/dist/chunk-XRWLPU24.js.map +1 -0
  24. package/dist/chunk-ZIODMXST.js +1146 -0
  25. package/dist/chunk-ZIODMXST.js.map +1 -0
  26. package/dist/diff-QO7HMAK3.js +200 -0
  27. package/dist/diff-QO7HMAK3.js.map +1 -0
  28. package/dist/{dist-4DIRTBJH.js → dist-JPWHWMV2.js} +88 -26
  29. package/dist/dist-JPWHWMV2.js.map +1 -0
  30. package/dist/{dist-RL2DT3ZE.js → dist-ROHCFKYT.js} +3 -2
  31. package/dist/dist-ROHCFKYT.js.map +1 -0
  32. package/dist/generate-MS4BM7RU.js +21 -0
  33. package/dist/generate-MS4BM7RU.js.map +1 -0
  34. package/dist/{generate-story-EFHGINHA.js → generate-story-OMM322L7.js} +43 -19
  35. package/dist/generate-story-OMM322L7.js.map +1 -0
  36. package/dist/{generate-test-plan-BO7444RG.js → generate-test-plan-75W7SZIO.js} +61 -11
  37. package/dist/generate-test-plan-75W7SZIO.js.map +1 -0
  38. package/dist/{graph-5XINV7PT.js → graph-QOTMXENE.js} +49 -11
  39. package/dist/graph-QOTMXENE.js.map +1 -0
  40. package/dist/index.d.ts +302 -0
  41. package/dist/index.js +2996 -357
  42. package/dist/index.js.map +1 -1
  43. package/dist/lint-LPFLHVO4.js +184 -0
  44. package/dist/lint-LPFLHVO4.js.map +1 -0
  45. package/dist/main.js +10 -229
  46. package/dist/main.js.map +1 -1
  47. package/dist/mcp-OEC43SPF.js +35 -0
  48. package/dist/mcp-OEC43SPF.js.map +1 -0
  49. package/dist/{migrate-4KF6GHLO.js → migrate-CBP2AVLH.js} +21 -9
  50. package/dist/migrate-CBP2AVLH.js.map +1 -0
  51. package/dist/{pack-DSOODXAN.js → pack-X6FSWORJ.js} +41 -13
  52. package/dist/pack-X6FSWORJ.js.map +1 -0
  53. package/dist/{ready-6DNKIHP6.js → ready-7MJWRGLT.js} +55 -14
  54. package/dist/ready-7MJWRGLT.js.map +1 -0
  55. package/dist/skills/{specdx-author-spec.md → core/specdx-author-spec/SKILL.md} +10 -6
  56. package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-01-frontmatter.md +1 -1
  57. package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-02-sections.md +41 -0
  58. package/dist/skills/{specdx-onboard.md → core/specdx-onboard/SKILL.md} +8 -3
  59. package/dist/skills/{specdx-plan-from-spec.md → core/specdx-plan-from-spec/SKILL.md} +5 -1
  60. package/dist/skills/{specdx-pre-commit.md → core/specdx-pre-commit/SKILL.md} +16 -2
  61. package/dist/skills/{specdx-review-spec.md → core/specdx-review-spec/SKILL.md} +5 -1
  62. package/dist/skills/core/specdx-router/SKILL.md +67 -0
  63. package/dist/skills/{specdx-sprint-review.md → core/specdx-sprint-review/SKILL.md} +6 -2
  64. package/dist/skills/{specdx-start-task.md → core/specdx-start-task/SKILL.md} +5 -1
  65. package/dist/skills/{specdx-check-drift.md → experimental/specdx-check-drift/SKILL.md} +10 -4
  66. package/dist/skills/{specdx-verify.md → experimental/specdx-verify/SKILL.md} +6 -2
  67. package/dist/skills-36SRUEMR.js +121 -0
  68. package/dist/skills-36SRUEMR.js.map +1 -0
  69. package/dist/{status-WZK247CI.js → status-UUPZYX3J.js} +63 -32
  70. package/dist/status-UUPZYX3J.js.map +1 -0
  71. package/dist/{update-JTNSYX3B.js → update-EI7IJRHG.js} +22 -12
  72. package/dist/update-EI7IJRHG.js.map +1 -0
  73. package/dist/{validate-LBDYWUDX.js → validate-HTTZLQWI.js} +36 -17
  74. package/dist/validate-HTTZLQWI.js.map +1 -0
  75. package/hooks/hooks.json +12 -6
  76. package/hooks/session-start +35 -3
  77. package/package.json +28 -13
  78. package/dist/changelog-XUVHY3QK.js +0 -93
  79. package/dist/changelog-XUVHY3QK.js.map +0 -1
  80. package/dist/check-4FSSC6HN.js.map +0 -1
  81. package/dist/chunk-7JXW2GTJ.js.map +0 -1
  82. package/dist/chunk-AKNPCB37.js.map +0 -1
  83. package/dist/chunk-DAZCOUVK.js +0 -496
  84. package/dist/chunk-DAZCOUVK.js.map +0 -1
  85. package/dist/chunk-GAM4MXPC.js +0 -15
  86. package/dist/chunk-GAM4MXPC.js.map +0 -1
  87. package/dist/chunk-IHTYAW7C.js.map +0 -1
  88. package/dist/chunk-N77RNV7J.js.map +0 -1
  89. package/dist/chunk-SRZ33RJP.js +0 -1147
  90. package/dist/chunk-SRZ33RJP.js.map +0 -1
  91. package/dist/diff-OXZ34NU4.js +0 -107
  92. package/dist/diff-OXZ34NU4.js.map +0 -1
  93. package/dist/dist-4DIRTBJH.js.map +0 -1
  94. package/dist/explain-QBV3AESQ.js +0 -109
  95. package/dist/explain-QBV3AESQ.js.map +0 -1
  96. package/dist/generate-7GNPT2WJ.js +0 -13
  97. package/dist/generate-7GNPT2WJ.js.map +0 -1
  98. package/dist/generate-story-EFHGINHA.js.map +0 -1
  99. package/dist/generate-test-plan-BO7444RG.js.map +0 -1
  100. package/dist/graph-5XINV7PT.js.map +0 -1
  101. package/dist/lint-PTMWMLDQ.js +0 -122
  102. package/dist/lint-PTMWMLDQ.js.map +0 -1
  103. package/dist/mcp-BGFAPM6G.js +0 -17
  104. package/dist/mcp-BGFAPM6G.js.map +0 -1
  105. package/dist/migrate-4KF6GHLO.js.map +0 -1
  106. package/dist/pack-DSOODXAN.js.map +0 -1
  107. package/dist/ready-6DNKIHP6.js.map +0 -1
  108. package/dist/skills-3GBBWZW2.js +0 -93
  109. package/dist/skills-3GBBWZW2.js.map +0 -1
  110. package/dist/status-WZK247CI.js.map +0 -1
  111. package/dist/update-JTNSYX3B.js.map +0 -1
  112. package/dist/validate-LBDYWUDX.js.map +0 -1
  113. /package/dist/{dist-RL2DT3ZE.js.map → chunk-5WRI5ZAA.js.map} +0 -0
  114. /package/dist/skills/{spec-type-reference.md → core/specdx-author-spec/references/spec-type-reference.md} +0 -0
  115. /package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-03-finalize.md +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../lint/src/engine.ts","../../lint/src/rules/story-coverage.ts","../../lint/src/resolve-lint-config.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","../../lint/src/agents/discover.ts","../../lint/src/agents/rules/structure.ts","../../lint/src/agents/rules/stale-references.ts","../../lint/src/agents/rules/size-budget.ts","../../lint/src/agents/resolve-reference.ts","../../lint/src/agents/index.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 * Absolute spec paths `lint.ignore` excludes.\n *\n * Excluded specs are still passed to rules as `allSpecs` — ignoring a file\n * means \"do not report on it\", not \"pretend it left the suite\". A reference\n * to an ignored spec must still resolve, or `ignore` would quietly\n * manufacture broken-reference errors elsewhere.\n */\n ignore?: string[];\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 const ignored = new Set(options.ignore ?? []);\n for (const spec of specs) {\n if (ignored.has(spec.filePath)) continue;\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 // A rule that walks the whole suite can name a file other than the\n // one it was called for, so the exclusion is applied to the\n // diagnostic's own path as well as to the spec being linted.\n if (ignored.has(diagnostic.filePath)) continue;\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 { isAbsolute, resolve } from \"node:path\";\nimport { resolveGlob } from \"@specdx/core\";\nimport type { SdxConfig } from \"@specdx/schema\";\nimport type { LintRule, Severity } from \"./types.js\";\nimport { getPreset } from \"./presets.js\";\nimport { allBuiltinRules } from \"./rules/index.js\";\nimport { loadCustomRule } from \"./custom-rule-loader.js\";\n\nconst SEVERITIES: ReadonlySet<string> = new Set([\"error\", \"warn\", \"info\"]);\n\nexport interface ResolveLintConfigOptions {\n /** The loaded `spec.config.yaml`. */\n config?: SdxConfig;\n /** Explicit preset, from `--preset` / the Action input / `runLint({ preset })`. Beats `lint.extends`. */\n preset?: string;\n /** Directory holding `spec.config.yaml`. Custom rule paths and ignore globs resolve against it. */\n configDir: string;\n}\n\nexport interface ResolvedLintConfig {\n rules: LintRule[];\n /** Absolute paths of spec files `lint.ignore` excludes. */\n ignore: string[];\n}\n\n/** `off`, `false` and an empty value all mean \"do not run this rule\". */\nfunction isOff(value: unknown): boolean {\n return value === false || value === null || value === \"off\";\n}\n\nfunction severityOf(value: unknown): Severity | undefined {\n return typeof value === \"string\" && SEVERITIES.has(value) ? (value as Severity) : undefined;\n}\n\nfunction describe(value: unknown): string {\n return typeof value === \"string\" ? `\"${value}\"` : JSON.stringify(value);\n}\n\n/**\n * Turn `lint.extends`, `lint.rules` and `lint.ignore` into the rule set and\n * exclusion list the engine runs with.\n *\n * `lint.rules` and `lint.ignore` were declared in the config schema, documented\n * in the README and CONTRIBUTING, accepted by `validate` — and read by nothing.\n * Only `lint.extends` was ever consumed, so `naming-conventions: off` left the\n * rule firing, a custom rule never loaded (`loadCustomRule` was exported and\n * called by nothing), and `ignore` excluded no file. A team that writes a rule\n * override into CI believes it has configured a gate; the belief is the damage.\n *\n * This is the single place all six linting surfaces resolve their rules, so a\n * fix here cannot reach the CLI and miss the Action or MCP.\n */\nexport async function resolveLintConfig({\n config,\n preset,\n configDir,\n}: ResolveLintConfigOptions): Promise<ResolvedLintConfig> {\n const presetName = preset ?? config?.lint?.extends ?? \"recommended\";\n const byId = new Map<string, LintRule>(getPreset(presetName).map((rule) => [rule.id, rule]));\n\n // Every built-in, not just the ones this preset enabled: an override may\n // re-enable a rule the preset left out, which is the other half of being\n // able to turn one off.\n const builtins = new Map<string, LintRule>(allBuiltinRules.map((rule) => [rule.id, rule]));\n\n for (const [id, value] of Object.entries(config?.lint?.rules ?? {})) {\n if (isOff(value)) {\n // A typo'd id is the same silent no-op as the defect this fixes: the\n // author believes they turned a rule off, and it keeps firing. Refuse\n // rather than delete nothing.\n if (!builtins.has(id)) {\n throw new Error(\n `lint.rules[\"${id}\"]: cannot turn off \"${id}\" — no built-in rule has that id. Check the spelling.`,\n );\n }\n byId.delete(id);\n continue;\n }\n\n let severity: Severity | undefined;\n let rulePath: string | undefined;\n\n if (Array.isArray(value)) {\n severity = severityOf(value[0]);\n if (severity === undefined) {\n throw new Error(\n `lint.rules[\"${id}\"]: ${describe(value[0])} is not a severity. Use \"error\", \"warn\", \"info\", or \"off\".`,\n );\n }\n const options = value[1];\n if (options !== undefined) {\n if (typeof options !== \"object\" || options === null || Array.isArray(options)) {\n throw new Error(\n `lint.rules[\"${id}\"]: expected options like { path: \"./rule.js\" }, got ${describe(options)}.`,\n );\n }\n const declared = (options as { path?: unknown }).path;\n if (declared !== undefined) {\n if (typeof declared !== \"string\" || declared.length === 0) {\n throw new Error(`lint.rules[\"${id}\"]: \\`path\\` must be a non-empty string.`);\n }\n rulePath = declared;\n }\n }\n } else {\n severity = severityOf(value);\n if (severity === undefined) {\n throw new Error(\n `lint.rules[\"${id}\"]: ${describe(value)} is not a severity. Use \"error\", \"warn\", \"info\", or \"off\".`,\n );\n }\n }\n\n if (rulePath !== undefined) {\n const absolute = isAbsolute(rulePath) ? rulePath : resolve(configDir, rulePath);\n const custom = await loadCustomRule(absolute);\n byId.set(id, { ...custom, id, severity });\n continue;\n }\n\n const existing = byId.get(id) ?? builtins.get(id);\n if (!existing) {\n throw new Error(\n `lint.rules[\"${id}\"]: no built-in rule with that id. ` +\n `For a custom rule, give it a file: [\"${severity}\", { path: \"./rules/my-rule.js\" }].`,\n );\n }\n byId.set(id, { ...existing, severity });\n }\n\n const ignore: string[] = [];\n for (const pattern of config?.lint?.ignore ?? []) {\n ignore.push(...(await resolveGlob(pattern, configDir)));\n }\n\n return { rules: [...byId.values()], ignore };\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\n/** The section a test plan is required to carry, and where its cases belong. */\nconst EDGE_CASE_SECTION = \"edge cases\";\n\n/** Bodies that say \"nothing has been written here yet\". */\nconst PLACEHOLDER_BODIES = /^(todo|tbd|fixme|n\\/a|na|none|xxx|\\.{2,}|-|\\*)$/i;\n\n/** Bodies that answer the question with \"there aren't any\", which is not coverage. */\nconst DISCLAIMED_BODIES = /^(none|no|nothing|n\\/a)\\b[\\s\\S]{0,40}$/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\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 // A test plan is *required* to carry an `## Edge Cases` heading, so scanning\n // the whole document for the words \"edge case\" matched the scaffolding and\n // nothing else -- the rule could never fire on the half of its scope that\n // has a dedicated home for the answer. Judge that section's body instead.\n const section = context.spec.parsedSections.find(\n (s) => s.heading.trim().toLowerCase() === EDGE_CASE_SECTION,\n );\n if (type === \"test-plan\" && section) {\n const body = meaningfulContent(section.content);\n const written =\n body !== \"\" && !PLACEHOLDER_BODIES.test(body) && !DISCLAIMED_BODIES.test(body);\n if (written) return [];\n\n return [\n {\n ruleId: \"completeness/edge-case-coverage\",\n severity: \"warn\" as const,\n message: `The \"${section.heading}\" section lists no cases — describe the boundary conditions and failure modes this plan covers, or the plan asserts only the happy path.`,\n filePath: context.spec.filePath,\n section: section.heading,\n },\n ];\n }\n\n // No dedicated section (a user story, or a test plan missing the heading —\n // `structure/required-sections` owns that): judge the document as a whole.\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","import { readFile } from \"node:fs/promises\";\nimport { relative } from \"node:path\";\nimport { resolveGlob, countTokens } from \"@specdx/core\";\nimport type { AgentFile } from \"./types.js\";\n\n/**\n * Where agent instruction files live when `agents.paths` does not say.\n *\n * Root-level only. A recursive default would sweep `node_modules` and every\n * vendored copy of someone else's CLAUDE.md, and reporting on a file the user\n * did not write is worse than reporting on nothing.\n */\nexport const DEFAULT_AGENT_PATHS = [\"AGENTS.md\", \"CLAUDE.md\"];\n\n/** Default ceiling for one agent file, in tokens. */\nexport const DEFAULT_MAX_TOKENS = 8000;\n\n/**\n * Resolve `agents.paths` to files on disk.\n *\n * Returns them sorted by relative path so diagnostics come out in a stable\n * order regardless of glob expansion order — otherwise CI output churns\n * between runs for no reason.\n */\nexport async function discoverAgentFiles(\n patterns: string[],\n configDir: string,\n): Promise<AgentFile[]> {\n const seen = new Set<string>();\n const files: AgentFile[] = [];\n\n for (const pattern of patterns) {\n for (const filePath of await resolveGlob(pattern, configDir)) {\n // Two patterns can legitimately match the same file (`*.md` and\n // `AGENTS.md`); linting it twice would double every diagnostic.\n if (seen.has(filePath)) continue;\n seen.add(filePath);\n\n const content = await readFile(filePath, \"utf8\");\n files.push({\n filePath,\n relativePath: relative(configDir, filePath),\n content,\n lines: content.split(\"\\n\"),\n tokens: countTokens(content),\n });\n }\n }\n\n return files.sort((a, b) => a.relativePath.localeCompare(b.relativePath));\n}\n","import type { Diagnostic } from \"../../types.js\";\nimport type { AgentRule, AgentLintContext, AgentRuleResult } from \"../types.js\";\n\n/**\n * An agent instruction file has to be navigable.\n *\n * Two failures, both falsifiable and both real: a file with no content at all,\n * and a file that is one undifferentiated block of prose. The second matters\n * because an agent — and a human maintaining the file — can only be pointed at\n * a heading. A wall of text can be appended to forever and never revised,\n * which is how these files rot.\n *\n * This rule deliberately does not judge whether the *advice* is any good. That\n * is an opinion about content, and specdx's claim is determinism.\n */\nexport const structureRule: AgentRule = {\n id: \"agents/structure\",\n description: \"Agent instruction files should have content and be organised under headings\",\n severity: \"warn\",\n\n run(context: AgentLintContext): AgentRuleResult {\n const { file } = context;\n const diagnostics: Diagnostic[] = [];\n\n if (file.content.trim() === \"\") {\n diagnostics.push({\n ruleId: \"agents/structure\",\n severity: \"warn\",\n message: `${file.relativePath} is empty. An empty instruction file steers nothing — delete it or write it.`,\n filePath: file.filePath,\n });\n // Every later assertion is about content this file does not have.\n return { diagnostics };\n }\n\n // ATX headings only. Setext (`===` underlines) is vanishingly rare in\n // these files, and matching it would mean tracking the previous line for\n // no practical gain.\n const headings = file.lines.filter((line) => /^#{1,6}\\s+\\S/.test(line));\n\n if (headings.length === 0) {\n diagnostics.push({\n ruleId: \"agents/structure\",\n severity: \"warn\",\n message: `${file.relativePath} has no headings, so it is one undifferentiated block. Nothing can be referenced, revised, or removed in isolation.`,\n filePath: file.filePath,\n });\n }\n\n return { diagnostics };\n },\n};\n","import type { AgentRule, AgentLintContext, AgentRuleResult } from \"../types.js\";\n\n/**\n * Paths an agent instruction file names must still exist.\n *\n * This is the failure mode that does active harm. A stale spec is merely out\n * of date; a CLAUDE.md that says \"the config lives at `config/app.yaml`\" after\n * that file moved sends every agent session to the wrong place, confidently.\n * specdx's own docs had exactly this rot — `other-platforms.md` named a path\n * and a command that did not exist.\n *\n * Extraction is deliberately conservative, because a false positive here costs\n * more than a miss. Only two things are treated as claims about the filesystem:\n *\n * - inline code spans that look like paths — `` `packages/cli/src/main.ts` ``\n * - relative Markdown link targets — `[the config](./spec.config.yaml)`\n *\n * Fenced code blocks are skipped entirely. They are full of illustrative and\n * hypothetical paths (`src/your-app.ts`), and flagging those would train users\n * to ignore this rule, which is worse than not having it.\n */\n\n/** A path-shaped token: has a directory separator, or a known source extension. */\nconst PATH_SHAPED =\n /^(?:[\\w.@-]+\\/)+[\\w.-]+$|^[\\w.-]+\\.(?:ts|tsx|js|jsx|mjs|cjs|json|md|ya?ml|toml|sh|py|rb|rs|go|java|css|html)$/;\n\n/** Things that are path-shaped but are not claims about this repo. */\nfunction isNotAFileClaim(candidate: string): boolean {\n return (\n candidate.includes(\"*\") || // a glob describes a set, not a file\n candidate.includes(\"://\") || // a URL\n candidate.startsWith(\"http\") ||\n candidate.startsWith(\"@\") || // an npm scope: @specdx/core\n candidate.startsWith(\"~\") || // a home-relative path outside the repo\n candidate.startsWith(\"/\") || // an absolute path outside the repo\n /^[A-Z_]+=/.test(candidate) // an env assignment\n );\n}\n\n/** Strip a leading `./`, and any trailing punctuation a sentence left behind. */\nfunction normalise(candidate: string): string {\n return candidate.replace(/^\\.\\//, \"\").replace(/[.,;:)]+$/, \"\");\n}\n\n/**\n * Line indices that sit inside a fenced code block, so they can be skipped.\n * Handles ``` and ~~~ fences of any length.\n */\nfunction fencedLines(lines: string[]): Set<number> {\n const fenced = new Set<number>();\n let fence: string | undefined;\n lines.forEach((line, index) => {\n const match = /^\\s*(`{3,}|~{3,})/.exec(line);\n if (match) {\n if (fence === undefined) {\n fence = match[1]!;\n fenced.add(index);\n return;\n }\n // Only a fence of the same character closes the block.\n if (match[1]![0] === fence[0]) fence = undefined;\n fenced.add(index);\n return;\n }\n if (fence !== undefined) fenced.add(index);\n });\n return fenced;\n}\n\nexport interface ExtractedReference {\n path: string;\n /** 1-indexed, to match how every other diagnostic in specdx reports lines. */\n line: number;\n}\n\n/** Exported for tests: the extraction is the part most likely to drift. */\nexport function extractReferences(lines: string[]): ExtractedReference[] {\n const skip = fencedLines(lines);\n const found: ExtractedReference[] = [];\n const seen = new Set<string>();\n\n lines.forEach((line, index) => {\n if (skip.has(index)) return;\n\n const candidates: string[] = [];\n // Inline code spans.\n for (const match of line.matchAll(/`([^`\\n]+)`/g)) candidates.push(match[1]!);\n // Relative Markdown links. The leading `!` form (images) counts too.\n for (const match of line.matchAll(/\\]\\((?!https?:|#)([^)\\s]+)\\)/g)) candidates.push(match[1]!);\n\n for (const raw of candidates) {\n const candidate = normalise(raw.trim());\n if (!candidate || isNotAFileClaim(candidate)) continue;\n if (!PATH_SHAPED.test(candidate)) continue;\n if (seen.has(candidate)) continue;\n seen.add(candidate);\n found.push({ path: candidate, line: index + 1 });\n }\n });\n\n return found;\n}\n\nexport const staleReferencesRule: AgentRule = {\n id: \"agents/stale-references\",\n description: \"Paths named by an agent instruction file must exist\",\n severity: \"warn\",\n\n run(context: AgentLintContext): AgentRuleResult {\n const { file, exists } = context;\n const references = extractReferences(file.lines);\n\n // Honest about scope: a file naming no paths had nothing checked, and\n // saying so beats letting a clean run imply the references were verified.\n // Same contract `check` was forced into — \"not assessed\" is not \"passing\".\n if (references.length === 0) {\n return {\n diagnostics: [],\n assessed: false,\n notAssessedReason: `${file.relativePath} names no file paths, so none were checked for staleness.`,\n };\n }\n\n return {\n diagnostics: references\n .filter((reference) => !exists(reference.path))\n .map((reference) => ({\n ruleId: \"agents/stale-references\",\n severity: this.severity,\n message: `${file.relativePath} refers to \"${reference.path}\", which does not exist. An agent told to look there will not find it.`,\n filePath: file.filePath,\n line: reference.line,\n })),\n };\n },\n};\n","import type { AgentRule, AgentLintContext, AgentRuleResult } from \"../types.js\";\n\n/**\n * An agent instruction file competes for the context window it exists to protect.\n *\n * These files only grow. Every incident adds a rule, nothing is ever removed,\n * and eventually the instructions consume the budget that should have gone to\n * the code and specs. The count uses the same tokenizer as `pack`, so the\n * number here and the number in a pack budget mean the same thing.\n *\n * This rule always applies — every file has a token count — so it can never be\n * vacuous the way a reference check over a file naming no paths can be.\n */\nexport const sizeBudgetRule: AgentRule = {\n id: \"agents/size-budget\",\n description: \"Agent instruction files should fit a token budget\",\n severity: \"warn\",\n\n run(context: AgentLintContext): AgentRuleResult {\n const { file, maxTokens } = context;\n if (file.tokens <= maxTokens) return { diagnostics: [] };\n\n const over = file.tokens - maxTokens;\n const percent = Math.round((over / maxTokens) * 100);\n return {\n diagnostics: [\n {\n ruleId: \"agents/size-budget\",\n severity: this.severity,\n message: `${file.relativePath} is ${file.tokens} tokens, ${over} over the ${maxTokens} budget (${percent}% over). It is spending the context window it exists to protect.`,\n filePath: file.filePath,\n },\n ],\n };\n },\n};\n","import { readdirSync } from \"node:fs\";\nimport { join, sep } from \"node:path\";\n\n/**\n * Directories never worth indexing. Vendored trees contain other people's\n * files, and a reference resolving against `node_modules` would be a false\n * *negative* — the worse direction for a rule whose job is finding rot.\n */\nconst SKIP_DIRECTORIES = new Set([\n \"node_modules\",\n \".git\",\n \"dist\",\n \"build\",\n \"coverage\",\n \".next\",\n \".turbo\",\n \".cache\",\n \"out\",\n]);\n\n/** Bail out rather than walk a pathological tree. */\nconst MAX_INDEXED_FILES = 20_000;\n\n/**\n * Every file path in the project, relative to the config directory, with `/`\n * separators regardless of platform.\n */\nexport function indexProjectFiles(configDir: string): string[] {\n const found: string[] = [];\n\n const walk = (dir: string, prefix: string) => {\n if (found.length >= MAX_INDEXED_FILES) return;\n let entries;\n try {\n entries = readdirSync(dir, { withFileTypes: true });\n } catch {\n return; // unreadable directory is not a reason to fail a lint run\n }\n for (const entry of entries) {\n if (found.length >= MAX_INDEXED_FILES) return;\n const relative = prefix ? `${prefix}/${entry.name}` : entry.name;\n if (entry.isDirectory()) {\n if (SKIP_DIRECTORIES.has(entry.name)) continue;\n // Directories are indexed too: an agent file can legitimately point at\n // one (\"skills live in `packages/skills/skills/core`\").\n found.push(relative);\n walk(join(dir, entry.name), relative);\n } else {\n found.push(relative);\n }\n }\n };\n\n walk(configDir, \"\");\n return found;\n}\n\n/**\n * Stems that are universally placeholders rather than claims about this repo.\n *\n * Documentation says \"tests live alongside source — `src/foo.test.ts` next to\n * `src/foo.ts`\" and means the *pattern*, not those files. Flagging them is the\n * kind of false positive that teaches people to ignore the rule, and the ADR\n * is explicit that a miss is cheaper than that.\n */\nconst PLACEHOLDER_STEMS = new Set([\n \"foo\",\n \"bar\",\n \"baz\",\n \"qux\",\n \"example\",\n \"your-app\",\n \"my-app\",\n \"some-file\",\n \"path\",\n]);\n\nexport function isPlaceholder(reference: string): boolean {\n const base = reference.split(\"/\").pop() ?? reference;\n // `foo.test.ts` -> `foo`; `foo` -> `foo`\n const stem = base.split(\".\")[0] ?? base;\n return PLACEHOLDER_STEMS.has(stem.toLowerCase());\n}\n\n/**\n * Does a reference in an agent file point at something real?\n *\n * Exact match first, then **suffix** match against the project index. Suffix\n * matching is what makes shorthand work: prose says \"`resolver.ts` scores spec\n * relevance\" having already named the package, and `core/specdx-router` means\n * the one under `packages/skills/skills/`. Requiring full paths would flag\n * almost every real instruction file, which is a rule nobody would keep on.\n *\n * A path that was renamed or deleted still matches nothing, which is the case\n * the rule exists for.\n */\nexport function createReferenceResolver(files: string[]): (reference: string) => boolean {\n const exact = new Set(files);\n // Bucket by basename so a lookup is not a scan of the whole index per\n // reference. Directory references are keyed by their own last segment.\n const byLastSegment = new Map<string, string[]>();\n for (const file of files) {\n const last = file.split(\"/\").pop()!;\n const bucket = byLastSegment.get(last);\n if (bucket) bucket.push(file);\n else byLastSegment.set(last, [file]);\n }\n\n return (reference: string): boolean => {\n const normalised = reference.split(sep).join(\"/\");\n if (exact.has(normalised)) return true;\n if (isPlaceholder(normalised)) return true;\n\n const last = normalised.split(\"/\").pop();\n if (!last) return false;\n const candidates = byLastSegment.get(last);\n if (!candidates) return false;\n\n // Suffix must land on a path boundary: `b.ts` must not satisfy `sub/b.ts`\n // by matching `other/sub-thing/b.ts`.\n return candidates.some(\n (candidate) => candidate === normalised || candidate.endsWith(`/${normalised}`),\n );\n };\n}\n","import type { SdxConfig } from \"@specdx/schema\";\nimport type { Severity, Diagnostic } from \"../types.js\";\nimport type { AgentRule, AgentLintResults } from \"./types.js\";\nimport { discoverAgentFiles, DEFAULT_AGENT_PATHS, DEFAULT_MAX_TOKENS } from \"./discover.js\";\nimport { structureRule } from \"./rules/structure.js\";\nimport { staleReferencesRule } from \"./rules/stale-references.js\";\nimport { sizeBudgetRule } from \"./rules/size-budget.js\";\nimport { indexProjectFiles, createReferenceResolver } from \"./resolve-reference.js\";\n\nexport type {\n AgentFile,\n AgentRule,\n AgentRuleResult,\n AgentLintContext,\n AgentLintResults,\n} from \"./types.js\";\nexport { discoverAgentFiles, DEFAULT_AGENT_PATHS, DEFAULT_MAX_TOKENS } from \"./discover.js\";\nexport { extractReferences } from \"./rules/stale-references.js\";\nexport { indexProjectFiles, createReferenceResolver, isPlaceholder } from \"./resolve-reference.js\";\n\n/**\n * The agent rule set, in its own namespace.\n *\n * Not merged into the spec presets, and not reachable from `lint.extends`:\n * `strict` must not silently start failing builds over someone's CLAUDE.md\n * (ADR constraint 2). Severity is configured through `agents.rules` only.\n */\nexport const AGENT_RULES: AgentRule[] = [structureRule, staleReferencesRule, sizeBudgetRule];\n\nconst VALID_SEVERITIES = new Set<Severity>([\"error\", \"warn\", \"info\"]);\n\nexport class AgentConfigError extends Error {}\n\n/**\n * Apply `agents.rules` overrides.\n *\n * An unknown rule id throws rather than being ignored. A typo that silently\n * configures nothing is the exact shape `lint.rules` shipped in for six\n * audits: it looked configured and did nothing.\n */\nexport function resolveAgentRules(overrides: Record<string, unknown> = {}): AgentRule[] {\n const known = new Map(AGENT_RULES.map((rule) => [rule.id, rule]));\n\n for (const id of Object.keys(overrides)) {\n if (!known.has(id)) {\n throw new AgentConfigError(\n `Unknown agent rule \"${id}\" in agents.rules. Known rules: ${[...known.keys()].join(\", \")}.`,\n );\n }\n }\n\n const resolved: AgentRule[] = [];\n for (const rule of AGENT_RULES) {\n const override = overrides[rule.id];\n if (override === undefined) {\n resolved.push(rule);\n continue;\n }\n if (override === false || override === \"off\") continue;\n if (typeof override === \"string\" && VALID_SEVERITIES.has(override as Severity)) {\n resolved.push({ ...rule, severity: override as Severity });\n continue;\n }\n throw new AgentConfigError(\n `Invalid severity ${JSON.stringify(override)} for \"${rule.id}\". Use \"error\", \"warn\", \"info\", \"off\", or false.`,\n );\n }\n return resolved;\n}\n\nexport interface LintAgentFilesOptions {\n config: SdxConfig;\n configDir: string;\n /** Overridable so tests need no fixture tree on disk. */\n exists?: (relativePath: string) => boolean;\n}\n\n/**\n * Lint every configured agent instruction file.\n *\n * Returns `assessed: false` when the configured paths matched nothing, so a\n * caller can refuse to call that a pass (ADR constraint 3).\n */\nexport async function lintAgentFiles(options: LintAgentFilesOptions): Promise<AgentLintResults> {\n const { config, configDir } = options;\n const agents = config.agents ?? {};\n const patterns = agents.paths ?? DEFAULT_AGENT_PATHS;\n const maxTokens = agents.max_tokens ?? DEFAULT_MAX_TOKENS;\n const rules = resolveAgentRules(agents.rules as Record<string, unknown> | undefined);\n const files = await discoverAgentFiles(patterns, configDir);\n\n // Index the project once per run, and only when there is something to check\n // against it. Walking the tree for a repo with no agent files configured\n // would be pure cost.\n const exists =\n options.exists ??\n (files.length > 0 ? createReferenceResolver(indexProjectFiles(configDir)) : () => true);\n\n const diagnostics: Diagnostic[] = [];\n\n for (const file of files) {\n for (const rule of rules) {\n const result = rule.run({ file, configDir, exists, maxTokens });\n\n // The rule object's severity is the authority, never the severity a rule\n // happened to write into the diagnostic it returned. Same contract the\n // spec engine enforces, for the same reason: it is what makes an\n // override mean anything.\n for (const diagnostic of result.diagnostics) {\n diagnostics.push({ ...diagnostic, severity: rule.severity });\n }\n\n // A rule that could not judge anything says so, rather than returning an\n // empty array that reads as a pass. Structural, not inferred from a\n // severity string — `assessed: false` is the only way to say it.\n if (result.assessed === false) {\n diagnostics.push({\n ruleId: rule.id,\n severity: \"info\",\n message:\n result.notAssessedReason ?? `${rule.id} assessed nothing in ${file.relativePath}.`,\n filePath: file.filePath,\n });\n }\n }\n }\n\n return { diagnostics, filesLinted: files.length, assessed: files.length > 0 };\n}\n"],"mappings":";;;;;;;;;;AAuBM,SAAU,iBAAiB,SAA0B;AACzD,SAAO;IACL,KAAK,OAAmB;AACtB,YAAM,cAA4B,CAAA;AAClC,YAAM,UAAU,IAAI,IAAI,QAAQ,UAAU,CAAA,CAAE;AAC5C,iBAAW,QAAQ,OAAO;AACxB,YAAI,QAAQ,IAAI,KAAK,QAAQ;AAAG;AAChC,mBAAW,QAAQ,QAAQ,OAAO;AAChC,gBAAM,UAAU,KAAK,IAAI;YACvB;YACA,UAAU;YACV,QAAQ,QAAQ;YAChB,OAAO,QAAQ;WAChB;AAWD,qBAAW,cAAc,SAAS;AAIhC,gBAAI,QAAQ,IAAI,WAAW,QAAQ;AAAG;AACtC,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;;;AC3DA,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,EAA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AAmB,UAAU,SAAS;AAK1D,QAAM,SACJ,QAAQ,WACP,MAAM,SAAS,IAAI,wBAAwB,kBAAkB,SAAS,CAAC,IAAI,MAAM;AAEpF,QAAM,cAA4B,CAAA;AAElC,aAAW,QAAQ,OAAO;AACxB,eAAW,QAAQ,OAAO;AACxB,YAAM,SAAS,KAAK,IAAI,EAAE,MAAM,WAAW,QAAQ,UAAS,CAAE;AAM9D,iBAAW,cAAc,OAAO,aAAa;AAC3C,oBAAY,KAAK,EAAE,GAAG,YAAY,UAAU,KAAK,SAAQ,CAAE;MAC7D;AAKA,UAAI,OAAO,aAAa,OAAO;AAC7B,oBAAY,KAAK;UACf,QAAQ,KAAK;UACb,UAAU;UACV,SACE,OAAO,qBAAqB,GAAG,KAAK,EAAE,wBAAwB,KAAK,YAAY;UACjF,UAAU,KAAK;SAChB;MACH;IACF;EACF;AAEA,SAAO,EAAE,aAAa,aAAa,MAAM,QAAQ,UAAU,MAAM,SAAS,EAAC;AAC7E;","names":["STOPWORDS","PLACEHOLDER_BODIES","meaningfulContent","relative"]}
@@ -0,0 +1,200 @@
1
+ import {
2
+ DEFAULT_DIFF_CONFIG,
3
+ DiffError,
4
+ diffBetweenRefs
5
+ } from "./chunk-6WFNZH7F.js";
6
+ import {
7
+ createOutput
8
+ } from "./chunk-NHD44ZYN.js";
9
+ import {
10
+ resolveFormat,
11
+ sharedArgs
12
+ } from "./chunk-DMGABJ6T.js";
13
+ import {
14
+ loadConfig
15
+ } from "./chunk-BP3SB35W.js";
16
+ import "./chunk-XRWLPU24.js";
17
+ import "./chunk-5WRI5ZAA.js";
18
+
19
+ // src/commands/core/diff.ts
20
+ import { defineCommand } from "citty";
21
+ import { join } from "path";
22
+
23
+ // src/formatters/changelog.ts
24
+ function formatChangelog(result, baseRef, headRef) {
25
+ const lines = [];
26
+ lines.push(`## Spec Changes (${baseRef}..${headRef})
27
+ `);
28
+ if (result.diffs.length > 0) {
29
+ lines.push("### Modified");
30
+ for (const diff of result.diffs) {
31
+ const sections = diff.sections.map((s) => s.heading).join(", ");
32
+ const versionChange = diff.frontmatter.find((f) => f.field === "version");
33
+ const versionStr = versionChange ? ` (${String(versionChange.before)} \u2192 ${String(versionChange.after)})` : "";
34
+ lines.push(`- **${diff.specId}**${versionStr} \u2014 ${sections || "frontmatter only"}`);
35
+ }
36
+ lines.push("");
37
+ }
38
+ if (result.added.length > 0) {
39
+ lines.push("### Added");
40
+ for (const id of result.added) {
41
+ lines.push(`- **${id}**`);
42
+ }
43
+ lines.push("");
44
+ }
45
+ if (result.removed.length > 0) {
46
+ lines.push("### Removed");
47
+ for (const id of result.removed) {
48
+ lines.push(`- **${id}**`);
49
+ }
50
+ lines.push("");
51
+ }
52
+ const allDownstream = result.impact.flatMap((i) => i.downstream);
53
+ if (allDownstream.length > 0) {
54
+ lines.push("### Downstream Impact");
55
+ for (const d of allDownstream) {
56
+ lines.push(`- ${d.specId} may be stale (${d.reason})`);
57
+ }
58
+ lines.push("");
59
+ }
60
+ if (result.diffs.length === 0 && result.added.length === 0 && result.removed.length === 0) {
61
+ lines.push("No spec changes detected.\n");
62
+ }
63
+ if (result.uncommittedSpecFiles.length > 0) {
64
+ lines.push(
65
+ `> \u26A0 ${result.uncommittedSpecFiles.length} spec file(s) changed in the working tree are not covered by this range.
66
+ `
67
+ );
68
+ }
69
+ return lines.join("\n");
70
+ }
71
+
72
+ // src/commands/core/diff.ts
73
+ var FORMATS = ["pretty", "json", "changelog"];
74
+ async function runDiff(options) {
75
+ const configDir = options.configDir ?? process.cwd();
76
+ const config = await loadConfig(void 0, configDir);
77
+ const baseRef = options.base ?? config.diff?.baseline_ref ?? DEFAULT_DIFF_CONFIG.baseline_ref;
78
+ const headRef = options.head ?? "HEAD";
79
+ const configPath = join(configDir, "spec.config.yaml");
80
+ const result = await diffBetweenRefs(configPath, baseRef, headRef, {
81
+ working: options.working ?? false
82
+ });
83
+ if (options.spec) {
84
+ result.diffs = result.diffs.filter((d) => d.specId === options.spec);
85
+ result.impact = result.impact.filter((i) => i.changedSpec === options.spec);
86
+ }
87
+ return result;
88
+ }
89
+ var diff_default = defineCommand({
90
+ meta: { name: "diff", description: "Show spec changes and downstream impact" },
91
+ args: {
92
+ base: { type: "string", description: "Base git ref (default: from config or 'main')" },
93
+ head: { type: "string", description: "Head git ref (default: HEAD)" },
94
+ working: {
95
+ type: "boolean",
96
+ description: "Compare the base ref against the working tree (includes uncommitted specs)",
97
+ default: false
98
+ },
99
+ spec: { type: "string", description: "Scope to a single spec ID" },
100
+ ...sharedArgs(FORMATS)
101
+ },
102
+ async run({ args }) {
103
+ const format = resolveFormat(args.format, FORMATS);
104
+ if (!format.ok) {
105
+ console.error(`
106
+ \u2717 ${format.message}
107
+ `);
108
+ process.exit(1);
109
+ }
110
+ const output = createOutput({ quiet: args.quiet });
111
+ try {
112
+ try {
113
+ const result = await runDiff({
114
+ base: args.base,
115
+ head: args.head,
116
+ spec: args.spec,
117
+ format: args.format,
118
+ working: args.working
119
+ });
120
+ if (format.format === "json") {
121
+ console.log(JSON.stringify(result, null, 2));
122
+ return;
123
+ }
124
+ if (format.format === "changelog") {
125
+ const baseRef = args.base ?? (await loadConfig(void 0, process.cwd())).diff?.baseline_ref ?? "main";
126
+ console.log(
127
+ formatChangelog(result, baseRef, args.working ? "working tree" : args.head ?? "HEAD")
128
+ );
129
+ return;
130
+ }
131
+ const printUncommittedWarning = () => {
132
+ if (result.uncommittedSpecFiles.length === 0) return;
133
+ const count = result.uncommittedSpecFiles.length;
134
+ console.log(
135
+ `
136
+ \u26A0 ${count} spec file(s) changed in the working tree are not covered by this comparison:`
137
+ );
138
+ for (const file of result.uncommittedSpecFiles) {
139
+ console.log(` ${file}`);
140
+ }
141
+ console.log(" Run with --working to include them.");
142
+ };
143
+ if (result.diffs.length === 0 && result.added.length === 0 && result.removed.length === 0) {
144
+ output.info(" \u2713 No spec changes detected.");
145
+ printUncommittedWarning();
146
+ return;
147
+ }
148
+ console.log(result.summary);
149
+ console.log();
150
+ for (const diff of result.diffs) {
151
+ console.log(` ${diff.specId}:`);
152
+ for (const fc of diff.frontmatter) {
153
+ const detail = fc.before !== void 0 || fc.after !== void 0 ? ` (${String(fc.before)} \u2192 ${String(fc.after)})` : "";
154
+ console.log(` ${fc.type}: ${fc.field}${detail}`);
155
+ }
156
+ for (const sc of diff.sections) {
157
+ console.log(` ${sc.type}: ${sc.heading}`);
158
+ }
159
+ }
160
+ if (result.added.length > 0) {
161
+ console.log(`
162
+ Added: ${result.added.join(", ")}`);
163
+ }
164
+ if (result.removed.length > 0) {
165
+ console.log(`
166
+ Removed: ${result.removed.join(", ")}`);
167
+ }
168
+ if (result.impact.length > 0) {
169
+ console.log("\n Downstream Impact:");
170
+ for (const impact of result.impact) {
171
+ for (const d of impact.downstream) {
172
+ console.log(
173
+ ` ${d.specId} \u2014 staleness: ${d.staleness.toFixed(2)} \u2014 ${d.reason}`
174
+ );
175
+ }
176
+ }
177
+ }
178
+ printUncommittedWarning();
179
+ } catch (err) {
180
+ if (err instanceof DiffError) {
181
+ console.error(`
182
+ \u2717 ${err.message}
183
+ `);
184
+ process.exit(1);
185
+ }
186
+ throw err;
187
+ }
188
+ } catch (err) {
189
+ console.error(`
190
+ \u2717 ${err.message}
191
+ `);
192
+ process.exit(1);
193
+ }
194
+ }
195
+ });
196
+ export {
197
+ diff_default as default,
198
+ runDiff
199
+ };
200
+ //# sourceMappingURL=diff-QO7HMAK3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/core/diff.ts","../src/formatters/changelog.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { join } from \"node:path\";\nimport { diffBetweenRefs, DEFAULT_DIFF_CONFIG, DiffError } from \"@specdx/diff\";\nimport { loadConfig } from \"@specdx/core\";\nimport { formatChangelog } from \"../../formatters/changelog.js\";\nimport type { DiffResult } from \"@specdx/diff\";\nimport { sharedArgs, resolveFormat } from \"../../shared-args.js\";\nimport { createOutput } from \"../../output.js\";\n\nconst FORMATS = [\"pretty\", \"json\", \"changelog\"] as const;\n\nexport interface RunDiffOptions {\n base?: string;\n head?: string;\n spec?: string;\n format?: string;\n /** Compare the base ref against the working tree instead of a head ref. */\n working?: boolean;\n /**\n * Directory holding spec.config.yaml. Defaults to the process cwd; a library\n * consumer needs to point it elsewhere (audit run 5, F8).\n */\n configDir?: string;\n}\n\nexport async function runDiff(options: RunDiffOptions): Promise<DiffResult> {\n const configDir = options.configDir ?? process.cwd();\n const config = await loadConfig(undefined, configDir);\n\n const baseRef = options.base ?? config.diff?.baseline_ref ?? DEFAULT_DIFF_CONFIG.baseline_ref;\n const headRef = options.head ?? \"HEAD\";\n\n const configPath = join(configDir, \"spec.config.yaml\");\n\n const result = await diffBetweenRefs(configPath, baseRef, headRef, {\n working: options.working ?? false,\n });\n\n if (options.spec) {\n result.diffs = result.diffs.filter((d) => d.specId === options.spec);\n result.impact = result.impact.filter((i) => i.changedSpec === options.spec);\n }\n\n return result;\n}\n\nexport default defineCommand({\n meta: { name: \"diff\", description: \"Show spec changes and downstream impact\" },\n args: {\n base: { type: \"string\", description: \"Base git ref (default: from config or 'main')\" },\n head: { type: \"string\", description: \"Head git ref (default: HEAD)\" },\n working: {\n type: \"boolean\",\n description: \"Compare the base ref against the working tree (includes uncommitted specs)\",\n default: false,\n },\n spec: { type: \"string\", description: \"Scope to a single spec ID\" },\n ...sharedArgs(FORMATS),\n },\n async run({ args }) {\n const format = resolveFormat(args.format, FORMATS);\n if (!format.ok) {\n console.error(`\\n ✗ ${format.message}\\n`);\n process.exit(1);\n }\n const output = createOutput({ quiet: args.quiet });\n\n try {\n try {\n const result = await runDiff({\n base: args.base,\n head: args.head,\n spec: args.spec,\n format: args.format,\n working: args.working,\n });\n\n if (format.format === \"json\") {\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n if (format.format === \"changelog\") {\n const baseRef =\n args.base ?? (await loadConfig(undefined, process.cwd())).diff?.baseline_ref ?? \"main\";\n console.log(\n formatChangelog(result, baseRef, args.working ? \"working tree\" : (args.head ?? \"HEAD\")),\n );\n return;\n }\n\n // A ref-to-ref comparison cannot see the working tree, so an unqualified\n // \"no changes\" would be a false all-clear for anyone about to commit.\n const printUncommittedWarning = (): void => {\n if (result.uncommittedSpecFiles.length === 0) return;\n const count = result.uncommittedSpecFiles.length;\n console.log(\n `\\n \\u26a0 ${count} spec file(s) changed in the working tree are not covered by this comparison:`,\n );\n for (const file of result.uncommittedSpecFiles) {\n console.log(` ${file}`);\n }\n console.log(\" Run with --working to include them.\");\n };\n\n // Pretty format\n if (result.diffs.length === 0 && result.added.length === 0 && result.removed.length === 0) {\n output.info(\" \\u2713 No spec changes detected.\");\n printUncommittedWarning();\n return;\n }\n\n console.log(result.summary);\n console.log();\n\n for (const diff of result.diffs) {\n console.log(` ${diff.specId}:`);\n for (const fc of diff.frontmatter) {\n const detail =\n fc.before !== undefined || fc.after !== undefined\n ? ` (${String(fc.before)} \\u2192 ${String(fc.after)})`\n : \"\";\n console.log(` ${fc.type}: ${fc.field}${detail}`);\n }\n for (const sc of diff.sections) {\n console.log(` ${sc.type}: ${sc.heading}`);\n }\n }\n\n if (result.added.length > 0) {\n console.log(`\\n Added: ${result.added.join(\", \")}`);\n }\n if (result.removed.length > 0) {\n console.log(`\\n Removed: ${result.removed.join(\", \")}`);\n }\n\n if (result.impact.length > 0) {\n console.log(\"\\n Downstream Impact:\");\n for (const impact of result.impact) {\n for (const d of impact.downstream) {\n console.log(\n ` ${d.specId} \\u2014 staleness: ${d.staleness.toFixed(2)} \\u2014 ${d.reason}`,\n );\n }\n }\n }\n\n printUncommittedWarning();\n } catch (err) {\n if (err instanceof DiffError) {\n console.error(`\\n \\u2717 ${err.message}\\n`);\n process.exit(1);\n }\n throw err;\n }\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n },\n});\n","import type { DiffResult } from \"@specdx/diff\";\n\n/**\n * Render a diff as a markdown changelog.\n *\n * Formerly the `specdx changelog` command, which ran the same comparison as\n * `diff` and differed only in presentation. It is a format, not a second\n * question, so it lives as `diff --format changelog`.\n */\nexport function formatChangelog(result: DiffResult, baseRef: string, headRef: string): string {\n const lines: string[] = [];\n lines.push(`## Spec Changes (${baseRef}..${headRef})\\n`);\n\n if (result.diffs.length > 0) {\n lines.push(\"### Modified\");\n for (const diff of result.diffs) {\n const sections = diff.sections.map((s) => s.heading).join(\", \");\n const versionChange = diff.frontmatter.find((f) => f.field === \"version\");\n const versionStr = versionChange\n ? ` (${String(versionChange.before)} → ${String(versionChange.after)})`\n : \"\";\n lines.push(`- **${diff.specId}**${versionStr} — ${sections || \"frontmatter only\"}`);\n }\n lines.push(\"\");\n }\n\n if (result.added.length > 0) {\n lines.push(\"### Added\");\n for (const id of result.added) {\n lines.push(`- **${id}**`);\n }\n lines.push(\"\");\n }\n\n if (result.removed.length > 0) {\n lines.push(\"### Removed\");\n for (const id of result.removed) {\n lines.push(`- **${id}**`);\n }\n lines.push(\"\");\n }\n\n const allDownstream = result.impact.flatMap((i) => i.downstream);\n if (allDownstream.length > 0) {\n lines.push(\"### Downstream Impact\");\n for (const d of allDownstream) {\n lines.push(`- ${d.specId} may be stale (${d.reason})`);\n }\n lines.push(\"\");\n }\n\n if (result.diffs.length === 0 && result.added.length === 0 && result.removed.length === 0) {\n lines.push(\"No spec changes detected.\\n\");\n }\n\n // The uncommitted warning matters most here: a changelog is usually written\n // at release time, when unstaged spec edits are easy to miss.\n if (result.uncommittedSpecFiles.length > 0) {\n lines.push(\n `> ⚠ ${result.uncommittedSpecFiles.length} spec file(s) changed in the working tree are not covered by this range.\\n`,\n );\n }\n\n return lines.join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,YAAY;;;ACQd,SAAS,gBAAgB,QAAoB,SAAiB,SAAyB;AAC5F,QAAM,QAAkB,CAAC;AACzB,QAAM,KAAK,oBAAoB,OAAO,KAAK,OAAO;AAAA,CAAK;AAEvD,MAAI,OAAO,MAAM,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