From 055cd85efaa98565ac404e9c8310073d7cdfc835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=8B=E7=AB=9F?= <1048927295@qq.com> Date: Fri, 24 Apr 2026 15:27:10 +0800 Subject: [PATCH] fix(cli): clean up /diff feature review issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove invalid `commandType` field from diffCommand (SlashCommand has no such property; caused a TS build failure). - Drop duplicate `NumstatResult` interface in gitDiff.ts — it is structurally identical to `GitDiffResult`. - Register the 9 missing `/diff` i18n strings in en.js / zh.js so the command is translatable (previously only `Configuration not available.` had entries). --- packages/cli/src/i18n/locales/en.js | 16 ++++++++++++++++ packages/cli/src/i18n/locales/zh.js | 15 +++++++++++++++ packages/cli/src/ui/commands/diffCommand.ts | 1 - packages/core/src/utils/gitDiff.ts | 7 +------ scripts/unused-keys-only-in-locales.json | 2 +- 5 files changed, 33 insertions(+), 8 deletions(-) diff --git a/packages/cli/src/i18n/locales/en.js b/packages/cli/src/i18n/locales/en.js index c2a427bdb..01b8a1535 100644 --- a/packages/cli/src/i18n/locales/en.js +++ b/packages/cli/src/i18n/locales/en.js @@ -153,6 +153,22 @@ export default { 'Configure authentication information for login', 'Copy the last result or code snippet to clipboard': 'Copy the last result or code snippet to clipboard', + 'Show working-tree change stats versus HEAD': + 'Show working-tree change stats versus HEAD', + 'Could not determine current working directory.': + 'Could not determine current working directory.', + 'Failed to compute git diff stats': 'Failed to compute git diff stats', + 'No diff available. Either this is not a git repository, HEAD is missing, or a merge/rebase/cherry-pick/revert is in progress.': + 'No diff available. Either this is not a git repository, HEAD is missing, or a merge/rebase/cherry-pick/revert is in progress.', + 'Clean working tree — no changes against HEAD.': + 'Clean working tree — no changes against HEAD.', + '{{count}} file changed, +{{added}} / -{{removed}}': + '{{count}} file changed, +{{added}} / -{{removed}}', + '{{count}} files changed, +{{added}} / -{{removed}}': + '{{count}} files changed, +{{added}} / -{{removed}}', + '…and {{hidden}} more (showing first {{shown}})': + '…and {{hidden}} more (showing first {{shown}})', + '(binary)': '(binary)', // ============================================================================ // Commands - Agents diff --git a/packages/cli/src/i18n/locales/zh.js b/packages/cli/src/i18n/locales/zh.js index 4c3c98ba6..2bfde8c6f 100644 --- a/packages/cli/src/i18n/locales/zh.js +++ b/packages/cli/src/i18n/locales/zh.js @@ -149,6 +149,21 @@ export default { 'Configure authentication information for login': '配置登录认证信息', 'Copy the last result or code snippet to clipboard': '将最后的结果或代码片段复制到剪贴板', + 'Show working-tree change stats versus HEAD': + '显示工作区相对 HEAD 的变更统计', + 'Could not determine current working directory.': '无法确定当前工作目录。', + 'Failed to compute git diff stats': '计算 git diff 统计失败', + 'No diff available. Either this is not a git repository, HEAD is missing, or a merge/rebase/cherry-pick/revert is in progress.': + '无可用 diff。可能不是 Git 仓库、HEAD 缺失,或正在执行 merge/rebase/cherry-pick/revert。', + 'Clean working tree — no changes against HEAD.': + '工作区干净 —— 与 HEAD 无差异。', + '{{count}} file changed, +{{added}} / -{{removed}}': + '{{count}} 个文件变更,+{{added}} / -{{removed}}', + '{{count}} files changed, +{{added}} / -{{removed}}': + '{{count}} 个文件变更,+{{added}} / -{{removed}}', + '…and {{hidden}} more (showing first {{shown}})': + '…还有 {{hidden}} 个(仅显示前 {{shown}} 个)', + '(binary)': '(二进制)', // ============================================================================ // Commands - Agents diff --git a/packages/cli/src/ui/commands/diffCommand.ts b/packages/cli/src/ui/commands/diffCommand.ts index af6adcc3d..cd67b9780 100644 --- a/packages/cli/src/ui/commands/diffCommand.ts +++ b/packages/cli/src/ui/commands/diffCommand.ts @@ -140,7 +140,6 @@ export const diffCommand: SlashCommand = { return t('Show working-tree change stats versus HEAD'); }, kind: CommandKind.BUILT_IN, - commandType: 'local', supportedModes: ['interactive', 'non_interactive', 'acp'] as const, action: diffAction, }; diff --git a/packages/core/src/utils/gitDiff.ts b/packages/core/src/utils/gitDiff.ts index f8b712585..63fd8756b 100644 --- a/packages/core/src/utils/gitDiff.ts +++ b/packages/core/src/utils/gitDiff.ts @@ -34,11 +34,6 @@ export interface GitDiffResult { perFileStats: Map; } -export interface NumstatResult { - stats: GitDiffStats; - perFileStats: Map; -} - const GIT_TIMEOUT_MS = 5000; /** Maximum files retained in per-file results. Matches issue #2997 "50 files" cap. */ export const MAX_FILES = 50; @@ -137,7 +132,7 @@ export async function fetchGitDiffHunks( * counts. Only the first `MAX_FILES` entries are kept in `perFileStats`, but * total stats account for every line. */ -export function parseGitNumstat(stdout: string): NumstatResult { +export function parseGitNumstat(stdout: string): GitDiffResult { const lines = stdout.split('\n').filter(Boolean); let added = 0; let removed = 0; diff --git a/scripts/unused-keys-only-in-locales.json b/scripts/unused-keys-only-in-locales.json index 8c0076ffd..abf3e862d 100644 --- a/scripts/unused-keys-only-in-locales.json +++ b/scripts/unused-keys-only-in-locales.json @@ -1,5 +1,5 @@ { - "generatedAt": "2026-04-22T15:40:32.318Z", + "generatedAt": "2026-04-24T07:26:06.808Z", "keys": [ " Models: Qwen latest models\n", " qwen auth qwen-oauth - Authenticate with Qwen OAuth (discontinued)",