@holmes-lab/holmes-kit 0.35.23 → 0.35.25
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 +115 -0
- package/README.md +5 -3
- package/dist/.build-id +1 -1
- package/dist/holmes/cli/agent-registry.d.ts +7 -0
- package/dist/holmes/cli/agent-registry.js +10 -0
- package/dist/holmes/cli/agents.d.ts +2 -2
- package/dist/holmes/cli/agents.js +196 -6
- package/dist/holmes/cli/approve.js +4 -4
- package/dist/holmes/cli/doctor.d.ts +22 -0
- package/dist/holmes/cli/doctor.js +160 -11
- package/dist/holmes/cli/index.js +23 -1
- package/dist/holmes/cli/init.d.ts +24 -0
- package/dist/holmes/cli/init.js +55 -3
- package/dist/holmes/cli/runtime-binding-approval.js +3 -2
- package/dist/holmes/cli/runtime-binding.d.ts +10 -1
- package/dist/holmes/cli/runtime-binding.js +139 -2
- package/dist/holmes/cli/scratch.d.ts +12 -0
- package/dist/holmes/cli/scratch.js +20 -0
- package/dist/holmes/governance/approval-queue.js +4 -3
- package/dist/holmes/guardrail/impact-gate.d.ts +2 -0
- package/dist/holmes/guardrail/impact-gate.js +34 -11
- package/dist/holmes/guardrail/risk-classifier.js +14 -2
- package/dist/holmes/guardrail/risk-types.d.ts +1 -0
- package/dist/holmes/hooks/adapters/antigravity.js +3 -2
- package/dist/holmes/hooks/heartbeat.d.ts +47 -0
- package/dist/holmes/hooks/heartbeat.js +247 -0
- package/dist/holmes/hooks/pre-tool-use.d.ts +1 -1
- package/dist/holmes/hooks/pre-tool-use.js +46 -3
- package/dist/holmes/hooks/stop.d.ts +3 -1
- package/dist/holmes/hooks/stop.js +16 -4
- package/dist/holmes/mcp/elicit-approval.js +4 -4
- package/dist/holmes/mcp/handlers/runtime-binding-tool.d.ts +28 -0
- package/dist/holmes/mcp/handlers/runtime-binding-tool.js +42 -9
- package/dist/holmes/mcp/handlers/spec-approval.js +3 -2
- package/dist/holmes/mcp/handlers/workspace-preflight.js +2 -2
- package/dist/holmes/mcp/handlers.d.ts +27 -1
- package/dist/holmes/project/npx-bin.d.ts +26 -0
- package/dist/holmes/project/npx-bin.js +272 -2
- package/dist/holmes/project/scratch-root.d.ts +12 -0
- package/dist/holmes/project/scratch-root.js +132 -0
- package/dist/holmes/project/workspace-preflight.d.ts +3 -0
- package/dist/holmes/project/workspace-preflight.js +42 -2
- package/dist/holmes/runtime/dispatch.js +8 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,121 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
<!-- @implements A-SPEC-209 -->
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.35.25] - 2026-10-17
|
|
11
|
+
|
|
12
|
+
Upgrading:
|
|
13
|
+
- Where another holmes-kit copy sits in an ancestor `node_modules` of the workspace, approval hints now name the
|
|
14
|
+
running install's own path (`'<node>' '<…>/bin/holmes-kit.js' approve …`). Elsewhere they stay `npx holmes-kit approve
|
|
15
|
+
…`.
|
|
16
|
+
- doctor's new `npx resolution` row names such a copy.
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- **`holmes-kit scratch [--new <label>]`** (REQ-773, A-SPEC-773): a per-user Holmes scratch root,
|
|
21
|
+
`os.tmpdir()/holmes-scratch-<uid>`, mode 0700.
|
|
22
|
+
- On macOS and Linux, an agent in Claude Code, Codex or Antigravity can remove an existing subdirectory of it
|
|
23
|
+
without an operator act, using one plain `rm -r[f]` of absolute paths, at most 64 of them.
|
|
24
|
+
- The gate checks on each call that the root is still this user's own, not a link, with no group/other bits. It
|
|
25
|
+
judges each target by its real path.
|
|
26
|
+
- These keep today's refusal:
|
|
27
|
+
- the root itself, the rest of the temporary directory, links out of the root, `..` and globs;
|
|
28
|
+
- tracked source;
|
|
29
|
+
- any command that is not a single plain `rm`: pipes into `xargs`/`parallel`, aliases, and a link or move earlier
|
|
30
|
+
in the same command (adversarial review, round 1).
|
|
31
|
+
- On Windows the directory is made, but the gate does not relax.
|
|
32
|
+
- The refusal of an out-of-project recursive `rm` now names `holmes-kit scratch --new <label>`.
|
|
33
|
+
- Known limits:
|
|
34
|
+
- `mv` is not gated, so data moved into the root by an earlier command can then be removed. The same two steps
|
|
35
|
+
were already possible with `rm -r` without `-f`.
|
|
36
|
+
- The window between the gate's judgement and the command's execution is not closed.
|
|
37
|
+
- The Codex and Antigravity hook `TMPDIR` has not been measured live. Where it differs from the agent's shell, the
|
|
38
|
+
gate simply does not relax.
|
|
39
|
+
- Owner decision, 2026-10-17: agents could not clean up review probes and had to ask.
|
|
40
|
+
|
|
41
|
+
### Fixed
|
|
42
|
+
|
|
43
|
+
- **Approval hints reach the install that issued them** (A-SPEC-770.3–770.6).
|
|
44
|
+
- The incident: under a home directory holding `~/node_modules/@holmes-lab/holmes-kit` 0.19.3, a 0.35.23 refusal's
|
|
45
|
+
own `npx holmes-kit approve --grant <id>` ran 0.19.3 and answered "no pending request matches".
|
|
46
|
+
- The hint now walks the ancestors of the workspace and of the home directory, as npx does. It looks for a
|
|
47
|
+
`node_modules/.bin/holmes-kit` file entry that belongs to another install. Shim files (npm on Windows, pnpm) are
|
|
48
|
+
identified through the package directory beside them.
|
|
49
|
+
- When it finds one, the hint names the running install's quoted absolute path. That form needs no network, no npm
|
|
50
|
+
cache and no published version. On Windows it is PowerShell syntax.
|
|
51
|
+
- The emitters are the refusals, the Stop block, the dialog notices, the approve screens, the governance-wiring
|
|
52
|
+
message, the decline reason and the stale-grant hint.
|
|
53
|
+
- A version-pinned `npx -p …@<version>` was tried and withdrawn before release (review round 1). On a cold cache it
|
|
54
|
+
was a 703 MB download behind a prompt, and it failed for an unpublished version.
|
|
55
|
+
- The hint also treats as a shadow a project whose own `package.json` declares a `holmes-kit` bin. npx runs that bin
|
|
56
|
+
first, so this covers a holmes-kit checkout or fork.
|
|
57
|
+
- doctor WARNs on such a copy and names it.
|
|
58
|
+
- Known limit: a workspace member under a root that declares the bin is not detected yet.
|
|
59
|
+
- **`holmes-kit approve --refusals --target <root>` runs** (A-SPEC-770.11). Every refusal outside the inbox prints
|
|
60
|
+
this command. It exited with "--refusals requires a value" because the count was mandatory. The count is now optional
|
|
61
|
+
and defaults to 20.
|
|
62
|
+
- **A Codex or Antigravity hook that inherited `CLAUDE_PROJECT_DIR` is no longer denied** (A-SPEC-751.7). Claude Code
|
|
63
|
+
passes the variable to every process it launches. Through the runtime dispatcher, a Codex session under one of them
|
|
64
|
+
had every tool call denied as "Conflicting runtime workspace hints". The variable is now a hint for the Claude harness
|
|
65
|
+
only.
|
|
66
|
+
- **The pre-edit evidence warning no longer says "no-analysis" when an analysis exists** (A-SPEC-278.4, A-SPEC-278.5).
|
|
67
|
+
- With no digest (every Edit or Write), an analysis persisted at this HEAD that did not predict the file was skipped.
|
|
68
|
+
The warning then claimed no analysis at all.
|
|
69
|
+
- It now gives that analysis's own verdict, `target-out-of-scope`, naming its digest. The remediation no longer asks
|
|
70
|
+
for a digest retry the session cannot make.
|
|
71
|
+
- **`runtime-binding status` reads the heartbeat where the kernel writes it** (A-SPEC-772.12).
|
|
72
|
+
- In a nested checkout without `.ax`, status said `unverified` while doctor said observed.
|
|
73
|
+
- `observedUnrouted` now names each unrouted event, PreToolUse first, as `observedOther` does.
|
|
74
|
+
|
|
75
|
+
## [0.35.24] - 2026-10-17
|
|
76
|
+
|
|
77
|
+
Upgrading: run `holmes-kit runtime-binding setup` again with this build, so the deployed dispatcher passes the routing
|
|
78
|
+
mode to the hooks. Until you do, doctor says "the deployed dispatcher does not report its routing mode". After setup,
|
|
79
|
+
trust the rewritten Codex hooks once with `/hooks`. A Codex Stop hook under 75 s is now a doctor FAIL.
|
|
80
|
+
|
|
81
|
+
### Added
|
|
82
|
+
|
|
83
|
+
- **Each harness's hooks leave evidence that they ran** (REQ-772, A-SPEC-772.1). The PreToolUse and Stop kernels write
|
|
84
|
+
a small per-harness record under `.ax/state/hook-heartbeat/`. The record is git-ignored, written at most once a minute,
|
|
85
|
+
and never changes a hook decision. Antigravity is named by its adapter and routed hooks by the dispatcher
|
|
86
|
+
(`HOLMES_HOOK_HARNESS`, which must agree with the input shape). Claude and Codex are otherwise named by their hook
|
|
87
|
+
input. Harness environment markers such as `CLAUDECODE` are never read: a Codex hook received `CLAUDECODE=1`.
|
|
88
|
+
- `workspace_preflight` with `harness` reports `runtime-enforcement` as `pass` only after that harness's PreToolUse
|
|
89
|
+
gate was observed within 24 h and since its wiring last changed. Otherwise it is `unknown`, naming why: never
|
|
90
|
+
observed, stale, only the Stop observed, or wiring changed.
|
|
91
|
+
- doctor shows one `hook observed (<harness>)` row per harness (honouring `--agent`).
|
|
92
|
+
- `runtime-binding status` reports `activation: observed` only for this selection's PreToolUse gate. It names
|
|
93
|
+
other-build, other-mode and Stop-only observations per event (`observedOther`), the latest observation without
|
|
94
|
+
routing evidence (`observedUnrouted`), and an outdated deployed dispatcher (`routerOutdated`).
|
|
95
|
+
- `HOLMES_HEARTBEAT=off` turns recording off, for tests that spawn the real kernel inside a repository. preflight and
|
|
96
|
+
doctor's observation rows say so when their own environment has it.
|
|
97
|
+
- Known limit: a user-level Codex `/hooks` switch-off or plugin disable lives in the machine-shared
|
|
98
|
+
`~/.codex/config.toml` and does not mark an observation stale.
|
|
99
|
+
|
|
100
|
+
Specs: A-SPEC-772.1, A-SPEC-772.5, A-SPEC-772.6, A-SPEC-772.7, A-SPEC-772.8, A-SPEC-772.9, A-SPEC-772.10,
|
|
101
|
+
A-SPEC-772.11.
|
|
102
|
+
|
|
103
|
+
### Fixed
|
|
104
|
+
|
|
105
|
+
- **`runtime_binding` no longer answers "not registered" for a governed workspace** (A-SPEC-772). A workspace with no
|
|
106
|
+
development binding is answered with its routing: the release build and package routed hooks run, `unrouted` without
|
|
107
|
+
a registry, or `unroutable` with the reason. Measured in holmes-lab: a Codex session read "not registered" as "not
|
|
108
|
+
governed".
|
|
109
|
+
- **init states a Codex verdict when the operator registry owns the Codex files** (A-SPEC-772.2, A-SPEC-772.4,
|
|
110
|
+
A-SPEC-772.5, A-SPEC-772.6, A-SPEC-772.7).
|
|
111
|
+
- The line names the routing and the trust state of the routed gates.
|
|
112
|
+
- It adds an operator line when a Codex Stop hook is under 75 s.
|
|
113
|
+
- It names a workspace Codex marks untrusted.
|
|
114
|
+
- The `~/.codex/config.toml` receipt ignores Codex's own trust, project and notice tables, so it is no longer
|
|
115
|
+
permanent drift.
|
|
116
|
+
- **doctor FAILs a running Holmes Stop hook under 75 s** (A-SPEC-772.3, A-SPEC-772.5, A-SPEC-772.6). This covers Claude entries
|
|
117
|
+
(unless Claude's hooks are switched off), Antigravity entries, and trusted Codex user, project or plugin entries.
|
|
118
|
+
Untrusted or switched-off entries stay WARN.
|
|
119
|
+
- **init re-merges the Codex plugin `hooks.json`** (A-SPEC-772.3, A-SPEC-772.6, A-SPEC-772.7, A-SPEC-772.8). The merge:
|
|
120
|
+
- keeps every group and handler at its index, because Codex keys trust by index;
|
|
121
|
+
- keeps foreign handlers and leaves operator routers in place;
|
|
122
|
+
- recognizes only the command shapes Holmes writes;
|
|
123
|
+
- writes Stop in group shape.
|
|
124
|
+
|
|
10
125
|
## [0.35.23] - 2026-10-17
|
|
11
126
|
|
|
12
127
|
Upgrading: run `holmes-kit runtime-binding setup` again so the hooks run this build. A binding whose workspace was
|
package/README.md
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
<!-- holmes-kit:attest:begin -->
|
|
10
10
|

|
|
11
11
|
|
|
12
|
-
**
|
|
13
|
-
Measured at `
|
|
12
|
+
**444/446** source files (99.5%) trace to an approved spec · **835/900** approved A-SPECs (92.7%) are anchored from code.
|
|
13
|
+
Measured at `a36f0d1b502f` (specs `sha256:d41ff5dd491a`) — reproduce with `holmes-kit attest`.
|
|
14
14
|
<!-- holmes-kit:attest:end -->
|
|
15
15
|
|
|
16
16
|
---
|
|
@@ -23,6 +23,8 @@ Measured at `3fe5cc250195` (specs `sha256:974cd643361c`) — reproduce with `hol
|
|
|
23
23
|
|
|
24
24
|
### 🛡️ Currently Supported Features (Production Features)
|
|
25
25
|
|
|
26
|
+
- **Agents clean up their own temporary work** *(new in 0.35.25)*: `holmes-kit scratch --new <label>` makes a directory under a per-user Holmes scratch root (`os.tmpdir()/holmes-scratch-<uid>`, mode 0700), and on macOS and Linux the gate lets an agent in Claude Code, Codex or Antigravity remove it with one plain `rm -rf <absolute path>` without an operator act; the root itself, tracked source, every other path and any compound command keep their verdict. Where another holmes-kit install sits in an ancestor `node_modules` of the workspace or the home directory (npm, Windows shims and pnpm alike), approval hints name the running install's own path so that copy cannot answer them (a PowerShell form on Windows), and doctor's `npx resolution` row names it.
|
|
27
|
+
- **You can tell whether a harness's gate actually ran here** *(new in 0.35.24)*: the PreToolUse and Stop hooks of Claude Code, Codex and Antigravity leave a git-ignored per-harness record (`.ax/state/hook-heartbeat/`, at most one write a minute, never part of a decision). `workspace_preflight` with `harness` passes `runtime-enforcement` only after that harness's PreToolUse gate was observed within 24 h and since its wiring last changed; doctor shows one `hook observed (<harness>)` row each; `runtime-binding status` reports `activation` for this selection's gate and names every other observation and an outdated deployed dispatcher. `runtime_binding` answers an unbound workspace with its routing instead of "not registered", init states a Codex verdict for registry-owned Codex files, and doctor FAILs a running Stop hook under 75 s. Measured need: a Codex session in a release-routed workspace concluded it was ungoverned.
|
|
26
28
|
- **A benchmark run the operator pre-approved finishes with zero human waits — the run delegation** *(new in 0.35.19)*: `holmes-kit autonomy delegate --run <id> --allow <rule[,rule]> [--for 2h] [--limit k=v]… [--rationale <text>]` (same human proof as `autonomy on`) writes a run-scoped, workspace-bound (realpath), expiring delegation that covers a closed set of autonomy-grader rules — root-only or gate-file Files to Touch, an undirected gate-behavior grade, an upstream without A-SPEC; never architecture documents, un-admitted requirements, undeclared or unknown grades. A hitl spec whose only reason is a covered rule seals on its own with `source: 'delegated'` and a ledger row naming the run and the rule; an uncovered case refuses with the named limit (`does not cover`, `expired`, `for <workspace>, not this root`, `invalid document`). `autonomy status`, `approve --status` and the session-start banner show it; `revoke-delegation` or `off` ends it. The host's own approval layer is named as not covered. Measured need: X1 (2026-10-12) stopped a pre-approved fixture on `files-to-touch-root-only`. Every operator hint now also names the workspace (`--target <root>`), a context-only Codex patch is refused as a no-op by name, and `runtime-binding status`/`doctor` report a Codex lifecycle routed to Holmes from both the user-level and the workspace hooks file.
|
|
27
29
|
- **A refusal you cannot see in the inbox is still answerable from its own hint** *(new in 0.35.18)*: six repairs measured in a Codex X1 runtime session and a field report. Every refusal line written to the refusal log ends with `run: holmes-kit approve --grant <id> --target <root>` carrying the actual id, the inbox (`approve --list` / `--watch`) prints a footer counting requests outside the inbox, and the `--refusals` closing line spells the same command (the positional `approve <id>` the first repair wrote is refused by the CLI, so it was measured and rewritten). An autonomy refusal on a parent spec names the child rule that forces the human decision (`upstream-has-human-aspec: <id> — <rule>`). A runtime deadline refusal ends with the per-phase millisecond split, and the Stop hook prints how much of its 18 s budget it used once it passes half. `runtime-binding status` separates `drift` (operator-config / stale-workspace) from `conflicts` and reports whether the router is intact. The `--autonomy` usage, the `init` refusal and the interactive prompt now say the same thing.
|
|
28
30
|
- **An agent is told what to do after an approval, and a patch is judged the way the tool applies it** *(new in 0.35.17)*: five repairs measured on a Codex worker in a SWE-bench comparison. `approval_status` now carries `request { id, state, question?, reason?, ts? }` (pending / held / granted / consumed / denied / revoked, read from the approval queue, with the operator's LATEST hold question) and one `nextAction` sentence — a sealed spec says "stop polling", a held request relays the question; the pending-approval hint ends with an `Agent:` line beside the unchanged operator lines. `test_run` reports `anchorDiagnostics` for an `@implements` list joined by `;`, `|`, `&`, `/` or `and` (the comma grammar does not read them; attribution is unchanged, the omission is named). A Codex `apply_patch` update is applied chunk by chunk from the previous chunk's position, as the tool does, so a context line that recurs earlier in the file no longer makes it "unreadable", and a patch that does not apply is refused by a sentence naming the file and the chunk. A quoted or escaped glob (`rg ".*"`) is no longer read as a spelling of the `.ax` store (an unquoted `.*` still is). The background refresh child records `failure { stage, reason }` on its freshness receipt instead of failing silently.
|
|
@@ -308,7 +310,7 @@ flowchart LR
|
|
|
308
310
|
| `holmes-kit init --autonomy` | Opt the project into autonomous spec approval (low-risk only; governance-critical still HITL) |
|
|
309
311
|
| `holmes-kit init --dry-run` | Preview files and configuration changes without writing |
|
|
310
312
|
| `holmes-kit runtime-binding setup --workspace <root> --package <built-package> --release-package <release-install> --dry-run` | Preview explicit development/release routing; omit `--dry-run` only after reviewing the plan and satisfying its approval request |
|
|
311
|
-
| `holmes-kit runtime-binding status --workspace <root>` | Inspect selected package, build, spec store and wiring conflicts; not
|
|
313
|
+
| `holmes-kit runtime-binding status --workspace <root>` | Inspect selected package, build, spec store and wiring conflicts, and whether this selection's PreToolUse gate was observed running (`activation`); an observation is evidence the hook ran, not a guarantee every call is judged |
|
|
312
314
|
| `holmes-kit doctor --target <root> --registry <bindings.json>` | Diagnose the same operator registry used by custom routing installations |
|
|
313
315
|
| `holmes-kit autonomy status` | Show the current autonomous-approval posture (project default + session envelope) |
|
|
314
316
|
| `holmes-kit autonomy on --for 2h` | Self-drive low-risk specs for this session only (expiring; needs a TTY or `HOLMES_APPROVAL`) |
|
package/dist/.build-id
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
e7fd416c-mvcf1aig
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The harness registry, with no imports: hook processes read it on every call (the heartbeat), and pulling it from
|
|
3
|
+
* `cli/agents.ts` loaded seven modules (guidance, launcher, …) into every PreToolUse — measured +8 ms (2026-10-17).
|
|
4
|
+
* `cli/agents.ts` re-exports these, so every existing import keeps working and ADR-018's single registry stays one list.
|
|
5
|
+
*/
|
|
6
|
+
export declare const AGENTS: readonly ["claude", "antigravity", "codex"];
|
|
7
|
+
export type Agent = (typeof AGENTS)[number];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AGENTS = void 0;
|
|
4
|
+
// @implements A-SPEC-772.6
|
|
5
|
+
/**
|
|
6
|
+
* The harness registry, with no imports: hook processes read it on every call (the heartbeat), and pulling it from
|
|
7
|
+
* `cli/agents.ts` loaded seven modules (guidance, launcher, …) into every PreToolUse — measured +8 ms (2026-10-17).
|
|
8
|
+
* `cli/agents.ts` re-exports these, so every existing import keeps working and ADR-018's single registry stays one list.
|
|
9
|
+
*/
|
|
10
|
+
exports.AGENTS = ['claude', 'antigravity', 'codex'];
|
|
@@ -7,8 +7,8 @@ import { LauncherMode } from './mcp-launcher';
|
|
|
7
7
|
* 없다면 **집행한다고 말하지 않는 것**이 이 파일의 일이다. 도구는 주되 규율은 못 세우면서
|
|
8
8
|
* 세운다고 적으면, 그 문장을 믿은 사용자가 지켜지지 않는 게이트 위에서 일한다.
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
export type Agent
|
|
10
|
+
import { AGENTS, type Agent } from './agent-registry';
|
|
11
|
+
export { AGENTS, type Agent };
|
|
12
12
|
/**
|
|
13
13
|
* 그 하네스에서 게이트가 **집행되는가**.
|
|
14
14
|
*
|
|
@@ -51,7 +51,7 @@ exports.agentLinks = agentLinks;
|
|
|
51
51
|
exports.agyOtherHooksFiles = agyOtherHooksFiles;
|
|
52
52
|
exports.agySwitches = agySwitches;
|
|
53
53
|
exports.agyCanonicalFile = agyCanonicalFile;
|
|
54
|
-
// @implements A-SPEC-708, A-SPEC-707, A-SPEC-202, A-SPEC-250, A-SPEC-341
|
|
54
|
+
// @implements A-SPEC-708, A-SPEC-707, A-SPEC-202, A-SPEC-250, A-SPEC-341, A-SPEC-772.3, A-SPEC-772.5, A-SPEC-772.6, A-SPEC-772.7, A-SPEC-772.8
|
|
55
55
|
// @implements A-SPEC-442
|
|
56
56
|
// @implements A-SPEC-193
|
|
57
57
|
// @implements A-SPEC-769.10
|
|
@@ -71,7 +71,9 @@ const hook_process_1 = require("../runtime/hook-process");
|
|
|
71
71
|
* 없다면 **집행한다고 말하지 않는 것**이 이 파일의 일이다. 도구는 주되 규율은 못 세우면서
|
|
72
72
|
* 세운다고 적으면, 그 문장을 믿은 사용자가 지켜지지 않는 게이트 위에서 일한다.
|
|
73
73
|
*/
|
|
74
|
-
|
|
74
|
+
// @implements A-SPEC-772.6 — defined in the import-free registry module; re-exported here for every existing caller.
|
|
75
|
+
const agent_registry_1 = require("./agent-registry");
|
|
76
|
+
Object.defineProperty(exports, "AGENTS", { enumerable: true, get: function () { return agent_registry_1.AGENTS; } });
|
|
75
77
|
/**
|
|
76
78
|
* 그 하네스에서 게이트가 **집행되는가**.
|
|
77
79
|
*
|
|
@@ -490,12 +492,197 @@ function agyUserSwitch(file = agyUserHooksPath()) {
|
|
|
490
492
|
return { off: false, unconfirmed: `the holmes-kit entry in ${file} has "enabled" that is not true or false` };
|
|
491
493
|
return { off: false, unconfirmed: null };
|
|
492
494
|
}
|
|
495
|
+
/**
|
|
496
|
+
* @implements A-SPEC-772.3 — the Codex shape (`{ hooks: { <Event>: [group] } }`): per event, the groups that hold a
|
|
497
|
+
* Holmes kernel command — as a group's handler or as a flat handler (the shape init wrote before) — are replaced by ours;
|
|
498
|
+
* every other group and top-level key is kept. Measured 2026-10-17: the namespace merge below kept the whole previous
|
|
499
|
+
* file and named our own `hooks` key as foreign, so the plugin file was never updated after its first write.
|
|
500
|
+
*/
|
|
501
|
+
/**
|
|
502
|
+
* @implements A-SPEC-772.6 — what a handler runs, judged by its script token (the first token, or the second after a
|
|
503
|
+
* `node` executable): a Holmes kernel, a Holmes Codex router, or neither. A wrapper that merely mentions a kernel path
|
|
504
|
+
* later in its arguments is a foreign command (round 2 measured it deleted as "ours").
|
|
505
|
+
*/
|
|
506
|
+
function holmesScriptKind(h) {
|
|
507
|
+
if (h === null || typeof h !== 'object' || typeof h.command !== 'string')
|
|
508
|
+
return null;
|
|
509
|
+
// @implements A-SPEC-772.7 — only the shapes Holmes writes: `<node> <absolute script>` or the script alone, as shell
|
|
510
|
+
// words (single quotes with '\'' escapes, double quotes). Any operator, flag or further word makes it foreign — a
|
|
511
|
+
// looser match deleted `node …/stop.js && curl …` as ours and missed `nodejs` routers (round 3).
|
|
512
|
+
const words = [];
|
|
513
|
+
let cur = '';
|
|
514
|
+
let inWord = false;
|
|
515
|
+
let quote = null;
|
|
516
|
+
let escaped = false;
|
|
517
|
+
const text = h.command.trim();
|
|
518
|
+
for (let i = 0; i < text.length; i++) {
|
|
519
|
+
const ch = text[i];
|
|
520
|
+
// @implements A-SPEC-772.8 — outside quotes `\` is accepted only as the `'\''` apostrophe escape a router writes.
|
|
521
|
+
if (escaped) {
|
|
522
|
+
if (ch !== "'")
|
|
523
|
+
return null;
|
|
524
|
+
cur += ch;
|
|
525
|
+
escaped = false;
|
|
526
|
+
inWord = true;
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
// @implements A-SPEC-772.8 — the shell expands `$` and backticks inside double quotes, and `\` escapes there before
|
|
530
|
+
// `$`, a backtick, `"` or `\`: none is a shape Holmes writes. A `\` before anything else is literal (Windows paths).
|
|
531
|
+
if (quote === '"' && (ch === '$' || ch === '`' || (ch === '\\' && /[$`"\\]/.test(text[i + 1] ?? ''))))
|
|
532
|
+
return null;
|
|
533
|
+
if (quote) {
|
|
534
|
+
if (ch === quote)
|
|
535
|
+
quote = null;
|
|
536
|
+
else
|
|
537
|
+
cur += ch;
|
|
538
|
+
continue;
|
|
539
|
+
}
|
|
540
|
+
if (ch === '\\') {
|
|
541
|
+
escaped = true;
|
|
542
|
+
continue;
|
|
543
|
+
}
|
|
544
|
+
if (ch === "'" || ch === '"') {
|
|
545
|
+
quote = ch;
|
|
546
|
+
inWord = true;
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
549
|
+
if (/\s/.test(ch)) {
|
|
550
|
+
if (inWord) {
|
|
551
|
+
words.push(cur);
|
|
552
|
+
cur = '';
|
|
553
|
+
inWord = false;
|
|
554
|
+
}
|
|
555
|
+
continue;
|
|
556
|
+
}
|
|
557
|
+
if (/[;&|<>`$()*?]/.test(ch))
|
|
558
|
+
return null;
|
|
559
|
+
cur += ch;
|
|
560
|
+
inWord = true;
|
|
561
|
+
}
|
|
562
|
+
if (quote || escaped)
|
|
563
|
+
return null;
|
|
564
|
+
if (inWord)
|
|
565
|
+
words.push(cur);
|
|
566
|
+
const nodeExec = (w) => /^node(?:js)?\d*(?:\.exe)?$/i.test(w.split(/[/\\]/).pop() ?? '');
|
|
567
|
+
const script = words.length === 1 ? words[0] : words.length === 2 && nodeExec(words[0]) ? words[1] : null;
|
|
568
|
+
if (script === null || !(script.startsWith('/') || /^[A-Za-z]:[/\\]/.test(script)))
|
|
569
|
+
return null;
|
|
570
|
+
if (/[/\\]dist[/\\]holmes[/\\]hooks[/\\](?:pre-tool-use|stop)\.js$/.test(script))
|
|
571
|
+
return 'kernel';
|
|
572
|
+
if (/[/\\]\.holmes[/\\]runtime[/\\]codex-(?:pre-tool-use|stop)\.js$/.test(script))
|
|
573
|
+
return 'router';
|
|
574
|
+
// @implements A-SPEC-772.8 — a router written beside a registry given with --registry: its folder holds the dispatcher.
|
|
575
|
+
if (/[/\\]codex-(?:pre-tool-use|stop)\.js$/.test(script)) {
|
|
576
|
+
try {
|
|
577
|
+
if (fs.existsSync(path.join(path.dirname(script), 'dispatch.js')))
|
|
578
|
+
return 'router';
|
|
579
|
+
}
|
|
580
|
+
catch { /* unreadable: not ours */ }
|
|
581
|
+
}
|
|
582
|
+
return null;
|
|
583
|
+
}
|
|
584
|
+
function mergeCodexHooksByEvent(prev, oursObj, before) {
|
|
585
|
+
const handlersOf = (g) => (g !== null && typeof g === 'object' && Array.isArray(g.hooks)) ? g.hooks : [g];
|
|
586
|
+
const unchanged = (why) => ({ content: before ?? `${JSON.stringify(prev, null, 2)}\n`, preserved: [], notes: [`Codex plugin hooks.json not merged: ${why}; it was left as it is`] });
|
|
587
|
+
if (prev.hooks !== undefined && (prev.hooks === null || typeof prev.hooks !== 'object' || Array.isArray(prev.hooks)))
|
|
588
|
+
return unchanged('its "hooks" is not an object');
|
|
589
|
+
const prevHooks = (prev.hooks ?? {});
|
|
590
|
+
const ourHooks = oursObj.hooks;
|
|
591
|
+
for (const event of Object.keys(ourHooks))
|
|
592
|
+
if (prevHooks[event] !== undefined && !Array.isArray(prevHooks[event]))
|
|
593
|
+
return unchanged(`its ${event} is not a list`);
|
|
594
|
+
const merged = { ...prevHooks };
|
|
595
|
+
const preserved = [];
|
|
596
|
+
const notes = [];
|
|
597
|
+
for (const [event, groupsRaw] of Object.entries(ourHooks)) {
|
|
598
|
+
const groups = Array.isArray(groupsRaw) ? groupsRaw : [];
|
|
599
|
+
const old = prevHooks[event];
|
|
600
|
+
if (old === undefined) {
|
|
601
|
+
merged[event] = groups;
|
|
602
|
+
continue;
|
|
603
|
+
}
|
|
604
|
+
// @implements A-SPEC-772.5/772.6 — an event emptied on purpose (setup empties the legacy plugin) stays empty, said.
|
|
605
|
+
if (old.length === 0) {
|
|
606
|
+
merged[event] = [];
|
|
607
|
+
notes.push(`${event} is empty on purpose and was not re-wired (holmes-kit runtime-binding setup manages it when routed)`);
|
|
608
|
+
continue;
|
|
609
|
+
}
|
|
610
|
+
// @implements A-SPEC-772.6 — operator routing is not replaced by a direct kernel command.
|
|
611
|
+
if (old.some((g) => handlersOf(g).some((h) => holmesScriptKind(h) === 'router'))) {
|
|
612
|
+
merged[event] = old;
|
|
613
|
+
old.forEach((g, i) => { if (!handlersOf(g).every((h) => holmesScriptKind(h) !== null))
|
|
614
|
+
preserved.push(`${event} group ${i + 1}`); });
|
|
615
|
+
continue;
|
|
616
|
+
}
|
|
617
|
+
// @implements A-SPEC-772.6 — Codex keys trust and switch-off by index (`<file>:<event>:<i>:<j>`): our group is
|
|
618
|
+
// replaced where it stands, foreign groups keep their positions, and ours is appended only when no group was ours.
|
|
619
|
+
const out = [];
|
|
620
|
+
let placed = false;
|
|
621
|
+
for (const g of old) {
|
|
622
|
+
const hs = handlersOf(g);
|
|
623
|
+
const mine = hs.filter((h) => holmesScriptKind(h) === 'kernel');
|
|
624
|
+
if (mine.length === 0) {
|
|
625
|
+
out.push(g);
|
|
626
|
+
preserved.push(`${event} group ${out.length}`);
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
if (mine.length === hs.length) {
|
|
630
|
+
if (!placed) {
|
|
631
|
+
out.push(...groups);
|
|
632
|
+
placed = true;
|
|
633
|
+
}
|
|
634
|
+
continue;
|
|
635
|
+
}
|
|
636
|
+
// @implements A-SPEC-772.7 — a mixed group with our matcher keeps our handler at its own index j (Codex keys
|
|
637
|
+
// trust per handler); with another matcher ours cannot live there, so it is stripped and our group appended.
|
|
638
|
+
const ourGroup = groups[0];
|
|
639
|
+
// @implements A-SPEC-772.8 — Codex does not match Stop; for PreToolUse a missing matcher, '', '*' and '.*' all mean every tool.
|
|
640
|
+
const everyTool = (m) => m === undefined || m === null || m === '' || m === '*' || m === '.*';
|
|
641
|
+
const matcherEq = (a, b) => event === 'Stop' || a === b || (everyTool(a) && everyTool(b));
|
|
642
|
+
const sameMatcher = ourGroup !== undefined && matcherEq(g.matcher, ourGroup.matcher) && Array.isArray(ourGroup.hooks);
|
|
643
|
+
if (!placed && sameMatcher) {
|
|
644
|
+
let first = true;
|
|
645
|
+
const hooks = [];
|
|
646
|
+
for (const h of hs) {
|
|
647
|
+
if (holmesScriptKind(h) !== 'kernel') {
|
|
648
|
+
hooks.push(h);
|
|
649
|
+
continue;
|
|
650
|
+
}
|
|
651
|
+
if (first) {
|
|
652
|
+
hooks.push(...ourGroup.hooks);
|
|
653
|
+
first = false;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
out.push({ ...g, hooks });
|
|
657
|
+
placed = true;
|
|
658
|
+
}
|
|
659
|
+
else {
|
|
660
|
+
out.push({ ...g, hooks: hs.filter((h) => holmesScriptKind(h) !== 'kernel') });
|
|
661
|
+
if (!sameMatcher)
|
|
662
|
+
notes.push(`${event} group ${out.length} shares a ${String(g.matcher ?? 'missing')} matcher with a foreign hook; the Holmes handler was moved to its own group`);
|
|
663
|
+
}
|
|
664
|
+
preserved.push(`${event} group ${out.length}`);
|
|
665
|
+
}
|
|
666
|
+
if (!placed)
|
|
667
|
+
out.push(...groups);
|
|
668
|
+
merged[event] = out;
|
|
669
|
+
}
|
|
670
|
+
for (const event of Object.keys(prevHooks))
|
|
671
|
+
if (!(event in ourHooks) && Array.isArray(prevHooks[event]))
|
|
672
|
+
prevHooks[event].forEach((_g, i) => preserved.push(`${event} group ${i + 1}`));
|
|
673
|
+
const result = { ...prev, ...oursObj, hooks: merged };
|
|
674
|
+
// @implements A-SPEC-772.6 — a file that is already current is left byte for byte.
|
|
675
|
+
const content = before !== null && JSON.stringify(result) === JSON.stringify(prev) ? before : `${JSON.stringify(result, null, 2)}\n`;
|
|
676
|
+
return { content, preserved, notes };
|
|
677
|
+
}
|
|
493
678
|
/** `.agents/hooks.json`. Top-level keys are tool namespaces; only ours is replaced. */
|
|
494
679
|
function mergeHooksJson(before, ours) {
|
|
495
680
|
const parsed = parseOr(before, ours, 'hooks.json');
|
|
496
681
|
if (isMerge(parsed))
|
|
497
682
|
return parsed;
|
|
498
683
|
const oursObj = asObject(JSON.parse(ours));
|
|
684
|
+
if (!(HOLMES in oursObj) && oursObj.hooks !== null && typeof oursObj.hooks === 'object')
|
|
685
|
+
return mergeCodexHooksByEvent(parsed.prev, oursObj, before);
|
|
499
686
|
const out = { ...parsed.prev, [HOLMES]: oursObj[HOLMES] };
|
|
500
687
|
return {
|
|
501
688
|
content: `${JSON.stringify(out, null, 2)}\n`,
|
|
@@ -611,10 +798,13 @@ function agentFiles(agent, opts) {
|
|
|
611
798
|
timeout: 30,
|
|
612
799
|
}],
|
|
613
800
|
}],
|
|
801
|
+
// @implements A-SPEC-772.3 — the group shape every other Codex hooks file uses.
|
|
614
802
|
Stop: [{
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
803
|
+
hooks: [{
|
|
804
|
+
type: 'command',
|
|
805
|
+
command: kernelCommand(packageRoot, 'stop.js'),
|
|
806
|
+
timeout: hook_process_1.STOP_HOOK_TIMEOUT_SECONDS, // A-SPEC-769.10
|
|
807
|
+
}],
|
|
618
808
|
}],
|
|
619
809
|
},
|
|
620
810
|
}, null, 2)}\n`,
|
|
@@ -623,7 +813,7 @@ function agentFiles(agent, opts) {
|
|
|
623
813
|
];
|
|
624
814
|
default:
|
|
625
815
|
// 모르는 하네스를 조용히 건너뛰면 "배선했다"는 보고와 실제가 어긋난다.
|
|
626
|
-
throw new Error(`알 수 없는 하네스: ${String(agent)} — 아는 것: ${
|
|
816
|
+
throw new Error(`알 수 없는 하네스: ${String(agent)} — 아는 것: ${agent_registry_1.AGENTS.join(', ')}`);
|
|
627
817
|
}
|
|
628
818
|
}
|
|
629
819
|
/**
|
|
@@ -48,7 +48,7 @@ exports.decisionDetail = decisionDetail;
|
|
|
48
48
|
exports.renderRefusals = renderRefusals;
|
|
49
49
|
exports.renderNonTtyHint = renderNonTtyHint;
|
|
50
50
|
exports.runInteractive = runInteractive;
|
|
51
|
-
// @implements A-SPEC-246, A-SPEC-626, A-SPEC-532.5
|
|
51
|
+
// @implements A-SPEC-246, A-SPEC-626, A-SPEC-532.5, A-SPEC-770.3, A-SPEC-770.6
|
|
52
52
|
// @implements A-SPEC-549.4 — renderPending and renderNonTtyHint in this file are the English CLI
|
|
53
53
|
// surface the Hangul-absence guard reads.
|
|
54
54
|
const execution_context_1 = require("../project/execution-context");
|
|
@@ -182,7 +182,7 @@ function grantRequest(root, id, opts) {
|
|
|
182
182
|
// a subject keeps the default, because there the clock is all that stands between the decision and a changed act.
|
|
183
183
|
const untilUsed = opts.ttlMinutes === undefined && typeof entry?.subject === 'string' && entry.subject !== '';
|
|
184
184
|
if (!entry)
|
|
185
|
-
return { ok: false, reason: `no pending request ${(0, screen_safe_1.rowField)(id, 40)} — check with ${(0, npx_bin_1.
|
|
185
|
+
return { ok: false, reason: `no pending request ${(0, screen_safe_1.rowField)(id, 40)} — check with ${(0, npx_bin_1.holmesKitCommand)(root)} approve --list` };
|
|
186
186
|
if (!recordIsSelfConsistent(entry))
|
|
187
187
|
return { ok: false, reason: TAMPERED };
|
|
188
188
|
// A "does this match what the operator saw" parameter was written here too and then removed: the
|
|
@@ -360,7 +360,7 @@ function outsideInboxFooter(outside, root) {
|
|
|
360
360
|
const target = root === undefined ? '' : ` --target ${/\s/.test(root) ? `"${root}"` : root}`;
|
|
361
361
|
// `◆` rather than the `◇` the spec sketched: §13 (approve-corpus) admits only the template's own glyphs on a decision
|
|
362
362
|
// row, and U+25C7 is of ambiguous width while U+25C6 is already furniture of this screen.
|
|
363
|
-
return `◆ ${outside} refusal(s) on this machine are outside this inbox (shell/gate refusals) — list them: ${(0, npx_bin_1.
|
|
363
|
+
return `◆ ${outside} refusal(s) on this machine are outside this inbox (shell/gate refusals) — list them: ${(0, npx_bin_1.holmesKitCommand)(root)} approve --refusals${target} · grant one: ${(0, npx_bin_1.holmesKitCommand)(root)} approve --grant <id>${target}`;
|
|
364
364
|
}
|
|
365
365
|
function renderPending(state, view, outside, root) {
|
|
366
366
|
const withFooter = (lines) => {
|
|
@@ -500,7 +500,7 @@ function renderRefusals(refusals, limit = 20, root) {
|
|
|
500
500
|
// @implements A-SPEC-770.1 — `--grant <id>`: the positional form this line named since 2026-09-06 is refused.
|
|
501
501
|
// @implements A-SPEC-770.2 — and the workspace whose log this screen read, when the caller knows it.
|
|
502
502
|
const target = root === undefined ? '' : ` --target ${/\s/.test(root) ? `"${root}"` : root}`;
|
|
503
|
-
lines.push('', `decide one: ${(0, npx_bin_1.
|
|
503
|
+
lines.push('', `decide one: ${(0, npx_bin_1.holmesKitCommand)(root)} approve --grant <id>${target}`);
|
|
504
504
|
return lines.join('\n');
|
|
505
505
|
}
|
|
506
506
|
function renderNonTtyHint(state) {
|
|
@@ -239,7 +239,29 @@ export type CodexGateReading = {
|
|
|
239
239
|
timeout: number | null;
|
|
240
240
|
}[];
|
|
241
241
|
untrusted: string[];
|
|
242
|
+
/** @implements A-SPEC-772.5 — Codex Holmes Stops below 75 s that are not switched off, and whether Codex runs them now. */
|
|
243
|
+
shortStops?: {
|
|
244
|
+
file: string;
|
|
245
|
+
runs: boolean;
|
|
246
|
+
}[];
|
|
242
247
|
};
|
|
248
|
+
/**
|
|
249
|
+
* One row per harness: has this harness's PreToolUse or Stop hook been observed running in the target within 24 h?
|
|
250
|
+
* Measured 2026-10-17: nothing recorded a hook run, so a governed Codex session could not tell it was governed. The
|
|
251
|
+
* row reports an observation, never enforcement; a target without `.ax` is not a governed workspace and gets none.
|
|
252
|
+
*/
|
|
253
|
+
/**
|
|
254
|
+
* @implements A-SPEC-772.11 — the runtime binding row's activation words, narrowed by --agent: "observed (claude)"
|
|
255
|
+
* beside a Codex-only report read as Codex's activation.
|
|
256
|
+
*/
|
|
257
|
+
export declare function activationText(observed: string[], agent?: string): string;
|
|
258
|
+
/**
|
|
259
|
+
* @implements A-SPEC-770.3 — the nearest ancestor node_modules copy of holmes-kit, which the bare npx command run from the
|
|
260
|
+
* target (or below) resolves before any global install. Field incident 2026-10-17: ~/node_modules held 0.19.3 and a
|
|
261
|
+
* 0.35.23 refusal's own grant hint answered "no pending request matches". No copy: no row.
|
|
262
|
+
*/
|
|
263
|
+
export declare function npxResolutionCheck(target: string, runningVersion: string): Check | null;
|
|
264
|
+
export declare function hookObservationChecks(targetIn: string, now?: number, agent?: Agent): Check[];
|
|
243
265
|
/**
|
|
244
266
|
* Codex runs the Holmes PreToolUse gate here but no Holmes Stop gate: Codex sessions end without the constitution
|
|
245
267
|
* check. Measured 2026-10-16 in the dev root (user Stop switched off at timeout 30, project `Stop: []`). No row when no
|