pie is a Rust rewrite of the original pi project (pi-coding-agent). pie is a terminal-based AI coding agent, run it inside a project, ask it to inspect files, make edits,
run shell commands, remember preferences, and continue previous sessions.
git clone https://github.com/c4pt0r/pie.git
cd pie
cargo build --releaseThe CLI binary will be at ./target/release/pie.
pie auto-detects the first available provider credential. Set an API key before starting:
export ANTHROPIC_API_KEY=sk-ant-...
# or: OPENAI_API_KEY, OPENROUTER_API_KEY, GROQ_API_KEY,
# MISTRAL_API_KEY, GEMINI_API_KEY, GOOGLE_API_KEYYou can also store a key from inside pie:
/login anthropic sk-ant-...
pie can also use local OpenAI-compatible servers. Add a model definition to
~/.pie/models.json (user-global) or <project>/.pie/models.json (project-local, higher
precedence), then select it with --provider and --model.
Example for DS4, the DeepSeek V4 Flash local server. The Responses endpoint is the preferred OpenAI-compatible API for Codex-style clients; chat completions also works for simpler integrations.
# In the DS4 checkout:
./ds4-server --ctx 100000 --kv-disk-dir /tmp/ds4-kv --kv-disk-space-mb 8192
# If launching from another directory, add: --chdir /path/to/ds4{
"models": [
{
"id": "deepseek-v4-flash",
"name": "DeepSeek V4 Flash (local DS4)",
"api": "openai-responses",
"provider": "ds4",
"baseUrl": "http://127.0.0.1:8000/v1",
"reasoning": true,
"thinkingLevelMap": {
"off": null,
"minimal": "low",
"low": "low",
"medium": "medium",
"high": "high",
"xhigh": "xhigh"
},
"input": ["text"],
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
"contextWindow": 100000,
"maxTokens": 384000,
"compat": {
"supportsStore": false,
"supportsDeveloperRole": false,
"supportsReasoningEffort": true,
"supportsUsageInStreaming": true,
"maxTokensField": "max_tokens",
"supportsStrictMode": false,
"thinkingFormat": "deepseek",
"requiresReasoningContentOnAssistantMessages": true
}
}
]
}Then run:
export DS4_API_KEY=dsv4-local
./target/release/pie --provider ds4 --model deepseek-v4-flashDS4 is local and accepts placeholder bearer tokens. You can also store the same
local placeholder with /login ds4 dsv4-local. Using the ds4 provider keeps
local model credentials separate from real OPENAI_API_KEY credentials.
# Start in the current project
./target/release/pie
# Choose a specific provider/model
./target/release/pie --provider anthropic --model claude-haiku-4-5
# Enable extended thinking where supported
./target/release/pie --thinking high
# Resume the most recent session for this project
./target/release/pie --resumeOnce the REPL opens, type a request such as:
summarize this repository
fix the failing tests
add a README example and run the relevant checks
when ~/build.done appears, run cargo test and show me the result
Inside pie, slash commands control the session:
| Command | What it does |
|---|---|
/help |
Show all commands |
/model [provider:model-id] |
Show or switch model |
/thinking |
Show or set thinking level, off, minimal, low, medium, high, xhigh |
/sessions |
List sessions for the current project |
/save [path] |
Export the transcript to Markdown |
/compact [instructions] |
Compact long context |
/undo |
Remove the most recent user/assistant turn |
/cost |
Show token and cost totals |
/login <provider> <api-key> |
Store an API key |
/logout <provider> |
Remove a stored API key |
/triggers |
Show trigger rules, sources, running actions, and audit |
/triggers rules |
List dynamic trigger ids and state |
/triggers enable <id> / /triggers disable <id> |
Resume or pause a trigger |
/triggers remove <id> |
Delete a trigger |
/quit |
Exit |
CLI helpers:
./target/release/pie --help
./target/release/pie --list-sessions
./target/release/pie --list-all-sessions
./target/release/pie --delete-session <id>
./target/release/pie --image screenshot.pngThe agent has tools for common coding workflows:
- read, write, and edit files
- list files and search with grep/find
- run shell commands
- manage persistent memory
- delegate focused sub-tasks
- resume JSONL-backed sessions per project
- attach images to the first prompt with
--image - create session-scoped natural-language triggers that run actions when local checks or MCP push events match
- run local command hooks or HTTP webhooks on agent lifecycle events; see docs/hooks.md
Triggers let you describe an automation in normal chat:
when $HOME/helloworld exists, print its contents
pie turns that request into a dynamic trigger rule. Rules are stored next to the active
session, so a new session starts cleanly and --resume brings that session's rules back.
Dynamic triggers fire once by default; ask for a repeating trigger when you want it to keep
running.
Trigger actions run in a separate sub-agent. The sub-agent inherits the parent model, tools,
tool hooks, thinking level, and skill catalog, but it does not receive the full parent
conversation by default. Trigger output is shown in the TUI and written to trigger audit
records. If you explicitly ask for the result to be visible to future turns, the rule is
created with promote_to_chat=true and successful trigger output is inserted into the main
chat context with a [Trigger ...] prefix.
Local dynamic checks poll every 60 seconds by default, and only emit checks while at least
one enabled dynamic rule exists. Configure the interval in ~/.pie/config.toml:
[triggers]
poll_interval_secs = 60For one run, override it with:
./target/release/pie --trigger-poll-secs 10MCP notifications are treated as trigger sources too: a configured MCP server can push an event into the same trigger runtime, where the same rules, audit, deduping, and output behavior apply.
By default, pie stores local state under ~/.pie:
| Path | What |
|---|---|
~/.pie/sessions/<cwd-hash>/<uuidv7>.jsonl |
Session history for each project |
~/.pie/memory/*.md |
Cross-session memory injected into future sessions |
~/.pie/auth.json |
Stored API keys from /login |
~/.pie/models.json |
User-global local/custom model definitions |
~/.pie/history |
Prompt history |
~/.pie/hooks.toml |
Optional command/webhook hooks |
~/.pie/config.toml |
Optional user config, including trigger poll interval |
Set PIE_DIR to use a different base directory.
cargo build --workspace
cargo test --workspace
cargo clippy --workspace --all-targets -- -D warnings
cargo fmt --all --check