feat: Implement Plan Mode for Safe Code Planning (#658)

This commit is contained in:
tanzhenxin
2025-09-24 14:26:17 +08:00
committed by GitHub
parent 8379bc4d81
commit 4e7a7e2656
43 changed files with 2895 additions and 281 deletions

View File

@@ -883,6 +883,16 @@ function toToolCallContent(toolResult: ToolResult): acp.ToolCallContent | null {
type: 'content',
content: { type: 'text', text: todoText },
};
} else if (
'type' in toolResult.returnDisplay &&
toolResult.returnDisplay.type === 'plan_summary'
) {
const planDisplay = toolResult.returnDisplay;
const planText = `${planDisplay.message}\n\n${planDisplay.plan}`;
return {
type: 'content',
content: { type: 'text', text: planText },
};
} else if ('fileDiff' in toolResult.returnDisplay) {
// Handle FileDiff
return {
@@ -954,6 +964,15 @@ function toPermissionOptions(
},
...basicPermissionOptions,
];
case 'plan':
return [
{
optionId: ToolConfirmationOutcome.ProceedAlways,
name: `Always Allow Plans`,
kind: 'allow_always',
},
...basicPermissionOptions,
];
default: {
const unreachable: never = confirmation;
throw new Error(`Unexpected: ${unreachable}`);