import { Effect } from 'effect'; import { ProcessError } from '../types/errors.js'; import { Worktree, Session, SessionState } from '../types/index.js'; export interface HookEnvironment { CCMANAGER_WORKTREE_PATH: string; CCMANAGER_WORKTREE_BRANCH: string; CCMANAGER_GIT_ROOT: string; CCMANAGER_BASE_BRANCH?: string; [key: string]: string | undefined; } /** * Execute a hook command with the provided environment variables using Effect * * Spawns a shell process to run the hook command with custom environment. * Errors are captured but hook failures don't propagate to prevent breaking main flow. * * @param {string} command - Shell command to execute * @param {string} cwd - Working directory for command execution * @param {HookEnvironment} environment - Environment variables for the hook * @returns {Effect.Effect} Effect that succeeds on hook completion or fails with ProcessError * * @example * ```typescript * import {Effect} from 'effect'; * import {executeHook} from './utils/hookExecutor.js'; * * const env = { * CCMANAGER_WORKTREE_PATH: '/path/to/worktree', * CCMANAGER_WORKTREE_BRANCH: 'feature-branch', * CCMANAGER_GIT_ROOT: '/path/to/repo' * }; * * // Execute hook with error recovery * const result = await Effect.runPromise( * Effect.catchAll( * executeHook('npm install', '/path/to/worktree', env), * (error) => { * console.error(`Hook failed: ${error.message}`); * return Effect.succeed(undefined); // Continue despite error * } * ) * ); * ``` */ export declare function executeHook(command: string, cwd: string, environment: HookEnvironment): Effect.Effect; /** * Execute a worktree pre-creation hook using Effect * Errors propagate to abort worktree creation - this is intentional * * @param {string} command - Shell command to execute * @param {string} worktreePath - Path where the worktree will be created (doesn't exist yet) * @param {string} branch - Branch name for the new worktree * @param {string} gitRoot - Git repository root (working directory for the hook) * @param {string} baseBranch - Optional base branch the worktree is created from * @returns {Effect.Effect} Effect that succeeds on hook completion or fails with ProcessError */ export declare function executeWorktreePreCreationHook(command: string, worktreePath: string, branch: string, gitRoot: string, baseBranch?: string): Effect.Effect; /** * Execute a worktree post-creation hook using Effect * Errors are caught and logged but do not break the main flow */ export declare function executeWorktreePostCreationHook(command: string, worktree: Worktree, gitRoot: string, baseBranch?: string): Effect.Effect; /** * Execute a session status change hook using Effect * Errors are caught and logged but do not break the main flow */ export declare function executeStatusHook(oldState: SessionState, newState: SessionState, session: Session): Effect.Effect;