← 返回更新日志

Pi v1.2.0

2026-10-12 · GitHub 原文
### 新功能 - **按密钥提供 OpenRouter 模型列表**:使用 OpenRouter 密钥时,Pi 仅列出该密钥可使用的模型,并显示该密钥对应的上下文大小、最大输出量和价格,包括在 `models.json` 中设置的区域端点。参见 [OpenRouter](https://github.com/earendil-works/pi/blob/v1.2.0/packages/coding-agent/docs/providers.md#openrouter)。 - **已发布配置 schema**:为 `settings.json`、`models.json`、按键绑定和主题添加 `$schema`,以便在编辑器中进行验证和自动补全。参见[设置](https://github.com/earendil-works/pi/blob/v1.2.0/packages/coding-agent/docs/settings.md)、[模型](https://github.com/earendil-works/pi/blob/v1.2.0/packages/coding-agent/docs/models.md)、[按键绑定](https://github.com/earendil-works/pi/blob/v1.2.0/packages/coding-agent/docs/keybindings.md)和[主题](https://github.com/earendil-works/pi/blob/v1.2.0/packages/coding-agent/docs/themes.md)。 - **远程会话中的剪贴板复制**:当 Pi 无法检测到远程会话时,例如从另一台机器连接到终端复用器的情况,`PI_CLIPBOARD_OSC52=1` 会将复制的文本发送到远程客户端的剪贴板。参见 [Pi 进程配置](https://github.com/earendil-works/pi/blob/v1.2.0/packages/coding-agent/docs/environment-variables.md#pi-process-configuration)。 - **Codemode 改进**:工具声明会显示整数、最小值/最大值和默认值等输入约束,codemode 行会显示已用时间和总耗时。参见 [Codemode](https://github.com/earendil-works/pi/blob/v1.2.0/packages/coding-agent/docs/codemode.md)。 - **扩展触发的运行也会触发 `before_agent_start`**:通过 `pi.sendMessage(..., { triggerTurn: true })` 启动的运行会经历与提示词相同的初始化流程。参见[事件与并发](https://github.com/earendil-works/pi/blob/v1.2.0/packages/coding-agent/docs/extensions.md#events-and-concurrency)。 ### 破坏性变更 - 在 `https://pi.dev/schemas/*.schema.json` 发布了为模型、设置、按键绑定和主题生成的配置 schema。主题 schema 已移至 `https://pi.dev/schemas/theme.schema.json`;启动时加载的主题现在会接受与后续重新加载相同的 schema 验证。请更新主题的 `$schema` 引用,在 `vars` 下定义可复用的颜色,并移除不受支持的元数据([#9880](https://github.com/earendil-works/pi/pull/9880)、[#10751](https://github.com/earendil-works/pi/pull/10751),由 [@christianklotz](https://github.com/christianklotz) 贡献) - 更改了 `before_agent_start`,使其也会在空闲时通过 `pi.sendMessage(..., { triggerTurn: true })` 启动运行时触发。`BeforeAgentStartEvent` 现在是以 `messageType` 为判别字段的联合类型:`"user"` 事件携带 `prompt` 和 `images`,`"custom"` 事件携带启动运行的 `message`,不含 `prompt`。处理器返回的消息会添加到这两种运行中,待处理的 `deliverAs: "nextTurn"` 消息会随自定义消息运行一起投递。仅应处理用户提示词的处理器必须检查 `event.messageType === "user"`([#10267](https://github.com/earendil-works/pi/issues/10267)、[#5581](https://github.com/earendil-works/pi/issues/5581)、[#10739](https://github.com/earendil-works/pi/pull/10739),由 [@davidbrai](https://github.com/davidbrai) 贡献) - 更改了会话状态,使其在运行启动期间(包括执行 `before_agent_start` 处理器时)被视为忙碌:`ctx.isIdle()` 为 false,`pi.sendMessage()` 会将消息排入正在启动的运行,而不是启动第二个运行并因“Agent is already processing”而失败;`pi.sendUserMessage()` 必须指定 `deliverAs`;在此期间发出的中止请求会在运行开始后将其中止([#10739](https://github.com/earendil-works/pi/pull/10739),由 [@davidbrai](https://github.com/davidbrai) 贡献) - 更改了 `pi mcp list --json`,对于提供资源的服务器,现在报告 `resources: true`,而不是 `resources` 和 `resourceTemplates` 的数量;Pi 不再在连接时列出资源([#10526](https://github.com/earendil-works/pi/issues/10526)) ### 新增 - 为工具定义添加了 `reachesTools`,使会调用其他工具的工具(例如 `codemode` 和 `tool_search`)能够声明一次调用可能涉及哪些工具;MCP 扩展用它来等待调用所需的服务器,并判断替代的 `codemode` 或 `tool_search` 工具是否能够调用 MCP 工具 - 为工具命名空间添加了 `aliases`;codemode 的 `describeNamespace()` 和 `searchTools()` 的 `namespace` 选项会匹配这些别名,MCP 命名空间使用服务器名称作为别名 - 新增按密钥提供的 OpenRouter 模型列表:使用 OpenRouter 密钥时,Pi 仅列出该密钥可使用的聊天模型,并显示该密钥对应的上下文大小、最大输出量和价格,同时考虑防护规则以及在 `models.json` 中设为基础 URL 的区域端点。该列表会被保存,并可在离线时使用([#10353](https://github.com/earendil-works/pi/issues/10353)、[#10672](https://github.com/earendil-works/pi/pull/10672),由 [@davidbrai](https://github.com/davidbrai) 贡献) - 添加了 `PI_CLIPBOARD_OSC52=1`,在写入本地剪贴板后通过 OSC 52 将复制的文本发送到终端,以便在 Pi 无法检测到远程会话时(例如从另一台机器连接终端复用器,或使用远程 IDE 守护进程的情况),将复制内容传送到远程客户端的剪贴板([#10826](https://github.com/earendil-works/pi/issues/10826)、[#10835](https://github.com/earendil-works/pi/issues/10835)、[#10114](https://github.com/earendil-works/pi/issues/10114)) - 在 codemode 工具行中添加了脚本运行时的已用时间以及完成后的总耗时,与 bash 行类似([#10708](https://github.com/earendil-works/pi/issues/10708)) ### 更改 - 更改了 `showHardwareCursor` 设置,使其仅使用终端光标,不再同时绘制 Pi 的反色光标 - 更改了 codemode 工具声明,将整数、最小值/最大值、长度、模式和默认值等输入约束作为属性注释中的 `@` 标签显示,让脚本能够看到这些约束,而无需工具在描述中重复它们([#10707](https://github.com/earendil-works/pi/issues/10707)) - 更改了 MCP 工具的 codemode 声明,直接列明结果类型(`content`、`structuredContent`、`isError`),而不是引用 `CallToolResult<T>`;此前 `describeTool()`、`searchTools()` 和 `ALL_TOOLS` 会显示该类型却未定义它。codemode 描述不再包含共享的 MCP 类型 - 更改了 `serializeConversation()`(用于上下文压缩、分支摘要和错误报告),使其省略思考块;回放的思考内容通常不在当前上下文中,因此包含这些内容可能导致摘要请求比它要总结的上下文更大,从而失败 ### 修复 - 修复了 codemode 忽略不在脚本第一行的 `// @options:` 行、导致脚本运行时未采用请求的 `timeout_ms` 的问题;现在此类调用会在脚本运行前报错失败([#10631](https://github.com/earendil-works/pi/issues/10631)) - 修复了 Mistral 流式响应在请求超时后于生成中途(例如长时间思考期间)被中止的问题;现在超时仅适用于等待响应头的阶段([#10609](https://github.com/earendil-works/pi/issues/10609)) - 修复了嵌套在主仓库中的 git worktree 内通过符号链接引用的 `AGENTS.md` 导致任何项目上下文文件都无法加载的问题([#10681](https://github.com/earendil-works/pi/issues/10681)) - 修复了 code mode 工具描述声称每次失败的工具调用都会使 Promise 拒绝的问题;声明了输出 schema 的工具即使失败也会兑现并返回其值(例如 `bash` 以非零退出码退出时) - 修复了通过 `pi.sendMessage(..., { triggerTurn: true })` 启动的运行在首次工具调用后移除 `before_agent_start` 中添加的系统提示词段落的问题;这会在运行中途改变提示词,并使提供商的提示词缓存每次运行失效两次([#10267](https://github.com/earendil-works/pi/issues/10267)、[#10739](https://github.com/earendil-works/pi/pull/10739),由 [@davidbrai](https://github.com/davidbrai) 贡献) - 修复了 codemode 在运行包含大量 `text()` 调用的脚本后阻塞进程数秒至数分钟的问题;此前拼接输出项的时间复杂度为平方级([#10678](https://github.com/earendil-works/pi/issues/10678)) - 修复了打印模式(`-p`)在最终响应因达到模型输出 token 上限而被截断时,不发出警告并以退出码 0 退出的问题;现在会打印部分文本,向 stderr 写入警告,并以退出码 1 退出([#10799](https://github.com/earendil-works/pi/issues/10799)) - 修复了 `pi mcp login --help` 和 CLI 文档将 `--timeout` 描述为仅限制等待浏览器的时间的问题;它限制的是整个登录过程([#10636](https://github.com/earendil-works/pi/issues/10636)) - 修复了 `extensions`、`skills`、`prompts` 和 `themes` 设置中的 `!pattern`、`+path` 和 `-path` 条目不展开 `~` 的问题,此前这会导致 `!~/skills/pdf` 等条目无法匹配任何内容([#10765](https://github.com/earendil-works/pi/issues/10765)) - 修复了提供资源的 MCP 服务器在所有资源列出完毕前不注册任何工具的问题;Pi 不再在连接时列出资源,因此 `/mcp` 和 `pi mcp list` 现在显示服务器是否提供资源,而不是资源数量([#10526](https://github.com/earendil-works/pi/issues/10526)) - 修复了服务器返回非对象的结构化内容(数组、`null` 或原始值,MCP 2026-07-28 允许这些类型)时 MCP 工具调用失败的问题;对于没有输出 schema 的 MCP 工具,其 codemode 声明现在将 `structuredContent` 的类型设为 `unknown`,而不是对象([#10416](https://github.com/earendil-works/pi/issues/10416)) - 修复了 Windows 上前一个锁文件夹仍在删除时,读取或写入 `auth.json` 因 `EPERM` 而失败的问题;Pi 现在会在报告错误前进行短暂重试([#10801](https://github.com/earendil-works/pi/issues/10801)) - 修复了 `openrouter/auto` 等 OpenRouter 路由模型显示每百万 token 费用为 -$1,000,000 的问题;OpenRouter 的负数占位价格现在按 0 处理([#10672](https://github.com/earendil-works/pi/pull/10672),由 [@davidbrai](https://github.com/davidbrai) 贡献) - 修复了提供商因语法大小、工具数量或联合类型限制而拒绝严格工具集时,Anthropic 请求失败的问题;Pi 现在会将优先工具改为非严格模式并重试一次([#10409](https://github.com/earendil-works/pi/issues/10409)) - 修复了未将“The upstream provider returned an error”视为临时提供商错误并进行重试的问题([#10842](https://github.com/earendil-works/pi/issues/10842)) - 修复了获得焦点的全屏覆盖层阻止通过鼠标滚轮滚动对话记录的问题([#10769](https://github.com/earendil-works/pi/issues/10769)) - 修复了分片的终端颜色响应将十六进制值泄漏到提示词输入区并打开外部编辑器的问题(相关报告:[#10256](https://github.com/earendil-works/pi/issues/10256)、[#10657](https://github.com/earendil-works/pi/issues/10657)) - 修复了自 1.1.0 起内嵌图像无法在 Herdr 中渲染的问题([#10774](https://github.com/earendil-works/pi/pull/10774),由 [@ogulcancelik](https://github.com/ogulcancelik) 贡献) - 修复了指定需按 Shift 输入的符号(如 `+` 或 `ctrl++`)的按键绑定在 Kitty 键盘协议或 modifyOtherKeys 下无法匹配的问题([#9880](https://github.com/earendil-works/pi/pull/9880),由 [@christianklotz](https://github.com/christianklotz) 贡献) - 修复了嵌入自定义编辑器的上下文压缩状态指示器使用默认弱化颜色,而不是像工作状态指示器一样使用编辑器边框颜色或思考级别颜色的问题([#10809](https://github.com/earendil-works/pi/issues/10809)、[#10810](https://github.com/earendil-works/pi/pull/10810),由 [@Jay-Madden](https://github.com/Jay-Madden) 贡献) - 修复了在等待 OAuth 刷新期间已取消或超时的 MCP 工具调用仍在刷新完成后被发送到服务器的问题([#10598](https://github.com/earendil-works/pi/issues/10598)) - 修复了 MCP OAuth 登录接受带有 `iss` 参数、但因未发现授权服务器元数据而无法验证该参数的授权响应的问题;现在登录会因颁发者不匹配而失败。由 [@AizenvoltPrime](https://github.com/AizenvoltPrime) 报告 - 修复了在 Node 24 或 26 上通过 `node --watch` 运行 Pi 时,codemode 因桥接连接损坏错误而失败的问题([#10725](https://github.com/earendil-works/pi/issues/10725)) ### 移除 - 移除了尚未发布的实验性服务器、客户端和插件栈(`src/experimental`、`src/cli/experimental`),以及仅存在于源码中的 `./client` 和 `./experimental/plugin` 导出;这些内容均未包含在已发布的软件包中。其使用的 `@earendil-works/pi-client`、`@earendil-works/pi-protocol` 和 `@earendil-works/pi-server` 软件包已移除,不再发布 - 移除了对 `@earendil-works/chord` 的依赖