Documentation
¶
Overview ¶
Package pi provides an Executor implementation for the pi CLI (npm: @mariozechner/pi-coding-agent), a deliberately minimal Claude Agent SDK-based coding harness with broad multi-provider reach.
pi emits NDJSON via `pi --mode json` — a different schema from Claude, Gemini, Codex, and opencode. See README.md and testdata/ for full schema documentation with fixture-backed examples.
Key parser facts (pi 0.70.x):
- Top-level events: session, agent_start, turn_start, message_start, message_update, message_end, tool_execution_start, tool_execution_end, turn_end, agent_end. agent_end is the unambiguous terminal event.
- Inside message_update, assistantMessageEvent.type ∈ {text_start, text_delta, text_end, thinking_start, thinking_delta, thinking_end, toolcall_start, toolcall_delta, toolcall_end}.
- Per-turn token deltas in message_end (role=assistant) — sum across turns for totals (similar pattern to opencode's step_finish).
- Cost reported directly in message_end.message.usage.cost.total — summed across turns rather than recomputed from token counts.
- Model string: "provider/id" shorthand (e.g. "anthropic/claude-haiku-4-5", "openai/gpt-5.4").
Index ¶
- func Register()
- type PiExecutor
- func (e *PiExecutor) Capabilities() []executor.Capability
- func (e *PiExecutor) Close() error
- func (e *PiExecutor) CostModel() *executor.CostModel
- func (e *PiExecutor) Execute(ctx context.Context, task *executor.Task) (*executor.Result, error)
- func (e *PiExecutor) ExecuteStreaming(ctx context.Context, task *executor.Task, handler executor.EventHandler) (*executor.Result, error)
- func (e *PiExecutor) HealthCheck(ctx context.Context) error
- func (e *PiExecutor) Name() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type PiExecutor ¶
type PiExecutor struct {
// contains filtered or unexported fields
}
PiExecutor executes tasks using the pi CLI.
func (*PiExecutor) Capabilities ¶
func (e *PiExecutor) Capabilities() []executor.Capability
Capabilities returns the list of features this executor supports.
func (*PiExecutor) Close ¶
func (e *PiExecutor) Close() error
Close releases any resources held by the executor.
func (*PiExecutor) CostModel ¶
func (e *PiExecutor) CostModel() *executor.CostModel
CostModel returns a placeholder cost model. Pi reports cost directly in message_end.usage.cost.total per turn; the executor sums those values into Result.CostUSD rather than recomputing from token counts.
func (*PiExecutor) ExecuteStreaming ¶
func (e *PiExecutor) ExecuteStreaming(ctx context.Context, task *executor.Task, handler executor.EventHandler) (*executor.Result, error)
ExecuteStreaming runs a task with real-time event callbacks, parsing the pi NDJSON stream into normalized executor events.
func (*PiExecutor) HealthCheck ¶
func (e *PiExecutor) HealthCheck(ctx context.Context) error
HealthCheck verifies the pi binary exists on PATH and responds.