Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(provider-sharing): inspect source lines in Git whitespace diagnostics
MagicLizi94641636a3a4
diff --git a/apps/desktop/src/main/remote-agent/executor/__tests__/gitCredentials.git-integration.test.ts b/apps/desktop/src/main/remote-agent/executor/__tests__/gitCredentials.git-integration.test.tsindex b28b7ddbc1..e8d9c59956 100644--- a/apps/desktop/src/main/remote-agent/executor/__tests__/gitCredentials.git-integration.test.ts+++ b/apps/desktop/src/main/remote-agent/executor/__tests__/gitCredentials.git-integration.test.ts@@ -223,6 +223,30 @@ describe('GitCredentialHistory', () => {expect(await provesSafe(history, 'git show blob-tag -- src')).toBe(false);});+ it('checks credential lines printed by whitespace diagnostics without blocking source checks', async () => {+ commit('credential baseline', '.env');+ write('.env', 'PRIVATE_FIXTURE=whitespace-check \n');+ write('src/app.ts', 'const changed = true; \n');+ const history = new GitCredentialHistory();+ const check = async (args: string[]) => {+ const output = spawnSync('git', args, { cwd: repo, encoding: 'utf8' });+ expect(output.stdout, args.join(' ')).toContain('PRIVATE_FIXTURE=whitespace-check');+ const command = 'git ' + args.join(' ');+ expect(await provesSafe(history, command), command).toBe(false);+ await requiresCredentialConfirmation(history, command);+ if (!args.includes('--stat')) {+ expect(await provesSafe(history, command + ' -- src/app.ts'), command).toBe(true);+ }+ };+ await check(['diff', '--check']);+ await check(['diff', '--stat', '--check']);+ git('add', '.env', 'src/app.ts');+ await check(['diff', '--cached', '--check']);+ git('commit', '-qm', 'whitespace change', '--no-gpg-sign');+ for (const sub of ['log', 'show']) await check([sub, '--check', '-1']);+ expect(await provesSafe(history, 'git diff --check')).toBe(true);+ });+it('keeps consent for implicit merge patches containing credentials', async () => {write('.env', 'PRIVATE_FIXTURE=base\n');git('add', '.env');diff --git a/apps/desktop/src/main/remote-agent/executor/gitCredentials.ts b/apps/desktop/src/main/remote-agent/executor/gitCredentials.tsindex 75dafa210b..e31c5449fc 100644--- a/apps/desktop/src/main/remote-agent/executor/gitCredentials.ts+++ b/apps/desktop/src/main/remote-agent/executor/gitCredentials.ts@@ -68,7 +68,7 @@ const MIXED_OUTPUT_OPTION = /^--(?:graph|stat|numstat|shortstat|dirstat|summary|* `--名称=值`、带数字的短选项或提交;否则插进去的选项可能被它当成取值(`git log -S <文件名>`)。*/const VALUELESS_OPTIONS: ReadonlySet<string> = new Set([- '-p', '-u', '--patch', '-W', '--function-context', '--cached', '--staged', '--merge-base', '-R',+ '-p', '-u', '--patch', '-W', '--function-context', '--cached', '--staged', '--merge-base', '-R', '--check','-a', '--text', '-w', '-b', '--ignore-all-space', '--ignore-space-change', '--ignore-blank-lines','--minimal', '--patience', '--histogram', '--word-diff', '--color-words', '--color', '--no-color','--no-ext-diff', '--no-textconv', '--no-prefix', '--full-index', '--binary', '-M', '-C', '-B', '--find-renames', '--no-renames',@@ -380,14 +380,19 @@ async function revisionsAreCovered(*/async function shownFilesArgs(read: GitRead, cwd: string): Promise<string[] | null> {const listing = SHOWN_FILES[read.sub];- if (!listing || read.args.some((arg) => MIXED_OUTPUT_OPTION.test(arg))) return null;+ const separator = read.args.indexOf('--');+ // --check prints source lines and conflicts with --name-only. Remove only+ // actual flags; preserve path operands and possible values of other options.+ const args = read.args.filter((arg, index) => !(arg === '--check'+ && (separator < 0 || index < separator) && cannotTakeNextAsValue(read.args[index - 1])));+ if (!listing || args.some((arg) => MIXED_OUTPUT_OPTION.test(arg))) return null;const objectsMustBeCommits = read.sub === 'diff' || read.sub === 'show';const resolves = (spec: string) => git(['rev-parse', '--verify', '--quiet', spec], cwd).then(() => true, () => false);- const separator = read.args.indexOf('--');- let insertAt = separator < 0 ? read.args.length : separator;+ const argsSeparator = args.indexOf('--');+ let insertAt = argsSeparator < 0 ? args.length : argsSeparator;let sawCommit = false;for (let index = 0; index < insertAt; index += 1) {- const arg = read.args[index];+ const arg = args[index];if (arg.startsWith('-')) continue;const range = arg.split(/\.\.\.?/);if (range.length > 1) {@@ -409,8 +414,8 @@ async function shownFilesArgs(read: GitRead, cwd: string): Promise<string[] | nuif (await exists(path.resolve(cwd, arg))) insertAt = index;}if (read.sub === 'show' && !sawCommit && !(await resolves('HEAD^{commit}'))) return null;- if (!cannotTakeNextAsValue(read.args[insertAt - 1])) return null;- return [listing.sub, ...read.args.slice(0, insertAt), ...listing.args, ...read.args.slice(insertAt)];+ if (!cannotTakeNextAsValue(args[insertAt - 1])) return null;+ return [listing.sub, ...args.slice(0, insertAt), ...listing.args, ...args.slice(insertAt)];}/**diff --git a/docs/product-rules/provider-sharing.md b/docs/product-rules/provider-sharing.mdindex 539d799c35..6c0d486a61 100644--- a/docs/product-rules/provider-sharing.md+++ b/docs/product-rules/provider-sharing.md@@ -360,6 +360,8 @@ Desktop「设置 → 模型供应商」的左栏(2026-10-08 用户裁决):重合并历史(`--remerge-diff`、`--diff-merges=remerge` 或配置选择的 remerge 模式)可能运行自定义 `merge.<driver>.driver`,非空时先保留确认。内部历史/文件列表探针固定逐父提交比较,不继承重合并配置、不运行 merge driver;普通 Git 查看不因仅存在 merge driver 就额外确认;+ `git diff/log/show --check` 的空白错误诊断会输出出错的源码行,因此同样按内容读取核实涉及的+ 文件;与统计等输出选项组合时也不直接豁免,限定到普通源码的检查仍可免确认;`git var -l` 与单个逻辑变量查询按实际输出检查,包含环境中的 editor/pager 及派生值,不能仅凭 Git 配置没有密钥就豁免;检查结果留在本机内存,不记录原始输出;`--bare` 这类改变仓库上下文的选项、前面的命令段可能修改 Git 状态、运行环境,或写法认不出时也不能豁免。diff --git a/packages/maker-core/src/agents/shared/auto-review.test.ts b/packages/maker-core/src/agents/shared/auto-review.test.tsindex 8b6396ee2d..ca5fed0414 100644--- a/packages/maker-core/src/agents/shared/auto-review.test.ts+++ b/packages/maker-core/src/agents/shared/auto-review.test.ts@@ -4997,6 +4997,18 @@ describe('shellCommandReadsCredentials — 分享任务的附加选项', () => {},);+ it.each([+ 'git diff --check', 'git diff --cached --check', 'git diff --stat --check',+ 'git log --check -1', 'git show --check HEAD', 'git whatchanged --check -1',+ ])('checks whitespace diagnostics as sharing content without changing local decisions: %s', (command) => {+ expect(shellCommandReadsCredentials(command, roots)).toBe(false);+ expect(classifyShellCommand(command, roots)).toBe('auto-approve');+ const collect = vi.fn(() => true);+ expect(shellCommandReadsCredentials(command, roots, { gitContentRead: collect })).toBe(false);+ expect(collect).toHaveBeenCalledExactlyOnceWith(expect.not.objectContaining({ metadataOnly: true }));+ expect(shellCommandReadsCredentials(command, roots, { gitContentRead: () => false })).toBe(true);+ });+it('checks sharing git show object types even when patch output is suppressed', () => {for (const command of ['git show -s deadbeef', 'git show --name-only deadbeef', 'git show --no-patch']) {expect(shellCommandReadsCredentials(command, roots), command).toBe(false);diff --git a/packages/maker-core/src/agents/shared/auto-review.ts b/packages/maker-core/src/agents/shared/auto-review.tsindex 8edb214a54..924da0d8fe 100644--- a/packages/maker-core/src/agents/shared/auto-review.ts+++ b/packages/maker-core/src/agents/shared/auto-review.ts@@ -6440,7 +6440,13 @@ function shellCommandReadsDotenv(const mode = arg.includes('=') ? arg.slice(arg.indexOf('=') + 1) : args[index + 1];return '--diff-merges'.startsWith(name) && mode !== 'off' && mode !== 'none';});- const readsContent = gitContentReadWithoutPath(invocation.sub, invocation.args) || probesShowObject || probesMergePatch;+ // Whitespace diagnostics print offending source lines even without -p,+ // including when --check is combined with a metadata output flag.+ const probesWhitespaceContent = sharesGitCredentialChecks+ && /^(?:diff|log|show|whatchanged)$/.test(invocation.sub)+ && invocation.args.includes('--check');+ const readsContent = gitContentReadWithoutPath(invocation.sub, invocation.args)+ || probesShowObject || probesMergePatch || probesWhitespaceContent;const probesRuntime = opts.gitContentRead !== undefined&& /^(?:diff|show|log|whatchanged|grep|cat-file|status|blame|ls-files|check-ignore)$/.test(invocation.sub);const checksContent = readsContent || probesRuntime || (sharesGitCredentialChecks