* refactor(agent-core-v2): rebuild undo as wire-level journal rewind Replace the compensating context.undo op with a wire-layer rewind primitive: a log.cut control record with a persisted target, applied uniformly by the wire during fold. Turn boundaries become first-class (TurnIndexModel indexing turn.prompt record positions), models declare a temporal classification (rewindable), and a single IAgentRewindService owns the undo pipeline (quiesce -> precheck -> cut -> reconcile) with all entry points converged. - wire: log.cut record, rewindable model flag, re-fold rebuild; OpApplyContext.recordIndex for position-aware reducers - rewind service: aborts the active turn, cancels in-flight compaction, preserves the pending queue, rebases measured tokens, reconciles lastPrompt, tracks conversation_undo - todo list, plan mode, task-notification delivery and the turn index now rewind together with the undone turns - transcript reducer applies cut ranges so snapshot/messages surfaces stay consistent with the model context - REST/RPC/debug undo entry points converge on the rewind service; TUI parses the v2 undo-unavailable error shape - legacy context.undo records keep replaying for old journals * refactor(agent-core-v2): keep undo domain-owned * refactor: enhance /undo functionality for consistency and safety, including todo list rollback and improved event handling * chore: clean up undo changeset artifacts * refactor: rebuild rewind consistency * fix: make conversation undo durable and consistent * fix(agent-core-v2): stabilize undo restoration * fix: keep TUI undo on legacy error contract * refactor(agent-core-v2): drop unused full compaction cancel API Undo now rejects with session.busy while compaction runs instead of cancelling it, so the awaitable cancel() added for the earlier rewind semantics has no callers left. Remove it from the interface and implementation; the RPC cancel path keeps using the task abort controller directly. * fix(agent-core-v2): remove injected context on undo * chore(agent-core-v2): regenerate wire manifest * docs(agent-core-dev): rename rewind to undo in layer table * fix(agent-core-v2): undo prompt-owned image reminders * refactor: remove transcript undo reconciliation * fix(kap-server): map undo busy errors * refactor(agent-core-v2): rename undo participant registry and attribute checkpoint depth - Rename IAgentConversationUndoReconciliationRegistry to IAgentConversationUndoParticipantRegistry (conversationUndoParticipants). - Return the limiting model from checkpointDepth and include it in the SESSION_UNDO_UNAVAILABLE details; report checkpoint_lost instead of compaction_boundary when no compaction explains the missing depth. - Add a registry invariant test: every model reacting to context.* ops must be registered via defineCheckpointedModel or explicitly exempt. * Delete .changeset/fix-undo-injections.md Signed-off-by: 7Sageer <sag77r@hotmail.com> --------- Signed-off-by: 7Sageer <sag77r@hotmail.com>
10 KiB
斜杠命令
斜杠命令是 Kimi Code CLI 在交互式 TUI 中提供的内置控制命令,涵盖账号配置、会话管理、模式切换、信息查询等操作。在输入框中输入 / 即可触发命令补全,候选列表随后续字符实时过滤;命令的别名也会一并参与匹配。
输入完整命令名后按 Enter 执行。如果输入的 / 开头内容不匹配任何内置或 Skill 命令,则按普通消息发送给 Agent。
::: tip 提示
部分命令仅在空闲(idle)状态下可用。会话正在流式输出或压缩上下文时执行这些命令会被拦截,需先按 Esc 或 Ctrl-C 中断。下表「随时可用」列标注了流式输出期间也可用的命令。
:::
账号与配置
| 命令 | 别名 | 说明 | 随时可用 |
|---|---|---|---|
/login |
— | 选择账号或平台并登录:Kimi Code 走 OAuth 验证码流程,Kimi Platform 通过 API 密钥登录 | 否 |
/logout |
— | 清除当前所选账号的凭据 | 否 |
/provider |
— | 打开交互式供应商管理器,查看、添加和删除已配置的供应商。详见平台与模型 — /provider 与供应商管理 |
是 |
/model |
— | 切换当前会话使用的 LLM 模型 | 是 |
/settings |
/config |
打开 TUI 内的设置面板 | 是 |
/experiments |
/experimental |
打开实验功能面板 | 是 |
/permission |
— | 选择权限模式 | 是 |
/editor |
— | 配置 Ctrl-G 调起的外部编辑器 |
是 |
/theme |
— | 切换终端 UI 配色主题 | 是 |
会话管理
| 命令 | 别名 | 说明 | 随时可用 |
|---|---|---|---|
/new |
/clear |
开启全新会话,丢弃当前上下文 | 否 |
/sessions |
/resume |
浏览历史会话并切换/恢复 | 否 |
/tasks |
/task |
浏览后台任务列表 | 是 |
/fork |
— | 基于当前会话 fork 一份新会话,保留完整对话历史 | 否 |
/title [<text>] |
/rename |
不带参数时显示当前会话标题;带参数时设置为新标题(最长 200 字符) | 是 |
/compact [<instruction>] |
— | 压缩当前对话上下文,释放 token 占用;可附带自定义指令,提示模型压缩时保留哪些信息 | 否 |
/undo [<count>] |
— | 从当前上下文撤销最近的提示词。不带数量时打开选择器;带数量时撤销对应条数。最后一次上下文压缩之前的提示词不能撤销。撤销会一并回滚这些提示词产生的 todo 列表和计划模式状态(不回滚代码改动) | 否 |
/init |
— | 分析当前代码库并生成 AGENTS.md |
否 |
/export-md [<path>] |
/export |
将当前会话导出为 Markdown 文件 | 否 |
/export-debug-zip |
— | 将当前会话导出为调试用 ZIP 压缩包(与 kimi export 行为一致) |
否 |
/copy |
— | 将最后一条 AI 回复复制到剪贴板 | 否 |
/add-dir [<path>] |
— | 为当前会话添加额外的工作目录。不带路径(或传入 list)运行时列出已配置的目录。添加时可选择是否将目录记入项目的 .kimi-code/local.toml |
否 |
/web |
— | 在 web UI 中打开当前会话:选择一个运行中的实例进行连接,或在 TUI 退出后新开一个前台服务器。参见 kimi web |
是 |
模式与运行控制
| 命令 | 别名 | 说明 | 随时可用 |
|---|---|---|---|
/yolo [on|off] |
/yes |
切换 YOLO 模式。不带参数时翻转;显式传 on/off 时强制设置。开启后跳过普通工具调用审批;Plan 模式的退出审批不受影响 |
是 |
/auto [on|off] |
— | 切换 auto 权限模式。开启后工具审批自动处理,Agent 不会向用户提问 | 是 |
/plan [on|off] |
— | 切换 Plan 模式。不带参数时翻转;显式传 on/off 时强制设置。单纯切换不会创建空计划文件 |
是 |
/plan clear |
— | 清除当前 plan 方案 | 否 |
/swarm on|off |
— | 开启或关闭 swarm mode,但不发送提示词。 | 是 |
/swarm <task> |
— | 先开启 swarm mode,再把 <task> 作为普通提示词发送。如果该轮次正常完成,swarm mode 会自动关闭。若当前是 manual 权限模式,启动前会提示是否切换到 auto 或 yolo。 |
否 |
/goal [...] |
— | 开始或管理目标模式 | 见下文 |
::: warning 注意
/yolo 会跳过普通工具调用的审批确认,使用前请确保了解可能的风险。Plan 模式的退出审批不会被 /yolo 跳过;Plan 模式下的 Bash 也按 /yolo 的普通放行规则处理。
:::
目标模式
/goal 用于开始或管理目标模式:Kimi Code 会在自动续跑的轮次中持续朝一个持久目标工作。使用指导和示例见使用目标模式。
/goal 更新 checkout 文档,运行 docs build,如果 20 轮后仍被阻塞就停止
| 命令 | 作用 | 可用性 |
|---|---|---|
/goal 或 /goal status |
显示当前目标及其状态、已用时间、轮次数、token 数 | 随时可用 |
/goal pause |
暂停当前的目标,但不删除 | 随时可用 |
/goal resume |
继续被暂停或被阻塞的目标 | 仅空闲时 |
/goal cancel |
移除当前目标 | 随时可用 |
/goal replace <objective> |
用新目标替换已保存的目标 | 仅空闲时 |
/goal next <objective> |
为当前会话安排一个后续目标。如果当前没有目标,则立即开始它。当前目标完成前,Agent 不会看到已排队的目标 | 随时可用 |
/goal next manage |
打开后续目标管理器。用 ↑ / ↓ 浏览,Space 选择一个目标以便移动,选中后用 ↑ / ↓ 调整顺序,E 编辑,D 删除,Esc 取消。编辑输入框中,用 Shift-Enter 或 Ctrl-J 添加新行,用 Enter 保存 | 随时可用 |
status、pause、resume、cancel、replace 和 next 只有作为 /goal 后的第一个词时才是子命令。如果你的目标需要以这些词开头,请在目标前加 --:
/goal -- cancel 函数需要在订单失败时返回可重试错误,并补充测试
如果后续目标需要以 manage 开头,请在 next 后加 --:
/goal next -- manage 发布检查清单
在非交互式 prompt 模式中,只有创建形式会启动目标模式:
kimi -p "/goal 修复 checkout 测试失败"
Prompt 模式在目标完成时以退出码 0 退出,在目标阻塞时以 3 退出,在目标暂停时以 6 退出。其它 /goal 子命令,包括 next,都是 TUI 控制命令,不由 kimi -p 处理。
信息与状态
| 命令 | 别名 | 说明 | 随时可用 |
|---|---|---|---|
/help |
/h、/? |
显示快捷键和所有可用命令 | 是 |
/btw [问题] |
— | 在 fork 出的子 Agent 中打开旁路对话,不改变当前主 Agent 轮次;不带问题时会先打开面板等待输入 | 是 |
/usage |
— | 显示 token 用量、上下文占用以及配额信息 | 是 |
/status |
— | 显示当前会话运行时状态:版本、模型、工作目录、权限模式等 | 是 |
/mcp |
— | 列出当前会话中的 MCP server 及连接状态 | 是 |
/plugins |
— | 打开交互式 plugin 管理器 | 是 |
/version |
— | 显示 Kimi Code CLI 版本号 | 是 |
/feedback |
— | 提交反馈,可附加诊断日志和代码库上下文 | 是 |
退出
| 命令 | 别名 | 说明 | 随时可用 |
|---|---|---|---|
/exit |
/quit、/q |
退出 Kimi Code CLI | 否 |
内置 Skill 命令
Kimi Code CLI 随包内置了一组 Skill,直接以 /<name> 形式出现在斜杠命令面板中。与外部 Skill 不同,它们不需要 skill: 前缀,开箱即用。
| 命令 | 说明 |
|---|---|
/mcp-config |
配置 MCP server 并处理 MCP OAuth 登录。详见 MCP |
/custom-theme [<text>] |
创建或编辑自定义 TUI 配色主题。详见 主题 |
/update-config |
查看或编辑 config.toml(模型、供应商、权限、hooks)和 tui.toml(主题、编辑器、通知、自动更新) |
/check-kimi-code-docs |
依据官方文档回答 Kimi Code 产品问题(CLI 用法、配置、会员、错误码) |
/import-from-cc-codex |
从 Claude Code 和 Codex 导入 instructions、skills 和 MCP 设置 |
/sub-skill |
发现并将本地 skill 库存重组为分层子 skill 包。包含 /sub-skill.review(只读提案)和 /sub-skill.consolidate(执行重组) |
所有内置 Skill 命令仅在空闲状态下可用。
Skill 动态命令
已激活的外部 Skill 会自动注册为斜杠命令。普通外部 Skill 以 skill: 作为命名空间前缀:
/skill:<name> [附加文本]
例如 /skill:code-style 加载名为 code-style 的 Skill 并发送给 Agent;命令后附带的文本拼接到 Skill 提示词之后。
外部子 Skill 会直接以点分名称出现在斜杠命令面板中:
/<parent-skill>.<sub-skill> [附加文本]
例如,父 Skill 名为 code-style,其中子 Skill 的本地名称为 review,面板中显示为 /code-style.review。点分命令名由层级自动生成,子 Skill 的 SKILL.md 可以保留本地 name。
为方便输入,外部 Skill 命令同时支持省略 skill: 前缀的简写形式 /<name>,前提是该名称未被系统斜杠命令占用——即 /code-style 会回退匹配到 /skill:code-style。
Kimi Code CLI 随包内置的 Skill 会直接以 /<name> 形式出现在斜杠命令面板中。例如,/mcp-config 用于配置 MCP server 和处理 MCP OAuth 登录,/custom-theme [附加文本] 用于进入自定义主题流程,创建或编辑 TUI 主题。
::: info 说明
所有 Skill 命令仅在空闲状态下可用。flow 类型的 Skill 同样通过 /skill:<name> 暴露,没有独立的 /flow: 命名空间。
:::
Skill 的安装与编写详见 Agent Skills。