Command tests write outside their temp directory on Windows

Summary

On Windows, parts of the command test suite write into the working tree and into the developer's real home directory instead of the temp directory the tests set up. Running go test ./... on a checkout leaves files behind, and one test creates a real ~/.agents/skills/glab/SKILL.md.

Two independent causes.

Environment

  • OS: Windows 11 - AMD64
  • SHELL: bash
  • TERM: Windows Terminal
  • GLAB: built from main at 411aa39d (also present in v1.109.0)

Steps to reproduce

  1. On Windows, run go test ./... from a clean checkout.
  2. git status in the checkout.
  3. Look at %USERPROFILE%\.agents\skills\glab\SKILL.md.

What is the current bug behavior?

Backslashes are eaten before the command ever runs. cmdtest's exec helper puts the command line through shlex.Split, which treats a backslash as an escape character. A path from t.TempDir() such as C:\Users\...\Temp\TestFoo123\001 arrives at the command as C:Users...TempTestFoo123001, which is a relative path, so the command writes into the working tree rather than the temp directory.

HOME is not the home directory on Windows. TestNewCmdInstall_GlobalFlag and the --global case in the orbit setup tests set only HOME, but os.UserHomeDir reads USERPROFILE on Windows. The tests therefore resolve to the real home directory and write a genuine ~/.agents/skills/glab/SKILL.md.

What is the expected correct behavior?

Tests should stay inside the temp directory they create, on every supported platform, and must never write into the developer's home directory.

Possible fixes

Pass temp paths through filepath.ToSlash before they reach shlex.Split, and set both HOME and USERPROFILE when a test needs to relocate the home directory. config_file_test.go already documents the second convention.