difit-review
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDifit Review
Difit 审查
Overview
概述
This skill launches a requested git diff in a viewer that is easy for humans to read. At the same time, the agent can attach arbitrary comments via the option.
This comment mechanism is well suited for code review findings and code explanations.
Before running commands, choose using the following rule:
--comment<difit-command>- If succeeds, use
command -v difit.difit - Otherwise, use .
npx difit - If falling back to would require network access in a sandboxed environment without network permission, request escalated permissions and user approval before running it.
npx difit
该Skill会在一款易于人类阅读的查看器中启动指定的git diff,同时Agent可通过参数添加任意评论。
这种评论机制非常适合用于代码审查结果和代码解释的展示。
在运行命令前,请根据以下规则选择:
--comment<difit-command>- 若执行成功,则使用
command -v difit。difit - 否则,使用。
npx difit - 若在无网络权限的沙箱环境中回退到需要网络访问,请先申请提升权限并获得用户批准后再运行。
npx difit
Steps
步骤
The final command typically looks like this:
bash
<difit-command> <target> [compare-with] \
--comment '{"type":"thread","filePath":"src/foobar.ts","position":{"side":"old","line":102},"body":"line 1\nline 2"}' \
--comment '{"type":"thread","filePath":"src/example.ts","position":{"side":"new","line":{"start":36,"end":39}},"body":"Range comment for L36-L39"}'The detailed procedure is as follows.
- Identify the target diff and review its contents.
- Inspect the diff specified by the user. This may be a local git revision, a GitHub URL, a patch file, or something similar.
- Understand the diff normally, inspect surrounding code when needed, and think through the response required by the user's request, whether that is review findings, explanations, or something else.
- For PR reviews, inspect the PR locally and keep the review result limited to difit output. Do not post comments back to remote GitHub.
- Attach the prepared comments and launch difit.
- difit launch options
- Use to specify the target diff.
<difit-command> <target> [compare-with] - For uncommitted changes use , for working tree changes use
<difit-command> ., and for staged changes use<difit-command> working.<difit-command> staging - For PRs use . For stdin input, use a form such as
<difit-command> --pr <URL>.diff -u file1.txt file2.txt | <difit-command>
- Use
- Comment arguments
- Use for each comment.
type: "thread" - Write comment bodies in the language the user is using.
- Use for lines that exist on the target side of the diff.
position.side: "new" - Use for lines that exist only on the deleted side.
position.side: "old" - Use range comments for issues that span multiple lines.
- Use
- Additional argument for files not yet added to git
- For uncommitted changes, if you decide files not yet added to git should also appear in the diff, add .
--include-untracked
- For uncommitted changes, if you decide files not yet added to git should also appear in the diff, add
- Share the difit URL and finish the response.
- If there were no comments to attach, explicitly say so.
- No manual verification of the launched difit page is required.
最终命令通常如下所示:
bash
<difit-command> <target> [compare-with] \
--comment '{"type":"thread","filePath":"src/foobar.ts","position":{"side":"old","line":102},"body":"line 1\nline 2"}' \
--comment '{"type":"thread","filePath":"src/example.ts","position":{"side":"new","line":{"start":36,"end":39}},"body":"Range comment for L36-L39"}'详细流程如下:
- 确定目标diff并审查其内容。
- 检查用户指定的diff,这可能是本地git版本、GitHub URL、补丁文件或类似内容。
- 常规理解diff内容,必要时查看周边代码,思考用户请求所需的回应,无论是审查结果、代码解释还是其他内容。
- 对于PR审查,请在本地检查PR,并将审查结果限定在difit输出中,不要将评论发布到远程GitHub。
- 添加准备好的评论并启动difit。
- difit启动选项
- 使用指定目标diff。
<difit-command> <target> [compare-with] - 对于未提交的变更,使用;对于工作区变更,使用
<difit-command> .;对于暂存区变更,使用<difit-command> working。<difit-command> staging - 对于PR,使用。对于标准输入,可使用类似
<difit-command> --pr <URL>的形式。diff -u file1.txt file2.txt | <difit-command>
- 使用
- 评论参数
- 每条评论使用。
type: "thread" - 评论正文使用用户所使用的语言编写。
- 对于diff目标侧存在的行,使用。
position.side: "new" - 对于仅在删除侧存在的行,使用。
position.side: "old" - 对于跨多行的问题,使用范围评论。
- 每条评论使用
- 针对未添加到git的文件的额外参数
- 对于未提交的变更,若你认为未被git追踪的文件也应出现在diff中,请添加参数。
--include-untracked
- 对于未提交的变更,若你认为未被git追踪的文件也应出现在diff中,请添加
- 分享difit URL并完成回应。
- 若没有需要添加的评论,请明确说明。
- 无需手动验证已启动的difit页面。