Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt

Use this file to discover all available pages before exploring further.

Pi Coding Agent is a TypeScript coding agent with seven built-in tools (read, write, edit, bash, grep, find, ls). Mirage provides an extension factory that swaps Pi’s host-backed operations for Workspace operations.
Node only. Pi is a CLI agent; it uses process.cwd(), agent directories, and other Node-only APIs.

Install

pnpm add @struktoai/mirage-agents @struktoai/mirage-node @mariozechner/pi-coding-agent @mariozechner/pi-ai

Usage

import { MountMode, OpsRegistry, RAMResource, Workspace } from '@struktoai/mirage-node'
import { getModel } from '@mariozechner/pi-ai'
import {
  createAgentSession,
  DefaultResourceLoader,
  getAgentDir,
  SessionManager,
  SettingsManager,
} from '@mariozechner/pi-coding-agent'
import { buildSystemPrompt, mirageExtension } from '@struktoai/mirage-agents/pi'

const ram = new RAMResource()
const ops = new OpsRegistry()
for (const op of ram.ops()) ops.register(op)
const ws = new Workspace({ '/': ram }, { mode: MountMode.WRITE, ops })

const resourceLoader = new DefaultResourceLoader({
  cwd: process.cwd(),
  agentDir: getAgentDir(),
  settingsManager: SettingsManager.create(process.cwd(), getAgentDir()),
  systemPrompt: buildSystemPrompt({
    mountInfo: { '/': 'In-memory filesystem (read/write)' },
  }),
  extensionFactories: [mirageExtension(ws)],
  noExtensions: true,
  noSkills: true,
})
await resourceLoader.reload()

const { session } = await createAgentSession({
  model: getModel('anthropic', 'claude-sonnet-4-6'),
  resourceLoader,
  sessionManager: SessionManager.inMemory(),
})

await session.prompt("Create /hello.txt with 'hi' and ls /.")

Exports

SymbolPurpose
mirageExtension(ws, opts?)Returns an ExtensionFactory that registers all 7 Pi tools against ws.
mirageOperations(ws)Lower-level: returns the { read, write, edit, bash, grep, find, ls } operation bundle if you want to register tools manually.
buildSystemPromptGenerates a system prompt that describes mounted paths to the model.
mirageExtension accepts { cwd?: string }, defaults to '/', which tells Pi the working directory inside the mounted workspace.

Examples