# shellcheck shell=bash # opencode-sandbox init: add .opencode-sandbox/ to the current git repository ocsb_init() { local root t=${OCSB_HOME}/templates/project f root=$(git rev-parse --show-toplevel 2>/dev/null) || ocsb_die "run init inside a git repository" if [[ -f ${root}/.opencode-sandbox/sandbox.conf ]]; then ocsb_die "${root}/.opencode-sandbox already exists" fi mkdir -p "${root}/.opencode-sandbox/hooks" "${root}/.opencode-sandbox/local" cp "${t}/sandbox.conf" "${t}/egress.conf" "${root}/.opencode-sandbox/" printf '/local/\n' >"${root}/.opencode-sandbox/.gitignore" for f in "${t}"/hooks/*.example; do cp "${f}" "${root}/.opencode-sandbox/hooks/" done if [[ ! -e ${root}/.cc-safety-net/policy.json ]]; then mkdir -p "${root}/.cc-safety-net" cp "${t}/cc-safety-net-policy.json" "${root}/.cc-safety-net/policy.json" fi cat <