Repository navigation
feat(agenthook): report Pi sessions so hosts can resume them - #161
Conversation
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
…iles still install
e83b47e to
0122104
Compare
roborev: Combined Review (
|
A host that reopens a Pi session with pi --session needs to know the session was resumed. Pi reports startup for every first launch, even when it opens a saved session. Claude Code reports resume in the same case, so hosts got a different answer from Pi. A saved session file at startup means Pi opened an existing session, so the module now reports resume. A failed hook showed only its exit status in Pi. The command's own error text was lost, so a user had nothing to act on. Failures now end with the tail of the command's stderr. Reading stderr adds a risk: a background process that the hook starts can inherit the pipe and keep it open. The module stops waiting shortly after the command exits, and keeps reading the pipe so that process never blocks and Pi is not held open. After the last application uninstalled, Pi kept loading an empty module on every start. The file belongs only to kit, so Uninstall now deletes it. Result.Data is nil in that case, so callers that dump the planned config can tell a deletion from a rewrite. PI_CODING_AGENT_DIR also accepts file URLs, as Pi's own path handling does. Kit used to treat such a URL as a relative path and installed the module where Pi never looks. The Pi source links now point to a fixed commit, so their line ranges stay correct as Pi changes. Generated with Claude Code (claude-opus-5-5) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
roborev: Combined Review (
|
A hook that finished just before its timeout could still be reported as timed out. This happened when a background process it started kept its stderr open: the deadline stayed armed while the extension waited a short time for stderr to close. The deadline now stops when the command exits. No test covers this window. It needs a command to exit within 250ms of its deadline, and process start time on CI runners varies by more than that. Kit read some PI_CODING_AGENT_DIR file URLs differently from Pi. Node, which Pi runs on, lowercases the host, so file://LOCALHOST is a local path. Node also reads file://C:/ as drive C, where Go reads C: as a host. In those cases kit installed the module in a directory Pi never loads, or refused a value that Pi accepts. The Pi test no longer checks that each reported transcript exists. It ran after the test had created every saved file, so it could not catch an early report, and the exact report comparison already rejects any report for a session that was never saved. The helper's background process now starts in the test binary's directory instead of the system temp directory, which the usetesting lint rejects in tests. Generated with Claude Code (claude-opus-5-5) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
roborev: Combined Review (
|
A Pi conversation now comes back after a restart. Tools that install agenthook hooks, such as Forge, get Pi's session ID and reopen it with
pi --session <id>. Pi has no command-hook config, so install writes one extension module,extensions/agenthook.js, that runs every application's commands without a shell. It needs Pi 0.80.4 or later.The module reports only from Pi's terminal UI, and only after Pi saves the session file, so each reported ID resumes from the project it started in. SessionEnd fires only when another session replaces the current one, so quitting leaves the session resumable. A root
index.ts,index.jsorpackage.jsonextension list stops Pi loading the module.Refs kenn-io/forge#1282, slice 11 (Resume Pi agents)