diff --git a/src/cli.ts b/src/cli.ts index b4c689f..0d667cc 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,7 +1,8 @@ #!/usr/bin/env bun import { Command } from "commander" -import { join } from "path" +import { basename, join } from "path" +import { homedir } from "os" import * as git from "./git.ts" import * as vm from "./vm.ts" import * as state from "./state.ts" @@ -22,8 +23,7 @@ program .description("Create a new session and launch Claude") .action(async (branch: string, prompt?: string) => { const root = await git.repoRoot() - const worktreeRel = `.sandlot/${branch}` - const worktreeAbs = join(root, worktreeRel) + const worktreeAbs = join(homedir(), '.sandlot', basename(root), branch) const existing = await state.getSession(root, branch) if (existing) { @@ -40,7 +40,7 @@ program await state.setSession(root, { branch, - worktree: worktreeRel, + worktree: worktreeAbs, created_at: new Date().toISOString(), }) @@ -94,7 +94,7 @@ program await vm.ensure() spin.succeed("Session ready") - await vm.claude(join(root, session.worktree)) + await vm.claude(session.worktree) }) // ── sandlot close ─────────────────────────────────────────── @@ -102,11 +102,10 @@ program const closeAction = async (branch: string) => { const root = await git.repoRoot() const session = await state.getSession(root, branch) - const worktreeRel = session?.worktree ?? `.sandlot/${branch}` - const worktreeAbs = join(root, worktreeRel) + const worktreeAbs = session?.worktree ?? join(homedir(), '.sandlot', basename(root), branch) await git.removeWorktree(worktreeAbs, root) - console.log(`Removed worktree ${worktreeRel}/`) + console.log(`Removed worktree ${worktreeAbs}/`) await git.deleteLocalBranch(branch, root) console.log(`Deleted local branch ${branch}`) @@ -157,7 +156,7 @@ program process.exit(1) } - const worktreeAbs = join(root, session.worktree) + const worktreeAbs = session.worktree const spin = spinner("Starting VM") await vm.ensure() diff --git a/src/vm.ts b/src/vm.ts index 224ed64..60f5e57 100644 --- a/src/vm.ts +++ b/src/vm.ts @@ -15,7 +15,7 @@ export async function ensure(): Promise { // Create from scratch const home = homedir() - await $`limactl create --name=${VM_NAME} --mount=${home}/dev:w template:ubuntu-24.04`.quiet() + await $`limactl create --name=${VM_NAME} --mount=${home}/dev --mount=${home}/.sandlot:w template:ubuntu-24.04`.quiet() await $`limactl start ${VM_NAME}`.quiet() // Provision