Skip to content

Add Cursor Agent and Gemini CLI hook integrations#10

Merged
codejunkie99 merged 3 commits into
codejunkie99:masterfrom
akeyx:feat/cursor-gemini-hooks
May 18, 2026
Merged

Add Cursor Agent and Gemini CLI hook integrations#10
codejunkie99 merged 3 commits into
codejunkie99:masterfrom
akeyx:feat/cursor-gemini-hooks

Conversation

@akeyx
Copy link
Copy Markdown
Contributor

@akeyx akeyx commented May 8, 2026

Summary

Adds automatic interception support for Cursor Agent and Gemini CLI alongside the existing Claude Code hooks, making ztk a multi-agent compression layer.

What changed

  • Cursor Agent hooks (src/hooks/cursor*.zig) — installs a PreToolUse hook into .cursor/hooks.json that invokes ztk cursor-rewrite for run_terminal_command tool calls
  • Gemini CLI hooks (src/hooks/gemini*.zig) — installs a BeforeTool hook into .gemini/settings.json that invokes ztk gemini-rewrite for run_shell_command tool calls
  • Unified ztk init — detects which agent config directories exist (.claude/, .cursor/, .gemini/) and installs hooks only for those agents; errors if none are found
  • CLI subcommands — adds cursor-rewrite and gemini-rewrite subcommands
  • README — updated to reflect multi-agent support with a supported agents table
  • 38 new tests (269 total) covering init, rewrite, and edge cases for both new integrations

Design decisions

  • Module structure mirrors the existing claude_* pattern exactly (per-agent init.zig, init_build.zig, rewrite.zig, test.zig, and a root module)
  • Reuses claude_rewrite.extractCommand for command parsing since the JSON shape is compatible
  • writeAtomic follows the direct-write pattern from cursor_init.zig rather than temp+rename
  • Error handling follows upstream conventions (catch return error.HomeNotSet, FileNotFound discrimination)

Testing

All 269 tests pass (zig build test). Manually verified ztk init -g correctly detects and installs hooks for present agents only.

akeyx added 3 commits May 8, 2026 12:55
- Add cursor-rewrite subcommand for Cursor Agent PreToolUse hooks
- Add gemini-rewrite subcommand for Gemini CLI BeforeTool hooks
- Unify ztk init to auto-detect and install hooks for all supported
  agents (.claude/, .cursor/, .gemini/) present on the system
- Add cursor.zig, cursor_init.zig, cursor_rewrite.zig, cursor_test.zig
- Add gemini.zig, gemini_init.zig, gemini_init_build.zig,
  gemini_rewrite.zig, gemini_test.zig
- 262 tests pass including 7 new Gemini-specific tests
- resolveSettingsPath: use 'catch return error.HomeNotSet' instead of
  'try' for clearer error propagation when HOME is unset
- readIfExists: discriminate FileNotFound from other errors instead of
  swallowing all errors as null
- Replace Claude Code-specific language with agent-agnostic framing
- Document Cursor Agent and Gemini CLI as supported agents
- Add supported agents table with hook mechanisms
- Update test count from 231 to 269
- Clarify that ztk init detects and installs for all present agents
@codejunkie99 codejunkie99 merged commit 83f30c6 into codejunkie99:master May 18, 2026
@akeyx akeyx deleted the feat/cursor-gemini-hooks branch May 19, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants