Large or multiline pasted ! commands are routed as prompts
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- cli
Research direction
Start with packages/pi-tui/src/components/editor.ts and apps/kimi-code/src/tui/components/editor/custom-editor.ts, especially the paste-folding and ! detection paths cited in the report. Review the existing Kimi CLI editor and shell tests, then add coverage for 1,001-character and 11-line ! pastes. Done means expanded input beginning with ! routes to bash and removes the leading !, while ordinary large prompts remain unchanged.
Written by the indexing model from the issue text.
Description
What version of Kimi Code is running?
0.29.2, reproduced from main at d88b3775c9816c15ae82dea8b34794b1e729b5d0.
Which open platform/subscription were you using?
Not applicable. This reproduces before model invocation with a fresh KIMI_CODE_HOME.
Which model were you using?
Not applicable.
What platform is your computer?
Linux 6.17.0-20-generic x86_64 x86_64, xterm-compatible PTY, 120 x 40 cells.
What issue are you seeing?
Pasting a shell command beginning with ! into an empty prompt enters bash mode only when the paste is at most 1,000 characters and at most 10 lines. A paste above either threshold is submitted as a normal model prompt instead of a shell command.
The boundary is deterministic:
| Pasted input | Actual route |
|---|---|
1,000 characters beginning with ! |
bash |
1,001 characters beginning with ! |
prompt |
10 lines beginning with ! |
bash |
11 lines beginning with ! |
prompt |
In a fresh, logged-out test profile, the route is observable without executing either payload: the control reaches the shell path and reports Bash tool is not available, while the two large-paste cases reach the model path and report LLM not set, send "/login" to login.
What steps can reproduce the bug?
- Start Kimi Code in an interactive terminal with an empty prompt.
- As one paste operation, paste a valid shell command whose first character is
!and whose total length is 1,001 characters. A harmless example is!printf ok #followed by enoughxcharacters to reach 1,001 characters. - Press Enter.
- Observe that the input is handled as a normal prompt rather than a shell command.
- Repeat with exactly 1,000 characters as a control; it enters bash mode.
The same issue can be reproduced with an 11-line paste beginning with !; a 10-line paste is the control.
I reproduced the full route matrix twice through a real PTY. I also passed the bracketed-paste sequence through three stdin chunk patterns (one complete chunk, markers/content split across chunks, and fixed 37-character chunks); all retained the full expanded input and produced the same routing result.
What is the expected behavior?
When the expanded content pasted into an empty prompt begins with !, Kimi Code should enter bash mode regardless of whether the editor folds the paste for display. The leading ! should be removed from the expanded command exactly as it is for a short paste.
Additional information
The editor intentionally folds pastes over 10 lines or 1,000 characters into a [paste #...] marker (source). The custom editor checks this.getText().startsWith('!') only after that folding has happened (source), so it sees the marker rather than the expanded content.
Controls checked:
- Typing
!first and then pasting a large command remains in bash mode. - A large ordinary prompt remains in prompt mode and its expanded content is preserved.
- Existing Kimi CLI editor/shell tests and the complete pi-tui test suite pass; the current tests cover short
!pastes but not the folding boundary.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 41m
- Merged PRs (30d)
- 345
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MoonshotAI/kimi-code
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
MoonshotAI/kimi-code#3947 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
MoonshotAI/kimi-code#3836 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
MoonshotAI/kimi-code#3790 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
MoonshotAI/kimi-code#3755 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
MoonshotAI/kimi-code#3627 ·
All issues in MoonshotAI/kimi-code
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fullcalendar/fullcalendar#8106 ·