import type { Repo } from "../api/repo.ts"; import type { Actor } from "../objects/types.ts"; /** * Programmatic git-history import (issue #63). * * A server process (or any embedder) replays a git repository's history into * an AVCS operation graph without shelling out to the `avcs` CLI. Two layers, * so the core's git-independence is preserved: * * - {@link GitHistorySource} — the seam. Anything that can enumerate commits * (sha + metadata + per-commit file changes) drives the import; no git * binary is required at this layer. * - {@link gitCliSource} — the batteries-included source. Reads a checkout, * a bare repo, a bundle file, or a clone URL by shelling out to `git` * (exactly like the CLI's existing git-bridge does). Fails with a clear * error when no git binary is available. * * History maps onto AVCS the way `commitWorkingTree` established: one intent + * one session per commit (title = the commit subject, owner = the git author), * `put_file`/`delete_file` operations per changed path, each new commit's ops * anchored on the previous frontier via `causalDeps`. AVCS history is an * operation graph, not replayed diffs — the import walks the FIRST-PARENT * line, so a merge commit lands as its net effect on the mainline (the side * branch's internal commits are not replayed). * * Commit metadata travels in existing fields — no object-schema change: * the actor is `git:`, `Co-authored-by:` trailers become * `coAuthors`, and `declaredPurpose` carries the full commit message plus a * `[git ] ` provenance line. */ /** One file touched by a commit. `read` is required for `kind: "write"`. */ export interface GitFileChange { readonly path: string; readonly kind: "write" | "delete"; readonly read?: () => Promise; } /** One commit on the imported line, in replay (oldest-first) order. */ export interface GitCommitRecord { readonly sha: string; readonly subject: string; readonly message: string; readonly authorName: string; readonly authorEmail: string; /** Author date, ISO-8601. */ readonly authorDate: string; readonly coAuthors: ReadonlyArray<{ name: string; email: string; }>; readonly changes: readonly GitFileChange[]; } /** The import seam: enumerate commits oldest-first. No git binary implied. */ export interface GitHistorySource { commits(): AsyncIterable; /** Release temp resources (e.g. a bare clone). Safe to omit. */ close?(): Promise; } export interface ImportGitHistoryOptions { /** AVCS line (view) to import onto. Default `main`. */ readonly line?: string; /** * Actor recorded when a commit has no usable author identity, and the * session opener. Defaults to `{ id: "git-import", kind: "ci_bot" }`. */ readonly actor?: Actor; /** Progress callback: commits replayed so far + the sha just finished. */ readonly onCommit?: (done: number, sha: string) => void; } export interface ImportGitHistoryResult { /** Commits walked on the first-parent line (empty ones included). */ readonly commits: number; /** Operations authored. */ readonly operations: number; /** Intents created (one per commit that changed anything). */ readonly intents: number; } /** What {@link gitCliSource} accepts: a checkout/bare dir, a bundle, or a URL. */ export type GitCliTarget = string | { dir?: string; url?: string; bundle?: string; ref?: string; /** * Wall-clock bound for EVERY git invocation (issue #71). A server driving * this cannot afford an unbounded clone: an endpoint that accepts and never * answers would hang the request forever and leak the temp clone. Default * 10 minutes; 0 disables the bound. */ timeoutMs?: number; }; /** * A {@link GitHistorySource} backed by the `git` binary. A URL or bundle is * bare-cloned into a temp dir (removed on `close()`); a local dir is read in * place. The walk is `rev-list --first-parent --reverse ` and per-commit * changes come from `diff-tree` against the first parent (`--no-renames`, so * a rename is a delete + write — the reducer treats paths as entities). */ export declare function gitCliSource(target: GitCliTarget): Promise; /** * Replay a git history into `repo` as an operation graph. See the module doc * for the mapping. Accepts a {@link GitHistorySource}, or anything * {@link gitCliSource} understands (dir / URL / bundle path). */ export declare function importGitHistory(repo: Repo, source: GitHistorySource | GitCliTarget, opts?: ImportGitHistoryOptions): Promise; //# sourceMappingURL=gitHistory.d.ts.map