MoonshotAI / MoonshotAI/kimi-code

ACP: expose undo and session fork/close (btw support)

Open
#1,685 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

Motivation

The ACP adapter currently exposes /compact as a built-in slash command, but two adjacent session operations have no ACP surface:

  • UndoSession.undoHistory(count) exists in the node SDK (the TUI's /undo drives it), but ACP clients cannot reach it. Hosts embedding kimi acp (IDEs, chat bots) have no way to roll back turns.
  • Fork / btwKimiHarness.forkSession exists in the node SDK, but ACP clients cannot create an ephemeral fork to run a side conversation that cannot pollute the main session's context.

Proposal

  1. /undo [count] built-in slash command (same shape as /compact): parse an optional positive-integer count, refuse while a turn is running (the kernel's context.undo has no active-turn guard, so an undo landing mid-turn would splice the history the in-flight turn is still reading), and call Session.undoHistory(count).
  2. kimi/session/fork extension method { sessionId } -> { sessionId }: fork a session into an ephemeral copy and register it as a first-class ACP session the client can session/prompt with the full streaming/tool surface. Kernel-side SESSION_FORK_ACTIVE_TURN rejection is preserved.
  3. kimi/session/close extension method { sessionId, archive? }: close and drop a session from the adapter; with archive: true also archive the on-disk directory (the fork cleanup path). Requires an archiveSession passthrough in the node SDK (agent-core already implements it).

Extension methods live in the kimi/* namespace so they cannot collide with future ACP spec methods.

Known limitation

ACP-supplied mcpServers are not carried into forks: resumeSession rebuilds MCP from the on-disk config only. Carrying caller-supplied MCP servers through fork is a follow-up.

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

Start with the ACP adapter and its existing /compact built-in command, then trace Session.undoHistory and KimiHarness.forkSession in the node SDK. Check how session/prompt and streaming/tool handling register sessions, and where archiveSession would fit. Done means /undo, kimi/session/fork, and kimi/session/close work with the stated guards and archive behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
api, backend, cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.