mirror of
https://github.com/earendil-works/pi.git
synced 2026-10-29 18:22:54 +08:00
- ai: StreamingJsonParser / ToolCallArgumentsStream read each argument delta once (tolerant, immutable snapshots, linear cost); every provider, pi-messages and the faux provider use it and keep stream state (partialJson, partialArgs, index, customInput, streamIndex, Bedrock reasoning bytes) off the content blocks; grammar tool input appends per delta - agent: streamProxy uses the same parser - chord: Delta append ops own their text (ownedSlice), so ops and replicas no longer keep the whole growing string alive - durable, ai, mcp: bounded error excerpts and summaries own their characters - coding-agent: tool calls render streamed arguments once per frame, not once per delta
Examples
Example code for the pi-coding-agent SDK, process integration, and extensions.
CLI integration
rpc-client.ts uses the typed RpcClient to run Pi in a child process, stream events, and wait for the run to settle.
Build the coding-agent package before running it from a repository checkout:
node examples/rpc-client.ts "Explain this repository"
Directories
sdk/
Programmatic usage via createAgentSession(). Shows how to customize models, prompts, tools, extensions, and session management.
extensions/
Example extensions demonstrating:
- Lifecycle event handlers (tool interception, safety gates, context modifications)
- Custom tools (todo lists, questions, subagents, output truncation)
- Commands and keyboard shortcuts
- Custom UI (footers, headers, editors, overlays)
- Git integration (checkpoints, auto-commit)
- System prompt modifications and custom compaction
- External integrations (SSH, file watchers, system theme sync)
- Custom providers (Anthropic with custom streaming, GitLab Duo)