Skip to content

feat: 兼容 PTC 模式 diff 展示 - #2

Merged
better-er merged 1 commit into
mainfrom
feat/ptc-mode-support
Sep 1, 2026
Merged

feat: 兼容 PTC 模式 diff 展示#2
better-er merged 1 commit into
mainfrom
feat/ptc-mode-support

Conversation

@better-er

Copy link
Copy Markdown
Owner

概述

兼容 PTC 模式下 edit/write 工具卡片的 diff 展示。

背景

DSH 的 PTC 模式通过 run_code 执行程序,程序内部调用 tools.edit()/tools.write()。这些子调用记录为 tool/code-dispatch 事件,前端渲染时 block.parentCallId 未被设置,导致原有 PTC 检测条件失效,diff 不显示。

修复

  • 检测条件:从 block.parentCallId !== undefined 改为 block.callId.includes(':code:'),可靠识别 run_code 子调用
  • diff 构建:从子调用的 argsRaw 中提取 old_string/new_stringcontent,动态构建 diff
  • write 说明write 是全文件覆写,无旧内容,只能显示全新增;精确 diff 应使用 edit

改动文件

文件 改动
lib/client.js extractDiffs 新增 PTC 分支,头部注释中文化
lib/index.js 注释中文化
README.md 新增 PTC 模式说明,去中文括号
package.json 版本 0.1.1 → 0.2.0,描述补充 PTC
.github/workflows/ci.yml 去中文括号
.github/workflows/release.yml 去中文括号

测试

  • 标准模式 edit/write:diff 正常显示 ✓
  • PTC 模式 edit:diff 正常显示 ✓
  • PTC 模式 write:全新增显示,符合预期 ✓

- 通过 callId 中的 :code: 标记识别 run_code 子调用

- 从 argsRaw 动态构建 edit/write 的 diff

- 修复中文括号、更新注释为中文、版本升至 0.2.0
@better-er
better-er merged commit 67601ae into main Sep 1, 2026
2 checks passed
@better-er
better-er deleted the feat/ptc-mode-support branch September 1, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant