| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | set -uo pipefail |
| 10 | |
| 11 | SELF_DIR="$(CDPATH= cd -- "$(dirname "${BASH_SOURCE[0]:-$0}")/.." >/dev/null && pwd)" |
| 12 | SETUP_SH="${SETUP_SH:-$SELF_DIR/agent-vm.setup.sh}" |
| 13 | |
| 14 | FAIL=0 |
| 15 | PASSED=0 |
| 16 | pass() { PASSED=$((PASSED + 1)); printf ' ok %s\n' "$1"; } |
| 17 | fail() { FAIL=$((FAIL + 1)); printf ' FAIL %s\n' "$1"; } |
| 18 | check() { |
| 19 | if [ "$2" = "$3" ]; then pass "$1" |
| 20 | else fail "$1"; printf ' expected: %s\n actual: %s\n' "$3" "$2"; fi |
| 21 | } |
| 22 | section() { printf '\n%s\n' "$1"; } |
| 23 | |
| 24 | SB="$(mktemp -d)" |
| 25 | |
| 26 | SB="$(CDPATH= cd -P -- "$SB" >/dev/null && pwd)" |
| 27 | trap 'rm -rf "$SB"' EXIT |
| 28 | |
| 29 | |
| 30 | section "setup script: apt runs with a working debconf frontend" |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | if grep -qE '^[^#]*sudo apt-get' "$SETUP_SH"; then |
| 36 | fail "an apt call bypasses apt_get: $(grep -nE '^[^#]*sudo apt-get' "$SETUP_SH" | head -1)" |
| 37 | else |
| 38 | pass "every apt call goes through apt_get" |
| 39 | fi |
| 40 | |
| 41 | |
| 42 | apt_fn="$(sed -n '/^apt_get() {/,/^}/p' "$SETUP_SH")" |
| 43 | check "apt_get does not read the script's stdin" \ |
| 44 | "$({ printf 'sudo() { cat >/dev/null; }\n%s\napt_get update\necho after\n' "$apt_fn"; } | bash 2>/dev/null)" "after" |
| 45 | check "npm installs do not read it either" \ |
| 46 | "$(grep -E '^[^#]*npm i ' "$SETUP_SH" | grep -vc '</dev/null$')" "0" |
| 47 | if grep -q 'sudo env DEBIAN_FRONTEND=noninteractive apt-get' "$SETUP_SH"; then |
| 48 | pass "apt_get hands the frontend to sudo" |
| 49 | else |
| 50 | fail "apt_get no longer passes DEBIAN_FRONTEND through sudo" |
| 51 | fi |
| 52 | |
| 53 | if grep -qv -- '--no-install-recommends' <<< "$(grep -E '^[^#]*apt_get install' "$SETUP_SH")"; then |
| 54 | fail "an install pulls in Recommends: $(grep -nE '^[^#]*apt_get install' "$SETUP_SH" | grep -v -- '--no-install-recommends' | head -1)" |
| 55 | else |
| 56 | pass "every apt install skips Recommends" |
| 57 | fi |
| 58 | if grep -qE '^[^#]*\| *sudo( -E)? bash' "$SETUP_SH"; then |
| 59 | fail "a remote script is piped to a root shell: $(grep -nE '^[^#]*\| *sudo( -E)? bash' "$SETUP_SH" | head -1)" |
| 60 | else |
| 61 | pass "no remote script runs as root" |
| 62 | fi |
| 63 | |
| 64 | |
| 65 | chromium_block="$(awk '/^if \[\[ "\$INSTALL_CHROMIUM" == "1" \]\]; then/,/^fi$/' "$SETUP_SH")" |
| 66 | chromium_install="$( |
| 67 | INSTALL_CHROMIUM=1 CLAUDE_CAGE=1 |
| 68 | sudo() { :; } |
| 69 | apt_get() { printf 'install: %s\n' "$*"; } |
| 70 | cage_is_ubuntu() { return 1; } |
| 71 | cage_cache_chromium() { printf 'cache: %s\n' "$*"; } |
| 72 | eval "$chromium_block" |
| 73 | )" |
| 74 | case "$chromium_install" in |
| 75 | *'install: install -y --no-install-recommends chromium chromium-l10n '*) pass "Chromium explicitly installs its language packs";; |
| 76 | *) fail "Chromium install omits language packs: $chromium_install";; |
| 77 | esac |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | proxy_line="$(grep -n '/etc/sudoers.d/10-agent-vm-proxy' "$SETUP_SH" | head -1 | cut -d: -f1)" |
| 83 | visudo_line="$(grep -n 'sudo visudo -cqf /tmp/agent-vm-proxy.sudoers' "$SETUP_SH" | head -1 | cut -d: -f1)" |
| 84 | apt_line="$(grep -nE '^[^#]*apt_get (update|install)' "$SETUP_SH" | head -1 | cut -d: -f1)" |
| 85 | if [ -n "$proxy_line" ] && [ -n "$visudo_line" ] && [ "$visudo_line" -lt "$proxy_line" ] && [ "$proxy_line" -lt "$apt_line" ]; then |
| 86 | pass "sudo keeps the proxy settings from before the first apt call, checked by visudo" |
| 87 | else |
| 88 | fail "proxy sudoers drop-in: visudo at ${visudo_line:-none}, install at ${proxy_line:-none}, first apt at ${apt_line:-none}" |
| 89 | fi |
| 90 | kept=" $(grep -o 'env_keep += "[^"]*"' "$SETUP_SH" | cut -d'"' -f2) " |
| 91 | dropped="" |
| 92 | for v in http_proxy https_proxy ftp_proxy no_proxy HTTP_PROXY HTTPS_PROXY FTP_PROXY NO_PROXY; do |
| 93 | case "$kept" in *" $v "*) ;; *) dropped="$dropped $v" ;; esac |
| 94 | done |
| 95 | check "sudo keeps every proxy variable, both cases" "$dropped" "" |
| 96 | |
| 97 | |
| 98 | |
| 99 | sed -n "/^cat >> ~\/.zshrc <<'ZSHRC'/,/^ZSHRC\$/p" "$SETUP_SH" | sed '1d;$d' > "$SB/zshrc-history" |
| 100 | if command -v zsh >/dev/null 2>&1; then |
| 101 | check "zsh history: saved to a file, space-prefixed commands left out" \ |
| 102 | "$(HOME="$SB" zsh -fc '. "$1"; print -r -- "$HISTFILE $SAVEHIST"; [[ -o histignorespace && -o incappendhistory ]] && print opts' _ "$SB/zshrc-history")" \ |
| 103 | "$SB/.zsh_history 10000 |
| 104 | opts" |
| 105 | else |
| 106 | printf ' skip zsh history (zsh not installed)\n' |
| 107 | fi |
| 108 | |
| 109 | |
| 110 | |
| 111 | sed -n '/^sudo tee \/usr\/local\/bin\/sshfs/,/^EOF$/p' "$SETUP_SH" | sed '1d;$d' \ |
| 112 | | sed "s|/usr/bin/sshfs|$SB/sshfs-real|g" > "$SB/sshfs-wrapper" |
| 113 | sshfs_stub() { |
| 114 | printf '#!/bin/sh\n[ "$1" = -h ] && { echo "%s"; exit 1; }\necho "$*"\n' "$1" > "$SB/sshfs-real" |
| 115 | chmod +x "$SB/sshfs-real" |
| 116 | } |
| 117 | sshfs_stub ' -o no_contain_symlinks allow all symlink targets' |
| 118 | check "sshfs wrapper: turns contain_symlinks off where it exists" \ |
| 119 | "$(sh "$SB/sshfs-wrapper" ':/p' /p -o slave -o allow_other)" ":/p /p -o slave -o allow_other -o no_contain_symlinks" |
| 120 | sshfs_stub ' -o follow_symlinks' |
| 121 | check "sshfs wrapper: an older sshfs gets the arguments unchanged" \ |
| 122 | "$(sh "$SB/sshfs-wrapper" ':/p' /p -o slave)" ":/p /p -o slave" |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | has_block="$(awk '/^HAS_CLAUDE=0 HAS_OPENCODE=0 HAS_CODEX=0 HAS_VIBE=0$/,/HAS_VIBE=1$/' "$SETUP_SH")" |
| 128 | |
| 129 | has() { ( INSTALL_CLAUDE="$1" INSTALL_CODE_CLAUDE="$2" INSTALL_OPENCODE="$3" INSTALL_CODE_OPENCODE="$4" INSTALL_CODEX="$5" INSTALL_CODE_CODEX="$6" INSTALL_VIBE="$7" INSTALL_CODE_VIBE="$8" |
| 130 | eval "$has_block"; echo "$HAS_CLAUDE$HAS_OPENCODE$HAS_CODEX$HAS_VIBE" ); } |
| 131 | check "setup: the agents' config, for a command or an extension" \ |
| 132 | "$(has 1 0 0 0 0 0 0 0) $(has 0 1 0 0 0 0 0 0) $(has 0 0 1 0 0 0 0 0) $(has 0 0 0 1 0 0 0 0) $(has 0 0 0 0 1 0 0 0) $(has 0 0 0 0 0 1 0 0) $(has 0 0 0 0 0 0 1 1) $(has 0 0 0 0 0 0 0 0)" "1000 1000 0100 0100 0010 0010 0001 0000" |
| 133 | |
| 134 | |
| 135 | section "MCP config writer" |
| 136 | |
| 137 | |
| 138 | |
| 139 | if ! command -v jq >/dev/null 2>&1; then |
| 140 | printf ' skip configure_mcp tests (jq not installed)\n' |
| 141 | else |
| 142 | MCPHOME="$SB/mcp"; mkdir -p "$MCPHOME" |
| 143 | ( |
| 144 | HOME="$MCPHOME" |
| 145 | eval "$(awk '/^configure_mcp\(\) \{/,/^\}/' "$SETUP_SH")" |
| 146 | HAS_CLAUDE=1 HAS_OPENCODE=1 HAS_VIBE=1 HAS_CODEX=1 |
| 147 | for _ in 1 2; do |
| 148 | configure_mcp chrome-devtools npx -y chrome-devtools-mcp@latest --headless=true |
| 149 | configure_mcp playwright env PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npx -y @playwright/mcp@latest |
| 150 | done |
| 151 | ) >/dev/null 2>&1 |
| 152 | |
| 153 | oc="$MCPHOME/.config/opencode/opencode.json" |
| 154 | check "opencode: two servers" "$(jq '.mcp | length' "$oc")" "2" |
| 155 | check "opencode: \$schema kept" "$(jq -r '."$schema"' "$oc")" "https://opencode.ai/config.json" |
| 156 | check "opencode: command starts with the launcher" \ |
| 157 | "$(jq -r '.mcp.playwright.command[0]' "$oc")" "env" |
| 158 | check "opencode: env assignment survives as its own argv entry" \ |
| 159 | "$(jq -r '.mcp.playwright.command[1]' "$oc")" "PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1" |
| 160 | check "claude: two servers" \ |
| 161 | "$(jq '.mcpServers | length' "$MCPHOME/.claude.json")" "2" |
| 162 | check "codex: no duplicate table after two runs" \ |
| 163 | "$(grep -cF '[mcp_servers.playwright]' "$MCPHOME/.codex/config.toml")" "1" |
| 164 | check "vibe: no duplicate entry after two runs" \ |
| 165 | "$(grep -c '^\[\[mcp_servers\]\]' "$MCPHOME/.vibe/config.toml")" "2" |
| 166 | fi |
| 167 | |
| 168 | |
| 169 | section "Pi install block" |
| 170 | |
| 171 | |
| 172 | if ! command -v jq >/dev/null 2>&1; then |
| 173 | printf ' skip Pi install tests (jq not installed)\n' |
| 174 | else |
| 175 | pi_block="$(awk '/^if \[\[ "\$INSTALL_PI" == "1" \]\]; then/,/^fi$/' "$SETUP_SH")" |
| 176 | |
| 177 | run_pi_block() { |
| 178 | ( HOME="$1"; INSTALL_PI=1 INSTALL_NODE="$2" |
| 179 | sudo() { echo "sudo $*" >> "$HOME/sudo.log"; } |
| 180 | eval "$pi_block" ) >/dev/null 2>&1 |
| 181 | } |
| 182 | PIH="$SB/pi-home"; mkdir -p "$PIH" |
| 183 | run_pi_block "$PIH" 1 |
| 184 | check "pi: the maintained package, without install scripts" "$(cat "$PIH/sudo.log" 2>/dev/null)" \ |
| 185 | "sudo npm i -g --ignore-scripts @earendil-works/pi-coding-agent" |
| 186 | |
| 187 | check "pi: project files trusted" \ |
| 188 | "$(jq -r .defaultProjectTrust "$PIH/.pi/agent/settings.json" 2>/dev/null)" "always" |
| 189 | check "pi: telemetry off" \ |
| 190 | "$(jq -r .enableInstallTelemetry "$PIH/.pi/agent/settings.json" 2>/dev/null)" "false" |
| 191 | PIH0="$SB/pi-home-nonode"; mkdir -p "$PIH0" |
| 192 | run_pi_block "$PIH0" 0 |
| 193 | check "pi: skipped without node" "$( [ -e "$PIH0/sudo.log" ] || [ -e "$PIH0/.pi" ]; echo $?)" "1" |
| 194 | fi |
| 195 | |
| 196 | |
| 197 | section "OpenCode install block" |
| 198 | |
| 199 | |
| 200 | oc_block="$(awk '/^if \[\[ "\$INSTALL_OPENCODE" == "1" \|\| "\$INSTALL_CODE_OPENCODE" == "1" \]\]; then/,/^fi$/' "$SETUP_SH")" |
| 201 | |
| 202 | run_oc_block() { |
| 203 | ( HOME="$SB/oc-home"; mkdir -p "$HOME"; rm -f "$HOME/curl.log" |
| 204 | INSTALL_OPENCODE="$1" INSTALL_CODE_OPENCODE="$2" |
| 205 | curl() { echo "curl $*" >> "$HOME/curl.log"; } |
| 206 | eval "$oc_block" ) >/dev/null 2>&1 |
| 207 | cat "$SB/oc-home/curl.log" 2>/dev/null |
| 208 | } |
| 209 | check "opencode: installed for the command line" "$(run_oc_block 1 0)" "curl -fsSL https://opencode.ai/install" |
| 210 | check "opencode: installed for the extension alone" "$(run_oc_block 0 1)" "curl -fsSL https://opencode.ai/install" |
| 211 | check "opencode: not installed for neither" "$(run_oc_block 0 0)" "" |
| 212 | |
| 213 | |
| 214 | section "code-server JSON schemas" |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | if ! command -v jq >/dev/null 2>&1 || [ "${BASH_VERSINFO[0]}" -lt 4 ]; then |
| 220 | printf ' skip code-server schema tests (needs jq and bash 4)\n' |
| 221 | else |
| 222 | SCH="$SB/schemas"; mkdir -p "$SCH/ext/a" "$SCH/ext/b" "$SCH/web" |
| 223 | web() { printf '%s' "$1" | tr -c 'a-zA-Z0-9' _; } |
| 224 | echo '{"contributes":{"jsonValidation":[{"fileMatch":"a.json","url":"https://h.test/s/a"},{"fileMatch":"x","url":"vscode://schemas/x"}]}}' > "$SCH/ext/a/package.json" |
| 225 | echo '{"contributes":{"jsonValidation":[{"fileMatch":"b.json","url":"https://json.schemastore.org/b"},{"fileMatch":"g","url":"https://h.test/gone"}]}}' > "$SCH/ext/b/package.json" |
| 226 | |
| 227 | |
| 228 | echo '{"$ref":"#/definitions/x","definitions":{"x":{"$ref":"https://h.test/abs.json"},"y":{"$ref":"./rel.json#/z"},"z":{"$ref":"vscode://schemas/settings"},"w":{"properties":{"$ref":{"type":"string"}}}}}' > "$SCH/web/$(web https://h.test/s/a)" |
| 229 | |
| 230 | echo '{"type":"object","properties":{"t":{"$ref":"https://h.test/true.json"}}}' > "$SCH/web/$(web https://h.test/abs.json)" |
| 231 | echo 'true' > "$SCH/web/$(web https://h.test/true.json)" |
| 232 | echo '{"$ref":"../top.json"}' > "$SCH/web/$(web https://h.test/s/rel.json)" |
| 233 | echo '{"type":"string"}' > "$SCH/web/$(web https://h.test/top.json)" |
| 234 | echo '{"type":"number"}' > "$SCH/web/$(web https://www.schemastore.org/b)" |
| 235 | |
| 236 | |
| 237 | mkdir -p "$SCH/ext/c" |
| 238 | echo '{"contributes":{"jsonValidation":[{"fileMatch":"c.json","url":"https://www.schemastore.org/package"},{"fileMatch":"d.json","url":"https://h.test/s/a/b/d.json"}]}}' > "$SCH/ext/c/package.json" |
| 239 | echo '{"$id":"https://json.schemastore.org/package.json","properties":{"e":{"$ref":"eslintrc.json#"}}}' > "$SCH/web/$(web https://www.schemastore.org/package)" |
| 240 | echo '{"type":"boolean"}' > "$SCH/web/$(web https://www.schemastore.org/eslintrc.json)" |
| 241 | echo '{"$ref":"../../c.json"}' > "$SCH/web/$(web https://h.test/s/a/b/d.json)" |
| 242 | echo '{"type":"null"}' > "$SCH/web/$(web https://h.test/s/c.json)" |
| 243 | out="$( ( curl() { |
| 244 | local o="" st=0 |
| 245 | echo call >> "$SCH/calls" |
| 246 | while [ $# -gt 0 ]; do |
| 247 | case "$1" in |
| 248 | -o) o="$2"; shift 2 ;; |
| 249 | --parallel-max|--max-time) shift 2 ;; |
| 250 | -*) shift ;; |
| 251 | *) |
| 252 | echo "$1" >> "$SCH/fetched" |
| 253 | if [ -f "$SCH/web/$(web "$1")" ]; then cp "$SCH/web/$(web "$1")" "$o"; else st=22; fi |
| 254 | shift ;; |
| 255 | esac |
| 256 | done |
| 257 | return "$st" |
| 258 | } |
| 259 | set -euo pipefail |
| 260 | eval "$(awk '/^(code_server_schemas|schema_url_resolve)\(\) \{/,/^\}/' "$SETUP_SH")" |
| 261 | code_server_schemas "$SCH/ext" "$SCH/machine/settings.json"; echo "rc=$?" ) 2>&1)" |
| 262 | check "every schema named, and every one they refer to, by the URL the editor asks" \ |
| 263 | "$(jq -r '."json.schemas"[].url' "$SCH/machine/settings.json" 2>/dev/null | sort | tr '\n' ' ')" \ |
| 264 | "https://h.test/abs.json https://h.test/s/a https://h.test/s/a/b/d.json https://h.test/s/c.json https://h.test/s/rel.json https://h.test/top.json https://h.test/true.json https://json.schemastore.org/b https://json.schemastore.org/eslintrc.json https://www.schemastore.org/package " |
| 265 | check "a level of references fetched in one call" "$(wc -l < "$SCH/calls" | tr -d ' ')" "3" |
| 266 | check "each with its content" \ |
| 267 | "$(jq -r '."json.schemas"[] | select(.url == "https://h.test/top.json") | .schema.type' "$SCH/machine/settings.json" 2>/dev/null)" "string" |
| 268 | check "json.schemastore.org fetched from www.schemastore.org, where it redirects" \ |
| 269 | "$(grep -c 'json.schemastore.org' "$SCH/fetched"; grep -c '^https://www.schemastore.org/b$' "$SCH/fetched")" "$(printf '0\n1')" |
| 270 | check "the editor's own schemas are left alone" "$(grep -c vscode "$SCH/fetched")" "0" |
| 271 | case "$out" in |
| 272 | *"could not download the JSON schema https://h.test/gone"*"rc=0") pass "a failed download is a warning, not a failure" ;; |
| 273 | *) fail "failed download: $out" ;; |
| 274 | esac |
| 275 | fi |
| 276 | |
| 277 | |
| 278 | section "code-server install block" |
| 279 | |
| 280 | |
| 281 | |
| 282 | if ! command -v jq >/dev/null 2>&1; then |
| 283 | printf ' skip code-server install tests (jq not installed)\n' |
| 284 | else |
| 285 | cs_block="$(awk '/^toml_prepend\(\) \{/,/^\}/' "$SETUP_SH") |
| 286 | $(awk '/^if \[\[ "\$INSTALL_CODE_SERVER" == "1" \]\]; then/,/^fi$/' "$SETUP_SH") |
| 287 | $(awk '/^configure_mcp\(\) \{/,/^\}/' "$SETUP_SH")" |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | |
| 293 | run_cs_block() { |
| 294 | mkdir -p "$1/.config/code-server"; echo "password: from-the-base" > "$1/.config/code-server/config.yaml" |
| 295 | ( set -e |
| 296 | HOME="$1"; INSTALL_CODE_SERVER=1 INSTALL_CODE_CLAUDE="$2" INSTALL_CODE_OPENCODE="$3" INSTALL_CODE_CODEX="$4" INSTALL_CODE_VIBE="$5" |
| 297 | HAS_CLAUDE="$2" HAS_OPENCODE="$3" HAS_CODEX="$4" HAS_VIBE="$5" |
| 298 | curl() { echo "curl $*" >> "$HOME/calls.log"; } |
| 299 | code-server() { echo "code-server $*" >> "$HOME/calls.log"; } |
| 300 | code_server_schemas() { echo "schemas $*" >> "$HOME/calls.log"; mkdir -p "$(dirname "$2")"; echo '{"json.schemas":[]}' > "$2"; } |
| 301 | eval "$cs_block" |
| 302 | mkdir -p "$HOME/first" |
| 303 | for f in .codex/config.toml .vibe/config.toml; do [ ! -f "$HOME/$f" ] || cp "$HOME/$f" "$HOME/first/${f%%/*}"; done |
| 304 | configure_mcp chrome-devtools npx -y chrome-devtools-mcp@latest |
| 305 | eval "$cs_block" |
| 306 | configure_mcp chrome-devtools npx -y chrome-devtools-mcp@latest |
| 307 | echo 'done' > "$HOME/finished" ) >/dev/null 2>&1 |
| 308 | } |
| 309 | CSB="$SB/cs-bare"; mkdir -p "$CSB" |
| 310 | run_cs_block "$CSB" 0 0 0 0 |
| 311 | check "code-server alone: no extension installed" "$(grep -c '^code-server' "$CSB/calls.log")" "0" |
| 312 | check "code-server alone: Copilot off" \ |
| 313 | "$(jq -r '."chat.disableAIFeatures"' "$CSB/.local/share/code-server/User/settings.json")" "true" |
| 314 | check "code-server alone: dark theme" \ |
| 315 | "$(jq -r '."workbench.colorTheme"' "$CSB/.local/share/code-server/User/settings.json")" "Dark 2026" |
| 316 | check "code-server alone: no telemetry, no experiments" \ |
| 317 | "$(jq -r '[."telemetry.telemetryLevel", ."workbench.enableExperiments"] | map(tostring) | join(" ")' \ |
| 318 | "$CSB/.local/share/code-server/User/settings.json")" "off false" |
| 319 | check "code-server alone: the editor downloads no schema" \ |
| 320 | "$(jq -r '."json.schemaDownload.enable"' "$CSB/.local/share/code-server/User/settings.json")" "false" |
| 321 | check "code-server alone: setup puts them in the machine settings" \ |
| 322 | "$(grep '^schemas' "$CSB/calls.log" | head -n 1 | sed 's|^schemas [^ ]*/lib/vscode/extensions |schemas <ext> |')" \ |
| 323 | "schemas <ext> $CSB/.local/share/code-server/Machine/settings.json" |
| 324 | check "code-server alone: no Claude settings" \ |
| 325 | "$(jq -r 'keys | map(select(startswith("claudeCode"))) | length' "$CSB/.local/share/code-server/User/settings.json")" "0" |
| 326 | check "the password code-server wrote is not left in the base" \ |
| 327 | "$([ -e "$CSB/.config/code-server" ] && echo left || echo gone)" "gone" |
| 328 | |
| 329 | check "code-server alone: runs to the end under set -e" "$(cat "$CSB/finished" 2>/dev/null)" "done" |
| 330 | |
| 331 | CSA="$SB/cs-all"; mkdir -p "$CSA" |
| 332 | run_cs_block "$CSA" 1 1 1 1 |
| 333 | check "with the extensions: runs to the end under set -e" "$(cat "$CSA/finished" 2>/dev/null)" "done" |
| 334 | check "codex: written on a fresh home" "$(head -n 2 "$CSA/first/.codex" 2>/dev/null | sort | tr '\n' ' ')" \ |
| 335 | 'approval_policy = "never" sandbox_mode = "danger-full-access" ' |
| 336 | check "vibe: written on a fresh home" "$(cat "$CSA/first/.vibe" 2>/dev/null)" 'default_agent = "auto-approve"' |
| 337 | check "the four extensions, in one call" \ |
| 338 | "$(grep '^code-server' "$CSA/calls.log" | head -n 1)" \ |
| 339 | "code-server --install-extension anthropic.claude-code --install-extension sst-dev.opencode --install-extension openai.chatgpt --install-extension mistralai.mistral-vibe-code" |
| 340 | |
| 341 | |
| 342 | check "claude: bypass mode allowed and picked, in the machine settings" \ |
| 343 | "$(jq -r '[."claudeCode.allowDangerouslySkipPermissions", ."claudeCode.initialPermissionMode"] | map(tostring) | join(" ")' \ |
| 344 | "$CSA/.local/share/code-server/Machine/settings.json")" "true bypassPermissions" |
| 345 | check "claude: and not in the user settings, where they do nothing" \ |
| 346 | "$(jq -r 'keys | map(select(startswith("claudeCode.") and . != "claudeCode.hideOnboarding")) | length' \ |
| 347 | "$CSA/.local/share/code-server/User/settings.json")" "0" |
| 348 | check "claude: no onboarding checklist" \ |
| 349 | "$(jq -r '."claudeCode.hideOnboarding"' "$CSA/.local/share/code-server/User/settings.json")" "true" |
| 350 | check "codex: full access, once, before any table" \ |
| 351 | "$(head -n 2 "$CSA/.codex/config.toml" | sort | tr '\n' ' '; grep -c '^approval_policy' "$CSA/.codex/config.toml")" \ |
| 352 | 'approval_policy = "never" sandbox_mode = "danger-full-access" 1' |
| 353 | check "vibe: auto-approve, once, before any table" \ |
| 354 | "$(head -n 1 "$CSA/.vibe/config.toml"; grep -c '^default_agent' "$CSA/.vibe/config.toml")" \ |
| 355 | "$(printf 'default_agent = "auto-approve"\n1')" |
| 356 | check "opencode: everything allowed, next to the MCP server, written twice" \ |
| 357 | "$(jq -r '[.permission, (.mcp | keys | join(","))] | join(" ")' "$CSA/.config/opencode/opencode.json")" "allow chrome-devtools" |
| 358 | check "code-server alone: no OpenCode config" "$([ -e "$CSB/.config/opencode" ]; echo $?)" "1" |
| 359 | if python3 -c 'import tomllib' 2>/dev/null; then |
| 360 | check "codex: the file parses, keys at the top level" \ |
| 361 | "$(python3 -c 'import sys,tomllib; d=tomllib.load(open(sys.argv[1],"rb")); print(d["approval_policy"], "chrome-devtools" in d["mcp_servers"])' "$CSA/.codex/config.toml")" \ |
| 362 | "never True" |
| 363 | check "vibe: the file parses, key at the top level" \ |
| 364 | "$(python3 -c 'import sys,tomllib; d=tomllib.load(open(sys.argv[1],"rb")); print(d["default_agent"], len(d["mcp_servers"]))' "$CSA/.vibe/config.toml")" \ |
| 365 | "auto-approve 1" |
| 366 | else |
| 367 | printf ' skip TOML parse checks (no python3 with tomllib)\n' |
| 368 | fi |
| 369 | fi |
| 370 | |
| 371 | printf '\n%s passed, %s failed\n' "$PASSED" "$FAIL" |
| 372 | [ "$FAIL" -eq 0 ] || exit 1 |