/** * Git diff integration for drift detection * * Shells out to git to determine what files changed between the current * working tree and a base ref (typically main/master). */ import type { ChangedFile } from '../../types/index.js'; export interface GitDiffOptions { rootPath: string; baseRef: string; pathFilter?: string[]; includeUnstaged: boolean; } export interface GitDiffResult { resolvedBase: string; files: ChangedFile[]; hasUnstagedChanges: boolean; currentBranch: string; } /** * Classify a file path as test/config/generated */ export declare function classifyFile(filePath: string): Pick; /** * Check if a file is a skippable binary/lock file */ export declare function isSkippableFile(filePath: string): boolean; /** * Check if the given path is a git repository */ export declare function isGitRepository(rootPath: string): Promise; /** * Get the current branch name */ export declare function getCurrentBranch(rootPath: string): Promise; /** * Validate a user-supplied git ref to prevent unexpected git argument injection. * Allows branch/tag names, SHA hashes, relative refs (HEAD~1, @{upstream}), and * the empty-tree SHA. Rejects refs containing shell metacharacters or null bytes. * * Argument-injection guard (mcp-security: Subprocess Argument Safety): a ref is * always passed to git as a single argv element, which prevents shell injection but * NOT flag interpretation — `--upload-pack=...` or `--output=x` would still be read * by git as an OPTION. Real refs/branches/SHAs never begin with `-`, so a * leading-dash ref is rejected outright; this is the validation half of the spec's * "`--` separator OR allowlist" requirement (ref operands are also placed after `--` * at the call sites where git supports it). */ export declare function validateGitRef(ref: string): void; /** * Resolve a base ref, falling back through main → master → HEAD~1 */ export declare function resolveBaseRef(rootPath: string, preferredRef: string): Promise; /** * Get the unified diff content for a specific file against a base ref. * Returns the diff text, truncated to maxChars to fit LLM context windows. */ export declare function getFileDiff(rootPath: string, filePath: string, baseRef: string, maxChars?: number): Promise; /** * Get commit messages between baseRef and HEAD as a single string. * Returns empty string if no commits or git fails. */ export declare function getCommitMessages(rootPath: string, baseRef: string): Promise; /** * Get changed files between working tree and a base ref */ export declare function getChangedFiles(options: GitDiffOptions): Promise; //# sourceMappingURL=git-diff.d.ts.map