pi-worktrees/findings.md
David Kong 618288aa79 Create extension file structure with tool scaffolding
- Add .pi/extensions/pi-worktree.ts with correct imports and default export
- Define WorktreeEntry, WorktreeListResult, WorktreeError types
- Register 4 tools: create, list, switch, remove (stubs)
- Register /worktree command (stub)
- Add helper function stubs: parseWorktreeList, pathExists, resolveWorktreeTarget
- Uses defineTool() and Type from pi SDK for type-safe registration
2026-07-24 18:16:00 +10:00

40 lines
2 KiB
Markdown

# Findings — Issue #1: Create Extension File Structure
## Git Workflow
- Branch: `issue-1` (based on origin/main)
- Remote: `https://git.excelera.net/david/pi-worktrees.git`
- Tool: `fj` CLI for Forgejo issues (auto-detected from git remote)
- PR: Will use `fj pr create` when complete
## Project Context
- **Extension location**: `.pi/extensions/pi-worktree.ts`
- **Pattern**: Single-file extension with default export function
- **API imports**: `@earendil-works/pi-coding-agent` (ExtensionAPI, ExtensionContext)
- **Schema library**: TypeBox (`typebox`) for tool parameter schemas
- **No npm dependencies** beyond what pi provides
## Validation Approach
This project has no traditional test suite. Validation is:
1. File exists at `.pi/extensions/pi-worktree.ts`
2. Correct imports from `@earendil-works/pi-coding-agent` and `typebox`
3. Follows single-file extension pattern (default export function)
4. pi loads without errors via `/reload` or restart
## Issue #1 Acceptance Criteria
- [ ] `.pi/extensions/pi-worktree.ts` exists
- [ ] Correct imports from `@earendil-works/pi-coding-agent` and `typebox`
- [ ] Extension loads without errors when pi starts
- [ ] Follows the single-file extension pattern with default export function
## Related Files (from main branch)
| File | Purpose |
|------|---------|
| `README.md` | User-facing docs — describes 4 tools + `/worktree` command |
| `DESIGN.md` | Architecture decisions for the extension |
| `DOMAIN.md` | Git worktree domain concepts and terminology |
| `AGENTS.md` | Agent conventions, repo details, fj CLI usage |
## Session Discoveries
- **TypeBox import**: Use `{ Type } from "@earendil-works/pi-ai"` (re-exported) rather than direct `typebox` import — matches pi's extension examples.
- **Tool definition helper**: Use `defineTool()` from `@earendil-works/pi-coding-agent` for type-safe tool registration.
- **Validation command**: `bun build <file> --no-bundle --emit=metadata` compiles and validates TypeScript without bundling.