Developing pi Packages
Core Principle
A pi package is an npm/git package with a pi manifest declaring resources. The contract lives in the local docs — re-read it before structural changes; this skill is the checklist, not the spec.
When to Use / NOT
- Use when: creating or modifying a pi package (extensions, skills, prompts, themes); wiring
package.jsonfor pi; testing withpi -e/pi install; publishing. - NOT when: building non-package npm libraries; pi CLI core development (repo, not package).
Workflow
- Re-read the spec: open the local docs file (References) — it is authoritative and versioned with the installed pi.
- Manifest: add a
pikey topackage.json—"extensions","skills","prompts","themes"arrays, relative to package root, globs and!exclusionsallowed. No manifest? Conventional dirs (extensions/,skills/,prompts/,themes/) are auto-discovered. - Discoverability: include
"pi-package"inkeywords(gallery: pi.dev/packages). Optionalpi.video(MP4) /pi.image(PNG/JPEG/GIF/WebP) preview fields; video wins if both. - Dependencies rule (the common mistake):
- Third-party runtime deps →
dependencies(pi runsnpm installon package install). - Core pi packages —
@earendil-works/pi-ai,@earendil-works/pi-agent-core,@earendil-works/pi-coding-agent,@earendil-works/pi-tui,typebox— import freely but list inpeerDependencieswith"*"and never bundle them. - Other pi packages →
dependencies+bundledDependencies, reference vianode_modules/<pkg>/...paths.
- Third-party runtime deps →
- Dev loop:
pi -e /abs/path/to/pkgloads a one-off without installing;pi install <source>persists (user vs-lproject settings);pi configtoggles resources;pi listshows installs. - Stop condition: manifest valid, keyword set, dependency tiers correct, package loads via
pi -e.
Red Flags
- HARD-GATE: never put core pi packages (
pi-ai,pi-agent-core,pi-coding-agent,pi-tui,typebox) independenciesor bundle them —peerDependencieswith"*"only. - Do not ship resources outside
files/the tarball — an extension importing a file npm did not pack breaks on install. - Dot-prefixed resources are not glob-discovered; list them directly in the manifest.
- Pinning a git source ref is intentional (
pi updatenever moves it); usepi install git:host/user/repo@new-refto move it. - Settings filters (object form) only narrow what the manifest allows — they cannot add resources.
Verification
bun -escript asserting:pimanifest present,pi-packagekeyword, entry files exist, core packages inpeerDependencieswith"*"and absent fromdependencies,filescomplete.- Load the package:
pi -e <path>and exercise the extension in a session.
References
~/.bun/install/global/node_modules/@earendil-works/pi-coding-agent/docs/packages.md— the spec (mirrors https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/packages.md).~/.bun/install/global/node_modules/@earendil-works/pi-coding-agent/docs/extensions.md— extension API surface.