Repository navigation
Write hook configs atomically, keep tests out of the real home, refresh stale Claude hooks - #147
Merged
Merged
Conversation
…e, refresh stale Claude hooks Hook configs and rc files are now written to a temp file and renamed into place, through symlinks, keeping the mode, and not at all when nothing changed. A plain write racing another app's left ~/.claude/settings.json and ~/.codex/hooks.json unparseable, and Claude Code then loads none of it. npm test preloads a scratch HOME and CODEX_HOME. Hook tests run the install repair, which was repointing the developer's real desktop hooks at the worktree under test. The Claude installer now replaces a vibe hook whose pinned path changed, as the Codex, Cursor and ZCode installers already did, so the session-start repair fixes a Node that moved.
This was referenced Oct 29, 2026
Track desktop conversations vibetime never saw start, including every Cursor Agent conversation
#146
Merged
Codex keys hook trust by position as well as content and skips a hook until it is reviewed again when either changes. Moving our group to the end on every repair shifted the hooks after it, other tools' included.
Linux caps one argv entry at 128 KB, so passing it on the command line failed with E2BIG in CI.
…ommands The install repair runs from whichever vibe starts: a second Node under nvm, a dev checkout, an npx cache. It now leaves a vibe hook alone while the Node and CLI it pins still exist, so it stops trading working hooks for ones that may vanish, and stops sending Codex hooks back for review. An explicit vibe hooks install still pins to the CLI that ran it. A vibe hook is now __hook followed by one of our events, not any command containing __hook, so a user's pre_commit__hooks.py is never replaced. A Claude group with no hooks list no longer throws, and each app's repair is attempted on its own so one broken config cannot skip the rest. writeFileAtomic writes through a dangling symlink to its target, keeps the mode of a file it cannot read, and falls back to a plain write on EACCES.
Teardown ran in registration order, so the folder was removed while the wrapper still wrote to it. The ENOTEMPTY skipped the hooks that close the stub server and stop the wrapper, and the file hung: 2 runs in 10 here, 1 in 10 on main. 0 in 35 after.
Merged
This was referenced Oct 29, 2026
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three fixes to how vibetime writes the desktop apps' hook configs. All three were found on the maintainer's machine on 2026-10-29:
~/.claude/settings.jsonand~/.codex/hooks.jsonwere both unparseable, and Claude Code loads nothing from a settings file it can't parse, so every hook and setting in it was off. The Codex file had been broken since Oct 21.1. Config writes can tear
The installers and the rc-file edits used a plain
writeFileSync, which truncates and then writes. When two writers hit the same file at once (here vibetime and Orca, which keeps its own hooks in the same file), the result was a short object followed by the tail of a long one. Because the session-start repair runs the installers on every session, every user is exposed, and Claude Code reads its settings while they're being written.New
src/write-file.ts,writeFileAtomic:settings.jsonor.zshrcstays a link, and keeps the file's mode.Used by the Claude, Codex, Cursor and ZCode installers and by
init.ts's rc rewrites.It doesn't stop lost updates: if vibetime and another app both rewrite the file at the same moment, one change wins whole. That's recoverable, since each app re-adds its hooks; a torn file isn't.
2. Tests rewrote the developer's real hooks
Hook tests fire
session-start, which runsreconcileInstall()against the real~/.claude,~/.codex,~/.cursorand~/.zcode. Tests only redirectedVIBE_DIR. So everynpm testin a worktree pointed the developer's desktop hooks at that worktree, and they stopped working when the worktree was deleted. That's how the broken Codex file came to point at an old.claude/worktrees/agent-…path.npm testnow preloadstest/isolate-home.mjs, which pointsHOME,USERPROFILEandCODEX_HOMEat a scratch dir for every test file. Test files that setHOMEthemselves are unaffected.3. The Claude installer never refreshed a stale path
reconcile.tssays every installer "refreshes stale pinned paths". The Codex, Cursor and ZCode installers do, but the Claude one kept any vibe hook it found. After an nvm upgrade that removes the old Node, Claude Desktop tracking fails silently, and the repair that exists for this case doesn't fix it. It now replaces a vibe hook whose command changed, and only vibe's own commands: anything else sharing that group stays.Verified
test/write-file.test.mjsruns six writers (200 KB and 100 B bodies, 60 writes each) and one reader, all released at a shared instant. Against a plainwriteFileSync, the reader got unparseable content 89, 83 and 89 times in three runs. With this change it got 0, 0 and 0. Symlink, mode and unchanged-content tests are alongside.test/hook-reopen.test.mjswithout the preload rewrote all five hooks to the worktree'sdist/cli.js. With the preload the file was untouched. Two fullnpm testruns left the real~/.claude/settings.json,~/.codex/hooks.json,~/.cursor/hooks.json,~/.zcode/cli/config.jsonand~/.zshrcbyte-identical (shasum before and after).test/claude-hooks.test.mjs(the Claude installer had no tests) fails on main withSessionStart still points at '/old/node' …and passes here. It also checks that a foreign command in the same group, a foreign event and other top-level settings survive, and that a current install isn't rewritten.npm test: 201/201. Server typecheck clean.Not covered
*.tmpnext to the config.node --test test/x.test.mjsskips the preload. CI andnpm testalways use it.Changes from release QA
An independent review of the combined release (#146, #147, #148) found these. Each fix has a test that fails without it.
vibestarts: a second Node under nvm, a dev checkout, an npx cache. It used to point every app's hooks at itself. Codex then skips the changed hook until it's reviewed again, and a dev checkout's hooks die with the checkout. The released 0.15.0 does this too; it's how the maintainer's hooks ended up on a worktree. Installers now have an explicit mode:repair, run at session start and invibe status, leaves a vibe hook alone while the Node andcli.jsit pins exist and its arguments are current.install, run byvibe hooks install, still pins to the CLI that ran it.file:event:group:handlerplus a hash of the hook (codex-rs/hooks/src/engine/discovery.rs). Moving our group to the end shifted every hook after it, other tools' included. Reproduced on 0.15.0 with an Orca-style hook after ours: its own session-start repair swapped the two.__hookfollowed by one of our event names. Before, any command containing__hook, such aspre_commit__hooks.py, was taken for ours, and the new Claude refresh would have replaced it. The rule lives in one place,src/hook-command.ts.hookslist no longer throws, and each app's repair runs on its own, so an exception can't skip the rest.writeFileAtomicedge cases. It writes through a dangling symlink to its target instead of replacing the link, keeps the mode of a file it can't read, and falls back to a plain write onEACCES(a writable file in a folder we can't create files in).wrap-pending-delivery.test.mjsremoved its scratch folder before stopping the wrapper. TheENOTEMPTYskipped the teardown that stops it, and the file hung: 1 run in 10 on main, 2 in 10 here, 0 in 35 after the fix.Upgrade path, checked end to end: 0.15.0 built from its tag and installed at a fixed path with hooks for all four apps, ZCode hooks switched on, and a foreign Codex hook after ours. Then the new build was swapped in at the same path and run through
vibe status, a Claude start, a Codex start, a Cursor first prompt and a ZCode first prompt:vibe statusrun from a dev checkout leaves them identical too.vibe status, with the Codex hook staying in its slot.