← 返回更新日志

Pi v0.27.0

2025-12-22 · GitHub 原文
### 破坏性变更 - **会话钩子 API 重新设计**:将 `branch` 事件合并到 `session` 事件中。移除了 `BranchEvent`、`BranchEventResult` 类型以及 `pi.on("branch", ...)`。请改用 `pi.on("session", ...)` 并配合 `reason: "before_branch" | "branch"`。`AgentSession.branch()` 现在返回 `{ cancelled }` 而非 `{ skipped }`。`AgentSession.reset()` 和 `switchSession()` 现在返回 `boolean` 类型(若被钩子取消则返回 false)。RPC 命令 `reset`、`switch_session` 和 `branch` 的响应数据中现在均包含 `cancelled` 字段。 ([#278](https://github.com/badlogic/pi-mono/issues/278)) ### 新增 - **会话生命周期钩子**:新增了 `before_*` 变体(`before_switch`、`before_clear`、`before_branch`),这些钩子会在操作执行前触发,并可通过返回 `{ cancel: true }` 来取消操作。新增了 `shutdown` 原因以支持优雅退出处理。 ([#278](https://github.com/badlogic/pi-mono/issues/278)) ### 修复 - **文件标签页补全显示**:文件路径不再被过早截断。文件夹现在会显示末尾的 `/`,并移除了冗余的“目录”/“文件”标签以最大化水平显示空间。 ([#280](https://github.com/badlogic/pi-mono/issues/280)) - **Bash 工具视觉行截断**:修复了折叠模式下 Bash 工具输出的行数计算问题,改为使用视觉行数计数(考虑换行)而非逻辑行数计数。现在与 `bash-execution.ts` 的行为保持一致。提取了共享的 `truncateToVisualLines` 工具函数。 ([#275](https://github.com/badlogic/pi-mono/issues/275))