Simplify activity hook script and remove unused activeWorktrees function

This commit is contained in:
Chris Wanstrath 2026-02-19 19:15:28 -08:00
parent 86fd1e6c25
commit e23e84655d

View File

@ -97,9 +97,8 @@ export async function ensure(log?: (msg: string) => void): Promise<void> {
const activityTmp = `${home}/.sandlot/.sandlot-activity.tmp`
await Bun.write(activityTmp, [
'#!/bin/bash',
'DIR=$(dirname "$CLAUDE_PROJECT_DIR")',
'BRANCH=$(basename "$CLAUDE_PROJECT_DIR")',
'echo "$1" > "$DIR/.activity-$BRANCH"',
'P="${CLAUDE_PROJECT_DIR%/}"',
'echo "$1" > "$(dirname "$P")/.activity-$(basename "$P")"',
'',
].join('\n'))
await $`chmod +x ${activityTmp}`.quiet()
@ -181,21 +180,6 @@ export async function exec(workdir: string, command: string): Promise<{ exitCode
}
}
/** Get host paths of worktrees where claude is currently running in the container. */
export async function activeWorktrees(): Promise<string[]> {
const s = await status()
if (s !== "running") return []
const result = await $`container exec ${CONTAINER_NAME} bash -c ${'for pid in $(pgrep -x claude 2>/dev/null); do readlink /proc/$pid/cwd 2>/dev/null; done'}`.nothrow().quiet().text()
const home = homedir()
return result.trim().split("\n").filter(Boolean).map(p => {
if (p.startsWith("/sandlot")) return `${home}/.sandlot${p.slice("/sandlot".length)}`
if (p.startsWith("/host")) return `${home}/dev${p.slice("/host".length)}`
return p
})
}
/** Check if Claude is actively working in the given worktree (based on activity hook). */
export async function isClaudeActive(worktree: string, branch: string): Promise<boolean> {
const file = `${dirname(worktree)}/.activity-${branch}`