From 9f250188ca2845f4d38fdef6d0650941baaf968b Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Tue, 17 Feb 2026 19:23:35 -0800 Subject: [PATCH] allow optional manual commit message in sandlot save, skip AI generation when provided --- src/cli.ts | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index 7cd6780..077c3fe 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -146,8 +146,9 @@ program program .command("save") .argument("", "branch name") - .description("Stage all changes and commit with an AI-generated message") - .action(async (branch: string) => { + .argument("[message]", "commit message (AI-generated if omitted)") + .description("Stage all changes and commit") + .action(async (branch: string, message?: string) => { const root = await git.repoRoot() const session = await state.getSession(root, branch) if (!session) { @@ -169,27 +170,33 @@ program process.exit(1) } - spin.text = "Generating commit message" - const gen = await vm.exec( - worktreeAbs, - 'set -a; source ~/.env 2>/dev/null; set +a; git diff --staged | claude -p "write a short commit message summarizing these changes. output only the message, no quotes or extra text" > /tmp/sandlot_commit_msg', - ) - if (gen.exitCode !== 0) { - spin.fail("Failed to generate commit message") - if (gen.stderr) console.error(gen.stderr) - process.exit(1) + let msg: string + if (message) { + msg = message + } else { + spin.text = "Generating commit message" + const gen = await vm.exec( + worktreeAbs, + 'set -a; source ~/.env 2>/dev/null; set +a; git diff --staged | claude -p "write a short commit message summarizing these changes. output only the message, no quotes or extra text" > /tmp/sandlot_commit_msg', + ) + if (gen.exitCode !== 0) { + spin.fail("Failed to generate commit message") + if (gen.stderr) console.error(gen.stderr) + process.exit(1) + } + const { stdout } = await vm.exec(worktreeAbs, "cat /tmp/sandlot_commit_msg") + await vm.exec(worktreeAbs, "rm -f /tmp/sandlot_commit_msg") + msg = stdout } spin.text = "Committing" - const commit = await vm.exec(worktreeAbs, "git commit -F /tmp/sandlot_commit_msg") + const commit = await vm.exec(worktreeAbs, `git commit -m ${JSON.stringify(msg)}`) if (commit.exitCode !== 0) { spin.fail("Commit failed") if (commit.stderr) console.error(commit.stderr) process.exit(1) } - const { stdout: msg } = await vm.exec(worktreeAbs, "cat /tmp/sandlot_commit_msg") - await vm.exec(worktreeAbs, "rm -f /tmp/sandlot_commit_msg") spin.succeed(`Saved: ${msg}`) })