Commit graph

14 commits

Author SHA1 Message Date
Mario Zechner
6f7c10e323 Add setEditorText/getEditorText to hook UI context, improve custom() API
- Add setEditorText() and getEditorText() to HookUIContext for prompt generator pattern
- custom() now accepts async factories for fire-and-forget work
- Add CancellableLoader component to tui package
- Add BorderedLoader component for hooks with cancel UI
- Export HookAPI, HookContext, HookFactory from main package
- Update all examples to import from packages instead of relative paths
- Update hooks.md and custom-tools.md documentation

fixes #350
2026-01-01 00:04:56 +01:00
Mario Zechner
84b663276d Add creation hints to docs and update system prompt
- System prompt now instructs to read docs AND examples, follow cross-refs
- Each doc starts with 'pi can create X. Ask it to build one.'
2025-12-31 13:16:44 +01:00
Mario Zechner
20fbf40fac Add tui.md and improve TUI documentation
- New tui.md covers component system for hooks and custom tools
- Update hooks.md intro with 'Key capabilities' highlighting UI
- Update custom-tools.md intro with 'Key capabilities' highlighting UI
- Reference tui.md from both docs
2025-12-31 13:05:59 +01:00
Mario Zechner
19c4182c21 Reorder execute params: (toolCallId, params, onUpdate, ctx, signal?)
Optional signal now at the end for cleaner API
2025-12-31 12:14:28 +01:00
Mario Zechner
4c9c453646 Update CHANGELOG, README, and custom-tools.md for new CustomTool API
- Add custom tools API rework to CHANGELOG breaking changes
- Update docs/custom-tools.md with new types and signatures
- Update README quick example with correct execute signature
2025-12-31 12:10:37 +01:00
Mario Zechner
ff78ac2f84 Replace custom tool dispose() with shutdown session event
Breaking change: CustomAgentTool.dispose() removed. Use onSession with
reason 'shutdown' instead for cleanup.

- Add 'shutdown' to SessionEvent.reason for custom tools
- Remove dispose() method from CustomAgentTool interface
- Make emitToolSessionEvent() public on AgentSession
- Emit shutdown event to tools in InteractiveMode.shutdown()
- Update custom-tools.md with new API and examples
2025-12-31 02:55:45 +01:00
Mario Zechner
454ea1d36a Rename /clear to /new, update hook events to before_new/new
Closes #305 - took direct rename approach instead of alias system

Thanks @mitsuhiko for the nudge!
2025-12-25 04:15:10 +01:00
Aliou Diallo
7470dde1e9
docs: fix outdated custom tools paths and add missing header shortcut (#283)
* docs: fix custom tools example paths to use index.ts structure

* fix: add missing ctrl+g shortcut to startup header

* docs: fix /session -> /resume for session switching references
2025-12-23 03:29:31 +01:00
Mario Zechner
4fb3af93fb Refactor subagent tool, fix custom tool discovery, fix JSON mode stdout flush
Breaking changes:
- Custom tools now require index.ts entry point in subdirectory
  (e.g., tools/mytool/index.ts instead of tools/mytool.ts)

Subagent tool improvements:
- Refactored to use Message[] from ai package instead of custom types
- Extracted agent discovery to separate agents.ts module
- Added parallel mode streaming (shows progress from all tasks)
- Added turn count to usage stats footer
- Removed redundant Query section from scout output

Fixes:
- JSON mode stdout flush: Fixed race condition where pi --mode json
  could exit before all output was written, causing consumers to
  miss final events

Also:
- Added signal/timeout support to pi.exec() for custom tools and hooks
- Renamed pi-pods bin to avoid conflict with pi
2025-12-19 04:54:02 +01:00
Mario Zechner
3424550d21 Improve documentation: README settings table, philosophy section, custom-tools intro, rpc hook_error event, hooks import aliases 2025-12-17 22:04:28 +01:00
Mario Zechner
ed8ee03e22 Add available imports section to custom tools docs 2025-12-17 16:41:55 +01:00
Mario Zechner
909989066a Fix TUI performance regression: add caching to Box, use Text directly for built-in tools 2025-12-17 16:39:23 +01:00
Mario Zechner
aedce30618 Re-export Type from typebox, update examples to import from pi-coding-agent 2025-12-17 16:10:01 +01:00
Mario Zechner
e7097d911a Custom tools with session lifecycle, examples for hooks and tools
- Custom tools: TypeScript modules that extend pi with new tools
  - Custom TUI rendering via renderCall/renderResult
  - User interaction via pi.ui (select, confirm, input, notify)
  - Session lifecycle via onSession callback for state reconstruction
  - Examples: todo.ts, question.ts, hello.ts

- Hook examples: permission-gate, git-checkpoint, protected-paths

- Session lifecycle centralized in AgentSession
  - Works across all modes (interactive, print, RPC)
  - Unified session event for hooks (replaces session_start/session_switch)

- Box component added to pi-tui

- Examples bundled in npm and binary releases

Fixes #190
2025-12-17 16:03:23 +01:00