import { z } from 'zod'; import { type DeclaredIntentRef } from '@mmnto/totem'; /** Options for {@link prMergeCommand}. */ export interface PrMergeOptions { /** Evaluate posture + auto-close safety and exit 0/1 WITHOUT merging. */ checkOnly: boolean; /** After a successful merge, close marker-declared targets (default: print the commands). */ closeDeclared: boolean; } /** Runs a `gh` subcommand, returning stdout. MUST throw on a non-zero exit (fail-closed). */ export type GhRunner = (args: string[]) => string; /** Injectable seams for {@link prMergeCommand} (defaults spawn real `gh`). */ export interface PrMergeDeps { gh: GhRunner; cwd: string; out: (text: string) => void; err: (text: string) => void; } /** * `gh pr view --json title,body,state,number,headRefOid`. NO comments field — * comments never auto-close, so they are never fetched or scanned. `body` is * coerced from a possible null to '' (gh emits null for an empty description). */ export declare const PrViewSchema: z.ZodObject<{ title: z.ZodString; body: z.ZodEffects>, string, string | null | undefined>; state: z.ZodString; number: z.ZodNumber; headRefOid: z.ZodString; }, "strip", z.ZodTypeAny, { number: number; state: string; title: string; body: string; headRefOid: string; }, { number: number; state: string; title: string; headRefOid: string; body?: string | null | undefined; }>; export type PrView = z.infer; /** `gh pr view N --json state,mergedAt` — the post-command landing check (codex B-5). */ export declare const PrMergeStateSchema: z.ZodObject<{ state: z.ZodString; mergedAt: z.ZodOptional>; }, "strip", z.ZodTypeAny, { state: string; mergedAt?: string | null | undefined; }, { state: string; mergedAt?: string | null | undefined; }>; /** * Reject any PR positional that is not a positive decimal (codex B-2). Called at * BOTH the Commander boundary (index.ts action) and the command boundary * (prMergeCommand) so no path forwards a URL/branch to `gh pr view`. `undefined` * (no positional — merge the current branch's PR) is allowed. */ export declare function assertValidPrNumberArg(arg: string | undefined): void; /** Result of evaluating a PR's title + body for undeclared auto-close refs. */ export interface PrMergeEvaluation { /** True iff every close-keyword-adjacent ref is marker-authorized. */ ok: boolean; /** Normalized keys of every close-keyword-adjacent ref found. */ findings: string[]; /** Normalized keys authorized by a totem-close marker. */ declaredByMarker: string[]; /** Findings NOT authorized by a marker — these refuse the merge. */ undeclared: string[]; } /** * Evaluate a PR's title + body against the ONE shared close-keyword evaluator. * Reuses core's {@link scanPrCorpus} (which composes `findAutoCloseRefs` + * `parseDeclaredCloseIntent` + the marker-strip) over the title + body ONLY — no * commit messages, no comments. `closingIssuesReferences` is GitHub-derived and * therefore non-authorizing (codex #3), so the client wrapper passes `[]`. */ export declare function evaluatePrMerge(pr: { title: string; body: string; repo: string; }): PrMergeEvaluation; /** * Flags a merge argv must NEVER contain: any body/subject vector. Under the BLANK * squash posture a `--body`/`-b`/`--body-file`/`-F`/`-t`/`--subject` is the * confirmed accidental-close vector, so the constructed argv is asserted (not just * the behavior) to exclude them. */ export declare const FORBIDDEN_MERGE_FLAGS: string[]; /** * Build the squash-only merge argv. NO body/subject flags, EVER (asserted in * tests). Binds the merge to the resolved `repo` (same identity `gh pr view` used * — codex B-2) and to the evaluated snapshot via `--match-head-commit ` * (codex Q / Greptile P1 / CR): the merge refuses if HEAD moved after evaluation. */ export declare function buildMergeArgv(prNumber: number, repo: string, headRefOid: string): string[]; /** * Build the `gh issue close` argv for a marker-declared target (opt-in * --close-declared). Binds to the ref's qualifier when present, else the resolved * `repo` (same identity as the merge). The comment carries NO backticks (they * execute as command substitution if the printed line is pasted — codex NB-1) and * no close-keyword adjacent to the digit ref (the word before `#N` is `PR`). */ export declare function buildIssueCloseArgv(ref: DeclaredIntentRef, prNumber: number, repo: string): string[]; /** * Shell-quote a single argv token for a COPY-PASTE-runnable display line * (codex NB-1). OS-appropriate: PowerShell single-quotes (embedded `'` doubled) * on Windows, POSIX single-quotes (embedded `'` → `'\''`) elsewhere. A token with * no shell-special char is left bare. */ export declare function quoteArgForDisplay(token: string): string; /** Render a `gh ` line that is safe to copy-paste into the user's shell. */ export declare function displayGhCommand(argv: string[]): string; /** * `totem pr merge [number]`. Returns an exit code (the index wrapper sets * process.exitCode) — 0 on a clean merge / clean --check-only / a queued * (merge-queue) landing, 1 on an invalid PR argument, posture drift, an undeclared * close-keyword ref, any gh/env failure in the pre-merge phase (fail-closed, NO * merge attempted), or a `--close-declared` run where a requested close failed. * * `assertValidPrNumberArg` runs FIRST (before any gh call) so a URL/branch * positional is refused up front (codex B-2); it throws a TotemError that * propagates to the index handler. */ export declare function prMergeCommand(prNumberArg: string | undefined, opts: PrMergeOptions, depsInput?: Partial): Promise<{ exitCode: number; }>; //# sourceMappingURL=pr.d.ts.map