"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.content = exports.filename = void 0;
exports.filename = 'example-hook.ts';
exports.content = `/**
* Example Hook Script
* 
* Usage: 
* 1. Attach to 'patch' or 'overwrite_file' tool as a 'before' hook.
* 2. It will block edits to any file with 'lock' in the name.
*/
// --- Type Definitions ---

export interface HookAction {
  tool_name: string;
  args: Record<string, any>;
  // Only present for 'after' hooks
  result?: {
    status: 'SUCCESS' | 'FAILURE';
    output?: string;
    error?: string;
  };
}

export interface HookContext {
  hook_type: 'before' | 'after';
  action: HookAction;
  plan_context: any; // Shared state of current AI plan
}

export interface HookOutput {
  // If true, AI plan stops immediately.
  should_halt_plan?: boolean;
  
  // Optional message to log in UI
  message?: string;
  
  // Optional data to merge back into plan context
  update_context?: Record<string, any>;
}

// --- Hook Logic ---

export default async function(context: HookContext): Promise<HookOutput | void> {
  // 1. Extract Data
  const filePath = context.action?.args?.file_path || '';
  
  // Log to console (appears in backend logs)
  console.log(\`[Hook] analyzing action on: \${filePath}\`);

  // 2. Logic
  if (filePath.includes('lock')) {
    // Return Halt Signal
    return {
      should_halt_plan: true,
      message: \`BLOCKED: Editing files with "lock" in the name is forbidden by policy. File: \${filePath}\`
    };
  } else {
    // Return Pass Signal
    return {
      should_halt_plan: false,
      message: \`Hook allowed action on \${filePath}\`
    };
  }
}
`;
//# sourceMappingURL=example-hook.js.map