fix(pi-ext): stop importing @earendil-works/pi-ai at runtime #105
Reference in New Issue
Block a user
Delete Branch "fix/pi-ext-module-resolution"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The pi extension failed to load outright on older pi installs:
Root cause
pi doesn't resolve an extension's bare specifiers the ordinary way — it hands jiti a hard-coded alias table built from its own dependencies, and that table differs between pi distributions:
@earendil-works/pi-coding-agent0.84.1@earendil-works/*and legacy@mariozechner/*@mariozechner/pi-coding-agent0.73.1@mariozechner/*onlyNeither resolves the other's namespace, so one import outside the intersection takes the whole extension down — every tool, the
/mcpctlcommand, the status line.Fix
The only thing we used from pi-ai was
StringEnum, a six-line wrapper overType.Unsafe. Inlined as a localstringEnumwith byte-identical output, sotypebox— aliased by every published pi — is now the sole bare runtime import. The call site also passesdescriptionthrough, which the pi-ai version was silently dropping.Guarded in
tests/config/pi-extension-embed.test.ts: any runtime import in the embedded sources that isn'tnode:, relative, or typebox now fails the build. Confirmed the guard flags the old source.Verification
Same active project, both installs:
mc_sre_begin_sessionmc_sre_begin_sessionstringEnumoutput compared against pi-ai'sStringEnum: identical JSON, with and without a descriptiontypecheck:pi-extclean; 700 CLI tests pass; lint unchanged from themainbaselineDocs updated with the constraint and a
type -a pipointer for the two-installs-on-PATH case.🤖 Generated with Claude Code
https://claude.ai/code/session_014tsRTqhEC7YYYYaP3cBqo8