diff --git a/content/docs/beta/troubleshooting/configuration.en.mdx b/content/docs/beta/troubleshooting/configuration.en.mdx index 8552365..6d8cb26 100644 --- a/content/docs/beta/troubleshooting/configuration.en.mdx +++ b/content/docs/beta/troubleshooting/configuration.en.mdx @@ -107,4 +107,5 @@ source and value, and a new runtime session behaves as expected. - [Runtime cannot find a Skill or Agent](./runtime-cannot-find-skill-or-agent) - [Kit installation problems](./kit-installation) +- [Grok CLI Hook errors](./grok-hooks) - [CLI reference](../reference/cli) diff --git a/content/docs/beta/troubleshooting/configuration.vi.mdx b/content/docs/beta/troubleshooting/configuration.vi.mdx index 04e1e82..f513de5 100644 --- a/content/docs/beta/troubleshooting/configuration.vi.mdx +++ b/content/docs/beta/troubleshooting/configuration.vi.mdx @@ -106,4 +106,5 @@ giá trị, và session runtime mới hoạt động như mong đợi. - [Runtime không tìm thấy Skill hoặc Agent](./runtime-cannot-find-skill-or-agent) - [Lỗi cài Kit](./kit-installation) +- [Lỗi Hook trên Grok CLI](./grok-hooks) - [Tham chiếu CLI](../reference/cli) diff --git a/content/docs/beta/troubleshooting/grok-hooks.en.mdx b/content/docs/beta/troubleshooting/grok-hooks.en.mdx new file mode 100644 index 0000000..2506d07 --- /dev/null +++ b/content/docs/beta/troubleshooting/grok-hooks.en.mdx @@ -0,0 +1,114 @@ +--- +title: Grok CLI Hook errors +description: Stop Grok from failing Claude-compat Hooks without editing AgentKit-managed settings.json, then re-enable Claude scan after an AgentKit update that folds global Hook commands. +--- + +Use this page when Grok CLI reports Hook errors on every prompt or tool call, +especially a missing `~/.claude/node`, after a global AgentKit Kit install for +Claude Code. + +## Confirm the symptom + +Typical signs: + +- Grok shows Hook errors on `SessionStart`, `UserPromptSubmit`, `PreToolUse`, + `PostToolUse`, or `Stop`. +- The failing path is `~/.claude/node`, or Node starts without the Hook script. +- One-liner Hooks already stored as a single `command` string still run. Entries + with `"command": "node"` plus an `args` array fail. + +Grok reads `~/.claude/settings.json` by default. It treats `command` as a path +relative to that JSON file, or as an inline shell command when the string +contains whitespace. It does not use Claude's `args` array. + +## Do not edit AgentKit-managed settings + +Do not rewrite `command` / `args` inside `~/.claude/settings.json` or +`/.claude/settings.json`. `ak kit update` matches managed Hooks by +the `.cjs` script path and writes the exec-form back. + +Do not create `~/.claude/node` as a symlink to your real Node binary. Grok still +drops `args`, so that shim would start Node with no script. + +Do not add a second copy of the same Hooks under `~/.grok/hooks/` while Claude +compat scanning stays on. Grok merges sources and the Hooks would run twice. + +## Workaround until AgentKit folds global Hooks + +Keep Claude Code on the AgentKit-managed settings file. Point Grok at its own +Hook files and turn off Claude Hook scanning. + +1. In `~/.grok/config.toml`: + +```toml +[compat.claude] +hooks = false +``` + +The same switch is `GROK_CLAUDE_HOOKS_ENABLED=0` for one process. + +2. Add Grok-native Hook files under `~/.grok/hooks/`. Use a one-liner `command` + that includes the script path, matching the form Grok already accepts: + +```json +{ + "hooks": { + "SessionStart": [ + { + "matcher": "*", + "hooks": [ + { + "type": "command", + "command": "node '/Users/you/.claude/hooks/session-init.cjs'" + } + ] + } + ] + } +} +``` + +Copy only the AgentKit Hooks you need from `~/.claude/settings.json`. Keep +timeouts and matchers. Quote paths that contain spaces. + +3. Restart Grok and inspect `/hooks`. Project Hooks also need `/hooks-trust` or + `--trust` before they run. + +This overlay lives outside AgentKit ownership. Kit update and uninstall will +not create, refresh, or delete `~/.grok/hooks/`. Re-check the overlay when a +Kit adds or removes a Hook. + +Project-native Claude settings already emit portable `node "