@descent-vtt/spec-guard 0.3.0 → 0.4.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 +60 -0
- package/README.md +89 -24
- package/dist/cli.d.ts +2 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +6 -0
- package/dist/cli.js.map +1 -1
- package/dist/engine.d.ts +43 -49
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +162 -254
- package/dist/engine.js.map +1 -1
- package/dist/glob.d.ts +19 -6
- package/dist/glob.d.ts.map +1 -1
- package/dist/glob.js +14 -28
- package/dist/glob.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/reporter.d.ts.map +1 -1
- package/dist/reporter.js +33 -3
- package/dist/reporter.js.map +1 -1
- package/dist/runner.d.ts +12 -3
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +137 -92
- package/dist/runner.js.map +1 -1
- package/dist/scope.d.ts +108 -0
- package/dist/scope.d.ts.map +1 -0
- package/dist/scope.js +115 -0
- package/dist/scope.js.map +1 -0
- package/dist/types.d.ts +13 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -6
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,66 @@ 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
|
+
## 0.4.0
|
|
9
|
+
|
|
10
|
+
An audit found spec-guard reporting a clean pass on a repository that contained
|
|
11
|
+
the forbidden symbol. On a tree with eight copies of one token, the scanner
|
|
12
|
+
found two and ripgrep found four, and neither said anything about the rest.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- **Hidden directories are searched.** `.github`, `.husky`, `.claude-rules` and
|
|
17
|
+
`.agents` hold CI, hooks and agent rules, and both engines skipped them
|
|
18
|
+
entirely - so an absence assertion passed while the forbidden thing sat in a
|
|
19
|
+
workflow file.
|
|
20
|
+
- **The skip list is now four names**: `.git`, `.hg`, `.svn`, `node_modules`.
|
|
21
|
+
`dist`, `build`, `out`, `coverage`, `.next` and eight others are searched,
|
|
22
|
+
because spec-guard cannot tell build output from a directory of build scripts,
|
|
23
|
+
and guessing wrong means a rule silently covers nothing. **If a run starts
|
|
24
|
+
failing on your build output, that is this change, and the fix is to say so:**
|
|
25
|
+
|
|
26
|
+
```md
|
|
27
|
+
<!-- @assert-absence target="." symbol="TODO" exclude="dist coverage" -->
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
- **`.gitignore` is no longer consulted.** It describes what git should carry,
|
|
31
|
+
not what a rule covers - and ripgrep applies it only inside a git repository,
|
|
32
|
+
so the same tree gave different answers depending on whether a `.git`
|
|
33
|
+
directory existed above it.
|
|
34
|
+
- **Binary files are searched, and a match in one is reported** rather than
|
|
35
|
+
dropped. It is not counted as a violation, but it is no longer invisible.
|
|
36
|
+
"Binary" now means "contains a NUL byte" for both engines; the scanner used to
|
|
37
|
+
look only at the first 8KB, which disagreed with ripgrep on files whose first
|
|
38
|
+
NUL came later.
|
|
39
|
+
- **`--strict` fails when a file could not be inspected**, which now has a
|
|
40
|
+
precise meaning: unreadable, or binary and containing the symbol.
|
|
41
|
+
- **The engines are one implementation.** ripgrep now answers only *which files
|
|
42
|
+
contain this text*; the scanner does all counting, comment classification,
|
|
43
|
+
binary handling and reporting for both. `--engine` changes how long a run
|
|
44
|
+
takes, not what it concludes. See [ADR-0007](docs/adr/0007-search-scope.md).
|
|
45
|
+
|
|
46
|
+
### Added
|
|
47
|
+
|
|
48
|
+
- **`--no-default-skips`** to search even those four directories.
|
|
49
|
+
- **`skipped`** on each result in `--json`: what was not inspected, and why.
|
|
50
|
+
|
|
51
|
+
### Removed
|
|
52
|
+
|
|
53
|
+
- `DEFAULT_IGNORED_DIRECTORIES`, `canBatchLiterals`, `shouldBatchPatterns`,
|
|
54
|
+
`createRipgrepSink` and `byteColumnToCharacter` from the public API. All of
|
|
55
|
+
them existed to make ripgrep's own counting trustworthy; as a pre-filter it
|
|
56
|
+
does not count, so pattern batching no longer has to be proved safe and
|
|
57
|
+
ripgrep's byte columns no longer need converting.
|
|
58
|
+
|
|
59
|
+
### Fixed
|
|
60
|
+
|
|
61
|
+
- ripgrep's per-file errors are no longer discarded. `--no-messages` meant a
|
|
62
|
+
file that could not be opened produced no match, no error, and no way to tell
|
|
63
|
+
it apart from one that was read and found clean.
|
|
64
|
+
- `comments="include"` no longer changes whether binary files are searched. An
|
|
65
|
+
attribute about comments decided that, because it selected a different code
|
|
66
|
+
path through the engine.
|
|
67
|
+
|
|
8
68
|
## 0.3.0
|
|
9
69
|
|
|
10
70
|
### Added
|
package/README.md
CHANGED
|
@@ -199,6 +199,53 @@ an unknown extension, an unterminated literal — the text counts as code, and t
|
|
|
199
199
|
report says which files it could not classify. A match wrongly kept is a visible
|
|
200
200
|
failure you can argue with; a match wrongly dropped is a lie.
|
|
201
201
|
|
|
202
|
+
## What gets searched
|
|
203
|
+
|
|
204
|
+
An assertion is worth exactly as much as the set of files behind it, so
|
|
205
|
+
spec-guard is explicit about that set and never quietly narrows it.
|
|
206
|
+
|
|
207
|
+
**Four directory names are skipped**, and nothing else:
|
|
208
|
+
|
|
209
|
+
| Skipped | Why |
|
|
210
|
+
| --- | --- |
|
|
211
|
+
| `.git`, `.hg`, `.svn` | version-control stores hold compressed copies of code you deleted on purpose |
|
|
212
|
+
| `node_modules` | code you did not write, which your architecture rules are not about |
|
|
213
|
+
|
|
214
|
+
Everything else is searched. That includes **hidden directories** - `.github`,
|
|
215
|
+
`.husky`, `.claude-rules`, `.agents` - because that is where CI, hooks and agent
|
|
216
|
+
rules live, and a rule that cannot see your workflow files is not enforcing much.
|
|
217
|
+
It also includes `dist`, `build`, `out` and `coverage`, because spec-guard
|
|
218
|
+
cannot tell build output from a directory of build scripts, and guessing wrong
|
|
219
|
+
means a rule silently stops covering anything.
|
|
220
|
+
|
|
221
|
+
`.gitignore` is not consulted. It describes what git should carry, not what a
|
|
222
|
+
rule covers - and ripgrep applies it only inside a git repository, so honouring
|
|
223
|
+
it made the same tree answer differently depending on whether a `.git` directory
|
|
224
|
+
happened to exist above it.
|
|
225
|
+
|
|
226
|
+
To narrow scope, say so in the assertion:
|
|
227
|
+
|
|
228
|
+
```md
|
|
229
|
+
<!-- @assert-absence target="src" symbol="TODO" exclude="dist coverage" -->
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
`--no-default-skips` removes even those four, for a run that has to be certain.
|
|
233
|
+
|
|
234
|
+
### Nothing is skipped quietly
|
|
235
|
+
|
|
236
|
+
A file spec-guard could not read, or one whose bytes are not text but which
|
|
237
|
+
contained the symbol anyway, is a gap in the answer rather than a detail of it.
|
|
238
|
+
Those are reported, and `--strict` fails on them:
|
|
239
|
+
|
|
240
|
+
```text
|
|
241
|
+
✖ docs/adr.md:3 @assert-absence
|
|
242
|
+
"ApiKey" must not appear in .
|
|
243
|
+
expected no matches, found 0, and 1 file could not be inspected
|
|
244
|
+
⚠ 1 match in 1 binary file not counted: build/app.bin
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
The counts are in `--json` too, as `skipped` on each result.
|
|
248
|
+
|
|
202
249
|
### `@assert-count` - this symbol occurs exactly / at least / at most N times
|
|
203
250
|
|
|
204
251
|
```md
|
|
@@ -318,6 +365,7 @@ spec-guard [patterns...] [options]
|
|
|
318
365
|
| `--engine <auto\|rg\|js>` | Search engine (default `auto`: scanner for small trees, ripgrep for big ones) |
|
|
319
366
|
| `--strict` | Treat analysis that could not be completed as a failure |
|
|
320
367
|
| `--allow-missing-targets` | Warn instead of failing when a `target` path does not exist |
|
|
368
|
+
| `--no-default-skips` | Search `.git`, `.hg`, `.svn` and `node_modules` too |
|
|
321
369
|
| `--include-specs` | Also count matches inside the spec files themselves |
|
|
322
370
|
| `--max-snippets <n>` | Failure snippets per assertion (default 5) |
|
|
323
371
|
| `--concurrency <n>` | Search passes in flight at once (default 8) |
|
|
@@ -392,45 +440,54 @@ parser ──▶ Directive[] ──▶ runner ──▶ Assertion[] ──▶ e
|
|
|
392
440
|
|
|
393
441
|
Scanning a tree costs about the same whether you look for one symbol or twenty,
|
|
394
442
|
so spec-guard groups assertions by target set and flags and answers each group
|
|
395
|
-
in one pass.
|
|
396
|
-
2,000-file, 5.1 MB tree with 8 assertions:
|
|
397
|
-
|
|
398
|
-
| | one pass per assertion | batched (current) |
|
|
399
|
-
| --- | --- | --- |
|
|
400
|
-
| ripgrep engine | ~280 ms | **~72 ms** |
|
|
401
|
-
| JavaScript fallback | ~780 ms | **~283 ms** |
|
|
443
|
+
in one pass.
|
|
402
444
|
|
|
403
445
|
`auto` then picks between the two engines **per search group**, because they
|
|
404
446
|
have different shapes of cost: ripgrep is dominated by process startup and
|
|
405
447
|
barely notices tree size, while the built-in scanner has no startup cost and
|
|
406
448
|
grows linearly. Starting a process to search a handful of files is a bad trade.
|
|
449
|
+
Re-measured for 0.4.0 on Windows 11 / Node 24, median of three, one symbol over
|
|
450
|
+
a synthetic tree:
|
|
451
|
+
|
|
452
|
+
| files | scanner | ripgrep | |
|
|
453
|
+
| --- | --- | --- | --- |
|
|
454
|
+
| 100 | **17 ms** | 214 ms | scanner, 12.9x |
|
|
455
|
+
| 500 | **70 ms** | 263 ms | scanner, 3.8x |
|
|
456
|
+
| 1,000 | 216 ms | **181 ms** | ripgrep, 1.2x |
|
|
457
|
+
| 3,000 | 735 ms | **222 ms** | ripgrep, 3.3x |
|
|
458
|
+
| 5,000 | 1,046 ms | **241 ms** | ripgrep, 4.3x |
|
|
407
459
|
|
|
408
460
|
The decision uses a bounded enumeration as its probe: spec-guard walks the
|
|
409
461
|
target set until it either finishes - in which case the file list is already in
|
|
410
462
|
hand and the scanner runs against it, with no process and no second walk - or
|
|
411
|
-
exceeds a budget, in which case ripgrep takes over.
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
463
|
+
exceeds a budget, in which case ripgrep takes over. The crossover above sits
|
|
464
|
+
between 500 and 1,000 files, which is what the Windows budget of 512 encodes;
|
|
465
|
+
on Linux it is far lower, because what is really being measured is process
|
|
466
|
+
spawn cost. `scripts/bench-engines.mjs` reproduces this, and
|
|
467
|
+
[ADR-0004](docs/adr/0004-adaptive-engine.md) has the full tables.
|
|
468
|
+
|
|
469
|
+
Treat single measurements from one machine with suspicion. On the development
|
|
470
|
+
machine used here, an absence assertion over 2,000 files measures 303 ms with
|
|
471
|
+
the scanner and 399 ms with ripgrep, but ripgrep's own spread across five runs
|
|
472
|
+
was 379-1039 ms - wide enough that the two are not really distinguishable at
|
|
473
|
+
that size. The order-of-magnitude differences at the ends of the table are the
|
|
474
|
+
part worth trusting.
|
|
422
475
|
|
|
423
476
|
Two honest caveats:
|
|
424
477
|
|
|
425
478
|
- **The reported engine is the one that ran, not the one available.** On a small
|
|
426
479
|
repository `--json` reports `"engine": "javascript"` even with ripgrep
|
|
427
480
|
installed. That is the optimisation working, not a failure to find `rg`.
|
|
428
|
-
- **
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
481
|
+
- **The engines are one implementation, not two that agree.** This used to say
|
|
482
|
+
that ripgrep was the reference and the scanner merely matched it "on
|
|
483
|
+
everything the test suite covers", with a note that the two treated
|
|
484
|
+
`.gitignore` and ignored directories differently and that you should pin an
|
|
485
|
+
engine if it mattered. It did matter: on a tree with eight copies of a symbol
|
|
486
|
+
the scanner found two and ripgrep found four. Since 0.4.0 ripgrep answers only
|
|
487
|
+
*which files contain this text*, and the scanner does all the counting,
|
|
488
|
+
classification and reporting for both. `--engine` now changes how long a run
|
|
489
|
+
takes and nothing about its verdict, and the suite asserts that on trees built
|
|
490
|
+
from every case that used to split them.
|
|
434
491
|
|
|
435
492
|
## Programmatic API
|
|
436
493
|
|
|
@@ -506,6 +563,14 @@ nothing, and reported success — the exact shape of a green check that verified
|
|
|
506
563
|
nothing. `--allow-missing-targets` restores the old behaviour for repositories
|
|
507
564
|
where a path is legitimately optional.
|
|
508
565
|
|
|
566
|
+
**Hidden directories are searched, and `.gitignore` is not consulted.** An
|
|
567
|
+
audit of 0.3.0 found the tool reporting a clean pass on a repository whose
|
|
568
|
+
forbidden symbol sat in `.github/workflows/ci.yml`; the scanner and ripgrep also
|
|
569
|
+
disagreed with each other, finding two matches and four on the same tree. Scope
|
|
570
|
+
is now one policy that both engines are driven by, the skip list is four names
|
|
571
|
+
long, and anything spec-guard could not inspect is reported rather than assumed
|
|
572
|
+
clean ([ADR-0007](docs/adr/0007-search-scope.md)).
|
|
573
|
+
|
|
509
574
|
**Comments are excluded by default, and the exclusion is reported.** Counting
|
|
510
575
|
the note that records a deletion as an occurrence of the thing deleted punishes
|
|
511
576
|
the documentation this tool exists to keep honest ([ADR-0006](docs/adr/0006-comment-classification.md)).
|
package/dist/cli.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export interface CliOptions {
|
|
|
25
25
|
json: boolean;
|
|
26
26
|
engine: EnginePreference;
|
|
27
27
|
allowMissingTargets: boolean;
|
|
28
|
+
defaultSkips: boolean;
|
|
28
29
|
strictTargets: boolean;
|
|
29
30
|
includeSpecs: boolean;
|
|
30
31
|
allowEmpty: boolean;
|
|
@@ -36,7 +37,7 @@ export interface CliOptions {
|
|
|
36
37
|
}
|
|
37
38
|
export declare class UsageError extends Error {
|
|
38
39
|
}
|
|
39
|
-
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\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 --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\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\n Matches inside comments do not count; add comments=\"include\" to count them.\n\nExit codes\n 0 all assertions passed 1 an assertion failed 2 spec-guard could not run";
|
|
40
|
+
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\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 --no-default-skips Search .git, .hg, .svn and node_modules 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\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\n Matches inside comments do not count; add comments=\"include\" to count them.\n\nExit codes\n 0 all assertions passed 1 an assertion failed 2 spec-guard could not run";
|
|
40
41
|
/** Minimal, dependency-free argv parser. Supports `--flag value` and `--flag=value`. */
|
|
41
42
|
export declare function parseArgs(argv: readonly string[], cwd: string): CliOptions;
|
|
42
43
|
/** 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,KAAK,IAAI,CAAC;IAC/B,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,gBAAgB,CAAC;IACzB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,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O,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,qBAAa,UAAW,SAAQ,KAAK;CAAG;AAaxC,eAAO,MAAM,IAAI,2xDAmC8D,CAAC;AAgChF,wFAAwF;AACxF,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,CA2G1E;AAYD,0DAA0D;AAC1D,wBAAsB,IAAI,CAAC,IAAI,GAAE,SAAS,MAAM,EAA0B,EAAE,EAAE,GAAE,KAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAiEpH"}
|
package/dist/cli.js
CHANGED
|
@@ -44,6 +44,7 @@ Options
|
|
|
44
44
|
--strict Treat analysis that could not be completed as a failure
|
|
45
45
|
--allow-missing-targets
|
|
46
46
|
Tolerate target paths that do not exist (they fail by default)
|
|
47
|
+
--no-default-skips Search .git, .hg, .svn and node_modules too
|
|
47
48
|
--include-specs Also count matches inside the spec files themselves
|
|
48
49
|
--max-snippets <n> Failure snippets per assertion (default: ${DEFAULT_MAX_SNIPPETS})
|
|
49
50
|
--concurrency <n> Assertions executed in parallel (default: ${DEFAULT_CONCURRENCY})
|
|
@@ -99,6 +100,7 @@ export function parseArgs(argv, cwd) {
|
|
|
99
100
|
json: false,
|
|
100
101
|
engine: 'auto',
|
|
101
102
|
allowMissingTargets: false,
|
|
103
|
+
defaultSkips: true,
|
|
102
104
|
strictTargets: false,
|
|
103
105
|
includeSpecs: false,
|
|
104
106
|
allowEmpty: false,
|
|
@@ -151,6 +153,9 @@ export function parseArgs(argv, cwd) {
|
|
|
151
153
|
case '--allow-missing-targets':
|
|
152
154
|
options.allowMissingTargets = true;
|
|
153
155
|
break;
|
|
156
|
+
case '--no-default-skips':
|
|
157
|
+
options.defaultSkips = false;
|
|
158
|
+
break;
|
|
154
159
|
case '--include-specs':
|
|
155
160
|
options.includeSpecs = true;
|
|
156
161
|
break;
|
|
@@ -227,6 +232,7 @@ export async function main(argv = process.argv.slice(2), io = defaultIO()) {
|
|
|
227
232
|
engine: options.engine,
|
|
228
233
|
failFast: options.failFast,
|
|
229
234
|
allowMissingTargets: options.allowMissingTargets,
|
|
235
|
+
defaultSkips: options.defaultSkips,
|
|
230
236
|
strictTargets: options.strictTargets,
|
|
231
237
|
includeSpecs: options.includeSpecs,
|
|
232
238
|
concurrency: options.concurrency,
|
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,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACzF,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;
|
|
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,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACzF,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,C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O;YACxB,KAAK,EAAE,cAAc,CAAC,EAAE,CAAC,GAAG,CAAC;SAC9B,EACD,OAAO,CAAC,WAAW,CACpB,CACF,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC;AAC3C,CAAC"}
|
package/dist/engine.d.ts
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Search engines.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* There is one set of semantics here, not two. The scanner reads files, counts
|
|
5
|
+
* matches, classifies comments, decides what is binary and keeps the ledger of
|
|
6
|
+
* what it could not inspect. ripgrep answers one question - which files under
|
|
7
|
+
* these targets contain this text at all - and everything downstream of that is
|
|
8
|
+
* the scanner's work, for both engines.
|
|
7
9
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
10
|
+
* It was not always so, and the reason for the rewrite is worth keeping: the
|
|
11
|
+
* two used to be independent implementations, and they drifted. On a tree with
|
|
12
|
+
* eight copies of one symbol the scanner found two and ripgrep found four,
|
|
13
|
+
* because one honoured .gitignore and the other did not, one skipped a
|
|
14
|
+
* hardcoded list of directory names and the other did not, and they disagreed
|
|
15
|
+
* about binary files. Nothing in the output said so. See ADR-0007.
|
|
11
16
|
*
|
|
12
17
|
* Both engines expose a batch API. Scanning a tree costs the same whether you
|
|
13
18
|
* look for one symbol or twenty, so assertions that share a target set and
|
|
14
|
-
* flags are answered by a single pass.
|
|
15
|
-
* eight assertions cost ~280ms as eight ripgrep passes and ~90ms as one.
|
|
19
|
+
* flags are answered by a single pass.
|
|
16
20
|
*/
|
|
17
21
|
import { type CommentMask } from './comments.js';
|
|
22
|
+
import { type SkippedPath } from './scope.js';
|
|
18
23
|
import type { EngineName, MatchLocation, SearchOptions, SearchResult } from './types.js';
|
|
19
24
|
/** Files larger than this are skipped by both engines, keeping them in sync. */
|
|
20
25
|
export declare const MAX_FILE_SIZE: number;
|
|
@@ -38,16 +43,6 @@ export interface Engine {
|
|
|
38
43
|
}
|
|
39
44
|
export type EnginePreference = 'auto' | 'ripgrep' | 'javascript';
|
|
40
45
|
export declare function escapeRegExp(value: string): string;
|
|
41
|
-
/**
|
|
42
|
-
* Converts ripgrep's byte column into a character column.
|
|
43
|
-
*
|
|
44
|
-
* ripgrep counts bytes; the scanner counts characters, and so does every editor
|
|
45
|
-
* that a reader will paste the location into. On an ASCII line the two agree,
|
|
46
|
-
* which is why the difference went unnoticed - it only appears once a line
|
|
47
|
-
* holds a non-ASCII character before the match, and then the two engines report
|
|
48
|
-
* different columns for the same match.
|
|
49
|
-
*/
|
|
50
|
-
export declare function byteColumnToCharacter(line: string, byteOffset: number): number;
|
|
51
46
|
/**
|
|
52
47
|
* Orders matches by path, then by line. ripgrep searches in parallel and emits
|
|
53
48
|
* files in no fixed order, so this is what makes snippet output stable.
|
|
@@ -60,47 +55,44 @@ interface Tally {
|
|
|
60
55
|
/** Matches skipped because they were inside a comment. */
|
|
61
56
|
commentCount: number;
|
|
62
57
|
}
|
|
63
|
-
/**
|
|
64
|
-
* True when no two of these literals can ever match overlapping text, which is
|
|
65
|
-
* exactly when merging them into one ripgrep alternation is safe.
|
|
66
|
-
*
|
|
67
|
-
* Two ways an alternation loses a match that separate passes would find:
|
|
68
|
-
* containment - ["Primary", "PrimaryButton"] on "PrimaryButton"; and
|
|
69
|
-
* dovetailing - ["abc", "cd"] on "abcd", where the scan resumes past "cd".
|
|
70
|
-
* Rejecting both leaves batching indistinguishable from separate passes.
|
|
71
|
-
*/
|
|
72
|
-
export declare function canBatchLiterals(patterns: readonly string[]): boolean;
|
|
73
58
|
/** Runs requests through the batch API when the engine has one. */
|
|
74
59
|
export declare function runSearches(engine: Engine, requests: SearchRequest[]): Promise<SearchResult[]>;
|
|
75
60
|
export declare function resetRipgrepProbe(): void;
|
|
76
61
|
/** Locates a usable `rg` binary. `SPEC_GUARD_RG` overrides PATH lookup. */
|
|
77
62
|
export declare function findRipgrep(): Promise<string | null>;
|
|
78
|
-
/** Builds the argv for one ripgrep pass over `patterns`. */
|
|
79
|
-
export declare function buildRipgrepArgs(request: SearchRequest, patterns?: readonly string[]): string[];
|
|
80
63
|
/**
|
|
81
|
-
*
|
|
64
|
+
* Builds the argv that makes ripgrep walk exactly what the scanner walks.
|
|
65
|
+
*
|
|
66
|
+
* Almost every flag here switches off an opinion. ripgrep's defaults are
|
|
67
|
+
* excellent for a developer grepping their own checkout and wrong for a rule
|
|
68
|
+
* about a repository:
|
|
69
|
+
*
|
|
70
|
+
* --hidden `.github`, `.husky` and `.claude-rules` hold real code, and
|
|
71
|
+
* leaving them out let an absence assertion pass while the
|
|
72
|
+
* forbidden thing sat in a workflow file.
|
|
73
|
+
* --no-ignore .gitignore says what git should carry, not what a rule
|
|
74
|
+
* covers - and it applies only inside a git repository, so the
|
|
75
|
+
* same tree answered differently depending on whether a .git
|
|
76
|
+
* directory happened to exist above it.
|
|
82
77
|
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
78
|
+
* What remains is spec-guard's own scope policy, passed as exclusions so that
|
|
79
|
+
* both engines skip the same four names for the same reasons. Those come last
|
|
80
|
+
* because ripgrep lets a later glob override an earlier one, and a policy skip
|
|
81
|
+
* must not be undone by a user's `glob="*.ts"`.
|
|
87
82
|
*/
|
|
88
|
-
export declare function
|
|
89
|
-
export interface RipgrepSink {
|
|
90
|
-
/** Feeds one line of ripgrep --json output. */
|
|
91
|
-
line(text: string): void;
|
|
92
|
-
readonly tallies: Map<string, Tally>;
|
|
93
|
-
readonly failure: Error | null;
|
|
94
|
-
}
|
|
83
|
+
export declare function buildRipgrepArgs(request: SearchRequest, patterns?: readonly string[]): string[];
|
|
95
84
|
/**
|
|
96
|
-
*
|
|
85
|
+
* Pulls the paths out of ripgrep's stderr.
|
|
86
|
+
*
|
|
87
|
+
* `--no-messages` used to be passed, which threw these away: a file ripgrep
|
|
88
|
+
* could not open produced no match, no error and no difference from a file that
|
|
89
|
+
* was searched and found clean. ripgrep writes one line per failure, as
|
|
90
|
+
* `path: reason`, and the path is what the report needs.
|
|
97
91
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* unattributable match - is trivial to exercise as data and nearly impossible
|
|
101
|
-
* to provoke from a real ripgrep on demand.
|
|
92
|
+
* Anything that does not parse is returned as-is rather than dropped, on the
|
|
93
|
+
* principle that an unexplained line from a subprocess is still information.
|
|
102
94
|
*/
|
|
103
|
-
export declare function
|
|
95
|
+
export declare function parseRipgrepErrors(stderr: string): string[];
|
|
104
96
|
/** Builds the matching RegExp shared by the JS engine. */
|
|
105
97
|
export declare function buildJsRegExp(symbol: string, options: SearchOptions): RegExp;
|
|
106
98
|
interface CandidateFile {
|
|
@@ -112,6 +104,8 @@ export interface Enumeration {
|
|
|
112
104
|
/** True when the walk stopped early because the budget was reached. */
|
|
113
105
|
exceeded: boolean;
|
|
114
106
|
bytes: number;
|
|
107
|
+
/** Paths the walk declined to inspect, with the reason for each. */
|
|
108
|
+
skipped: SkippedPath[];
|
|
115
109
|
}
|
|
116
110
|
export interface EnumerationBudget {
|
|
117
111
|
maxFiles: number;
|
|
@@ -138,7 +132,7 @@ getMask?: () => CommentMask): Tally;
|
|
|
138
132
|
/** An engine that is guaranteed to implement the batch API. */
|
|
139
133
|
export type BatchEngine = Engine & Required<Pick<Engine, 'searchBatch'>> & {
|
|
140
134
|
/** Scans a file list that the caller already enumerated. */
|
|
141
|
-
searchFiles(files: readonly CandidateFile[], requests: SearchRequest[]): Promise<SearchResult[]>;
|
|
135
|
+
searchFiles(files: readonly CandidateFile[], requests: SearchRequest[], unreadable?: readonly string[], skipped?: readonly SkippedPath[]): Promise<SearchResult[]>;
|
|
142
136
|
};
|
|
143
137
|
export declare const javascriptEngine: BatchEngine;
|
|
144
138
|
/**
|
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEzF,gFAAgF;AAChF,eAAO,MAAM,aAAa,QAAmB,CAAC;AAQ9C,MAAM,WAAW,aAAa;IAC5B,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACtD;;;OAGG;IACH,WAAW,CAAC,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;CAClE;AAED,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,SAAS,GAAG,YAAY,CAAC;AAEjE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD;AAQD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,aAAa,EAAE,GAAG,aAAa,EAAE,CAEzE;AAED,oDAAoD;AACpD,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,0DAA0D;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