From ef8e40ecb35fde43dda7308abeca7b9c3796dffd Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Fri, 20 Feb 2026 07:44:43 -0800 Subject: [PATCH] add `sandlot shell ` command to open a shell in a session's worktree --- src/cli.ts | 18 ++++++++++++++++++ src/vm.ts | 12 ++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index 361a246..2e32b75 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -355,6 +355,24 @@ program } }) +// ── sandlot shell ─────────────────────────────────────────── + +program + .command("shell") + .argument("", "branch name") + .description("Open a shell in the VM at the session's worktree") + .action(async (branch: string) => { + const root = await git.repoRoot() + const session = await state.getSession(root, branch) + if (!session) { + console.error(`✖ No session found for branch "${branch}".`) + process.exit(1) + } + + await vm.ensure() + await vm.shell(session.worktree) + }) + // ── sandlot close ─────────────────────────────────────────── const closeAction = async (branch: string) => { diff --git a/src/vm.ts b/src/vm.ts index 8e384c9..f8a4aaa 100644 --- a/src/vm.ts +++ b/src/vm.ts @@ -202,12 +202,12 @@ export async function claude(workdir: string, opts?: { prompt?: string; print?: await proc.exited } -/** Open an interactive fish shell in the container. */ -export async function shell(): Promise { - const proc = Bun.spawn( - ["container", "exec", "-it", "--user", USER, CONTAINER_NAME, "env", "TERM=xterm-256color", "fish", "--login"], - { stdin: "inherit", stdout: "inherit", stderr: "inherit" }, - ) +/** Open an interactive fish shell in the container, optionally in a specific directory. */ +export async function shell(workdir?: string): Promise { + const args = ["container", "exec", "-it", "--user", USER] + if (workdir) args.push("--workdir", containerPath(workdir)) + args.push(CONTAINER_NAME, "env", "TERM=xterm-256color", "fish", "--login") + const proc = Bun.spawn(args, { stdin: "inherit", stdout: "inherit", stderr: "inherit" }) await proc.exited }