/** * `totem wt create|remove|list` — worktree lifecycle verbs with VERIFIED * removal (mmnto-ai/totem#2580 slice-2). * * The reason this exists is one git behaviour: `git worktree remove` exits 0 * on a removal that leaves the directory standing, and a husk that nobody * notices is the failure class the slice-1 estate sensor keeps finding. So the * removal verb never trusts an exit code — it removes, verifies absence, * finishes the residue if anything is left, re-verifies, and only then touches * the registry. Exit 0 means the directory is gone, and nothing else does. * * Three disciplines run through every verb here: * - **Record-first.** `create` writes the `~/.totem/worktrees.json` entry * BEFORE invoking git. A phantom entry fails visibly (`wt list` prints it * `missing`); an unrecorded worktree fails invisibly, which is exactly the * class this issue exists for. * - **Check-first.** A path is passed to `git worktree remove` only when * git's own list names it (the `author-sandbox.ts:112` precedent). A path * git does not track never reaches a git removal verb, and a path that is * in NEITHER git's list nor the registry is never touched at all. * - **Accounting, not classification.** `wt list` reports what was recorded * plus whether it is on disk. Deciding whether a worktree is active or * stale stays with `totem doctor --estate` — derive-once, one sensor. * * Classification of what a seat may delete is deliberately narrow at the ECL * boundary: untracked content under `/.totem/orchestration/**` blocks * removal outright, with no bypass flag (the operator ruling — a bypass would * re-open the silently-deleted-ECL hole this verb closes). */ import type { ResidueRemovalResult } from '@mmnto/totem'; /** * The core barrel, imported dynamically inside each command (mmnto-ai/totem#2339). * The `--help` cold-start protection is index.ts's lazy per-action * `await import('./commands/wt.js')`; the dynamic imports HERE (core, and * `./mail.js` for seat resolution) keep this module itself light so that lazy * load stays cheap. Only types cross the boundary statically — erased at build. */ type Core = typeof import('@mmnto/totem'); /** The injected exec seam — structurally `safeExec`, so tests pass a spy. */ export type WtExecFn = Core['safeExec']; /** Injected residue finish, so the still-present failure arm is reachable in tests. */ export type WtResidueFn = (dir: string) => Promise; export interface WtCreateOptions { slug: string; /** Container root override — highest precedence. */ root?: string; /** Seat override; default is `resolveSelfSender` against the home repo. */ seat?: string; /** Branch override; default `feat/-` or `wt/`. */ branch?: string; ticket?: string; json?: boolean; /** Test seam — production callers use `process.cwd()`. */ cwdForTest?: string; /** Test seam — production callers use `process.env`. */ envForTest?: NodeJS.ProcessEnv; /** Test seam — canned git. */ execForTest?: WtExecFn; /** Test seam — pins `createdAt`. */ nowForTest?: string; } export interface WtRemoveOptions { /** Absolute path, relative path, or a unique recorded basename. */ target: string; json?: boolean; cwdForTest?: string; execForTest?: WtExecFn; /** Test seam — production callers use `removeWorktreeResidue`. */ residueForTest?: WtResidueFn; } export interface WtListOptions { json?: boolean; /** Test seam — pins every `age-days`. */ nowForTest?: number; } /** * Create a worktree at `/--` on a NEW branch. * * `git worktree add -b` always: an existing branch is a hard error in v1 (the * ruling), so a create can never silently adopt someone else's in-flight work. * The registry entry is written first and rolled back best-effort on a git * failure; a rollback that ALSO fails names the phantom entry loudly rather * than leaving the operator to discover it from `wt list`. */ export declare function wtCreateCommand(options: WtCreateOptions): Promise; /** * Remove a worktree and PROVE it is gone. Exit 0 is granted only by a * no-follow existence probe returning absent; every failure path retains the * registry entry so the problem stays visible in `wt list`. */ export declare function wtRemoveCommand(options: WtRemoveOptions): Promise; /** * Accounting only: what was recorded, and whether it is on disk. Whether a * worktree is active or stale is NOT decided here — that classification lives * in the slice-1 sensor (`totem doctor --estate`), and duplicating it would * mint a second, drifting answer to the same question. */ export declare function wtListCommand(options?: WtListOptions): Promise; export {}; //# sourceMappingURL=wt.d.ts.map