optional prompt for new

This commit is contained in:
Chris Wanstrath 2026-02-17 20:15:09 -08:00
parent 9f250188ca
commit f7517fbd1b
2 changed files with 7 additions and 7 deletions

View File

@ -18,8 +18,9 @@ program.name("sandlot").description("Branch-based development with git worktrees
program program
.command("new") .command("new")
.argument("<branch>", "branch name") .argument("<branch>", "branch name")
.argument("[prompt]", "initial prompt for Claude")
.description("Create a new session and launch Claude") .description("Create a new session and launch Claude")
.action(async (branch: string) => { .action(async (branch: string, prompt?: string) => {
const root = await git.repoRoot() const root = await git.repoRoot()
const worktreeRel = `.sandlot/${branch}` const worktreeRel = `.sandlot/${branch}`
const worktreeAbs = join(root, worktreeRel) const worktreeAbs = join(root, worktreeRel)
@ -43,7 +44,7 @@ program
created_at: new Date().toISOString(), created_at: new Date().toISOString(),
}) })
await vm.claude(worktreeAbs) await vm.claude(worktreeAbs, prompt)
}) })
// ── sandlot list ────────────────────────────────────────────────────── // ── sandlot list ──────────────────────────────────────────────────────

View File

@ -65,13 +65,12 @@ async function loadEnv(): Promise<Record<string, string>> {
} }
/** Launch claude in the VM at the given workdir. */ /** Launch claude in the VM at the given workdir. */
export async function claude(workdir: string): Promise<void> { export async function claude(workdir: string, prompt?: string): Promise<void> {
const env = await loadEnv() const env = await loadEnv()
const envArgs = Object.entries(env).map(([k, v]) => `${k}=${v}`) const envArgs = Object.entries(env).map(([k, v]) => `${k}=${v}`)
const proc = Bun.spawn( const args = ["limactl", "shell", `--workdir=${workdir}`, VM_NAME, "env", ...envArgs, "claude", "--dangerously-skip-permissions"]
["limactl", "shell", `--workdir=${workdir}`, VM_NAME, "env", ...envArgs, "claude", "--dangerously-skip-permissions"], if (prompt) args.push(prompt)
{ stdin: "inherit", stdout: "inherit", stderr: "inherit" }, const proc = Bun.spawn(args, { stdin: "inherit", stdout: "inherit", stderr: "inherit" })
)
await proc.exited await proc.exited
} }