pi-lazy-packages0.1.0
Opt-in lazy loading of pi package extensions: the prompt renders first, marked packages load after session_start.
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
pi-lazy-packages
Opt-in lazy loading of pi package extensions. The prompt renders first; packages listed in lazyPackages load after session_start, and the first agent turn waits for them. Nothing is lazy by default.
Design: docs/superpowers/specs/2026-12-03-lazy-packages-design.md.
Install
pi install npm:pi-lazy-packages
(A local checkout path in packages works the same way while developing.)
Config
~/.pi/agent/settings.json — two disjoint lists:
{
"packages": ["npm:pi-lazy-packages"],
"lazyPackages": ["npm:pi-lens", "npm:pi-transcript-ui", "npm:pi-subagents"]
}
packagesstays as-is (stringnpm:<name>entries, imported eagerly by pi). It only needs the loader's path; relative paths resolve from~/.pi/agent.lazyPackagesis the only requirement:npm:<name>sources, loaded from~/.pi/agent/npm/node_modules/<name>. A source in both lists is skipped with the warningalso in packages (remove it there or here).- Lazy packages stay installed because
~/.pi/agent/npm/package.jsonlists them — neverpi removethem. Update withnpm update <name> --cwd ~/.pi/agent/npm.
How it loads
- After
session_start: skipped entries are warned, then each package's extension entries are imported in listed order and itssession_starthandlers are replayed with the loader's event and ctx; skills, prompts and themes are handed to pi viaresources_discover. - First turn gated:
before_agent_startwaits for the load, so a prompt typed while loading waits and then runs with the lazy tools. - Footer shows
loading <names>…while loading, then clears;lazy packages loaded: <names>toast.
Known limits
- CLI flags of lazy packages (
--no-lens, …) are unknown at startup (Unknown option, exit 1); keyboard shortcuts of lazy packages are inert while the load runs (bound right aftersession_startresolves). - Their tools, commands and errors are attributed to
pi-lazy-packagesin/toolsand error lines. pi configandpi updatedo not see lazy packages: keep them installed, update them with npm.- POSIX paths only.
- The loader must stay a
.tsfile: pi's jiti rewritesimport()only in modules it transpiles.
Dev
npm install # devDependencies only
npm run typecheck
npm test
Verify
npm run typecheck && npm test
# exit 0, empty stderr:
pi --mode rpc --no-session --no-extensions -e "$PWD/index.ts" </dev/null
# must list pi-lazy-packages; must not list any lazyPackages entry:
PI_TIMING=1 pi --mode rpc --no-session </dev/null 2>&1 | grep -A40 'Startup Timings: extensions'
- Live session: footer shows
loading …then clears, the toast appears, nopi-lazy-packageswarning; a prompt typed before the load ends waits and its first turn can call the lazy tools;pi-lensskills still listed. - Render time:
createAgentSessionRuntimein thatPI_TIMING=1block is the proxy for first render (1174 ms with the loader vs 1815–2400 ms all-eager on 2026-12-03); the prompt is on screen within a few hundred ms of it, before thelazy packages loadedtoast.