min-zed opens Minimal boxes (min sessions, libkrun microVMs) in Zed as ssh
remote projects (zed ssh://min-zed.NAME/workbench), with sshd running inside
the box behind a min session exec ProxyCommand. One POSIX shell script plus
a python3 merger, no build step. It is the Zed twin of min-vscode
(gominimal/min-vscode): same plumbing
and commands; only the editor-specific constants, the merger and the loadout
differ. There is no Zed extension (Zed's WASM API has no UI): the UI is Zed's
own surfaces, which setup wires: the Remote Projects list
(ssh_connections), global tasks, and one key.
| File | Role |
|---|---|
bin/min-zed |
tool constants, then the transport/ssh/session plumbing, then the client layer, whose first block holds every editor-specific constant |
| plumbing | transport, box ids (stored_id, pick_id, box_id, need_box, own_filter, id_field), PREP/prepare, stored_path, ssh options and stanzas, ssh-config, _proxy, ssh, naming, pick_session, activate_session, destroy_one, in_use_names/box_in_use, track_orphans, default_loadouts, the ssh-config record, report helpers; editor-neutral, reaching the client layer only through its hooks |
| client layer | open/new/attach (session, stanza, settings, zed ssh://… unless --no-window; new --empty; on a terminal new offers PATH's live box), destroy (--if-idle; no NAME: the cwd's own box, else on a terminal the picker), gc, status (--json), doctor, completions, config (alias zed-config), setup, hidden _sessions; hooks client_on_connect and client_on_destroy (settings sync) |
bin/min-zed-config |
python3 merger for three JSONC files in ~/.config/zed: settings.json (ssh_connections entries for live sessions, edited in place), tasks.json and keymap.json (a marked block at the top of the array: the Minimal tasks, the local-terminal key); --install, --sync NAME..., --remove, --doctor, --dry-run |
loadouts/zed.toml, loadouts/zed/ |
openssh curl rsync xxhash git; sshd env prep; min:workbench rc line; a patch copying zed/skills/minimal-sandbox to ~/.claude/skills in the box. setup copies zed/ beside the linked toml: $LOADOUT_ROOT must be a real directory |
skills/, loadouts/zed/skills/ |
Minimal's skills, vendored from gominimal/minimal-skills (MIT) at a pinned commit by just skills: the host ones (setup copies them into the Mac's ~/.agents/skills (Zed's agent) and ~/.claude/skills, marked .min-zed-copy, never over a dir with no .min-*-copy mark; one another min tool marked is shared, keeping its mark, and --remove deletes it only once no other mark is left) and minimal-sandbox (box only: the host ones teach commands a box lacks) |
minimal.toml |
developing this repo in a box: session packages for just check; task check (min task run check) |
justfile |
check, install/uninstall (= setup), ssh-config, zed-config, skills |
tests/run.sh, tests/stubs/ |
plain-sh tests over stub min, zed, ssh, ssh-keygen, ps (+ find/mv for PREP races) and a tripwire for bare GUI commands; LONG_PREFIX=1 reruns them with a long host prefix; the destroy picker runs on a pty through script(1) (skipped without it); fixture ids are UUIDs (ID_A, id_of NAME), and the ids_* cases cover box ids |
docs/ |
user docs (being rewritten for 0.2.0), public/ marks and badge |
- One
ssh_connectionsentry per live own session,{"host": "min-zed.NAME", "nickname": "NAME", "projects": [{"paths": ["/workbench"]}]}: the Remote Projects modal (ctrl-cmd-o), reloaded live. tasks.jsonblock, seven tasks:Minimal: New Box from Folder…(new FOLDER: the window's folder, given asenvMIN_ZED_TASK_FOLDER: ${ZED_WORKTREE_ROOT:none}so the task is offered with no folder open too; with none, or a single-file window, it asks in macOS's folder picker (osascriptchoose folder, from$HOME; cancel exits 0); withoutosascriptit prints one line saying to open a folder;newthen offers the folder's live own box,[Y/n], before a second one),Minimal: New Empty Box(new --empty),Minimal: Open Box…(attach: picker),Minimal: Destroy Box…(destroy: the cwd's box, else picker),Minimal: Clean Up Idle Boxes…(gc),Minimal: Status,Minimal: Doctor. Each runs through"shell": {"program": "sh"}(any login shell) and calls$HOME/.local/bin/min-zedby absolute path; where that is missing (a box window: global tasks run in the box) it prints one line pointing at a local window or the local-terminal key, and exits 1. The CLI's own y/N questions and numbered pickers are the UI.reveal: always,use_new_terminal: false,allow_concurrent_runs: false,show_command: false;hide: on_successfor the three that open a window,neverfor the rest. No$ZED_*variable in a command orcwd: Zed pastes them into a command unquoted, and a root may be a file.keymap.jsonblock, contextWorkspace:ctrl-alt-`→["workspace::NewTerminal", {"local": true}](a Mac terminal from a box window);ctrl-alt-n/ctrl-alt-o→["task::Spawn", {"task_name": …}]for New Box from Folder…/Open Box… (Zed's welcome page is hard-coded, so keys are how the tasks reach it; both free in the default macOS and vim keymaps). Free in Zed 1.26.2's default macOS keymap, besidectrl-`(terminal panel) andctrl-~(new terminal). No task bindings:cmd-shift-r, then "Minimal".
- Session names match
^[a-z0-9][a-z0-9-]*$,-nincluded: they are hostnames and sshHostpatterns. Without-n, min names the session;activate_sessiontakes the one new session for the path and refuses a name that is no hostname. - Host alias is
min-zed.NAME(HOST_PREFIX); nothing hard-codes the prefix length (the long-prefix test run guards it). preparere-pins the host key and re-pushes the public key on everyopen/attach/ssh/_proxy, so a box min-zed recreated self-heals; it never replaces a recorded id with another._proxyalways runsprepareand writes nothing to stdout beforeexec(stdout is the SSH byte stream)._proxyandpreparenever call client hooks, never touch Zed's files.ssh-configis an opt-in gate: nothing under~/.sshis touched until it has run.ssh-config --removeleaves~/.ssh/configbyte-identical to before install;--printwrites nothing (not even a legacy key dir's adopted id:PICK_NOADOPT). Other tools' Include lines are never touched.configis the same kind of gate for Zed's files:--syncis a no-op untilconfighas run (STATE/settings-installed), and--sync(from open/attach/ssh/destroy/gc) touches onlyssh_connections; onlyconfig(--install, also run bysetup) writes the tasks and keymap blocks. Settings: only entries whose host starts with the prefix are added or removed; an existing entry of ours is kept verbatim; every other byte (comments between entries, CRLF, BOM) stays; the key is removed only if we added it (STATE/settings-key-added); adding ours and taking them out again gives back the bytes (a comment after the user's last entry stays on its line). 0.1.0'sSTATE/zed-config-installedandzed-config.jsonare taken over once (opt-in, key added, file created). Tasks/keymap: the block between// min-zed:beginand// min-zed:end(the marks only as comment lines of their own, the first right after the top-level[) is ours and rewritten whole (Zed's keymap editor appends after it); a file with no array gets one marked// min-zed:array, taken out with the block while nothing else went into it. For all three: dated backup inSTATE/backups/before a write; written through a symlink, replaced atomically; never written when unchanged;--removerestores the bytes it found and deletes a file it created (STATE/<file>-created) once empty; a file that does not parse (or is not UTF-8, or has the wrong top level) is refused, and then none of the three is written. Settings sync is skipped whenmin lsfails.ssh_connectionsstays keyed by host alias (min-zed.NAME, nickname NAME), never by id; it lists only own boxes (prepared_live:own_filter, without adopting).- The host key is pinned (
StrictHostKeyChecking=yes); neveraccept-new. - Agent and X11 forwarding stay off on every client path: one option list
(
ssh_common) feeds both the stanza andssh_opts. - Facts the box reports (user, hostkey, home, sshd) are untrusted:
preparevalidates them before writing anything, and dies if a write fails; storedhome/sshdare re-checked on read (stored_path) by_proxyand by the ProxyCommandsshbuilds. gcanddestroynever destroy without an explicit y;-yis the only way pastdestroy's question.- A box is gone (keys, records and stanza dropped,
client_on_destroyrun bydestroy_one) only when a successfulmin lsno longer lists its id; a failedmin lskeeps everything (ssh-config not rewritten), warns, and after a y exits non-zero;destroy NAMEdrops what was kept once a successfulmin lsno longer lists the recorded id, even while another box holds the name (never touching that box); for a key dir with no id, once no box is named NAME.min_lsfails unless its output has a.sessionsarray, so junk on exit 0 is a failedmin ls, never "no box";own_filterfails with its jq, and a box listed under NAME with no usable id (pick_id7) is "no id to trust", never "none". - Every min call aimed at one box passes its id, never its name (min 0.8
resolves a name to whichever box holds it):
session exec(prepare,_proxy's exec,proxy_command) andsession destroy(destroy_one). The id isSTATE/sessions/NAME/id(activate_session: the one id new inmin ls, named NAME with-n, else for PATH, a null name refused;preparewrites it with the facts, and refuses a badidfile or a different id, never writing over either), checked againstID_EREon every read (stored_id, which also refuses a NAME that is no session name) before it reaches a command line or a stanza.pick_id/box_idresolve NAME: own (the recorded id, listed under NAME); a key dir with noidadopts the one box named NAME (and writes it only on a connect:attach/ssh/_proxythroughbox_id/need_box,openthroughprepareonce the project checks out;own_filteralways runspick_idunderPICK_NOADOPT=1, so no list adopts: open's reuse, the pickers, the cwd lookup, gc, status, completions, stanzas,prepared_live;cmd_open,cmd_destroy,ssh-config,config,setupanddoctorset it too).destroynever writes an id: an explicitdestroy NAMEreaches the one box of the name by its id without recording it, and a NAME the cwd lookup or the picker chose is refused unless its id is recorded ("NAME has no recorded box id yet; …").gcnever adopts or destroys a key dir with noid: it lists it ("no id recorded (attach NAME once)") without asking.status --jsongivesrecorded. In-use checks of own boxes go by name and id (gc rows,gc_still_idle NAME ID,st_used,track_orphans).min_lsneeds exactly one JSON value whose.sessionsis an array of objects; a jq failure inpick_idis status 8 ("could not read min ls"), never "none";pick_idreturns 1 for a NAME that is no session name before touchingsess_dir; several boxes named NAME, none recorded, a badidfile, or a listed box with no usable id: no id (box_idstatus 2,BWHY), so an explicit NAME dies saying why,doctorwarns, it is not own and gets no stanza orssh_connectionsentry; never a by-name call. A recorded id is never traded for a box found by name: ours gone (id unlisted;pick_id5) with another box named NAME isbox_idstatus 5, "your box NAME is gone":destroy NAMEdrops only our keys and records, everything else refuses; ours listed under another name or none (pick_id6) is refused everywhere. A NAME chosen from the own list (the cwd, the pickers) resolves withown. A failedmin lskeeps every stanza but a bad-id one. An explicit NAME that is not own and has no recorded id reaches the one box of that name (attach,ssh,open -n,destroy), refused when several share it;_proxy NAMEonly an own box, or the one box of that name when there is no key dir at all (a stanza of a box of ours that is gone never reaches the box that took its name). Helpers reading one session (id_field,ls_lists) select by id. gcoffers only own sessions (own_ls: a key dirSTATE/sessions/NAMEwhose recorded idmin lslists under NAME;status --jsongivesid), andgc/statusdate only those inorphan/(track_orphans, each run); boxes made byminalone are never listed. The same holds wherever a session is chosen for the user:open's reuse of a live session for PATH,new's offer of one,destroy's cwd lookup and its picker, theattachpicker and_sessions(completions). Only an explicit NAME (attach NAME,ssh NAME,destroy NAME,open -n NAME) may reach another tool's box.newasks only on a terminal and only without-nor--empty:[Y/n]to attach to PATH's live own session (live_boxoverown_filter, asopenreuses), and only an n makes the second box. Without a terminal it is always a new session. A box of another tool is never offered: min's refusal stands. On a y it reaches the box by id: a key dir with no recorded id is adopted asopen's reuse adopts (prepare records it); an n, or no terminal, writes no id for it.destroywithout NAME: exactly one own session for the cwd is it; otherwise, on a terminal (a Zed task), the own-session picker; without a terminal, or with no own session at all, the errors ("no session for DIR; pass NAME", "several sessions for DIR: …; pass NAME").- In use = some host process runs
min session exec X ... sshd(any ssh client's connection); X is an id or a bare name (connections from before ids, other tools), and every check of an own box asks for both. Never contact a box without such a live process: a connect starts a stopped box. gcre-checksgc_still_idlebefore each question;destroy --if-idlere-checks it too (exit 3 when in use); without a terminal, unsaved changes exit 4 and onlydestroy -y --forcediscards them.- Activation passes the user's
default_loadoutson before--loadout zed. - What
ssh-configcreated under~/.sshis recorded in~/.local/state/min-clients/ssh-config-created; removing the lastInclude ~/.ssh/min-*.confdeletes only that, so~/.ssh/configends byte-identical. - Install never edits
default_loadouts;setup --remove(just uninstall) removes only our own links, marked skill copies, Zed entries and blocks, and Include; when the merger refuses a Zed file it removes nothing else and fails.setupreplaces a link only when missing, dangling, or pointing to another copy of the same file (a moved checkout); stanzas bake the~/.local/binlink, so it follows the checkout.
- min 0.8.0-dev.381 (gominimal/minimal#2756,
BOX-004/005): a session name is an alias many boxes may share. A
stopped box keeps its name, and
min lsstill lists it, but it does not stop a new box from taking the name; only a running box (or a resume in flight) does (minimald'sclaim_name/running_name_holder). A name resolves to the running box, else the latest.session exec,attach,destroy,renameandpolicytake a full session id first (SessionLookup::parse), andmin ls --jsongives each session'sid(lowercase hex UUID) andname(which may be null). minis a zsh function on the host;MIN_BINis resolved to an absolute path and baked into each stanza (Zed spawns ssh with the launchd PATH).- Without
zedon PATH,bin/min-zeduses the app's own CLI ($MIN_ZED_EDITOR_APP/Contents/MacOS/cli, default/Applications/Zed.app);MIN_ZED_EDITOR_BINoverrides both.zed --versionprintsZed 1.26.2 – /Applications/Zed.app; doctor notes a version other than the tested 1.26.2. bin/min-zedappends/opt/homebrew/bin,/usr/local/binand~/.local/binto PATH (unlessMIN_NO_PATH_EXTEND=1, which tests set, withZDOTDIR VISUAL EDITORunset), where the realzedlives: tests must pointMIN_ZED_EDITOR_BIN(and every other*_BIN) at an absolute stub path, never a bare name. Bareopen,osascript,zed,code,cursorandwindsurfon the test PATH aretests/stubs/tripwire(stubs live in$T/stub-bin), and any tripwire line fails the case. A mutation check never removes or bypasses a stub or the tripwire; skip any that could launch a real app.- ssh runs the ProxyCommand via
$SHELL -c "exec ..."and expands%tokens: every word goes throughshqand the whole string throughpct. - Zed 1.26.2, seen live 2026-10-29:
ssh_connectionsentries appear in Remote Projects and reload live; global~/.config/zed/tasks.jsontasks run on the Mac in a local window and in the box (bash, cwd/workbench) in a box window;["workspace::NewTerminal", {"local": true}]opens a Mac terminal from a box window; a new box host opens in Restricted Mode until trusted once; agent notifications fire for box threads. - Zed task commands go through
shellexpand(Zed source, v1.26.2):$ZED_*variables are pasted into the command text unquoted, a task whose$ZED_*variable is unset is not offered unless it is written${ZED_VAR:default}, other$VARSare left to the shell.envvalues get the same substitution but are no shell text, and the task variables are exported too.ZED_WORKTREE_ROOTis set without a directory check: in a single-file window it is the file. Tasks run in an interactive terminal (sh -i -c), so[ -t 0 ]holds. - Restricted Mode (Zed source, v1.26.2): trust is stored per (ssh user,
host, path) in Zed's SQLite db, read at startup and rewritten from memory,
so each new box name asks once (a box recreated under the same name keeps
its trust). Trust also lets project settings start MCP servers, which run
on the Mac unless
"remote": true: the box does not contain them. The Mac decides itself (worktree_store.rscallscan_trustwith the Mac's settings), so a"linux"settings override that reaches the box server does not stop the dialog. The only switch,session.trust_all_worktrees, also trusts every local folder:confignever writes it. Per-host trust asked upstream: zed-industries/zed#66313. - Zed downloads its remote server into the box itself:
~/.zed_server/zed-remote-server-stable-<ver>+stable.<build>.<sha>. Claude Agent (ACP) runs in the box with the Node Zed downloads (~/.local/share/zed/node; the loadout needs none) and reads~/.claude/skillsthere; Zed's own agent runs on the Mac and reads~/.agents/skills/<skill>/SKILL.md. - Claude Agent's adapter (agentclientprotocol/claude-agent-acp) runs
$CLAUDE_CODE_EXECUTABLEinstead of the SDK's own claude and loads user settings. Minimal'sclaudepackage (min add claude) is a/usr/bin/claudewrapper adding--plugin-dir=/usr/share/claude/plugins/minimal(skill, SessionStart primer, denial-triage hook). PREP and the loadout hook set the variable in~/.ssh/environmentonly when/usr/bin/claudeexists; never Zed's globalagent_serversenv, which local windows share. Unverified: that the variable reaches the agent process, and that the SDK runs the wrapper. - The box is uid 1000 with
$HOME=/home, aarch64, glibc 2.44, has bash, tar, curl and awk (GNU Awk 5.4.1; seen 2026-11-10);sshdat/usr/sbin/sshd. No python3 or zsh unless a loadout or the project brings them; these loadouts need neither. - sshd scrubs the environment: PREP writes
~/.ssh/environment(filteringPROMPT_COMMAND/MINIMAL_MOTD) and sshd runs withPermitUserEnvironment=yes. - The box's
env(GNU coreutils 9.12) shell-quotes values (X='a b'), which sshd would read literally: PREP and the loadout hook dump the environment with awk'sENVIRON(envonly without awk), dropping multi-line values whole. gawk addsAWKPATH/AWKLIBPATHtoENVIRONwhen unset; they pass the filters (filtering them would drop a user's own). - In the box, the host key and
authorized_keyslive in~/.ssh/min-zed/. - Without a terminal,
min session destroyrefuses a box with unsaved changes ("refusing to destroy the session without confirmation; pass --force").
- Verify:
just check. - Tests never touch the real min, Zed,
~/.sshor~/.config: stubs first on a private PATH,HOME,MIN_ZED_STATE_DIR,MIN_ZED_SETTINGS,MIN_ZED_TASKSandMIN_ZED_KEYMAPin a tempdir. - Don't create, attach or destroy min sessions, or
min session execinto one, without asking. Don't runssh-config,config,_proxy,just install/uninstallagainst the real HOME; useHOME=<scratch>XDG_CONFIG_HOME=<scratch>and a stubMIN_BIN.
- New Box from Folder… with no folder open: the osascript folder picker (may open behind Zed's window).
- Destroying the box a window is on: what that window does.
Seen end to end (Zed 1.26.2, 2026-10-29): the tasks through sh, the
folder through env, hide: on_success, pickers and y/N in a task
terminal, the box-window guard line, all three keys (US keyboard), Remote
Projects, setup --remove restoring ~/.ssh/config byte-identical.