/** `t--<4 hex>`: the part before the hex is at most 32 characters. */ export declare function taskTag(id: number, title: string, rand?: () => string): string; export interface TaskWorktree { path: string; branch: string; repo: string; base: string; baseRef: string; cwd: string; sourceDirty: boolean; included: string[]; } /** A worktree and branch for a task, from the tip of the branch checked out in the main checkout. */ export declare function createTaskWorktree(repoDir: string, id: number, title: string, rand?: () => string): TaskWorktree; /** No tracked or untracked changes (ignored files are fine); undefined when git fails. */ export declare function worktreeClean(path: string): Promise; export declare function commitAll(path: string, message: string): Promise<{ ok: true; sha: string; } | { ok: false; error: string; }>; export declare function revParse(dir: string, ref: string): Promise; export declare function isAncestor(dir: string, a: string, b: string): Promise; export declare function hasIdentity(dir: string): Promise; export type SyncResult = { kind: "clean"; moved: boolean; } | { kind: "conflict"; files: string[]; } | { kind: "error"; message: string; }; /** Merge base into the task branch, in its worktree. A conflict stays in progress there. */ export declare function syncWithBase(path: string, baseRef: string): Promise; export declare function abortSync(path: string): Promise; /** The checkout (main or linked) that has refs/heads/ checked out. */ export declare function findCheckout(repo: string, baseRef: string): Promise; export type MergeResult = { kind: "merged"; into: string; } | { kind: "moved"; } | { kind: "refused"; reason: string; } | { kind: "failed"; message: string; baseMoved: boolean; }; export declare function mergeIntoBase(o: { repo: string; branch: string; baseRef: string; tip: string; oldBase: string; mode: "ff" | "no-ff"; }): Promise; /** After a merge: remove a clean worktree, delete the branch if it is exactly what was merged. */ export declare function cleanupMergedTask(t: { repo: string; path: string; branch: string; tip: string; baseRef: string; }): Promise<{ worktreeRemoved: boolean; branchDeleted: boolean; reason?: string; }>; /** Orders pi-roost's own merges in one repository: a lock file in the common git dir. */ export declare function withMergeLock(repo: string, fn: () => Promise, staleMs?: number): Promise; /** M55: the branch checked out in a worktree (refs/heads/… without the prefix), or undefined (detached, unreadable). */ export declare function currentBranch(path: string): Promise; /** * M57: what a task's worktree holds against its base: the files changed since the commit * its branch shares with base (committed and not, tracked; new files too), the commits * base does not have, whether anything is uncommitted. Undefined when git cannot say (the * worktree gone, no base). Read-only, without the index lock. */ export declare function taskChanges(path: string, baseRef: string): Promise; /** M59: a task's worktree removed (shelved): only a clean one; its branch stays. */ export declare function removeTaskWorktree(repo: string, path: string): Promise<{ ok: true; } | { ok: false; reason: string; }>; /** * M59: a shelved task's worktree made again at its old path from its branch (the branch * checked out there again, `.worktreeinclude` copied as for a new one). */ export declare function restoreTaskWorktree(repo: string, path: string, branch: string): void; /** M59: the task worktrees git knows in a repository: path, branch (without refs/heads/), the task id in its name. */ export declare function taskWorktrees(repo: string): Promise<{ path: string; branch: string; id: number; }[]>; /** `owner/repo` (with its host when not github.com) from a remote's URL, for `gh --repo`; undefined when it is not one. */ export declare function ghRepoOf(url: string): string | undefined; /** * M60: where a task's pull request goes: the remote (`origin`, else the only one), the URL * git pushes to (pushurl and insteadOf applied), the repository gh opens it in. */ export declare function prTarget(path: string): Promise<{ ok: true; remote: string; url: string; repo?: string; } | { ok: false; reason: string; }>; /** * M60: the optional exit: the commit shown (`tip`, not whatever the branch is now) pushed * to the branch on the remote shown, never forced; then a pull request into base with * `gh` (in the repository the push went to). A pull request gh says exists already, or * opened before gh was cut short, is found and taken. */ export declare function openTaskPr(o: { path: string; branch: string; baseRef: string; tip: string; remote: string; repo?: string; title: string; body: string; }): Promise<{ ok: true; url: string; } | { ok: false; reason: string; }>; export declare const makeTaskWorktree: (repo: string, id: number, title: string) => Promise; export declare const remakeTaskWorktree: (repo: string, path: string, branch: string) => Promise;