@holmes-lab/holmes-kit 0.30.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 +494 -0
- package/README.md +10 -1
- 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.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 +35 -0
- package/dist/holmes/cli/codex-toml.js +321 -52
- package/dist/holmes/cli/doctor.d.ts +98 -8
- package/dist/holmes/cli/doctor.js +1328 -94
- package/dist/holmes/cli/index.js +23 -11
- package/dist/holmes/cli/init.d.ts +11 -0
- package/dist/holmes/cli/init.js +736 -44
- 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/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/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.js +3 -1
- package/dist/holmes/hooks/rtm-refresh.js +8 -4
- 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-commit.d.ts +5 -6
- package/dist/holmes/mcp/approval-commit.js +18 -2
- package/dist/holmes/mcp/elicit-approval.js +4 -2
- package/dist/holmes/mcp/handlers/graph-operations.js +3 -2
- 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.js +5 -3
- package/dist/holmes/mcp/handlers/review-evidence.js +8 -2
- package/dist/holmes/mcp/handlers/slice-orchestration.d.ts +11 -0
- package/dist/holmes/mcp/handlers/slice-orchestration.js +115 -16
- package/dist/holmes/mcp/handlers/spec-approval.d.ts +9 -0
- package/dist/holmes/mcp/handlers/spec-approval.js +110 -17
- package/dist/holmes/mcp/handlers/spec-authoring.js +17 -2
- 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 +81 -9
- package/dist/holmes/mcp/handlers.js +70 -23
- package/dist/holmes/mcp/harness-attestation.d.ts +20 -0
- package/dist/holmes/mcp/harness-attestation.js +179 -0
- package/dist/holmes/mcp/requirement-triage-evidence.d.ts +36 -0
- package/dist/holmes/mcp/requirement-triage-evidence.js +160 -4
- package/dist/holmes/mcp/server.js +20 -1
- package/dist/holmes/mcp/tool-schemas.js +26 -9
- 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/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.js +3 -2
- 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/run-replay.js +3 -2
- package/dist/holmes/review/temporal-prior.js +3 -2
- package/dist/holmes/review/test-evidence.js +3 -2
- package/dist/holmes/review/test-outcomes.js +3 -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
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare function workspaceRoots(realTarget: string): string[];
|
|
2
|
+
/**
|
|
3
|
+
* @implements A-SPEC-251.2 (round 34) — a real path is the workspace's when it lies under a workspace root, or when a
|
|
4
|
+
* directory above it holds a `.git` whose common git directory is (or lies under — a submodule's `modules/`) the common git
|
|
5
|
+
* directory of a workspace repository: round 33 listed `worktrees/` and kept the first 64 (the 65th sibling's wrapper ran
|
|
6
|
+
* and passed), re-reading the listing for every `.git` file (200,000 entries: 88 s — measured).
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @implements A-SPEC-251.2 (round 51) — whether the target is the home directory or lies above it (a dotfiles repository
|
|
10
|
+
* taken as the target): every install under home (nvm, volta) is then "inside the workspace", so a `node` found through an
|
|
11
|
+
* ABSOLUTE PATH entry is not read as the workspace's there (an untouched canonical wiring read FAIL three times — measured).
|
|
12
|
+
*/
|
|
13
|
+
export declare function targetHoldsHome(realTarget: string): boolean;
|
|
14
|
+
export declare function inWorkspace(realTarget: string, real: string): boolean;
|
|
15
|
+
export declare const REMOTE_GIT = "\0remote";
|
|
16
|
+
/**
|
|
17
|
+
* The common git directory of the repository whose `.git` sits in `dir`, `REMOTE_GIT` when it names a network path, or null.
|
|
18
|
+
* Round 35: a symlinked `.git` is followed (a `repo`-tool main checkout's wrapper ran — measured); `.git`, `commondir` and
|
|
19
|
+
* `gitdir` files are read to 64 KiB (four 2 GB `.git` files took 12.5 s — measured).
|
|
20
|
+
*/
|
|
21
|
+
export declare function commonGitDirAt(dir: string): string | null;
|
|
22
|
+
export declare function isWithin(root: string, p: string): boolean;
|
|
@@ -0,0 +1,375 @@
|
|
|
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.REMOTE_GIT = void 0;
|
|
37
|
+
exports.workspaceRoots = workspaceRoots;
|
|
38
|
+
exports.targetHoldsHome = targetHoldsHome;
|
|
39
|
+
exports.inWorkspace = inWorkspace;
|
|
40
|
+
exports.commonGitDirAt = commonGitDirAt;
|
|
41
|
+
exports.isWithin = isWithin;
|
|
42
|
+
// @implements A-SPEC-251.2
|
|
43
|
+
// The workspace a wiring must not run a program from — shared by doctor and init (round 50: init judged by the target
|
|
44
|
+
// alone). Moved here from doctor.ts unchanged, so that init can use it without importing doctor (doctor imports init).
|
|
45
|
+
const fs = __importStar(require("node:fs"));
|
|
46
|
+
const os = __importStar(require("node:os"));
|
|
47
|
+
const path = __importStar(require("node:path"));
|
|
48
|
+
const codex_oracle_1 = require("./codex-oracle");
|
|
49
|
+
const claude_switches_1 = require("./claude-switches");
|
|
50
|
+
const ROOTS_MEMO = new Map();
|
|
51
|
+
function workspaceOf(realTarget) {
|
|
52
|
+
// Round 33: once per target within a doctor run, each directory walked once (`.git` files naming one `.git`-less
|
|
53
|
+
// directory made the walk (m+1)^8: 11 s at 3 levels, 66 s at 4 — measured).
|
|
54
|
+
const hit = ROOTS_MEMO.get(realTarget);
|
|
55
|
+
if (hit !== undefined && Date.now() - hit.at < 5000)
|
|
56
|
+
return hit.ws;
|
|
57
|
+
const ws = workspaceUncached(realTarget);
|
|
58
|
+
ROOTS_MEMO.set(realTarget, { at: Date.now(), ws });
|
|
59
|
+
return ws;
|
|
60
|
+
}
|
|
61
|
+
function workspaceRoots(realTarget) { return workspaceOf(realTarget).roots; }
|
|
62
|
+
/**
|
|
63
|
+
* @implements A-SPEC-251.2 (round 34) — a real path is the workspace's when it lies under a workspace root, or when a
|
|
64
|
+
* directory above it holds a `.git` whose common git directory is (or lies under — a submodule's `modules/`) the common git
|
|
65
|
+
* directory of a workspace repository: round 33 listed `worktrees/` and kept the first 64 (the 65th sibling's wrapper ran
|
|
66
|
+
* and passed), re-reading the listing for every `.git` file (200,000 entries: 88 s — measured).
|
|
67
|
+
*/
|
|
68
|
+
/**
|
|
69
|
+
* @implements A-SPEC-251.2 (round 51) — whether the target is the home directory or lies above it (a dotfiles repository
|
|
70
|
+
* taken as the target): every install under home (nvm, volta) is then "inside the workspace", so a `node` found through an
|
|
71
|
+
* ABSOLUTE PATH entry is not read as the workspace's there (an untouched canonical wiring read FAIL three times — measured).
|
|
72
|
+
*/
|
|
73
|
+
function targetHoldsHome(realTarget) {
|
|
74
|
+
const home = (() => { try {
|
|
75
|
+
return fs.realpathSync.native(process.platform !== 'win32' && process.env.HOME ? process.env.HOME : os.homedir());
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return '';
|
|
79
|
+
} })();
|
|
80
|
+
return home !== '' && (home === realTarget || isWithin(realTarget, home));
|
|
81
|
+
}
|
|
82
|
+
function inWorkspace(realTarget, real) {
|
|
83
|
+
const ws = workspaceOf(realTarget);
|
|
84
|
+
if (ws.roots.some((r) => isWithin(r, real)))
|
|
85
|
+
return true;
|
|
86
|
+
if (ws.commons.length === 0)
|
|
87
|
+
return false;
|
|
88
|
+
for (let d = real, i = 0; i < 256; i++) {
|
|
89
|
+
const c = commonGitDirAt(d);
|
|
90
|
+
// Round 35: a `.git` naming a network path cannot be checked — it is read as the workspace's (never run).
|
|
91
|
+
if (c === exports.REMOTE_GIT)
|
|
92
|
+
return true;
|
|
93
|
+
if (c !== null && ws.commons.some((w) => isWithin(w, c)))
|
|
94
|
+
return true;
|
|
95
|
+
const parent = path.dirname(d);
|
|
96
|
+
if (parent === d)
|
|
97
|
+
break;
|
|
98
|
+
d = parent;
|
|
99
|
+
}
|
|
100
|
+
// @implements A-SPEC-251.2 (round 35) — a worktree the common directory lists whose own `.git` file is gone (round 34
|
|
101
|
+
// dropped the listing and its wrapper ran — measured): read once per common directory, only here.
|
|
102
|
+
for (const c of ws.commons) {
|
|
103
|
+
const listed = listedWorktrees(c);
|
|
104
|
+
if (listed === null || listed.some((w) => isWithin(w, real)))
|
|
105
|
+
return true;
|
|
106
|
+
// Round 36: what the text does not match is walked within one budget (4,096 entries naming a 428-level directory took
|
|
107
|
+
// 44 s — measured); past it the path is read as the workspace's.
|
|
108
|
+
const resolved = resolvedWorktrees(c, listed);
|
|
109
|
+
if (resolved === null || resolved.some((w) => isWithin(w, real)))
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
exports.REMOTE_GIT = '\u0000remote';
|
|
115
|
+
/**
|
|
116
|
+
* The common git directory of the repository whose `.git` sits in `dir`, `REMOTE_GIT` when it names a network path, or null.
|
|
117
|
+
* Round 35: a symlinked `.git` is followed (a `repo`-tool main checkout's wrapper ran — measured); `.git`, `commondir` and
|
|
118
|
+
* `gitdir` files are read to 64 KiB (four 2 GB `.git` files took 12.5 s — measured).
|
|
119
|
+
*/
|
|
120
|
+
function commonGitDirAt(dir) {
|
|
121
|
+
const gitPath = path.join(dir, '.git');
|
|
122
|
+
let st;
|
|
123
|
+
try {
|
|
124
|
+
st = fs.lstatSync(gitPath);
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
let file = gitPath;
|
|
130
|
+
if (st.isSymbolicLink()) {
|
|
131
|
+
const walked = (0, claude_switches_1.localPhysicalRealpath)(gitPath);
|
|
132
|
+
if (walked.refused)
|
|
133
|
+
return exports.REMOTE_GIT;
|
|
134
|
+
if (walked.path === null)
|
|
135
|
+
return null;
|
|
136
|
+
try {
|
|
137
|
+
st = fs.statSync(walked.path);
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
if (st.isDirectory())
|
|
143
|
+
return walked.path;
|
|
144
|
+
file = walked.path;
|
|
145
|
+
}
|
|
146
|
+
else if (st.isDirectory()) {
|
|
147
|
+
try {
|
|
148
|
+
return fs.realpathSync.native(gitPath);
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return gitPath;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (!st.isFile())
|
|
155
|
+
return null;
|
|
156
|
+
const m = /^gitdir:[ \t]*(.+?)[ \t]*$/m.exec((0, claude_switches_1.readFileHead)(file) ?? '');
|
|
157
|
+
if (m === null)
|
|
158
|
+
return null;
|
|
159
|
+
const asWritten = path.resolve(dir, m[1]);
|
|
160
|
+
if (!(0, codex_oracle_1.openableLocalPath)(asWritten))
|
|
161
|
+
return exports.REMOTE_GIT;
|
|
162
|
+
// Round 36: walked before it is read (`gitdir: lnk/wt/.git/…` with `lnk -> /net/…` opened `commondir` — measured).
|
|
163
|
+
const walkedGitdir = (0, claude_switches_1.localPhysicalRealpath)(asWritten);
|
|
164
|
+
if (walkedGitdir.refused)
|
|
165
|
+
return exports.REMOTE_GIT;
|
|
166
|
+
const gitdir = walkedGitdir.path ?? asWritten;
|
|
167
|
+
// Round 37: the `commondir` file is walked too (a link into /net was opened — measured).
|
|
168
|
+
const commondirFile = walkedGitdir.path === null ? null : (0, claude_switches_1.localPhysicalRealpath)(path.join(gitdir, 'commondir'));
|
|
169
|
+
if (commondirFile?.refused)
|
|
170
|
+
return exports.REMOTE_GIT;
|
|
171
|
+
const commondir = commondirFile?.path ? (0, claude_switches_1.readFileHead)(commondirFile.path) : null;
|
|
172
|
+
const common = commondir === null ? gitdir : path.resolve(gitdir, commondir.trim());
|
|
173
|
+
if (!(0, codex_oracle_1.openableLocalPath)(common))
|
|
174
|
+
return exports.REMOTE_GIT;
|
|
175
|
+
const walked = (0, claude_switches_1.localPhysicalRealpath)(common);
|
|
176
|
+
return walked.refused ? exports.REMOTE_GIT : walked.path ?? common;
|
|
177
|
+
}
|
|
178
|
+
const LISTED_MEMO = new Map();
|
|
179
|
+
/**
|
|
180
|
+
* The checkouts each `<common>/worktrees/<id>/gitdir` names, as written (null past 4,096 entries, or when the `worktrees`
|
|
181
|
+
* directory reaches a network path: read as the workspace's). Round 36: the directory is walked before it is listed (a
|
|
182
|
+
* `worktrees -> /net/…` link was listed — measured).
|
|
183
|
+
*/
|
|
184
|
+
function listedWorktrees(common) {
|
|
185
|
+
const hit = LISTED_MEMO.get(common);
|
|
186
|
+
if (hit !== undefined && Date.now() - hit.at < 5000)
|
|
187
|
+
return hit.dirs;
|
|
188
|
+
const at = (0, claude_switches_1.localPhysicalRealpath)(path.join(common, 'worktrees'));
|
|
189
|
+
let dirs = [];
|
|
190
|
+
if (at.refused)
|
|
191
|
+
dirs = null;
|
|
192
|
+
else if (at.path !== null) {
|
|
193
|
+
let ids = [];
|
|
194
|
+
try {
|
|
195
|
+
ids = fs.readdirSync(at.path);
|
|
196
|
+
}
|
|
197
|
+
catch { /* none */ }
|
|
198
|
+
if (ids.length > 4096)
|
|
199
|
+
dirs = null;
|
|
200
|
+
else {
|
|
201
|
+
// Round 38: a plain entry and `gitdir` file cost two look-ups; only a link is walked, within 20,000 components for the
|
|
202
|
+
// whole list (4,096 entries linked to 428-level directories took 53 s — measured, a round-37 regression), past which
|
|
203
|
+
// the list is read as the workspace's.
|
|
204
|
+
const budget = { left: 20_000 };
|
|
205
|
+
for (const id of ids) {
|
|
206
|
+
// Round 37: the entry and its `gitdir` file are walked too (links into /net were opened — measured).
|
|
207
|
+
const gd = path.join(at.path, id, 'gitdir');
|
|
208
|
+
let fileAt = null;
|
|
209
|
+
try {
|
|
210
|
+
budget.left -= 2;
|
|
211
|
+
if (!fs.lstatSync(path.join(at.path, id)).isSymbolicLink() && fs.lstatSync(gd).isFile())
|
|
212
|
+
fileAt = gd;
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (budget.left < 0) {
|
|
218
|
+
dirs = null;
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
if (fileAt === null) {
|
|
222
|
+
const file = (0, claude_switches_1.localPhysicalRealpath)(gd, budget);
|
|
223
|
+
if (file.exhausted) {
|
|
224
|
+
dirs = null;
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
if (file.refused || file.path === null)
|
|
228
|
+
continue;
|
|
229
|
+
fileAt = file.path;
|
|
230
|
+
}
|
|
231
|
+
const g = (0, claude_switches_1.readFileHead)(fileAt)?.trim();
|
|
232
|
+
if (g === undefined || g === '')
|
|
233
|
+
continue;
|
|
234
|
+
const w = path.dirname(path.resolve(at.path, id, g));
|
|
235
|
+
if ((0, codex_oracle_1.openableLocalPath)(w))
|
|
236
|
+
dirs.push(w);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
LISTED_MEMO.set(common, { at: Date.now(), dirs });
|
|
241
|
+
return dirs;
|
|
242
|
+
}
|
|
243
|
+
const RESOLVED_MEMO = new Map();
|
|
244
|
+
/** The same checkouts' real paths, all walked within 20,000 components in total (null past the budget or on a network path). */
|
|
245
|
+
function resolvedWorktrees(common, listed) {
|
|
246
|
+
const hit = RESOLVED_MEMO.get(common);
|
|
247
|
+
if (hit !== undefined && Date.now() - hit.at < 5000)
|
|
248
|
+
return hit.dirs;
|
|
249
|
+
// Round 37: each parent directory is walked once (siblings share it — 1,250 worktrees ran out of the budget and every node
|
|
250
|
+
// wiring read FAIL, a round-36 regression, measured); an entry on a network path drops only itself.
|
|
251
|
+
const budget = { left: 20_000 };
|
|
252
|
+
const parents = new Map();
|
|
253
|
+
let dirs = [];
|
|
254
|
+
for (const w of listed) {
|
|
255
|
+
const parent = path.dirname(w);
|
|
256
|
+
let real = parents.get(parent);
|
|
257
|
+
if (real === undefined) {
|
|
258
|
+
const walked = (0, claude_switches_1.localPhysicalRealpath)(parent, budget);
|
|
259
|
+
if (walked.exhausted) {
|
|
260
|
+
dirs = null;
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
real = walked.path;
|
|
264
|
+
parents.set(parent, real);
|
|
265
|
+
}
|
|
266
|
+
if (real === null)
|
|
267
|
+
continue;
|
|
268
|
+
// Only the last component is new: a link there is walked in full.
|
|
269
|
+
const full = path.join(real, path.basename(w));
|
|
270
|
+
if (--budget.left < 0) {
|
|
271
|
+
dirs = null;
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
let st;
|
|
275
|
+
try {
|
|
276
|
+
st = fs.lstatSync(full);
|
|
277
|
+
}
|
|
278
|
+
catch {
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
if (!st.isSymbolicLink()) {
|
|
282
|
+
dirs.push(full);
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
const walked = (0, claude_switches_1.localPhysicalRealpath)(full, budget);
|
|
286
|
+
if (walked.exhausted) {
|
|
287
|
+
dirs = null;
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
if (walked.path !== null)
|
|
291
|
+
dirs.push(walked.path);
|
|
292
|
+
}
|
|
293
|
+
RESOLVED_MEMO.set(common, { at: Date.now(), dirs });
|
|
294
|
+
return dirs;
|
|
295
|
+
}
|
|
296
|
+
function workspaceUncached(realTarget) {
|
|
297
|
+
// Round 32: every repository around the target (below the home directory), and the repository that owns a `.git` FILE
|
|
298
|
+
// — a submodule's or a linked worktree's — followed through its `gitdir:` (the owning, enclosing or main checkout's
|
|
299
|
+
// wrapper, spelled as a known absolute path, ran and passed — measured).
|
|
300
|
+
// `$HOME` as os.homedir() reads it on POSIX, from this process's environment.
|
|
301
|
+
const home = (() => { try {
|
|
302
|
+
return fs.realpathSync.native(process.platform !== 'win32' && process.env.HOME ? process.env.HOME : os.homedir());
|
|
303
|
+
}
|
|
304
|
+
catch {
|
|
305
|
+
return '';
|
|
306
|
+
} })();
|
|
307
|
+
const atOrAboveHome = (d) => home !== '' && (d === home || isWithin(d, home));
|
|
308
|
+
const roots = new Set([realTarget]);
|
|
309
|
+
const commons = new Set();
|
|
310
|
+
// Round 34: a common git directory counts unless its checkout is the home directory or above it (round 33 added a home
|
|
311
|
+
// dotfiles repository as an owner: nvm's node under home read FAIL — measured, a regression).
|
|
312
|
+
const addCommon = (d) => {
|
|
313
|
+
const c = commonGitDirAt(d);
|
|
314
|
+
if (c === null || c === exports.REMOTE_GIT)
|
|
315
|
+
return;
|
|
316
|
+
if (path.basename(c) === '.git' && atOrAboveHome(path.dirname(c)))
|
|
317
|
+
return;
|
|
318
|
+
commons.add(c);
|
|
319
|
+
};
|
|
320
|
+
const walked = new Set();
|
|
321
|
+
const visit = (start, depth) => {
|
|
322
|
+
for (let d = start;;) {
|
|
323
|
+
if (walked.has(d) || walked.size > 4096)
|
|
324
|
+
return;
|
|
325
|
+
walked.add(d);
|
|
326
|
+
if (atOrAboveHome(d))
|
|
327
|
+
return;
|
|
328
|
+
let st = null;
|
|
329
|
+
try {
|
|
330
|
+
st = fs.lstatSync(path.join(d, '.git'));
|
|
331
|
+
}
|
|
332
|
+
catch { /* none here */ }
|
|
333
|
+
if (st !== null) {
|
|
334
|
+
roots.add(d);
|
|
335
|
+
addCommon(d);
|
|
336
|
+
if (st.isFile() && depth < 8)
|
|
337
|
+
for (const owner of gitdirOwners(d)) {
|
|
338
|
+
if (atOrAboveHome(owner))
|
|
339
|
+
continue;
|
|
340
|
+
roots.add(owner);
|
|
341
|
+
visit(owner, depth + 1);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
const parent = path.dirname(d);
|
|
345
|
+
if (parent === d)
|
|
346
|
+
return;
|
|
347
|
+
d = parent;
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
visit(realTarget, 0);
|
|
351
|
+
return { roots: [...roots], commons: [...commons] };
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* The checkout a `.git` file shares a repository with: the parent of the `.git` directory its `gitdir:` points into (a
|
|
355
|
+
* submodule's super-repository, a worktree's main checkout). Round 34: sibling worktrees are found by their common git
|
|
356
|
+
* directory (`inWorkspace`), not by listing `worktrees/`.
|
|
357
|
+
*/
|
|
358
|
+
function gitdirOwners(dir) {
|
|
359
|
+
const c = commonGitDirAt(dir);
|
|
360
|
+
if (c === null || c === exports.REMOTE_GIT)
|
|
361
|
+
return [];
|
|
362
|
+
for (let d = c, i = 0; i < 64; i++) {
|
|
363
|
+
if (path.basename(d) === '.git')
|
|
364
|
+
return [path.dirname(d)];
|
|
365
|
+
const parent = path.dirname(d);
|
|
366
|
+
if (parent === d)
|
|
367
|
+
break;
|
|
368
|
+
d = parent;
|
|
369
|
+
}
|
|
370
|
+
return [];
|
|
371
|
+
}
|
|
372
|
+
function isWithin(root, p) {
|
|
373
|
+
const rel = path.relative(root, p);
|
|
374
|
+
return rel === '' || (rel !== '..' && !rel.startsWith('..' + path.sep) && !path.isAbsolute(rel));
|
|
375
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
1
2
|
import { LanguageParser } from './language-parser';
|
|
2
3
|
import type { ScannedFile } from './scanned-file';
|
|
3
4
|
export type { ScannedFile } from './scanned-file';
|
|
@@ -37,6 +38,34 @@ export declare const SKIP: Set<string>;
|
|
|
37
38
|
* as a test AND gated as production at the same time.
|
|
38
39
|
*/
|
|
39
40
|
export declare function isUnderSkippedDir(p: unknown): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Evidence-based virtualenv detection. A Python virtualenv is defined by containing `pyvenv.cfg`,
|
|
43
|
+
* whatever the user named the directory (`env`, `.env311`, `myproject-venv`, …), so name matching
|
|
44
|
+
* alone misses them. Checking for the marker file is precise: no real source tree has one at its
|
|
45
|
+
* root. Same idea for a vendored `site-packages` nested under an unconventionally named env.
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* @implements A-SPEC-734 — a directory holding its own `.git` (a file for a worktree or submodule, a
|
|
49
|
+
* directory for a nested clone) is another repository's working tree, not this project's source.
|
|
50
|
+
* Measured: four agent worktrees under .claude/worktrees made the graph 2,293 files instead of 639.
|
|
51
|
+
*/
|
|
52
|
+
export declare function isNestedWorkTree(dir: string, root?: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* @implements A-SPEC-734 (round 15/16/17) — directories holding `.git` whose nesting git could not answer (the root is
|
|
55
|
+
* a repository, but its worktree list, tracked listing or ignored listing did not answer). Round 17: they are SKIPPED
|
|
56
|
+
* by every walker and recorded here (round 16 walked them, and `entity_renumber` planned a registered worktree's
|
|
57
|
+
* files, test_run's scope took its tests and a link into it carried its marker into ART-9 — measured). What was not
|
|
58
|
+
* walked is not judged: `ci` fails, `attest` says `+unknown` and the Stop hook names them (round 15 skipped them
|
|
59
|
+
* silently, and `ci` read 100% — measured). Real paths, per process; `unverifiedUnder` reads one root's.
|
|
60
|
+
*/
|
|
61
|
+
export declare const UNVERIFIED_NESTED: Set<string>;
|
|
62
|
+
/** The recorded unverified directories under `root` (real paths), after `forgetUnverifiedUnder(root)` and a walk. */
|
|
63
|
+
export declare function unverifiedUnder(root: string): string[];
|
|
64
|
+
/** Forget the records under `root` before a walk that reads them (a long-lived process keeps no stale answer). */
|
|
65
|
+
export declare function forgetUnverifiedUnder(root: string): void;
|
|
66
|
+
/** Whether `file` lies under a directory recorded as unverified nesting. */
|
|
67
|
+
export declare function underUnverifiedNesting(file: string): boolean;
|
|
68
|
+
export declare function isRegularSource(entry: fs.Dirent, abs: string, root: string): boolean;
|
|
40
69
|
/** Single source of truth for which file extensions CpgScanner ingests (REQ-124 gate 2). */
|
|
41
70
|
/**
|
|
42
71
|
* Extension -> grammar. Exported because a SECOND consumer now reads data flow (the def-use symbol
|