@gate-forge/cli 0.7.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -704
- package/dist/adapter-audit.d.ts +208 -0
- package/dist/adapter-audit.d.ts.map +1 -0
- package/dist/adapter-audit.js +579 -0
- package/dist/adapter-audit.js.map +1 -0
- package/dist/adapter-scaffold.d.ts +91 -0
- package/dist/adapter-scaffold.d.ts.map +1 -0
- package/dist/adapter-scaffold.js +474 -0
- package/dist/adapter-scaffold.js.map +1 -0
- package/dist/adopted-baseline.d.ts +10 -0
- package/dist/adopted-baseline.d.ts.map +1 -1
- package/dist/adopted-baseline.js +18 -1
- package/dist/adopted-baseline.js.map +1 -1
- package/dist/args.d.ts +15 -0
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +61 -2
- package/dist/args.js.map +1 -1
- package/dist/behavior-setup.d.ts +239 -0
- package/dist/behavior-setup.d.ts.map +1 -0
- package/dist/behavior-setup.js +751 -0
- package/dist/behavior-setup.js.map +1 -0
- package/dist/broker.d.ts.map +1 -1
- package/dist/broker.js +28 -2
- package/dist/broker.js.map +1 -1
- package/dist/cache-exclusions.d.ts +45 -0
- package/dist/cache-exclusions.d.ts.map +1 -0
- package/dist/cache-exclusions.js +205 -0
- package/dist/cache-exclusions.js.map +1 -0
- package/dist/candidate-tree.d.ts +86 -14
- package/dist/candidate-tree.d.ts.map +1 -1
- package/dist/candidate-tree.js +236 -62
- package/dist/candidate-tree.js.map +1 -1
- package/dist/ci-witnessed-template.d.ts +43 -0
- package/dist/ci-witnessed-template.d.ts.map +1 -0
- package/dist/ci-witnessed-template.js +283 -0
- package/dist/ci-witnessed-template.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +31 -4
- package/dist/cli.js.map +1 -1
- package/dist/commands/adapters.d.ts +15 -0
- package/dist/commands/adapters.d.ts.map +1 -0
- package/dist/commands/adapters.js +355 -0
- package/dist/commands/adapters.js.map +1 -0
- package/dist/commands/adopt.d.ts +7 -0
- package/dist/commands/adopt.d.ts.map +1 -1
- package/dist/commands/adopt.js +44 -2
- package/dist/commands/adopt.js.map +1 -1
- package/dist/commands/baseline.d.ts.map +1 -1
- package/dist/commands/baseline.js +42 -1
- package/dist/commands/baseline.js.map +1 -1
- package/dist/commands/blocking.d.ts +105 -2
- package/dist/commands/blocking.d.ts.map +1 -1
- package/dist/commands/blocking.js +395 -53
- package/dist/commands/blocking.js.map +1 -1
- package/dist/commands/check.d.ts +36 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +1068 -64
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/classify.d.ts +2 -1
- package/dist/commands/classify.d.ts.map +1 -1
- package/dist/commands/classify.js +188 -5
- package/dist/commands/classify.js.map +1 -1
- package/dist/commands/enforce.d.ts +4 -4
- package/dist/commands/enforce.d.ts.map +1 -1
- package/dist/commands/enforce.js +41 -9
- package/dist/commands/enforce.js.map +1 -1
- package/dist/commands/enforcement.d.ts +13 -1
- package/dist/commands/enforcement.d.ts.map +1 -1
- package/dist/commands/enforcement.js +880 -33
- 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/history.d.ts +12 -0
- package/dist/commands/history.d.ts.map +1 -0
- package/dist/commands/history.js +45 -0
- package/dist/commands/history.js.map +1 -0
- package/dist/commands/init-presets.d.ts +155 -0
- package/dist/commands/init-presets.d.ts.map +1 -0
- package/dist/commands/init-presets.js +203 -0
- package/dist/commands/init-presets.js.map +1 -0
- package/dist/commands/init.d.ts +7 -12
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +987 -99
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/keys.d.ts.map +1 -1
- package/dist/commands/keys.js +29 -13
- package/dist/commands/keys.js.map +1 -1
- package/dist/commands/next.d.ts.map +1 -1
- package/dist/commands/next.js +846 -19
- package/dist/commands/next.js.map +1 -1
- package/dist/commands/pre-commit.d.ts +25 -0
- package/dist/commands/pre-commit.d.ts.map +1 -1
- package/dist/commands/pre-commit.js +91 -6
- package/dist/commands/pre-commit.js.map +1 -1
- package/dist/commands/quarantine.d.ts +16 -0
- package/dist/commands/quarantine.d.ts.map +1 -0
- package/dist/commands/quarantine.js +213 -0
- package/dist/commands/quarantine.js.map +1 -0
- package/dist/commands/run.d.ts +39 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +196 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/test-gates.d.ts +284 -2
- package/dist/commands/test-gates.d.ts.map +1 -1
- package/dist/commands/test-gates.js +3620 -187
- package/dist/commands/test-gates.js.map +1 -1
- package/dist/commands/tests.d.ts +1 -1
- package/dist/commands/tests.d.ts.map +1 -1
- package/dist/commands/tests.js +264 -29
- 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 +78 -9
- package/dist/endpoint-compiler.js.map +1 -1
- package/dist/engine-browser.d.ts +183 -0
- package/dist/engine-browser.d.ts.map +1 -0
- package/dist/engine-browser.js +381 -0
- package/dist/engine-browser.js.map +1 -0
- package/dist/engine-identity.d.ts +100 -0
- package/dist/engine-identity.d.ts.map +1 -0
- package/dist/engine-identity.js +182 -0
- package/dist/engine-identity.js.map +1 -0
- package/dist/evaluate.d.ts +105 -1
- package/dist/evaluate.d.ts.map +1 -1
- package/dist/evaluate.js +149 -18
- package/dist/evaluate.js.map +1 -1
- package/dist/execution.d.ts +253 -9
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +309 -12
- package/dist/execution.js.map +1 -1
- package/dist/gateforge-owned.d.ts +78 -0
- package/dist/gateforge-owned.d.ts.map +1 -0
- package/dist/gateforge-owned.js +254 -0
- package/dist/gateforge-owned.js.map +1 -0
- package/dist/git-hooks.d.ts +35 -0
- package/dist/git-hooks.d.ts.map +1 -1
- package/dist/git-hooks.js +140 -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/git-objects.d.ts +60 -0
- package/dist/git-objects.d.ts.map +1 -0
- package/dist/git-objects.js +152 -0
- package/dist/git-objects.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/history.d.ts +52 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +116 -0
- package/dist/history.js.map +1 -0
- package/dist/host-load.d.ts +49 -0
- package/dist/host-load.d.ts.map +1 -0
- package/dist/host-load.js +78 -0
- package/dist/host-load.js.map +1 -0
- 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/input-snapshot.d.ts +63 -9
- package/dist/input-snapshot.d.ts.map +1 -1
- package/dist/input-snapshot.js +195 -17
- package/dist/input-snapshot.js.map +1 -1
- package/dist/io.d.ts +49 -0
- package/dist/io.d.ts.map +1 -1
- package/dist/io.js +22 -0
- package/dist/io.js.map +1 -1
- package/dist/mapping.d.ts +84 -1
- package/dist/mapping.d.ts.map +1 -1
- package/dist/mapping.js +276 -5
- package/dist/mapping.js.map +1 -1
- package/dist/native-freeze.d.ts +217 -0
- package/dist/native-freeze.d.ts.map +1 -0
- package/dist/native-freeze.js +332 -0
- package/dist/native-freeze.js.map +1 -0
- package/dist/pipeline.d.ts +67 -1
- package/dist/pipeline.d.ts.map +1 -1
- package/dist/pipeline.js +164 -6
- 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/playwright-browsers.d.ts +210 -0
- package/dist/playwright-browsers.d.ts.map +1 -0
- package/dist/playwright-browsers.js +364 -0
- package/dist/playwright-browsers.js.map +1 -0
- package/dist/plugins.d.ts +15 -5
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +59 -9
- package/dist/plugins.js.map +1 -1
- package/dist/progress.d.ts +148 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +263 -0
- package/dist/progress.js.map +1 -0
- package/dist/providers.d.ts +26 -1
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +39 -0
- package/dist/providers.js.map +1 -1
- package/dist/receipts.d.ts +1 -0
- package/dist/receipts.d.ts.map +1 -1
- package/dist/receipts.js +35 -7
- package/dist/receipts.js.map +1 -1
- package/dist/repo-scan.d.ts +15 -1
- package/dist/repo-scan.d.ts.map +1 -1
- package/dist/repo-scan.js +329 -34
- package/dist/repo-scan.js.map +1 -1
- package/dist/reseal-chain.d.ts +184 -0
- package/dist/reseal-chain.d.ts.map +1 -0
- package/dist/reseal-chain.js +735 -0
- package/dist/reseal-chain.js.map +1 -0
- package/dist/reseal-evidence.d.ts +241 -0
- package/dist/reseal-evidence.d.ts.map +1 -0
- package/dist/reseal-evidence.js +319 -0
- package/dist/reseal-evidence.js.map +1 -0
- package/dist/reseal.d.ts +181 -0
- package/dist/reseal.d.ts.map +1 -0
- package/dist/reseal.js +1620 -0
- package/dist/reseal.js.map +1 -0
- package/dist/response-field-guidance.d.ts +82 -0
- package/dist/response-field-guidance.d.ts.map +1 -0
- package/dist/response-field-guidance.js +184 -0
- package/dist/response-field-guidance.js.map +1 -0
- 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/run-cache.d.ts +260 -0
- package/dist/run-cache.d.ts.map +1 -0
- package/dist/run-cache.js +771 -0
- package/dist/run-cache.js.map +1 -0
- package/dist/run-preflight.d.ts +77 -0
- package/dist/run-preflight.d.ts.map +1 -0
- package/dist/run-preflight.js +774 -0
- package/dist/run-preflight.js.map +1 -0
- package/dist/run-recipe.d.ts +107 -0
- package/dist/run-recipe.d.ts.map +1 -0
- package/dist/run-recipe.js +295 -0
- package/dist/run-recipe.js.map +1 -0
- package/dist/run-reliability.d.ts +126 -0
- package/dist/run-reliability.d.ts.map +1 -0
- package/dist/run-reliability.js +221 -0
- package/dist/run-reliability.js.map +1 -0
- package/dist/runtime.d.ts +15 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +11 -1
- package/dist/runtime.js.map +1 -1
- 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/secret-guard.d.ts +36 -0
- package/dist/secret-guard.d.ts.map +1 -0
- package/dist/secret-guard.js +63 -0
- package/dist/secret-guard.js.map +1 -0
- package/dist/singleton-guidance.d.ts +82 -0
- package/dist/singleton-guidance.d.ts.map +1 -0
- package/dist/singleton-guidance.js +138 -0
- package/dist/singleton-guidance.js.map +1 -0
- package/dist/staged-candidate.d.ts +17 -0
- package/dist/staged-candidate.d.ts.map +1 -1
- package/dist/staged-candidate.js +50 -0
- package/dist/staged-candidate.js.map +1 -1
- package/dist/state-artifacts.d.ts +70 -0
- package/dist/state-artifacts.d.ts.map +1 -0
- package/dist/state-artifacts.js +215 -0
- package/dist/state-artifacts.js.map +1 -0
- package/dist/state.d.ts +170 -2
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +248 -8
- package/dist/state.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/dist/verifier-keys.d.ts +33 -2
- package/dist/verifier-keys.d.ts.map +1 -1
- package/dist/verifier-keys.js +95 -9
- package/dist/verifier-keys.js.map +1 -1
- package/guides/CONNECT-YOUR-PROJECT.md +425 -0
- package/guides/QUICKSTART.md +306 -26
- package/guides/REFERENCE.md +1710 -0
- package/guides/RUNNER-NEUTRAL-EVIDENCE.md +199 -0
- package/guides/TEST-ENVIRONMENT.md +1044 -6
- package/guides/UPGRADE-0.6-to-0.7.md +3 -3
- package/guides/UPGRADE-0.7-to-0.8.md +114 -0
- package/guides/UPGRADE-0.8-to-0.9.md +104 -0
- package/package.json +10 -9
|
@@ -0,0 +1,254 @@
|
|
|
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
|
+
/** Repo-relative path of the tracked mapping sidecar. */
|
|
44
|
+
export const GATEFORGE_TEST_MAP_PATH = '.gateforge/test-map.yml';
|
|
45
|
+
/** Repo-relative path of the machine-specific engine checkout reference. */
|
|
46
|
+
export const GATEFORGE_ENGINE_REFERENCE_PATH = '.gateforge/engine';
|
|
47
|
+
/** Repo-relative path of the agent skill file `init` writes. */
|
|
48
|
+
export const GATEFORGE_SKILL_FILE = 'GATEFORGE.md';
|
|
49
|
+
/**
|
|
50
|
+
* Repo-relative path of the overlay-proof directory README `init` writes.
|
|
51
|
+
* EXACT path on purpose: the overlay TESTS an owner or agent writes beside
|
|
52
|
+
* it in `tests/e2e/gateforge/` are product work and stay mappable and
|
|
53
|
+
* gradeable.
|
|
54
|
+
*/
|
|
55
|
+
export const GATEFORGE_OVERLAY_README_PATH = 'tests/e2e/gateforge/README.md';
|
|
56
|
+
/**
|
|
57
|
+
* Engine-owned subdirectories of `.gateforge/`: the generated gate wiring and
|
|
58
|
+
* the record directories every gate decision reads. Segment-aware matching
|
|
59
|
+
* only — `.gateforge/hooksy/x` is not inside `.gateforge/hooks`.
|
|
60
|
+
*/
|
|
61
|
+
export const GATEFORGE_OWNED_DIRS = [
|
|
62
|
+
'.gateforge/adapters',
|
|
63
|
+
'.gateforge/baselines',
|
|
64
|
+
'.gateforge/ci',
|
|
65
|
+
'.gateforge/hooks',
|
|
66
|
+
'.gateforge/quarantine',
|
|
67
|
+
'.gateforge/waivers',
|
|
68
|
+
];
|
|
69
|
+
/**
|
|
70
|
+
* Extensions accepted for an engine document directly under `.gateforge/`
|
|
71
|
+
* (`.gateforge/policies.yml`, `.gateforge/planes.json`, …). Source and
|
|
72
|
+
* executable code never qualifies: only documents the engine itself reads.
|
|
73
|
+
*/
|
|
74
|
+
const ENGINE_DOCUMENT_EXTENSIONS = new Set([
|
|
75
|
+
'.yml',
|
|
76
|
+
'.yaml',
|
|
77
|
+
'.json',
|
|
78
|
+
'.md',
|
|
79
|
+
'.txt',
|
|
80
|
+
]);
|
|
81
|
+
/**
|
|
82
|
+
* Owner-owned files that carry a Gateforge-managed block, with the markers
|
|
83
|
+
* that prove the block is still wired. A file whose marker is gone is not a
|
|
84
|
+
* policy input anymore — that is exactly the E17 self-authorization case.
|
|
85
|
+
*/
|
|
86
|
+
const MANAGED_OWNER_FILES = {
|
|
87
|
+
'.gitlab-ci.yml': { kind: 'ci-wiring', markers: ['.gateforge/ci/'] },
|
|
88
|
+
'.pre-commit-config.yaml': { kind: 'pre-commit-wiring', markers: ['gateforge-check'] },
|
|
89
|
+
'.github/workflows/gateforge.yml': { kind: 'ci-wiring', markers: ['# Generated by Gateforge'] },
|
|
90
|
+
'.github/workflows/gateforge-witnessed.yml': { kind: 'ci-wiring', markers: ['# Generated by Gateforge'] },
|
|
91
|
+
};
|
|
92
|
+
/** Normalizes a configured repo path to the posix form used for comparison. */
|
|
93
|
+
function normalizeRepoPath(path) {
|
|
94
|
+
const posix = path.split('\\').join('/');
|
|
95
|
+
return posix.startsWith('./') ? posix.slice(2) : posix;
|
|
96
|
+
}
|
|
97
|
+
/** Segment-aware directory membership (`a/b` is inside `a`, `a2` is not). */
|
|
98
|
+
function underDir(file, dir) {
|
|
99
|
+
return file === dir || file.startsWith(`${dir}/`);
|
|
100
|
+
}
|
|
101
|
+
/** The lowercase extension of a basename, or `''` when it has none. */
|
|
102
|
+
function extensionOf(basename) {
|
|
103
|
+
const lower = basename.toLowerCase();
|
|
104
|
+
return lower.includes('.') ? lower.slice(lower.lastIndexOf('.')) : '';
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Classifies a repo-relative path as a Gateforge-owned policy input.
|
|
108
|
+
*
|
|
109
|
+
* Args:
|
|
110
|
+
* file: normalized repo-relative changed path.
|
|
111
|
+
* config: the loaded gateforge config (its document paths are honored).
|
|
112
|
+
*
|
|
113
|
+
* Returns:
|
|
114
|
+
* GateforgeOwnedInput | null: the matched input, or null when the path is
|
|
115
|
+
* not a Gateforge-owned policy input (a product file, or engine run state).
|
|
116
|
+
*/
|
|
117
|
+
export function gateforgeOwnedInput(file, config) {
|
|
118
|
+
const posix = normalizeRepoPath(file);
|
|
119
|
+
if (posix === '.gateforge.yml')
|
|
120
|
+
return { path: '.gateforge.yml', kind: 'config' };
|
|
121
|
+
if (posix === GATEFORGE_SKILL_FILE)
|
|
122
|
+
return { path: GATEFORGE_SKILL_FILE, kind: 'agent-skill' };
|
|
123
|
+
if (posix === GATEFORGE_OVERLAY_README_PATH) {
|
|
124
|
+
return { path: GATEFORGE_OVERLAY_README_PATH, kind: 'agent-skill' };
|
|
125
|
+
}
|
|
126
|
+
if (posix === GATEFORGE_ENGINE_REFERENCE_PATH) {
|
|
127
|
+
return { path: GATEFORGE_ENGINE_REFERENCE_PATH, kind: 'engine-reference' };
|
|
128
|
+
}
|
|
129
|
+
if (posix === GATEFORGE_TEST_MAP_PATH)
|
|
130
|
+
return { path: GATEFORGE_TEST_MAP_PATH, kind: 'mapping-sidecar' };
|
|
131
|
+
if (posix === DOCS_EXCLUSIONS_PATH || posix === CACHE_EXCLUSIONS_PATH) {
|
|
132
|
+
return { path: posix, kind: 'exclusion-declaration' };
|
|
133
|
+
}
|
|
134
|
+
for (const packConfig of PACK_CONFIGS) {
|
|
135
|
+
if (posix === packConfig)
|
|
136
|
+
return { path: packConfig, kind: 'pack-config' };
|
|
137
|
+
}
|
|
138
|
+
// Configured documents: the config may point anywhere in the repository.
|
|
139
|
+
if (posix === normalizeRepoPath(config.policies))
|
|
140
|
+
return { path: posix, kind: 'policy' };
|
|
141
|
+
if (posix === normalizeRepoPath(config.classificationPolicy)) {
|
|
142
|
+
return { path: posix, kind: 'classification-policy' };
|
|
143
|
+
}
|
|
144
|
+
if (config.behaviorPolicy !== undefined && posix === normalizeRepoPath(config.behaviorPolicy)) {
|
|
145
|
+
return { path: posix, kind: 'behavior-policy' };
|
|
146
|
+
}
|
|
147
|
+
if (config.runtime !== undefined && posix === normalizeRepoPath(config.runtime)) {
|
|
148
|
+
return { path: posix, kind: 'runtime-policy' };
|
|
149
|
+
}
|
|
150
|
+
const baselines = normalizeRepoPath(config.baselines);
|
|
151
|
+
if (posix === baselines)
|
|
152
|
+
return { path: posix, kind: 'baseline' };
|
|
153
|
+
const adapters = normalizeRepoPath(config.adapters);
|
|
154
|
+
if (underDir(posix, adapters))
|
|
155
|
+
return { path: adapters, kind: 'adapter' };
|
|
156
|
+
const waivers = normalizeRepoPath(config.waivers);
|
|
157
|
+
if (underDir(posix, waivers))
|
|
158
|
+
return { path: waivers, kind: 'waiver' };
|
|
159
|
+
for (const plugin of config.plugins) {
|
|
160
|
+
const module = plugin.module;
|
|
161
|
+
if (typeof module !== 'string')
|
|
162
|
+
continue;
|
|
163
|
+
const normalized = normalizeRepoModule(module);
|
|
164
|
+
if (normalized !== null && (posix === normalized || underDir(posix, normalized))) {
|
|
165
|
+
return { path: normalized, kind: 'plugin-module' };
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// The baseline record directory: the adoption receipt is the sibling of the
|
|
169
|
+
// configured baseline document and Gateforge writes both.
|
|
170
|
+
const baselineDir = baselines.slice(0, baselines.lastIndexOf('/'));
|
|
171
|
+
if (baselineDir.includes('/') && underDir(posix, baselineDir))
|
|
172
|
+
return { path: baselineDir, kind: 'baseline' };
|
|
173
|
+
for (const dir of GATEFORGE_OWNED_DIRS) {
|
|
174
|
+
if (underDir(posix, dir))
|
|
175
|
+
return { path: dir, kind: dir === '.gateforge/quarantine' ? 'quarantine' : 'wiring' };
|
|
176
|
+
}
|
|
177
|
+
// Engine documents directly under `.gateforge/` (`docs-exclusions.yml`,
|
|
178
|
+
// `runtime.yml`, a custom policies document, …). Depth one only, and only
|
|
179
|
+
// document types — `.gateforge/<anything>.py` is not a policy input.
|
|
180
|
+
const segments = posix.split('/');
|
|
181
|
+
if (segments.length === 2 &&
|
|
182
|
+
segments[0] === '.gateforge' &&
|
|
183
|
+
ENGINE_DOCUMENT_EXTENSIONS.has(extensionOf(segments[1] ?? ''))) {
|
|
184
|
+
return { path: posix, kind: 'policy' };
|
|
185
|
+
}
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Whether an owner-owned file still carries Gateforge's managed block.
|
|
190
|
+
*
|
|
191
|
+
* Args:
|
|
192
|
+
* cwd: absolute repo root (the candidate's own checkout).
|
|
193
|
+
* file: repo-relative path.
|
|
194
|
+
*
|
|
195
|
+
* Returns:
|
|
196
|
+
* boolean: true for a managed owner file whose marker is still present.
|
|
197
|
+
*/
|
|
198
|
+
export function managedOwnerBlockPresent(cwd, file) {
|
|
199
|
+
const entry = MANAGED_OWNER_FILES[file];
|
|
200
|
+
if (entry === undefined)
|
|
201
|
+
return false;
|
|
202
|
+
const absolute = join(cwd, ...file.split('/'));
|
|
203
|
+
if (!existsSync(absolute))
|
|
204
|
+
return false;
|
|
205
|
+
try {
|
|
206
|
+
const body = readFileSync(absolute, 'utf8');
|
|
207
|
+
return entry.markers.some((marker) => body.includes(marker));
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Classifies a path including the owner files that carry a managed block.
|
|
215
|
+
*
|
|
216
|
+
* Args:
|
|
217
|
+
* cwd: absolute repo root (the candidate's own checkout).
|
|
218
|
+
* file: repo-relative path.
|
|
219
|
+
* config: the loaded gateforge config.
|
|
220
|
+
*
|
|
221
|
+
* Returns:
|
|
222
|
+
* GateforgeOwnedInput | null: the matched input, or null.
|
|
223
|
+
*/
|
|
224
|
+
export function classifyGateforgeOwnedInput(cwd, file, config) {
|
|
225
|
+
const direct = gateforgeOwnedInput(file, config);
|
|
226
|
+
if (direct !== null)
|
|
227
|
+
return direct;
|
|
228
|
+
const managed = MANAGED_OWNER_FILES[normalizeRepoPath(file)];
|
|
229
|
+
return managed !== undefined && managedOwnerBlockPresent(cwd, normalizeRepoPath(file))
|
|
230
|
+
? { path: normalizeRepoPath(file), kind: managed.kind }
|
|
231
|
+
: null;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Classifies a whole changed set in one pass (one config walk, no re-reads
|
|
235
|
+
* per file beyond the managed-block check).
|
|
236
|
+
*
|
|
237
|
+
* Args:
|
|
238
|
+
* cwd: absolute repo root.
|
|
239
|
+
* files: repo-relative changed paths.
|
|
240
|
+
* config: the loaded gateforge config.
|
|
241
|
+
*
|
|
242
|
+
* Returns:
|
|
243
|
+
* Map<string, GateforgeOwnedInput>: the subset that is Gateforge-owned.
|
|
244
|
+
*/
|
|
245
|
+
export function gateforgeOwnedInputs(cwd, files, config) {
|
|
246
|
+
const owned = new Map();
|
|
247
|
+
for (const file of files) {
|
|
248
|
+
const match = classifyGateforgeOwnedInput(cwd, file, config);
|
|
249
|
+
if (match !== null)
|
|
250
|
+
owned.set(file, match);
|
|
251
|
+
}
|
|
252
|
+
return owned;
|
|
253
|
+
}
|
|
254
|
+
//# 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;AAExE,yDAAyD;AACzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAEjE,4EAA4E;AAC5E,MAAM,CAAC,MAAM,+BAA+B,GAAG,mBAAmB,CAAC;AAEnE,gEAAgE;AAChE,MAAM,CAAC,MAAM,oBAAoB,GAAG,cAAc,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,+BAA+B,CAAC;AAE7E;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAsB;IACrD,qBAAqB;IACrB,sBAAsB;IACtB,eAAe;IACf,kBAAkB;IAClB,uBAAuB;IACvB,oBAAoB;CACrB,CAAC;AAEF;;;;GAIG;AACH,MAAM,0BAA0B,GAAwB,IAAI,GAAG,CAAC;IAC9D,MAAM;IACN,OAAO;IACP,OAAO;IACP,KAAK;IACL,MAAM;CACP,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,mBAAmB,GAA4F;IACnH,gBAAgB,EAAE,EAAE,IAAI,EAAE,W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,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAC7D,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
|
@@ -2,6 +2,12 @@ import { HOOK_MARKER_BEGIN, HOOK_MARKER_END, HOOK_VERIFY_ARG, gateforgeHookScrip
|
|
|
2
2
|
export { HOOK_MARKER_BEGIN, HOOK_MARKER_END, HOOK_VERIFY_ARG, gateforgeHookScript, hasGateforgeMarker, resolveHooksDir, verifyHookActivation };
|
|
3
3
|
/** Name of the hook Git runs before a commit is created. */
|
|
4
4
|
export declare const PRE_COMMIT_HOOK_NAME = "pre-commit";
|
|
5
|
+
/** Name of the hook Git runs before a ref update is pushed. */
|
|
6
|
+
export declare const PRE_PUSH_HOOK_NAME = "pre-push";
|
|
7
|
+
/** Marker lines delimiting Gateforge's pre-push hook. */
|
|
8
|
+
export declare const PRE_PUSH_MARKER_BEGIN = "# >>> gateforge pre-push v1 >>>";
|
|
9
|
+
/** End marker for the generated pre-push hook. */
|
|
10
|
+
export declare const PRE_PUSH_MARKER_END = "# <<< gateforge pre-push v1 <<<";
|
|
5
11
|
/**
|
|
6
12
|
* The standalone staged-gate runner written under `.gateforge/hooks/`:
|
|
7
13
|
* consumers with a foreign hook manager chain it manually (the exact
|
|
@@ -44,6 +50,24 @@ export type HookInstallOutcome = {
|
|
|
44
50
|
detail: string;
|
|
45
51
|
action: string;
|
|
46
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;
|
|
47
71
|
/**
|
|
48
72
|
* Installs (or verifies) the active pre-commit hook (plan Phase 5 item
|
|
49
73
|
* 1). Writing the hook is not enough: after writing or finding a
|
|
@@ -60,6 +84,17 @@ export type HookInstallOutcome = {
|
|
|
60
84
|
* installation by the caller (nonzero exit).
|
|
61
85
|
*/
|
|
62
86
|
export declare function installCommitHook(cwd: string, env: NodeJS.ProcessEnv, gateArgs?: readonly string[]): HookInstallOutcome;
|
|
87
|
+
/**
|
|
88
|
+
* Installs the receipt-verification pre-push lane without replacing foreign hooks.
|
|
89
|
+
*
|
|
90
|
+
* Args:
|
|
91
|
+
* cwd: absolute repository root.
|
|
92
|
+
* env: process environment used to resolve Git's hooks directory.
|
|
93
|
+
*
|
|
94
|
+
* Returns:
|
|
95
|
+
* HookInstallOutcome: installed, verified, conflict, or incomplete state.
|
|
96
|
+
*/
|
|
97
|
+
export declare function installPrePushHook(cwd: string, env: NodeJS.ProcessEnv): HookInstallOutcome;
|
|
63
98
|
/**
|
|
64
99
|
* Writes the standalone staged-gate script under `.gateforge/hooks/`
|
|
65
100
|
* (idempotent, executable) — the chaining target the conflict report
|
package/dist/git-hooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-hooks.d.ts","sourceRoot":"","sources":["../src/git-hooks.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,eAAe,EAAE,oBA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I,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
|
@@ -25,6 +25,12 @@ import { HOOK_MARKER_BEGIN, HOOK_MARKER_END, HOOK_VERIFY_ARG, gateforgeHookScrip
|
|
|
25
25
|
export { HOOK_MARKER_BEGIN, HOOK_MARKER_END, HOOK_VERIFY_ARG, gateforgeHookScript, hasGateforgeMarker, resolveHooksDir, verifyHookActivation };
|
|
26
26
|
/** Name of the hook Git runs before a commit is created. */
|
|
27
27
|
export const PRE_COMMIT_HOOK_NAME = 'pre-commit';
|
|
28
|
+
/** Name of the hook Git runs before a ref update is pushed. */
|
|
29
|
+
export const PRE_PUSH_HOOK_NAME = 'pre-push';
|
|
30
|
+
/** Marker lines delimiting Gateforge's pre-push hook. */
|
|
31
|
+
export const PRE_PUSH_MARKER_BEGIN = '# >>> gateforge pre-push v1 >>>';
|
|
32
|
+
/** End marker for the generated pre-push hook. */
|
|
33
|
+
export const PRE_PUSH_MARKER_END = '# <<< gateforge pre-push v1 <<<';
|
|
28
34
|
/**
|
|
29
35
|
* The standalone staged-gate runner written under `.gateforge/hooks/`:
|
|
30
36
|
* consumers with a foreign hook manager chain it manually (the exact
|
|
@@ -37,6 +43,26 @@ export const STAGED_GATE_SCRIPT_BASENAME = 'gateforge-staged.sh';
|
|
|
37
43
|
* regenerates this file from .pre-commit-config.yaml on every run, so any
|
|
38
44
|
* direct edit to it — including gateforge's — would be silently wiped). */
|
|
39
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
|
+
}
|
|
40
66
|
/**
|
|
41
67
|
* Installs (or verifies) the active pre-commit hook (plan Phase 5 item
|
|
42
68
|
* 1). Writing the hook is not enough: after writing or finding a
|
|
@@ -112,7 +138,7 @@ export function installCommitHook(cwd, env, gateArgs = ['check', '--staged', '--
|
|
|
112
138
|
// wiped on the next `pre-commit install`. Gateforge integrates through
|
|
113
139
|
// the framework config instead (the caller appends the gateforge hook
|
|
114
140
|
// block there); activation = the framework config carries the hook.
|
|
115
|
-
if (
|
|
141
|
+
if (isFrameworkManagedHookBody(body)) {
|
|
116
142
|
return {
|
|
117
143
|
status: 'framework',
|
|
118
144
|
hookPath,
|
|
@@ -165,6 +191,119 @@ export function installCommitHook(cwd, env, gateArgs = ['check', '--staged', '--
|
|
|
165
191
|
detail: `hook installed and ACTIVE at '${hookPath}' (exec bit set; verified invocation)`,
|
|
166
192
|
};
|
|
167
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Installs the receipt-verification pre-push lane without replacing foreign hooks.
|
|
196
|
+
*
|
|
197
|
+
* Args:
|
|
198
|
+
* cwd: absolute repository root.
|
|
199
|
+
* env: process environment used to resolve Git's hooks directory.
|
|
200
|
+
*
|
|
201
|
+
* Returns:
|
|
202
|
+
* HookInstallOutcome: installed, verified, conflict, or incomplete state.
|
|
203
|
+
*/
|
|
204
|
+
export function installPrePushHook(cwd, env) {
|
|
205
|
+
const hooksDir = resolveHooksDir(cwd, env);
|
|
206
|
+
if (hooksDir === null) {
|
|
207
|
+
return {
|
|
208
|
+
status: 'incomplete',
|
|
209
|
+
hookPath: null,
|
|
210
|
+
hooksDir: null,
|
|
211
|
+
detail: 'no usable Git repository found — the pre-push hook could not be installed',
|
|
212
|
+
action: 'Run `gateforge init --blocking` inside a Git repository work tree.',
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
const hookPath = join(hooksDir, PRE_PUSH_HOOK_NAME);
|
|
216
|
+
const script = prePushHookScript();
|
|
217
|
+
if (existsSync(hookPath)) {
|
|
218
|
+
const current = readFileSync(hookPath, 'utf8');
|
|
219
|
+
if (!current.includes(PRE_PUSH_MARKER_BEGIN) || !current.includes(PRE_PUSH_MARKER_END)) {
|
|
220
|
+
return {
|
|
221
|
+
status: 'conflict',
|
|
222
|
+
hookPath,
|
|
223
|
+
hooksDir,
|
|
224
|
+
detail: `a foreign pre-push hook exists at '${hookPath}'; Gateforge did not overwrite it`,
|
|
225
|
+
action: `Add a pre-push stdin loop that runs \`gateforge check --candidate-commit "$local_sha" --require-e2e\` for each non-deletion local SHA, then re-run \`gateforge init --blocking\`.`,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
const verify = probeHookExecution(hookPath);
|
|
229
|
+
if (!verify.ok) {
|
|
230
|
+
return {
|
|
231
|
+
status: 'incomplete',
|
|
232
|
+
hookPath,
|
|
233
|
+
hooksDir,
|
|
234
|
+
detail: `pre-push activation verification failed: ${verify.detail}`,
|
|
235
|
+
action: `Inspect '${hookPath}' and re-run \`gateforge init --blocking\`.`,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
return { status: 'verified', hookPath, hooksDir, detail: `pre-push hook active at '${hookPath}'` };
|
|
239
|
+
}
|
|
240
|
+
try {
|
|
241
|
+
mkdirSync(hooksDir, { recursive: true });
|
|
242
|
+
writeFileSync(hookPath, script, 'utf8');
|
|
243
|
+
chmodSync(hookPath, 0o755);
|
|
244
|
+
}
|
|
245
|
+
catch (error) {
|
|
246
|
+
return {
|
|
247
|
+
status: 'incomplete',
|
|
248
|
+
hookPath,
|
|
249
|
+
hooksDir,
|
|
250
|
+
detail: `the pre-push hook could not be written to '${hooksDir}': ${error.message}`,
|
|
251
|
+
action: `Ensure '${hooksDir}' is writable, then re-run \`gateforge init --blocking\`.`,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
const verify = probeHookExecution(hookPath);
|
|
255
|
+
if (!verify.ok) {
|
|
256
|
+
return {
|
|
257
|
+
status: 'incomplete',
|
|
258
|
+
hookPath,
|
|
259
|
+
hooksDir,
|
|
260
|
+
detail: `pre-push hook written but activation verification failed: ${verify.detail}`,
|
|
261
|
+
action: `Inspect '${hookPath}' and re-run \`gateforge init --blocking\`.`,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
return { status: 'installed', hookPath, hooksDir, detail: `pre-push hook installed and active at '${hookPath}'` };
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Renders the pre-push hook that verifies every non-deletion local ref tip.
|
|
268
|
+
*
|
|
269
|
+
* Returns:
|
|
270
|
+
* string: executable POSIX shell source.
|
|
271
|
+
*/
|
|
272
|
+
function prePushHookScript() {
|
|
273
|
+
return `#!/bin/sh
|
|
274
|
+
${PRE_PUSH_MARKER_BEGIN}
|
|
275
|
+
if [ "$1" = "${HOOK_VERIFY_ARG}" ]; then
|
|
276
|
+
echo "gateforge: pre-push receipt lane active"
|
|
277
|
+
exit 0
|
|
278
|
+
fi
|
|
279
|
+
GF_BIN=""
|
|
280
|
+
if [ -f "node_modules/.bin/gateforge" ]; then
|
|
281
|
+
GF_BIN="node_modules/.bin/gateforge"
|
|
282
|
+
elif command -v gateforge >/dev/null 2>&1; then
|
|
283
|
+
GF_BIN="gateforge"
|
|
284
|
+
fi
|
|
285
|
+
if [ -n "$GATEFORGE_CLI" ] && [ -x "$GATEFORGE_CLI" ]; then
|
|
286
|
+
GF_BIN="$GATEFORGE_CLI"
|
|
287
|
+
fi
|
|
288
|
+
if [ -z "$GF_BIN" ]; then
|
|
289
|
+
echo "gateforge: CLI engine not found; push blocked (fail closed)" >&2
|
|
290
|
+
exit 1
|
|
291
|
+
fi
|
|
292
|
+
unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_PREFIX
|
|
293
|
+
while IFS=' ' read -r local_ref local_sha remote_ref remote_sha
|
|
294
|
+
do
|
|
295
|
+
case "$local_sha" in
|
|
296
|
+
*[!0]*) ;;
|
|
297
|
+
*) continue ;;
|
|
298
|
+
esac
|
|
299
|
+
case "$GF_BIN" in
|
|
300
|
+
*/*) node "$GF_BIN" check --candidate-commit "$local_sha" --require-e2e ;;
|
|
301
|
+
*) "$GF_BIN" check --candidate-commit "$local_sha" --require-e2e ;;
|
|
302
|
+
esac || exit $?
|
|
303
|
+
done
|
|
304
|
+
${PRE_PUSH_MARKER_END}
|
|
305
|
+
`;
|
|
306
|
+
}
|
|
168
307
|
/**
|
|
169
308
|
* Writes the standalone staged-gate script under `.gateforge/hooks/`
|
|
170
309
|
* (idempotent, executable) — the chaining target the conflict report
|
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,EA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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"}
|