(host: SlashCommandHost, args: string)
| 91 | } |
| 92 | |
| 93 | export async function handleYoloCommand(host: SlashCommandHost, args: string): Promise<void> { |
| 94 | const session = host.session; |
| 95 | if (session === undefined) { |
| 96 | host.showError(NO_ACTIVE_SESSION_MESSAGE); |
| 97 | return; |
| 98 | } |
| 99 | |
| 100 | const subcmd = args.trim().toLowerCase(); |
| 101 | const currentMode = host.state.appState.permissionMode; |
| 102 | |
| 103 | if (subcmd === 'on') { |
| 104 | if (currentMode === 'yolo') { |
| 105 | host.showNotice('YOLO mode is already on'); |
| 106 | return; |
| 107 | } |
| 108 | await session.setPermission('yolo'); |
| 109 | host.setAppState({ permissionMode: 'yolo' }); |
| 110 | host.showNotice('YOLO mode: ON', 'Workspace tools auto-approved.'); |
| 111 | return; |
| 112 | } |
| 113 | |
| 114 | if (subcmd === 'off') { |
| 115 | if (currentMode !== 'yolo') { |
| 116 | host.showNotice('YOLO mode is already off'); |
| 117 | return; |
| 118 | } |
| 119 | await session.setPermission('manual'); |
| 120 | host.setAppState({ permissionMode: 'manual' }); |
| 121 | host.showNotice('YOLO mode: OFF'); |
| 122 | return; |
| 123 | } |
| 124 | |
| 125 | // toggle |
| 126 | if (currentMode === 'yolo') { |
| 127 | await session.setPermission('manual'); |
| 128 | host.setAppState({ permissionMode: 'manual' }); |
| 129 | host.showNotice('YOLO mode: OFF'); |
| 130 | } else { |
| 131 | await session.setPermission('yolo'); |
| 132 | host.setAppState({ permissionMode: 'yolo' }); |
| 133 | host.showNotice('YOLO mode: ON', 'Workspace tools auto-approved.'); |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | export async function handleAutoCommand(host: SlashCommandHost, args: string): Promise<void> { |
| 138 | const session = host.session; |
no test coverage detected