feat(kiro_cli): add full TUI mode support with --legacy-ui fallback (#159)#163
Conversation
…159) Remove hardcoded --legacy-ui from launch command and add TUI-native status detection and message extraction. The provider now: - Launches in TUI mode by default, falls back to --legacy-ui on timeout - Detects COMPLETED via ▸ Credits: marker + idle prompt (TUI path) - Extracts messages using separator (────) boundaries when no green arrows - Retains full backward compatibility with legacy UI patterns Also adds "aren't available" to e2e REFUSAL_KEYWORDS for Claude Code test fix. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| Ask a question or describe a task | ||
|
|
||
| Strategy: | ||
| 1. Find the last Credits line (response end marker) |
There was a problem hiding this comment.
Could this be simplified by detecting the ghost text "Kiro is working" present in the user prompt space? Unless waiting for a tool permission, the "Kiro is working" text is always present when the agent is not idle. When a permission request appears the text changes to Yes, No and Always Allow for this session.
Ghost text
Tool permission
There was a problem hiding this comment.
Implemented — added TUI_PROCESSING_PATTERN = r'Kiro is working' as a positive PROCESSING signal (checked first in get_status()), and TUI_PERMISSION_PATTERN = r'Yes\s+No\s+Always [Aa]llow' for TUI permission prompt detection that triggers WAITING_USER_ANSWER. Both are in the latest commits.
| return TerminalStatus.PROCESSING | ||
|
|
||
| # Check 5: TUI completion — Credits marker + idle prompt after it. | ||
| # In pure TUI mode, there are no green arrows. Completion is indicated |
There was a problem hiding this comment.
Kiro in TUI mode allows queuing messages while the agent is working. The prompt remains in the queue until the current loop completes. It is similar to the current behaviour. Maybe exact checks for agent completion can be relaxed in the future and leverage the in-built functionality.
There was a problem hiding this comment.
@jwalaQ Acknowledged — thanks for the insight on native queuing. CAO currently requires a strict send → wait for COMPLETED → extract response cycle across all providers (including Claude Code, which also supports native queuing). This is because CAO needs to extract each response to return it via the API, route it between agents (handoffs/assigns), and store conversation history. Relaxing completion checks would require a new CAO-level API contract (e.g., fire-and-forget with async response collection), which is a broader architectural change beyond this PR. Noted as a potential future optimization.
Also cao at the moment do not support "queuing message" for any providers, including Claude code, which by itself supports queuing messages long ago.
- Raise separator minimum from 4 to 20 chars to avoid matching short markdown separators in agent output (jwalaQ comment #4) - Remove redundant ANSI cleanup in _extract_tui_message — input is already ANSI-stripped by caller (jwalaQ comment #5) - Improve timeout error message wording (jwalaQ comment #3) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add "Kiro is working" ghost text as positive PROCESSING signal, checked before idle prompt absence (jwalaQ comment #1) - Add TUI permission pattern "Yes No Always Allow" alongside legacy [y/n/t] format, requires all three options to avoid false positives on bare "Yes"/"No" in agent output (jwalaQ comment #2) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…output Verified against real kiro-cli v1.29.1 TUI output via tmux capture-pane: - Idle prompt is "Ask a question or describe a task" (capital A, no comma) - Pattern now accepts both old (lowercase, comma) and new formats - Updated fixtures to use real TUI output format - Updated inline test strings to match v1.29+ output Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@jwalaQ thanks very much for you looking into this, can you please review again, i believe your comments are addressed. |
…utput separators (#159) Changed _extract_tui_message() to find the first separator after the previous turn's Credits line instead of the last separator before the current Credits. This prevents false matches when agent output contains box-drawing separator characters. Also updated docs for launch command. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| ──────────────────────────────────────────────────── | ||
| What files are in this directory? | ||
|
|
||
| Analyzing the directory structure... |
There was a problem hiding this comment.
Add the "Kiro is working" ghost text here as well?
…#159) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Thanks for this PR! |
Title
feat(kiro_cli): add full TUI mode support with --legacy-ui fallback (#159)
Summary
--legacy-uifrom the Kiro CLI launch command — the provider now launches in TUI mode by default and auto-detects the output format▸ Credits:completion marker detection for TUI mode (TUI_CREDITS_PATTERN) alongside existing green arrow detection for legacy mode_extract_tui_message()) as fallback when no green arrows are found in pure TUI output--legacy-uiretry fallback ininitialize()— if TUI init times out, the provider sends/exitand retries with--legacy-uiautomatically"aren't available"to e2eREFUSAL_KEYWORDSto fix a Claude Code test false positiveWhat changed
src/cli_agent_orchestrator/providers/kiro_cli.pyTUI_SEPARATOR_PATTERN = r"^[─]{4,}$",TUI_CREDITS_PATTERN = r"▸\s*Credits:\s*[\d.]+"initialize()/exit+--legacy-uifallback on timeoutget_status()COMPLETED; Credits without idle →PROCESSING_extract_tui_message()▸ Credits:, skips user message paragraph, extracts agent responseextract_last_message_from_script()_extract_tui_message()when no green arrows foundStatus detection flow (updated)
test/providers/test_kiro_cli_unit.pytest_initialize_success— assertskiro-cli chat --agent developer(no--legacy-ui)test_initialize_kiro_cli_timeout— expects "both TUI and --legacy-ui failed"test_initialize_legacy_ui_fallback— verifies TUI fail →/exit→--legacy-uiretryTestKiroCliTuiModeclass (11 tests):test/providers/fixtures/(4 new files)kiro_cli_tui_idle_output.txt— separator + header + idle promptkiro_cli_tui_completed_output.txt— user msg + agent response + Credits + idlekiro_cli_tui_processing_output.txt— no idle prompt visiblekiro_cli_tui_complex_response.txt— code blocks, multiple paragraphs + Creditsdocs/kiro-cli.md--legacy-uiby default)--legacy-uiwrapperstest/e2e/test_allowed_tools.py"aren't available"toREFUSAL_KEYWORDS(fixes Claude Codetest_reviewer_cannot_writefalse positive)Test plan
--legacy-uifallback triggers correctly when TUI is unavailable (e.g., older kiro-cli version)Closes #159