import type { RunRecord } from "./types.js";
export type MergeNodeResult = {
    mergeChangeId: string;
    opId: string;
    conflictedFiles: string[];
};
/**
 * Hard requirement: jj must be installed. Throws MissingToolError otherwise.
 */
export declare function ensureJj(): void;
/**
 * Parse `jj --version`. Returns the version string (e.g. "0.40.0") or "".
 * Warns (does not throw) when below MIN_JJ.
 */
export declare function jjVersion(): Promise<string>;
/**
 * Idempotently colocate a jj repo with the git repo at repoRoot. If already a
 * jj repo, no-op. Otherwise runs `jj git init --colocate`.
 */
export declare function ensureColocated(repoRoot: string): Promise<void>;
export declare function isJjRepo(cwd: string): boolean;
export declare function findJjRoot(cwd: string): string;
/**
 * The change id of `@` (the working-copy commit) in the given workspace.
 */
export declare function currentJjChangeId(workspacePath: string): Promise<string>;
export declare function jjStatus(workspacePath: string): Promise<string[]>;
export declare function parseJjStatus(stdout: string): string[];
export declare function jjDiff(workspacePath: string): Promise<string>;
/**
 * Create a new empty change parented on the given changes. Reads the new change
 * id back by querying a unique marker embedded in the description, never by
 * scraping stdout. Returns the new change id.
 */
export declare function createEmptyChange(params: {
    repoRoot: string;
    parents: string[];
    description: string;
}): Promise<string>;
export declare function describeChange(repoRoot: string, changeId: string, message: string): Promise<void>;
/**
 * Create a jj workspace for a node/run. Workspace name matches the original
 * rudder regex `rudder-<id.slice(0,14)>-<shortHash(id).slice(0,6)>`. If
 * `atChangeId` is given, parent the working-copy commit on it; falls back to
 * `jj workspace add` + `jj edit <atChangeId>` if `-r` is unsupported.
 */
export declare function createNodeWorkspace(params: {
    repoRoot: string;
    nodeId?: string;
    runId?: string;
    task?: string;
    atChangeId?: string;
}): Promise<{
    workspaceName: string;
    path: string;
}>;
/**
 * Phase-1 entry point used by run-manager. Delegates to createNodeWorkspace.
 */
export declare function createRunJjWorkspace(params: {
    repoRoot: string;
    runId: string;
    task: string;
}): Promise<{
    workspaceName: string;
    path: string;
}>;
/**
 * Merge a run's jj change into the current (main) workspace `@`. Captures the
 * operation id before the merge and records it on merge.operationId. On
 * conflict sets merge.status="conflict" + conflictedFiles + mergeChangeId.
 */
export declare function mergeJjRunIntoCurrentWorkspace(run: RunRecord, allowDirty?: boolean): Promise<RunRecord>;
/**
 * Merge two changes into a new change. Captures the op id (after the merge),
 * returns the new merge change id and any conflicted files. jj merges never
 * fail on conflict; the conflict is recorded in the merge change.
 */
export declare function mergeNode(params: {
    repoRoot: string;
    nodeChangeId: string;
    intoChangeId: string;
    message: string;
}): Promise<MergeNodeResult>;
export declare function jjConflictedFiles(workspacePath: string): Promise<string[]>;
/**
 * Alias matching the plan's API name.
 */
export declare function listConflicts(workspacePath: string): Promise<string[]>;
export declare function parseJjConflictedFiles(stdout: string): string[];
/**
 * The id of the latest operation in the op log.
 */
export declare function currentOpId(repoRoot: string): Promise<string>;
/**
 * Restore the repo to an earlier operation. One call rewinds all workspaces and
 * refs atomically (op restore is global).
 */
export declare function undoToOp(repoRoot: string, opId: string): Promise<void>;
export declare function undoLast(repoRoot: string): Promise<void>;
/**
 * Export jj changes to the colocated git repo. Call after each merge, before
 * opening a diff review, and before a PR.
 */
export declare function exportToGit(repoRoot: string): Promise<void>;
export declare function createBookmark(repoRoot: string, name: string, atChangeId: string): Promise<void>;
export declare function pushBookmark(repoRoot: string, name: string): Promise<void>;
/**
 * Forget a jj workspace and remove its directory.
 */
export declare function forgetWorkspace(params: {
    repoRoot: string;
    workspaceName: string;
    workspacePath: string;
}): Promise<void>;
export declare function removeRunWorkspace(run: RunRecord): Promise<void>;
/**
 * Rebase a run's node change onto the trunk. jj records conflicts in place and
 * never blocks, so there is no rebase-in-progress dance.
 */
export declare function syncRunWorkspace(run: RunRecord, baseBranch: string): Promise<RunRecord>;
