Repository navigation
Namespace agent hook CLI commands - #3298
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughReplaces legacy per-agent top-level hook commands with a unified Changes
Sequence Diagram(s)sequenceDiagram
participant Agent as Agent process
participant Wrapper as Injected wrapper
participant CLI as cmux CLI
participant Dispatcher as Hooks dispatcher
participant Service as CMUX handler
Agent->>Wrapper: lifecycle/event trigger
Wrapper->>CLI: execute "cmux hooks <agent>|feed --source <agent> <event>"
CLI->>Dispatcher: determine routing (no-socket vs socket)
alt no-socket
Dispatcher->>CLI: handle help/no-op locally
else socket
Dispatcher->>Service: deliver event to agent bridge/handler
Service-->>Dispatcher: ack/result
end
Dispatcher-->>CLI: return status/output
CLI-->>Wrapper: propagate exit/output
Wrapper-->>Agent: return result
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/8 reviews remaining, refill in 6 minutes and 33 seconds.Comment |
Greptile SummaryThis PR consolidates all agent hook CLI commands under a single Confidence Score: 4/5Safe to merge; logic is sound and backward-compat aliases are correctly wired. No P0 or P1 findings. All three comments are P2: one style suggestion ( CLI/cmux.swift — specifically the new Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["cmux hooks <args>"] --> B["runHooksNoSocketCommand(commandArgs)"]
B -->|"setup / install"| C["runSetupHooks(uninstall: false)"]
B -->|"uninstall / remove"| D["runSetupHooks(uninstall: true)"]
B -->|"help / --help"| E["print subcommandUsage('hooks')"]
B -->|"<agent> install"| F["installHooksForAgent(def, arguments)"]
B -->|"<agent> uninstall"| G["uninstallHooksForAgent(def, arguments)"]
B -->|"feed / claude / <agent> <event>"| H{"returns false\n(needs socket)"}
H --> I["hooksCommandNeedsCmuxSurface?"]
I -->|"yes & no CMUX_SURFACE_ID"| J["print '{}' — graceful no-op"]
I -->|"no / has CMUX_SURFACE_ID"| K["runHooksSocketCommand(commandArgs)"]
K -->|"feed"| L["runFeedHook"]
K -->|"claude"| M["runClaudeHook"]
K -->|"<agent>"| N["runGenericAgentHook(def)"]
F -->|"opencode + --project"| O["installOpenCodePlugin(projectLocal: true)"]
F -->|"opencode (global)"| P["installAgentHooks + installOpenCodePlugin(global)"]
F -->|"other agent"| Q["installAgentHooks(def)"]
subgraph "Compat aliases (always dispatched)"
R["cmux claude-hook <event>"] --> M
S["cmux codex install-hooks"] --> Q
T["cmux codex-hook <event>"] --> N
end
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/test_opencode_plugin_install.py (1)
211-216: Consider explicitly rejecting legacy hook tokens in args log.Current checks ensure the new token exists once, but won’t fail if a legacy token appears alongside it.
Optional hardening patch
if "hooks opencode session-start" not in args_log: print(f"FAIL: plugin did not invoke hooks opencode session-start, got {args_log!r}") return 1 + if "opencode-hook session-start" in args_log: + print(f"FAIL: plugin emitted legacy opencode-hook command, got {args_log!r}") + return 1 if args_log.count("hooks opencode session-start") != 1: print(f"FAIL: plugin invoked duplicate session-start hooks, got {args_log!r}") return 1🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/test_opencode_plugin_install.py` around lines 211 - 216, The test currently only asserts that the new token "hooks opencode session-start" appears exactly once in args_log; update the test to also explicitly reject legacy hook tokens (e.g. "hooks session-start" or any older token form) by asserting those legacy strings are not present in args_log and failing the test if they are found; modify the block that inspects args_log (the same section using args_log.count("hooks opencode session-start")) to add negative checks like `if "hooks session-start" in args_log: fail` so the test fails when legacy tokens accompany the new token.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/feed.md`:
- Line 116: Update the sentence about the per-event timeout for Feed bridge
entries to avoid implying a universal 120000 ms value: either make it
agent-specific (mention that Claude’s PermissionRequest bridge is set to 125000
ms in the wrapper) or state a 120–125s range so readers know Claude uses 125s;
refer to the existing phrasing "Per-event timeout inside the agent's hook
config" and the "PermissionRequest bridge" to locate and edit the line
accordingly.
---
Nitpick comments:
In `@tests/test_opencode_plugin_install.py`:
- Around line 211-216: The test currently only asserts that the new token "hooks
opencode session-start" appears exactly once in args_log; update the test to
also explicitly reject legacy hook tokens (e.g. "hooks session-start" or any
older token form) by asserting those legacy strings are not present in args_log
and failing the test if they are found; modify the block that inspects args_log
(the same section using args_log.count("hooks opencode session-start")) to add
negative checks like `if "hooks session-start" in args_log: fail` so the test
fails when legacy tokens accompany the new token.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b2022f8f-019b-4267-b87e-6591ad577513
📒 Files selected for processing (12)
CLI/cmux.swiftResources/Localizable.xcstringsResources/bin/claudeResources/opencode-plugin.jsSources/RestorableAgentSession.swiftSources/cmuxApp.swiftdocs/cli-contract.mddocs/feed.mddocs/notifications.mdtests/test_claude_wrapper_hooks.pytests/test_codex_hook_agent_ports.pytests/test_opencode_plugin_install.py
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8268492e85
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
8268492 to
6beb3db
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6beb3dbe1c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
docs/feed.md (1)
116-116:⚠️ Potential issue | 🟡 MinorClarify the timeout wording to avoid implying a single universal value.
Line 116 still reads like all agents use
120 000 ms. Please make this agent-specific (or state a ~120–125s range) so Claude’sPermissionRequesttimeout behavior is not misread.Suggested doc tweak
-Per-event timeout inside the agent's hook config is bumped to 120 000 ms specifically for Feed bridge entries, so a user taking 30 seconds to approve something doesn't trip the agent's default 5 000 ms timeout. +Per-event timeout inside agent hook configs is raised to roughly 120s for Feed bridge entries (Claude uses 125s for PermissionRequest), so a user taking 30 seconds to approve something doesn't trip default 5 000 ms hook timeouts.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/feed.md` at line 116, The sentence currently implies a universal 120000 ms timeout; update the wording in the docs to clarify this is agent-specific by stating that the per-event timeout in the agent's hook config for Feed bridge entries is increased to ~120000 ms (or a ~120–125s range) so it only affects Feed bridge PermissionRequest handling and not all agents; mention "Feed bridge entries", "agent's hook config", and "PermissionRequest" to make the scope explicit.
🧹 Nitpick comments (2)
CLI/cmux.swift (1)
8364-8393: Consider generating the agent list in help text fromagentDefs.The hardcoded agent list in usage text can drift from
Self.agentDefs. Building this section dynamically would reduce future maintenance misses.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@CLI/cmux.swift` around lines 8364 - 8393, The help text for the "hooks" command hardcodes the Agents list and can drift from the canonical definitions; instead, update the "hooks" usage branch (the "case \"hooks\"" return) to programmatically build the Agents section from Self.agentDefs (or its member name) when composing the multi-line usage string—generate a comma-separated list from Self.agentDefs and inject it into the usage/help string so the printed Agents line always reflects the current definitions.docs/cli-contract.md (1)
291-292: Consider adding a no-socket probe forcmux hooks feed --help.You now validate
hooks --helpandcodex --help; adding ahooks feedprobe would better lock the replacement path for the removedfeed-hooksurface.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/cli-contract.md` around lines 291 - 292, Add a no-socket probe entry for the removed feed-hook surface by documenting the `cmux hooks feed --help` usage string alongside the existing `cmux hooks --help` and `cmux codex --help` lines; specifically add a line like ``- `cmux hooks feed --help` -> `Usage: cmux hooks feed [--agent <name>] [--yes|-y]` `` in the same section so the docs lock the replacement path for the old `feed-hook` command.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@CLI/cmux.swift`:
- Around line 18588-18593: The uninstall path in uninstallHooksForAgent
currently always calls uninstallAgentHooks(def) for the "opencode" agent,
causing global hooks to be removed even when the user passed "--project"; change
the logic so that uninstallAgentHooks(def) is only called when arguments does
NOT contain "--project", and when "--project" is present only call
uninstallOpenCodePlugin(projectLocal: true) (i.e., mirror the install path
behavior), so update uninstallHooksForAgent to check
arguments.contains("--project") before deciding between uninstallAgentHooks and
uninstallOpenCodePlugin.
---
Duplicate comments:
In `@docs/feed.md`:
- Line 116: The sentence currently implies a universal 120000 ms timeout; update
the wording in the docs to clarify this is agent-specific by stating that the
per-event timeout in the agent's hook config for Feed bridge entries is
increased to ~120000 ms (or a ~120–125s range) so it only affects Feed bridge
PermissionRequest handling and not all agents; mention "Feed bridge entries",
"agent's hook config", and "PermissionRequest" to make the scope explicit.
---
Nitpick comments:
In `@CLI/cmux.swift`:
- Around line 8364-8393: The help text for the "hooks" command hardcodes the
Agents list and can drift from the canonical definitions; instead, update the
"hooks" usage branch (the "case \"hooks\"" return) to programmatically build the
Agents section from Self.agentDefs (or its member name) when composing the
multi-line usage string—generate a comma-separated list from Self.agentDefs and
inject it into the usage/help string so the printed Agents line always reflects
the current definitions.
In `@docs/cli-contract.md`:
- Around line 291-292: Add a no-socket probe entry for the removed feed-hook
surface by documenting the `cmux hooks feed --help` usage string alongside the
existing `cmux hooks --help` and `cmux codex --help` lines; specifically add a
line like ``- `cmux hooks feed --help` -> `Usage: cmux hooks feed [--agent
<name>] [--yes|-y]` `` in the same section so the docs lock the replacement path
for the old `feed-hook` command.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: fb64a868-9a24-469b-8820-ca8307308c88
📒 Files selected for processing (12)
CLI/cmux.swiftResources/Localizable.xcstringsResources/bin/claudeResources/opencode-plugin.jsSources/RestorableAgentSession.swiftSources/cmuxApp.swiftdocs/cli-contract.mddocs/feed.mddocs/notifications.mdtests/test_claude_wrapper_hooks.pytests/test_codex_hook_agent_ports.pytests/test_opencode_plugin_install.py
✅ Files skipped from review due to trivial changes (6)
- docs/notifications.md
- Resources/opencode-plugin.js
- tests/test_codex_hook_agent_ports.py
- Sources/cmuxApp.swift
- tests/test_claude_wrapper_hooks.py
- Resources/Localizable.xcstrings
🚧 Files skipped from review as they are similar to previous changes (3)
- Sources/RestorableAgentSession.swift
- tests/test_opencode_plugin_install.py
- Resources/bin/claude
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
CLI/cmux.swift (1)
19252-19256:⚠️ Potential issue | 🟠 MajorProject-local OpenCode uninstall still tears down the global integration.
This is still asymmetric with the install path:
cmux hooks opencode uninstall --projectremoves the global hook config before removing the project-local plugin, so a local cleanup can break the user's global OpenCode setup.Suggested fix
private func uninstallHooksForAgent(_ def: AgentHookDef, arguments: [String]) throws { if def.name == "opencode" { - try uninstallAgentHooks(def) - try uninstallOpenCodePlugin(projectLocal: arguments.contains("--project")) + let projectLocal = arguments.contains("--project") + if projectLocal { + try uninstallOpenCodePlugin(projectLocal: true) + return + } + try uninstallAgentHooks(def) + try uninstallOpenCodePlugin(projectLocal: false) return } try uninstallAgentHooks(def) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@CLI/cmux.swift` around lines 19252 - 19256, uninstallHooksForAgent currently calls uninstallAgentHooks before uninstallOpenCodePlugin regardless of project-local flag, which causes global OpenCode teardown when running "cmux hooks opencode uninstall --project"; update uninstallHooksForAgent so that when arguments.contains("--project") is true it skips calling uninstallAgentHooks and only calls uninstallOpenCodePlugin(projectLocal: true), otherwise it should perform the global uninstall by calling uninstallAgentHooks and uninstallOpenCodePlugin(projectLocal: false) (or the existing call pattern). Reference the functions uninstallHooksForAgent, uninstallAgentHooks, and uninstallOpenCodePlugin to implement the conditional branching and preserve the early return behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@CLI/cmux.swift`:
- Around line 8367-8370: The help text advertises the --project flag for all
"cmux hooks <agent> install|uninstall" commands even though the flag is only
honored for the opencode agent; update the usage/help strings in CLI/cmux.swift
so that the --project flag is scoped to OpenCode only (e.g., change "cmux hooks
<agent> install [--project]" and "cmux hooks <agent> uninstall [--project]" to
indicate the flag is for opencode only or only present for the opencode
subcommand). Locate the usage lines containing the exact strings "Usage: cmux
hooks <agent> install [--project]" and "Usage: cmux hooks <agent> uninstall
[--project]" and either remove the [--project] option there or replace it with a
parenthetical like "[--project (opencode only)]" so the help matches actual
behavior.
---
Duplicate comments:
In `@CLI/cmux.swift`:
- Around line 19252-19256: uninstallHooksForAgent currently calls
uninstallAgentHooks before uninstallOpenCodePlugin regardless of project-local
flag, which causes global OpenCode teardown when running "cmux hooks opencode
uninstall --project"; update uninstallHooksForAgent so that when
arguments.contains("--project") is true it skips calling uninstallAgentHooks and
only calls uninstallOpenCodePlugin(projectLocal: true), otherwise it should
perform the global uninstall by calling uninstallAgentHooks and
uninstallOpenCodePlugin(projectLocal: false) (or the existing call pattern).
Reference the functions uninstallHooksForAgent, uninstallAgentHooks, and
uninstallOpenCodePlugin to implement the conditional branching and preserve the
early return behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b0d954a3-25da-487c-955d-8126ecc93e71
📒 Files selected for processing (3)
CLI/cmux.swiftResources/Localizable.xcstringsSources/cmuxApp.swift
✅ Files skipped from review due to trivial changes (2)
- Sources/cmuxApp.swift
- Resources/Localizable.xcstrings
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 583bc081da
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
♻️ Duplicate comments (1)
CLI/cmux.swift (1)
8367-8370:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winScope
--projectto OpenCode in the hooks help.These usage lines still imply every agent accepts
--project, but the new installers only honor that flag foropencode. That makes commands likecmux hooks codex install --projectlook supported even though the flag is ignored.Suggested wording
- Usage: cmux hooks setup [--agent <name>] [--yes|-y] - cmux hooks uninstall [--agent <name>] [--yes|-y] - cmux hooks <agent> install [--project] [--yes|-y] - cmux hooks <agent> uninstall [--project] [--yes|-y] + Usage: cmux hooks setup [--agent <name>] [--yes|-y] + cmux hooks uninstall [--agent <name>] [--yes|-y] + cmux hooks <agent> install [--yes|-y] + cmux hooks <agent> uninstall [--yes|-y] + cmux hooks opencode install [--project] [--yes|-y] + cmux hooks opencode uninstall [--project] [--yes|-y]🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@CLI/cmux.swift` around lines 8367 - 8370, The help usage currently shows "[--project]" for generic agent install/uninstall which wrongly suggests all agents accept that flag; update the usage text in the CLI/cmux.swift help block so that the --project option is only shown for the opencode agent (e.g. change "cmux hooks <agent> install [--project]" and "cmux hooks <agent> uninstall [--project]" to "cmux hooks opencode install [--project]" and "cmux hooks opencode uninstall [--project]") so help output accurately reflects that only the opencode installer honors --project.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@CLI/cmux.swift`:
- Around line 8367-8370: The help usage currently shows "[--project]" for
generic agent install/uninstall which wrongly suggests all agents accept that
flag; update the usage text in the CLI/cmux.swift help block so that the
--project option is only shown for the opencode agent (e.g. change "cmux hooks
<agent> install [--project]" and "cmux hooks <agent> uninstall [--project]" to
"cmux hooks opencode install [--project]" and "cmux hooks opencode uninstall
[--project]") so help output accurately reflects that only the opencode
installer honors --project.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 48ed5a29-3054-4666-9e4e-883c3aca4681
⛔ Files ignored due to path filters (1)
.github/swift-file-length-budget.tsvis excluded by!**/*.tsv
📒 Files selected for processing (2)
CLI/cmux.swiftdocs/feed.md
🚧 Files skipped from review as they are similar to previous changes (1)
- docs/feed.md
Summary
cmux hooks ...cmux codex install-hooks|uninstall-hooksandcmux claude-hook ...Testing
git diff --check./scripts/reload.sh --tag hookns2cmux hooks --helpcmux codex --helpcmux --help | rg 'codex-hook|feed-hook|hooks install|hooks remove|hooks .*install-hooks|hooks .*uninstall-hooks'(no matches)\n -cmux hooks codex install-hooks(errors, no alias)\n -printf '{}' | cmux hooks codex session-start\n -printf '{}' | cmux hooks feed --source codex\n -CMUX_SOCKET_PATH=/tmp/cmux-hookns2-missing.sock cmux codex-hook session-start(socket error, no pre-socket alias)\n -CMUX_SOCKET_PATH=/tmp/cmux-hookns2-missing.sock cmux feed-hook --source codex(socket error, no pre-socket alias)\n\n## Notes\n-codex-hookandfeed-hookare intentionally not preserved as runnable aliases because they are not in the public main help surface.\n- Stale Codex hook config markers are still pruned when reinstalling or uninstalling, because the publiccmux codex install-hookscommand on main could have generated those config entries.Summary by CodeRabbit
New Features
Changes
Documentation
Tests