#!/usr/bin/env npx tsx /** * Directory Guard Hook * * PreToolUse hook that restricts Claude Code file operations to a specific working directory. * This prevents the agent from accessing files outside the allowed directory. * * Usage: * CLAUDE_WORKDIR=/path/to/allowed npx tsx directory-guard.ts * * The hook reads JSON from stdin (Claude Code hook protocol) and outputs a decision. * * @module agents/claude/hooks/directory-guard */ /** * Hook input from Claude Code */ export interface HookInput { tool_name: string; tool_input: Record; } /** * Hook output decision */ export interface HookOutput { decision: 'allow' | 'block'; reason?: string; } /** * Tools that operate on file paths */ export declare const FILE_TOOLS: string[]; /** * Check if a path is within the allowed working directory * * @param targetPath - The path to check * @param workdir - The allowed working directory * @returns True if the path is within the workdir */ export declare function isPathWithinWorkdir(targetPath: string, workdir: string): boolean; /** * Extract file path from tool input based on tool type * * @param toolName - The name of the tool being called * @param toolInput - The tool input parameters * @returns The file path if found, null otherwise */ export declare function extractFilePath(toolName: string, toolInput: Record): string | null; /** * Process a hook input and return the decision * * @param hookInput - The hook input from Claude Code * @param workdir - The allowed working directory * @returns The hook output decision */ export declare function processHookInput(hookInput: HookInput, workdir: string): HookOutput; /** * Main hook entry point - reads from stdin and writes to stdout */ export declare function main(): Promise; //# sourceMappingURL=directory-guard.d.ts.map