Repository navigation
feat(cli): install Cursor and Antigravity hooks globally with --global - #367
Conversation
`shelltime cursor install --global` and `shelltime agy install --global` write ~/.cursor/hooks.json and a `shelltime-global` group of ~/.gemini/config/hooks.json, which the agents run in every folder (never in their cloud runs). The global command is the project's self-contained one without --project, so a moved or removed shelltime never fails a hook, and it rewrites what older versions left there (absolute binary paths, the global `shelltime` group) in place. A project's hook still leaves an event to the global hooks when they record it: userHooksRecord now also counts the --global command (AgentHooksStatus.GlobalEvents), which finds the binaries wherever the project's does. The global Antigravity group is named apart from the project's in case a workspace group replaces a global one of the same name. `uninstall --global` cleans only the global file. doctor checks the global file in and outside repositories: an older version's hooks with a missing binary fail and a copied project command warns, both fixed by `install --global`, and a repository without hooks of its own is only a note while global hooks are installed. init mentions --global. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014EpZRfhTSPrQA29S15UhWm
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
⏱️
|
| Scenario | base | head | Δ | p | |
|---|---|---|---|---|---|
Startup/floor |
307 µs ±3% | 307 µs ±1% | ~ | 0.796 | A/A |
Startup/version |
3.20 ms ±2% | 3.17 ms ±1% | -1.16% | 0.003 | ✅ |
Track/daemon/pre |
3.35 ms ±1% | 3.33 ms ±2% | ~ | 0.218 | ✅ |
Track/daemon/post |
3.37 ms ±1% | 3.34 ms ±1% | -0.90% | 0.003 | ✅ |
Track/direct/pre |
3.37 ms ±1% | 3.33 ms ±2% | ~ | 0.105 | ✅ |
Track/direct/post |
4.57 ms ±1% | 4.55 ms ±2% | ~ | 0.247 | ✅ |
Track/direct/post-sync |
6.55 ms ±2% | 6.49 ms ±1% | ~ | 0.143 | ✅ |
Binary size: 23.6 MiB → 23.6 MiB (+0.1%).
CPU, tail latency and memory
Per exec, base → head (Δ when significant).
| Scenario | p95 wall | user CPU | sys CPU | peak RSS |
|---|---|---|---|---|
Startup/floor |
356 µs → 358 µs | 229 µs → 224 µs | 44 µs → 48 µs | 9.4 MiB → 9.4 MiB |
Startup/version |
3.43 ms → 3.37 ms (-1.66%) | 1.56 ms → 1.51 ms | 2.04 ms → 2.02 ms | 16.9 MiB → 17.1 MiB (+1.10%) |
Track/daemon/pre |
3.57 ms → 3.53 ms | 1.67 ms → 1.66 ms | 2.06 ms → 2.10 ms | 17.6 MiB → 18.0 MiB (+2.47%) |
Track/daemon/post |
3.61 ms → 3.54 ms (-1.87%) | 1.71 ms → 1.67 ms | 2.05 ms → 2.03 ms | 17.4 MiB → 17.7 MiB (+1.86%) |
Track/direct/pre |
3.59 ms → 3.56 ms | 1.65 ms → 1.60 ms | 2.11 ms → 2.14 ms | 17.6 MiB → 18.0 MiB (+2.48%) |
Track/direct/post |
4.81 ms → 4.78 ms | 2.60 ms → 2.65 ms | 2.45 ms → 2.36 ms | 18.0 MiB → 18.5 MiB (+2.42%) |
Track/direct/post-sync |
6.96 ms → 6.88 ms (-1.11%) | 4.76 ms → 4.84 ms | 3.76 ms → 3.73 ms | 20.6 MiB → 21.0 MiB (+1.60%) |
benchstat
goos: linux
goarch: amd64
pkg: github.com/malamtime/cli/perf
cpu: Intel(R) Xeon(R) 6975P-C
│ base │ head │
│ sec/op │ sec/op vs base │
Startup/floor-4 306.9µ ± 3% 307.1µ ± 1% ~ (p=0.796 n=10)
Startup/version-4 3.205m ± 2% 3.168m ± 1% -1.16% (p=0.003 n=10)
Track/daemon/pre-4 3.353m ± 1% 3.332m ± 2% ~ (p=0.218 n=10)
Track/daemon/post-4 3.366m ± 1% 3.335m ± 1% -0.90% (p=0.003 n=10)
Track/direct/pre-4 3.370m ± 1% 3.334m ± 2% ~ (p=0.105 n=10)
Track/direct/post-4 4.574m ± 1% 4.549m ± 2% ~ (p=0.247 n=10)
Track/direct/post-sync-4 6.547m ± 2% 6.490m ± 1% ~ (p=0.143 n=10)
geomean 2.726m 2.707m -0.72%
│ base │ head │
│ p50-sec/op │ p50-sec/op vs base │
Startup/floor-4 298.4µ ± 3% 296.6µ ± 1% ~ (p=0.529 n=10)
Startup/version-4 3.197m ± 1% 3.157m ± 1% -1.27% (p=0.015 n=10)
Track/daemon/pre-4 3.340m ± 1% 3.326m ± 1% ~ (p=0.436 n=10)
Track/daemon/post-4 3.345m ± 1% 3.317m ± 1% -0.83% (p=0.009 n=10)
Track/direct/pre-4 3.356m ± 2% 3.324m ± 1% ~ (p=0.143 n=10)
Track/direct/post-4 4.556m ± 1% 4.528m ± 1% ~ (p=0.218 n=10)
Track/direct/post-sync-4 6.554m ± 2% 6.503m ± 1% ~ (p=0.529 n=10)
geomean 2.708m 2.687m -0.78%
│ base │ head │
│ p95-sec/op │ p95-sec/op vs base │
Startup/floor-4 356.0µ ± 11% 357.7µ ± 10% ~ (p=0.912 n=10)
Startup/version-4 3.431m ± 4% 3.374m ± 1% -1.66% (p=0.000 n=10)
Track/daemon/pre-4 3.570m ± 3% 3.528m ± 4% ~ (p=0.143 n=10)
Track/daemon/post-4 3.608m ± 1% 3.540m ± 1% -1.87% (p=0.000 n=10)
Track/direct/pre-4 3.593m ± 1% 3.557m ± 2% ~ (p=0.075 n=10)
Track/direct/post-4 4.811m ± 2% 4.784m ± 2% ~ (p=0.247 n=10)
Track/direct/post-sync-4 6.958m ± 2% 6.882m ± 1% -1.11% (p=0.043 n=10)
geomean 2.939m 2.909m -0.99%
│ base │ head │
│ peak-rss-B │ peak-rss-B vs base │
Startup/floor-4 9.399Mi ± 1% 9.426Mi ± 2% ~ (p=0.566 n=10)
Startup/version-4 16.87Mi ± 0% 17.06Mi ± 0% +1.10% (p=0.000 n=10)
Track/daemon/pre-4 17.57Mi ± 0% 18.00Mi ± 0% +2.47% (p=0.000 n=10)
Track/daemon/post-4 17.42Mi ± 0% 17.75Mi ± 0% +1.86% (p=0.000 n=10)
Track/direct/pre-4 17.59Mi ± 0% 18.03Mi ± 0% +2.48% (p=0.000 n=10)
Track/direct/post-4 18.03Mi ± 0% 18.47Mi ± 0% +2.42% (p=0.000 n=10)
Track/direct/post-sync-4 20.65Mi ± 0% 20.98Mi ± 0% +1.60% (p=0.000 n=10)
geomean 16.39Mi 16.68Mi +1.74%
│ base │ head │
│ sys-sec/op │ sys-sec/op vs base │
Startup/floor-4 43.77µ ± 24% 48.02µ ± 11% ~ (p=0.353 n=10)
Startup/version-4 2.045m ± 5% 2.016m ± 8% ~ (p=0.481 n=10)
Track/daemon/pre-4 2.063m ± 6% 2.097m ± 5% ~ (p=0.739 n=10)
Track/daemon/post-4 2.049m ± 9% 2.027m ± 6% ~ (p=0.247 n=10)
Track/direct/pre-4 2.111m ± 5% 2.139m ± 5% ~ (p=0.218 n=10)
Track/direct/post-4 2.454m ± 6% 2.357m ± 5% ~ (p=0.280 n=10)
Track/direct/post-sync-4 3.759m ± 5% 3.726m ± 7% ~ (p=0.481 n=10)
geomean 1.330m 1.339m +0.69%
│ base │ head │
│ user-sec/op │ user-sec/op vs base │
Startup/floor-4 229.5µ ± 4% 223.7µ ± 4% ~ (p=0.247 n=10)
Startup/version-4 1.556m ± 6% 1.513m ± 10% ~ (p=0.971 n=10)
Track/daemon/pre-4 1.666m ± 8% 1.663m ± 8% ~ (p=0.631 n=10)
Track/daemon/post-4 1.705m ± 9% 1.674m ± 8% ~ (p=0.853 n=10)
Track/direct/pre-4 1.646m ± 7% 1.596m ± 4% ~ (p=0.063 n=10)
Track/direct/post-4 2.599m ± 5% 2.650m ± 3% ~ (p=0.280 n=10)
Track/direct/post-sync-4 4.757m ± 2% 4.836m ± 5% ~ (p=0.436 n=10)
geomean 1.541m 1.526m -0.97%
Δ compares medians; ~ means no significant difference (Mann-Whitney U, p ≥ 0.05). A scenario is flagged when it is more than 10% and more than 250µs slower with p < 0.05. Startup/floor runs true, not shelltime: it is an A/A check of runner noise. Runner: linux/amd64, Intel(R) Xeon(R) 6975P-C. go1.27.1, 10 rounds × 100 execs per scenario and binary.
| } | ||
|
|
||
| user := a.user() | ||
| user := a.global() |
There was a problem hiding this comment.
Nit (optional): plain shelltime cursor uninstall / agy uninstall now also removes the global hooks, which install --global writes on purpose. A user who runs it in one repository to drop that repository's hooks loses tracking for every other folder on the machine, with only a green "removed from ~/.cursor/hooks.json" line to show for it. The old behavior only cleaned hooks an older version had left behind. Fix: leave the global file alone unless --global is passed, and print a hint when global hooks exist. Or ask before removing them. If both-by-default stays, say so in the command's Usage text.
There was a problem hiding this comment.
Keeping this one as it is. Plain uninstall cleaning both files is what the plan for this PR set out, and it matches what uninstall did before. The command's Usage text says so: "Remove the ShellTime hooks from the current repository's .cursor/hooks.json and ~/.cursor/hooks.json, or with --global from ~/.cursor/hooks.json only". uninstall --global is the narrower option. Whether plain uninstall should leave the global file alone is left to the maintainer.
The other two points are fixed in cf00d5d:
- doctor and project install count global hooks only when they record (
globalHooksRecord). isGlobalHookCommandreads--projectfrom hook-ingest's own arguments (hookIngestArgs).
Generated by Claude Code
☁️ Claude Code cloud · Plan global installs for Cursor and AGY commandsResearched global installation support for the Cursor and AGY CLI commands and produced an implementation plan for adding a
29.6M tokens: 60.5K input · 106.9K output · 28.5M cache read · 903.7K cache write 📝 AI summaryInvestigated the recently added Outlined a plan to add a View this session on ShellTime → Updated 2026-12-01 15:03 UTC by ShellTime · totals for the whole session so far · the session page is visible to its owner |
doctor and project install treated any ShellTime hook in the global file as recording, also an older version's whose binary is gone, which records nothing: a project without hooks of its own then got a note instead of the warning. globalHooksRecord counts the --global command or an older version's existing binary. isGlobalHookCommand now reads --project from hook-ingest's own arguments (hookIngestArgs), so text elsewhere in a hand-edited command doesn't count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014EpZRfhTSPrQA29S15UhWm
|
|
||
| legacy, other := false, false | ||
| for _, event := range slices.Sorted(maps.Keys(status.EventBinaries)) { | ||
| if slices.Contains(status.GlobalEvents, event) { |
There was a problem hiding this comment.
Nit (optional): doctor skips every event that has a --global command, so a project command copied into the same event is not reported, although it is counted twice. The other warning fires only when the whole event has no global command. Fix: scan the event's binaries and commands before the GlobalEvents skip, or keep a ProjectEvents list in AgentHooksStatus to flag the double count.
| case err != nil: | ||
| return []doctorResult{{ID: a.id + ".hooks", Status: doctorSkip, Message: fmt.Sprintf("Couldn't read %s: %v", file.Path(), err)}} | ||
| return []doctorResult{{ID: a.id + ".hooks", Status: doctorSkip, Message: fmt.Sprintf("Couldn't read %s: %v", file.Path(), err)}}, false | ||
| case !status.Installed && globalRecords: |
There was a problem hiding this comment.
Nit (optional): globalRecords is true when any one event has a global command, but the project check treats the whole project as covered ("your global hooks record Cursor in it"). If the global file is partial (some events in MissingEvents), the project's own hook yields only per event, so the missing events are recorded by neither file. Doctor reports this only as a separate global "out of date" warning. Fix: have the note say which events the global hooks lack, or report it as a warning when MissingEvents is non-empty.
| if _, ok := getField(root, name); !ok { | ||
| // Where the group an older version wrote was | ||
| for i := range root { | ||
| if containsString(s.groups(), root[i].Key) { |
There was a problem hiding this comment.
Nit (optional): the rename-in-place takes over any group named shelltime in the global file, whatever it holds, and the loop below then deletes it. A user group of that name with their own non-ShellTime hooks would be overwritten silently. Fix: rename or delete a legacy group only when its commands contain hook-ingest --agent agy.
Why
Since #359,
shelltime cursor installandshelltime agy installwrite only the current repository's hook file, so tracking every folder means installing into each repository. Both agents also read a user-level file that they run in every folder:~/.cursor/hooks.jsonruns from~/.cursor/. Cloud Agents read only the repository's.cursor/hooks.json.~/.gemini/config/hooks.jsonand the workspace file is.agents/hooks.json. Google's I/O post says workspace hooks "take precedence", and nothing documents how two groups with the same name combine.hook-ingestreads the workspace from the hook payload (workspace_roots,workspacePaths), not from its working directory, so a hook that runs from~/.cursor/records the right folder.Changes
--globalshelltime cursor install --global/-gwrites~/.cursor/hooks.json.shelltime agy install --globalwrites ashelltime-globalgroup to~/.gemini/config/hooks.json. Both work from any folder, including the home folder. Windows is still refused.shcommand without--project. A Homebrew upgrade or an uninstall therefore never leaves a hook that fails on every event, and a home folder synced to machines without ShellTime is fine.shelltimegroup.uninstall --globalcleans only the global file. Plainuninstallstill cleans the repository's file and the global one.--global.initmentions it too.No double counting
userHooksRecordnow also counts the--globalcommand (AgentHooksStatus.GlobalEvents).shelltimeandshelltime-daemonin the same places, in the same environment, so if the project hook reachedhook-ingest, the global one did too.shelltime-global, apart from the project'sshelltime. If Antigravity lets a workspace group replace a global group of the same name, the project hook would otherwise step aside for a hook that never runs.doctor--globalhooks: OK, with a warning and a fix for missing events.install --global.Docs
README,
docs/CONFIG.md,CLAUDE.md.Open points
https://forum.cursor.com/t/cursor-cli-2026-11-05-macos-user-level-cursor-hooks-json-is-never-loaded-project-level-cursor-hooks-json-works/177989) says Cursor CLI 2026.11.05 on macOS never loads~/.cursor/hooks.json. If that's true,cursor-agentsessions in a repository that has both global and project hooks lose their events: the project hook steps aside for a hook the CLI never runs. The same already applies to hooks older versions left in that file. Not tested on a real Cursor.Testing
gofmt,go vet ./...andgo test ./...pass./bin/sh;isGlobalHookCommand;install --global/uninstall --globalfor both agents, including on Windows and with an invalid file;doctorcases above;inithint.cursor install --global, then the written command run with a stand-inshelltime(it records) and with none (it answers{});doctor --offlineoutside and inside a repository, and a project install next to global hooks;agy install -gover an older group whose binary is gone, thenagy uninstall --global.hook-ingestwas not run by hand: its fast path always uses/tmp/shelltime.sock, where a real daemon runs in this container. The unit tests cover it.Generated by Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.