import type { GitAuth } from "./config.js"; export declare class GitError extends Error { readonly exitCode: number | null; readonly stderr: string; constructor(message: string, exitCode: number | null, stderr: string); } /** * Inject PAT into an HTTPS URL: `https://host/path` → `https://oauth2:@host/path`. * Returns undefined for non-HTTPS URLs (SSH, file://, etc.). */ export declare function injectPat(url: string, pat: string): string | undefined; /** * Shallow-clone a repo into `targetDir`. * * Auth behaviour: * - `auto`: try unauthenticated, PAT fallback on failure (HTTPS only). * - `pat`: inject PAT immediately. * - `none`: no credentials injected. */ export declare function clone(url: string, targetDir: string, auth: GitAuth, depth?: number, branch?: string): Promise; /** * Fetch latest from origin (shallow), then reset HEAD and working tree to * `FETCH_HEAD` so subsequent `git show HEAD:path` and `fs.readdir` see the new * content. Managed clones are mcp-digger-owned, so discarding any local * working-tree state via `reset --hard` is safe. * * Uses explicit URL for PAT retry so the token is never persisted in remote config. * Refspec is unified to `branch ?? "HEAD"` across both auth paths so * `FETCH_HEAD` resolves to a single deterministic commit. */ export declare function fetch(repoDir: string, auth: GitAuth, remoteUrl?: string, branch?: string): Promise; /** Get the commit hash for a ref (e.g. "HEAD", "FETCH_HEAD"). */ export declare function revParse(repoDir: string, ref: string): Promise; /** Check whether `dirPath` is inside a valid git repository. */ export declare function isValidRepo(dirPath: string): Promise; /** Read a file from the committed HEAD of a repo (not the working tree). */ export declare function readFile(repoDir: string, filePath: string): Promise; /** * List tracked files in the repo, optionally filtered by a pathspec pattern. * Returns repo-relative paths using forward slashes. */ export declare function listFiles(repoDir: string, pattern?: string): Promise; /** * List files in the repo at `HEAD`. Unlike {@link listFiles} (which reads the * git index and therefore counts staged-but-uncommitted files), this reads * the committed tree — matching downstream `git show HEAD:` semantics * used by `readFile()`. Use this when validity must be defined against what * is committed, not what is staged. */ export declare function listHeadFiles(repoDir: string): Promise; export interface LsRemoteResult { reachable: boolean; /** Number of branch refs found (only set when reachable). */ refCount?: number; /** Error message when not reachable (PAT-redacted). */ error?: string; /** Which auth methods were attempted, in order. */ attempts: Array<"unauthenticated" | "pat">; /** True when URL is HTTPS (PAT injection possible). */ isHttps: boolean; } /** * Lightweight connectivity check via `git ls-remote --heads`. * * Never throws — returns a result object indicating reachability. * Auth behaviour mirrors {@link clone}: auto tries unauthenticated first * with PAT fallback, pat injects immediately, none skips credentials. */ export declare function lsRemote(url: string, auth: GitAuth): Promise; //# sourceMappingURL=gitClient.d.ts.map