mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -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]>
38 lines
1.2 KiB
Go
38 lines
1.2 KiB
Go
package cli
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/devvmhq/devvm/internal/msg"
|
|
"github.com/devvmhq/devvm/internal/vm"
|
|
)
|
|
|
|
// newHostCmd is devvm host [--ssh-config].
|
|
func newHostCmd(a *app) *cobra.Command {
|
|
var include bool
|
|
cmd := &cobra.Command{
|
|
Use: "host",
|
|
Annotations: about{
|
|
docs: "using/ssh#devvm-host-devvm-code-and-devvm-cursor", group: groupVM,
|
|
noJSON: "it shows one host name, for ssh as it is",
|
|
}.annotations(),
|
|
Short: "Get this folder's VM ready for ssh and editors, and show its host name",
|
|
Long: "Get this folder's VM ready for ssh and editors as devvm does before it opens a shell, starting the VM if it's stopped. " +
|
|
"Then show the host name that ssh and VS Code's Remote-SSH reach it by, such as devvm-website for a folder named website.",
|
|
Example: examples(
|
|
"devvm host", "get the VM ready and show its host name",
|
|
"ssh devvm-website", "then connect by that name, for a folder named website",
|
|
),
|
|
Args: noArgs,
|
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
|
return a.env(func(env *vm.Env) error {
|
|
env.AddInclude = include
|
|
return vm.Launch{Env: env}.ShowHost(cmd.Context())
|
|
}, msg.SSHFailed)
|
|
},
|
|
}
|
|
addSSHConfigFlag(cmd.Flags(), &include)
|
|
addFolderFlags(cmd, a)
|
|
return cmd
|
|
}
|