specdx 0.4.0-alpha.21 → 0.4.0-alpha.23
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.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +24 -6
- package/dist/{check-GGGHTDTH.js → check-PHXXA7VY.js} +58 -21
- package/dist/check-PHXXA7VY.js.map +1 -0
- package/dist/{chunk-IEW62WR2.js → chunk-CPOXPRS7.js} +12 -12
- package/dist/chunk-CPOXPRS7.js.map +1 -0
- package/dist/chunk-DMGABJ6T.js +41 -0
- package/dist/chunk-DMGABJ6T.js.map +1 -0
- package/dist/{chunk-6IVWJKMQ.js → chunk-ESXULBLW.js} +2 -2
- package/dist/{chunk-6IVWJKMQ.js.map → chunk-ESXULBLW.js.map} +1 -1
- package/dist/{chunk-PXQML7NE.js → chunk-NAWYG4VV.js} +1 -1
- package/dist/chunk-NAWYG4VV.js.map +1 -0
- package/dist/chunk-NHD44ZYN.js +20 -0
- package/dist/chunk-NHD44ZYN.js.map +1 -0
- package/dist/{chunk-QOP2KHW3.js → chunk-UFTEMDPU.js} +27 -5
- package/dist/chunk-UFTEMDPU.js.map +1 -0
- package/dist/{diff-VHVSXLKU.js → diff-6C5LJ7SH.js} +23 -11
- package/dist/diff-6C5LJ7SH.js.map +1 -0
- package/dist/{dist-QRCEQ5WI.js → dist-SOZ3I4RP.js} +3 -3
- package/dist/{generate-WMJ37LCN.js → generate-IXDZTWWA.js} +3 -3
- package/dist/{generate-story-ORJX24P7.js → generate-story-3O4T4CEV.js} +2 -2
- package/dist/{graph-TG2CONHV.js → graph-4RNURBNP.js} +45 -8
- package/dist/graph-4RNURBNP.js.map +1 -0
- package/dist/index.d.ts +111 -7
- package/dist/index.js +235 -51
- package/dist/index.js.map +1 -1
- package/dist/{lint-ZFG6ALIT.js → lint-PKWAK4CO.js} +28 -10
- package/dist/lint-PKWAK4CO.js.map +1 -0
- package/dist/main.js +2 -2
- package/dist/{mcp-WBHZANS5.js → mcp-ZOLM2ATO.js} +3 -3
- package/dist/{pack-VDEO7GRF.js → pack-DE4UBTCC.js} +6 -5
- package/dist/pack-DE4UBTCC.js.map +1 -0
- package/dist/{ready-VDOH3XCV.js → ready-IKVESKEB.js} +17 -8
- package/dist/ready-IKVESKEB.js.map +1 -0
- package/dist/skills/core/specdx-sprint-review/SKILL.md +1 -1
- package/dist/{status-JIQUF6MX.js → status-W557JGZB.js} +52 -26
- package/dist/status-W557JGZB.js.map +1 -0
- package/dist/{update-DNXF5Q64.js → update-UFOHZEAK.js} +13 -4
- package/dist/update-UFOHZEAK.js.map +1 -0
- package/dist/{validate-TSAMI65E.js → validate-EZHUB5TW.js} +32 -14
- package/dist/validate-EZHUB5TW.js.map +1 -0
- package/package.json +2 -2
- package/dist/check-GGGHTDTH.js.map +0 -1
- package/dist/chunk-GAM4MXPC.js +0 -15
- package/dist/chunk-GAM4MXPC.js.map +0 -1
- package/dist/chunk-IEW62WR2.js.map +0 -1
- package/dist/chunk-PXQML7NE.js.map +0 -1
- package/dist/chunk-QOP2KHW3.js.map +0 -1
- package/dist/diff-VHVSXLKU.js.map +0 -1
- package/dist/graph-TG2CONHV.js.map +0 -1
- package/dist/lint-ZFG6ALIT.js.map +0 -1
- package/dist/pack-VDEO7GRF.js.map +0 -1
- package/dist/ready-VDOH3XCV.js.map +0 -1
- package/dist/status-JIQUF6MX.js.map +0 -1
- package/dist/update-DNXF5Q64.js.map +0 -1
- package/dist/validate-TSAMI65E.js.map +0 -1
- /package/dist/{dist-QRCEQ5WI.js.map → dist-SOZ3I4RP.js.map} +0 -0
- /package/dist/{generate-WMJ37LCN.js.map → generate-IXDZTWWA.js.map} +0 -0
- /package/dist/{generate-story-ORJX24P7.js.map → generate-story-3O4T4CEV.js.map} +0 -0
- /package/dist/{mcp-WBHZANS5.js.map → mcp-ZOLM2ATO.js.map} +0 -0
|
@@ -475,6 +475,12 @@ var EDGE_CASE_KEYWORDS = [
|
|
|
475
475
|
"unprocessable"
|
|
476
476
|
];
|
|
477
477
|
var ERROR_STATUS_CODE = /\b[45]\d{2}\b/;
|
|
478
|
+
var EDGE_CASE_SECTION = "edge cases";
|
|
479
|
+
var PLACEHOLDER_BODIES = /^(todo|tbd|fixme|n\/a|na|none|xxx|\.{2,}|-|\*)$/i;
|
|
480
|
+
var DISCLAIMED_BODIES = /^(none|no|nothing|n\/a)\b[\s\S]{0,40}$/i;
|
|
481
|
+
function meaningfulContent(content) {
|
|
482
|
+
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();
|
|
483
|
+
}
|
|
478
484
|
var edgeCaseCoverageRule = {
|
|
479
485
|
id: "completeness/edge-case-coverage",
|
|
480
486
|
description: "Flag user stories or test plans that don't mention error states or edge cases",
|
|
@@ -483,6 +489,22 @@ var edgeCaseCoverageRule = {
|
|
|
483
489
|
const type = context.spec.frontmatter.type;
|
|
484
490
|
if (type !== "user-story" && type !== "test-plan")
|
|
485
491
|
return [];
|
|
492
|
+
const section = context.spec.parsedSections.find((s) => s.heading.trim().toLowerCase() === EDGE_CASE_SECTION);
|
|
493
|
+
if (type === "test-plan" && section) {
|
|
494
|
+
const body = meaningfulContent(section.content);
|
|
495
|
+
const written = body !== "" && !PLACEHOLDER_BODIES.test(body) && !DISCLAIMED_BODIES.test(body);
|
|
496
|
+
if (written)
|
|
497
|
+
return [];
|
|
498
|
+
return [
|
|
499
|
+
{
|
|
500
|
+
ruleId: "completeness/edge-case-coverage",
|
|
501
|
+
severity: "warn",
|
|
502
|
+
message: `The "${section.heading}" section lists no cases \u2014 describe the boundary conditions and failure modes this plan covers, or the plan asserts only the happy path.`,
|
|
503
|
+
filePath: context.spec.filePath,
|
|
504
|
+
section: section.heading
|
|
505
|
+
}
|
|
506
|
+
];
|
|
507
|
+
}
|
|
486
508
|
const content = context.spec.content.toLowerCase();
|
|
487
509
|
const hasEdgeCases = EDGE_CASE_KEYWORDS.some((kw) => content.includes(kw)) || ERROR_STATUS_CODE.test(content);
|
|
488
510
|
if (hasEdgeCases)
|
|
@@ -623,8 +645,8 @@ var ambiguityScoreAiRule = {
|
|
|
623
645
|
};
|
|
624
646
|
|
|
625
647
|
// ../lint/dist/rules/no-placeholder-sections.js
|
|
626
|
-
var
|
|
627
|
-
function
|
|
648
|
+
var PLACEHOLDER_BODIES2 = /^(todo|tbd|fixme|n\/a|na|none|xxx|\.{2,}|-|\*)$/i;
|
|
649
|
+
function meaningfulContent2(content) {
|
|
628
650
|
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
651
|
}
|
|
630
652
|
var noPlaceholderSectionsRule = {
|
|
@@ -633,8 +655,8 @@ var noPlaceholderSectionsRule = {
|
|
|
633
655
|
severity: "warn",
|
|
634
656
|
run(context) {
|
|
635
657
|
return context.spec.parsedSections.filter((section) => section.heading !== "").filter((section) => {
|
|
636
|
-
const body =
|
|
637
|
-
return body === "" ||
|
|
658
|
+
const body = meaningfulContent2(section.content);
|
|
659
|
+
return body === "" || PLACEHOLDER_BODIES2.test(body);
|
|
638
660
|
}).map((section) => ({
|
|
639
661
|
ruleId: "completeness/no-placeholder-sections",
|
|
640
662
|
severity: "warn",
|
|
@@ -725,4 +747,4 @@ export {
|
|
|
725
747
|
uncoveredFeatures,
|
|
726
748
|
getPreset
|
|
727
749
|
};
|
|
728
|
-
//# sourceMappingURL=chunk-
|
|
750
|
+
//# sourceMappingURL=chunk-UFTEMDPU.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\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"],"mappings":";;;;;;;;AAcM,SAAU,iBAAiB,SAA0B;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I,QAAQ;AAAI,aAAO,CAAA;AAEvB,WAAO;MACL;QACE,QAAQ;QACR,UAAU;QACV,SACE,qBAAqB,EAAE,+CAA+C,GAAG,8CAC9B,EAAE,kCAAkC,GAAG;QAEpF,UAAU,KAAK;;;EAGrB;;;;ACvCK,IAAM,iBAA6B;EACxC;EACA;EACA;EACA;EACA;EACA;;AAGK,IAAM,eAA2B;EACtC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGK,IAAM,kBAA8B,CAAC,GAAG,gBAAgB,GAAG,YAAY;;;ACnCxE,SAAU,UAAU,MAAY;AACpC,UAAQ,MAAM;IACZ,KAAK;AACH,aAAO;IACT,KAAK;AACH,aAAO;IACT,KAAK;AAKH,aAAO,gBAAgB,IAAI,CAAC,SAC1B,KAAK,aAAa,SAAS,EAAE,GAAG,MAAM,UAAU,QAAgB,IAAK,IAAI;IAE7E;AACE,YAAM,IAAI,MACR,oBAAoB,IAAI,kHAAkH;EAEhJ;AACF;;;ACtBA,SAAS,qBAAqB;","names":["STOPWORDS","PLACEHOLDER_BODIES","meaningfulContent"]}
|
|
@@ -2,7 +2,14 @@ import {
|
|
|
2
2
|
DEFAULT_DIFF_CONFIG,
|
|
3
3
|
DiffError,
|
|
4
4
|
diffBetweenRefs
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-NAWYG4VV.js";
|
|
6
|
+
import {
|
|
7
|
+
createOutput
|
|
8
|
+
} from "./chunk-NHD44ZYN.js";
|
|
9
|
+
import {
|
|
10
|
+
resolveFormat,
|
|
11
|
+
sharedArgs
|
|
12
|
+
} from "./chunk-DMGABJ6T.js";
|
|
6
13
|
import {
|
|
7
14
|
loadConfig
|
|
8
15
|
} from "./chunk-SNQNQ2MP.js";
|
|
@@ -63,8 +70,9 @@ function formatChangelog(result, baseRef, headRef) {
|
|
|
63
70
|
}
|
|
64
71
|
|
|
65
72
|
// src/commands/core/diff.ts
|
|
73
|
+
var FORMATS = ["pretty", "json", "changelog"];
|
|
66
74
|
async function runDiff(options) {
|
|
67
|
-
const configDir = process.cwd();
|
|
75
|
+
const configDir = options.configDir ?? process.cwd();
|
|
68
76
|
const config = await loadConfig(void 0, configDir);
|
|
69
77
|
const baseRef = options.base ?? config.diff?.baseline_ref ?? DEFAULT_DIFF_CONFIG.baseline_ref;
|
|
70
78
|
const headRef = options.head ?? "HEAD";
|
|
@@ -89,13 +97,17 @@ var diff_default = defineCommand({
|
|
|
89
97
|
default: false
|
|
90
98
|
},
|
|
91
99
|
spec: { type: "string", description: "Scope to a single spec ID" },
|
|
92
|
-
|
|
93
|
-
type: "string",
|
|
94
|
-
description: "Output format: pretty, json, changelog",
|
|
95
|
-
default: "pretty"
|
|
96
|
-
}
|
|
100
|
+
...sharedArgs(FORMATS)
|
|
97
101
|
},
|
|
98
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 });
|
|
99
111
|
try {
|
|
100
112
|
try {
|
|
101
113
|
const result = await runDiff({
|
|
@@ -105,11 +117,11 @@ var diff_default = defineCommand({
|
|
|
105
117
|
format: args.format,
|
|
106
118
|
working: args.working
|
|
107
119
|
});
|
|
108
|
-
if (
|
|
120
|
+
if (format.format === "json") {
|
|
109
121
|
console.log(JSON.stringify(result, null, 2));
|
|
110
122
|
return;
|
|
111
123
|
}
|
|
112
|
-
if (
|
|
124
|
+
if (format.format === "changelog") {
|
|
113
125
|
const baseRef = args.base ?? (await loadConfig(void 0, process.cwd())).diff?.baseline_ref ?? "main";
|
|
114
126
|
console.log(
|
|
115
127
|
formatChangelog(result, baseRef, args.working ? "working tree" : args.head ?? "HEAD")
|
|
@@ -129,7 +141,7 @@ var diff_default = defineCommand({
|
|
|
129
141
|
console.log(" Run with --working to include them.");
|
|
130
142
|
};
|
|
131
143
|
if (result.diffs.length === 0 && result.added.length === 0 && result.removed.length === 0) {
|
|
132
|
-
|
|
144
|
+
output.info(" \u2713 No spec changes detected.");
|
|
133
145
|
printUncommittedWarning();
|
|
134
146
|
return;
|
|
135
147
|
}
|
|
@@ -185,4 +197,4 @@ export {
|
|
|
185
197
|
diff_default as default,
|
|
186
198
|
runDiff
|
|
187
199
|
};
|
|
188
|
-
//# sourceMappingURL=diff-
|
|
200
|
+
//# sourceMappingURL=diff-6C5LJ7SH.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,SAAS,GAAG;AAC3B,UAAM,KAAK,cAAc;AACzB,eAAW,QAAQ,OAAO,OAAO;AAC/B,YAAM,WAAW,KAAK,SAAS,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,IAAI;AAC9D,YAAM,gBAAgB,KAAK,YAAY,KAAK,CAAC,MAAM,EAAE,UAAU,SAAS;AACxE,YAAM,aAAa,gBACf,KAAK,OAAO,cAAc,MAAM,CAAC,WAAM,OAAO,cAAc,KAAK,CAAC,MAClE;AACJ,YAAM,KAAK,OAAO,KAAK,MAAM,KAAK,UAAU,WAAM,YAAY,kBAAkB,EAAE;AAAA,IACpF;AACA,UAAM,KAAK,EAAE;AAAA,EACf;AAEA,MAAI,OAAO,MAAM,SAAS,GAAG;AAC3B,UAAM,KAAK,WAAW;AACtB,eAAW,MAAM,OAAO,OAAO;AAC7B,YAAM,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AAAA,QACzD;AAEA,YAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,kBAAQ,IAAI,wBAAwB;AACpC,qBAAW,UAAU,OAAO,QAAQ;AAClC,uBAAW,KAAK,OAAO,YAAY;AACjC,sBAAQ;AAAA,gBACN,OAAO,EAAE,MAAM,sBAAsB,EAAE,UAAU,QAAQ,CAAC,CAAC,WAAW,EAAE,MAAM;AAAA,cAChF;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAEA,gCAAwB;AAAA,MAC1B,SAAS,KAAK;AACZ,YAAI,eAAe,WAAW;AAC5B,kBAAQ,MAAM;AAAA,WAAc,IAAI,OAAO;AAAA,CAAI;AAC3C,kBAAQ,KAAK,CAAC;AAAA,QAChB;AACA,cAAM;AAAA,MACR;AAAA,IACF,SAAS,KAAK;AACZ,cAAQ,MAAM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
createLintEngine,
|
|
9
9
|
getPreset
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-UFTEMDPU.js";
|
|
11
11
|
import {
|
|
12
12
|
DEFAULT_DIFF_CONFIG,
|
|
13
13
|
DiffError,
|
|
14
14
|
diffBetweenRefs
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-NAWYG4VV.js";
|
|
16
16
|
import {
|
|
17
17
|
ConfigError,
|
|
18
18
|
GraphError,
|
|
@@ -315,4 +315,4 @@ function createMcpServer(version = "0.0.0-unknown") {
|
|
|
315
315
|
export {
|
|
316
316
|
createMcpServer
|
|
317
317
|
};
|
|
318
|
-
//# sourceMappingURL=dist-
|
|
318
|
+
//# sourceMappingURL=dist-SOZ3I4RP.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
labelled
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CPOXPRS7.js";
|
|
4
4
|
import "./chunk-HCJDCS26.js";
|
|
5
5
|
import "./chunk-5WRI5ZAA.js";
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ import { defineCommand } from "citty";
|
|
|
9
9
|
var generate_default = defineCommand({
|
|
10
10
|
meta: { name: "generate", description: "Generate spec stubs from existing specs" },
|
|
11
11
|
subCommands: {
|
|
12
|
-
story: () => import("./generate-story-
|
|
12
|
+
story: () => import("./generate-story-3O4T4CEV.js").then((m) => labelled("generate story", m.default)),
|
|
13
13
|
"test-plan": () => import("./generate-test-plan-Z46W3N3B.js").then(
|
|
14
14
|
(m) => labelled("generate test-plan", m.default)
|
|
15
15
|
)
|
|
@@ -18,4 +18,4 @@ var generate_default = defineCommand({
|
|
|
18
18
|
export {
|
|
19
19
|
generate_default as default
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=generate-
|
|
21
|
+
//# sourceMappingURL=generate-IXDZTWWA.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseFeatureEntries,
|
|
3
3
|
uncoveredFeatures
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UFTEMDPU.js";
|
|
5
5
|
import {
|
|
6
6
|
createLogger,
|
|
7
7
|
loadConfig,
|
|
@@ -217,4 +217,4 @@ export {
|
|
|
217
217
|
defineCommandExport,
|
|
218
218
|
generateStories
|
|
219
219
|
};
|
|
220
|
-
//# sourceMappingURL=generate-story-
|
|
220
|
+
//# sourceMappingURL=generate-story-3O4T4CEV.js.map
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
+
createOutput
|
|
3
|
+
} from "./chunk-NHD44ZYN.js";
|
|
4
|
+
import {
|
|
5
|
+
resolveFormat,
|
|
2
6
|
sharedArgs
|
|
3
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-DMGABJ6T.js";
|
|
4
8
|
import {
|
|
5
9
|
GraphError,
|
|
6
10
|
buildGraph,
|
|
@@ -15,10 +19,19 @@ import "./chunk-5WRI5ZAA.js";
|
|
|
15
19
|
|
|
16
20
|
// src/commands/core/graph.ts
|
|
17
21
|
import { defineCommand } from "citty";
|
|
22
|
+
var FORMATS = ["pretty", "json", "dot"];
|
|
18
23
|
var graph_default = defineCommand({
|
|
19
24
|
meta: { name: "graph", description: "Print the spec dependency graph" },
|
|
20
|
-
args: { ...sharedArgs },
|
|
25
|
+
args: { ...sharedArgs(FORMATS) },
|
|
21
26
|
async run({ args }) {
|
|
27
|
+
const format = resolveFormat(args.format, FORMATS);
|
|
28
|
+
if (!format.ok) {
|
|
29
|
+
console.error(`
|
|
30
|
+
\u2717 ${format.message}
|
|
31
|
+
`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
const output = createOutput({ quiet: args.quiet });
|
|
22
35
|
let config;
|
|
23
36
|
const configDir = process.cwd();
|
|
24
37
|
try {
|
|
@@ -46,7 +59,31 @@ var graph_default = defineCommand({
|
|
|
46
59
|
}
|
|
47
60
|
const referenceEdges = collectReferenceEdges(specs);
|
|
48
61
|
const unreflected = findUnreflectedReferences(referenceEdges, idToEntry, graph);
|
|
49
|
-
if (
|
|
62
|
+
if (format.format === "json") {
|
|
63
|
+
console.log(
|
|
64
|
+
JSON.stringify(
|
|
65
|
+
{
|
|
66
|
+
nodes: sorted,
|
|
67
|
+
edges: graph.edges,
|
|
68
|
+
referenceEdges,
|
|
69
|
+
unreflectedReferences: unreflected.map(
|
|
70
|
+
({ edge, requiringEntry, requiredEntry, createsCycle }) => ({
|
|
71
|
+
from: edge.fromId,
|
|
72
|
+
to: edge.toId,
|
|
73
|
+
relationship: edge.relationship,
|
|
74
|
+
requiringEntry,
|
|
75
|
+
requiredEntry,
|
|
76
|
+
createsCycle
|
|
77
|
+
})
|
|
78
|
+
)
|
|
79
|
+
},
|
|
80
|
+
null,
|
|
81
|
+
2
|
|
82
|
+
)
|
|
83
|
+
);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (format.format === "dot") {
|
|
50
87
|
console.log("digraph specs {");
|
|
51
88
|
for (const edge of graph.edges) console.log(` "${edge.from}" -> "${edge.to}";`);
|
|
52
89
|
for (const ref of referenceEdges) {
|
|
@@ -57,16 +94,16 @@ var graph_default = defineCommand({
|
|
|
57
94
|
console.log("}");
|
|
58
95
|
return;
|
|
59
96
|
}
|
|
60
|
-
|
|
97
|
+
output.info("\n Spec Dependency Graph:\n");
|
|
61
98
|
for (const node of sorted) {
|
|
62
99
|
const downstream = graph.getDownstream(node);
|
|
63
100
|
const arrow = downstream.length > 0 ? ` \u2192 ${downstream.join(", ")}` : "";
|
|
64
|
-
|
|
101
|
+
output.out(` ${node}${arrow}`);
|
|
65
102
|
}
|
|
66
103
|
if (referenceEdges.length > 0) {
|
|
67
|
-
|
|
104
|
+
output.info("\n Reference edges (frontmatter):\n");
|
|
68
105
|
for (const ref of referenceEdges) {
|
|
69
|
-
|
|
106
|
+
output.out(` ${ref.fromId} \u2014${ref.relationship}\u2192 ${ref.toId}`);
|
|
70
107
|
}
|
|
71
108
|
}
|
|
72
109
|
const suggestions = unreflected.filter((u) => !u.createsCycle);
|
|
@@ -100,4 +137,4 @@ var graph_default = defineCommand({
|
|
|
100
137
|
export {
|
|
101
138
|
graph_default as default
|
|
102
139
|
};
|
|
103
|
-
//# sourceMappingURL=graph-
|
|
140
|
+
//# sourceMappingURL=graph-4RNURBNP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/core/graph.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport {\n loadConfig,\n buildGraph,\n GraphError,\n parseSpec,\n resolveGlob,\n collectReferenceEdges,\n findUnreflectedReferences,\n} from \"@specdx/core\";\nimport type { ParsedSpec } from \"@specdx/core\";\nimport { sharedArgs, resolveFormat } from \"../../shared-args.js\";\nimport { createOutput } from \"../../output.js\";\n\nconst FORMATS = [\"pretty\", \"json\", \"dot\"] as const;\n\nexport default defineCommand({\n meta: { name: \"graph\", description: \"Print the spec dependency graph\" },\n args: { ...sharedArgs(FORMATS) },\n async run({ args }) {\n const format = resolveFormat(args.format, FORMATS);\n if (!format.ok) {\n console.error(`\\n ✗ ${format.message}\\n`);\n process.exit(1);\n }\n const output = createOutput({ quiet: args.quiet });\n\n let config;\n const configDir = process.cwd();\n try {\n config = await loadConfig(undefined, configDir);\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n try {\n const graph = buildGraph(config);\n const sorted = graph.topologicalSort();\n\n // Frontmatter references are a second, richer source of relationships;\n // surface them alongside config requires instead of silently ignoring\n // them (issue #8).\n const idToEntry = new Map<string, string>();\n const specs: ParsedSpec[] = [];\n for (const [key, entry] of Object.entries(config.specs)) {\n const paths = await resolveGlob(entry.path, configDir);\n for (const p of paths) {\n const spec = await parseSpec(p);\n specs.push(spec);\n if (typeof spec.frontmatter.id === \"string\") {\n idToEntry.set(spec.frontmatter.id, key);\n }\n }\n }\n const referenceEdges = collectReferenceEdges(specs);\n const unreflected = findUnreflectedReferences(referenceEdges, idToEntry, graph);\n\n if (format.format === \"json\") {\n console.log(\n JSON.stringify(\n {\n nodes: sorted,\n edges: graph.edges,\n referenceEdges,\n unreflectedReferences: unreflected.map(\n ({ edge, requiringEntry, requiredEntry, createsCycle }) => ({\n from: edge.fromId,\n to: edge.toId,\n relationship: edge.relationship,\n requiringEntry,\n requiredEntry,\n createsCycle,\n }),\n ),\n },\n null,\n 2,\n ),\n );\n return;\n }\n\n if (format.format === \"dot\") {\n console.log(\"digraph specs {\");\n for (const edge of graph.edges) console.log(` \"${edge.from}\" -> \"${edge.to}\";`);\n for (const ref of referenceEdges) {\n console.log(\n ` \"${ref.fromId}\" -> \"${ref.toId}\" [style=dashed, label=\"${ref.relationship}\"];`,\n );\n }\n console.log(\"}\");\n return;\n }\n\n output.info(\"\\n Spec Dependency Graph:\\n\");\n for (const node of sorted) {\n const downstream = graph.getDownstream(node);\n const arrow = downstream.length > 0 ? ` → ${downstream.join(\", \")}` : \"\";\n output.out(` ${node}${arrow}`);\n }\n\n if (referenceEdges.length > 0) {\n output.info(\"\\n Reference edges (frontmatter):\\n\");\n for (const ref of referenceEdges) {\n output.out(` ${ref.fromId} —${ref.relationship}→ ${ref.toId}`);\n }\n }\n\n const suggestions = unreflected.filter((u) => !u.createsCycle);\n const conflicts = unreflected.filter((u) => u.createsCycle);\n\n if (suggestions.length > 0) {\n console.log(\"\\n ⚠ References not reflected in config requires:\\n\");\n for (const { edge, requiringEntry, requiredEntry } of suggestions) {\n console.log(\n ` ${edge.fromId} ${edge.relationship} ${edge.toId} — add \"requires: [${requiredEntry}]\" to the \"${requiringEntry}\" entry in spec.config.yaml`,\n );\n }\n }\n\n if (conflicts.length > 0) {\n console.log(\"\\n ⚠ References that conflict with the requires chain:\\n\");\n for (const { edge, requiringEntry, requiredEntry } of conflicts) {\n console.log(\n ` ${edge.fromId} ${edge.relationship} ${edge.toId} — implies \"${requiringEntry}\" requires \"${requiredEntry}\", but that would create a cycle; review the reference or the config requires`,\n );\n }\n }\n\n console.log(\"\");\n } catch (err) {\n if (err instanceof GraphError) {\n console.error(` ✗ ${err.message}`);\n process.exit(1);\n }\n throw err;\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAc9B,IAAM,UAAU,CAAC,UAAU,QAAQ,KAAK;AAExC,IAAO,gBAAQ,cAAc;AAAA,EAC3B,MAAM,EAAE,MAAM,SAAS,aAAa,kCAAkC;AAAA,EACtE,MAAM,EAAE,GAAG,WAAW,OAAO,EAAE;AAAA,EAC/B,MAAM,IAAI,EAAE,KAAK,GAAG;AAClB,UAAM,SAAS,cAAc,KAAK,QAAQ,OAAO;AACjD,QAAI,CAAC,OAAO,IAAI;AACd,cAAQ,MAAM;AAAA,WAAS,OAAO,OAAO;AAAA,CAAI;AACzC,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,U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AAK,MAAM,IAAI,KAAK,YAAY,IAAI,KAAK,IAAI,oBAAe,cAAc,eAAe,aAAa;AAAA,UAC7G;AAAA,QACF;AAAA,MACF;AAEA,cAAQ,IAAI,EAAE;AAAA,IAChB,SAAS,KAAK;AACZ,UAAI,eAAe,YAAY;AAC7B,gBAAQ,MAAM,YAAO,IAAI,OAAO,EAAE;AAClC,gBAAQ,KAAK,CAAC;AAAA,MAChB;AACA,YAAM;AAAA,IACR;AAAA,EACF;AACF,CAAC;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,60 @@ interface ScaffoldOptions {
|
|
|
6
6
|
}
|
|
7
7
|
declare function scaffoldProject({ projectName, template, targetDir, }: ScaffoldOptions): Promise<void>;
|
|
8
8
|
|
|
9
|
+
declare const SPEC_TYPES: readonly ["prd", "technical-design", "user-story", "test-plan", "adr", "api-contract", "epic", "quick-spec", "project-context"];
|
|
10
|
+
type SpecType = (typeof SPEC_TYPES)[number];
|
|
11
|
+
interface SpecEntry {
|
|
12
|
+
path: string;
|
|
13
|
+
type: SpecType;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
requires?: string[];
|
|
16
|
+
owner?: string;
|
|
17
|
+
}
|
|
18
|
+
interface PackCompressionConfig {
|
|
19
|
+
strip_boilerplate?: boolean;
|
|
20
|
+
stable_days?: number;
|
|
21
|
+
collapse_resolved_adrs?: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface PackConfig {
|
|
24
|
+
max_tokens?: number;
|
|
25
|
+
format?: "xml" | "markdown" | "json";
|
|
26
|
+
compression?: PackCompressionConfig;
|
|
27
|
+
boilerplate_sections?: string[];
|
|
28
|
+
}
|
|
29
|
+
interface SdxConfig {
|
|
30
|
+
version: string;
|
|
31
|
+
project?: {
|
|
32
|
+
name?: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
};
|
|
35
|
+
specs: Record<string, SpecEntry>;
|
|
36
|
+
lint?: {
|
|
37
|
+
extends?: string;
|
|
38
|
+
rules?: Record<string, unknown>;
|
|
39
|
+
ignore?: string[];
|
|
40
|
+
};
|
|
41
|
+
pack?: PackConfig;
|
|
42
|
+
diff?: {
|
|
43
|
+
baseline_ref?: string;
|
|
44
|
+
staleness_threshold_days?: number;
|
|
45
|
+
ignore_paths?: string[];
|
|
46
|
+
};
|
|
47
|
+
ci?: {
|
|
48
|
+
block_on?: ("error" | "warn" | "info")[];
|
|
49
|
+
post_comment?: boolean;
|
|
50
|
+
update_badge?: boolean;
|
|
51
|
+
trigger_paths?: string[];
|
|
52
|
+
};
|
|
53
|
+
check?: {
|
|
54
|
+
framework?: "auto" | "express" | "hono" | "nextjs";
|
|
55
|
+
routes_dir?: string;
|
|
56
|
+
app_dir?: string;
|
|
57
|
+
types_dir?: string;
|
|
58
|
+
tests_dir?: string;
|
|
59
|
+
ignore?: string[];
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
9
63
|
type Severity = "error" | "warn" | "info";
|
|
10
64
|
interface Diagnostic {
|
|
11
65
|
ruleId: string;
|
|
@@ -28,13 +82,28 @@ interface RunLintOptions {
|
|
|
28
82
|
}
|
|
29
83
|
/** Lint results plus whether anything was actually linted (vacuous-pass audit). */
|
|
30
84
|
interface RunLintResults extends LintResults {
|
|
31
|
-
/** Number of
|
|
32
|
-
|
|
85
|
+
/** Number of spec files linted. Named for what it counts, not "count". */
|
|
86
|
+
specFiles: number;
|
|
33
87
|
/** False when no specs resolved — "no diagnostics" is then not a pass. */
|
|
34
88
|
assessed: boolean;
|
|
35
89
|
}
|
|
36
90
|
declare function runLint(options: RunLintOptions): Promise<RunLintResults>;
|
|
37
91
|
|
|
92
|
+
/** Options for the pack command. */
|
|
93
|
+
interface PackOptions {
|
|
94
|
+
/** Specific task or context to optimise relevance for. */
|
|
95
|
+
task?: string;
|
|
96
|
+
/** Glob patterns or spec IDs to include. */
|
|
97
|
+
specs?: string[];
|
|
98
|
+
/** Maximum token budget for the output. */
|
|
99
|
+
budget?: number;
|
|
100
|
+
/** Output format (e.g. "xml", "json", "markdown"). */
|
|
101
|
+
format?: string;
|
|
102
|
+
/** Include all specs without budget trimming. */
|
|
103
|
+
full?: boolean;
|
|
104
|
+
/** Preview what would be packed without writing output. */
|
|
105
|
+
dryRun?: boolean;
|
|
106
|
+
}
|
|
38
107
|
/** Statistics about how the budget was allocated. */
|
|
39
108
|
interface PackStats {
|
|
40
109
|
/** Total token budget. */
|
|
@@ -137,7 +206,12 @@ interface DiffResult {
|
|
|
137
206
|
}
|
|
138
207
|
interface StatusResult {
|
|
139
208
|
project: string;
|
|
140
|
-
|
|
209
|
+
/**
|
|
210
|
+
* Spec *files* resolved, not config entries — one glob entry can resolve to
|
|
211
|
+
* many files. The old name `specCount` did not say which, and meant the
|
|
212
|
+
* other thing in `runValidate` (audit run 5, F4).
|
|
213
|
+
*/
|
|
214
|
+
specFiles: number;
|
|
141
215
|
byStatus: Record<string, number>;
|
|
142
216
|
lintHealth: {
|
|
143
217
|
errors: number;
|
|
@@ -161,11 +235,41 @@ interface RunDiffOptions {
|
|
|
161
235
|
format?: string;
|
|
162
236
|
/** Compare the base ref against the working tree instead of a head ref. */
|
|
163
237
|
working?: boolean;
|
|
238
|
+
/**
|
|
239
|
+
* Directory holding spec.config.yaml. Defaults to the process cwd; a library
|
|
240
|
+
* consumer needs to point it elsewhere (audit run 5, F8).
|
|
241
|
+
*/
|
|
242
|
+
configDir?: string;
|
|
164
243
|
}
|
|
165
244
|
declare function runDiff(options: RunDiffOptions): Promise<DiffResult>;
|
|
166
245
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
246
|
+
interface RunStatusOptions {
|
|
247
|
+
/**
|
|
248
|
+
* Directory holding spec.config.yaml. Defaults to the process cwd, which is
|
|
249
|
+
* right for the CLI and useless to a library consumer — `runLint` and
|
|
250
|
+
* `runPack` take one, so this does too (audit run 5, F8).
|
|
251
|
+
*/
|
|
252
|
+
configDir?: string;
|
|
253
|
+
}
|
|
254
|
+
declare function runStatus(options?: RunStatusOptions): Promise<StatusResult>;
|
|
255
|
+
|
|
256
|
+
interface ValidateResult {
|
|
257
|
+
valid: boolean;
|
|
258
|
+
/** Number of spec entries declared in the config. */
|
|
259
|
+
specEntries?: number;
|
|
260
|
+
/** Number of spec files those entries actually resolve to. */
|
|
261
|
+
specFiles?: number;
|
|
262
|
+
/** Non-fatal honesty notes: entries resolving to nothing, empty suite. */
|
|
263
|
+
warnings: string[];
|
|
264
|
+
error?: string;
|
|
265
|
+
details?: unknown[];
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Validate spec.config.yaml: a schema-valid config, a buildable dependency
|
|
269
|
+
* graph (issue #13), and declared spec paths that actually resolve. An entry
|
|
270
|
+
* that matches no files makes every downstream verdict vacuous, so it is
|
|
271
|
+
* reported here rather than silently flowing into lint/status/ready.
|
|
272
|
+
*/
|
|
273
|
+
declare function runValidate(configDir: string): Promise<ValidateResult>;
|
|
170
274
|
|
|
171
|
-
export { runDiff, runLint, runPack, runStatus, scaffoldProject };
|
|
275
|
+
export { type Diagnostic, type DiffResult, type LintResults, type PackOptions, type PackResult, type RunDiffOptions, type RunLintOptions, type RunLintResults, type RunPackOptions, type RunStatusOptions, type ScaffoldOptions, type SdxConfig, type SpecType, type StatusResult, type Template, type ValidateResult, runDiff, runLint, runPack, runStatus, runValidate, scaffoldProject };
|