mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 18:01:22 +00:00
docs: clarify SDK extension discovery and settings.json support
This commit is contained in:
parent
4a7e8672af
commit
3129e2ac10
2 changed files with 13 additions and 5 deletions
|
|
@ -468,12 +468,15 @@ Custom tools passed via `customTools` are combined with extension-registered too
|
|||
|
||||
### Extensions
|
||||
|
||||
Extensions are discovered from `~/.pi/agent/extensions/` and `.pi/extensions/`. You can also pass inline extensions or additional paths:
|
||||
By default, extensions are discovered from multiple locations:
|
||||
- `~/.pi/agent/extensions/` (global)
|
||||
- `.pi/extensions/` (project-local)
|
||||
- Paths listed in `settings.json` `"extensions"` array
|
||||
|
||||
```typescript
|
||||
import { createAgentSession, type ExtensionFactory } from "@mariozechner/pi-coding-agent";
|
||||
|
||||
// Inline extension
|
||||
// Inline extension factory
|
||||
const myExtension: ExtensionFactory = (pi) => {
|
||||
pi.on("tool_call", async (event, ctx) => {
|
||||
console.log(`Tool: ${event.toolName}`);
|
||||
|
|
@ -487,15 +490,20 @@ const myExtension: ExtensionFactory = (pi) => {
|
|||
});
|
||||
};
|
||||
|
||||
// Pass inline extensions (merged with discovery)
|
||||
// Pass inline extensions (skips file discovery)
|
||||
const { session } = await createAgentSession({
|
||||
extensions: [myExtension],
|
||||
});
|
||||
|
||||
// Or add paths to load (merged with discovery)
|
||||
// Add paths to load (merged with discovery)
|
||||
const { session } = await createAgentSession({
|
||||
additionalExtensionPaths: ["/path/to/my-extension.ts"],
|
||||
});
|
||||
|
||||
// Disable extension discovery entirely
|
||||
const { session } = await createAgentSession({
|
||||
extensions: [],
|
||||
});
|
||||
```
|
||||
|
||||
Extensions can register tools, subscribe to events, add commands, and more. See [extensions.md](extensions.md) for the full API.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue