/** The proposal row as the hub returns it (`Task.gitNaming`). */ export interface GitNamingProposal { branchName?: string | null; commitSubject?: string | null; commitBody?: string | null; prTitle?: string | null; prBody?: string | null; /** pending | applied | refused - only `pending` is a live proposal. */ status?: string | null; } /** Hard caps, mirrored by the MCP tool's schema (`tasks/git-naming.dto.ts`). */ export declare const GIT_COMMIT_SUBJECT_MAX = 72; export declare const GIT_COMMIT_BODY_MAX = 2000; export declare const GIT_PR_TITLE_MAX = 120; export declare const GIT_PR_BODY_MAX = 4000; export declare const GIT_BRANCH_NAME_MAX = 120; /** * THE prompt text. One constant, appended to the task brief AND the run/build/ * worker prompts, so "you may name it, you may not do it" cannot drift between * the surfaces an agent reads. */ export declare const GIT_DELIVERY_BLOCK: string; /** True when a proposal has not been consumed by a previous delivery report. */ export declare function isLiveProposal(proposal: GitNamingProposal | null | undefined): proposal is GitNamingProposal; export type BranchProposalResult = { ok: true; name: string; } | { ok: false; reason: string; }; /** * Normalize an agent-proposed branch name into the same shape the derived * branches use: lowercase `[a-z0-9-]` segments joined by `/`, prefixed with the * project slug when the agent sent a bare slug. * * Never throws: an unusable proposal is `{ ok: false, reason }` and the caller * keeps the derived name. */ export declare function normalizeBranchProposal(raw: string | null | undefined, projectSlug: string | null | undefined): BranchProposalResult; /** * The commit message the pipeline will use. Falls back to the task title, which * is exactly what the pipeline committed before this feature existed. */ export declare function composeCommitMessage(proposal: GitNamingProposal | null | undefined, taskTitle: string): { subject: string; body: string; }; /** The PR title, with the same fallback rule as the commit subject. */ export declare function composePrTitle(proposal: GitNamingProposal | null | undefined, taskTitle: string): string; /** * The PR body: the agent's description first, then the DETERMINISTIC trailer. * * The trailer is never omitted. A proposal can add context, but a reviewer must * always be able to get from a PR back to the task, its branch and its base - * that is what makes "which work is this?" answerable without the console. */ export declare function composePrBody(proposal: GitNamingProposal | null | undefined, ctx: { taskId: string; taskTitle: string; branch: string; baseBranch: string; }): string; export interface BranchRenameDecision { action: 'rename' | 'keep'; /** The branch this run delivers on (always the derived one on `keep`). */ branch: string; /** Why the proposal was not applied - reported to the human and the hub. */ reason?: string; /** The proposed name already IS the derived name; nothing to do. */ noop?: boolean; } /** * Decide whether the proposed branch name may replace this run's branch. * * Pure and order-sensitive on purpose: every rule is a refusal, so the default * for anything unexpected is the branch the pipeline already uses. */ export declare function decideBranchRename(input: { /** Already normalized proposed name (or null when none was proposed). */ proposed: string | null; /** Derived branch this run would deliver on. */ current: string; /** An orchestrator/chain assignment named the branch - never overridden. */ hubAssigned: boolean; /** The task already delivered on a branch (a retry continues it). */ alreadyDelivered: boolean; /** How many repos this run actually changed. */ changedRepos: number; /** The current branch already exists on the remote. */ published: boolean; /** The proposed name already exists locally or on the remote. */ targetExists: boolean; }): BranchRenameDecision; /** Local branch existence (`refs/heads/`), never guesses. */ export declare function branchExistsLocally(gitRoot: string, name: string): boolean; /** * Remote branch existence. `undefined` means "could not ask" (network/auth), * which the caller must treat as a refusal - guessing here is how a pushed * branch gets renamed under a reviewer. */ export declare function branchExistsOnRemote(gitRoot: string, remote: string, name: string): boolean | undefined; /** * Rename the CURRENT branch. Only ever called when the tree is on `from` (checked * here again) and the pre-flight said the name is free, so a failure is a git * refusal (a locked index), not a policy problem. */ export declare function renameBranch(gitRoot: string, from: string, to: string): { ok: boolean; detail: string; };