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

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 in this file. PostToolUse uses the nested {matcher, hooks:[{type, command, timeout}]} form, while SessionStart, PreInvocation, PostInvocation and Stop use flat {type, command, timeout} entries. The top-level "shelltime" wrapper key is also unusual. If the agy loader expects one shape, the other events are silently ignored or the file is rejected. Fix: check this against the agy hooks schema and use one consistent shape, or document why the mix is intended.

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

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 Stop hook can emit a blank line instead of JSON. If shelltime hook-ingest exits 0 with empty stdout, printf '%s\n' "$out" prints just a newline. The || echo '{"decision":"allow"}' fallback only runs when the command fails, so a successful empty run gives the agent no valid decision payload. The same applies to every other command in this file and in .cursor/hooks.json; the cursor beforeSubmitPrompt hook, which expects {"continue":true}, is the riskiest. Fix: make the fallback depend on empty output, e.g. out=$(...) ; [ -n "$out" ] && printf '%s\n' "$out" || echo '<default>'.

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

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): unlike the agy hooks, none of the Cursor hooks set a timeout. Every prompt submit, tool use and stop synchronously runs a shell pipeline that calls shelltime hook-ingest. If the daemon hangs, beforeSubmitPrompt can stall the user's prompt until Cursor's default timeout. Fix: add an explicit short timeout, as .agents/hooks.json does with 15.

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): these hooks use --project and forward every prompt, tool call and response to the local shelltime daemon for every contributor who has shelltime installed. This is a public repository, and the command is repeated in about 12 places. A contributor who has shelltime installed gets their sessions in this repo tracked without opting in per repo. Fix: confirm this is intended for a public repo. Otherwise keep the hooks in user-level config, or gitignore .cursor/hooks.json and .agents/hooks.json.

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

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): the full hook shell pipeline is copy-pasted 12 times across the two files. The only differences are the agent, the event and the fallback payload. Any fix, such as to the PATH handling, has to be made in each copy, and the 12 copies can drift apart. Fix: call a small wrapper script, or let shelltime generate and own these files, and note in the repo docs that the files are generated.

}
}
Loading