fix(vim): keep extensions loadable when host pi-tui metadata is unresolvable - #1594
Conversation
…olvable Pi aliases only ES imports of host-provided packages. The module-level createRequire of @earendil-works/pi-tui/package.json walks node_modules from the extension directory, which a git install does not have since the host packages became peers, so gentle-shell and gentle-agents failed to load. An unresolvable host now leaves the imported TUI version unknown, which keeps the unverified identity gate closed; the verified runtime path from resolveVimRuntime is unchanged. Fixes Gentleman-Programming#1586
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe adapter now catches failures to resolve ChangesVim Adapter Host Resolution
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change prevents missing host metadata from aborting extension loading while retaining version verification. It is mergeable subject to normal CI checks. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 2 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The PR meets the runtime loading objective in [ Resolution Implement the coding requirements from [
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Reviewed and verified locally. This fixes the root cause, not just the symptom. Root cause: the module-level Correctness: an unresolved host leaves the version Evidence (macOS):
Minor, non-blocking: the Thanks @dnlrsls, great write-up and a clean, well-scoped fix. |
Linked issue
Closes #1586
Closes #1589
PR type
Summary
lib/vim-editor-adapter.tsread the TUI version at module load withcreateRequire(import.meta.url)("@earendil-works/pi-tui/package.json"). Pi's extension loader aliases only ESimportspecifiers of host-provided packages; a raw CommonJS require walksnode_modulesfrom the extension directory instead. Since14f77e68movedpi-tui/pi-aito optional peers (the manifest fix for bug(install): gentle-pi ships host-provided @earendil-works/pi-tui as a dependency, hoisting a duplicate 0.85.1 copy over the host 0.99.0 #1559 / bug(install): gentle-pi hard-depends on host-provided @earendil-works/pi-tui (and pi-ai on main), tripping the extension-loader warning and hoisting a stale duplicate #1564 / Warning del extension loader: @earendil-works/pi-tui debe ir en peerDependencies #1578), a git install has no extension-local copy, so the require throws and takes downgentle-shell.tsandgentle-agents.ts(both import the adapter).undefined. That keeps the unverified identity gate closed (Unsupported Pi editor layout/version, whichvimAdapter()already turns into the ordinary-editing compatibility notice). The verified path —resolveVimRuntime()proving the host agent/TUI pair and passingverifiedVersion— is unchanged, so Vim still works on the bundled 0.99.1 host.createRequireline unchanged.Review path
lib/vim-editor-adapter.ts(one guarded expression), thentests/vim-editor-adapter-host-resolution.test.ts.Changes
lib/vim-editor-adapter.tspi-tuimetadata in atry; unresolved → version unknown → unverified gate stays closed.tests/vim-editor-adapter-host-resolution.test.tsnode_modules, aliases only the ES@earendil-works/pi-tuispecifier (as Pi's loader does), and asserts the module loads, rejects an unverified editor and admits a verified one.Test plan
mainwithCannot find module '@earendil-works/pi-tui/package.json'and passes with the fix.git archivecopies withoutnode_modules,pi --mode rpc --offline --no-session -ne -e <copy>/extensions/gentle-shell.ts -e <copy>/extensions/gentle-agents.ts:mainprints bothFailed to load extension ... Cannot find module '@earendil-works/pi-tui/package.json'errors and exits 1; with the fix both extensions load and it exits 0.tests/vim-editor-adapter.test.ts,tests/vim-editor-adapter-host-resolution.test.ts,tests/gentle-shell.test.ts: 278/281 pass. The 3 failures (customize Vim reports a persistence error…,customize previews installed source palette…,registered canonical root governs real Git discovery…) reproduce with identical signatures on untouchedmainon this Windows machine.pnpm run typecheck: no regressions against the recorded baseline.vim-editor-adapterorpi-tuiresolution). With dev dependencies installed the require resolves exactly as before, so behavior only differs when it would previously have thrown. CI remains the gate.Contributor checklist
status:approved.type:bug).Summary by CodeRabbit
Bug Fixes
Tests