mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 21:36:40 -10:00
devvm cursor is devvm code's twin for Cursor, the editor. It gets the folder's VM ready as devvm host does, then runs `cursor --remote ssh-remote+HOST DIR` in devvm's place, with the SSH agent devvm started with. Without `cursor` on PATH it fails with no_cursor_command, naming the host to connect to. Cursor's Agent and your sign-in (from CJ's manual check with a real login): recent Cursor runs Agent in the editor's server in the VM, which holds your Cursor sign-in in memory only (no token on disk, in any environment or command line) and calls Cursor from the VM. Cursor's `cursorAgentHost.remoteInferenceRoute` is application-scoped, so it's read only from the user settings on this machine; with it set to "always", Agent's own requests go through the Cursor app here, while the VM's server still talks to Cursor. - vm: Code and Cursor share openRemote; vm.CursorCommand names the editor's command, apart from the CLI agent's agents.Cursor. After LookPath finds `cursor`, devvm reads Cursor's user settings on this machine (platform.AppSettingsDir: Application Support on macOS, $XDG_CONFIG_HOME or ~/.config on Linux) through safefile.Read, 1 MiB at most, read-only, as JSON with comments, and warns with cursor_agent_in_vm unless the route is "always". It never fails on the file. - sync.sh: Cursor's ~/.cursor-server/data/Machine/settings.json gets VS Code's remote.autoForwardPorts, git.terminalAuthentication and github.gitAuthentication off, in one loop over both editors' files. devvm doesn't write the route there, since Cursor ignores it. - structure: nameFree lets a literal that is an agent's name stand in one file, with its reason, and fails when it frees nothing. - cli: cursor.go (--ssh-config, --here, --parent), registered beside code; cursor_failed, no_cursor_command, cursor_agent_in_vm and their doc links; ssh_host_info names Cursor too; the cli skill's judgment note: an editor's command is a bare verb named after the editor's. - Tests: host_code.txtar (cursor, its full-name host, the missing command, the warning and no warning once the route is set), guest.txtar, TestCursorAgentWarning (always, absent, other values, no file, broken JSON, too long, a FIFO, the XDG path; never written), e2e network: devvm cursor passes the editor only the host and folder, a fake editor sign-in on this machine reaches neither the VM's home, its processes' environments nor the proxy's logs, and a Cursor login in the store reaches the CLI's methods while the agent store's are refused. - Docs: SSH and editors (commands first; "Cursor's Agent": it runs in the VM with your sign-in, the user-settings line, what it doesn't cover, open only VMs you trust; if Tab doesn't work on the allowlist tier, devvm network allow api3.cursor.sh), the agents page's Cursor notes, Commands, attack vectors, design, the home page, CHANGELOG, generated CLI pages. Reviewed adversarially before the push: the settings read (size, FIFOs, links), the warning's wording and when it fires. Researched with PR #44's design as reference only. Co-authored-by: JB <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
139 lines
5.2 KiB
Plaintext
139 lines
5.2 KiB
Plaintext
# devvm host, devvm code and devvm cursor: the folder's VM launched as
|
|
# devvm does without its shell (checked, started, self-checked, set up, in
|
|
# devvm's ssh config), then its host name shown, or its folder opened in
|
|
# VS Code or Cursor (a stub code or cursor) with the SSH agent devvm
|
|
# started with. The Include line is offered for the sandbox's own
|
|
# ~/.ssh/config only.
|
|
|
|
# No VM.
|
|
project web
|
|
! exec devvm host
|
|
stderr '^devvm: no_vm dir=\S*/web$'
|
|
! exec devvm code
|
|
stderr '^devvm: no_vm dir=\S*/web$'
|
|
! exec devvm cursor
|
|
stderr '^devvm: no_vm dir=\S*/web$'
|
|
! stderr cursor_agent_in_vm
|
|
|
|
# A stopped VM: started and set up, no shell. Without a terminal, the
|
|
# Include line is shown, not added.
|
|
exec devvm --network open --no-git-protect
|
|
vm_name WEB web
|
|
exec limactl stop $WEB
|
|
stub_reset
|
|
exec devvm host
|
|
stdout '^==> starting vm=devvm-web-[0-9a-f]{14}$'
|
|
stdout '^ssh_include_needed line=Include /\S*/data/devvm/ssh_config$'
|
|
stderr '^devvm: ssh_include_yourself$'
|
|
stdout '^ssh_host_info dir=/\S*/web host=devvm-web$'
|
|
stub_calls
|
|
stdout '^limactl start --tty=false devvm-web-[0-9a-f]{14}$'
|
|
stdout 'tar -xf'
|
|
! stdout 'limactl shell --workdir /\S*/web devvm-web'
|
|
catg $DATA/ssh_config
|
|
stdout '^Host devvm-web devvm-web-[0-9a-f]{14}$'
|
|
! exists $HOME/.ssh
|
|
|
|
# With the line there: nothing asked. A size its state asks for waits for
|
|
# the running VM's next start, as on a launch.
|
|
exec sh -c 'mkdir -p "$HOME/.ssh" && echo "Include $DATA/ssh_config" > "$HOME/.ssh/config"'
|
|
# ssh by the folder's name reads devvm's ssh config in its data folder
|
|
# through that line: the real ssh resolves the name, connecting to nothing.
|
|
[exec:/usr/bin/ssh] exec /usr/bin/ssh -F $HOME/.ssh/config -G devvm-web
|
|
[exec:/usr/bin/ssh] stdout '^hostname 127\.0\.0\.1$'
|
|
[exec:/usr/bin/ssh] stdout '^userknownhostsfile \S*/data/devvm/vms/[0-9a-f]{14}/run/known_hosts$'
|
|
[exec:/usr/bin/ssh] stdout '^hostkeyalias devvm-web-[0-9a-f]{14}$'
|
|
json_set $WEB_dir/vm.json size.cpus=6
|
|
stub_reset
|
|
exec devvm host
|
|
! stdout 'starting|ssh_include'
|
|
stderr '^devvm: next_start_size vm=devvm-web-[0-9a-f]{14}\ndevvm: next_start count=1 vm=devvm-web-[0-9a-f]{14}$'
|
|
stdout '^ssh_host_info dir=/\S*/web host=devvm-web$'
|
|
stub_calls
|
|
! stdout 'limactl (start|edit)'
|
|
|
|
# devvm code: the folder in VS Code over Remote-SSH, with the SSH agent
|
|
# devvm started with, though this VM's own connections carry none.
|
|
env SSH_AUTH_SOCK=$WORK/user-agent.sock
|
|
stub_reset
|
|
exec devvm code
|
|
stub_calls
|
|
stdout '^code --remote ssh-remote\+devvm-web /\S*/web$'
|
|
exec sh -c 'cat "$STUB_DIR/code-agent"'
|
|
stdout '^\S*/user-agent\.sock$'
|
|
|
|
# devvm cursor: the same in the Cursor editor, with its cursor command,
|
|
# first warning that Cursor's Agent will run in the VM while Cursor's
|
|
# user settings on this machine don't route it through the app here.
|
|
stub_reset
|
|
exec devvm cursor
|
|
stderr '^devvm: cursor_agent_in_vm file=.*/Cursor/User/settings\.json$'
|
|
stub_calls
|
|
stdout '^cursor --remote ssh-remote\+devvm-web /\S*/web$'
|
|
! stdout '^code '
|
|
exec sh -c 'cat "$STUB_DIR/cursor-agent"'
|
|
stdout '^\S*/user-agent\.sock$'
|
|
env SSH_AUTH_SOCK=
|
|
# With the route set there, no warning, and the file stays as it was.
|
|
[darwin] env CURSOR_USER=$HOME/Library/Application' Support'/Cursor/User
|
|
[!darwin] env CURSOR_USER=$XDG_CONFIG_HOME/Cursor/User
|
|
mkdir $CURSOR_USER
|
|
cp $WORK/cursor-settings.json $CURSOR_USER/settings.json
|
|
exec devvm cursor
|
|
! stderr cursor_agent_in_vm
|
|
cmp $CURSOR_USER/settings.json $WORK/cursor-settings.json
|
|
|
|
# Two folders named web: the VM by its full name.
|
|
mkdir $WORK/other/web
|
|
cd $WORK/other/web
|
|
exec devvm --network open --no-git-protect
|
|
stub_reset
|
|
exec devvm code
|
|
stub_calls
|
|
stdout '^code --remote ssh-remote\+devvm-web-[0-9a-f]{14} /\S*/other/web$'
|
|
stub_reset
|
|
exec devvm cursor
|
|
stub_calls
|
|
stdout '^cursor --remote ssh-remote\+devvm-web-[0-9a-f]{14} /\S*/other/web$'
|
|
|
|
# No code or cursor command on PATH: said, with the host to connect to,
|
|
# and no warning about Cursor's Agent, without Cursor's settings too.
|
|
rm $CURSOR_USER/settings.json
|
|
exec sh -c 'mkdir "$WORK/nocode" && for f in "$(dirname "$DEVVM_HOST_MISE")"/*; do case "${f##*/}" in code|cursor) ;; *) ln -s "$f" "$WORK/nocode/";; esac; done'
|
|
env SAVED_PATH=$PATH
|
|
env PATH=$DEVVM_BIN:$WORK/nocode:/usr/bin:/bin:/usr/sbin:/sbin
|
|
stub_reset
|
|
! exec devvm code
|
|
stderr '^devvm: no_code_command host=devvm-web-[0-9a-f]{14}$'
|
|
! exec devvm cursor
|
|
stderr '^devvm: no_cursor_command host=devvm-web-[0-9a-f]{14}$'
|
|
! stderr cursor_agent_in_vm
|
|
stub_calls
|
|
! stdout '^(code|cursor) '
|
|
env PATH=$SAVED_PATH
|
|
|
|
# Network policy: a VM devvm started confined that still reaches the
|
|
# internet directly is stopped, as on a launch; no host name. (Its
|
|
# hostagent here: the test's runner, which runs on, in place of the
|
|
# stub's.)
|
|
project leak
|
|
exec devvm --network allowlist --no-git-protect
|
|
vm_name LEAK leak
|
|
exec sh -c 'echo $PPID > "$LIMA_HOME/$LEAK/ha.pid"; echo "$PPID 1" > "$LEAK_dir/run/started"'
|
|
stub_reset
|
|
exec sh -c ': > "$STUB_DIR/net-direct"'
|
|
! exec devvm host
|
|
stderr '^devvm: net_direct_route vm=devvm-leak-[0-9a-f]{14}$'
|
|
! stdout ssh_host_info
|
|
stub_calls
|
|
stdout '^limactl stop devvm-leak-[0-9a-f]{14}$'
|
|
! stdout 'tar -xf'
|
|
rm $STUB_DIR/net-direct
|
|
|
|
-- cursor-settings.json --
|
|
// Cursor's user settings, with comments and a trailing comma.
|
|
{
|
|
"editor.fontSize": 14,
|
|
"cursorAgentHost.remoteInferenceRoute": "always",
|
|
}
|