← 返回更新日志

Pi v0.62.0

2026-03-23 · GitHub 原文
### 新功能 - 内置工具现作为可扩展的 ToolDefinition。扩展作者现在可以使用自定义的 `renderCall`/`renderResult` 组件来覆盖内置的 read/write/edit/bash/grep/find/ls 工具的渲染逻辑。详见 [docs/extensions.md](docs/extensions.md)。 - 通过 `sourceInfo` 统一来源追溯。所有资源、命令、工具、技能(skills)和提示词模板现在都携带结构化的 `sourceInfo`,包含路径、作用域和来源元数据。这些信息在自动补全、RPC 发现和 SDK 自省中可见。详见 [docs/extensions.md](docs/extensions.md)。 - AWS Bedrock 成本分配标记。在 `BedrockOptions` 上新增的 `requestMetadata` 选项会将键值对转发至 Bedrock Converse API,用于 AWS Cost Explorer 的分摊成本分配。 ### 破坏性变更 - 更改了 `ToolDefinition.renderCall` 和 `renderResult` 的语义。回退渲染现在仅在未为该插槽定义渲染器时发生。如果定义了 `renderCall` 或 `renderResult`,则必须返回一个 `Component`。 - 统一斜杠命令的来源追溯以使用 `sourceInfo`。RPC `get_commands`、`RpcSlashCommand` 和 SDK `SlashCommandInfo` 不再暴露 `location` 或 `path`。请改用 `sourceInfo` ([#1734](https://github.com/badlogic/pi-mono/issues/1734)) - 从 `Skill` 和 `PromptTemplate` 中移除了旧的 `source` 字段。请改用 `sourceInfo.source` 进行来源追溯 ([#1734](https://github.com/badlogic/pi-mono/issues/1734)) - 移除了 `ResourceLoader.getPathMetadata()`。资源来源追溯现在通过 `sourceInfo` 直接附加到已加载的资源上 ([#1734](https://github.com/badlogic/pi-mono/issues/1734)) - 从 `RegisteredCommand` 和 `RegisteredTool` 中移除了 `extensionPath`。请改用 `sourceInfo.path` 进行来源追溯 ([#1734](https://github.com/badlogic/pi-mono/issues/1734)) #### 迁移说明 资源、命令和工具的来源追溯现在统一使用 `sourceInfo`。 常见更新: - RPC `get_commands`:将 `path` 和 `location` 替换为 `sourceInfo.path`、`sourceInfo.scope` 和 `sourceInfo.source` - `SlashCommandInfo`:将 `command.path` 和 `command.location` 替换为 `command.sourceInfo` - `Skill` 和 `PromptTemplate`:将 `.source` 替换为 `.sourceInfo.source` - `RegisteredCommand` 和 `RegisteredTool`:将 `.extensionPath` 替换为 `.sourceInfo.path` - 自定义 `ResourceLoader` 实现:移除 `getPathMetadata()`,并直接从已加载的资源中读取来源追溯信息 示例: - `command.path` -> `command.sourceInfo.path` - `command.location === "user"` -> `command.sourceInfo.scope === "user"` - `skill.source` -> `skill.sourceInfo.source` - `tool.extensionPath` -> `tool.sourceInfo.path` ### 变更 - 内置工具现在像扩展中的自定义工具一样工作。要获取内置工具定义,请从 `@mariozechner/pi-coding-agent` 导入 `readToolDefinition` / `createReadToolDefinition()` 以及等效的 `bash`、`edit`、`write`、`grep`、`find` 和 `ls` 导出。 - 重构了 `buildSystemPrompt()`,使内置工具代码片段和工具本地指南来自内置 `ToolDefinition` 元数据,而跨工具和全局提示词规则仍保留在系统提示词构建中。 - 为内置、SDK 和扩展工具的 `pi.getAllTools()` 结果添加了结构化的 `sourceInfo` ([#1734](https://github.com/badlogic/pi-mono/issues/1734)) ### 修复 - 修复了扩展命令名称冲突的问题,允许名称重复的扩展同时加载。冲突的扩展命令现在会根据加载顺序获得数字调用后缀,例如 `/review:1` 和 `/review:2` ([#1061](https://github.com/badlogic/pi-mono/issues/1061)) - 修复了自动补全和命令发现中扩展命令、提示词模板和技能的斜杠命令来源归属问题 ([#1734](https://github.com/badlogic/pi-mono/issues/1734)) - 修复了自动调整图像大小的处理逻辑:对最终的 base64 负载强制执行内联图像大小限制;当调整大小无法生成安全图像时返回纯文本回退方案;并在 `read` 和 `@file` 自动调整大小路径中避免回退到原始图像 ([#2055](https://github.com/badlogic/pi-mono/issues/2055)) - 修复了 git 包的 `pi update` 命令:当获取的目标已匹配本地检出时,跳过破坏性的 reset、clean 和 reinstall 步骤 ([#2503](https://github.com/badlogic/pi-mono/issues/2503)) - 修复了打印和 JSON 模式:在非交互式启动期间接管 stdout,防止包管理器和无关输出干扰协议/输出 stdout ([#2482](https://github.com/badlogic/pi-mono/issues/2482)) - 修复了 cli-highlight 的自动检测功能:之前会将无语言标记的代码块中的普通文本误识别为编程语言,并将随机英文单词着色为关键字 - 修复了 Anthropic 的 thinking 禁用处理:当明确关闭 thinking 时,向具备推理能力的模型发送 `thinking: { type: "disabled" }` ([#2022](https://github.com/badlogic/pi-mono/issues/2022)) - 修复了跨 Google、Google Vertex、Gemini CLI、OpenAI Responses、Azure OpenAI Responses 以及 OpenRouter 支持的 OpenAI 兼容补全的显式 thinking 禁用处理 ([#2490](https://github.com/badlogic/pi-mono/issues/2490)) - 修复了 OpenAI Responses 的 replay 功能:通过将外部工具调用项 ID 哈希为受限的 `fc_<hash>` ID 来处理 - 修复了 OpenAI 兼容补全流:忽略 null 块而不是崩溃 ([#2466](https://github.com/badlogic/pi-mono/pull/2466) by [@Cheng-Zi-Qing](https://github.com/Cheng-Zi-Qing)) - 通过流式截断修复了 `truncateToWidth()` 处理超长字符串的性能问题 ([#2447](https://github.com/badlogic/pi-mono/issues/2447)) - 修复了标题内联代码块后 markdown 标题样式丢失的问题