publish.yml has been red on main since 7ebab07c (run 43011771755, and
43012668584, 43012789287 after it): 4 of gumloop's regression tests
failed with `Executable not found in $PATH: "node"`, so dist and npm
were skipped and gumloop 0.1.0 and agy-cli 0.1.19 reached neither.
Cause: bun test runs every file of the root run in one process.
packages/grok/nocli.mjs sets PATH=/usr/bin:/bin (and HOME, USERPROFILE,
GROK_HOME, GROK_BIN_DIR) for grok's files and never put them back, so
every file after grok's ran with that PATH. On ubuntu CI node is
actions/setup-node's, under /opt/hostedtoolcache, so gumloop's
spawn("node") found none whenever bun ran grok's files before
gumloop's (CI's order). Locally bun ran gumloop first, so it passed.
Change:
- grok/nocli.mjs: the first noRealGrok of a file snapshots process.env
and registers an afterAll that puts it back, removing what was added.
- gumloop/regression.test.mjs: node's absolute path is found once with
Bun.which at load and spawned by path; not found, the Node tests fail
as before (no skip).
- Siblings the same way (a file-level env change never put back), found
by a full-run env audit: chat/chat.test.mjs (XDG_CONFIG_HOME pointing
at its deleted temp dir, MAGPIE_API_KEY/GATEWAY_KEY/ADDR deleted) and
cursor/calls.test.mjs (XDG_DATA_HOME) now restore them in afterAll.
window-warmup's fake-gateway.ts/scheduler.test.ts XDG pins are left,
filed as #996 (fake-gateway is also the --serve demo's).
Other PATH writers (devin, gcp-ai, grok's own tests, sap-aicore,
agy-cli, layerfs) already restore theirs; the audit saw PATH change
only at grok's files.
Ran (magpie-desktop WSL, node only in ~/sdk/node/bin, bun 1.4.2):
- Red first, origin/main: `bun test --randomize --seed=3` (and 5) on
grok/loop-check + gumloop/regression: the 4 CI failures, same error;
also with --preload ./packages/grok/nocli.mjs.
- Same seeds with this change: 95 pass 0 fail (new gumloop test plus
origin/main's copy of it).
- Broken by hand: afterAll(putBack) commented out -> both seeds red
again, 4 fail.
- Root `HOME=$(mktemp -d) bun test` (with an env-audit preload): 8298
pass, 19 skip, 0 fail, 8317 tests, 584 files; PATH back to the start
value at the first file after grok's.
- Touched packages (chat, cursor, grok, gumloop, qoder) after the
chat/cursor change: 1117 pass 0 fail, each XDG value back to start.
Not tried: ubuntu CI itself before pushing (publish.yml runs it next);
Windows (nocli sets PATH empty there, restored the same way).
magpie's Usage page counts only what went through magpie, so Cursor's
editor and cursor-agent use was missing ("求支持统计cursor的使用情况").
auth.calls reads GetFilteredUsageEvents page by page from the time magpie
asks for and gives each of the account's own events: id, time, model,
tokens (input uncached; cache read/write apart), cost (totalCents / 100)
and conversation. A team's other members (owningUser vs GetMe's userId)
and the conversations this plugin ran itself (kept 40 days in
$XDG_DATA_HOME/opencode-cursor-auth/conversations.json, written
temp-and-rename) are left out. A refused page fails the reading.
Run: bun test in packages/cursor on mote (410 pass), scripts/check.mjs.
calls.test.mjs's fixtures carry the field names of a real Pro account's
reply. Real account: the hook read 43 events (30 days) from the owner's
Cursor sign-in, tokens and costs as the dashboard has them.
Broken by hand: without the own-conversation and owningUser filters the
first calls test goes red.
Not tried: a team account with other members; Cursor's editor (none
installed here), so an editor event's shape is taken as the same.