Files
w3cjandClaude Opus 5.5 376f1c2ad7 fix(agents): opencode's save, plugin approvals and the history scripts' framing
devvm agent save refused a VM whose ~/.config/opencode held a bun.lock (which opencode's plugins' installs write), a package-lock.json, a .gitignore or a .DS_Store: the save's script sent every entry of that folder but node_modules and FolderOwn, while the host's listedPath refuses those files (fileSetting), so it saved nothing. notSettings is now their one list, as patterns path.Match and the shell's case read alike: fileSetting leaves them out and the script sends a file of those names no more, only a folder that isn't a link, which is a setting. TestAgentSaveScriptRuns plants them and a folder named old.lock, and failed with agent_save_unsafe before the fix.

opencode's HistoryOwn names its native client's plugin approvals, in its state folder (cli-rs's plugin/src/loader/approval.rs and tui/src/plugins/host.rs, opencode v2.4.1): plugin-approvals.json, its .lock and the .plugin-approvals.json.<pid>.<n>.tmp it's written through, and plugin-staged, the approved trees' copies, which it reuses by their hash's name without hashing them again, so a hostile VM's export could approve a project plugin for the VM that imports it. That client doesn't ship in 2.4.1. TestHistoryExportRuns and TestHistoryImportRuns plant them, with plugin-notes.json as the control, and failed on fedora without the entries.

The history scripts' framing (onInputCmd) now says why on its stderr, which goes to the VM's log, when its input was cut short: TestOnInputCutShort checks it for every cut, an empty input included, and none for a whole one, and failed before. TestHistoryScriptsOnInput holds each script under 128 KiB, Linux's limit on one argument, which bash -c "$s" passes it as. The CLI scripts match the framing's new start.

Docs: the save's and the store's table say which files stay in the VM; the import's and How it works' lists name the plugin approvals; the release page gets opencode's lock files in a save and the approvals; the changelog's opencode block gets the save's fix, and the hardening line names approved plugins. The review's optional wording: the design note's `*` matches every resource, and the plain-password steps set this machine's password first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 00:03:05 -07:00

65 lines
2.8 KiB
Plaintext

# history export: the folder's VM's agent history, to the exports folder or a
# file, from the VM, started if it's stopped. A failed export leaves the
# file it would replace as it was. history: the exports in the exports
# folder, each with its VM's folder, and nothing else there.
env EXPORTS=$XDG_DATA_HOME/devvm/exports
project web
! exec devvm history export
stderr '^devvm: no_vm dir=\S*/web$'
! exec devvm history now
stderr '^devvm: no_subcommand command=devvm history commands=export, import given=now$'
# None yet: the header alone, no VM needed.
exec devvm history
stdout '^FILE +VM +FOLDER +DATE +SIZE\n\z'
exec devvm history --json
stdout '\A{\n "version": 1,\n "exports": \[\]\n}\n\z'
exec devvm --network open
vm_name WEB web
exec limactl stop $WEB
stub_reset
exec devvm history export
stdout '^==> starting what=devvm-web-[0-9a-f]{14}$'
stdout '^==> exported file=\S*/data/devvm/exports/devvm-web-[0-9a-f]{14}-[0-9]{8}-[0-9]{6}\.tar\.gz vm=devvm-web-[0-9a-f]{14}$'
stub_calls
# The export's script goes on bash's input, never in its arguments.
stdout 'exec ''bash'' ''-c'' ''if IFS= read -r n '
grep '^devvm_opencode_clean\(\) \{$' $STUB_DIR/history-export.sh
grep '^cd ~ && ls -d \.claude \.claude\.json .*--exclude=\.claude/\.credentials\.json.* -T - ' $STUB_DIR/history-export.sh
exec sh -c 'ls "$EXPORTS"/*.tar.gz | wc -l'
stdout '^ *1$'
# A file, relative to here, in a folder made for it.
exec devvm history export out/h.tar.gz
stdout '^==> exported file=\S*/web/out/h\.tar\.gz vm=devvm-web-[0-9a-f]{14}$'
exists out/h.tar.gz
! stdout starting
! exists out/h.folder
# A failed export keeps the file as it was, and the VM.
exec sh -c 'echo before > out/h.tar.gz'
exec sh -c ': > "$STUB_DIR/shell-fails"'
! exec devvm history export out/h.tar.gz
stderr '^devvm: history_not_exported vm=devvm-web-[0-9a-f]{14}$'
rm $STUB_DIR/shell-fails
exec cat out/h.tar.gz
stdout '^before$'
exec ls -A out
stdout '^h\.tar\.gz\n\z'
vm_name WEB web
exists $WEB_dir/vm.json
# history lists the exports folder's: its own export with its folder, one
# devvm has no folder for as -, and never another file there or one of
# your own.
exec sh -c 'echo x > "$EXPORTS/devvm-old-12345612345612-20200101-000000.tar.gz" && echo x > "$EXPORTS/notes.tar.gz"'
exec devvm history
stdout '^FILE +VM +FOLDER +DATE +SIZE\n'
stdout '^\S*/exports/devvm-old-12345612345612-20200101-000000\.tar\.gz +devvm-old-12345612345612 +- +2020-01-01 00:00 +\S+\n\S*/exports/devvm-web-'
stdout '^\S*/exports/devvm-web-[0-9a-f]{14}-[0-9]{8}-[0-9]{6}\.tar\.gz +devvm-web-[0-9a-f]{14} +\S*/web +[0-9-]+ [0-9:]+ +\S+$'
! stdout notes
exec devvm history --json
stdout '^ "file": "\S*/exports/devvm-old-12345612345612-20200101-000000\.tar\.gz",\n "vm": "devvm-old-12345612345612",\n "folder": "",\n "date": "2020-01-01T00:00:00[-+Z][0-9:]*",\n "size": \d+\n'
! stdout out/h