MoonshotAI / MoonshotAI/kimi-code

feat(tui): run `!` shell commands interactively (PTY) so prompts can be answered

Open
#2,918 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
7.5k
Forks
1.2k
Avg merge
11h 53m
Merged PRs (30d)
350

Description

What feature would you like to see?

Run foreground ! shell commands interactively — under a PTY, with the user's keystrokes forwarded to the running command — so interactive commands can be answered.

Motivating example: !gh auth login prompts (Where do you use GitHub?, (Y/n)-style confirmations), but there is no way to answer. The same applies to ssh, sudo, npm init, scripts using read -p, etc. Today the only option is to leave the TUI and run these in a separate terminal.

Why it can't work today: ! commands reuse the agent's non-interactive Bash tool. The process is spawned with piped stdio and no TTY, and the RPC surface only exposes runShellCommand / cancelShellCommand — there is no path to forward user input to the running process. Note that a stdin pipe alone is not sufficient: gh auth login requires a TTY for its prompts (it hangs even with stdin redirected), so the motivating cases need a real PTY.

Proposal:

  • Spawn foreground ! commands with a PTY (node-pty is already a dependency of the CLI and agent-core).
  • While a ! command is running, route editor keystrokes to its stdin; keep Esc / Ctrl+C as cancel.
  • Stream and record output in the transcript as today (shell_command context message).

Deliberately out of scope: a persistent / stateful shell session (the !! mode proposed in #2213). This request is only about answering the prompts of a single foreground command.

Additional information

  • Related issues: #2213 (closed as not planned — a much broader persistent-shell request; this is the narrow slice), #2915 (raw escape sequences from foreground Bash output — PTY output makes control sequences unavoidable, so transcript rendering needs a decision: sanitize vs. interpret).
  • A stdin-only variant (forward keystrokes, no PTY) would cover simple line-based prompts (read -p) but not TTY-checking tools like gh / ssh / sudo; PTY seems required for the motivating cases.
  • Open questions for maintainers: PTY vs stdin-only; how the transcript should render control sequences; whether the recorded context should capture the raw stream or cleaned text.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Trace the existing runShellCommand and cancelShellCommand RPC paths and the TUI editor keystroke handling; node-pty is already listed as a CLI and agent-core dependency. Resolve the PTY and transcript-rendering questions, then verify that a foreground ! command accepts input, preserves Esc/Ctrl+C cancellation, and records its output.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, shell, typescript
Domain
cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.