Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .agents/hooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"shelltime": {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

"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 '{}'",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

"timeout": 15
}
],
"PreInvocation": [
{
"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 PreInvocation --project) && printf '%s\\n' \"$out\" || echo '{}'",
"timeout": 15
}
],
"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
}
]
}
Comment on lines +17 to +27

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

],
"PostInvocation": [
{
"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 PostInvocation --project) && printf '%s\\n' \"$out\" || echo '{}'",
"timeout": 15
}
],
"Stop": [
{
"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 Stop --project) && printf '%s\\n' \"$out\" || echo '{\"decision\":\"allow\"}'",
"timeout": 15
}
]
}
}
40 changes: 40 additions & 0 deletions .cursor/hooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"version": 1,
"hooks": {
"beforeSubmitPrompt": [
{

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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>'.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

"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 cursor --event beforeSubmitPrompt --project) && printf '%s\\n' \"$out\" || echo '{\"continue\":true}'"
}
],
"postToolUse": [
{
"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 cursor --event postToolUse --project) && printf '%s\\n' \"$out\" || echo '{}'"
}
],
"postToolUseFailure": [
{
"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 cursor --event postToolUseFailure --project) && printf '%s\\n' \"$out\" || echo '{}'"
}
],
"afterAgentResponse": [
{
"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 cursor --event afterAgentResponse --project) && printf '%s\\n' \"$out\" || echo '{}'"
}
],
"stop": [
{
"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 cursor --event stop --project) && printf '%s\\n' \"$out\" || echo '{}'"
}
],
"sessionStart": [
{
"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 cursor --event sessionStart --project) && printf '%s\\n' \"$out\" || echo '{}'"
}
],
"sessionEnd": [
{
"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 cursor --event sessionEnd --project) && printf '%s\\n' \"$out\" || echo '{}'"
}
]
}
}
Loading