omp packages

pi-lazy-packages0.1.0

Opt-in lazy loading of pi package extensions: the prompt renders first, marked packages load after session_start.

aemonge Published 20 hours ago ~0 downloads/mo

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.

Did it work for you?

Result

One report per person. A new report replaces your old one.

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"]
}
  • packages stays as-is (string npm:<name> entries, imported eagerly by pi). It only needs the loader's path; relative paths resolve from ~/.pi/agent.
  • lazyPackages is the only requirement: npm:<name> sources, loaded from ~/.pi/agent/npm/node_modules/<name>. A source in both lists is skipped with the warning also in packages (remove it there or here).
  • Lazy packages stay installed because ~/.pi/agent/npm/package.json lists them — never pi remove them. Update with npm 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 its session_start handlers are replayed with the loader's event and ctx; skills, prompts and themes are handed to pi via resources_discover.
  • First turn gated: before_agent_start waits 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 after session_start resolves).
  • Their tools, commands and errors are attributed to pi-lazy-packages in /tools and error lines.
  • pi config and pi update do not see lazy packages: keep them installed, update them with npm.
  • POSIX paths only.
  • The loader must stay a .ts file: pi's jiti rewrites import() 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, no pi-lazy-packages warning; a prompt typed before the load ends waits and its first turn can call the lazy tools; pi-lens skills still listed.
  • Render time: createAgentSessionRuntime in that PI_TIMING=1 block 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 the lazy packages loaded toast.