Pi extensions
This configuration ships a large set of pi coding-agent extensions. There are three provisioning paths:
- Home-manager managed extensions:
modules/ai.nixbuildspi-extensions-mergedfrom everything underpi-extensions/, plus externalanswer.tsandtodos.tsfrommitsuhiko/agent-stuff. It symlinks the result to~/.pi/agent/extensions/. Any directory with anindex.ts(or a top-level*.tsfile) is loaded as an extension on the nexthome-manager switch. - Package-based extensions: extensions shipped as Nix packages —
pi-observability,r-modern,drawio-extension,astro-web-terminal. They are installed viamodules/pi-extensions.nixand surface options underprograms.pi-extensions.*. - Extension loading: pi loads extensions from
cwd/.pi/extensions/(project-local),~/.pi/agent/extensions/(global, symlinked to the home-manager directory). It also loads explicitly configured paths (the package-based ones, wired inmodules/ai.nixsettings.json).
Inside pi, run /extensions to list the loaded extensions and /tools to discover their tools.
Extension inventory
Curated list of the extensions in pi-extensions/, grouped by purpose.
The exact set drifts as extensions are added and removed, so treat this as an overview rather than an exhaustive index.
- Document / web / media:
docparse/— parse PDFs, Excel, ODF, and documents (text, markdown, tables, OCR, screenshots).pixelrag/— visual RAG; render documents and web pages to screenshot tiles and search a hosted visual index.typst/— initialize, compile, query, and inspect fonts for Typst documents.pi-mermaid/anddrawio/— diagrams (Mermaid and draw.io shapes, auto-layout).menyoki/— screen capture, screencast recording, and image editing/analysis.
- Integrations:
anytype/,anytype-tree-view/— Anytype objects (see Anytype integration).azure/,azure-app-id/— Azure & Microsoft 365.application-assistant/— job-application workflow.denful/— Nix flakes editor and tool-versioning CLI.r-modern/— R code analysis and evaluation.
- Models & providers:
scaleway/,engine-gate/(on-demand local engine lifecycle),model-identity/.
- Security:
path-guard/— file-access allowlist/denylist (see security.mdx).azure-guard/— disable Azure/Microsoft 365 tools in unattended Firstmate sessions.credential-leak/— transcript scanning and redaction.curl/— safe HTTP requests (see below).
- Workflow & helpers:
branch-guard/— branch-per-task enforcement (see below).nix-fmt/— auto-format Nix files after edits.rg-replace/,fd-replace/— swapgrep/findforrg/fdin bash tool calls.cost-tracker/,cost-tracker-scaleway/— token/cost tracking (see below).tps-tracker/— footer stat for average tokens/sec.subagent/— delegate to isolated subagent processes.clipboard/— push text to the macOS clipboard viapbcopy.lazy-load/,schema-sanitizer/,request-logger/,nix-pi-crafter/— miscellaneous plumbing.integration-layer/— extension coordination and workflows (see below).integration-example/,workflow-example/— usage examples.
Branch guard
pi-extensions/branch-guard/ enforces the “branch-per-task” workflow documented in AGENTS.md.
Behavior:
- On session start, checks if we are on the main branch.
- If on main and starting a new task, prompts to create a new branch.
- Suggests branch names following Conventional Commits conventions (e.g.
feat/short-description,fix/issue-name). - Automatically handles git operations (switch to main, create and switch to a new branch).
- Tracks state to avoid repeated prompts in the same session.
Curl extension with path restrictions
pi-extensions/curl/ provides HTTP request capabilities with fine-grained security controls.
The extension-specific documentation lives in pi-extensions/docs/CURL_ENHANCEMENTS.md.
Features: domain allowlisting, path-level restrictions, wildcard path patterns, method restrictions, rate limiting (30 req/min per domain), and request caching (5-minute TTL). It also provides automatic retries, comprehensive logging, and graceful error handling.
Domains and paths are configured in pi-extensions/curl-config.json:
{
"safeUrls": [
{ "domain": "codefloe.com", "methods": ["GET", "POST", "PUT", "DELETE"], "paths": ["/spectral-cockpit", "/philipp-baumann", "/crowci"] },
{ "domain": "httpbin.org", "methods": ["GET", "POST", "PUT", "DELETE"] }
]
}
Inside pi, the tools curl_request, curl_add_safe_url, curl_check_rate_limit, and curl_clear_cache expose the functionality programmatically.
Cost tracker
pi-extensions/cost-tracker/ tracks Claude/Anthropic spend.
It writes one JSON line per assistant turn to ~/.pi/agent/cost-tracker.jsonl and shows a live per-session status line in pi’s footer (cost: api=$… sub=$…).
Each turn is classified as either api (billed to your Anthropic API key) or subscription (absorbed by a Claude Max/Pro plan via pi’s /login OAuth flow).
On this machine all Anthropic traffic goes through ANTHROPIC_API_KEY (exported by modules/shell.nix from a SOPS secret), so in practice every live turn lands in the api bucket.
Commands, all run inside pi:
# show today / last 7d / last 30d / all time, plus per-day (14), per-week (8),
# per-month (6), and per-model breakdowns
/cost
# one-time import of historical Claude turns from ~/.pi/agent/sessions into
# the log. pi does not persist the OAuth/subscription flag per message, so you
# must tell it which bucket old turns should land in. On this setup, use `api`.
/cost-backfill api
# re-run the backfill (e.g. after editing the log or wiping the sentinel)
/cost-backfill api --force
The backfill sentinel lives at ~/.pi/agent/cost-tracker.backfilled.
Delete it (or pass --force) to re-import.
pi-extensions/cost-tracker-scaleway/ does the same for Scaleway model usage, logging to ~/.pi/agent/cost-tracker-scaleway.jsonl.
It exposes a /cost-scaleway command plus a scw: … footer status.
Integration layer
pi-extensions/integration-layer/ lets extensions cooperate while staying independent.
It provides extension registration, dependency resolution, health monitoring, workflow creation, and cross-extension tool discovery.
The full API and examples live in pi-extensions/docs/README.md and pi-extensions/INTEGRATION_LAYER.md.
Highlights:
- Extension Registration: extensions register themselves with metadata, dependencies, and optional health checks.
- Dependency Management: topological resolution of declared dependencies.
- Workflow Creation: combine extensions into reusable workflows with a priority-ordered execution pipeline.
- Health Monitoring: central health checks for all registered extensions.
- Slash commands:
/integration,/integration list,/integration health,/integration workflow,/integration workflows,/integration start,/integration tools. - Tools:
integration_list_extensions,integration_check_health,integration_list_workflows,integration_start_workflow,integration_get_workflow_status,integration_list_all_tools.
The examples in pi-extensions/integration-example/ and pi-extensions/workflow-example/ demonstrate best practices.
Anytype integration
The Anytype integration has two independent pieces that share secrets/anytype.yaml:
pi-extensions/anytype/— pi tools that call the Anytype desktop app’s REST API onhttp://localhost:31009. Seepi-extensions/anytype/README.mdfor setup, env vars, tool reference, and troubleshooting.modules/anytype.nix— packages the standaloneanytype-mcpMCP server plusanytype-cli, and writes a wrapper at~/.config/anytype/anytype-mcp-wrapper.shthat injects the API key from sops. Use this wrapper in external MCP clients such as Claude Desktop or Cursor.
The integration is enabled via programs.anytype.enable = true; in home.nix.
Nothing in this repo runs the desktop-app-backed pi extension as a long-running service; the optional headless CLI server runs as a launchd/systemd service on port 31012.
Credentials
secrets/anytype.yaml holds the apiKey and workspaceId keys.
They are declared in modules/ai.nix and exported as ANYTYPE_API_KEY and ANYTYPE_WORKSPACE by modules/shell.nix for use by the pi extension.
See security.mdx for how to edit encrypted secrets.
Related
pi-extensions/anytype-tree-view/— a tree-view over Anytype search results.pi-extensions/anytype/README.md— detailed documentation.