/** * The `/worktrees` command: what it needs, and how a choice becomes a transition. * * The invariant this module protects is that one dshline window drives one * root Session. `/worktrees` does not open a tab, a pane, or a second agent — * it resolves to exactly the same two attachment targets `/sessions` and * `/new` already produce, and hands them to the window's own transition: * * ```text * current attachment * ↓ retire (the owned AgentHandle disposer) * next target * ↓ * ctx.agents.resume({ resumeSessionId }) an existing conversation * ctx.agents.create({ meta: { cwd } }) a fresh one in the chosen directory * ↓ * next attachment * ``` * * Nothing else is written. A fresh session becomes a member of the directory's * group because Harness stamps `cwd` into its immutable header, which is the * grouping rule itself — there is no membership record to update, and no * durable state in dshline at all. * * Parallel work across directories is therefore still several terminals, each * rooted in its own — which is what the shell already gives, and what a * multiplexer inside the frontend would take over badly. * @module dshline/worktrees */ import type { Context } from '@deepseek-ai/cordis'; import type { SessionId } from '@deepseek-ai/dsh-session'; import type { SessionEntry } from '../sessions/model.ts'; import type { NewPlan, ResumePlan } from '../sessions/plan.ts'; import type { WorktreeChoice } from './model.ts'; export type { WorktreeCatalogSpec } from './catalog.ts'; export { WorktreeCatalog } from './catalog.ts'; export type { WorktreeChoice, WorktreeListing, WorktreeRow, WorktreeSelection, WorktreeSessionRow, } from './model.ts'; export { listingMessage, matchesWorktree, sessionCountLabel, sessionsMessage, worktreeLabel, worktreePath, worktreeRows, worktreeSessionRows, } from './model.ts'; export type { WorktreesOverlaySpec } from './overlay.ts'; export { createWorktreesOverlay } from './overlay.ts'; /** What opening the picker needs to know about the window it opens over. */ export interface WorktreesSpec { /** Context carrying the session corpus and the slot registry. */ readonly ctx: Context; /** The session this window is driving. */ readonly currentSessionId: SessionId; /** * The attached session's own `SessionHeader.cwd`, when its header records one. * * Optional and unsubstituted: a session whose header names no directory * marks no row, because the launch directory it operationally falls back to * is not a place that session's own history claims. Used only to mark the * current row; never to re-root anything. */ readonly currentCwd?: string; /** * Decide whether reopening one session is safe right now. * * The whole plan rather than the conditions it reads, and a function rather * than a value: the picker stays open across turns, so the busy and * active-work facts have to be sampled at the instant `enter` is pressed. * It is the same `planResume` `/sessions` uses — retiring this agent for a * directory is exactly as consequential as retiring it for a session, and * this offers no stronger resume promise than `/sessions` does. */ readonly planResume: (entry: SessionEntry) => ResumePlan; /** Decide whether retiring this attachment for a fresh session is safe right now. */ readonly planNew: () => NewPlan; /** The user's home directory; injected so path shortening is assertable. */ readonly home: string; /** Current time; injected so relative ages are assertable. */ readonly now?: () => number; } /** * Show the `/worktrees` picker and wait for the reader's answer. * * Resolves with a transition only when the reader chose one AND its plan * accepted it, so the caller never re-checks the conditions. Dismissing, or * choosing something a plan refused, resolves with undefined. * @param spec - the context, the attached session, and the live plans. * @returns the attachment transition to request, or undefined. */ export declare function openWorktrees(spec: WorktreesSpec): Promise; //# sourceMappingURL=index.d.ts.map