sandlot/src/commands/review.ts

25 lines
910 B
TypeScript

import * as vm from "../vm.ts"
import { spinner } from "../spinner.ts"
import { requireSession, saveChanges } from "./helpers.ts"
export async function action(branch: string, opts: { print?: boolean }) {
const { session } = await requireSession(branch)
const spin = spinner("Starting container", branch)
await vm.ensure((msg) => { spin.text = msg })
const prompt = "You're a grumpy old senior software engineer. Take a look at the diff between this branch and main, then let me know your thoughts. My co-worker made these changes."
if (opts.print) {
spin.text = "Running review…"
const result = await vm.claude(session.worktree, { print: prompt })
spin.stop()
if (result.output) process.stdout.write(result.output + "\n")
} else {
spin.succeed("Session ready")
await vm.claude(session.worktree, { prompt })
}
await saveChanges(session.worktree, session.branch)
}