Update custom tools README for subdirectory/index.ts structure

This commit is contained in:
Mario Zechner 2025-12-19 04:53:09 +01:00
parent a930eb8489
commit 48e792aa52

View file

@ -4,13 +4,15 @@ Example custom tools for pi-coding-agent.
## Examples
### hello.ts
Each example uses the `subdirectory/index.ts` structure required for tool discovery.
### hello/
Minimal example showing the basic structure of a custom tool.
### question.ts
### question/
Demonstrates `pi.ui.select()` for asking the user questions with options.
### todo.ts
### todo/
Full-featured example demonstrating:
- `onSession` for state reconstruction from session history
- Custom `renderCall` and `renderResult`
@ -19,7 +21,8 @@ Full-featured example demonstrating:
### subagent/
Delegate tasks to specialized subagents with isolated context windows. Includes:
- `subagent.ts` - The custom tool (single, parallel, and chain modes)
- `index.ts` - The custom tool (single, parallel, and chain modes)
- `agents.ts` - Agent discovery helper
- `agents/` - Sample agent definitions (scout, planner, reviewer, worker)
- `commands/` - Workflow presets (/implement, /scout-and-plan, /implement-and-review)
@ -28,11 +31,11 @@ See [subagent/README.md](subagent/README.md) for full documentation.
## Usage
```bash
# Test directly
pi --tool examples/custom-tools/todo.ts
# Test directly (can point to any .ts file)
pi --tool examples/custom-tools/todo/index.ts
# Or copy to tools directory for persistent use
cp todo.ts ~/.pi/agent/tools/
# Or copy entire folder to tools directory for persistent use
cp -r todo ~/.pi/agent/tools/
```
Then in pi: