Repository navigation
fix(agent-runtime): feed pi's file-op collector the names it reads - #862
Merged
Merged
Conversation
A checkpoint's readFiles/modifiedFiles, and the <read-files> section a summary appends, are produced by pi's own extractFileOpsFromMessage, which switches on the lowercase names read/write/edit — the names pi's tools carry. PI-Desktop registers Read/Write/Edit, so the collector matched nothing and every checkpoint reported an empty file list (issue #827 read a compaction report that showed it). The conversion stays on our side of the boundary: withPiFileOpToolNames copies the entries handed to pi's prepareCompaction with exactly those three names respawned, so no stored byte changes and the common path allocates nothing. It is the smallest change that makes the collection work; the alternative — moving the whole tool namespace to pi's spelling — is a much larger contract change. Only those three names are converted, because pi's collector reads nothing else: Grep, Glob, Bash, plugin and MCP names keep the spelling we register.
…p fixture The build typechecks the tests too: Entry is a union, so the fixture entries need an intermediate cast, and prepareCompaction answers a discriminated Result that has to be narrowed before value is read.
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
摘要
修
#827排查时发现的一条缺陷:压缩检查点的文件清单永远为空。修法是在把条目交给 pi 的准备阶段时,把 pi 只认的三个工具名(read/write/edit)转成小写。不 closes 任何 issue。根因
检查点的
readFiles/modifiedFiles,以及摘要追加的<read-files>段,都由 pi 自己的extractFileOpsFromMessage产出。它switch (block.name)只匹配小写read/write/edit——即 pi 自己工具的名字;PI-Desktop 注册的是Read/Write/Edit,于是每次收集都匹配不到任何东西,检查点始终报出空文件清单。已核实(
@earendil-works/pi-coding-agent@0.86.1的dist/core/compaction/utils.js,其调用点在compaction.js与branch-summarization.js):整个 pi 包中"Read"出现 0 次。改法(最小改动,只动边界一侧)
新增
packages/agent-runtime/src/pi-file-ops.ts:PI_FILE_OP_TOOL_NAMES = { Read: "read", Write: "write", Edit: "edit" }withPiFileOpToolNames(entries):把交给 piprepareCompaction的条目复制一份并改写这三个名字的拼写。在
runtime.ts::prepareCompactionInput里接上:prepareCompaction(withPiFileOpToolNames(entries), …)。三条性质:
toBe级别有测试钉住)。Grep、Glob、Bash、插件与 MCP 名字保持我们注册的拼写,被摘要的文本只在 pi 真正消费该名字的地方变化。验证
packages/agent-runtime/src/pi-file-ops.test.ts(7 条,全部通过):prepareCompaction对照:同一段历史,接适配器时fileOps.read = ["src/a.txt"]、edited = ["src/a.ts"];不接适配器时三个集合都为空(正是这条缺陷的回归锁);read/edit,确认改变只发生在拼写层面。全量:
packages/agent-runtime957 passed(60 文件);pnpm docs:check通过(508 页,en/zh 双语镜像齐备)。文档
docs/spec/03-runtime/02-agent-runtime.md§5.1(上下文检查点保护)+ zh 镜像:说明文件清单来自 pi 的收集器、以及边界转换;说明
没有采用"把整个工具命名空间改成 pi 的小写拼写"的方案:那是跨 Rust/TS/UI/文档/历史数据的契约级改动,与本次缺陷的规模不匹配;本 PR 是能让收集生效的最小改动。