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): 确认卡预览保留浏览器参数与文件变更的类型、移动目标和补丁

Dash0b797e6ec270
diff --git a/packages/maker-shared/src/__tests__/interaction.test.ts b/packages/maker-shared/src/__tests__/interaction.test.ts
index 04b9299851..6e87fef2d8 100644
--- a/packages/maker-shared/src/__tests__/interaction.test.ts
+++ b/packages/maker-shared/src/__tests__/interaction.test.ts
@@ -22,6 +22,7 @@ import {
canStartInteractionResolve,
encodeMultiSelectAnswer,
extractPlanOutline,
+ describePermissionAction,
formatPermissionInput,
interactionBlocksRemoteComposer,
isFreeTextAskOptionLabel,
@@ -301,7 +302,16 @@ describe('interaction shared model', () => {
requestId: 'p-browser',
toolName: 'mcp:cindy_browser:call_tool',
input: { name: 'browser', args: { action: 'navigate', url: 'https://x.com/compose/post' } },
- })).toMatchObject({ title: '允许浏览器执行这一步?', code: 'navigate https://x.com/compose/post' });
+ })).toMatchObject({ title: '允许浏览器执行这一步?', code: expect.stringContaining('navigate {"url":"https://x.com/compose/post"}') });
+
+ // The summary must not hide what the user is approving (review 2026-10-24: recipe/typed text, move/diff).
+ expect(describePermissionAction('mcp:cindy_browser:call_tool', {
+ name: 'browser', args: { action: 'recipe', recipeId: 'post-reply', site: 'x.com', text: 'hello' },
+ }).preview).toBe('recipe {"recipeId":"post-reply","site":"x.com","text":"hello"}');
+ expect(describePermissionAction('file_change', { changes: [
+ { path: '/repo/a.ts', kind: { type: 'update', move_path: '/repo/b.ts' }, diff: '@@ -1 +1 @@' },
+ { path: '/repo/old.ts', kind: { type: 'delete' } },
+ ] }).preview).toBe('update /repo/a.ts \u2192 /repo/b.ts\n@@ -1 +1 @@\ndelete /repo/old.ts');
// A failed review shows its own fixed copy, never a stale model reason.
expect(buildPermissionReviewPresentation({
diff --git a/packages/maker-shared/src/interaction.ts b/packages/maker-shared/src/interaction.ts
index 9fe901483c..c24a3d07fb 100644
--- a/packages/maker-shared/src/interaction.ts
+++ b/packages/maker-shared/src/interaction.ts
@@ -918,15 +918,27 @@ function filePaths(input: Record<string, unknown>, search: boolean): string | nu
const direct = search ? readString(input.pattern) ?? readString(input.query) ?? path : path;
if (direct) return direct;
const changes = Array.isArray(input.changes) ? input.changes : isRecord(input.changes) ? Object.keys(input.changes) : [];
- const paths = changes.map((change) => typeof change === 'string' ? change : isRecord(change) ? readString(change.path) : null)
- .filter((path): path is string => !!path);
- return paths.length ? paths.join('\n') : null;
+ const lines = changes.map((change) => {
+ if (typeof change === 'string') return change;
+ if (!isRecord(change) || !readString(change.path)) return null;
+ // Keep what distinguishes delete / update / move and the patch itself.
+ const kind = isRecord(change.kind) ? readString(change.kind.type) : readString(change.kind);
+ const move = isRecord(change.kind) ? readString(change.kind.move_path) : null;
+ const head = `${kind ? `${kind} ` : ''}${change.path}${move ? ` \u2192 ${move}` : ''}`;
+ const diff = readString(change.diff);
+ return diff ? `${head}\n${diff}` : head;
+ }).filter((line): line is string => !!line);
+ if (!lines.length) return null;
+ const text = lines.join('\n');
+ return text.length > 500 ? `${text.slice(0, 500)}...` : text;
}
+/** Browser step: the action plus every other argument, so recipes, typed text and sites stay visible. */
function browserStep(args: Record<string, unknown>): string {
const action = readString(args.action);
- const target = readString(args.url) ?? readString(args.selector) ?? readString(args.text) ?? readString(args.targetId);
- return action ? [action, target].filter(Boolean).join(' ') : previewOf(args);
+ if (!action) return previewOf(args);
+ const { action: _action, ...rest } = args;
+ return [action, argsPreview(rest)].filter(Boolean).join(' ');
}
/**