Compare commits

...

2 Commits

Author SHA1 Message Date
9994782748 0.0.29 2026-03-11 21:50:46 -07:00
8eabd31442 Use unique temp file names for Claude pipe 2026-03-11 21:50:43 -07:00
2 changed files with 4 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@because/sandlot",
"version": "0.0.28",
"version": "0.0.29",
"description": "Sandboxed, branch-based development with Claude",
"type": "module",
"bin": {

View File

@ -334,12 +334,13 @@ export async function exec(workdir: string, command: string): Promise<{ exitCode
/** Pipe input text to Claude in the container with a prompt, returning the output. */
export async function claudePipe(input: string, prompt: string): Promise<{ exitCode: number; stdout: string; stderr: string }> {
const tmpPath = join(homedir(), '.sandlot', '.claude-pipe-tmp')
const tmpName = `.claude-pipe-${crypto.randomUUID()}`
const tmpPath = join(homedir(), '.sandlot', tmpName)
try {
await Bun.write(tmpPath, input)
return await exec(
join(homedir(), '.sandlot'),
`cat /sandlot/.claude-pipe-tmp | claude -p "${prompt.replace(/"/g, '\\"')}"`,
`cat /sandlot/${tmpName} | claude -p "${prompt.replace(/"/g, '\\"')}"`,
)
} finally {
await Bun.file(tmpPath).unlink().catch(() => {})