diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-23 02:58:34 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-23 02:58:34 +0300 |
| commit | cbcf0e6f5ad3ed81fa96caa528cbef3b37145ac7 (patch) | |
| tree | 31ca3d911d7c5e8e73c9027e53582cc210482be2 | |
| parent | 09d9ddde97d5def9107c9ad6a0939bf12703203e (diff) | |
fix: detect kiro approval prompts as blocked
refs #255
| -rw-r--r-- | src/detect.rs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/detect.rs b/src/detect.rs index 9b973678..e50c3ad9 100644 --- a/src/detect.rs +++ b/src/detect.rs @@ -434,12 +434,20 @@ fn has_kimi_working_status(content: &str) -> bool { /// Kiro CLI detection. /// -/// Kiro exposes reliable working and idle terminal markers. Confirmation -/// prompts currently render as normal inline conversation followed by the input -/// prompt, so they are intentionally treated as idle instead of guessing. +/// Kiro exposes reliable working and idle terminal markers. Tool approval +/// prompts render with a stable "requires approval" line and an action menu. fn detect_kiro(content: &str) -> AgentState { let lower = content.to_lowercase(); + let has_approval_request = lower.contains("requires approval"); + let has_approval_actions = lower.contains("yes, single permission") + || lower.contains("trust, always allow") + || lower.contains("no (tab to edit)") + || lower.contains("esc to close"); + if has_approval_request && has_approval_actions { + return AgentState::Blocked; + } + if lower.contains("kiro is working") || (lower.contains("esc to cancel") && has_kiro_tool_spinner(content)) { @@ -2125,6 +2133,12 @@ mod tests { } #[test] + fn kiro_blocked_on_tool_approval_prompt() { + let screen = "↓ Shell mkdir -p /tmp/test-kiro-{a,b,c} && ls /tmp/test-kiro-*\n\n─────────────────────────────────────────────────────────────────────────────────────────\n shell requires approval\n ❯ Yes, single permission\n Trust, always allow in this session\n No (Tab to edit)\n─────────────────────────────────────────────────────────────────────────────────────────\n ESC to close | Tab to edit"; + assert_eq!(detect_state(Some(Agent::Kiro), screen), AgentState::Blocked); + } + + #[test] fn kiro_does_not_treat_stale_failure_spinner_as_working() { let screen = "● 1 MCP failure — see /mcp\n─────────────────────────────────────────────────────\nKiro · auto · ◔ 6%\n\n ask a question or describe a task ↵"; assert_eq!(detect_state(Some(Agent::Kiro), screen), AgentState::Idle); |
