Files
devvm/testdata/script/export.txtar
T
w3cjandClaude Opus 5.5 5304e9a2b7 feat(export): devvm export saves a VM's agent history
devvm export [FILE] saves this folder's VM's agents' history (the same
paths and login excludes as rm's export) to FILE, relative to the
current folder, or to a new <vm>-<date>-<time>.tar.gz in the exports
folder. A stopped VM is started for it. It needs a finished VM made for
this folder.

The export is now written to a temporary file beside its target (mode
600) and renamed into place once complete, for rm's export too: a failed
export leaves no file and an existing FILE as it was.

Messages: history_not_exported (logged) and export_failed (reason) for
devvm export; rm's is now rm_export_failed.

Tests: TestExport (default folder, a new folder for FILE, a failed
export keeping FILE); testdata/script/export.txtar (no VM, usage, a
stopped VM started, the script, a relative FILE, a failure keeping FILE
and the VM); e2e's project section exports a stopped agent VM's history
to a file, without its logins.

Docs: coding-agents.md#history, commands.md, the CLI reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 21:30:52 -06:00

42 lines
1.4 KiB
Plaintext

# 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.
env DEVVM_MESSAGES=names
env VMS=$XDG_DATA_HOME/devvm/vms
mkdir $WORK/web
cd $WORK/web
! exec devvm export
stderr '^devvm: no_vm dir=\S*/web$'
! exec devvm export a b
stderr usage_error
exec devvm --no-network-policy base
exec sh -c 'limactl stop "$(basename "$VMS"/devvm-web-*)"'
exec sh -c ': > "$STUB_LOG"'
exec devvm export
stdout '^==> starting vm=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
stdout 'exec ''bash'' ''-c'' ''cd ~ && ls -d \.claude \.claude\.json .* --exclude=\.claude/\.credentials\.json .* -T -'''
exec sh -c 'ls "$XDG_DATA_HOME/devvm/exports" | wc -l'
stdout '^ *1$'
# A file, relative to here, in a folder made for it.
exec devvm 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
# 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 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'
exec sh -c 'ls "$VMS"'
stdout devvm-web