Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(auto-review): include network review targets

zqchris49738973ac59
diff --git a/packages/maker-core/src/agents/claude-code/__tests__/auto-review-policy.test.ts b/packages/maker-core/src/agents/claude-code/__tests__/auto-review-policy.test.ts
index c905323e48..bb12ec2870 100644
--- a/packages/maker-core/src/agents/claude-code/__tests__/auto-review-policy.test.ts
+++ b/packages/maker-core/src/agents/claude-code/__tests__/auto-review-policy.test.ts
@@ -8,7 +8,10 @@
*/
import { describe, expect, it } from 'vitest';
-import { classifyBuiltinToolForAutoReview } from '../auto-review-policy.js';
+import {
+ classifyBuiltinToolForAutoReview,
+ normalizeBuiltinToolForAutoReview,
+} from '../auto-review-policy.js';
const roots = ['/repo', '/extra']; // 工作区根:cwd + 一个额外目录
@@ -29,6 +32,25 @@ describe('classifyBuiltinToolForAutoReview — 只读与安全状态工具', ()
});
});
+describe('normalizeBuiltinToolForAutoReview — network review context', () => {
+ it('preserves the concrete URL or query for the lightweight reviewer', () => {
+ expect(normalizeBuiltinToolForAutoReview('WebFetch', {
+ url: 'https://example.com/status',
+ prompt: 'Summarize the response',
+ })).toEqual({
+ kind: 'network',
+ operation: 'WebFetch',
+ target: 'https://example.com/status',
+ });
+ expect(normalizeBuiltinToolForAutoReview('WebSearch', { query: 'current release notes' }))
+ .toEqual({
+ kind: 'network',
+ operation: 'WebSearch',
+ target: 'current release notes',
+ });
+ });
+});
+
describe('classifyBuiltinToolForAutoReview — 文件写(结构化 path 精确判定)', () => {
it('工作区内相对路径写 → auto-approve', () => {
expect(verdict('Write', { file_path: 'src/a.ts' })).toBe('auto-approve');
diff --git a/packages/maker-core/src/agents/claude-code/auto-review-policy.ts b/packages/maker-core/src/agents/claude-code/auto-review-policy.ts
index 6156a24586..491f65057c 100644
--- a/packages/maker-core/src/agents/claude-code/auto-review-policy.ts
+++ b/packages/maker-core/src/agents/claude-code/auto-review-policy.ts
@@ -79,6 +79,14 @@ function extractReadPath(toolName: string, input: unknown): string | undefined {
return candidates.find((c) => isSensitiveCredentialPath(c)) ?? candidates[0];
}
+function extractNetworkTarget(toolName: string, input: unknown): string | undefined {
+ if (!input || typeof input !== 'object' || Array.isArray(input)) return undefined;
+ const obj = input as Record<string, unknown>;
+ const key = toolName === 'WebFetch' ? 'url' : 'query';
+ const value = obj[key];
+ return typeof value === 'string' && value.trim() ? value : undefined;
+}
+
/**
* Auto-review 下对一个**内置工具调用**给出审查档位。仅在权限档为 `auto` 时调用
* (见 claude-code/index.ts 的 canUseTool dispatcher)。纯映射,判定逻辑全在 core。
@@ -111,7 +119,11 @@ export function normalizeBuiltinToolForAutoReview(
}
// WebFetch/WebSearch:把 URL/搜索词送往外部(exfil 面)→ 升级。
if (toolName === 'WebFetch' || toolName === 'WebSearch') {
- return { kind: 'network' };
+ return {
+ kind: 'network',
+ operation: toolName,
+ target: extractNetworkTarget(toolName, input),
+ };
}
// 未知 / 其它一切工具 → fail-closed 升级。
return { kind: 'other' };