MoonshotAI / MoonshotAI/kimi-code
Large or multiline pasted ! commands are routed as prompts
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
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.
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.
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.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100