This adds codemode and MCP support to pi. Codemode (packages/codemode) runs model-written JavaScript in a QuickJS wasm VM inside a worker. From there the script calls pi's tools as async functions, uses a per-session store, and can read the model catalog and run classifiers. The codemode tool in coding-agent is compatible with Codex's exec tool, and codemode.mode works like Codex's tool modes (on or only). Large results are written to a JSON temp file. MCP (packages/mcp) is a standalone client for stdio and streamable HTTP servers, with OAuth. The core only gets general mechanisms; codemode, tool_search and MCP are built-in extensions that use them. Other extensions can replace these built-ins. Tools declare an exposure: direct, model-only, codemode, deferred or hidden. prepareLoadout() lets an orchestrating tool change which tool declarations the model sees. ctx.executeTool() runs nested calls through validation and the tool_call/tool_result hooks. Those calls emit events with parentToolCallId and are recorded as bounded nestedCalls on the parent result, which compaction and HTML export use. Tools can also return structuredContent with an outputSchema, and can report errors with isError instead of throwing. MCP servers come from mcp.json (global, or per project after the project is trusted) or from pi.registerMcpServer(). They are managed with /mcp and pi mcp list|login|logout, and their runtimes load on first use. Closes #10040
3.2 KiB
Configuration
Pi supports user-level and project configuration. User-level configuration lives in the agent directory, which defaults to ~/.pi/agent. Project configuration lives in .pi under the working directory and loads after project trust is granted. The only exception is sessionDir, which Pi reads before resolving trust so it can locate sessions.
In interactive mode, use /settings to change common preferences. For other options, ask Pi to update the configuration or edit the relevant files directly. Run /reload after manually changing settings, keybindings, instructions, or resources.
Agent directory
The agent directory is shown as <agent-dir> below. Set its location with the PI_CODING_AGENT_DIR environment variable or the SDK's agentDir option.
| Path | Responsibility |
|---|---|
<agent-dir>/settings.json |
User-level settings, including preferences, defaults, resource paths, and Pi package declarations. |
<agent-dir>/keybindings.json |
Custom terminal UI and application keybindings. |
<agent-dir>/mcp.json |
MCP servers available in every project. |
<agent-dir>/models.json |
Compatible endpoints, models, and model overrides. |
<agent-dir>/auth.json |
Saved API keys and OAuth credentials. |
<agent-dir>/AGENTS.override.md, AGENTS.md, AGENTS.MD, CLAUDE.md, or CLAUDE.MD |
User instructions applied across working directories. |
<agent-dir>/SYSTEM.md |
Replaces Pi’s default system prompt. |
<agent-dir>/APPEND_SYSTEM.md |
Adds instructions to Pi’s system prompt. |
<agent-dir>/extensions/ |
User extensions. |
<agent-dir>/skills/ |
User skills and supporting files. |
<agent-dir>/prompts/ |
User prompt templates exposed as slash commands. |
<agent-dir>/themes/ |
User theme files. |
Project .pi directory
| Path | Responsibility |
|---|---|
.pi/settings.json |
Project-level settings, resource paths, and Pi package declarations. |
.pi/mcp.json |
Project MCP servers. |
.pi/SYSTEM.md |
Replaces the system prompt for the project. |
.pi/APPEND_SYSTEM.md |
Adds project-specific instructions to the system prompt. |
.pi/extensions/ |
Project extensions. |
.pi/skills/ |
Project skills and supporting files. |
.pi/prompts/ |
Project prompt templates exposed as slash commands. |
.pi/themes/ |
Project theme files. |
For SYSTEM.md and APPEND_SYSTEM.md, the trusted project file takes precedence over the corresponding agent-directory file. Files with the same name are not combined.
Context files
Context files are separate from project .pi configuration. Pi loads them from the agent directory, the working directory, and its parent directories. A context file applies whenever Pi runs in its directory or anywhere below it.
An AGENTS.override.md replaces AGENTS.md or CLAUDE.md only in the same directory. It does not suppress context files from the agent directory or other directories.
Context-file discovery does not require project trust.