MCPcopy Create free account
hub / github.com/Noumena-Network/code / executeWorktreeCreateHook

Function executeWorktreeCreateHook

src/utils/hooks.ts:4932–4962  ·  view source on GitHub ↗
(
  name: string,
)

Source from the content-addressed store, hash-verified

4930 * Callers should check hasWorktreeCreateHook() before calling this.
4931 */
4932export async function executeWorktreeCreateHook(
4933 name: string,
4934): Promise<{ worktreePath: string }> {
4935 const hookInput = {
4936 ...createBaseHookInput(undefined),
4937 hook_event_name: 'WorktreeCreate' as const,
4938 name,
4939 }
4940
4941 const results = await executeHooksOutsideREPL({
4942 hookInput,
4943 timeoutMs: TOOL_HOOK_EXECUTION_TIMEOUT_MS,
4944 })
4945
4946 // Find the first successful result with non-empty output
4947 const successfulResult = results.find(
4948 r => r.succeeded && r.output.trim().length > 0,
4949 )
4950
4951 if (!successfulResult) {
4952 const failedOutputs = results
4953 .filter(r => !r.succeeded)
4954 .map(r => `${r.command}: ${r.output.trim() || 'no output'}`)
4955 throw new Error(
4956 `WorktreeCreate hook failed: ${failedOutputs.join('; ') || 'no successful output'}`,
4957 )
4958 }
4959
4960 const worktreePath = successfulResult.output.trim()
4961 return { worktreePath }
4962}
4963
4964/**
4965 * Execute WorktreeRemove hooks if configured.

Callers 3

createWorktreeForSessionFunction · 0.85
createAgentWorktreeFunction · 0.85
execIntoTmuxWorktreeFunction · 0.85

Calls 2

createBaseHookInputFunction · 0.85
executeHooksOutsideREPLFunction · 0.85

Tested by

no test coverage detected