Repository navigation
Description
Problem
Every supported client can run a command on agent events such as session start or before a tool call, and each reads those hooks from a project file. Maintainers who want the same hook for all contributors have to write it five times, in five formats, with five sets of tool names. The manifest has no declaration for it.
Hooks are also the one kind of automation that fits OpenLune's model. Scheduled automations live in the contributor's account or app and cannot be published as files (see #71); hooks can.
Proposal
A hooks section that declares the wiring once:
hooks:
format-on-write:
event: tool.after # session.start | tool.before | tool.after | agent.stop
tools: [files.write] # existing capability names; omitted = every tool
command: python3
args: [openlune/hooks/format.py]
timeout: 60 # seconds; omitted = client default- Events: the four that all five clients document. Client-specific events stay out.
- Tool filter: the capability vocabulary agents already use. Each adapter maps it to its native tool names for the matcher.
- Command: a command with literal arguments, reviewed in plan and apply like an MCP launch command.
- Portable wiring, native protocol: the script receives the client's own JSON payload and answers in the client's own contract. OpenLune does not translate either in the first version.
What each client would get
| Client | Output | Shell / file-write tool names | Exit 2 blocks a tool | Client's own gate |
|---|---|---|---|---|
| Claude Code | hooks.<Event> entries in .claude/settings.json |
Bash / Edit, Write |
Yes | Workspace trust |
| Codex | .codex/hooks.json |
Bash / apply_patch |
Yes | Project trust, then per-hook review in /hooks, repeated after every change |
| Copilot | .github/hooks/openlune.json |
bash, powershell / edit, create |
Yes (any non-zero) | Folder trust |
| Cursor | .cursor/hooks.json |
Shell / Write |
Yes | Workspace trust |
| Antigravity | .agents/hooks.json |
run_command / write_to_file, replace_file_content, multi_replace_file_content |
No: non-zero is ignored, a deny needs JSON | None documented |
Ownership
Claude Code, Codex and Cursor keep hooks as unnamed array items, so the current file-or-keyed-entry ownership cannot own a single hook. Owning the declared hooks as one set per client (the whole file, or Claude Code's per-event entry in its shared settings file) needs no new ownership machinery.
Consequences: an unmanaged project hooks file at the same path stops planning, as other unmanaged collisions do, and a contributor's own hooks belong in user-level files, which every client merges with project hooks.
What is portable without translation
- Side-effect hooks are fully portable: session setup, formatting after a write, logging.
- A guard that exits 2 to block a tool works on four of five clients. On Antigravity it does not block.
- Stop-time "keep going" checks are not portable: Copilot, Cursor and Antigravity need JSON output for that.
Known rough edges
- Double runs: Copilot always reads
.claude/settings.json, and Cursor does by default. A checkout applied for Claude Code and then for either of them runs each hook twice, because outputs of a previously selected client are not removed. Plan would have to flag the overlap, as it does for instruction files. - Codex re-review: Codex skips a new or changed hook until the contributor reviews it, and its trust key includes the hook's position, so adding or reordering hooks forces another review. Apply should say so when it changes Codex hooks.
- Default timeouts differ: 600 seconds on Claude Code and Codex, 30 on Copilot and Antigravity.
Open questions
- Launcher or native command? Only Claude Code and Copilot CLI accept an argument list. Codex, Cursor and Antigravity take one shell string, run by
sh, PowerShell orcmddepending on the host, and the clients disagree on the working directory.- Rendering
openlune hook run <id>, as stdio MCP does withmcp run, keeps literal arguments, runs from the repository root, can useinstall.tools, and runs only what the contributor last reviewed, so pulling a manifest change cannot alter a hook before the next apply. The cost is OpenLune in the path of every matching tool call, and Codex's per-hook review seeing only the launcher line. - Declaring a shell string and passing it through unchanged needs far less code, but leaves cross-OS and cross-client behavior to the maintainer.
- Rendering
- Should a capability with no documented native tool name on a client be a deviation (the hook never fires for it) or a rejection?
- Is one owned set per client acceptable, given that it stops on
6D75
an existing unmanaged
.cursor/hooks.json,.codex/hooks.jsonor.agents/hooks.json? - Should the launcher, if chosen, later translate a blocking exit into Antigravity's JSON deny, or does that stay a documented limit?
Not in the first version
MCP tool filters, session-start sources (startup vs resume), prompt and HTTP handler types, client-specific events, and cloud agents.
Not verified
The details above come from each vendor's documentation, and from Codex source where its documentation is silent. Nothing was run against a client.
- Cursor's tool input shape, and Antigravity's shell and working directory for workspace hooks.
- Copilot's default working directory, and hook support in JetBrains.
- Whether each client fires the rendered hooks at all, which is qualification work per client.
Activity