MoonshotAI / MoonshotAI/kimi-code

feat: 支持 first-class apply_patch / 多 hunk patch 编辑工具

Open
#494 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
7.5k
Forks
1.2k
Avg merge
11h 53m
Merged PRs (30d)
350

Description

What feature would you like to see?

希望 Kimi Code 增加一个 first-class 的 patch 编辑原语,用来补充当前 Edit / Write 工具:

  • 支持单次提交多文件、多 hunk 的 add/update/delete/move patch。
  • 在写入前先解析并校验 patch,尽量提前发现路径、上下文、格式错误。
  • 如果上下文过期或 patch 无法应用,返回明确、可恢复的错误,而不是让模型反复尝试 exact string replacement。
  • 在审批 UI 中展示完整 diff,让用户能一次性审批或拒绝一组相关改动。
  • 在结果中返回修改文件列表、增删行统计、失败原因等结构化信息。

这个工具不需要替代现有 Edit / Write

  • 小范围精确替换仍然适合 Edit
  • 新建或全量覆盖文件仍然适合 Write
  • 跨多个文件、需要保留上下文、需要一次审批的变更更适合 patch 原语。
Additional information

当前代码里 Edit 是 exact string replacement:old_string / new_stringold_string 找不到或不唯一会失败;Write 则是整文件 overwrite/append。这两个工具对简单编辑很直接,但对大型 XML/JSON、重复文本、批量修改、多文件相关改动来说,模型容易进入反复替换失败或多次工具调用的循环。

我注意到已有 #56 在反馈“替换频繁失败报错”,所以这个 issue 不是重复报告单个 replace bug,而是建议讨论一个更通用的编辑原语:可验证、可展示 diff、可一次性应用多 hunk 的 patch 工具。

我也搜索过 apply_patchapply patchunified diffpatch editingmulti hunk,没有找到同主题 issue 或未合并 PR。

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing Edit and Write tool entry points and the failure discussion in issue #56. Compare their current replacement and overwrite behavior with the requested multi-file, multi-hunk patch workflow, then define completion around pre-application validation, reviewable diffs, structured results, and recoverable errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.