refactor(sandbox): pin shell shim to sandbox agent bash without rewriting commands

This commit is contained in:
Chris Scott committed 2026-08-23 14:02:31 -04:00
1 parent 681181ef4c
commit 098816f7cc
14 files changed
+1041 -1357

No files matched your search

@@ -2,15 +2,16 @@ import { join } from 'path'
import { writeFileAtomic } from '../../utils/fs-safe'
import { buildGhEnvPluginSource } from '../opencode-gh-env-plugin'
import { buildSandboxPluginSource } from '../opencode-sandbox-plugin'
import { ensureSandboxShellShim } from '../sandbox/shell-shim'
type ManagedOpenCodePlugin = {
filename: string
buildSource: () => string
buildSource: (context: { shellShimPath: string }) => string
}
const MANAGED_OPENCODE_PLUGINS: readonly ManagedOpenCodePlugin[] = [
{ filename: 'ocm-gh-env.js', buildSource: buildGhEnvPluginSource },
{ filename: 'ocm-sandbox.js', buildSource: buildSandboxPluginSource },
{ filename: 'ocm-gh-env.js', buildSource: () => buildGhEnvPluginSource() },
{ filename: 'ocm-sandbox.js', buildSource: ({ shellShimPath }) => buildSandboxPluginSource(shellShimPath) },
]
export function getOpenCodePluginDir(configHome: string): string {
@@ -18,8 +19,9 @@ export function getOpenCodePluginDir(configHome: string): string {
}
export async function installManagedPlugins(configHome: string): Promise<void> {
const shellShimPath = await ensureSandboxShellShim(configHome)
const dir = getOpenCodePluginDir(configHome)
for (const plugin of MANAGED_OPENCODE_PLUGINS) {
await writeFileAtomic(join(dir, plugin.filename), plugin.buildSource())
await writeFileAtomic(join(dir, plugin.filename), plugin.buildSource({ shellShimPath }))
}
}