@descent-vtt/spec-guard 0.6.0 → 0.7.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 CHANGED
@@ -5,7 +5,14 @@ All notable changes to this project are documented here. Versions follow
5
5
  may change in a minor release — each such change is listed under **Changed**
6
6
  with the flag that restores the previous behaviour.
7
7
 
8
- ## Unreleased
8
+ ## 0.7.0
9
+
10
+ Two things an architecture document could not do before. It can state the shape
11
+ of a codebase: which layers depend on which, and that nothing imports itself
12
+ round a loop. And it can be asked, before any code is written, which of its
13
+ rules govern the file about to change - from the command line, or by an AI agent
14
+ over the Model Context Protocol. Building the second found a false green older
15
+ than every release, and it is fixed below.
9
16
 
10
17
  ### Added
11
18
 
@@ -30,16 +37,76 @@ with the flag that restores the previous behaviour.
30
37
  and for why the other four languages are not in the graph.
31
38
  - `buildGraph`, `resolveReference`, `stronglyConnected`, `cyclicComponents`,
32
39
  `witness`, `checkLayers` and `referenceForms` are exported, with their types.
40
+ - **`spec-guard query <paths...>`** - the rules in force for a file or directory,
41
+ grouped by the document that states them, with each rule's reason, a path's
42
+ position in every layer order (`may import`, `must not import`), and any
43
+ baseline entry that exempts it. Answered from the specs alone, without reading
44
+ the codebase, so it works for a file that does not exist yet; `--json` for
45
+ scripts. Rules in documents that are not in force are counted and named, and
46
+ listed with `--ignore-status`. The arithmetic behind it is tested against the
47
+ files a real run searches, under both engines and on random trees; see
48
+ [ADR-0012](docs/adr/0012-query-and-mcp.md) for the three things it cannot see.
49
+ - **`spec-guard mcp`** - a Model Context Protocol server on stdio, with no
50
+ dependency on the MCP SDK. Tools `get_architectural_rules` (the query) and
51
+ `check_architecture` (a run, narrowed to the rules governing given paths, each
52
+ judged over its whole scope, with violations marked as in those paths or not);
53
+ resources `spec://rules` and `spec://doc/{+path}`. Serves clients that open
54
+ with `initialize` (2024-10-07 to 2025-11-25) and clients on 2026-07-28 that
55
+ version every request and probe with `server/discover`, classifying each
56
+ request the way the TypeScript SDK's own server does. Run end to end against
57
+ the official clients: `@modelcontextprotocol/sdk` 1.30.0, and
58
+ `@modelcontextprotocol/client` 2.0.0 pinned to 2026-07-28, probing, and on
59
+ the legacy handshake.
60
+ - **`--spec <pattern>`**, repeatable: where `query` and `mcp` take their specs,
61
+ and an alternative to positional patterns for a run.
62
+ - `select` on `runSpecGuard`, to execute only some of the resolved assertions.
63
+ `readSpecs`, `parseDocument`, `parseTitle`, `walkPaths`, `governs`,
64
+ `queryRules`, `createMcpHandler` and `serveStdio` are exported, with their types.
65
+
66
+ ### Fixed
67
+
68
+ - **A rule whose every `target` was missing searched the whole repository**
69
+ under `--allow-missing-targets`, because an empty target list means the root
70
+ to the engine. So `@assert-count target="src/auth" symbol="verifyToken"
71
+ min="1"` kept passing after `src/auth` was deleted, as long as a test still
72
+ named `verifyToken`; import, layer and cycle rules did the same. This has been
73
+ true since 0.1.0 - the 0.3.0 entry below that describes the old behaviour as
74
+ "search nothing, find nothing" was wrong about what the code did. Such a rule
75
+ now has an empty scope: it fails as one, and with `--allow-empty-scope` or
76
+ `allow-empty="true"` it finds nothing. **If you rely on
77
+ `--allow-missing-targets` for a rule whose only target is gone, add
78
+ `--allow-empty-scope`.**
79
+ - An import rule whose only target is missing, without `--allow-missing-targets`,
80
+ now says the target does not exist instead of that its scope is empty.
33
81
 
34
82
  ### Changed
35
83
 
36
- - **Mutation score 97.97%** over 5,078 mutants, up from 0.6.0's 97.77%. The two
37
- new modules are at 99.51% (`graph.ts`) and 96.43% (`layers.ts`), and each of
38
- their three survivors was shown equivalent by running the mutated build
39
- against the real one on thousands of random inputs. The first sweep of this
40
- work found 34 survivors that 37 hand-written negative controls had not; see
41
- [ADR-0003](docs/adr/0003-mutation-testing.md) for how they were replayed from
42
- the report and killed.
84
+ - **`query` and `mcp` are commands when they are the first argument.** A spec
85
+ file literally named `query` or `mcp`, passed as the first pattern, now starts
86
+ a command instead; write `./query`, or put it after `--`.
87
+ - **A rule whose every `target` is missing has an empty scope under
88
+ `--allow-missing-targets`**, where it used to search the whole repository -
89
+ see Fixed. Add `--allow-empty-scope`, or `allow-empty="true"` on the rule, for
90
+ it to pass. Searching the root in its place is not restorable: it was the bug.
91
+ - **Mutation score 98.47%** over 6,263 mutants, up from 0.6.0's 97.77%, with 93
92
+ survivors - four fewer than before the 1,185 mutants this release adds. The
93
+ layering and cycle modules are at 99.51% (`graph.ts`) and 96.43%
94
+ (`layers.ts`); their three survivors were shown equivalent by running the
95
+ mutated build against the real one on thousands of random inputs. The query
96
+ and the server (`query.ts`, `rules.ts`, `mcp.ts`, `specs.ts`) are all at 100%;
97
+ most of the survivors found on the way were code nothing could observe, and it
98
+ was deleted. See [ADR-0003](docs/adr/0003-mutation-testing.md) for both
99
+ accounts, and for why one sweep's count is good to about three.
100
+ - `version(manifest?)` takes the manifest to read, so its fallback for a broken
101
+ install - `0.0.0` rather than a crash - is tested.
102
+ - **Reading specs is several times faster**, which a query's budget made worth
103
+ measuring. `maskCode` builds ranges instead of blanking a character array
104
+ (7.8 ms to 1.1 ms over this repository's specs, identical output on 72 real
105
+ documents and 100,000 random inputs); spec globs no longer stat every file
106
+ they list (102 ms to 18 ms over 1,200 specs on Windows); and specs are read
107
+ 16 at a time. A query over this repository went from 24.6 ms to 5.1 ms. A run
108
+ spends most of its time searching code, so this repository's selfcheck gained
109
+ about 8%.
43
110
  - The SARIF fingerprint of an assertion that names neither a symbol nor a file
44
111
  now includes its description. Only the two new kinds are affected; every
45
112
  existing alert keeps its identity. Without it, two cycle rules on one target
package/README.md CHANGED
@@ -575,15 +575,100 @@ pass if you accepted it today.
575
575
  [ADR-0010](docs/adr/0010-spec-status.md) has the full reasoning, including why
576
576
  there is no per-directive `if-status` attribute.
577
577
 
578
+ ## Asking before writing - `query` and the MCP server
579
+
580
+ A run tells you, after the fact, that code broke a rule. `spec-guard query`
581
+ tells you which rules a file is under before you touch it:
582
+
583
+ ```bash
584
+ spec-guard query src/domain/user.ts --spec "docs/**/*.md"
585
+ ```
586
+
587
+ ```text
588
+ src/domain/user.ts
589
+ 3 rules from 2 documents
590
+
591
+ ADR-0004: No legacy client (docs/adr/0004-legacy.md, accepted)
592
+ :12 @assert-absence "LegacyClient" must not appear in src
593
+
594
+ ADR-0011: Layering constraints (docs/adr/0011-layers.md, accepted)
595
+ :40 @assert-layers src must keep its layers in order, src/domain < src/application < src/infrastructure
596
+ layer: src/domain (1 of 3)
597
+ may import: src/domain
598
+ must not import: src/application, src/infrastructure
599
+ reason: the domain depends on nothing
600
+ :41 @assert-import-absence src/domain must not import "pg"
601
+
602
+ 1 more rule would govern this path if docs/adr/0014-clocks.md (proposed) were in force; --ignore-status lists it
603
+
604
+ 14 spec files read in 6.1ms
605
+ ```
606
+
607
+ It answers from the specs alone, without reading the codebase, so it works for
608
+ a file that does not exist yet. A directory lists every rule that could reach a
609
+ file under it. `--json` is the same answer for a script. Rules in documents that
610
+ are not in force are counted and named, never silently left out.
611
+
612
+ The arithmetic that decides whether a rule governs a path is tested against the
613
+ walk a real run makes, file for file, under both engines and on randomly
614
+ generated trees. [ADR-0012](docs/adr/0012-query-and-mcp.md) lists the three
615
+ things it cannot see: file content (binary, oversized, unreadable), symbolic
616
+ links, and letter case on case-insensitive filesystems.
617
+
618
+ ### The MCP server
619
+
620
+ `spec-guard mcp` serves the same answer to an AI agent over the
621
+ [Model Context Protocol](https://modelcontextprotocol.io) on stdio, with no
622
+ dependency on the MCP SDK. Register it with your client as a stdio server; the
623
+ usual `mcpServers` entry is:
624
+
625
+ ```json
626
+ {
627
+ "mcpServers": {
628
+ "spec-guard": {
629
+ "command": "npx",
630
+ "args": ["spec-guard", "mcp", "--spec", "docs/**/*.md"]
631
+ }
632
+ }
633
+ }
634
+ ```
635
+
636
+ The root defaults to the directory the client starts the server in; pass
637
+ `--root` if yours starts servers somewhere else. On Windows, `npx` is a `.cmd`
638
+ script that a client spawning without a shell cannot launch; point `command` at
639
+ `node` and the first argument at
640
+ `node_modules/@descent-vtt/spec-guard/bin/spec-guard.js` instead. Run flags such
641
+ as `--engine`, `--strict`, `--ignore-status` and `--allow-missing-targets` apply
642
+ to its checks.
643
+
644
+ | Tool | What it does |
645
+ | --- | --- |
646
+ | `get_architectural_rules(path, include_inactive?)` | The query above, as text and as structured content |
647
+ | `check_architecture(paths?)` | A run. Given paths, only the rules that govern them, each over its whole scope, with every violation marked as in those paths or not |
648
+
649
+ | Resource | What it holds |
650
+ | --- | --- |
651
+ | `spec://rules` | Every rule in force, as JSON |
652
+ | `spec://doc/{+path}` | Any spec document, in force or not |
653
+
654
+ Both protocol eras are served: clients that open with `initialize` (revisions
655
+ 2024-10-07 to 2025-11-25), and clients on 2026-07-28 that put the protocol
656
+ version on every request and probe with `server/discover`. Nothing is cached, so
657
+ an ADR edited mid-session is read as edited. ADR-0012 has the shapes, the
658
+ sources they follow, and what is deliberately not implemented.
659
+
578
660
  ## CLI
579
661
 
580
662
  ```bash
581
- spec-guard [patterns...] [options]
663
+ spec-guard [patterns...] [options] # execute the directives
664
+ spec-guard query <paths...> [options] # the rules in force for files or directories
665
+ spec-guard mcp [options] # serve the rules over MCP on stdio
582
666
  ```
583
667
 
584
668
  | Option | Description |
585
669
  | --- | --- |
586
670
  | `-r, --root <path>` | Codebase root that assertions resolve against (default: cwd) |
671
+ | `--spec <pattern>` | A spec glob or path, repeatable. `query` and `mcp` take their specs only from here |
587
672
  | `-v, --verbose` | Print passing assertions too |
588
673
  | `--fail-fast` | Stop at the first failing assertion |
589
674
  | `--json` | Machine-readable report on stdout (same as `--format json`) |
package/dist/cli.d.ts CHANGED
@@ -6,6 +6,7 @@
6
6
  * 1 - an assertion failed, or a directive was invalid
7
7
  * 2 - spec-guard could not run (bad usage, no spec files, missing engine)
8
8
  */
9
+ import type { Readable } from 'node:stream';
9
10
  import type { EnginePreference } from './engine.js';
10
11
  export declare const EXIT_OK = 0;
11
12
  export declare const EXIT_FAILED = 1;
@@ -16,11 +17,18 @@ export interface CliIO {
16
17
  env: NodeJS.ProcessEnv;
17
18
  cwd: string;
18
19
  isTTY: boolean;
20
+ /** Where `spec-guard mcp` reads its messages. Only that command reads input. */
21
+ stdin?: Readable;
19
22
  }
23
+ /** What the command line asked for: a run, a query, or a server. */
24
+ export type Command = 'check' | 'query' | 'mcp';
20
25
  /** How a finished run is written out. */
21
26
  export type OutputFormat = 'human' | 'json' | 'sarif';
22
27
  export interface CliOptions {
28
+ command: Command;
23
29
  patterns: string[];
30
+ /** The paths `spec-guard query` asks about. */
31
+ paths: string[];
24
32
  root: string;
25
33
  verbose: boolean;
26
34
  failFast: boolean;
@@ -44,8 +52,15 @@ export interface CliOptions {
44
52
  }
45
53
  export declare class UsageError extends Error {
46
54
  }
47
- export declare function version(): string;
48
- export declare const HELP = "spec-guard - Executable architecture assertions for Markdown specs & ADRs\n\nUsage\n spec-guard [patterns...] [options]\n\nPatterns\n Globs or paths to the Markdown specs to execute. A directory expands to the\n Markdown files inside it. Defaults to \"docs/**/*.md\" when omitted.\n\nOptions\n -r, --root <path> Codebase root that assertions are resolved against (default: cwd)\n -v, --verbose Print passing assertions too\n --fail-fast Stop at the first failing assertion\n --json Emit a machine-readable JSON report (same as --format json)\n --format <name> human | json | sarif (sarif uploads to GitHub code scanning)\n --engine <name> auto | rg | js (default: auto - scanner for small trees, ripgrep for big ones)\n --strict Treat analysis that could not be completed as a failure\n --allow-missing-targets\n Tolerate target paths that do not exist (they fail by default)\n --allow-empty-scope Tolerate assertions whose scope holds no files (they fail by default)\n --print-baseline Print the baseline=\"...\" that would exempt today's violations, and exit\n --no-default-skips Search .git, .hg, .svn and node_modules too\n --ignore-status Execute directives in draft, proposed and superseded documents too\n --include-specs Also count matches inside the spec files themselves\n --max-snippets <n> Failure snippets per assertion (default: 5)\n --concurrency <n> Assertions executed in parallel (default: 8)\n --allow-empty Exit 0 when no spec files matched (about the run, not an assertion)\n --color/--no-color Force colour on or off (NO_COLOR is honoured)\n -h, --help Show this help\n --version Print the version\n\nDirectives\n <!-- @assert-absence target=\"src/\" symbol=\"LegacyGateway\" exclude=\"src/legacy/**\" -->\n <!-- @assert-count target=\"src/\" symbol=\"SessionManager\" expected=\"1\" -->\n <!-- @assert-present file=\"SECURITY.md\" -->\n <!-- @assert-import-cycle target=\"src/\" types=\"ignore\" -->\n <!-- @assert-layers target=\"src/\" order=\"domain, application, infrastructure\" -->\n\n Matches inside comments do not count; add comments=\"include\" to count them.\n An assertion whose scope holds no files fails; add allow-empty=\"true\" to allow it.\n A document whose status is draft, proposed, rejected, deprecated or superseded\n is reported and not executed; --ignore-status runs it anyway.\n\nExit codes\n 0 all assertions passed 1 an assertion failed 2 spec-guard could not run";
55
+ /**
56
+ * The installed version, or `0.0.0` when the manifest cannot say.
57
+ *
58
+ * The manifest is a parameter so the fallback can be tested: it is what a
59
+ * broken install reports instead of crashing, and a fallback nothing runs is a
60
+ * fallback nobody knows still works.
61
+ */
62
+ export declare function version(manifest?: string): string;
63
+ export declare const HELP = "spec-guard - Executable architecture assertions for Markdown specs & ADRs\n\nUsage\n spec-guard [patterns...] [options] execute the directives in the specs\n spec-guard query <paths...> [options] list the rules in force for files or directories\n spec-guard mcp [options] serve the rules to an AI agent over MCP on stdio\n\nPatterns\n Globs or paths to the Markdown specs to execute. A directory expands to the\n Markdown files inside it. Defaults to \"docs/**/*.md\" when omitted. query and\n mcp take theirs from --spec.\n\nOptions\n -r, --root <path> Codebase root that assertions are resolved against (default: cwd)\n --spec <pattern> A spec glob or path; repeatable (default: \"docs/**/*.md\")\n -v, --verbose Print passing assertions too\n --fail-fast Stop at the first failing assertion\n --json Emit a machine-readable JSON report (same as --format json)\n --format <name> human | json | sarif (sarif uploads to GitHub code scanning)\n --engine <name> auto | rg | js (default: auto - scanner for small trees, ripgrep for big ones)\n --strict Treat analysis that could not be completed as a failure\n --allow-missing-targets\n Tolerate target paths that do not exist (they fail by default)\n --allow-empty-scope Tolerate assertions whose scope holds no files (they fail by default)\n --print-baseline Print the baseline=\"...\" that would exempt today's violations, and exit\n --no-default-skips Search .git, .hg, .svn and node_modules too\n --ignore-status Execute directives in draft, proposed and superseded documents too\n --include-specs Also count matches inside the spec files themselves\n --max-snippets <n> Failure snippets per assertion (default: 5)\n --concurrency <n> Assertions executed in parallel (default: 8)\n --allow-empty Exit 0 when no spec files matched (about the run, not an assertion)\n --color/--no-color Force colour on or off (NO_COLOR is honoured)\n -h, --help Show this help\n --version Print the version\n\nDirectives\n <!-- @assert-absence target=\"src/\" symbol=\"LegacyGateway\" exclude=\"src/legacy/**\" -->\n <!-- @assert-count target=\"src/\" symbol=\"SessionManager\" expected=\"1\" -->\n <!-- @assert-present file=\"SECURITY.md\" -->\n <!-- @assert-import-cycle target=\"src/\" types=\"ignore\" -->\n <!-- @assert-layers target=\"src/\" order=\"domain, application, infrastructure\" -->\n\n Matches inside comments do not count; add comments=\"include\" to count them.\n An assertion whose scope holds no files fails; add allow-empty=\"true\" to allow it.\n A document whose status is draft, proposed, rejected, deprecated or superseded\n is reported and not executed; --ignore-status runs it anyway.\n\nquery answers from the specs alone, without reading the codebase, so it works\nfor a file that does not exist yet. mcp offers the same answer, and a check,\nas the tools get_architectural_rules and check_architecture.\n\nExit codes\n 0 all assertions passed 1 an assertion failed 2 spec-guard could not run";
49
64
  /** Minimal, dependency-free argv parser. Supports `--flag value` and `--flag=value`. */
50
65
  export declare function parseArgs(argv: readonly string[], cwd: string): CliOptions;
51
66
  /** Runs the CLI and resolves to the process exit code. */
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,eAAO,MAAM,OAAO,IAAI,CAAC;AACzB,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,UAAU,IAAI,CAAC;AAE5B,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,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,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,qBAAa,UAAW,SAAQ,KAAK;CAAG;AAExC;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,QAAQ,SAAoB,GAAG,MAAM,CAQ5D;AAED,eAAO,MAAM,IAAI,opGAoD8D,CAAC;AA2DhF,wFAAwF;AACxF,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,CAqJ1E;AAoED,0DAA0D;AAC1D,wBAAsB,IAAI,CAAC,IAAI,GAAE,SAAS,MAAM,EAA0B,EAAE,EAAE,GAAE,KAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CA8EpH"}
package/dist/cli.js CHANGED
@@ -8,6 +8,8 @@
8
8
  */
9
9
  import { createRequire } from 'node:module';
10
10
  import path from 'node:path';
11
+ import { createMcpHandler, serveStdio } from './mcp.js';
12
+ import { formatQuery, formatQueryJson, queryRules } from './query.js';
11
13
  import { formatBaselines, formatJson, formatReport, formatSarif, shouldUseAscii, shouldUseColor } from './reporter.js';
12
14
  import { DEFAULT_CONCURRENCY, DEFAULT_MAX_SNIPPETS, runSpecGuard } from './runner.js';
13
15
  export const EXIT_OK = 0;
@@ -15,28 +17,38 @@ export const EXIT_FAILED = 1;
15
17
  export const EXIT_ERROR = 2;
16
18
  export class UsageError extends Error {
17
19
  }
18
- export function version() {
20
+ /**
21
+ * The installed version, or `0.0.0` when the manifest cannot say.
22
+ *
23
+ * The manifest is a parameter so the fallback can be tested: it is what a
24
+ * broken install reports instead of crashing, and a fallback nothing runs is a
25
+ * fallback nobody knows still works.
26
+ */
27
+ export function version(manifest = '../package.json') {
19
28
  try {
20
29
  const require = createRequire(import.meta.url);
21
- const pkg = require('../package.json');
30
+ const pkg = require(manifest);
22
31
  return pkg.version ?? '0.0.0';
23
32
  }
24
33
  catch {
25
- /* c8 ignore next 2 -- only reachable from a broken install */
26
34
  return '0.0.0';
27
35
  }
28
36
  }
29
37
  export const HELP = `spec-guard - Executable architecture assertions for Markdown specs & ADRs
30
38
 
31
39
  Usage
32
- spec-guard [patterns...] [options]
40
+ spec-guard [patterns...] [options] execute the directives in the specs
41
+ spec-guard query <paths...> [options] list the rules in force for files or directories
42
+ spec-guard mcp [options] serve the rules to an AI agent over MCP on stdio
33
43
 
34
44
  Patterns
35
45
  Globs or paths to the Markdown specs to execute. A directory expands to the
36
- Markdown files inside it. Defaults to "docs/**/*.md" when omitted.
46
+ Markdown files inside it. Defaults to "docs/**/*.md" when omitted. query and
47
+ mcp take theirs from --spec.
37
48
 
38
49
  Options
39
50
  -r, --root <path> Codebase root that assertions are resolved against (default: cwd)
51
+ --spec <pattern> A spec glob or path; repeatable (default: "docs/**/*.md")
40
52
  -v, --verbose Print passing assertions too
41
53
  --fail-fast Stop at the first failing assertion
42
54
  --json Emit a machine-readable JSON report (same as --format json)
@@ -69,6 +81,10 @@ Directives
69
81
  A document whose status is draft, proposed, rejected, deprecated or superseded
70
82
  is reported and not executed; --ignore-status runs it anyway.
71
83
 
84
+ query answers from the specs alone, without reading the codebase, so it works
85
+ for a file that does not exist yet. mcp offers the same answer, and a check,
86
+ as the tools get_architectural_rules and check_architecture.
87
+
72
88
  Exit codes
73
89
  0 all assertions passed 1 an assertion failed 2 spec-guard could not run`;
74
90
  const ENGINE_ALIASES = {
@@ -99,10 +115,39 @@ function positiveInteger(name, value) {
99
115
  throw new UsageError(`Option ${name} expects a non-negative integer, got "${value}".`);
100
116
  return Number.parseInt(value, 10);
101
117
  }
118
+ /**
119
+ * Options that mean nothing to a command, by command.
120
+ *
121
+ * Refused rather than ignored: `spec-guard query --strict` accepting the flag
122
+ * and doing nothing with it would tell someone their query was strict.
123
+ */
124
+ const NOT_FOR = {
125
+ query: new Set([
126
+ '--verbose',
127
+ '--fail-fast',
128
+ '--engine',
129
+ '--strict',
130
+ '--allow-missing-targets',
131
+ '--allow-empty-scope',
132
+ '--print-baseline',
133
+ '--allow-empty',
134
+ '--max-snippets',
135
+ '--concurrency',
136
+ '--color',
137
+ '--no-color',
138
+ ]),
139
+ mcp: new Set(['--verbose', '--fail-fast', '--json', '--format', '--print-baseline', '--allow-empty', '--color', '--no-color']),
140
+ };
141
+ /** The long name of an option, whichever way it was spelled. */
142
+ const LONG_NAMES = { '-v': '--verbose' };
102
143
  /** Minimal, dependency-free argv parser. Supports `--flag value` and `--flag=value`. */
103
144
  export function parseArgs(argv, cwd) {
145
+ const command = argv[0] === 'query' || argv[0] === 'mcp' ? argv[0] : 'check';
146
+ const specs = [];
104
147
  const options = {
148
+ command,
105
149
  patterns: [],
150
+ paths: [],
106
151
  root: cwd,
107
152
  verbose: false,
108
153
  failFast: false,
@@ -123,10 +168,12 @@ export function parseArgs(argv, cwd) {
123
168
  version: false,
124
169
  };
125
170
  let onlyPositional = false;
126
- for (let index = 0; index < argv.length; index++) {
171
+ for (let index = command === 'check' ? 0 : 1; index < argv.length; index++) {
127
172
  const argument = argv[index];
128
173
  if (onlyPositional || !argument.startsWith('-') || argument === '-') {
129
- options.patterns.push(argument);
174
+ if (command === 'mcp')
175
+ throw new UsageError(`spec-guard mcp takes no arguments, got "${argument}". Name specs with --spec.`);
176
+ (command === 'query' ? options.paths : options.patterns).push(argument);
130
177
  continue;
131
178
  }
132
179
  if (argument === '--') {
@@ -142,6 +189,9 @@ export function parseArgs(argv, cwd) {
142
189
  index += 1;
143
190
  return requireValue(name, argv[index]);
144
191
  };
192
+ if (command !== 'check' && NOT_FOR[command].has(LONG_NAMES[name] ?? name)) {
193
+ throw new UsageError(`Option ${name} does not apply to spec-guard ${command}.`);
194
+ }
145
195
  switch (name) {
146
196
  case '-h':
147
197
  case '--help':
@@ -163,6 +213,9 @@ export function parseArgs(argv, cwd) {
163
213
  break;
164
214
  case '--format': {
165
215
  const value = nextValue().toLowerCase();
216
+ if (command === 'query' && value === 'sarif') {
217
+ throw new UsageError('spec-guard query has no sarif format: it lists rules, not results. Expected human or json.');
218
+ }
166
219
  if (value !== 'human' && value !== 'json' && value !== 'sarif') {
167
220
  throw new UsageError(`Unknown format "${value}". Expected human, json or sarif.`);
168
221
  }
@@ -204,6 +257,9 @@ export function parseArgs(argv, cwd) {
204
257
  case '--root':
205
258
  options.root = path.resolve(cwd, nextValue());
206
259
  break;
260
+ case '--spec':
261
+ specs.push(nextValue());
262
+ break;
207
263
  case '--engine': {
208
264
  const value = nextValue().toLowerCase();
209
265
  const engine = ENGINE_ALIASES[value];
@@ -223,8 +279,12 @@ export function parseArgs(argv, cwd) {
223
279
  throw new UsageError(`Unknown option "${name}". Run spec-guard --help.`);
224
280
  }
225
281
  }
282
+ options.patterns.push(...specs);
226
283
  if (options.patterns.length === 0)
227
284
  options.patterns = ['docs/**/*.md'];
285
+ if (command === 'query' && options.paths.length === 0 && !options.help && !options.version) {
286
+ throw new UsageError('spec-guard query needs a path to ask about, e.g. spec-guard query src/domain/user.ts.');
287
+ }
228
288
  return options;
229
289
  }
230
290
  function defaultIO() {
@@ -234,8 +294,63 @@ function defaultIO() {
234
294
  env: process.env,
235
295
  cwd: process.cwd(),
236
296
  isTTY: Boolean(process.stdout.isTTY),
297
+ stdin: process.stdin,
237
298
  };
238
299
  }
300
+ /** `spec-guard query`: prints the rules governing each path. */
301
+ async function runQuery(options, io) {
302
+ let report;
303
+ try {
304
+ report = await queryRules({
305
+ patterns: options.patterns,
306
+ root: options.root,
307
+ paths: options.paths,
308
+ includeInactive: options.ignoreStatus,
309
+ includeSpecs: options.includeSpecs,
310
+ defaultSkips: options.defaultSkips,
311
+ });
312
+ }
313
+ catch (error) {
314
+ io.stderr(`spec-guard: ${error instanceof Error ? error.message : String(error)}`);
315
+ return EXIT_ERROR;
316
+ }
317
+ if (report.specFiles.length === 0) {
318
+ if (options.format === 'json')
319
+ io.stdout(formatQueryJson(report));
320
+ else
321
+ io.stderr(`spec-guard: no spec files matched ${options.patterns.map((p) => `"${p}"`).join(', ')}`);
322
+ return EXIT_ERROR;
323
+ }
324
+ io.stdout(options.format === 'json' ? formatQueryJson(report) : formatQuery(report));
325
+ return EXIT_OK;
326
+ }
327
+ /** `spec-guard mcp`: serves until the client closes stdin. */
328
+ async function runMcp(options, io) {
329
+ if (!io.stdin) {
330
+ io.stderr('spec-guard: mcp needs a readable stdin.');
331
+ return EXIT_ERROR;
332
+ }
333
+ const handler = createMcpHandler({
334
+ root: options.root,
335
+ patterns: options.patterns,
336
+ version: version(),
337
+ run: {
338
+ engine: options.engine,
339
+ allowMissingTargets: options.allowMissingTargets,
340
+ allowEmptyScope: options.allowEmptyScope,
341
+ defaultSkips: options.defaultSkips,
342
+ ignoreStatus: options.ignoreStatus,
343
+ strictTargets: options.strictTargets,
344
+ includeSpecs: options.includeSpecs,
345
+ concurrency: options.concurrency,
346
+ maxSnippets: options.maxSnippets,
347
+ },
348
+ });
349
+ // stderr is the one channel the stdio binding leaves free for people.
350
+ io.stderr(`spec-guard ${version()}: MCP server on stdio, rules from ${options.patterns.join(', ')} under ${options.root}`);
351
+ await serveStdio(io.stdin, io.stdout, handler);
352
+ return EXIT_OK;
353
+ }
239
354
  /** Runs the CLI and resolves to the process exit code. */
240
355
  export async function main(argv = process.argv.slice(2), io = defaultIO()) {
241
356
  let options;
@@ -256,6 +371,10 @@ export async function main(argv = process.argv.slice(2), io = defaultIO()) {
256
371
  io.stdout(version());
257
372
  return EXIT_OK;
258
373
  }
374
+ if (options.command === 'query')
375
+ return runQuery(options, io);
376
+ if (options.command === 'mcp')
377
+ return runMcp(options, io);
259
378
  let report;
260
379
  try {
261
380
  report = await runSpecGuard({
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACvH,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGtF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC;AACzB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC;AAC7B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC;AAqC5B,MAAM,OAAO,UAAW,SAAQ,KAAK;CAAG;AAExC,MAAM,UAAU,OAAO;IACrB,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAyB,CAAC;QAC/D,OAAO,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,8DAA8D;QAC9D,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;;qEAwBiD,oBAAoB;sEACnB,mBAAmB;;;;;;;;;;;;;;;;;;;+EAmBV,CAAC;AAEhF,MAAM,cAAc,GAAqC;IACvD,IAAI,EAAE,MAAM;IACZ,EAAE,EAAE,SAAS;IACb,OAAO,EAAE,SAAS;IAClB,EAAE,EAAE,YAAY;IAChB,UAAU,EAAE,YAAY;IACxB,IAAI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,13 @@ export interface WalkOptions {
86
86
  */
87
87
  readDirectory?: DirectoryReader;
88
88
  }
89
- export interface WalkedFile {
89
+ /** A file the walk found, before anyone has asked how big it is. */
90
+ export interface WalkedPath {
90
91
  absolutePath: string;
91
92
  /** Path relative to the walk root, POSIX separators. */
92
93
  relativePath: string;
94
+ }
95
+ export interface WalkedFile extends WalkedPath {
93
96
  size: number;
94
97
  }
95
98
  /** Orders directory entries by name, byte-wise and stable across platforms. */
@@ -99,10 +102,22 @@ export declare function compareDirents(a: {
99
102
  name: string;
100
103
  }): number;
101
104
  /**
102
- * Depth-first directory walk yielding regular files.
105
+ * Depth-first directory walk yielding regular files with their sizes.
103
106
  * Emits nothing when `root` is missing or is not a directory.
107
+ *
108
+ * A file that is listed but cannot be stat'd - it was deleted mid-walk, or its
109
+ * permissions forbid it - is reported as unreadable rather than yielded.
104
110
  */
105
111
  export declare function walkFiles(root: string, options?: WalkOptions): AsyncGenerator<WalkedFile>;
112
+ /**
113
+ * The same walk, without a stat per file.
114
+ *
115
+ * Split out for the spec patterns, which need names and never sizes. The stat is
116
+ * most of what a walk costs on Windows: 516ms for 1,200 files against 42ms for
117
+ * the directory reads alone, measured when `spec-guard query` put a budget on
118
+ * finding the specs. See ADR-0012.
119
+ */
120
+ export declare function walkPaths(root: string, options?: WalkOptions): AsyncGenerator<WalkedPath>;
106
121
  /** Longest leading directory of a glob that contains no metacharacters. */
107
122
  export declare function globBase(pattern: string): {
108
123
  base: string;
@@ -1 +1 @@
1
- {"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../src/glob.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAkB,KAAK,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAGlE,OAAO,EAAiB,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAI9E,0DAA0D;AAC1D,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CA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