Skip to content

feat: add interactive multi-turn chat REPL (mmx text repl)#141

Open
NianJiuZst wants to merge 5 commits into
MiniMax-AI:mainfrom
NianJiuZst:main
Open

feat: add interactive multi-turn chat REPL (mmx text repl)#141
NianJiuZst wants to merge 5 commits into
MiniMax-AI:mainfrom
NianJiuZst:main

Conversation

@NianJiuZst
Copy link
Copy Markdown
Contributor

@NianJiuZst NianJiuZst commented May 12, 2026

Summary

Closes #140

Adds mmx text repl — an interactive multi-turn chat REPL that maintains conversation context automatically, replacing the need to manually construct message history with repeated --message flags.

Motivation

mmx text chat requires users to manually pass full conversation history on each invocation:

mmx text chat --message "user:Hello" --message "assistant:Hi!" --message "user:How are you?"

mmx text repl gives a natural interactive experience:

mmx text repl
> Hello
...
> How are you?
...
> /exit

Features

Core REPL

  • Multi-turn conversation with automatic context management
  • Streaming response display with separated thinking / response sections
  • Full message history tracked across turns

Visual input area

  • Bordered input area (gray horizontal lines above and below the prompt)
  • Cursor always stays within the input area

Real-time slash command suggestions

  • Type / to instantly see all available commands below the input area
  • Suggestions filter as you type more characters — no Tab required
  • Disappears when the command is fully typed or / is deleted

Slash commands

Command Description
/exit Exit the conversation
/clear Clear conversation history (keeps system prompt)
/system [prompt] Show or set the system prompt
/model [model-id] Show or set the model
/save <path> Save conversation to a JSON file
/help Show available commands
/history Show messages with role labels and content preview

Line editing

  • Full keyboard navigation: arrow keys, Home/End, Ctrl+A/E/U/W
  • History navigation with arrow up/down
  • Tab automatic completion for slash commands
  • Double Ctrl+C to force quit; single interrupt during response streaming

Usage

mmx text repl                                     # Start with defaults
mmx text repl --model MiniMax-M2.7-highspeed      # Custom model
mmx text repl --system "You are a coding expert"  # System prompt
mmx text repl --temperature 0.7 --max-tokens 8192 # Tuning

Files changed

File Change
src/commands/text/repl.ts New file — REPL implementation (~420 lines)
src/registry.ts +2 lines — import and register text repl
test/commands/text/repl.test.ts New file — metadata and non-interactive rejection tests

Screenshots

4cc9cd26476ff7d7b1e46cf5b6f36c37

@RyanLee-Dev
Copy link
Copy Markdown
Collaborator

hello @NianJiuZst NianJiuZst 可以加一下我飞书
image

NianJiuZst and others added 5 commits May 12, 2026 22:02
Introduce a custom LineEditor class for interactive terminal input that
renders a bordered input area using ANSI escape sequences. The editor
supports:

- Arrow key navigation (left/right/home/end)
- History browsing (up/down)
- Emacs-style line editing (Ctrl+A, Ctrl+E, Ctrl+U, Ctrl+W)
- Backspace and delete
- Raw-mode keypress handling with per-character processing

The text repl command skeleton wires the editor to stdin and provides
a minimal /exit command. Chat integration will follow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wire up the slash command infrastructure in the text repl:

- Define 7 slash commands: /exit, /clear, /system, /model, /save, /help,
  /history
- Show filtered command suggestions below the input area in real time
  as the user types — no Tab key required
- Auto-hide suggestions when the command is fully typed or / is deleted
- Tab key auto-completes the only matching slash command
- handleSlash() dispatches typed commands to their handlers

The suggestion rendering reuses the LineEditor's existing ANSI layout,
appending matches below the bottom border outside the input area.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wire the REPL to the MiniMax Messages API for real chat:

- Introduce ReplState to track messages, model, system prompt, and sampling
  parameters across turns
- Implement sendMessages() with SSE streaming, thinking/response display
  separation, and automatic conversation history accumulation
- Wire /clear, /system, /model, /save, and /history slash commands to
  operate on the live conversation state
- Add SIGINT handler with double-Ctrl+C to quit and single-interrupt
  during response streaming
- Initialize state from CLI flags (--model, --system, --temperature, etc.)
  and config defaults

The echo placeholder is replaced with a full chat loop — each user message
is added to the conversation, streamed to the API, and the assistant
response is appended back to history.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wire the text repl command into the CLI's command trie so it is
discoverable via `mmx text repl` and shown in help output under
`mmx text --help`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verify command import, metadata, option flags, and non-interactive
mode rejection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add interactive multi-turn chat REPL (mmx text repl)

2 participants