@descent-vtt/spec-graph 0.8.0 → 0.9.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/CHANGELOG.md +410 -0
- package/README.md +102 -17
- package/dist/cli.d.ts +2 -2
- package/dist/cli.js +38 -19
- package/dist/cli.js.map +1 -1
- package/dist/directives.d.ts +9 -2
- package/dist/directives.js +15 -4
- package/dist/directives.js.map +1 -1
- package/dist/extract.d.ts +1 -1
- package/dist/extract.js +50 -16
- package/dist/extract.js.map +1 -1
- package/dist/glob.d.ts +44 -44
- package/dist/glob.js +152 -116
- package/dist/glob.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/lifecycle.js +10 -2
- package/dist/lifecycle.js.map +1 -1
- package/dist/markdown.d.ts +53 -161
- package/dist/markdown.js +42 -864
- package/dist/markdown.js.map +1 -1
- package/dist/report.d.ts +23 -0
- package/dist/report.js +80 -0
- package/dist/report.js.map +1 -1
- package/dist/rules.js +48 -14
- package/dist/rules.js.map +1 -1
- package/dist/sections.d.ts +1 -1
- package/dist/sections.js +7 -3
- package/dist/sections.js.map +1 -1
- package/dist/select.d.ts +2 -2
- package/dist/select.js +3 -3
- package/dist/select.js.map +1 -1
- package/dist/source.d.ts +6 -19
- package/dist/source.js +4 -70
- package/dist/source.js.map +1 -1
- package/dist/types.d.ts +23 -3
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/vendor/spec-core/markdown/frontmatter.d.ts +103 -0
- package/dist/vendor/spec-core/markdown/frontmatter.js +459 -0
- package/dist/vendor/spec-core/markdown/frontmatter.js.map +1 -0
- package/dist/vendor/spec-core/markdown/headings.d.ts +45 -0
- package/dist/vendor/spec-core/markdown/headings.js +199 -0
- package/dist/vendor/spec-core/markdown/headings.js.map +1 -0
- package/dist/vendor/spec-core/markdown/index.d.ts +5 -0
- package/dist/vendor/spec-core/markdown/index.js +4 -0
- package/dist/vendor/spec-core/markdown/index.js.map +1 -0
- package/dist/vendor/spec-core/markdown/layout.d.ts +39 -0
- package/dist/vendor/spec-core/markdown/layout.js +28 -0
- package/dist/vendor/spec-core/markdown/layout.js.map +1 -0
- package/dist/vendor/spec-core/markdown/links.d.ts +22 -0
- package/dist/vendor/spec-core/markdown/links.js +364 -0
- package/dist/vendor/spec-core/markdown/links.js.map +1 -0
- package/dist/vendor/spec-core/markdown/lists.d.ts +22 -0
- package/dist/vendor/spec-core/markdown/lists.js +127 -0
- package/dist/vendor/spec-core/markdown/lists.js.map +1 -0
- package/dist/vendor/spec-core/markdown/scan.d.ts +36 -0
- package/dist/vendor/spec-core/markdown/scan.js +439 -0
- package/dist/vendor/spec-core/markdown/scan.js.map +1 -0
- package/dist/vendor/spec-core/markdown/syntax.d.ts +75 -0
- package/dist/vendor/spec-core/markdown/syntax.js +181 -0
- package/dist/vendor/spec-core/markdown/syntax.js.map +1 -0
- package/dist/vendor/spec-core/markdown/tables.d.ts +18 -0
- package/dist/vendor/spec-core/markdown/tables.js +86 -0
- package/dist/vendor/spec-core/markdown/tables.js.map +1 -0
- package/dist/vendor/spec-core/markdown/types.d.ts +287 -0
- package/dist/vendor/spec-core/markdown/types.js +9 -0
- package/dist/vendor/spec-core/markdown/types.js.map +1 -0
- package/dist/vendor/spec-core/path/index.d.ts +1 -0
- package/dist/vendor/spec-core/path/index.js +2 -0
- package/dist/vendor/spec-core/path/index.js.map +1 -0
- package/dist/vendor/spec-core/path/posix.d.ts +83 -0
- package/dist/vendor/spec-core/path/posix.js +150 -0
- package/dist/vendor/spec-core/path/posix.js.map +1 -0
- package/dist/vendor/spec-core/pattern/automaton.d.ts +129 -0
- package/dist/vendor/spec-core/pattern/automaton.js +340 -0
- package/dist/vendor/spec-core/pattern/automaton.js.map +1 -0
- package/dist/vendor/spec-core/pattern/charset.d.ts +58 -0
- package/dist/vendor/spec-core/pattern/charset.js +116 -0
- package/dist/vendor/spec-core/pattern/charset.js.map +1 -0
- package/dist/vendor/spec-core/pattern/glob.d.ts +121 -0
- package/dist/vendor/spec-core/pattern/glob.js +481 -0
- package/dist/vendor/spec-core/pattern/glob.js.map +1 -0
- package/dist/vendor/spec-core/pattern/index.d.ts +6 -0
- package/dist/vendor/spec-core/pattern/index.js +4 -0
- package/dist/vendor/spec-core/pattern/index.js.map +1 -0
- package/dist/{regex.d.ts → vendor/spec-core/pattern/regex.d.ts} +20 -29
- package/dist/{regex.js → vendor/spec-core/pattern/regex.js} +40 -49
- package/dist/vendor/spec-core/pattern/regex.js.map +1 -0
- package/dist/vendor/spec-core/text/index.d.ts +2 -0
- package/dist/vendor/spec-core/text/index.js +2 -0
- package/dist/vendor/spec-core/text/index.js.map +1 -0
- package/dist/vendor/spec-core/text/lines.d.ts +72 -0
- package/dist/vendor/spec-core/text/lines.js +156 -0
- package/dist/vendor/spec-core/text/lines.js.map +1 -0
- package/dist/yaml.d.ts +44 -12
- package/dist/yaml.js +115 -206
- package/dist/yaml.js.map +1 -1
- package/package.json +3 -2
- package/src/vendor/spec-core/LICENSE +21 -0
- package/src/vendor/spec-core/README.md +8 -0
- package/dist/regex.js.map +0 -1
package/dist/cli.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export interface CliOptions {
|
|
|
54
54
|
readonly ratchet: boolean;
|
|
55
55
|
/** Skip the repository configuration file entirely. */
|
|
56
56
|
readonly noConfig: boolean;
|
|
57
|
-
readonly format: 'human' | 'json' | 'sarif' | 'markdown';
|
|
57
|
+
readonly format: 'human' | 'json' | 'sarif' | 'markdown' | 'gitlab';
|
|
58
58
|
readonly graphFormat: GraphFormat;
|
|
59
59
|
readonly severities: Partial<Record<AnyRuleId, Severity>>;
|
|
60
60
|
readonly color: boolean | null;
|
|
@@ -77,7 +77,7 @@ export interface CliIO {
|
|
|
77
77
|
readonly env?: Readonly<Record<string, string | undefined>> | undefined;
|
|
78
78
|
readonly isTTY?: boolean | undefined;
|
|
79
79
|
}
|
|
80
|
-
export declare 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.\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.\n --ignore-family <name> Families that are never citations - RFC when the repo\n cites RFC 2119 and keeps its own RFCs. Repeatable.\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 or markdown. sarif is the\n interchange format GitHub code scanning and editors\n already read, for check; markdown
|
|
80
|
+
export declare 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.\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.\n --ignore-family <name> Families that are never citations - RFC when the repo\n cites RFC 2119 and keeps its own RFCs. Repeatable.\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, gitlab or markdown. sarif is the\n interchange format GitHub code scanning and editors\n already read, and gitlab the Code Quality report a\n GitLab merge request reads, both for check; markdown\n is a table for a pull-request comment or\n $GITHUB_STEP_SUMMARY, for check or diff\n (default: 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\n --verbose Include parse problems, per-file detail, and every\n reference --ignore-ref or --ignore-family silenced\n -h, --help Show this help\n -v, --version Show the version\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\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\n A flag always wins over the file, and list flags add to it rather than\n replacing it.\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 configuration that did\n not load checks a different repository than the one configured, and would\n report that one as consistent. --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 gitlab > gl-code-quality-report.json\n spec-graph diff base.json head.json --format markdown >> \"$GITHUB_STEP_SUMMARY\"\n";
|
|
81
81
|
/** Parses argv into options. Throws {@link UsageError} on anything malformed. */
|
|
82
82
|
export declare function parseArgs(argv: readonly string[], cwd: string): CliOptions;
|
|
83
83
|
/** Runs the CLI and returns the process exit code. Never throws. */
|
package/dist/cli.js
CHANGED
|
@@ -14,7 +14,7 @@ import { discoverConfig, loadConfig } from './config.js';
|
|
|
14
14
|
import { DiffInputError, diffExports, formatDiffJson, formatDiffMarkdown, formatDiffText, parseGraphExport, } from './diff.js';
|
|
15
15
|
import { isGlob, underRoot } from './glob.js';
|
|
16
16
|
import { analyse, DEFAULT_PATTERNS, withDiagnostics } from './runner.js';
|
|
17
|
-
import { formatGraph, formatJson, formatMarkdown, formatReport, formatSarif, shouldUseAscii, shouldUseColor, } from './report.js';
|
|
17
|
+
import { formatGitlab, formatGraph, formatJson, formatMarkdown, formatReport, formatSarif, shouldUseAscii, shouldUseColor, } from './report.js';
|
|
18
18
|
import { DEFAULT_SEVERITIES, resolveStrict, RULE_DECISIONS, RULE_DESCRIPTIONS, RULE_IDS, RULE_QUERIES, } from './rules.js';
|
|
19
19
|
import { isAbsolutePath, toPosix } from './paths.js';
|
|
20
20
|
import { formatRef } from './source.js';
|
|
@@ -81,11 +81,13 @@ OPTIONS
|
|
|
81
81
|
--ratchet Also fail when a baseline entry no longer occurs, so
|
|
82
82
|
a paid-off exemption cannot outlive the defect.
|
|
83
83
|
--no-config Ignore .spec-graph.json and the package.json key.
|
|
84
|
-
--format <fmt> human, json, sarif or markdown. sarif is the
|
|
84
|
+
--format <fmt> human, json, sarif, gitlab or markdown. sarif is the
|
|
85
85
|
interchange format GitHub code scanning and editors
|
|
86
|
-
already read,
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
already read, and gitlab the Code Quality report a
|
|
87
|
+
GitLab merge request reads, both for check; markdown
|
|
88
|
+
is a table for a pull-request comment or
|
|
89
|
+
$GITHUB_STEP_SUMMARY, for check or diff
|
|
90
|
+
(default: human)
|
|
89
91
|
--graph-format <fmt> dot, mermaid or json (default: dot)
|
|
90
92
|
--documents-only Leave items out of the exported graph
|
|
91
93
|
--rule <id>=<severity> Override one rule: error, warn, info or off. A project
|
|
@@ -201,6 +203,7 @@ EXAMPLES
|
|
|
201
203
|
spec-graph check --rule project:no-draft-dependency=off
|
|
202
204
|
spec-graph query project:no-draft-dependency # what does that rule match?
|
|
203
205
|
spec-graph check --format markdown >> "$GITHUB_STEP_SUMMARY"
|
|
206
|
+
spec-graph check --format gitlab > gl-code-quality-report.json
|
|
204
207
|
spec-graph diff base.json head.json --format markdown >> "$GITHUB_STEP_SUMMARY"
|
|
205
208
|
`;
|
|
206
209
|
const SEVERITIES = ['error', 'warn', 'info', 'off'];
|
|
@@ -330,8 +333,8 @@ export function parseArgs(argv, cwd) {
|
|
|
330
333
|
break;
|
|
331
334
|
case '--format': {
|
|
332
335
|
const value = next(arg, i);
|
|
333
|
-
if (value !== 'human' && value !== 'json' && value !== 'sarif' && value !== 'markdown') {
|
|
334
|
-
throw new UsageError(`--format must be human, json, sarif or
|
|
336
|
+
if (value !== 'human' && value !== 'json' && value !== 'sarif' && value !== 'markdown' && value !== 'gitlab') {
|
|
337
|
+
throw new UsageError(`--format must be human, json, sarif, markdown or gitlab, got "${value}"`);
|
|
335
338
|
}
|
|
336
339
|
format = value;
|
|
337
340
|
i += 1;
|
|
@@ -381,12 +384,13 @@ export function parseArgs(argv, cwd) {
|
|
|
381
384
|
throw new UsageError(`unknown option "${arg}"\n run "spec-graph --help" to see the available options`);
|
|
382
385
|
}
|
|
383
386
|
}
|
|
384
|
-
// SARIF
|
|
385
|
-
// back to JSON would hand a pipeline something
|
|
386
|
-
// message about a schema rather than about the
|
|
387
|
-
// is for a pull request, which reads a check
|
|
388
|
-
|
|
389
|
-
|
|
387
|
+
// SARIF and GitLab's Code Quality are reports about findings, and only
|
|
388
|
+
// `check` produces those. Falling back to JSON would hand a pipeline something
|
|
389
|
+
// its uploader rejects with a message about a schema rather than about the
|
|
390
|
+
// command that was run. Markdown is for a pull request, which reads a check
|
|
391
|
+
// or a diff.
|
|
392
|
+
if ((format === 'sarif' || format === 'gitlab') && command !== 'check' && !help && !version) {
|
|
393
|
+
throw new UsageError(`--format ${format} reports findings, so it belongs to check, not to ${command}`);
|
|
390
394
|
}
|
|
391
395
|
if (format === 'markdown' && command !== 'check' && command !== 'diff' && !help && !version) {
|
|
392
396
|
throw new UsageError(`--format markdown is a report for a pull request, so it belongs to check or diff, not to ${command}`);
|
|
@@ -702,11 +706,13 @@ export async function main(io = {}) {
|
|
|
702
706
|
const reporterOptions = { verbose: options.verbose, max: options.max, escalated, ...baselineNote };
|
|
703
707
|
out(options.format === 'sarif'
|
|
704
708
|
? formatSarif(reported, reported.graph, { version: await readVersion(), escalated, projectRules })
|
|
705
|
-
: options.format === '
|
|
706
|
-
?
|
|
707
|
-
: options.format === '
|
|
708
|
-
?
|
|
709
|
-
:
|
|
709
|
+
: options.format === 'gitlab'
|
|
710
|
+
? formatGitlab(reported, { escalated })
|
|
711
|
+
: options.format === 'json'
|
|
712
|
+
? formatJson(reported, { escalated, ...baselineNote })
|
|
713
|
+
: options.format === 'markdown'
|
|
714
|
+
? formatMarkdown(reported, reporterOptions)
|
|
715
|
+
: `${formatReport(reported, { color, ascii, ...reporterOptions })}\n`);
|
|
710
716
|
if (!reported.ok || looseBaseline)
|
|
711
717
|
return EXIT_FAILED;
|
|
712
718
|
if (options.maxWarnings >= 0 && reported.summary.warnings > options.maxWarnings)
|
|
@@ -738,7 +744,20 @@ function below(root, from) {
|
|
|
738
744
|
function anchor(prefix, value) {
|
|
739
745
|
if (prefix === '' || isAbsolutePath(value))
|
|
740
746
|
return value;
|
|
741
|
-
|
|
747
|
+
const negated = value.startsWith('!');
|
|
748
|
+
const directories = prefix.split('/');
|
|
749
|
+
let rest = toPosix(negated ? value.slice(1) : value);
|
|
750
|
+
// `../docs` typed one directory down is the root's `docs`. That is arithmetic
|
|
751
|
+
// on two relative paths, and this is the one place both are known; left in
|
|
752
|
+
// the pattern, it reads as a glob climbing out of the root, which is refused.
|
|
753
|
+
// A bare `..` typed in `docs/deep` leaves `docs/`: the directory's contents,
|
|
754
|
+
// which is what it named.
|
|
755
|
+
while (directories.length > 0 && (rest === '..' || rest.startsWith('../'))) {
|
|
756
|
+
directories.pop();
|
|
757
|
+
rest = rest.slice(3);
|
|
758
|
+
}
|
|
759
|
+
const joined = [...directories, rest].join('/');
|
|
760
|
+
return negated ? `!${joined}` : joined;
|
|
742
761
|
}
|
|
743
762
|
/** The same, for an ignore, where a bare name is a directory at any depth. */
|
|
744
763
|
function anchorPath(prefix, pattern) {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;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,SAAS,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAA4C,MAAM,aAAa,CAAC;AACnH,OAAO,EACL,WAAW,EACX,UAAU,EACV,cAAc,EACd,YAAY,EACZ,WAAW,EACX,cAAc,EACd,cAAc,GAEf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,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;IACD,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,KAAmC,CAAC;IAC5D,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,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,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 */\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, underRoot } from './glob.js';\nimport { analyse, DEFAULT_PATTERNS, withDiagnostics, type AnalyseOptions, type AnalysisResult } from './runner.js';\nimport {\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 RULE_DESCRIPTIONS,\n RULE_IDS,\n RULE_QUERIES,\n} from './rules.js';\nimport { isAbsolutePath, 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';\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';\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.\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.\n --ignore-family <name> Families that are never citations - RFC when the repo\n cites RFC 2119 and keeps its own RFCs. Repeatable.\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 or markdown. sarif is the\n interchange format GitHub code scanning and editors\n already read, for check; markdown is a table for a\n pull-request comment or $GITHUB_STEP_SUMMARY, for check\n or diff (default: 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\n --verbose Include parse problems, per-file detail, and every\n reference --ignore-ref or --ignore-family silenced\n -h, --help Show this help\n -v, --version Show the version\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\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\n A flag always wins over the file, and list flags add to it rather than\n replacing it.\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 configuration that did\n not load checks a different repository than the one configured, and would\n report that one as consistent. --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 diff base.json head.json --format markdown >> \"$GITHUB_STEP_SUMMARY\"\n`;\n\nconst SEVERITIES: readonly Severity[] = ['error', 'warn', 'info', 'off'];\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 if (args.length > 0 && !((args[0] as string).startsWith('-'))) {\n const first = args[0] as string;\n if (first === 'check' || first === 'query' || first === 'graph' || first === 'rules' || first === 'diff') {\n command = first;\n args.shift();\n }\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: 'human' | 'json' | 'sarif' | 'markdown' = '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 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 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 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 = next(arg, i);\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(next(arg, i));\n i += 1;\n break;\n case '--ignore-family':\n ignoreFamilies.push(next(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 = next(arg, i);\n i += 1;\n break;\n case '--record-baseline':\n recordBaseline = next(arg, i);\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 (value !== 'human' && value !== 'json' && value !== 'sarif' && value !== 'markdown') {\n throw new UsageError(`--format must be human, json, sarif or markdown, 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 is a report about findings, and only `check` produces those. Falling\n // back to JSON would hand a pipeline something its uploader rejects with a\n // message about a schema rather than about the command that was run. Markdown\n // is for a pull request, which reads a check or a diff.\n if (format === 'sarif' && command !== 'check' && !help && !version) {\n throw new UsageError(`--format sarif 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 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 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/** Runs the CLI and returns the process exit code. Never throws. */\nexport async function main(io: CliIO = {}): 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 err = io.stderr ?? ((text) => process.stderr.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 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 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, projectRules, wanted ?? null, loaded.source));\n return EXIT_OK;\n }\n\n const patterns =\n options.patterns.length > 0 ? options.patterns.map((pattern) => anchor(here, pattern)) : (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 const analyseOptions: AnalyseOptions = {\n root,\n patterns,\n // A bare name prunes a directory of that name at any depth, the way a\n // .gitignore line does, so it means the same thing wherever it was typed.\n // A path or a glob is matched against the repository-relative path, and\n // leaving that one alone would make it silently match nothing.\n ignore: [...(file.ignore ?? []), ...options.ignore.map((pattern) => anchorPath(here, pattern))],\n ignoreReferences: [...(file.ignoreReferences ?? []), ...options.ignoreReferences],\n families: [...(file.families ?? []), ...options.families],\n ignoreFamilies: [...(file.ignoreFamilies ?? []), ...options.ignoreFamilies],\n historyPatterns: [...(file.historyPatterns ?? []), ...options.historyPatterns.map((pattern) => anchorPath(here, pattern))],\n severities,\n projectRules,\n ...(file.maxRelated !== undefined ? { maxRelated: file.maxRelated } : {}),\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) {\n const depth = here === '' ? 0 : here.split('/').length;\n err(`configuration: ${'../'.repeat(depth)}${loaded.source}\\n`);\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 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 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 // 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 await writeFile(underRoot(root, anchor(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) : anchor(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 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 // 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 && outcome.stale.length > 0))) {\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 baselineNote = note === undefined ? {} : { baseline: note };\n const reporterOptions = { verbose: options.verbose, max: options.max, escalated, ...baselineNote };\n out(\n options.format === 'sarif'\n ? formatSarif(reported, reported.graph, { version: await readVersion(), escalated, projectRules })\n : options.format === 'json'\n ? formatJson(reported, { escalated, ...baselineNote })\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 return start.startsWith(`${root}/`) ? start.slice(root.length + 1) : '';\n}\n\n/**\n * Re-anchors a path typed in `prefix` so it reads from the root.\n *\n * An absolute path is left alone: it was not relative to anywhere, so moving\n * the root cannot change what it means.\n */\nfunction anchor(prefix: string, value: string): string {\n if (prefix === '' || isAbsolutePath(value)) return value;\n return value.startsWith('!') ? `!${prefix}/${value.slice(1)}` : `${prefix}/${value}`;\n}\n\n/** The same, for an ignore, where a bare name is a directory at any depth. */\nfunction anchorPath(prefix: string, pattern: string): string {\n return isGlob(pattern) || pattern.includes('/') ? anchor(prefix, pattern) : pattern;\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 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 projectRules: readonly ProjectRule[] = [],\n only: string | null = null,\n configSource: string | null = 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: RULE_DECISIONS[id],\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 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/** Points at the exact character of a selector that failed to parse. */\nfunction renderQueryError(selector: string, error: QueryError): string {\n const caret = `${' '.repeat(Math.max(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 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 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\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":"AAA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AC;YACpD,GAAG,CAAC,eAAe,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;YACtC,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;IACD,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,KAAmC,CAAC;IAC5D,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,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,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 */\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, underRoot } from './glob.js';\nimport { analyse, DEFAULT_PATTERNS, withDiagnostics, type AnalyseOptions, type AnalysisResult } from './runner.js';\nimport {\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 RULE_DESCRIPTIONS,\n RULE_IDS,\n RULE_QUERIES,\n} from './rules.js';\nimport { isAbsolutePath, 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';\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';\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.\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.\n --ignore-family <name> Families that are never citations - RFC when the repo\n cites RFC 2119 and keeps its own RFCs. Repeatable.\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, gitlab or markdown. sarif is the\n interchange format GitHub code scanning and editors\n already read, and gitlab the Code Quality report a\n GitLab merge request reads, both for check; markdown\n is a table for a pull-request comment or\n $GITHUB_STEP_SUMMARY, for check or diff\n (default: 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\n --verbose Include parse problems, per-file detail, and every\n reference --ignore-ref or --ignore-family silenced\n -h, --help Show this help\n -v, --version Show the version\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\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\n A flag always wins over the file, and list flags add to it rather than\n replacing it.\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 configuration that did\n not load checks a different repository than the one configured, and would\n report that one as consistent. --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 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/** 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 if (args.length > 0 && !((args[0] as string).startsWith('-'))) {\n const first = args[0] as string;\n if (first === 'check' || first === 'query' || first === 'graph' || first === 'rules' || first === 'diff') {\n command = first;\n args.shift();\n }\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 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 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 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 = next(arg, i);\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(next(arg, i));\n i += 1;\n break;\n case '--ignore-family':\n ignoreFamilies.push(next(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 = next(arg, i);\n i += 1;\n break;\n case '--record-baseline':\n recordBaseline = next(arg, i);\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 (value !== 'human' && value !== 'json' && value !== 'sarif' && value !== 'markdown' && value !== 'gitlab') {\n throw new UsageError(`--format must be human, json, sarif, markdown or gitlab, 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 and GitLab's Code Quality are reports about findings, and only\n // `check` produces those. Falling back to JSON would hand a pipeline something\n // its uploader rejects with a message about a schema rather than about the\n // command that was run. Markdown is for a pull request, which reads a check\n // or a diff.\n if ((format === 'sarif' || format === 'gitlab') && 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 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 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/** Runs the CLI and returns the process exit code. Never throws. */\nexport async function main(io: CliIO = {}): 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 err = io.stderr ?? ((text) => process.stderr.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 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 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, projectRules, wanted ?? null, loaded.source));\n return EXIT_OK;\n }\n\n const patterns =\n options.patterns.length > 0 ? options.patterns.map((pattern) => anchor(here, pattern)) : (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 const analyseOptions: AnalyseOptions = {\n root,\n patterns,\n // A bare name prunes a directory of that name at any depth, the way a\n // .gitignore line does, so it means the same thing wherever it was typed.\n // A path or a glob is matched against the repository-relative path, and\n // leaving that one alone would make it silently match nothing.\n ignore: [...(file.ignore ?? []), ...options.ignore.map((pattern) => anchorPath(here, pattern))],\n ignoreReferences: [...(file.ignoreReferences ?? []), ...options.ignoreReferences],\n families: [...(file.families ?? []), ...options.families],\n ignoreFamilies: [...(file.ignoreFamilies ?? []), ...options.ignoreFamilies],\n historyPatterns: [...(file.historyPatterns ?? []), ...options.historyPatterns.map((pattern) => anchorPath(here, pattern))],\n severities,\n projectRules,\n ...(file.maxRelated !== undefined ? { maxRelated: file.maxRelated } : {}),\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) {\n const depth = here === '' ? 0 : here.split('/').length;\n err(`configuration: ${'../'.repeat(depth)}${loaded.source}\\n`);\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 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 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 // 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 await writeFile(underRoot(root, anchor(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) : anchor(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 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 // 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 && outcome.stale.length > 0))) {\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 baselineNote = note === undefined ? {} : { baseline: note };\n const reporterOptions = { verbose: options.verbose, max: options.max, escalated, ...baselineNote };\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 === 'json'\n ? formatJson(reported, { escalated, ...baselineNote })\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 return start.startsWith(`${root}/`) ? start.slice(root.length + 1) : '';\n}\n\n/**\n * Re-anchors a path typed in `prefix` so it reads from the root.\n *\n * An absolute path is left alone: it was not relative to anywhere, so moving\n * the root cannot change what it means.\n */\nfunction anchor(prefix: string, value: string): string {\n if (prefix === '' || isAbsolutePath(value)) return value;\n const negated = value.startsWith('!');\n const directories = prefix.split('/');\n let rest = toPosix(negated ? value.slice(1) : value);\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\n // the pattern, it reads as a glob climbing out of the root, which is refused.\n // A bare `..` typed in `docs/deep` leaves `docs/`: the directory's contents,\n // which is what it named.\n while (directories.length > 0 && (rest === '..' || rest.startsWith('../'))) {\n directories.pop();\n rest = rest.slice(3);\n }\n const joined = [...directories, rest].join('/');\n return negated ? `!${joined}` : joined;\n}\n\n/** The same, for an ignore, where a bare name is a directory at any depth. */\nfunction anchorPath(prefix: string, pattern: string): string {\n return isGlob(pattern) || pattern.includes('/') ? anchor(prefix, pattern) : pattern;\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 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 projectRules: readonly ProjectRule[] = [],\n only: string | null = null,\n configSource: string | null = 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: RULE_DECISIONS[id],\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 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/** Points at the exact character of a selector that failed to parse. */\nfunction renderQueryError(selector: string, error: QueryError): string {\n const caret = `${' '.repeat(Math.max(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 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 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\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"]}
|
package/dist/directives.d.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* A directive always wins over anything inferred, and says so in the report, so
|
|
18
18
|
* an override is visible rather than mysterious.
|
|
19
19
|
*/
|
|
20
|
-
import type
|
|
20
|
+
import { type HtmlComment, type ListItem, type ScannedDocument } from './markdown.js';
|
|
21
21
|
export type DirectiveName = 'spec-node' | 'spec-item' | 'spec-edge' | 'spec-ignore' | 'spec-history';
|
|
22
22
|
export interface Attribute {
|
|
23
23
|
readonly value: string;
|
|
@@ -35,7 +35,14 @@ export interface Directive {
|
|
|
35
35
|
/** Attribute names that were written but are not part of this directive. */
|
|
36
36
|
readonly unknownAttributes: readonly string[];
|
|
37
37
|
}
|
|
38
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Reads every spec-graph directive out of a document's HTML comments.
|
|
40
|
+
*
|
|
41
|
+
* Only out of a comment that closes. One that opens a line and never does runs
|
|
42
|
+
* to the end of the document, and read as a directive, a stray
|
|
43
|
+
* `<!-- @spec-ignore` would drop the file, and a stray `<!-- @spec-node` would
|
|
44
|
+
* take every `name=value` in the rest of it as an attribute.
|
|
45
|
+
*/
|
|
39
46
|
export declare function parseDirectives(comments: readonly HtmlComment[]): Directive[];
|
|
40
47
|
/** Reads an attribute, trimmed. Returns `null` when absent or blank. */
|
|
41
48
|
export declare function attr(directive: Directive, name: string): Attribute | null;
|
package/dist/directives.js
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* A directive always wins over anything inferred, and says so in the report, so
|
|
18
18
|
* an override is visible rather than mysterious.
|
|
19
19
|
*/
|
|
20
|
+
import { isMarkdownLine } from './markdown.js';
|
|
20
21
|
const KNOWN = new Set([
|
|
21
22
|
'spec-node',
|
|
22
23
|
'spec-item',
|
|
@@ -35,10 +36,19 @@ const SCHEMA = {
|
|
|
35
36
|
'spec-edge': ['kind', 'to', 'from', 'reason'],
|
|
36
37
|
'spec-ignore': ['reason'],
|
|
37
38
|
};
|
|
38
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Reads every spec-graph directive out of a document's HTML comments.
|
|
41
|
+
*
|
|
42
|
+
* Only out of a comment that closes. One that opens a line and never does runs
|
|
43
|
+
* to the end of the document, and read as a directive, a stray
|
|
44
|
+
* `<!-- @spec-ignore` would drop the file, and a stray `<!-- @spec-node` would
|
|
45
|
+
* take every `name=value` in the rest of it as an attribute.
|
|
46
|
+
*/
|
|
39
47
|
export function parseDirectives(comments) {
|
|
40
48
|
const out = [];
|
|
41
49
|
for (const comment of comments) {
|
|
50
|
+
if (comment.closed === false)
|
|
51
|
+
continue;
|
|
42
52
|
const head = DIRECTIVE_HEAD.exec(comment.inner);
|
|
43
53
|
if (!head)
|
|
44
54
|
continue;
|
|
@@ -145,16 +155,17 @@ export function bindItemDirectives(scanned, directives) {
|
|
|
145
155
|
// how long this takes and nothing else.
|
|
146
156
|
if (wanted.length === 0)
|
|
147
157
|
return bound;
|
|
148
|
-
const { lines, listItems
|
|
158
|
+
const { lines, listItems } = scanned;
|
|
159
|
+
const masked = scanned.masks.structure;
|
|
149
160
|
// The indentation of each line holding nothing but whitespace and comments.
|
|
150
|
-
// Code
|
|
161
|
+
// Code and raw-text HTML are masked too, so they are told apart by their flags.
|
|
151
162
|
const quiet = new Map();
|
|
152
163
|
// For every other line, where the run of quiet lines directly above it began,
|
|
153
164
|
// when there was one.
|
|
154
165
|
const quietFrom = new Map();
|
|
155
166
|
let run;
|
|
156
167
|
for (const line of lines) {
|
|
157
|
-
if (
|
|
168
|
+
if (isMarkdownLine(line) && masked.slice(line.contentStart, line.end).trim() === '') {
|
|
158
169
|
quiet.set(line.line, line.indent);
|
|
159
170
|
run ??= line.start;
|
|
160
171
|
continue;
|