pigo

module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT

README

pigo

A faithful, slim, pure-Go port of Mario Zechner's MIT-licensed pi coding agent, built by Ordalie as an SDK-first Go module and a single static CLI binary. Byte-compatible with upstream pi's session format, wire protocols, config files, and extension examples at the pinned upstream version in UPSTREAM.lock; every divergence is recorded in docs/DECISIONS.md. The pigo binary deliberately coexists with upstream's pi; this module is unrelated to the older github.com/dimetron/pi-go project.

Install

curl -fsSL https://raw.githubusercontent.com/OrdalieTech/pigo/main/scripts/install.sh | sh

This installs pigo to ~/.local/bin after verifying the release checksum. Override the directory with PIGO_INSTALL_DIR; alternatively, with Go ≥ 1.26.5:

go install github.com/OrdalieTech/pigo/cmd/pigo@latest

Update

Run pigo update. It never replaces its running binary; it prints the exact installer or Go command for your installation, while pigo update --extensions updates installed pi packages.

First session

export OPENAI_API_KEY=sk-...          # or ANTHROPIC_API_KEY, or run `pigo login`
pigo                                  # interactive TUI
pigo -p "explain this repository"    # headless print mode

Sessions are plain JSONL, interchangeable with upstream pi: a session written by pigo opens in TS pi and vice versa. pigo --mode rpc speaks upstream's RPC protocol; upstream's own RPC test suite runs unmodified against it.

Embed the SDK

import "github.com/OrdalieTech/pigo/codingagent"

result, err := codingagent.NewAgentSession(codingagent.AgentSessionOptions{})
if err != nil { log.Fatal(err) }
defer result.Session.Dispose()
result.Session.Prompt(context.Background(), "list the files here")

Thirteen runnable examples live in codingagent/examples, from a minimal session to custom tools, providers, and session runtimes — 01_minimal runs offline against the bundled faux provider.

Run an upstream extension

pigo executes many upstream TypeScript extensions unmodified in an embedded JS runtime. Fetch the pirate example from the pinned upstream revision and load it:

curl -fsSLO https://raw.githubusercontent.com/earendil-works/pi/20be4b18d4c57487f8993d2762bace129f0cf7c6/packages/coding-agent/examples/extensions/pirate.ts
pigo --extension ./pirate.ts

Run /pirate in the TUI to exercise the extension.

61 of upstream's 69 single-file examples run as-is. In a locked snapshot of the 44 most-downloaded valid Pi packages, 24 load stably in both runtimes and 20 expose exactly the same observed tools and commands; six of seven safe command handlers and Piolium's real knowledge-base workflow also match. See the ecosystem matrix, the example matrix, and the bridge guide for the exact package-by-package result and remaining runtime ceilings. .pi/extensions/ in a trusted project and the global agent directory are discovered like upstream.

Provenance

Upstream pi is © Mario Zechner, MIT — this port tracks the exact commit in UPSTREAM.lock and regenerates its conformance goldens from upstream source (make fixtures-check). pigo is MIT too; see LICENSE, CONTRIBUTING.md, and SECURITY.md.

Every GitHub release includes a checksummed pigo_<version>_source.tar.gz. To verify that source independently, download it with checksums.txt, run sha256sum -c checksums.txt, extract it, and run CGO_ENABLED=0 go build -buildvcs=false ./cmd/pigo; release CI performs the same rebuild before publishing. The flag is required because a source archive intentionally contains no .git metadata.

Directories

Path Synopsis
ai
Package ai provides pi's provider-neutral message and streaming contracts.
Package ai provides pi's provider-neutral message and streaming contracts.
api
models
Package models contains the generated model catalog and its persisted refresh overlay.
Package models contains the generated model catalog and its persisted refresh overlay.
models/internal/cataloggen
Package cataloggen normalizes the models.dev api.json shape into pi models.
Package cataloggen normalizes the models.dev api.json shape into pi models.
providers/faux
Package faux provides a scripted, in-memory provider for agent and provider tests.
Package faux provides a scripted, in-memory provider for agent and provider tests.
Package chat implements the core of the pigo chat gateway (D27): platform-agnostic messages, the synchronous turn processor with its durable turn ledger, a preview coalescer, and a local single-process runner with a durable spool.
Package chat implements the core of the pigo chat gateway (D27): platform-agnostic messages, the synchronous turn processor with its durable turn ledger, a preview coalescer, and a local single-process runner with a durable spool.
discord
Package discord implements the Discord adapter for the pigo chat gateway: Gateway (WebSocket) ingress over the internal RFC 6455 client — hello/heartbeat/identify, READY capture, resume-first reconnects — plus REST delivery with a refreshed typing indicator, streamed preview edits, chunked finalization with mass-mention suppression, and pre-signed attachment download.
Package discord implements the Discord adapter for the pigo chat gateway: Gateway (WebSocket) ingress over the internal RFC 6455 client — hello/heartbeat/identify, READY capture, resume-first reconnects — plus REST delivery with a refreshed typing indicator, streamed preview edits, chunked finalization with mass-mention suppression, and pre-signed attachment download.
examples/localbot command
Command localbot runs a minimal Telegram chat gateway: long-poll ingress, the durable local spool, and per-conversation agent sessions under a local data directory.
Command localbot runs a minimal Telegram chat gateway: long-poll ingress, the durable local spool, and per-conversation agent sessions under a local data directory.
googlechat
Package googlechat implements the Google Chat adapter for the pigo chat gateway: an HTTP-endpoint Chat app with bearer-JWT-verified ingress, service-account authenticated delivery, and authenticated media download.
Package googlechat implements the Google Chat adapter for the pigo chat gateway: an HTTP-endpoint Chat app with bearer-JWT-verified ingress, service-account authenticated delivery, and authenticated media download.
internal/graphhook
Package graphhook holds the Meta Graph webhook plumbing shared by the Cloud API chat adapters (WhatsApp today, Messenger next): the one-time hub.challenge subscribe handshake and the X-Hub-Signature-256 raw-body HMAC check.
Package graphhook holds the Meta Graph webhook plumbing shared by the Cloud API chat adapters (WhatsApp today, Messenger next): the one-time hub.challenge subscribe handshake and the X-Hub-Signature-256 raw-body HMAC check.
internal/runechunk
Package runechunk splits platform text at readable rune boundaries.
Package runechunk splits platform text at readable rune boundaries.
internal/wsclient
Package wsclient implements a minimal RFC 6455 WebSocket client on the standard library alone: client role only, no extensions, no compression, no subprotocol negotiation.
Package wsclient implements a minimal RFC 6455 WebSocket client on the standard library alone: client role only, no extensions, no compression, no subprotocol negotiation.
messenger
Package messenger implements the Facebook Messenger (Meta Messenger Platform for Pages) adapter for the pigo chat gateway: webhook ingress over the Graph "page" object (hub handshake + HMAC-signed entry[].messaging[] events), final-message delivery via the Send API, sender-action typing, and direct-URL attachment download.
Package messenger implements the Facebook Messenger (Meta Messenger Platform for Pages) adapter for the pigo chat gateway: webhook ingress over the Graph "page" object (hub handshake + HMAC-signed entry[].messaging[] events), final-message delivery via the Send API, sender-action typing, and direct-URL attachment download.
slack
Package slack implements the Slack adapter for the pigo chat gateway: Events API ingress over HTTP (v0 request signing, url_verification handshake, echo filtering), Web API delivery with a bot token (streamed preview edits via chat.update, mrkdwn finalization with chunking), and authenticated file download.
Package slack implements the Slack adapter for the pigo chat gateway: Events API ingress over HTTP (v0 request signing, url_verification handshake, echo filtering), Web API delivery with a bot token (streamed preview edits via chat.update, mrkdwn finalization with chunking), and authenticated file download.
teams
Package teams implements the Microsoft Teams (Bot Framework) adapter for the pigo chat gateway, speaking the raw connector REST API with no SDK: JWT-validated webhook ingress, typing plus final-only delivery, markdown-subset formatting with UTF-16 chunking, and authenticated attachment download.
Package teams implements the Microsoft Teams (Bot Framework) adapter for the pigo chat gateway, speaking the raw connector REST API with no SDK: JWT-validated webhook ingress, typing plus final-only delivery, markdown-subset formatting with UTF-16 chunking, and authenticated attachment download.
telegram
Package telegram implements the Telegram Bot API adapter for the pigo chat gateway: ingress (webhook and long poll), delivery (typing indicator, streamed preview edits, HTML finalization with chunking), and media download.
Package telegram implements the Telegram Bot API adapter for the pigo chat gateway: ingress (webhook and long poll), delivery (typing indicator, streamed preview edits, HTML finalization with chunking), and media download.
whatsapp
Package whatsapp implements the WhatsApp Business Cloud API adapter for the pigo chat gateway: webhook ingress (hub handshake + HMAC-signed events), final-message delivery with reply threading, and authenticated media download.
Package whatsapp implements the WhatsApp Business Cloud API adapter for the pigo chat gateway: webhook ingress (hub handshake + HMAC-signed events), final-message delivery with reply threading, and authenticated media download.
cmd
pigo command
Package codingagent provides the high-level SDK for embedding pi's agent capabilities in Go programs.
Package codingagent provides the high-level SDK for embedding pi's agent capabilities in Go programs.
examples/01_minimal command
Minimal SDK usage with all defaults.
Minimal SDK usage with all defaults.
examples/02_custom_model command
Custom model selection and thinking level.
Custom model selection and thinking level.
examples/03_custom_prompt command
Custom system prompt replacement and extension through DefaultResourceLoader.
Custom system prompt replacement and extension through DefaultResourceLoader.
examples/04_skills command
Skills configuration through DefaultResourceLoader discovery and overrides.
Skills configuration through DefaultResourceLoader discovery and overrides.
examples/05_tools command
Tools configuration: tool allowlists and denylists.
Tools configuration: tool allowlists and denylists.
examples/06_extensions command
Extensions configuration through DefaultResourceLoader inline factories.
Extensions configuration through DefaultResourceLoader inline factories.
examples/07_context_files command
Context files discovered and extended through DefaultResourceLoader.
Context files discovered and extended through DefaultResourceLoader.
examples/08_prompt_templates command
Prompt templates discovered and extended through DefaultResourceLoader.
Prompt templates discovered and extended through DefaultResourceLoader.
examples/09_api_keys command
API key and OAuth configuration through ModelRegistry and runtime callbacks.
API key and OAuth configuration through ModelRegistry and runtime callbacks.
examples/10_settings command
Settings configuration through SettingsManager.
Settings configuration through SettingsManager.
examples/11_sessions command
Session management: in-memory, persistent, continue, list, and open.
Session management: in-memory, persistent, continue, list, and open.
examples/12_full_control command
Full control: explicit model, settings, session, ResourceLoader, and tools.
Full control: explicit model, settings, session, ResourceLoader, and tools.
examples/13_session_runtime command
Session runtime demonstrates recreating cwd-bound services when the active AgentSession is replaced and rebinding session-local host state.
Session runtime demonstrates recreating cwd-bound services when the active AgentSession is replaced and rebinding session-local host state.
extensions
Package extensions provides the Go-native extension registry, API surface, and ordered event runner used by the coding agent.
Package extensions provides the Go-native extension registry, API surface, and ordered event runner used by the coding agent.
extensions/host
Package host implements pigo's original out-of-process JavaScript extension host protocol and lifecycle manager.
Package host implements pigo's original out-of-process JavaScript extension host protocol and lifecycle manager.
mcp
Package mcp implements pigo's bundled, settings-driven MCP extension.
Package mcp implements pigo's bundled, settings-driven MCP extension.
modes
Package modes contains coding-agent run-mode orchestration.
Package modes contains coding-agent run-mode orchestration.
plugins
Package plugins contains pigo's bundled, default-off first-party extensions.
Package plugins contains pigo's bundled, default-off first-party extensions.
session
Package session stores coding-agent conversations as pi-compatible JSONL trees.
Package session stores coding-agent conversations as pi-compatible JSONL trees.
conformance
runner
Package runner provides shared conformance-fixture test helpers.
Package runner provides shared conformance-fixture test helpers.
internal
ignorerules
Package ignorerules holds the shared gitignore-rule matching loop that both skill loaders (agent/harness and codingagent) port from the npm `ignore` dependency.
Package ignorerules holds the shared gitignore-rule matching loop that both skill loaders (agent/harness and codingagent) port from the npm `ignore` dependency.
partialjson
Package partialjson parses the incomplete JSON emitted while tool-call arguments are streaming.
Package partialjson parses the incomplete JSON emitted while tool-call arguments are streaming.
semver
Package semver implements the subset of npm's semver used by pi package management: exact versions, ranges (^ ~ x-ranges, hyphen, ||, primitives), Satisfies and MaxSatisfying with npm's prerelease-inclusion rule.
Package semver implements the subset of npm's semver used by pi package management: exact versions, ranges (^ ~ x-ranges, hyphen, ||, primitives), Satisfies and MaxSatisfying with npm's prerelease-inclusion rule.
sync
Package upstreamsync analyzes and promotes pinned upstream revisions.
Package upstreamsync analyzes and promotes pinned upstream revisions.
uuidv7
Package uuidv7 generates the monotonic UUID and short entry identifiers used by upstream harness session storage.
Package uuidv7 generates the monotonic UUID and short entry identifiers used by upstream harness session storage.
Package memory defines pigo's root-level durable memory SDK seam.
Package memory defines pigo's root-level durable memory SDK seam.
Package tui provides pi's differential terminal renderer and components.
Package tui provides pi's differential terminal renderer and components.

Jump to

Keyboard shortcuts

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