Pig is a local-first coding-agent project implemented in Zig.
The Zig implementation targets Zig 0.16.x.
M0 established the engineering foundation and CLI diagnostics. M1 added the provider layer foundation: provider message/content types, unified streaming events, SSE parsing, OpenAI-compatible recorded parser, Anthropic recorded parser, provider auth resolution, and optional live smoke harness. M2 added the reusable core agent runtime: state ownership, turn loop, provider-event bridge, fake tool-call loop, agent events, middleware hooks, cooperative abort, and offline agent fixtures. M3 added built-in local coding tools: read, write, edit, bash, grep, find, and ls. M4 added the local append-only session JSONL store and context tree foundation. M5 added print/json CLI modes, M6 added the terminal UI foundation and live interactive loop, and M7 added config/auth/models/resources loading.
Available local commands:
zig build run
zig build run -- --version
zig build run -- --help
zig build run -- doctor
zig build run -- paths
zig build run -- --interactive- Zig 0.16.x
- No third-party Zig dependencies in M1
Check your version:
zig versionDefault checks are offline:
zig build
zig build test
zig build smoke
zig build provider-fixtures
zig build agent-fixtures
zig build tools-fixtures
zig build session-fixtures
zig build provider-live
zig build fmt-checkzig build provider-live skips unless explicitly enabled. M1 includes the live harness; actual live HTTP streaming transport currently reports unsupported when fully enabled. To attempt a live OpenAI-compatible streaming check once transport is implemented:
PIG_PROVIDER_LIVE=1 \
PIG_OPENAI_COMPAT_BASE_URL="https://..." \
PIG_OPENAI_COMPAT_API_KEY="..." \
PIG_OPENAI_COMPAT_MODEL="..." \
zig build provider-liveAPI keys must come from the environment and must not be committed.
build.zig/build.zig.zon— Zig 0.16 build configurationsrc/main.zig— Zig CLI entry pointsrc/app— CLI dispatch and build infosrc/core— shared errors, ID placeholders, and M2core.agentruntimesrc/provider— M1 provider models, events, SSE parsing, auth, transport, recorded parserssrc/tools— M3 built-in coding tools, metadata, approval, path policy, and registry adaptersrc/session— M4 session entry DTOs, append-only JSONL store, and context tree indexsrc/resources— settings, model registry, context files, metadata discovery, and warningssrc/tui— terminal lifecycle, input decoding, editor state, layout, components, renderer, and testing helperssrc/rpc/src/plugin— protocol version placeholderssrc/util— path and testing helperstest— unit, fixture, provider, and agent runtime testsfixtures— small offline fixturesdocs— architecture, error, fixture, allocator, and provider notes
docs/architecture.mddocs/error-model.mddocs/fixtures.mddocs/allocator-policy.mddocs/provider-events.mddocs/provider-auth.mddocs/provider-transport.md
.envis local-only and gitignored.- Default tests are offline and do not require API keys.
- M2 agent runtime is available as a reusable core module and is tested with scripted providers/fake tools.
- M3 built-in coding tools are available as reusable modules and through the M2 tool registry adapter.
pigwith no arguments starts the terminal UI. In non-TTY contexts, interactive mode uses a cooked fallback and exits cleanly on EOF.