/** * Nested-repo scan for `specweave handoff --all` (read-only). * * An umbrella workspace keeps product code in its own Git checkouts under * `repositories//` (or any nested folder with its own `.git`), * usually gitignored by the umbrella, so the umbrella's own `git status` * never sees them. This module lists every checkout there (plus the worktrees Git knows about for each, wherever they * live, and the workspace root itself) and reports the ones holding work that * exists only on this machine: uncommitted files, commits ahead of the * upstream, or a branch with no remote. * * Nothing here writes: no fetch, no commit, no push. `gh pr list` is asked * for the open PR of each flagged branch when `gh` is installed; when it is * not, or it fails, the PR column stays empty. * * @module core/session/nested-repos */ export interface PullRequestInfo { number: number; url: string; state: string; isDraft: boolean; } export interface CheckoutState { /** Absolute path of the checkout. */ path: string; /** Path for display: relative to the workspace root when inside it. */ display: string; /** Branch name, or `(detached)`. */ branch: string; detached: boolean; /** Short sha of HEAD ('' in an empty repo). */ sha: string; /** Changed, staged and untracked files. */ dirty: number; /** Commits not on the upstream (or on no remote at all when there is no upstream). */ ahead: number; /** `origin/x` style upstream, when one is set and still exists. */ upstream?: string; /** The branch has no upstream and no remote-tracking branch of the same name. */ noRemote: boolean; /** ISO time of the last commit. */ lastCommitAt?: string; /** Open PR for the branch, when `gh` found one. */ pr?: PullRequestInfo; /** 4-digit increment ids found in the path or branch name. */ incrementIds: string[]; /** Why it is listed: dirty, ahead, no remote. Empty when the checkout is safe. */ reasons: string[]; } export type PrLookup = (cwd: string, branch: string) => Promise; export interface ScanOptions { /** 4-digit ids of the increments to map checkouts to. */ incrementIds?: string[]; /** Look up PRs (default: `gh pr list` when gh is installed). `false` skips it. */ prLookup?: PrLookup | false; /** Parallel Git processes (default 8). */ concurrency?: number; /** Include the workspace root checkout itself (default true). */ includeRoot?: boolean; } export interface NestedRepoScan { /** Every checkout found, flagged or not. */ scanned: number; /** Checkouts with local-only work, sorted by path. */ flagged: CheckoutState[]; } /** How deep below the root nested checkouts are looked for (`repositories//` is 3). */ export declare const NESTED_DEPTH = 3; /** Most directories one discovery reads, so a huge plain folder cannot stall a command. */ export declare const NESTED_DIR_BUDGET = 5000; /** * Nested Git checkouts under a workspace root: the repositories registered in * `.specweave/config.json`, then any folder up to {@link NESTED_DEPTH} levels * down that has a `.git` folder or file, whatever it is named * (`repositories//`, `apps/api`, `my-service`). The walk stays * inside the root, stops at the first checkout on each path, and lists each * real path once, preferring a registered or non-symlinked path over an * alias. The root itself is not listed. */ export declare function findNestedCheckouts(root: string): string[]; /** Increment ids (4 digits, not part of a longer number) that appear in the text. */ export declare function matchIncrementIds(text: string, ids: string[]): string[]; /** Parse `git status --porcelain=v2 --branch` into branch, upstream, ahead and dirty count. */ export declare function parseStatusV2(out: string): { branch: string; detached: boolean; upstream?: string; ahead?: number; dirty: number; oid?: string; }; /** State of one checkout. Returns null when it is not a readable Git checkout. */ export declare function inspectCheckout(dir: string, root: string, incrementIds?: string[]): Promise; /** `gh pr list --head ` in the checkout; undefined when gh is missing, fails or finds none. */ export declare const ghPrLookup: PrLookup; /** * Scan the workspace root, every nested checkout and their worktrees. * Read-only; never throws for a single unreadable checkout. */ export declare function scanNestedRepos(root: string, opts?: ScanOptions): Promise; //# sourceMappingURL=nested-repos.d.ts.map