@holmes-lab/holmes-kit 0.30.0 → 0.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +505 -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 +26 -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 +18 -0
- package/dist/holmes/cli/upgrade.js +129 -24
- 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.d.ts +5 -0
- package/dist/holmes/update/refresh.js +26 -1
- package/dist/holmes/update/update-notice.d.ts +6 -0
- package/dist/holmes/update/update-notice.js +18 -1
- package/dist/holmes/update/upgrade-plan.d.ts +28 -0
- package/dist/holmes/update/upgrade-plan.js +31 -2
- package/package.json +11 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface AgyPreDecision {
|
|
2
|
-
decision: 'allow' | 'deny';
|
|
2
|
+
decision: 'allow' | 'deny' | 'ask';
|
|
3
3
|
reason?: string;
|
|
4
4
|
}
|
|
5
5
|
export interface AgyStopDecision {
|
|
@@ -21,6 +21,8 @@ export declare const TOOL_MAP: Record<string, {
|
|
|
21
21
|
pathArg?: string;
|
|
22
22
|
contentArg?: string;
|
|
23
23
|
commandArg?: string;
|
|
24
|
+
oldArg?: string;
|
|
25
|
+
allArg?: string;
|
|
24
26
|
}>;
|
|
25
27
|
/** 훅을 실행해 그 표준 출력을 돌려준다. 실행 자체가 실패하면 `null`(호출자가 닫는 쪽으로 받는다). */
|
|
26
28
|
export type HookRunner = (hookPath: string, payload: string, cwd: string) => Record<string, unknown> | null;
|
|
@@ -37,9 +37,11 @@ exports.TOOL_MAP = void 0;
|
|
|
37
37
|
exports.adaptPreToolUse = adaptPreToolUse;
|
|
38
38
|
exports.adaptStop = adaptStop;
|
|
39
39
|
// @implements A-SPEC-193
|
|
40
|
+
// @implements A-SPEC-734
|
|
40
41
|
const fs = __importStar(require("node:fs"));
|
|
41
42
|
const path = __importStar(require("node:path"));
|
|
42
43
|
const node_child_process_1 = require("node:child_process");
|
|
44
|
+
const bounded_io_1 = require("../../project/bounded-io");
|
|
43
45
|
/**
|
|
44
46
|
* 실측한 도구만 등재한다.
|
|
45
47
|
*
|
|
@@ -53,7 +55,7 @@ const node_child_process_1 = require("node:child_process");
|
|
|
53
55
|
exports.TOOL_MAP = {
|
|
54
56
|
run_command: { as: 'Bash', commandArg: 'CommandLine' },
|
|
55
57
|
write_to_file: { as: 'Write', pathArg: 'TargetFile', contentArg: 'CodeContent' },
|
|
56
|
-
replace_file_content: { as: 'Edit', pathArg: 'TargetFile', contentArg: 'ReplacementContent' },
|
|
58
|
+
replace_file_content: { as: 'Edit', pathArg: 'TargetFile', contentArg: 'ReplacementContent', oldArg: 'TargetContent', allArg: 'AllowMultiple' },
|
|
57
59
|
view_file: { as: 'Read', pathArg: 'AbsolutePath' },
|
|
58
60
|
grep_search: { as: 'Grep' },
|
|
59
61
|
list_dir: { as: 'Glob' },
|
|
@@ -66,6 +68,11 @@ const runShippedHook = (hookPath, payload, cwd) => {
|
|
|
66
68
|
cwd, input: payload, encoding: 'utf8', timeout: 30_000,
|
|
67
69
|
env: { ...process.env },
|
|
68
70
|
});
|
|
71
|
+
// @implements A-SPEC-734 (round 16) — three-harness parity: the hook's "not judged" notices reach the harness as
|
|
72
|
+
// they do for Claude and Codex (the adapter dropped every one — measured).
|
|
73
|
+
for (const line of String(r.stderr ?? '').split('\n'))
|
|
74
|
+
if (line.startsWith('[Holmes-Kit]'))
|
|
75
|
+
process.stderr.write(`${line.slice(0, 2000)}\n`);
|
|
69
76
|
const out = String(r.stdout ?? '').trim();
|
|
70
77
|
if (out === '')
|
|
71
78
|
return null;
|
|
@@ -98,16 +105,26 @@ function workspaceOf(payload, cwd) {
|
|
|
98
105
|
/** 게이트의 결정 문면에서 사유를 꺼낸다 — 훅은 두 모양 중 하나로 답한다. */
|
|
99
106
|
function decisionOf(out) {
|
|
100
107
|
if (out === null)
|
|
101
|
-
return {};
|
|
108
|
+
return { answered: false };
|
|
102
109
|
const nested = out.hookSpecificOutput;
|
|
103
|
-
if (nested !== undefined && typeof nested === 'object') {
|
|
110
|
+
if (nested !== undefined && nested !== null && typeof nested === 'object') {
|
|
111
|
+
// A-SPEC-739: the gate's pass carries no decision — an answer is its PreToolUse output, decision or not.
|
|
112
|
+
const decision = str(nested.permissionDecision);
|
|
104
113
|
return {
|
|
105
|
-
|
|
106
|
-
|
|
114
|
+
answered: decision !== undefined || nested.hookEventName === 'PreToolUse',
|
|
115
|
+
decision,
|
|
116
|
+
reason: str(nested.permissionDecisionReason) ?? str(nested.additionalContext),
|
|
107
117
|
};
|
|
108
118
|
}
|
|
109
|
-
|
|
119
|
+
const decision = str(out.permissionDecision) ?? str(out.decision);
|
|
120
|
+
return { answered: decision !== undefined, decision, reason: str(out.permissionDecisionReason) ?? str(out.reason) };
|
|
110
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* @implements A-SPEC-739 — Antigravity requires a decision, and its `allow` is "Automatically allow the tool
|
|
124
|
+
* execution" (its bundled hook contract). The gate grants nothing, so a pass is `ask` — the user is asked unless
|
|
125
|
+
* their Always-Allow covers the call — except for the read-only tools Antigravity runs without asking anyway.
|
|
126
|
+
*/
|
|
127
|
+
const READ_ONLY_AS = new Set(['Read', 'Grep', 'Glob']);
|
|
111
128
|
/**
|
|
112
129
|
* PreToolUse: Antigravity 의 말 → 게이트 → Antigravity 의 말.
|
|
113
130
|
*
|
|
@@ -128,7 +145,8 @@ function adaptPreToolUse(stdin, cwd = process.cwd(), run = runShippedHook) {
|
|
|
128
145
|
return { decision: 'deny', reason: '[Holmes-Kit] 훅 입력에 toolCall.name 이 없습니다 — 무엇을 판정하는지 알 수 없어 허용하지 않습니다.' };
|
|
129
146
|
}
|
|
130
147
|
const args = (call.args ?? {});
|
|
131
|
-
|
|
148
|
+
// A-SPEC-739 (round 2): an own property only — `constructor`, `__proto__` found Object's and skipped the unmapped path.
|
|
149
|
+
const map = Object.prototype.hasOwnProperty.call(exports.TOOL_MAP, name) ? exports.TOOL_MAP[name] : undefined;
|
|
132
150
|
const toolInput = {};
|
|
133
151
|
if (map?.commandArg !== undefined) {
|
|
134
152
|
const command = str(args[map.commandArg]);
|
|
@@ -136,6 +154,14 @@ function adaptPreToolUse(stdin, cwd = process.cwd(), run = runShippedHook) {
|
|
|
136
154
|
return { decision: 'deny', reason: `[Holmes-Kit] ${name} 의 ${map.commandArg} 를 읽을 수 없습니다 — 판정할 수 없는 호출은 허용하지 않습니다.` };
|
|
137
155
|
}
|
|
138
156
|
toolInput.command = command;
|
|
157
|
+
// A-SPEC-739 (round 2): the directory the command runs in (`rm -r ledger` with `Cwd: <root>/.ax` was `ask` here and a
|
|
158
|
+
// deny for Claude and Codex — measured).
|
|
159
|
+
// Round 3: a null Cwd is no Cwd (it denied every command); a number, list or object still denies.
|
|
160
|
+
if (args.Cwd !== undefined && args.Cwd !== null) {
|
|
161
|
+
if (typeof args.Cwd !== 'string')
|
|
162
|
+
return { decision: 'deny', reason: `[Holmes-Kit] ${name} 의 Cwd 를 읽을 수 없습니다 — 판정할 수 없는 호출은 허용하지 않습니다.` };
|
|
163
|
+
toolInput.workdir = args.Cwd;
|
|
164
|
+
}
|
|
139
165
|
}
|
|
140
166
|
if (map?.pathArg !== undefined) {
|
|
141
167
|
const p = str(args[map.pathArg]);
|
|
@@ -149,6 +175,15 @@ function adaptPreToolUse(stdin, cwd = process.cwd(), run = runShippedHook) {
|
|
|
149
175
|
toolInput.new_string = c;
|
|
150
176
|
}
|
|
151
177
|
}
|
|
178
|
+
// @implements A-SPEC-728 (rule 40) — the text replaced and whether every copy is: the gate judges the edit's result, not
|
|
179
|
+
// the replacement as the whole file (`draft` → `approved` was a deny for Claude and `ask` here — measured).
|
|
180
|
+
if (map?.oldArg !== undefined) {
|
|
181
|
+
const o = str(args[map.oldArg]);
|
|
182
|
+
if (o !== undefined)
|
|
183
|
+
toolInput.old_string = o;
|
|
184
|
+
}
|
|
185
|
+
if (map?.allArg !== undefined && args[map.allArg] === true)
|
|
186
|
+
toolInput.replace_all = true;
|
|
152
187
|
// 등재되지 않은 도구: 이름을 그대로 넘기고 인자에서 경로처럼 보이는 것을 실어 준다.
|
|
153
188
|
// 게이트가 "읽기 전용으로 알려지지 않았는데 경로를 들고 왔다 → 쓰기"로 받는다.
|
|
154
189
|
if (map === undefined) {
|
|
@@ -161,12 +196,13 @@ function adaptPreToolUse(stdin, cwd = process.cwd(), run = runShippedHook) {
|
|
|
161
196
|
}
|
|
162
197
|
}
|
|
163
198
|
const root = workspaceOf(payload, cwd);
|
|
164
|
-
const
|
|
199
|
+
const raw = run(shippedHook('pre-tool-use.js'), JSON.stringify({
|
|
165
200
|
tool_name: map?.as ?? name,
|
|
166
201
|
tool_input: toolInput,
|
|
167
202
|
cwd: root,
|
|
168
|
-
}), root)
|
|
169
|
-
|
|
203
|
+
}), root);
|
|
204
|
+
const out = decisionOf(raw);
|
|
205
|
+
if (!out.answered) {
|
|
170
206
|
return { decision: 'deny', reason: '[Holmes-Kit] 게이트가 답하지 않았습니다 — 판정 없이 진행하지 않습니다.' };
|
|
171
207
|
}
|
|
172
208
|
// @implements A-SPEC-336
|
|
@@ -179,9 +215,77 @@ function adaptPreToolUse(stdin, cwd = process.cwd(), run = runShippedHook) {
|
|
|
179
215
|
//
|
|
180
216
|
// Still nothing when there is nothing to say: a silent gate must stay silent, or it masks another
|
|
181
217
|
// gate's verdict.
|
|
182
|
-
|
|
218
|
+
// A-SPEC-739 (round 2): only a missing decision is a pass; `deny`/`block` in any case, nested or top-level, is a deny,
|
|
219
|
+
// and any other value is asked about.
|
|
220
|
+
const refuses = (v) => typeof v === 'string' && /^(?:deny|block)$/i.test(v);
|
|
221
|
+
const decision = refuses(out.decision) || refuses(raw?.decision) || refuses(raw?.permissionDecision) ? 'deny'
|
|
222
|
+
: out.decision !== undefined ? 'ask'
|
|
223
|
+
: READ_ONLY_AS.has(map?.as ?? '') && readInWorkspace(name, args, payload.workspacePaths, root) ? 'allow' : 'ask';
|
|
183
224
|
return out.reason ? { decision, reason: out.reason } : { decision };
|
|
184
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* @implements A-SPEC-739 (round 2) — a read Antigravity may run without asking: its path argument lies inside one of the
|
|
228
|
+
* call's workspace paths and git says it is not ignored (`view_file` of `~/.ssh/id_rsa`, a workspace `.env` or `/` was
|
|
229
|
+
* `allow` — measured; Antigravity has its own non-workspace and git-ignored file policies, and `allow` overrides them).
|
|
230
|
+
*/
|
|
231
|
+
const OWN_PATH_KEY = { view_file: 'AbsolutePath', grep_search: 'SearchPath', list_dir: 'DirectoryPath' };
|
|
232
|
+
const PATH_KEYS = ['AbsolutePath', 'SearchPath', 'DirectoryPath', 'TargetFile', 'FilePath', 'Path'];
|
|
233
|
+
/**
|
|
234
|
+
* @implements A-SPEC-728 (rule 44) — the keys this reading vouches for, case-folded as Go's JSON decoder folds them (`ſ` is `s`,
|
|
235
|
+
* the Kelvin sign `k`): a decoder that matches keys case-insensitively reads the LAST of `AbsolutePath` and `absolutepath`
|
|
236
|
+
* (`view_file {AbsolutePath: <ws file>, absolutepath: <ws>/.env}` was `allow` — measured).
|
|
237
|
+
*/
|
|
238
|
+
const READ_KEYS = [...PATH_KEYS, 'Includes', 'Excludes'];
|
|
239
|
+
const goFold = (k) => k.toUpperCase().toLowerCase();
|
|
240
|
+
const FOLDED_READ_KEYS = new Map(READ_KEYS.map((k) => [goFold(k), k]));
|
|
241
|
+
function readInWorkspace(name, args, workspacePaths, root) {
|
|
242
|
+
if (Object.keys(args).some((k) => { const exact = FOLDED_READ_KEYS.get(goFold(k)); return exact !== undefined && exact !== k; }))
|
|
243
|
+
return false;
|
|
244
|
+
// Round 3: the tool's own key only; another path key in the call is a read this cannot vouch for (`grep_search
|
|
245
|
+
// {AbsolutePath: <ws file>, SearchPath: <outside>}` was allow — measured).
|
|
246
|
+
const own = Object.prototype.hasOwnProperty.call(OWN_PATH_KEY, name) ? OWN_PATH_KEY[name] : undefined;
|
|
247
|
+
if (own === undefined)
|
|
248
|
+
return false;
|
|
249
|
+
const p = str(args[own]);
|
|
250
|
+
if (p === undefined || p === '' || PATH_KEYS.some((k) => k !== own && args[k] !== undefined))
|
|
251
|
+
return false;
|
|
252
|
+
// @implements A-SPEC-728 (rule 42) — a grep's filters stay inside what the search path vouches for: relative patterns without
|
|
253
|
+
// a `..` segment (`Includes: ['/etc/*']` beside an in-workspace SearchPath was `allow` — measured).
|
|
254
|
+
// @implements A-SPEC-728 (rule 43) — any `Includes` can name an ignored file (ripgrep's `--glob .env` searches it — measured), so
|
|
255
|
+
// it is not auto-allowed; an `Excludes` entry admits no brace and no leading `!` either.
|
|
256
|
+
if (args.Includes !== undefined && args.Includes !== null)
|
|
257
|
+
return false;
|
|
258
|
+
const excludes = args.Excludes;
|
|
259
|
+
if (excludes !== undefined && excludes !== null) {
|
|
260
|
+
const list = Array.isArray(excludes) ? excludes : [excludes];
|
|
261
|
+
if (!list.every((g) => typeof g === 'string' && !/^(?:[\\/]|~|[A-Za-z]:|!)/.test(g) && !/[{}]/.test(g) && !g.split(/[\\/]/).includes('..')))
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
const real = (q) => { try {
|
|
265
|
+
return fs.realpathSync.native(q);
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
return path.resolve(q);
|
|
269
|
+
} };
|
|
270
|
+
// Round 3: resolved as written — `<ws>/link/../secret.txt` folded as text named a missing in-workspace file while the
|
|
271
|
+
// kernel reads the one the link leads to (measured); a path that does not resolve is not a workspace read.
|
|
272
|
+
let target;
|
|
273
|
+
try {
|
|
274
|
+
target = fs.realpathSync.native(path.isAbsolute(p) ? p : `${root}${path.sep}${p}`);
|
|
275
|
+
}
|
|
276
|
+
catch {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
const roots = (Array.isArray(workspacePaths) ? workspacePaths : [root]).filter((w) => typeof w === 'string' && w !== '').map(real);
|
|
280
|
+
const home = roots.find((r) => { const rel = path.relative(r, target); return rel === '' || (rel !== '..' && !rel.startsWith('..' + path.sep) && !path.isAbsolute(rel)); });
|
|
281
|
+
if (home === undefined)
|
|
282
|
+
return false;
|
|
283
|
+
if (path.relative(home, target).split(path.sep).includes('.git'))
|
|
284
|
+
return false;
|
|
285
|
+
// Round 3: an ignore rule matches a tracked file too (`--no-index`).
|
|
286
|
+
const r = (0, bounded_io_1.gitOnce)(home, ['check-ignore', '-q', '--no-index', '--', target], 'repo');
|
|
287
|
+
return r.status === 1;
|
|
288
|
+
}
|
|
185
289
|
/**
|
|
186
290
|
* Stop: 게이트가 "막아라"라고 하면, 이 하네스에서 막는 말은 `continue` 다.
|
|
187
291
|
*
|
|
@@ -2,7 +2,7 @@ import { Spec } from '../spec/spec-parser';
|
|
|
2
2
|
import { Approval } from '../guardrail/risk-gate';
|
|
3
3
|
import { RiskAction, RiskAssessment, RmSignal } from '../guardrail/risk-types';
|
|
4
4
|
import { type PreEditEvidenceMode } from '../guardrail/impact-gate';
|
|
5
|
-
export declare function resolveRmSignals(command: string, cwd: string): Record<string, RmSignal> | undefined;
|
|
5
|
+
export declare function resolveRmSignals(command: string, cwd: string, projectRoot?: string, specsDir?: string): Record<string, RmSignal> | undefined;
|
|
6
6
|
/**
|
|
7
7
|
* @implements A-SPEC-149
|
|
8
8
|
* The out-of-band approval channel, read at the ENTRY only. `evaluateHook` no longer calls this on
|
|
@@ -12,12 +12,22 @@ export declare function resolveRmSignals(command: string, cwd: string): Record<s
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function readApprovalFromEnv(): Approval | undefined;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* stripped of leading assignments/wrappers and, for a nested shell, its `-c` body is re-examined.
|
|
19
|
-
* `env FOO=1 cmd` is a RUNNER (assignment then command), not a dump.
|
|
15
|
+
* @implements A-SPEC-732 (round 2) — the PreToolUse output. For `approval_commit` an unobjected call
|
|
16
|
+
* carries no decision: an `allow` would pre-empt the harness's own sensitive-tool confirmation, the
|
|
17
|
+
* premise of the host-gated route.
|
|
20
18
|
*/
|
|
19
|
+
/**
|
|
20
|
+
* @implements A-SPEC-739 — the gate takes decisions away and never grants one. A deny reaches the harness as a deny with
|
|
21
|
+
* its reason; anything else carries no permission decision, so the harness's own flow (the user's confirmation, allow
|
|
22
|
+
* rules, auto mode) decides. Measured: Claude Code 2.1.281 handles a hook `allow` as "Hook approved tool use …,
|
|
23
|
+
* bypassing permission prompt", so every miss of the shell model ran unconfirmed; Codex 0.155 ignores `allow`
|
|
24
|
+
* ("unsupported permissionDecision:allow"). A pass's warning travels as `additionalContext` (A-SPEC-336's reason).
|
|
25
|
+
* Round-1 A-SPEC-718's approval_commit exception is now the rule for every tool.
|
|
26
|
+
*/
|
|
27
|
+
export declare function hookOutputFor(_toolName: string, out: {
|
|
28
|
+
permissionDecision: string;
|
|
29
|
+
permissionDecisionReason?: string;
|
|
30
|
+
} & Record<string, unknown>): Record<string, unknown>;
|
|
21
31
|
export declare function dumpsEnvInCommandPosition(command: string, depth?: number): boolean;
|
|
22
32
|
/**
|
|
23
33
|
* Coerce a hook envelope into known shapes so a type surprise cannot become an exception.
|
|
@@ -40,7 +50,21 @@ export interface HookInput {
|
|
|
40
50
|
content?: string;
|
|
41
51
|
new_string?: string;
|
|
42
52
|
command?: string;
|
|
53
|
+
old_string?: string;
|
|
54
|
+
replace_all?: boolean;
|
|
55
|
+
edits?: Array<{
|
|
56
|
+
old_string?: string;
|
|
57
|
+
new_string?: string;
|
|
58
|
+
replace_all?: boolean;
|
|
59
|
+
}>;
|
|
60
|
+
/** @implements A-SPEC-728 (round 17) — Codex's shell tool runs the command in `workdir` when given. */
|
|
61
|
+
workdir?: string;
|
|
43
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* @implements A-SPEC-728 (round 17) — the directory the harness runs the shell in (every harness
|
|
65
|
+
* sends it). The shell base for relative words when it lies inside the project; the root otherwise.
|
|
66
|
+
*/
|
|
67
|
+
cwd?: string;
|
|
44
68
|
/**
|
|
45
69
|
* @implements A-SPEC-163
|
|
46
70
|
* The raw payload carried a path field that was NOT a string, or `tool_input` was not an object.
|
|
@@ -156,7 +180,9 @@ export declare function evaluateHook(input: {
|
|
|
156
180
|
old_string?: string;
|
|
157
181
|
new_string?: string;
|
|
158
182
|
command?: string;
|
|
183
|
+
workdir?: string;
|
|
159
184
|
};
|
|
185
|
+
cwd?: string;
|
|
160
186
|
}, specsDir: string, opts: {
|
|
161
187
|
assess?: (a: RiskAction) => RiskAssessment;
|
|
162
188
|
/**
|