WorktreeCreate envelope fix — #1990 before / after

orchestkit · run-hook.mjs · #1990

Spawn a worktree-isolated agent. CC reads a command-type WorktreeCreate hook's stdout as the worktree directory path. OrchestKit's logger is observability-only — it has no path to give. Toggle before/fix and the hook's output to see the envelope get misread as a path (before) vs empty stdout letting CC use its default (fix).

version
hook output

Agent(isolation:"worktree") spawn

the fix — diff

src/hooks/bin/run-hook.mjs
// early exits (event not parsed yet → key on hook NAME) + const IS_WORKTREE_PATH_HOOK = hookName.startsWith('worktree/'); + function silentExit(){ if(!IS_WORKTREE_PATH_HOOK) console.log(SILENT_OK); process.exit(0); } - if(!hookFn){ console.log(SILENT_OK); process.exit(0); } + if(!hookFn){ silentExit(); } // run path (event known → key on hook_event) + function emitHookResult(result, ev){ + if(WORKTREE_PATH_EVENTS.has(ev) && !result?.hookSpecificOutput?.worktreePath) return; + console.log(JSON.stringify(sanitizeOutput(result, ev))); + } - console.log(JSON.stringify(sanitizeOutput(result, firingEvent))); + emitHookResult(result, firingEvent);