设置
Pi 使用 JSON 设置文件,项目设置会覆盖全局设置。
| 位置 Location | 作用域 Scope |
|---|---|
~/.pi/agent/settings.json | 全局(所有项目) |
.pi/settings.json | 项目(当前目录) |
可直接编辑文件,或使用 /settings 命令设置常用选项。
项目信任 Project Trust
交互式启动时,如果项目目录包含本地设置、资源或 .agents/skills,且 ~/.pi/agent/trust.json 中对该目录或其父目录无已保存的信任决策,pi 会询问是否信任该项目。信任后,pi 可加载 .pi/settings.json 和 .pi 资源、安装缺失的包以及执行项目扩展。
非交互模式(-p、--mode json、--mode rpc)不弹出信任提示,使用全局 defaultProjectTrust 决定行为:"ask"(默认)和 "never" 会忽略这些项目资源,"always" 则信任它们。传递 --approve/-a 或 --no-approve/-na 可以单次运行时覆盖项目信任。
如果没有适用的扩展或已保存决策,defaultProjectTrust 控制回退行为。在 ~/.pi/agent/settings.json 中将其设置为 "ask"、"always" 或 "never",或通过 /settings 更改。
pi config 和包相关命令也使用相同的项目信任流程,但 pi update 从不提示。传递 --approve 可在单条命令中信任项目本地设置,或传递 --no-approve 忽略它们。
在交互模式中使用 /trust 可保存项目信任决策供后续会话使用,包括信任直接父文件夹。它只写入 ~/.pi/agent/trust.json;当前会话不会重新加载,因此需要重启 pi 才能让更改生效。
所有设置 All Settings
模型与思考 Model & Thinking
| 设置 Setting | 类型 Type | 默认值 Default | 描述 Description |
|---|---|---|---|
defaultProvider | string | - | 默认提供商(如 "anthropic"、"openai") |
defaultModel | string | - | 默认模型 ID |
defaultThinkingLevel | string | - | "off"、"minimal"、"low"、"medium"、"high"、"xhigh"、"max" |
hideThinkingBlock | boolean | false | 在输出中隐藏思考块 |
showCacheMissNotices | boolean | false | 显示关于显著提示缓存未命中的对话记录通知 |
thinkingBudgets | object | - | 每个思考级别的自定义令牌预算 |
thinkingBudgets
{
"thinkingBudgets": {
"minimal": 1024,
"low": 4096,
"medium": 10240,
"high": 32768
}
}UI 与显示 UI & Display
| 设置 Setting | 类型 Type | 默认值 Default | 描述 Description |
|---|---|---|---|
theme | string | "dark" | 主题名称("dark"、"light" 或自定义) |
externalEditor | string | $VISUAL,然后是 $EDITOR,Windows 上为 Notepad,其他平台为 nano | Ctrl+G 外部编辑器命令;优先级高于环境变量 |
quietStartup | boolean | false | 隐藏启动标题 |
defaultProjectTrust | string | "ask" | 回退项目信任行为:"ask"、"always" 或 "never"。仅全局设置 |
collapseChangelog | boolean | false | 更新后显示精简版变更日志 |
enableInstallTelemetry | boolean | true | 首次安装或检测到变更日志更新后发送匿名安装/更新版本 ping。这不控制更新检查 |
enableAnalytics | boolean | false | 自愿选择的分析数据共享。目前仅在实验性首次设置(PI_EXPERIMENTAL=1)时询问 |
trackingId | string | - | 分析跟踪标识符,在 enableAnalytics 开启时生成 |
doubleEscapeAction | string | "tree" | 双 Escape 的动作:"tree"、"fork" 或 "none" |
treeFilterMode | string | "default" | /tree 的默认过滤器:"default"、"no-tools"、"user-only"、"labeled-only"、"all" |
editorPaddingX | number | 0 | 输入编辑器的水平内边距(0-3) |
outputPad | number | 1 | 用户消息、助手消息和思考块的水平内边距(0 或 1) |
autocompleteMaxVisible | number | 5 | 自动补全下拉菜单中最大可见项数(3-20) |
showHardwareCursor | boolean | false | 在 TUI 定位光标以支持 IME 时,显示终端光标 |
对于 VS Code,包含 --wait 以便 pi 在编辑器退出后恢复:
{
"externalEditor": "code --wait"
}遥测与更新检查 Telemetry and update checks
enableInstallTelemetry 仅控制向 https://pi.dev/api/report-install 发送的匿名安装/更新 ping。退出遥测不会禁用更新检查;Pi 仍可访问 https://pi.dev/api/latest-version 以查找最新版本。
设置 PI_SKIP_VERSION_CHECK=1 可禁用 Pi 版本更新检查。使用 --offline 或 PI_OFFLINE=1 可禁用此处描述的所有启动网络操作,包括更新检查、包更新检查以及安装/更新遥测。
网络 Network
| 设置 Setting | 类型 Type | 默认值 Default | 描述 Description |
|---|---|---|---|
httpProxy | string | - | HTTP 代理 URL,作为 HTTP_PROXY 和 HTTPS_PROXY 应用。仅全局设置。 |
{
"httpProxy": "http://127.0.0.1:7890"
}警告 Warnings
| 设置 Setting | 类型 Type | 默认值 Default | 描述 Description |
|---|---|---|---|
warnings.anthropicExtraUsage | boolean | true | 当 Anthropic 订阅认证可能使用付费额外用量时显示警告 |
{
"warnings": {
"anthropicExtraUsage": false
}
}压缩 Compaction
| 设置 Setting | 类型 Type | 默认值 Default | 描述 Description |
|---|---|---|---|
compaction.enabled | boolean | true | 启用自动压缩 |
compaction.reserveTokens | number | 16384 | 为 LLM 响应预留的令牌数 |
compaction.keepRecentTokens | number | 20000 | 保留的最近令牌数(不进行摘要) |
{
"compaction": {
"enabled": true,
"reserveTokens": 16384,
"keepRecentTokens": 20000
}
}分支摘要 Branch Summary
| 设置 Setting | 类型 Type | 默认值 Default | 描述 Description |
|---|---|---|---|
branchSummary.reserveTokens | number | 16384 | 为分支摘要预留的令牌数 |
branchSummary.skipPrompt | boolean | false | 在 /tree 导航时跳过「汇总分支?」提示(默认不生成摘要) |
重试 Retry
| 设置 Setting | 类型 Type | 默认值 Default | 描述 Description |
|---|---|---|---|
retry.enabled | boolean | true | 启用临时错误时的自动代理级重试 |
retry.maxRetries | number | 3 | 最大代理级重试次数 |
retry.baseDelayMs | number | 2000 | 代理级指数退避的基础延迟(2s、4s、8s) |
retry.provider.timeoutMs | number | SDK 默认值 | 提供商/SDK 请求超时(毫秒) |
retry.provider.maxRetries | number | 0 | 提供商/SDK 重试次数 |
retry.provider.maxRetryDelayMs | number | 60000 | 服务器请求延迟的最大值,超过此值则失败(60 秒) |
当提供商请求的重试延迟超过 retry.provider.maxRetryDelayMs(例如 Google 的「配额将在 5 小时后重置」),请求会立即失败并显示信息性错误,而不是静默等待。设置为 0 可禁用上限。
除非明确需要提供商级别的重试,否则将 retry.provider.maxRetries 保持在 0。将其设置为高于 0 可能会使 SDK/提供商重试在处理超出使用限制的错误时,Pi 无法感知,这可能在特定情况下阻塞代理直到提供商配额重置。
{
"retry": {
"enabled": true,
"maxRetries": 3,
"baseDelayMs": 2000,
"provider": {
"timeoutMs": 3600000,
"maxRetries": 0,
"maxRetryDelayMs": 60000
}
}
}消息投递 Message Delivery
| 设置 Setting | 类型 Type | 默认值 Default | 描述 Description |
|---|---|---|---|
steeringMode | string | "one-at-a-time" | 引导消息的发送方式:"all" 或 "one-at-a-time" |
followUpMode | string | "one-at-a-time" | 跟进消息的发送方式:"all" 或 "one-at-a-time" |
transport | string | "auto" | 支持多种传输方式的提供商的首选传输协议:"sse"、"websocket"、"websocket-cached" 或 "auto" |
httpIdleTimeoutMs | number | 300000 | HTTP 头部/主体空闲超时(毫秒),也用于具有显式流空闲超时的提供商。设置为 0 可禁用。 |
websocketConnectTimeoutMs | number | 15000 | 支持 WebSocket 传输的提供商的 WebSocket 连接/开启握手超时(毫秒)。设置为 0 可禁用。 |
终端与图片 Terminal & Images
| 设置 Setting | 类型 Type | 默认值 Default | 描述 Description |
|---|---|---|---|
terminal.showImages | boolean | true | 在终端中显示图片(如果支持) |
terminal.imageWidthCells | number | 60 | 终端中内联图片的首选宽度(以终端单元格为单位) |
terminal.clearOnShrink | boolean | false | 内容收缩时清除空行(可能导致闪烁) |
images.autoResize | boolean | true | 将图片调整为最大 2000x2000 |
images.blockImages | boolean | false | 阻止所有图片发送给 LLM |
终端 Shell
| 设置 Setting | 类型 Type | 默认值 Default | 描述 Description |
|---|---|---|---|
shellPath | string | - | 自定义 Shell 路径(例如 Windows 上的 Cygwin);支持前导 ~ 表示 home 目录 |
shellCommandPrefix | string | - | 每条 bash 命令的前缀(例如 "shopt -s expand_aliases") |
npmCommand | string[] | - | 用于 npm 包查找/安装操作的命令 argv(例如 ["mise", "exec", "node@20", "--", "npm"]) |
{
"npmCommand": ["mise", "exec", "node@20", "--", "npm"]
}npmCommand 用于所有 npm 包管理器操作,包括安装、卸载以及 git 包中的依赖安装。用户作用域的 npm 包安装在 ~/.pi/agent/npm/ 下;项目作用域的 npm 包安装在 .pi/npm/ 下。请使用与进程启动方式完全一致的 argv 格式条目。当配置了 npmCommand 时,git 包的依赖安装使用普通的 install,以避免在包装器或其他包管理器中传入 npm 特定标志。
会话 Sessions
| 设置 Setting | 类型 Type | 默认值 Default | 描述 Description |
|---|---|---|---|
sessionDir | string | - | 存储会话文件的目录。接受绝对路径、相对路径以及 ~。 |
{ "sessionDir": ".pi/sessions" }当多个来源指定了会话目录时,优先级为 --session-dir、PI_CODING_AGENT_SESSION_DIR,然后是 settings.json 中的 sessionDir。
模型切换 Model Cycling
| 设置 Setting | 类型 Type | 默认值 Default | 描述 Description |
|---|---|---|---|
enabledModels | string[] | - | Ctrl+P 切换的模型模式(格式与 --models CLI 标志相同) |
{
"enabledModels": ["claude-*", "gpt-4o", "gemini-2*"]
}Markdown
| 设置 Setting | 类型 Type | 默认值 Default | 描述 Description |
|---|---|---|---|
markdown.codeBlockIndent | string | " " | 代码块的缩进 |
资源 Resources
以下设置定义了从何处加载扩展、技能、提示模板和主题。
~/.pi/agent/settings.json 中的路径相对于 ~/.pi/agent 解析。.pi/settings.json 中的路径相对于 .pi 解析。支持绝对路径和 ~。
| 设置 Setting | 类型 Type | 默认值 Default | 描述 Description |
|---|---|---|---|
packages | array | [] | 从中加载资源的 npm/git 包 |
extensions | string[] | [] | 本地扩展文件路径或目录 |
skills | string[] | [] | 本地技能文件路径或目录 |
prompts | string[] | [] | 本地提示模板文件路径或目录 |
themes | string[] | [] | 本地主题文件路径或目录 |
enableSkillCommands | boolean | true | 将技能注册为 /skill:name 命令 |
数组支持 glob 模式和排除项。使用 !pattern 排除。使用 +path 强制包含精确路径,使用 -path 强制排除精确路径。
packages
字符串形式加载包中的所有资源:
{
"packages": ["pi-skills", "@org/my-extension"]
}对象形式过滤要加载的资源:
{
"packages": [
{
"source": "pi-skills",
"skills": ["brave-search", "transcribe"],
"extensions": []
}
]
}详见 packages.md。
示例 Example
{
"defaultProvider": "anthropic",
"defaultModel": "claude-sonnet-4-20250514",
"defaultThinkingLevel": "medium",
"theme": "dark",
"compaction": {
"enabled": true,
"reserveTokens": 16384,
"keepRecentTokens": 20000
},
"retry": {
"enabled": true,
"maxRetries": 3
},
"enabledModels": ["claude-*", "gpt-4o"],
"warnings": {
"anthropicExtraUsage": true
},
"packages": ["pi-skills"]
}项目覆盖 Project Overrides
项目设置(.pi/settings.json)会覆盖全局设置。嵌套对象会合并:
// ~/.pi/agent/settings.json(全局)
{
"theme": "dark",
"compaction": { "enabled": true, "reserveTokens": 16384 }
}
// .pi/settings.json(项目)
{
"compaction": { "reserveTokens": 8192 }
}
// 结果
{
"theme": "dark",
"compaction": { "enabled": true, "reserveTokens": 8192 }
}