@phren/cli
Version:
Knowledge layer for AI agents - CLI, MCP server, and data layer
46 lines (45 loc) • 2.04 kB
TypeScript
import { type Json } from "./protocol.js";
/** Safe removal of a linked worktree from the phone. A preview first describes
* what removing it would lose; its token is a digest of that exact state, so a
* later removal either confirms the same state or is refused with the new one.
* The branch is never deleted, and only worktrees outside the main checkout and
* the requesting pane's own checkout qualify. */
export interface WorktreeRemovalSession {
pane: string;
title: string;
}
export interface WorktreeRemovalSubmodule {
path: string;
unpushedCommits: number;
}
export interface WorktreeRemovalPreview {
token: string;
repository: string;
path: string;
branch: string | null;
dirty: string[];
untracked: number;
submodules: WorktreeRemovalSubmodule[];
sessions: WorktreeRemovalSession[];
removable: boolean;
reason?: string;
}
/** A live pane, with the folder it is running in, considered for blocking. */
export interface WorktreeRemovalLiveSession {
pane: string;
title: string;
cwd: string;
}
export interface WorktreeRemovalContext {
/** The checkout the request's pane is in; never removable. */
paneRoot?: string;
/** Live panes on this server; any running inside the worktree blocks removal. */
sessions?: WorktreeRemovalLiveSession[];
}
/** Preview a removal: what the worktree is, what it would lose, and whether
* anything live is using it. A main or current checkout is refused outright. */
export declare function previewWorktreeRemoval(cwd: string, worktree: unknown, context?: WorktreeRemovalContext): Promise<WorktreeRemovalPreview>;
/** Remove a worktree after its preview token matches the state recomputed now.
* Dirty or untracked files the preview showed let the removal use `--force`;
* a token for a clean worktree never does. The branch is left in place. */
export declare function removeWorktree(cwd: string, worktree: unknown, token: unknown, expectedRepository: unknown, context?: WorktreeRemovalContext): Promise<Json>;