Skip to content

feat(kimi-code): recognize multiple inline skill activations in one prompt - #2935

Open
chengluyu wants to merge 11 commits into
feat/v2-multi-skillfrom
feat/tui-inline-multi-skill
Open

feat(kimi-code): recognize multiple inline skill activations in one prompt#2935
chengluyu wants to merge 11 commits into
feat/v2-multi-skillfrom
feat/tui-inline-multi-skill

Conversation

@chengluyu

Copy link
Copy Markdown
Collaborator

Related Issue

Resolve #1736

Stacked on #2934 (engine-side grouped multi-skill submissions). This PR wires the capability up in the TUI.

Problem

The prompt editor only recognizes a single explicit skill activation per prompt. Users who type several /skill: tokens in one message expect all of them to activate.

What changed

TUI (apps/kimi-code)

  • /skill: tokens are recognized anywhere in the prompt (after whitespace, including on following lines), with completion, highlighting, and de-duplication (utils/inline-skill-tokens.ts).
  • Submitting a prompt with multiple skill tokens goes through session.promptWithSkills, so the prompt and all activations land as a single grouped turn (one undo unit) using the engine API from feat(agent-core-v2): bundle multiple skill activations into one prompt submission #2934.
  • Undo / replay treat the group consistently; grouped submissions queue client-side while the session is busy or a goal is running.
  • Ctrl-S does not promote grouped items or drafts containing skill tokens.
  • Enter accepts an inline completion without submitting (pi-tui inlineSlashTrigger + data.inlineSkill marker).
  • Cache-hint and /btw (including the initial prompt) pass activations through.

packages/pi-tui: inline slash trigger support in the editor / autocomplete / select-list.

Docs updated (docs/en|zh/guides/interaction.md).

Verification

  • tsc --noEmit on apps/kimi-code
  • kimi-code TUI suite: all tests pass
  • pi-tui: all tests pass
  • pnpm run lint: 0 errors

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 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 290700d

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

@chengluyu

Copy link
Copy Markdown
Collaborator Author

@codex review

@pkg-pr-new

pkg-pr-new Bot commented Aug 14, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@290700d
npx https://pkg.pr.new/@moonshot-ai/kimi-code@290700d

commit: 290700d

@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: 8e47c73a56

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/kimi-code/src/tui/controllers/session-replay.ts Outdated
Comment thread apps/kimi-code/src/tui/controllers/session-replay.ts Outdated
@chengluyu
chengluyu force-pushed the feat/tui-inline-multi-skill branch from 8e47c73 to d98e001 Compare August 14, 2026 23:54
@chengluyu

Copy link
Copy Markdown
Collaborator Author

Reworked on top of the refactored engine (#2934 switched from submissionId-correlated groups to bundled prompt messages), force-pushed as a single clean commit.

What changed relative to the previous revision:

  • No more submissionId anywhere: the TUI calls session.promptWithSkills(input, skills) and the engine bundles the activations into the prompt's own user message.
  • Replay got much simpler: the grouped-submission lookahead and turn-group tracking are gone. A bundled prompt is one replay record — the renderer expands origin.skillActivations into per-skill cards, projects hook results recorded ahead of the bundle into its window, and the user bubble shows only the caller's own parts (the engine prepends one rendered text part per skill to the content).
  • Undo: the prompt and its skill cards are removed together via a bundledWithPrompt marker on card entries (live submissions mark the cards appended synchronously during the call; replay marks cards rebuilt from the origin). Bundle cards no longer count as undo anchors; standalone /skill cards keep their own anchor as before.
  • The replay turn-count and hook-result-lookahead issues Codex flagged on the previous revision are moot now — that machinery was deleted rather than patched.

@codex review

@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: d98e001de3

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/kimi-code/src/tui/kimi-tui.ts Outdated
Comment thread apps/kimi-code/src/tui/controllers/session-replay.ts Outdated
Comment thread apps/kimi-code/src/tui/commands/dispatch.ts Outdated
@chengluyu

Copy link
Copy Markdown
Collaborator Author

Review threads addressed in 000ddca:

  • Bundle cards marked by entry id — the transcript window trim can replace the entries array mid-call, so marking now decides membership by id rather than indexing a captured array.
  • Hook results survive the replay cutoff — the turn limiter no longer separates a bundled prompt from the consecutive hook results recorded before it; the oldest visible bundle keeps its hook context (with a regression test that proves the cut happens).
  • Leading-combo bundles queue while busy/skill:a args /skill:b now follows the inline-skill path's busy behavior (queue intact) instead of being rejected by the single-skill slash gate; the combo's own busy/model gates were redundant with sendInlineSkillUserInput's.

The two earlier P2 threads from the pre-bundle revision (replay turn counting across a group, multi-hook-result lookahead) are moot: grouped submissions are a single replay record now, so that machinery was deleted rather than patched.

@codex review

@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: 000ddca2a0

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/kimi-code/src/tui/controllers/session-replay.ts
@chengluyu

Copy link
Copy Markdown
Collaborator Author

Good catch — the TUI-side preservation was indeed one trim too late: resumeSession already applies the limit inside the SDK, so the hook records were gone before preserveBundleHookResults could see them. Fixed in c9bab32: resume now fetches one extra turn of margin (REPLAY_FETCH_TURN_LIMIT = REPLAY_TURN_LIMIT + 1) and lets the TUI-side limiter make the final cut, so the hook run preceding the oldest visible bundle survives end-to-end.

@codex review

@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: c9bab32228

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/pi-tui/src/components/editor.ts
@chengluyu

Copy link
Copy Markdown
Collaborator Author

Fixed in 17d3d1a: typing token characters inside an inline slash token now counts as an autocomplete context (isInInlineSlashContext), so when /rev arrives in one stdin chunk each letter supersedes the slash's in-flight request instead of letting it go stale and get discarded. Regression test added — the menu now appears in the one-chunk scenario. (The CI failure on the previous push was the startup tests asserting the old resume limit; they're updated to REPLAY_FETCH_TURN_LIMIT.)

@codex review

@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: 17d3d1af52

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/pi-tui/src/components/editor.ts Outdated
@chengluyu

Copy link
Copy Markdown
Collaborator Author

Fixed in c3c9467: the retrigger context no longer routes through isSlashMenuAllowed() (which confines the slash-command menu to the first line — the wrong domain for the inline trigger). Later-line tokens now retrigger both mid-line (after whitespace) and at line start, and the regression suite covers the hello\n/skill:r one-chunk scenario.

@codex review

@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: c3c94670da

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/kimi-code/src/tui/commands/btw.ts Outdated
Comment thread apps/kimi-code/src/tui/commands/dispatch.ts Outdated
@chengluyu

Copy link
Copy Markdown
Collaborator Author

Both fixed in c8c9d4e:

  • /btw leading skill — the initial side-agent prompt lives entirely in the slash arguments, so a token there sits at position 0; it's now scanned with includeLeading: true, and /btw /skill:review check this goes through promptWithSkills (regression test added).
  • Repeated-token combo — combo-ness is now decided by the raw inline token count (pre-dedupe), so /skill:review check /skill:review submits as a bundled prompt with one deduplicated activation instead of falling through to the standalone slash path with the repeated token swallowed into args (regression test added).

@codex review

@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: c8c9d4ef7c

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/kimi-code/src/tui/commands/dispatch.ts Outdated
@chengluyu

Copy link
Copy Markdown
Collaborator Author

Fixed in 82f473a: sendInlineSkillUserInput now rewrites any arg-carrying activation through rewriteMediaPlaceholders(..., 'plain') before submission — the same escape-proof file references the standalone sendSkillActivation path produces. The rewrite happens ahead of the busy-queue and /btw-intercept branches so those paths carry resolved args too, and the media continue to ride the prompt as extracted parts (regression test asserts both the rewritten args and the unchanged prompt parts).

@codex review

@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: 82f473a6ce

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/kimi-code/src/tui/commands/dispatch.ts Outdated

@liruifengv liruifengv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@chengluyu

Copy link
Copy Markdown
Collaborator Author

Semantics decision after design review: skill mentions never carry args in a bundled prompt (42274f9).

Two or more skill tokens anywhere in the input — the leading one included — now make one bundled prompt in which every token activates by name only. Args remain a standalone /skill:<name> args concept. This is the mention model other tools converged on, and it removes a class of issues at once:

  • the first skill's args can no longer leak the next token (which showed up as the prompt duplicated under its card);
  • media placeholders need no arg rewriting — args no longer exist in bundles (the placeholder-rewrite from 82f473a is removed as structurally unnecessary; media still ride the prompt as extracted parts);
  • the newline-separator thread: bundle-ness is now decided by whitespace-generic tokenization rather than parseSlashInput's literal-space command parsing, so /skill:review⏎check this /skill:security activates both skills exactly like its space-separated equivalent (regression test added).

Docs updated (en/zh): a mention in a prompt never carries arguments.

@codex review

@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: 42274f9293

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/kimi-code/src/tui/commands/dispatch.ts Outdated
@chengluyu

Copy link
Copy Markdown
Collaborator Author

Fixed in 0d3c123: the intent is now resolved before the token count is consulted — recognized builtin and plugin commands always keep their own path no matter how many skill tokens their arguments mention, so /btw check /skill:review /skill:security opens the side panel again (and the bundled prompt goes to the side agent with both skills). Skill-led and newline-led inputs still bundle exactly as before. Regression test added.

@codex review

@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: 0d3c1230da

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/pi-tui/src/components/editor.ts Outdated
…rompt

Inline /skill: tokens are recognized anywhere in the prompt (after
whitespace, including on following lines) with completion, highlighting,
and de-duplication. Submitting goes through session.promptWithSkills, so
the engine bundles every activation into the prompt's own user message —
one turn, one undo anchor. Replay rebuilds the per-skill cards from the
prompt origin's skillActivations and shows only the caller's own parts in
the user bubble; undo removes the prompt together with its marked bundle
cards; hook results ahead of a bundle are projected inside its window.
Enter accepts an inline completion without submitting (pi-tui
inlineSlashTrigger), and cache-hint plus /btw pass activations through.
- Mark bundle cards by entry id, not by index into a captured array: the
  transcript window trim may replace the entries array mid-call.
- The replay turn limiter no longer cuts between a bundled prompt and the
  hook results recorded immediately before it; the oldest visible bundle
  keeps its hook context.
- A leading-combo bundle (/skill:a args /skill:b) now queues while busy
  like any other inline-skill prompt, instead of being rejected by the
  single-skill slash gate.
The SDK trims the replay to the requested limit before returning it, so a
trim landing between a bundled prompt and its preceding hook results would
make them unrecoverable to the TUI-side limiter. Resume now fetches one
extra turn of margin; preserveBundleHookResults does the final cut without
losing the hook context.
When the terminal delivers `/rev` in one stdin chunk, the slash starts an
autocomplete request but the following letters arrived to a null
autocomplete state and — unlike a leading slash command — matched no
retrigger context, so the stale request was discarded and the menu never
appeared. Typing token characters inside an inline slash token now
retriggers completion (with a regression test). Also aligns the startup
resume tests with REPLAY_FETCH_TURN_LIMIT.
isSlashMenuAllowed confines the slash-command menu to the first line, so
reusing it for the inline-slash retrigger context silently disabled
retriggering on every later line — the bare-slash request went stale and
the menu never appeared. The inline context now covers a token-opening
slash on subsequent lines as well (with a regression test).
…ken combos

- /btw's initial prompt lives entirely in the slash arguments, so a skill
  token there sits at position 0; scan it with includeLeading so
  `/btw /skill:review …` actually activates the skill.
- Combo-ness is now decided by the raw inline token count rather than the
  deduplicated activation count, so `/skill:review check /skill:review`
  submits as a bundled prompt instead of falling through to the
  single-skill path with the repeated token swallowed into the args.
A leading combo's first activation carries the raw slash arguments, so a
pasted media placeholder in them reached the engine unresolved — unlike
the standalone sendSkillActivation path, which rewrites placeholders into
escape-proof plain-text file references first. sendInlineSkillUserInput
now rewrites any arg-carrying activation the same way (covering the busy
queue and /btw intercept paths too), while the media themselves continue
to ride the prompt as extracted parts.
Align bundled submissions with the mention model: two or more skill
tokens anywhere in the input (the leading one included) make one bundled
prompt in which every token activates by name only, and args stay a
standalone /skill:<name> args concept. This removes the leading combo's
command+args parsing, so the first skill's arguments can no longer leak
the next token (displayed as a duplicated prompt under its card), media
placeholders no longer need arg rewriting, and newline-separated bundles
behave exactly like space-separated ones (parseSlashInput's literal-space
separator no longer decides bundle-ness).
…ndle rule

The no-args bundle rule claimed any input with two or more skill tokens
before checking what led it, so `/btw check /skill:a /skill:b` was
submitted to the main agent as a bundled prompt instead of opening the
side panel. The intent is now resolved first: builtin and plugin commands
always keep their own path regardless of how many skill tokens their
arguments mention, while skill-led and newline-led inputs still bundle as
before.
…ocal divergences

External skill tokens are shaped /skill:<name>, but the inline-slash
retrigger character classes excluded ':' — typing the colon launched no
replacement request, the bare-slash request went stale, and the menu never
appeared for prefixed skill names. Colons now retrigger completion like
other token characters (with a regression test). Also registers the
inlineSlashTrigger and autocomplete-data divergences in the package's
re-vendor protection list.
@chengluyu
chengluyu force-pushed the feat/tui-inline-multi-skill branch from 0d3c123 to 22595ce Compare August 16, 2026 14:32
@chengluyu

Copy link
Copy Markdown
Collaborator Author

Rebased onto the updated base (#2934 was itself rebased onto current main) — merged the queue/steer semantics from main's activate rework with this PR's bundle drain (standalone 'skill' queue mode and inlineSkillActivations now coexist).

Also fixed in 22595ce: external skill tokens are shaped /skill:<name>, but the inline-slash retrigger character classes excluded :, so the colon launched no replacement request and the menu never appeared for prefixed skill names. Colons now retrigger completion like other token characters (regression test added), and the pi-tui re-vendor protection list now registers the inlineSlashTrigger / autocomplete-data divergences.

@codex review

@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: 22595ce902

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/kimi-code/src/tui/controllers/editor-keyboard.ts Outdated
Comment thread apps/kimi-code/src/tui/components/editor/file-mention-provider.ts
…dented inline completion

- Ctrl-S steering now stops at the first inline-skill bundle: a later
  queued message (or the editor draft) no longer jumps ahead of the
  unsteerable bundle into the running turn, so the conversational order
  survives steering.
- The leading-whitespace slash-path suppression now yields to the inline
  skill context first, so an indented token (`  /skill:rev`) completes
  like its column-0 equivalent instead of being suppressed as a path.
@chengluyu

Copy link
Copy Markdown
Collaborator Author

Both fixed in 290700d:

  • FIFO: Ctrl-S steering now stops at the first inline-skill bundle — the steerable window is the queue prefix before it, and everything from the bundle onward (plus any bash items) stays queued, so a later message can no longer overtake the unsteerable bundle into the running turn. The editor draft is likewise held back while a bundle is queued. Regression tests cover bundle-in-the-middle and bundle-first queues.
  • Indented inline completion: the inline skill context is now resolved before shouldSuppressLeadingWhitespaceSlashPath, so /skill:rev (indented, any line) reaches the skill picker; indented paths like /etc/pa are still suppressed as before (regression tests on both line 0 and later lines).

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 290700d8a1

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

feat(tui): support inline multi-skill activation in a single prompt

2 participants