fix: allow YOLO when starting swarm tasks (#645)

This commit is contained in:
_Kerman 2026-06-11 14:34:35 +08:00 committed by GitHub
parent e37d7e5837
commit 1b58aa8cdf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 40 additions and 6 deletions

View file

@ -0,0 +1,5 @@
---
"@moonshot-ai/kimi-code": patch
---
Add a YOLO choice when starting swarm tasks from Manual mode.

View file

@ -71,7 +71,7 @@ async function startSwarmWithPermission(
prompt: string,
choice: SwarmStartPermissionChoice,
): Promise<void> {
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');
});

View file

@ -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<SwarmStartPermissionChoice>[] = [
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',

View file

@ -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' });

View file

@ -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 <task>` | — | Turn swarm mode on, then send `<task>` 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 <task>` | — | Turn swarm mode on, then send `<task>` 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

View file

@ -46,7 +46,7 @@
| `/plan [on\|off]` | — | 切换 Plan 模式。不带参数时翻转;显式传 `on`/`off` 时强制设置。单纯切换不会创建空计划文件 | 是 |
| `/plan clear` | — | 清除当前 plan 方案 | 否 |
| `/swarm on\|off` | — | 开启或关闭 swarm mode但不发送提示词。 | 是 |
| `/swarm <task>` | — | 先开启 swarm mode再把 `<task>` 作为普通提示词发送。如果该轮次正常完成swarm mode 会自动关闭。若当前是 `manual` 权限模式,启动前会提示是否切换到 `auto`。 | 否 |
| `/swarm <task>` | — | 先开启 swarm mode再把 `<task>` 作为普通提示词发送。如果该轮次正常完成swarm mode 会自动关闭。若当前是 `manual` 权限模式,启动前会提示是否切换到 `auto``yolo`。 | 否 |
| `/goal [...]` | — | 开始或管理目标模式 | 见下文 |
::: warning 注意