feat(fork): append_file 输出 inline unified diff - #2
Merged
h3c-hexin merged 3 commits intoJul 30, 2026
Conversation
append_file 此前只返回字节摘要,前端无法像 write_file 一样渲染 diff 预览。 追加前快照旧内容,输出 unified diff(尾部 context + 追加行),字节摘要保留在末尾; 已存文件超过 512KB(APPEND_FILE_INLINE_DIFF_LIMIT_BYTES)或非 UTF-8 时回退 [diff omitted] / 纯字节摘要。归属 T2 工具面主题,附 forkguard 结果式回归。
|
Thanks @asto18089 for taking the time to contribute. This repository is observing a maintainer-managed PR intake gate in dry-run mode, so this pull request is staying open. This note helps maintainers prepare the allowlist before any enforcement is considered. Please read |
审阅发现:追加前快照旧内容的 read_to_string 在 512KB 上限判断之前执行, 向超大文件(如数 GB 日志)追加会把整个文件读入内存。改为先用 metadata 的 before_len 门控,超限直接走 [diff omitted] 说明,不再读取;prior.len() 检查保留作为 metadata 与读取之间文件增长的兜底。 同时补齐非 UTF-8 旧文件回退纯字节摘要的 forkguard 回归测试。 Signed-off-by: asto <asto18089@126.com>
Author
|
审阅后推送修复 commit a1728d6:
验证: |
Signed-off-by: hexin <372726039@qq.com>
h3c-hexin
pushed a commit
to Pinvou/pinvou-agent
that referenced
this pull request
Jul 30, 2026
底座 append_file 输出 inline unified diff 后(Pinvou/CodeWhale#2),前端工具卡片 与 write_file 一样走 DiffView 渲染带行号、着色的 diff 预览;旧 session 落盘的 纯文本输出保留 appendBytes 字节摘要兜底。fork-guard 指纹与 fork-modifications.md 按同 PR 要求随 fork patch 登记。gitlink 与稳定 tag 待 fork PR 合并后本 PR 内更新。 Signed-off-by: hexin <372726039@qq.com>
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.
概述
append_file工具结果与write_file/edit_file一样在头部输出 inline unified diff(尾部 context + 追加行),字节摘要保留在末尾;pinvou3 前端工具卡片据此渲染与 write_file 一致的 diff 预览。背景
pinvou3 前端对 write_file / edit_file 已基于 unified diff 渲染带行号、着色的 diff 预览(DiffView);而 append_file 只返回
Appended N bytes (X -> Y bytes)纯文本,只能显示一行字节摘要。append_file 是大产物分块写入的主路径(skeleton + ≤16KB chunks),恰恰是最需要预览写入内容的场景。变更
AppendFileTool::execute追加前快照旧内容(已存文件非 UTF-8 时跳过,无可信 diff 基底),经新增append_file_result_body()输出 unified diff;原{action} N bytes (X -> Y bytes)字节摘要原样保留在末尾,兼容旧格式解析。APPEND_FILE_INLINE_DIFF_LIMIT_BYTES = 512KB:已存文件超过该值回退[diff omitted]提示。取 512KB 而非 write_file 的 32KB,是因为 append 是分块写大文件的路径,旧内容两次 16KB chunk 即超过 32KB;similar会裁剪公共前缀,diff 输出始终保持很小。forkguard_append_file_emits_inline_diff、forkguard_append_file_omits_inline_diff_for_huge_prior_contents两条结果式回归。验证
cargo test -p codewhale-tui --lib tools::file:76 passed(含 2 条新 forkguard 测试)./scripts/fork-guard.sh --fast指纹层全过;前端diff_viewer_ui_smoke.mjs(真实 Chrome 渲染)通过备注
pinvou-v0.9.0-r2:父仓scripts/verify-public-submodule.sh要求 gitlink 与固定 tag 解引用一致,父仓 PR 需要该 tag 才能通过 required-gate。