Merge branch 'session-worktree'
This commit is contained in:
commit
51cc12596d
25
src/vm.ts
25
src/vm.ts
|
|
@ -144,6 +144,15 @@ async function installTooling(cached: boolean, log?: (msg: string) => void): Pro
|
|||
await $`container exec --user ${USER} ${CONTAINER_NAME} bash -c ${"cp ~/.local/bin/bun ~/.local/bin/claude ~/.local/bin/neofetch /sandlot/.cache/ && cp /tmp/nvim.tar.gz /sandlot/.cache/nvim.tar.gz"}`.nothrow().quiet()
|
||||
}
|
||||
|
||||
/** Write a script to a temp file, copy it into ~/.local/bin/ in the container, then clean up. */
|
||||
async function installScript(home: string, name: string, content: string): Promise<void> {
|
||||
const tmp = `${home}/.sandlot/.${name}.tmp`
|
||||
await Bun.write(tmp, content)
|
||||
await $`chmod +x ${tmp}`.quiet()
|
||||
await $`container exec --user ${USER} ${CONTAINER_NAME} bash -c ${`cp /sandlot/.${name}.tmp ~/.local/bin/${name}`}`.quiet()
|
||||
await Bun.file(tmp).unlink()
|
||||
}
|
||||
|
||||
/** Configure git identity, API key helper, activity hook, and Claude settings. */
|
||||
async function configureEnvironment(home: string, apiKey: string): Promise<void> {
|
||||
const gitName = (await $`git config user.name`.quiet().text()).trim()
|
||||
|
|
@ -157,7 +166,8 @@ async function configureEnvironment(home: string, apiKey: string): Promise<void>
|
|||
Stop: [{ hooks: [{ type: "command", command: `${activityBin} idle` }] }],
|
||||
PostToolUseFailure: [{ hooks: [{ type: "command", command: `${activityBin} idle` }] }],
|
||||
}
|
||||
const settingsJson = JSON.stringify({ apiKeyHelper: "~/.claude/api-key-helper.sh", skipDangerousModePermissionPrompt: true, hooks })
|
||||
const statusLine = { type: "command", command: `/home/${USER}/.local/bin/sandlot-statusline` }
|
||||
const settingsJson = JSON.stringify({ apiKeyHelper: "~/.claude/api-key-helper.sh", skipDangerousModePermissionPrompt: true, hooks, statusLine })
|
||||
const claudeJson = JSON.stringify({ hasCompletedOnboarding: true, effortCalloutDismissed: true, projects: { "/": { hasTrustDialogAccepted: true } } })
|
||||
|
||||
// Write the helper script to a temp file and copy it in so the key
|
||||
|
|
@ -168,17 +178,8 @@ async function configureEnvironment(home: string, apiKey: string): Promise<void>
|
|||
await $`container exec --user ${USER} ${CONTAINER_NAME} bash -c ${"mkdir -p ~/.claude && cp /sandlot/.api-key-helper.tmp ~/.claude/api-key-helper.sh"}`.quiet()
|
||||
await Bun.file(tmp).unlink()
|
||||
|
||||
// Install activity tracking hook script
|
||||
const activityTmp = `${home}/.sandlot/.sandlot-activity.tmp`
|
||||
await Bun.write(activityTmp, [
|
||||
'#!/bin/bash',
|
||||
'P="${CLAUDE_PROJECT_DIR%/}"',
|
||||
'echo "$1" > "$(dirname "$P")/.activity-$(basename "$P")"',
|
||||
'',
|
||||
].join('\n'))
|
||||
await $`chmod +x ${activityTmp}`.quiet()
|
||||
await $`container exec --user ${USER} ${CONTAINER_NAME} bash -c ${"cp /sandlot/.sandlot-activity.tmp ~/.local/bin/sandlot-activity"}`.quiet()
|
||||
await Bun.file(activityTmp).unlink()
|
||||
await installScript(home, "sandlot-activity", `#!/bin/bash\nP="\${CLAUDE_PROJECT_DIR%/}"\necho "$1" > "$(dirname "$P")/.activity-$(basename "$P")"\n`)
|
||||
await installScript(home, "sandlot-statusline", `#!/bin/bash\ninput=$(cat)\nbranch=$(echo "$input" | grep -oP '"branch"\\s*:\\s*"\\K[^"]+' | head -1)\n[ -n "$branch" ] && printf '\\033[36m\u2387 %s\\033[0m\\n' "$branch"\n`)
|
||||
|
||||
await $`container exec --user ${USER} ${CONTAINER_NAME} bash -c ${`
|
||||
mkdir -p ~/.claude
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user