Extensions are TypeScript modules that can subscribe to agent lifecycle events, register LLM-callable tools, register commands/keyboard shortcuts/CLI flags, and interact with the user via UI primitives — capabilities defined in packages/coding-agent/src/core/extensions/types.ts.[1] Extensions are loaded via jiti, so TypeScript works without compilation.[2] packages/coding-agent/src/core/extensions/index.ts is the single public barrel for the extension system, re-exporting all event types, context types, tool helpers, loader functions, and the ExtensionRunner from their respective implementation files — see Extension API and lifecycle for the full public API surface.[3]
Place extensions in ~/.prime/agent/extensions/ (global) or .prime/agent/extensions/ (project-local) for auto-discovery; only extensions in these locations can be hot-reloaded with /reload.[2] The -e ./path.ts flag loads an extension directly and is intended for quick tests only.[2]
For extensions with npm dependencies, place a package.json with a "pi": { "extensions": ["./src/index.ts"] } field next to the extension and run npm install; imports from node_modules/ are resolved automatically.[2] For extensions distributed as Prime Agent packages (installed via prime-agent package install), runtime dependencies must be in dependencies rather than devDependencies, because installation uses npm install --omit=dev by default.[2] Available imports for extensions include @earendil-works/pi-coding-agent (types: ExtensionAPI, ExtensionContext, and events), typebox (tool parameter schemas), @earendil-works/pi-ai (StringEnum for Google-compatible enums), @earendil-works/pi-tui (TUI components for custom rendering), and Node.js built-ins such as node:fs and node:path.[2]
Extensions run with the user's full system permissions and can execute arbitrary code — only install extensions from sources you trust.[2]
Sources