From f47dabbabc8d5821095587466fafe5ed2623171e Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Thu, 19 Feb 2026 11:24:32 -0800 Subject: [PATCH] Add `sandlot show` command to display prompt and diff for a branch --- src/cli.ts | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/cli.ts b/src/cli.ts index eaa1baf..45dacff 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -390,6 +390,45 @@ program } }) +// ── sandlot show ─────────────────────────────────────────── + +program + .command("show") + .argument("", "branch name") + .description("Show the prompt and full diff for a branch (for code review)") + .action(async (branch: string) => { + const root = await git.repoRoot() + const session = await state.getSession(root, branch) + if (!session) { + console.error(`No session found for branch "${branch}".`) + process.exit(1) + } + + const main = await git.mainBranch(root) + const result = await $`git -C ${session.worktree} diff --color=always ${main}...${branch}`.nothrow().quiet() + if (result.exitCode !== 0) { + console.error("git diff failed") + process.exit(1) + } + + let output = "" + if (session.prompt) { + output += `PROMPT: ${session.prompt}\n\n` + } + output += result.text() + + const lines = output.split("\n").length + const termHeight = process.stdout.rows || 24 + if (lines > termHeight) { + const pager = Bun.spawn(["less", "-R"], { stdin: "pipe", stdout: "inherit", stderr: "inherit" }) + pager.stdin.write(output) + pager.stdin.end() + await pager.exited + } else { + process.stdout.write(output) + } + }) + // ── sandlot log ──────────────────────────────────────────── program