@hasna/projects
Version:
High-level project management CLI, MCP server, SDK, and AI SDK agent loop for coding agents
124 lines • 5.41 kB
TypeScript
type TmuxCommandRunner = (args: string[]) => string;
export declare function withTmuxCommandRunnerForTest<T>(runner: TmuxCommandRunner, fn: () => T): T;
export interface TmuxSession {
name: string;
group: string;
windows: number;
attached: boolean;
}
export interface TmuxWindow {
session: string;
index: number;
name: string;
active: boolean;
}
export type TmuxWindowDeadReason = "alive" | "missing" | "no-panes" | "all-panes-dead";
export interface TmuxPaneStatus {
session: string;
windowIndex: number;
windowName: string;
paneIndex: number;
command: string;
currentPath: string;
dead: boolean;
deadStatus: number | null;
active: boolean;
}
export interface TmuxWindowHealth extends TmuxWindow {
exists: boolean;
panes: TmuxPaneStatus[];
dead: boolean;
reason: TmuxWindowDeadReason;
}
export interface CreateWindowOptions {
cwd?: string;
detached?: boolean;
index?: number;
}
export interface ReviveWindowOptions {
command?: string;
cwd?: string;
force?: boolean;
}
export interface ReviveWindowResult {
action: "alive" | "created" | "recreated";
before: TmuxWindowHealth;
after: TmuxWindowHealth;
}
export interface TmuxGroup {
name: string;
sessions: string[];
windows: number;
}
export interface TmuxSessionLocation {
name: string;
group: string;
path: string;
}
export interface CreateGroupOptions {
/**
* Working directory the group session starts in. tmux resolves the start
* directory of a window from the session it is created in, so a group
* session without a project path leaves every grouped window in the cwd of
* whichever process happened to create the group.
*/
cwd?: string;
/** Name for the initial window. Ignored when joining an existing group (tmux rejects -n with -t). */
windowName?: string;
/** Existing tmux session group to join instead of anchoring a new one. */
group?: string;
}
export declare function listGroups(): TmuxGroup[];
export declare function createGroup(name: string, options?: CreateGroupOptions): void;
/**
* Working directory a tmux session was started in, used as the fallback start
* directory for windows created without an explicit cwd.
*/
export declare function sessionPath(session: string): string | undefined;
export declare function destroyGroup(name: string): void;
export declare function listSessionLocations(): TmuxSessionLocation[];
/**
* Point a tmux session's working directory at `cwd`.
*
* tmux only exposes session cwd mutation through `attach-session -c`. The
* runner always invokes tmux with piped stdio, so the attach itself can never
* succeed (tmux reports "open terminal failed: not a terminal") and can never
* hijack the caller's terminal; tmux applies `-c` before it tries to attach, so
* the working directory is still updated. The failure is therefore expected and
* swallowed.
*/
export declare function setSessionWorkingDirectory(session: string, cwd: string): void;
/**
* Keep every session in a tmux session group pointed at the project directory.
*
* `createGroup()` anchors the groups Projects creates, and `createWindow()`
* falls back to `#{session_path}`, but a session moved into a group outside the
* CLI (`tmux new-session -t <project> -s <peer>`) records the cwd of whatever
* shell ran that command — usually $HOME. tmux resolves the start directory of
* a window opened by an *attached* client from that session cwd, so grouped
* windows opened by hand still land outside the project until the group is
* realigned. Ungrouped sessions are left alone: their cwd belongs to whoever
* created them.
*/
export declare function alignGroupedSessionWorkingDirectories(session: string, cwd: string): string[];
export declare function listSessions(): TmuxSession[];
export declare function listWindows(session?: string): TmuxWindow[];
export declare function getWindowHealth(session: string, window: string): TmuxWindowHealth;
export declare function listWindowHealth(session: string): TmuxWindowHealth[];
export declare function findDeadWindows(session?: string): TmuxWindowHealth[];
export declare function createSession(name: string, projectPath?: string, windowName?: string): void;
export declare function createWindow(session: string, name: string, command?: string, options?: CreateWindowOptions): void;
export declare function killSession(name: string): void;
export declare function killWindow(session: string, name: string): void;
export declare function reviveWindow(session: string, window: string, options?: ReviveWindowOptions): ReviveWindowResult;
export declare function restartSession(name: string, projectPath?: string, windowName?: string): void;
export declare function reviveSession(name: string): boolean;
export declare function findDeadSessions(sessions?: TmuxSession[]): string[];
export declare function attachSession(name: string): void;
export declare function focusWindow(session: string, window: string): void;
export declare function renameWindow(session: string, oldName: string, newName: string): void;
export declare function renameSession(oldName: string, newName: string): void;
export declare function execInWindow(session: string, window: string, command: string): void;
export declare function cleanupDeadSessions(): string[];
export {};
//# sourceMappingURL=tmux.d.ts.map