import type { Hooks } from '@opencode-ai/plugin'; import type { Logger } from '../types'; import type { GraphService } from '../graph/service'; interface GraphToolHookDeps { graphService: GraphService | null; logger: Logger; cwd: string; } /** * Map storing pre-command git revision snapshots keyed by callID. * Only populated for bash commands that are branch-change candidates. * Exported for testing purposes. */ export declare const pendingBranchSnapshots: Map; /** * Resolves the effective git working directory for a bash tool call. * - Uses args.workdir when present * - Falls back to the plugin/project cwd * - Normalizes relative paths against the project root */ export declare function resolveBashWorkdir(args: unknown, projectCwd: string): string; /** * Determines whether a bash command is worth branch tracking. * Initial command set includes git branch-changing commands. * Excludes file restoration commands with explicit -- separator like `git checkout -- `. * For bare `git checkout ` without --, we conservatively track it and let the * after-hook compare pre/post branch state to determine if a rescan is needed. */ export declare function isBranchChangeCommand(args: unknown): boolean; /** * Extract file paths from git checkout file restoration commands. * Handles patterns like: * - git checkout -- * - git checkout HEAD -- * - git checkout -- * - git checkout (unambiguous file path without --) * Returns empty array if not a checkout file restore command. */ export declare function extractCheckoutPaths(args: unknown, workdir: string): string[]; /** * Reads the current git HEAD revision (commit hash) from the resolved working directory using git. * Returns null when the directory is not a repo or the revision cannot be determined. */ export declare function getCurrentHeadRef(workdir: string): string | null; /** * Reads the current branch name from the resolved working directory using git. * Returns null when the directory is not a repo or the branch cannot be determined. */ export declare function getCurrentBranch(workdir: string): string | null; /** * Gets the list of changed file paths between two git revisions. * Uses git diff --name-only with the specified diff filter to detect additions, deletions, and modifications. * Returns an empty array if the refs are equal, invalid, or if git command fails. */ export declare function getChangedPathsBetweenRefs(workdir: string, prevRef: string, nextRef: string): string[]; /** * Creates a before-hook for graph tool execution that captures pre-command branch state. * Only inspects bash tool calls that are branch-change candidates. */ export declare function createGraphToolBeforeHook(deps: GraphToolHookDeps): Hooks['tool.execute.before']; export declare function createGraphToolAfterHook(deps: GraphToolHookDeps): Hooks['tool.execute.after']; export {}; //# sourceMappingURL=graph-tools.d.ts.map