@holmes-lab/holmes-kit 0.29.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +556 -0
- package/README.md +15 -5
- package/bin/holmes-hook-antigravity.js +4 -0
- package/bin/holmes-kit.js +4 -0
- package/bin/holmes-pre-push.js +3 -0
- package/bin/holmes-stop-antigravity.js +4 -0
- package/dist/.build-id +1 -1
- package/dist/holmes/cli/agents-guidance-history.d.ts +1 -1
- package/dist/holmes/cli/agents-guidance-history.js +11 -2
- package/dist/holmes/cli/agents-guidance.d.ts +1 -0
- package/dist/holmes/cli/agents-guidance.js +11 -8
- package/dist/holmes/cli/agents.d.ts +41 -0
- package/dist/holmes/cli/agents.js +382 -2
- package/dist/holmes/cli/attest.d.ts +2 -0
- package/dist/holmes/cli/attest.js +66 -15
- package/dist/holmes/cli/ci-gate.js +16 -1
- package/dist/holmes/cli/claude-switches.d.ts +95 -0
- package/dist/holmes/cli/claude-switches.js +967 -0
- package/dist/holmes/cli/codex-hooks.d.ts +77 -0
- package/dist/holmes/cli/codex-hooks.js +802 -0
- package/dist/holmes/cli/codex-oracle.d.ts +194 -0
- package/dist/holmes/cli/codex-oracle.js +1245 -0
- package/dist/holmes/cli/codex-toml.d.ts +58 -1
- package/dist/holmes/cli/codex-toml.js +456 -40
- package/dist/holmes/cli/doctor.d.ts +108 -8
- package/dist/holmes/cli/doctor.js +1408 -98
- package/dist/holmes/cli/index.js +23 -11
- package/dist/holmes/cli/init.d.ts +13 -0
- package/dist/holmes/cli/init.js +749 -77
- package/dist/holmes/cli/interactive-prompt.js +2 -2
- package/dist/holmes/cli/mcp-launcher.d.ts +64 -6
- package/dist/holmes/cli/mcp-launcher.js +189 -6
- package/dist/holmes/cli/mcp-version.js +13 -2
- package/dist/holmes/cli/settings-merge.js +8 -2
- package/dist/holmes/cli/upgrade.d.ts +13 -0
- package/dist/holmes/cli/upgrade.js +116 -23
- package/dist/holmes/cli/workspace-scope.d.ts +22 -0
- package/dist/holmes/cli/workspace-scope.js +375 -0
- package/dist/holmes/cli/worktree-readiness.d.ts +1 -0
- package/dist/holmes/cli/worktree-readiness.js +17 -3
- package/dist/holmes/cpg/cpg-scanner.d.ts +29 -0
- package/dist/holmes/cpg/cpg-scanner.js +403 -3
- package/dist/holmes/cpg/cycle-detect.js +2 -1
- package/dist/holmes/cpg/forbidden-edges.js +9 -2
- package/dist/holmes/cpg/required-calls.js +8 -1
- package/dist/holmes/governance/autonomy.d.ts +9 -0
- package/dist/holmes/governance/autonomy.js +28 -1
- package/dist/holmes/governance/constitution-debt.js +3 -2
- package/dist/holmes/governance/constitution.js +15 -3
- package/dist/holmes/governance/provenance-chain.js +3 -2
- package/dist/holmes/governance/push-gate-runner.js +4 -3
- package/dist/holmes/guardrail/dependency-delta.js +4 -3
- package/dist/holmes/guardrail/linear-match.d.ts +57 -0
- package/dist/holmes/guardrail/linear-match.js +256 -0
- package/dist/holmes/guardrail/risk-classifier.d.ts +6 -7
- package/dist/holmes/guardrail/risk-classifier.js +931 -44
- package/dist/holmes/guardrail/risk-types.d.ts +6 -0
- package/dist/holmes/guardrail/scope-judgment.d.ts +4 -24
- package/dist/holmes/guardrail/scope-judgment.js +100 -23
- package/dist/holmes/guardrail/shell-words.d.ts +42 -0
- package/dist/holmes/guardrail/shell-words.js +1720 -0
- package/dist/holmes/guardrail/write-target.d.ts +168 -3
- package/dist/holmes/guardrail/write-target.js +2379 -87
- package/dist/holmes/hooks/adapters/antigravity.d.ts +3 -1
- package/dist/holmes/hooks/adapters/antigravity.js +115 -11
- package/dist/holmes/hooks/pre-tool-use.d.ts +32 -6
- package/dist/holmes/hooks/pre-tool-use.js +923 -87
- package/dist/holmes/hooks/rtm-refresh-child.d.ts +22 -1
- package/dist/holmes/hooks/rtm-refresh-child.js +102 -18
- package/dist/holmes/hooks/rtm-refresh.d.ts +20 -1
- package/dist/holmes/hooks/rtm-refresh.js +60 -15
- package/dist/holmes/hooks/session-start.d.ts +10 -0
- package/dist/holmes/hooks/session-start.js +31 -7
- package/dist/holmes/hooks/stop.d.ts +2 -1
- package/dist/holmes/hooks/stop.js +197 -91
- package/dist/holmes/mcp/approval-adapters.d.ts +22 -0
- package/dist/holmes/mcp/approval-adapters.js +21 -0
- package/dist/holmes/mcp/approval-commit.d.ts +20 -0
- package/dist/holmes/mcp/approval-commit.js +108 -0
- package/dist/holmes/mcp/approval-intent.d.ts +44 -0
- package/dist/holmes/mcp/approval-intent.js +67 -0
- package/dist/holmes/mcp/approval-policy.d.ts +14 -0
- package/dist/holmes/mcp/approval-policy.js +18 -0
- package/dist/holmes/mcp/elicit-approval.d.ts +2 -0
- package/dist/holmes/mcp/elicit-approval.js +8 -3
- package/dist/holmes/mcp/handlers/graph-operations.d.ts +17 -1
- package/dist/holmes/mcp/handlers/graph-operations.js +15 -6
- package/dist/holmes/mcp/handlers/maintenance-analysis.js +11 -5
- package/dist/holmes/mcp/handlers/maintenance-evidence.js +3 -2
- package/dist/holmes/mcp/handlers/phase-queries.d.ts +22 -7
- package/dist/holmes/mcp/handlers/phase-queries.js +81 -2
- package/dist/holmes/mcp/handlers/requirement-triage.d.ts +26 -0
- package/dist/holmes/mcp/handlers/requirement-triage.js +48 -11
- package/dist/holmes/mcp/handlers/review-evidence.d.ts +2 -1
- package/dist/holmes/mcp/handlers/review-evidence.js +15 -5
- package/dist/holmes/mcp/handlers/slice-orchestration.d.ts +18 -0
- package/dist/holmes/mcp/handlers/slice-orchestration.js +122 -16
- package/dist/holmes/mcp/handlers/spec-approval.d.ts +35 -2
- package/dist/holmes/mcp/handlers/spec-approval.js +175 -57
- package/dist/holmes/mcp/handlers/spec-authoring.js +36 -3
- package/dist/holmes/mcp/handlers/spec-queries.d.ts +39 -3
- package/dist/holmes/mcp/handlers/spec-queries.js +114 -7
- package/dist/holmes/mcp/handlers/test-execution.js +9 -3
- package/dist/holmes/mcp/handlers.d.ts +126 -8
- package/dist/holmes/mcp/handlers.js +109 -18
- package/dist/holmes/mcp/harness-attestation.d.ts +20 -0
- package/dist/holmes/mcp/harness-attestation.js +179 -0
- package/dist/holmes/mcp/maintenance-analyze.js +28 -4
- package/dist/holmes/mcp/maintenance-evidence.js +1 -1
- package/dist/holmes/mcp/requirement-triage-evidence.d.ts +72 -2
- package/dist/holmes/mcp/requirement-triage-evidence.js +227 -1
- package/dist/holmes/mcp/server.js +24 -3
- package/dist/holmes/mcp/supervisor.js +7 -3
- package/dist/holmes/mcp/tool-schemas.d.ts +8 -0
- package/dist/holmes/mcp/tool-schemas.js +54 -7
- package/dist/holmes/mcp/validate-args.js +12 -0
- package/dist/holmes/project/bounded-io.d.ts +102 -0
- package/dist/holmes/project/bounded-io.js +212 -0
- package/dist/holmes/project/change-source.js +3 -1
- package/dist/holmes/project/ci-runs.js +3 -2
- package/dist/holmes/project/ignore.d.ts +31 -2
- package/dist/holmes/project/ignore.js +409 -50
- package/dist/holmes/project/regular-file-guard.d.ts +13 -0
- package/dist/holmes/project/regular-file-guard.js +149 -0
- package/dist/holmes/project/root.js +12 -3
- package/dist/holmes/refresh/freshness-coordinator.d.ts +67 -0
- package/dist/holmes/refresh/freshness-coordinator.js +230 -0
- package/dist/holmes/reverse/anchor.js +4 -3
- package/dist/holmes/reverse/scan.js +6 -2
- package/dist/holmes/review/commit-text.js +3 -2
- package/dist/holmes/review/condition-hunk-replay.d.ts +12 -0
- package/dist/holmes/review/condition-hunk-replay.js +13 -2
- package/dist/holmes/review/condition-hunk-resolution.js +59 -8
- package/dist/holmes/review/failed-test-names.js +13 -10
- package/dist/holmes/review/findings.js +3 -1
- package/dist/holmes/review/kills-check.js +6 -1
- package/dist/holmes/review/point-in-time-replay.js +5 -4
- package/dist/holmes/review/replay-corpus.js +5 -4
- package/dist/holmes/review/requirement-triage-human-records.d.ts +59 -0
- package/dist/holmes/review/requirement-triage-human-records.js +119 -0
- package/dist/holmes/review/run-replay.js +3 -2
- package/dist/holmes/review/scope.js +6 -1
- package/dist/holmes/review/temporal-prior.js +3 -2
- package/dist/holmes/review/test-evidence.js +3 -2
- package/dist/holmes/review/test-outcomes.d.ts +28 -0
- package/dist/holmes/review/test-outcomes.js +92 -2
- package/dist/holmes/review/test-runner.d.ts +6 -0
- package/dist/holmes/review/test-runner.js +36 -15
- package/dist/holmes/rtm/advisory-outcomes.js +3 -2
- package/dist/holmes/rtm/anchor-ids.js +42 -2
- package/dist/holmes/rtm/file-anchors.js +4 -1
- package/dist/holmes/rtm/ftt-fulfilment.js +8 -3
- package/dist/holmes/rtm/git-changes.js +3 -1
- package/dist/holmes/rtm/graph-store.js +3 -2
- package/dist/holmes/rtm/test-scope.js +9 -4
- package/dist/holmes/spec/compat-impact.d.ts +25 -4
- package/dist/holmes/spec/compat-impact.js +682 -11
- package/dist/holmes/spec/entity-git-snapshot.js +3 -2
- package/dist/holmes/spec/entity-integration.js +3 -2
- package/dist/holmes/spec/entity-renumber-transaction.d.ts +19 -0
- package/dist/holmes/spec/entity-renumber-transaction.js +79 -6
- package/dist/holmes/spec/remote-spec-refs.js +3 -2
- package/dist/holmes/spec/renumber.js +25 -10
- package/dist/holmes/spec/spec-parser.js +9 -3
- package/dist/holmes/spec/yaml-scalar.js +2 -2
- package/dist/holmes/update/refresh.js +3 -1
- package/dist/holmes/update/update-notice.d.ts +6 -0
- package/dist/holmes/update/update-notice.js +18 -1
- package/package.json +11 -4
|
@@ -218,6 +218,18 @@ function judgeObject(path, schema, value, out) {
|
|
|
218
218
|
: `외 ${quoteAll('', us.slice(1))}은(는) 알 수 없는 키입니다 — ${target}을(를) 잘못 쓴 것 아닙니까`,
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
|
+
// @implements A-SPEC-732 (round 3) — `additionalProperties: false` is a contract that NO other
|
|
222
|
+
// key is accepted; only near-typos were refused, so `{...intent, root}` passed approval_commit.
|
|
223
|
+
// Keys already named through a typo line above are not named twice.
|
|
224
|
+
if (schema.additionalProperties === false) {
|
|
225
|
+
const strays = unknownKeys.filter((u) => !assign.has(u)).sort();
|
|
226
|
+
if (strays.length > 0) {
|
|
227
|
+
out.push({
|
|
228
|
+
path: path ? `${path}.${strays[0]}` : strays[0],
|
|
229
|
+
message: `${strays.length > 1 ? ` 외 ${quoteAll('', strays.slice(1))}` : ''}은(는) 이 도구가 받지 않는 키입니다 (additionalProperties: false)`,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
221
233
|
for (const [key, prop] of Object.entries(props)) {
|
|
222
234
|
const v = value[key];
|
|
223
235
|
if (v === undefined || v === null)
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded I/O shared by every caller on a hook, MCP or scan path (A-SPEC-734 round 12).
|
|
3
|
+
*
|
|
4
|
+
* A git child without a timeout, a git child with Node's 1 MiB default output buffer, or a plain
|
|
5
|
+
* `readFileSync` of a path that could be a FIFO each turned into a hang or a silently skipped check
|
|
6
|
+
* somewhere in the tree (measured: a FIFO `.gitattributes` blocked `git log --name-only` inside
|
|
7
|
+
* `maintenance_analyze`; `include.path` pointing at a FIFO blocked `git rev-parse` in every hook; a
|
|
8
|
+
* status larger than 1 MiB made the Stop hook's ART-1 check read "no signal"). The bounds live here
|
|
9
|
+
* so they are one decision, and a census test reads the tree for every git child.
|
|
10
|
+
*/
|
|
11
|
+
import { type SpawnSyncReturns } from 'node:child_process';
|
|
12
|
+
/** A git child on a hook, MCP or scan path. */
|
|
13
|
+
export declare const GIT_TIMEOUT_MS = 5000;
|
|
14
|
+
/** Replay and integration tooling that walks whole histories or object stores. */
|
|
15
|
+
export declare const GIT_LONG_TIMEOUT_MS = 120000;
|
|
16
|
+
/** Output a git child may produce before it counts as a failure (Node's default is 1 MiB). */
|
|
17
|
+
export declare const GIT_MAX_BUFFER: number;
|
|
18
|
+
/**
|
|
19
|
+
* @implements A-SPEC-734 (round 13) — the memory is kept per KIND of query. `repo` queries read only the
|
|
20
|
+
* configuration, refs and the index (`rev-parse`, `worktree list`, `ls-files -s`); `worktree` queries also read
|
|
21
|
+
* work-tree files, attributes or ignore rules (`status`, `diff`, `log` with paths, `ls-files -o`,
|
|
22
|
+
* `check-ignore`). A `worktree` timeout blocks `worktree` queries only; a `repo` timeout blocks both — the
|
|
23
|
+
* configuration itself does not load. One shared stamp made a slow status (`core.fsmonitor`, a FIFO
|
|
24
|
+
* `.gitattributes`) silence `worktree list` for 60 s, and the Stop hook walked three registered agent
|
|
25
|
+
* worktrees and blocked on ART-9 in their files (measured).
|
|
26
|
+
*/
|
|
27
|
+
export type GitKind = 'repo' | 'worktree';
|
|
28
|
+
/**
|
|
29
|
+
* Whether a git child of this kind for `root` timed out within the last minute (every caller then answers
|
|
30
|
+
* "no signal" at once). The default kind is `worktree`, the one every timeout blocks.
|
|
31
|
+
*/
|
|
32
|
+
export declare function gitRootBlocked(root: string, kind?: GitKind): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Records a git failure for `root` when it was a timeout (other failures are ordinary answers). The default
|
|
35
|
+
* kind is `worktree`: a caller that does not say is never allowed to silence the `repo` queries.
|
|
36
|
+
*/
|
|
37
|
+
export declare function noteGitFailure(root: string, err: unknown, kind?: GitKind): void;
|
|
38
|
+
/**
|
|
39
|
+
* @implements A-SPEC-734 (round 13) — one bounded git child that consults and feeds the memory: a blocked
|
|
40
|
+
* root answers at once with `status: null` and `error.code: 'EBLOCKED'`. The Stop hook's git children go
|
|
41
|
+
* through it (five of its call sites neither consulted nor fed the memory: `include.path` → FIFO took
|
|
42
|
+
* 27–32 s — measured).
|
|
43
|
+
*/
|
|
44
|
+
export declare function gitOnce(root: string, args: string[], kind: GitKind, opts?: {
|
|
45
|
+
cwd?: string;
|
|
46
|
+
input?: string;
|
|
47
|
+
timeout?: number;
|
|
48
|
+
env?: NodeJS.ProcessEnv;
|
|
49
|
+
}): SpawnSyncReturns<string>;
|
|
50
|
+
/** Test seam: forget every blocked root. */
|
|
51
|
+
export declare function resetGitBlocked(): void;
|
|
52
|
+
/**
|
|
53
|
+
* A file read only when it is a REGULAR file: opened non-blocking, so a FIFO in its place returns at once
|
|
54
|
+
* instead of waiting for a writer, then refused with everything else that is not a regular file (a device
|
|
55
|
+
* such as `/dev/zero` included). Throws like `readFileSync` does, so callers keep their error handling.
|
|
56
|
+
*/
|
|
57
|
+
export declare function readRegularFileSync(p: string): Buffer;
|
|
58
|
+
/** `readRegularFileSync` as UTF-8 text. */
|
|
59
|
+
export declare function readRegularTextSync(p: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* @implements A-SPEC-734 (round 15) — what a git result means: `answered` (exit 0), `no-repository` (git SAYS the
|
|
62
|
+
* directory is not a repository, or there is no git at all), or `unanswered` — every other failure: a timeout, an
|
|
63
|
+
* overflow, a blocked root, or a refusal inside a repository (dubious ownership, an unknown `extensions.*`, a
|
|
64
|
+
* corrupt index — all exit 128, and were read as "no repository": `rm -r src` was allowed — measured). Accepts a
|
|
65
|
+
* `spawnSync` result or a thrown `execFileSync` error; the caller must have piped stderr for a refusal to be told
|
|
66
|
+
* apart from "not a repository" (without it, a failure is `unanswered`, the stricter reading).
|
|
67
|
+
*/
|
|
68
|
+
export type GitAnswer = 'answered' | 'no-repository' | 'unanswered';
|
|
69
|
+
/**
|
|
70
|
+
* @implements A-SPEC-734 (round 16) — with `dir`, "no repository" is decided by the TREE: no `.git` entry in `dir` or
|
|
71
|
+
* any ancestor. Round 15 read git's English message — a translated git (Linux/Homebrew git under `LANG=ko_KR`) turned
|
|
72
|
+
* every non-git project into "did not answer", and `not a git repository: <gitdir>` (a submodule without its modules
|
|
73
|
+
* directory, a linked worktree whose main repository moved) read as "no repository" (measured).
|
|
74
|
+
*/
|
|
75
|
+
export declare function gitAnswerOf(r: {
|
|
76
|
+
error?: unknown;
|
|
77
|
+
status?: number | null;
|
|
78
|
+
stderr?: unknown;
|
|
79
|
+
code?: unknown;
|
|
80
|
+
}, dir?: string): GitAnswer;
|
|
81
|
+
/** Whether `dir` or an ancestor holds a `.git` entry (file, directory or link) — the tree's own answer to "is this a repository". */
|
|
82
|
+
export declare function gitEntryAbove(dir: string): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* @implements A-SPEC-734 (round 16) — the variables that relocate the repository a git child reads. An exported
|
|
85
|
+
* dotfiles `GIT_DIR` made the rm gate judge the project by that repository (measured).
|
|
86
|
+
*/
|
|
87
|
+
export declare const REPO_LOCATING_GIT_VARS: readonly ["GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE", "GIT_COMMON_DIR", "GIT_OBJECT_DIRECTORY", "GIT_ALTERNATE_OBJECT_DIRECTORIES", "GIT_NAMESPACE", "GIT_CEILING_DIRECTORIES", "GIT_DISCOVERY_ACROSS_FILESYSTEM"];
|
|
88
|
+
/**
|
|
89
|
+
* @implements A-SPEC-734 (round 17) — `full` (a porcelain path from the repository root) relative to the project whose
|
|
90
|
+
* `rev-parse --show-prefix` is `prefix`, compared segment by segment NFC and case-folded; null when it lies elsewhere.
|
|
91
|
+
* A `-- .` pathspec is matched case-sensitively by git, so a package whose directory case differs between the index and
|
|
92
|
+
* a case-folding disk read clean (measured).
|
|
93
|
+
*/
|
|
94
|
+
export declare function underGitPrefix(full: string, prefix: string): string | null;
|
|
95
|
+
/** A git child's environment: the caller's, without the variables that relocate the repository (round 17). */
|
|
96
|
+
export declare function gitEnv(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
97
|
+
/** Whether a failed git answer means "not judged" rather than "no repository" (round 15: a refusal is not judged too). */
|
|
98
|
+
export declare function gitUnanswered(r: {
|
|
99
|
+
error?: unknown;
|
|
100
|
+
status?: number | null;
|
|
101
|
+
stderr?: unknown;
|
|
102
|
+
}, dir?: string): boolean;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.REPO_LOCATING_GIT_VARS = exports.GIT_MAX_BUFFER = exports.GIT_LONG_TIMEOUT_MS = exports.GIT_TIMEOUT_MS = void 0;
|
|
37
|
+
exports.gitRootBlocked = gitRootBlocked;
|
|
38
|
+
exports.noteGitFailure = noteGitFailure;
|
|
39
|
+
exports.gitOnce = gitOnce;
|
|
40
|
+
exports.resetGitBlocked = resetGitBlocked;
|
|
41
|
+
exports.readRegularFileSync = readRegularFileSync;
|
|
42
|
+
exports.readRegularTextSync = readRegularTextSync;
|
|
43
|
+
exports.gitAnswerOf = gitAnswerOf;
|
|
44
|
+
exports.gitEntryAbove = gitEntryAbove;
|
|
45
|
+
exports.underGitPrefix = underGitPrefix;
|
|
46
|
+
exports.gitEnv = gitEnv;
|
|
47
|
+
exports.gitUnanswered = gitUnanswered;
|
|
48
|
+
// @implements A-SPEC-734
|
|
49
|
+
/**
|
|
50
|
+
* Bounded I/O shared by every caller on a hook, MCP or scan path (A-SPEC-734 round 12).
|
|
51
|
+
*
|
|
52
|
+
* A git child without a timeout, a git child with Node's 1 MiB default output buffer, or a plain
|
|
53
|
+
* `readFileSync` of a path that could be a FIFO each turned into a hang or a silently skipped check
|
|
54
|
+
* somewhere in the tree (measured: a FIFO `.gitattributes` blocked `git log --name-only` inside
|
|
55
|
+
* `maintenance_analyze`; `include.path` pointing at a FIFO blocked `git rev-parse` in every hook; a
|
|
56
|
+
* status larger than 1 MiB made the Stop hook's ART-1 check read "no signal"). The bounds live here
|
|
57
|
+
* so they are one decision, and a census test reads the tree for every git child.
|
|
58
|
+
*/
|
|
59
|
+
const node_child_process_1 = require("node:child_process");
|
|
60
|
+
const fs = __importStar(require("node:fs"));
|
|
61
|
+
const path = __importStar(require("node:path"));
|
|
62
|
+
/** A git child on a hook, MCP or scan path. */
|
|
63
|
+
exports.GIT_TIMEOUT_MS = 5000;
|
|
64
|
+
/** Replay and integration tooling that walks whole histories or object stores. */
|
|
65
|
+
exports.GIT_LONG_TIMEOUT_MS = 120_000;
|
|
66
|
+
/** Output a git child may produce before it counts as a failure (Node's default is 1 MiB). */
|
|
67
|
+
exports.GIT_MAX_BUFFER = 256 * 1024 * 1024;
|
|
68
|
+
/** How long a root whose git timed out is remembered as blocked. */
|
|
69
|
+
const BLOCKED_TTL_MS = 60_000;
|
|
70
|
+
const BLOCKED = new Map();
|
|
71
|
+
const keyOf = (root) => {
|
|
72
|
+
try {
|
|
73
|
+
return fs.realpathSync.native(root);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return path.resolve(root);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Whether a git child of this kind for `root` timed out within the last minute (every caller then answers
|
|
81
|
+
* "no signal" at once). The default kind is `worktree`, the one every timeout blocks.
|
|
82
|
+
*/
|
|
83
|
+
function gitRootBlocked(root, kind = 'worktree') {
|
|
84
|
+
const at = BLOCKED.get(keyOf(root))?.[kind];
|
|
85
|
+
return at !== undefined && Date.now() - at < BLOCKED_TTL_MS;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Records a git failure for `root` when it was a timeout (other failures are ordinary answers). The default
|
|
89
|
+
* kind is `worktree`: a caller that does not say is never allowed to silence the `repo` queries.
|
|
90
|
+
*/
|
|
91
|
+
function noteGitFailure(root, err, kind = 'worktree') {
|
|
92
|
+
const e = err;
|
|
93
|
+
if (e?.code !== 'ETIMEDOUT' && e?.error?.code !== 'ETIMEDOUT')
|
|
94
|
+
return;
|
|
95
|
+
const key = keyOf(root);
|
|
96
|
+
const now = Date.now();
|
|
97
|
+
const cur = BLOCKED.get(key) ?? {};
|
|
98
|
+
BLOCKED.set(key, kind === 'repo' ? { repo: now, worktree: now } : { ...cur, worktree: now });
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* @implements A-SPEC-734 (round 13) — one bounded git child that consults and feeds the memory: a blocked
|
|
102
|
+
* root answers at once with `status: null` and `error.code: 'EBLOCKED'`. The Stop hook's git children go
|
|
103
|
+
* through it (five of its call sites neither consulted nor fed the memory: `include.path` → FIFO took
|
|
104
|
+
* 27–32 s — measured).
|
|
105
|
+
*/
|
|
106
|
+
function gitOnce(root, args, kind, opts = {}) {
|
|
107
|
+
if (gitRootBlocked(root, kind)) {
|
|
108
|
+
const error = Object.assign(new Error(`git ${args[0] ?? ''}: not asked — a git child for this root timed out within the last minute`), { code: 'EBLOCKED' });
|
|
109
|
+
return { pid: 0, output: [null, '', ''], stdout: '', stderr: '', status: null, signal: null, error };
|
|
110
|
+
}
|
|
111
|
+
const env = gitEnv(opts.env ?? process.env);
|
|
112
|
+
const r = (0, node_child_process_1.spawnSync)('git', args, { cwd: opts.cwd ?? root, input: opts.input, encoding: 'utf8', timeout: opts.timeout ?? exports.GIT_TIMEOUT_MS, killSignal: 'SIGKILL',
|
|
113
|
+
maxBuffer: exports.GIT_MAX_BUFFER, windowsHide: true, env, stdio: [opts.input === undefined ? 'ignore' : 'pipe', 'pipe', 'pipe'] });
|
|
114
|
+
noteGitFailure(root, r, kind);
|
|
115
|
+
return r;
|
|
116
|
+
}
|
|
117
|
+
/** Test seam: forget every blocked root. */
|
|
118
|
+
function resetGitBlocked() { BLOCKED.clear(); }
|
|
119
|
+
/**
|
|
120
|
+
* A file read only when it is a REGULAR file: opened non-blocking, so a FIFO in its place returns at once
|
|
121
|
+
* instead of waiting for a writer, then refused with everything else that is not a regular file (a device
|
|
122
|
+
* such as `/dev/zero` included). Throws like `readFileSync` does, so callers keep their error handling.
|
|
123
|
+
*/
|
|
124
|
+
function readRegularFileSync(p) {
|
|
125
|
+
const flags = fs.constants.O_RDONLY | (typeof fs.constants.O_NONBLOCK === 'number' ? fs.constants.O_NONBLOCK : 0);
|
|
126
|
+
const fd = fs.openSync(p, flags);
|
|
127
|
+
try {
|
|
128
|
+
if (!fs.fstatSync(fd).isFile()) {
|
|
129
|
+
const err = new Error(`not a regular file: ${p}`);
|
|
130
|
+
err.code = 'EINVAL';
|
|
131
|
+
throw err;
|
|
132
|
+
}
|
|
133
|
+
return fs.readFileSync(fd);
|
|
134
|
+
}
|
|
135
|
+
finally {
|
|
136
|
+
fs.closeSync(fd);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/** `readRegularFileSync` as UTF-8 text. */
|
|
140
|
+
function readRegularTextSync(p) {
|
|
141
|
+
return readRegularFileSync(p).toString('utf8');
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* @implements A-SPEC-734 (round 16) — with `dir`, "no repository" is decided by the TREE: no `.git` entry in `dir` or
|
|
145
|
+
* any ancestor. Round 15 read git's English message — a translated git (Linux/Homebrew git under `LANG=ko_KR`) turned
|
|
146
|
+
* every non-git project into "did not answer", and `not a git repository: <gitdir>` (a submodule without its modules
|
|
147
|
+
* directory, a linked worktree whose main repository moved) read as "no repository" (measured).
|
|
148
|
+
*/
|
|
149
|
+
function gitAnswerOf(r, dir) {
|
|
150
|
+
const code = r.error?.code ?? (typeof r.code === 'string' ? r.code : undefined);
|
|
151
|
+
if (code === 'ENOENT')
|
|
152
|
+
return 'no-repository'; // no git
|
|
153
|
+
if (r.status === 0 && code === undefined)
|
|
154
|
+
return 'answered';
|
|
155
|
+
if (dir !== undefined)
|
|
156
|
+
return gitEntryAbove(dir) ? 'unanswered' : 'no-repository';
|
|
157
|
+
const stderr = typeof r.stderr === 'string' ? r.stderr : Buffer.isBuffer(r.stderr) ? r.stderr.toString('utf8') : '';
|
|
158
|
+
if (/not a git repository/i.test(stderr))
|
|
159
|
+
return 'no-repository';
|
|
160
|
+
return 'unanswered';
|
|
161
|
+
}
|
|
162
|
+
/** Whether `dir` or an ancestor holds a `.git` entry (file, directory or link) — the tree's own answer to "is this a repository". */
|
|
163
|
+
function gitEntryAbove(dir) {
|
|
164
|
+
let d = path.resolve(dir);
|
|
165
|
+
for (;;) {
|
|
166
|
+
try {
|
|
167
|
+
fs.lstatSync(path.join(d, '.git'));
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
catch { /* none here */ }
|
|
171
|
+
const parent = path.dirname(d);
|
|
172
|
+
if (parent === d)
|
|
173
|
+
return false;
|
|
174
|
+
d = parent;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* @implements A-SPEC-734 (round 16) — the variables that relocate the repository a git child reads. An exported
|
|
179
|
+
* dotfiles `GIT_DIR` made the rm gate judge the project by that repository (measured).
|
|
180
|
+
*/
|
|
181
|
+
exports.REPO_LOCATING_GIT_VARS = ['GIT_DIR', 'GIT_WORK_TREE', 'GIT_INDEX_FILE', 'GIT_COMMON_DIR', 'GIT_OBJECT_DIRECTORY',
|
|
182
|
+
'GIT_ALTERNATE_OBJECT_DIRECTORIES', 'GIT_NAMESPACE', 'GIT_CEILING_DIRECTORIES', 'GIT_DISCOVERY_ACROSS_FILESYSTEM'];
|
|
183
|
+
/**
|
|
184
|
+
* @implements A-SPEC-734 (round 17) — `full` (a porcelain path from the repository root) relative to the project whose
|
|
185
|
+
* `rev-parse --show-prefix` is `prefix`, compared segment by segment NFC and case-folded; null when it lies elsewhere.
|
|
186
|
+
* A `-- .` pathspec is matched case-sensitively by git, so a package whose directory case differs between the index and
|
|
187
|
+
* a case-folding disk read clean (measured).
|
|
188
|
+
*/
|
|
189
|
+
function underGitPrefix(full, prefix) {
|
|
190
|
+
const want = prefix.split('/').filter((p) => p !== '');
|
|
191
|
+
if (want.length === 0)
|
|
192
|
+
return full;
|
|
193
|
+
const have = full.split('/');
|
|
194
|
+
if (have.length <= want.length)
|
|
195
|
+
return null;
|
|
196
|
+
const fold = (p) => p.normalize('NFC').toUpperCase();
|
|
197
|
+
for (let i = 0; i < want.length; i++)
|
|
198
|
+
if (fold(have[i]) !== fold(want[i]))
|
|
199
|
+
return null;
|
|
200
|
+
return have.slice(want.length).join('/');
|
|
201
|
+
}
|
|
202
|
+
/** A git child's environment: the caller's, without the variables that relocate the repository (round 17). */
|
|
203
|
+
function gitEnv(env = process.env) {
|
|
204
|
+
const out = { ...env };
|
|
205
|
+
for (const k of exports.REPO_LOCATING_GIT_VARS)
|
|
206
|
+
delete out[k];
|
|
207
|
+
return out;
|
|
208
|
+
}
|
|
209
|
+
/** Whether a failed git answer means "not judged" rather than "no repository" (round 15: a refusal is not judged too). */
|
|
210
|
+
function gitUnanswered(r, dir) {
|
|
211
|
+
return gitAnswerOf(r, dir) === 'unanswered';
|
|
212
|
+
}
|
|
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.EMPTY_CHANGE_SET = exports.GitChangeSource = exports.SnapshotChangeSource = exports.hashOf = exports.isDerivedState = void 0;
|
|
37
37
|
exports.hashTree = hashTree;
|
|
38
38
|
exports.diffHashes = diffHashes;
|
|
39
|
-
// @implements A-SPEC-128
|
|
39
|
+
// @implements A-SPEC-128, A-SPEC-734
|
|
40
40
|
const fs = __importStar(require("node:fs"));
|
|
41
41
|
const path = __importStar(require("node:path"));
|
|
42
42
|
const node_crypto_1 = require("node:crypto");
|
|
@@ -89,6 +89,8 @@ function hashTree(root, opts = {}) {
|
|
|
89
89
|
if (cpg_scanner_1.SKIP.has(e.name))
|
|
90
90
|
continue;
|
|
91
91
|
const abs = path.join(dir, e.name);
|
|
92
|
+
if (e.isDirectory() && (0, cpg_scanner_1.isNestedWorkTree)(abs, root))
|
|
93
|
+
continue; // A-SPEC-734: another repository
|
|
92
94
|
const rel = path.relative(root, abs).split(path.sep).join('/');
|
|
93
95
|
if ((0, exports.isDerivedState)(`${rel}${e.isDirectory() ? '/' : ''}`) || opts.isIgnored?.(rel))
|
|
94
96
|
continue;
|
|
@@ -38,7 +38,7 @@ exports.readCiRuns = readCiRuns;
|
|
|
38
38
|
exports.latestCiRun = latestCiRun;
|
|
39
39
|
exports.ciVerdict = ciVerdict;
|
|
40
40
|
exports.ciStatusLine = ciStatusLine;
|
|
41
|
-
// @implements A-SPEC-664
|
|
41
|
+
// @implements A-SPEC-664, A-SPEC-734
|
|
42
42
|
/**
|
|
43
43
|
* The CI-runs ledger reader — the product side of the minimal Linux matrix.
|
|
44
44
|
*
|
|
@@ -50,6 +50,7 @@ exports.ciStatusLine = ciStatusLine;
|
|
|
50
50
|
*/
|
|
51
51
|
const fs = __importStar(require("node:fs"));
|
|
52
52
|
const path = __importStar(require("node:path"));
|
|
53
|
+
const bounded_io_1 = require("./bounded-io");
|
|
53
54
|
const FILE_RE = /^ci-runs\.([^.]+)\.jsonl$/;
|
|
54
55
|
/**
|
|
55
56
|
* @implements A-SPEC-664 — the ADOPTION predicate: does this workspace use the CI matrix at all?
|
|
@@ -82,7 +83,7 @@ function readCiRuns(root) {
|
|
|
82
83
|
for (const n of names) {
|
|
83
84
|
let text;
|
|
84
85
|
try {
|
|
85
|
-
text =
|
|
86
|
+
text = (0, bounded_io_1.readRegularTextSync)(path.join(dir, n));
|
|
86
87
|
}
|
|
87
88
|
catch {
|
|
88
89
|
continue;
|
|
@@ -28,6 +28,35 @@ export interface IgnoreMatcher {
|
|
|
28
28
|
/** Format-level limits of this implementation, stated so a caller never has to infer them. */
|
|
29
29
|
limitations(): string[];
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
/** The cap on a `.gitignore` the matcher reads (round 12: a planted 2 MB file cost 1.6 s per path). */
|
|
32
|
+
export declare const IGNORE_FILE_CAP: number;
|
|
33
|
+
/** The most distinct rules a `.gitignore` may carry before none apply (round 13: bounded work per path). */
|
|
34
|
+
export declare const IGNORE_RULES_CAP = 10000;
|
|
35
|
+
/**
|
|
36
|
+
* The most pattern tokens one path's candidate rules may carry (round 13). The walk is O(tokens × path
|
|
37
|
+
* length) per candidate; a planted file of 10,000 rules sharing one literal cost 25 s over 600 paths
|
|
38
|
+
* (measured). Over the budget the path is treated as NOT ignored — every consumer skips ignored files,
|
|
39
|
+
* so the answer errs toward scanning more, never toward hiding — and the matcher reports it.
|
|
40
|
+
*/
|
|
41
|
+
export declare const IGNORE_PATH_TOKENS_BUDGET = 4000;
|
|
42
|
+
export declare function parseIgnore(content: string, extraUnsupported?: string[]): IgnoreMatcher;
|
|
43
|
+
/**
|
|
44
|
+
* Load the project-root `.gitignore`. A missing file ignores nothing.
|
|
45
|
+
* @implements A-SPEC-733 (round 12) — a non-blocking read of a REGULAR file at most 2 MB: a FIFO named
|
|
46
|
+
* `.gitignore` blocked every act that loads the file forever (measured); over the cap the file yields no
|
|
47
|
+
* rules and `unsupportedPatterns` names the size — toward scanning more, never less.
|
|
48
|
+
*/
|
|
33
49
|
export declare function loadIgnore(root: string): IgnoreMatcher;
|
|
50
|
+
/**
|
|
51
|
+
* @implements A-SPEC-733 (round 12) / A-SPEC-734 (round 10) — the project-root `.gitignore` read
|
|
52
|
+
* non-blocking, as a REGULAR file, at most 2 MiB: a FIFO there blocked every reader forever (measured,
|
|
53
|
+
* `loadIgnore` and `planSourceRenumber`). `bytes` is null with a reason: `missing`, `not a regular
|
|
54
|
+
* file`, `unreadable`, or the size refusal.
|
|
55
|
+
*/
|
|
56
|
+
export declare function readIgnoreFileSafely(root: string): {
|
|
57
|
+
bytes: Buffer;
|
|
58
|
+
reason: '';
|
|
59
|
+
} | {
|
|
60
|
+
bytes: null;
|
|
61
|
+
reason: string;
|
|
62
|
+
};
|