specdx 0.4.0-alpha.12 → 0.4.0-alpha.14
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/dist/{chunk-3GMYCATE.js → chunk-V7JOVK6D.js} +26 -2
- package/dist/chunk-V7JOVK6D.js.map +1 -0
- package/dist/{diff-DHU3OMNM.js → diff-AWFDXYX4.js} +60 -2
- package/dist/diff-AWFDXYX4.js.map +1 -0
- package/dist/{dist-6XCIT3RF.js → dist-2YMKBA6A.js} +2 -2
- package/dist/{explain-EULHHRQC.js → explain-M2VXXXGP.js} +5 -2
- package/dist/explain-M2VXXXGP.js.map +1 -0
- package/dist/index.js +114 -89
- package/dist/index.js.map +1 -1
- package/dist/{lint-NKE5XJQY.js → lint-A5AXYDSO.js} +2 -2
- package/dist/main.js +11 -10
- package/dist/main.js.map +1 -1
- package/dist/mcp-CWJKX27S.js +32 -0
- package/dist/mcp-CWJKX27S.js.map +1 -0
- package/dist/{pack-RRSHBRKJ.js → pack-I5WFM6B6.js} +28 -5
- package/dist/pack-I5WFM6B6.js.map +1 -0
- package/dist/{ready-UNK75BQ7.js → ready-2M5HXTRZ.js} +20 -2
- package/dist/ready-2M5HXTRZ.js.map +1 -0
- package/dist/{status-7OVCSV2I.js → status-QLG3ZKS7.js} +2 -2
- package/package.json +5 -3
- package/dist/changelog-COHY6ILK.js +0 -94
- package/dist/changelog-COHY6ILK.js.map +0 -1
- package/dist/chunk-3GMYCATE.js.map +0 -1
- package/dist/diff-DHU3OMNM.js.map +0 -1
- package/dist/explain-EULHHRQC.js.map +0 -1
- package/dist/mcp-OG3DRYN6.js +0 -19
- package/dist/mcp-OG3DRYN6.js.map +0 -1
- package/dist/pack-RRSHBRKJ.js.map +0 -1
- package/dist/ready-UNK75BQ7.js.map +0 -1
- /package/dist/{dist-6XCIT3RF.js.map → dist-2YMKBA6A.js.map} +0 -0
- /package/dist/{lint-NKE5XJQY.js.map → lint-A5AXYDSO.js.map} +0 -0
- /package/dist/{status-7OVCSV2I.js.map → status-QLG3ZKS7.js.map} +0 -0
|
@@ -482,6 +482,29 @@ var ambiguityScoreAiRule = {
|
|
|
482
482
|
}
|
|
483
483
|
};
|
|
484
484
|
|
|
485
|
+
// ../lint/dist/rules/no-placeholder-sections.js
|
|
486
|
+
var PLACEHOLDER_BODIES = /^(todo|tbd|fixme|n\/a|na|none|xxx|\.{2,}|-|\*)$/i;
|
|
487
|
+
function meaningfulContent(content) {
|
|
488
|
+
return content.replace(/<!--[\s\S]*?-->/g, "").split("\n").map((line) => line.replace(/^\s*[-*+]\s+/, "").trim()).filter((line) => line.length > 0 && !/^-{3,}$/.test(line)).join("\n").trim();
|
|
489
|
+
}
|
|
490
|
+
var noPlaceholderSectionsRule = {
|
|
491
|
+
id: "completeness/no-placeholder-sections",
|
|
492
|
+
description: "Spec sections contain content, not scaffolding placeholders",
|
|
493
|
+
severity: "warn",
|
|
494
|
+
run(context) {
|
|
495
|
+
return context.spec.parsedSections.filter((section) => section.heading !== "").filter((section) => {
|
|
496
|
+
const body = meaningfulContent(section.content);
|
|
497
|
+
return body === "" || PLACEHOLDER_BODIES.test(body);
|
|
498
|
+
}).map((section) => ({
|
|
499
|
+
ruleId: "completeness/no-placeholder-sections",
|
|
500
|
+
severity: "warn",
|
|
501
|
+
message: `Section "${section.heading}" is still a placeholder \u2014 write its content or remove the section`,
|
|
502
|
+
filePath: context.spec.filePath,
|
|
503
|
+
section: section.heading
|
|
504
|
+
}));
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
|
|
485
508
|
// ../lint/dist/rules/index.js
|
|
486
509
|
var structureRules = [
|
|
487
510
|
validFrontmatterRule,
|
|
@@ -498,7 +521,8 @@ var contentRules = [
|
|
|
498
521
|
edgeCaseCoverageRule,
|
|
499
522
|
namingConventionsRule,
|
|
500
523
|
threatCoverageRule,
|
|
501
|
-
ambiguityScoreAiRule
|
|
524
|
+
ambiguityScoreAiRule,
|
|
525
|
+
noPlaceholderSectionsRule
|
|
502
526
|
];
|
|
503
527
|
var allBuiltinRules = [...structureRules, ...contentRules];
|
|
504
528
|
|
|
@@ -523,4 +547,4 @@ export {
|
|
|
523
547
|
createLintEngine,
|
|
524
548
|
getPreset
|
|
525
549
|
};
|
|
526
|
-
//# sourceMappingURL=chunk-
|
|
550
|
+
//# sourceMappingURL=chunk-V7JOVK6D.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../lint/src/engine.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/story-coverage.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/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 diagnostics.push(...results);\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\";\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: ${err.message ?? JSON.stringify(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 type { LintRule } from \"../types.js\";\n\nconst FEATURE_PATTERN = /\\*\\*F\\d+\\*\\*:\\s*(.+)/g;\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 const features: string[] = [];\n let match;\n const re = new RegExp(FEATURE_PATTERN.source, \"g\");\n while ((match = re.exec(context.spec.content)) !== null) {\n features.push(match[1]!.trim());\n }\n if (features.length === 0) return [];\n const stories = context.allSpecs.filter((s) => s.frontmatter.type === \"user-story\");\n const storyContent = stories.map((s) => s.content + \" \" + s.frontmatter.title).join(\" \");\n return features\n .filter((feature) => !storyContent.toLowerCase().includes(feature.toLowerCase()))\n .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 { 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 \"404\",\n \"500\",\n \"missing\",\n \"malformed\",\n \"overflow\",\n \"duplicate\",\n \"graceful\",\n \"fall back\",\n \"fallback\",\n \"crash\",\n \"nonexistent\",\n \"corrupt\",\n];\n\nexport const edgeCaseCoverageRule: LintRule = {\n id: \"completeness/edge-case-coverage\",\n description: \"Flag user stories or test plans that don't mention error states or edge cases\",\n severity: \"warn\",\n run(context) {\n const type = context.spec.frontmatter.type as string;\n if (type !== \"user-story\" && type !== \"test-plan\") return [];\n\n const content = context.spec.content.toLowerCase();\n const hasEdgeCases = EDGE_CASE_KEYWORDS.some((kw) => content.includes(kw));\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 `sdx 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 { 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 type { LintRule } from \"../types.js\";\n\nexport const structureRules: LintRule[] = [\n validFrontmatterRule,\n requiredSectionsRule,\n validReferencesRule,\n noCircularDepsRule,\n singleProjectContextRule,\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};\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 return allBuiltinRules.map((rule) => ({ ...rule, severity: \"error\" as const }));\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;AACD,sBAAY,KAAK,GAAG,OAAO;QAC7B;MACF;AACA,aAAO;QACL;QACA,WAAW,YAAY,KAAK,CAAC,MAAM,EAAE,aAAa,OAAO;QACzD,aAAa,YAAY,KAAK,CAAC,MAAM,EAAE,aAAa,MAAM;;IAE9D;;AAEJ;;;AClCO,IAAM,uBAAiC;EAC5C,IAAI;EACJ,aAAa;EACb,UAAU;EACV,IAAI,SAAO;AACT,QAAI,QAAQ,KAAK;AAAO,aAAO,CAAA;AAC/B,UAAM,SAAS,QAAQ,KAAK,oBAAoB,CAAA;AAChD,WAAO,OAAO,IAAI,CAAC,SAAS;MAC1B,QAAQ;MACR,UAAU;MACV,SAAS,wBAAwB,IAAI,WAAW,KAAK,UAAU,GAAG,CAAC;MACnE,UAAU,QAAQ,KAAK;MACvB;EACJ;;;;ACXK,IAAM,uBAAiC;EAC5C,IAAI;EACJ,aAAa;EACb,UAAU;EACV,IAAI,SA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src/commands/diff.ts
|
|
13
13
|
import { defineCommand } from "citty";
|
|
14
14
|
import { join } from "path";
|
|
15
|
+
|
|
16
|
+
// src/formatters/changelog.ts
|
|
17
|
+
function formatChangelog(result, baseRef, headRef) {
|
|
18
|
+
const lines = [];
|
|
19
|
+
lines.push(`## Spec Changes (${baseRef}..${headRef})
|
|
20
|
+
`);
|
|
21
|
+
if (result.diffs.length > 0) {
|
|
22
|
+
lines.push("### Modified");
|
|
23
|
+
for (const diff of result.diffs) {
|
|
24
|
+
const sections = diff.sections.map((s) => s.heading).join(", ");
|
|
25
|
+
const versionChange = diff.frontmatter.find((f) => f.field === "version");
|
|
26
|
+
const versionStr = versionChange ? ` (${String(versionChange.before)} \u2192 ${String(versionChange.after)})` : "";
|
|
27
|
+
lines.push(`- **${diff.specId}**${versionStr} \u2014 ${sections || "frontmatter only"}`);
|
|
28
|
+
}
|
|
29
|
+
lines.push("");
|
|
30
|
+
}
|
|
31
|
+
if (result.added.length > 0) {
|
|
32
|
+
lines.push("### Added");
|
|
33
|
+
for (const id of result.added) {
|
|
34
|
+
lines.push(`- **${id}**`);
|
|
35
|
+
}
|
|
36
|
+
lines.push("");
|
|
37
|
+
}
|
|
38
|
+
if (result.removed.length > 0) {
|
|
39
|
+
lines.push("### Removed");
|
|
40
|
+
for (const id of result.removed) {
|
|
41
|
+
lines.push(`- **${id}**`);
|
|
42
|
+
}
|
|
43
|
+
lines.push("");
|
|
44
|
+
}
|
|
45
|
+
const allDownstream = result.impact.flatMap((i) => i.downstream);
|
|
46
|
+
if (allDownstream.length > 0) {
|
|
47
|
+
lines.push("### Downstream Impact");
|
|
48
|
+
for (const d of allDownstream) {
|
|
49
|
+
lines.push(`- ${d.specId} may be stale (${d.reason})`);
|
|
50
|
+
}
|
|
51
|
+
lines.push("");
|
|
52
|
+
}
|
|
53
|
+
if (result.diffs.length === 0 && result.added.length === 0 && result.removed.length === 0) {
|
|
54
|
+
lines.push("No spec changes detected.\n");
|
|
55
|
+
}
|
|
56
|
+
if (result.uncommittedSpecFiles.length > 0) {
|
|
57
|
+
lines.push(
|
|
58
|
+
`> \u26A0 ${result.uncommittedSpecFiles.length} spec file(s) changed in the working tree are not covered by this range.
|
|
59
|
+
`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
return lines.join("\n");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/commands/diff.ts
|
|
15
66
|
async function runDiff(options) {
|
|
16
67
|
const configDir = process.cwd();
|
|
17
68
|
const config = await loadConfig(void 0, configDir);
|
|
@@ -40,7 +91,7 @@ var diff_default = defineCommand({
|
|
|
40
91
|
spec: { type: "string", description: "Scope to a single spec ID" },
|
|
41
92
|
format: {
|
|
42
93
|
type: "string",
|
|
43
|
-
description: "Output format: pretty, json",
|
|
94
|
+
description: "Output format: pretty, json, changelog",
|
|
44
95
|
default: "pretty"
|
|
45
96
|
}
|
|
46
97
|
},
|
|
@@ -58,6 +109,13 @@ var diff_default = defineCommand({
|
|
|
58
109
|
console.log(JSON.stringify(result, null, 2));
|
|
59
110
|
return;
|
|
60
111
|
}
|
|
112
|
+
if (args.format === "changelog") {
|
|
113
|
+
const baseRef = args.base ?? (await loadConfig(void 0, process.cwd())).diff?.baseline_ref ?? "main";
|
|
114
|
+
console.log(
|
|
115
|
+
formatChangelog(result, baseRef, args.working ? "working tree" : args.head ?? "HEAD")
|
|
116
|
+
);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
61
119
|
const printUncommittedWarning = () => {
|
|
62
120
|
if (result.uncommittedSpecFiles.length === 0) return;
|
|
63
121
|
const count = result.uncommittedSpecFiles.length;
|
|
@@ -127,4 +185,4 @@ export {
|
|
|
127
185
|
diff_default as default,
|
|
128
186
|
runDiff
|
|
129
187
|
};
|
|
130
|
-
//# sourceMappingURL=diff-
|
|
188
|
+
//# sourceMappingURL=diff-AWFDXYX4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/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,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AAC9B,oBAAQ,IAAI,OAAO,GAAG,IAAI,KAAK,GAAG,OAAO,EAAE;AAAA,UAC7C;AAAA,QACF;AAEA,YAAI,OAAO,MAAM,SAAS,GAAG;AAC3B,kBAAQ,IAAI;AAAA,WAAc,OAAO,MAAM,KAAK,IAAI,CAAC,EAAE;AAAA,QACrD;AACA,YAAI,OAAO,QAAQ,SAAS,GAAG;AAC7B,kBAAQ,IAAI;AAAA,aAAgB,OAAO,QAAQ,KAAK,IAAI,CAAC,EAAE;AAAA,QACzD;AAEA,YAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,kBAAQ,IAAI,wBAAwB;AACpC,qBAAW,UAAU,OAAO,QAAQ;AAClC,uBAAW,KAAK,OAAO,YAAY;AACjC,sBAAQ;AAAA,gBACN,OAAO,EAAE,MAAM,sBAAsB,EAAE,UAAU,QAAQ,CAAC,CAAC,WAAW,EAAE,MAAM;AAAA,cAChF;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAEA,gCAAwB;AAAA,MAC1B,SAAS,KAAK;AACZ,YAAI,eAAe,WAAW;AAC5B,kBAAQ,MAAM;AAAA,WAAc,IAAI,OAAO;AAAA,CAAI;AAC3C,kBAAQ,KAAK,CAAC;AAAA,QAChB;AACA,cAAM;AAAA,MACR;AAAA,IACF,SAAS,KAAK;AACZ,cAAQ,MAAM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
createLintEngine,
|
|
9
9
|
getPreset
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-V7JOVK6D.js";
|
|
11
11
|
import {
|
|
12
12
|
DEFAULT_DIFF_CONFIG,
|
|
13
13
|
DiffError,
|
|
@@ -307,4 +307,4 @@ function createMcpServer() {
|
|
|
307
307
|
export {
|
|
308
308
|
createMcpServer
|
|
309
309
|
};
|
|
310
|
-
//# sourceMappingURL=dist-
|
|
310
|
+
//# sourceMappingURL=dist-2YMKBA6A.js.map
|
|
@@ -60,7 +60,10 @@ async function runExplain(_options = {}) {
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
var explain_default = defineCommand({
|
|
63
|
-
meta: {
|
|
63
|
+
meta: {
|
|
64
|
+
name: "explain",
|
|
65
|
+
description: "[experimental] Explain the spec suite for onboarding"
|
|
66
|
+
},
|
|
64
67
|
args: {
|
|
65
68
|
format: { type: "string", description: "Output format: pretty, json", default: "pretty" }
|
|
66
69
|
},
|
|
@@ -107,4 +110,4 @@ export {
|
|
|
107
110
|
explain_default as default,
|
|
108
111
|
runExplain
|
|
109
112
|
};
|
|
110
|
-
//# sourceMappingURL=explain-
|
|
113
|
+
//# sourceMappingURL=explain-M2VXXXGP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/explain.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, buildGraph, resolveGlob } from \"@specdx/core\";\nimport type { ParsedSpec } from \"@specdx/core\";\n\ninterface ExplainResult {\n project: string;\n description?: string;\n specCount: number;\n byType: Record<string, number>;\n byStatus: Record<string, number>;\n specs: { id: string; type: string; title: string; status: string; firstLine: string }[];\n graph: string[];\n}\n\nexport async function runExplain(_options: { format?: string } = {}): Promise<ExplainResult> {\n const configDir = process.cwd();\n const config = await loadConfig(undefined, configDir);\n\n // Parse all specs\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 specs.push(await parseSpec(p));\n }\n }\n\n // Count by type and status\n const byType: Record<string, number> = {};\n const byStatus: Record<string, number> = {};\n for (const spec of specs) {\n const type = (spec.frontmatter.type as string) || \"unknown\";\n const status = (spec.frontmatter.status as string) || \"unknown\";\n byType[type] = (byType[type] ?? 0) + 1;\n byStatus[status] = (byStatus[status] ?? 0) + 1;\n }\n\n // Build spec summaries — first sentence of first section content\n const specSummaries = specs.map((spec) => {\n const firstSection = spec.parsedSections[0];\n const firstLine =\n firstSection?.content\n ?.split(\"\\n\")\n .find((l) => l.trim().length > 0)\n ?.trim() ?? \"\";\n const truncated = firstLine.slice(0, 120) + (firstLine.length > 120 ? \"...\" : \"\");\n return {\n id: spec.frontmatter.id as string,\n type: spec.frontmatter.type as string,\n title: spec.frontmatter.title as string,\n status: spec.frontmatter.status as string,\n firstLine: truncated,\n };\n });\n\n // Build dependency graph lines\n const graph = buildGraph(config);\n const graphLines: string[] = [];\n for (const node of graph.nodes) {\n const downstream = graph.edges.filter((e) => e.from === node).map((e) => e.to);\n if (downstream.length > 0) {\n graphLines.push(`${node} → ${downstream.join(\", \")}`);\n } else {\n graphLines.push(node);\n }\n }\n\n return {\n project: config.project?.name ?? \"unknown\",\n description: config.project?.description,\n specCount: specs.length,\n byType,\n byStatus,\n specs: specSummaries,\n graph: graphLines,\n };\n}\n\nexport default defineCommand({\n meta: {\n name: \"explain\",\n description: \"[experimental] Explain the spec suite for onboarding\",\n },\n args: {\n format: { type: \"string\", description: \"Output format: pretty, json\", default: \"pretty\" },\n },\n async run({ args }) {\n try {\n const result = await runExplain({ format: args.format });\n\n if (args.format === \"json\") {\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n // Pretty format\n console.log(`\\n ${result.project}`);\n if (result.description) {\n console.log(` ${result.description}`);\n }\n console.log(\n `\\n ${result.specCount} specs: ${Object.entries(result.byType)\n .map(([k, v]) => `${v} ${k}`)\n .join(\", \")}`,\n );\n console.log(\n ` Status: ${Object.entries(result.byStatus)\n .map(([k, v]) => `${v} ${k}`)\n .join(\", \")}`,\n );\n\n console.log(\"\\n Specs:\");\n for (const spec of result.specs) {\n console.log(` ${spec.id} (${spec.type}, ${spec.status}) — ${spec.title}`);\n if (spec.firstLine) {\n console.log(` ${spec.firstLine}`);\n }\n }\n\n console.log(\"\\n Dependencies:\");\n for (const line of result.graph)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AAQ;AAAA,QACN,aAAa,OAAO,QAAQ,OAAO,QAAQ,EACxC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,EAAE,EAC3B,KAAK,IAAI,CAAC;AAAA,MACf;AAEA,cAAQ,IAAI,YAAY;AACxB,iBAAW,QAAQ,OAAO,OAAO;AAC/B,gBAAQ,IAAI,OAAO,KAAK,EAAE,KAAK,KAAK,IAAI,KAAK,KAAK,MAAM,YAAO,KAAK,KAAK,EAAE;AAC3E,YAAI,KAAK,WAAW;AAClB,kBAAQ,IAAI,SAAS,KAAK,SAAS,EAAE;AAAA,QACvC;AAAA,MACF;AAEA,cAAQ,IAAI,mBAAmB;AAC/B,iBAAW,QAAQ,OAAO,OAAO;AAC/B,gBAAQ,IAAI,OAAO,IAAI,EAAE;AAAA,MAC3B;AACA,cAAQ,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":[]}
|
package/dist/index.js
CHANGED
|
@@ -2963,6 +2963,29 @@ var ambiguityScoreAiRule = {
|
|
|
2963
2963
|
}
|
|
2964
2964
|
};
|
|
2965
2965
|
|
|
2966
|
+
// ../lint/dist/rules/no-placeholder-sections.js
|
|
2967
|
+
var PLACEHOLDER_BODIES = /^(todo|tbd|fixme|n\/a|na|none|xxx|\.{2,}|-|\*)$/i;
|
|
2968
|
+
function meaningfulContent(content) {
|
|
2969
|
+
return content.replace(/<!--[\s\S]*?-->/g, "").split("\n").map((line) => line.replace(/^\s*[-*+]\s+/, "").trim()).filter((line) => line.length > 0 && !/^-{3,}$/.test(line)).join("\n").trim();
|
|
2970
|
+
}
|
|
2971
|
+
var noPlaceholderSectionsRule = {
|
|
2972
|
+
id: "completeness/no-placeholder-sections",
|
|
2973
|
+
description: "Spec sections contain content, not scaffolding placeholders",
|
|
2974
|
+
severity: "warn",
|
|
2975
|
+
run(context) {
|
|
2976
|
+
return context.spec.parsedSections.filter((section) => section.heading !== "").filter((section) => {
|
|
2977
|
+
const body = meaningfulContent(section.content);
|
|
2978
|
+
return body === "" || PLACEHOLDER_BODIES.test(body);
|
|
2979
|
+
}).map((section) => ({
|
|
2980
|
+
ruleId: "completeness/no-placeholder-sections",
|
|
2981
|
+
severity: "warn",
|
|
2982
|
+
message: `Section "${section.heading}" is still a placeholder \u2014 write its content or remove the section`,
|
|
2983
|
+
filePath: context.spec.filePath,
|
|
2984
|
+
section: section.heading
|
|
2985
|
+
}));
|
|
2986
|
+
}
|
|
2987
|
+
};
|
|
2988
|
+
|
|
2966
2989
|
// ../lint/dist/rules/index.js
|
|
2967
2990
|
var structureRules = [
|
|
2968
2991
|
validFrontmatterRule,
|
|
@@ -2979,7 +3002,8 @@ var contentRules = [
|
|
|
2979
3002
|
edgeCaseCoverageRule,
|
|
2980
3003
|
namingConventionsRule,
|
|
2981
3004
|
threatCoverageRule,
|
|
2982
|
-
ambiguityScoreAiRule
|
|
3005
|
+
ambiguityScoreAiRule,
|
|
3006
|
+
noPlaceholderSectionsRule
|
|
2983
3007
|
];
|
|
2984
3008
|
var allBuiltinRules = [...structureRules, ...contentRules];
|
|
2985
3009
|
|
|
@@ -3789,6 +3813,16 @@ function copyToClipboard(text) {
|
|
|
3789
3813
|
}
|
|
3790
3814
|
execSync(cmd, { input: text, stdio: ["pipe", "ignore", "ignore"] });
|
|
3791
3815
|
}
|
|
3816
|
+
function emptyPackReason(stats, specsResolved) {
|
|
3817
|
+
if (stats.specsIncluded > 0) return void 0;
|
|
3818
|
+
if (specsResolved === 0) {
|
|
3819
|
+
return "no specs resolved from spec.config.yaml \u2014 check the paths in your config";
|
|
3820
|
+
}
|
|
3821
|
+
if (stats.specsExcluded === 0) {
|
|
3822
|
+
return `none of the ${specsResolved} resolved spec(s) scored above the relevance threshold for this task \u2014 try different --task wording, name specs with --specs, or use --full`;
|
|
3823
|
+
}
|
|
3824
|
+
return `all ${stats.specsExcluded} candidate spec(s) were excluded \u2014 widen --specs or raise --budget`;
|
|
3825
|
+
}
|
|
3792
3826
|
async function runPack(options) {
|
|
3793
3827
|
const config = await loadConfig(void 0, options.configDir);
|
|
3794
3828
|
const allSpecs = [];
|
|
@@ -3816,7 +3850,7 @@ async function runPack(options) {
|
|
|
3816
3850
|
config.pack,
|
|
3817
3851
|
graph
|
|
3818
3852
|
);
|
|
3819
|
-
return result;
|
|
3853
|
+
return { ...result, specsResolved: allSpecs.length };
|
|
3820
3854
|
}
|
|
3821
3855
|
var pack_default = defineCommand3({
|
|
3822
3856
|
meta: { name: "pack", description: "Pack specs into AI-ready context" },
|
|
@@ -3887,12 +3921,16 @@ var pack_default = defineCommand3({
|
|
|
3887
3921
|
}
|
|
3888
3922
|
console.log(`
|
|
3889
3923
|
Budget: ${stats.used} / ${stats.budget} tokens`);
|
|
3890
|
-
console.log(
|
|
3891
|
-
` Included: ${stats.specsIncluded} / ${stats.specsIncluded + stats.specsExcluded} specs`
|
|
3892
|
-
);
|
|
3924
|
+
console.log(` Included: ${stats.specsIncluded} / ${result.specsResolved} specs`);
|
|
3893
3925
|
console.log(` Sections compressed: ${stats.sectionsCompressed}`);
|
|
3894
3926
|
console.log(` Sections omitted: ${stats.sectionsOmitted}
|
|
3895
3927
|
`);
|
|
3928
|
+
const dryReason = emptyPackReason(stats, result.specsResolved);
|
|
3929
|
+
if (dryReason) {
|
|
3930
|
+
console.log(` \u26A0 Nothing would be packed: ${dryReason}
|
|
3931
|
+
`);
|
|
3932
|
+
process.exit(3);
|
|
3933
|
+
}
|
|
3896
3934
|
return;
|
|
3897
3935
|
}
|
|
3898
3936
|
if (args.out) {
|
|
@@ -3911,6 +3949,14 @@ var pack_default = defineCommand3({
|
|
|
3911
3949
|
`Packed ${stats.specsIncluded}/${total} specs \u2022 ${stats.used} / ${stats.budget} tokens \u2022 ${stats.sectionsCompressed} sections compressed \u2022 ${stats.sectionsOmitted} sections omitted
|
|
3912
3950
|
`
|
|
3913
3951
|
);
|
|
3952
|
+
const emptyReason = emptyPackReason(stats, result.specsResolved);
|
|
3953
|
+
if (emptyReason) {
|
|
3954
|
+
process.stderr.write(`
|
|
3955
|
+
\u26A0 No context packed: ${emptyReason}
|
|
3956
|
+
|
|
3957
|
+
`);
|
|
3958
|
+
process.exit(3);
|
|
3959
|
+
}
|
|
3914
3960
|
} catch (err) {
|
|
3915
3961
|
console.error(`
|
|
3916
3962
|
\u2717 ${err.message}
|
|
@@ -5229,6 +5275,55 @@ async function diffBetweenRefs(configPath, baseRef, headRef, options = {}) {
|
|
|
5229
5275
|
return { diffs, added, removed, impact, summary, uncommittedSpecFiles };
|
|
5230
5276
|
}
|
|
5231
5277
|
|
|
5278
|
+
// src/formatters/changelog.ts
|
|
5279
|
+
function formatChangelog(result, baseRef, headRef) {
|
|
5280
|
+
const lines = [];
|
|
5281
|
+
lines.push(`## Spec Changes (${baseRef}..${headRef})
|
|
5282
|
+
`);
|
|
5283
|
+
if (result.diffs.length > 0) {
|
|
5284
|
+
lines.push("### Modified");
|
|
5285
|
+
for (const diff2 of result.diffs) {
|
|
5286
|
+
const sections = diff2.sections.map((s) => s.heading).join(", ");
|
|
5287
|
+
const versionChange = diff2.frontmatter.find((f) => f.field === "version");
|
|
5288
|
+
const versionStr = versionChange ? ` (${String(versionChange.before)} \u2192 ${String(versionChange.after)})` : "";
|
|
5289
|
+
lines.push(`- **${diff2.specId}**${versionStr} \u2014 ${sections || "frontmatter only"}`);
|
|
5290
|
+
}
|
|
5291
|
+
lines.push("");
|
|
5292
|
+
}
|
|
5293
|
+
if (result.added.length > 0) {
|
|
5294
|
+
lines.push("### Added");
|
|
5295
|
+
for (const id of result.added) {
|
|
5296
|
+
lines.push(`- **${id}**`);
|
|
5297
|
+
}
|
|
5298
|
+
lines.push("");
|
|
5299
|
+
}
|
|
5300
|
+
if (result.removed.length > 0) {
|
|
5301
|
+
lines.push("### Removed");
|
|
5302
|
+
for (const id of result.removed) {
|
|
5303
|
+
lines.push(`- **${id}**`);
|
|
5304
|
+
}
|
|
5305
|
+
lines.push("");
|
|
5306
|
+
}
|
|
5307
|
+
const allDownstream = result.impact.flatMap((i) => i.downstream);
|
|
5308
|
+
if (allDownstream.length > 0) {
|
|
5309
|
+
lines.push("### Downstream Impact");
|
|
5310
|
+
for (const d of allDownstream) {
|
|
5311
|
+
lines.push(`- ${d.specId} may be stale (${d.reason})`);
|
|
5312
|
+
}
|
|
5313
|
+
lines.push("");
|
|
5314
|
+
}
|
|
5315
|
+
if (result.diffs.length === 0 && result.added.length === 0 && result.removed.length === 0) {
|
|
5316
|
+
lines.push("No spec changes detected.\n");
|
|
5317
|
+
}
|
|
5318
|
+
if (result.uncommittedSpecFiles.length > 0) {
|
|
5319
|
+
lines.push(
|
|
5320
|
+
`> \u26A0 ${result.uncommittedSpecFiles.length} spec file(s) changed in the working tree are not covered by this range.
|
|
5321
|
+
`
|
|
5322
|
+
);
|
|
5323
|
+
}
|
|
5324
|
+
return lines.join("\n");
|
|
5325
|
+
}
|
|
5326
|
+
|
|
5232
5327
|
// src/commands/diff.ts
|
|
5233
5328
|
async function runDiff(options) {
|
|
5234
5329
|
const configDir = process.cwd();
|
|
@@ -5258,7 +5353,7 @@ var diff_default = defineCommand4({
|
|
|
5258
5353
|
spec: { type: "string", description: "Scope to a single spec ID" },
|
|
5259
5354
|
format: {
|
|
5260
5355
|
type: "string",
|
|
5261
|
-
description: "Output format: pretty, json",
|
|
5356
|
+
description: "Output format: pretty, json, changelog",
|
|
5262
5357
|
default: "pretty"
|
|
5263
5358
|
}
|
|
5264
5359
|
},
|
|
@@ -5276,6 +5371,13 @@ var diff_default = defineCommand4({
|
|
|
5276
5371
|
console.log(JSON.stringify(result, null, 2));
|
|
5277
5372
|
return;
|
|
5278
5373
|
}
|
|
5374
|
+
if (args.format === "changelog") {
|
|
5375
|
+
const baseRef = args.base ?? (await loadConfig(void 0, process.cwd())).diff?.baseline_ref ?? "main";
|
|
5376
|
+
console.log(
|
|
5377
|
+
formatChangelog(result, baseRef, args.working ? "working tree" : args.head ?? "HEAD")
|
|
5378
|
+
);
|
|
5379
|
+
return;
|
|
5380
|
+
}
|
|
5279
5381
|
const printUncommittedWarning = () => {
|
|
5280
5382
|
if (result.uncommittedSpecFiles.length === 0) return;
|
|
5281
5383
|
const count = result.uncommittedSpecFiles.length;
|
|
@@ -5483,87 +5585,8 @@ var status_default = defineCommand5({
|
|
|
5483
5585
|
}
|
|
5484
5586
|
});
|
|
5485
5587
|
|
|
5486
|
-
// src/commands/changelog.ts
|
|
5487
|
-
import { defineCommand as defineCommand6 } from "citty";
|
|
5488
|
-
import { join as join6 } from "path";
|
|
5489
|
-
async function runChangelog(options) {
|
|
5490
|
-
const configDir = process.cwd();
|
|
5491
|
-
const config = await loadConfig(void 0, configDir);
|
|
5492
|
-
const fromRef = options.from ?? config.diff?.baseline_ref ?? DEFAULT_DIFF_CONFIG.baseline_ref;
|
|
5493
|
-
const toRef = options.to ?? "HEAD";
|
|
5494
|
-
const configPath = join6(configDir, "spec.config.yaml");
|
|
5495
|
-
const result = await diffBetweenRefs(configPath, fromRef, toRef);
|
|
5496
|
-
const lines = [];
|
|
5497
|
-
lines.push(`## Spec Changes (${fromRef}..${toRef})
|
|
5498
|
-
`);
|
|
5499
|
-
if (result.diffs.length > 0) {
|
|
5500
|
-
lines.push("### Modified");
|
|
5501
|
-
for (const diff2 of result.diffs) {
|
|
5502
|
-
const sections = diff2.sections.map((s) => s.heading).join(", ");
|
|
5503
|
-
const versionChange = diff2.frontmatter.find((f) => f.field === "version");
|
|
5504
|
-
const versionStr = versionChange ? ` (${String(versionChange.before)} \u2192 ${String(versionChange.after)})` : "";
|
|
5505
|
-
lines.push(`- **${diff2.specId}**${versionStr} \u2014 ${sections || "frontmatter only"}`);
|
|
5506
|
-
}
|
|
5507
|
-
lines.push("");
|
|
5508
|
-
}
|
|
5509
|
-
if (result.added.length > 0) {
|
|
5510
|
-
lines.push("### Added");
|
|
5511
|
-
for (const id of result.added) {
|
|
5512
|
-
lines.push(`- **${id}**`);
|
|
5513
|
-
}
|
|
5514
|
-
lines.push("");
|
|
5515
|
-
}
|
|
5516
|
-
if (result.removed.length > 0) {
|
|
5517
|
-
lines.push("### Removed");
|
|
5518
|
-
for (const id of result.removed) {
|
|
5519
|
-
lines.push(`- **${id}**`);
|
|
5520
|
-
}
|
|
5521
|
-
lines.push("");
|
|
5522
|
-
}
|
|
5523
|
-
const allDownstream = result.impact.flatMap((i) => i.downstream);
|
|
5524
|
-
if (allDownstream.length > 0) {
|
|
5525
|
-
lines.push("### Downstream Impact");
|
|
5526
|
-
for (const d of allDownstream) {
|
|
5527
|
-
lines.push(`- ${d.specId} may be stale (${d.reason})`);
|
|
5528
|
-
}
|
|
5529
|
-
lines.push("");
|
|
5530
|
-
}
|
|
5531
|
-
if (result.diffs.length === 0 && result.added.length === 0 && result.removed.length === 0) {
|
|
5532
|
-
lines.push("No spec changes detected.\n");
|
|
5533
|
-
}
|
|
5534
|
-
return lines.join("\n");
|
|
5535
|
-
}
|
|
5536
|
-
var changelog_default = defineCommand6({
|
|
5537
|
-
meta: { name: "changelog", description: "Generate changelog of spec changes between git refs" },
|
|
5538
|
-
args: {
|
|
5539
|
-
from: { type: "string", description: "Start git ref (default: from config or 'main')" },
|
|
5540
|
-
to: { type: "string", description: "End git ref (default: HEAD)" }
|
|
5541
|
-
},
|
|
5542
|
-
async run({ args }) {
|
|
5543
|
-
try {
|
|
5544
|
-
try {
|
|
5545
|
-
const output = await runChangelog(args);
|
|
5546
|
-
console.log(output);
|
|
5547
|
-
} catch (err) {
|
|
5548
|
-
if (err instanceof DiffError) {
|
|
5549
|
-
console.error(`
|
|
5550
|
-
\u2717 ${err.message}
|
|
5551
|
-
`);
|
|
5552
|
-
process.exit(1);
|
|
5553
|
-
}
|
|
5554
|
-
throw err;
|
|
5555
|
-
}
|
|
5556
|
-
} catch (err) {
|
|
5557
|
-
console.error(`
|
|
5558
|
-
\u2717 ${err.message}
|
|
5559
|
-
`);
|
|
5560
|
-
process.exit(1);
|
|
5561
|
-
}
|
|
5562
|
-
}
|
|
5563
|
-
});
|
|
5564
|
-
|
|
5565
5588
|
// src/commands/explain.ts
|
|
5566
|
-
import { defineCommand as
|
|
5589
|
+
import { defineCommand as defineCommand6 } from "citty";
|
|
5567
5590
|
async function runExplain(_options = {}) {
|
|
5568
5591
|
const configDir = process.cwd();
|
|
5569
5592
|
const config = await loadConfig(void 0, configDir);
|
|
@@ -5614,8 +5637,11 @@ async function runExplain(_options = {}) {
|
|
|
5614
5637
|
graph: graphLines
|
|
5615
5638
|
};
|
|
5616
5639
|
}
|
|
5617
|
-
var explain_default =
|
|
5618
|
-
meta: {
|
|
5640
|
+
var explain_default = defineCommand6({
|
|
5641
|
+
meta: {
|
|
5642
|
+
name: "explain",
|
|
5643
|
+
description: "[experimental] Explain the spec suite for onboarding"
|
|
5644
|
+
},
|
|
5619
5645
|
args: {
|
|
5620
5646
|
format: { type: "string", description: "Output format: pretty, json", default: "pretty" }
|
|
5621
5647
|
},
|
|
@@ -5659,7 +5685,6 @@ var explain_default = defineCommand7({
|
|
|
5659
5685
|
}
|
|
5660
5686
|
});
|
|
5661
5687
|
export {
|
|
5662
|
-
runChangelog,
|
|
5663
5688
|
runDiff,
|
|
5664
5689
|
runExplain,
|
|
5665
5690
|
runLint,
|