specdx 0.4.0-alpha.21 → 0.4.0-alpha.22
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-AQZQIURH.js} +12 -12
- package/dist/chunk-AQZQIURH.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-KVLFW5MI.js} +2 -2
- package/dist/{chunk-6IVWJKMQ.js.map → chunk-KVLFW5MI.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-AVXZHH76.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 +221 -50
- 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-VMHFWM3O.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-NWMX2KJZ.js} +38 -25
- package/dist/status-NWMX2KJZ.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 +5 -5
- 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-AVXZHH76.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-VMHFWM3O.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../lint/src/engine.ts","../../lint/src/rules/story-coverage.ts","../../lint/src/rules/valid-frontmatter.ts","../../lint/src/rules/required-sections.ts","../../lint/src/rules/valid-references.ts","../../lint/src/rules/no-circular-deps.ts","../../lint/src/rules/staleness-check.ts","../../lint/src/rules/no-vague-language.ts","../../lint/src/rules/single-project-context.ts","../../lint/src/rules/terminology.ts","../../lint/src/rules/edge-case-coverage.ts","../../lint/src/rules/naming-conventions.ts","../../lint/src/rules/threat-coverage.ts","../../lint/src/rules/ambiguity-score-ai.ts","../../lint/src/rules/no-placeholder-sections.ts","../../lint/src/rules/id-matches-config-key.ts","../../lint/src/rules/index.ts","../../lint/src/presets.ts","../../lint/src/custom-rule-loader.ts"],"sourcesContent":["import type { ParsedSpec, DependencyGraph } from \"@specdx/core\";\nimport type { SdxConfig } from \"@specdx/schema\";\nimport type { LintRule, LintResults, Diagnostic } from \"./types.js\";\n\nexport interface LintEngineOptions {\n rules: LintRule[];\n config?: SdxConfig;\n graph?: DependencyGraph;\n}\n\nexport interface LintEngine {\n lint(specs: ParsedSpec[]): LintResults;\n}\n\nexport function createLintEngine(options: LintEngineOptions): LintEngine {\n return {\n lint(specs: ParsedSpec[]): LintResults {\n const diagnostics: Diagnostic[] = [];\n for (const spec of specs) {\n for (const rule of options.rules) {\n const results = rule.run({\n spec,\n allSpecs: specs,\n config: options.config,\n graph: options.graph,\n });\n // The rule object's `severity` is the authority, not the severity a\n // rule happens to write into the diagnostic it returns.\n //\n // Every built-in rule emits exactly one severity -- its own -- but ten\n // of them hardcoded it as a literal in the diagnostic. Presets rewrite\n // `rule.severity`, so nothing downstream read what `strict` set, and\n // `--preset strict` produced output byte-identical to `recommended` on\n // the CLI, in `extends:`, in the Action's `preset` input and in\n // `runLint({ preset })`. Stamping it here is what makes a preset mean\n // anything.\n for (const diagnostic of results) {\n diagnostics.push({ ...diagnostic, severity: rule.severity });\n }\n }\n }\n return {\n diagnostics,\n hasErrors: diagnostics.some((d) => d.severity === \"error\"),\n hasWarnings: diagnostics.some((d) => d.severity === \"warn\"),\n };\n },\n };\n}\n","import type { LintRule } from \"../types.js\";\nimport type { ParsedSpec } from \"@specdx/core\";\n\n/** Words carrying no signal about what a feature is. */\nconst STOPWORDS = new Set([\n \"a\",\n \"an\",\n \"the\",\n \"and\",\n \"or\",\n \"of\",\n \"to\",\n \"for\",\n \"with\",\n \"its\",\n \"it\",\n \"in\",\n \"on\",\n \"at\",\n \"by\",\n \"from\",\n \"into\",\n \"every\",\n \"each\",\n \"that\",\n \"this\",\n \"be\",\n \"is\",\n \"are\",\n \"as\",\n \"can\",\n \"will\",\n \"must\",\n \"so\",\n \"their\",\n \"them\",\n \"when\",\n \"which\",\n \"who\",\n]);\n\n/** Share of a feature's words a story must echo to count as covering it. */\nconst OVERLAP_THRESHOLD = 0.5;\n\n/** Lower bar for a story that explicitly references the PRD. */\nconst REFERENCED_THRESHOLD = 0.34;\n\nfunction tokenise(text: string): Set<string> {\n const words = text\n .toLowerCase()\n .replace(/[^a-z0-9\\s-]/g, \" \")\n .split(/\\s+/)\n .filter((w) => w.length > 2 && !STOPWORDS.has(w))\n // Crude singularisation, so \"actions\" matches \"action\".\n .map((w) => (w.length > 3 && w.endsWith(\"s\") && !w.endsWith(\"ss\") ? w.slice(0, -1) : w));\n return new Set(words);\n}\n\nfunction extractFeatureSection(content: string): string | null {\n // Scanned line by line rather than with one regex: `$` and `\\Z` behave\n // differently enough across multiline modes to make the regex form a trap.\n const lines = content.split(\"\\n\");\n const start = lines.findIndex((l) => /^##\\s+Features\\s*$/.test(l.trim()));\n if (start === -1) return null;\n const body: string[] = [];\n for (let i = start + 1; i < lines.length; i++) {\n if (/^##\\s/.test(lines[i]!)) break;\n body.push(lines[i]!);\n }\n return body.join(\"\\n\");\n}\n\n/**\n * Feature descriptions from a PRD's Features section.\n *\n * Previously only `- **F1**: text` was recognised, so a PRD written any other\n * way parsed to zero features and the rule passed vacuously -- which `ready`\n * then reported as \"all features have stories\" over an empty set.\n */\nexport function parseFeatures(content: string): string[] {\n return parseFeatureEntries(content).map((f) => f.text);\n}\n\n/** A PRD feature, with its `F<N>` number when the author gave it one. */\nexport interface FeatureEntry {\n /** The feature description, with any ID prefix removed. */\n text: string;\n /** The `N` from `**F<N>**:`, when present. */\n num?: string;\n}\n\n/**\n * The single source of truth for what counts as a feature in a PRD.\n *\n * `generate story` used to carry its own regex requiring `**F<N>**:`, so on a\n * PRD without those IDs the lint rule reported three features and the generator\n * reported none -- two commands in the same suite contradicting each other over\n * one file. Anything that needs to know what a PRD's features are calls this.\n */\nexport function parseFeatureEntries(content: string): FeatureEntry[] {\n const section = extractFeatureSection(content);\n if (section === null) return [];\n\n /** `**F1**:`, `F1:`, `F1 -` — an optional feature ID prefix. */\n const ID_PREFIX = /^\\*{0,2}F(\\d+)\\*{0,2}\\s*[:.-]\\s*/i;\n\n const features: FeatureEntry[] = [];\n for (const rawLine of section.split(\"\\n\")) {\n const line = rawLine.trim();\n if (!line) continue;\n\n const bullet = /^[-*]\\s+(.*)$/.exec(line);\n // A bullet is a feature whether or not it carries an ID. A non-bullet line\n // counts only when it does, so ordinary prose in the section is not\n // mistaken for a feature list.\n const text = bullet ? (bullet[1] ?? \"\").trim() : ID_PREFIX.test(line) ? line : \"\";\n if (!text) continue;\n\n const idMatch = ID_PREFIX.exec(text);\n const stripped = text.replace(ID_PREFIX, \"\").trim();\n if (stripped) features.push({ text: stripped, num: idMatch?.[1] });\n }\n return features;\n}\n\nfunction overlap(featureTokens: Set<string>, storyTokens: Set<string>): number {\n if (featureTokens.size === 0) return 0;\n let shared = 0;\n for (const token of featureTokens) if (storyTokens.has(token)) shared++;\n return shared / featureTokens.size;\n}\n\nfunction referencesSpec(story: ParsedSpec, specId: unknown): boolean {\n const refs = story.frontmatter.references;\n if (!Array.isArray(refs)) return false;\n return refs.some((r) => (r as { id?: unknown })?.id === specId);\n}\n\n/**\n * Features from `features` that no story in `stories` appears to cover.\n *\n * Exported so the linter and `generate story` share one definition of\n * \"covered\". They had two, which is why the rule warned about features that\n * had stories while the generator re-stubbed features that already had them.\n */\nexport function uncoveredFeatures(\n features: string[],\n stories: ParsedSpec[],\n prdId: unknown,\n): string[] {\n const scored = stories.map((story) => ({\n tokens: tokenise(`${String(story.frontmatter.title ?? \"\")} ${story.content}`),\n threshold: referencesSpec(story, prdId) ? REFERENCED_THRESHOLD : OVERLAP_THRESHOLD,\n }));\n\n const tokenised = features.map(tokenise);\n\n return features.filter((_feature, i) => {\n const featureTokens = tokenised[i]!;\n // What makes *this* feature different from its siblings. Share of words\n // alone is not enough: \"Export the payroll report as PDF\" and \"Export the\n // invoice report as CSV\" agree on half their words, so a story covering one\n // was read as covering both -- and `ready` then asserted that every feature\n // had a story while one plainly had none. A story only covers a feature if\n // it also mentions something that sets that feature apart.\n const distinctive = distinctiveTokens(featureTokens, tokenised, i);\n return !scored.some(\n (s) =>\n overlap(featureTokens, s.tokens) >= s.threshold &&\n covers(distinctive, featureTokens, s.tokens),\n );\n });\n}\n\n/**\n * Whether a story picks up more than half of what sets a feature apart from its\n * siblings.\n *\n * One distinctive word is not enough on its own. \"List customers for the\n * finance console\" is set apart by *finance* and *console*, and a story about\n * amending invoices that opens \"as a member of finance\" hits one of the two —\n * enough to be waved through by a \"matches something distinctive\" test, and\n * plainly not a story about the finance console.\n *\n * Two cases hand the decision back to the overlap threshold alone, because in\n * both of them distinctiveness carries no information:\n *\n * - Nothing is distinctive. Two features written in near-identical words are\n * genuinely indistinguishable to a word-overlap rule.\n * - Everything is distinctive. No sibling shares a word, so no sibling's\n * vocabulary inflated the overlap score in the first place — and demanding\n * half of a long feature description would reject the short, accurate story\n * titles this rule exists to accept.\n */\nfunction covers(\n distinctive: Set<string>,\n featureTokens: Set<string>,\n storyTokens: Set<string>,\n): boolean {\n if (distinctive.size === 0 || distinctive.size === featureTokens.size) return true;\n let matched = 0;\n for (const token of distinctive) if (storyTokens.has(token)) matched++;\n return matched > distinctive.size / 2;\n}\n\n/**\n * The tokens of `features[index]` that no sibling feature uses.\n */\nfunction distinctiveTokens(\n featureTokens: Set<string>,\n allFeatureTokens: Set<string>[],\n index: number,\n): Set<string> {\n const distinctive = new Set(featureTokens);\n for (let i = 0; i < allFeatureTokens.length; i++) {\n if (i === index) continue;\n for (const token of allFeatureTokens[i]!) distinctive.delete(token);\n }\n return distinctive;\n}\n\nexport const storyCoverageRule: LintRule = {\n id: \"completeness/story-coverage\",\n description: \"Every feature listed in a PRD has at least one corresponding user story\",\n severity: \"warn\",\n run(context) {\n if (context.spec.frontmatter.type !== \"prd\") return [];\n\n const features = parseFeatures(context.spec.content);\n if (features.length === 0) return [];\n\n const stories = context.allSpecs.filter((s) => s.frontmatter.type === \"user-story\");\n\n return uncoveredFeatures(features, stories, context.spec.frontmatter.id).map((feature) => ({\n ruleId: \"completeness/story-coverage\",\n severity: \"warn\" as const,\n message: `Feature \"${feature}\" has no corresponding user story`,\n filePath: context.spec.filePath,\n }));\n },\n};\n","import type { LintRule } from \"../types.js\";\n\n/**\n * The shape of an ajv error, described structurally.\n *\n * Typed here rather than imported so the lint package does not take a\n * dependency on ajv for a single type.\n */\ninterface ValidationError {\n instancePath?: string;\n message?: string;\n params?: Record<string, unknown>;\n}\n\n/** `/references/0/relationship` -> `references[0].relationship`. */\nfunction readablePath(instancePath: string): string {\n return instancePath\n .split(\"/\")\n .filter(Boolean)\n .map((segment) => (/^\\d+$/.test(segment) ? `[${segment}]` : `.${segment}`))\n .join(\"\")\n .replace(/^\\./, \"\");\n}\n\n/**\n * Turn one ajv error into something a spec author can act on.\n *\n * ajv only names the offending field inside `message` for `required`\n * violations. For `enum`, `const` and `type` the field lives in `instancePath`\n * and the acceptable values in `params`, so a bare `err.message` reads\n * \"must be equal to one of the allowed values\" and identifies nothing -- which\n * is what every `references:` entry produced.\n */\nexport function describeValidationError(err: ValidationError): string {\n const path = readablePath(err.instancePath ?? \"\");\n const allowed = (err.params as { allowedValues?: unknown[] } | undefined)?.allowedValues;\n\n let detail = err.message ?? JSON.stringify(err);\n if (Array.isArray(allowed) && allowed.length > 0) {\n detail += `: ${allowed.map((v) => JSON.stringify(v)).join(\", \")}`;\n }\n\n return path ? `${path} ${detail}` : detail;\n}\n\nexport const validFrontmatterRule: LintRule = {\n id: \"structure/valid-frontmatter\",\n description: \"Frontmatter matches the schema for the declared spec type\",\n severity: \"error\",\n run(context) {\n if (context.spec.valid) return [];\n const errors = context.spec.validationErrors ?? [];\n return errors.map((err) => ({\n ruleId: \"structure/valid-frontmatter\",\n severity: \"error\" as const,\n message: `Invalid frontmatter: ${describeValidationError(err)}`,\n filePath: context.spec.filePath,\n }));\n },\n};\n","import type { LintRule } from \"../types.js\";\nimport { REQUIRED_SECTIONS } from \"@specdx/schema\";\nimport type { SpecType } from \"@specdx/schema\";\n\nexport const requiredSectionsRule: LintRule = {\n id: \"structure/required-sections\",\n description: \"Spec body contains all required sections for its type\",\n severity: \"error\",\n run(context) {\n // Skip YAML specs (no markdown body)\n const ext = context.spec.filePath.split(\".\").pop()?.toLowerCase();\n if (ext === \"yaml\" || ext === \"yml\") return [];\n\n const specType = context.spec.frontmatter.type as SpecType;\n const required = REQUIRED_SECTIONS[specType];\n if (!required) return [];\n\n const missing = required.filter((s) => !context.spec.sections.includes(s));\n return missing.map((section) => ({\n ruleId: \"structure/required-sections\",\n severity: \"error\" as const,\n message: `Missing required section: \"${section}\"`,\n filePath: context.spec.filePath,\n section,\n }));\n },\n};\n","import type { LintRule } from \"../types.js\";\n\nexport const validReferencesRule: LintRule = {\n id: \"structure/valid-references\",\n description: \"All references in frontmatter point to specs that exist in the suite\",\n severity: \"error\",\n run(context) {\n const refs = context.spec.frontmatter.references;\n if (!refs || refs.length === 0) return [];\n const allIds = new Set(context.allSpecs.map((s) => s.frontmatter.id));\n return refs\n .filter((ref) => !allIds.has(ref.id))\n .map((ref) => ({\n ruleId: \"structure/valid-references\",\n severity: \"error\" as const,\n message: `Reference \"${ref.id}\" does not match any spec in the suite`,\n filePath: context.spec.filePath,\n }));\n },\n};\n","import type { LintRule } from \"../types.js\";\n\nexport const noCircularDepsRule: LintRule = {\n id: \"structure/no-circular-deps\",\n description: \"The dependency graph has no cycles\",\n severity: \"error\",\n run() {\n // Cycle detection happens in buildGraph() — if graph construction succeeds, it's acyclic.\n // GraphErrors are surfaced as diagnostics by the lint command, not by this rule.\n return [];\n },\n};\n","import { buildRelationResolver } from \"@specdx/core\";\nimport type { ParsedSpec } from \"@specdx/core\";\nimport type { SdxConfig } from \"@specdx/schema\";\nimport type { LintRule } from \"../types.js\";\n\n/**\n * Group specs by the config entry whose glob they came from, so config\n * `requires` edges can be mapped into spec id space. Matching is by the entry\n * path's directory prefix, which is enough for the resolver: an id that maps\n * to no entry simply contributes no `requires` edges.\n */\nfunction groupByEntry(config: SdxConfig, specs: ParsedSpec[]): Map<string, ParsedSpec[]> {\n const byEntry = new Map<string, ParsedSpec[]>();\n for (const key of Object.keys(config.specs)) byEntry.set(key, []);\n\n for (const spec of specs) {\n let bestKey: string | undefined;\n let bestLen = -1;\n for (const [key, entry] of Object.entries(config.specs)) {\n const prefix = entry.path.split(\"*\")[0] ?? \"\";\n const normalized = spec.filePath.replace(/\\\\/g, \"/\");\n if (normalized.includes(prefix) && prefix.length > bestLen) {\n bestKey = key;\n bestLen = prefix.length;\n }\n }\n if (bestKey) byEntry.get(bestKey)!.push(spec);\n }\n return byEntry;\n}\n\nfunction lastUpdated(spec: ParsedSpec): string {\n return (\n (spec.frontmatter.updated as string | undefined) ?? (spec.frontmatter.created as string) ?? \"\"\n );\n}\n\nexport const stalenessCheckRule: LintRule = {\n id: \"freshness/staleness-check\",\n description: \"Warns if a spec hasn't been updated since its upstream dependency changed\",\n severity: \"warn\",\n run(context) {\n const specId = context.spec.frontmatter.id;\n if (typeof specId !== \"string\") return [];\n\n const specUpdated = lastUpdated(context.spec);\n if (!specUpdated) return [];\n const specDate = new Date(specUpdated);\n\n // Upstream comes from config `requires` and frontmatter `references`\n // unioned, so a suite declaring dependencies either way gets the same\n // answer (ADR: references/requires unification).\n const byEntry = context.config\n ? groupByEntry(context.config, context.allSpecs)\n : new Map([[\"\", context.allSpecs]]);\n const relations = buildRelationResolver(context.config, byEntry);\n const upstreamIds = relations.getUpstream(specId);\n\n const diagnostics = [];\n for (const upstreamId of upstreamIds) {\n const upstream = context.allSpecs.find((s) => s.frontmatter.id === upstreamId);\n if (!upstream) continue;\n const upstreamUpdated = lastUpdated(upstream);\n if (!upstreamUpdated) continue;\n\n if (new Date(upstreamUpdated) > specDate) {\n diagnostics.push({\n ruleId: \"freshness/staleness-check\",\n severity: \"warn\" as const,\n message: `Potentially stale: upstream \"${upstreamId}\" was updated on ${upstreamUpdated}, but this spec was last updated on ${specUpdated}`,\n filePath: context.spec.filePath,\n });\n }\n }\n return diagnostics;\n },\n};\n","import type { LintRule } from \"../types.js\";\n\nconst DEFAULT_VAGUE_PATTERNS = [\n \"as appropriate\",\n \"handle edge cases\",\n \"as needed\",\n \"etc\\\\.\",\n \"TBD\",\n \"TODO\",\n \"and so on\",\n \"various\",\n \"somehow\",\n \"straightforward\",\n \"obviously\",\n \"simply\",\n \"just need to\",\n];\n\nexport const noVagueLanguageRule: LintRule = {\n id: \"clarity/no-vague-language\",\n description: \"Flags known ambiguous phrases\",\n severity: \"warn\",\n run(context) {\n if (!context.spec.content) return [];\n const diagnostics = [];\n for (const pattern of DEFAULT_VAGUE_PATTERNS) {\n const regex = new RegExp(`\\\\b${pattern}`, \"gi\");\n let match;\n while ((match = regex.exec(context.spec.content)) !== null) {\n diagnostics.push({\n ruleId: \"clarity/no-vague-language\",\n severity: \"warn\" as const,\n message: `Vague language: \"${match[0]}\"`,\n filePath: context.spec.filePath,\n });\n }\n }\n return diagnostics;\n },\n};\n","import type { LintRule } from \"../types.js\";\n\nexport const singleProjectContextRule: LintRule = {\n id: \"structure/single-project-context\",\n description: \"Only one project-context spec should exist per suite\",\n severity: \"warn\",\n run(context) {\n if (context.spec.frontmatter.type !== \"project-context\") return [];\n\n const contextSpecs = context.allSpecs.filter((s) => s.frontmatter.type === \"project-context\");\n\n if (contextSpecs.length > 1) {\n return [\n {\n ruleId: \"structure/single-project-context\",\n severity: \"warn\" as const,\n message: `Multiple project-context specs found (${contextSpecs.length}). Only one should exist per suite.`,\n filePath: context.spec.filePath,\n },\n ];\n }\n\n return [];\n },\n};\n","import type { LintRule } from \"../types.js\";\n\nfunction normalizeCompound(term: string): string {\n // Split camelCase: \"UserProfile\" → \"user profile\"\n // Split hyphens/underscores: \"user-profile\" → \"user profile\"\n return term\n .replace(/([a-z])([A-Z])/g, \"$1 $2\")\n .replace(/[-_]/g, \" \")\n .toLowerCase()\n .trim();\n}\n\nfunction extractCompoundTerms(content: string): string[] {\n const terms: string[] = [];\n\n // Extract camelCase words (e.g., UserProfile, userProfile)\n const camelCaseRegex = /\\b[a-zA-Z]*[a-z][A-Z][a-zA-Z]*\\b/g;\n let match;\n while ((match = camelCaseRegex.exec(content)) !== null) {\n terms.push(match[0]);\n }\n\n // Extract hyphenated words (e.g., user-profile, my-component)\n const hyphenatedRegex = /\\b[a-z][a-z0-9]*(?:-[a-z][a-z0-9]*)+\\b/g;\n while ((match = hyphenatedRegex.exec(content)) !== null) {\n terms.push(match[0]);\n }\n\n return terms;\n}\n\nexport const terminologyRule: LintRule = {\n id: \"consistency/terminology\",\n description:\n \"Detects terminology drift (e.g., user-profile vs UserProfile vs user profile) across specs\",\n severity: \"warn\",\n run(context) {\n // Only run on the first spec to avoid duplicate diagnostics\n if (context.spec !== context.allSpecs[0]) return [];\n\n // Build a map: normalized form → Set of original forms found across all specs\n const termMap = new Map<string, Set<string>>();\n\n for (const spec of context.allSpecs) {\n if (!spec.content) continue;\n const terms = extractCompoundTerms(spec.content);\n for (const term of terms) {\n const normalized = normalizeCompound(term);\n // Only track multi-word normalized forms (skip single words)\n if (!normalized.includes(\" \")) continue;\n if (!termMap.has(normalized)) {\n termMap.set(normalized, new Set());\n }\n termMap.get(normalized)!.add(term);\n }\n }\n\n const diagnostics = [];\n\n for (const [normalized, variants] of termMap) {\n if (variants.size >= 2) {\n const variantList = [...variants].join(\", \");\n diagnostics.push({\n ruleId: \"consistency/terminology\",\n severity: \"warn\" as const,\n message: `Inconsistent terminology for \"${normalized}\": found variants [${variantList}]. Standardize terminology across specs.`,\n filePath: context.spec.filePath,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { LintRule } from \"../types.js\";\n\nconst EDGE_CASE_KEYWORDS = [\n \"error\",\n \"invalid\",\n \"empty\",\n \"timeout\",\n \"fails\",\n \"failure\",\n \"boundary\",\n \"edge case\",\n \"null\",\n \"undefined\",\n \"reject\",\n \"unauthorized\",\n \"forbidden\",\n \"missing\",\n \"malformed\",\n \"overflow\",\n \"duplicate\",\n \"graceful\",\n \"fall back\",\n \"fallback\",\n \"crash\",\n \"nonexistent\",\n \"corrupt\",\n // Vocabulary that names a failure without using any of the words above.\n \"conflict\",\n \"denied\",\n \"expired\",\n \"not found\",\n \"retry\",\n \"rate limit\",\n \"unavailable\",\n \"unprocessable\",\n];\n\n/**\n * Any 4xx or 5xx status code counts as naming an error path.\n *\n * The list above held `404` and `500` and no other code, so a story whose only\n * error case was a 409 read as having no error handling at all -- changing that\n * one token to 404 silenced the warning with nothing else altered. Enumerating\n * codes was always going to be arbitrary; matching the class is not.\n */\nconst ERROR_STATUS_CODE = /\\b[45]\\d{2}\\b/;\n\nexport const edgeCaseCoverageRule: LintRule = {\n id: \"completeness/edge-case-coverage\",\n description: \"Flag user stories or test plans that don't mention error states or edge cases\",\n severity: \"warn\",\n run(context) {\n const type = context.spec.frontmatter.type as string;\n if (type !== \"user-story\" && type !== \"test-plan\") return [];\n\n const content = context.spec.content.toLowerCase();\n const hasEdgeCases =\n EDGE_CASE_KEYWORDS.some((kw) => content.includes(kw)) || ERROR_STATUS_CODE.test(content);\n\n if (hasEdgeCases) return [];\n\n return [\n {\n ruleId: \"completeness/edge-case-coverage\",\n severity: \"warn\" as const,\n message:\n \"No error states or edge cases mentioned. Consider adding error handling, boundary conditions, or failure mode scenarios.\",\n filePath: context.spec.filePath,\n },\n ];\n },\n};\n","import type { LintRule } from \"../types.js\";\n\nexport const namingConventionsRule: LintRule = {\n id: \"consistency/naming-conventions\",\n description: \"Enforce consistent naming conventions across specs\",\n severity: \"warn\",\n run(context) {\n const { spec } = context;\n const type = spec.frontmatter.type as string;\n const diagnostics = [];\n\n if (type === \"prd\") {\n // Split content into sections and find the Features section\n const sectionParts = spec.content.split(/^(?=## )/m);\n const featuresSection = sectionParts.find((p) => /^## Features\\b/.test(p));\n if (featuresSection) {\n const bullets = featuresSection.match(/^- .+$/gm) ?? [];\n for (const bullet of bullets) {\n if (bullet.match(/^- \\*\\*F\\d+\\*\\*:/) === null && bullet.trim().length > 2) {\n diagnostics.push({\n ruleId: \"consistency/naming-conventions\",\n severity: \"warn\" as const,\n message: `PRD feature missing feature ID pattern (**F<N>**:): \"${bullet.slice(0, 60)}\"`,\n filePath: spec.filePath,\n });\n }\n }\n }\n }\n\n if (type === \"user-story\") {\n const id = spec.frontmatter.id as string;\n if (!id.startsWith(\"story-\")) {\n diagnostics.push({\n ruleId: \"consistency/naming-conventions\",\n severity: \"warn\" as const,\n message: `User story ID \"${id}\" should start with \"story-\" (e.g., \"story-${id}\")`,\n filePath: spec.filePath,\n });\n }\n }\n\n if (type === \"api-contract\") {\n // Check endpoints for camelCase path segments\n const endpointRe = /^###\\s+(GET|POST|PUT|PATCH|DELETE)\\s+(\\S+)/gm;\n let match;\n while ((match = endpointRe.exec(spec.content)) !== null) {\n const path = match[2]!;\n if (/\\/[a-z]+[A-Z]/.test(path)) {\n diagnostics.push({\n ruleId: \"consistency/naming-conventions\",\n severity: \"warn\" as const,\n message: `Endpoint path \"${path}\" uses camelCase — use kebab-case instead (e.g., \"${path.replace(/([a-z])([A-Z])/g, \"$1-$2\").toLowerCase()}\")`,\n filePath: spec.filePath,\n });\n }\n }\n }\n\n return diagnostics;\n },\n};\n","import type { LintRule } from \"../types.js\";\n\nconst STOPWORDS = new Set([\"the\", \"and\", \"for\", \"with\", \"from\", \"that\", \"this\", \"into\", \"via\"]);\n\nfunction extractThreats(content: string): string[] {\n // Split into sections at each ## heading, then filter for Threats/Security\n const parts = content.split(/^(?=## )/m);\n const threats: string[] = [];\n for (const part of parts) {\n if (!/^##\\s+(Threats|Security)\\b/i.test(part)) continue;\n const bullets = part.match(/^- .+$/gm) ?? [];\n threats.push(...bullets.map((b) => b.slice(2).trim()));\n }\n return threats;\n}\n\nfunction extractKeyTerms(text: string): string[] {\n return text\n .toLowerCase()\n .split(/\\W+/)\n .filter((w) => w.length > 3)\n .filter((w) => !STOPWORDS.has(w));\n}\n\nexport const threatCoverageRule: LintRule = {\n id: \"security/threat-coverage\",\n description: \"Technical design specs must address threats identified in other specs\",\n severity: \"warn\",\n run(context) {\n if (context.spec.frontmatter.type !== \"technical-design\") return [];\n\n const allThreats: string[] = [];\n for (const spec of context.allSpecs) {\n if (spec.filePath === context.spec.filePath) continue;\n allThreats.push(...extractThreats(spec.content));\n }\n\n if (allThreats.length === 0) return [];\n\n const techContent = context.spec.content.toLowerCase();\n const diagnostics = [];\n\n for (const threat of allThreats) {\n const keyTerms = extractKeyTerms(threat);\n const covered = keyTerms.some((term) => techContent.includes(term));\n if (!covered) {\n diagnostics.push({\n ruleId: \"security/threat-coverage\",\n severity: \"warn\" as const,\n message: `Threat not addressed in technical design: \"${threat}\". Ensure the design covers this threat.`,\n filePath: context.spec.filePath,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { LintRule } from \"../types.js\";\n\nexport const ambiguityScoreAiRule: LintRule = {\n id: \"clarity/ambiguity-score-ai\",\n description: \"AI-powered ambiguity detection (requires ANTHROPIC_API_KEY)\",\n severity: \"info\",\n run(context) {\n if (!process.env[\"ANTHROPIC_API_KEY\"]) return [];\n\n return [\n {\n ruleId: \"clarity/ambiguity-score-ai\",\n severity: \"info\" as const,\n message:\n \"AI ambiguity analysis available — run `specdx check --ai` for LLM-powered ambiguity detection\",\n filePath: context.spec.filePath,\n },\n ];\n },\n};\n","import type { LintRule } from \"../types.js\";\n\n/**\n * Bodies that say \"nothing has been written here yet\".\n *\n * Matched against the whole section body, never as a substring: prose that\n * mentions a TODO is real content, a body that *is* \"TODO\" is not.\n */\nconst PLACEHOLDER_BODIES = /^(todo|tbd|fixme|n\\/a|na|none|xxx|\\.{2,}|-|\\*)$/i;\n\n/** Strip HTML comments, list bullets and separators to expose the real body. */\nfunction meaningfulContent(content: string): string {\n return content\n .replace(/<!--[\\s\\S]*?-->/g, \"\")\n .split(\"\\n\")\n .map((line) => line.replace(/^\\s*[-*+]\\s+/, \"\").trim())\n .filter((line) => line.length > 0 && !/^-{3,}$/.test(line))\n .join(\"\\n\")\n .trim();\n}\n\n/**\n * Flags sections that exist only as scaffolding.\n *\n * `structure/required-sections` checks that a heading is present, never that\n * anything was written under it. Without this rule a freshly scaffolded suite\n * of `<!-- placeholder -->` stubs lints clean, reports healthy, and is declared\n * ready for implementation -- the vacuous-pass failure mode, reached on a new\n * user's first command.\n *\n * Warning rather than error: an untouched scaffold should be visibly incomplete\n * without failing the very first `specdx lint` a user runs. `ready` enforces\n * the harder gate.\n */\nexport const noPlaceholderSectionsRule: LintRule = {\n id: \"completeness/no-placeholder-sections\",\n description: \"Spec sections contain content, not scaffolding placeholders\",\n severity: \"warn\",\n run(context) {\n return (\n context.spec.parsedSections\n // The preamble carries no heading and is not a section a user must fill.\n .filter((section) => section.heading !== \"\")\n .filter((section) => {\n const body = meaningfulContent(section.content);\n return body === \"\" || PLACEHOLDER_BODIES.test(body);\n })\n .map((section) => ({\n ruleId: \"completeness/no-placeholder-sections\",\n severity: \"warn\" as const,\n message: `Section \"${section.heading}\" is still a placeholder — write its content or remove the section`,\n filePath: context.spec.filePath,\n section: section.heading,\n }))\n );\n },\n};\n","import { basename } from \"node:path\";\nimport type { LintRule } from \"../types.js\";\n\n/**\n * A spec's frontmatter `id` must match the key it is registered under.\n *\n * When they disagree, nothing used to say so. `validate` passed, because the\n * config itself is well-formed and the file exists. `lint` reported dangling\n * references -- but blamed every spec that referenced the id, none of which was\n * at fault. And `graph` listed nodes by config key while drawing edges by\n * frontmatter id, so it rendered a node with no edges beside edges from a node\n * that did not exist.\n *\n * One diagnostic on the spec that actually diverged replaces all of that.\n *\n * A warning rather than an error: both names resolve, in different places --\n * frontmatter `references` match the id, config `requires` match the key -- so\n * a suite that keeps them apart still works. What it cannot do is produce a\n * coherent graph, or a useful message when a reference goes stale.\n */\nexport const idMatchesConfigKeyRule: LintRule = {\n id: \"structure/id-matches-config-key\",\n description: \"A spec's frontmatter id should match the key it is registered under in the config\",\n severity: \"warn\",\n run(context) {\n const { spec, config } = context;\n if (!config) return [];\n\n const id = spec.frontmatter.id;\n if (typeof id !== \"string\" || id.length === 0) return [];\n\n // Find the entry this file was loaded from. Paths may be globs, so match on\n // the filename the config points at rather than re-resolving every glob.\n const specFile = basename(spec.filePath);\n const candidates = Object.entries(config.specs).filter(([, entry]) => {\n const target = basename(entry.path);\n // A glob entry (`specs/stories/*.md`) claims a directory, not a filename,\n // and cannot be checked this way -- its key names a group, not a spec.\n return !target.includes(\"*\") && target === specFile;\n });\n\n if (candidates.length !== 1) return [];\n const key = candidates[0]![0];\n if (key === id) return [];\n\n return [\n {\n ruleId: \"structure/id-matches-config-key\",\n severity: \"warn\" as const,\n message:\n `Spec declares id \"${id}\" but is registered in spec.config.yaml as \"${key}\". ` +\n `Frontmatter references resolve against \"${id}\" and config requires against \"${key}\", ` +\n \"so the dependency graph shows them as two things. Rename one so they agree.\",\n filePath: spec.filePath,\n },\n ];\n },\n};\n","import { validFrontmatterRule } from \"./valid-frontmatter.js\";\nimport { requiredSectionsRule } from \"./required-sections.js\";\nimport { validReferencesRule } from \"./valid-references.js\";\nimport { noCircularDepsRule } from \"./no-circular-deps.js\";\nimport { storyCoverageRule } from \"./story-coverage.js\";\nimport { stalenessCheckRule } from \"./staleness-check.js\";\nimport { noVagueLanguageRule } from \"./no-vague-language.js\";\nimport { singleProjectContextRule } from \"./single-project-context.js\";\nimport { terminologyRule } from \"./terminology.js\";\nimport { edgeCaseCoverageRule } from \"./edge-case-coverage.js\";\nimport { namingConventionsRule } from \"./naming-conventions.js\";\nimport { threatCoverageRule } from \"./threat-coverage.js\";\nimport { ambiguityScoreAiRule } from \"./ambiguity-score-ai.js\";\nimport { noPlaceholderSectionsRule } from \"./no-placeholder-sections.js\";\nimport { idMatchesConfigKeyRule } from \"./id-matches-config-key.js\";\nimport type { LintRule } from \"../types.js\";\n\nexport const structureRules: LintRule[] = [\n validFrontmatterRule,\n requiredSectionsRule,\n validReferencesRule,\n noCircularDepsRule,\n singleProjectContextRule,\n idMatchesConfigKeyRule,\n];\n\nexport const contentRules: LintRule[] = [\n storyCoverageRule,\n stalenessCheckRule,\n noVagueLanguageRule,\n terminologyRule,\n edgeCaseCoverageRule,\n namingConventionsRule,\n threatCoverageRule,\n ambiguityScoreAiRule,\n noPlaceholderSectionsRule,\n];\n\nexport const allBuiltinRules: LintRule[] = [...structureRules, ...contentRules];\n\nexport {\n validFrontmatterRule,\n requiredSectionsRule,\n validReferencesRule,\n noCircularDepsRule,\n storyCoverageRule,\n stalenessCheckRule,\n noVagueLanguageRule,\n singleProjectContextRule,\n terminologyRule,\n edgeCaseCoverageRule,\n namingConventionsRule,\n threatCoverageRule,\n ambiguityScoreAiRule,\n noPlaceholderSectionsRule,\n idMatchesConfigKeyRule,\n};\n","import type { LintRule } from \"./types.js\";\nimport { structureRules, allBuiltinRules } from \"./rules/index.js\";\n\nexport function getPreset(name: string): LintRule[] {\n switch (name) {\n case \"minimal\":\n return structureRules;\n case \"recommended\":\n return allBuiltinRules;\n case \"strict\":\n // Promote warnings only. An info-class rule is an advisory the author\n // cannot satisfy by editing specs (ambiguity-score-ai fires whenever\n // ANTHROPIC_API_KEY is set), so promoting it would fail every suite\n // linted in an environment that carries the key.\n return allBuiltinRules.map((rule) =>\n rule.severity === \"warn\" ? { ...rule, severity: \"error\" as const } : rule,\n );\n default:\n throw new Error(\n `Unknown preset: \"${name}\". Use \"minimal\", \"recommended\", or \"strict\", or resolve external presets via resolvePreset() from @specdx/core.`,\n );\n }\n}\n","import { pathToFileURL } from \"node:url\";\nimport type { LintRule } from \"./types.js\";\n\nexport async function loadCustomRule(filePath: string): Promise<LintRule> {\n const module = await import(pathToFileURL(filePath).href);\n const rule = module.default ?? module.rule;\n if (!rule || !rule.id || !rule.run) {\n throw new Error(\n `Custom rule at ${filePath} must export a default LintRule with id and run function`,\n );\n }\n return rule as LintRule;\n}\n"],"mappings":";;;;;;;;AAcM,SAAU,iBAAiB,SAA0B;AACzD,SAAO;IACL,KAAK,OAAmB;AACtB,YAAM,cAA4B,CAAA;AAClC,iBAAW,QAAQ,OAAO;AACxB,mBAAW,QAAQ,QAAQ,OAAO;AAChC,gBAAM,UAAU,KAAK,IAAI;YACvB;YACA,UAAU;YACV,QAAQ,QAAQ;YAChB,OAAO,QAAQ;WAChB;AAWD,qBAAW,cAAc,SAAS;AAChC,wBAAY,KAAK,EAAE,GAAG,YAAY,UAAU,KAAK,SAAQ,CAAE;UAC7D;QACF;MACF;AACA,aAAO;QACL;QACA,WAAW,YAAY,KAAK,CAAC,MAAM,EAAE,aAAa,OAAO;QACzD,aAAa,YAAY,KAAK,CAAC,MAAM,EAAE,aAAa,MAAM;;IAE9D;;AAEJ;;;AC5CA,IAAM,YAAY,oBAAI,IAAI;EACxB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AAGD,IAAM,oBAAoB;AAG1B,IAAM,uBAAuB;AAE7B,SAAS,SAAS,MAAY;AAC5B,QAAM,QAAQ,KACX,YAAW,EACX,QAAQ,iBAAiB,GAAG,EAC5B,MAAM,KAAK,EACX,OAAO,CAAC,MAAM,EAAE,SAAS,KAAK,CAAC,UAAU,IAAI,CAAC,CAAC,EAE/C,IAAI,CAAC,MAAO,EAAE,SAAS,KAAK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;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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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\";\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\nexport async function runDiff(options: RunDiffOptions): Promise<DiffResult> {\n const 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 format: {\n type: \"string\",\n description: \"Output format: pretty, json, changelog\",\n default: \"pretty\",\n },\n },\n async run({ args }) {\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 (args.format === \"json\") {\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n if (args.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 console.log(\" \\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,KAAK,OAAO,EAAE,IAAI;AAAA,IAC1B;AACA,UAAM,KAAK,EAAE;AAAA,EACf;AAEA,MAAI,OAAO,QAAQ,SAAS,GAAG;AAC7B,UAAM,KAAK,aAAa;AACxB,eAAW,MAAM,OAAO,SAAS;AAC/B,YAAM,KAAK,OAAO,EAAE,IAAI;AAAA,IAC1B;AACA,UAAM,KAAK,EAAE;AAAA,EACf;AAEA,QAAM,gBAAgB,OAAO,OAAO,QAAQ,CAAC,MAAM,EAAE,UAAU;AAC/D,MAAI,cAAc,SAAS,GAAG;AAC5B,UAAM,KAAK,uBAAuB;AAClC,eAAW,KAAK,eAAe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
|
@@ -1 +0,0 @@
|
|
|
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 } from \"../../shared-args.js\";\n\nexport default defineCommand({\n meta: { name: \"graph\", description: \"Print the spec dependency graph\" },\n args: { ...sharedArgs },\n async run({ args }) {\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 (args.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 console.log(\"\\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 console.log(` ${node}${arrow}`);\n }\n\n if (referenceEdges.length > 0) {\n console.log(\"\\n Reference edges (frontmatter):\\n\");\n for (const ref of referenceEdges) {\n console.log(` ${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;AAa9B,IAAO,gBAAQ,cAAc;AAAA,EAC3B,MAAM,EAAE,MAAM,SAAS,aAAa,kCAAkC;AAAA,EACtE,MAAM,EAAE,GAAG,WAAW;AAAA,EACtB,MAAM,IAAI,EAAE,KAAK,GAAG;AAClB,QAAI;AACJ,UAAM,YAAY,QAAQ,IAAI;AAC9B,QAAI;AACF,eAAS,MAAM,WAAW,QAAW,SAAS;AAAA,IAChD,SAAS,KAAK;AACZ,cAAQ,MAAM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,QAAI;AACF,YAAM,QAAQ,WAAW,MAAM;AAC/B,YAAM,SAAS,MAAM,gBAAgB;AAKrC,YAAM,YAAY,oBAAI,IAAoB;AAC1C,YAAM,QAAsB,CAAC;AAC7B,iBAAW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CAAC,MAAM,EAAE,YAAY;AAE1D,UAAI,YAAY,SAAS,GAAG;AAC1B,gBAAQ,IAAI,2DAAsD;AAClE,mBAAW,EAAE,MAAM,gBAAgB,cAAc,KAAK,aAAa;AACjE,kBAAQ;AAAA,YACN,KAAK,KAAK,MAAM,IAAI,KAAK,YAAY,IAAI,KAAK,IAAI,2BAAsB,aAAa,cAAc,cAAc;AAAA,UACnH;AAAA,QACF;AAAA,MACF;AAEA,UAAI,UAAU,SAAS,GAAG;AACxB,gBAAQ,IAAI,gEAA2D;AACvE,mBAAW,EAAE,MAAM,gBAAgB,cAAc,KAAK,WAAW;AAC/D,kBAAQ;AAAA,YACN,KAAK,KAAK,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":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/core/lint.ts","../src/formatters/pretty.ts","../src/formatters/json.ts","../src/formatters/github.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, resolveGlob, buildGraph, createLogger } from \"@specdx/core\";\nimport { createLintEngine, getPreset, type LintResults } from \"@specdx/lint\";\nimport type { ParsedSpec } from \"@specdx/core\";\nimport { sharedArgs } from \"../../shared-args.js\";\nimport { formatPretty } from \"../../formatters/pretty.js\";\nimport { formatJson } from \"../../formatters/json.js\";\nimport { formatGithub } from \"../../formatters/github.js\";\n\nexport interface RunLintOptions {\n configDir: string;\n specPath?: string;\n preset?: \"minimal\" | \"recommended\" | \"strict\";\n}\n\n/** Lint results plus whether anything was actually linted (vacuous-pass audit). */\nexport interface RunLintResults extends LintResults {\n /** Number of specs linted. */\n specCount: number;\n /** False when no specs resolved — \"no diagnostics\" is then not a pass. */\n assessed: boolean;\n}\n\nexport async function runLint(options: RunLintOptions): Promise<RunLintResults> {\n // A JS caller omitting the option otherwise dies as ERR_INVALID_ARG_TYPE\n // deep inside path.join, with no mention of what was missing.\n if (!options.configDir) {\n throw new TypeError(\"runLint requires `configDir` — the directory holding spec.config.yaml.\");\n }\n const config = await loadConfig(undefined, options.configDir);\n const preset = options.preset ?? config.lint?.extends ?? \"recommended\";\n const rules = getPreset(preset);\n\n // Always parse the full suite so cross-reference rules have complete\n // context; a single-file lint filters the *diagnostics*, not the suite.\n const specs: ParsedSpec[] = [];\n for (const [, entry] of Object.entries(config.specs)) {\n const files = await resolveGlob(entry.path, options.configDir);\n for (const file of files) {\n specs.push(await parseSpec(file));\n }\n }\n\n let graph;\n let graphError: string | undefined;\n try {\n graph = buildGraph(config);\n } catch (err) {\n graphError = (err as Error).message;\n }\n\n const engine = createLintEngine({ rules, config, graph });\n const results = engine.lint(specs);\n\n if (options.specPath) {\n const specPath = options.specPath;\n results.diagnostics = results.diagnostics.filter((d) => d.filePath.includes(specPath));\n results.hasErrors = results.diagnostics.some((d) => d.severity === \"error\");\n results.hasWarnings = results.diagnostics.some((d) => d.severity === \"warn\");\n }\n\n if (graphError) {\n results.diagnostics.push({\n ruleId: \"structure/no-circular-deps\",\n severity: \"error\",\n message: graphError,\n filePath: \"spec.config.yaml\",\n });\n results.hasErrors = true;\n }\n\n return { ...results, specCount: specs.length, assessed: specs.length > 0 };\n}\n\nexport default defineCommand({\n meta: { name: \"lint\", description: \"Lint all specs in the suite\" },\n args: {\n ...sharedArgs,\n fix: { type: \"boolean\", description: \"Auto-fix issues where possible\" },\n path: { type: \"positional\", description: \"Lint a specific spec file\", required: false },\n preset: { type: \"string\", description: \"Lint preset (minimal, recommended, strict)\" },\n },\n async run({ args }) {\n const logger = createLogger({ quiet: args.quiet, verbose: args.verbose });\n\n if (args.fix) {\n logger.info(\"No auto-fixable issues supported yet.\");\n }\n\n try {\n const results = await runLint({\n configDir: process.cwd(),\n specPath: args.path,\n preset: args.preset as \"minimal\" | \"recommended\" | \"strict\" | undefined,\n });\n\n const formatter =\n args.format === \"json\"\n ? formatJson\n : args.format === \"github\"\n ? formatGithub\n : formatPretty;\n // \"No diagnostics\" over an empty suite is not a pass (vacuous-pass audit)\n if (!results.assessed) {\n console.error(\n \"\\n ⚠ No specs found — nothing was linted. Check the spec paths in spec.config.yaml.\\n\",\n );\n process.exit(3);\n }\n\n console.log(formatter(results.diagnostics));\n\n if (results.hasErrors) process.exit(1);\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n },\n});\n","import type { Diagnostic } from \"@specdx/lint\";\n\nexport function formatPretty(diagnostics: Diagnostic[]): string {\n if (diagnostics.length === 0) return \" ✓ All specs pass lint checks.\\n\";\n return diagnostics\n .map((d) => {\n const icon = d.severity === \"error\" ? \"✗\" : d.severity === \"warn\" ? \"⚠\" : \"ℹ\";\n return ` ${icon} ${d.severity} ${d.message} (${d.ruleId})\\n ${d.filePath}${d.line ? `:${d.line}` : \"\"}`;\n })\n .join(\"\\n\");\n}\n","import type { Diagnostic } from \"@specdx/lint\";\nexport function formatJson(diagnostics: Diagnostic[]): string {\n return JSON.stringify(diagnostics, null, 2);\n}\n","import type { Diagnostic } from \"@specdx/lint\";\nexport function formatGithub(diagnostics: Diagnostic[]): string {\n return diagnostics\n .map((d) => {\n const level = d.severity === \"error\" ? \"error\" : \"warning\";\n const line = d.line ? `,line=${d.line}` : \"\";\n return `::${level} file=${d.filePath}${line}::${d.message} (${d.ruleId})`;\n })\n .join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;;;ACEvB,SAAS,aAAa,aAAmC;AAC9D,MAAI,YAAY,WAAW,EAAG,QAAO;AACrC,SAAO,YACJ,IAAI,CAAC,M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ED,YAAM,YACJ,KAAK,WAAW,SACZ,aACA,KAAK,WAAW,WACd,eACA;AAER,UAAI,CAAC,QAAQ,UAAU;AACrB,gBAAQ;AAAA,UACN;AAAA,QACF;AACA,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAEA,cAAQ,IAAI,UAAU,QAAQ,WAAW,CAAC;AAE1C,UAAI,QAAQ,UAAW,SAAQ,KAAK,CAAC;AAAA,IACvC,SAAS,KAAK;AACZ,cAAQ,MAAM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/core/pack.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, resolveGlob, buildGraph, createLogger } from \"@specdx/core\";\nimport { pack, type PackResult } from \"@specdx/pack\";\nimport type { ParsedSpec } from \"@specdx/core\";\nimport { sharedArgs } from \"../../shared-args.js\";\nimport { writeFile } from \"node:fs/promises\";\nimport { execSync } from \"node:child_process\";\n\nfunction copyToClipboard(text: string): void {\n const platform = process.platform;\n let cmd: string;\n if (platform === \"darwin\") {\n cmd = \"pbcopy\";\n } else if (platform === \"linux\") {\n cmd = \"xclip -selection clipboard\";\n } else if (platform === \"win32\") {\n cmd = \"clip\";\n } else {\n throw new Error(`Clipboard not supported on platform: ${platform}`);\n }\n execSync(cmd, { input: text, stdio: [\"pipe\", \"ignore\", \"ignore\"] });\n}\n\n/**\n * Why a pack produced no context, if it produced none.\n *\n * An empty `<context>` on stdout with exit 0 reads as \"here is your context\"\n * to whatever consumes it. `lint` and `check` already use exit 3 for\n * \"nothing was assessed\"; packing nothing is the same claim.\n */\nexport function emptyPackReason(\n stats: { specsIncluded: number; specsExcluded: number },\n specsResolved: number,\n): string | undefined {\n if (stats.specsIncluded > 0) return undefined;\n if (specsResolved === 0) {\n return \"no specs resolved from spec.config.yaml — check the paths in your config\";\n }\n // The relevance resolver drops sub-threshold specs before allocation, so\n // stats.specsExcluded counts only allocator-level exclusions. Reporting the\n // resolved total instead keeps the message from blaming the config.\n if (stats.specsExcluded === 0) {\n return `none of the ${specsResolved} resolved spec(s) scored above the relevance threshold for this task — try different --task wording, name specs with --specs, or use --full`;\n }\n return `all ${stats.specsExcluded} candidate spec(s) were excluded — widen --specs or raise --budget`;\n}\n\nexport interface RunPackOptions {\n configDir: string;\n task?: string;\n specs?: string[];\n budget?: number;\n format?: \"xml\" | \"markdown\" | \"json\";\n full?: boolean;\n dryRun?: boolean;\n}\n\nexport async function runPack(\n options: RunPackOptions,\n): Promise<PackResult & { specsResolved: number }> {\n if (!options.configDir) {\n throw new TypeError(\"runPack requires `configDir` — the directory holding spec.config.yaml.\");\n }\n const config = await loadConfig(undefined, options.configDir);\n\n const allSpecs: ParsedSpec[] = [];\n for (const [, entry] of Object.entries(config.specs)) {\n const files = await resolveGlob(entry.path, options.configDir);\n for (const file of files) {\n allSpecs.push(await parseSpec(file));\n }\n }\n\n let graph;\n try {\n graph = buildGraph(config);\n } catch {\n // non-fatal: proceed without graph\n }\n\n const result = pack(\n allSpecs,\n {\n task: options.task,\n specs: options.specs,\n budget: options.budget,\n format: options.format,\n full: options.full,\n dryRun: options.dryRun,\n },\n config.pack,\n graph,\n );\n\n return { ...result, specsResolved: allSpecs.length };\n}\n\nexport default defineCommand({\n meta: { name: \"pack\", description: \"Pack specs into AI-ready context\" },\n args: {\n quiet: sharedArgs.quiet,\n verbose: sharedArgs.verbose,\n task: { type: \"string\", description: \"Task or context to optimise relevance for\" },\n specs: { type: \"string\", description: \"Comma-separated spec IDs or glob patterns to include\" },\n budget: { type: \"string\", description: \"Maximum token budget for the output\" },\n format: {\n type: \"string\",\n description: \"Output format (xml, markdown, json)\",\n default: \"xml\",\n },\n out: { type: \"string\", description: \"Write output to file instead of stdout\" },\n copy: { type: \"boolean\", description: \"Copy output to system clipboard\" },\n full: { type: \"boolean\", description: \"Include all specs without budget trimming\" },\n \"dry-run\": {\n type: \"boolean\",\n description: \"Preview what would be packed without writing output\",\n },\n },\n async run({ args }) {\n const logger = createLogger({ quiet: args.quiet, verbose: args.verbose });\n\n // Validate: --task and --specs are mutually exclusive\n if (args.task && args.specs) {\n console.error(\"\\n \\u2717 --task and --specs are mutually exclusive\\n\");\n process.exit(1);\n }\n\n // Validate: --copy and --dry-run are mutually exclusive\n if (args.copy && args[\"dry-run\"]) {\n console.error(\"\\n \\u2717 --copy and --dry-run are mutually exclusive\\n\");\n process.exit(1);\n }\n\n // Validate: --budget is a valid number\n let budget: number | undefined;\n if (args.budget) {\n budget = Number(args.budget);\n if (Number.isNaN(budget)) {\n console.error(\"\\n \\u2717 --budget must be a valid number\\n\");\n process.exit(1);\n }\n }\n\n // Validate: --format is valid\n const format = args.format as string;\n if (format && ![\"xml\", \"markdown\", \"json\"].includes(format)) {\n console.error(`\\n \\u2717 --format must be one of: xml, markdown, json\\n`);\n process.exit(1);\n }\n\n try {\n const specsList = args.specs ? args.specs.split(\",\").map((s: string) => s.trim()) : undefined;\n\n const result = await runPack({\n configDir: process.cwd(),\n task: args.task,\n specs: specsList,\n budget,\n format: format as \"xml\" | \"markdown\" | \"json\" | undefined,\n full: args.full,\n dryRun: args[\"dry-run\"],\n });\n\n const { stats } = result;\n\n // Dry-run: print plan to stdout\n if (args[\"dry-run\"]) {\n console.log(\"\\n Dry Run Summary:\\n\");\n for (const alloc of stats.allocations) {\n const status = alloc.included ? \"\\u2713\" : \"\\u2717\";\n const compressed = alloc.compressed ? \" (compressed)\" : \"\";\n console.log(\n ` ${status} ${alloc.specId} relevance=${alloc.relevance.toFixed(2)} tokens=${alloc.tokens}${compressed}`,\n );\n }\n console.log(`\\n Budget: ${stats.used} / ${stats.budget} tokens`);\n console.log(` Included: ${stats.specsIncluded} / ${result.specsResolved} specs`);\n console.log(` Sections compressed: ${stats.sectionsCompressed}`);\n console.log(` Sections omitted: ${stats.sectionsOmitted}\\n`);\n // A dry run that plans nothing is as misleading as an empty payload.\n const dryReason = emptyPackReason(stats, result.specsResolved);\n if (dryReason) {\n console.log(` ⚠ Nothing would be packed: ${dryReason}\\n`);\n process.exit(3);\n }\n return;\n }\n\n // Write output\n if (args.out) {\n await writeFile(args.out, result.output, \"utf-8\");\n logger.info(`Output written to ${args.out}`);\n }\n if (args.copy) {\n copyToClipboard(result.output);\n logger.info(\"Output copied to clipboard\");\n }\n if (!args.out && !args.copy) {\n process.stdout.write(result.output);\n }\n\n // Token report to stderr\n const total = stats.specsIncluded + stats.specsExcluded;\n process.stderr.write(\n `Packed ${stats.specsIncluded}/${total} specs \\u2022 ${stats.used} / ${stats.budget} tokens \\u2022 ${stats.sectionsCompressed} sections compressed \\u2022 ${stats.sectionsOmitted} sections omitted\\n`,\n );\n\n // Never let an empty payload leave looking like a successful pack.\n const emptyReason = emptyPackReason(stats, result.specsResolved);\n if (emptyReason) {\n process.stderr.write(`\\n \\u26a0 No context packed: ${emptyReason}\\n\\n`);\n process.exit(3);\n }\n } catch (err) {\n console.error(`\\n \\u2717 ${(err as Error).message}\\n`);\n process.exit(1);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAK9B,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AAEzB,SAAS,gBAAgB,MAAoB;AAC3C,QAAM,WAAW,QAAQ;AACzB,MAAI;AACJ,MAAI,aAAa,UAAU;AACzB,UAAM;AAAA,EACR,WAAW,aAAa,SAAS;AAC/B,UAAM;AAAA,EACR,WAAW,aAAa,SAAS;AAC/B,UAAM;AAAA,EACR,OAAO;AACL,UAAM,IAAI,MAAM,wCAAwC,QAAQ,EAAE;AAAA,EACpE;AACA,WAAS,KAAK,EAAE,OAAO,MAAM,OAAO,CAAC,QAAQ,UAAU,QAAQ,EAAE,CAAC;AACpE;AASO,SAAS,gBACd,OACA,eACoB;AACpB,MAAI,MAAM,gBAAgB,EAAG,QAAO;AACpC,MAAI,kBAAkB,GA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MAAM,kBAAkB,MAAM,kBAAkB,+BAA+B,MAAM,eAAe;AAAA;AAAA,MACnL;AAGA,YAAM,cAAc,gBAAgB,OAAO,OAAO,aAAa;AAC/D,UAAI,aAAa;AACf,gBAAQ,OAAO,MAAM;AAAA,8BAAiC,WAAW;AAAA;AAAA,CAAM;AACvE,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAAA,IACF,SAAS,KAAK;AACZ,cAAQ,MAAM;AAAA,WAAe,IAAc,OAAO;AAAA,CAAI;AACtD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/core/ready.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, resolveGlob, buildGraph, createLogger } from \"@specdx/core\";\nimport { createLintEngine, getPreset, parseFeatures } from \"@specdx/lint\";\nimport type { ParsedSpec } from \"@specdx/core\";\nimport { DEFAULT_DIFF_CONFIG } from \"@specdx/diff\";\nimport { sharedArgs } from \"../../shared-args.js\";\n\nexport interface ReadyCheck {\n name: string;\n passed: boolean;\n /** True when the check had nothing to verify — reported as skipped, not as a pass. */\n skipped?: boolean;\n details: string;\n}\n\nexport interface ReadyResult {\n project: string;\n ready: boolean;\n checks: ReadyCheck[];\n}\n\nexport async function runReady(): Promise<ReadyResult> {\n const configDir = process.cwd();\n const config = await loadConfig(undefined, configDir);\n\n const checks: ReadyCheck[] = [];\n\n // Resolve and parse all specs\n const specs: {\n spec: ParsedSpec;\n key: string;\n entry: { path: string; required?: boolean; owner?: string };\n }[] = [];\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({\n spec,\n key,\n entry: entry as { path: string; required?: boolean; owner?: string },\n });\n }\n }\n\n // Check 0: The suite has specs at all. Without this, every check below\n // ticks over an empty set and READY means nothing (vacuous-pass audit).\n checks.push({\n name: \"Spec suite non-empty\",\n passed: specs.length > 0,\n details:\n specs.length > 0\n ? `${specs.length} specs resolved`\n : \"no spec files resolved — check the spec paths in spec.config.yaml\",\n });\n\n // Check 1: Required specs exist\n const requiredEntries = Object.entries(config.specs).filter(\n ([, entry]) => (entry as { required?: boolean }).required,\n );\n const missingRequired: string[] = [];\n for (const [key, entry] of requiredEntries) {\n const paths = await resolveGlob(entry.path, configDir);\n if (paths.length === 0) {\n missingRequired.push(key);\n }\n }\n if (requiredEntries.length === 0) {\n checks.push({\n name: \"Required specs present\",\n passed: true,\n skipped: true,\n details: \"skipped (no specs marked required in config)\",\n });\n } else {\n checks.push({\n name: \"Required specs present\",\n passed: missingRequired.length === 0,\n details:\n missingRequired.length === 0\n ? `All ${requiredEntries.length} required specs found`\n : `Missing: ${missingRequired.join(\", \")}`,\n });\n }\n\n // Check 2: Lint health (no errors)\n const presetName = config.lint?.extends ?? \"recommended\";\n const rules = getPreset(presetName);\n\n let graph;\n let graphError: string | undefined;\n try {\n graph = buildGraph(config);\n } catch (err) {\n graphError = (err as Error).message;\n }\n\n const engine = createLintEngine({ rules, config, graph });\n const lintResults = engine.lint(specs.map((s) => s.spec));\n\n if (graphError) {\n lintResults.diagnostics.push({\n ruleId: \"structure/no-circular-deps\",\n severity: \"error\",\n message: graphError,\n filePath: \"spec.config.yaml\",\n });\n lintResults.hasErrors = true;\n }\n\n const errors = lintResults.diagnostics.filter((d) => d.severity === \"error\").length;\n const warnings = lintResults.diagnostics.filter((d) => d.severity === \"warn\").length;\n if (specs.length === 0) {\n checks.push({\n name: \"Lint health\",\n passed: true,\n skipped: true,\n details: \"skipped (no specs to lint)\",\n });\n } else {\n checks.push({\n name: \"Lint health\",\n passed: errors === 0,\n details: `${errors} errors, ${warnings} warnings`,\n });\n }\n\n // Check 2b: specs actually say something. A scaffolded suite passes every\n // structural check while every section is still a placeholder, so without\n // this a brand new project is declared ready to implement (issue #24).\n const placeholderDiagnostics = lintResults.diagnostics.filter(\n (d) => d.ruleId === \"completeness/no-placeholder-sections\",\n );\n const placeholderFiles = new Set(placeholderDiagnostics.map((d) => d.filePath));\n if (specs.length === 0) {\n checks.push({\n name: \"Specs have content\",\n passed: true,\n skipped: true,\n details: \"skipped (no specs to assess)\",\n });\n } else {\n checks.push({\n name: \"Specs have content\",\n passed: placeholderFiles.size === 0,\n details:\n placeholderFiles.size === 0\n ? \"No placeholder sections\"\n : `${placeholderDiagnostics.length} placeholder section(s) across ${placeholderFiles.size} spec(s)`,\n });\n }\n\n // Check 3: No integrity issues (broken refs, circular deps)\n const integrityIssues: string[] = [];\n if (graphError) {\n integrityIssues.push(graphError);\n }\n const refErrors = lintResults.diagnostics.filter(\n (d) => d.ruleId === \"structure/valid-references\",\n );\n for (const d of refErrors) {\n integrityIssues.push(d.message);\n }\n const hasDeclaredRelations =\n specs.some((s) => {\n const refs = s.spec.frontmatter.references;\n return Array.isArray(refs) && refs.length > 0;\n }) ||\n Object.values(config.specs).some(\n (entry) => ((entry as { requires?: string[] }).requires?.length ?? 0) > 0,\n );\n if (integrityIssues.length === 0 && !hasDeclaredRelations) {\n checks.push({\n name: \"No integrity issues\",\n passed: true,\n skipped: true,\n details: \"skipped (no references or dependencies declared)\",\n });\n } else {\n checks.push({\n name: \"No integrity issues\",\n passed: integrityIssues.length === 0,\n details:\n integrityIssues.length === 0\n ? \"References and dependencies valid\"\n : integrityIssues.join(\"; \"),\n });\n }\n\n // Check 4: No stale specs\n const thresholdDays =\n config.diff?.staleness_threshold_days ?? DEFAULT_DIFF_CONFIG.staleness_threshold_days;\n const now = Date.now();\n const staleSpecs: { specId: string; days: number }[] = [];\n for (const { spec } of specs) {\n const dateStr =\n (spec.frontmatter.updated as string | undefined) ||\n (spec.frontmatter.created as string | undefined);\n if (dateStr) {\n const days = Math.floor((now - new Date(dateStr).getTime()) / (1000 * 60 * 60 * 24));\n if (days > thresholdDays) {\n staleSpecs.push({ specId: spec.frontmatter.id as string, days });\n }\n }\n }\n if (specs.length === 0) {\n checks.push({\n name: \"No stale specs\",\n passed: true,\n skipped: true,\n details: \"skipped (no specs to date-check)\",\n });\n } else {\n checks.push({\n name: \"No stale specs\",\n passed: staleSpecs.length === 0,\n details:\n staleSpecs.length === 0\n ? `All specs within ${thresholdDays}-day threshold`\n : staleSpecs.map((s) => `${s.specId} (${s.days}d)`).join(\", \"),\n });\n }\n\n // Check 5: Story coverage — every PRD feature has a user story\n const hasPrd = specs.some((s) => s.spec.frontmatter.type === \"prd\");\n const storyCoverageErrors = lintResults.diagnostics.filter(\n (d) => d.ruleId === \"completeness/story-coverage\",\n );\n // A PRD with no parseable features has nothing to be covered, so asserting\n // that every feature has a story is a claim about an empty set -- the same\n // vacuous pass the suite-level checks were fixed for.\n const featureCount = specs\n .filter((s) => s.spec.frontmatter.type === \"prd\")\n .reduce((sum, s) => sum + parseFeatures(s.spec.content).length, 0);\n\n if (!hasPrd) {\n checks.push({\n name: \"Story coverage\",\n passed: true,\n skipped: true,\n details: \"skipped (no PRD in suite)\",\n });\n } else if (featureCount === 0) {\n checks.push({\n name: \"Story coverage\",\n passed: true,\n skipped: true,\n details: \"skipped (no features declared in the PRD)\",\n });\n } else {\n checks.push({\n name: \"Story coverage\",\n passed: storyCoverageErrors.length === 0,\n details:\n storyCoverageErrors.length === 0\n ? \"All PRD features have corresponding stories\"\n : storyCoverageErrors.map((d) => d.message).join(\"; \"),\n });\n }\n\n const ready = checks.every((c) => c.passed);\n return { project: config.project?.name ?? \"project\", ready, checks };\n}\n\nexport default defineCommand({\n meta: { name: \"ready\", description: \"Check if spec suite is ready for implementation\" },\n args: {\n ...sharedArgs,\n },\n async run({ args }) {\n try {\n const logger = createLogger({ quiet: args.quiet, verbose: args.verbose });\n logger.debug(\"Running readiness checks...\");\n\n const result = await runReady();\n\n if (args.format === \"json\") {\n console.log(JSON.stringify(result, null, 2));\n if (!result.ready) process.exit(1);\n return;\n }\n\n // Pretty format\n const icon = result.ready ? \"✓\" : \"✗\";\n const label = result.ready ? \"ready for implementation\" : \"not ready for implementation\";\n\n console.log(`\\n ${icon} ${result.project} — ${label}\\n`);\n\n for (const check of result.checks) {\n const checkIcon = check.skipped ? \"–\" : check.passed ? \"✓\" : \"✗\";\n console.log(` ${checkIcon} ${check.name}: ${check.details}`);\n }\n\n const failCount = result.checks.filter((c) => !c.passed).length;\n if (failCount > 0) {\n console.log(\n `\\n Verdict: NOT READY — ${failCount} issue${failCount > 1 ? \"s\" : \"\"} to resolve\\n`,\n );\n } else {\n console.log(`\\n Verdict: READY\\n`);\n }\n\n if (!result.ready) process.exit(1);\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAqB9B,eAAsB,WAAiC;AACrD,QAAM,YAAY,QAAQ,IAAI;AAC9B,QAAM,SAAS,MAAM,WAAW,QAAW,SAAS;AAEpD,QAAM,SAAuB,CAAC;AAG9B,QAAM,QAIA,CAAC;AACP,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,KAAK,GAAG;AACvD,UAAM,QAAQ,MAAM,YAAY,MAAM,MAAM,SAAS;AACrD,eAAW,KAAK,OAAO;AACrB,YAAM,OAAO,MAAM,UAAU,CAAC;AAC9B,YAAM,KAAK;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAIA,SAAO,KAAK;AAAA,IACV,MAAM;AAAA,IACN,QAAQ,MAAM,SAAS;AAAA,IACvB,SACE,MAAM,SAAS,IACX,GAAG,MAAM,MAAM,oBACf;AAAA,EACR,CAAC;AAGD,QAAM,kBAAkB,OAAO,QAAQ,OAAO,KAAK,EAAE;AAAA,IACnD,CAAC,CAAC,EAAE,KAAK,MAAO,MAAiC;AAAA,EACnD;AACA,QAAM,kBAA4B,CAAC;AACnC,aAAW,CAAC,KAAK,KAAK,KAAK,iBAAiB;AAC1C,UAAM,QA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Q,IAAI;AAAA,IAAO,IAAI,IAAI,OAAO,OAAO,WAAM,KAAK;AAAA,CAAI;AAExD,iBAAW,SAAS,OAAO,QAAQ;AACjC,cAAM,YAAY,MAAM,UAAU,WAAM,MAAM,SAAS,WAAM;AAC7D,gBAAQ,IAAI,OAAO,SAAS,IAAI,MAAM,IAAI,KAAK,MAAM,OAAO,EAAE;AAAA,MAChE;AAEA,YAAM,YAAY,OAAO,OAAO,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE;AACzD,UAAI,YAAY,GAAG;AACjB,gBAAQ;AAAA,UACN;AAAA,8BAA4B,SAAS,SAAS,YAAY,IAAI,MAAM,EAAE;AAAA;AAAA,QACxE;AAAA,MACF,OAAO;AACL,gBAAQ,IAAI;AAAA;AAAA,CAAsB;AAAA,MACpC;AAEA,UAAI,CAAC,OAAO,MAAO,SAAQ,KAAK,CAAC;AAAA,IACnC,SAAS,KAAK;AACZ,cAAQ,MAAM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/core/status.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, buildGraph, resolveGlob } from \"@specdx/core\";\nimport { createLintEngine, getPreset } from \"@specdx/lint\";\nimport { DEFAULT_DIFF_CONFIG } from \"@specdx/diff\";\nimport type { StatusResult } from \"@specdx/diff\";\nimport type { ParsedSpec } from \"@specdx/core\";\n\nexport async function runStatus(_options: { format?: string } = {}): Promise<StatusResult> {\n const configDir = process.cwd();\n const config = await loadConfig(undefined, configDir);\n\n // Resolve and parse all specs\n const specs: { spec: ParsedSpec; entry: { path: string; owner?: string } }[] = [];\n for (const [, entry] of Object.entries(config.specs)) {\n const paths = await resolveGlob(entry.path, configDir);\n for (const p of paths) {\n const spec = await parseSpec(p);\n specs.push({ spec, entry: entry as { path: string; owner?: string } });\n }\n }\n\n // Count by status\n const byStatus: Record<string, number> = {};\n for (const { spec } of specs) {\n const status = (spec.frontmatter.status as string) || \"unknown\";\n byStatus[status] = (byStatus[status] ?? 0) + 1;\n }\n\n // Lint health\n const presetName = config.lint?.extends ?? \"recommended\";\n const rules = getPreset(presetName);\n\n let graph;\n let graphError: string | undefined;\n try {\n graph = buildGraph(config);\n } catch (err) {\n graphError = (err as Error).message;\n }\n\n const engine = createLintEngine({ rules, config, graph });\n const lintResults = engine.lint(specs.map((s) => s.spec));\n\n if (graphError) {\n lintResults.diagnostics.push({\n ruleId: \"structure/no-circular-deps\",\n severity: \"error\",\n message: graphError,\n filePath: \"spec.config.yaml\",\n });\n lintResults.hasErrors = true;\n }\n\n const errors = lintResults.diagnostics.filter((d) => d.severity === \"error\").length;\n const warnings = lintResults.diagnostics.filter((d) => d.severity === \"warn\").length;\n\n // Staleness\n const thresholdDays =\n config.diff?.staleness_threshold_days ?? DEFAULT_DIFF_CONFIG.staleness_threshold_days;\n const now = Date.now();\n const staleSpecs: { specId: string; daysSinceUpdate: number; owner?: string }[] = [];\n for (const { spec, entry } of specs) {\n const dateStr =\n (spec.frontmatter.updated as string | undefined) ||\n (spec.frontmatter.created as string | undefined);\n if (dateStr) {\n const daysSinceUpdate = Math.floor(\n (now - new Date(dateStr).getTime()) / (1000 * 60 * 60 * 24),\n );\n if (daysSinceUpdate > thresholdDays) {\n staleSpecs.push({\n specId: spec.frontmatter.id as string,\n daysSinceUpdate,\n owner: entry.owner,\n });\n }\n }\n }\n\n // Integrity issues\n const integrityIssues: string[] = [];\n if (graphError) {\n integrityIssues.push(graphError);\n }\n const refErrors = lintResults.diagnostics.filter(\n (d) => d.ruleId === \"structure/valid-references\",\n );\n for (const d of refErrors) {\n integrityIssues.push(d.message);\n }\n\n // Verdict — an empty suite is unassessed, never a vacuous \"healthy\"\n let verdict: StatusResult[\"verdict\"] = \"healthy\";\n if (errors > 0) verdict = \"errors\";\n else if (warnings > 0 || staleSpecs.length > 0) verdict = \"warnings\";\n else if (specs.length === 0) verdict = \"unassessed\";\n\n return {\n project: config.project?.name ?? \"unknown\",\n specCount: specs.length,\n byStatus,\n lintHealth: { errors, warnings, passing: specs.length - errors },\n staleSpecs,\n integrityIssues,\n verdict,\n };\n}\n\nexport default defineCommand({\n meta: { name: \"status\", description: \"Show spec suite health overview\" },\n args: {\n format: {\n type: \"string\",\n description: \"Output format: pretty, json, github\",\n default: \"pretty\",\n },\n },\n async run({ args }) {\n try {\n const result = await runStatus({ format: args.format });\n\n if (args.format === \"json\") {\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n if (args.format === \"github\") {\n for (const s of result.staleSpecs) {\n console.log(\n `::warning::Spec \"${s.specId}\" is stale (${s.daysSinceUpdate} days since update)`,\n );\n }\n for (const issue of result.integrityIssues) {\n console.log(`::error::${issue}`);\n }\n return;\n }\n\n // Pretty format\n const icon =\n result.verdict === \"healthy\"\n ? \"✓\"\n : result.verdict === \"warnings\" || result.verdict === \"unassessed\"\n ? \"⚠\"\n : \"✗\";\n console.log(`\\n ${icon} ${result.project} — ${result.verdict}`);\n if (result.verdict === \"unassessed\") {\n console.log(\n \" No specs resolved — nothing was assessed. Check the spec paths in spec.config.yaml.\",\n );\n }\n console.log(\n ` ${result.specCount} specs: ${Object.entries(result.byStatus)\n .map(([k, v]) => `${v} ${k}`)\n .join(\", \")}`,\n );\n console.log(\n ` Lint: ${result.lintHealth.errors} errors, ${result.lintHealth.warnings} warnings`,\n );\n\n if (result.staleSpecs.length > 0) {\n console.log(\n ` Stale: ${result.staleSpecs.map((s) => `${s.specId} (${s.daysSinceUpdate}d)`).join(\", \")}`,\n );\n }\n if (result.integrityIssues.length > 0) {\n console.log(` Issues: ${result.integrityIssues.join(\"; \")}`);\n }\n console.log();\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,qBAA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,IAAI;AAAA,IACd,SAAS,KAAK;AACZ,cAAQ,MAAM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/experimental/update.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, resolveGlob, createLogger } from \"@specdx/core\";\nimport { runCheck } from \"@specdx/check\";\nimport type { Finding } from \"@specdx/check\";\nimport type { ParsedSpec } from \"@specdx/core\";\nimport { sharedArgs } from \"../../shared-args.js\";\n\nexport interface UpdateSuggestion {\n specId: string;\n section: string;\n addition: string;\n reason: string;\n}\n\nexport interface GenerateUpdatesInput {\n findings: Finding[];\n}\n\nexport interface GenerateUpdatesResult {\n suggestions: UpdateSuggestion[];\n}\n\nfunction buildRouteAddition(actual: string): string {\n const parts = actual.trim().split(/\\s+/);\n const method = parts[0] ?? \"GET\";\n const path = parts[1] ?? actual;\n return `### ${method} ${path}\\nDescription placeholder.`;\n}\n\nfunction buildTypeAddition(actual: string): string {\n return `- ${actual}`;\n}\n\nfunction buildTestAddition(actual: string): string {\n return `- ${actual}`;\n}\n\nexport function generateUpdates({ findings }: GenerateUpdatesInput): GenerateUpdatesResult {\n const suggestions: UpdateSuggestion[] = [];\n\n for (const finding of findings) {\n // Only act on extra findings — code has something the spec doesn't know about.\n // missing = code is wrong, spec is correct → skip.\n // mismatch = ambiguous → skip for now, let the user decide.\n if (finding.type !== \"extra\") continue;\n\n const actual = finding.actual ?? \"\";\n\n if (finding.category === \"route\") {\n suggestions.push({\n specId: finding.specId,\n section: \"Endpoints\",\n addition: buildRouteAddition(actual),\n reason: `Route ${actual} exists in code but is not documented in the spec.`,\n });\n } else if (finding.category === \"type\") {\n suggestions.push({\n specId: finding.specId,\n section: \"Data Model\",\n addition: buildTypeAddition(actual),\n reason: `${actual} exists in code but is not documented in the spec.`,\n });\n } else if (finding.category === \"test\") {\n suggestions.push({\n specId: finding.specId,\n section: \"Test Cases\",\n addition: buildTestAddition(actual),\n reason: `Test case \"${actual}\" exists in code but is not listed in the spec.`,\n });\n }\n }\n\n return { suggestions };\n}\n\nfunction printSuggestionsPretty(suggestions: UpdateSuggestion[]): void {\n if (suggestions.length === 0) {\n console.log(\"\\n specdx update — no spec updates suggested\\n\");\n return;\n }\n\n console.log(`\\n specdx update — ${suggestions.length} suggested spec update(s)\\n`);\n\n // Group by specId\n const bySpec = new Map<string, UpdateSuggestion[]>();\n for (const s of suggestions) {\n const list = bySpec.get(s.specId) ?? [];\n list.push(s);\n bySpec.set(s.specId, list);\n }\n\n for (const [specId, items] of bySpec) {\n console.log(` ${specId}:`);\n for (const item of items) {\n console.log(` [${item.section}] ${item.reason}`);\n console.log(` Add:\\n ${item.addition.replace(/\\n/g, \"\\n \")}`);\n }\n console.log();\n }\n\n console.log(\" Note: --apply is not implemented in v1. Apply changes manually.\\n\");\n}\n\nexport default defineCommand({\n meta: {\n name: \"update\",\n description: \"Suggest spec updates based on specdx check findings (--from-code)\",\n },\n args: {\n ...sharedArgs,\n \"from-code\": {\n type: \"boolean\",\n description: \"Generate suggestions from code drift (specdx check findings)\",\n default: true,\n },\n spec: { type: \"string\", description: \"Limit to a specific spec ID\" },\n framework: { type: \"string\", description: \"Framework override: express, hono, nextjs\" },\n },\n async run({ args }) {\n const logger = createLogger({ quiet: args.quiet, verbose: args.verbose });\n const configDir = process.cwd();\n const config = await loadConfig(undefined, configDir);\n\n logger.debug(\"Loading specs...\");\n\n const specs: ParsedSpec[] = [];\n for (const [, entry] of Object.entries(config.specs)) {\n const paths = await resolveGlob(entry.path, configDir);\n for (const p of paths) {\n const spec = await parseSpec(p);\n if (args.spec && spec.frontmatter.id !== args.spec) continue;\n specs.push(spec);\n }\n }\n\n logger.debug(`Running check on ${specs.length} specs...`);\n\n const checkConfig = {\n ...config.check,\n ...(args.framework\n ? { framework: args.framework as \"auto\" | \"express\" | \"hono\" | \"nextjs\" }\n : {}),\n };\n\n const checkResult = await runCheck(specs, configDir, checkConfig);\n const { suggestions } = generateUpdates({ findings: checkResult.findings });\n\n if (args.format === \"json\") {\n console.log(JSON.stringify({ suggestions }, null, 2));\n } else {\n printSuggestionsPretty(suggestions);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAsB9B,SAAS,mBAAmB,QAAwB;AAClD,QAAM,QAAQ,OAAO,KAAK,EAAE,MAAM,KAAK;AACvC,QAAM,SAAS,MAAM,CAAC,KAAK;AAC3B,QAAM,OAAO,MAAM,CAAC,KAAK;AACzB,SAAO,OAAO,MAAM,IAAI,IAAI;AAAA;AAC9B;AAEA,SAAS,kBAAkB,QAAwB;AACjD,SAAO,KAAK,MAAM;AACpB;AAEA,SAAS,kBAAkB,QAAwB;AACjD,SAAO,KAAK,MAAM;AACpB;AAEO,SAAS,gBAAgB,EAAE,SAAS,GAAgD;AACzF,QAAM,cAAkC,CAAC;AAEzC,aAAW,WAAW,UAAU;AAI9B,QAAI,QAAQ,SAAS,QAAS;AAE9B,UAAM,SAAS,QAAQ,UAAU;AAEjC,QAAI,QAAQ,aAAa,SAAS;AAChC,kBAAY,KAAK;AAAA,QACf,QAAQ,QAAQ;AAAA,QAChB,SAAS;AAAA,QACT,UAAU,mBAAmB,MAAM;AAAA,QACnC,QAAQ,SAAS,MAAM;AAAA,MACzB,CAAC;AAAA,IACH,WAAW,QAAQ,aAAa,QAAQ;AACtC,kBAAY,KAAK;AAAA,QACf,QAAQ,QAAQ;AAAA,QAChB,SAAS;AAAA,QACT,UAAU,kBAAkB,MAAM;AAAA,QAClC,QAAQ,GAAG,MAAM;AAAA,MACnB,CAAC;AAAA,IACH,WAAW,QAAQ,aAAa,QAAQ;AACtC,kBAAY,KAAK;AAAA,QACf,QAAQ,QAAQ;AAAA,QAChB,SAAS;AAAA,QACT,UAAU,kBAAkB,MAAM;AAAA,QAClC,QAAQ,cAAc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MAAM,WAAW,QAAW,SAAS;AAEpD,WAAO,MAAM,kBAAkB;AAE/B,UAAM,QAAsB,CAAC;AAC7B,eAAW,CAAC,EAAE,KAAK,KAAK,OAAO,QAAQ,OAAO,KAAK,GAAG;AACpD,YAAM,QAAQ,MAAM,YAAY,MAAM,MAAM,SAAS;AACrD,iBAAW,KAAK,OAAO;AACrB,cAAM,OAAO,MAAM,UAAU,CAAC;AAC9B,YAAI,KAAK,QAAQ,KAAK,YAAY,OAAO,KAAK,KAAM;AACpD,cAAM,KAAK,IAAI;AAAA,MACjB;AAAA,IACF;AAEA,WAAO,MAAM,oBAAoB,MAAM,MAAM,WAAW;AAExD,UAAM,cAAc;AAAA,MAClB,GAAG,OAAO;AAAA,MACV,GAAI,KAAK,YACL,EAAE,WAAW,KAAK,UAAoD,IACtE,CAAC;AAAA,IACP;AAEA,UAAM,cAAc,MAAM,SAAS,OAAO,WAAW,WAAW;AAChE,UAAM,EAAE,YAAY,IAAI,gBAAgB,EAAE,UAAU,YAAY,SAAS,CAAC;AAE1E,QAAI,KAAK,WAAW,QAAQ;AAC1B,cAAQ,IAAI,KAAK,UAAU,EAAE,YAAY,GAAG,MAAM,CAAC,CAAC;AAAA,IACtD,OAAO;AACL,6BAAuB,WAAW;AAAA,IACpC;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/core/validate.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, buildGraph, resolveGlob, ConfigError, GraphError } from \"@specdx/core\";\nimport { sharedArgs } from \"../../shared-args.js\";\n\nexport interface ValidateResult {\n valid: boolean;\n /** Number of spec entries declared in the config. */\n specCount?: number;\n /** Number of spec files those entries actually resolve to. */\n specFileCount?: number;\n /** Non-fatal honesty notes: entries resolving to nothing, empty suite. */\n warnings: string[];\n error?: string;\n details?: unknown[];\n}\n\n/**\n * Validate spec.config.yaml: a schema-valid config, a buildable dependency\n * graph (issue #13), and declared spec paths that actually resolve. An entry\n * that matches no files makes every downstream verdict vacuous, so it is\n * reported here rather than silently flowing into lint/status/ready.\n */\nexport async function runValidate(configDir: string): Promise<ValidateResult> {\n const warnings: string[] = [];\n try {\n const config = await loadConfig(undefined, configDir);\n buildGraph(config);\n\n let specFileCount = 0;\n const missingRequired: string[] = [];\n for (const [key, entry] of Object.entries(config.specs)) {\n const files = await resolveGlob(entry.path, configDir);\n specFileCount += files.length;\n if (files.length > 0) continue;\n\n if ((entry as { required?: boolean }).required) {\n missingRequired.push(`\"${key}\" (${entry.path})`);\n } else {\n warnings.push(`spec entry \"${key}\" resolves to no files: ${entry.path}`);\n }\n }\n\n if (missingRequired.length > 0) {\n return {\n valid: false,\n specCount: Object.keys(config.specs).length,\n specFileCount,\n warnings,\n error: `required spec entry resolves to no files: ${missingRequired.join(\", \")}`,\n };\n }\n\n if (specFileCount === 0) {\n warnings.push(\n \"no spec files found — every downstream check (lint, status, ready) would pass vacuously\",\n );\n }\n\n return {\n valid: true,\n specCount: Object.keys(config.specs).length,\n specFileCount,\n warnings,\n };\n } catch (err) {\n if (err instanceof ConfigError) {\n return { valid: false, warnings, error: err.message, details: err.errors ?? undefined };\n }\n if (err instanceof GraphError) {\n return { valid: false, warnings, error: err.message };\n }\n throw err;\n }\n}\n\nexport default defineCommand({\n meta: { name: \"validate\", description: \"Validate spec.config.yaml\" },\n args: { ...sharedArgs },\n async run() {\n const result = await runValidate(process.cwd());\n\n if (result.valid) {\n console.log(\n ` ✓ Config valid. ${result.specCount} spec entries, ${result.specFileCount} spec files.`,\n );\n for (const w of result.warnings) console.log(` ⚠ ${w}`);\n return;\n }\n\n console.error(` ✗ Config invalid: ${result.error}`);\n for (const w of result.warnings) console.error(` ⚠ ${w}`);\n if (result.details) {\n for (const e of result.details) console.error(` - ${JSON.stringify(e)}`);\n }\n process.exit(1);\n },\n});\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAsB9B,eAAsB,YAAY,WAA4C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