提交记录修改CHANGELOG.md+27 −0看文件
修改README.md+2 −1看文件
修改agent-vm.setup.sh+77 −7看文件
修改agent-vm.sh+10 −4看文件
新增lib/code.sh+184 −0看文件
修改lib/help.sh+8 −1看文件
修改lib/info.sh+1 −1看文件
修改lib/setup.sh+68 −11看文件
修改lib/ui.sh+20 −0看文件
修改tests/02-setup-output.sh+27 −0看文件
修改tests/06-help-and-setup-script.sh+78 −3看文件
修改tests/11-recorded-commands.sh+3 −0看文件
新增tests/22-code.sh+69 −0看文件
修改www/src/i18n/en.ts+20 −7看文件
修改www/src/i18n/fr.ts+20 −7看文件
| @@ -1,5 +1,32 @@ | ||
| 1 | 1 | # Changelog |
| 2 | 2 | |
| 3 | 新增:## Unreleased | |
| 4 | 新增: | |
| 5 | 新增:### Added | |
| 6 | 新增: | |
| 7 | 新增:- `agent-vm code`: VS Code (code-server) served from the VM and opened in | |
| 8 | 新增: the browser, until Ctrl-C. Opt-in at setup: `--preinstall=code-server` | |
| 9 | 新增: for the editor alone, `code-claude`, `code-codex` and `code-vibe` for it | |
| 10 | 新增: with that agent's extension, each starting with no permission prompts. | |
| 11 | 新增: The wizard asks about the editor after the agents, then whether the | |
| 12 | 新增: agents that have an extension get it, the command line, or both. An | |
| 13 | 新增: extension ships its own copy of its agent: without the command line, | |
| 14 | 新增: `agent-vm claude` (or `codex`, `vibe`) says it is not installed. Dark | |
| 15 | 新增: theme, GitHub Copilot off, no telemetry or update checks. | |
| 16 | 新增:- The editor's password is made in each VM on first use, never in the base, | |
| 17 | 新增: of which every VM is a copy, and printed. Each VM's editor is at | |
| 18 | 新增: `http://<vm-name>.localhost:<port>/`, a port of its own from 20000 to | |
| 19 | 新增: 29999, the same on every start: browsers keep cookies per host name, not | |
| 20 | 新增: per port, so at `127.0.0.1` a page served by any VM would get the session | |
| 21 | 新增: of every editor, which logs into it. Safari may not resolve `*.localhost`: | |
| 22 | 新增: then `127.0.0.1` in a private window kept for the editor. code-server's | |
| 23 | 新增: port proxy is off. | |
| 24 | 新增: | |
| 25 | 新增:### Changed | |
| 26 | 新增: | |
| 27 | 新增:- A command that is not in the VM (`agent-vm run foo`, or an agent not | |
| 28 | 新增: installed) says so, with status 127, instead of `env`'s error. | |
| 29 | 新增: | |
| 3 | 30 | ## 0.2.0 |
| 4 | 31 | |
| 5 | 32 | ### Security |
| @@ -23,6 +23,7 @@ cd your-project | ||
| 23 | 23 | agent-vm claude # or opencode, codex, vibe, pi |
| 24 | 24 | agent-vm shell # a shell in this project's VM |
| 25 | 25 | agent-vm run npm test # one command in it |
| 26 | 新增:agent-vm code # VS Code in the browser (setup --preinstall=default,code-claude) | |
| 26 | 27 | agent-vm --readonly shell # nothing on the host writable from the VM |
| 27 | 28 | agent-vm --scratch claude # nothing of yours mounted, VM deleted on exit |
| 28 | 29 | agent-vm stop # or rm; list for all VMs |
| @@ -36,7 +37,7 @@ Everyday use: [Usage](https://www.agent-vm.org/#usage). Every command, option, f | ||
| 36 | 37 | The agent is root in its VM and has the network. What it can reach on your machine is what crosses the shares: |
| 37 | 38 | |
| 38 | 39 | - Every `.git` and `.hg`, and the folder of a `core.hooksPath` inside the project, are read-only for the VM with a Lima that has `sshfs.readonlyNames`, which `agent-vm setup` offers to install. Before a VM boots, agent-vm stops on what it cannot protect and asks whether to go on: [Protecting .git](https://www.agent-vm.org/#git). |
| 39 | 删除:- The agent writes the project folder: on your machine, open it in your editor and use git there, and run everything else in the VM. Open agent-vm projects in VS Code's Restricted Mode. Editors, agents, commit hooks and commands you run on the host can run code the agent wrote: [What else reads the project](https://www.agent-vm.org/#what-else-on-your-machine-reads-the-project). | |
| 40 | 新增:- The agent writes the project folder: on your machine, open it in your editor and use git there, and run everything else in the VM. Open agent-vm projects in VS Code's Restricted Mode, and never connect an editor to the VM over SSH (Remote-SSH trusts the VM with your machine: [SSH from your machine](https://www.agent-vm.org/#ssh-from-your-machine)). Editors, agents, commit hooks and commands you run on the host can run code the agent wrote: [What else reads the project](https://www.agent-vm.org/#what-else-on-your-machine-reads-the-project). | |
| 40 | 41 | - The VM reaches your machine's loopback and prints to your terminal: [Security](https://www.agent-vm.org/#security). |
| 41 | 42 | |
| 42 | 43 | ## Development |
| @@ -30,8 +30,9 @@ apt_get() { | ||
| 30 | 30 | |
| 31 | 31 | # Component toggles. The host wizard prepends `export` lines for these before |
| 32 | 32 | # piping the script in. Members of the default install set (everything except |
| 33 | 删除:# Ruby/Rust/Go/Pi/Playwright MCP) default to 1 so running this script standalone (without the | |
| 34 | 删除:# wizard) produces the same install you'd get from `agent-vm setup --preinstall=default`. | |
| 33 | 新增:# Ruby/Rust/Go/Pi/Playwright MCP/code-server and its extensions) default to 1 so running this | |
| 34 | 新增:# script standalone (without the wizard) produces the same install you'd get from | |
| 35 | 新增:# `agent-vm setup --preinstall=default`. | |
| 35 | 36 | INSTALL_PYTHON="${AGENT_VM_INSTALL_PYTHON:-1}" |
| 36 | 37 | INSTALL_NODE="${AGENT_VM_INSTALL_NODE:-1}" |
| 37 | 38 | INSTALL_RUBY="${AGENT_VM_INSTALL_RUBY:-0}" |
| @@ -45,10 +46,25 @@ INSTALL_OPENCODE="${AGENT_VM_INSTALL_OPENCODE:-1}" | ||
| 45 | 46 | INSTALL_CODEX="${AGENT_VM_INSTALL_CODEX:-1}" |
| 46 | 47 | INSTALL_VIBE="${AGENT_VM_INSTALL_VIBE:-1}" |
| 47 | 48 | INSTALL_PI="${AGENT_VM_INSTALL_PI:-0}" |
| 49 | 新增:INSTALL_CODE_SERVER="${AGENT_VM_INSTALL_CODE_SERVER:-0}" | |
| 50 | 新增:# Each agent's code-server extension, which brings its own copy of the agent. | |
| 51 | 新增:INSTALL_CODE_CLAUDE="${AGENT_VM_INSTALL_CODE_CLAUDE:-0}" | |
| 52 | 新增:INSTALL_CODE_CODEX="${AGENT_VM_INSTALL_CODE_CODEX:-0}" | |
| 53 | 新增:INSTALL_CODE_VIBE="${AGENT_VM_INSTALL_CODE_VIBE:-0}" | |
| 54 | 新增:if [[ "$INSTALL_CODE_CLAUDE$INSTALL_CODE_CODEX$INSTALL_CODE_VIBE" == *1* ]]; then | |
| 55 | 新增: INSTALL_CODE_SERVER=1 | |
| 56 | 新增:fi | |
| 48 | 57 | # MCP servers wired into every installed agent's config (see lib/setup.sh). |
| 49 | 58 | INSTALL_MCP_CHROME="${AGENT_VM_INSTALL_MCP_CHROME:-1}" |
| 50 | 59 | INSTALL_MCP_PLAYWRIGHT="${AGENT_VM_INSTALL_MCP_PLAYWRIGHT:-0}" |
| 51 | 60 | |
| 61 | 新增:# An agent there in either form: its command line and its extension read the | |
| 62 | 新增:# same config, which is written for both. | |
| 63 | 新增:HAS_CLAUDE=0 HAS_CODEX=0 HAS_VIBE=0 | |
| 64 | 新增:[[ "$INSTALL_CLAUDE$INSTALL_CODE_CLAUDE" == *1* ]] && HAS_CLAUDE=1 | |
| 65 | 新增:[[ "$INSTALL_CODEX$INSTALL_CODE_CODEX" == *1* ]] && HAS_CODEX=1 | |
| 66 | 新增:[[ "$INSTALL_VIBE$INSTALL_CODE_VIBE" == *1* ]] && HAS_VIBE=1 | |
| 67 | 新增: | |
| 52 | 68 | # For this session too: installers (Claude Code, Vibe) warn when ~/.local/bin |
| 53 | 69 | # is not on PATH, which ~/.zshenv only sets for the next ones. |
| 54 | 70 | export PATH="$HOME/.local/bin:$PATH" |
| @@ -223,7 +239,9 @@ if [[ "$INSTALL_CLAUDE" == "1" ]]; then | ||
| 223 | 239 | echo "Installing Claude Code..." |
| 224 | 240 | curl -fsSL https://claude.ai/install.sh | bash |
| 225 | 241 | echo 'export PATH=$HOME/.claude/local/bin:$PATH' >> ~/.zshenv |
| 242 | 新增:fi | |
| 226 | 243 | |
| 244 | 新增:if [[ "$HAS_CLAUDE" == "1" ]]; then | |
| 227 | 245 | # Enforce full autonomy via *managed* settings (highest precedence), not the |
| 228 | 246 | # user's ~/.claude/. A user can bind-mount or overwrite their own ~/.claude/ |
| 229 | 247 | # dir freely; this system-level policy is untouched and always wins. |
| @@ -235,6 +253,7 @@ if [[ "$INSTALL_CLAUDE" == "1" ]]; then | ||
| 235 | 253 | # "ask" permission mode. Settings are re-read on every (re)launch, so encoding |
| 236 | 254 | # the policy here makes it survive those relaunches. `tui: fullscreen` also |
| 237 | 255 | # pins fullscreen from the first launch, so the opt-in relaunch never fires. |
| 256 | 新增: # The extension's own copy of Claude Code reads it too. | |
| 238 | 257 | echo "Configuring Claude managed settings (bypass permissions + fullscreen)..." |
| 239 | 258 | sudo mkdir -p /etc/claude-code |
| 240 | 259 | cat << 'JSON' | sudo tee /etc/claude-code/managed-settings.json > /dev/null |
| @@ -290,6 +309,57 @@ JSON | ||
| 290 | 309 | fi |
| 291 | 310 | fi |
| 292 | 311 | |
| 312 | 新增:# A top-level TOML key as the first line of <file>, where the tables the MCP | |
| 313 | 新增:# config appends later cannot capture it. Skipped when the key is there. | |
| 314 | 新增:toml_prepend() { | |
| 315 | 新增: local file="$1" key="$2" value="$3" | |
| 316 | 新增: mkdir -p "$(dirname "$file")" | |
| 317 | 新增: if [[ -f "$file" ]] && grep -q "^$key *=" "$file"; then | |
| 318 | 新增: return 0 | |
| 319 | 新增: fi | |
| 320 | 新增: { printf '%s = %s\n' "$key" "$value"; [[ ! -f "$file" ]] || cat "$file"; } > "$file.tmp" | |
| 321 | 新增: mv "$file.tmp" "$file" | |
| 322 | 新增:} | |
| 323 | 新增: | |
| 324 | 新增:if [[ "$INSTALL_CODE_SERVER" == "1" ]]; then | |
| 325 | 新增: # The editor of `agent-vm code` (lib/code.sh). No password here: every VM | |
| 326 | 新增: # is a copy of this disk, so each one makes its own on first use. | |
| 327 | 新增: echo "Installing code-server..." | |
| 328 | 新增: curl -fsSL https://code-server.dev/install.sh | sh | |
| 329 | 新增: extensions=() | |
| 330 | 新增: [[ "$INSTALL_CODE_CLAUDE" == "1" ]] && extensions+=(--install-extension anthropic.claude-code) | |
| 331 | 新增: [[ "$INSTALL_CODE_CODEX" == "1" ]] && extensions+=(--install-extension openai.chatgpt) | |
| 332 | 新增: [[ "$INSTALL_CODE_VIBE" == "1" ]] && extensions+=(--install-extension mistralai.mistral-vibe-code) | |
| 333 | 新增: if [[ ${#extensions[@]} -gt 0 ]]; then | |
| 334 | 新增: echo "Installing the agents' extensions..." | |
| 335 | 新增: code-server "${extensions[@]}" </dev/null | |
| 336 | 新增: fi | |
| 337 | 新增: # chat.disableAIFeatures turns off the GitHub Copilot chat and completions | |
| 338 | 新增: # that code-server ships. The Claude keys start its conversations in bypass | |
| 339 | 新增: # mode, as the managed settings above do for the CLI. | |
| 340 | 新增: mkdir -p "$HOME/.local/share/code-server/User" | |
| 341 | 新增: jq -n --arg claude "$INSTALL_CODE_CLAUDE" ' | |
| 342 | 新增: { | |
| 343 | 新增: "workbench.colorTheme": "Dark 2026", | |
| 344 | 新增: "chat.disableAIFeatures": true | |
| 345 | 新增: } + if $claude == "1" then { | |
| 346 | 新增: "claudeCode.allowDangerouslySkipPermissions": true, | |
| 347 | 新增: "claudeCode.initialPermissionMode": "bypassPermissions" | |
| 348 | 新增: } else {} end' > "$HOME/.local/share/code-server/User/settings.json" | |
| 349 | 新增: # Codex and Vibe have no setting for it: their extensions start in the mode | |
| 350 | 新增: # the agent's own config names. These match the flags the command line gets | |
| 351 | 新增: # (_agent_vm_agent in agent-vm.sh). | |
| 352 | 新增: if [[ "$INSTALL_CODE_CODEX" == "1" ]]; then | |
| 353 | 新增: toml_prepend "$HOME/.codex/config.toml" sandbox_mode '"danger-full-access"' | |
| 354 | 新增: toml_prepend "$HOME/.codex/config.toml" approval_policy '"never"' | |
| 355 | 新增: fi | |
| 356 | 新增: if [[ "$INSTALL_CODE_VIBE" == "1" ]]; then | |
| 357 | 新增: toml_prepend "$HOME/.vibe/config.toml" default_agent '"auto-approve"' | |
| 358 | 新增: fi | |
| 359 | 新增: # Written by code-server on its first run, with a password of its own. | |
| 360 | 新增: rm -rf "$HOME/.config/code-server" | |
| 361 | 新增:fi | |
| 362 | 新增: | |
| 293 | 363 | # Wire one stdio MCP server into every installed agent's config. Each agent |
| 294 | 364 | # stores MCP servers in its own format, so that mapping is written once here |
| 295 | 365 | # instead of being copy-pasted per server. |
| @@ -313,7 +383,7 @@ configure_mcp() { | ||
| 313 | 383 | local args_json |
| 314 | 384 | args_json="$(printf '%s\n' "$@" | jq -R . | jq -sc .)" |
| 315 | 385 | |
| 316 | 删除: if [[ "$INSTALL_CLAUDE" == "1" ]]; then | |
| 386 | 新增: if [[ "$HAS_CLAUDE" == "1" ]]; then | |
| 317 | 387 | echo "Configuring $name MCP server for Claude..." |
| 318 | 388 | local config="$HOME/.claude.json" |
| 319 | 389 | [ -f "$config" ] || echo '{}' > "$config" |
| @@ -344,7 +414,7 @@ configure_mcp() { | ||
| 344 | 414 | fi |
| 345 | 415 | fi |
| 346 | 416 | |
| 347 | 删除: if [[ "$INSTALL_VIBE" == "1" ]]; then | |
| 417 | 新增: if [[ "$HAS_VIBE" == "1" ]]; then | |
| 348 | 418 | # Vibe uses TOML; append an array-of-tables entry (valid even if the wizard |
| 349 | 419 | # later writes to the same file). Guard against duplicates on repeated runs. |
| 350 | 420 | echo "Configuring $name MCP server for Vibe..." |
| @@ -361,7 +431,7 @@ configure_mcp() { | ||
| 361 | 431 | fi |
| 362 | 432 | fi |
| 363 | 433 | |
| 364 | 删除: if [[ "$INSTALL_CODEX" == "1" ]]; then | |
| 434 | 新增: if [[ "$HAS_CODEX" == "1" ]]; then | |
| 365 | 435 | # Codex CLI uses TOML at ~/.codex/config.toml with [mcp_servers.NAME] |
| 366 | 436 | # tables. Guard against duplicates on repeated setup runs. |
| 367 | 437 | echo "Configuring $name MCP server for Codex..." |
| @@ -380,8 +450,8 @@ configure_mcp() { | ||
| 380 | 450 | # True when at least one agent is installed: nothing to configure otherwise, |
| 381 | 451 | # and no reason to print a "skipping" notice either. |
| 382 | 452 | any_agent_installed() { |
| 383 | 删除: [[ "$INSTALL_CLAUDE" == "1" || "$INSTALL_OPENCODE" == "1" \ | |
| 384 | 删除: || "$INSTALL_CODEX" == "1" || "$INSTALL_VIBE" == "1" ]] | |
| 453 | 新增: [[ "$HAS_CLAUDE" == "1" || "$INSTALL_OPENCODE" == "1" \ | |
| 454 | 新增: || "$HAS_CODEX" == "1" || "$HAS_VIBE" == "1" ]] | |
| 385 | 455 | } |
| 386 | 456 | |
| 387 | 457 | # Chrome DevTools MCP runs via `npx` and drives the Chromium installed above, |
| @@ -52,7 +52,7 @@ fi | ||
| 52 | 52 | # The rest of agent-vm, one file per concern, sourced like this one. Only |
| 53 | 53 | # functions and settings: nothing runs until a command does. A file that is |
| 54 | 54 | # missing stops here, not half-way through a command. |
| 55 | 删除:for _agent_vm_lib in ui options host vm mounts git runtime env info install doctor help setup; do | |
| 55 | 新增:for _agent_vm_lib in ui options host vm mounts git runtime env info install doctor help setup code; do | |
| 56 | 56 | _agent_vm_lib="$AGENT_VM_SCRIPT_DIR/lib/$_agent_vm_lib.sh" |
| 57 | 57 | if [[ ! -r "$_agent_vm_lib" ]] || ! . "$_agent_vm_lib"; then |
| 58 | 58 | echo "agent-vm: cannot load $_agent_vm_lib" >&2 |
| @@ -700,7 +700,7 @@ agent-vm() { | ||
| 700 | 700 | if [[ ${#lead[@]} -gt 0 ]]; then |
| 701 | 701 | case "$cmd" in |
| 702 | 702 | stop|rm|destroy|destroy-all|list|status|name|info|env|project-env|version|--version|-V|doctor|install|uninstall|help|--help|-h) |
| 703 | 删除: echo "Error: ${lead[*]:0:1} is an option for the commands that start a VM (claude, opencode, codex, vibe, pi, shell, run), not for '$cmd'." >&2 | |
| 703 | 新增: echo "Error: ${lead[*]:0:1} is an option for the commands that start a VM (claude, opencode, codex, vibe, pi, shell, run, code), not for '$cmd'." >&2 | |
| 704 | 704 | return 1 ;; |
| 705 | 705 | esac |
| 706 | 706 | fi |
| @@ -731,6 +731,9 @@ agent-vm() { | ||
| 731 | 731 | run) |
| 732 | 732 | _agent_vm_run ${lead[@]+"${lead[@]}"} "$@" |
| 733 | 733 | ;; |
| 734 | 新增: code) | |
| 735 | 新增: _agent_vm_code ${lead[@]+"${lead[@]}"} "$@" | |
| 736 | 新增: ;; | |
| 734 | 737 | stop) |
| 735 | 738 | _agent_vm_stop "$@" |
| 736 | 739 | ;; |
| @@ -813,7 +816,8 @@ agent-vm() { | ||
| 813 | 816 | # guest shell never re-parses them; `env` runs the command and keeps leading |
| 814 | 817 | # VAR=value assignments working. `env --`: GNU env still reads assignments |
| 815 | 818 | # after it, and a command starting with `-` (`run -i foo`) is not taken for |
| 816 | 删除:# one of its options. | |
| 819 | 新增:# one of its options. A command that is not there is said so, with env's | |
| 820 | 新增:# status: an agent installed only as an editor extension has no command. | |
| 817 | 821 | # |
| 818 | 822 | # Usage: _agent_vm_lima_run <vm_name> <host_dir> <tty:1|""> <command> [args...] |
| 819 | 823 | _agent_vm_lima_run() { |
| @@ -821,7 +825,9 @@ _agent_vm_lima_run() { | ||
| 821 | 825 | shift 3 |
| 822 | 826 | local shell_opts=(--workdir "$host_dir") |
| 823 | 827 | [[ -n "$want_tty" ]] && shell_opts+=(--tty) |
| 824 | 删除: limactl shell "${shell_opts[@]}" "$vm_name" -- zsh -l -c 'exec env -- "$@"' agent-vm "$@" | |
| 828 | 新增: limactl shell "${shell_opts[@]}" "$vm_name" -- zsh -l -c \ | |
| 829 | 新增: 'case "$1" in *=*) ;; *) command -v -- "$1" >/dev/null || { print -r -- "agent-vm: $1 is not installed in this VM." >&2; exit 127; } ;; esac; exec env -- "$@"' \ | |
| 830 | 新增: agent-vm "$@" | |
| 825 | 831 | } |
| 826 | 832 | |
| 827 | 833 | # Starts this directory's VM with the caller's vm_opts, runs <function> with |
| @@ -0,0 +1,184 @@ | ||
| 1 | 新增:# --- code: code-server in the VM, opened in the host's browser ---------------- | |
| 2 | 新增: | |
| 3 | 新增:# Run in the VM before the editor starts, with the candidate ports as | |
| 4 | 新增:# arguments. Prints `missing` without code-server, else its config file and | |
| 5 | 新增:# password, the port of an editor of this VM already running, and which | |
| 6 | 新增:# candidates something in the VM listens on. | |
| 7 | 新增:# | |
| 8 | 新增:# The password is made here, in the VM, on first use, never in the base: | |
| 9 | 新增:# every VM is a copy of the base disk, and one VM knowing another's password | |
| 10 | 新增:# could log into it through the host's loopback, which every VM reaches. The | |
| 11 | 新增:# file is named after the hostname, which Lima sets per VM, so a file that | |
| 12 | 新增:# came with the base is never used. | |
| 13 | 新增:_AGENT_VM_CODE_PREP=' | |
| 14 | 新增:command -v code-server >/dev/null 2>&1 || { echo missing; exit 0; } | |
| 15 | 新增:cfg="$HOME/.config/code-server/agent-vm-$(hostname).yaml" | |
| 16 | 新增:if [ ! -s "$cfg" ]; then | |
| 17 | 新增: pw="$(od -An -N16 -tx1 /dev/urandom | tr -d " \n")" | |
| 18 | 新增: [ "${#pw}" = 32 ] || exit 1 | |
| 19 | 新增: mkdir -p "${cfg%/*}" || exit 1 | |
| 20 | 新增: (umask 077 && printf "auth: password\npassword: %s\ncert: false\n" "$pw" > "$cfg") || exit 1 | |
| 21 | 新增:fi | |
| 22 | 新增:echo "config=$cfg" | |
| 23 | 新增:echo "password=$(sed -n "s/^password: //p" "$cfg")" | |
| 24 | 新增:pgrep -u "$(id -u)" -af -- "--config $cfg" \ | |
| 25 | 新增: | sed -n "s/.*--bind-addr 127\.0\.0\.1:\([0-9]*\).*/running=\1/p" | head -n 1 | |
| 26 | 新增:for p in "$@"; do | |
| 27 | 新增: curl -s -o /dev/null --max-time 1 "http://127.0.0.1:$p/" && echo "listening=$p" | |
| 28 | 新增:done | |
| 29 | 新增:exit 0 | |
| 30 | 新增:' | |
| 31 | 新增: | |
| 32 | 新增:# Ten host ports for <vm>'s editor, from its name: the same on every start, | |
| 33 | 新增:# so the browser finds the saved password at the same address. | |
| 34 | 新增:_agent_vm_code_ports() { | |
| 35 | 新增: local h base i | |
| 36 | 新增: h="$(printf '%s' "$1" | _agent_vm_sha256 | cut -c1-4)" | |
| 37 | 新增: [[ "$h" =~ ^[0-9a-f]{4}$ ]] || return 1 | |
| 38 | 新增: base=$((20000 + (16#$h % 1000) * 10)) | |
| 39 | 新增: for i in 0 1 2 3 4 5 6 7 8 9; do printf '%s ' $((base + i)); done | |
| 40 | 新增:} | |
| 41 | 新增: | |
| 42 | 新增:# The host name the browser reaches <vm>'s editor at: <vm>.localhost, which | |
| 43 | 新增:# Chrome and Firefox send to 127.0.0.1 on their own. Browsers keep cookies | |
| 44 | 新增:# per host name, not per port: on 127.0.0.1, a page served by any VM would | |
| 45 | 新增:# receive the session cookie of every editor, which logs into it. Lowercase, | |
| 46 | 新增:# and at most 63 characters (a DNS label), the hash at the end kept. | |
| 47 | 新增:_agent_vm_code_host() { | |
| 48 | 新增: local label | |
| 49 | 新增: label="$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')" | |
| 50 | 新增: if [[ ${#label} -gt 63 ]]; then | |
| 51 | 新增: label="${label:0:54}-${label:$((${#label} - 8))}" | |
| 52 | 新增: fi | |
| 53 | 新增: printf '%s.localhost\n' "$label" | |
| 54 | 新增:} | |
| 55 | 新增: | |
| 56 | 新增:# 0 when something on this machine accepts connections on 127.0.0.1:<port>. | |
| 57 | 新增:_agent_vm_host_port_open() { | |
| 58 | 新增: (exec 3<>"/dev/tcp/127.0.0.1/$1") 2>/dev/null | |
| 59 | 新增:} | |
| 60 | 新增: | |
| 61 | 新增:# The editor's <url> on <port>, and its <password>. Safari leaves *.localhost | |
| 62 | 新增:# to macOS, which may not resolve it: 127.0.0.1 then, in a window of its own. | |
| 63 | 新增:_agent_vm_code_say() { | |
| 64 | 新增: echo "Editor: $1" | |
| 65 | 新增: echo "Password: $3" | |
| 66 | 新增: if [[ "$(uname -s)" == Darwin ]]; then | |
| 67 | 新增: echo "(Safari may not resolve it: then http://127.0.0.1:$2/, in a private window kept for this editor, so pages from other VMs never get its cookie.)" | |
| 68 | 新增: fi | |
| 69 | 新增:} | |
| 70 | 新增: | |
| 71 | 新增:# Open <url> in the host's browser once Lima forwards <port>. | |
| 72 | 新增:_agent_vm_code_open() { | |
| 73 | 新增: local url="$1" port="$2" i=0 | |
| 74 | 新增: until _agent_vm_host_port_open "$port"; do | |
| 75 | 新增: i=$((i + 1)) | |
| 76 | 新增: if [[ $i -ge 60 ]]; then | |
| 77 | 新增: echo "Warning: nothing on 127.0.0.1:$port after 60s: Lima did not forward the editor's port." >&2 | |
| 78 | 新增: return 1 | |
| 79 | 新增: fi | |
| 80 | 新增: sleep 1 | |
| 81 | 新增: done | |
| 82 | 新增: if _agent_vm_on_windows; then | |
| 83 | 新增: start "$url" | |
| 84 | 新增: elif [[ "$(uname -s)" == Darwin ]]; then | |
| 85 | 新增: open "$url" | |
| 86 | 新增: elif [[ -n "${DISPLAY:-}${WAYLAND_DISPLAY:-}" ]] && command -v xdg-open >/dev/null 2>&1; then | |
| 87 | 新增: xdg-open "$url" | |
| 88 | 新增: fi >/dev/null 2>&1 | |
| 89 | 新增: return 0 | |
| 90 | 新增:} | |
| 91 | 新增: | |
| 92 | 新增:# `agent-vm code`: code-server for the project, in the foreground until | |
| 93 | 新增:# Ctrl-C. Takes no argument of its own. | |
| 94 | 新增:_agent_vm_code() { | |
| 95 | 新增: local vm_opts=() rm="" tty="" args=() | |
| 96 | 新增: _agent_vm_split_args "$@" || return 1 | |
| 97 | 新增: if [[ ${#args[@]} -gt 0 || -n "$tty" ]]; then | |
| 98 | 新增: echo "Error: unknown argument for code: ${args[0]:---tty}" >&2 | |
| 99 | 新增: echo "Usage: agent-vm [vm options] code" >&2 | |
| 100 | 新增: return 1 | |
| 101 | 新增: fi | |
| 102 | 新增: _agent_vm_in_vm _agent_vm_code_session | |
| 103 | 新增:} | |
| 104 | 新增: | |
| 105 | 新增:_agent_vm_code_session() { | |
| 106 | 新增: local vm_name="$1" host_dir="$2" ports out line cfg="" pw="" running="" listening=" " port="" p | |
| 107 | 新增: local url opener="" want_tty="" st=0 | |
| 108 | 新增: ports="$(_agent_vm_code_ports "$vm_name")" || { | |
| 109 | 新增: echo "Error: cannot hash the VM name: install shasum or sha256sum." >&2 | |
| 110 | 新增: return 1 | |
| 111 | 新增: } | |
| 112 | 新增: # shellcheck disable=SC2086 | |
| 113 | 新增: if ! out="$(limactl shell "$vm_name" -- zsh -lc "$_AGENT_VM_CODE_PREP" agent-vm-code $ports </dev/null)"; then | |
| 114 | 新增: echo "Error: could not set up the editor's password in VM '$vm_name'." >&2 | |
| 115 | 新增: return 1 | |
| 116 | 新增: fi | |
| 117 | 新增: while IFS= read -r line; do | |
| 118 | 新增: case "$line" in | |
| 119 | 新增: missing) | |
| 120 | 新增: echo "Error: code-server is not installed in VM '$vm_name'." >&2 | |
| 121 | 新增: echo " 'agent-vm setup --preinstall=default,code-claude' (or code-server alone) adds it to the base, then 'agent-vm --reset code'" >&2 | |
| 122 | 新增: echo " re-clones this VM (its disk is lost)." >&2 | |
| 123 | 新增: return 1 ;; | |
| 124 | 新增: config=*) cfg="${line#config=}" ;; | |
| 125 | 新增: password=*) pw="${line#password=}" ;; | |
| 126 | 新增: running=*) running="${line#running=}" ;; | |
| 127 | 新增: listening=*) listening="$listening${line#listening=} " ;; | |
| 128 | 新增: esac | |
| 129 | 新增: done <<< "$out" | |
| 130 | 新增: # Printed to the terminal: nothing the VM wrote may carry escape sequences. | |
| 131 | 新增: if [[ -z "$pw" || "$pw$cfg" == *[[:cntrl:]]* || ( -n "$running" && ! "$running" =~ ^[0-9]+$ ) ]]; then | |
| 132 | 新增: echo "Error: could not read the editor's password in VM '$vm_name'." >&2 | |
| 133 | 新增: return 1 | |
| 134 | 新增: fi | |
| 135 | 新增: | |
| 136 | 新增: if [[ -n "$running" ]]; then | |
| 137 | 新增: url="http://$(_agent_vm_code_host "$vm_name"):$running/" | |
| 138 | 新增: echo "The editor of VM '$vm_name' already runs, from another terminal." | |
| 139 | 新增: _agent_vm_code_say "$url" "$running" "$pw" | |
| 140 | 新增: [[ -t 1 ]] && _agent_vm_code_open "$url" "$running" | |
| 141 | 新增: return 0 | |
| 142 | 新增: fi | |
| 143 | 新增: | |
| 144 | 新增: # The first port free both here and in the VM: Lima forwards the VM's port | |
| 145 | 新增: # to the same one here, and only when nothing holds it. | |
| 146 | 新增: for p in $ports; do | |
| 147 | 新增: [[ "$listening" == *" $p "* ]] && continue | |
| 148 | 新增: _agent_vm_host_port_open "$p" && continue | |
| 149 | 新增: port="$p" | |
| 150 | 新增: break | |
| 151 | 新增: done | |
| 152 | 新增: if [[ -z "$port" ]]; then | |
| 153 | 新增: echo "Error: no free port for the editor among: $ports" >&2 | |
| 154 | 新增: return 1 | |
| 155 | 新增: fi | |
| 156 | 新增: | |
| 157 | 新增: url="http://$(_agent_vm_code_host "$vm_name"):$port/" | |
| 158 | 新增: _agent_vm_code_say "$url" "$port" "$pw" | |
| 159 | 新增: echo "The password is kept in the VM, in $cfg. Ctrl-C stops the editor." | |
| 160 | 新增: if [[ -t 1 ]]; then | |
| 161 | 新增: _agent_vm_code_open "$url" "$port" & | |
| 162 | 新增: opener=$! | |
| 163 | 新增: fi | |
| 164 | 新增: # A terminal for Ctrl-C to reach code-server: without one, it would keep | |
| 165 | 新增: # running in the VM once this command ends. | |
| 166 | 新增: [[ -t 0 && -t 1 ]] && want_tty=1 | |
| 167 | 新增: # Bound to the VM's loopback, which Lima forwards to this machine's only. | |
| 168 | 新增: # The cookie suffix keeps sessions apart at 127.0.0.1, where two editors | |
| 169 | 新增: # would overwrite each other's cookie. --disable-proxy: no route from the | |
| 170 | 新增: # browser to the VM's other ports, and the proxy is where CVE-2025-47269 was. | |
| 171 | 新增: _agent_vm_lima_run "$vm_name" "$host_dir" "$want_tty" code-server \ | |
| 172 | 新增: --config "$cfg" \ | |
| 173 | 新增: --bind-addr "127.0.0.1:$port" \ | |
| 174 | 新增: --cookie-suffix "$vm_name" \ | |
| 175 | 新增: --app-name "$vm_name" \ | |
| 176 | 新增: --disable-telemetry \ | |
| 177 | 新增: --disable-update-check \ | |
| 178 | 新增: --disable-workspace-trust \ | |
| 179 | 新增: --disable-proxy \ | |
| 180 | 新增: --disable-getting-started-override \ | |
| 181 | 新增: "$host_dir" || st=$? | |
| 182 | 新增: [[ -z "$opener" ]] || kill "$opener" 2>/dev/null | |
| 183 | 新增: return "$st" | |
| 184 | 新增:} | |
| @@ -21,6 +21,12 @@ Commands: | ||
| 21 | 21 | run <cmd> [args] Run a command in the VM (no shell: for pipes/redirects |
| 22 | 22 | use 'shell -c "..."' instead; pass --tty for TUIs like |
| 23 | 23 | opencode, vibe, htop, etc.) |
| 24 | 新增: code Serve VS Code (code-server) from the VM, at | |
| 25 | 新增: http://<vm-name>.localhost:<port>/, and open it in the | |
| 26 | 新增: browser, until Ctrl-C. Its password is made in each VM | |
| 27 | 新增: and printed. Opt-in at setup, with the agents' | |
| 28 | 新增: extensions or without: --preinstall=default,code-claude | |
| 29 | 新增: (or code-codex, code-vibe, code-server) | |
| 24 | 30 | stop [vm-name] Stop the VM for the current directory, or the named one |
| 25 | 31 | rm [vm-name] Stop and delete the VM for the current directory, or the |
| 26 | 32 | named one. Pass a name from 'agent-vm list' to reach a VM |
| @@ -64,7 +70,7 @@ Commands: | ||
| 64 | 70 | (2 when the call itself is wrong). For integrators. |
| 65 | 71 | help Show this help |
| 66 | 72 | |
| 67 | 删除:VM options (for claude, opencode, codex, vibe, pi, shell, run), read before the | |
| 73 | 新增:VM options (for claude, opencode, codex, vibe, pi, shell, run, code), read before the | |
| 68 | 74 | command or right after its name, never later: in 'agent-vm run docker run |
| 69 | 75 | --rm x', --rm belongs to docker. |
| 70 | 76 | --disk GB VM disk size |
| @@ -120,6 +126,7 @@ Examples: | ||
| 120 | 126 | agent-vm sh -c "ls -la | grep config" # One-shot command via login zsh |
| 121 | 127 | agent-vm run npm install # Run a command in the VM |
| 122 | 128 | agent-vm run --tty opencode -p "..." # Run a TUI with PTY allocated |
| 129 | 新增: agent-vm code # VS Code in the browser | |
| 123 | 130 | agent-vm claude -p "fix lint errors" # Pass args to claude |
| 124 | 131 | agent-vm rm agent-vm-old-name-1a2b3c4d # Delete a VM by name (see 'list') |
| 125 | 132 | |
| @@ -109,7 +109,7 @@ _agent_vm_version() { | ||
| 109 | 109 | # --unsafe-disable-security-prompts to accept them, or --readonly. |
| 110 | 110 | # |
| 111 | 111 | # ssh_host is the Host alias in ssh_config, the file Lima rewrites with the |
| 112 | 删除:# current port on each start (https://www.agent-vm.org/#connect-an-ide-over-ssh). | |
| 112 | 新增:# current port on each start (https://www.agent-vm.org/#ssh-from-your-machine). | |
| 113 | 113 | _agent_vm_info() { |
| 114 | 114 | local dir="${1:-$(pwd)}" |
| 115 | 115 | local vm_name |
| @@ -89,12 +89,37 @@ _agent_vm_node_needed_by() { | ||
| 89 | 89 | elif [[ "$install_pi" == 1 ]]; then |
| 90 | 90 | echo "Pi requires npm" |
| 91 | 91 | elif [[ "$install_chromium" == 1 && "$install_mcp_chrome" == 1 \ |
| 92 | 删除: && ( "$install_claude" == 1 || "$install_opencode" == 1 || "$install_vibe" == 1 ) ]]; then | |
| 92 | 新增: && ( "$install_claude" == 1 || "$install_opencode" == 1 || "$install_vibe" == 1 \ | |
| 93 | 新增: || "$install_code_claude" == 1 || "$install_code_codex" == 1 || "$install_code_vibe" == 1 ) ]]; then | |
| 93 | 94 | echo "Chrome DevTools MCP uses npx" |
| 94 | 95 | fi |
| 95 | 96 | return 0 |
| 96 | 97 | } |
| 97 | 98 | |
| 99 | 新增:# The wizard's question after code-server, on the caller's install_*: how the | |
| 100 | 新增:# agents picked that have an extension (Claude Code, Codex, Vibe) are | |
| 101 | 新增:# installed. Asked only when there is one. | |
| 102 | 新增:_agent_vm_ask_code_extensions() { | |
| 103 | 新增: local names="" choice | |
| 104 | 新增: [[ "$install_code_server" == 1 ]] || return 0 | |
| 105 | 新增: [[ "$install_claude" == 1 ]] && names="$names, Claude Code" | |
| 106 | 新增: [[ "$install_codex" == 1 ]] && names="$names, Codex" | |
| 107 | 新增: [[ "$install_vibe" == 1 ]] && names="$names, Mistral Vibe" | |
| 108 | 新增: [[ -n "$names" ]] || return 0 | |
| 109 | 新增: printf ' %s in the editor:\n' "${names#, }" >&2 | |
| 110 | 新增: choice="$(_agent_vm_ask_choice "Pick one" 1 \ | |
| 111 | 新增: "Extension and command line (agent-vm claude...)" \ | |
| 112 | 新增: "Extension only" \ | |
| 113 | 新增: "Command line only")" | |
| 114 | 新增: [[ "$choice" == 3 ]] && return 0 | |
| 115 | 新增: install_code_claude="$install_claude" | |
| 116 | 新增: install_code_codex="$install_codex" | |
| 117 | 新增: install_code_vibe="$install_vibe" | |
| 118 | 新增: if [[ "$choice" == 2 ]]; then | |
| 119 | 新增: install_claude=0 install_codex=0 install_vibe=0 | |
| 120 | 新增: fi | |
| 121 | 新增:} | |
| 122 | 新增: | |
| 98 | 123 | _agent_vm_setup() { |
| 99 | 124 | local disk=10 |
| 100 | 125 | local memory=3 |
| @@ -103,15 +128,17 @@ _agent_vm_setup() { | ||
| 103 | 128 | local preinstall_seen="" |
| 104 | 129 | # The default set, used without --preinstall when the wizard's first |
| 105 | 130 | # question is accepted or there is no terminal. Opt-in: Ruby, Rust, Go, Pi |
| 106 | 删除: # (0.x, released several times a week) and Playwright MCP (a second | |
| 107 | 删除: # browser-driving server, whose tools cost context in every agent). Only MCP | |
| 108 | 删除: # servers with something to bake into the image belong here; a remote one | |
| 109 | 删除: # is per-project config. | |
| 131 | 新增: # (0.x, released several times a week), Playwright MCP (a second | |
| 132 | 新增: # browser-driving server, whose tools cost context in every agent), and | |
| 133 | 新增: # code-server with its agent extensions (an editor most use on the host). | |
| 134 | 新增: # Only MCP servers with something to bake into the image belong here; a | |
| 135 | 新增: # remote one is per-project config. | |
| 110 | 136 | local install_python=1 install_node=1 |
| 111 | 137 | local install_ruby=0 install_rust=0 install_golang=0 |
| 112 | 138 | local install_docker=1 install_chromium=1 install_gh=1 |
| 113 | 139 | local install_claude=1 install_opencode=1 install_codex=1 install_vibe=1 |
| 114 | 140 | local install_pi=0 |
| 141 | 新增: local install_code_server=0 install_code_claude=0 install_code_codex=0 install_code_vibe=0 | |
| 115 | 142 | local install_mcp_chrome=1 install_mcp_playwright=0 |
| 116 | 143 | |
| 117 | 144 | local vm_opts=() rm="" taken |
| @@ -141,8 +168,8 @@ Usage: agent-vm setup [options] | ||
| 141 | 168 | |
| 142 | 169 | Create a base VM template with dev tools and agents pre-installed. Runs an |
| 143 | 170 | interactive wizard by default; the first prompt offers a "default install" |
| 144 | 删除:(everything except the opt-in Ruby, Rust, Go, Pi, Playwright MCP). Answer 'n' for | |
| 145 | 删除:per-component prompts. Pass --preinstall=... to skip the wizard and pick a | |
| 171 | 新增:(everything except the opt-in Ruby, Rust, Go, Pi, Playwright MCP, code-server | |
| 172 | 新增:and its extensions). Answer 'n' for per-component prompts. Pass --preinstall=... to skip the wizard and pick a | |
| 146 | 173 | specific subset non-interactively. When no terminal is available (e.g. CI), |
| 147 | 174 | the wizard is skipped automatically and the default set is installed. |
| 148 | 175 | |
| @@ -155,13 +182,21 @@ Options: | ||
| 155 | 182 | skipped. Use: |
| 156 | 183 | 'default' for the default set |
| 157 | 184 | (everything except Ruby, Rust, Go, Pi, |
| 158 | 删除: mcp-playwright), | |
| 185 | 新增: mcp-playwright, code-server, code-*), | |
| 159 | 186 | 'all' for everything, |
| 160 | 187 | 'none' for nothing. |
| 161 | 188 | Available names: |
| 162 | 189 | python, node, ruby, rust, golang, docker, chromium, |
| 163 | 190 | gh, claude, opencode, codex, vibe, pi, mcp-chrome, |
| 164 | 删除: mcp-playwright | |
| 191 | 新增: mcp-playwright, code-server, code-claude, | |
| 192 | 新增: code-codex, code-vibe | |
| 193 | 新增: 'code-server' is VS Code in the browser, for | |
| 194 | 新增: 'agent-vm code', with GitHub Copilot turned off. | |
| 195 | 新增: 'code-claude', 'code-codex' and 'code-vibe' add that | |
| 196 | 新增: agent's extension, and code-server with it. Each | |
| 197 | 新增: extension brings its own copy of the agent: 'claude', | |
| 198 | 新增: 'codex' and 'vibe' are the command-line ones, for | |
| 199 | 新增: 'agent-vm claude' and the others. | |
| 165 | 200 | Selecting codex or pi also installs node (npm). So does |
| 166 | 201 | mcp-chrome when chromium and an agent are selected |
| 167 | 202 | (npx). mcp-playwright does not: list node yourself. |
| @@ -179,6 +214,7 @@ Options: | ||
| 179 | 214 | --preinstall=default,rust # default set plus Rust |
| 180 | 215 | --preinstall=python,docker,claude |
| 181 | 216 | --preinstall=node,chromium,opencode # no chrome MCP |
| 217 | 新增: --preinstall=default,code-claude # plus the editor | |
| 182 | 218 | --help Show this help |
| 183 | 219 | EOF |
| 184 | 220 | return 0 |
| @@ -220,6 +256,7 @@ EOF | ||
| 220 | 256 | install_docker=0 install_chromium=0 install_gh=0 |
| 221 | 257 | install_claude=0 install_opencode=0 install_codex=0 install_vibe=0 |
| 222 | 258 | install_pi=0 |
| 259 | 新增: install_code_server=0 install_code_claude=0 install_code_codex=0 install_code_vibe=0 | |
| 223 | 260 | install_mcp_chrome=0 install_mcp_playwright=0 |
| 224 | 261 | [[ -z "$preinstall" ]] && preinstall="default" |
| 225 | 262 | # Iterate the comma-list by appending a trailing comma and peeling off |
| @@ -238,6 +275,7 @@ EOF | ||
| 238 | 275 | install_docker=1 install_chromium=1 install_gh=1 |
| 239 | 276 | install_claude=1 install_opencode=1 install_codex=1 install_vibe=1 |
| 240 | 277 | install_pi=1 |
| 278 | 新增: install_code_server=1 install_code_claude=1 install_code_codex=1 install_code_vibe=1 | |
| 241 | 279 | install_mcp_chrome=1 install_mcp_playwright=1 |
| 242 | 280 | ;; |
| 243 | 281 | default) |
| @@ -263,9 +301,13 @@ EOF | ||
| 263 | 301 | pi) install_pi=1 ;; |
| 264 | 302 | mcp-chrome) install_mcp_chrome=1 ;; |
| 265 | 303 | mcp-playwright) install_mcp_playwright=1 ;; |
| 304 | 新增: code-server) install_code_server=1 ;; | |
| 305 | 新增: code-claude) install_code_claude=1 ;; | |
| 306 | 新增: code-codex) install_code_codex=1 ;; | |
| 307 | 新增: code-vibe) install_code_vibe=1 ;; | |
| 266 | 308 | *) |
| 267 | 309 | echo "Unknown preinstall name: $f (names are lowercase)" >&2 |
| 268 | 删除: echo "Valid: python, node, ruby, rust, golang, docker, chromium, gh, claude, opencode, codex, vibe, pi, mcp-chrome, mcp-playwright, default, all, none" >&2 | |
| 310 | 新增: echo "Valid: python, node, ruby, rust, golang, docker, chromium, gh, claude, opencode, codex, vibe, pi, mcp-chrome, mcp-playwright, code-server, code-claude, code-codex, code-vibe, default, all, none" >&2 | |
| 269 | 311 | return 1 |
| 270 | 312 | ;; |
| 271 | 313 | esac |
| @@ -337,7 +379,7 @@ EOF | ||
| 337 | 379 | printf ' Agents: Claude Code, OpenCode, Codex CLI, Mistral Vibe\n' >&2 |
| 338 | 380 | printf ' Tools: Python, Node.js, Docker, Chromium, gh,\n' >&2 |
| 339 | 381 | printf ' Chrome DevTools MCP\n' >&2 |
| 340 | 删除: printf ' Skip: Pi, Ruby, Rust, Go, Playwright MCP\n\n' >&2 | |
| 382 | 新增: printf ' Skip: Pi, Ruby, Rust, Go, Playwright MCP, code-server\n\n' >&2 | |
| 341 | 383 | local use_default_software |
| 342 | 384 | use_default_software=$(_agent_vm_ask_yn "Use this default" Y) |
| 343 | 385 | if [[ "$use_default_software" != "1" ]]; then |
| @@ -349,6 +391,11 @@ EOF | ||
| 349 | 391 | install_vibe=$(_agent_vm_ask_yn "Mistral Vibe" Y) |
| 350 | 392 | install_pi=$(_agent_vm_ask_yn "Pi" N) |
| 351 | 393 | |
| 394 | 新增: printf '\nEditor\n' >&2 | |
| 395 | 新增: printf '──────\n' >&2 | |
| 396 | 新增: install_code_server=$(_agent_vm_ask_yn "code-server (VS Code in the browser, for 'agent-vm code')" N) | |
| 397 | 新增: _agent_vm_ask_code_extensions | |
| 398 | 新增: | |
| 352 | 399 | printf '\nSystem tools\n' >&2 |
| 353 | 400 | printf '────────────\n' >&2 |
| 354 | 401 | install_docker=$(_agent_vm_ask_yn "Docker" Y) |
| @@ -411,6 +458,11 @@ EOF | ||
| 411 | 458 | echo "Running security checks..." |
| 412 | 459 | [[ -n "$declined_protection" ]] || _agent_vm_offer_git_protection |
| 413 | 460 | |
| 461 | 新增: # An extension needs the editor. | |
| 462 | 新增: if [[ "$install_code_claude$install_code_codex$install_code_vibe" == *1* ]]; then | |
| 463 | 新增: install_code_server=1 | |
| 464 | 新增: fi | |
| 465 | 新增: | |
| 414 | 466 | # --preinstall can name what needs node without node. |
| 415 | 467 | local node_reason |
| 416 | 468 | node_reason="$(_agent_vm_node_needed_by)" |
| @@ -488,6 +540,10 @@ EOF | ||
| 488 | 540 | printf 'export AGENT_VM_INSTALL_CODEX=%s\n' "$install_codex" |
| 489 | 541 | printf 'export AGENT_VM_INSTALL_VIBE=%s\n' "$install_vibe" |
| 490 | 542 | printf 'export AGENT_VM_INSTALL_PI=%s\n' "$install_pi" |
| 543 | 新增: printf 'export AGENT_VM_INSTALL_CODE_SERVER=%s\n' "$install_code_server" | |
| 544 | 新增: printf 'export AGENT_VM_INSTALL_CODE_CLAUDE=%s\n' "$install_code_claude" | |
| 545 | 新增: printf 'export AGENT_VM_INSTALL_CODE_CODEX=%s\n' "$install_code_codex" | |
| 546 | 新增: printf 'export AGENT_VM_INSTALL_CODE_VIBE=%s\n' "$install_code_vibe" | |
| 491 | 547 | printf 'export AGENT_VM_INSTALL_MCP_CHROME=%s\n' "$install_mcp_chrome" |
| 492 | 548 | printf 'export AGENT_VM_INSTALL_MCP_PLAYWRIGHT=%s\n' "$install_mcp_playwright" |
| 493 | 549 | cat "${AGENT_VM_SCRIPT_DIR}/agent-vm.setup.sh" |
| @@ -524,6 +580,7 @@ EOF | ||
| 524 | 580 | [[ "$install_codex" == "1" ]] && echo " agent-vm codex" |
| 525 | 581 | [[ "$install_vibe" == "1" ]] && echo " agent-vm vibe" |
| 526 | 582 | [[ "$install_pi" == "1" ]] && echo " agent-vm pi" |
| 583 | 新增: [[ "$install_code_server" == "1" ]] && echo " agent-vm code" | |
| 527 | 584 | # Only worth saying to someone who has a VM to re-clone: on a first install |
| 528 | 585 | # there is nothing to reset, and the advice reads like a missed step. |
| 529 | 586 | if [[ -n "$(_agent_vm_project_vms)" ]]; then |
| @@ -37,6 +37,26 @@ _agent_vm_ask_yn() { | ||
| 37 | 37 | esac |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 新增:# A numbered choice: the options as arguments after the prompt and the | |
| 41 | 新增:# default's number. Prints the number picked. Re-asks on anything else. | |
| 42 | 新增:_agent_vm_ask_choice() { | |
| 43 | 新增: local prompt="$1" default="$2" reply i | |
| 44 | 新增: shift 2 | |
| 45 | 新增: i=1 | |
| 46 | 新增: for reply in "$@"; do | |
| 47 | 新增: printf ' %s) %s\n' "$i" "$reply" >&2 | |
| 48 | 新增: i=$((i + 1)) | |
| 49 | 新增: done | |
| 50 | 新增: while true; do | |
| 51 | 新增: reply="$(_agent_vm_ask "$prompt" "$default")" | |
| 52 | 新增: if [[ "$reply" =~ ^[1-9][0-9]*$ && "$reply" -le $# ]]; then | |
| 53 | 新增: printf '%s\n' "$reply" | |
| 54 | 新增: return 0 | |
| 55 | 新增: fi | |
| 56 | 新增: printf ' (a number from 1 to %s; got: %s)\n' "$#" "$reply" >&2 | |
| 57 | 新增: done | |
| 58 | 新增:} | |
| 59 | 新增: | |
| 40 | 60 | # Can a question be asked, and seen? A terminal to read the answer from, and |
| 41 | 61 | # stderr, where the question goes, on a terminal too: a caller capturing |
| 42 | 62 | # stderr would otherwise wait on a question nobody sees. |
| @@ -17,6 +17,33 @@ check "default leaves pi out" "$(preinstall_exports default PI)" " | ||
| 17 | 17 | check "all installs pi" "$(preinstall_exports all PI)" "1" |
| 18 | 18 | check "naming pi installs it" "$(preinstall_exports default,pi PI)" "1" |
| 19 | 19 | check "pi pulls node in" "$(preinstall_exports pi NODE)" "1" |
| 20 | 新增:check "default leaves code-server out" "$(preinstall_exports default CODE_SERVER)" "0" | |
| 21 | 新增:check "all installs code-server" "$(preinstall_exports all CODE_SERVER)" "1" | |
| 22 | 新增:check "naming code-server installs it" "$(preinstall_exports default,code-server CODE_SERVER)" "1" | |
| 23 | 新增:check "code-server alone has no extension" "$(preinstall_exports code-server CODE_CLAUDE)" "0" | |
| 24 | 新增:check "code-claude pulls code-server in" "$(preinstall_exports code-claude CODE_SERVER)" "1" | |
| 25 | 新增:check "code-claude alone: no Claude CLI" "$(preinstall_exports code-claude CLAUDE)" "0" | |
| 26 | 新增:check "default leaves the extensions out" "$(preinstall_exports default CODE_CODEX)" "0" | |
| 27 | 新增:check "all installs the extensions" "$(preinstall_exports all CODE_VIBE)" "1" | |
| 28 | 新增:check "code-codex needs no npm" "$(preinstall_exports code-codex NODE)" "0" | |
| 29 | 新增:check "but the chrome MCP wired into it does" "$(preinstall_exports code-codex,chromium,mcp-chrome NODE)" "1" | |
| 30 | 新增: | |
| 31 | 新增:section "setup wizard: agents in the editor" | |
| 32 | 新增:# The question after code-server, with the answer given. | |
| 33 | 新增:code_ext() { | |
| 34 | 新增: ( install_code_server="$1" install_claude="$2" install_codex="$3" install_vibe="$4" | |
| 35 | 新增: install_code_claude=0 install_code_codex=0 install_code_vibe=0 answer="$5" | |
| 36 | 新增: _agent_vm_ask_choice() { echo asked >> "$SB/asked.log"; echo "$answer"; } | |
| 37 | 新增: _agent_vm_ask_code_extensions 2>/dev/null | |
| 38 | 新增: echo "$install_claude$install_codex$install_vibe:$install_code_claude$install_code_codex$install_code_vibe" ) | |
| 39 | 新增:} | |
| 40 | 新增:check "both: CLIs kept, extensions added" "$(code_ext 1 1 0 1 1)" "101:101" | |
| 41 | 新增:check "extension only: CLIs dropped" "$(code_ext 1 1 1 0 2)" "000:110" | |
| 42 | 新增:check "command line only: no extension" "$(code_ext 1 1 1 1 3)" "111:000" | |
| 43 | 新增:: > "$SB/asked.log" | |
| 44 | 新增:check "no code-server: not asked" "$(code_ext 0 1 1 1 2)" "111:000" | |
| 45 | 新增:check "no agent with an extension: not asked" "$(code_ext 1 0 0 0 2)" "000:000" | |
| 46 | 新增:check "and nothing was asked" "$(wc -l < "$SB/asked.log" | tr -d ' ')" "0" | |
| 20 | 47 | |
| 21 | 48 | section "--preinstall: MCP names" |
| 22 | 49 | check "default wires the chrome MCP" "$(preinstall_exports default MCP_CHROME)" "1" |
| @@ -5,10 +5,11 @@ section "release hygiene" | ||
| 5 | 5 | # is a command nobody uses. (`sh`/`destroy`/`status` are aliases documented inline.) |
| 6 | 6 | help_text="$(agent-vm help)" |
| 7 | 7 | missing="" |
| 8 | 删除:for verb in setup claude opencode codex vibe pi shell run stop rm destroy-all \ | |
| 8 | 新增:for verb in setup claude opencode codex vibe pi shell run code stop rm destroy-all \ | |
| 9 | 9 | list name info env version help; do |
| 10 | 新增: # The word, then a space or a comma: `codex` is not `code`. | |
| 10 | 11 | case "$help_text" in |
| 11 | 删除: *" $verb"*) ;; | |
| 12 | 新增: *" $verb "*|*" $verb,"*) ;; | |
| 12 | 13 | *) missing="$missing $verb" ;; |
| 13 | 14 | esac |
| 14 | 15 | done |
| @@ -163,7 +164,7 @@ else | ||
| 163 | 164 | ( |
| 164 | 165 | HOME="$MCPHOME" |
| 165 | 166 | eval "$(awk '/^configure_mcp\(\) \{/,/^\}/' "$SETUP_SH")" |
| 166 | 删除: INSTALL_CLAUDE=1 INSTALL_OPENCODE=1 INSTALL_VIBE=1 INSTALL_CODEX=1 | |
| 167 | 新增: HAS_CLAUDE=1 INSTALL_OPENCODE=1 HAS_VIBE=1 HAS_CODEX=1 | |
| 167 | 168 | for _ in 1 2; do # twice: the writer must be idempotent |
| 168 | 169 | configure_mcp chrome-devtools npx -y chrome-devtools-mcp@latest --headless=true |
| 169 | 170 | configure_mcp playwright env PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npx -y @playwright/mcp@latest |
| @@ -211,3 +212,77 @@ else | ||
| 211 | 212 | run_pi_block "$PIH0" 0 |
| 212 | 213 | check "pi: skipped without node" "$( [ -e "$PIH0/sudo.log" ] || [ -e "$PIH0/.pi" ]; echo $?)" "1" |
| 213 | 214 | fi |
| 215 | 新增: | |
| 216 | 新增:# ============================================================================= | |
| 217 | 新增:section "code-server install block" | |
| 218 | 新增:# ============================================================================= | |
| 219 | 新增:# Lifted out like the Pi block, with curl and code-server recorded instead of | |
| 220 | 新增:# run, then the MCP writer after it, as in the script. | |
| 221 | 新增:if ! command -v jq >/dev/null 2>&1; then | |
| 222 | 新增: printf ' skip code-server install tests (jq not installed)\n' | |
| 223 | 新增:else | |
| 224 | 新增: cs_block="$(awk '/^toml_prepend\(\) \{/,/^\}/' "$SETUP_SH") | |
| 225 | 新增:$(awk '/^if \[\[ "\$INSTALL_CODE_SERVER" == "1" \]\]; then/,/^fi$/' "$SETUP_SH") | |
| 226 | 新增:$(awk '/^configure_mcp\(\) \{/,/^\}/' "$SETUP_SH")" | |
| 227 | 新增: # <home> <claude> <codex> <vibe>: the extensions asked for. | |
| 228 | 新增: # Under set -e, as the script runs: a failing step must show here. Twice: | |
| 229 | 新增: # setup can be run again on a base. The first run's state is kept in | |
| 230 | 新增: # <home>/first. | |
| 231 | 新增: run_cs_block() { | |
| 232 | 新增: mkdir -p "$1/.config/code-server"; echo "password: from-the-base" > "$1/.config/code-server/config.yaml" | |
| 233 | 新增: ( set -e | |
| 234 | 新增: HOME="$1"; INSTALL_CODE_SERVER=1 INSTALL_CODE_CLAUDE="$2" INSTALL_CODE_CODEX="$3" INSTALL_CODE_VIBE="$4" | |
| 235 | 新增: HAS_CLAUDE="$2" HAS_CODEX="$3" HAS_VIBE="$4" INSTALL_OPENCODE=0 | |
| 236 | 新增: curl() { echo "curl $*" >> "$HOME/calls.log"; } | |
| 237 | 新增: code-server() { echo "code-server $*" >> "$HOME/calls.log"; } | |
| 238 | 新增: eval "$cs_block" | |
| 239 | 新增: mkdir -p "$HOME/first" | |
| 240 | 新增: for f in .codex/config.toml .vibe/config.toml; do [ ! -f "$HOME/$f" ] || cp "$HOME/$f" "$HOME/first/${f%%/*}"; done | |
| 241 | 新增: configure_mcp chrome-devtools npx -y chrome-devtools-mcp@latest | |
| 242 | 新增: eval "$cs_block" | |
| 243 | 新增: configure_mcp chrome-devtools npx -y chrome-devtools-mcp@latest | |
| 244 | 新增: echo done > "$HOME/finished" ) >/dev/null 2>&1 | |
| 245 | 新增: } | |
| 246 | 新增: CSB="$SB/cs-bare"; mkdir -p "$CSB" | |
| 247 | 新增: run_cs_block "$CSB" 0 0 0 | |
| 248 | 新增: check "code-server alone: no extension installed" "$(grep -c '^code-server' "$CSB/calls.log")" "0" | |
| 249 | 新增: check "code-server alone: Copilot off" \ | |
| 250 | 新增: "$(jq -r '."chat.disableAIFeatures"' "$CSB/.local/share/code-server/User/settings.json")" "true" | |
| 251 | 新增: check "code-server alone: dark theme" \ | |
| 252 | 新增: "$(jq -r '."workbench.colorTheme"' "$CSB/.local/share/code-server/User/settings.json")" "Dark 2026" | |
| 253 | 新增: check "code-server alone: no Claude settings" \ | |
| 254 | 新增: "$(jq -r 'keys | map(select(startswith("claudeCode"))) | length' "$CSB/.local/share/code-server/User/settings.json")" "0" | |
| 255 | 新增: check "the password code-server wrote is not left in the base" \ | |
| 256 | 新增: "$([ -e "$CSB/.config/code-server" ] && echo left || echo gone)" "gone" | |
| 257 | 新增: | |
| 258 | 新增: check "code-server alone: runs to the end under set -e" "$(cat "$CSB/finished" 2>/dev/null)" "done" | |
| 259 | 新增: | |
| 260 | 新增: CSA="$SB/cs-all"; mkdir -p "$CSA" | |
| 261 | 新增: run_cs_block "$CSA" 1 1 1 | |
| 262 | 新增: check "with the extensions: runs to the end under set -e" "$(cat "$CSA/finished" 2>/dev/null)" "done" | |
| 263 | 新增: check "codex: written on a fresh home" "$(head -n 2 "$CSA/first/.codex" 2>/dev/null | sort | tr '\n' ' ')" \ | |
| 264 | 新增: 'approval_policy = "never" sandbox_mode = "danger-full-access" ' | |
| 265 | 新增: check "vibe: written on a fresh home" "$(cat "$CSA/first/.vibe" 2>/dev/null)" 'default_agent = "auto-approve"' | |
| 266 | 新增: check "the three extensions, in one call" \ | |
| 267 | 新增: "$(grep '^code-server' "$CSA/calls.log" | head -n 1)" \ | |
| 268 | 新增: "code-server --install-extension anthropic.claude-code --install-extension openai.chatgpt --install-extension mistralai.mistral-vibe-code" | |
| 269 | 新增: check "claude: bypass mode allowed and picked" \ | |
| 270 | 新增: "$(jq -r '[."claudeCode.allowDangerouslySkipPermissions", ."claudeCode.initialPermissionMode"] | join(" ")' \ | |
| 271 | 新增: "$CSA/.local/share/code-server/User/settings.json")" "true bypassPermissions" | |
| 272 | 新增: check "codex: full access, once, before any table" \ | |
| 273 | 新增: "$(head -n 2 "$CSA/.codex/config.toml" | sort | tr '\n' ' '; grep -c '^approval_policy' "$CSA/.codex/config.toml")" \ | |
| 274 | 新增: 'approval_policy = "never" sandbox_mode = "danger-full-access" 1' | |
| 275 | 新增: check "vibe: auto-approve, once, before any table" \ | |
| 276 | 新增: "$(head -n 1 "$CSA/.vibe/config.toml"; grep -c '^default_agent' "$CSA/.vibe/config.toml")" \ | |
| 277 | 新增: "$(printf 'default_agent = "auto-approve"\n1')" | |
| 278 | 新增: if python3 -c 'import tomllib' 2>/dev/null; then | |
| 279 | 新增: check "codex: the file parses, keys at the top level" \ | |
| 280 | 新增: "$(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")" \ | |
| 281 | 新增: "never True" | |
| 282 | 新增: check "vibe: the file parses, key at the top level" \ | |
| 283 | 新增: "$(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")" \ | |
| 284 | 新增: "auto-approve 1" | |
| 285 | 新增: else | |
| 286 | 新增: printf ' skip TOML parse checks (no python3 with tomllib)\n' | |
| 287 | 新增: fi | |
| 288 | 新增:fi | |
| @@ -69,6 +69,9 @@ case "$1" in | ||
| 69 | 69 | esac |
| 70 | 70 | [ -z "${AGENT_VM_TEST_RO:-}" ] || exit 1 ;; |
| 71 | 71 | *"exec "*" -s"*) cat >> "${AGENT_VM_TEST_STDIN:-/dev/null}" ;; |
| 72 | 新增: # The editor's prep (lib/code.sh): AGENT_VM_TEST_CODE_PREP is its answer. | |
| 73 | 新增: *"agent-vm-code "*) | |
| 74 | 新增: printf '%b' "${AGENT_VM_TEST_CODE_PREP-config=/home/u/.config/code-server/agent-vm-lima-x.yaml\npassword=0123456789abcdef0123456789abcdef\n}" ;; | |
| 72 | 75 | esac ;; |
| 73 | 76 | start) rm -f "$AGENT_VM_TEST_REC.stopped" ;; |
| 74 | 77 | stop) cat >/dev/null; [ -n "${AGENT_VM_TEST_STOP_FAIL:-}" ] || touch "$AGENT_VM_TEST_REC.stopped" ;; |
| @@ -0,0 +1,69 @@ | ||
| 1 | 新增:# ============================================================================= | |
| 2 | 新增:section "code: code-server in the VM" | |
| 3 | 新增:# ============================================================================= | |
| 4 | 新增:# Against the recording limactl of tests/11-recorded-commands.sh. | |
| 5 | 新增:ports="$(_agent_vm_code_ports "$PV")" | |
| 6 | 新增:first="${ports%% *}" | |
| 7 | 新增:check "ten ports per VM" "$(printf '%s\n' $ports | wc -l | tr -d ' ')" "10" | |
| 8 | 新增:check "the same ones on every start" "$(_agent_vm_code_ports "$PV")" "$ports" | |
| 9 | 新增:case "$first" in | |
| 10 | 新增: 2[0-9][0-9][0-9][0-9]) pass "from 20000 to 29999" ;; | |
| 11 | 新增: *) fail "port out of range: $first" ;; | |
| 12 | 新增:esac | |
| 13 | 新增:check "host name: the VM's, lowercased" "$(_agent_vm_code_host agent-vm-My-Proj-0a1b2c3d)" "agent-vm-my-proj-0a1b2c3d.localhost" | |
| 14 | 新增:long="agent-vm-$(printf 'x%.0s' $(seq 1 80))-0a1b2c3d" | |
| 15 | 新增:check "host name: a DNS label, the hash kept" \ | |
| 16 | 新增: "$(_agent_vm_code_host "$long" | sed 's/\.localhost$//' | awk '{ print length($0) <= 63, substr($0, length($0) - 8) }')" "1 -0a1b2c3d" | |
| 17 | 新增:check "another VM, other ports" \ | |
| 18 | 新增: "$([ "$(_agent_vm_code_ports agent-vm-other-00000000)" != "$ports" ] && echo differ)" "differ" | |
| 19 | 新增: | |
| 20 | 新增:if _agent_vm_host_port_open "$first"; then | |
| 21 | 新增: printf ' skip code launch tests (port %s is taken on this machine)\n' "$first" | |
| 22 | 新增:else | |
| 23 | 新增: out="$(rec code)" | |
| 24 | 新增: rec_has "agent-vm code-server --config /home/u/.config/code-server/agent-vm-lima-x.yaml --bind-addr 127.0.0.1:$first --cookie-suffix $PV" \ | |
| 25 | 新增: && pass "code-server on the VM's loopback, the VM's own config and cookie" \ | |
| 26 | 新增: || fail "code: $(grep 'code-server --config' "$REC")" | |
| 27 | 新增: rec_has "--disable-proxy --disable-getting-started-override $PROJ" \ | |
| 28 | 新增: && pass "no port proxy, and the project opened" || fail "code flags: $(grep 'code-server --config' "$REC")" | |
| 29 | 新增: case "$out" in | |
| 30 | 新增: *"Editor: http://$PV.localhost:$first/"*"Password: 0123456789abcdef0123456789abcdef"*) | |
| 31 | 新增: pass "the VM's own host name, and the password" ;; | |
| 32 | 新增: *) fail "code output: $out" ;; | |
| 33 | 新增: esac | |
| 34 | 新增: check "the Safari fallback, on macOS only" \ | |
| 35 | 新增: "$(uname() { echo Linux; }; _agent_vm_code_say u 20000 pw | grep -c 127.0.0.1; uname() { echo Darwin; }; _agent_vm_code_say u 20000 pw | grep -c 'http://127.0.0.1:20000/')" \ | |
| 36 | 新增: "$(printf '0\n1')" | |
| 37 | 新增: | |
| 38 | 新增: AGENT_VM_TEST_CODE_PREP="config=/c.yaml\npassword=pw\nlistening=$first\n" rec code >/dev/null | |
| 39 | 新增: rec_has "--bind-addr 127.0.0.1:$((first + 1))" \ | |
| 40 | 新增: && pass "a port taken in the VM is skipped" || fail "taken port: $(grep 'code-server --config' "$REC")" | |
| 41 | 新增: | |
| 42 | 新增: out="$(AGENT_VM_TEST_CODE_PREP="config=/c.yaml\npassword=pw\nrunning=$first\n" rec code)" | |
| 43 | 新增: rec_has "code-server --config" && fail "a second editor was started" \ | |
| 44 | 新增: || pass "an editor already running is not started again" | |
| 45 | 新增: case "$out" in | |
| 46 | 新增: *"already runs"*"http://$PV.localhost:$first/"*"Password: pw"*) pass "and its address is given" ;; | |
| 47 | 新增: *) fail "running: $out" ;; | |
| 48 | 新增: esac | |
| 49 | 新增:fi | |
| 50 | 新增: | |
| 51 | 新增:out="$(AGENT_VM_TEST_CODE_PREP='missing\n' rec code; echo "rc=$?")" | |
| 52 | 新增:case "$out" in | |
| 53 | 新增: *"code-server is not installed"*"--preinstall=default,code-claude"*"rc=1") pass "without code-server: says how to add it" ;; | |
| 54 | 新增: *) fail "missing: $out" ;; | |
| 55 | 新增:esac | |
| 56 | 新增:rec_has "code-server --config" && fail "missing: started anyway" || pass "and starts nothing" | |
| 57 | 新增: | |
| 58 | 新增:out="$(AGENT_VM_TEST_CODE_PREP='config=/c.yaml\npassword=a\033]0;x\a\n' rec code; echo "rc=$?")" | |
| 59 | 新增:case "$out" in | |
| 60 | 新增: *"could not read the editor's password"*"rc=1") pass "a password with control characters is not printed" ;; | |
| 61 | 新增: *) fail "control chars: $(printf '%s' "$out" | cat -v)" ;; | |
| 62 | 新增:esac | |
| 63 | 新增: | |
| 64 | 新增:out="$(rec code foo; echo "rc=$?")" | |
| 65 | 新增:case "$out" in | |
| 66 | 新增: *"unknown argument for code: foo"*"rc=1") pass "code takes no argument" ;; | |
| 67 | 新增: *) fail "code foo: $out" ;; | |
| 68 | 新增:esac | |
| 69 | 新增:rec_has "shell" && fail "code foo: the VM was entered" || pass "and enters no VM" | |
| @@ -169,7 +169,7 @@ export const en = { | ||
| 169 | 169 | { |
| 170 | 170 | title: 'Get inside', |
| 171 | 171 | body: 'A shell to poke around, or a single command when you already know what you want.', |
| 172 | 删除: code: 'agent-vm shell # zsh in the VM\nagent-vm run npm install # one-off command\nagent-vm run --tty opencode # allocate a PTY for TUIs\nagent-vm sh -c "ls -la | grep config"', | |
| 172 | 新增: code: 'agent-vm shell # zsh in the VM\nagent-vm run npm install # one-off command\nagent-vm run --tty opencode # allocate a PTY for TUIs\nagent-vm sh -c "ls -la | grep config"\nagent-vm code # VS Code in the browser, if set up', | |
| 173 | 173 | }, |
| 174 | 174 | { |
| 175 | 175 | title: 'Manage the fleet', |
| @@ -192,9 +192,9 @@ export const en = { | ||
| 192 | 192 | code: 'agent-vm env set GH_TOKEN # pasted unseen, not in history\nagent-vm env list # names only, never values\nagent-vm env has ANTHROPIC_API_KEY\n\n# scoped to this project only\nagent-vm project-env set SOME_PATH ./config', |
| 193 | 193 | }, |
| 194 | 194 | { |
| 195 | 删除: title: 'Connect an IDE over SSH', | |
| 196 | 删除: body: 'VS Code Remote-SSH, JetBrains Gateway or a GUI agent can work in the VM over SSH, through the alias `agent-vm info` prints as `ssh_host`. Put these lines at the top of `~/.ssh/config`: a `ForwardAgent yes` found before them would hand the VM your SSH keys. `--ssh-port` pins the port for tools that save it.', | |
| 197 | 删除: code: '# top of ~/.ssh/config\nInclude ~/.lima/*/ssh.config\nHost lima-agent-vm-*\n ForwardAgent no\n ForwardX11 no\n\nagent-vm info | grep ^ssh_host # the alias to use\nagent-vm --ssh-port 2222 shell # a fixed port', | |
| 195 | 新增: title: 'Edit with the VM’s tools', | |
| 196 | 新增: body: 'For language servers, linters, the debugger and the VM’s packages, run the editor in the VM: `agent-vm code` serves VS Code (code-server) to a browser tab, the only part on your machine. Set it up with `code-server` or a `code-*` name ([What is in the VM](#what-is-in-the-vm)). The tab can still open links, and every VM reaches the editor’s port, hence a password and a host name per VM ([Network and ports](#network-and-ports)). Do not connect a desktop editor over SSH instead ([SSH from your machine](#ssh-from-your-machine)).', | |
| 197 | 新增: code: 'agent-vm setup --preinstall=default,code-claude # once\nagent-vm code # prints the address and the password\n # Ctrl-C stops the editor', | |
| 198 | 198 | }, |
| 199 | 199 | ], |
| 200 | 200 | gitTitle: 'Letting the agent commit', |
| @@ -229,6 +229,7 @@ export const en = { | ||
| 229 | 229 | rows: [ |
| 230 | 230 | ['shell, sh', 'Open a zsh shell in the VM. `-c "…"` runs a one-shot command through a login shell.'], |
| 231 | 231 | ['run <cmd> [args]', 'Run a command with no shell. `--tty` allocates a PTY for TUIs.'], |
| 232 | 新增: ['code', 'Serve VS Code (code-server) from the VM at `http://<vm-name>.localhost:<port>/` and open it in your browser, until Ctrl-C. Its password is made in the VM on first use and printed. Needs `code-server` or a `code-*` name at setup ([What is in the VM](#what-is-in-the-vm)).'], | |
| 232 | 233 | ], |
| 233 | 234 | }, |
| 234 | 235 | { |
| @@ -262,7 +263,7 @@ export const en = { | ||
| 262 | 263 | }, |
| 263 | 264 | ], |
| 264 | 265 | optionsTitle: 'VM options', |
| 265 | 删除: optionsNote: 'For `claude`, `opencode`, `codex`, `vibe`, `pi`, `shell` and `run`, placed before the command or right after its name. Anything later belongs to the command: in `agent-vm run docker run --rm x`, `--rm` is docker’s.', | |
| 266 | 新增: optionsNote: 'For `claude`, `opencode`, `codex`, `vibe`, `pi`, `shell`, `run` and `code`, placed before the command or right after its name. Anything later belongs to the command: in `agent-vm run docker run --rm x`, `--rm` is docker’s.', | |
| 266 | 267 | optionsHeaders: ['Flag', 'What it does', 'Default'], |
| 267 | 268 | options: [ |
| 268 | 269 | ['--disk GB', 'VM disk size. Can grow, never shrink.', 'the template’s (10)'], |
| @@ -526,6 +527,15 @@ export const en = { | ||
| 526 | 527 | ], |
| 527 | 528 | code: '', |
| 528 | 529 | }, |
| 530 | 新增: { | |
| 531 | 新增: title: 'SSH from your machine', | |
| 532 | 新增: paras: [ | |
| 533 | 新增: 'Do not connect VS Code Remote-SSH or open-remote-ssh to an agent VM. They run a server in the VM, which root in the VM controls, and the editor on your machine trusts it. Microsoft’s Remote-SSH page says so: “a compromised remote could use the VS Code Remote connection to execute code on your local machine”, and it is by design. Public write-ups show it opening a terminal on the host and running commands there. That removes the boundary agent-vm sets up, which is worse than opening the project in Restricted Mode. JetBrains Gateway most likely works the same way; it has not been checked. For language servers and a debugger with the VM’s packages, use [`agent-vm code`](#edit-with-the-vm-s-tools).', | |
| 534 | 新增: 'For scripts, `scp` or `rsync`, `agent-vm info` prints the SSH alias as `ssh_host`. Put these lines at the top of `~/.ssh/config`: a `ForwardAgent yes` found before them would hand the VM your SSH keys. `--ssh-port` pins the port for tools that save it.', | |
| 535 | 新增: ], | |
| 536 | 新增: list: [], | |
| 537 | 新增: code: '# top of ~/.ssh/config\nInclude ~/.lima/*/ssh.config\nHost lima-agent-vm-*\n ForwardAgent no\n ForwardX11 no\n\nagent-vm info | grep ^ssh_host # the alias to use\nagent-vm --ssh-port 2222 shell # a fixed port', | |
| 538 | 新增: }, | |
| 529 | 539 | { |
| 530 | 540 | title: 'Shell, commands, hooks', |
| 531 | 541 | paras: [], |
| @@ -570,6 +580,7 @@ export const en = { | ||
| 570 | 580 | title: 'Network and ports', |
| 571 | 581 | paras: [ |
| 572 | 582 | 'The VM reaches the internet and every service on your machine’s loopback, at `192.168.5.2`. Lima forwards every port a VM listens on to your `127.0.0.1` when it is free: a VM that listens first on 5432 receives the connections, and passwords, meant for your local Postgres. Blocking this is [on the roadmap](#roadmap).', |
| 583 | 新增: 'So every VM can reach the editor of every other one. `agent-vm code` gives each its own password, made in that VM, and its own host name, `<vm-name>.localhost`: browsers keep cookies per host name and not per port, so at `127.0.0.1` any page a VM serves would receive the editor sessions of the others, and with them a way in. Chrome and Firefox resolve `*.localhost` themselves; Safari may not, and then `127.0.0.1` in a private window kept for the editor does the same.', | |
| 573 | 584 | ], |
| 574 | 585 | list: [], |
| 575 | 586 | code: '', |
| @@ -641,11 +652,13 @@ export const en = { | ||
| 641 | 652 | ['AI agents', 'Pi', 'pi', 'no'], |
| 642 | 653 | ['MCP', 'Chrome DevTools MCP, wired into every installed agent but Pi (no MCP support)', 'mcp-chrome', 'yes'], |
| 643 | 654 | ['MCP', 'Playwright MCP, reusing the same Chromium', 'mcp-playwright', 'no'], |
| 655 | 新增: ['Editor', 'code-server (VS Code in the browser, for `agent-vm code`), dark theme, GitHub Copilot off', 'code-server', 'no'], | |
| 656 | 新增: ['Editor', 'The Claude Code, Codex or Mistral Vibe extension, each starting with no permission prompts, with code-server', 'code-claude, code-codex, code-vibe', 'no'], | |
| 644 | 657 | ], |
| 645 | 658 | contentsCode: |
| 646 | 删除: 'agent-vm setup --preinstall=default # no prompts\nagent-vm setup --preinstall=default,rust # plus Rust\nagent-vm setup --preinstall=python,docker,claude # minimal Claude setup\nagent-vm setup --disk 50 --memory 16 --cpus 8 # a bigger template', | |
| 659 | 新增: 'agent-vm setup --preinstall=default # no prompts\nagent-vm setup --preinstall=default,rust # plus Rust\nagent-vm setup --preinstall=python,docker,claude # minimal Claude setup\nagent-vm setup --preinstall=default,code-claude # plus the editor\nagent-vm setup --disk 50 --memory 16 --cpus 8 # a bigger template', | |
| 647 | 660 | contentsNote: |
| 648 | 删除: '`codex` and `pi` pull in `node`, and so does `mcp-chrome` with `chromium` and an agent. Both MCP servers are skipped without `node` and `chromium`. This is only what the template ships: the agent is root in the VM and has the network, so it installs whatever else it needs.', | |
| 661 | 新增: '`codex` and `pi` pull in `node`, and so does `mcp-chrome` with `chromium` and an agent. Both MCP servers are skipped without `node` and `chromium`. Each editor extension ships its own copy of its agent (200 to 600 MB): the wizard asks whether to keep the command-line one too. Without it, `agent-vm claude` says it is not installed. This is only what the template ships: the agent is root in the VM and has the network, so it installs whatever else it needs.', | |
| 649 | 662 | dockerTitle: 'Why not Docker', |
| 650 | 663 | dockerLede: |
| 651 | 664 | 'On Linux, containers share the host kernel, so a compromised dependency that finds a kernel bug is on your host. On macOS, Docker Desktop already runs a VM, which narrows the gap, but it is one VM shared by every container rather than one per project. A VM brings its own kernel, and root inside it still has the hypervisor between it and your machine. The practical differences matter as much as the security one.', |
| @@ -171,7 +171,7 @@ export const fr: Dictionary = { | ||
| 171 | 171 | { |
| 172 | 172 | title: 'Entrer dans la VM', |
| 173 | 173 | body: 'Un shell pour aller voir ce qui s\'y passe, ou une commande isolée quand tu sais déjà ce que tu veux.', |
| 174 | 删除: code: 'agent-vm shell # zsh dans la VM\nagent-vm run npm install # commande unique\nagent-vm run --tty opencode # un PTY pour les TUI\nagent-vm sh -c "ls -la | grep config"', | |
| 174 | 新增: code: 'agent-vm shell # zsh dans la VM\nagent-vm run npm install # commande unique\nagent-vm run --tty opencode # un PTY pour les TUI\nagent-vm sh -c "ls -la | grep config"\nagent-vm code # VS Code dans le navigateur, si installé', | |
| 175 | 175 | }, |
| 176 | 176 | { |
| 177 | 177 | title: 'Gérer le parc', |
| @@ -194,9 +194,9 @@ export const fr: Dictionary = { | ||
| 194 | 194 | code: 'agent-vm env set GH_TOKEN # masqué, hors historique\nagent-vm env list # les noms, jamais les valeurs\nagent-vm env has ANTHROPIC_API_KEY\n\n# limité à ce projet\nagent-vm project-env set SOME_PATH ./config', |
| 195 | 195 | }, |
| 196 | 196 | { |
| 197 | 删除: title: 'Brancher un IDE en SSH', | |
| 198 | 删除: body: 'VS Code Remote-SSH, JetBrains Gateway ou un agent graphique peuvent travailler dans la VM en SSH, par l\'alias qu\'`agent-vm info` affiche comme `ssh_host`. Mets ces lignes en haut de `~/.ssh/config` : un `ForwardAgent yes` trouvé avant elles donnerait tes clés SSH à la VM. `--ssh-port` fixe le port pour les outils qui l\'enregistrent.', | |
| 199 | 删除: code: '# en haut de ~/.ssh/config\nInclude ~/.lima/*/ssh.config\nHost lima-agent-vm-*\n ForwardAgent no\n ForwardX11 no\n\nagent-vm info | grep ^ssh_host # l\'alias à utiliser\nagent-vm --ssh-port 2222 shell # un port fixe', | |
| 197 | 新增: title: 'Éditer avec les outils de la VM', | |
| 198 | 新增: body: 'Pour les serveurs de langage, les linters, le débogueur et les paquets de la VM, fais tourner l\'éditeur dans la VM : `agent-vm code` sert VS Code (code-server) dans un onglet du navigateur, seule partie sur ta machine. Il s\'installe avec `code-server` ou un nom `code-*` ([Ce qu\'il y a dans la VM](#what-is-in-the-vm)). L\'onglet peut toujours ouvrir des liens, et chaque VM atteint le port de l\'éditeur, d\'où un mot de passe et un nom d\'hôte par VM ([Réseau et ports](#network-and-ports)). N\'y branche pas plutôt un éditeur de bureau en SSH ([SSH depuis ta machine](#ssh-from-your-machine)).', | |
| 199 | 新增: code: 'agent-vm setup --preinstall=default,code-claude # une fois\nagent-vm code # affiche l\'adresse et le mot de passe\n # Ctrl-C arrête l\'éditeur', | |
| 200 | 200 | }, |
| 201 | 201 | ], |
| 202 | 202 | gitTitle: 'Laisser l\'agent commiter', |
| @@ -231,6 +231,7 @@ export const fr: Dictionary = { | ||
| 231 | 231 | rows: [ |
| 232 | 232 | ['shell, sh', 'Ouvre un shell zsh dans la VM. `-c "…"` exécute une commande unique via un shell de connexion.'], |
| 233 | 233 | ['run <cmd> [args]', 'Exécute une commande sans shell. `--tty` alloue un PTY pour les TUI.'], |
| 234 | 新增: ['code', 'Sert VS Code (code-server) depuis la VM à `http://<nom-de-vm>.localhost:<port>/` et l\'ouvre dans ton navigateur, jusqu\'à Ctrl-C. Son mot de passe est créé dans la VM à la première utilisation, puis affiché. Demande `code-server` ou un nom `code-*` au setup ([Ce qu\'il y a dans la VM](#what-is-in-the-vm)).'], | |
| 234 | 235 | ], |
| 235 | 236 | }, |
| 236 | 237 | { |
| @@ -264,7 +265,7 @@ export const fr: Dictionary = { | ||
| 264 | 265 | }, |
| 265 | 266 | ], |
| 266 | 267 | optionsTitle: 'Options de VM', |
| 267 | 删除: optionsNote: 'Pour `claude`, `opencode`, `codex`, `vibe`, `pi`, `shell` et `run`, à placer avant la commande ou juste après son nom. Tout ce qui suit appartient à la commande : dans `agent-vm run docker run --rm x`, `--rm` est l\'option de docker.', | |
| 268 | 新增: optionsNote: 'Pour `claude`, `opencode`, `codex`, `vibe`, `pi`, `shell`, `run` et `code`, à placer avant la commande ou juste après son nom. Tout ce qui suit appartient à la commande : dans `agent-vm run docker run --rm x`, `--rm` est l\'option de docker.', | |
| 268 | 269 | optionsHeaders: ['Option', 'Rôle', 'Défaut'], |
| 269 | 270 | options: [ |
| 270 | 271 | ['--disk GB', 'Taille du disque. Peut grandir, jamais rétrécir.', 'celle de l\'image (10)'], |
| @@ -528,6 +529,15 @@ export const fr: Dictionary = { | ||
| 528 | 529 | ], |
| 529 | 530 | code: '', |
| 530 | 531 | }, |
| 532 | 新增: { | |
| 533 | 新增: title: 'SSH depuis ta machine', | |
| 534 | 新增: paras: [ | |
| 535 | 新增: 'Ne branche pas VS Code Remote-SSH ou open-remote-ssh sur une VM d\'agent. Ils font tourner un serveur dans la VM, que contrôle root dans la VM, et l\'éditeur sur ta machine lui fait confiance. La page de Remote-SSH chez Microsoft le dit : « a compromised remote could use the VS Code Remote connection to execute code on your local machine », et c\'est voulu. Des articles publics le montrent ouvrant un terminal sur l\'hôte et y lançant des commandes. Cela supprime la frontière que pose agent-vm, ce qui est pire qu\'ouvrir le projet en mode restreint. JetBrains Gateway fonctionne très probablement de la même façon ; ce n\'est pas vérifié. Pour les serveurs de langage et un débogueur avec les paquets de la VM, utilise [`agent-vm code`](#edit-with-the-vm-s-tools).', | |
| 536 | 新增: 'Pour des scripts, `scp` ou `rsync`, `agent-vm info` affiche l\'alias SSH comme `ssh_host`. Mets ces lignes en haut de `~/.ssh/config` : un `ForwardAgent yes` trouvé avant elles donnerait tes clés SSH à la VM. `--ssh-port` fixe le port pour les outils qui l\'enregistrent.', | |
| 537 | 新增: ], | |
| 538 | 新增: list: [], | |
| 539 | 新增: code: '# en haut de ~/.ssh/config\nInclude ~/.lima/*/ssh.config\nHost lima-agent-vm-*\n ForwardAgent no\n ForwardX11 no\n\nagent-vm info | grep ^ssh_host # l\'alias à utiliser\nagent-vm --ssh-port 2222 shell # un port fixe', | |
| 540 | 新增: }, | |
| 531 | 541 | { |
| 532 | 542 | title: 'Shell, commandes, hooks', |
| 533 | 543 | paras: [], |
| @@ -572,6 +582,7 @@ export const fr: Dictionary = { | ||
| 572 | 582 | title: 'Réseau et ports', |
| 573 | 583 | paras: [ |
| 574 | 584 | 'La VM atteint Internet et tous les services de la boucle locale de ta machine, à `192.168.5.2`. Lima redirige chaque port qu\'écoute une VM vers ton `127.0.0.1` s\'il est libre : une VM qui écoute la première sur 5432 reçoit les connexions, et les mots de passe, destinés à ton Postgres local. Le bloquer est [sur la feuille de route](#roadmap).', |
| 585 | 新增: 'Chaque VM peut donc joindre l\'éditeur de toutes les autres. `agent-vm code` donne à chacune son propre mot de passe, créé dans cette VM, et son propre nom d\'hôte, `<nom-de-vm>.localhost` : les navigateurs rangent les cookies par nom d\'hôte et non par port, si bien qu\'à `127.0.0.1` n\'importe quelle page servie par une VM recevrait les sessions d\'éditeur des autres, et avec elles une porte d\'entrée. Chrome et Firefox résolvent `*.localhost` eux-mêmes ; Safari peut ne pas le faire, et `127.0.0.1` dans une fenêtre privée réservée à l\'éditeur fait alors la même chose.', | |
| 575 | 586 | ], |
| 576 | 587 | list: [], |
| 577 | 588 | code: '', |
| @@ -643,11 +654,13 @@ export const fr: Dictionary = { | ||
| 643 | 654 | ['Agents IA', 'Pi', 'pi', 'non'], |
| 644 | 655 | ['MCP', 'Chrome DevTools MCP, câblé dans chaque agent installé sauf Pi (pas de support MCP)', 'mcp-chrome', 'oui'], |
| 645 | 656 | ['MCP', 'Playwright MCP, réutilisant le même Chromium', 'mcp-playwright', 'non'], |
| 657 | 新增: ['Éditeur', 'code-server (VS Code dans le navigateur, pour `agent-vm code`), thème sombre, GitHub Copilot désactivé', 'code-server', 'non'], | |
| 658 | 新增: ['Éditeur', 'L\'extension Claude Code, Codex ou Mistral Vibe, chacune démarrant sans demande de permission, avec code-server', 'code-claude, code-codex, code-vibe', 'non'], | |
| 646 | 659 | ], |
| 647 | 660 | contentsCode: |
| 648 | 删除: 'agent-vm setup --preinstall=default # sans question\nagent-vm setup --preinstall=default,rust # avec Rust en plus\nagent-vm setup --preinstall=python,docker,claude # Claude seul, minimal\nagent-vm setup --disk 50 --memory 16 --cpus 8 # une image plus grosse', | |
| 661 | 新增: 'agent-vm setup --preinstall=default # sans question\nagent-vm setup --preinstall=default,rust # avec Rust en plus\nagent-vm setup --preinstall=python,docker,claude # Claude seul, minimal\nagent-vm setup --preinstall=default,code-claude # avec l\'éditeur\nagent-vm setup --disk 50 --memory 16 --cpus 8 # une image plus grosse', | |
| 649 | 662 | contentsNote: |
| 650 | 删除: '`codex` et `pi` entraînent `node`, tout comme `mcp-chrome` avec `chromium` et un agent. Les deux serveurs MCP sont ignorés sans `node` et `chromium`. Ce n\'est que ce que l\'image contient au départ : l\'agent est root dans la VM et a le réseau, il installe lui-même ce qui lui manque.', | |
| 663 | 新增: '`codex` et `pi` entraînent `node`, tout comme `mcp-chrome` avec `chromium` et un agent. Les deux serveurs MCP sont ignorés sans `node` et `chromium`. Chaque extension de l\'éditeur apporte sa propre copie de son agent (200 à 600 Mo) : l\'assistant demande s\'il faut garder aussi celle en ligne de commande. Sans elle, `agent-vm claude` dit qu\'il n\'est pas installé. Ce n\'est que ce que l\'image contient au départ : l\'agent est root dans la VM et a le réseau, il installe lui-même ce qui lui manque.', | |
| 651 | 664 | dockerTitle: 'Pourquoi pas Docker', |
| 652 | 665 | dockerLede: |
| 653 | 666 | 'Sous Linux, les conteneurs partagent le noyau de l\'hôte : une dépendance compromise qui trouve une faille dans le noyau se retrouve sur ta machine. Sous macOS, Docker Desktop fait déjà tourner une VM, ce qui réduit l\'écart, mais c\'est une seule VM partagée par tous tes conteneurs, pas une par projet. Une VM a son propre noyau, et root dans la VM a encore l\'hyperviseur entre lui et ton poste. Les différences pratiques comptent autant que celle-ci.', |

