fix: generalize tmux prompt injection timing for kimi/qwen/opencode (#42)#44
Closed
xzq-xu wants to merge 1 commit intoHKUDS:mainfrom
Closed
fix: generalize tmux prompt injection timing for kimi/qwen/opencode (#42)#44xzq-xu wants to merge 1 commit intoHKUDS:mainfrom
xzq-xu wants to merge 1 commit intoHKUDS:mainfrom
Conversation
Fixes HKUDS#42 — prompt injection in tmux mode could fail for non-Claude CLIs because the old code only waited 1 second before sending keys, which is insufficient for slower-starting TUIs. Changes: 1. Add CLI detection for kimi, qwen (qwen-code), and opencode in command_validation.py, and include them in is_interactive_cli(). 2. Replace the Claude-specific _wait_for_claude_ready with a generic _wait_for_cli_ready that: - Checks for common TUI prompt indicators (❯, >, ›, $, %) - Falls back to a "content stabilized" heuristic (3 consecutive identical pane snapshots) for unknown CLIs - Polls up to 30 seconds instead of sleeping a fixed 1 second 3. Extract _inject_prompt_via_buffer helper that uses tmux load-buffer/paste-buffer for ALL interactive CLIs (not just Claude), preventing multi-line prompt escaping issues. 4. Add skip-permissions flags: - kimi: --yolo - qwen: --dangerously-skip-permissions - opencode: --yolo 5. Add 19 new tests covering CLI detection, readiness polling with stabilization fallback, and skip-permissions for all new CLIs. Made-with: Cursor
Contributor
Author
|
Closing in favor of a rebased PR — upstream merged #36 (kimi support + NativeCliAdapter refactor) which conflicts with this branch. Will re-submit the remaining improvements (generic readiness detection, buffer-based injection for all CLIs, qwen/opencode support) on top of current main. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #42 — prompt injection in tmux mode fails for non-Claude CLIs (kimi, qwen, opencode, etc.) because the old code only waited 1 second before
send-keys, which is insufficient for slower-starting TUIs._wait_for_claude_readywith_wait_for_cli_readythat polls up to 30 seconds using CLI-specific prompt indicators and a generic "content stabilized" fallback (3 consecutive identical pane snapshots). This works for any CLI, not just known ones._inject_prompt_via_bufferthat uses tmuxload-buffer/paste-bufferfor ALL interactive CLIs (previously only Claude used this). This prevents multi-line prompt escaping issues and is more reliable thansend-keys.is_kimi_command,is_qwen_command,is_opencode_commanddetectors and updatedis_interactive_cli()to include them.--yolo), qwen (--dangerously-skip-permissions), opencode (--yolo) — in both tmux and subprocess backends.Before vs After
sleep(1)+send-keys(broken)sleep(1)+send-keysTest plan
Made with Cursor