Skip to content

feat(tui): support mid-prompt slash commands - #2496

Closed
BB-fat wants to merge 5 commits into
MoonshotAI:mainfrom
BB-fat:feat/mid-prompt-slash-commands
Closed

feat(tui): support mid-prompt slash commands#2496
BB-fat wants to merge 5 commits into
MoonshotAI:mainfrom
BB-fat:feat/mid-prompt-slash-commands

Conversation

@BB-fat

@BB-fat BB-fat commented Aug 1, 2026

Copy link
Copy Markdown

Related Issue

No linked issue — the problem is explained below.

Problem

Slash commands only work at the very start of the input: a skill or plugin
command can't be embedded in a natural prompt, and flipping a mode or opening
a panel (plan, model…) means clearing a half-typed prompt first.

What changed

  • Typing / mid-prompt (at a word boundary) now offers slash completions:
    skill/plugin commands plus a curated builtin set; other builtins stay
    leading-only. Bash mode and path fall-through behave as before.
  • Submitting text that embeds a registered /skill:name or
    /plugin:command activates it with the surrounding text as args
    (exact-name match only, so /tmp stays plain text). Blocked activations
    restore the draft.
  • Selecting a builtin mid-prompt runs it immediately in place — the /token
    is dropped from the draft (undoable) and the menu labels these
    "runs immediately". The set: plan, yolo, auto, permission, model, effort,
    secondary_model, usage, status, plus newly added settings, help, tasks,
    mcp, plugins, provider.
  • pi-tui: slash completion triggers at mid-line token boundaries;
    applyCompletion can return preventSubmit so confirming a completion
    doesn't also submit the editor text.
  • Docs updated (slash-commands reference + interaction guide, both locales);
    tests added for parsing/resolution, menu filtering and apply behavior,
    immediate triggers, and preventSubmit.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Aug 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ec0e4a6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/kimi-code Minor
@moonshot-ai/pi-tui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

BB-fat added 5 commits August 1, 2026 02:11
Allow selected slash commands to appear when typing `/` mid-prompt, and
activate skills/plugins embedded in free text on submit. Builtins that
only make sense at the start stay leading-only.
- applyCompletion only rewrites a /token prefix as a command name when
  the item is a registered slash command, so a mid-prompt path
  completion (e.g. 'please /tm' -> '/tmp/') no longer produces a
  doubled slash with a stray trailing space.
- Update plugin-commands test expectations for the midPrompt flag.
- Drop the now-unused isAtStartOfMessage helper from pi-tui's editor.
- Treat tab as a separator in the leading-command argument guard,
  matching the tokenizer.
Selecting a builtin offered by the mid-prompt slash menu now executes it
in place instead of inserting its name into the draft: the /token is
dropped from the text (undoable) and the command runs with the draft
preserved. Settings, help, tasks, mcp, plugins and provider join the
mid-prompt set alongside the existing toggles and info panels; skill and
plugin commands keep insert-on-select and activate on submit.

applyCompletion can now return preventSubmit so confirming such a
completion does not fall through to submitting the draft (pi-tui submits
slash-prefix completions on Enter). Blocked commands only show the busy
error without touching the in-place draft, and immediate items are
labeled 'runs immediately' in the mid-prompt menu.
Add a Mid-prompt commands section to the slash-commands reference and
mention the new completion in the interaction guide, in both locales.
Drop the outdated note that a slash after leading whitespace is treated
as plain text — indented slash input now opens command completion.
@BB-fat
BB-fat force-pushed the feat/mid-prompt-slash-commands branch from 9d7a55b to ec0e4a6 Compare August 1, 2026 02:11

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9d7a55b069

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +200 to +202
// No command matched: fall through so path completion can still run
// for mid-prompt tokens that look like paths.
if (slashToken.isLeading) return null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prevent Enter on mid-prompt path completions from submitting

When a mid-prompt /... token has no command match, this fallthrough can return ordinary path suggestions with a prefix like /tm; in the editor, any accepted completion whose prefix starts with / falls through to submit, so pressing Enter to accept /tmp/ in please /tm sends the prompt immediately instead of just completing the path. This only affects prompt-mode mid-prompt path completions; either avoid returning slash-prefixed path suggestions there or mark them so Enter does not submit.

Useful? React with 👍 / 👎.

Comment on lines +1226 to +1227
if (char === "/" && this.isSlashMenuAllowed()) {
const currentLine = this.state.lines[this.state.cursorLine] || "";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow mid-prompt slash completion past the first line

This new mid-prompt trigger is still gated by isSlashMenuAllowed(), which only allows cursor line 0, so typing / on the second or later line of a multi-line prompt never opens the slash completion menu even though inline slash tokens are resolved from the full submitted text. This leaves users composing multi-line prompts unable to discover or insert skill/plugin commands anywhere after the first line.

Useful? React with 👍 / 👎.

@liruifengv liruifengv closed this Aug 1, 2026
@liruifengv

Copy link
Copy Markdown
Collaborator

Thank you for your interest in contributing to Kimi Code.

For new features, please discuss fisrt. We are not currently accepting pull requests for new features.

@BB-fat
BB-fat deleted the feat/mid-prompt-slash-commands branch August 1, 2026 05:12
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.

2 participants