Show the escalation confirmation prompt. Returns one of: (True, None) — proceed with suggested CLI (False, None) — skip escalation ("switch", cli_name) — user wants a specific different CLI ("redirect", instru
(
self,
cli: PeerCLI,
task_type: str,
user_message: str,
)
| 198 | return "\n".join(lines) |
| 199 | |
| 200 | def confirm( |
| 201 | self, |
| 202 | cli: PeerCLI, |
| 203 | task_type: str, |
| 204 | user_message: str, |
| 205 | ) -> Tuple: |
| 206 | """ |
| 207 | Show the escalation confirmation prompt. |
| 208 | |
| 209 | Returns one of: |
| 210 | (True, None) — proceed with suggested CLI |
| 211 | (False, None) — skip escalation |
| 212 | ("switch", cli_name) — user wants a specific different CLI |
| 213 | ("redirect", instruction) — user gave Codey a new instruction |
| 214 | """ |
| 215 | from utils.logger import console |
| 216 | available_names = [c.name for c in self.available()] |
| 217 | others = [n for n in available_names if n != cli.name] |
| 218 | |
| 219 | separator() |
| 220 | console.print("\n[bold yellow] ⚠ Codey hit max retries and needs help.[/bold yellow]") |
| 221 | console.print(f" Task: [dim]{user_message[:80]}{'…' if len(user_message) > 80 else ''}[/dim]") |
| 222 | console.print(f" Suggest: [bold cyan]{cli.description}[/bold cyan] [dim]({task_type} task)[/dim]") |
| 223 | if others: |
| 224 | console.print(f" Fallbacks: [dim]{', '.join(others)}[/dim]") |
| 225 | console.print() |
| 226 | console.print(" [bold]Your options:[/bold]") |
| 227 | console.print(f" [green]y / enter[/green] Call {cli.description}") |
| 228 | console.print(f" [red]n[/red] Skip — return control to you") |
| 229 | if others: |
| 230 | console.print(f" [cyan]{' | '.join(others)}[/cyan]" |
| 231 | f"{'':>4}Use that CLI instead") |
| 232 | console.print(f" [cyan]<any text>[/cyan] Tell Codey to try differently\n") |
| 233 | |
| 234 | try: |
| 235 | ans = console.input(" → ").strip() |
| 236 | except (EOFError, KeyboardInterrupt): |
| 237 | return False, None |
| 238 | |
| 239 | if not ans or ans.lower() in ("y", "yes"): |
| 240 | return True, None |
| 241 | if ans.lower() in ("n", "no"): |
| 242 | return False, None |
| 243 | # Check if the answer is a known CLI name |
| 244 | by_name = {c.name: c for c in self.available()} |
| 245 | if ans.lower() in by_name: |
| 246 | return "switch", ans.lower() |
| 247 | # Otherwise treat as a redirect instruction to Codey |
| 248 | return "redirect", ans |
| 249 | |
| 250 | def call(self, cli: PeerCLI, prompt: str) -> str: |
| 251 | """ |