@descent-vtt/spec-graph 0.14.1 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,aAAa,EACb,cAAc,EACd,cAAc,EACd,aAAa,GAGd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,UAAU,EAAwB,MAAM,aAAa,CAAC;AAC/E,OAAO,EACL,cAAc,EACd,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,gBAAgB,GAEjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAA4C,MAAM,aAAa,CAAC;AACnH,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,UAAU,EACV,cAAc,EACd,YAAY,EACZ,WAAW,EACX,cAAc,EACd,cAAc,GAEf,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,QAAQ,EACR,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAA8B,MAAM,aAAa,CAAC;AACvG,OAAO,EAAE,aAAa,EAA6D,MAAM,YAAY,CAAC;AACtG,OAAO,EAAE,YAAY,EAAE,MAA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M,EAAE,KAAK,CAAC,CAAC;IACxC,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IACxH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;GAQG;AACH,KAAK,UAAU,WAAW;IACxB,IAAI,CAAC;QACH,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QACtD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,iBAAiB,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACxD,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;QAChE,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,SAAS,IAAI,MAAM,EAAE,CAAC;YACzE,OAAO,MAAM,CAAE,MAA+B,CAAC,OAAO,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,mEAAmE;IACrE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/**\n * The command line.\n *\n * Five verbs, because there are five questions worth asking of a specification\n * graph: is it consistent (`check`), what does it contain (`query`), what does\n * it look like (`graph`), what will you check for me (`rules`), and what did a\n * change do to it (`diff`).\n *\n * Exit codes are the contract with CI: `0` clean, `1` findings, `2` the tool\n * itself could not run. A usage mistake never masquerades as a passing build,\n * and an error nothing here expected never as findings.\n */\n\nimport {\n applyBaseline,\n EMPTY_BASELINE,\n formatBaseline,\n parseBaseline,\n type Baseline,\n type StaleEntry,\n} from './baseline.js';\nimport { discoverConfig, loadConfig, type SpecGraphConfig } from './config.js';\nimport {\n DiffInputError,\n diffExports,\n formatDiffJson,\n formatDiffMarkdown,\n formatDiffText,\n parseGraphExport,\n type GraphExport,\n} from './diff.js';\nimport { isGlob, rebasePattern, underRoot } from './glob.js';\nimport { isFamilyName } from './identity.js';\nimport { analyse, DEFAULT_PATTERNS, withDiagnostics, type AnalyseOptions, type AnalysisResult } from './runner.js';\nimport {\n formatGithub,\n formatGitlab,\n formatGraph,\n formatJson,\n formatMarkdown,\n formatReport,\n formatSarif,\n shouldUseAscii,\n shouldUseColor,\n type GraphFormat,\n} from './report.js';\nimport type { ProjectRule } from './project-rules.js';\nimport {\n DEFAULT_SEVERITIES,\n resolveStrict,\n RULE_DECISIONS,\n decisionUrl,\n RULE_DESCRIPTIONS,\n RULE_IDS,\n RULE_QUERIES,\n} from './rules.js';\nimport { isAbsolutePath, joinPosix, toPosix } from './paths.js';\nimport { formatRef } from './source.js';\nimport { execute, parseQuery, QueryError, renderMatch, type Match, type QuerySpec } from './select.js';\nimport { isProjectRule, type AnyRuleId, type RuleId, type Severity, type SpecNode } from './types.js';\nimport { displayWidth } from './vendor/spec-core/text/index.js';\n\nexport const EXIT_OK = 0;\nexport const EXIT_FAILED = 1;\nexport const EXIT_ERROR = 2;\n\nexport class UsageError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'UsageError';\n }\n}\n\nexport type Command = 'check' | 'query' | 'graph' | 'rules' | 'diff';\n\nexport interface CliOptions {\n readonly command: Command;\n readonly patterns: readonly string[];\n readonly root: string;\n /**\n * Whether `--root` was given.\n *\n * When it was, the caller has named the root and configuration is read from\n * exactly there. When it was not, the root is discovered - which is a\n * different question from what the root currently is. See ADR-0018.\n */\n readonly rootExplicit: boolean;\n readonly ignore: readonly string[];\n /** Reference targets to leave unreported when they do not resolve. */\n readonly ignoreReferences: readonly string[];\n /** Families a bare identifier may name. Empty means any family in the corpus. */\n readonly families: readonly string[];\n /** Families that are never citations. */\n readonly ignoreFamilies: readonly string[];\n /** Files that log what was decided rather than deciding it. */\n readonly historyPatterns: readonly string[];\n /** Accepted-debt file to read. `null` means none was asked for. */\n readonly baseline: string | null;\n /** Where to write the current findings as accepted debt. */\n readonly recordBaseline: string | null;\n /**\n * Fail when the baseline allows something that no longer happens.\n *\n * The other side of the ratchet, and off by default for the reason ADR-0012\n * gives: failing a build because somebody fixed something is a strange way to\n * encourage them. A team that has decided its debt only goes one way asks for\n * it explicitly, and then a dead exemption cannot outlive the defect.\n */\n readonly ratchet: boolean;\n /** Skip the repository configuration file entirely. */\n readonly noConfig: boolean;\n readonly format: 'human' | 'json' | 'sarif' | 'markdown' | 'gitlab' | 'github';\n readonly graphFormat: GraphFormat;\n readonly severities: Partial<Record<AnyRuleId, Severity>>;\n readonly color: boolean | null;\n readonly ascii: boolean | null;\n readonly verbose: boolean;\n readonly documentsOnly: boolean;\n readonly max: number;\n readonly maxWarnings: number;\n /** Raise every warning to an error. Explicit `--rule` overrides still win. */\n readonly strict: boolean;\n readonly selector: string | null;\n readonly help: boolean;\n readonly version: boolean;\n}\n\nexport interface CliIO {\n readonly argv?: readonly string[] | undefined;\n readonly cwd?: string | undefined;\n readonly stdout?: ((text: string) => void) | undefined;\n readonly stderr?: ((text: string) => void) | undefined;\n readonly env?: Readonly<Record<string, string | undefined>> | undefined;\n readonly isTTY?: boolean | undefined;\n}\n\nexport const HELP = `spec-graph - turn Markdown specifications into a verifiable graph\n\nUSAGE\n spec-graph [check] [patterns...] [options]\n spec-graph query <selector|project:rule> [patterns...] [options]\n spec-graph graph [patterns...] [--graph-format dot|mermaid|json]\n spec-graph rules [rule-id] [--explain]\n spec-graph diff <before.json> <after.json> [--format human|json|markdown]\n\nCOMMANDS\n check Validate the specification graph. The default.\n query Run a selector - or a registered project rule, by its id - and\n print the matching paths.\n graph Export the graph for Graphviz, Mermaid, or another tool.\n rules List the diagnostics that will run, built in and project. Name one\n to see only that one; --explain adds its selector and the ADR that\n decided it.\n diff Compare two graph exports: documents added, removed, moved or\n accepted; relations added or removed; and obligations resolved or\n reopened where they can be told apart. Make both exports with the\n same spec-graph. Exits 0 whether anything changed or not.\n\nOPTIONS\n --root <dir> Directory the patterns resolve against. Without it,\n .spec-graph.json is looked for in the working\n directory and then upward as far as the repository,\n and the directory holding it becomes the root - so a\n run from a subdirectory reports what a run from the\n top reports. Paths typed on the command line stay\n relative to where they were typed. It has to be a\n directory that is there.\n --ignore <glob> Skip paths. Repeatable.\n --ignore-ref <glob> Do not report these reference targets when they fail\n to resolve, for repositories where [[...]] tags a\n concept rather than naming a file. Repeatable.\n Suppresses findings only, never edges.\n --family <name> Families a bare identifier in prose may name. When\n given, everything else stays prose. Repeatable: one\n name each time, the prefix its identifiers are\n written with, ADR for ADR-0007. A document here has\n to belong to one of them, or the check stops: a list\n that names none allows nothing.\n --ignore-family <name> Families that are never citations - RFC when the repo\n cites RFC 2119 and keeps its own RFCs. Repeatable,\n one name each time.\n --history <glob> Files that log what was decided rather than deciding\n it - journals, changelogs, minutes. Their links are\n still checked; their obligations are not. Repeatable.\n --baseline <file> Accept the findings recorded in this file and report\n only what is new since. The file has to be there: a\n path that reads nothing accepts nothing and says so\n nowhere. A \"baseline\" in the configuration may name a\n file not recorded yet; a path typed here may not.\n --record-baseline <f> Write today's findings to this file as accepted debt,\n and exit 0 without judging them.\n --ratchet Also fail when a baseline entry no longer occurs, so\n a paid-off exemption cannot outlive the defect.\n --no-config Ignore .spec-graph.json and the package.json key.\n --format <fmt> human, json, sarif, github, gitlab or markdown. json\n is for check, query or diff. sarif is the interchange\n format GitHub code scanning and editors already read,\n github the workflow commands a GitHub Actions log\n turns into annotations, and gitlab the Code Quality\n report a GitLab merge request reads, all three for\n check; markdown is a table for a pull-request comment\n or $GITHUB_STEP_SUMMARY, for check or diff (default:\n human)\n --graph-format <fmt> dot, mermaid or json (default: dot)\n --documents-only Leave items out of the exported graph\n --rule <id>=<severity> Override one rule: error, warn, info or off. A project\n rule is named in full: project:no-draft-dependency.\n Repeatable.\n --max <n> Show at most n findings (0 = no limit)\n --max-warnings <n> Fail when warnings exceed n (default: no limit)\n --strict Raise every warning to an error. An explicit --rule\n still wins, so --strict --rule x=warn exempts x.\n --color / --no-color Force colour on or off\n --ascii Use ASCII glyphs only. SPEC_GRAPH_ASCII asks for the\n same, unless it is empty, 0 or false\n --verbose Include parse problems, per-file detail, and every\n reference --ignore-ref or --ignore-family silenced\n --explain With rules: add each rule's selector and the ADR\n that decided it\n -h, --help Show this help\n -v, --version Show the version\n\n An option belongs to the commands that read it, and any other command\n refuses it by name:\n\n --root, --verbose check, query, graph, rules\n --ignore, --history check, query, graph\n --format check, query, diff\n --graph-format, --documents-only graph\n --explain rules\n every other option check\n\n --no-config, --no-color and --ascii are taken by every command: each is\n true already of a command with nothing to read it for.\n\n A value that begins with -- reads as an option, so the option before it is\n refused as missing its value. A name that does begin so is written ./--name\n for a file, [-]-name in a pattern and \\\\--name for a reference target.\n\nSELECTORS\n A selector is a path through the graph.\n\n item[openness=open] -delegates-to-> document[phase=retired]\n document[phase=active] -assumes-> document[phase=retired]\n document =supersedes=> document\n *[path^=docs/adr] -contains-> item[state=accepted-debt]\n\n Node types: document, item, * (any)\n Attributes: id, kind, title, path, file, line, phase, status, receptivity,\n alias, document, state (or disposition), openness, section,\n text, body, evidence, conflicted, fm.<front-matter-key>\n Operators: = != ^= $= *= ~= and [attr] for \"is present\"\n ~= is a regular expression, matched by an automaton that cannot\n backtrack: linear in the subject, whatever the pattern. It reads\n the usual syntax minus backreferences and lookaround, which are\n not regular - both are refused when the selector is read, with\n the character pointed at\n Relations: -kind-> <-kind- =kind=> <=kind= (= forms are transitive)\n\nEXIT CODES\n 0 clean\n 1 findings at error severity (or over --max-warnings)\n 2 the tool could not run\n\n An input that is set and names nothing is a 2, named on stderr, and never\n read as if it had not been given: an empty value, a family name no family\n has, a list of families no document here belongs to, a --root that is no\n directory, a second word after rules, an option of another command.\n\nCONFIGURATION\n Anything repeated on every run belongs in the repository rather than in the\n command. spec-graph reads the first of these that exists:\n\n .spec-graph.json, spec-graph.config.json, or a \"spec-graph\" key in\n package.json\n\n { \"patterns\": [\"docs/**/*.md\"],\n \"ignoreReferences\": [\"trap *\"],\n \"ignoreFamilies\": [\"RFC\"],\n \"historyPatterns\": [\"**/JOURNAL_*.md\", \"archive/**\"],\n \"baseline\": \".spec-graph-baseline.json\",\n \"severities\": { \"self-reference\": \"off\" },\n \"strict\": true,\n \"maxRelated\": 3 }\n\n A flag always wins over the file, and list flags add to it rather than\n replacing it. maxRelated has no flag: it caps how many related locations one\n finding lists, 8 unless set, and 0 lists none.\n\n A problem in that file stops the run with exit 2, named on stderr: invalid\n JSON, an unknown key, a rule that does not compile, a file that is there and\n cannot be read. A configuration that did not load checks a different\n repository than the one configured, and would report that one as consistent.\n --no-config runs on defaults instead.\n\nPROJECT RULES\n A convention spec-graph never anticipated is a selector plus a sentence, and\n belongs in the same file. Every rule declared here runs beside the built-ins\n and is reported, baselined, escalated by --strict and silenced by --rule in\n exactly the same way.\n\n { \"rules\": {\n \"no-draft-dependency\": {\n \"query\": \"document[phase=active] -depends-on-> document[phase=draft]\",\n \"message\": \"{0} depends on {1}, which is still a draft\",\n \"hint\": \"wait for {1} to be accepted, or drop it from {0.path}\",\n \"severity\": \"error\" } } }\n\n query One selector, or a list of them read as a union.\n message The headline. {0} is the first node on the path, {1} the next;\n {1.phase} and {0.fm.owner} read any selector attribute.\n hint The next action. Optional, and templated the same way.\n severity error, warn, info or off. Defaults to warn - a rule a team has\n just written has not yet earned the right to fail their build.\n\n The id is the name with project: in front, which is why it can never collide\n with a built-in. A selector that does not parse, or a {2} the query can never\n reach, is reported when the file is read rather than found missing later.\n\n To see what one matches without copying its selector out of the file:\n\n spec-graph query project:no-draft-dependency --verbose\n\nADOPTING THIS ON AN OLD REPOSITORY\n Record what is already wrong, then report only what happens next:\n\n spec-graph check --record-baseline .spec-graph-baseline.json\n git add .spec-graph-baseline.json\n\n The file is keyed by specification and citation, not by line number, so it\n survives edits, moves and renames. Findings that stop occurring are reported\n so the file can be tightened; nothing new gets in.\n\nEXAMPLES\n spec-graph \"docs/**/*.md\"\n spec-graph check --rule self-reference=off --format json\n spec-graph query 'item[openness=open] -delegates-to-> document[phase=retired]'\n spec-graph check --ignore-ref \"trap *\" # [[trap 55]] tags a concept, not a file\n spec-graph graph --documents-only --graph-format mermaid > graph.mmd\n spec-graph check --history \"**/JOURNAL_*.md\" # a log is not a specification\n spec-graph check --baseline .spec-graph-baseline.json\n spec-graph rules --explain # including this repository's own\n spec-graph rules ghost-handover --explain # and why it exists\n spec-graph check --rule project:no-draft-dependency=off\n spec-graph query project:no-draft-dependency # what does that rule match?\n spec-graph check --format markdown >> \"$GITHUB_STEP_SUMMARY\"\n spec-graph check --format github # annotations from an Actions log\n spec-graph check --format gitlab > gl-code-quality-report.json\n spec-graph diff base.json head.json --format markdown >> \"$GITHUB_STEP_SUMMARY\"\n`;\n\nconst SEVERITIES: readonly Severity[] = ['error', 'warn', 'info', 'off'];\n\n/**\n * The commands that read an option, or nothing for one every command takes.\n *\n * Any other command refuses the option, rather than run as if it were not\n * there: `query --strict` taking the flag and doing nothing with it would\n * tell someone their query was strict, `graph --record-baseline` wrote no\n * file and said so nowhere, and `spec-graph --graph-format mermaid`, the\n * command forgotten, wrote the check's report into what was meant to hold a\n * graph. The three options about citations are a check's alone: they pass\n * over findings and never an edge, so a graph or a query is the same with\n * them as without.\n *\n * `--no-color`, `--ascii` and `--no-config` are taken by every command.\n * Each is true already of what the commands that do not read it write - none\n * of them colours or draws a glyph, and `diff` reads no configuration - and\n * a script passes them to every command it runs. `--color` is not one of\n * them: it would promise colour that only a check prints.\n *\n * A function and not a table, so that none of it runs when the module loads:\n * a mutant of a table built at import pays for the whole suite (ADR-0007).\n */\nfunction readersOf(option: string): readonly Command[] | undefined {\n switch (option) {\n case '--root':\n case '--verbose':\n return ['check', 'query', 'graph', 'rules'];\n case '--ignore':\n case '--history':\n return ['check', 'query', 'graph'];\n case '--format':\n return ['check', 'query', 'diff'];\n case '--graph-format':\n case '--documents-only':\n return ['graph'];\n case '--explain':\n return ['rules'];\n case '--ignore-ref':\n case '--family':\n case '--ignore-family':\n case '--baseline':\n case '--record-baseline':\n case '--ratchet':\n case '--rule':\n case '--strict':\n case '--max':\n case '--max-warnings':\n case '--color':\n return ['check'];\n }\n return undefined;\n}\n\n/** `a`, `a or b`, `a, b or c`: one name or more in a sentence, with the word that joins the last. */\nfunction listed(names: readonly string[], joint: string): string {\n return names.length < 2 ? (names[0] as string) : `${names.slice(0, -1).join(', ')} ${joint} ${names[names.length - 1] as string}`;\n}\n\n/** Parses argv into options. Throws {@link UsageError} on anything malformed. */\nexport function parseArgs(argv: readonly string[], cwd: string): CliOptions {\n const args = [...argv];\n let command: Command = 'check';\n\n const first = args[0];\n if (first === 'check' || first === 'query' || first === 'graph' || first === 'rules' || first === 'diff') {\n command = first;\n args.shift();\n }\n\n const patterns: string[] = [];\n const ignore: string[] = [];\n const ignoreReferences: string[] = [];\n const families: string[] = [];\n const ignoreFamilies: string[] = [];\n const historyPatterns: string[] = [];\n let noConfig = false;\n const severities: Partial<Record<AnyRuleId, Severity>> = {};\n let root = cwd;\n let rootExplicit = false;\n let format: CliOptions['format'] = 'human';\n let graphFormat: GraphFormat = 'dot';\n let color: boolean | null = null;\n let ascii: boolean | null = null;\n let verbose = false;\n let documentsOnly = false;\n let max = 0;\n let maxWarnings = -1;\n let strict = false;\n let baseline: string | null = null;\n let ratchet = false;\n let recordBaseline: string | null = null;\n let selector: string | null = null;\n let help = false;\n let version = false;\n\n // In the order they were given, so the first that does not belong is the\n // one named. A set keeps that order, and starts from no literal: a list\n // seeded with a word no option is called would refuse nothing more, which\n // is a mutant no test can tell from the code.\n const given = new Set<string>();\n const next = (flag: string, index: number): string => {\n const value = args[index + 1];\n if (value === undefined) throw new UsageError(`${flag} needs a value`);\n // The option after one whose value was forgotten. Taken as the value,\n // `--ignore --strict` ignored a directory called `--strict` and the check\n // was not strict, and `--record-baseline --verbose` wrote a file of that\n // name. A name that does begin with two dashes has another spelling\n // wherever one can be meant: `./--x` for a file, `[-]-x` in a pattern,\n // `\\--x` for a reference target.\n if (value.startsWith('--') || value === '-h' || value === '-v') {\n throw new UsageError(`${flag} needs a value, and ${value} reads as an option`);\n }\n return value;\n };\n // A blank value is what an unset variable leaves in `--root \"$DIR\"`. A path\n // made of it names the directory beside it or a file called \" \", and the run\n // then answered for a place nobody named.\n const filled = (flag: string, index: number, what: string): string => {\n const value = next(flag, index);\n if (value.trim() === '') throw new UsageError(`${flag} expects ${what}, got \"${value}\"`);\n return value;\n };\n // A family is taken once per option. A blank, `ADR,RFC` or the option typed\n // after it is a name no family has: alone on the allowlist it left every\n // citation as prose, and the check passed over the ones that dangle.\n const family = (flag: string, index: number): string => {\n const value = next(flag, index);\n if (!isFamilyName(value)) throw new UsageError(`${flag} expects one family's name, such as ADR, got \"${value}\"`);\n return value;\n };\n\n for (let i = 0; i < args.length; i += 1) {\n const arg = args[i] as string;\n\n if (arg === '--') {\n patterns.push(...args.slice(i + 1));\n break;\n }\n\n if (!arg.startsWith('-')) {\n if (command === 'query' && selector === null) selector = arg;\n else patterns.push(arg);\n continue;\n }\n\n given.add(arg);\n switch (arg) {\n case '-h':\n case '--help':\n help = true;\n break;\n case '-v':\n case '--version':\n version = true;\n break;\n case '--verbose':\n verbose = true;\n break;\n case '--color':\n color = true;\n break;\n case '--no-color':\n color = false;\n break;\n case '--ascii':\n ascii = true;\n break;\n case '--documents-only':\n documentsOnly = true;\n break;\n case '--strict':\n strict = true;\n break;\n case '--ratchet':\n ratchet = true;\n break;\n case '--explain':\n verbose = true;\n break;\n case '--root':\n root = filled(arg, i, 'a directory');\n rootExplicit = true;\n i += 1;\n break;\n case '--ignore':\n ignore.push(next(arg, i));\n i += 1;\n break;\n case '--ignore-ref':\n ignoreReferences.push(next(arg, i));\n i += 1;\n break;\n case '--family':\n families.push(family(arg, i));\n i += 1;\n break;\n case '--ignore-family':\n ignoreFamilies.push(family(arg, i));\n i += 1;\n break;\n case '--history':\n historyPatterns.push(next(arg, i));\n i += 1;\n break;\n case '--baseline':\n baseline = filled(arg, i, 'a file');\n i += 1;\n break;\n case '--record-baseline':\n recordBaseline = filled(arg, i, 'a file');\n i += 1;\n break;\n case '--no-config':\n noConfig = true;\n break;\n case '--format': {\n const value = next(arg, i);\n if (\n value !== 'human' &&\n value !== 'json' &&\n value !== 'sarif' &&\n value !== 'markdown' &&\n value !== 'gitlab' &&\n value !== 'github'\n ) {\n throw new UsageError(`--format must be human, json, sarif, markdown, gitlab or github, got \"${value}\"`);\n }\n format = value;\n i += 1;\n break;\n }\n case '--graph-format': {\n const value = next(arg, i);\n if (value !== 'dot' && value !== 'mermaid' && value !== 'json') {\n throw new UsageError(`--graph-format must be dot, mermaid or json, got \"${value}\"`);\n }\n graphFormat = value;\n i += 1;\n break;\n }\n case '--rule': {\n const value = next(arg, i);\n const equals = value.indexOf('=');\n if (equals === -1) throw new UsageError(`--rule expects <id>=<severity>, got \"${value}\"`);\n const id = value.slice(0, equals) as AnyRuleId;\n const level = value.slice(equals + 1) as Severity;\n // A project rule is taken on its namespace here and checked for real\n // once the configuration defining it has been read: arguments are\n // parsed before any file is opened, and a flag has to be usable on that\n // first pass whatever the repository turns out to declare.\n if (!RULE_IDS.includes(id as RuleId) && !isProjectRule(id)) {\n throw new UsageError(`unknown rule \"${id}\"\\n known rules: ${RULE_IDS.join(', ')}`);\n }\n if (!SEVERITIES.includes(level)) {\n throw new UsageError(`unknown severity \"${level}\", expected one of: ${SEVERITIES.join(', ')}`);\n }\n severities[id] = level;\n i += 1;\n break;\n }\n case '--max': {\n max = parseCount(arg, next(arg, i));\n i += 1;\n break;\n }\n case '--max-warnings': {\n maxWarnings = parseCount(arg, next(arg, i));\n i += 1;\n break;\n }\n default:\n throw new UsageError(`unknown option \"${arg}\"\\n run \"spec-graph --help\" to see the available options`);\n }\n }\n\n // SARIF, GitHub's workflow commands and GitLab's Code Quality are reports\n // about findings, and only `check` produces those. Falling back to JSON would\n // hand a pipeline something its uploader rejects with a message about a\n // schema rather than about the command that was run. Markdown is for a pull\n // request, which reads a check or a diff.\n if ((format === 'sarif' || format === 'gitlab' || format === 'github') && command !== 'check' && !help && !version) {\n throw new UsageError(`--format ${format} reports findings, so it belongs to check, not to ${command}`);\n }\n if (format === 'markdown' && command !== 'check' && command !== 'diff' && !help && !version) {\n throw new UsageError(`--format markdown is a report for a pull request, so it belongs to check or diff, not to ${command}`);\n }\n\n // JSON is refused where the other reports are, and for the reason above:\n // `graph --format json` wrote DOT and `rules --format json` a list, each\n // with exit 0, to whatever was waiting for JSON.\n if (format === 'json' && (command === 'graph' || command === 'rules') && !help && !version) {\n const instead = command === 'graph' ? 'graph writes JSON with --graph-format json' : 'rules lists the rules as text';\n throw new UsageError(`--format json belongs to check, query or diff, not to ${command}: ${instead}`);\n }\n\n if (!help && !version) {\n for (const option of given) {\n const readers = readersOf(option);\n if (readers !== undefined && !readers.includes(command)) {\n throw new UsageError(`${option} belongs to ${listed(readers, 'or')}, not to ${command}`);\n }\n }\n }\n\n // The second word given to `rules` was dropped, so `rules a b` listed `a`\n // and said nothing of `b`.\n if (command === 'rules' && patterns.length > 1 && !help && !version) {\n throw new UsageError(`rules takes one rule id, got ${patterns.length}: ${patterns.join(', ')}`);\n }\n\n if (command === 'diff' && patterns.length !== 2 && !help && !version) {\n throw new UsageError(\n 'diff compares two graph exports, for example:\\n spec-graph diff base.json head.json\\n (make each with spec-graph graph --graph-format json)',\n );\n }\n\n // An empty name resolved to the directory the run was started in, and the\n // refusal was the read's: `cannot read : EISDIR`.\n const blank = patterns.findIndex((path) => path.trim() === '');\n if (command === 'diff' && blank !== -1 && !help && !version) {\n throw new UsageError(`diff expects a graph export on each side, got \"${patterns[blank] as string}\" for the ${blank === 0 ? 'first' : 'second'}`);\n }\n\n if (command === 'query' && selector === null && !help && !version) {\n throw new UsageError('query needs a selector, for example:\\n spec-graph query \\'item[openness=open]\\'');\n }\n\n return {\n command,\n patterns,\n root,\n rootExplicit,\n ignore,\n ignoreReferences,\n families,\n ignoreFamilies,\n historyPatterns,\n baseline,\n ratchet,\n recordBaseline,\n noConfig,\n format,\n graphFormat,\n severities,\n color,\n ascii,\n verbose,\n documentsOnly,\n max,\n maxWarnings,\n strict,\n selector,\n help,\n version,\n };\n}\n\nfunction count(n: number, word: string, many?: string): string {\n return `${n} ${n === 1 ? word : (many ?? `${word}s`)}`;\n}\n\ninterface HeldBaseline {\n readonly baseline: Baseline;\n readonly problems: readonly string[];\n /** What stopped the file being read, when something did. */\n readonly unread: { readonly missing: boolean; readonly message: string } | null;\n}\n\n/**\n * Reads a baseline file.\n *\n * Absent and unreadable are different answers, and the caller needs both. A\n * repository that has not recorded a baseline yet declares the path before the\n * file exists, and an empty baseline accepts nothing, which is what that run\n * should report (ADR-0012). Anything else - a directory, a permission, a path\n * that went somewhere unintended - is the tool failing to do what it was told.\n */\nasync function readBaseline(path: string, source: string): Promise<HeldBaseline> {\n let raw: string;\n try {\n const { readFile } = await import('node:fs/promises');\n raw = await readFile(path, 'utf8');\n } catch (error) {\n const failure = error as Error & { code?: string };\n return {\n baseline: EMPTY_BASELINE,\n problems: [],\n unread: { missing: failure.code === 'ENOENT', message: failure.message },\n };\n }\n return { ...parseBaseline(raw, source), unread: null };\n}\n\nfunction parseCount(flag: string, value: string): number {\n const parsed = Number.parseInt(value, 10);\n if (!Number.isFinite(parsed) || parsed < 0 || String(parsed) !== value.trim()) {\n throw new UsageError(`${flag} expects a non-negative whole number, got \"${value}\"`);\n }\n return parsed;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Entry point */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Runs the CLI and returns the process exit code. Never throws.\n *\n * An error nothing below expected is neither a finding nor a usage mistake:\n * the answer cannot be trusted, which is the family contract's 2 (spec-core's\n * ADR-0005). Rejected instead, it reached the launcher as Node's uncaught\n * error, exit 1, which CI reads as findings. The stack is what makes a report\n * of it something to act on, and it goes to stderr alone: a script that reads\n * a document from stdout is handed no part of one.\n *\n * A write its reader had closed the pipe for is not such an error: the answer\n * was not delivered, which is still 2, and nothing in spec-graph is at fault,\n * so it is said in a line and no stack sends a person looking for a defect.\n * The process's own streams report it as an event, which the launcher answers\n * in the same words; here it is a caller's stream that throws it. It is read\n * by its code: stdout and stderr are the only pipes spec-graph writes to.\n */\nexport async function main(io: CliIO = {}): Promise<number> {\n const err = io.stderr ?? ((text) => process.stderr.write(text));\n try {\n return await run(io, err);\n } catch (error) {\n if (!(error instanceof Error)) err(`spec-graph: unexpected error: ${String(error)}\\n`);\n else if ((error as { code?: unknown }).code === 'EPIPE') err('spec-graph: stdout was closed before all of the output was written\\n');\n else err(`spec-graph: unexpected error: ${error.stack ?? error.message}\\n`);\n return EXIT_ERROR;\n }\n}\n\n/** One run of the command line, which rejects on an error it did not expect. */\nasync function run(io: CliIO, err: (text: string) => void): Promise<number> {\n const argv = io.argv ?? process.argv.slice(2);\n const cwd = io.cwd ?? process.cwd();\n const out = io.stdout ?? ((text) => process.stdout.write(text));\n const env = io.env ?? process.env;\n\n let options: CliOptions;\n try {\n options = parseArgs(argv, cwd);\n } catch (error) {\n // parseArgs throws nothing but a UsageError for any argv, so no test can\n // tell this check from `true`: the rethrow is for a bug in the parser.\n if (error instanceof UsageError) {\n err(`spec-graph: ${error.message}\\n`);\n return EXIT_ERROR;\n }\n throw error;\n }\n\n if (options.help) {\n out(HELP);\n return EXIT_OK;\n }\n if (options.version) {\n out(`${await readVersion()}\\n`);\n return EXIT_OK;\n }\n\n // A diff reads two files and nothing else: no configuration and no corpus, so\n // it can compare exports from a checkout it is not running in.\n if (options.command === 'diff') return runDiff(options.patterns as readonly [string, string], cwd, options.format, out, err);\n\n // A root that was named is a directory, for every command that reads one.\n // `rules --root` with a path that is not there listed the built-in rules and\n // exited 0, as if the repository declared none, and the others said only\n // that no specification matched under it.\n if (options.rootExplicit) {\n const { stat } = await import('node:fs/promises');\n // A path that cannot be reached reads as one that is not there: either\n // way there is nothing under it to read.\n const found = await stat(options.root).catch(() => null);\n if (found === null || !found.isDirectory()) {\n err(`spec-graph: --root \"${options.root}\" is not ${found === null ? 'there' : 'a directory'}\\n`);\n return EXIT_ERROR;\n }\n }\n\n const color = options.color ?? shouldUseColor({ isTTY: io.isTTY, env });\n const ascii = options.ascii ?? shouldUseAscii({ env });\n\n // Configuration is what is true of the repository; a flag is somebody\n // overriding it for one run. So a flag always wins, and lists add rather than\n // replace - a `--ignore-ref` on the command line is one more exclusion, not a\n // decision to throw away the ones the repository already declared.\n //\n // Read before `rules` prints anything, so that command lists the conventions\n // this repository will actually check rather than the ones spec-graph ships.\n const loaded = options.noConfig\n ? { config: {} as SpecGraphConfig, source: null, problems: [], root: options.root }\n : options.rootExplicit\n ? { ...loadConfig(options.root), root: options.root }\n : discoverConfig(options.root);\n for (const problem of loaded.problems) err(`spec-graph: ${problem}\\n`);\n // A configuration that did not load means a run against a different\n // repository than the one configured - other patterns, other rules, other\n // severities - and the verdict printed is about that one. Reporting the\n // problem and carrying on gave a green build with `ok: true` from a file with\n // a typo in it, which is the one answer a checker must never reach by\n // accident, and the same mistake in a `--rule` has always exited 2. The\n // findings are one flag away, and the flag is named. Amends ADR-0010.\n if (loaded.problems.length > 0) {\n err(\n `spec-graph: ${count(loaded.problems.length, 'problem')} in the configuration, so nothing was checked\\n fix it, or run again with --no-config to check on defaults\\n`,\n );\n return EXIT_ERROR;\n }\n const file = loaded.config;\n const projectRules = file.rules ?? [];\n const root = loaded.root;\n // How far the root moved up. Everything a repository declares about itself is\n // relative to the root; everything typed on the command line is relative to\n // where it was typed, and this is what keeps those two readings apart.\n const here = below(root, options.root);\n\n // A `--rule` naming a project rule that does not exist is a flag that\n // silently does nothing, and nothing in the output would distinguish that\n // from a rule that ran and found none.\n for (const id of Object.keys(options.severities)) {\n if (!isProjectRule(id as AnyRuleId) || projectRules.some((rule) => rule.id === id)) continue;\n err(`spec-graph: unknown rule \"${id}\"\\n ${knownProjectRules(projectRules)}\\n`);\n return EXIT_ERROR;\n }\n\n if (options.command === 'rules') {\n // The one positional argument `rules` can take is a rule id: this command\n // reads no files, so a pattern here would be a word with nowhere to go.\n const wanted = options.patterns[0];\n if (wanted !== undefined && !RULE_IDS.includes(wanted as RuleId) && !projectRules.some((rule) => rule.id === wanted)) {\n err(\n `spec-graph: unknown rule \"${wanted}\"\\n known rules: ${RULE_IDS.join(', ')}\\n ${knownProjectRules(projectRules)}\\n`,\n );\n return EXIT_ERROR;\n }\n out(renderRules(options.verbose, await readVersion(), projectRules, wanted ?? null, loaded.source));\n return EXIT_OK;\n }\n\n // Named the way the reader would have to type it, because a discovered\n // configuration is often not the one in front of them.\n //\n // On stderr, with everything else this run says about itself. stdout is the\n // report, and in three of the four formats it is a document: a line above it\n // made `--verbose --format json` unparseable and handed `--format sarif` to a\n // code-scanning uploader that rejects it over a schema.\n if (options.verbose && loaded.source !== null) err(`configuration: ${fromHere(here, loaded.source)}\\n`);\n\n // A bare `--ignore` name prunes a directory of that name at any depth, the\n // way a .gitignore line does, so it means the same thing wherever it was\n // typed. Every other pattern is matched against the repository-relative\n // path, a bare `--history` name included, and leaving one alone would make\n // it silently match something else or nothing. A pattern that cannot be\n // rebased onto the root stops the run as one the dialect refuses does,\n // named as it was typed.\n let typed;\n try {\n typed = {\n patterns: options.patterns.map((pattern) => anchor(here, pattern)),\n ignore: options.ignore.map((pattern) => anchorPath(here, pattern)),\n history: options.historyPatterns.map((pattern) => anchor(here, pattern)),\n };\n } catch (error) {\n err(`spec-graph: ${(error as Error).message}\\n`);\n return EXIT_ERROR;\n }\n const patterns = typed.patterns.length > 0 ? typed.patterns : (file.patterns ?? DEFAULT_PATTERNS);\n const severityOverrides = { ...(file.severities ?? {}), ...options.severities };\n const { severities, escalated } = resolveStrict(\n severityOverrides,\n options.strict || (file.strict ?? false),\n projectRules,\n );\n\n // The list the check is held against, once it has read the documents.\n const families = [...(file.families ?? []), ...options.families];\n const analyseOptions: AnalyseOptions = {\n root,\n patterns,\n // A stray entry in one of the empty fallbacks here changes a run only if\n // it matches a path or a target some corpus has, so the mutants that plant\n // one survive every corpus but one built for them - except in the two\n // lists of families, where what they plant is no family's name and is\n // refused.\n ignore: [...(file.ignore ?? []), ...typed.ignore],\n ignoreReferences: [...(file.ignoreReferences ?? []), ...options.ignoreReferences],\n families,\n ignoreFamilies: [...(file.ignoreFamilies ?? []), ...options.ignoreFamilies],\n historyPatterns: [...(file.historyPatterns ?? []), ...typed.history],\n severities,\n projectRules,\n maxRelated: file.maxRelated,\n };\n\n let result;\n try {\n result = await analyse(analyseOptions);\n } catch (error) {\n err(`spec-graph: ${(error as Error).message}\\n`);\n return EXIT_ERROR;\n }\n\n if (result.files.length === 0) {\n err(\n `spec-graph: no specifications matched ${\n patterns.map((p) => `\"${p}\"`).join(', ')\n }\\n looked under ${root}\\n`,\n );\n return EXIT_ERROR;\n }\n\n switch (options.command) {\n case 'graph':\n out(\n formatGraph(result.graph, options.graphFormat, {\n documentsOnly: options.documentsOnly,\n generator: { name: 'spec-graph', version: await readVersion() },\n }),\n );\n return EXIT_OK;\n\n case 'query': {\n const selector = options.selector as string;\n let queries: readonly QuerySpec[];\n\n // A registered rule is asked for by name, because by the time this runs\n // it is already compiled and the alternative is copying its selector out\n // of the configuration file by hand. The namespace cannot collide with\n // the grammar: no selector begins with a word and a colon. See ADR-0016.\n if (isProjectRule(selector as AnyRuleId)) {\n const rule = projectRules.find((candidate) => candidate.id === selector);\n if (rule === undefined) {\n err(`spec-graph: unknown rule \"${selector}\"\\n ${knownProjectRules(projectRules)}\\n`);\n return EXIT_ERROR;\n }\n queries = rule.queries;\n // Beside the report rather than inside it, for the reason the\n // configuration line above is: `--format json` is a document.\n if (options.verbose) for (const source of rule.sources) err(`${rule.id}: ${source}\\n`);\n } else {\n try {\n queries = [parseQuery(selector)];\n } catch (error) {\n // Every selector that fails to parse fails as a QueryError, so no\n // test can tell this check from `true`.\n if (error instanceof QueryError) {\n err(renderQueryError(selector, error));\n return EXIT_ERROR;\n }\n throw error;\n }\n }\n\n const matches = union(result.graph, queries);\n // renderMatches asks only whether this is 'json', so the other word is a\n // name for the reader and emptying it changes nothing.\n out(renderMatches(matches, options.format === 'json' ? 'json' : 'human', result.graph.nodes.size));\n return matches.length > 0 ? EXIT_OK : EXIT_FAILED;\n }\n\n default: {\n // An allowlist is held against the corpus it was written for. One that\n // names no family a document here belongs to allows nothing the corpus\n // has: every citation is then prose, and the run that failed on a\n // dangling one reported a consistent graph - for `--family ADRS` as it\n // did for `--family \"\"`. Nothing was measured, which is not clean\n // (spec-core's ADR-0005), so the run stops before it says anything. A\n // list that names such a family beside one the corpus has is a family\n // the repository means to start, or a typo in half of it: said, and\n // nothing fails.\n const allowed = [...new Set(families.map((family) => family.trim().toUpperCase()))];\n const absent = allowed.filter((family) => !result.corpus.families.includes(family));\n if (absent.length > 0) {\n const lists: string[] = [];\n if (options.families.length > 0) lists.push('--family');\n if (file.families !== undefined && file.families.length > 0) lists.push(`\"families\" in ${loaded.source}`);\n const here = `the documents here belong to ${result.corpus.families.length > 0 ? listed(result.corpus.families, 'and') : 'no family'}`;\n if (absent.length === allowed.length) {\n err(\n `spec-graph: no document here belongs to a family named by ${lists.join(' and ')} (${allowed.join(', ')}); ${here}\\n name a family the documents belong to, or leave the list out\\n`,\n );\n return EXIT_ERROR;\n }\n err(`spec-graph: no document here belongs to ${listed(absent, 'or')}, named by ${lists.join(' and ')}; ${here}\\n`);\n }\n\n // Recording is not checking. It writes down what is wrong today so that\n // tomorrow can be compared against it, and says nothing about whether\n // today is acceptable - so it reports what it wrote and exits clean.\n if (options.recordBaseline !== null) {\n const text = formatBaseline(result.graph, result.diagnostics);\n try {\n const { writeFile } = await import('node:fs/promises');\n // Node writes a string as UTF-8 when the encoding is empty too, so\n // emptying this literal writes the same bytes.\n await writeFile(underRoot(root, anchorFile(here, options.recordBaseline)), text, 'utf8');\n } catch (error) {\n err(`spec-graph: cannot write ${options.recordBaseline}: ${(error as Error).message}\\n`);\n return EXIT_ERROR;\n }\n const entries = (JSON.parse(text) as Baseline).findings.length;\n out(\n `recorded ${count(result.diagnostics.length, 'finding')} as ${count(entries, 'entry', 'entries')} in ${options.recordBaseline}\\n`,\n );\n return EXIT_OK;\n }\n\n const source = options.baseline === null ? (file.baseline ?? null) : anchorFile(here, options.baseline);\n const ratchet = options.ratchet || file.ratchet === true;\n let reported = result;\n let note:\n | {\n source: string;\n suppressed: number;\n stale: number;\n ratchet: boolean;\n entries: readonly StaleEntry[];\n }\n | undefined;\n let recordAs: string | undefined;\n if (source !== null) {\n const held = await readBaseline(underRoot(root, source), source);\n // A path typed on the command line says the file is there for this run.\n // Read as an empty baseline instead, a typo in it reports every accepted\n // finding as new, and passes --ratchet with nothing left to be stale.\n // A path in the configuration is the case ADR-0012 argued for, and only\n // where the file is absent: unreadable is unreadable wherever the path\n // was written.\n if (held.unread !== null && (options.baseline !== null || !held.unread.missing)) {\n err(`spec-graph: cannot read the baseline ${source}: ${held.unread.message}\\n`);\n return EXIT_ERROR;\n }\n // Quiet by default, because a configured path legitimately precedes the\n // first --record-baseline. Under --verbose, where parse problems already\n // go, a path that reads nothing says so rather than accepting nothing.\n if (held.unread !== null && options.verbose) {\n err(`spec-graph: baseline ${source} is not there, so nothing is accepted\\n`);\n }\n for (const problem of held.problems) err(`spec-graph: ${problem}\\n`);\n const outcome = applyBaseline(result.graph, result.diagnostics, held.baseline);\n reported = withDiagnostics(result, outcome.kept);\n note = {\n source,\n suppressed: outcome.suppressed,\n stale: outcome.stale.length,\n ratchet,\n entries: outcome.stale,\n };\n // The command that re-records it is typed where this run was: a path\n // typed on this command line is relative to there already, and the\n // configuration's is from the root.\n recordAs = options.baseline ?? fromHere(here, source);\n // Listed rather than counted when the run turns on them: a number is\n // enough to know the file has slack, and not enough to strike it. On\n // stdout only for a human - the structured formats carry the same rows\n // inside the document, where a stray line is the difference between\n // parsing and not.\n if (options.format === 'human' && (options.verbose || ratchet)) {\n for (const entry of outcome.stale) {\n const subject = entry.subject === '' ? '' : ` \"${entry.subject}\"`;\n const why = entry.reason === 'gone' ? ` - ${entry.document} is not in this corpus` : '';\n out(` ${entry.reason}: ${entry.rule} ${entry.document}${subject}${why}\\n`);\n }\n }\n }\n const looseBaseline = note !== undefined && note.ratchet && note.stale > 0;\n\n const reporterOptions = { verbose: options.verbose, max: options.max, escalated, baseline: note, recordAs };\n out(\n options.format === 'sarif'\n ? formatSarif(reported, reported.graph, { version: await readVersion(), escalated, projectRules })\n : options.format === 'gitlab'\n ? formatGitlab(reported, { escalated })\n : options.format === 'github'\n ? formatGithub(reported, { escalated })\n : options.format === 'json'\n ? formatJson(reported, { escalated, baseline: note })\n : options.format === 'markdown'\n ? formatMarkdown(reported, reporterOptions)\n : `${formatReport(reported, { color, ascii, ...reporterOptions })}\\n`,\n );\n if (!reported.ok || looseBaseline) return EXIT_FAILED;\n if (options.maxWarnings >= 0 && reported.summary.warnings > options.maxWarnings) return EXIT_FAILED;\n return EXIT_OK;\n }\n }\n}\n\n/* -------------------------------------------------------------------------- */\n/* Rendering */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Where the working directory sits below the root, or `''` when it is the root.\n *\n * Discovery only ever walks upward, so the root is always a prefix of the\n * directory the command was typed in, and this is a slice rather than path\n * arithmetic.\n */\nfunction below(root: string, from: string): string {\n const start = toPosix(from).replace(/[/]+$/, '');\n // The prefix test only guards a root that is neither `start` nor above it,\n // which nothing returns; for `start` itself, slicing past its end is `''`\n // too, so emptying the prefix changes nothing a run can reach.\n return start.startsWith(`${root}/`) ? start.slice(root.length + 1) : '';\n}\n\n/**\n * A path from the root, as it is typed in `here`: one `../` for each directory\n * `here` is below the root. An absolute path reads the same from anywhere.\n */\nfunction fromHere(here: string, path: string): string {\n return here === '' || isAbsolutePath(path) ? path : `${'../'.repeat(here.split('/').length)}${path}`;\n}\n\n/**\n * Re-anchors a pattern typed in `prefix` so it reads from the root, brace\n * alternative by brace alternative, or throws naming it as typed.\n *\n * `../docs` typed one directory down is the root's `docs`. That is arithmetic\n * on two relative paths, and this is the one place both are known; left in the\n * pattern, it reads as a glob climbing out of the root, which is refused.\n *\n * An absolute path is left alone: it was not relative to anywhere, so moving\n * the root cannot change what it means. spec-core roots a leading `/` and\n * knows no drive letter, so `C:/docs` is told apart here.\n */\nfunction anchor(prefix: string, pattern: string): string {\n return isAbsolutePath(pattern) ? pattern : rebasePattern(pattern, prefix);\n}\n\n/**\n * The same, for an `--ignore`, where a bare name is a directory at any depth.\n * Only the walk reads a name that way; a `--history` pattern is matched as a\n * whole path, and goes to {@link anchor}.\n */\nfunction anchorPath(prefix: string, pattern: string): string {\n return isGlob(pattern) || pattern.includes('/') ? anchor(prefix, pattern) : pattern;\n}\n\n/**\n * Re-anchors a file typed in `prefix`, a baseline, so it reads from the root.\n *\n * A file name is not a pattern: a brace or a `!` in it is a character, which\n * {@link anchor} would read as syntax, and a baseline outside the repository\n * is as good as one inside, so a `..` past the root is a path like any other.\n * At the root the file is named as it was typed.\n */\nfunction anchorFile(prefix: string, file: string): string {\n return prefix === '' || isAbsolutePath(file) ? file : joinPosix(prefix, toPosix(file));\n}\n\nfunction knownProjectRules(projectRules: readonly ProjectRule[]): string {\n const known = projectRules.map((rule) => rule.id);\n return known.length > 0 ? `project rules here: ${known.join(', ')}` : 'this repository defines no project rules';\n}\n\n/**\n * Runs a list of selectors as one result set.\n *\n * A project rule is a union of its selectors, and a path that two of them both\n * find is one path - the same dedupe `projectFindings` does, so that asking\n * this command what a rule matches answers with the set `check` reports on.\n */\nfunction union(graph: AnalysisResult['graph'], queries: readonly QuerySpec[]): Match[] {\n // `execute` already returns each path of nodes once, keyed the way this is,\n // so one selector needs no second pass and sending it through one anyway\n // returns the same matches.\n if (queries.length === 1) return execute(graph, queries[0] as QuerySpec);\n const seen = new Set<string>();\n const matches: Match[] = [];\n for (const spec of queries) {\n for (const match of execute(graph, spec)) {\n const key = match.nodes.map((node) => node.id).join('>');\n if (seen.has(key)) continue;\n seen.add(key);\n matches.push(match);\n }\n }\n return matches;\n}\n\ninterface RuleRow {\n readonly id: string;\n readonly severity: Severity;\n readonly description: string;\n /** The selector, where the rule is one. */\n readonly query: string | undefined;\n /** Where the reasoning is: an ADR, or the file that declared the rule. */\n readonly decided: string;\n}\n\nfunction renderRules(\n explain: boolean,\n version: string,\n projectRules: readonly ProjectRule[],\n only: string | null,\n configSource: string | null,\n): string {\n // A project rule is described by the selector it is, because that is what it\n // is - its message is a template, and a template is not a description.\n const rows: RuleRow[] = [\n ...RULE_IDS.map((id): RuleRow => ({\n id,\n severity: DEFAULT_SEVERITIES[id],\n description: RULE_DESCRIPTIONS[id],\n query: RULE_QUERIES[id],\n decided: decisionUrl(RULE_DECISIONS[id], version),\n })),\n ...projectRules.map((rule): RuleRow => ({\n id: rule.id,\n severity: rule.severity,\n description: rule.sources[0] as string,\n query: rule.sources.slice(1).join(' | ') || undefined,\n // A project rule only exists because a file declared it, so the source\n // is never null here and the first branch is for the type alone.\n decided: configSource === null ? `rules.${rule.name}` : `${configSource}: rules.${rule.name}`,\n })),\n ];\n\n const shown = only === null ? rows : rows.filter((row) => row.id === only);\n const width = Math.max(...shown.map((row) => row.id.length));\n const lines: string[] = [];\n for (const row of shown) {\n lines.push(`${row.id.padEnd(width)} ${row.severity.padEnd(5)} ${row.description}`);\n if (!explain) continue;\n if (row.query) lines.push(`${' '.repeat(width)} ${row.query}`);\n // Where the decision is written down, rather than a second copy of it. A\n // reader who has just been told their document is inconsistent is entitled\n // to know who decided that and why, and the ADR is the answer.\n lines.push(`${' '.repeat(width)} ${row.decided}`);\n }\n return `${lines.join('\\n')}\\n`;\n}\n\nfunction renderMatches(matches: readonly Match[], format: 'human' | 'json', total: number): string {\n if (format === 'json') {\n return `${JSON.stringify(\n {\n version: 1,\n count: matches.length,\n matches: matches.map((match) => ({\n nodes: match.nodes.map((node) => nodeSummary(node)),\n edges: match.edges.map((edge) => ({\n kind: edge.kind,\n from: edge.from,\n to: edge.to,\n file: edge.declaredAt.file,\n line: edge.declaredAt.span.start.line,\n })),\n })),\n },\n null,\n 2,\n )}\\n`;\n }\n\n if (matches.length === 0) return `no matches (searched ${total} nodes)\\n`;\n\n const lines: string[] = [];\n for (const match of matches) {\n const head = match.nodes[0] as SpecNode;\n const tail = match.nodes[match.nodes.length - 1] as SpecNode;\n lines.push(renderMatch(match));\n lines.push(` ${formatRef(head.at)}${match.nodes.length > 1 ? ` ${formatRef(tail.at)}` : ''}`);\n }\n lines.push(`${matches.length} ${matches.length === 1 ? 'match' : 'matches'}`);\n return `${lines.join('\\n')}\\n`;\n}\n\nfunction nodeSummary(node: SpecNode): Record<string, unknown> {\n return {\n id: node.id,\n kind: node.kind,\n title: node.title,\n file: node.at.file,\n line: node.at.span.start.line,\n ...(node.kind === 'document' ? { phase: node.phase } : { state: node.disposition, openness: node.openness }),\n };\n}\n\n/**\n * Points at the exact character of a selector that failed to parse, in the\n * columns a terminal draws: a Han character before it takes two, so an offset\n * counted in UTF-16 units put the caret short of it. The offset is a position\n * the parser reached, never negative, so it needs no floor.\n */\nfunction renderQueryError(selector: string, error: QueryError): string {\n const caret = `${' '.repeat(displayWidth(selector.slice(0, error.offset)))}^`;\n return `spec-graph: ${error.message}\\n ${selector}\\n ${caret}\\n`;\n}\n\n/**\n * Compares two exports.\n *\n * Exit 0 whether anything changed or not: a diff describes, and `check` gates. A\n * diff that failed on a removed relation would fail every legitimate\n * supersession (ADR-0020).\n */\nasync function runDiff(\n paths: readonly [string, string],\n cwd: string,\n format: CliOptions['format'],\n out: (text: string) => void,\n err: (text: string) => void,\n): Promise<number> {\n const { readFile } = await import('node:fs/promises');\n const { resolve } = await import('node:path');\n const sides: GraphExport[] = [];\n for (const path of paths) {\n let raw: string;\n try {\n // Without the encoding this is a Buffer, which JSON.parse decodes as\n // UTF-8 all the same - so emptying the literal parses the same export.\n raw = await readFile(resolve(cwd, path), 'utf8');\n } catch (error) {\n err(`spec-graph: cannot read ${path}: ${(error as Error).message}\\n`);\n return EXIT_ERROR;\n }\n try {\n sides.push(parseGraphExport(raw, path));\n } catch (error) {\n // Every input parseGraphExport refuses, it refuses as a DiffInputError;\n // the rethrow is for a bug in it, which no file reaches.\n if (!(error instanceof DiffInputError)) throw error;\n err(`spec-graph: ${error.message}\\n`);\n return EXIT_ERROR;\n }\n }\n const [before, after] = sides as [GraphExport, GraphExport];\n const diff = diffExports(before, after);\n out(format === 'json' ? formatDiffJson(diff) : format === 'markdown' ? formatDiffMarkdown(diff) : formatDiffText(diff));\n return EXIT_OK;\n}\n\n/**\n * The version in the package's own manifest.\n *\n * The guards and the placeholder are for a manifest that is missing or\n * malformed, and the one this reads always parses and always has a version, so\n * no test reaches them without replacing the file the package ships - and the\n * same parse without the encoding reads a Buffer, which JSON.parse decodes as\n * UTF-8 all the same.\n */\nasync function readVersion(): Promise<string> {\n try {\n const { readFile } = await import('node:fs/promises');\n const url = new URL('../package.json', import.meta.url);\n const parsed: unknown = JSON.parse(await readFile(url, 'utf8'));\n if (typeof parsed === 'object' && parsed !== null && 'version' in parsed) {\n return String((parsed as { version: unknown }).version);\n }\n } catch {\n // Fall through to the placeholder rather than failing `--version`.\n }\n return '0.0.0';\n}\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,aAAa,EACb,cAAc,EACd,cAAc,EACd,aAAa,GAGd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,UAAU,EAAwB,MAAM,aAAa,CAAC;AAC/E,OAAO,EACL,cAAc,EACd,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,gBAAgB,GAEjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAA4C,MAAM,aAAa,CAAC;AACnH,OAAO,EACL,YAAY,EACZ,YAAY,EACZ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MAAM,CAAC;QACP,mEAAmE;IACrE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/**\n * The command line.\n *\n * Five verbs, because there are five questions worth asking of a specification\n * graph: is it consistent (`check`), what does it contain (`query`), what does\n * it look like (`graph`), what will you check for me (`rules`), and what did a\n * change do to it (`diff`).\n *\n * Exit codes are the contract with CI: `0` clean, `1` findings, `2` the tool\n * itself could not run. A usage mistake never masquerades as a passing build,\n * and an error nothing here expected never as findings.\n */\n\nimport {\n applyBaseline,\n EMPTY_BASELINE,\n formatBaseline,\n parseBaseline,\n type Baseline,\n type StaleEntry,\n} from './baseline.js';\nimport { discoverConfig, loadConfig, type SpecGraphConfig } from './config.js';\nimport {\n DiffInputError,\n diffExports,\n formatDiffJson,\n formatDiffMarkdown,\n formatDiffText,\n parseGraphExport,\n type GraphExport,\n} from './diff.js';\nimport { isGlob, rebasePattern, underRoot } from './glob.js';\nimport { isFamilyName } from './identity.js';\nimport { analyse, DEFAULT_PATTERNS, withDiagnostics, type AnalyseOptions, type AnalysisResult } from './runner.js';\nimport {\n formatGithub,\n formatGitlab,\n formatGraph,\n formatJson,\n formatMarkdown,\n formatReport,\n formatSarif,\n shouldUseAscii,\n shouldUseColor,\n type GraphFormat,\n} from './report.js';\nimport type { ProjectRule } from './project-rules.js';\nimport {\n DEFAULT_SEVERITIES,\n resolveStrict,\n RULE_DECISIONS,\n decisionUrl,\n RULE_DESCRIPTIONS,\n RULE_IDS,\n RULE_QUERIES,\n} from './rules.js';\nimport { isAbsolutePath, joinPosix, toPosix } from './paths.js';\nimport { formatRef } from './source.js';\nimport { execute, parseQuery, QueryError, renderMatch, type Match, type QuerySpec } from './select.js';\nimport { isProjectRule, type AnyRuleId, type RuleId, type Severity, type SpecNode } from './types.js';\nimport { displayWidth } from './vendor/spec-core/text/index.js';\n\nexport const EXIT_OK = 0;\nexport const EXIT_FAILED = 1;\nexport const EXIT_ERROR = 2;\n\nexport class UsageError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'UsageError';\n }\n}\n\nexport type Command = 'check' | 'query' | 'graph' | 'rules' | 'diff';\n\nexport interface CliOptions {\n readonly command: Command;\n readonly patterns: readonly string[];\n readonly root: string;\n /**\n * Whether `--root` was given.\n *\n * When it was, the caller has named the root and configuration is read from\n * exactly there. When it was not, the root is discovered - which is a\n * different question from what the root currently is. See ADR-0018.\n */\n readonly rootExplicit: boolean;\n readonly ignore: readonly string[];\n /** Reference targets to leave unreported when they do not resolve. */\n readonly ignoreReferences: readonly string[];\n /** Families a bare identifier may name. Empty means any family in the corpus. */\n readonly families: readonly string[];\n /** Families that are never citations. */\n readonly ignoreFamilies: readonly string[];\n /** Files that log what was decided rather than deciding it. */\n readonly historyPatterns: readonly string[];\n /** Accepted-debt file to read. `null` means none was asked for. */\n readonly baseline: string | null;\n /** Where to write the current findings as accepted debt. */\n readonly recordBaseline: string | null;\n /**\n * Fail when the baseline allows something that no longer happens.\n *\n * The other side of the ratchet, and off by default for the reason ADR-0012\n * gives: failing a build because somebody fixed something is a strange way to\n * encourage them. A team that has decided its debt only goes one way asks for\n * it explicitly, and then a dead exemption cannot outlive the defect.\n */\n readonly ratchet: boolean;\n /** Skip the repository configuration file entirely. */\n readonly noConfig: boolean;\n readonly format: 'human' | 'json' | 'sarif' | 'markdown' | 'gitlab' | 'github';\n readonly graphFormat: GraphFormat;\n readonly severities: Partial<Record<AnyRuleId, Severity>>;\n readonly color: boolean | null;\n readonly ascii: boolean | null;\n readonly verbose: boolean;\n readonly documentsOnly: boolean;\n readonly max: number;\n readonly maxWarnings: number;\n /** Raise every warning to an error. Explicit `--rule` overrides still win. */\n readonly strict: boolean;\n readonly selector: string | null;\n readonly help: boolean;\n readonly version: boolean;\n}\n\nexport interface CliIO {\n readonly argv?: readonly string[] | undefined;\n readonly cwd?: string | undefined;\n readonly stdout?: ((text: string) => void) | undefined;\n readonly stderr?: ((text: string) => void) | undefined;\n readonly env?: Readonly<Record<string, string | undefined>> | undefined;\n readonly isTTY?: boolean | undefined;\n}\n\nexport const HELP = `spec-graph - turn Markdown specifications into a verifiable graph\n\nUSAGE\n spec-graph [check] [patterns...] [options]\n spec-graph query <selector|project:rule> [patterns...] [options]\n spec-graph graph [patterns...] [--graph-format dot|mermaid|json]\n spec-graph rules [rule-id] [--explain]\n spec-graph diff <before.json> <after.json> [--format human|json|markdown]\n\nCOMMANDS\n check Validate the specification graph. The default.\n query Run a selector - or a registered project rule, by its id - and\n print the matching paths.\n graph Export the graph for Graphviz, Mermaid, or another tool.\n rules List the diagnostics that will run, built in and project. Name one\n to see only that one; --explain adds its selector and the ADR that\n decided it.\n diff Compare two graph exports: documents added, removed, moved or\n accepted; relations added or removed; and obligations resolved or\n reopened where they can be told apart. Make both exports with the\n same spec-graph. Exits 0 whether anything changed or not.\n\nOPTIONS\n --root <dir> Directory the patterns resolve against. Without it,\n .spec-graph.json is looked for in the working\n directory and then upward as far as the repository,\n and the directory holding it becomes the root - so a\n run from a subdirectory reports what a run from the\n top reports. Paths typed on the command line stay\n relative to where they were typed. It has to be a\n directory that is there.\n --ignore <glob> Skip paths. Repeatable.\n --ignore-ref <glob> Do not report these reference targets when they fail\n to resolve, for repositories where [[...]] tags a\n concept rather than naming a file. Repeatable.\n Suppresses findings only, never edges.\n --family <name> Families a bare identifier in prose may name. When\n given, everything else stays prose. Repeatable: one\n name each time, the prefix its identifiers are\n written with, ADR for ADR-0007. A document here has\n to belong to one of them, or the check stops: a list\n that names none allows nothing. It stops too where\n a name has no document and the list leaves out a\n family the documents do belong to, as RFCS for RFC\n does: one is most likely meant for the other.\n --ignore-family <name> Families that are never citations - RFC when the repo\n cites RFC 2119 and keeps its own RFCs. Repeatable,\n one name each time.\n --history <glob> Files that log what was decided rather than deciding\n it - journals, changelogs, minutes. Their links are\n still checked; their obligations are not. Repeatable.\n --baseline <file> Accept the findings recorded in this file and report\n only what is new since. The file has to be there: a\n path that reads nothing accepts nothing and says so\n nowhere. A \"baseline\" in the configuration may name a\n file not recorded yet; a path typed here may not.\n --record-baseline <f> Write today's findings to this file as accepted debt,\n and exit 0 without judging them.\n --ratchet Also fail when a baseline entry no longer occurs, so\n a paid-off exemption cannot outlive the defect.\n --no-config Ignore .spec-graph.json and the package.json key.\n --format <fmt> human, json, sarif, github, gitlab or markdown. json\n is for check, query or diff. sarif is the interchange\n format GitHub code scanning and editors already read,\n github the workflow commands a GitHub Actions log\n turns into annotations, and gitlab the Code Quality\n report a GitLab merge request reads, all three for\n check; markdown is a table for a pull-request comment\n or $GITHUB_STEP_SUMMARY, for check or diff (default:\n human)\n --graph-format <fmt> dot, mermaid or json (default: dot)\n --documents-only Leave items out of the exported graph\n --rule <id>=<severity> Override one rule: error, warn, info or off. A project\n rule is named in full: project:no-draft-dependency.\n Repeatable.\n --max <n> Show at most n findings (0 = no limit)\n --max-warnings <n> Fail when warnings exceed n (default: no limit)\n --strict Raise every warning to an error. An explicit --rule\n still wins, so --strict --rule x=warn exempts x.\n --color / --no-color Force colour on or off\n --ascii / --no-ascii ASCII glyphs or Unicode ones. SPEC_GRAPH_ASCII asks\n for ASCII, unless it is empty, 0 or false. Either\n option wins over it, and over what the terminal is\n taken for. The two together are refused\n --verbose Include parse problems, per-file detail, and every\n reference --ignore-ref or --ignore-family silenced\n --explain With rules: add each rule's selector and the ADR\n that decided it\n -h, --help Show this help\n -v, --version Show the version\n\n An option belongs to the commands that read it, and any other command\n refuses it by name:\n\n --root, --verbose check, query, graph, rules\n --ignore, --history check, query, graph\n --format check, query, diff\n --graph-format, --documents-only graph\n --explain rules\n every other option check\n\n --no-config, --no-color and --ascii are taken by every command: each is\n true already of a command with nothing to read it for. --color and\n --no-ascii are not: each would say that a command drew what only a check\n draws.\n\n A value that begins with -- reads as an option, so the option before it is\n refused as missing its value. A name that does begin so is written ./--name\n for a file, [-]-name in a pattern and \\\\--name for a reference target.\n\nSELECTORS\n A selector is a path through the graph.\n\n item[openness=open] -delegates-to-> document[phase=retired]\n document[phase=active] -assumes-> document[phase=retired]\n document =supersedes=> document\n *[path^=docs/adr] -contains-> item[state=accepted-debt]\n\n Node types: document, item, * (any)\n Attributes: id, kind, title, path, file, line, phase, status, receptivity,\n alias, document, state (or disposition), openness, section,\n text, body, evidence, conflicted, fm.<front-matter-key>\n Operators: = != ^= $= *= ~= and [attr] for \"is present\"\n ~= is a regular expression, matched by an automaton that cannot\n backtrack: linear in the subject, whatever the pattern. It reads\n the usual syntax minus backreferences and lookaround, which are\n not regular - both are refused when the selector is read, with\n the character pointed at\n Relations: -kind-> <-kind- =kind=> <=kind= (= forms are transitive)\n\nEXIT CODES\n 0 clean\n 1 findings at error severity (or over --max-warnings)\n 2 the tool could not run\n\n An input that is set and names nothing is a 2, named on stderr, and never\n read as if it had not been given: an empty value, a family name no family\n has, a list of families no document here belongs to, a --root that is no\n directory, a second word after rules, an option of another command.\n\nCONFIGURATION\n Anything repeated on every run belongs in the repository rather than in the\n command. spec-graph reads the first of these that exists:\n\n .spec-graph.json, spec-graph.config.json, or a \"spec-graph\" key in\n package.json\n\n { \"patterns\": [\"docs/**/*.md\"],\n \"ignoreReferences\": [\"trap *\"],\n \"ignoreFamilies\": [\"RFC\"],\n \"historyPatterns\": [\"**/JOURNAL_*.md\", \"archive/**\"],\n \"baseline\": \".spec-graph-baseline.json\",\n \"severities\": { \"self-reference\": \"off\" },\n \"strict\": true,\n \"maxRelated\": 3 }\n\n A flag always wins over the file, and list flags add to it rather than\n replacing it. maxRelated has no flag: it caps how many related locations one\n finding lists, 8 unless set, and 0 lists none.\n\n A problem in that file stops the run with exit 2, named on stderr: invalid\n JSON, an unknown key, a rule that does not compile, a file that is there and\n cannot be read. A configuration that did not load checks a different\n repository than the one configured, and would report that one as consistent.\n --no-config runs on defaults instead.\n\nPROJECT RULES\n A convention spec-graph never anticipated is a selector plus a sentence, and\n belongs in the same file. Every rule declared here runs beside the built-ins\n and is reported, baselined, escalated by --strict and silenced by --rule in\n exactly the same way.\n\n { \"rules\": {\n \"no-draft-dependency\": {\n \"query\": \"document[phase=active] -depends-on-> document[phase=draft]\",\n \"message\": \"{0} depends on {1}, which is still a draft\",\n \"hint\": \"wait for {1} to be accepted, or drop it from {0.path}\",\n \"severity\": \"error\" } } }\n\n query One selector, or a list of them read as a union.\n message The headline. {0} is the first node on the path, {1} the next;\n {1.phase} and {0.fm.owner} read any selector attribute.\n hint The next action. Optional, and templated the same way.\n severity error, warn, info or off. Defaults to warn - a rule a team has\n just written has not yet earned the right to fail their build.\n\n The id is the name with project: in front, which is why it can never collide\n with a built-in. A selector that does not parse, or a {2} the query can never\n reach, is reported when the file is read rather than found missing later.\n\n To see what one matches without copying its selector out of the file:\n\n spec-graph query project:no-draft-dependency --verbose\n\nADOPTING THIS ON AN OLD REPOSITORY\n Record what is already wrong, then report only what happens next:\n\n spec-graph check --record-baseline .spec-graph-baseline.json\n git add .spec-graph-baseline.json\n\n The file is keyed by specification and citation, not by line number, so it\n survives edits, moves and renames. Findings that stop occurring are reported\n so the file can be tightened; nothing new gets in.\n\nEXAMPLES\n spec-graph \"docs/**/*.md\"\n spec-graph check --rule self-reference=off --format json\n spec-graph query 'item[openness=open] -delegates-to-> document[phase=retired]'\n spec-graph check --ignore-ref \"trap *\" # [[trap 55]] tags a concept, not a file\n spec-graph graph --documents-only --graph-format mermaid > graph.mmd\n spec-graph check --history \"**/JOURNAL_*.md\" # a log is not a specification\n spec-graph check --baseline .spec-graph-baseline.json\n spec-graph rules --explain # including this repository's own\n spec-graph rules ghost-handover --explain # and why it exists\n spec-graph check --rule project:no-draft-dependency=off\n spec-graph query project:no-draft-dependency # what does that rule match?\n spec-graph check --format markdown >> \"$GITHUB_STEP_SUMMARY\"\n spec-graph check --format github # annotations from an Actions log\n spec-graph check --format gitlab > gl-code-quality-report.json\n spec-graph diff base.json head.json --format markdown >> \"$GITHUB_STEP_SUMMARY\"\n`;\n\nconst SEVERITIES: readonly Severity[] = ['error', 'warn', 'info', 'off'];\n\n/**\n * The commands that read an option, or nothing for one every command takes.\n *\n * Any other command refuses the option, rather than run as if it were not\n * there: `query --strict` taking the flag and doing nothing with it would\n * tell someone their query was strict, `graph --record-baseline` wrote no\n * file and said so nowhere, and `spec-graph --graph-format mermaid`, the\n * command forgotten, wrote the check's report into what was meant to hold a\n * graph. The three options about citations are a check's alone: they pass\n * over findings and never an edge, so a graph or a query is the same with\n * them as without.\n *\n * `--no-color`, `--ascii` and `--no-config` are taken by every command.\n * Each is true already of what the commands that do not read it write - none\n * of them colours or draws a glyph, and `diff` reads no configuration - and\n * a script passes them to every command it runs. `--color` is not one of\n * them: it would promise colour that only a check prints. Nor is\n * `--no-ascii`, for the same reason: taken by a query, it would say the\n * Unicode glyphs were drawn where none is. An option is refused where\n * taking it would say what is not so, and taken where it asks a command to\n * leave out what it never does (spec-core's ADR-0005, 2026-10-11).\n *\n * A function and not a table, so that none of it runs when the module loads:\n * a mutant of a table built at import pays for the whole suite (ADR-0007).\n */\nfunction readersOf(option: string): readonly Command[] | undefined {\n switch (option) {\n case '--root':\n case '--verbose':\n return ['check', 'query', 'graph', 'rules'];\n case '--ignore':\n case '--history':\n return ['check', 'query', 'graph'];\n case '--format':\n return ['check', 'query', 'diff'];\n case '--graph-format':\n case '--documents-only':\n return ['graph'];\n case '--explain':\n return ['rules'];\n case '--ignore-ref':\n case '--family':\n case '--ignore-family':\n case '--baseline':\n case '--record-baseline':\n case '--ratchet':\n case '--rule':\n case '--strict':\n case '--max':\n case '--max-warnings':\n case '--color':\n case '--no-ascii':\n return ['check'];\n }\n return undefined;\n}\n\n/** `a`, `a or b`, `a, b or c`: one name or more in a sentence, with the word that joins the last. */\nfunction listed(names: readonly string[], joint: string): string {\n return names.length < 2 ? (names[0] as string) : `${names.slice(0, -1).join(', ')} ${joint} ${names[names.length - 1]!}`;\n}\n\n/** Parses argv into options. Throws {@link UsageError} on anything malformed. */\nexport function parseArgs(argv: readonly string[], cwd: string): CliOptions {\n const args = [...argv];\n let command: Command = 'check';\n\n const first = args[0];\n if (first === 'check' || first === 'query' || first === 'graph' || first === 'rules' || first === 'diff') {\n command = first;\n args.shift();\n }\n\n const patterns: string[] = [];\n const ignore: string[] = [];\n const ignoreReferences: string[] = [];\n const families: string[] = [];\n const ignoreFamilies: string[] = [];\n const historyPatterns: string[] = [];\n let noConfig = false;\n const severities: Partial<Record<AnyRuleId, Severity>> = {};\n let root = cwd;\n let rootExplicit = false;\n let format: CliOptions['format'] = 'human';\n let graphFormat: GraphFormat = 'dot';\n let color: boolean | null = null;\n let ascii: boolean | null = null;\n let verbose = false;\n let documentsOnly = false;\n let max = 0;\n let maxWarnings = -1;\n let strict = false;\n let baseline: string | null = null;\n let ratchet = false;\n let recordBaseline: string | null = null;\n let selector: string | null = null;\n let help = false;\n let version = false;\n\n // In the order they were given, so the first that does not belong is the\n // one named. A set keeps that order, and starts from no literal: a list\n // seeded with a word no option is called would refuse nothing more, which\n // is a mutant no test can tell from the code.\n const given = new Set<string>();\n const next = (flag: string, index: number): string => {\n const value = args[index + 1];\n if (value === undefined) throw new UsageError(`${flag} needs a value`);\n // The option after one whose value was forgotten. Taken as the value,\n // `--ignore --strict` ignored a directory called `--strict` and the check\n // was not strict, and `--record-baseline --verbose` wrote a file of that\n // name. A name that does begin with two dashes has another spelling\n // wherever one can be meant: `./--x` for a file, `[-]-x` in a pattern,\n // `\\--x` for a reference target.\n if (value.startsWith('--') || value === '-h' || value === '-v') {\n throw new UsageError(`${flag} needs a value, and ${value} reads as an option`);\n }\n return value;\n };\n // A blank value is what an unset variable leaves in `--root \"$DIR\"`. A path\n // made of it names the directory beside it or a file called \" \", and the run\n // then answered for a place nobody named.\n const filled = (flag: string, index: number, what: string): string => {\n const value = next(flag, index);\n if (value.trim() === '') throw new UsageError(`${flag} expects ${what}, got \"${value}\"`);\n return value;\n };\n // A family is taken once per option. A blank, `ADR,RFC` or the option typed\n // after it is a name no family has: alone on the allowlist it left every\n // citation as prose, and the check passed over the ones that dangle.\n const family = (flag: string, index: number): string => {\n const value = next(flag, index);\n if (!isFamilyName(value)) throw new UsageError(`${flag} expects one family's name, such as ADR, got \"${value}\"`);\n return value;\n };\n\n for (let i = 0; i < args.length; i += 1) {\n const arg = args[i] as string;\n\n if (arg === '--') {\n patterns.push(...args.slice(i + 1));\n break;\n }\n\n if (!arg.startsWith('-')) {\n if (command === 'query' && selector === null) selector = arg;\n else patterns.push(arg);\n continue;\n }\n\n given.add(arg);\n switch (arg) {\n case '-h':\n case '--help':\n help = true;\n break;\n case '-v':\n case '--version':\n version = true;\n break;\n case '--verbose':\n verbose = true;\n break;\n case '--color':\n color = true;\n break;\n case '--no-color':\n color = false;\n break;\n case '--ascii':\n ascii = true;\n break;\n case '--no-ascii':\n ascii = false;\n break;\n case '--documents-only':\n documentsOnly = true;\n break;\n case '--strict':\n strict = true;\n break;\n case '--ratchet':\n ratchet = true;\n break;\n case '--explain':\n verbose = true;\n break;\n case '--root':\n root = filled(arg, i, 'a directory');\n rootExplicit = true;\n i += 1;\n break;\n case '--ignore':\n ignore.push(next(arg, i));\n i += 1;\n break;\n case '--ignore-ref':\n ignoreReferences.push(next(arg, i));\n i += 1;\n break;\n case '--family':\n families.push(family(arg, i));\n i += 1;\n break;\n case '--ignore-family':\n ignoreFamilies.push(family(arg, i));\n i += 1;\n break;\n case '--history':\n historyPatterns.push(next(arg, i));\n i += 1;\n break;\n case '--baseline':\n baseline = filled(arg, i, 'a file');\n i += 1;\n break;\n case '--record-baseline':\n recordBaseline = filled(arg, i, 'a file');\n i += 1;\n break;\n case '--no-config':\n noConfig = true;\n break;\n case '--format': {\n const value = next(arg, i);\n if (\n value !== 'human' &&\n value !== 'json' &&\n value !== 'sarif' &&\n value !== 'markdown' &&\n value !== 'gitlab' &&\n value !== 'github'\n ) {\n throw new UsageError(`--format must be human, json, sarif, markdown, gitlab or github, got \"${value}\"`);\n }\n format = value;\n i += 1;\n break;\n }\n case '--graph-format': {\n const value = next(arg, i);\n if (value !== 'dot' && value !== 'mermaid' && value !== 'json') {\n throw new UsageError(`--graph-format must be dot, mermaid or json, got \"${value}\"`);\n }\n graphFormat = value;\n i += 1;\n break;\n }\n case '--rule': {\n const value = next(arg, i);\n const equals = value.indexOf('=');\n if (equals === -1) throw new UsageError(`--rule expects <id>=<severity>, got \"${value}\"`);\n const before = value.slice(0, equals);\n const after = value.slice(equals + 1);\n const id = before as AnyRuleId;\n const level = after as Severity;\n // A project rule is taken on its namespace here and checked for real\n // once the configuration defining it has been read: arguments are\n // parsed before any file is opened, and a flag has to be usable on that\n // first pass whatever the repository turns out to declare.\n if (!RULE_IDS.includes(id as RuleId) && !isProjectRule(id)) {\n throw new UsageError(`unknown rule \"${id}\"\\n known rules: ${RULE_IDS.join(', ')}`);\n }\n if (!SEVERITIES.includes(level)) {\n throw new UsageError(`unknown severity \"${level}\", expected one of: ${SEVERITIES.join(', ')}`);\n }\n severities[id] = level;\n i += 1;\n break;\n }\n case '--max': {\n max = parseCount(arg, next(arg, i));\n i += 1;\n break;\n }\n case '--max-warnings': {\n maxWarnings = parseCount(arg, next(arg, i));\n i += 1;\n break;\n }\n default:\n throw new UsageError(`unknown option \"${arg}\"\\n run \"spec-graph --help\" to see the available options`);\n }\n }\n\n // SARIF, GitHub's workflow commands and GitLab's Code Quality are reports\n // about findings, and only `check` produces those. Falling back to JSON would\n // hand a pipeline something its uploader rejects with a message about a\n // schema rather than about the command that was run. Markdown is for a pull\n // request, which reads a check or a diff.\n if ((format === 'sarif' || format === 'gitlab' || format === 'github') && command !== 'check' && !help && !version) {\n throw new UsageError(`--format ${format} reports findings, so it belongs to check, not to ${command}`);\n }\n if (format === 'markdown' && command !== 'check' && command !== 'diff' && !help && !version) {\n throw new UsageError(`--format markdown is a report for a pull request, so it belongs to check or diff, not to ${command}`);\n }\n\n // JSON is refused where the other reports are, and for the reason above:\n // `graph --format json` wrote DOT and `rules --format json` a list, each\n // with exit 0, to whatever was waiting for JSON.\n if (format === 'json' && (command === 'graph' || command === 'rules') && !help && !version) {\n const instead = command === 'graph' ? 'graph writes JSON with --graph-format json' : 'rules lists the rules as text';\n throw new UsageError(`--format json belongs to check, query or diff, not to ${command}: ${instead}`);\n }\n\n if (!help && !version) {\n for (const option of given) {\n const readers = readersOf(option);\n if (readers !== undefined && !readers.includes(command)) {\n throw new UsageError(`${option} belongs to ${listed(readers, 'or')}, not to ${command}`);\n }\n }\n }\n\n // The later of the two would decide and the earlier go unread: a script\n // that adds `--no-ascii` to a line already holding `--ascii` would be told\n // nothing of which it got.\n if (given.has('--ascii') && given.has('--no-ascii') && !help && !version) {\n throw new UsageError('--ascii is given beside --no-ascii, and the glyphs are drawn one way: give one of the two');\n }\n\n // The second word given to `rules` was dropped, so `rules a b` listed `a`\n // and said nothing of `b`.\n if (command === 'rules' && patterns.length > 1 && !help && !version) {\n throw new UsageError(`rules takes one rule id, got ${patterns.length}: ${patterns.join(', ')}`);\n }\n\n if (command === 'diff' && patterns.length !== 2 && !help && !version) {\n throw new UsageError(\n 'diff compares two graph exports, for example:\\n spec-graph diff base.json head.json\\n (make each with spec-graph graph --graph-format json)',\n );\n }\n\n // An empty name resolved to the directory the run was started in, and the\n // refusal was the read's: `cannot read : EISDIR`.\n const blank = patterns.findIndex((path) => path.trim() === '');\n if (command === 'diff' && blank !== -1 && !help && !version) {\n throw new UsageError(`diff expects a graph export on each side, got \"${patterns[blank] as string}\" for the ${blank === 0 ? 'first' : 'second'}`);\n }\n\n if (command === 'query' && selector === null && !help && !version) {\n throw new UsageError('query needs a selector, for example:\\n spec-graph query \\'item[openness=open]\\'');\n }\n\n return {\n command,\n patterns,\n root,\n rootExplicit,\n ignore,\n ignoreReferences,\n families,\n ignoreFamilies,\n historyPatterns,\n baseline,\n ratchet,\n recordBaseline,\n noConfig,\n format,\n graphFormat,\n severities,\n color,\n ascii,\n verbose,\n documentsOnly,\n max,\n maxWarnings,\n strict,\n selector,\n help,\n version,\n };\n}\n\nfunction count(n: number, word: string, many?: string): string {\n return `${n} ${n === 1 ? word : (many ?? `${word}s`)}`;\n}\n\ninterface HeldBaseline {\n readonly baseline: Baseline;\n readonly problems: readonly string[];\n /** What stopped the file being read, when something did. */\n readonly unread: { readonly missing: boolean; readonly message: string } | null;\n}\n\n/**\n * Reads a baseline file.\n *\n * Absent and unreadable are different answers, and the caller needs both. A\n * repository that has not recorded a baseline yet declares the path before the\n * file exists, and an empty baseline accepts nothing, which is what that run\n * should report (ADR-0012). Anything else - a directory, a permission, a path\n * that went somewhere unintended - is the tool failing to do what it was told.\n */\nasync function readBaseline(path: string, source: string): Promise<HeldBaseline> {\n let raw: string;\n try {\n const { readFile } = await import('node:fs/promises');\n raw = await readFile(path, 'utf8');\n } catch (error) {\n const failure = error as Error & { code?: string };\n return {\n baseline: EMPTY_BASELINE,\n problems: [],\n unread: { missing: failure.code === 'ENOENT', message: failure.message },\n };\n }\n return { ...parseBaseline(raw, source), unread: null };\n}\n\nfunction parseCount(flag: string, value: string): number {\n const parsed = Number.parseInt(value, 10);\n if (!Number.isFinite(parsed) || parsed < 0 || String(parsed) !== value.trim()) {\n throw new UsageError(`${flag} expects a non-negative whole number, got \"${value}\"`);\n }\n return parsed;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Entry point */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Runs the CLI and returns the process exit code. Never throws.\n *\n * An error nothing below expected is neither a finding nor a usage mistake:\n * the answer cannot be trusted, which is the family contract's 2 (spec-core's\n * ADR-0005). Rejected instead, it reached the launcher as Node's uncaught\n * error, exit 1, which CI reads as findings. The stack is what makes a report\n * of it something to act on, and it goes to stderr alone: a script that reads\n * a document from stdout is handed no part of one.\n *\n * A write its reader had closed the pipe for is not such an error: the answer\n * was not delivered, which is still 2, and nothing in spec-graph is at fault,\n * so it is said in a line and no stack sends a person looking for a defect.\n * The process's own streams report it as an event, which the launcher answers\n * in the same words; here it is a caller's stream that throws it. It is read\n * by its code: stdout and stderr are the only pipes spec-graph writes to.\n */\nexport async function main(io: CliIO = {}): Promise<number> {\n const err = io.stderr ?? ((text) => process.stderr.write(text));\n try {\n return await run(io, err);\n } catch (error) {\n if (!(error instanceof Error)) err(`spec-graph: unexpected error: ${String(error)}\\n`);\n else if ((error as { code?: unknown }).code === 'EPIPE') err('spec-graph: stdout was closed before all of the output was written\\n');\n else err(`spec-graph: unexpected error: ${error.stack ?? error.message}\\n`);\n return EXIT_ERROR;\n }\n}\n\n/** One run of the command line, which rejects on an error it did not expect. */\nasync function run(io: CliIO, err: (text: string) => void): Promise<number> {\n const argv = io.argv ?? process.argv.slice(2);\n const cwd = io.cwd ?? process.cwd();\n const out = io.stdout ?? ((text) => process.stdout.write(text));\n const env = io.env ?? process.env;\n\n let options: CliOptions;\n try {\n options = parseArgs(argv, cwd);\n } catch (error) {\n // parseArgs throws nothing but a UsageError for any argv, so no test can\n // tell this check from `true`: the rethrow is for a bug in the parser.\n if (error instanceof UsageError) {\n err(`spec-graph: ${error.message}\\n`);\n return EXIT_ERROR;\n }\n throw error;\n }\n\n if (options.help) {\n out(HELP);\n return EXIT_OK;\n }\n if (options.version) {\n out(`${await readVersion()}\\n`);\n return EXIT_OK;\n }\n\n // A diff reads two files and nothing else: no configuration and no corpus, so\n // it can compare exports from a checkout it is not running in.\n if (options.command === 'diff') return runDiff(options.patterns as readonly [string, string], cwd, options.format, out, err);\n\n // A root that was named is a directory, for every command that reads one.\n // `rules --root` with a path that is not there listed the built-in rules and\n // exited 0, as if the repository declared none, and the others said only\n // that no specification matched under it.\n if (options.rootExplicit) {\n const { stat } = await import('node:fs/promises');\n // A path that cannot be reached reads as one that is not there: either\n // way there is nothing under it to read.\n const found = await stat(options.root).catch(() => null);\n if (found === null || !found.isDirectory()) {\n err(`spec-graph: --root \"${options.root}\" is not ${found === null ? 'there' : 'a directory'}\\n`);\n return EXIT_ERROR;\n }\n }\n\n const color = options.color ?? shouldUseColor({ isTTY: io.isTTY, env });\n const ascii = options.ascii ?? shouldUseAscii({ env });\n\n // Configuration is what is true of the repository; a flag is somebody\n // overriding it for one run. So a flag always wins, and lists add rather than\n // replace - a `--ignore-ref` on the command line is one more exclusion, not a\n // decision to throw away the ones the repository already declared.\n //\n // Read before `rules` prints anything, so that command lists the conventions\n // this repository will actually check rather than the ones spec-graph ships.\n const loaded = options.noConfig\n ? { config: {} as SpecGraphConfig, source: null, problems: [], root: options.root }\n : options.rootExplicit\n ? { ...loadConfig(options.root), root: options.root }\n : discoverConfig(options.root);\n for (const problem of loaded.problems) err(`spec-graph: ${problem}\\n`);\n // A configuration that did not load means a run against a different\n // repository than the one configured - other patterns, other rules, other\n // severities - and the verdict printed is about that one. Reporting the\n // problem and carrying on gave a green build with `ok: true` from a file with\n // a typo in it, which is the one answer a checker must never reach by\n // accident, and the same mistake in a `--rule` has always exited 2. The\n // findings are one flag away, and the flag is named. Amends ADR-0010.\n if (loaded.problems.length > 0) {\n err(\n `spec-graph: ${count(loaded.problems.length, 'problem')} in the configuration, so nothing was checked\\n fix it, or run again with --no-config to check on defaults\\n`,\n );\n return EXIT_ERROR;\n }\n const file = loaded.config;\n const projectRules = file.rules ?? [];\n const root = loaded.root;\n // How far the root moved up. Everything a repository declares about itself is\n // relative to the root; everything typed on the command line is relative to\n // where it was typed, and this is what keeps those two readings apart.\n const here = below(root, options.root);\n\n // A `--rule` naming a project rule that does not exist is a flag that\n // silently does nothing, and nothing in the output would distinguish that\n // from a rule that ran and found none.\n for (const id of Object.keys(options.severities)) {\n if (!isProjectRule(id as AnyRuleId) || projectRules.some((rule) => rule.id === id)) continue;\n err(`spec-graph: unknown rule \"${id}\"\\n ${knownProjectRules(projectRules)}\\n`);\n return EXIT_ERROR;\n }\n\n if (options.command === 'rules') {\n // The one positional argument `rules` can take is a rule id: this command\n // reads no files, so a pattern here would be a word with nowhere to go.\n const wanted = options.patterns[0];\n if (wanted !== undefined && !RULE_IDS.includes(wanted as RuleId) && !projectRules.some((rule) => rule.id === wanted)) {\n err(\n `spec-graph: unknown rule \"${wanted}\"\\n known rules: ${RULE_IDS.join(', ')}\\n ${knownProjectRules(projectRules)}\\n`,\n );\n return EXIT_ERROR;\n }\n out(renderRules(options.verbose, await readVersion(), projectRules, wanted ?? null, loaded.source));\n return EXIT_OK;\n }\n\n // Named the way the reader would have to type it, because a discovered\n // configuration is often not the one in front of them.\n //\n // On stderr, with everything else this run says about itself. stdout is the\n // report, and in three of the four formats it is a document: a line above it\n // made `--verbose --format json` unparseable and handed `--format sarif` to a\n // code-scanning uploader that rejects it over a schema.\n if (options.verbose && loaded.source !== null) err(`configuration: ${fromHere(here, loaded.source)}\\n`);\n\n // A bare `--ignore` name prunes a directory of that name at any depth, the\n // way a .gitignore line does, so it means the same thing wherever it was\n // typed. Every other pattern is matched against the repository-relative\n // path, a bare `--history` name included, and leaving one alone would make\n // it silently match something else or nothing. A pattern that cannot be\n // rebased onto the root stops the run as one the dialect refuses does,\n // named as it was typed.\n let typed;\n try {\n typed = {\n patterns: options.patterns.map((pattern) => anchor(here, pattern)),\n ignore: options.ignore.map((pattern) => anchorPath(here, pattern)),\n history: options.historyPatterns.map((pattern) => anchor(here, pattern)),\n };\n } catch (error) {\n err(`spec-graph: ${(error as Error).message}\\n`);\n return EXIT_ERROR;\n }\n const patterns = typed.patterns.length > 0 ? typed.patterns : (file.patterns ?? DEFAULT_PATTERNS);\n const severityOverrides = { ...(file.severities ?? {}), ...options.severities };\n const { severities, escalated } = resolveStrict(\n severityOverrides,\n options.strict || (file.strict ?? false),\n projectRules,\n );\n\n // The list the check is held against, once it has read the documents, and\n // the families taken out on purpose, which that list is not held to.\n const families = [...(file.families ?? []), ...options.families];\n const ignoreFamilies = [...(file.ignoreFamilies ?? []), ...options.ignoreFamilies];\n const analyseOptions: AnalyseOptions = {\n root,\n patterns,\n // A stray entry in one of the empty fallbacks here changes a run only if\n // it matches a path or a target some corpus has, so the mutants that plant\n // one survive every corpus but one built for them - except in the two\n // lists of families, where what they plant is no family's name and is\n // refused.\n ignore: [...(file.ignore ?? []), ...typed.ignore],\n ignoreReferences: [...(file.ignoreReferences ?? []), ...options.ignoreReferences],\n families,\n ignoreFamilies,\n historyPatterns: [...(file.historyPatterns ?? []), ...typed.history],\n severities,\n projectRules,\n maxRelated: file.maxRelated,\n };\n\n let result;\n try {\n result = await analyse(analyseOptions);\n } catch (error) {\n err(`spec-graph: ${(error as Error).message}\\n`);\n return EXIT_ERROR;\n }\n\n if (result.files.length === 0) {\n err(\n `spec-graph: no specifications matched ${\n patterns.map((p) => `\"${p}\"`).join(', ')\n }\\n looked under ${root}\\n`,\n );\n return EXIT_ERROR;\n }\n\n switch (options.command) {\n case 'graph':\n out(\n formatGraph(result.graph, options.graphFormat, {\n documentsOnly: options.documentsOnly,\n generator: { name: 'spec-graph', version: await readVersion() },\n }),\n );\n return EXIT_OK;\n\n case 'query': {\n const selector = options.selector as string;\n let queries: readonly QuerySpec[];\n\n // A registered rule is asked for by name, because by the time this runs\n // it is already compiled and the alternative is copying its selector out\n // of the configuration file by hand. The namespace cannot collide with\n // the grammar: no selector begins with a word and a colon. See ADR-0016.\n if (isProjectRule(selector as AnyRuleId)) {\n const rule = projectRules.find((candidate) => candidate.id === selector);\n if (rule === undefined) {\n err(`spec-graph: unknown rule \"${selector}\"\\n ${knownProjectRules(projectRules)}\\n`);\n return EXIT_ERROR;\n }\n queries = rule.queries;\n // Beside the report rather than inside it, for the reason the\n // configuration line above is: `--format json` is a document.\n if (options.verbose) for (const source of rule.sources) err(`${rule.id}: ${source}\\n`);\n } else {\n try {\n queries = [parseQuery(selector)];\n } catch (error) {\n // Every selector that fails to parse fails as a QueryError, so no\n // test can tell this check from `true`.\n if (error instanceof QueryError) {\n err(renderQueryError(selector, error));\n return EXIT_ERROR;\n }\n throw error;\n }\n }\n\n const matches = union(result.graph, queries);\n // renderMatches asks only whether this is 'json', so the other word is a\n // name for the reader and emptying it changes nothing.\n out(renderMatches(matches, options.format === 'json' ? 'json' : 'human', result.graph.nodes.size));\n return matches.length > 0 ? EXIT_OK : EXIT_FAILED;\n }\n\n default: {\n // An allowlist is held against the corpus it was written for. One that\n // names no family a document here belongs to allows nothing the corpus\n // has: every citation is then prose, and the run that failed on a\n // dangling one reported a consistent graph - for `--family ADRS` as it\n // did for `--family \"\"`. Nothing was measured, which is not clean\n // (spec-core's ADR-0005), so the run stops before it says anything.\n //\n // One such name beside names that have documents costs the run a\n // finding only where the list also leaves out a family the documents\n // do belong to: `ADR` and `RFCS` over ADRs and RFCs pass over every\n // citation of an RFC, and the run that fails without the list reports\n // a consistent graph. One name is most likely meant for the other, and\n // the run stops there too. Where every family the corpus has is on the\n // list, the name is a family the repository means to start, or one\n // whose documents this run does not read; the list passes over nothing\n // the run would have read without it, so it is said, and nothing\n // fails. A family on `--ignore-family` was taken out on purpose, and\n // is not one the list leaves out (ADR-0010, 2026-10-12).\n const allowed = [...new Set(families.map((family) => family.trim().toUpperCase()))];\n const absent = allowed.filter((family) => !result.corpus.families.includes(family));\n if (absent.length > 0) {\n const lists: string[] = [];\n if (options.families.length > 0) lists.push('--family');\n if (file.families !== undefined && file.families.length > 0) lists.push(`\"families\" in ${loaded.source}`);\n const here = `the documents here belong to ${result.corpus.families.length > 0 ? listed(result.corpus.families, 'and') : 'no family'}`;\n const named = lists.join(' and ');\n if (absent.length === allowed.length) {\n err(\n `spec-graph: no document here belongs to a family named by ${named} (${allowed.join(', ')}); ${here}\\n name a family the documents belong to, or leave the list out\\n`,\n );\n return EXIT_ERROR;\n }\n const ignored = ignoreFamilies.map((family) => family.trim().toUpperCase());\n const left = result.corpus.families.filter((family) => !allowed.includes(family) && !ignored.includes(family));\n const said = `spec-graph: no document here belongs to ${listed(absent, 'or')}, named by ${named}; ${here}`;\n if (left.length > 0) {\n err(\n `${said}, and the list leaves out ${listed(left, 'and')}\\n name each family as its documents do, or leave it off the list until its first document is written\\n`,\n );\n return EXIT_ERROR;\n }\n err(`${said}\\n`);\n }\n\n // Recording is not checking. It writes down what is wrong today so that\n // tomorrow can be compared against it, and says nothing about whether\n // today is acceptable - so it reports what it wrote and exits clean.\n if (options.recordBaseline !== null) {\n const text = formatBaseline(result.graph, result.diagnostics);\n try {\n const { writeFile } = await import('node:fs/promises');\n // Node writes a string as UTF-8 when the encoding is empty too, so\n // emptying this literal writes the same bytes.\n await writeFile(underRoot(root, anchorFile(here, options.recordBaseline)), text, 'utf8');\n } catch (error) {\n err(`spec-graph: cannot write ${options.recordBaseline}: ${(error as Error).message}\\n`);\n return EXIT_ERROR;\n }\n const entries = (JSON.parse(text) as Baseline).findings.length;\n out(\n `recorded ${count(result.diagnostics.length, 'finding')} as ${count(entries, 'entry', 'entries')} in ${options.recordBaseline}\\n`,\n );\n return EXIT_OK;\n }\n\n const source = options.baseline === null ? (file.baseline ?? null) : anchorFile(here, options.baseline);\n const ratchet = options.ratchet || file.ratchet === true;\n let reported = result;\n let note:\n | {\n source: string;\n suppressed: number;\n stale: number;\n ratchet: boolean;\n entries: readonly StaleEntry[];\n }\n | undefined;\n let recordAs: string | undefined;\n if (source !== null) {\n const held = await readBaseline(underRoot(root, source), source);\n // A path typed on the command line says the file is there for this run.\n // Read as an empty baseline instead, a typo in it reports every accepted\n // finding as new, and passes --ratchet with nothing left to be stale.\n // A path in the configuration is the case ADR-0012 argued for, and only\n // where the file is absent: unreadable is unreadable wherever the path\n // was written.\n if (held.unread !== null && (options.baseline !== null || !held.unread.missing)) {\n err(`spec-graph: cannot read the baseline ${source}: ${held.unread.message}\\n`);\n return EXIT_ERROR;\n }\n // Quiet by default, because a configured path legitimately precedes the\n // first --record-baseline. Under --verbose, where parse problems already\n // go, a path that reads nothing says so rather than accepting nothing.\n if (held.unread !== null && options.verbose) {\n err(`spec-graph: baseline ${source} is not there, so nothing is accepted\\n`);\n }\n for (const problem of held.problems) err(`spec-graph: ${problem}\\n`);\n const outcome = applyBaseline(result.graph, result.diagnostics, held.baseline);\n reported = withDiagnostics(result, outcome.kept);\n note = {\n source,\n suppressed: outcome.suppressed,\n stale: outcome.stale.length,\n ratchet,\n entries: outcome.stale,\n };\n // The command that re-records it is typed where this run was: a path\n // typed on this command line is relative to there already, and the\n // configuration's is from the root.\n recordAs = options.baseline ?? fromHere(here, source);\n // Listed rather than counted when the run turns on them: a number is\n // enough to know the file has slack, and not enough to strike it. On\n // stdout only for a human - the structured formats carry the same rows\n // inside the document, where a stray line is the difference between\n // parsing and not.\n if (options.format === 'human' && (options.verbose || ratchet)) {\n for (const entry of outcome.stale) {\n const subject = entry.subject === '' ? '' : ` \"${entry.subject}\"`;\n const why = entry.reason === 'gone' ? ` - ${entry.document} is not in this corpus` : '';\n out(` ${entry.reason}: ${entry.rule} ${entry.document}${subject}${why}\\n`);\n }\n }\n }\n const looseBaseline = note !== undefined && note.ratchet && note.stale > 0;\n\n const reporterOptions = { verbose: options.verbose, max: options.max, escalated, baseline: note, recordAs };\n out(\n options.format === 'sarif'\n ? formatSarif(reported, reported.graph, { version: await readVersion(), escalated, projectRules })\n : options.format === 'gitlab'\n ? formatGitlab(reported, { escalated })\n : options.format === 'github'\n ? formatGithub(reported, { escalated })\n : options.format === 'json'\n ? formatJson(reported, { escalated, baseline: note })\n : options.format === 'markdown'\n ? formatMarkdown(reported, reporterOptions)\n : `${formatReport(reported, { color, ascii, ...reporterOptions })}\\n`,\n );\n if (!reported.ok || looseBaseline) return EXIT_FAILED;\n if (options.maxWarnings >= 0 && reported.summary.warnings > options.maxWarnings) return EXIT_FAILED;\n return EXIT_OK;\n }\n }\n}\n\n/* -------------------------------------------------------------------------- */\n/* Rendering */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Where the working directory sits below the root, or `''` when it is the root.\n *\n * Discovery only ever walks upward, so the root is always a prefix of the\n * directory the command was typed in, and this is a slice rather than path\n * arithmetic.\n */\nfunction below(root: string, from: string): string {\n const start = toPosix(from).replace(/[/]+$/, '');\n // The prefix test only guards a root that is neither `start` nor above it,\n // which nothing returns; for `start` itself, slicing past its end is `''`\n // too, so emptying the prefix changes nothing a run can reach.\n return start.startsWith(`${root}/`) ? start.slice(root.length + 1) : '';\n}\n\n/**\n * A path from the root, as it is typed in `here`: one `../` for each directory\n * `here` is below the root. An absolute path reads the same from anywhere.\n */\nfunction fromHere(here: string, path: string): string {\n return here === '' || isAbsolutePath(path) ? path : `${'../'.repeat(here.split('/').length)}${path}`;\n}\n\n/**\n * Re-anchors a pattern typed in `prefix` so it reads from the root, brace\n * alternative by brace alternative, or throws naming it as typed.\n *\n * `../docs` typed one directory down is the root's `docs`. That is arithmetic\n * on two relative paths, and this is the one place both are known; left in the\n * pattern, it reads as a glob climbing out of the root, which is refused.\n *\n * An absolute path is left alone: it was not relative to anywhere, so moving\n * the root cannot change what it means. spec-core roots a leading `/` and\n * knows no drive letter, so `C:/docs` is told apart here.\n */\nfunction anchor(prefix: string, pattern: string): string {\n return isAbsolutePath(pattern) ? pattern : rebasePattern(pattern, prefix);\n}\n\n/**\n * The same, for an `--ignore`, where a bare name is a directory at any depth.\n * Only the walk reads a name that way; a `--history` pattern is matched as a\n * whole path, and goes to {@link anchor}.\n */\nfunction anchorPath(prefix: string, pattern: string): string {\n return isGlob(pattern) || pattern.includes('/') ? anchor(prefix, pattern) : pattern;\n}\n\n/**\n * Re-anchors a file typed in `prefix`, a baseline, so it reads from the root.\n *\n * A file name is not a pattern: a brace or a `!` in it is a character, which\n * {@link anchor} would read as syntax, and a baseline outside the repository\n * is as good as one inside, so a `..` past the root is a path like any other.\n * At the root the file is named as it was typed.\n */\nfunction anchorFile(prefix: string, file: string): string {\n return prefix === '' || isAbsolutePath(file) ? file : joinPosix(prefix, toPosix(file));\n}\n\nfunction knownProjectRules(projectRules: readonly ProjectRule[]): string {\n const known = projectRules.map((rule) => rule.id);\n return known.length > 0 ? `project rules here: ${known.join(', ')}` : 'this repository defines no project rules';\n}\n\n/**\n * Runs a list of selectors as one result set.\n *\n * A project rule is a union of its selectors, and a path that two of them both\n * find is one path - the same dedupe `projectFindings` does, so that asking\n * this command what a rule matches answers with the set `check` reports on.\n */\nfunction union(graph: AnalysisResult['graph'], queries: readonly QuerySpec[]): Match[] {\n // `execute` already returns each path of nodes once, keyed the way this is,\n // so one selector needs no second pass and sending it through one anyway\n // returns the same matches.\n if (queries.length === 1) return execute(graph, queries[0] as QuerySpec);\n const seen = new Set<string>();\n const matches: Match[] = [];\n for (const spec of queries) {\n for (const match of execute(graph, spec)) {\n const key = match.nodes.map((node) => node.id).join('>');\n if (seen.has(key)) continue;\n seen.add(key);\n matches.push(match);\n }\n }\n return matches;\n}\n\ninterface RuleRow {\n readonly id: string;\n readonly severity: Severity;\n readonly description: string;\n /** The selector, where the rule is one. */\n readonly query: string | undefined;\n /** Where the reasoning is: an ADR, or the file that declared the rule. */\n readonly decided: string;\n}\n\nfunction renderRules(\n explain: boolean,\n version: string,\n projectRules: readonly ProjectRule[],\n only: string | null,\n configSource: string | null,\n): string {\n // A project rule is described by the selector it is, because that is what it\n // is - its message is a template, and a template is not a description.\n const rows: RuleRow[] = [\n ...RULE_IDS.map((id): RuleRow => ({\n id,\n severity: DEFAULT_SEVERITIES[id],\n description: RULE_DESCRIPTIONS[id],\n query: RULE_QUERIES[id],\n decided: decisionUrl(RULE_DECISIONS[id], version),\n })),\n ...projectRules.map((rule): RuleRow => ({\n id: rule.id,\n severity: rule.severity,\n description: rule.sources[0] as string,\n query: rule.sources.slice(1).join(' | ') || undefined,\n // A project rule only exists because a file declared it, so the source\n // is never null here and the first branch is for the type alone.\n decided: configSource === null ? `rules.${rule.name}` : `${configSource}: rules.${rule.name}`,\n })),\n ];\n\n const shown = only === null ? rows : rows.filter((row) => row.id === only);\n const width = Math.max(...shown.map((row) => row.id.length));\n const lines: string[] = [];\n for (const row of shown) {\n lines.push(`${row.id.padEnd(width)} ${row.severity.padEnd(5)} ${row.description}`);\n if (!explain) continue;\n if (row.query) lines.push(`${' '.repeat(width)} ${row.query}`);\n // Where the decision is written down, rather than a second copy of it. A\n // reader who has just been told their document is inconsistent is entitled\n // to know who decided that and why, and the ADR is the answer.\n lines.push(`${' '.repeat(width)} ${row.decided}`);\n }\n return `${lines.join('\\n')}\\n`;\n}\n\nfunction renderMatches(matches: readonly Match[], format: 'human' | 'json', total: number): string {\n if (format === 'json') {\n return `${JSON.stringify(\n {\n version: 1,\n count: matches.length,\n matches: matches.map((match) => ({\n nodes: match.nodes.map((node) => nodeSummary(node)),\n edges: match.edges.map((edge) => ({\n kind: edge.kind,\n from: edge.from,\n to: edge.to,\n file: edge.declaredAt.file,\n line: edge.declaredAt.span.start.line,\n })),\n })),\n },\n null,\n 2,\n )}\\n`;\n }\n\n if (matches.length === 0) return `no matches (searched ${total} nodes)\\n`;\n\n const lines: string[] = [];\n for (const match of matches) {\n const head = match.nodes[0] as SpecNode;\n const tail = match.nodes[match.nodes.length - 1]!;\n lines.push(renderMatch(match));\n lines.push(` ${formatRef(head.at)}${match.nodes.length > 1 ? ` ${formatRef(tail.at)}` : ''}`);\n }\n lines.push(`${matches.length} ${matches.length === 1 ? 'match' : 'matches'}`);\n return `${lines.join('\\n')}\\n`;\n}\n\nfunction nodeSummary(node: SpecNode): Record<string, unknown> {\n return {\n id: node.id,\n kind: node.kind,\n title: node.title,\n file: node.at.file,\n line: node.at.span.start.line,\n ...(node.kind === 'document' ? { phase: node.phase } : { state: node.disposition, openness: node.openness }),\n };\n}\n\n/**\n * Points at the exact character of a selector that failed to parse, in the\n * columns a terminal draws: a Han character before it takes two, so an offset\n * counted in UTF-16 units put the caret short of it. The offset is a position\n * the parser reached, never negative, so it needs no floor.\n */\nfunction renderQueryError(selector: string, error: QueryError): string {\n const caret = `${' '.repeat(displayWidth(selector.slice(0, error.offset)))}^`;\n return `spec-graph: ${error.message}\\n ${selector}\\n ${caret}\\n`;\n}\n\n/**\n * Compares two exports.\n *\n * Exit 0 whether anything changed or not: a diff describes, and `check` gates. A\n * diff that failed on a removed relation would fail every legitimate\n * supersession (ADR-0020).\n */\nasync function runDiff(\n paths: readonly [string, string],\n cwd: string,\n format: CliOptions['format'],\n out: (text: string) => void,\n err: (text: string) => void,\n): Promise<number> {\n const { readFile } = await import('node:fs/promises');\n const { resolve } = await import('node:path');\n const sides: GraphExport[] = [];\n for (const path of paths) {\n let raw: string;\n try {\n // Without the encoding this is a Buffer, which JSON.parse decodes as\n // UTF-8 all the same - so emptying the literal parses the same export.\n raw = await readFile(resolve(cwd, path), 'utf8');\n } catch (error) {\n err(`spec-graph: cannot read ${path}: ${(error as Error).message}\\n`);\n return EXIT_ERROR;\n }\n try {\n sides.push(parseGraphExport(raw, path));\n } catch (error) {\n // Every input parseGraphExport refuses, it refuses as a DiffInputError;\n // the rethrow is for a bug in it, which no file reaches.\n if (!(error instanceof DiffInputError)) throw error;\n err(`spec-graph: ${error.message}\\n`);\n return EXIT_ERROR;\n }\n }\n const [before, after] = sides as [GraphExport, GraphExport];\n const diff = diffExports(before, after);\n out(format === 'json' ? formatDiffJson(diff) : format === 'markdown' ? formatDiffMarkdown(diff) : formatDiffText(diff));\n return EXIT_OK;\n}\n\n/**\n * The version in the package's own manifest.\n *\n * The guards and the placeholder are for a manifest that is missing or\n * malformed, and the one this reads always parses and always has a version, so\n * no test reaches them without replacing the file the package ships - and the\n * same parse without the encoding reads a Buffer, which JSON.parse decodes as\n * UTF-8 all the same.\n */\nasync function readVersion(): Promise<string> {\n try {\n const { readFile } = await import('node:fs/promises');\n const url = new URL('../package.json', import.meta.url);\n const parsed: unknown = JSON.parse(await readFile(url, 'utf8'));\n if (typeof parsed === 'object' && parsed !== null && 'version' in parsed) {\n return String((parsed as { version: unknown }).version);\n }\n } catch {\n // Fall through to the placeholder rather than failing `--version`.\n }\n return '0.0.0';\n}\n"]}