- TypeScript 100%
| .pi | ||
| config | ||
| README.md | ||
my-pi
An experiment in building a customized distribution of pi to serve as my primary coding agent instead of OpenCode.
Extensions
Project-local extensions live in .pi/extensions/ and are auto-discovered by pi on startup.
mcp.ts — MCP tool
Exposes a single mcp tool that lets the LLM interact with MCP (Model Context Protocol) servers via the mcporter CLI. Server configuration is managed externally — the extension never adds, removes, or edits config; it only drives the CLI.
| Action | What it does | Required params |
|---|---|---|
list_servers |
mcporter list — enumerate all configured servers |
— |
list_tools |
mcporter list <server> — show TypeScript-style tool signatures |
server |
call_tool |
mcporter call <server>.<tool> — invoke a tool |
server, tool |
Tool arguments for call_tool are passed as a JSON object via the args field. An optional output_format parameter controls how mcporter renders the response (text / markdown / json / raw, default text). Output is truncated to 2000 lines or 50 KB; if truncated, the full response is saved to a temp file and the LLM is told where to find it.
exit.ts — Exit command and prompt shortcut
Two ways to quit pi gracefully:
| Trigger | Description |
|---|---|
/exit |
Slash command |
exit (Enter) |
Typing exit (case-insensitive) as a plain prompt intercepts it before it reaches the LLM and shuts down |
sessions.ts — Session switcher
Adds a /sessions command that opens an interactive dialog listing all sessions for the current project directory.
| Key | Action |
|---|---|
↑ / ↓ |
Navigate |
| type | Filter sessions by name |
Enter |
Switch to the selected session |
Ctrl+D |
Arm deletion of the hovered session |
Ctrl+D (again) |
Confirm deletion |
| any other key | Cancel pending deletion |
Esc |
Dismiss the dialog |
Sessions are sorted most-recent-first. Each entry shows the session's display name (set via /name) when available, falling back to the first message text, with the last-modified timestamp as a subtitle. The active session is pinned to the top, marked with ← current, and is protected from deletion.
undo.ts — Undo last turn
Adds a /undo command that removes the last user prompt and everything the LLM did in response, reverts any file changes made during that turn, and restores the prompt text into the editor for editing and re-sending.
File reversion
| Tool | Reversion strategy |
|---|---|
write |
Scans backwards through session history for the most recent prior write to the same path and restores that content. If no prior write exists the file was created in this turn and is deleted. |
edit |
Applies each edit call's hunks in reverse — oldText and newText are swapped, hunks are processed bottom-to-top within each call, and calls are replayed in reverse chronological order. Files that were also writen in the same turn are skipped; write reversion covers them entirely. |
Only successful tool calls (those where isError is false) are reverted. If any file cannot be reverted a warning notification lists the affected paths.
Empty session handling
If /undo is called on the very first user message — leaving the session with no user-visible content — pi switches to a fresh empty session and the now-empty session file is deleted immediately.
Limitations
- Images attached to the undone prompt are not restored to the editor (only text is recovered).
bashtool side-effects (files created or modified via shell commands) are not reverted.- If a file existed before the session started and was overwritten by a
writecall in the very first turn, the pre-session content cannot be recovered (no prior write exists in the session history to source it from).