Skip to content

crash: pi fails with missing @earendil-works/* after pi install git:... #1589

Description

@pablon

Problem

When running pi install git:github.com/Gentleman-Programming/gentle-shell@main, Pi fails to start with these errors:

Error: Failed to load extension ".../gentle-shell/extensions/gentle-agents.ts":
Failed to load extension: Cannot find module '@earendil-works/pi-tui/package.json'
Require stack:
- .../lib/vim-editor-adapter.ts

Root cause

pi install performs git fetch + git reset --hard (or git pull) which wipes node_modules/, but it does NOT run npm install.

@earendil-works/* were originally only optional peerDependencies, which npm does not install automatically. They are only transitively installed if another dependency's peer resolution happens to pull them in — but this is not guaranteed (especially in fresh clones or if the dep tree changes).

The code directly imports from these packages at runtime (e.g., vim-editor-adapter.ts line 1: `import { CURSOR_MARKER, Editor, visibleWidth } from "@earendil-works/pi-tui"``), making them hard runtime requirements, not optional peers.

Solution

Layered dependency strategy — the @earendil-works/* packages are now declared in three places:

  1. dependencies — ensures npm install (triggered by git hooks, CI, or manual setup) correctly installs them at runtime
  2. peerDependencies — preserves the runtime contract and existing test expectations
  3. devDependencies — for local development and testing
"dependencies": {
  "@earendil-works/pi-ai": "0.99.1",
  "@earendil-works/pi-coding-agent": "0.99.1",
  "@earendil-works/pi-tui": "0.99.1",
  "typebox": "^1.3.34"
},
"peerDependencies": {
  "@earendil-works/pi-ai": "*",
  "@earendil-works/pi-coding-agent": ">=0.99.1",
  "@earendil-works/pi-tui": "*"
},
"devDependencies": {
  "@earendil-works/pi-ai": "0.99.1",
  "@earendil-works/pi-coding-agent": "0.99.1",
  "@earendil-works/pi-tui": "0.99.1"
}

Note on typebox: The original ^0.37.0 was invalid — npm only publishes 1.x versions. Updated to ^1.3.34.

PR

Fix in progress: #1588 (layered dependency strategy with 3 commits)

Activity

  1. dnlrsls commented on Sep 30, 2026

    @dnlrsls
    Member

    This is the same crash as #1586, which is the root issue (the createRequire of host pi-tui metadata in lib/vim-editor-adapter.ts bypasses Pi's import alias). Proposed fix: #1594.

    Note on the proposed fix in #1588: re-adding @earendil-works/* to dependencies would restore the extension-local host copies that #1559 / #1564 report (loader warning + duplicate runtime modules). #1594 removes the need for a local copy instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions