/**
 * Check if `dir` is inside a git repository (**async, worktree-correct**).
 *
 * Shells out to `git rev-parse --git-dir`, so it returns true from any
 * subdirectory and for linked worktrees. Distinct from the synchronous,
 * root-only `isGitRepo` in `lib/git.ts` (a `.git`-existence check): different
 * semantics, so the two are intentionally **not** merged.
 */
export declare function isGitRepo(dir: string): Promise<boolean>;
export declare function getGitRoot(dir: string): Promise<string>;
/**
 * Check if a worktree directory has uncommitted changes.
 */
export declare function hasUncommittedChanges(worktreePath: string): Promise<boolean>;
/** Default cap on diff text so one giant worktree can't blow up the serve dashboard. */
export declare const DEFAULT_DIFF_MAX_BYTES = 200000;
/**
 * Return the uncommitted working-tree diff for a worktree (staged + unstaged,
 * relative to HEAD), capped so a huge diff can't overwhelm the read-only serve
 * dashboard. Read-only: shells out to `git diff HEAD` and never mutates state.
 * Returns '' when the path isn't a git worktree or has no pending changes.
 */
export declare function gitDiff(worktreePath: string, maxBytes?: number): Promise<string>;
/**
 * Resolve the repo's default branch name (origin/HEAD → `main`/`master`/…).
 * Refreshes origin/HEAD first so a repo cloned before the default was set resolves.
 * Falls back to `main` when origin/HEAD isn't set.
 */
export declare function localDefaultBranch(gitRoot: string): Promise<string>;
/**
 * How many commits the checkout at `repoDir` is behind freshly-fetched
 * `origin/<default>` — the staleness the `teams add` guard checks before pointing
 * a team at a repo.
 *
 * Fetches `origin` FIRST, on purpose: the exact failure this guards (a team
 * pointed at a repo "without fetching first" — a 71-commit-stale s1 checkout in
 * the real incident) leaves the remote-tracking ref itself stale, so a naive
 * `HEAD..origin/<default>` reads 0 and hides the drift. After the fetch the count
 * is against the true remote.
 *
 * Measures the passed checkout's OWN root ({@link getGitRoot} / `--show-toplevel`,
 * worktree-correct) — NOT {@link getMainRepoRoot}: for a `--use-worktree` shared
 * worktree (or a caller standing inside a linked worktree), the teammate runs in
 * THAT worktree, whose HEAD differs from the main checkout's, so folding to the
 * main root would report the wrong tree's staleness. `origin/<default>` resolves
 * from the shared object store regardless of which worktree we stand in. Returns
 * null when `repoDir` isn't a git repo, origin is unreachable, or git errors — the
 * caller treats null as "can't tell, don't block".
 */
export declare function commitsBehindDefault(repoDir: string): Promise<{
    behind: number;
    base: string;
} | null>;
/**
 * Create a new git worktree for a teammate, branched off the freshly-fetched
 * default branch. Fetches `origin` first and bases the branch on
 * `origin/<default>` so a stale local checkout cannot fork teammates off old
 * code. Matches `createRemoteWorktree` — local and remote isolation share one
 * base policy.
 *
 * Resolves the placement root with {@link getMainRepoRoot}, NOT the local
 * `getGitRoot`/`--show-toplevel`, on purpose: when `repoDir` (the caller's
 * ambient cwd) is itself inside another teammate's linked worktree,
 * `--show-toplevel` returns THAT worktree's own root, so the new worktree
 * lands nested inside it (observed: `.../worktrees/A/.agents/worktrees/B`,
 * destroyed along with A's cleanup). `getMainRepoRoot` follows
 * `--git-common-dir`, which always points at the primary checkout's `.git`
 * regardless of which worktree the caller is standing in.
 *
 * @param repoDir - Directory inside the git repository (main checkout or any linked worktree)
 * @param worktreeName - Name for the worktree (used in path and branch)
 * @returns The absolute path to the created worktree
 */
export declare function createWorktree(repoDir: string, worktreeName: string): Promise<string>;
/**
 * Remove a git worktree and optionally its branch.
 *
 * Resolves via {@link getMainRepoRoot}, same as {@link createWorktree} — a
 * caller standing inside a DIFFERENT linked worktree (e.g. a `teams stop`
 * run from within another teammate's checkout) must still target the main
 * repo's `.agents/worktrees/<name>`, not `--show-toplevel`'s local answer.
 *
 * @param repoDir - Directory inside the git repository (main checkout or any linked worktree)
 * @param worktreeName - Name of the worktree to remove
 * @param deleteBranch - Whether to delete the associated branch
 */
export declare function removeWorktree(repoDir: string, worktreeName: string, deleteBranch?: boolean): Promise<void>;
/**
 * Get the worktree path for a given name.
 */
export declare function getWorktreePath(gitRoot: string, worktreeName: string): string;
/**
 * Get the branch name for a worktree.
 */
export declare function getWorktreeBranch(worktreeName: string): string;
/**
 * Does the CHECKOUT DIRECTORY for this worktree name exist?
 *
 * Narrower than {@link worktreeExists}, and the difference is load-bearing:
 * `teams add` only ever cleans up after a failed create when there is NO
 * checkout — i.e. when all that can be left is a dangling `agents/<name>`
 * branch ref. That keeps the cleanup incapable of deleting anybody's files,
 * including a concurrent add's freshly-created worktree, whatever the
 * pre-flight probe saw a `git fetch` ago. (RUSH-2356)
 */
export declare function worktreeCheckoutExists(repoDir: string, worktreeName: string): Promise<boolean>;
/**
 * Does anything already exist under this worktree name — the checkout directory
 * or its `agents/<name>` branch?
 *
 * Answered from git and the filesystem, never from teammate records: it is asked
 * by `teams add` immediately BEFORE {@link createWorktree}, so that if the create
 * fails the command can tell "the branch ref I half-created" (safe to remove)
 * from "something that was already here" (never remove — `teams stop` deliberately
 * KEEPS a worktree holding uncommitted changes, and its teammate record is
 * terminal by then, so no record-based check can protect it). (RUSH-2356)
 */
export declare function worktreeExists(repoDir: string, worktreeName: string): Promise<boolean>;
