Files
yetone f230fa23b0 plugin tests: TestPiPackage runs on a pi pinned by a bun.lock, not npm's latest that minute (#1879)
TestPiPackage installed pi the way ensurePi does, `bun add
@earendil-works/pi-coding-agent` at npm's latest, so it ran on whatever
pi's packages were that minute. pi-codemode 1.2.0 (2026-10-12 23:00:01Z)
dropped MCP_TYPESCRIPT_PREAMBLE and mcpStructuredContentSchema, which
pi-coding-agent 1.0.x and 1.1.0 import from it; their ^1.x range takes
1.2.0. pi-coding-agent 1.2.0 (no longer importing them) came out at
23:03:25Z. A full run that reached TestPiPackage in between got
pi-coding-agent 1.1.0 + pi-codemode 1.2.0 and pi didn't load; the run
alone came after. Nothing is shared between tests here (each has its
own plugins folder, and bunCommand puts Bun's cache under the test's
HOME), so "only in the full run" was the clock, not the suite.

The test now writes testdata/pi-lock's package.json and bun.lock (pi
1.2.0, every package at its npm integrity) into the plugins folder and
runs `bun install --frozen-lockfile`; Add then finds pi there. The
"pi is installed with a pi package" half moves to TestEnsurePi, with bun
stubbed: installed once for a pi package, not again with pi there, not
for an OpenCode plugin. The BUN_INSTALL_CACHE_DIR the test set did
nothing (bunCommand sets its own after it) and is gone.

Users: magpie installs pi at latest (1.2.0 with 1.2.0 now), and bun
keeps a plugins folder's lock when other plugins are added, so a folder
installed before the 1.2.0 release keeps 1.1.0 with 1.1.0. Only a pi
install that resolved in those ~3-8 minutes (CDN metadata cache) got the
broken pair. No magpie change.

Run:
- with the lock swapped for pi-coding-agent 1.1.0 (codemode resolved to
  1.2.0): TestPiPackage fails with the issue's exact "Export named
  'MCP_TYPESCRIPT_PREAMBLE' not found"; with 1.1.0 + codemode 1.1.0 and
  with the 1.2.0 lock committed it passes
- TestEnsurePi fails with ensurePi's "pi is there" check removed
- go test ./internal/plugin/ -count=1 three times: ok (140s, 121s, 112s)
- go test ./internal/plugin/ -run 'TestPiPackage|TestEnsurePi' -count=5: ok
- go test -tags nogui ./internal/...: ok
- gofmt -l; go vet darwin, linux -tags nogui, windows: clean
2026-10-13 07:39:46 +08:00
..