Skip to main content
Pi Coding Agent is a TypeScript coding agent with seven built-in tools (read, write, edit, bash, grep, find, and ls). Mirage provides a native Pi inline extension that replaces their host-filesystem operations with a Workspace.
Node 22.19 or newer only. Pi is a CLI agent; it uses process.cwd(), agent directories, and other Node-only APIs.

Install

Native Pi UI

Pass the Mirage extension to Pi’s regular entry point. Pi continues to own its CLI/TUI, model selection, sessions, themes, commands, and authentication.
Running this script in a terminal opens Pi’s existing UI. The extension also routes interactive ! and !! shell commands through Mirage at the virtual working directory. For an isolated Mirage session, prevent Pi from loading AGENTS.md and CLAUDE.md files from the host project:
After asking Pi to create a file, you can verify that the native UI is using Mirage:
Omit --no-context-files when you intentionally want Pi to combine host-project instructions with the mounted Mirage workspace. The one-shot examples use Pi’s lower-level session API and accept PI_PROVIDER, PI_MODEL, PI_BASE_URL, and PI_API_KEY. This lets a built-in Pi provider and model run through a compatible gateway without writing credentials to Pi’s configuration files.

Stale-write protection

Pi serializes its own mutations and its edit tool checks that the requested old text still exists in the current file. It does not, however, retain a file revision from an earlier agent read. The Mirage extension records a content fingerprint whenever Pi reads or greps a file. A later edit or full-file write fails with StaleMirageFileError if that content changed in the meantime. Reading the file again refreshes the fingerprint, so the agent can reconsider the new content and retry. The edit adapter also checks again immediately before writing. This protection is enabled by default. It observes the content returned by the mounted resource, so a remote backend’s cache and invalidation policy still determines when an external change becomes visible to Mirage.

Exports

mirageExtension accepts:

Examples