Files
magpie/docs
yetone 7b002b6be8 library: an MCP command's %USERPROFILE%, $USERPROFILE and ~\ are the home on every system (0xBCD18E on X)
0xBCD18E's Library server ran
"%USERPROFILE%\AppData\Local\Programs\Pinky\pinky.exe", and the check
said it couldn't find "%USERPROFILE%\A…": magpie read $NAME, ${NAME}
and ~ in a command but not cmd.exe's %NAME%, so the only way to share
one server across computers with different user names was a per-device
command.

Now HOME and USERPROFILE are both the home, on every system, as $NAME,
${NAME} or %NAME% (either case), and a leading ~ or ~\ too:
- library.json (and so sync and backups) keeps them as written;
- an agent that reads references in a command (Claude Code, CodeBuddy,
  WorkBuddy, Grok, Gemini, omp/Qoder/AtomCode, OpenCode, Cursor) is
  given the home's own variable where it runs: ${USERPROFILE} on
  Windows, where an agent seldom has HOME, ${HOME} on a Mac, Linux and
  in WSL, where nothing has USERPROFILE. Before this, $HOME went to
  Claude Code on Windows as ${HOME}, which it usually hasn't;
- every other agent (Codex, Kiro, Droid, Copilot, Crush, Goose, Pi, ...)
  and magpie's own start (the check, the router, Codex through the
  gateway) get the home's path;
- any other %NAME% (%APPDATA%) is a variable on Windows only, and is
  left as written elsewhere, so 100% or %Y% in an arg stays as it is;
- a command's environment: a leading ~ and %USERPROFILE% / %HOME% in a
  value are put in as the home for every agent and for magpie's start
  (homeEnv); ${NAME} there stays envref's.
No cwd: a Library server has none.

Tests: TestCmdVarsUserProfile forces cmdOS to windows, darwin and linux
for Codex, Claude, Cursor, OpenCode and Claude in WSL, command, args
and env; TestCmdVarsUserProfileLaunch starts a real server by
%USERPROFILE%<sep>prog, %HOME%/prog and $USERPROFILE/prog.
TestCmdVarsPerAgent pins the Unix variable; TestCmdVarsSync expects
${USERPROFILE} in .claude.json on Windows.

Run: the red was checked on origin/main e0889719c's cmdvars.go,
mcp_check.go and mcp_run.go with these tests: all 8 subtests of
TestCmdVarsUserProfile and TestCmdVarsUserProfileLaunch FAIL; with the
change, ok on mote (darwin), on xiaomi-gpu (Windows 11, win-run: the
real check starts the server by %USERPROFILE%\prog, and Claude Code's
.claude.json gets ${USERPROFILE}/bin/x) and in WSL magpie-desktop
(wsl-run). Full suite at b84b6dc3c (this change on e0889719c) on mica
under suite.lock: gofmt -l clean, go vet, GOOS=linux go vet -tags
nogui, GOOS=windows go vet, the three builds, and go test -tags nogui
-count=1 -timeout 45m ./...: 99 packages ok, suite exit 0. Rebased onto
8df4239a8; internal/library run again there.
Not tried: a real agent (Claude Code, Codex) launching the server on
Windows from its written config; no GUI change.
2026-11-14 12:04:38 +08:00
..