Skip to content

Commit 6a52106

Browse files
committed
docs(hooks): cover EPIPE, truncation, stdio, and enablement
85 lines was not enough. Part of CL-7901.
1 parent 9f37404 commit 6a52106

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

docs/HOOKS.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,22 @@ Local hooks in `.corbits/hooks/` take precedence over global hooks in
1111
`~/.corbits/hooks/` when both directories contain a hook with the same file
1212
name.
1313

14-
Supported files:
14+
Supported files (dotfiles skipped; anything else ignored; sorted by path):
1515

1616
- `*.ts` files run with Bun.
1717
- `*.sh` files run with `sh`.
1818

19-
Hook failures are recorded in hook status and logged, but they do not stop the
20-
agent run. `postTurn` hooks run in the background. `postRun` hooks finish before
21-
the process exits so they can flush their output and record final status.
19+
Hook outcomes are recorded in hook status (`lastExitStatus`) but they do not stop the
20+
agent run. `postTurn` hooks run in the background. `postRun` hooks are awaited before
21+
the process exits so they can finish their side effects and record final status.
22+
23+
A hook may exit without reading its payload — for example, a shell hook whose
24+
`case "$1"` handles only one lifecycle kind. The payload write then fails with
25+
`EPIPE`; that is treated as a hook outcome, not a crash, and the hook's status
26+
notes `hook exited without reading its payload`.
27+
28+
Hooks start enabled and can be toggled in the TUI hook panel. Each hook's
29+
status tracks `enabled`, `lastFiredAt`, `lastKind`, and `lastExitStatus`.
2230

2331
## TypeScript Hooks
2432

@@ -83,3 +91,12 @@ type RunSummary = {
8391
error?: string;
8492
};
8593
```
94+
95+
Tool results inside hook payloads are truncated to the last 4,000 characters,
96+
with a `[N chars omitted]` marker, so large tool outputs stay bounded.
97+
98+
Hook stdout is ignored; hook stderr is captured into the hook's
99+
`lastExitStatus`. The JSON payload is the hook's only structured input.
100+
101+
The nested types (`ConversationTurn`, `ToolCall`, `ToolResult`, `TokenUsage`,
102+
`LastCycleSource`) are defined with the runtime types; see `src/session/hooks.ts`.

0 commit comments

Comments
 (0)