@phren/cli
Version:
Knowledge layer for AI agents - CLI, MCP server, and data layer
44 lines (43 loc) • 3.1 kB
TypeScript
import { type Json } from "./protocol.js";
/** Nested reads share one deadline. Abort and reap outstanding Git processes on
* expiry or failure; never leave a timed-out request running its command chain. */
export declare function withGitReadDeadline<T>(read: () => Promise<T>): Promise<T>;
/** Run provider work outside a completed route's local Git budget. Each local
* Git call retains its own timeout, while forge requests use provider limits. */
export declare function withoutGitReadDeadline<T>(read: () => Promise<T>): Promise<T>;
/** A background lookup owns its deadline even after the requesting route ends. */
export declare function withIndependentGitReadDeadline<T>(read: () => Promise<T>): Promise<T>;
/** Bind Git to the selected checkout, even when Hook inherited another Git
* process's repository/index environment. Keep user config (including excludes). */
export declare function checkoutGitEnv(): NodeJS.ProcessEnv;
export declare function git(cwd: string, ...args: string[]): Promise<string>;
export declare function gitRoot(dir: string): Promise<string | undefined>;
/** An unborn HEAD is normal; process/configuration failures are not. */
export declare function gitHead(root: string): Promise<string | undefined>;
/** The pane's working tree, plus anything the command named: files in the
* same repository that a hook already committed, and files in other
* repositories — the phren store, a sibling checkout — grouped by root. */
export declare function repositoryDiff(cwd: string, touched?: unknown[], allowedPaths?: string[]): Promise<Json>;
/** The HEAD file of the repository holding `cwd` (`.git/HEAD`, or a linked
* worktree's through its `.git` file), found without spawning git. */
export declare function headFile(cwd: string): Promise<string | undefined>;
export declare function repositoryBranch(cwd: string): Promise<string | undefined>;
/** `unverified`: the owner could not be checked against the live socket table, so no session may be handed this server. */
export interface LocalServer {
name: string;
port: number;
origin: string;
process?: string;
pid?: number;
unverified?: true;
}
/** The web servers listening here. A cached listener is checked against the live socket table
* before it is returned: if the process that held its address and port no longer listens there
* (it stopped, or closed the socket and kept running), the port may already belong to another
* session's server, and attributing it to the old owner would open that session's preview on the
* wrong app. Such a result drops the entry and refreshes the cache. */
export declare function webServers(): Promise<LocalServer[]>;
/** The key `addListener` files a server under: its host with the port always spelled out (a URL's host drops the default one). */
export declare function listenerKey(server: Pick<LocalServer, "origin" | "port">): string;
/** Launch only in real local directories under home or a locator candidate. */
export declare function launchDirectory(raw: unknown, activity?: Json[], located?: Iterable<string>): Promise<string>;