singularity-forge/docs/dev/extending-pi/05-extension-structure-styles.md
ace-pm b29c12d5e5 refactor(native): rename gsd_parser.rs to forge_parser.rs
Final rebrand: rename remaining Rust source file to complete the gsd → forge
transition. All parser references already use forge_parser after earlier commits.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 14:58:21 +02:00

54 lines
1.3 KiB
Markdown

# Extension Structure & Styles
### Single File (simplest)
```
~/.sf/agent/extensions/
└── my-extension.ts
```
### Directory with index.ts (multi-file)
```
~/.sf/agent/extensions/
└── my-extension/
├── index.ts # Entry point (must export default function)
├── tools.ts
└── utils.ts
```
### Package with Dependencies (npm packages needed)
```
~/.sf/agent/extensions/
└── my-extension/
├── package.json
├── package-lock.json
├── node_modules/
└── src/
└── index.ts
```
```json
// package.json
{
"name": "my-extension",
"dependencies": { "zod": "^3.0.0" },
"pi": { "extensions": ["./src/index.ts"] }
}
```
Run `npm install` in the extension directory. Imports from `node_modules/` resolve automatically.
### Available Imports
| Package | Purpose |
|---------|---------|
| `@mariozechner/pi-coding-agent` | Extension types (`ExtensionAPI`, `ExtensionContext`, event types, utilities) |
| `@sinclair/typebox` | Schema definitions for tool parameters (`Type.Object`, `Type.String`, etc.) |
| `@mariozechner/pi-ai` | AI utilities (`StringEnum` for Google-compatible enums) |
| `@mariozechner/pi-tui` | TUI components (`Text`, `Box`, `Container`, `SelectList`, etc.) |
| Node.js built-ins | `node:fs`, `node:path`, `node:child_process`, etc. |
---