Repository navigation
chore(agents): install shelltime hooks for agy and cursor - #23
Conversation
Install project-level ShellTime tracking hooks for Antigravity (.agents/hooks.json) and Cursor (.cursor/hooks.json).
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. |
| "PostToolUse": [ | ||
| { | ||
| "matcher": "*", | ||
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "PATH=${PATH:+$PATH:}$HOME/.shelltime/bin:/opt/homebrew/bin:/usr/local/bin; command -v shelltime >/dev/null 2>&1 && command -v shelltime-daemon >/dev/null 2>&1 && out=$(shelltime hook-ingest --agent agy --event PostToolUse --project) && printf '%s\\n' \"$out\" || echo '{}'", | ||
| "timeout": 15 | ||
| } | ||
| ] | ||
| } |
There was a problem hiding this comment.
Important: the hook schema is inconsistent within this file. SessionStart, PreInvocation, PostInvocation and Stop list flat {type, command, timeout} entries. PostToolUse alone uses the nested {matcher, hooks: [...]} shape. The host can only parse one of these shapes for a given event. Either the flat events or the PostToolUse entry will probably be ignored or rejected. In that case tool-use heartbeats, or session start and stop, are silently never ingested.
Fix: check the agy hooks schema and use one shape consistently. If matchers are needed for tool events, use the nested form where the schema requires it. Otherwise flatten this entry.
| @@ -0,0 +1,44 @@ | |||
| { | |||
| "shelltime": { | |||
There was a problem hiding this comment.
Important (needs checking): every event is nested under a top-level "shelltime" key. The .cursor/hooks.json file in this PR puts event names under "hooks" with "version": 1. If agy expects event names (SessionStart, ...) at the top level, or under hooks, no hook will ever fire. The failure would be silent.
Fix: confirm against the agy hooks file format that a named group such as shelltime is a valid wrapper. If it isn't, move the events to where the loader expects them.
| "version": 1, | ||
| "hooks": { | ||
| "beforeSubmitPrompt": [ | ||
| { |
There was a problem hiding this comment.
Important: in the success path the command can print a bare newline instead of JSON. The shape is ... && out=$(shelltime hook-ingest ...) && printf '%s\n' "$out" || echo '<fallback>'. If hook-ingest exits 0 with empty stdout, printf '%s\n' "" prints a blank line and the || echo fallback never runs. Cursor and agy expect a JSON object on stdout. This matters most for beforeSubmitPrompt (needs {"continue":true}) and agy Stop (needs a decision). A blank response there could be read as a parse error or block the prompt or stop. The same pattern is used in every command in both files.
Fix: fall back when the output is empty, for example out=$(...) && [ -n "$out" ] && printf '%s\n' "$out" || echo '<fallback>'.
| "version": 1, | ||
| "hooks": { | ||
| "beforeSubmitPrompt": [ | ||
| { |
There was a problem hiding this comment.
Nit (optional): none of the Cursor hook entries sets a timeout, but the agy file uses 15s on each. beforeSubmitPrompt runs synchronously before every prompt. If the daemon socket stalls, shelltime hook-ingest blocks the prompt for as long as Cursor's default timeout. Fix: add a timeout to each entry, matching agy's 15s or lower.
| "SessionStart": [ | ||
| { | ||
| "type": "command", | ||
| "command": "PATH=${PATH:+$PATH:}$HOME/.shelltime/bin:/opt/homebrew/bin:/usr/local/bin; command -v shelltime >/dev/null 2>&1 && command -v shelltime-daemon >/dev/null 2>&1 && out=$(shelltime hook-ingest --agent agy --event SessionStart --project) && printf '%s\\n' \"$out\" || echo '{}'", |
There was a problem hiding this comment.
Nit (optional): this change adds personal tooling hooks to a Neovim plugin repo. They run shelltime hook-ingest for every agent event for every contributor who opens the repo in agy or Cursor. The roughly 300-character shell one-liner is copy-pasted 12 times across the two files, which makes it easy for the copies to drift. Also, the repo's CLAUDE.md architecture and conventions don't mention these files. Fix: if the hooks are meant to be shared, consider generating them from the CLI installer rather than hand-committing them. Otherwise add them to .gitignore.
Install project-level ShellTime tracking hooks for Antigravity (
.agents/hooks.json) and Cursor (.cursor/hooks.json).Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.