Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 完善命令产物路径识别
david1ecb5271a9e3
diff --git a/apps/desktop/src/renderer/__tests__/generatedFiles.test.ts b/apps/desktop/src/renderer/__tests__/generatedFiles.test.tsindex 12504c5267..a10074731f 100644--- a/apps/desktop/src/renderer/__tests__/generatedFiles.test.ts+++ b/apps/desktop/src/renderer/__tests__/generatedFiles.test.ts@@ -206,6 +206,17 @@ describe('extractCommandOutputPathCandidates', () => {'Get-Content "inputs/source.md" && copy "inputs/source.md" \'artifacts/report.md\'',),).toEqual(['artifacts/report.md']);+ expect(+ extractCommandOutputPathCandidates("python -c \"from pathlib import Path; Path('out/report.md').write_text('ok')\""),+ ).toEqual(['out/report.md']);+ expect(+ extractCommandOutputPathCandidates("Path('out/data.bin').write_bytes(payload)"),+ ).toEqual(['out/data.bin']);+ expect(extractCommandOutputPathCandidates('cp source.txt output/')).toEqual(['output/']);+ expect(extractCommandOutputPathCandidates('copy source.txt output\\')).toEqual(['output\\']);+ expect(+ extractCommandOutputPathCandidates('cp inputs/a.txt inputs/b.txt output/'),+ ).toEqual(['output/']);});it('skips temp dirs, extension-less tokens, plain filenames and URLs', () => {diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/review/index.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/review/index.tsxindex 2a663c6680..34fc4fb234 100644--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/review/index.tsx+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/review/index.tsx@@ -43,7 +43,7 @@ export interface ReviewState {fileTreeVisible: boolean;/** diff 行是否自动换行。默认关闭,保留横向滚动。 */wordWrap: boolean;- /** 是否显示行内文字差异强调。对齐 Codex,默认开启。 */+ /** 是否显示行内文字差异强调。默认关闭,避免大文件审查时增加渲染开销。 */wordDiff: boolean;/** 是否用忽略空白模式读取 diff。默认关闭,避免影响 patch 类操作。 */hideWhitespace: boolean;diff --git a/apps/desktop/src/renderer/lib/generatedFiles.ts b/apps/desktop/src/renderer/lib/generatedFiles.tsindex d33ed40667..d2a85a2f1a 100644--- a/apps/desktop/src/renderer/lib/generatedFiles.ts+++ b/apps/desktop/src/renderer/lib/generatedFiles.ts@@ -87,7 +87,7 @@ function createdPathsFromToolUse(toolName: string, input: unknown): string[] {return [];}-/** 带扩展名(1–8 位字母数字,不含纯数字)的路径才算候选;`a.b.c` 取末段。 */+/** 文件候选需带扩展名;复制命令的目录目标可用末尾分隔符明确表达。 */const EXT_RE = /\.[A-Za-z][A-Za-z0-9]{0,7}$/;/** 临时目录里的产物是脚本自身/中间文件的高发区,一律不算「本轮产出」。 */@@ -96,7 +96,7 @@ const TEMP_DIR_RE = /(^|[\\/])(tmp|temp)([\\/])|[\\/]AppData[\\/]Local[\\/]Temp[function isPathCandidate(raw: string): boolean {const s = raw.trim();if (s.length < 3 || s.length > 512) return false;- if (!EXT_RE.test(s)) return false;+ if (!EXT_RE.test(s) && !/[\\/]$/.test(s)) return false;if (TEMP_DIR_RE.test(s)) return false;// 绝对路径,或含分隔符的相对路径(交给 resolveToolFilePath 按 workingDir 解析)。// 纯文件名(`输出.xlsx`)不收:随机带点 token 误报率太高。@@ -111,6 +111,9 @@ interface CommandPathToken {end: number;}+const RELATIVE_PATH_TOKEN_RE =+ /(?:^|[\s=(,>])([^\s'"<>|?*]+[\\/])(?=$|[\s'"<>|])/g;+/** 提取路径 token 及其在命令中的位置;写出语义需要靠相邻文本判断。 */function extractCommandPathTokens(command: string): CommandPathToken[] {if (!command) return [];@@ -145,6 +148,13 @@ function extractCommandPathTokens(command: string): CommandPathToken[] {const start = (m.index ?? 0) + m[0].length - m[1].length;if (!insideQuotedRange(start)) push(m[1], start, start + m[1].length);}+ for (const m of command.matchAll(RELATIVE_PATH_TOKEN_RE)) {+ const raw = m[1];+ const start = (m.index ?? 0) + m[0].length - raw.length;+ if (!insideQuotedRange(start) && !/^https?:\/\//i.test(raw)) {+ push(raw, start, start + raw.length);+ }+ }return out.sort((a, b) => a.start - b.start || a.end - b.end);}@@ -182,6 +192,7 @@ function isExplicitOutputPath(const after = command.slice(token.end, token.end + 80);if (WRITE_CALL_PREFIX_RE.test(before) ||+ /^\s*['"]?\s*\)\s*\.\s*write_(?:text|bytes)\s*\(/i.test(after) ||isPowerShellOutputPosition(before) ||OUTPUT_OPTION_PREFIX_RE.test(before) ||REDIRECT_PREFIX_RE.test(before) ||@@ -218,8 +229,13 @@ function isExplicitOutputPath(const segment = command.slice(segmentStart, segmentEnd);const lastPath = tokens.filter((candidate) => candidate.start >= segmentStart && candidate.end <= segmentEnd)+ .sort((a, b) => a.start - b.start || a.end - b.end).at(-1);- return lastPath === token && /(?:^|[|]\s*)\s*(?:cp|copy|Copy-Item)\b/i.test(segment);+ return (+ lastPath?.start === token.start &&+ lastPath.end === token.end &&+ /^(?:cp|copy|Copy-Item)\s+/i.test(segment.trim())+ );}/**