/** * Installs the lifecycle hooks: the session-start hook for Claude Code and * Codex, and the opt-in phase guard for Claude Code * (hooks-carry-lifecycle-state/AC-14..AC-16, AC-20, AC-21). * * Identity is a trailing marker, as for the cost hooks, but a different one * (design D9). With a shared marker `aidlc cost hooks status` would count a * lifecycle hook as a cost hook and `cost hooks remove` would delete it. The cost * installer matches `endsWith('#aidlc-cost-hook')`, which no command here * satisfies, so neither installer sees the other's entries and the cost code is * unchanged. The merge below is written again rather than generalised out of * `cost/hooks/claude-code.ts` because it also writes Codex's file, and the cost * installer's tests pin its exact behaviour. * * Codex trusts a hook by its content hash, and only the user's own config may * record that hash (knowledge: `codex-hook-trust-model`). So this module writes * the project's `.codex/hooks.json` and nothing else for Codex — never * `~/.codex/`, never a trust hash — and writes only when the text would change, * so installing twice cannot cost the user the trust they already gave. * * Design: design.md C4 * * @module */ export type LifecyclePlatform = 'claude-code' | 'codex'; export type LifecycleHook = 'session-start' | 'guard' | 'approval-guard'; export declare const LIFECYCLE_PLATFORMS: readonly LifecyclePlatform[]; export declare const LIFECYCLE_HOOK_MARKER = "#aidlc-lifecycle-hook"; export declare const GUARD_MATCHER = "Edit|Write|MultiEdit|NotebookEdit"; /** * The two hook commands for a platform. Both run through the cost-capture shim, * which finds an absolute `node` and this project's CLI at run time and never * consults `PATH` (cost-capture-goes-dark/AC-15) — a bare `aidlc` here would be a * `PATH` lookup on every session start (design D1). */ export declare function lifecycleCommands(platform?: LifecyclePlatform): Record; export declare function hookFilePath(projectRoot: string, platform: LifecyclePlatform): string; /** Whether the phase guard can be installed for a platform. */ export declare function supportsGuard(platform: LifecyclePlatform): boolean; /** The step the user still owes before the platform runs the hook, or null. */ export declare function trustStep(platform: LifecyclePlatform): string | null; /** Whether writing a platform's hook needs the user's explicit yes (AC-18..AC-20). */ export declare function needsConsent(platform: LifecyclePlatform): boolean; /** The command that writes a consent-gated platform's hook, for every path that does not. */ export declare function installCommand(platform: LifecyclePlatform): string; export interface WriteResult { /** False when the file already said exactly this. */ written: boolean; path: string; } /** * Install the session-start hook, and the guard when asked, into one platform's * hook file (AC-15, AC-16, AC-20). Writes the shim first when it is missing or * unusable, since every command here runs through it. * * @throws when the guard is asked for Codex — its `PreToolUse` can deny or * rewrite a call but not ask, and the guard only ever asks. */ export declare function installLifecycleHooks(projectRoot: string, opts: { platform: LifecyclePlatform; guard?: boolean; }): WriteResult; /** * Remove the lifecycle hooks from one platform's file, or only the guard * (AC-14, AC-16). Unmarked entries and every other key stay; a file that does * not exist is not created. */ export declare function removeLifecycleHooks(projectRoot: string, opts: { platform: LifecyclePlatform; guardOnly?: boolean; }): WriteResult; /** Whether one lifecycle hook is declared in a platform's file. Never throws. */ export declare function lifecycleHookInstalled(projectRoot: string, platform: LifecyclePlatform, which: LifecycleHook): boolean; /** The line every Codex install prints: the hook is inert until the user trusts it. */ export declare const CODEX_TRUST_STEP: string; /** The command that adds the Codex hook, for every path that does not write it. */ export declare const CODEX_INSTALL_COMMAND: string; //# sourceMappingURL=install.d.ts.map