/** * Pack-push primitives for the CLI clone-path flow (qfg-7429.4, §4.1 * of project/plans/qfg-git-commit-push-pull-improvements.md). * * The CLI ships actual git commit objects to app-quonfig instead of a * file-delta list. This module owns the two preflight checks and the * `git pack-objects` wrapper: * * - `getCurrentBranch(dir)` — refuse detached HEAD and `master` * before any pack work happens. Returns the branch name to use as * the basename of `targetRef` on success. * - `buildPack(dir, expectedSha, newSha)` — produce the packfile of * `..` and return it as raw bytes. Capped at * 25 MiB per §7 open Q #7; throws `PackTooLargeError` on overflow. * * Pure(ish): every git invocation goes through `runGit`/`spawn`. Tests * stand up real tmp-dir git repos rather than mocking the shell — the * pack format is too fiddly to fake convincingly. */ /** Per §7 open Q #7 of the design plan: pack size cap of 25 MiB. */ export declare const MAX_PACK_BYTES: number; /** * Result of `getCurrentBranch`. `branch` carries the name to forward * into the server `targetRef`. `detached` and `master` carry the exact * user-facing refusal message — callers throw it as-is. */ export type CurrentBranchResult = { kind: 'branch'; name: string; } | { kind: 'detached'; message: string; } | { kind: 'master'; message: string; }; /** * Resolve HEAD via `git symbolic-ref HEAD`. Empty/failed resolution * means detached HEAD (per §4.1 step 1). `master` is treated as a * structural workspace error rather than a transient one — the * workspace template uses `main`, and a `master` checkout is almost * always a leftover from cloning a non-Quonfig template. */ export declare function getCurrentBranch(dir: string): Promise; export declare class PackTooLargeError extends Error { bytes: number; limit: number; constructor(bytes: number, limit: number); } export interface BuildPackOptions { /** Override the size cap. Defaults to MAX_PACK_BYTES. */ maxBytes?: number; } /** * Produce a packfile covering `..` — i.e. the new * commit objects, their trees, and their blobs that are not already * reachable from `expectedSha`. Internally: * * printf '\n^\n' | git pack-objects --revs --stdout * * which is the canonical "pack everything reachable from newSha but not * from expectedSha" recipe. Buffers the entire output to memory so we * can enforce the §7 cap before shipping anything to the server. * * Returns an empty `Uint8Array` when `expectedSha === newSha` — there * are no new commits, so `pack-objects` would either error on stdin * with no candidate revs or produce an empty pack. Skipping the spawn * keeps the no-op caller path simple. */ export declare function buildPack(dir: string, expectedSha: string, newSha: string, options?: BuildPackOptions): Promise;