@gate-forge/cli 0.8.0 → 0.9.1
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/README.md +85 -1145
- package/dist/adapter-audit.d.ts +54 -0
- package/dist/adapter-audit.d.ts.map +1 -1
- package/dist/adapter-audit.js +48 -0
- package/dist/adapter-audit.js.map +1 -1
- package/dist/adapter-scaffold.d.ts +28 -3
- package/dist/adapter-scaffold.d.ts.map +1 -1
- package/dist/adapter-scaffold.js +145 -24
- package/dist/adapter-scaffold.js.map +1 -1
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +2 -0
- package/dist/args.js.map +1 -1
- package/dist/behavior-setup.d.ts.map +1 -1
- package/dist/behavior-setup.js +18 -5
- package/dist/behavior-setup.js.map +1 -1
- package/dist/commands/adapters.d.ts.map +1 -1
- package/dist/commands/adapters.js +73 -2
- package/dist/commands/adapters.js.map +1 -1
- package/dist/commands/adopt.d.ts +9 -1
- package/dist/commands/adopt.d.ts.map +1 -1
- package/dist/commands/adopt.js +72 -5
- package/dist/commands/adopt.js.map +1 -1
- package/dist/commands/blocking.d.ts +45 -2
- package/dist/commands/blocking.d.ts.map +1 -1
- package/dist/commands/blocking.js +165 -11
- package/dist/commands/blocking.js.map +1 -1
- package/dist/commands/check.d.ts +34 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +152 -8
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/classify.d.ts +1 -1
- package/dist/commands/classify.d.ts.map +1 -1
- package/dist/commands/classify.js +63 -18
- package/dist/commands/classify.js.map +1 -1
- package/dist/commands/enforcement.d.ts.map +1 -1
- package/dist/commands/enforcement.js +263 -9
- package/dist/commands/enforcement.js.map +1 -1
- package/dist/commands/explain.d.ts +1 -1
- package/dist/commands/explain.d.ts.map +1 -1
- package/dist/commands/explain.js +162 -3
- package/dist/commands/explain.js.map +1 -1
- package/dist/commands/init-presets.d.ts +7 -0
- package/dist/commands/init-presets.d.ts.map +1 -1
- package/dist/commands/init-presets.js +10 -1
- package/dist/commands/init-presets.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +579 -61
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/next.d.ts.map +1 -1
- package/dist/commands/next.js +109 -6
- package/dist/commands/next.js.map +1 -1
- package/dist/commands/pre-commit.d.ts.map +1 -1
- package/dist/commands/pre-commit.js +62 -19
- package/dist/commands/pre-commit.js.map +1 -1
- package/dist/commands/test-gates.js +1 -1
- package/dist/commands/tests.d.ts.map +1 -1
- package/dist/commands/tests.js +46 -7
- package/dist/commands/tests.js.map +1 -1
- package/dist/docs-exclusions.d.ts.map +1 -1
- package/dist/docs-exclusions.js +18 -3
- package/dist/docs-exclusions.js.map +1 -1
- package/dist/endpoint-compiler.d.ts.map +1 -1
- package/dist/endpoint-compiler.js +49 -1
- package/dist/endpoint-compiler.js.map +1 -1
- package/dist/evaluate.d.ts +16 -1
- package/dist/evaluate.d.ts.map +1 -1
- package/dist/evaluate.js +12 -2
- package/dist/evaluate.js.map +1 -1
- package/dist/gateforge-owned.d.ts +103 -0
- package/dist/gateforge-owned.d.ts.map +1 -0
- package/dist/gateforge-owned.js +375 -0
- package/dist/gateforge-owned.js.map +1 -0
- package/dist/git-hooks.d.ts +18 -0
- package/dist/git-hooks.d.ts.map +1 -1
- package/dist/git-hooks.js +36 -1
- package/dist/git-hooks.js.map +1 -1
- package/dist/git-ignored.d.ts +27 -0
- package/dist/git-ignored.d.ts.map +1 -0
- package/dist/git-ignored.js +102 -0
- package/dist/git-ignored.js.map +1 -0
- package/dist/glob.d.ts +33 -14
- package/dist/glob.d.ts.map +1 -1
- package/dist/glob.js +96 -5
- package/dist/glob.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/io.d.ts +18 -5
- package/dist/io.d.ts.map +1 -1
- package/dist/io.js +5 -4
- package/dist/io.js.map +1 -1
- package/dist/pipeline.d.ts +16 -1
- package/dist/pipeline.d.ts.map +1 -1
- package/dist/pipeline.js +23 -3
- package/dist/pipeline.js.map +1 -1
- package/dist/planes-inference.d.ts +12 -5
- package/dist/planes-inference.d.ts.map +1 -1
- package/dist/planes-inference.js +13 -15
- package/dist/planes-inference.js.map +1 -1
- package/dist/providers.d.ts +54 -0
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +101 -0
- package/dist/providers.js.map +1 -1
- package/dist/repo-scan.d.ts +7 -0
- package/dist/repo-scan.d.ts.map +1 -1
- package/dist/repo-scan.js +109 -8
- package/dist/repo-scan.js.map +1 -1
- package/dist/route-plane-proposals.d.ts +100 -0
- package/dist/route-plane-proposals.d.ts.map +1 -0
- package/dist/route-plane-proposals.js +213 -0
- package/dist/route-plane-proposals.js.map +1 -0
- package/dist/scope.d.ts +20 -0
- package/dist/scope.d.ts.map +1 -1
- package/dist/scope.js +26 -5
- package/dist/scope.js.map +1 -1
- package/dist/singleton-guidance.d.ts +15 -6
- package/dist/singleton-guidance.d.ts.map +1 -1
- package/dist/singleton-guidance.js +30 -10
- package/dist/singleton-guidance.js.map +1 -1
- package/dist/staged-candidate.d.ts.map +1 -1
- package/dist/staged-candidate.js +2 -1
- package/dist/staged-candidate.js.map +1 -1
- package/dist/trusted-policy.d.ts.map +1 -1
- package/dist/trusted-policy.js +3 -2
- package/dist/trusted-policy.js.map +1 -1
- package/dist/unmatched-routes.d.ts +60 -0
- package/dist/unmatched-routes.d.ts.map +1 -0
- package/dist/unmatched-routes.js +131 -0
- package/dist/unmatched-routes.js.map +1 -0
- package/guides/CONNECT-YOUR-PROJECT.md +93 -20
- package/guides/QUICKSTART.md +81 -16
- package/guides/REFERENCE.md +1756 -0
- package/guides/TEST-ENVIRONMENT.md +8 -5
- package/guides/UPGRADE-0.8-to-0.9.md +112 -0
- package/package.json +10 -10
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gateforge-owned policy inputs (0.9.0 D2).
|
|
3
|
+
*
|
|
4
|
+
* These are the files Gateforge itself writes and reads when it configures
|
|
5
|
+
* and wires itself: the config document, the policy / classification /
|
|
6
|
+
* behavior / runtime documents, the pack configs, the adapter, waiver,
|
|
7
|
+
* baseline and quarantine records, the generated gate wiring (hook script,
|
|
8
|
+
* CI job templates, agent skill file, engine reference) and the owner's own
|
|
9
|
+
* CI / pre-commit files while they still carry Gateforge's managed block.
|
|
10
|
+
*
|
|
11
|
+
* A change to one of them is a POLICY INPUT, never a product change:
|
|
12
|
+
*
|
|
13
|
+
* - it is never reported as an unmapped (`CHANGE_UNMAPPED`) product change,
|
|
14
|
+
* because nothing about product behavior is unaccounted for;
|
|
15
|
+
* - its integrity stays governed by the owner-approved policy digest exactly
|
|
16
|
+
* as it is today — `computeTrustedPolicyDigest` hashes the config, policy,
|
|
17
|
+
* classification, behavior, runtime, exclusion-declaration, mapping-sidecar,
|
|
18
|
+
* adapter, waiver, quarantine and repo-local plugin bytes, so a candidate
|
|
19
|
+
* that changes any of them changes the approved revision and a pin mismatch
|
|
20
|
+
* still blocks;
|
|
21
|
+
* - a change set whose ENTIRE content is these paths cannot change product
|
|
22
|
+
* behavior, so it does not drag the adopted E2E obligations into a strict
|
|
23
|
+
* re-grade (the adoption forgiveness survives; an owner waiver does not).
|
|
24
|
+
*
|
|
25
|
+
* Security boundary — the set is EXACT, never a directory wildcard:
|
|
26
|
+
*
|
|
27
|
+
* - `.gateforge/` is NOT exempt as a tree. Only the engine documents at its
|
|
28
|
+
* top level and the engine-owned subdirectories are, so an agent cannot
|
|
29
|
+
* park a product change somewhere under `.gateforge/` and have it excused.
|
|
30
|
+
* Engine run state (`.gateforge/test-gates/`, `.gateforge/ci-witnessed/`)
|
|
31
|
+
* stays outside the set on purpose: staged engine state is not a policy
|
|
32
|
+
* input and stays visible.
|
|
33
|
+
* - The owner's CI config and pre-commit config count ONLY while Gateforge's
|
|
34
|
+
* managed block is still in them. Deleting the gate job from
|
|
35
|
+
* `.gitlab-ci.yml` therefore keeps its historical, blocking
|
|
36
|
+
* `CHANGE_UNMAPPED` treatment.
|
|
37
|
+
*/
|
|
38
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
39
|
+
import { join } from 'node:path';
|
|
40
|
+
import { CACHE_EXCLUSIONS_PATH } from './cache-exclusions.js';
|
|
41
|
+
import { DOCS_EXCLUSIONS_PATH } from './docs-exclusions.js';
|
|
42
|
+
import { PACK_CONFIGS, normalizeRepoModule } from './input-snapshot.js';
|
|
43
|
+
import { DEFAULT_STATE_DIR } from './state.js';
|
|
44
|
+
/** Repo-relative path of the tracked mapping sidecar. */
|
|
45
|
+
export const GATEFORGE_TEST_MAP_PATH = '.gateforge/test-map.yml';
|
|
46
|
+
/** Repo-relative path of the machine-specific engine checkout reference. */
|
|
47
|
+
export const GATEFORGE_ENGINE_REFERENCE_PATH = '.gateforge/engine';
|
|
48
|
+
/** Repo-relative path of the agent skill file `init` writes. */
|
|
49
|
+
export const GATEFORGE_SKILL_FILE = 'GATEFORGE.md';
|
|
50
|
+
/**
|
|
51
|
+
* Repo-relative path of the overlay-proof directory README `init` writes.
|
|
52
|
+
* EXACT path on purpose: the overlay TESTS an owner or agent writes beside
|
|
53
|
+
* it in `tests/e2e/gateforge/` are product work and stay mappable and
|
|
54
|
+
* gradeable.
|
|
55
|
+
*/
|
|
56
|
+
export const GATEFORGE_OVERLAY_README_PATH = 'tests/e2e/gateforge/README.md';
|
|
57
|
+
/**
|
|
58
|
+
* The comment line that introduces Gateforge's managed
|
|
59
|
+
* `.gitignore` block. ONE definition shared by the writer
|
|
60
|
+
* (`init`) and the classifier (this module), so the block
|
|
61
|
+
* `init` appends is exactly the block the classifier
|
|
62
|
+
* recognizes.
|
|
63
|
+
*/
|
|
64
|
+
export const ENGINE_STATE_IGNORE_COMMENT = '# Gateforge engine state — never committed (regenerated by every run).';
|
|
65
|
+
/**
|
|
66
|
+
* The engine-owned state directories that must never be
|
|
67
|
+
* committed (`.gateforge/test-gates/` — the run catalog,
|
|
68
|
+
* plugin caches, receipts and history the engine regenerates
|
|
69
|
+
* on every run). ONE definition shared by the writer (`init`)
|
|
70
|
+
* and the classifier (this module).
|
|
71
|
+
*/
|
|
72
|
+
export const ENGINE_STATE_IGNORE_ENTRIES = [
|
|
73
|
+
`${DEFAULT_STATE_DIR}/`,
|
|
74
|
+
];
|
|
75
|
+
/**
|
|
76
|
+
* Engine-owned subdirectories of `.gateforge/`: the generated gate wiring and
|
|
77
|
+
* the record directories every gate decision reads. Segment-aware matching
|
|
78
|
+
* only — `.gateforge/hooksy/x` is not inside `.gateforge/hooks`.
|
|
79
|
+
*/
|
|
80
|
+
export const GATEFORGE_OWNED_DIRS = [
|
|
81
|
+
'.gateforge/adapters',
|
|
82
|
+
'.gateforge/baselines',
|
|
83
|
+
'.gateforge/ci',
|
|
84
|
+
'.gateforge/hooks',
|
|
85
|
+
'.gateforge/quarantine',
|
|
86
|
+
'.gateforge/waivers',
|
|
87
|
+
];
|
|
88
|
+
/**
|
|
89
|
+
* Extensions accepted for an engine document directly under `.gateforge/`
|
|
90
|
+
* (`.gateforge/policies.yml`, `.gateforge/planes.json`, …). Source and
|
|
91
|
+
* executable code never qualifies: only documents the engine itself reads.
|
|
92
|
+
*/
|
|
93
|
+
const ENGINE_DOCUMENT_EXTENSIONS = new Set([
|
|
94
|
+
'.yml',
|
|
95
|
+
'.yaml',
|
|
96
|
+
'.json',
|
|
97
|
+
'.md',
|
|
98
|
+
'.txt',
|
|
99
|
+
]);
|
|
100
|
+
/**
|
|
101
|
+
* Owner-owned files that carry a Gateforge-managed block, with the markers
|
|
102
|
+
* that prove the block is still wired. A file whose marker is gone is not a
|
|
103
|
+
* policy input anymore — that is exactly the E17 self-authorization case.
|
|
104
|
+
*/
|
|
105
|
+
const MANAGED_OWNER_FILES = {
|
|
106
|
+
'.gitlab-ci.yml': { kind: 'ci-wiring', markers: ['.gateforge/ci/'] },
|
|
107
|
+
'.pre-commit-config.yaml': { kind: 'pre-commit-wiring', markers: ['gateforge-check'] },
|
|
108
|
+
'.github/workflows/gateforge.yml': { kind: 'ci-wiring', markers: ['# Generated by Gateforge'] },
|
|
109
|
+
'.github/workflows/gateforge-witnessed.yml': { kind: 'ci-wiring', markers: ['# Generated by Gateforge'] },
|
|
110
|
+
};
|
|
111
|
+
/** Normalizes a configured repo path to the posix form used for comparison. */
|
|
112
|
+
function normalizeRepoPath(path) {
|
|
113
|
+
const posix = path.split('\\').join('/');
|
|
114
|
+
return posix.startsWith('./') ? posix.slice(2) : posix;
|
|
115
|
+
}
|
|
116
|
+
/** Segment-aware directory membership (`a/b` is inside `a`, `a2` is not). */
|
|
117
|
+
function underDir(file, dir) {
|
|
118
|
+
return file === dir || file.startsWith(`${dir}/`);
|
|
119
|
+
}
|
|
120
|
+
/** The lowercase extension of a basename, or `''` when it has none. */
|
|
121
|
+
function extensionOf(basename) {
|
|
122
|
+
const lower = basename.toLowerCase();
|
|
123
|
+
return lower.includes('.') ? lower.slice(lower.lastIndexOf('.')) : '';
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Classifies a repo-relative path as a Gateforge-owned policy input.
|
|
127
|
+
*
|
|
128
|
+
* Args:
|
|
129
|
+
* file: normalized repo-relative changed path.
|
|
130
|
+
* config: the loaded gateforge config (its document paths are honored).
|
|
131
|
+
*
|
|
132
|
+
* Returns:
|
|
133
|
+
* GateforgeOwnedInput | null: the matched input, or null when the path is
|
|
134
|
+
* not a Gateforge-owned policy input (a product file, or engine run state).
|
|
135
|
+
*/
|
|
136
|
+
export function gateforgeOwnedInput(file, config) {
|
|
137
|
+
const posix = normalizeRepoPath(file);
|
|
138
|
+
if (posix === '.gateforge.yml')
|
|
139
|
+
return { path: '.gateforge.yml', kind: 'config' };
|
|
140
|
+
if (posix === GATEFORGE_SKILL_FILE)
|
|
141
|
+
return { path: GATEFORGE_SKILL_FILE, kind: 'agent-skill' };
|
|
142
|
+
if (posix === GATEFORGE_OVERLAY_README_PATH) {
|
|
143
|
+
return { path: GATEFORGE_OVERLAY_README_PATH, kind: 'agent-skill' };
|
|
144
|
+
}
|
|
145
|
+
if (posix === GATEFORGE_ENGINE_REFERENCE_PATH) {
|
|
146
|
+
return { path: GATEFORGE_ENGINE_REFERENCE_PATH, kind: 'engine-reference' };
|
|
147
|
+
}
|
|
148
|
+
if (posix === GATEFORGE_TEST_MAP_PATH)
|
|
149
|
+
return { path: GATEFORGE_TEST_MAP_PATH, kind: 'mapping-sidecar' };
|
|
150
|
+
if (posix === DOCS_EXCLUSIONS_PATH || posix === CACHE_EXCLUSIONS_PATH) {
|
|
151
|
+
return { path: posix, kind: 'exclusion-declaration' };
|
|
152
|
+
}
|
|
153
|
+
for (const packConfig of PACK_CONFIGS) {
|
|
154
|
+
if (posix === packConfig)
|
|
155
|
+
return { path: packConfig, kind: 'pack-config' };
|
|
156
|
+
}
|
|
157
|
+
// Configured documents: the config may point anywhere in the repository.
|
|
158
|
+
if (posix === normalizeRepoPath(config.policies))
|
|
159
|
+
return { path: posix, kind: 'policy' };
|
|
160
|
+
if (posix === normalizeRepoPath(config.classificationPolicy)) {
|
|
161
|
+
return { path: posix, kind: 'classification-policy' };
|
|
162
|
+
}
|
|
163
|
+
if (config.behaviorPolicy !== undefined && posix === normalizeRepoPath(config.behaviorPolicy)) {
|
|
164
|
+
return { path: posix, kind: 'behavior-policy' };
|
|
165
|
+
}
|
|
166
|
+
if (config.runtime !== undefined && posix === normalizeRepoPath(config.runtime)) {
|
|
167
|
+
return { path: posix, kind: 'runtime-policy' };
|
|
168
|
+
}
|
|
169
|
+
const baselines = normalizeRepoPath(config.baselines);
|
|
170
|
+
if (posix === baselines)
|
|
171
|
+
return { path: posix, kind: 'baseline' };
|
|
172
|
+
const adapters = normalizeRepoPath(config.adapters);
|
|
173
|
+
if (underDir(posix, adapters))
|
|
174
|
+
return { path: adapters, kind: 'adapter' };
|
|
175
|
+
const waivers = normalizeRepoPath(config.waivers);
|
|
176
|
+
if (underDir(posix, waivers))
|
|
177
|
+
return { path: waivers, kind: 'waiver' };
|
|
178
|
+
for (const plugin of config.plugins) {
|
|
179
|
+
const module = plugin.module;
|
|
180
|
+
if (typeof module !== 'string')
|
|
181
|
+
continue;
|
|
182
|
+
const normalized = normalizeRepoModule(module);
|
|
183
|
+
if (normalized !== null && (posix === normalized || underDir(posix, normalized))) {
|
|
184
|
+
return { path: normalized, kind: 'plugin-module' };
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// The baseline record directory: the adoption receipt is the sibling of the
|
|
188
|
+
// configured baseline document and Gateforge writes both.
|
|
189
|
+
const baselineDir = baselines.slice(0, baselines.lastIndexOf('/'));
|
|
190
|
+
if (baselineDir.includes('/') && underDir(posix, baselineDir))
|
|
191
|
+
return { path: baselineDir, kind: 'baseline' };
|
|
192
|
+
for (const dir of GATEFORGE_OWNED_DIRS) {
|
|
193
|
+
if (underDir(posix, dir))
|
|
194
|
+
return { path: dir, kind: dir === '.gateforge/quarantine' ? 'quarantine' : 'wiring' };
|
|
195
|
+
}
|
|
196
|
+
// Engine documents directly under `.gateforge/` (`docs-exclusions.yml`,
|
|
197
|
+
// `runtime.yml`, a custom policies document, …). Depth one only, and only
|
|
198
|
+
// document types — `.gateforge/<anything>.py` is not a policy input.
|
|
199
|
+
const segments = posix.split('/');
|
|
200
|
+
if (segments.length === 2 &&
|
|
201
|
+
segments[0] === '.gateforge' &&
|
|
202
|
+
ENGINE_DOCUMENT_EXTENSIONS.has(extensionOf(segments[1] ?? ''))) {
|
|
203
|
+
return { path: posix, kind: 'policy' };
|
|
204
|
+
}
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Whether an owner-owned file still carries Gateforge's managed block.
|
|
209
|
+
*
|
|
210
|
+
* Args:
|
|
211
|
+
* cwd: absolute repo root (the candidate's own checkout).
|
|
212
|
+
* file: repo-relative path.
|
|
213
|
+
*
|
|
214
|
+
* Returns:
|
|
215
|
+
* boolean: true for a managed owner file whose marker is still present.
|
|
216
|
+
*/
|
|
217
|
+
export function managedOwnerBlockPresent(cwd, file) {
|
|
218
|
+
const entry = MANAGED_OWNER_FILES[file];
|
|
219
|
+
if (entry === undefined)
|
|
220
|
+
return false;
|
|
221
|
+
const absolute = join(cwd, ...file.split('/'));
|
|
222
|
+
if (!existsSync(absolute))
|
|
223
|
+
return false;
|
|
224
|
+
try {
|
|
225
|
+
const body = readFileSync(absolute, 'utf8');
|
|
226
|
+
return entry.markers.some((marker) => body.includes(marker));
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/** Repo-relative path of the ignore file `init` wires its managed block into. */
|
|
233
|
+
const GITIGNORE_PATH = '.gitignore';
|
|
234
|
+
/**
|
|
235
|
+
* Whether one `.gitignore` line belongs to Gateforge's
|
|
236
|
+
* managed engine-state block: the comment line that
|
|
237
|
+
* introduces it, or one of the ignored engine-state
|
|
238
|
+
* entries.
|
|
239
|
+
*
|
|
240
|
+
* Args:
|
|
241
|
+
* line: one `.gitignore` line.
|
|
242
|
+
*
|
|
243
|
+
* Returns:
|
|
244
|
+
* boolean: true for a managed-block line.
|
|
245
|
+
*/
|
|
246
|
+
function isEngineStateIgnoreLine(line) {
|
|
247
|
+
return (line === ENGINE_STATE_IGNORE_COMMENT ||
|
|
248
|
+
ENGINE_STATE_IGNORE_ENTRIES.includes(line));
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* The lines of a `.gitignore`, normalized for the
|
|
252
|
+
* managed-block comparison: split on `\n`, dropping a
|
|
253
|
+
* trailing empty line.
|
|
254
|
+
*
|
|
255
|
+
* Args:
|
|
256
|
+
* text: the full `.gitignore` contents.
|
|
257
|
+
*
|
|
258
|
+
* Returns:
|
|
259
|
+
* string[]: the normalized lines.
|
|
260
|
+
*/
|
|
261
|
+
function ignoreLines(text) {
|
|
262
|
+
const lines = text.split('\n');
|
|
263
|
+
if (lines.length > 0 && lines[lines.length - 1] === '') {
|
|
264
|
+
lines.pop();
|
|
265
|
+
}
|
|
266
|
+
return lines;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Classifies `.gitignore` as a Gateforge-owned input (kind
|
|
270
|
+
* `ignore-wiring`) when the managed engine-state block is
|
|
271
|
+
* the ONLY difference from the base revision of the change
|
|
272
|
+
* set: `init` appends exactly that block while writing the
|
|
273
|
+
* skeleton, so a setup commit that stages it is
|
|
274
|
+
* product-behavior-neutral and keeps the adopted E2E debt
|
|
275
|
+
* forgiven under strictE2E.
|
|
276
|
+
*
|
|
277
|
+
* Security boundary — exact line equality only. The
|
|
278
|
+
* candidate must actually carry the managed block, the
|
|
279
|
+
* base text must exist, and every other line must be
|
|
280
|
+
* unchanged: a `.gitignore` that is absent at the base
|
|
281
|
+
* revision, or that adds, removes or changes any other
|
|
282
|
+
* line, is NOT owned, because ignore wiring can hide
|
|
283
|
+
* product changes from the scan.
|
|
284
|
+
*
|
|
285
|
+
* Args:
|
|
286
|
+
* cwd: absolute repo root (the candidate's own checkout).
|
|
287
|
+
* baseText: reads a repo path at the base revision of
|
|
288
|
+
* the change set (null when absent there).
|
|
289
|
+
*
|
|
290
|
+
* Returns:
|
|
291
|
+
* GateforgeOwnedInput | null: the owned input, or null.
|
|
292
|
+
*/
|
|
293
|
+
function ignoreWiringInput(cwd, baseText) {
|
|
294
|
+
const base = baseText(GITIGNORE_PATH);
|
|
295
|
+
if (base === null)
|
|
296
|
+
return null;
|
|
297
|
+
let candidate;
|
|
298
|
+
try {
|
|
299
|
+
candidate = readFileSync(join(cwd, ...GITIGNORE_PATH.split('/')), 'utf8');
|
|
300
|
+
}
|
|
301
|
+
catch {
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
const candidateLines = ignoreLines(candidate);
|
|
305
|
+
if (!candidateLines.some((line) => isEngineStateIgnoreLine(line))) {
|
|
306
|
+
return null;
|
|
307
|
+
}
|
|
308
|
+
const strippedCandidate = candidateLines.filter((line) => !isEngineStateIgnoreLine(line));
|
|
309
|
+
const strippedBase = ignoreLines(base).filter((line) => !isEngineStateIgnoreLine(line));
|
|
310
|
+
if (strippedCandidate.length !== strippedBase.length)
|
|
311
|
+
return null;
|
|
312
|
+
for (const [index, line] of strippedCandidate.entries()) {
|
|
313
|
+
if (line !== strippedBase[index])
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
return { path: GITIGNORE_PATH, kind: 'ignore-wiring' };
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Classifies a path including the owner files that carry a
|
|
320
|
+
* managed block, and `.gitignore` while the managed
|
|
321
|
+
* engine-state block is the sole difference from the base
|
|
322
|
+
* revision.
|
|
323
|
+
*
|
|
324
|
+
* Args:
|
|
325
|
+
* cwd: absolute repo root (the candidate's own checkout).
|
|
326
|
+
* file: repo-relative path.
|
|
327
|
+
* config: the loaded gateforge config.
|
|
328
|
+
* baseText: reads a repo path at the base revision of the
|
|
329
|
+
* change set (null when absent there); without it no
|
|
330
|
+
* `.gitignore` is ever owned.
|
|
331
|
+
*
|
|
332
|
+
* Returns:
|
|
333
|
+
* GateforgeOwnedInput | null: the matched input, or null.
|
|
334
|
+
*/
|
|
335
|
+
export function classifyGateforgeOwnedInput(cwd, file, config, baseText) {
|
|
336
|
+
const direct = gateforgeOwnedInput(file, config);
|
|
337
|
+
if (direct !== null)
|
|
338
|
+
return direct;
|
|
339
|
+
const posix = normalizeRepoPath(file);
|
|
340
|
+
const managed = MANAGED_OWNER_FILES[posix];
|
|
341
|
+
if (managed !== undefined) {
|
|
342
|
+
return managedOwnerBlockPresent(cwd, posix)
|
|
343
|
+
? { path: posix, kind: managed.kind }
|
|
344
|
+
: null;
|
|
345
|
+
}
|
|
346
|
+
if (posix === GITIGNORE_PATH && baseText !== undefined) {
|
|
347
|
+
return ignoreWiringInput(cwd, baseText);
|
|
348
|
+
}
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Classifies a whole changed set in one pass (one config walk, no re-reads
|
|
353
|
+
* per file beyond the managed-block and `.gitignore` checks).
|
|
354
|
+
*
|
|
355
|
+
* Args:
|
|
356
|
+
* cwd: absolute repo root.
|
|
357
|
+
* files: repo-relative changed paths.
|
|
358
|
+
* config: the loaded gateforge config.
|
|
359
|
+
* baseText: reads a repo path at the base revision of the
|
|
360
|
+
* change set (null when absent there); without it no
|
|
361
|
+
* `.gitignore` is ever owned.
|
|
362
|
+
*
|
|
363
|
+
* Returns:
|
|
364
|
+
* Map<string, GateforgeOwnedInput>: the subset that is Gateforge-owned.
|
|
365
|
+
*/
|
|
366
|
+
export function gateforgeOwnedInputs(cwd, files, config, baseText) {
|
|
367
|
+
const owned = new Map();
|
|
368
|
+
for (const file of files) {
|
|
369
|
+
const match = classifyGateforgeOwnedInput(cwd, file, config, baseText);
|
|
370
|
+
if (match !== null)
|
|
371
|
+
owned.set(file, match);
|
|
372
|
+
}
|
|
373
|
+
return owned;
|
|
374
|
+
}
|
|
375
|
+
//# sourceMappingURL=gateforge-owned.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateforge-owned.js","sourceRoot":"","sources":["../src/gateforge-owned.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,yDAAyD;AACzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAEjE,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AAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,oBAAoB,CAClC,GAAW,EACX,KAAwB,EACxB,MAAuB,EACvB,QAA0C;IAE1C,MAAM,KAAK,GAAG,IAAI,GAAG,EAA+B,CAAC;IACrD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,2BAA2B,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QACvE,IAAI,KAAK,KAAK,IAAI;YAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/git-hooks.d.ts
CHANGED
|
@@ -50,6 +50,24 @@ export type HookInstallOutcome = {
|
|
|
50
50
|
detail: string;
|
|
51
51
|
action: string;
|
|
52
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* Whether a `.git/hooks/pre-commit` body was generated by a pre-commit
|
|
55
|
+
* FRAMEWORK rather than hand-written. Such a file carries no Gateforge
|
|
56
|
+
* marker by construction — the framework rewrites it from
|
|
57
|
+
* `.pre-commit-config.yaml` on every install — so every surface that
|
|
58
|
+
* asks "is the gate wired here?" has to ask this question instead of
|
|
59
|
+
* reading for our marker, or it reports a working setup as untouched.
|
|
60
|
+
*
|
|
61
|
+
* Exported so `enforcement doctor` and the installer answer with the
|
|
62
|
+
* same rule instead of two drifting marker lists.
|
|
63
|
+
*
|
|
64
|
+
* Args:
|
|
65
|
+
* body: the hook file's contents.
|
|
66
|
+
*
|
|
67
|
+
* Returns:
|
|
68
|
+
* boolean: true when the file is framework-managed.
|
|
69
|
+
*/
|
|
70
|
+
export declare function isFrameworkManagedHookBody(body: string): boolean;
|
|
53
71
|
/**
|
|
54
72
|
* Installs (or verifies) the active pre-commit hook (plan Phase 5 item
|
|
55
73
|
* 1). Writing the hook is not enough: after writing or finding a
|
package/dist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AAU,GAAG,kBAAkB,CA4D1F;AA4CD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,MAAM,EACX,QAAQ,GAAE,SAAS,MAAM,EAA2C,GACnE,MAAM,CAuBR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,CAAC,UAAU,GACrB;IACD,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAqCA;AAYD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAMpF"}
|
package/dist/git-hooks.js
CHANGED
|
@@ -43,6 +43,26 @@ export const STAGED_GATE_SCRIPT_BASENAME = 'gateforge-staged.sh';
|
|
|
43
43
|
* regenerates this file from .pre-commit-config.yaml on every run, so any
|
|
44
44
|
* direct edit to it — including gateforge's — would be silently wiped). */
|
|
45
45
|
const FRAMEWORK_HOOK_MARKERS = ['File generated by pre-commit', '-mpre_commit'];
|
|
46
|
+
/**
|
|
47
|
+
* Whether a `.git/hooks/pre-commit` body was generated by a pre-commit
|
|
48
|
+
* FRAMEWORK rather than hand-written. Such a file carries no Gateforge
|
|
49
|
+
* marker by construction — the framework rewrites it from
|
|
50
|
+
* `.pre-commit-config.yaml` on every install — so every surface that
|
|
51
|
+
* asks "is the gate wired here?" has to ask this question instead of
|
|
52
|
+
* reading for our marker, or it reports a working setup as untouched.
|
|
53
|
+
*
|
|
54
|
+
* Exported so `enforcement doctor` and the installer answer with the
|
|
55
|
+
* same rule instead of two drifting marker lists.
|
|
56
|
+
*
|
|
57
|
+
* Args:
|
|
58
|
+
* body: the hook file's contents.
|
|
59
|
+
*
|
|
60
|
+
* Returns:
|
|
61
|
+
* boolean: true when the file is framework-managed.
|
|
62
|
+
*/
|
|
63
|
+
export function isFrameworkManagedHookBody(body) {
|
|
64
|
+
return FRAMEWORK_HOOK_MARKERS.some((marker) => body.includes(marker));
|
|
65
|
+
}
|
|
46
66
|
/**
|
|
47
67
|
* Installs (or verifies) the active pre-commit hook (plan Phase 5 item
|
|
48
68
|
* 1). Writing the hook is not enough: after writing or finding a
|
|
@@ -118,7 +138,7 @@ export function installCommitHook(cwd, env, gateArgs = ['check', '--staged', '--
|
|
|
118
138
|
// wiped on the next `pre-commit install`. Gateforge integrates through
|
|
119
139
|
// the framework config instead (the caller appends the gateforge hook
|
|
120
140
|
// block there); activation = the framework config carries the hook.
|
|
121
|
-
if (
|
|
141
|
+
if (isFrameworkManagedHookBody(body)) {
|
|
122
142
|
return {
|
|
123
143
|
status: 'framework',
|
|
124
144
|
hookPath,
|
|
@@ -139,6 +159,21 @@ export function installCommitHook(cwd, env, gateArgs = ['check', '--staged', '--
|
|
|
139
159
|
`then re-run \`gateforge init --blocking\` to verify activation.`,
|
|
140
160
|
};
|
|
141
161
|
}
|
|
162
|
+
// Pre-commit FRAMEWORK without an installed hook: the framework
|
|
163
|
+
// owns .git/hooks/pre-commit (it regenerates that file from
|
|
164
|
+
// .pre-commit-config.yaml on every `pre-commit install`), so
|
|
165
|
+
// gateforge must NEVER write a raw hook file here — it wires
|
|
166
|
+
// itself through the framework config instead.
|
|
167
|
+
const frameworkConfig = join(cwd, '.pre-commit-config.yaml');
|
|
168
|
+
if (existsSync(frameworkConfig)) {
|
|
169
|
+
return {
|
|
170
|
+
status: 'framework',
|
|
171
|
+
hookPath,
|
|
172
|
+
hooksDir,
|
|
173
|
+
detail: 'pre-commit framework config found — gateforge wires itself through .pre-commit-config.yaml; ' +
|
|
174
|
+
'run `pre-commit install` to activate the gate',
|
|
175
|
+
};
|
|
176
|
+
}
|
|
142
177
|
const script = gateforgeHookScript(gateArgs);
|
|
143
178
|
try {
|
|
144
179
|
mkdirSync(hooksDir, { recursive: true });
|
package/dist/git-hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-hooks.js","sourceRoot":"","sources":["../src/git-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClG,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE5K,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,eAAe,EAAE,oBAAoB,EAAE,CAAC;AAE/I,4DAA4D;AAC5D,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY,CAAC;AACjD,+DAA+D;AAC/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,yDAAyD;AACzD,MAAM,CAAC,MAAM,qBAAqB,GAAG,iCAAiC,CAAC;AACvE,kDAAkD;AAClD,MAAM,CAAC,MAAM,mBAAmB,GAAG,iCAAiC,CAAC;AAErE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,qBAAqB,CAAC;AAWjE;;2EAE2E;AAC3E,MAAM,sBAAsB,GAAG,CAAC,8BAA8B,EAAE,cAAc,CAAC,CAAC;AAEhF;;;;;;;;;;;;;;GAcG;AACH,MA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AC;AAChE,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,MAAM,GAAG,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,eAAe,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAC1F,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,8BAA8B,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC;IAClF,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One run's answer to "which paths does Git ignore here". The two
|
|
3
|
+
* predicates are the contract callers use, so no caller can ask the
|
|
4
|
+
* file set a directory question or read past the `known: false` answer.
|
|
5
|
+
*/
|
|
6
|
+
export interface GitIgnoredScope {
|
|
7
|
+
/** False when Git could not answer; then both predicates are false. */
|
|
8
|
+
readonly known: boolean;
|
|
9
|
+
/** Whether the walk must not descend into this repo-relative directory. */
|
|
10
|
+
skipsDirectory(relativeDirectory: string): boolean;
|
|
11
|
+
/** Whether this repo-relative file is skipped by the walk. */
|
|
12
|
+
skipsFile(relativeFile: string): boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Asks Git which UNTRACKED paths this repository ignores. Callers
|
|
16
|
+
* compute this ONCE per run and hand it to every enumeration that must
|
|
17
|
+
* agree on the scan scope.
|
|
18
|
+
*
|
|
19
|
+
* Args:
|
|
20
|
+
* root: absolute repository root (the directory the walk starts at).
|
|
21
|
+
*
|
|
22
|
+
* Returns:
|
|
23
|
+
* GitIgnoredScope: the skip rules when Git answered; a `known: false`
|
|
24
|
+
* scope that skips nothing when there was no usable work tree.
|
|
25
|
+
*/
|
|
26
|
+
export declare function gitIgnoredPaths(root: string): GitIgnoredScope;
|
|
27
|
+
//# sourceMappingURL=git-ignored.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-ignored.d.ts","sourceRoot":"","sources":["../src/git-ignored.ts"],"names":[],"mappings":"AAyCA;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,2EAA2E;IAC3E,cAAc,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC;IACnD,8DAA8D;IAC9D,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1C;AAQD;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CA8C7D"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git-ignore awareness for the DETECTOR-INPUT walk (owner decision D5,
|
|
3
|
+
* release 0.9.0).
|
|
4
|
+
*
|
|
5
|
+
* A consumer working copy holds whole gitignored trees the repository
|
|
6
|
+
* never owns as source: the minified trace-viewer bundles a Playwright
|
|
7
|
+
* run writes into `playwright-report/`, build output, local caches. The
|
|
8
|
+
* scan walked them exactly like committed code, so every minified call
|
|
9
|
+
* in them became detector evidence — hundreds of
|
|
10
|
+
* `FRONTEND_CALL_TARGET_UNRESOLVED` entries the owner then had to
|
|
11
|
+
* `adopt` away. A clean clone of the same commit scanned none of it.
|
|
12
|
+
* The set Git already knows is the one honest answer to "what is source
|
|
13
|
+
* here", so the scan asks Git once and skips exactly that.
|
|
14
|
+
*
|
|
15
|
+
* Properties this module guarantees:
|
|
16
|
+
*
|
|
17
|
+
* - **Deterministic across machines.** `core.excludesFile` is
|
|
18
|
+
* overridden to empty on the command line, so the user's global
|
|
19
|
+
* excludes file cannot change which files one repository's scan sees.
|
|
20
|
+
* `.gitignore` at any depth and `.git/info/exclude` still count —
|
|
21
|
+
* they are repository state, not machine state.
|
|
22
|
+
* - **Tracked files are never skipped.** `ls-files --others` reports
|
|
23
|
+
* UNTRACKED paths only, so a committed file that matches an ignore
|
|
24
|
+
* pattern stays in the scan (git's own semantics, and the same rule
|
|
25
|
+
* the static test scanner in `@gate-forge/pack-playwright` follows).
|
|
26
|
+
* - **Absence of an answer is not an answer.** Outside a work tree, or
|
|
27
|
+
* when git is missing, unreadable, or too slow, the scope reports
|
|
28
|
+
* `known: false` and both predicates are false — the caller keeps
|
|
29
|
+
* exactly today's behaviour and skips nothing. Nothing is printed: a
|
|
30
|
+
* repository without usable Git inventory is already surfaced by the
|
|
31
|
+
* input snapshot's `snapshot-unavailable` diagnostic, and the scan
|
|
32
|
+
* must not invent a second warning channel for it.
|
|
33
|
+
* - **Whole ignored directories arrive collapsed.** `--directory` makes
|
|
34
|
+
* Git report an entirely-ignored directory as one `dir/` entry, so the
|
|
35
|
+
* walk skips the subtree without descending into it. A directory
|
|
36
|
+
* holding a TRACKED file is never collapsed — Git reports the ignored
|
|
37
|
+
* files inside it individually — so collapsing can never hide a
|
|
38
|
+
* committed byte.
|
|
39
|
+
*/
|
|
40
|
+
import { spawnSync } from 'node:child_process';
|
|
41
|
+
/** Hard cap on the ignore query's output buffer. */
|
|
42
|
+
const MAX_IGNORE_OUTPUT_BYTES = 64 * 1024 * 1024;
|
|
43
|
+
/** The ignore query's deadline; a slower git answers nothing (today's behaviour). */
|
|
44
|
+
const IGNORE_QUERY_TIMEOUT_MS = 20_000;
|
|
45
|
+
/**
|
|
46
|
+
* Asks Git which UNTRACKED paths this repository ignores. Callers
|
|
47
|
+
* compute this ONCE per run and hand it to every enumeration that must
|
|
48
|
+
* agree on the scan scope.
|
|
49
|
+
*
|
|
50
|
+
* Args:
|
|
51
|
+
* root: absolute repository root (the directory the walk starts at).
|
|
52
|
+
*
|
|
53
|
+
* Returns:
|
|
54
|
+
* GitIgnoredScope: the skip rules when Git answered; a `known: false`
|
|
55
|
+
* scope that skips nothing when there was no usable work tree.
|
|
56
|
+
*/
|
|
57
|
+
export function gitIgnoredPaths(root) {
|
|
58
|
+
const result = spawnSync('git', [
|
|
59
|
+
'-c',
|
|
60
|
+
'core.excludesFile=',
|
|
61
|
+
'ls-files',
|
|
62
|
+
'--others',
|
|
63
|
+
'--ignored',
|
|
64
|
+
'--exclude-standard',
|
|
65
|
+
'--directory',
|
|
66
|
+
'-z',
|
|
67
|
+
], {
|
|
68
|
+
cwd: root,
|
|
69
|
+
encoding: 'utf8',
|
|
70
|
+
maxBuffer: MAX_IGNORE_OUTPUT_BYTES,
|
|
71
|
+
timeout: IGNORE_QUERY_TIMEOUT_MS,
|
|
72
|
+
});
|
|
73
|
+
if (result.error !== undefined) {
|
|
74
|
+
return { known: false, skipsDirectory: () => false, skipsFile: () => false };
|
|
75
|
+
}
|
|
76
|
+
// Non-zero is "not a repository" (128) or an unreadable work tree —
|
|
77
|
+
// both mean no answer, and an unanswered query skips nothing.
|
|
78
|
+
if (result.status !== 0) {
|
|
79
|
+
return { known: false, skipsDirectory: () => false, skipsFile: () => false };
|
|
80
|
+
}
|
|
81
|
+
const files = new Set();
|
|
82
|
+
const directories = new Set();
|
|
83
|
+
for (const entry of (result.stdout ?? '').split('\0')) {
|
|
84
|
+
if (entry.length === 0)
|
|
85
|
+
continue;
|
|
86
|
+
if (entry.endsWith('/')) {
|
|
87
|
+
directories.add(entry.slice(0, -1));
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
files.add(entry);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (files.size === 0 && directories.size === 0) {
|
|
94
|
+
return { known: true, skipsDirectory: () => false, skipsFile: () => false };
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
known: true,
|
|
98
|
+
skipsDirectory: (relativeDirectory) => directories.has(relativeDirectory),
|
|
99
|
+
skipsFile: (relativeFile) => files.has(relativeFile),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=git-ignored.js.map
|