import path from 'node:path'; import type { PluginInput } from '@opencode-ai/plugin'; interface ToolExecuteBeforeInput { tool: string; } interface ToolExecuteBeforeOutput { args?: { filePath?: unknown; [key: string]: unknown; }; } type PathOperations = Pick; interface RescueOptions { pathOperations?: PathOperations; exists?: (p: string) => boolean; } /** * Re-anchor a guessed absolute path onto the workspace. * * Selection is unambiguous by construction: the anchor is the LONGEST * contiguous suffix of the workspace path that appears in the guess. * That anchor must appear exactly once in the guess (several * occurrences make the interpretation ambiguous → null), and only its * FULL relative tail is ever considered — a missing tail is a * legitimate absence → null. There is no fallback to a shorter anchor * or another occurrence once the longest anchor has been selected. * An empty tail (the guess ends at the anchor) rescues to the * workspace root — the canonical dropped-parents case. */ export declare function findRescuedSuffix(raw: string, workspace: string, pathOperations?: PathOperations, exists?: (p: string) => boolean): string | null; export declare function createAbsolutePathRescueHook(ctx: PluginInput, options?: RescueOptions): { 'tool.execute.before': (input: ToolExecuteBeforeInput, output: ToolExecuteBeforeOutput) => Promise; }; export {};