/** * Walk up from `startDir` looking for a `.git` entry (file or directory). * Returns the directory containing `.git`, or null if none found within * `maxLevels` parent directories (default 5). This mirrors what `git * rev-parse` does internally but without shelling out. * * When no `.git` is found walking UP, we also check one level DOWN into * common child directories (frontend/, backend/, src/, packages/, apps/). * This handles monorepo layouts where the linked folder is the parent of * multiple independent git repos (e.g. `TeamShare/` containing * `TeamShare/frontend/.git`, `TeamShare/teamshare-backend/.git`). */ export declare function findGitRoot(startDir: string, maxLevels?: number): string | null; /** * Find ALL git repositories under `startDir`. Used by the multi-repo * finalize path to commit changes across independent repos (e.g., * `TeamShare/` containing `frontend/.git` and `teamshare-backend/.git`). * * If `startDir` itself is a git repo, returns `[startDir]` (single-repo * fast path). Otherwise recursively scans children up to `maxDepth` levels. */ export declare function findAllGitRoots(startDir: string, maxDepth?: number): string[]; /** True for a well-known main line, ignoring any `origin/` prefix. */ export declare function isMainlineBranchName(name: string | null | undefined): boolean; /** * True when committing onto (or merging into) `branch` would touch a branch a * HUMAN maintains: a well-known main line, the repo's detected default, or * whatever is checked out right now. */ export declare function isProtectedIntegrationTarget(branch: string | null | undefined, opts?: { detectedDefault?: string | null; checkedOut?: string | null; }): boolean; /** * Is the working tree sitting on a branch an agent must not commit to? * * Detection alone is not enough. `origin/HEAD` is often unset (cloned with * `--single-branch`, or a local-only repo), and the old fallback was: * * defaultBranch = mainExists.ok ? "main" : masterExists.ok ? "master" : "main"; * * which only consulted `origin/*` and, when neither existed, GUESSED `main`. * On a local-only repo whose default is `master`, `onDefault` came back false * for a developer working on `master` - and the commit + push went straight to * their branch. A developer on `develop` was invisible to this function * entirely. */ export declare function isOnDefaultBranch(gitRoot: string): { onDefault: boolean; currentBranch: string; defaultBranch: string; }; /** * True when `dir` is a linked git WORKTREE rather than the main working * tree: a worktree's `.git` entry is a FILE containing * `gitdir:
/.git/worktrees/`, while the main tree has a `.git` * directory. Used to route runs (private tree = own index/HEAD) and to * detach auto-created worktrees after a successful run. */ export declare function isWorktreeDir(dir: string): boolean; /** Current checked-out branch of `dir` (best-effort; "" when unavailable). */ export declare function currentBranchOf(dir: string): string; /** * Absolute path of the MAIN repository owning the worktree `dir`: a * worktree's `.git` file points at `
/.git/worktrees/`, and * `rev-parse --git-common-dir` resolves to that shared `.git`. Returns null * when `dir` is not a worktree. Needed to run `git worktree remove` FROM the * main tree (git refuses to remove the tree you are standing in). */ export declare function mainRepoOfWorktree(dir: string): string | null;