Skip to content

feat(cli): install Cursor and Antigravity hooks globally with --global - #367

Merged
AnnatarHe merged 2 commits into
mainfrom
claude/wizardly-cray-vmg7pu
Nov 30, 2026
Merged

AnnatarHe merged 2 commits into
mainfrom
claude/wizardly-cray-vmg7pu

Conversation

@AnnatarHe

@AnnatarHe AnnatarHe commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Why

Since #359, shelltime cursor install and shelltime agy install write 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): hooks load from Enterprise, Team, Project and User, and all matching hooks run. ~/.cursor/hooks.json runs from ~/.cursor/. Cloud Agents read only the repository's .cursor/hooks.json.
  • Antigravity (hooks, where agy looks for hooks): the global file is ~/.gemini/config/hooks.json and 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-ingest reads 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

--global

  • shelltime cursor install --global / -g writes ~/.cursor/hooks.json. shelltime agy install --global writes a shelltime-global group to ~/.gemini/config/hooks.json. Both work from any folder, including the home folder. Windows is still refused.
  • The global command is the project's self-contained sh command 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.
  • A global install rewrites in place what older versions left in that file: commands with an absolute binary path, and the global shelltime group.
  • uninstall --global cleans only the global file. Plain uninstall still cleans the repository's file and the global one.
  • Project install outside a repository points to --global. init mentions it too.

No double counting

  • A project hook still steps aside when the global file records the same event. userHooksRecord now also counts the --global command (AgentHooksStatus.GlobalEvents).
  • That signal is exact: both commands look for shelltime and shelltime-daemon in the same places, in the same environment, so if the project hook reached hook-ingest, the global one did too.
  • A project's command copied into the global file still doesn't count.
  • The global Antigravity group is named shelltime-global, apart from the project's shelltime. 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

  • Checks the global file in and outside repositories:
    • --global hooks: OK, with a warning and a fix for missing events.
    • An older version's hooks still working: info.
    • An older version's hooks whose binary is gone: failure.
    • A copied project command, which would count events twice: warning.
  • The failure and the warning are fixed by install --global.
  • A repository without its own hooks is only a note while global hooks are installed, with no automatic fix that writes a hook file into it. The note says the agents' cloud runs still need the repository's hooks.
  • The binary check now runs for global hooks too.

Docs

README, docs/CONFIG.md, CLAUDE.md.

Open points

  • A [forum report](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-agent sessions 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.
  • The behavior of same-named Antigravity groups across files is undocumented; the group name only guards against the bad case. A third-party page says workspace hooks load only once the folder is trusted. Not tested on a real Antigravity.

Testing

  • gofmt, go vet ./... and go test ./... pass.
  • New or updated tests:
    • the global command text, and the command run in /bin/sh;
    • a global install replacing older entries in place and keeping the user's hooks;
    • the Antigravity group renamed where the old one was, and both group names read and removed;
    • isGlobalHookCommand;
    • install --global / uninstall --global for both agents, including on Windows and with an invalid file;
    • a project hook stepping aside for global hooks, and a global run recording;
    • the doctor cases above;
    • the init hint.
  • By hand, with the built binary in a throwaway HOME:
    • cursor install --global, then the written command run with a stand-in shelltime (it records) and with none (it answers {});
    • doctor --offline outside and inside a repository, and a project install next to global hooks;
    • agy install -g over an older group whose binary is gone, then agy uninstall --global.
  • The real hook-ingest was 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-bot with what you need.

`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
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-30T17:24:27.613410Z cf00d5d New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codecov

codecov Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.97980% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
commands/doctor_checks.go 96.47% 3 Missing ⚠️
commands/agent_hooks_install.go 97.05% 1 Missing ⚠️
Flag Coverage Δ
unittests 86.20% <97.97%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
agenthook/event.go 100.00% <ø> (ø)
commands/agy.go 80.00% <100.00%> (ø)
commands/cursor.go 100.00% <100.00%> (ø)
commands/hook_ingest.go 94.28% <100.00%> (+0.30%) ⬆️
commands/init.go 50.00% <100.00%> (+0.79%) ⬆️
daemon/agent_hooks.go 96.48% <ø> (ø)
model/agent_hooks_common.go 90.81% <100.00%> (+1.79%) ⬆️
model/antigravity_hooks.go 95.65% <100.00%> (+1.08%) ⬆️
model/cursor_hooks.go 92.53% <100.00%> (+0.11%) ⬆️
commands/agent_hooks_install.go 92.70% <97.05%> (+3.09%) ⬆️
... and 1 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

⏱️ shelltime track performance

✅ No significant change in shelltime track latency

Comparing main @ faa8e49 → #367 @ cf00d5d. Each scenario execs the binary the way the shell hooks do; values are the median of 10 interleaved rounds. Lower is better.

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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).
  • isGlobalHookCommand reads --project from hook-ingest's own arguments (hookIngestArgs).

Generated by Claude Code

Comment thread commands/doctor_checks.go Resolved
Comment thread model/agent_hooks_common.go Resolved
@shelltime

shelltime Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

☁️ Claude Code cloud · Plan global installs for Cursor and AGY commands

Researched global installation support for the Cursor and AGY CLI commands and produced an implementation plan for adding a --global flag.

💰 Cost 🔢 Tokens ⏱️ Duration 🧠 Models 💬 Prompts ✏️ Lines
$14.83 29.6M 3h 56m (18m active) claude-opus-5-5, claude-haiku-5-5 3 +29 / −16

29.6M tokens: 60.5K input · 106.9K output · 28.5M cache read · 903.7K cache write

📝 AI summary

Investigated the recently added shelltime cursor install and shelltime agy install commands to determine how their current project-scoped installation behavior could be extended. WebSearch and WebFetch were used to review relevant external documentation, while Bash and delegated agents helped inspect the CLI structure and existing command patterns.

Outlined a plan to add a --global option to both install commands, including command-line flag parsing, selecting global versus project-specific destination paths, preserving the existing local behavior as the default, and adding coverage for both modes. This session focused on research and implementation planning rather than reporting completed source-file changes.

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
Comment thread commands/doctor_checks.go

legacy, other := false, false
for _, event := range slices.Sorted(maps.Keys(status.EventBinaries)) {
if slices.Contains(status.GlobalEvents, event) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread commands/doctor_checks.go
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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@AnnatarHe
AnnatarHe merged commit f0ce50e into main Nov 30, 2026
14 checks passed
@AnnatarHe
AnnatarHe deleted the claude/wizardly-cray-vmg7pu branch November 30, 2026 17:25
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