pi

package
v0.65.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2026 License: BSD-2-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AgentStatusDone       = agentlib.AgentStatusDone
	AgentStatusFailed     = agentlib.AgentStatusFailed
	AgentStatusNeedsInput = agentlib.AgentStatusNeedsInput
)

Variables

This section is empty.

Functions

func BuildPrompt

func BuildPrompt(instructions string, envContext map[string]string, taskContent string) string

BuildPrompt combines instructions with environment context and task content.

func BuildResultSection

func BuildResultSection(r string) string

BuildResultSection renders a Result as a markdown section.

func NewStep

func NewStep(cfg StepConfig) agentlib.Step

NewStep wraps a single Pi invocation as an agentlib.Step.

func PrintResult

func PrintResult(ctx context.Context, result Result) error

PrintResult marshals a Result to JSON and prints to stdout.

Types

type AgentStatus

type AgentStatus = agentlib.AgentStatus

AgentStatus mirrors the shared agent status type.

type PiRunnerConfig

type PiRunnerConfig struct {
	// AgentDir is the working directory for the pi process. Pi's
	// context-file discovery walks AGENTS.md/CLAUDE.md from cwd toward /,
	// so place project guardrails as AGENTS.md inside this directory.
	// Pi's other config (settings, skills, sessions) is resolved via
	// $PI_CODING_AGENT_DIR or ~/.pi/agent/ and is independent of cwd.
	AgentDir string
	// AllowedTools is the comma-separated list of tool names to enable.
	AllowedTools string
	// Model selects the model (e.g. "MiniMax-M2.7-highspeed").
	Model string
	// Env holds extra KEY=VALUE entries appended to the subprocess environment.
	// Use for API keys, custom provider settings, etc.
	Env map[string]string
}

PiRunnerConfig holds configuration for spawning the Pi CLI.

type Result

type Result struct {
	Result string `json:"result"`
}

Result is the structured output from a Pi CLI run.

func (Result) GetResult

func (r Result) GetResult() string

type RunError

type RunError struct {
	Msg string
	Err error
}

RunError encapsulates a runner failure.

func (*RunError) Error

func (e *RunError) Error() string

func (*RunError) Unwrap

func (e *RunError) Unwrap() error

Unwrap exposes the underlying cause so callers can use errors.Is/As.

type Runner

type Runner interface {
	Run(ctx context.Context, prompt string) (*Result, error)
}

Runner spawns a headless Pi CLI session with a prompt and tools.

func NewRunner

func NewRunner(config PiRunnerConfig) Runner

NewRunner creates a Runner that spawns pi --print.

type StepConfig

type StepConfig struct {
	Name          string
	Runner        Runner
	Instructions  string
	EnvContext    map[string]string
	OutputSection string
	NextPhase     string
}

StepConfig bundles everything a Pi agent Step needs at construction time.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL