@descent-vtt/spec-harness 0.3.1 → 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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +68 -0
- package/README.md +3 -3
- package/dist/audit.d.ts +5 -0
- package/dist/audit.js +4 -0
- package/dist/audit.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/manifests.d.ts +17 -1
- package/dist/manifests.js +16 -4
- package/dist/manifests.js.map +1 -1
- package/dist/round.js +25 -7
- package/dist/round.js.map +1 -1
- package/dist/vendor/spec-core/pattern/glob.d.ts +2 -0
- package/dist/vendor/spec-core/pattern/glob.js +29 -8
- package/dist/vendor/spec-core/pattern/glob.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spec-harness",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Rounds of agent work under a brief: context, a guard on every write, escalations a person signs, an audit at the end. Needs Claude Code 2.1.139 or later, and @descent-vtt/spec-harness and @descent-vtt/spec-brief 0.2.0 or later installed in the project.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "DescentVTT",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,73 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
The audit names a `dependencies.manifests` name it cannot read, with
|
|
6
|
+
spec-core's reason, where it dropped the name in silence; `context` asks
|
|
7
|
+
spec-guard about a plain name in the scope as it is on disk; and spec-core is
|
|
8
|
+
at 56c7e54, which refuses a brace alternative that names no path, such as
|
|
9
|
+
`{./,src}`, where it read as every path.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `readManifestNames` in the programmatic API: the configured manifest
|
|
14
|
+
names read, a predicate over the paths they name and the names that could
|
|
15
|
+
not be read, each with spec-core's reason. `AuditInput.dependencies` takes
|
|
16
|
+
those as `unreadNames`, optional. `manifestMatcher` is unchanged.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- spec-core at 56c7e54. Its glob refuses braces that expand to a text
|
|
21
|
+
naming no path, as it refuses that text written alone. `{./,src}`,
|
|
22
|
+
`{src,./}`, `.{/,src}` and `{.,src}/` read `./` as the root's contents and
|
|
23
|
+
matched every path; each is now a pattern that cannot be read, with
|
|
24
|
+
spec-core's reason, `the braces expand to "./", which names no path`:
|
|
25
|
+
- In a brief's `protectedFiles` it protected every path: the guard refused
|
|
26
|
+
every write as `protected`, and a ruling over the path waived it. The
|
|
27
|
+
guard now refuses every write as `unreadable-protection`, naming the
|
|
28
|
+
pattern and the reason, which no ruling waives.
|
|
29
|
+
- In `affectedFiles` it put every path in the scope. It is now named
|
|
30
|
+
among the patterns that could not be read, and the rest of the scope
|
|
31
|
+
still counts. `context` and `start_round` no longer ask spec-guard about
|
|
32
|
+
the whole repository for it, so the packet no longer holds rules over
|
|
33
|
+
code the rest of the scope leaves out.
|
|
34
|
+
- In a ruling's paths it allowed every protected path; it is passed over,
|
|
35
|
+
as a malformed path is.
|
|
36
|
+
- In `dependencies.manifests` it made every file the round changed a
|
|
37
|
+
manifest, each one no reader understands reported as `manifest-unread`.
|
|
38
|
+
It is now the `manifest-name-unread` warning, with the reason.
|
|
39
|
+
- In spec-graph's `patterns` it read the briefs; the list now reads
|
|
40
|
+
nothing, and `init` says spec-graph does not read the briefs.
|
|
41
|
+
- `/./` and `/.//` are refused as `the pattern names no path`. They matched
|
|
42
|
+
only paths from the filesystem's root, none of which the guard is given,
|
|
43
|
+
so `protectedFiles: ["/./"]` protected nothing; it now refuses every write
|
|
44
|
+
as `unreadable-protection`.
|
|
45
|
+
- A pattern refused before names what its braces expand to: `{.,src}` is
|
|
46
|
+
`the braces expand to ".", which names no path`, `{/,src}` `"/"`, and
|
|
47
|
+
`{,src}` and `{}` `the braces expand to an empty pattern`, where each was
|
|
48
|
+
`the pattern names no path`. `src/{./,a}` reads as before, what `src`
|
|
49
|
+
holds.
|
|
50
|
+
|
|
51
|
+
### Fixed
|
|
52
|
+
|
|
53
|
+
- A name in `dependencies.manifests` that spec-core's glob cannot read,
|
|
54
|
+
malformed or too large to compile, is a finding in `audit` and
|
|
55
|
+
`audit_round`: a warning, `manifest-name-unread`, on `.spec-harness.json`,
|
|
56
|
+
with the name and spec-core's reason, such as `a "[" is never closed` or
|
|
57
|
+
`the pattern compiles to more than 65536 states`, whether or not there is
|
|
58
|
+
a base to measure from. It was passed over in silence, so every manifest
|
|
59
|
+
it was meant to name went unmeasured. The other names are read as before,
|
|
60
|
+
and the warning fails the audit only under `--strict`.
|
|
61
|
+
- `context` and `start_round` ask spec-guard for the rules over a name with
|
|
62
|
+
no glob syntax in `affectedFiles` as it is on disk: `src`, a directory, is
|
|
63
|
+
asked about as `src`, and `src/auth/a.ts`, a file, as that file. The
|
|
64
|
+
directory holding the name was asked about, the whole repository for a
|
|
65
|
+
name at the top, so the packet held rules over code outside the scope, one
|
|
66
|
+
over `lib/` say, where `src/` asked about `src` alone. A name the round
|
|
67
|
+
has yet to create is asked about through the directory that will hold it,
|
|
68
|
+
as before, since it may become a directory. The guard's answer is
|
|
69
|
+
unchanged.
|
|
70
|
+
|
|
3
71
|
## 0.3.1
|
|
4
72
|
|
|
5
73
|
spec-core at f9ce375. A trailing `/` on a brace alternative in a brief's
|
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ person approves brief 012 ─▶ agent on branch brief/012-rotate-tokens
|
|
|
32
32
|
|
|
33
33
|
### `context [brief]`
|
|
34
34
|
|
|
35
|
-
The brief in full - it is the contract - then what it implies: the files the round may write and must not change as the guard reads them, the rulings already signed, the briefs it depends on and whether they are done, the architecture rules spec-guard holds that code to, and the documents the brief links to, whole, until the packet reaches its budget (`context.budget`, 60,000 characters). Documents left out are named by path, not dropped. So is a document whose front matter opens on its first line and is never closed, which spec-core's scanner reads as no front matter: its status was not read, and the packet says so, with the fix - close the block with `---` on a line of its own - rather than showing a document without one. The note fails nothing; `context` exits 0. Rules spec-guard could not read are named as unread, with what it said, never as none; a repository where no spec file matches spec-guard's patterns has none. `--base` names the base the rulings are verified against.
|
|
35
|
+
The brief in full - it is the contract - then what it implies: the files the round may write and must not change as the guard reads them, the rulings already signed, the briefs it depends on and whether they are done, the architecture rules spec-guard holds that code to, and the documents the brief links to, whole, until the packet reaches its budget (`context.budget`, 60,000 characters). Documents left out are named by path, not dropped. So is a document whose front matter opens on its first line and is never closed, which spec-core's scanner reads as no front matter: its status was not read, and the packet says so, with the fix - close the block with `---` on a line of its own - rather than showing a document without one. The note fails nothing; `context` exits 0. Rules spec-guard could not read are named as unread, with what it said, never as none; a repository where no spec file matches spec-guard's patterns has none. The rules are those over the scope: spec-guard is asked about where `affectedFiles` can reach, `src` for `src/**` or `src/`, not the whole repository. A name with no glob syntax that exists, `src` or `src/a.ts`, is asked about as itself; one the round has yet to create is asked about through the directory that will hold it, the root for a name at the top, since it may become a directory as well as a file ([ADR-0001](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0001-the-harness-decides-the-agent-writes.md)). `--base` names the base the rulings are verified against.
|
|
36
36
|
|
|
37
37
|
### `guard <path...>` and the hooks
|
|
38
38
|
|
|
@@ -63,7 +63,7 @@ spec-brief's archive refuses a round that changed a protected file, and learns t
|
|
|
63
63
|
|
|
64
64
|
### `audit [brief]`
|
|
65
65
|
|
|
66
|
-
One report: what spec-brief's archive would refuse or warn about, run with `--dry-run`; the brief's own assertions through spec-guard - a goal that fails, or a premise (under a heading such as *The Defect, Measured*) that still holds after the round meant to change it; rulings whose signatures do not verify; and every dependency the round added to `package.json`, `Cargo.toml`, `go.mod`, `pyproject.toml`, `requirements*.txt`, NuGet project files or a `Gemfile`. A part that could not be measured is a finding, never a silence.
|
|
66
|
+
One report: what spec-brief's archive would refuse or warn about, run with `--dry-run`; the brief's own assertions through spec-guard - a goal that fails, or a premise (under a heading such as *The Defect, Measured*) that still holds after the round meant to change it; rulings whose signatures do not verify; and every dependency the round added to `package.json`, `Cargo.toml`, `go.mod`, `pyproject.toml`, `requirements*.txt`, NuGet project files or a `Gemfile`. A part that could not be measured is a finding, never a silence. So is a name in `dependencies.manifests` that spec-core's glob cannot read, malformed or too large to compile: the audit names it and the reason in a warning, `manifest-name-unread`, which fails the audit only under `--strict`, and reads the manifests the other names name.
|
|
67
67
|
|
|
68
68
|
### `probe [brief]`
|
|
69
69
|
|
|
@@ -128,7 +128,7 @@ The plugin's hooks and server are the ones `init` writes into `.claude/settings.
|
|
|
128
128
|
| `base` | the remote's default branch | What rounds are measured from, and where allowed signers are read. `init` names it, since a repository git did not clone may have no default branch recorded. |
|
|
129
129
|
| `rulings.section` | `"Rulings"` | The brief section holding the rulings table. |
|
|
130
130
|
| `rulings.allowedSigners` | `".github/allowed_signers"` | The allowed-signers file, read from the base branch. |
|
|
131
|
-
| `dependencies.manifests` | the list above | Manifest names whose added dependencies the audit reports. |
|
|
131
|
+
| `dependencies.manifests` | the list above | Manifest names whose added dependencies the audit reports. A name that cannot be read is a warning in the audit. |
|
|
132
132
|
| `context.budget` | `60000` | Characters a context packet may hold; cited documents fill what the rest leaves, and those that do not fit are named by path. |
|
|
133
133
|
| `assertions.premises` | `The Defect, Measured`, `Premises`, `Preconditions` | Sections whose assertions state what was true before the round. |
|
|
134
134
|
| `probes.runs`, `probes.timeout` | `2`, `600` | Runs per probe, and seconds per run. |
|
package/dist/audit.d.ts
CHANGED
|
@@ -43,6 +43,11 @@ export interface AuditInput {
|
|
|
43
43
|
readonly dependencies: {
|
|
44
44
|
readonly changes: readonly DependencyChange[];
|
|
45
45
|
readonly unread: readonly string[];
|
|
46
|
+
/** Names in `dependencies.manifests` that could not be read, with spec-core's reason; none when not given. */
|
|
47
|
+
readonly unreadNames?: readonly {
|
|
48
|
+
readonly name: string;
|
|
49
|
+
readonly reason: string;
|
|
50
|
+
}[] | undefined;
|
|
46
51
|
};
|
|
47
52
|
readonly archive: {
|
|
48
53
|
readonly blocking: readonly ArchiveReason[];
|
package/dist/audit.js
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
*
|
|
20
20
|
* A part that could not be measured is a finding, never a silence.
|
|
21
21
|
*/
|
|
22
|
+
import { CONFIG_FILE } from './config.js';
|
|
22
23
|
import { PLUGIN } from './configure.js';
|
|
23
24
|
import { rulingFor } from './guard.js';
|
|
24
25
|
import { sameSection } from './reader.js';
|
|
@@ -99,6 +100,9 @@ export function audit(input) {
|
|
|
99
100
|
for (const ruling of input.unverifiedRulings) {
|
|
100
101
|
out.push(finding('ruling-unverified', 'warning', `ruling ${ruling.id} allows nothing: ${ruling.reason}`, 'a ruling counts when the commit that last changed its row is signed by a key in the base branch\'s allowed signers', brief.file));
|
|
101
102
|
}
|
|
103
|
+
for (const { name, reason } of input.dependencies.unreadNames ?? []) {
|
|
104
|
+
out.push(finding('manifest-name-unread', 'warning', `"dependencies.manifests" names "${name}", which cannot be read: ${reason}; no manifest it names was read`, `fix or remove the name in ${CONFIG_FILE}; the other names were read`, CONFIG_FILE));
|
|
105
|
+
}
|
|
102
106
|
for (const file of input.dependencies.unread) {
|
|
103
107
|
out.push(finding('manifest-unread', 'warning', `${file} changed and could not be read for dependencies`, 'check its dependencies by hand; the audit cannot', file));
|
|
104
108
|
}
|
package/dist/audit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAuB,MAAM,YAAY,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAwC1C,SAAS,OAAO,CAAC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,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,EAAE,OAAO,KAAK,EAAE,EAC7H,4FAA4F,EAC5F,MAAM,CAAC,IAAI,CACZ,CACF,CAAC;QACJ,CAAC;aAAM,IAAI,MAAM,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YACjC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,MAAM,EAAE,sBAAsB,MAAM,CAAC,IAAI,UAAU,KAAK,EAAE,EAAE,eAAe,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACpI,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,MAAM,EAAE,oBAAoB,MAAM,CAAC,IAAI,UAAU,MAAM,CAAC,MAAM,OAAO,MAAM,CAAC,KAAK,OAAO,KAAK,EAAE,EAAE,sCAAsC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAChM,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAA6B,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAC3E,KAAK,MAAM,IAAI,IAAI,GAAG;QAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnD,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;AACnC,CAAC","sourcesContent":["/**\n * Did the round stay inside the lines?\n *\n * One report, from three sources and one question of its own:\n *\n * - spec-brief's archive, asked with `--dry-run`: open boxes, protected files\n * changed, files outside the scope, a tree that was not committed. The\n * archive is spec-brief's decision, so its reasons are carried as they are\n * - one defect, one finding - and the harness does not measure the scope a\n * second time.\n * - spec-guard, over the brief's own assertions: the goals must hold now. A\n * premise - an assertion in a section that states what was true before the\n * round, such as \"The Defect, Measured\" - is expected to stop holding, and\n * one that still holds says the defect may still be there.\n * - The rulings: each one whose signature does not verify is reported, since\n * an unverified ruling allows nothing.\n * - And the one question nobody else asks: which dependencies the round\n * added. A dependency is code no reviewer read.\n *\n * A part that could not be measured is a finding, never a silence.\n */\n\nimport { PLUGIN } from './configure.js';\nimport { rulingFor, type VerifiedRuling } from './guard.js';\nimport type { DependencyChange } from './manifests.js';\nimport { sameSection } from './reader.js';\nimport type { BriefRow, Finding, Severity } from './types.js';\n\nexport interface AssertionOutcome {\n readonly ok: boolean;\n readonly description: string;\n readonly message: string;\n readonly line: number;\n /** The brief section the directive sits in, or `null`. */\n readonly section: string | null;\n /** Every section it sits in, outermost first; `[section]` when not given. */\n readonly enclosing?: readonly string[] | undefined;\n}\n\n/** A reason spec-brief's archive gives; a `protected-file` refusal names its `path`. */\nexport interface ArchiveReason extends Finding {\n readonly path?: string | undefined;\n}\n\nexport interface AuditInput {\n readonly brief: BriefRow;\n /** Why the round's changes could not be measured, when they could not. */\n readonly unmeasured: string | null;\n readonly dependencies: { readonly changes: readonly DependencyChange[]; readonly unread: readonly string[] };\n readonly archive: { readonly blocking: readonly ArchiveReason[]; readonly warnings: readonly ArchiveReason[] } | { readonly unavailable: string };\n readonly assertions: readonly AssertionOutcome[] | { readonly unavailable: string };\n /** Section names whose assertions are premises. Compared without case, emphasis, a leading number or a trailing colon. */\n readonly premiseSections: readonly string[];\n readonly unverifiedRulings: readonly { readonly id: string; readonly reason: string }[];\n /** The rulings whose signatures verify, which a protected file the archive refuses may be covered by. */\n readonly verifiedRulings: readonly VerifiedRuling[];\n /** Whether spec-brief's configuration loads this package's plugin, through which its archive learns of them. */\n readonly pluginLoaded: boolean;\n}\n\nexport interface AuditReport {\n readonly findings: readonly Finding[];\n readonly counts: Readonly<Record<Severity, number>>;\n}\n\nfunction finding(rule: string, severity: Severity, message: string, hint: string, file?: string, line?: number): Finding {\n return { rule, severity, message, hint, ...(file === undefined ? {} : { file }), ...(line === undefined ? {} : { line }) };\n}\n\n/**\n * Whether an assertion's section is a premise section. Compared as the\n * rulings section is, and as spec-brief compares section names: a heading\n * written `## 3. **The Defect, Measured:**` is still the premise section, and\n * an assertion under it read as a goal would fail the round for retiring it.\n */\nexport function isPremise(sections: string | null | readonly string[], premises: readonly string[]): boolean {\n const list = sections === null ? [] : typeof sections === 'string' ? [sections] : sections;\n // A premise section's subsections are still premises: `### Before` under\n // `## The Defect, Measured` states what was true before the round.\n return list.some((section) => premises.some((premise) => sameSection(section, premise)));\n}\n\n/**\n * A live brief's premise that no longer holds, as `premises` reports it. On\n * the brief a round is working on - the one the flag, SPEC_BRIEF or the\n * branch names - that is what the round set out to do, and it is reported as\n * the audit reports it; on any other, what the brief was written against has\n * changed under it.\n */\nexport function premiseFinding(\n brief: Pick<BriefRow, 'id' | 'file'>,\n outcome: { readonly description: string; readonly message: string; readonly line: number },\n active: boolean,\n): Finding {\n if (active) {\n return finding(\n 'premise-retired',\n 'note',\n `brief ${brief.id}'s premise no longer holds, as the round on it intends: ${outcome.description}`,\n 'nothing to do: this is the round that changes it, and audit measures it',\n brief.file,\n outcome.line,\n );\n }\n return finding(\n 'stale-premise',\n 'error',\n `brief ${brief.id}'s premise no longer holds: ${outcome.description}: ${outcome.message}`,\n 'what the brief was written against has changed; archive the brief if its work is done, or rewrite its premise before a round is run on it',\n brief.file,\n outcome.line,\n );\n}\n\n/**\n * The next step for a reason the archive gives. A protected file a verified\n * ruling covers is refused only because the archive did not learn of the\n * ruling, and recording a departure in the brief would not fix that.\n */\nfunction archiveHint(reason: ArchiveReason, input: AuditInput): string {\n const ruling = reason.rule === 'protected-file' && reason.path !== undefined ? rulingFor(input.verifiedRulings, reason.path) : undefined;\n if (ruling === undefined) return reason.hint;\n const allowed = `ruling ${ruling.id}, signed by ${ruling.signer}, allows it`;\n return input.pluginLoaded\n ? `${allowed}, and the archive still refused it: check that spec-brief loads the spec-harness installed here and measures from the same base (spec-harness doctor)`\n : `${allowed}, but spec-brief does not load spec-harness's plugin, which is how its archive learns of signed rulings: add \"${PLUGIN}\" to \"plugins\" in its configuration, or run spec-harness init --write`;\n}\n\nexport function audit(input: AuditInput): AuditReport {\n const { brief } = input;\n const out: Finding[] = [];\n\n if (input.unmeasured !== null) {\n out.push(\n finding(\n 'unmeasured',\n 'warning',\n `the round's changes were not measured: ${input.unmeasured}`,\n 'pass --base <ref>, set \"base\" in .spec-harness.json, or audit on the round\\'s branch before it merges',\n brief.file,\n ),\n );\n }\n\n if ('unavailable' in input.archive) {\n out.push(finding('archive-unchecked', 'warning', `what the archive would say is unknown: ${input.archive.unavailable}`, 'install spec-brief, or fix what stopped it', brief.file));\n } else {\n for (const reason of [...input.archive.blocking, ...input.archive.warnings]) {\n out.push(finding(`archive/${reason.rule}`, reason.severity, reason.message, archiveHint(reason, input), reason.file, reason.line));\n }\n }\n\n if (!Array.isArray(input.assertions)) {\n const unavailable = (input.assertions as { unavailable: string }).unavailable;\n out.push(finding('assertions-unchecked', 'warning', `the brief's assertions were not run: ${unavailable}`, 'install spec-guard, or fix what stopped it', brief.file));\n } else {\n for (const outcome of input.assertions) {\n const premise = isPremise(outcome.enclosing ?? outcome.section, input.premiseSections);\n if (premise && outcome.ok) {\n out.push(\n finding(\n 'premise-holds',\n 'warning',\n `a premise still holds after the round: ${outcome.description}`,\n 'the round set out to change what this premise states; check that it did, or move the assertion out of the premises',\n brief.file,\n outcome.line,\n ),\n );\n } else if (premise) {\n out.push(finding('premise-retired', 'note', `a premise no longer holds, as the round intended: ${outcome.description}`, 'nothing to do', brief.file, outcome.line));\n } else if (!outcome.ok) {\n out.push(finding('goal-failed', 'error', `${outcome.description}: ${outcome.message}`, 'the round is not done until this holds', brief.file, outcome.line));\n }\n }\n }\n\n for (const ruling of input.unverifiedRulings) {\n out.push(\n finding(\n 'ruling-unverified',\n 'warning',\n `ruling ${ruling.id} allows nothing: ${ruling.reason}`,\n 'a ruling counts when the commit that last changed its row is signed by a key in the base branch\\'s allowed signers',\n brief.file,\n ),\n );\n }\n\n for (const file of input.dependencies.unread) {\n out.push(finding('manifest-unread', 'warning', `${file} changed and could not be read for dependencies`, 'check its dependencies by hand; the audit cannot', file));\n }\n for (const change of input.dependencies.changes) {\n const where = `${change.file} (${change.section})`;\n if (change.before === null) {\n out.push(\n finding(\n 'new-dependency',\n 'warning',\n `the round added ${change.ecosystem} dependency \"${change.name}\"${change.after === '' ? '' : ` ${change.after}`} in ${where}`,\n 'say in the brief why it is needed, or remove it; a new dependency is code no reviewer read',\n change.file,\n ),\n );\n } else if (change.after === null) {\n out.push(finding('dependency-removed', 'note', `the round removed \"${change.name}\" from ${where}`, 'nothing to do', change.file));\n } else {\n out.push(finding('dependency-changed', 'note', `the round moved \"${change.name}\" from ${change.before} to ${change.after} in ${where}`, 'nothing to do, if the brief meant it', change.file));\n }\n }\n\n const counts: Record<Severity, number> = { error: 0, warning: 0, note: 0 };\n for (const item of out) counts[item.severity] += 1;\n return { findings: out, counts };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAuB,MAAM,YAAY,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA6C1C,SAAS,OAAO,CAAC,IAAY,EAAE,QAAkB,EAAE,OAAe,EAAE,IAAY,EAAE,IAAa,EAAE,IAAa;IAC5G,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,C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AAK,EAAE,OAAO,KAAK,EAAE,EAC7H,4FAA4F,EAC5F,MAAM,CAAC,IAAI,CACZ,CACF,CAAC;QACJ,CAAC;aAAM,IAAI,MAAM,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YACjC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,MAAM,EAAE,sBAAsB,MAAM,CAAC,IAAI,UAAU,KAAK,EAAE,EAAE,eAAe,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACpI,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,MAAM,EAAE,oBAAoB,MAAM,CAAC,IAAI,UAAU,MAAM,CAAC,MAAM,OAAO,MAAM,CAAC,KAAK,OAAO,KAAK,EAAE,EAAE,sCAAsC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAChM,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAA6B,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAC3E,KAAK,MAAM,IAAI,IAAI,GAAG;QAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnD,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;AACnC,CAAC","sourcesContent":["/**\n * Did the round stay inside the lines?\n *\n * One report, from three sources and one question of its own:\n *\n * - spec-brief's archive, asked with `--dry-run`: open boxes, protected files\n * changed, files outside the scope, a tree that was not committed. The\n * archive is spec-brief's decision, so its reasons are carried as they are\n * - one defect, one finding - and the harness does not measure the scope a\n * second time.\n * - spec-guard, over the brief's own assertions: the goals must hold now. A\n * premise - an assertion in a section that states what was true before the\n * round, such as \"The Defect, Measured\" - is expected to stop holding, and\n * one that still holds says the defect may still be there.\n * - The rulings: each one whose signature does not verify is reported, since\n * an unverified ruling allows nothing.\n * - And the one question nobody else asks: which dependencies the round\n * added. A dependency is code no reviewer read.\n *\n * A part that could not be measured is a finding, never a silence.\n */\n\nimport { CONFIG_FILE } from './config.js';\nimport { PLUGIN } from './configure.js';\nimport { rulingFor, type VerifiedRuling } from './guard.js';\nimport type { DependencyChange } from './manifests.js';\nimport { sameSection } from './reader.js';\nimport type { BriefRow, Finding, Severity } from './types.js';\n\nexport interface AssertionOutcome {\n readonly ok: boolean;\n readonly description: string;\n readonly message: string;\n readonly line: number;\n /** The brief section the directive sits in, or `null`. */\n readonly section: string | null;\n /** Every section it sits in, outermost first; `[section]` when not given. */\n readonly enclosing?: readonly string[] | undefined;\n}\n\n/** A reason spec-brief's archive gives; a `protected-file` refusal names its `path`. */\nexport interface ArchiveReason extends Finding {\n readonly path?: string | undefined;\n}\n\nexport interface AuditInput {\n readonly brief: BriefRow;\n /** Why the round's changes could not be measured, when they could not. */\n readonly unmeasured: string | null;\n readonly dependencies: {\n readonly changes: readonly DependencyChange[];\n readonly unread: readonly string[];\n /** Names in `dependencies.manifests` that could not be read, with spec-core's reason; none when not given. */\n readonly unreadNames?: readonly { readonly name: string; readonly reason: string }[] | undefined;\n };\n readonly archive: { readonly blocking: readonly ArchiveReason[]; readonly warnings: readonly ArchiveReason[] } | { readonly unavailable: string };\n readonly assertions: readonly AssertionOutcome[] | { readonly unavailable: string };\n /** Section names whose assertions are premises. Compared without case, emphasis, a leading number or a trailing colon. */\n readonly premiseSections: readonly string[];\n readonly unverifiedRulings: readonly { readonly id: string; readonly reason: string }[];\n /** The rulings whose signatures verify, which a protected file the archive refuses may be covered by. */\n readonly verifiedRulings: readonly VerifiedRuling[];\n /** Whether spec-brief's configuration loads this package's plugin, through which its archive learns of them. */\n readonly pluginLoaded: boolean;\n}\n\nexport interface AuditReport {\n readonly findings: readonly Finding[];\n readonly counts: Readonly<Record<Severity, number>>;\n}\n\nfunction finding(rule: string, severity: Severity, message: string, hint: string, file?: string, line?: number): Finding {\n return { rule, severity, message, hint, ...(file === undefined ? {} : { file }), ...(line === undefined ? {} : { line }) };\n}\n\n/**\n * Whether an assertion's section is a premise section. Compared as the\n * rulings section is, and as spec-brief compares section names: a heading\n * written `## 3. **The Defect, Measured:**` is still the premise section, and\n * an assertion under it read as a goal would fail the round for retiring it.\n */\nexport function isPremise(sections: string | null | readonly string[], premises: readonly string[]): boolean {\n const list = sections === null ? [] : typeof sections === 'string' ? [sections] : sections;\n // A premise section's subsections are still premises: `### Before` under\n // `## The Defect, Measured` states what was true before the round.\n return list.some((section) => premises.some((premise) => sameSection(section, premise)));\n}\n\n/**\n * A live brief's premise that no longer holds, as `premises` reports it. On\n * the brief a round is working on - the one the flag, SPEC_BRIEF or the\n * branch names - that is what the round set out to do, and it is reported as\n * the audit reports it; on any other, what the brief was written against has\n * changed under it.\n */\nexport function premiseFinding(\n brief: Pick<BriefRow, 'id' | 'file'>,\n outcome: { readonly description: string; readonly message: string; readonly line: number },\n active: boolean,\n): Finding {\n if (active) {\n return finding(\n 'premise-retired',\n 'note',\n `brief ${brief.id}'s premise no longer holds, as the round on it intends: ${outcome.description}`,\n 'nothing to do: this is the round that changes it, and audit measures it',\n brief.file,\n outcome.line,\n );\n }\n return finding(\n 'stale-premise',\n 'error',\n `brief ${brief.id}'s premise no longer holds: ${outcome.description}: ${outcome.message}`,\n 'what the brief was written against has changed; archive the brief if its work is done, or rewrite its premise before a round is run on it',\n brief.file,\n outcome.line,\n );\n}\n\n/**\n * The next step for a reason the archive gives. A protected file a verified\n * ruling covers is refused only because the archive did not learn of the\n * ruling, and recording a departure in the brief would not fix that.\n */\nfunction archiveHint(reason: ArchiveReason, input: AuditInput): string {\n const ruling = reason.rule === 'protected-file' && reason.path !== undefined ? rulingFor(input.verifiedRulings, reason.path) : undefined;\n if (ruling === undefined) return reason.hint;\n const allowed = `ruling ${ruling.id}, signed by ${ruling.signer}, allows it`;\n return input.pluginLoaded\n ? `${allowed}, and the archive still refused it: check that spec-brief loads the spec-harness installed here and measures from the same base (spec-harness doctor)`\n : `${allowed}, but spec-brief does not load spec-harness's plugin, which is how its archive learns of signed rulings: add \"${PLUGIN}\" to \"plugins\" in its configuration, or run spec-harness init --write`;\n}\n\nexport function audit(input: AuditInput): AuditReport {\n const { brief } = input;\n const out: Finding[] = [];\n\n if (input.unmeasured !== null) {\n out.push(\n finding(\n 'unmeasured',\n 'warning',\n `the round's changes were not measured: ${input.unmeasured}`,\n 'pass --base <ref>, set \"base\" in .spec-harness.json, or audit on the round\\'s branch before it merges',\n brief.file,\n ),\n );\n }\n\n if ('unavailable' in input.archive) {\n out.push(finding('archive-unchecked', 'warning', `what the archive would say is unknown: ${input.archive.unavailable}`, 'install spec-brief, or fix what stopped it', brief.file));\n } else {\n for (const reason of [...input.archive.blocking, ...input.archive.warnings]) {\n out.push(finding(`archive/${reason.rule}`, reason.severity, reason.message, archiveHint(reason, input), reason.file, reason.line));\n }\n }\n\n if (!Array.isArray(input.assertions)) {\n const unavailable = (input.assertions as { unavailable: string }).unavailable;\n out.push(finding('assertions-unchecked', 'warning', `the brief's assertions were not run: ${unavailable}`, 'install spec-guard, or fix what stopped it', brief.file));\n } else {\n for (const outcome of input.assertions) {\n const premise = isPremise(outcome.enclosing ?? outcome.section, input.premiseSections);\n if (premise && outcome.ok) {\n out.push(\n finding(\n 'premise-holds',\n 'warning',\n `a premise still holds after the round: ${outcome.description}`,\n 'the round set out to change what this premise states; check that it did, or move the assertion out of the premises',\n brief.file,\n outcome.line,\n ),\n );\n } else if (premise) {\n out.push(finding('premise-retired', 'note', `a premise no longer holds, as the round intended: ${outcome.description}`, 'nothing to do', brief.file, outcome.line));\n } else if (!outcome.ok) {\n out.push(finding('goal-failed', 'error', `${outcome.description}: ${outcome.message}`, 'the round is not done until this holds', brief.file, outcome.line));\n }\n }\n }\n\n for (const ruling of input.unverifiedRulings) {\n out.push(\n finding(\n 'ruling-unverified',\n 'warning',\n `ruling ${ruling.id} allows nothing: ${ruling.reason}`,\n 'a ruling counts when the commit that last changed its row is signed by a key in the base branch\\'s allowed signers',\n brief.file,\n ),\n );\n }\n\n for (const { name, reason } of input.dependencies.unreadNames ?? []) {\n out.push(\n finding(\n 'manifest-name-unread',\n 'warning',\n `\"dependencies.manifests\" names \"${name}\", which cannot be read: ${reason}; no manifest it names was read`,\n `fix or remove the name in ${CONFIG_FILE}; the other names were read`,\n CONFIG_FILE,\n ),\n );\n }\n for (const file of input.dependencies.unread) {\n out.push(finding('manifest-unread', 'warning', `${file} changed and could not be read for dependencies`, 'check its dependencies by hand; the audit cannot', file));\n }\n for (const change of input.dependencies.changes) {\n const where = `${change.file} (${change.section})`;\n if (change.before === null) {\n out.push(\n finding(\n 'new-dependency',\n 'warning',\n `the round added ${change.ecosystem} dependency \"${change.name}\"${change.after === '' ? '' : ` ${change.after}`} in ${where}`,\n 'say in the brief why it is needed, or remove it; a new dependency is code no reviewer read',\n change.file,\n ),\n );\n } else if (change.after === null) {\n out.push(finding('dependency-removed', 'note', `the round removed \"${change.name}\" from ${where}`, 'nothing to do', change.file));\n } else {\n out.push(finding('dependency-changed', 'note', `the round moved \"${change.name}\" from ${change.before} to ${change.after} in ${where}`, 'nothing to do, if the brief meant it', change.file));\n }\n }\n\n const counts: Record<Severity, number> = { error: 0, warning: 0, note: 0 };\n for (const item of out) counts[item.severity] += 1;\n return { findings: out, counts };\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -19,8 +19,8 @@ export { claudeResponse, gitResponse, parseClaudeHook, WRITING_TOOLS } from './h
|
|
|
19
19
|
export type { HookRequest, HookResponse } from './hooks.js';
|
|
20
20
|
export { readJUnit } from './junit.js';
|
|
21
21
|
export type { JUnitCase, JUnitRead } from './junit.js';
|
|
22
|
-
export { diffManifest, ecosystemOf, manifestMatcher, readManifest } from './manifests.js';
|
|
23
|
-
export type { Dependency, DependencyChange, Ecosystem } from './manifests.js';
|
|
22
|
+
export { diffManifest, ecosystemOf, manifestMatcher, readManifest, readManifestNames } from './manifests.js';
|
|
23
|
+
export type { Dependency, DependencyChange, Ecosystem, ManifestNames } from './manifests.js';
|
|
24
24
|
export { classify, readProbes, renderEvidence, verdictOf } from './probe.js';
|
|
25
25
|
export type { Classified, CodeBlock, ProbeFile, ProbeResult, ProbeRun, ProbeSet, ProbeSpec } from './probe.js';
|
|
26
26
|
export { createReader } from './reader.js';
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ export { renderContext } from './context.js';
|
|
|
11
11
|
export { decide } from './guard.js';
|
|
12
12
|
export { claudeResponse, gitResponse, parseClaudeHook, WRITING_TOOLS } from './hooks.js';
|
|
13
13
|
export { readJUnit } from './junit.js';
|
|
14
|
-
export { diffManifest, ecosystemOf, manifestMatcher, readManifest } from './manifests.js';
|
|
14
|
+
export { diffManifest, ecosystemOf, manifestMatcher, readManifest, readManifestNames } from './manifests.js';
|
|
15
15
|
export { classify, readProbes, renderEvidence, verdictOf } from './probe.js';
|
|
16
16
|
export { createReader } from './reader.js';
|
|
17
17
|
export { addRulingRow, nextId, pathsOf, readRulings, renderMemo, renderRow } from './rulings.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAG5F,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAExG,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE9F,OAAO,EAAE,aAAa,EAAE,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Y,CAAC;AAE7E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEjG,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC1H,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["/**\n * Programmatic API. The command line is a thin shell over these; a harness of\n * another kind - a CI job, an orchestrator - can ask the same questions.\n */\n\nexport { main, run, EXIT_ERROR, EXIT_FAILED, EXIT_OK, UsageError, version } from './cli.js';\nexport type { CliIO } from './cli.js';\n\nexport { audit } from './audit.js';\nexport type { AssertionOutcome, AuditInput, AuditReport } from './audit.js';\nexport { briefIdFromBranch, idFromBranch, sameId, templateError } from './branch.js';\nexport { findActive, parseBriefList, SiblingOutputError, SUPPORTED_SCHEMA_VERSIONS } from './briefs.js';\nexport type { ActiveBrief, ActiveSource } from './briefs.js';\nexport { ConfigError, CONFIG_FILE, DEFAULT_CONFIG, parseConfig, SIBLINGS } from './config.js';\nexport type { HarnessConfig, OutOfScope, SiblingName } from './config.js';\nexport { renderContext } from './context.js';\nexport type { CitedDocument, ContextInput, ContextPacket, RuleInForce, RulingInForce } from './context.js';\nexport { decide } from './guard.js';\nexport type { Decision, GuardInput, Reason, Verdict, VerifiedRuling } from './guard.js';\nexport { claudeResponse, gitResponse, parseClaudeHook, WRITING_TOOLS } from './hooks.js';\nexport type { HookRequest, HookResponse } from './hooks.js';\nexport { readJUnit } from './junit.js';\nexport type { JUnitCase, JUnitRead } from './junit.js';\nexport { diffManifest, ecosystemOf, manifestMatcher, readManifest, readManifestNames } from './manifests.js';\nexport type { Dependency, DependencyChange, Ecosystem, ManifestNames } from './manifests.js';\nexport { classify, readProbes, renderEvidence, verdictOf } from './probe.js';\nexport type { Classified, CodeBlock, ProbeFile, ProbeResult, ProbeRun, ProbeSet, ProbeSpec } from './probe.js';\nexport { createReader } from './reader.js';\nexport { addRulingRow, nextId, pathsOf, readRulings, renderMemo, renderRow } from './rulings.js';\nexport type { EscalationOption, EscalationRequest, RulingRow, TableView } from './rulings.js';\nexport { buildContext, checkPaths, checkRulings, raiseEscalation, recordRuling, resolveBase, runAudit } from './round.js';\nexport { GUARD_HOOK, mcpServer, mergeClaudeSettings, mergeMcp, mergeSpecGraph, PROJECT_DIR, PROJECT_DIR_OR_HERE } from './configure.js';\nexport type { BriefRow, FileChange, Finding, Severity } from './types.js';\n"]}
|
package/dist/manifests.d.ts
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* that can be answered exactly, and it matters: a dependency is code nobody in
|
|
7
7
|
* the review read. Each reader here understands the part of its format that
|
|
8
8
|
* declares dependencies and nothing more - no resolver, no lockfile, no
|
|
9
|
-
* network. A manifest it cannot read is reported as unread, never as clean
|
|
9
|
+
* network. A manifest it cannot read is reported as unread, never as clean,
|
|
10
|
+
* and so is a configured name it cannot read.
|
|
10
11
|
*/
|
|
11
12
|
export type Ecosystem = 'npm' | 'cargo' | 'go' | 'pip' | 'python' | 'nuget' | 'bundler';
|
|
12
13
|
export interface Dependency {
|
|
@@ -34,6 +35,21 @@ export type ManifestRead = {
|
|
|
34
35
|
};
|
|
35
36
|
/** The ecosystem a manifest file name belongs to, or `null`. */
|
|
36
37
|
export declare function ecosystemOf(path: string): Ecosystem | null;
|
|
38
|
+
export interface ManifestNames {
|
|
39
|
+
/** Whether a path is a manifest by one of the names that could be read, matched at any depth. */
|
|
40
|
+
readonly match: (path: string) => boolean;
|
|
41
|
+
/** The names spec-core's glob refused, malformed or too large to compile, each with its reason. */
|
|
42
|
+
readonly unread: readonly {
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly reason: string;
|
|
45
|
+
}[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The configured manifest names, read. A name that cannot be read names no
|
|
49
|
+
* manifest, and is returned so the audit can say so: every file it was
|
|
50
|
+
* meant to name would otherwise go unmeasured in silence.
|
|
51
|
+
*/
|
|
52
|
+
export declare function readManifestNames(patterns: readonly string[]): ManifestNames;
|
|
37
53
|
/** A predicate over paths for the configured manifest names, matched at any depth. */
|
|
38
54
|
export declare function manifestMatcher(patterns: readonly string[]): (path: string) => boolean;
|
|
39
55
|
/** The name a PEP 508 requirement names, normalised as PEP 503 says. */
|
package/dist/manifests.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* that can be answered exactly, and it matters: a dependency is code nobody in
|
|
7
7
|
* the review read. Each reader here understands the part of its format that
|
|
8
8
|
* declares dependencies and nothing more - no resolver, no lockfile, no
|
|
9
|
-
* network. A manifest it cannot read is reported as unread, never as clean
|
|
9
|
+
* network. A manifest it cannot read is reported as unread, never as clean,
|
|
10
|
+
* and so is a configured name it cannot read.
|
|
10
11
|
*/
|
|
11
12
|
import { parseGlob } from './vendor/spec-core/pattern/index.js';
|
|
12
13
|
/** The ecosystem a manifest file name belongs to, or `null`. */
|
|
@@ -28,15 +29,26 @@ export function ecosystemOf(path) {
|
|
|
28
29
|
return 'bundler';
|
|
29
30
|
return null;
|
|
30
31
|
}
|
|
31
|
-
/**
|
|
32
|
-
|
|
32
|
+
/**
|
|
33
|
+
* The configured manifest names, read. A name that cannot be read names no
|
|
34
|
+
* manifest, and is returned so the audit can say so: every file it was
|
|
35
|
+
* meant to name would otherwise go unmeasured in silence.
|
|
36
|
+
*/
|
|
37
|
+
export function readManifestNames(patterns) {
|
|
33
38
|
const globs = [];
|
|
39
|
+
const unread = [];
|
|
34
40
|
for (const pattern of patterns) {
|
|
35
41
|
const parsed = parseGlob(pattern, { dialect: 'ripgrep', caseSensitive: true });
|
|
36
42
|
if (parsed.ok)
|
|
37
43
|
globs.push(parsed.glob);
|
|
44
|
+
else
|
|
45
|
+
unread.push({ name: pattern, reason: parsed.error });
|
|
38
46
|
}
|
|
39
|
-
return (path) => globs.some((glob) => glob.match(path));
|
|
47
|
+
return { match: (path) => globs.some((glob) => glob.match(path)), unread };
|
|
48
|
+
}
|
|
49
|
+
/** A predicate over paths for the configured manifest names, matched at any depth. */
|
|
50
|
+
export function manifestMatcher(patterns) {
|
|
51
|
+
return readManifestNames(patterns).match;
|
|
40
52
|
}
|
|
41
53
|
/* --------------------------------------------------------------------- npm */
|
|
42
54
|
const NPM_SECTIONS = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'];
|
package/dist/manifests.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifests.js","sourceRoot":"","sources":["../src/manifests.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,SAAS,EAAa,MAAM,qCAAqC,CAAC;AAwB3E,gEAAgE;AAChE,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACnD,IAAI,IAAI,KAAK,cAAc;QAAE,OAAO,KAAK,CAAC;IAC1C,IAAI,IAAI,KAAK,YAAY;QAAE,OAAO,OAAO,CAAC;IAC1C,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACnC,IAAI,IAAI,KAAK,gBAAgB;QAAE,OAAO,QAAQ,CAAC;IAC/C,IAAI,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACrD,IAAI,IAAI,KAAK,0BAA0B,IAAI,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,OAAO,CAAC;IAC5F,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACzC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AC,EAAE,CAAC,CAAC;QAC7B,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,OAAO,KAAK,UAAU,CAAC,OAAO,EAAE,CAAC;YACtE,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,IAAI,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;QACtJ,CAAC;IACH,CAAC;IACD,KAAK,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,IAAI,GAAG,EAAE,CAAC;QACnC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAClJ,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,CAAC;AACrB,CAAC","sourcesContent":["/**\n * Which dependencies a round added, removed or moved, read from the manifests\n * it changed.\n *\n * \"No new dependency without saying so\" is one of the few audit questions\n * that can be answered exactly, and it matters: a dependency is code nobody in\n * the review read. Each reader here understands the part of its format that\n * declares dependencies and nothing more - no resolver, no lockfile, no\n * network. A manifest it cannot read is reported as unread, never as clean.\n */\n\nimport { parseGlob, type Glob } from './vendor/spec-core/pattern/index.js';\n\nexport type Ecosystem = 'npm' | 'cargo' | 'go' | 'pip' | 'python' | 'nuget' | 'bundler';\n\nexport interface Dependency {\n readonly section: string;\n readonly name: string;\n /** The version or requirement as written; `''` when none is. */\n readonly version: string;\n}\n\nexport interface DependencyChange {\n readonly file: string;\n readonly ecosystem: Ecosystem;\n readonly section: string;\n readonly name: string;\n /** `null` when the dependency is new. */\n readonly before: string | null;\n /** `null` when the dependency was removed. */\n readonly after: string | null;\n}\n\nexport type ManifestRead = { readonly ok: true; readonly dependencies: readonly Dependency[] } | { readonly ok: false; readonly error: string };\n\n/** The ecosystem a manifest file name belongs to, or `null`. */\nexport function ecosystemOf(path: string): Ecosystem | null {\n const name = path.slice(path.lastIndexOf('/') + 1);\n if (name === 'package.json') return 'npm';\n if (name === 'Cargo.toml') return 'cargo';\n if (name === 'go.mod') return 'go';\n if (name === 'pyproject.toml') return 'python';\n if (/^requirements.*\\.txt$/.test(name)) return 'pip';\n if (name === 'Directory.Packages.props' || /\\.(?:cs|fs|vb)proj$/.test(name)) return 'nuget';\n if (name === 'Gemfile') return 'bundler';\n return null;\n}\n\n/** A predicate over paths for the configured manifest names, matched at any depth. */\nexport function manifestMatcher(patterns: readonly string[]): (path: string) => boolean {\n const globs: Glob[] = [];\n for (const pattern of patterns) {\n const parsed = parseGlob(pattern, { dialect: 'ripgrep', caseSensitive: true });\n if (parsed.ok) globs.push(parsed.glob);\n }\n return (path) => globs.some((glob) => glob.match(path));\n}\n\n/* --------------------------------------------------------------------- npm */\n\nconst NPM_SECTIONS = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'];\n\nfunction readNpm(text: string): ManifestRead {\n let value: unknown;\n try {\n value = JSON.parse(text);\n } catch {\n return { ok: false, error: 'not valid JSON' };\n }\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return { ok: false, error: 'not a JSON object' };\n const out: Dependency[] = [];\n for (const section of NPM_SECTIONS) {\n const table = (value as Record<string, unknown>)[section];\n if (table === undefined) continue;\n if (typeof table !== 'object' || table === null || Array.isArray(table)) return { ok: false, error: `\"${section}\" is not an object` };\n for (const [name, version] of Object.entries(table)) out.push({ section, name, version: String(version) });\n }\n return { ok: true, dependencies: out };\n}\n\n/* -------------------------------------------------------------------- TOML */\n\n/** A TOML value on one line, or the start of a multi-line array. Comments and quotes read the way TOML reads them. */\nfunction stripTomlComment(line: string): string {\n let quote: string | null = null;\n for (let i = 0; i < line.length; i += 1) {\n const ch = line.charAt(i);\n if (quote !== null) {\n if (ch === '\\\\' && quote === '\"') i += 1;\n else if (ch === quote) quote = null;\n } else if (ch === '\"' || ch === \"'\") {\n quote = ch;\n } else if (ch === '#') {\n return line.slice(0, i);\n }\n }\n return line;\n}\n\nfunction unquote(value: string): string {\n const trimmed = value.trim();\n if (trimmed.length >= 2 && (trimmed.startsWith('\"') || trimmed.startsWith(\"'\")) && trimmed.endsWith(trimmed.charAt(0))) {\n return trimmed.slice(1, -1);\n }\n return trimmed;\n}\n\n/**\n * The strings of a TOML array, `[\"a>=1\", 'b']`, possibly spread over lines.\n * A string inside an inline table is a value of that table, not an element:\n * `{include-group = \"test\"}` in a dependency group names a group, not a package.\n */\nfunction tomlStrings(text: string): string[] {\n const out: string[] = [];\n let depth = 0;\n let i = 0;\n while (i < text.length) {\n const ch = text.charAt(i);\n if (ch === '{') depth += 1;\n else if (ch === '}') depth -= 1;\n if (ch === '\"' || ch === \"'\") {\n let j = i + 1;\n let value = '';\n while (j < text.length && text.charAt(j) !== ch) {\n if (text.charAt(j) === '\\\\' && ch === '\"') {\n value += text.charAt(j + 1);\n j += 2;\n continue;\n }\n value += text.charAt(j);\n j += 1;\n }\n if (depth === 0) out.push(value);\n i = j + 1;\n continue;\n }\n i += 1;\n }\n return out;\n}\n\n/** The name a PEP 508 requirement names, normalised as PEP 503 says. */\nexport function pythonName(requirement: string): string {\n const match = /^\\s*([A-Za-z0-9][A-Za-z0-9._-]*)/.exec(requirement);\n return (match?.[1] ?? requirement.trim()).toLowerCase().replace(/[-_.]+/g, '-');\n}\n\ninterface TomlLine {\n readonly table: string;\n readonly key: string;\n readonly value: string;\n}\n\n/** Top-level `key = value` lines per table header, arrays gathered across lines. Enough for dependency tables. */\nfunction tomlEntries(text: string): TomlLine[] | string {\n const out: TomlLine[] = [];\n let table = '';\n const lines = text.split(/\\r?\\n/);\n for (let i = 0; i < lines.length; i += 1) {\n const line = stripTomlComment(lines[i] as string).trim();\n if (line === '') continue;\n const header = /^\\[\\[?\\s*([^\\]]+?)\\s*\\]\\]?$/.exec(line);\n if (header !== null) {\n table = (header[1] as string).replace(/\\s*\\.\\s*/g, '.');\n continue;\n }\n const eq = line.indexOf('=');\n if (eq <= 0) continue;\n const key = unquote(line.slice(0, eq));\n let value = line.slice(eq + 1).trim();\n if (value.startsWith('[') && !balanced(value)) {\n while (i + 1 < lines.length && !balanced(value)) {\n i += 1;\n value += ` ${stripTomlComment(lines[i] as string).trim()}`;\n }\n if (!balanced(value)) return `the array for \"${key}\" is never closed`;\n }\n out.push({ table, key, value });\n }\n return out;\n}\n\nfunction balanced(value: string): boolean {\n let depth = 0;\n let quote: string | null = null;\n for (let i = 0; i < value.length; i += 1) {\n const ch = value.charAt(i);\n if (quote !== null) {\n if (ch === '\\\\' && quote === '\"') i += 1;\n else if (ch === quote) quote = null;\n } else if (ch === '\"' || ch === \"'\") quote = ch;\n else if (ch === '[') depth += 1;\n else if (ch === ']') depth -= 1;\n }\n return depth <= 0 && quote === null;\n}\n\nconst CARGO_TABLE = /^(?:target\\..+\\.)?((?:workspace\\.)?(?:dev-|build-)?dependencies)(?:\\.(.+))?$/;\n\nfunction readCargo(text: string): ManifestRead {\n const entries = tomlEntries(text);\n if (typeof entries === 'string') return { ok: false, error: entries };\n const out = new Map<string, Dependency>();\n for (const { table, key, value } of entries) {\n const match = CARGO_TABLE.exec(table);\n if (match === null) continue;\n const section = match[1] as string;\n const inline = match[2];\n if (inline !== undefined) {\n // [dependencies.serde] then `version = \"1\"`: the table names the crate.\n const name = unquote(inline);\n const id = `${section}\\u0000${name}`;\n const current = out.get(id) ?? { section, name, version: '' };\n out.set(id, key === 'version' ? { ...current, version: unquote(value) } : current);\n continue;\n }\n const version = value.startsWith('{') ? (/version\\s*=\\s*(\"[^\"]*\"|'[^']*')/.exec(value)?.[1] ?? '') : value;\n out.set(`${section}\\u0000${key}`, { section, name: key, version: unquote(version) });\n }\n return { ok: true, dependencies: [...out.values()] };\n}\n\nfunction readPyproject(text: string): ManifestRead {\n const entries = tomlEntries(text);\n if (typeof entries === 'string') return { ok: false, error: entries };\n const out: Dependency[] = [];\n for (const { table, key, value } of entries) {\n if (table === 'project' && key === 'dependencies') {\n for (const requirement of tomlStrings(value)) out.push({ section: 'project', name: pythonName(requirement), version: requirement });\n } else if (table === 'project.optional-dependencies' || table === 'dependency-groups') {\n for (const requirement of tomlStrings(value)) out.push({ section: `${table}.${key}`, name: pythonName(requirement), version: requirement });\n } else if (/^tool\\.poetry\\.(?:group\\.[^.]+\\.)?(?:dev-)?dependencies$/.test(table) && key.toLowerCase() !== 'python') {\n out.push({ section: table, name: pythonName(key), version: unquote(value) });\n }\n }\n return { ok: true, dependencies: out };\n}\n\n/* ------------------------------------------------------------ line formats */\n\nfunction readGoMod(text: string): ManifestRead {\n const out: Dependency[] = [];\n let block = false;\n for (const raw of text.split(/\\r?\\n/)) {\n const indirect = /\\/\\/\\s*indirect\\b/.test(raw);\n const line = raw.replace(/\\/\\/.*$/, '').trim();\n if (line === '') continue;\n if (block) {\n if (line === ')') {\n block = false;\n continue;\n }\n const [name, version] = line.split(/\\s+/);\n if (name !== undefined) out.push({ section: indirect ? 'require (indirect)' : 'require', name, version: version ?? '' });\n continue;\n }\n if (/^require\\s*\\($/.test(line)) {\n block = true;\n continue;\n }\n const single = /^require\\s+(\\S+)\\s+(\\S+)/.exec(line);\n if (single !== null) out.push({ section: indirect ? 'require (indirect)' : 'require', name: single[1] as string, version: single[2] as string });\n }\n if (block) return { ok: false, error: 'a require block is never closed' };\n return { ok: true, dependencies: out };\n}\n\nfunction readRequirements(text: string): ManifestRead {\n const out: Dependency[] = [];\n for (const raw of text.split(/\\r?\\n/)) {\n const line = raw.replace(/(^|\\s)#.*$/, '').trim();\n if (line === '' || line.startsWith('-')) continue;\n out.push({ section: 'requirements', name: pythonName(line), version: line });\n }\n return { ok: true, dependencies: out };\n}\n\nfunction readNuget(text: string): ManifestRead {\n const out: Dependency[] = [];\n const element = /<(PackageReference|PackageVersion)\\b([^>]*?)\\/?>/g;\n for (let match = element.exec(text); match !== null; match = element.exec(text)) {\n const attributes = match[2] as string;\n const name = /\\bInclude\\s*=\\s*\"([^\"]*)\"/.exec(attributes)?.[1] ?? /\\bUpdate\\s*=\\s*\"([^\"]*)\"/.exec(attributes)?.[1];\n if (name === undefined) continue;\n const version = /\\bVersion\\s*=\\s*\"([^\"]*)\"/.exec(attributes)?.[1] ?? '';\n out.push({ section: match[1] as string, name, version });\n }\n return { ok: true, dependencies: out };\n}\n\nfunction readGemfile(text: string): ManifestRead {\n const out: Dependency[] = [];\n for (const raw of text.split(/\\r?\\n/)) {\n const match = /^\\s*gem\\s+([\"'])([^\"']+)\\1\\s*(?:,\\s*([\"'])([^\"']*)\\3)?/.exec(raw);\n if (match !== null) out.push({ section: 'gem', name: match[2] as string, version: match[4] ?? '' });\n }\n return { ok: true, dependencies: out };\n}\n\n/** Reads the dependencies a manifest declares. */\nexport function readManifest(ecosystem: Ecosystem, text: string): ManifestRead {\n switch (ecosystem) {\n case 'npm':\n return readNpm(text);\n case 'cargo':\n return readCargo(text);\n case 'go':\n return readGoMod(text);\n case 'python':\n return readPyproject(text);\n case 'pip':\n return readRequirements(text);\n case 'nuget':\n return readNuget(text);\n case 'bundler':\n return readGemfile(text);\n }\n}\n\n/**\n * What changed between two versions of one manifest. `null` text is a file\n * that does not exist on that side. Returns the error instead when either\n * side cannot be read.\n */\nexport function diffManifest(\n file: string,\n ecosystem: Ecosystem,\n before: string | null,\n after: string | null,\n): { readonly changes: readonly DependencyChange[] } | { readonly error: string } {\n const read = (text: string | null, side: string): readonly Dependency[] | string => {\n if (text === null) return [];\n const result = readManifest(ecosystem, text);\n return result.ok ? result.dependencies : `${file} (${side}): ${result.error}`;\n };\n const old = read(before, 'before');\n if (typeof old === 'string') return { error: old };\n const now = read(after, 'after');\n if (typeof now === 'string') return { error: now };\n const key = (d: Dependency): string => `${d.section}\\u0000${d.name}`;\n const was = new Map(old.map((d) => [key(d), d]));\n const is = new Map(now.map((d) => [key(d), d]));\n const changes: DependencyChange[] = [];\n for (const [id, dependency] of is) {\n const previous = was.get(id);\n if (previous === undefined || previous.version !== dependency.version) {\n changes.push({ file, ecosystem, section: dependency.section, name: dependency.name, before: previous?.version ?? null, after: dependency.version });\n }\n }\n for (const [id, dependency] of was) {\n if (!is.has(id)) changes.push({ file, ecosystem, section: dependency.section, name: dependency.name, before: dependency.version, after: null });\n }\n return { changes };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"manifests.js","sourceRoot":"","sources":["../src/manifests.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,SAAS,EAAa,MAAM,qCAAqC,CAAC;AAwB3E,gEAAgE;AAChE,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACnD,IAAI,IAAI,KAAK,cAAc;QAAE,OAAO,KAAK,CAAC;IAC1C,IAAI,IAAI,KAAK,YAAY;QAAE,OAAO,OAAO,CAAC;IAC1C,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACnC,IAAI,IAAI,KAAK,gBAAgB;QAAE,OAAO,QAAQ,CAAC;IAC/C,IAAI,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACrD,IAAI,IAAI,KAAK,0BAA0B,IAAI,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,OAAO,CAAC;IAC5F,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACzC,OAAO,IAAI,CAAC;AACd,CAAC;AASD;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAA2B;IAC3D,MAAM,KAAK,GAAW,EAAE,CAAC;IACzB,MAAM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AAC,CAAC,CAAC,CAAC;IAChD,MAAM,OAAO,GAAuB,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC;QAClC,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC7B,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,OAAO,KAAK,UAAU,CAAC,OAAO,EAAE,CAAC;YACtE,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,IAAI,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;QACtJ,CAAC;IACH,CAAC;IACD,KAAK,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,IAAI,GAAG,EAAE,CAAC;QACnC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAClJ,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,CAAC;AACrB,CAAC","sourcesContent":["/**\n * Which dependencies a round added, removed or moved, read from the manifests\n * it changed.\n *\n * \"No new dependency without saying so\" is one of the few audit questions\n * that can be answered exactly, and it matters: a dependency is code nobody in\n * the review read. Each reader here understands the part of its format that\n * declares dependencies and nothing more - no resolver, no lockfile, no\n * network. A manifest it cannot read is reported as unread, never as clean,\n * and so is a configured name it cannot read.\n */\n\nimport { parseGlob, type Glob } from './vendor/spec-core/pattern/index.js';\n\nexport type Ecosystem = 'npm' | 'cargo' | 'go' | 'pip' | 'python' | 'nuget' | 'bundler';\n\nexport interface Dependency {\n readonly section: string;\n readonly name: string;\n /** The version or requirement as written; `''` when none is. */\n readonly version: string;\n}\n\nexport interface DependencyChange {\n readonly file: string;\n readonly ecosystem: Ecosystem;\n readonly section: string;\n readonly name: string;\n /** `null` when the dependency is new. */\n readonly before: string | null;\n /** `null` when the dependency was removed. */\n readonly after: string | null;\n}\n\nexport type ManifestRead = { readonly ok: true; readonly dependencies: readonly Dependency[] } | { readonly ok: false; readonly error: string };\n\n/** The ecosystem a manifest file name belongs to, or `null`. */\nexport function ecosystemOf(path: string): Ecosystem | null {\n const name = path.slice(path.lastIndexOf('/') + 1);\n if (name === 'package.json') return 'npm';\n if (name === 'Cargo.toml') return 'cargo';\n if (name === 'go.mod') return 'go';\n if (name === 'pyproject.toml') return 'python';\n if (/^requirements.*\\.txt$/.test(name)) return 'pip';\n if (name === 'Directory.Packages.props' || /\\.(?:cs|fs|vb)proj$/.test(name)) return 'nuget';\n if (name === 'Gemfile') return 'bundler';\n return null;\n}\n\nexport interface ManifestNames {\n /** Whether a path is a manifest by one of the names that could be read, matched at any depth. */\n readonly match: (path: string) => boolean;\n /** The names spec-core's glob refused, malformed or too large to compile, each with its reason. */\n readonly unread: readonly { readonly name: string; readonly reason: string }[];\n}\n\n/**\n * The configured manifest names, read. A name that cannot be read names no\n * manifest, and is returned so the audit can say so: every file it was\n * meant to name would otherwise go unmeasured in silence.\n */\nexport function readManifestNames(patterns: readonly string[]): ManifestNames {\n const globs: Glob[] = [];\n const unread: { name: string; reason: string }[] = [];\n for (const pattern of patterns) {\n const parsed = parseGlob(pattern, { dialect: 'ripgrep', caseSensitive: true });\n if (parsed.ok) globs.push(parsed.glob);\n else unread.push({ name: pattern, reason: parsed.error });\n }\n return { match: (path) => globs.some((glob) => glob.match(path)), unread };\n}\n\n/** A predicate over paths for the configured manifest names, matched at any depth. */\nexport function manifestMatcher(patterns: readonly string[]): (path: string) => boolean {\n return readManifestNames(patterns).match;\n}\n\n/* --------------------------------------------------------------------- npm */\n\nconst NPM_SECTIONS = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'];\n\nfunction readNpm(text: string): ManifestRead {\n let value: unknown;\n try {\n value = JSON.parse(text);\n } catch {\n return { ok: false, error: 'not valid JSON' };\n }\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return { ok: false, error: 'not a JSON object' };\n const out: Dependency[] = [];\n for (const section of NPM_SECTIONS) {\n const table = (value as Record<string, unknown>)[section];\n if (table === undefined) continue;\n if (typeof table !== 'object' || table === null || Array.isArray(table)) return { ok: false, error: `\"${section}\" is not an object` };\n for (const [name, version] of Object.entries(table)) out.push({ section, name, version: String(version) });\n }\n return { ok: true, dependencies: out };\n}\n\n/* -------------------------------------------------------------------- TOML */\n\n/** A TOML value on one line, or the start of a multi-line array. Comments and quotes read the way TOML reads them. */\nfunction stripTomlComment(line: string): string {\n let quote: string | null = null;\n for (let i = 0; i < line.length; i += 1) {\n const ch = line.charAt(i);\n if (quote !== null) {\n if (ch === '\\\\' && quote === '\"') i += 1;\n else if (ch === quote) quote = null;\n } else if (ch === '\"' || ch === \"'\") {\n quote = ch;\n } else if (ch === '#') {\n return line.slice(0, i);\n }\n }\n return line;\n}\n\nfunction unquote(value: string): string {\n const trimmed = value.trim();\n if (trimmed.length >= 2 && (trimmed.startsWith('\"') || trimmed.startsWith(\"'\")) && trimmed.endsWith(trimmed.charAt(0))) {\n return trimmed.slice(1, -1);\n }\n return trimmed;\n}\n\n/**\n * The strings of a TOML array, `[\"a>=1\", 'b']`, possibly spread over lines.\n * A string inside an inline table is a value of that table, not an element:\n * `{include-group = \"test\"}` in a dependency group names a group, not a package.\n */\nfunction tomlStrings(text: string): string[] {\n const out: string[] = [];\n let depth = 0;\n let i = 0;\n while (i < text.length) {\n const ch = text.charAt(i);\n if (ch === '{') depth += 1;\n else if (ch === '}') depth -= 1;\n if (ch === '\"' || ch === \"'\") {\n let j = i + 1;\n let value = '';\n while (j < text.length && text.charAt(j) !== ch) {\n if (text.charAt(j) === '\\\\' && ch === '\"') {\n value += text.charAt(j + 1);\n j += 2;\n continue;\n }\n value += text.charAt(j);\n j += 1;\n }\n if (depth === 0) out.push(value);\n i = j + 1;\n continue;\n }\n i += 1;\n }\n return out;\n}\n\n/** The name a PEP 508 requirement names, normalised as PEP 503 says. */\nexport function pythonName(requirement: string): string {\n const match = /^\\s*([A-Za-z0-9][A-Za-z0-9._-]*)/.exec(requirement);\n return (match?.[1] ?? requirement.trim()).toLowerCase().replace(/[-_.]+/g, '-');\n}\n\ninterface TomlLine {\n readonly table: string;\n readonly key: string;\n readonly value: string;\n}\n\n/** Top-level `key = value` lines per table header, arrays gathered across lines. Enough for dependency tables. */\nfunction tomlEntries(text: string): TomlLine[] | string {\n const out: TomlLine[] = [];\n let table = '';\n const lines = text.split(/\\r?\\n/);\n for (let i = 0; i < lines.length; i += 1) {\n const line = stripTomlComment(lines[i] as string).trim();\n if (line === '') continue;\n const header = /^\\[\\[?\\s*([^\\]]+?)\\s*\\]\\]?$/.exec(line);\n if (header !== null) {\n table = (header[1] as string).replace(/\\s*\\.\\s*/g, '.');\n continue;\n }\n const eq = line.indexOf('=');\n if (eq <= 0) continue;\n const key = unquote(line.slice(0, eq));\n let value = line.slice(eq + 1).trim();\n if (value.startsWith('[') && !balanced(value)) {\n while (i + 1 < lines.length && !balanced(value)) {\n i += 1;\n value += ` ${stripTomlComment(lines[i] as string).trim()}`;\n }\n if (!balanced(value)) return `the array for \"${key}\" is never closed`;\n }\n out.push({ table, key, value });\n }\n return out;\n}\n\nfunction balanced(value: string): boolean {\n let depth = 0;\n let quote: string | null = null;\n for (let i = 0; i < value.length; i += 1) {\n const ch = value.charAt(i);\n if (quote !== null) {\n if (ch === '\\\\' && quote === '\"') i += 1;\n else if (ch === quote) quote = null;\n } else if (ch === '\"' || ch === \"'\") quote = ch;\n else if (ch === '[') depth += 1;\n else if (ch === ']') depth -= 1;\n }\n return depth <= 0 && quote === null;\n}\n\nconst CARGO_TABLE = /^(?:target\\..+\\.)?((?:workspace\\.)?(?:dev-|build-)?dependencies)(?:\\.(.+))?$/;\n\nfunction readCargo(text: string): ManifestRead {\n const entries = tomlEntries(text);\n if (typeof entries === 'string') return { ok: false, error: entries };\n const out = new Map<string, Dependency>();\n for (const { table, key, value } of entries) {\n const match = CARGO_TABLE.exec(table);\n if (match === null) continue;\n const section = match[1] as string;\n const inline = match[2];\n if (inline !== undefined) {\n // [dependencies.serde] then `version = \"1\"`: the table names the crate.\n const name = unquote(inline);\n const id = `${section}\\u0000${name}`;\n const current = out.get(id) ?? { section, name, version: '' };\n out.set(id, key === 'version' ? { ...current, version: unquote(value) } : current);\n continue;\n }\n const version = value.startsWith('{') ? (/version\\s*=\\s*(\"[^\"]*\"|'[^']*')/.exec(value)?.[1] ?? '') : value;\n out.set(`${section}\\u0000${key}`, { section, name: key, version: unquote(version) });\n }\n return { ok: true, dependencies: [...out.values()] };\n}\n\nfunction readPyproject(text: string): ManifestRead {\n const entries = tomlEntries(text);\n if (typeof entries === 'string') return { ok: false, error: entries };\n const out: Dependency[] = [];\n for (const { table, key, value } of entries) {\n if (table === 'project' && key === 'dependencies') {\n for (const requirement of tomlStrings(value)) out.push({ section: 'project', name: pythonName(requirement), version: requirement });\n } else if (table === 'project.optional-dependencies' || table === 'dependency-groups') {\n for (const requirement of tomlStrings(value)) out.push({ section: `${table}.${key}`, name: pythonName(requirement), version: requirement });\n } else if (/^tool\\.poetry\\.(?:group\\.[^.]+\\.)?(?:dev-)?dependencies$/.test(table) && key.toLowerCase() !== 'python') {\n out.push({ section: table, name: pythonName(key), version: unquote(value) });\n }\n }\n return { ok: true, dependencies: out };\n}\n\n/* ------------------------------------------------------------ line formats */\n\nfunction readGoMod(text: string): ManifestRead {\n const out: Dependency[] = [];\n let block = false;\n for (const raw of text.split(/\\r?\\n/)) {\n const indirect = /\\/\\/\\s*indirect\\b/.test(raw);\n const line = raw.replace(/\\/\\/.*$/, '').trim();\n if (line === '') continue;\n if (block) {\n if (line === ')') {\n block = false;\n continue;\n }\n const [name, version] = line.split(/\\s+/);\n if (name !== undefined) out.push({ section: indirect ? 'require (indirect)' : 'require', name, version: version ?? '' });\n continue;\n }\n if (/^require\\s*\\($/.test(line)) {\n block = true;\n continue;\n }\n const single = /^require\\s+(\\S+)\\s+(\\S+)/.exec(line);\n if (single !== null) out.push({ section: indirect ? 'require (indirect)' : 'require', name: single[1] as string, version: single[2] as string });\n }\n if (block) return { ok: false, error: 'a require block is never closed' };\n return { ok: true, dependencies: out };\n}\n\nfunction readRequirements(text: string): ManifestRead {\n const out: Dependency[] = [];\n for (const raw of text.split(/\\r?\\n/)) {\n const line = raw.replace(/(^|\\s)#.*$/, '').trim();\n if (line === '' || line.startsWith('-')) continue;\n out.push({ section: 'requirements', name: pythonName(line), version: line });\n }\n return { ok: true, dependencies: out };\n}\n\nfunction readNuget(text: string): ManifestRead {\n const out: Dependency[] = [];\n const element = /<(PackageReference|PackageVersion)\\b([^>]*?)\\/?>/g;\n for (let match = element.exec(text); match !== null; match = element.exec(text)) {\n const attributes = match[2] as string;\n const name = /\\bInclude\\s*=\\s*\"([^\"]*)\"/.exec(attributes)?.[1] ?? /\\bUpdate\\s*=\\s*\"([^\"]*)\"/.exec(attributes)?.[1];\n if (name === undefined) continue;\n const version = /\\bVersion\\s*=\\s*\"([^\"]*)\"/.exec(attributes)?.[1] ?? '';\n out.push({ section: match[1] as string, name, version });\n }\n return { ok: true, dependencies: out };\n}\n\nfunction readGemfile(text: string): ManifestRead {\n const out: Dependency[] = [];\n for (const raw of text.split(/\\r?\\n/)) {\n const match = /^\\s*gem\\s+([\"'])([^\"']+)\\1\\s*(?:,\\s*([\"'])([^\"']*)\\3)?/.exec(raw);\n if (match !== null) out.push({ section: 'gem', name: match[2] as string, version: match[4] ?? '' });\n }\n return { ok: true, dependencies: out };\n}\n\n/** Reads the dependencies a manifest declares. */\nexport function readManifest(ecosystem: Ecosystem, text: string): ManifestRead {\n switch (ecosystem) {\n case 'npm':\n return readNpm(text);\n case 'cargo':\n return readCargo(text);\n case 'go':\n return readGoMod(text);\n case 'python':\n return readPyproject(text);\n case 'pip':\n return readRequirements(text);\n case 'nuget':\n return readNuget(text);\n case 'bundler':\n return readGemfile(text);\n }\n}\n\n/**\n * What changed between two versions of one manifest. `null` text is a file\n * that does not exist on that side. Returns the error instead when either\n * side cannot be read.\n */\nexport function diffManifest(\n file: string,\n ecosystem: Ecosystem,\n before: string | null,\n after: string | null,\n): { readonly changes: readonly DependencyChange[] } | { readonly error: string } {\n const read = (text: string | null, side: string): readonly Dependency[] | string => {\n if (text === null) return [];\n const result = readManifest(ecosystem, text);\n return result.ok ? result.dependencies : `${file} (${side}): ${result.error}`;\n };\n const old = read(before, 'before');\n if (typeof old === 'string') return { error: old };\n const now = read(after, 'after');\n if (typeof now === 'string') return { error: now };\n const key = (d: Dependency): string => `${d.section}\\u0000${d.name}`;\n const was = new Map(old.map((d) => [key(d), d]));\n const is = new Map(now.map((d) => [key(d), d]));\n const changes: DependencyChange[] = [];\n for (const [id, dependency] of is) {\n const previous = was.get(id);\n if (previous === undefined || previous.version !== dependency.version) {\n changes.push({ file, ecosystem, section: dependency.section, name: dependency.name, before: previous?.version ?? null, after: dependency.version });\n }\n }\n for (const [id, dependency] of was) {\n if (!is.has(id)) changes.push({ file, ecosystem, section: dependency.section, name: dependency.name, before: dependency.version, after: null });\n }\n return { changes };\n}\n"]}
|
package/dist/round.js
CHANGED
|
@@ -15,7 +15,7 @@ import { readRules, renderContext } from './context.js';
|
|
|
15
15
|
import { readJsonObject, readText, repositoryPath, stateDirectory, writeAtomic } from './fs.js';
|
|
16
16
|
import { blameLine, changes, mergeBase, remoteDefault, revision, show, verifyCommit } from './git.js';
|
|
17
17
|
import { decide } from './guard.js';
|
|
18
|
-
import { diffManifest, ecosystemOf,
|
|
18
|
+
import { diffManifest, ecosystemOf, readManifestNames } from './manifests.js';
|
|
19
19
|
import { addRulingRow, nextId, readRulings, renderMemo, renderRow, } from './rulings.js';
|
|
20
20
|
import { compileGlob } from './vendor/spec-core/pattern/index.js';
|
|
21
21
|
import { dirname, isRelativeReference, resolveInside, splitReference } from './vendor/spec-core/path/index.js';
|
|
@@ -111,11 +111,26 @@ export async function checkPaths(workspace, brief, noBrief, given, cwd, reader,
|
|
|
111
111
|
return resolved.map(({ path, given: g }) => decide({ path, given: g, brief, noBrief, rulings, outOfScope: workspace.config.outOfScope }));
|
|
112
112
|
}
|
|
113
113
|
/* ----------------------------------------------------------------- context */
|
|
114
|
-
|
|
114
|
+
/**
|
|
115
|
+
* The paths spec-guard is asked about for a scope: where its patterns can
|
|
116
|
+
* match. A name with no glob syntax that exists is asked about as itself,
|
|
117
|
+
* since spec-guard reads from the disk whether a path is a file or a
|
|
118
|
+
* directory. One the round has yet to create may become either, and
|
|
119
|
+
* spec-guard would read it as a file, leaving out the rules over a
|
|
120
|
+
* directory of that name; it is asked about through the directory that will
|
|
121
|
+
* hold it, the root for a name at the top, which covers both.
|
|
122
|
+
*/
|
|
123
|
+
function scopeBases(root, patterns) {
|
|
124
|
+
// Read as a directory, a name's base is the name itself; read any other
|
|
125
|
+
// way, it is the directory holding it, so which other reading a missing
|
|
126
|
+
// name gets changes nothing. The glob is compiled for its bases and never
|
|
127
|
+
// matched: a file read as a directory narrows the question and nothing
|
|
128
|
+
// else.
|
|
129
|
+
const literal = (path) => (existsSync(join(root, path)) ? 'directory' : 'either');
|
|
115
130
|
const bases = new Set();
|
|
116
131
|
for (const pattern of patterns) {
|
|
117
132
|
try {
|
|
118
|
-
for (const base of compileGlob(pattern, { dialect: 'path', caseSensitive: true }).bases)
|
|
133
|
+
for (const base of compileGlob(pattern, { dialect: 'path', caseSensitive: true, literal }).bases)
|
|
119
134
|
bases.add(base === '' ? '.' : base);
|
|
120
135
|
}
|
|
121
136
|
catch {
|
|
@@ -125,7 +140,7 @@ function scopeBases(patterns) {
|
|
|
125
140
|
return [...bases].sort();
|
|
126
141
|
}
|
|
127
142
|
async function rulesFor(workspace, brief) {
|
|
128
|
-
const paths = scopeBases(brief.affectedFiles);
|
|
143
|
+
const paths = scopeBases(workspace.root, brief.affectedFiles);
|
|
129
144
|
if (paths.length === 0)
|
|
130
145
|
return [];
|
|
131
146
|
try {
|
|
@@ -199,9 +214,12 @@ export async function buildContext(workspace, brief, briefs, reader, baseFlag) {
|
|
|
199
214
|
}
|
|
200
215
|
/* ------------------------------------------------------------------- audit */
|
|
201
216
|
async function dependencyChanges(workspace, base) {
|
|
217
|
+
// A name that cannot be read is reported with or without a base: it would
|
|
218
|
+
// leave its manifests out of every audit measured from one.
|
|
219
|
+
const names = readManifestNames(workspace.config.dependencies.manifests);
|
|
202
220
|
if (base.kind === 'unresolved')
|
|
203
|
-
return { changes: [], unread: [] };
|
|
204
|
-
const isManifest =
|
|
221
|
+
return { changes: [], unread: [], unreadNames: names.unread };
|
|
222
|
+
const isManifest = names.match;
|
|
205
223
|
const out = [];
|
|
206
224
|
const unread = [];
|
|
207
225
|
for (const change of await changes(base.mergeBase, base.head, workspace.root)) {
|
|
@@ -220,7 +238,7 @@ async function dependencyChanges(workspace, base) {
|
|
|
220
238
|
else
|
|
221
239
|
out.push(...diff.changes);
|
|
222
240
|
}
|
|
223
|
-
return { changes: out, unread };
|
|
241
|
+
return { changes: out, unread, unreadNames: names.unread };
|
|
224
242
|
}
|
|
225
243
|
/** Whether spec-brief loads this package's plugin, as its configuration at the root says. */
|
|
226
244
|
export async function specBriefPlugin(root) {
|
package/dist/round.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"round.js","sourceRoot":"","sources":["../src/round.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO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: the operations the command line and the MCP server\n * share. Each gathers what a pure module needs - from git, the disk and the\n * siblings - and hands it over; the decisions are made in `context.ts`,\n * `audit.ts`, `guard.ts` and `rulings.ts`.\n */\n\nimport { createHash } from 'node:crypto';\nimport { existsSync } from 'node:fs';\nimport { readdir, readFile, rm } from 'node:fs/promises';\nimport { join } from 'node:path';\n\nimport { audit, type ArchiveReason, type AssertionOutcome, type AuditReport } from './audit.js';\nimport { sameId } from './branch.js';\nimport {\n enabledPlugin,\n holdsGuard,\n loadsPlugin,\n registersServer,\n SPEC_BRIEF_CONFIGS,\n type BaseSource,\n type ClaudeCodeWiring,\n type ClaudeSettings,\n type PluginState,\n} from './configure.js';\nimport { readRules, renderContext, type CitedDocument, type ContextPacket, type Rules } from './context.js';\nimport type { DocumentReader } from './document.js';\nimport { readJsonObject, readText, repositoryPath, stateDirectory, writeAtomic } from './fs.js';\nimport { blameLine, changes, mergeBase, remoteDefault, revision, show, verifyCommit } from './git.js';\nimport { decide, type Decision, type VerifiedRuling } from './guard.js';\nimport { diffManifest, ecosystemOf, manifestMatcher, type DependencyChange } from './manifests.js';\nimport {\n addRulingRow,\n nextId,\n readRulings,\n renderMemo,\n renderRow,\n type EscalationOption,\n type EscalationRequest,\n type RulingRow,\n} from './rulings.js';\nimport type { BriefRow, Finding } from './types.js';\nimport { compileGlob } from './vendor/spec-core/pattern/index.js';\nimport { dirname, isRelativeReference, resolveInside, splitReference } from './vendor/spec-core/path/index.js';\nimport { SiblingError } from './siblings.js';\nimport { UsageError, type CliIO, type Workspace } from './workspace.js';\n\n/* -------------------------------------------------------------------- base */\n\nexport type Base =\n | { readonly kind: 'resolved'; readonly ref: string; readonly source: BaseSource; readonly sha: string; readonly mergeBase: string; readonly head: string }\n | { readonly kind: 'unresolved'; readonly reason: string };\n\n/** What the round is measured from: the flag, the configuration, then the remote's default branch. */\nexport async function resolveBase(workspace: Workspace, flag: string | undefined): Promise<Base> {\n const source: BaseSource = flag !== undefined ? 'flag' : workspace.config.base !== null ? 'config' : 'remote';\n const ref = flag ?? workspace.config.base ?? (await remoteDefault(workspace.root));\n if (ref === null) {\n return { kind: 'unresolved', reason: 'no base is named and the remote has no default branch; pass --base <ref> or set \"base\"' };\n }\n const sha = await revision(ref, workspace.root);\n const head = await revision('HEAD', workspace.root);\n if (sha === null || head === null) return { kind: 'unresolved', reason: `\"${ref}\" names no commit` };\n const common = await mergeBase(sha, head, workspace.root);\n if (common === null) return { kind: 'unresolved', reason: `\"${ref}\" and HEAD share no history` };\n return { kind: 'resolved', ref, source, sha, mergeBase: common, head };\n}\n\n/* ----------------------------------------------------------------- rulings */\n\nexport interface RulingCheck {\n readonly rows: readonly RulingRow[];\n readonly verified: readonly VerifiedRuling[];\n readonly unverified: readonly { readonly id: string; readonly reason: string }[];\n readonly problems: readonly Finding[];\n}\n\n/**\n * The brief's rulings, each checked against its signature: the commit that\n * last changed its row must be signed by a principal the base branch's\n * allowed-signers file lists (ADR-0006).\n */\nexport async function checkRulings(workspace: Workspace, brief: BriefRow, text: string, reader: DocumentReader, base: Base): Promise<RulingCheck> {\n const { rulings: rows, problems } = readRulings(reader.sectionTables(text, workspace.config.rulings.section).tables);\n const findings: Finding[] = problems.map((problem) => ({\n rule: 'ruling-unreadable',\n severity: 'warning',\n message: problem.message,\n hint: 'a ruling row is | id | `paths` | allow or deny | note |',\n file: brief.file,\n line: problem.line,\n }));\n const allows = rows.filter((row) => row.decision === 'allow');\n if (allows.length === 0) return { rows, verified: [], unverified: [], problems: findings };\n if (base.kind === 'unresolved') {\n return { rows, verified: [], unverified: allows.map((row) => ({ id: row.id, reason: `no base to read the allowed signers from: ${base.reason}` })), problems: findings };\n }\n const signers = await show(base.sha, workspace.config.rulings.allowedSigners, workspace.root);\n if (signers === null) {\n const reason = `${base.ref} has no ${workspace.config.rulings.allowedSigners}, so no signature can count`;\n return { rows, verified: [], unverified: allows.map((row) => ({ id: row.id, reason })), problems: findings };\n }\n const directory = await stateDirectory(workspace.commonDir, 'signers');\n const file = join(directory, `${createHash('sha256').update(signers).digest('hex').slice(0, 16)}`);\n await writeAtomic(file, signers);\n const verified: VerifiedRuling[] = [];\n const unverified: { id: string; reason: string }[] = [];\n for (const row of allows) {\n // The row's line is a line of the text on disk, so it is blamed there: at\n // HEAD the same number can be another line, one a signed commit wrote,\n // and an uncommitted row would borrow that commit's signature.\n const commit = await blameLine(null, brief.file, row.line, workspace.root);\n if (commit === null || /^0+$/.test(commit)) {\n unverified.push({ id: row.id, reason: 'its row is not committed' });\n continue;\n }\n const signature = await verifyCommit(commit, file, workspace.root);\n if (signature.good && signature.principal !== null) verified.push({ id: row.id, paths: row.paths, signer: signature.principal });\n else unverified.push({ id: row.id, reason: `commit ${commit.slice(0, 12)} last changed its row, and ${signature.detail || 'it is not signed'}` });\n }\n return { rows, verified, unverified, problems: findings };\n}\n\n/* ------------------------------------------------------------------- guard */\n\nexport async function briefText(workspace: Workspace, brief: BriefRow): Promise<string> {\n const text = await readText(join(workspace.root, brief.file));\n if (text === null) throw new UsageError(`${brief.file} cannot be read`);\n return text;\n}\n\n/** Decides paths against the brief, with the rulings verified against the base `baseFlag` names, or the configured one. */\nexport async function checkPaths(\n workspace: Workspace,\n brief: BriefRow | null,\n noBrief: string | undefined,\n given: readonly string[],\n cwd: string,\n reader: DocumentReader,\n baseFlag: string | undefined,\n): Promise<Decision[]> {\n let rulings: readonly VerifiedRuling[] = [];\n const resolved = given.map((path) => ({ given: path, path: repositoryPath(path, workspace.root, cwd) }));\n if (brief !== null) {\n // Rulings cost a blame and a signature check each, so they are read only\n // when a write reaches a protected file.\n const first = resolved.map(({ path, given: g }) =>\n decide({ path, given: g, brief, noBrief, rulings: [], outOfScope: workspace.config.outOfScope }),\n );\n if (first.some((decision) => decision.reason === 'protected')) {\n const base = await resolveBase(workspace, baseFlag);\n rulings = (await checkRulings(workspace, brief, await briefText(workspace, brief), reader, base)).verified;\n } else {\n return first;\n }\n }\n return resolved.map(({ path, given: g }) => decide({ path, given: g, brief, noBrief, rulings, outOfScope: workspace.config.outOfScope }));\n}\n\n/* ----------------------------------------------------------------- context */\n\nfunction scopeBases(patterns: readonly string[]): string[] {\n const bases = new Set<string>();\n for (const pattern of patterns) {\n try {\n for (const base of compileGlob(pattern, { dialect: 'path', caseSensitive: true }).bases) bases.add(base === '' ? '.' : base);\n } catch {\n // spec-brief lint reports a pattern it cannot read; the rules for the rest still count.\n }\n }\n return [...bases].sort();\n}\n\nasync function rulesFor(workspace: Workspace, brief: BriefRow): Promise<Rules> {\n const paths = scopeBases(brief.affectedFiles);\n if (paths.length === 0) return [];\n try {\n const answer = await workspace.siblings.json('spec-guard', ['query', ...paths, '--json']);\n return 'absent' in answer ? { unavailable: answer.absent } : readRules(answer);\n } catch (error) {\n // spec-guard printed no JSON: what it said instead is the reason, and\n // the rest of the packet stands without the rules.\n if (error instanceof SiblingError) return { unavailable: error.message };\n throw error;\n }\n}\n\nasync function citedDocuments(workspace: Workspace, brief: BriefRow, text: string, reader: DocumentReader): Promise<CitedDocument[]> {\n const seen = new Set<string>();\n const out: CitedDocument[] = [];\n for (const citation of reader.citations(text)) {\n if (!isRelativeReference(citation.target)) continue;\n let target = splitReference(citation.target).path;\n try {\n target = decodeURIComponent(target);\n } catch {\n // A destination that is not valid percent-encoding is read as written.\n }\n const path = resolveInside(dirname(brief.file), target);\n if (path === null || path === '' || path === brief.file || seen.has(path)) continue;\n seen.add(path);\n const document = /\\.(?:md|markdown|mdx|txt)$/i.test(path);\n // A link to code or a directory that exists is not a document to include,\n // and must not be reported as a link that resolves to nothing.\n if (!document && existsSync(join(workspace.root, path))) continue;\n const content = document ? await readText(join(workspace.root, path)) : null;\n const meta = content === null ? { title: null, status: null } : reader.titleAndStatus(content);\n out.push({ path, ...meta, text: content });\n }\n return out;\n}\n\nexport async function buildContext(\n workspace: Workspace,\n brief: BriefRow,\n briefs: readonly BriefRow[],\n reader: DocumentReader,\n baseFlag: string | undefined,\n): Promise<ContextPacket> {\n const text = await briefText(workspace, brief);\n const base = await resolveBase(workspace, baseFlag);\n const [rules, cited, rulings] = await Promise.all([\n rulesFor(workspace, brief),\n citedDocuments(workspace, brief, text, reader),\n checkRulings(workspace, brief, text, reader, base),\n ]);\n return renderContext({\n brief,\n briefText: text,\n dependencies: brief.dependsOn.map(\n (id) =>\n // spec-brief reports a dependency as its front matter spells it, `7` for brief 007.\n briefs.find((candidate) => sameId(candidate.id, id)) ?? {\n ...brief,\n id,\n title: '(no such brief)',\n file: '',\n phase: 'live',\n status: 'unknown',\n },\n ),\n cited,\n rules,\n rulings: rulings.verified,\n branch: workspace.branch,\n base: base.kind === 'resolved' ? base.ref : null,\n budget: workspace.config.context.budget,\n });\n}\n\n/* ------------------------------------------------------------------- audit */\n\nasync function dependencyChanges(workspace: Workspace, base: Base): Promise<{ changes: DependencyChange[]; unread: string[] }> {\n if (base.kind === 'unresolved') return { changes: [], unread: [] };\n const isManifest = manifestMatcher(workspace.config.dependencies.manifests);\n const out: DependencyChange[] = [];\n const unread: string[] = [];\n for (const change of await changes(base.mergeBase, base.head, workspace.root)) {\n if (!isManifest(change.path) && !(change.from !== undefined && isManifest(change.from))) continue;\n const ecosystem = ecosystemOf(change.path);\n if (ecosystem === null) {\n unread.push(change.path);\n continue;\n }\n const before = change.status === 'A' ? null : await show(base.mergeBase, change.from ?? change.path, workspace.root);\n const after = change.status === 'D' ? null : await show(base.head, change.path, workspace.root);\n const diff = diffManifest(change.path, ecosystem, before, after);\n if ('error' in diff) unread.push(change.path);\n else out.push(...diff.changes);\n }\n return { changes: out, unread };\n}\n\n/** Whether spec-brief loads this package's plugin, as its configuration at the root says. */\nexport async function specBriefPlugin(root: string): Promise<PluginState> {\n const file = SPEC_BRIEF_CONFIGS.find((name) => existsSync(join(root, name)));\n if (file === undefined) return { kind: 'unconfigured' };\n const config = await readJsonObject(join(root, file));\n if (config === null || config === 'unreadable') return { kind: 'unreadable', file };\n return { kind: loadsPlugin(config) ? 'loaded' : 'not-loaded', file };\n}\n\n/**\n * Claude Code's settings files that can turn a plugin on or hold a hook,\n * lowest precedence first: the user's, the project's, and the person's own\n * for the project. The user's is in `CLAUDE_CONFIG_DIR` when that is set,\n * otherwise in `.claude` under the home directory Claude Code uses,\n * `USERPROFILE` on Windows and `HOME` elsewhere; with neither it is not read.\n * Managed settings and `--settings` are not files a project can see.\n */\nexport function claudeSettingsFiles(root: string, env: CliIO['env'], platform: NodeJS.Platform = process.platform): { file: string; path: string }[] {\n const home = (platform === 'win32' ? env['USERPROFILE'] : env['HOME']) || undefined;\n const configDir = env['CLAUDE_CONFIG_DIR'] || (home === undefined ? undefined : join(home, '.claude'));\n const user = configDir === undefined ? null : join(configDir, 'settings.json');\n return [\n ...(user === null ? [] : [{ file: user, path: user }]),\n { file: '.claude/settings.json', path: join(root, '.claude', 'settings.json') },\n { file: '.claude/settings.local.json', path: join(root, '.claude', 'settings.local.json') },\n ];\n}\n\n/** The settings files Claude Code reads here, as read; one that is missing or cannot be read as JSON holds nothing. */\nexport async function claudeSettings(root: string, env: CliIO['env']): Promise<ClaudeSettings[]> {\n return Promise.all(claudeSettingsFiles(root, env).map(async ({ file, path }) => ({ file, settings: await readJsonObject(path) })));\n}\n\n/** Whether the plugin, init's entries, both or neither wire Claude Code to the harness here. */\nexport async function claudeCodeWiring(root: string, env: CliIO['env']): Promise<ClaudeCodeWiring> {\n const sources = await claudeSettings(root, env);\n return {\n plugin: enabledPlugin(sources),\n hooks: sources.filter(({ settings }) => holdsGuard(settings)).map(({ file }) => file),\n server: registersServer(await readJsonObject(join(root, '.mcp.json'))),\n };\n}\n\nasync function archiveReasons(workspace: Workspace, brief: BriefRow, base: Base): Promise<{ blocking: ArchiveReason[]; warnings: ArchiveReason[] } | { unavailable: string }> {\n const args = ['archive', brief.id, '--dry-run', '--format', 'json', '--no-color'];\n if (base.kind === 'resolved') args.push('--base', base.ref);\n const answer = await workspace.siblings.json('spec-brief', args);\n if ('absent' in answer) return { unavailable: answer.absent };\n if (answer.code === 2) return { unavailable: 'spec-brief could not plan the archive' };\n const plan = (answer.document as { plan?: { blocking?: ArchiveReason[]; warnings?: ArchiveReason[] } }).plan;\n return { blocking: plan?.blocking ?? [], warnings: plan?.warnings ?? [] };\n}\n\nasync function briefAssertions(workspace: Workspace, brief: BriefRow, text: string, reader: DocumentReader): Promise<AssertionOutcome[] | { unavailable: string }> {\n const answer = await workspace.siblings.json('spec-guard', [brief.file, '--ignore-status', '--json']);\n if ('absent' in answer) return { unavailable: answer.absent };\n if (answer.code === 2) return { unavailable: 'spec-guard could not run the brief\\'s assertions' };\n const report = answer.document as { results?: { ok: boolean; description: string; message: string; spec?: { file: string; line: number } }[] };\n return (report.results ?? [])\n .filter((result) => result.spec === undefined || result.spec.file.replace(/\\\\/g, '/') === brief.file)\n .map((result) => {\n const line = result.spec?.line ?? 0;\n return { ok: result.ok, description: result.description, message: result.message, line, section: reader.sectionAt(text, line), enclosing: reader.sectionsAt(text, line) };\n });\n}\n\nexport interface AuditResult {\n readonly brief: BriefRow;\n readonly base: Base;\n readonly report: AuditReport;\n readonly dependencies: readonly DependencyChange[];\n}\n\nexport async function runAudit(workspace: Workspace, brief: BriefRow, reader: DocumentReader, baseFlag: string | undefined): Promise<AuditResult> {\n const base = await resolveBase(workspace, baseFlag);\n const text = await briefText(workspace, brief);\n const [dependencies, archive, assertions, rulings, plugin] = await Promise.all([\n dependencyChanges(workspace, base),\n archiveReasons(workspace, brief, base),\n briefAssertions(workspace, brief, text, reader),\n checkRulings(workspace, brief, text, reader, base),\n specBriefPlugin(workspace.root),\n ]);\n const unmeasured =\n base.kind === 'unresolved' ? base.reason : base.mergeBase === base.head ? `${base.ref} and HEAD are the same commit: there is nothing to measure` : null;\n const report = audit({\n brief,\n unmeasured,\n dependencies,\n archive,\n assertions,\n premiseSections: workspace.config.assertions.premises,\n unverifiedRulings: rulings.unverified,\n verifiedRulings: rulings.verified,\n pluginLoaded: plugin.kind === 'loaded',\n });\n return {\n brief,\n base,\n dependencies: dependencies.changes,\n report: { findings: [...rulings.problems, ...report.findings], counts: tally([...rulings.problems, ...report.findings]) },\n };\n}\n\nfunction tally(findings: readonly Finding[]): AuditReport['counts'] {\n const counts = { error: 0, warning: 0, note: 0 };\n for (const finding of findings) counts[finding.severity] += 1;\n return counts;\n}\n\n/* -------------------------------------------------------------- escalation */\n\nasync function escalationDirectory(workspace: Workspace): Promise<string> {\n return stateDirectory(workspace.commonDir, 'escalations');\n}\n\nexport async function listEscalations(workspace: Workspace): Promise<EscalationRequest[]> {\n const directory = await escalationDirectory(workspace);\n const out: EscalationRequest[] = [];\n for (const name of (await readdir(directory)).filter((n) => n.endsWith('.json')).sort()) {\n try {\n out.push(JSON.parse(await readFile(join(directory, name), 'utf8')) as EscalationRequest);\n } catch {\n // A request that cannot be read is skipped; listing it would list nothing true.\n }\n }\n return out;\n}\n\nexport async function raiseEscalation(\n workspace: Workspace,\n brief: BriefRow,\n request: { paths: readonly string[]; reason: string; options: readonly EscalationOption[]; recommendation: string | null },\n): Promise<{ request: EscalationRequest; memo: string }> {\n const existing = await listEscalations(workspace);\n const id = nextId('E', brief.id, existing.map((e) => e.id));\n const full: EscalationRequest = {\n id,\n brief: brief.id,\n briefFile: brief.file,\n paths: request.paths,\n reason: request.reason,\n options: request.options,\n recommendation: request.recommendation,\n created: new Date().toISOString(),\n branch: workspace.branch,\n head: await revision('HEAD', workspace.root),\n };\n await writeAtomic(join(await escalationDirectory(workspace), `${id}.json`), `${JSON.stringify(full, null, 2)}\\n`);\n return { request: full, memo: renderMemo(full) };\n}\n\n/** Writes a person's ruling into the brief and retires the request. Never commits: the signature is the person's. */\nexport async function recordRuling(\n workspace: Workspace,\n escalationId: string,\n decision: 'allow' | 'deny',\n note: string,\n reader: DocumentReader,\n): Promise<{ id: string; file: string; row: string }> {\n const request = (await listEscalations(workspace)).find((candidate) => candidate.id === escalationId.toUpperCase() || candidate.id === escalationId);\n if (request === undefined) throw new UsageError(`no escalation \"${escalationId}\" is waiting; spec-harness escalate --list shows those that are`);\n const path = join(workspace.root, request.briefFile);\n const text = await readText(path);\n if (text === null) throw new UsageError(`${request.briefFile} cannot be read`);\n const where = reader.sectionTables(text, workspace.config.rulings.section);\n const taken = readRulings(where.tables).rulings.map((row) => row.id);\n const id = nextId('R', request.brief, taken);\n const row = renderRow(id, request.paths, decision, note);\n await writeAtomic(path, addRulingRow(text, workspace.config.rulings.section, row, where));\n await rm(join(await escalationDirectory(workspace), `${request.id}.json`), { force: true });\n return { id, file: request.briefFile, row };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"round.js","sourceRoot":"","sources":["../src/round.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,KAAK,EAAgF,MAAM,YAAY,CAAC;AACjH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,aAAa,EACb,UAAU,EACV,WAAW,EACX,eAAe,EACf,kBAAkB,GAKnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAsD,MAAM,cAAc,CAAC;AAE5G,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAChG,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACtG,OAAO,EAAE,MAAM,EAAsC,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAyB,MAAM,gBAAgB,CAAC;AACrG,OAAO,EACL,YAAY,EACZ,MAAM,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G,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,IAAI,KAAK,IAAI;QAAE,MAAM,IAAI,UAAU,CAAC,GAAG,OAAO,CAAC,SAAS,iBAAiB,CAAC,CAAC;IAC/E,MAAM,KAAK,GAAG,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3E,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACrE,MAAM,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC7C,MAAM,GAAG,GAAG,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IACzD,MAAM,WAAW,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IAC1F,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,mBAAmB,CAAC,SAAS,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5F,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC;AAC9C,CAAC","sourcesContent":["/**\n * A round, measured: the operations the command line and the MCP server\n * share. Each gathers what a pure module needs - from git, the disk and the\n * siblings - and hands it over; the decisions are made in `context.ts`,\n * `audit.ts`, `guard.ts` and `rulings.ts`.\n */\n\nimport { createHash } from 'node:crypto';\nimport { existsSync } from 'node:fs';\nimport { readdir, readFile, rm } from 'node:fs/promises';\nimport { join } from 'node:path';\n\nimport { audit, type ArchiveReason, type AssertionOutcome, type AuditInput, type AuditReport } from './audit.js';\nimport { sameId } from './branch.js';\nimport {\n enabledPlugin,\n holdsGuard,\n loadsPlugin,\n registersServer,\n SPEC_BRIEF_CONFIGS,\n type BaseSource,\n type ClaudeCodeWiring,\n type ClaudeSettings,\n type PluginState,\n} from './configure.js';\nimport { readRules, renderContext, type CitedDocument, type ContextPacket, type Rules } from './context.js';\nimport type { DocumentReader } from './document.js';\nimport { readJsonObject, readText, repositoryPath, stateDirectory, writeAtomic } from './fs.js';\nimport { blameLine, changes, mergeBase, remoteDefault, revision, show, verifyCommit } from './git.js';\nimport { decide, type Decision, type VerifiedRuling } from './guard.js';\nimport { diffManifest, ecosystemOf, readManifestNames, type DependencyChange } from './manifests.js';\nimport {\n addRulingRow,\n nextId,\n readRulings,\n renderMemo,\n renderRow,\n type EscalationOption,\n type EscalationRequest,\n type RulingRow,\n} from './rulings.js';\nimport type { BriefRow, Finding } from './types.js';\nimport { compileGlob, type LiteralReading } from './vendor/spec-core/pattern/index.js';\nimport { dirname, isRelativeReference, resolveInside, splitReference } from './vendor/spec-core/path/index.js';\nimport { SiblingError } from './siblings.js';\nimport { UsageError, type CliIO, type Workspace } from './workspace.js';\n\n/* -------------------------------------------------------------------- base */\n\nexport type Base =\n | { readonly kind: 'resolved'; readonly ref: string; readonly source: BaseSource; readonly sha: string; readonly mergeBase: string; readonly head: string }\n | { readonly kind: 'unresolved'; readonly reason: string };\n\n/** What the round is measured from: the flag, the configuration, then the remote's default branch. */\nexport async function resolveBase(workspace: Workspace, flag: string | undefined): Promise<Base> {\n const source: BaseSource = flag !== undefined ? 'flag' : workspace.config.base !== null ? 'config' : 'remote';\n const ref = flag ?? workspace.config.base ?? (await remoteDefault(workspace.root));\n if (ref === null) {\n return { kind: 'unresolved', reason: 'no base is named and the remote has no default branch; pass --base <ref> or set \"base\"' };\n }\n const sha = await revision(ref, workspace.root);\n const head = await revision('HEAD', workspace.root);\n if (sha === null || head === null) return { kind: 'unresolved', reason: `\"${ref}\" names no commit` };\n const common = await mergeBase(sha, head, workspace.root);\n if (common === null) return { kind: 'unresolved', reason: `\"${ref}\" and HEAD share no history` };\n return { kind: 'resolved', ref, source, sha, mergeBase: common, head };\n}\n\n/* ----------------------------------------------------------------- rulings */\n\nexport interface RulingCheck {\n readonly rows: readonly RulingRow[];\n readonly verified: readonly VerifiedRuling[];\n readonly unverified: readonly { readonly id: string; readonly reason: string }[];\n readonly problems: readonly Finding[];\n}\n\n/**\n * The brief's rulings, each checked against its signature: the commit that\n * last changed its row must be signed by a principal the base branch's\n * allowed-signers file lists (ADR-0006).\n */\nexport async function checkRulings(workspace: Workspace, brief: BriefRow, text: string, reader: DocumentReader, base: Base): Promise<RulingCheck> {\n const { rulings: rows, problems } = readRulings(reader.sectionTables(text, workspace.config.rulings.section).tables);\n const findings: Finding[] = problems.map((problem) => ({\n rule: 'ruling-unreadable',\n severity: 'warning',\n message: problem.message,\n hint: 'a ruling row is | id | `paths` | allow or deny | note |',\n file: brief.file,\n line: problem.line,\n }));\n const allows = rows.filter((row) => row.decision === 'allow');\n if (allows.length === 0) return { rows, verified: [], unverified: [], problems: findings };\n if (base.kind === 'unresolved') {\n return { rows, verified: [], unverified: allows.map((row) => ({ id: row.id, reason: `no base to read the allowed signers from: ${base.reason}` })), problems: findings };\n }\n const signers = await show(base.sha, workspace.config.rulings.allowedSigners, workspace.root);\n if (signers === null) {\n const reason = `${base.ref} has no ${workspace.config.rulings.allowedSigners}, so no signature can count`;\n return { rows, verified: [], unverified: allows.map((row) => ({ id: row.id, reason })), problems: findings };\n }\n const directory = await stateDirectory(workspace.commonDir, 'signers');\n const file = join(directory, `${createHash('sha256').update(signers).digest('hex').slice(0, 16)}`);\n await writeAtomic(file, signers);\n const verified: VerifiedRuling[] = [];\n const unverified: { id: string; reason: string }[] = [];\n for (const row of allows) {\n // The row's line is a line of the text on disk, so it is blamed there: at\n // HEAD the same number can be another line, one a signed commit wrote,\n // and an uncommitted row would borrow that commit's signature.\n const commit = await blameLine(null, brief.file, row.line, workspace.root);\n if (commit === null || /^0+$/.test(commit)) {\n unverified.push({ id: row.id, reason: 'its row is not committed' });\n continue;\n }\n const signature = await verifyCommit(commit, file, workspace.root);\n if (signature.good && signature.principal !== null) verified.push({ id: row.id, paths: row.paths, signer: signature.principal });\n else unverified.push({ id: row.id, reason: `commit ${commit.slice(0, 12)} last changed its row, and ${signature.detail || 'it is not signed'}` });\n }\n return { rows, verified, unverified, problems: findings };\n}\n\n/* ------------------------------------------------------------------- guard */\n\nexport async function briefText(workspace: Workspace, brief: BriefRow): Promise<string> {\n const text = await readText(join(workspace.root, brief.file));\n if (text === null) throw new UsageError(`${brief.file} cannot be read`);\n return text;\n}\n\n/** Decides paths against the brief, with the rulings verified against the base `baseFlag` names, or the configured one. */\nexport async function checkPaths(\n workspace: Workspace,\n brief: BriefRow | null,\n noBrief: string | undefined,\n given: readonly string[],\n cwd: string,\n reader: DocumentReader,\n baseFlag: string | undefined,\n): Promise<Decision[]> {\n let rulings: readonly VerifiedRuling[] = [];\n const resolved = given.map((path) => ({ given: path, path: repositoryPath(path, workspace.root, cwd) }));\n if (brief !== null) {\n // Rulings cost a blame and a signature check each, so they are read only\n // when a write reaches a protected file.\n const first = resolved.map(({ path, given: g }) =>\n decide({ path, given: g, brief, noBrief, rulings: [], outOfScope: workspace.config.outOfScope }),\n );\n if (first.some((decision) => decision.reason === 'protected')) {\n const base = await resolveBase(workspace, baseFlag);\n rulings = (await checkRulings(workspace, brief, await briefText(workspace, brief), reader, base)).verified;\n } else {\n return first;\n }\n }\n return resolved.map(({ path, given: g }) => decide({ path, given: g, brief, noBrief, rulings, outOfScope: workspace.config.outOfScope }));\n}\n\n/* ----------------------------------------------------------------- context */\n\n/**\n * The paths spec-guard is asked about for a scope: where its patterns can\n * match. A name with no glob syntax that exists is asked about as itself,\n * since spec-guard reads from the disk whether a path is a file or a\n * directory. One the round has yet to create may become either, and\n * spec-guard would read it as a file, leaving out the rules over a\n * directory of that name; it is asked about through the directory that will\n * hold it, the root for a name at the top, which covers both.\n */\nfunction scopeBases(root: string, patterns: readonly string[]): string[] {\n // Read as a directory, a name's base is the name itself; read any other\n // way, it is the directory holding it, so which other reading a missing\n // name gets changes nothing. The glob is compiled for its bases and never\n // matched: a file read as a directory narrows the question and nothing\n // else.\n const literal = (path: string): LiteralReading => (existsSync(join(root, path)) ? 'directory' : 'either');\n const bases = new Set<string>();\n for (const pattern of patterns) {\n try {\n for (const base of compileGlob(pattern, { dialect: 'path', caseSensitive: true, literal }).bases) bases.add(base === '' ? '.' : base);\n } catch {\n // spec-brief lint reports a pattern it cannot read; the rules for the rest still count.\n }\n }\n return [...bases].sort();\n}\n\nasync function rulesFor(workspace: Workspace, brief: BriefRow): Promise<Rules> {\n const paths = scopeBases(workspace.root, brief.affectedFiles);\n if (paths.length === 0) return [];\n try {\n const answer = await workspace.siblings.json('spec-guard', ['query', ...paths, '--json']);\n return 'absent' in answer ? { unavailable: answer.absent } : readRules(answer);\n } catch (error) {\n // spec-guard printed no JSON: what it said instead is the reason, and\n // the rest of the packet stands without the rules.\n if (error instanceof SiblingError) return { unavailable: error.message };\n throw error;\n }\n}\n\nasync function citedDocuments(workspace: Workspace, brief: BriefRow, text: string, reader: DocumentReader): Promise<CitedDocument[]> {\n const seen = new Set<string>();\n const out: CitedDocument[] = [];\n for (const citation of reader.citations(text)) {\n if (!isRelativeReference(citation.target)) continue;\n let target = splitReference(citation.target).path;\n try {\n target = decodeURIComponent(target);\n } catch {\n // A destination that is not valid percent-encoding is read as written.\n }\n const path = resolveInside(dirname(brief.file), target);\n if (path === null || path === '' || path === brief.file || seen.has(path)) continue;\n seen.add(path);\n const document = /\\.(?:md|markdown|mdx|txt)$/i.test(path);\n // A link to code or a directory that exists is not a document to include,\n // and must not be reported as a link that resolves to nothing.\n if (!document && existsSync(join(workspace.root, path))) continue;\n const content = document ? await readText(join(workspace.root, path)) : null;\n const meta = content === null ? { title: null, status: null } : reader.titleAndStatus(content);\n out.push({ path, ...meta, text: content });\n }\n return out;\n}\n\nexport async function buildContext(\n workspace: Workspace,\n brief: BriefRow,\n briefs: readonly BriefRow[],\n reader: DocumentReader,\n baseFlag: string | undefined,\n): Promise<ContextPacket> {\n const text = await briefText(workspace, brief);\n const base = await resolveBase(workspace, baseFlag);\n const [rules, cited, rulings] = await Promise.all([\n rulesFor(workspace, brief),\n citedDocuments(workspace, brief, text, reader),\n checkRulings(workspace, brief, text, reader, base),\n ]);\n return renderContext({\n brief,\n briefText: text,\n dependencies: brief.dependsOn.map(\n (id) =>\n // spec-brief reports a dependency as its front matter spells it, `7` for brief 007.\n briefs.find((candidate) => sameId(candidate.id, id)) ?? {\n ...brief,\n id,\n title: '(no such brief)',\n file: '',\n phase: 'live',\n status: 'unknown',\n },\n ),\n cited,\n rules,\n rulings: rulings.verified,\n branch: workspace.branch,\n base: base.kind === 'resolved' ? base.ref : null,\n budget: workspace.config.context.budget,\n });\n}\n\n/* ------------------------------------------------------------------- audit */\n\nasync function dependencyChanges(workspace: Workspace, base: Base): Promise<AuditInput['dependencies']> {\n // A name that cannot be read is reported with or without a base: it would\n // leave its manifests out of every audit measured from one.\n const names = readManifestNames(workspace.config.dependencies.manifests);\n if (base.kind === 'unresolved') return { changes: [], unread: [], unreadNames: names.unread };\n const isManifest = names.match;\n const out: DependencyChange[] = [];\n const unread: string[] = [];\n for (const change of await changes(base.mergeBase, base.head, workspace.root)) {\n if (!isManifest(change.path) && !(change.from !== undefined && isManifest(change.from))) continue;\n const ecosystem = ecosystemOf(change.path);\n if (ecosystem === null) {\n unread.push(change.path);\n continue;\n }\n const before = change.status === 'A' ? null : await show(base.mergeBase, change.from ?? change.path, workspace.root);\n const after = change.status === 'D' ? null : await show(base.head, change.path, workspace.root);\n const diff = diffManifest(change.path, ecosystem, before, after);\n if ('error' in diff) unread.push(change.path);\n else out.push(...diff.changes);\n }\n return { changes: out, unread, unreadNames: names.unread };\n}\n\n/** Whether spec-brief loads this package's plugin, as its configuration at the root says. */\nexport async function specBriefPlugin(root: string): Promise<PluginState> {\n const file = SPEC_BRIEF_CONFIGS.find((name) => existsSync(join(root, name)));\n if (file === undefined) return { kind: 'unconfigured' };\n const config = await readJsonObject(join(root, file));\n if (config === null || config === 'unreadable') return { kind: 'unreadable', file };\n return { kind: loadsPlugin(config) ? 'loaded' : 'not-loaded', file };\n}\n\n/**\n * Claude Code's settings files that can turn a plugin on or hold a hook,\n * lowest precedence first: the user's, the project's, and the person's own\n * for the project. The user's is in `CLAUDE_CONFIG_DIR` when that is set,\n * otherwise in `.claude` under the home directory Claude Code uses,\n * `USERPROFILE` on Windows and `HOME` elsewhere; with neither it is not read.\n * Managed settings and `--settings` are not files a project can see.\n */\nexport function claudeSettingsFiles(root: string, env: CliIO['env'], platform: NodeJS.Platform = process.platform): { file: string; path: string }[] {\n const home = (platform === 'win32' ? env['USERPROFILE'] : env['HOME']) || undefined;\n const configDir = env['CLAUDE_CONFIG_DIR'] || (home === undefined ? undefined : join(home, '.claude'));\n const user = configDir === undefined ? null : join(configDir, 'settings.json');\n return [\n ...(user === null ? [] : [{ file: user, path: user }]),\n { file: '.claude/settings.json', path: join(root, '.claude', 'settings.json') },\n { file: '.claude/settings.local.json', path: join(root, '.claude', 'settings.local.json') },\n ];\n}\n\n/** The settings files Claude Code reads here, as read; one that is missing or cannot be read as JSON holds nothing. */\nexport async function claudeSettings(root: string, env: CliIO['env']): Promise<ClaudeSettings[]> {\n return Promise.all(claudeSettingsFiles(root, env).map(async ({ file, path }) => ({ file, settings: await readJsonObject(path) })));\n}\n\n/** Whether the plugin, init's entries, both or neither wire Claude Code to the harness here. */\nexport async function claudeCodeWiring(root: string, env: CliIO['env']): Promise<ClaudeCodeWiring> {\n const sources = await claudeSettings(root, env);\n return {\n plugin: enabledPlugin(sources),\n hooks: sources.filter(({ settings }) => holdsGuard(settings)).map(({ file }) => file),\n server: registersServer(await readJsonObject(join(root, '.mcp.json'))),\n };\n}\n\nasync function archiveReasons(workspace: Workspace, brief: BriefRow, base: Base): Promise<{ blocking: ArchiveReason[]; warnings: ArchiveReason[] } | { unavailable: string }> {\n const args = ['archive', brief.id, '--dry-run', '--format', 'json', '--no-color'];\n if (base.kind === 'resolved') args.push('--base', base.ref);\n const answer = await workspace.siblings.json('spec-brief', args);\n if ('absent' in answer) return { unavailable: answer.absent };\n if (answer.code === 2) return { unavailable: 'spec-brief could not plan the archive' };\n const plan = (answer.document as { plan?: { blocking?: ArchiveReason[]; warnings?: ArchiveReason[] } }).plan;\n return { blocking: plan?.blocking ?? [], warnings: plan?.warnings ?? [] };\n}\n\nasync function briefAssertions(workspace: Workspace, brief: BriefRow, text: string, reader: DocumentReader): Promise<AssertionOutcome[] | { unavailable: string }> {\n const answer = await workspace.siblings.json('spec-guard', [brief.file, '--ignore-status', '--json']);\n if ('absent' in answer) return { unavailable: answer.absent };\n if (answer.code === 2) return { unavailable: 'spec-guard could not run the brief\\'s assertions' };\n const report = answer.document as { results?: { ok: boolean; description: string; message: string; spec?: { file: string; line: number } }[] };\n return (report.results ?? [])\n .filter((result) => result.spec === undefined || result.spec.file.replace(/\\\\/g, '/') === brief.file)\n .map((result) => {\n const line = result.spec?.line ?? 0;\n return { ok: result.ok, description: result.description, message: result.message, line, section: reader.sectionAt(text, line), enclosing: reader.sectionsAt(text, line) };\n });\n}\n\nexport interface AuditResult {\n readonly brief: BriefRow;\n readonly base: Base;\n readonly report: AuditReport;\n readonly dependencies: readonly DependencyChange[];\n}\n\nexport async function runAudit(workspace: Workspace, brief: BriefRow, reader: DocumentReader, baseFlag: string | undefined): Promise<AuditResult> {\n const base = await resolveBase(workspace, baseFlag);\n const text = await briefText(workspace, brief);\n const [dependencies, archive, assertions, rulings, plugin] = await Promise.all([\n dependencyChanges(workspace, base),\n archiveReasons(workspace, brief, base),\n briefAssertions(workspace, brief, text, reader),\n checkRulings(workspace, brief, text, reader, base),\n specBriefPlugin(workspace.root),\n ]);\n const unmeasured =\n base.kind === 'unresolved' ? base.reason : base.mergeBase === base.head ? `${base.ref} and HEAD are the same commit: there is nothing to measure` : null;\n const report = audit({\n brief,\n unmeasured,\n dependencies,\n archive,\n assertions,\n premiseSections: workspace.config.assertions.premises,\n unverifiedRulings: rulings.unverified,\n verifiedRulings: rulings.verified,\n pluginLoaded: plugin.kind === 'loaded',\n });\n return {\n brief,\n base,\n dependencies: dependencies.changes,\n report: { findings: [...rulings.problems, ...report.findings], counts: tally([...rulings.problems, ...report.findings]) },\n };\n}\n\nfunction tally(findings: readonly Finding[]): AuditReport['counts'] {\n const counts = { error: 0, warning: 0, note: 0 };\n for (const finding of findings) counts[finding.severity] += 1;\n return counts;\n}\n\n/* -------------------------------------------------------------- escalation */\n\nasync function escalationDirectory(workspace: Workspace): Promise<string> {\n return stateDirectory(workspace.commonDir, 'escalations');\n}\n\nexport async function listEscalations(workspace: Workspace): Promise<EscalationRequest[]> {\n const directory = await escalationDirectory(workspace);\n const out: EscalationRequest[] = [];\n for (const name of (await readdir(directory)).filter((n) => n.endsWith('.json')).sort()) {\n try {\n out.push(JSON.parse(await readFile(join(directory, name), 'utf8')) as EscalationRequest);\n } catch {\n // A request that cannot be read is skipped; listing it would list nothing true.\n }\n }\n return out;\n}\n\nexport async function raiseEscalation(\n workspace: Workspace,\n brief: BriefRow,\n request: { paths: readonly string[]; reason: string; options: readonly EscalationOption[]; recommendation: string | null },\n): Promise<{ request: EscalationRequest; memo: string }> {\n const existing = await listEscalations(workspace);\n const id = nextId('E', brief.id, existing.map((e) => e.id));\n const full: EscalationRequest = {\n id,\n brief: brief.id,\n briefFile: brief.file,\n paths: request.paths,\n reason: request.reason,\n options: request.options,\n recommendation: request.recommendation,\n created: new Date().toISOString(),\n branch: workspace.branch,\n head: await revision('HEAD', workspace.root),\n };\n await writeAtomic(join(await escalationDirectory(workspace), `${id}.json`), `${JSON.stringify(full, null, 2)}\\n`);\n return { request: full, memo: renderMemo(full) };\n}\n\n/** Writes a person's ruling into the brief and retires the request. Never commits: the signature is the person's. */\nexport async function recordRuling(\n workspace: Workspace,\n escalationId: string,\n decision: 'allow' | 'deny',\n note: string,\n reader: DocumentReader,\n): Promise<{ id: string; file: string; row: string }> {\n const request = (await listEscalations(workspace)).find((candidate) => candidate.id === escalationId.toUpperCase() || candidate.id === escalationId);\n if (request === undefined) throw new UsageError(`no escalation \"${escalationId}\" is waiting; spec-harness escalate --list shows those that are`);\n const path = join(workspace.root, request.briefFile);\n const text = await readText(path);\n if (text === null) throw new UsageError(`${request.briefFile} cannot be read`);\n const where = reader.sectionTables(text, workspace.config.rulings.section);\n const taken = readRulings(where.tables).rulings.map((row) => row.id);\n const id = nextId('R', request.brief, taken);\n const row = renderRow(id, request.paths, decision, note);\n await writeAtomic(path, addRulingRow(text, workspace.config.rulings.section, row, where));\n await rm(join(await escalationDirectory(workspace), `${request.id}.json`), { force: true });\n return { id, file: request.briefFile, row };\n}\n"]}
|
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
* - Braces expand first, and each alternative reads as it would written on
|
|
30
30
|
* its own: `{src/,lib}` is `src/` or `lib`, and a trailing `/` means the
|
|
31
31
|
* directory's contents - in an exclusion, the directory and its contents.
|
|
32
|
+
* One that names no path, `{./,lib}` or `{,lib}`, is refused, as `./` and
|
|
33
|
+
* the empty pattern are.
|
|
32
34
|
* - Case is the caller's decision, stated every time. A result must not
|
|
33
35
|
* depend on the host it ran on.
|
|
34
36
|
* - A malformed pattern is an error, never a literal. An unclosed `[` or `{`,
|
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
* - Braces expand first, and each alternative reads as it would written on
|
|
30
30
|
* its own: `{src/,lib}` is `src/` or `lib`, and a trailing `/` means the
|
|
31
31
|
* directory's contents - in an exclusion, the directory and its contents.
|
|
32
|
+
* One that names no path, `{./,lib}` or `{,lib}`, is refused, as `./` and
|
|
33
|
+
* the empty pattern are.
|
|
32
34
|
* - Case is the caller's decision, stated every time. A result must not
|
|
33
35
|
* depend on the host it ran on.
|
|
34
36
|
* - A malformed pattern is an error, never a literal. An unclosed `[` or `{`,
|
|
@@ -104,6 +106,12 @@ function build(source, options) {
|
|
|
104
106
|
return expanded;
|
|
105
107
|
const alternatives = [];
|
|
106
108
|
for (const text of expanded) {
|
|
109
|
+
// Refused before its trailing slash is read, which would make `./` the
|
|
110
|
+
// contents of `.`, every path: `{./,a}` is refused as `./` alone is.
|
|
111
|
+
// Each text the braces give is shorter than the pattern, so only a
|
|
112
|
+
// pattern without braces is its own text.
|
|
113
|
+
if (namesNoPath(text))
|
|
114
|
+
return text === pattern ? 'the pattern names no path' : bracesNamingNoPath(text);
|
|
107
115
|
const parsed = parseAlternative(trailingSlash(text, options.dialect), escapes);
|
|
108
116
|
if (parsed === GLOBSTAR_IN_NAME)
|
|
109
117
|
return `${GLOBSTAR_IN_NAME}: ${globstarAdvice(written)}`;
|
|
@@ -253,6 +261,17 @@ function classEnd(pattern, open, escapes) {
|
|
|
253
261
|
return -1;
|
|
254
262
|
}
|
|
255
263
|
/* ---------------------------------------------------------------- segments */
|
|
264
|
+
/** Whether a pattern's text names no path: nothing in it but `/` and `.` segments. */
|
|
265
|
+
function namesNoPath(text) {
|
|
266
|
+
return text.split('/').every((part) => part === '' || part === '.');
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* The refusal of an alternative the braces give that names no path, naming
|
|
270
|
+
* it as it was expanded, so that `.{/,a}` is told `./`, the text refused.
|
|
271
|
+
*/
|
|
272
|
+
function bracesNamingNoPath(text) {
|
|
273
|
+
return text === '' ? 'the braces expand to an empty pattern' : `the braces expand to "${text}", which names no path`;
|
|
274
|
+
}
|
|
256
275
|
/**
|
|
257
276
|
* What a trailing slash means, read on each alternative the braces give, so
|
|
258
277
|
* that `{src/,lib}` reads `src/` as `src/` alone reads: the directory's
|
|
@@ -261,17 +280,21 @@ function classEnd(pattern, open, escapes) {
|
|
|
261
280
|
* In an exclusion `build/` excludes what `build` does. Git's rule is that a
|
|
262
281
|
* trailing slash matches only a directory, and a directory is excluded with
|
|
263
282
|
* everything in it; a matcher that sees only a path cannot tell a directory
|
|
264
|
-
* from a file, so the slash is dropped, and it anchors nothing.
|
|
265
|
-
* alternative that is only slashes names the root, which `parseAlternative`
|
|
266
|
-
* refuses as naming no path.
|
|
283
|
+
* from a file, so the slash is dropped, and it anchors nothing.
|
|
267
284
|
*
|
|
268
|
-
*
|
|
269
|
-
* is
|
|
285
|
+
* Only ever given a text that names a path, so a name is left. The whole run
|
|
286
|
+
* of slashes is taken, but one slash would read the same, since
|
|
287
|
+
* `parseAlternative` drops the empty segments the rest leave; and taken
|
|
288
|
+
* lazily it is the whole run all the same, since it ends the text.
|
|
270
289
|
*/
|
|
271
290
|
function trailingSlash(text, dialect) {
|
|
272
291
|
const name = text.replace(/\/+$/, '');
|
|
273
|
-
return name === text ||
|
|
292
|
+
return name === text || dialect === 'gitignore' ? name : `${name}/**`;
|
|
274
293
|
}
|
|
294
|
+
/**
|
|
295
|
+
* The segments of a text that names a path - `build` refuses one that does
|
|
296
|
+
* not - so at least one segment is left.
|
|
297
|
+
*/
|
|
275
298
|
function parseAlternative(text, escapes) {
|
|
276
299
|
const segments = [];
|
|
277
300
|
const raw = text.split('/');
|
|
@@ -290,8 +313,6 @@ function parseAlternative(text, escapes) {
|
|
|
290
313
|
return tokens;
|
|
291
314
|
segments.push({ kind: 'name', tokens });
|
|
292
315
|
}
|
|
293
|
-
if (segments.length === 0)
|
|
294
|
-
return 'the pattern names no path';
|
|
295
316
|
return { segments, slashed: raw.filter((part) => part !== '' && part !== '.').length > 1 };
|
|
296
317
|
}
|
|
297
318
|
const EXTGLOB = 'extended globs such as "+(a|b)" are not supported: write alternatives as "{a,b}", and a literal parenthesis as "[(]"';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/pattern/glob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EACL,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C;QACxC,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxE,IAAI,CAAC,MAAM,CAAC,EAAE;YAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,OAAO,MAAM,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;QAC7E,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO;QACL,EAAE,EAAE,IAAI;QACR,IAAI,EAAE;YACJ,OAAO;YACP,KAAK,CAAC,IAAY;gBAChB,IAAI,QAAQ,GAAG,KAAK,CAAC;gBACrB,KAAK,MAAM,KAAK,IAAI,OAAO;oBAAE,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;wBAAE,QAAQ,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC;gBACnF,OAAO,QAAQ,CAAC;YAClB,CAAC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Globs, in the three dialects the spec-* tools speak, compiled to one kind of\n * automaton.\n *\n * The syntax is the part people type: `*`, `**`, `?`, `[abc]`, `[!a-z]`,\n * `{a,b}`, and `\\` to escape. What differs between the tools is not the\n * syntax but what a pattern is matched against, and those differences are\n * deliberate, so each has a name (docs/adr/0003-glob-dialects.md):\n *\n * - `path` - the whole repository-relative path, anchored at the root. A\n * pattern with no glob syntax names a file, a directory, or either, as the\n * caller says; `src/auth` may cover `src/auth/login.ts`.\n * - `ripgrep` - as ripgrep's `-g`: a pattern with no `/` is matched against\n * the last segment at any depth, so `*.ts` matches `src/deep/a.ts`; one with\n * a `/` is matched against the whole path.\n * - `gitignore` - as an exclusion list reads: a pattern matches a path or any\n * directory above it, so `tests` excludes everything under any `tests`; one\n * with a `/` other than a trailing one is anchored at the root, and a\n * leading `/` only anchors.\n *\n * Shared by all three:\n *\n * - `**` is a globstar only as a whole segment. `a/**\\/b` matches `a/b` and\n * `a/x/y/b`; a trailing `/**` matches everything inside a directory and not\n * the directory itself. Two stars inside a name, `**.md`, are refused: the\n * tools read it three ways, and the quiet reading narrowed their scope. The\n * refusal writes the two patterns it may have meant from the one written.\n * - `*`, `?` and classes never match `/`, and `*` matches a leading dot.\n * - Braces expand first, and each alternative reads as it would written on\n * its own: `{src/,lib}` is `src/` or `lib`, and a trailing `/` means the\n * directory's contents - in an exclusion, the directory and its contents.\n * - Case is the caller's decision, stated every time. A result must not\n * depend on the host it ran on.\n * - A malformed pattern is an error, never a literal. An unclosed `[` or `{`,\n * an extended glob, a `..` - each is refused with a reason, because a typo\n * read as a literal is a scope that silently matches nothing. An extended\n * glob is a group holding a `|`, `+(a|b)`: without one, `C++(notes).md` is\n * a name with parentheses in it, as ripgrep and `.gitignore` read it.\n */\n\nimport {\n AutomatonTooLarge,\n Builder,\n findWitness,\n Matcher,\n WITNESS_BUDGET,\n type Automaton,\n type Fragment,\n type Witness,\n} from './automaton.js';\nimport { ANY, classSet, literalSet, SEPARATOR, type CodeRange } from './charset.js';\n\nexport type GlobDialect = 'path' | 'ripgrep' | 'gitignore';\n\n/** How a `path` pattern with no glob syntax is read. */\nexport type LiteralReading = 'file' | 'directory' | 'either';\n\nexport interface GlobOptions {\n readonly dialect: GlobDialect;\n /** Whether `A` and `a` differ. No default: the caller decides, every time. */\n readonly caseSensitive: boolean;\n /**\n * `path` dialect only: how a pattern with no glob syntax is read - as a\n * file, as a directory and everything beneath it, or as either. A function\n * is asked per literal path, for a caller that knows the tree. `either` when\n * unset. A trailing `/`, on the pattern or on one of its brace alternatives,\n * always means a directory's contents, and is never asked about.\n */\n readonly literal?: LiteralReading | ((path: string) => LiteralReading) | undefined;\n /**\n * `escape` (the default): `\\` escapes the next character, and a `\\` before a\n * letter or digit is refused as a Windows separator typed by mistake.\n * `separator`: every `\\` is a `/`, for patterns typed on a Windows shell.\n */\n readonly backslash?: 'escape' | 'separator' | undefined;\n}\n\nexport interface Glob {\n readonly source: string;\n readonly dialect: GlobDialect;\n readonly caseSensitive: boolean;\n /**\n * The directories a walk must enter to find every match: one per\n * alternative, the leading literal segments. `''` for an alternative that\n * can match at any depth.\n */\n readonly bases: readonly string[];\n readonly automaton: Automaton;\n /** Whether a canonical path - POSIX, no `.`, no empty or trailing segment - matches. */\n match(path: string): boolean;\n}\n\nexport type GlobParse = { readonly ok: true; readonly glob: Glob } | { readonly ok: false; readonly error: string };\n\nexport class GlobError extends Error {\n readonly source: string;\n constructor(source: string, reason: string) {\n super(`invalid glob \"${source}\": ${reason}`);\n this.name = 'GlobError';\n this.source = source;\n }\n}\n\n/** More alternatives than this is a pattern nobody meant. */\nexport const MAX_ALTERNATIVES = 256;\n\ntype Token =\n | { readonly kind: 'literal'; readonly point: number }\n | { readonly kind: 'any' }\n | { readonly kind: 'star' }\n | { readonly kind: 'class'; readonly negated: boolean; readonly ranges: readonly CodeRange[] };\n\ntype Segment = { readonly kind: 'globstar' } | { readonly kind: 'name'; readonly tokens: readonly Token[] };\n\ninterface Alternative {\n readonly segments: readonly Segment[];\n /** Written with a `/` somewhere other than at its end. */\n readonly slashed: boolean;\n}\n\n/** Whether a string uses glob syntax at all. */\nexport function isGlobSyntax(source: string): boolean {\n return /[*?[\\]{}]/.test(source);\n}\n\n/**\n * Parses and compiles a glob, or says why it cannot: malformed, or too large\n * to compile, past {@link MAX_ALTERNATIVES} alternatives or `MAX_STATES`\n * states. It throws only what a `literal` function throws.\n */\nexport function parseGlob(source: string, options: GlobOptions): GlobParse {\n const result = build(source, options);\n return typeof result === 'string' ? { ok: false, error: result } : { ok: true, glob: result };\n}\n\n/**\n * Parses and compiles a glob, throwing {@link GlobError} for every reason\n * {@link parseGlob} gives, and what a `literal` function throws.\n */\nexport function compileGlob(source: string, options: GlobOptions): Glob {\n const result = build(source, options);\n if (typeof result === 'string') throw new GlobError(source, result);\n return result;\n}\n\nfunction build(source: string, options: GlobOptions): Glob | string {\n const escapes = options.backslash !== 'separator';\n let pattern = source.trim();\n if (!escapes) pattern = pattern.replace(/\\\\/g, '/');\n const written = pattern;\n if (pattern.length === 0) return 'the pattern is empty';\n if (pattern.startsWith('!')) return 'a negated pattern is a list entry, not a glob; narrow the positive pattern';\n if (/(?:^|[^\\\\])[?*+@!]\\([^)]*\\|/.test(pattern)) return EXTGLOB;\n while (pattern.startsWith('./')) pattern = pattern.slice(2);\n\n // A leading slash roots a pattern at the filesystem's root in the path and\n // ripgrep dialects, and only anchors it at the repository root in gitignore.\n let rooted = false;\n let anchored = false;\n if (pattern.startsWith('/')) {\n if (options.dialect === 'gitignore') anchored = true;\n else rooted = true;\n pattern = pattern.replace(/^\\/+/, '');\n }\n if (pattern.length === 0) return 'the pattern names the root itself, not a path under it';\n\n const expanded = expandBraces(pattern, escapes);\n if (typeof expanded === 'string') return expanded;\n\n const alternatives: Alternative[] = [];\n for (const text of expanded) {\n const parsed = parseAlternative(trailingSlash(text, options.dialect), escapes);\n if (parsed === GLOBSTAR_IN_NAME) return `${GLOBSTAR_IN_NAME}: ${globstarAdvice(written)}`;\n if (typeof parsed === 'string') return parsed;\n alternatives.push(parsed);\n }\n\n const builder = new Builder();\n const fragments: Fragment[] = [];\n const bases: string[] = [];\n let automaton: Automaton;\n try {\n for (const alternative of alternatives) {\n const compiled = compileAlternative(builder, alternative, options, rooted, anchored);\n fragments.push(compiled.fragment);\n bases.push(compiled.base);\n }\n automaton = builder.finish(builder.either(fragments), options.caseSensitive);\n } catch (error) {\n // A pattern too large to compile is refused with a reason, as a malformed\n // one is. Anything else - a caller's literal reading that throws - is the\n // caller's failure, not the pattern's, and goes on up.\n if (error instanceof AutomatonTooLarge) return error.message;\n throw error;\n }\n let matcher: Matcher | null = null;\n return {\n source,\n dialect: options.dialect,\n caseSensitive: options.caseSensitive,\n bases: [...new Set(bases)],\n automaton,\n match(path: string): boolean {\n matcher ??= new Matcher(automaton);\n return matcher.test(path);\n },\n };\n}\n\n/* ------------------------------------------------------------------ braces */\n\n/**\n * Expands `{a,b}` groups into the patterns they stand for, or says why the\n * pattern is malformed.\n *\n * Classes and escapes are skipped while looking for braces and commas, so\n * `{[,]x,y}` is two alternatives, `[,]x` and `y`. A lone `}` is a literal: it\n * cannot be read as anything else. An unclosed `{` is an error.\n *\n * Here and in the two functions after it, a loop that reads one step past\n * the end reads `''`, which none of them acts on, and `classEnd` answers -1\n * or an index past the `[`, so `close > 0` and `close >= 0` read the same.\n * `open` is set by the `{` that any `}` read here closes, so its first value\n * is never read.\n */\nfunction expandBraces(pattern: string, escapes: boolean): string[] | string {\n let depth = 0;\n let open = -1;\n for (let i = 0; i < pattern.length; i += 1) {\n const ch = pattern.charAt(i);\n if (ch === '\\\\' && escapes) {\n i += 1;\n continue;\n }\n if (ch === '[') {\n const close = classEnd(pattern, i, escapes);\n if (close > 0) i = close;\n continue;\n }\n if (ch === '{') {\n if (depth === 0) open = i;\n depth += 1;\n continue;\n }\n if (ch !== '}' || depth === 0) continue;\n depth -= 1;\n if (depth > 0) continue;\n const prefix = pattern.slice(0, open);\n const suffix = pattern.slice(i + 1);\n const results: string[] = [];\n for (const option of splitOptions(pattern.slice(open + 1, i), escapes)) {\n const expanded = expandBraces(`${prefix}${option}${suffix}`, escapes);\n if (typeof expanded === 'string') return expanded;\n results.push(...expanded);\n if (results.length > MAX_ALTERNATIVES) return `the braces expand to more than ${MAX_ALTERNATIVES} patterns`;\n }\n return results;\n }\n if (depth > 0) return 'a \"{\" is never closed';\n return [pattern];\n}\n\n/** Splits a brace body on its top-level commas. */\nfunction splitOptions(body: string, escapes: boolean): string[] {\n const parts: string[] = [];\n let depth = 0;\n let start = 0;\n for (let i = 0; i < body.length; i += 1) {\n const ch = body.charAt(i);\n if (ch === '\\\\' && escapes) {\n i += 1;\n } else if (ch === '[') {\n const close = classEnd(body, i, escapes);\n if (close > 0) i = close;\n } else if (ch === '{') {\n depth += 1;\n } else if (ch === '}') {\n depth -= 1;\n } else if (ch === ',' && depth === 0) {\n parts.push(body.slice(start, i));\n start = i + 1;\n }\n }\n parts.push(body.slice(start));\n return parts;\n}\n\n/** The index of the `]` closing a class opened at `open`, or -1 when none does within the segment. */\nfunction classEnd(pattern: string, open: number, escapes: boolean): number {\n let i = open + 1;\n if (pattern.charAt(i) === '!' || pattern.charAt(i) === '^') i += 1;\n // The first member is always a member, even `]`.\n if (pattern.charAt(i) === ']') i += 1;\n for (; i < pattern.length; i += 1) {\n const ch = pattern.charAt(i);\n if (ch === '\\\\' && escapes) {\n i += 1;\n continue;\n }\n if (ch === '/') return -1;\n if (ch === ']') return i;\n }\n return -1;\n}\n\n/* ---------------------------------------------------------------- segments */\n\n/**\n * What a trailing slash means, read on each alternative the braces give, so\n * that `{src/,lib}` reads `src/` as `src/` alone reads: the directory's\n * contents, `src/**`, and not a literal that may be the directory itself.\n *\n * In an exclusion `build/` excludes what `build` does. Git's rule is that a\n * trailing slash matches only a directory, and a directory is excluded with\n * everything in it; a matcher that sees only a path cannot tell a directory\n * from a file, so the slash is dropped, and it anchors nothing. An\n * alternative that is only slashes names the root, which `parseAlternative`\n * refuses as naming no path.\n *\n * The whole run of slashes is taken, so that `{//,a}` is refused as `{/,a}`\n * is; taken lazily it is the whole run all the same, since it ends the text.\n */\nfunction trailingSlash(text: string, dialect: GlobDialect): string {\n const name = text.replace(/\\/+$/, '');\n return name === text || name === '' || dialect === 'gitignore' ? name : `${name}/**`;\n}\n\nfunction parseAlternative(text: string, escapes: boolean): Alternative | string {\n const segments: Segment[] = [];\n const raw = text.split('/');\n for (const part of raw) {\n if (part === '' || part === '.') continue;\n if (part === '..') return 'a pattern cannot climb out of its root with \"..\"';\n if (part === '**') {\n if (segments[segments.length - 1]?.kind !== 'globstar') segments.push({ kind: 'globstar' });\n continue;\n }\n const tokens = tokenize(part, escapes);\n if (typeof tokens === 'string') return tokens;\n segments.push({ kind: 'name', tokens });\n }\n if (segments.length === 0) return 'the pattern names no path';\n return { segments, slashed: raw.filter((part) => part !== '' && part !== '.').length > 1 };\n}\n\nconst EXTGLOB = 'extended globs such as \"+(a|b)\" are not supported: write alternatives as \"{a,b}\", and a literal parenthesis as \"[(]\"';\nconst GLOBSTAR_IN_NAME = '\"**\" means any number of directories only as a whole segment';\n\n/**\n * The two patterns a writer of `**` inside a name may have meant, built from\n * what they wrote. Each run of stars that is not a whole segment becomes, for\n * any depth, a globstar segment with a star kept on each side where a name\n * went on - `docs/**.md` to `docs/**\\/*.md`, `src/a**` to `src/a*\\/**`,\n * `a**b` to `a*\\/**\\/*b` - and for one level a single star. Everything else\n * stays as written, braces and classes included, and a globstar that was a\n * whole segment stays one.\n *\n * Only `/` is taken for a boundary. A run beside a brace, `{**.md,x}`, is\n * given a star on that side too, which keeps the advice a pattern that\n * compiles whatever the braces expand to.\n *\n * `written` holds a `\\` only where it escapes: in the `separator` reading\n * each one is already a `/`.\n */\nfunction globstarAdvice(written: string): string {\n let deep = '';\n let flat = '';\n let at = 0;\n // One step past the end reads `''` and appends nothing, so the bound could\n // be one further and give the same advice.\n while (at < written.length) {\n const ch = written.charAt(at);\n let next = at + 1;\n if (ch === '\\\\') {\n next = at + 2;\n } else if (ch === '[') {\n // A class is copied as written. `classEnd` answers an index past the\n // `[`, or -1 for one never closed, so `close >= 0` reads the same; and\n // stopping one short of the `]` copies the class all the same, since\n // its last member and the `]` after it are never a run of stars.\n const close = classEnd(written, at, true);\n if (close > 0) next = close + 1;\n } else if (ch === '*') {\n while (written.charAt(next) === '*') next += 1;\n const before = at > 0 && written.charAt(at - 1) !== '/';\n const after = next < written.length && written.charAt(next) !== '/';\n if (next - at > 2 || (next - at === 2 && (before || after))) {\n deep += `${before ? '*/' : ''}**${after ? '/*' : ''}`;\n flat += '*';\n at = next;\n continue;\n }\n }\n deep += written.slice(at, next);\n flat += written.slice(at, next);\n at = next;\n }\n return `write \"${deep}\" for any depth, or \"${flat}\" for one level`;\n}\n\nfunction tokenize(segment: string, escapes: boolean): Token[] | string {\n const tokens: Token[] = [];\n const chars = Array.from(segment);\n for (let i = 0; i < chars.length; i += 1) {\n const ch = chars[i] as string;\n if (ch === '\\\\' && escapes) {\n const next = chars[i + 1];\n if (next === undefined || /[A-Za-z0-9]/.test(next)) {\n return '\"\\\\\" escapes glob syntax; separate directories with \"/\"';\n }\n tokens.push({ kind: 'literal', point: next.codePointAt(0) as number });\n i += 1;\n } else if (ch === '*') {\n // Two stars inside a name are refused rather than read as one. The\n // tools this replaces read `docs/**.md` three ways - recursive, one\n // level, and as ripgrep does - and reading it as one level silently\n // dropped every nested document from a run that used to include them.\n if (chars[i + 1] === '*') return GLOBSTAR_IN_NAME;\n tokens.push({ kind: 'star' });\n } else if (ch === '?') {\n tokens.push({ kind: 'any' });\n } else if (ch === '[') {\n const parsed = readClass(chars, i, escapes);\n if (typeof parsed === 'string') return parsed;\n tokens.push(parsed.token);\n i = parsed.end;\n } else {\n tokens.push({ kind: 'literal', point: ch.codePointAt(0) as number });\n }\n }\n return tokens;\n}\n\nfunction readClass(chars: readonly string[], open: number, escapes: boolean): { token: Token; end: number } | string {\n let i = open + 1;\n let negated = false;\n if (chars[i] === '!' || chars[i] === '^') {\n negated = true;\n i += 1;\n }\n const ranges: CodeRange[] = [];\n let first = true;\n for (; i < chars.length; i += 1) {\n const ch = chars[i] as string;\n if (ch === ']' && !first) return { token: { kind: 'class', negated, ranges }, end: i };\n first = false;\n let low = ch;\n if (ch === '\\\\' && escapes && chars[i + 1] !== undefined) {\n i += 1;\n low = chars[i] as string;\n }\n let high = low;\n if (chars[i + 1] === '-' && chars[i + 2] !== undefined && chars[i + 2] !== ']') {\n i += 2;\n high = chars[i] as string;\n if (high === '\\\\' && escapes && chars[i + 1] !== undefined) {\n i += 1;\n high = chars[i] as string;\n }\n }\n const from = low.codePointAt(0) as number;\n const to = high.codePointAt(0) as number;\n if (to < from) return `the range \"${low}-${high}\" runs backwards`;\n ranges.push([from, to]);\n }\n return 'a \"[\" is never closed';\n}\n\n/* --------------------------------------------------------------- compiling */\n\nfunction literalText(segments: readonly Segment[]): string | null {\n const names: string[] = [];\n for (const segment of segments) {\n if (segment.kind !== 'name') return null;\n let name = '';\n for (const token of segment.tokens) {\n if (token.kind !== 'literal') return null;\n name += String.fromCodePoint(token.point);\n }\n names.push(name);\n }\n return names.join('/');\n}\n\n/** One segment name: at least one character, none of them `/`. */\nfunction name(b: Builder): Fragment {\n return b.plus(b.char(ANY));\n}\n\n/** Zero or more whole directories: `(name/)*`. */\nfunction anyDirectories(b: Builder): Fragment {\n return b.star(b.sequence([name(b), b.char(SEPARATOR)]));\n}\n\n/** One or more whole segments below a path: `/name(/name)*`. */\nfunction beneath(b: Builder): Fragment {\n return b.sequence([b.char(SEPARATOR), name(b), b.star(b.sequence([b.char(SEPARATOR), name(b)]))]);\n}\n\nfunction tokens(b: Builder, list: readonly Token[]): Fragment {\n return b.sequence(\n list.map((token) => {\n switch (token.kind) {\n case 'literal':\n return b.char(literalSet(token.point));\n case 'any':\n return b.char(ANY);\n case 'star':\n return b.star(b.char(ANY));\n case 'class':\n return b.char(classSet(token.ranges, token.negated));\n }\n }),\n );\n}\n\nfunction segmentsFragment(b: Builder, segments: readonly Segment[]): Fragment {\n const parts: Fragment[] = [];\n segments.forEach((segment, i) => {\n const last = i === segments.length - 1;\n if (segment.kind === 'globstar') {\n // Inside a path a globstar is any number of whole directories, the\n // separator after them included; at its end, at least one segment.\n parts.push(last ? b.sequence([name(b), b.star(b.sequence([b.char(SEPARATOR), name(b)]))]) : anyDirectories(b));\n return;\n }\n parts.push(tokens(b, segment.tokens));\n if (!last) parts.push(b.char(SEPARATOR));\n });\n return b.sequence(parts);\n}\n\nfunction compileAlternative(\n b: Builder,\n alternative: Alternative,\n options: GlobOptions,\n rooted: boolean,\n anchored: boolean,\n): { fragment: Fragment; base: string } {\n const { segments } = alternative;\n const body = segmentsFragment(b, segments);\n const root = rooted ? '/' : '';\n const literal = literalText(segments);\n const leading = leadingLiteral(segments);\n\n if (options.dialect === 'gitignore') {\n const floating = !anchored && !alternative.slashed;\n const parts = [body, b.optional(beneath(b))];\n if (floating) parts.unshift(anyDirectories(b));\n const base = literal !== null ? leading.slice(0, -1) : leading;\n return { fragment: b.sequence(parts), base: floating ? '' : base.join('/') };\n }\n\n if (options.dialect === 'ripgrep' && !rooted && !alternative.slashed) {\n return { fragment: b.sequence([anyDirectories(b), body]), base: '' };\n }\n\n const parts = rooted ? [b.char(SEPARATOR), body] : [body];\n if (options.dialect === 'path' && literal !== null) {\n const reading = typeof options.literal === 'function' ? options.literal(root + literal) : options.literal ?? 'either';\n if (reading === 'directory') {\n parts.push(beneath(b));\n return { fragment: b.sequence(parts), base: root + literal };\n }\n if (reading === 'either') parts.push(b.optional(beneath(b)));\n }\n // A literal path may be a file, whose base is the directory holding it.\n const base = literal !== null ? leading.slice(0, -1) : leading;\n return { fragment: b.sequence(parts), base: root + base.join('/') };\n}\n\nfunction leadingLiteral(segments: readonly Segment[]): string[] {\n const out: string[] = [];\n for (const segment of segments) {\n const text = literalText([segment]);\n if (text === null) break;\n out.push(text);\n }\n return out;\n}\n\n/* ---------------------------------------------------------------- questions */\n\nfunction assertComparable(globs: readonly Glob[]): void {\n for (const glob of globs) {\n if (!glob.caseSensitive) throw new Error(`\"${glob.source}\" ignores case; scopes are compared case-sensitively`);\n }\n}\n\n/**\n * A shortest path every glob in `include` matches and no glob in `exclude`\n * does: the file two scopes would both write, less what either protects.\n * `none` is a proof that there is no such path. Case-sensitive globs only.\n */\nexport function globWitness(\n include: readonly Glob[],\n exclude: readonly Glob[] = [],\n budget: number = WITNESS_BUDGET,\n): Witness {\n assertComparable([...include, ...exclude]);\n return findWitness(\n include.map((glob) => glob.automaton),\n exclude.map((glob) => glob.automaton),\n budget,\n );\n}\n\n/**\n * Whether every path `inner` matches is matched by one of `outer`: `true`,\n * `false`, or `undecided` when the search met its budget.\n */\nexport function globCovers(\n outer: readonly Glob[],\n inner: Glob,\n budget: number = WITNESS_BUDGET,\n): boolean | 'undecided' {\n const witness = globWitness([inner], outer, budget);\n return witness.kind === 'undecided' ? 'undecided' : witness.kind === 'none';\n}\n\n/* -------------------------------------------------------------------- lists */\n\nexport interface GlobList {\n /** Whether a path is in: the last entry that matches it decides, and a `!` entry takes it out. */\n match(path: string): boolean;\n readonly entries: readonly { readonly negated: boolean; readonly glob: Glob }[];\n}\n\nexport type GlobListParse = { readonly ok: true; readonly list: GlobList } | { readonly ok: false; readonly error: string };\n\n/**\n * A list of patterns read the way a `.gitignore` reads: in order, each entry\n * deciding the paths it matches, a leading `!` taking them back out.\n */\nexport function parseGlobList(patterns: readonly string[], options: GlobOptions): GlobListParse {\n const entries: { negated: boolean; glob: Glob }[] = [];\n for (const pattern of patterns) {\n const trimmed = pattern.trim();\n const negated = trimmed.startsWith('!');\n const parsed = parseGlob(negated ? trimmed.slice(1) : trimmed, options);\n if (!parsed.ok) return { ok: false, error: `\"${pattern}\": ${parsed.error}` };\n entries.push({ negated, glob: parsed.glob });\n }\n return {\n ok: true,\n list: {\n entries,\n match(path: string): boolean {\n let included = false;\n for (const entry of entries) if (entry.glob.match(path)) included = !entry.negated;\n return included;\n },\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/pattern/glob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EACL,iBAAiB,EACjB,OAAO,EACP,WAAW,EACX,OAAO,EACP,cAAc,GAIf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAkB,MAAM,cAAc,CAAC;AA4CpF,MAAM,OAAO,SAAU,SAAQ,KAAK;IACzB,MAAM,CAAS;IACxB,YAAY,MAAc,EAAE,MAAc;QACxC,KAAK,CAAC,iBAAiB,MAAM,MAAM,MAAM,EAAE,CAAC,CAAC;QA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ACvD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACxC,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxE,IAAI,CAAC,MAAM,CAAC,EAAE;YAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,OAAO,MAAM,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;QAC7E,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO;QACL,EAAE,EAAE,IAAI;QACR,IAAI,EAAE;YACJ,OAAO;YACP,KAAK,CAAC,IAAY;gBAChB,IAAI,QAAQ,GAAG,KAAK,CAAC;gBACrB,KAAK,MAAM,KAAK,IAAI,OAAO;oBAAE,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;wBAAE,QAAQ,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC;gBACnF,OAAO,QAAQ,CAAC;YAClB,CAAC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Globs, in the three dialects the spec-* tools speak, compiled to one kind of\n * automaton.\n *\n * The syntax is the part people type: `*`, `**`, `?`, `[abc]`, `[!a-z]`,\n * `{a,b}`, and `\\` to escape. What differs between the tools is not the\n * syntax but what a pattern is matched against, and those differences are\n * deliberate, so each has a name (docs/adr/0003-glob-dialects.md):\n *\n * - `path` - the whole repository-relative path, anchored at the root. A\n * pattern with no glob syntax names a file, a directory, or either, as the\n * caller says; `src/auth` may cover `src/auth/login.ts`.\n * - `ripgrep` - as ripgrep's `-g`: a pattern with no `/` is matched against\n * the last segment at any depth, so `*.ts` matches `src/deep/a.ts`; one with\n * a `/` is matched against the whole path.\n * - `gitignore` - as an exclusion list reads: a pattern matches a path or any\n * directory above it, so `tests` excludes everything under any `tests`; one\n * with a `/` other than a trailing one is anchored at the root, and a\n * leading `/` only anchors.\n *\n * Shared by all three:\n *\n * - `**` is a globstar only as a whole segment. `a/**\\/b` matches `a/b` and\n * `a/x/y/b`; a trailing `/**` matches everything inside a directory and not\n * the directory itself. Two stars inside a name, `**.md`, are refused: the\n * tools read it three ways, and the quiet reading narrowed their scope. The\n * refusal writes the two patterns it may have meant from the one written.\n * - `*`, `?` and classes never match `/`, and `*` matches a leading dot.\n * - Braces expand first, and each alternative reads as it would written on\n * its own: `{src/,lib}` is `src/` or `lib`, and a trailing `/` means the\n * directory's contents - in an exclusion, the directory and its contents.\n * One that names no path, `{./,lib}` or `{,lib}`, is refused, as `./` and\n * the empty pattern are.\n * - Case is the caller's decision, stated every time. A result must not\n * depend on the host it ran on.\n * - A malformed pattern is an error, never a literal. An unclosed `[` or `{`,\n * an extended glob, a `..` - each is refused with a reason, because a typo\n * read as a literal is a scope that silently matches nothing. An extended\n * glob is a group holding a `|`, `+(a|b)`: without one, `C++(notes).md` is\n * a name with parentheses in it, as ripgrep and `.gitignore` read it.\n */\n\nimport {\n AutomatonTooLarge,\n Builder,\n findWitness,\n Matcher,\n WITNESS_BUDGET,\n type Automaton,\n type Fragment,\n type Witness,\n} from './automaton.js';\nimport { ANY, classSet, literalSet, SEPARATOR, type CodeRange } from './charset.js';\n\nexport type GlobDialect = 'path' | 'ripgrep' | 'gitignore';\n\n/** How a `path` pattern with no glob syntax is read. */\nexport type LiteralReading = 'file' | 'directory' | 'either';\n\nexport interface GlobOptions {\n readonly dialect: GlobDialect;\n /** Whether `A` and `a` differ. No default: the caller decides, every time. */\n readonly caseSensitive: boolean;\n /**\n * `path` dialect only: how a pattern with no glob syntax is read - as a\n * file, as a directory and everything beneath it, or as either. A function\n * is asked per literal path, for a caller that knows the tree. `either` when\n * unset. A trailing `/`, on the pattern or on one of its brace alternatives,\n * always means a directory's contents, and is never asked about.\n */\n readonly literal?: LiteralReading | ((path: string) => LiteralReading) | undefined;\n /**\n * `escape` (the default): `\\` escapes the next character, and a `\\` before a\n * letter or digit is refused as a Windows separator typed by mistake.\n * `separator`: every `\\` is a `/`, for patterns typed on a Windows shell.\n */\n readonly backslash?: 'escape' | 'separator' | undefined;\n}\n\nexport interface Glob {\n readonly source: string;\n readonly dialect: GlobDialect;\n readonly caseSensitive: boolean;\n /**\n * The directories a walk must enter to find every match: one per\n * alternative, the leading literal segments. `''` for an alternative that\n * can match at any depth.\n */\n readonly bases: readonly string[];\n readonly automaton: Automaton;\n /** Whether a canonical path - POSIX, no `.`, no empty or trailing segment - matches. */\n match(path: string): boolean;\n}\n\nexport type GlobParse = { readonly ok: true; readonly glob: Glob } | { readonly ok: false; readonly error: string };\n\nexport class GlobError extends Error {\n readonly source: string;\n constructor(source: string, reason: string) {\n super(`invalid glob \"${source}\": ${reason}`);\n this.name = 'GlobError';\n this.source = source;\n }\n}\n\n/** More alternatives than this is a pattern nobody meant. */\nexport const MAX_ALTERNATIVES = 256;\n\ntype Token =\n | { readonly kind: 'literal'; readonly point: number }\n | { readonly kind: 'any' }\n | { readonly kind: 'star' }\n | { readonly kind: 'class'; readonly negated: boolean; readonly ranges: readonly CodeRange[] };\n\ntype Segment = { readonly kind: 'globstar' } | { readonly kind: 'name'; readonly tokens: readonly Token[] };\n\ninterface Alternative {\n readonly segments: readonly Segment[];\n /** Written with a `/` somewhere other than at its end. */\n readonly slashed: boolean;\n}\n\n/** Whether a string uses glob syntax at all. */\nexport function isGlobSyntax(source: string): boolean {\n return /[*?[\\]{}]/.test(source);\n}\n\n/**\n * Parses and compiles a glob, or says why it cannot: malformed, or too large\n * to compile, past {@link MAX_ALTERNATIVES} alternatives or `MAX_STATES`\n * states. It throws only what a `literal` function throws.\n */\nexport function parseGlob(source: string, options: GlobOptions): GlobParse {\n const result = build(source, options);\n return typeof result === 'string' ? { ok: false, error: result } : { ok: true, glob: result };\n}\n\n/**\n * Parses and compiles a glob, throwing {@link GlobError} for every reason\n * {@link parseGlob} gives, and what a `literal` function throws.\n */\nexport function compileGlob(source: string, options: GlobOptions): Glob {\n const result = build(source, options);\n if (typeof result === 'string') throw new GlobError(source, result);\n return result;\n}\n\nfunction build(source: string, options: GlobOptions): Glob | string {\n const escapes = options.backslash !== 'separator';\n let pattern = source.trim();\n if (!escapes) pattern = pattern.replace(/\\\\/g, '/');\n const written = pattern;\n if (pattern.length === 0) return 'the pattern is empty';\n if (pattern.startsWith('!')) return 'a negated pattern is a list entry, not a glob; narrow the positive pattern';\n if (/(?:^|[^\\\\])[?*+@!]\\([^)]*\\|/.test(pattern)) return EXTGLOB;\n while (pattern.startsWith('./')) pattern = pattern.slice(2);\n\n // A leading slash roots a pattern at the filesystem's root in the path and\n // ripgrep dialects, and only anchors it at the repository root in gitignore.\n let rooted = false;\n let anchored = false;\n if (pattern.startsWith('/')) {\n if (options.dialect === 'gitignore') anchored = true;\n else rooted = true;\n pattern = pattern.replace(/^\\/+/, '');\n }\n if (pattern.length === 0) return 'the pattern names the root itself, not a path under it';\n\n const expanded = expandBraces(pattern, escapes);\n if (typeof expanded === 'string') return expanded;\n\n const alternatives: Alternative[] = [];\n for (const text of expanded) {\n // Refused before its trailing slash is read, which would make `./` the\n // contents of `.`, every path: `{./,a}` is refused as `./` alone is.\n // Each text the braces give is shorter than the pattern, so only a\n // pattern without braces is its own text.\n if (namesNoPath(text)) return text === pattern ? 'the pattern names no path' : bracesNamingNoPath(text);\n const parsed = parseAlternative(trailingSlash(text, options.dialect), escapes);\n if (parsed === GLOBSTAR_IN_NAME) return `${GLOBSTAR_IN_NAME}: ${globstarAdvice(written)}`;\n if (typeof parsed === 'string') return parsed;\n alternatives.push(parsed);\n }\n\n const builder = new Builder();\n const fragments: Fragment[] = [];\n const bases: string[] = [];\n let automaton: Automaton;\n try {\n for (const alternative of alternatives) {\n const compiled = compileAlternative(builder, alternative, options, rooted, anchored);\n fragments.push(compiled.fragment);\n bases.push(compiled.base);\n }\n automaton = builder.finish(builder.either(fragments), options.caseSensitive);\n } catch (error) {\n // A pattern too large to compile is refused with a reason, as a malformed\n // one is. Anything else - a caller's literal reading that throws - is the\n // caller's failure, not the pattern's, and goes on up.\n if (error instanceof AutomatonTooLarge) return error.message;\n throw error;\n }\n let matcher: Matcher | null = null;\n return {\n source,\n dialect: options.dialect,\n caseSensitive: options.caseSensitive,\n bases: [...new Set(bases)],\n automaton,\n match(path: string): boolean {\n matcher ??= new Matcher(automaton);\n return matcher.test(path);\n },\n };\n}\n\n/* ------------------------------------------------------------------ braces */\n\n/**\n * Expands `{a,b}` groups into the patterns they stand for, or says why the\n * pattern is malformed.\n *\n * Classes and escapes are skipped while looking for braces and commas, so\n * `{[,]x,y}` is two alternatives, `[,]x` and `y`. A lone `}` is a literal: it\n * cannot be read as anything else. An unclosed `{` is an error.\n *\n * Here and in the two functions after it, a loop that reads one step past\n * the end reads `''`, which none of them acts on, and `classEnd` answers -1\n * or an index past the `[`, so `close > 0` and `close >= 0` read the same.\n * `open` is set by the `{` that any `}` read here closes, so its first value\n * is never read.\n */\nfunction expandBraces(pattern: string, escapes: boolean): string[] | string {\n let depth = 0;\n let open = -1;\n for (let i = 0; i < pattern.length; i += 1) {\n const ch = pattern.charAt(i);\n if (ch === '\\\\' && escapes) {\n i += 1;\n continue;\n }\n if (ch === '[') {\n const close = classEnd(pattern, i, escapes);\n if (close > 0) i = close;\n continue;\n }\n if (ch === '{') {\n if (depth === 0) open = i;\n depth += 1;\n continue;\n }\n if (ch !== '}' || depth === 0) continue;\n depth -= 1;\n if (depth > 0) continue;\n const prefix = pattern.slice(0, open);\n const suffix = pattern.slice(i + 1);\n const results: string[] = [];\n for (const option of splitOptions(pattern.slice(open + 1, i), escapes)) {\n const expanded = expandBraces(`${prefix}${option}${suffix}`, escapes);\n if (typeof expanded === 'string') return expanded;\n results.push(...expanded);\n if (results.length > MAX_ALTERNATIVES) return `the braces expand to more than ${MAX_ALTERNATIVES} patterns`;\n }\n return results;\n }\n if (depth > 0) return 'a \"{\" is never closed';\n return [pattern];\n}\n\n/** Splits a brace body on its top-level commas. */\nfunction splitOptions(body: string, escapes: boolean): string[] {\n const parts: string[] = [];\n let depth = 0;\n let start = 0;\n for (let i = 0; i < body.length; i += 1) {\n const ch = body.charAt(i);\n if (ch === '\\\\' && escapes) {\n i += 1;\n } else if (ch === '[') {\n const close = classEnd(body, i, escapes);\n if (close > 0) i = close;\n } else if (ch === '{') {\n depth += 1;\n } else if (ch === '}') {\n depth -= 1;\n } else if (ch === ',' && depth === 0) {\n parts.push(body.slice(start, i));\n start = i + 1;\n }\n }\n parts.push(body.slice(start));\n return parts;\n}\n\n/** The index of the `]` closing a class opened at `open`, or -1 when none does within the segment. */\nfunction classEnd(pattern: string, open: number, escapes: boolean): number {\n let i = open + 1;\n if (pattern.charAt(i) === '!' || pattern.charAt(i) === '^') i += 1;\n // The first member is always a member, even `]`.\n if (pattern.charAt(i) === ']') i += 1;\n for (; i < pattern.length; i += 1) {\n const ch = pattern.charAt(i);\n if (ch === '\\\\' && escapes) {\n i += 1;\n continue;\n }\n if (ch === '/') return -1;\n if (ch === ']') return i;\n }\n return -1;\n}\n\n/* ---------------------------------------------------------------- segments */\n\n/** Whether a pattern's text names no path: nothing in it but `/` and `.` segments. */\nfunction namesNoPath(text: string): boolean {\n return text.split('/').every((part) => part === '' || part === '.');\n}\n\n/**\n * The refusal of an alternative the braces give that names no path, naming\n * it as it was expanded, so that `.{/,a}` is told `./`, the text refused.\n */\nfunction bracesNamingNoPath(text: string): string {\n return text === '' ? 'the braces expand to an empty pattern' : `the braces expand to \"${text}\", which names no path`;\n}\n\n/**\n * What a trailing slash means, read on each alternative the braces give, so\n * that `{src/,lib}` reads `src/` as `src/` alone reads: the directory's\n * contents, `src/**`, and not a literal that may be the directory itself.\n *\n * In an exclusion `build/` excludes what `build` does. Git's rule is that a\n * trailing slash matches only a directory, and a directory is excluded with\n * everything in it; a matcher that sees only a path cannot tell a directory\n * from a file, so the slash is dropped, and it anchors nothing.\n *\n * Only ever given a text that names a path, so a name is left. The whole run\n * of slashes is taken, but one slash would read the same, since\n * `parseAlternative` drops the empty segments the rest leave; and taken\n * lazily it is the whole run all the same, since it ends the text.\n */\nfunction trailingSlash(text: string, dialect: GlobDialect): string {\n const name = text.replace(/\\/+$/, '');\n return name === text || dialect === 'gitignore' ? name : `${name}/**`;\n}\n\n/**\n * The segments of a text that names a path - `build` refuses one that does\n * not - so at least one segment is left.\n */\nfunction parseAlternative(text: string, escapes: boolean): Alternative | string {\n const segments: Segment[] = [];\n const raw = text.split('/');\n for (const part of raw) {\n if (part === '' || part === '.') continue;\n if (part === '..') return 'a pattern cannot climb out of its root with \"..\"';\n if (part === '**') {\n if (segments[segments.length - 1]?.kind !== 'globstar') segments.push({ kind: 'globstar' });\n continue;\n }\n const tokens = tokenize(part, escapes);\n if (typeof tokens === 'string') return tokens;\n segments.push({ kind: 'name', tokens });\n }\n return { segments, slashed: raw.filter((part) => part !== '' && part !== '.').length > 1 };\n}\n\nconst EXTGLOB = 'extended globs such as \"+(a|b)\" are not supported: write alternatives as \"{a,b}\", and a literal parenthesis as \"[(]\"';\nconst GLOBSTAR_IN_NAME = '\"**\" means any number of directories only as a whole segment';\n\n/**\n * The two patterns a writer of `**` inside a name may have meant, built from\n * what they wrote. Each run of stars that is not a whole segment becomes, for\n * any depth, a globstar segment with a star kept on each side where a name\n * went on - `docs/**.md` to `docs/**\\/*.md`, `src/a**` to `src/a*\\/**`,\n * `a**b` to `a*\\/**\\/*b` - and for one level a single star. Everything else\n * stays as written, braces and classes included, and a globstar that was a\n * whole segment stays one.\n *\n * Only `/` is taken for a boundary. A run beside a brace, `{**.md,x}`, is\n * given a star on that side too, which keeps the advice a pattern that\n * compiles whatever the braces expand to.\n *\n * `written` holds a `\\` only where it escapes: in the `separator` reading\n * each one is already a `/`.\n */\nfunction globstarAdvice(written: string): string {\n let deep = '';\n let flat = '';\n let at = 0;\n // One step past the end reads `''` and appends nothing, so the bound could\n // be one further and give the same advice.\n while (at < written.length) {\n const ch = written.charAt(at);\n let next = at + 1;\n if (ch === '\\\\') {\n next = at + 2;\n } else if (ch === '[') {\n // A class is copied as written. `classEnd` answers an index past the\n // `[`, or -1 for one never closed, so `close >= 0` reads the same; and\n // stopping one short of the `]` copies the class all the same, since\n // its last member and the `]` after it are never a run of stars.\n const close = classEnd(written, at, true);\n if (close > 0) next = close + 1;\n } else if (ch === '*') {\n while (written.charAt(next) === '*') next += 1;\n const before = at > 0 && written.charAt(at - 1) !== '/';\n const after = next < written.length && written.charAt(next) !== '/';\n if (next - at > 2 || (next - at === 2 && (before || after))) {\n deep += `${before ? '*/' : ''}**${after ? '/*' : ''}`;\n flat += '*';\n at = next;\n continue;\n }\n }\n deep += written.slice(at, next);\n flat += written.slice(at, next);\n at = next;\n }\n return `write \"${deep}\" for any depth, or \"${flat}\" for one level`;\n}\n\nfunction tokenize(segment: string, escapes: boolean): Token[] | string {\n const tokens: Token[] = [];\n const chars = Array.from(segment);\n for (let i = 0; i < chars.length; i += 1) {\n const ch = chars[i] as string;\n if (ch === '\\\\' && escapes) {\n const next = chars[i + 1];\n if (next === undefined || /[A-Za-z0-9]/.test(next)) {\n return '\"\\\\\" escapes glob syntax; separate directories with \"/\"';\n }\n tokens.push({ kind: 'literal', point: next.codePointAt(0) as number });\n i += 1;\n } else if (ch === '*') {\n // Two stars inside a name are refused rather than read as one. The\n // tools this replaces read `docs/**.md` three ways - recursive, one\n // level, and as ripgrep does - and reading it as one level silently\n // dropped every nested document from a run that used to include them.\n if (chars[i + 1] === '*') return GLOBSTAR_IN_NAME;\n tokens.push({ kind: 'star' });\n } else if (ch === '?') {\n tokens.push({ kind: 'any' });\n } else if (ch === '[') {\n const parsed = readClass(chars, i, escapes);\n if (typeof parsed === 'string') return parsed;\n tokens.push(parsed.token);\n i = parsed.end;\n } else {\n tokens.push({ kind: 'literal', point: ch.codePointAt(0) as number });\n }\n }\n return tokens;\n}\n\nfunction readClass(chars: readonly string[], open: number, escapes: boolean): { token: Token; end: number } | string {\n let i = open + 1;\n let negated = false;\n if (chars[i] === '!' || chars[i] === '^') {\n negated = true;\n i += 1;\n }\n const ranges: CodeRange[] = [];\n let first = true;\n for (; i < chars.length; i += 1) {\n const ch = chars[i] as string;\n if (ch === ']' && !first) return { token: { kind: 'class', negated, ranges }, end: i };\n first = false;\n let low = ch;\n if (ch === '\\\\' && escapes && chars[i + 1] !== undefined) {\n i += 1;\n low = chars[i] as string;\n }\n let high = low;\n if (chars[i + 1] === '-' && chars[i + 2] !== undefined && chars[i + 2] !== ']') {\n i += 2;\n high = chars[i] as string;\n if (high === '\\\\' && escapes && chars[i + 1] !== undefined) {\n i += 1;\n high = chars[i] as string;\n }\n }\n const from = low.codePointAt(0) as number;\n const to = high.codePointAt(0) as number;\n if (to < from) return `the range \"${low}-${high}\" runs backwards`;\n ranges.push([from, to]);\n }\n return 'a \"[\" is never closed';\n}\n\n/* --------------------------------------------------------------- compiling */\n\nfunction literalText(segments: readonly Segment[]): string | null {\n const names: string[] = [];\n for (const segment of segments) {\n if (segment.kind !== 'name') return null;\n let name = '';\n for (const token of segment.tokens) {\n if (token.kind !== 'literal') return null;\n name += String.fromCodePoint(token.point);\n }\n names.push(name);\n }\n return names.join('/');\n}\n\n/** One segment name: at least one character, none of them `/`. */\nfunction name(b: Builder): Fragment {\n return b.plus(b.char(ANY));\n}\n\n/** Zero or more whole directories: `(name/)*`. */\nfunction anyDirectories(b: Builder): Fragment {\n return b.star(b.sequence([name(b), b.char(SEPARATOR)]));\n}\n\n/** One or more whole segments below a path: `/name(/name)*`. */\nfunction beneath(b: Builder): Fragment {\n return b.sequence([b.char(SEPARATOR), name(b), b.star(b.sequence([b.char(SEPARATOR), name(b)]))]);\n}\n\nfunction tokens(b: Builder, list: readonly Token[]): Fragment {\n return b.sequence(\n list.map((token) => {\n switch (token.kind) {\n case 'literal':\n return b.char(literalSet(token.point));\n case 'any':\n return b.char(ANY);\n case 'star':\n return b.star(b.char(ANY));\n case 'class':\n return b.char(classSet(token.ranges, token.negated));\n }\n }),\n );\n}\n\nfunction segmentsFragment(b: Builder, segments: readonly Segment[]): Fragment {\n const parts: Fragment[] = [];\n segments.forEach((segment, i) => {\n const last = i === segments.length - 1;\n if (segment.kind === 'globstar') {\n // Inside a path a globstar is any number of whole directories, the\n // separator after them included; at its end, at least one segment.\n parts.push(last ? b.sequence([name(b), b.star(b.sequence([b.char(SEPARATOR), name(b)]))]) : anyDirectories(b));\n return;\n }\n parts.push(tokens(b, segment.tokens));\n if (!last) parts.push(b.char(SEPARATOR));\n });\n return b.sequence(parts);\n}\n\nfunction compileAlternative(\n b: Builder,\n alternative: Alternative,\n options: GlobOptions,\n rooted: boolean,\n anchored: boolean,\n): { fragment: Fragment; base: string } {\n const { segments } = alternative;\n const body = segmentsFragment(b, segments);\n const root = rooted ? '/' : '';\n const literal = literalText(segments);\n const leading = leadingLiteral(segments);\n\n if (options.dialect === 'gitignore') {\n const floating = !anchored && !alternative.slashed;\n const parts = [body, b.optional(beneath(b))];\n if (floating) parts.unshift(anyDirectories(b));\n const base = literal !== null ? leading.slice(0, -1) : leading;\n return { fragment: b.sequence(parts), base: floating ? '' : base.join('/') };\n }\n\n if (options.dialect === 'ripgrep' && !rooted && !alternative.slashed) {\n return { fragment: b.sequence([anyDirectories(b), body]), base: '' };\n }\n\n const parts = rooted ? [b.char(SEPARATOR), body] : [body];\n if (options.dialect === 'path' && literal !== null) {\n const reading = typeof options.literal === 'function' ? options.literal(root + literal) : options.literal ?? 'either';\n if (reading === 'directory') {\n parts.push(beneath(b));\n return { fragment: b.sequence(parts), base: root + literal };\n }\n if (reading === 'either') parts.push(b.optional(beneath(b)));\n }\n // A literal path may be a file, whose base is the directory holding it.\n const base = literal !== null ? leading.slice(0, -1) : leading;\n return { fragment: b.sequence(parts), base: root + base.join('/') };\n}\n\nfunction leadingLiteral(segments: readonly Segment[]): string[] {\n const out: string[] = [];\n for (const segment of segments) {\n const text = literalText([segment]);\n if (text === null) break;\n out.push(text);\n }\n return out;\n}\n\n/* ---------------------------------------------------------------- questions */\n\nfunction assertComparable(globs: readonly Glob[]): void {\n for (const glob of globs) {\n if (!glob.caseSensitive) throw new Error(`\"${glob.source}\" ignores case; scopes are compared case-sensitively`);\n }\n}\n\n/**\n * A shortest path every glob in `include` matches and no glob in `exclude`\n * does: the file two scopes would both write, less what either protects.\n * `none` is a proof that there is no such path. Case-sensitive globs only.\n */\nexport function globWitness(\n include: readonly Glob[],\n exclude: readonly Glob[] = [],\n budget: number = WITNESS_BUDGET,\n): Witness {\n assertComparable([...include, ...exclude]);\n return findWitness(\n include.map((glob) => glob.automaton),\n exclude.map((glob) => glob.automaton),\n budget,\n );\n}\n\n/**\n * Whether every path `inner` matches is matched by one of `outer`: `true`,\n * `false`, or `undecided` when the search met its budget.\n */\nexport function globCovers(\n outer: readonly Glob[],\n inner: Glob,\n budget: number = WITNESS_BUDGET,\n): boolean | 'undecided' {\n const witness = globWitness([inner], outer, budget);\n return witness.kind === 'undecided' ? 'undecided' : witness.kind === 'none';\n}\n\n/* -------------------------------------------------------------------- lists */\n\nexport interface GlobList {\n /** Whether a path is in: the last entry that matches it decides, and a `!` entry takes it out. */\n match(path: string): boolean;\n readonly entries: readonly { readonly negated: boolean; readonly glob: Glob }[];\n}\n\nexport type GlobListParse = { readonly ok: true; readonly list: GlobList } | { readonly ok: false; readonly error: string };\n\n/**\n * A list of patterns read the way a `.gitignore` reads: in order, each entry\n * deciding the paths it matches, a leading `!` taking them back out.\n */\nexport function parseGlobList(patterns: readonly string[], options: GlobOptions): GlobListParse {\n const entries: { negated: boolean; glob: Glob }[] = [];\n for (const pattern of patterns) {\n const trimmed = pattern.trim();\n const negated = trimmed.startsWith('!');\n const parsed = parseGlob(negated ? trimmed.slice(1) : trimmed, options);\n if (!parsed.ok) return { ok: false, error: `\"${pattern}\": ${parsed.error}` };\n entries.push({ negated, glob: parsed.glob });\n }\n return {\n ok: true,\n list: {\n entries,\n match(path: string): boolean {\n let included = false;\n for (const entry of entries) if (entry.glob.match(path)) included = !entry.negated;\n return included;\n },\n },\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@descent-vtt/spec-harness",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "The agent-facing member of the spec-* tools: context for a round, a guard on every write, an audit when it ends, probes that prove a defect before it is filed, and rulings a person signs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|