/**
 * ESM-friendly bridge to the bundled worktree Node-API native addon.
 *
 * The napi-rs loader staged into `native/worktree-napi.cjs` exposes its surface as
 * `module.exports = nativeBinding` — Node.js's CJS-to-ESM interop cannot
 * statically detect named exports from a dynamic require(), so consumers route
 * through this bridge instead of importing the native loader directly.
 *
 * This module wraps the native binding via `createRequire` so the import looks
 * like a regular dynamic require from a CJS context. All consumers in this
 * package import napi functions from THIS module, never directly from the
 * native loader.
 *
 * Resolution order (first hit wins):
 *
 *   1. Bundled loader at `../native/worktree-napi.cjs` (published
 *      `@cleocode/worktree` tarball).
 *   2. Repo-local crate loader at `../../../crates/worktree-napi/index.cjs`
 *      (source-tree execution after a local napi build).
 *   3. **Core-managed cache** (T11580 · R10-L1): the host-triple `.node`
 *      resolved by the shared `@cleocode/core` postinstall picker under
 *      `<cache>/cleo/napi-bin/<version>/worktree-napi.<triple>.node`. This is
 *      the Distribution Pattern P2 runtime hand-off — the picker downloads +
 *      sha256-verifies the addon; this loader simply `require()`s the cached
 *      file (the `.node` exports `module.exports = nativeBinding`, so no `.cjs`
 *      wrapper is needed). Picked newest-version-first.
 *
 * @task T9982
 * @task T11580
 */
interface CopyOptsNapi {
    /** Overwrite existing entries at the destination. */
    force: boolean;
    /** When set, every destination must resolve inside this root. */
    rootGuard?: string;
    /** Reserved for future use — symlinks are always followed by copy_leaf. */
    includeSymlinks: boolean;
}
interface CopyResultNapi {
    copiedCount: number;
    skippedCount: number;
    failedPaths: string[];
    totalBytes: number;
}
interface DestroyOptsNapi {
    repoRoot: string;
    worktreePath: string;
    force: boolean;
}
interface DestroyResultNapi {
    removed: boolean;
    branchDeleted: boolean;
}
interface IncludePatternNapi {
    pattern: string;
    isNegation: boolean;
}
interface ListOptsNapi {
    repoRoot: string;
}
interface WorktreeInfoNapi {
    path: string;
    branch?: string;
    head: string;
    isLocked: boolean;
    isPrunable: boolean;
}
/**
 * Options for the napi `pruneWorktrees` binding (T10203).
 *
 * Mirrors `crates/worktree-napi`'s `PruneOpts` — see ADR-087 for the
 * worktrunk-core SDK boundary contract.
 */
interface PruneOptsNapi {
    /** Absolute path to the git repository whose worktrees we plan to prune. */
    repoRoot: string;
    /**
     * The integration target branch (e.g. `"main"`) the candidates are tested
     * against for "is this merged in?".
     */
    integrationTarget: string;
}
/**
 * Single prune candidate returned by the napi `pruneWorktrees` plan (T10203).
 */
interface PruneCandidateNapi {
    /** Branch name (`undefined` for detached HEAD worktrees). */
    branch?: string;
    /** Display label (branch name or `(detached <short>)`). */
    label: string;
    /** Worktree path (`undefined` for branch-only candidates). */
    path?: string;
    /** Candidate kind: `"current" | "worktree" | "branch_only"`. */
    kind: string;
    /** Human-readable integration reason. */
    reason: string;
}
/**
 * Read-only prune plan returned by the napi `pruneWorktrees` binding (T10203).
 */
interface PrunePlanNapi {
    /** The default branch this plan was computed against. */
    integrationTarget: string;
    /** Candidates eligible for removal, in deterministic discovery order. */
    candidates: PruneCandidateNapi[];
}
/**
 * Options for the napi `removeDir` binding (T10203).
 *
 * Recursively removes a directory tree using
 * `worktrunk_core::remove_dir::remove_dir_with_progress`. Best-effort —
 * read/unlink/rmdir errors are silently skipped on the SDK side.
 */
interface RemoveDirOptsNapi {
    /** Absolute path to the directory tree to remove. */
    path: string;
}
/**
 * Result of a napi `removeDir` call (T10203).
 */
interface RemoveDirResultNapi {
    /** Number of leaf files unlinked. */
    files: number;
    /** Total bytes unlinked. Capped at `u32::MAX` for napi compatibility. */
    bytes: number;
}
/**
 * Options for the napi `provisionWorktree` binding (T11122).
 *
 * Mirrors `crates/worktree-napi`'s `ProvisionOpts` — see ADR-087 for the
 * worktrunk-core SDK boundary contract.
 */
interface ProvisionOptsNapi {
    /** Absolute path to the git repository. */
    repoRoot: string;
    /** Absolute target path where the new worktree should live. */
    targetPath: string;
    /** Branch name to create + check out. */
    branch: string;
    /** Base ref (commit-ish) to root the new worktree at. */
    baseRef: string;
    /** When set, the new worktree is locked with this reason string. */
    lockReason?: string;
}
/**
 * JS-facing handle returned from the napi `provisionWorktree` binding (T11122).
 */
interface WorktreeHandleNapi {
    /** Absolute path to the newly created worktree directory. */
    path: string;
    /** The branch the worktree checked out. */
    branch: string;
    /** The HEAD commit SHA at the moment of creation. */
    head: string;
}
/**
 * Options for the napi `integrateWorktree` binding (T11124).
 */
interface IntegrateOptsNapi {
    repoRoot: string;
    worktreePath: string;
    branch: string;
    targetBranch: string;
    taskTitle?: string;
    skipFetch: boolean;
}
/**
 * Result of the napi `integrateWorktree` binding (T11124).
 */
interface IntegrateResultNapi {
    taskId: string;
    targetBranch: string;
    merged: boolean;
    mergeCommit: string;
    commitCount: number;
    rebased: boolean;
    error?: string;
}
/**
 * Shape of the native module exported by the bundled Node-API binding.
 *
 * Mirrors the napi-rs `index.d.ts` but mapped into TS-friendly types that
 * this package owns (the `.d.ts` from the crate uses `Array<T>` and is
 * regenerated at every build, so we don't import from it directly).
 *
 * @internal
 */
interface WorktreeNapiModule {
    copyPathsParallel(srcDir: string, destDir: string, paths: string[], opts: CopyOptsNapi): CopyResultNapi;
    destroyWorktree(opts: DestroyOptsNapi): DestroyResultNapi;
    readWorktreeInclude(repoRoot: string): IncludePatternNapi[];
    applyInclude(patterns: IncludePatternNapi[], srcDir: string, destDir: string, opts: CopyOptsNapi): CopyResultNapi;
    listWorktrees(opts: ListOptsNapi): WorktreeInfoNapi[];
    pruneWorktrees(opts: PruneOptsNapi): PrunePlanNapi;
    removeDir(opts: RemoveDirOptsNapi): RemoveDirResultNapi;
    provisionWorktree(opts: ProvisionOptsNapi): WorktreeHandleNapi;
    integrateWorktree(opts: IntegrateOptsNapi): IntegrateResultNapi;
}
export declare const copyPathsParallel: WorktreeNapiModule['copyPathsParallel'];
export declare const destroyWorktree: WorktreeNapiModule['destroyWorktree'];
export declare const readWorktreeInclude: WorktreeNapiModule['readWorktreeInclude'];
export declare const applyInclude: WorktreeNapiModule['applyInclude'];
export declare const listWorktrees: WorktreeNapiModule['listWorktrees'];
export declare const pruneWorktrees: WorktreeNapiModule['pruneWorktrees'];
export declare const removeDir: WorktreeNapiModule['removeDir'];
export declare const provisionWorktree: WorktreeNapiModule['provisionWorktree'];
export declare const integrateWorktree: WorktreeNapiModule['integrateWorktree'];
export type { CopyOptsNapi, CopyResultNapi, DestroyOptsNapi, DestroyResultNapi, IncludePatternNapi, IntegrateOptsNapi, IntegrateResultNapi, ListOptsNapi, ProvisionOptsNapi, PruneCandidateNapi, PruneOptsNapi, PrunePlanNapi, RemoveDirOptsNapi, RemoveDirResultNapi, WorktreeHandleNapi, WorktreeInfoNapi, };
//# sourceMappingURL=napi-binding.d.ts.map