On Windows with Node managed by mise, the Agents page read "无法判断安装方式"
for an agent installed with npm install -g. howInstalled decided from the
binary's path, and a mise shim leads nowhere near node_modules: on a Mac
or Linux it is a symlink to the mise binary; on Windows a copy of
mise-shim.exe (exe mode, the default), a .cmd plus a bash script running
`mise x --` (file), or a hard or symbolic link to mise.exe.
A shim is now recognised (a link to mise, or a file in mise's shims
folder: parent "mise", a .mode file, or MISE_DATA_DIR/shims) and mise is
asked which program it runs, `mise which <cmd>` from the home folder; how
it was installed is read from that program. On Windows mise names npm's
extensionless sh script, so the .cmd beside it is used. The update runs
that Node version's own npm with --prefix, then `mise reshim`: on Windows
npm install -g makes no shim for a new command (seen on the box), mise's
Unix npm wrapper reshims itself, so it is harmless there.
Siblings:
- asdf shims (scripts with "# asdf-plugin:" and `exec asdf exec`) are
asked with `asdf which` the same way; asdf-nodejs's npm reshims itself
and asdf has no Windows build.
- proc.UserBinDirs on Windows also looks in mise's shims folder
(MISE_DATA_DIR, else XDG_DATA_HOME\mise, which mise follows on Windows,
else %LOCALAPPDATA%\mise) for an agent PATH doesn't reach.
- Install side: npmIn accepts npm.exe beside node as well as npm.cmd.
- WSL agents get no update path (CLI skips them) and wsl.go's probe
already lists mise/asdf shims: unchanged.
- MISE_DATA_DIR and ASDF_DIR join agentenv.Vars, so a test sandbox
clears them (TestFolderVarsAreListed).
Fixtures are real bytes: internal/agent/testdata/mise-windows from mise
2026.10.7 on the Windows box (file-mode snow.cmd and snow, .mode files,
npm's snow.cmd/snow in the Node folder); the Mac layout and the asdf
shim's text from mise 2026.10.7 and asdf 0.20.2 release binaries in a
sandbox home.
Run:
- flp's own layout (where.exe claude: installs\node\24.20.0\claude,
claude.cmd, shims\claude.exe; mise which claude names the extensionless
script): TestMiseShimWindowsFiveAgents covers claude, pi, codex,
opencode and codebuddy through shims\<cmd>.exe; run on the Windows box,
red with the fix removed by hand, green restored.
- go test -tags nogui ./internal/agent ./internal/proc -run
'Shim|HowInstalled|UpdateCLI|NpmIn|InstalledVersion'; with installedAt
skipping the shim by hand TestMiseShimIsNodesNpm,
TestUpdateCLIThroughMiseShim and TestAsdfShimIsNodesNpm go red, green
again restored.
- Real mise on the Mac (sandbox home, mise 2026.10.7, node 22.23.3,
snow-ai): detection through the real shim and `mise which`, and a real
update 0.9.1 -> 0.9.2 through UpdateCLI.
- Real mise on Windows (the box, sandbox USERPROFILE/LOCALAPPDATA, mise
2026.10.7, node 22.23.3, snow-ai): the Windows test binary's unit tests
(TestMiseShimWindows, TestHowInstalledWindowsShim, TestNpmIn) pass;
a temporary test through the real shim in exe, file and hardlink modes
found npm.cmd --prefix <node>, version 0.9.2; after npm install -g
snow-ai@0.9.1 a real UpdateCLI took it to 0.9.2 and reshimmed; snow.exe
ran 0.9.2. Symlink mode was not tried (needs developer mode); it is
the link-to-mise case the Mac covers. flp's own machine was not tried.
- go test -tags nogui -timeout 40m ./...; gofmt -l; GOOS=linux and
GOOS=windows go vet -tags nogui ./...