repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

extensions/AGENTS.md

Raw

Pi Extensions Workspace

New extension

  1. extensions/{name}/package.json — template below
  2. extensions/{name}/index.ts
  3. bun install

package.json

{
  "name": "@bugabinga/pi-ext-{name}",
  "version": "0.0.0",
  "private": true,
  "type": "module",
  "main": "index.ts",
  "peerDependencies": {
    "@earendil-works/pi-coding-agent": "*"
  }
}

Add only deps actually imported by the extension. Prefer peerDependencies for Pi packages (@earendil-works/*). Run bun install after any structural change.

Mandatory test harness

Independence

Startup

Checks

Commands

Documentation

Imports

Package Provides Use
@earendil-works/pi-coding-agent SDK — ExtensionAPI, types, ctx Always (peer dep)
@earendil-works/pi-tui TUI components, truncateToWidth, Key Rendering
@bugabinga/pi-ext-* — **Never
import
from
other
extensions**
Markdown source
File outline
# Pi Extensions Workspace

## New extension

1. `extensions/{name}/package.json` — template below
2. `extensions/{name}/index.ts`
3. `bun install`

## package.json

```json
{
  "name": "@bugabinga/pi-ext-{name}",
  "version": "0.0.0",
  "private": true,
  "type": "module",
  "main": "index.ts",
  "peerDependencies": {
    "@earendil-works/pi-coding-agent": "*"
  }
}
```

Add only deps actually imported by the extension.
Prefer `peerDependencies` for Pi packages (`@earendil-works/*`).
Run `bun install` after any structural change.

## Mandatory test harness

- Every extension must dev-depend on `@marcfargas/pi-test-harness`.
- Every extension must include a pi-test-harness test that loads `index.ts`
  through the real Pi extension runtime.
- Add `test:harness`:
  `bun test ./__tests__/harness.test.ts`.
- If no `test` script exists, add `test`:
  `bun test ./__tests__/*.test.ts`.

## Independence

- Extensions must be standalone packages.
- Never import from another `@bugabinga/pi-ext-*` package.
- Optional integration must be capability/event based and degrade cleanly.
- If behavior is important, provide a native fallback; decorative integration
  may no-op.

## Startup

- `session_start` must be fast.
- No awaited network, git, FS scans, or subprocesses.
- Publish minimal UI now; defer slow work with bg task + generation/stale guard.
- Never block other extensions for telemetry, recovery, decoration, or cache
  warming.

## Checks

- Source of truth:
  `mise.toml` → `scripts/extensions.py`.
- Run `mise run build -- [{name}]` before sharing or extracting an extension.
- `mise run build` = static checks + build.
- `mise run test` = pi-test-harness.
- `mise run changelog -- {name}` = ephemeral Pi agent writes a changelog section
  after reading git commits + extension source.
- `mise run publish -- {name}` = ci + demos + agent changelog + commit + tag +
  push.
- Publish is git-only.
  No npm registry flow.
- License is MIT.

## Commands

- Commands with subcommands must provide argument autocomplete.

## Documentation

- READMEs must be terse.
- Do not duplicate source-of-truth docs/config/API details.
- Link to canonical source files, commands, settings, or upstream docs instead.
- Package README should answer:
  what, install/load, commands/tools, settings link, optional integrations.

## Imports

| Package                           | Provides                             | Use               |
| --------------------------------- | ------------------------------------ | ----------------- |
| `@earendil-works/pi-coding-agent` | SDK — ExtensionAPI, types, ctx       | Always (peer dep) |
| `@earendil-works/pi-tui`          | TUI components, truncateToWidth, Key | Rendering         |
| `@bugabinga/pi-ext-*`             | —                                    | **Never           |
| import                            |                                      |                   |
| from                              |                                      |                   |
| other                             |                                      |                   |
| extensions**                      |                                      |                   |