Add -p/--print flag to new command for non-interactive Claude mode
This commit is contained in:
parent
f9d52110bb
commit
37136f5e04
|
|
@ -22,8 +22,9 @@ program
|
|||
.command("new")
|
||||
.argument("<branch>", "branch name")
|
||||
.argument("[prompt]", "initial prompt for Claude")
|
||||
.option("-p, --print <prompt>", "run Claude in non-interactive mode with -p")
|
||||
.description("Create a new session and launch Claude")
|
||||
.action(async (branch: string, prompt?: string) => {
|
||||
.action(async (branch: string, prompt: string | undefined, opts: { print?: string }) => {
|
||||
const root = await git.repoRoot()
|
||||
const worktreeAbs = join(homedir(), '.sandlot', basename(root), branch)
|
||||
|
||||
|
|
@ -56,7 +57,7 @@ program
|
|||
created_at: new Date().toISOString(),
|
||||
})
|
||||
|
||||
await vm.claude(worktreeAbs, prompt)
|
||||
await vm.claude(worktreeAbs, { prompt, print: opts.print })
|
||||
})
|
||||
|
||||
// ── sandlot list ──────────────────────────────────────────────────────
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ export async function status(): Promise<"running" | "stopped" | "missing"> {
|
|||
}
|
||||
|
||||
/** Launch claude in the container at the given workdir. */
|
||||
export async function claude(workdir: string, prompt?: string): Promise<void> {
|
||||
export async function claude(workdir: string, opts?: { prompt?: string; print?: string }): Promise<void> {
|
||||
const cwd = containerPath(workdir)
|
||||
const systemPrompt = [
|
||||
"You are running inside a sandlot container (Apple Container, ubuntu:24.04).",
|
||||
|
|
@ -117,7 +117,8 @@ export async function claude(workdir: string, prompt?: string): Promise<void> {
|
|||
].join("\n")
|
||||
|
||||
const args = ["container", "exec", "-it", "--user", USER, "--workdir", cwd, CONTAINER_NAME, CLAUDE_BIN, "--dangerously-skip-permissions", "--model", "claude-opus-4-6", "--append-system-prompt", systemPrompt]
|
||||
if (prompt) args.push(prompt)
|
||||
if (opts?.print) args.push("-p", opts.print)
|
||||
else if (opts?.prompt) args.push(opts.prompt)
|
||||
const proc = Bun.spawn(args, { stdin: "inherit", stdout: "inherit", stderr: "inherit" })
|
||||
await proc.exited
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user