From 1b58aa8cdf675e6f4c02cd083feb55debbe9b3f1 Mon Sep 17 00:00:00 2001 From: _Kerman Date: Thu, 11 Jun 2026 14:34:35 +0800 Subject: [PATCH] fix: allow YOLO when starting swarm tasks (#645) --- .changeset/swarm-yolo-start-option.md | 5 ++++ apps/kimi-code/src/tui/commands/swarm.ts | 6 +++-- .../dialogs/swarm-start-permission-prompt.ts | 8 ++++++- .../kimi-code/test/tui/commands/swarm.test.ts | 23 ++++++++++++++++++- docs/en/reference/slash-commands.md | 2 +- docs/zh/reference/slash-commands.md | 2 +- 6 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 .changeset/swarm-yolo-start-option.md diff --git a/.changeset/swarm-yolo-start-option.md b/.changeset/swarm-yolo-start-option.md new file mode 100644 index 000000000..ed1f2766e --- /dev/null +++ b/.changeset/swarm-yolo-start-option.md @@ -0,0 +1,5 @@ +--- +"@moonshot-ai/kimi-code": patch +--- + +Add a YOLO choice when starting swarm tasks from Manual mode. diff --git a/apps/kimi-code/src/tui/commands/swarm.ts b/apps/kimi-code/src/tui/commands/swarm.ts index 01e3ae012..540aa5860 100644 --- a/apps/kimi-code/src/tui/commands/swarm.ts +++ b/apps/kimi-code/src/tui/commands/swarm.ts @@ -71,7 +71,7 @@ async function startSwarmWithPermission( prompt: string, choice: SwarmStartPermissionChoice, ): Promise { - if (choice === 'auto') { + if (choice === 'auto' || choice === 'yolo') { if (!(await setPermissionForSwarm(host, choice))) return; } await startSwarmTask(host, prompt); @@ -111,7 +111,9 @@ async function applySwarmMode( } if (enabled && host.state.appState.permissionMode === 'manual') { showSwarmStartPermissionPrompt(host, commandText, 'Swarm mode not enabled.', async (choice) => { - if (choice === 'auto' && !(await setPermissionForSwarm(host, choice))) return; + if ((choice === 'auto' || choice === 'yolo') && !(await setPermissionForSwarm(host, choice))) { + return; + } if (!(await setSwarmMode(host, true, 'manual'))) return; renderSwarmModeMarker(host, 'active'); }); diff --git a/apps/kimi-code/src/tui/components/dialogs/swarm-start-permission-prompt.ts b/apps/kimi-code/src/tui/components/dialogs/swarm-start-permission-prompt.ts index b4da0d851..694c0c0e6 100644 --- a/apps/kimi-code/src/tui/components/dialogs/swarm-start-permission-prompt.ts +++ b/apps/kimi-code/src/tui/components/dialogs/swarm-start-permission-prompt.ts @@ -3,7 +3,7 @@ import { type StartPermissionOption, } from './start-permission-prompt'; -export type SwarmStartPermissionChoice = 'auto' | 'manual'; +export type SwarmStartPermissionChoice = 'auto' | 'yolo' | 'manual'; export interface SwarmStartPermissionPromptOptions { readonly onSelect: (choice: SwarmStartPermissionChoice) => void; @@ -17,6 +17,12 @@ const OPTIONS: readonly StartPermissionOption[] = [ description: 'Best for swarm tasks. Tools are approved automatically, and questions are skipped.', }, + { + value: 'yolo', + label: 'Switch to YOLO and start', + description: + 'Tools and plan changes are approved automatically. Kimi Code may still ask you questions.', + }, { value: 'manual', label: 'Start in Manual', diff --git a/apps/kimi-code/test/tui/commands/swarm.test.ts b/apps/kimi-code/test/tui/commands/swarm.test.ts index c9427a710..3e3c9b11a 100644 --- a/apps/kimi-code/test/tui/commands/swarm.test.ts +++ b/apps/kimi-code/test/tui/commands/swarm.test.ts @@ -214,7 +214,7 @@ describe('handleSwarmCommand', () => { expect(host.sendNormalUserInput).not.toHaveBeenCalled(); const text = stripAnsi(mountedPicker(host).render(80).join('\n')); expect(text).toContain('Manual mode can block swarm work'); - expect(text).not.toContain('Switch to YOLO and start'); + expect(text).toContain('Switch to YOLO and start'); expect(text).not.toContain('Do not start'); }); @@ -242,6 +242,7 @@ describe('handleSwarmCommand', () => { await handleSwarmCommand(host, 'Ship feature X'); const picker = mountedPicker(host); picker.handleInput(DOWN); + picker.handleInput(DOWN); picker.handleInput(ENTER); await vi.waitFor(() => { @@ -254,6 +255,26 @@ describe('handleSwarmCommand', () => { expectSwarmMarker(host, 'Swarm activated'); }); + it('can start a Manual-mode swarm task after switching to YOLO', async () => { + const { host, session } = makeHost({ permissionMode: 'manual' }); + + await handleSwarmCommand(host, 'Ship feature X'); + const picker = mountedPicker(host); + picker.handleInput(DOWN); + picker.handleInput(ENTER); + + await vi.waitFor(() => { + expect(host.sendNormalUserInput).toHaveBeenCalledWith('Ship feature X'); + }); + expect(session.setPermission).toHaveBeenCalledWith('yolo'); + expect(session.setSwarmMode).toHaveBeenCalledWith(true, 'task'); + expect(session.setSwarmMode).toHaveBeenCalledTimes(1); + expect(host.setAppState).toHaveBeenCalledWith({ permissionMode: 'yolo' }); + expect(host.setAppState).toHaveBeenCalledWith({ swarmMode: true }); + expect(host.state.swarmModeEntry).toBe('task'); + expectSwarmMarker(host, 'Swarm activated'); + }); + it('returns the command to the input box when a Manual-mode swarm start is cancelled', async () => { const { host, session } = makeHost({ permissionMode: 'manual' }); diff --git a/docs/en/reference/slash-commands.md b/docs/en/reference/slash-commands.md index 36cd41421..f6eb04cae 100644 --- a/docs/en/reference/slash-commands.md +++ b/docs/en/reference/slash-commands.md @@ -48,7 +48,7 @@ Some commands are only available in the idle state. Executing these commands whi | `/plan [on\|off]` | — | Toggle Plan mode. Without arguments, flips the current state; explicitly passing `on`/`off` forces the setting. Simply toggling does not create an empty plan file | Yes | | `/plan clear` | — | Clear the current plan | No | | `/swarm on\|off` | — | Turn swarm mode on or off without sending a prompt. | Yes | -| `/swarm ` | — | Turn swarm mode on, then send `` as a normal prompt. If the turn completes normally, swarm mode turns off automatically. In `manual` permission mode, Kimi Code asks whether to switch to `auto` before starting. | No | +| `/swarm ` | — | Turn swarm mode on, then send `` as a normal prompt. If the turn completes normally, swarm mode turns off automatically. In `manual` permission mode, Kimi Code asks whether to switch to `auto` or `yolo` before starting. | No | | `/goal [...]` | — | Start or manage an autonomous goal | See below | ::: warning diff --git a/docs/zh/reference/slash-commands.md b/docs/zh/reference/slash-commands.md index 9bd4ef343..e475ddf7d 100644 --- a/docs/zh/reference/slash-commands.md +++ b/docs/zh/reference/slash-commands.md @@ -46,7 +46,7 @@ | `/plan [on\|off]` | — | 切换 Plan 模式。不带参数时翻转;显式传 `on`/`off` 时强制设置。单纯切换不会创建空计划文件 | 是 | | `/plan clear` | — | 清除当前 plan 方案 | 否 | | `/swarm on\|off` | — | 开启或关闭 swarm mode,但不发送提示词。 | 是 | -| `/swarm ` | — | 先开启 swarm mode,再把 `` 作为普通提示词发送。如果该轮次正常完成,swarm mode 会自动关闭。若当前是 `manual` 权限模式,启动前会提示是否切换到 `auto`。 | 否 | +| `/swarm ` | — | 先开启 swarm mode,再把 `` 作为普通提示词发送。如果该轮次正常完成,swarm mode 会自动关闭。若当前是 `manual` 权限模式,启动前会提示是否切换到 `auto` 或 `yolo`。 | 否 | | `/goal [...]` | — | 开始或管理目标模式 | 见下文 | ::: warning 注意