SaylorTwift HF Staff commited on
Commit
f0634fb
·
verified ·
1 Parent(s): 68d7816

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .agents/skills/gen-changesets/SKILL.md +63 -0
  2. .agents/skills/gen-docs/SKILL.md +89 -0
  3. .agents/skills/pre-changelog/SKILL.md +72 -0
  4. .agents/skills/sync-changelog/SKILL.md +488 -0
  5. .agents/skills/tdd/SKILL.md +38 -0
  6. .agents/skills/tdd/mocking.md +59 -0
  7. .agents/skills/tdd/tests.md +77 -0
  8. .agents/skills/translate-docs/SKILL.md +67 -0
  9. .agents/skills/write-tui/DESIGN.md +178 -0
  10. .agents/skills/write-tui/SKILL.md +85 -0
  11. .gitattributes +5 -0
  12. apps/kimi-code/dist-web/assets/NotoSansSC_wght_-BkPpiACN.woff2 +3 -0
  13. docs/.vitepress/config.ts +215 -0
  14. docs/.vitepress/theme/Kimi.png +0 -0
  15. docs/.vitepress/theme/components/HomeFeatures.vue +319 -0
  16. docs/.vitepress/theme/components/HomeHero.vue +147 -0
  17. docs/.vitepress/theme/components/HomeLayout.vue +38 -0
  18. docs/.vitepress/theme/components/HomeQuickStart.vue +210 -0
  19. docs/.vitepress/theme/components/KimiLogo.vue +22 -0
  20. docs/.vitepress/theme/index.ts +12 -0
  21. docs/.vitepress/theme/styles/base.css +282 -0
  22. docs/.vitepress/theme/styles/home.css +85 -0
  23. docs/.vitepress/theme/styles/vars.css +120 -0
  24. docs/en/configuration/config-files.md +619 -0
  25. docs/en/configuration/data-locations.md +126 -0
  26. docs/en/configuration/env-vars.md +236 -0
  27. docs/en/configuration/overrides.md +107 -0
  28. docs/en/configuration/providers.md +165 -0
  29. docs/en/customization/agents.md +210 -0
  30. docs/en/customization/datasource.md +10 -0
  31. docs/en/customization/hooks.md +170 -0
  32. docs/en/customization/mcp.md +140 -0
  33. docs/en/customization/plugins.md +500 -0
  34. docs/en/customization/skills.md +151 -0
  35. docs/en/customization/themes.md +116 -0
  36. docs/en/guides/getting-started.md +175 -0
  37. docs/en/guides/ides.md +96 -0
  38. docs/en/guides/interaction.md +147 -0
  39. docs/en/guides/migration.md +40 -0
  40. docs/en/guides/remote-control.md +147 -0
  41. docs/en/guides/sessions.md +122 -0
  42. docs/en/guides/use-cases.md +148 -0
  43. docs/en/guides/web.md +107 -0
  44. docs/en/index.md +13 -0
  45. docs/en/reference/keyboard.md +104 -0
  46. docs/en/reference/kimi-acp.md +97 -0
  47. docs/en/reference/kimi-command.md +384 -0
  48. docs/en/reference/server-api.md +0 -0
  49. docs/en/reference/slash-commands.md +165 -0
  50. docs/en/reference/tools.md +158 -0
.agents/skills/gen-changesets/SKILL.md ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: gen-changesets
3
+ description: Use when generating changesets in the kimi-code repository — deciding whether to write one, which package to list, the bump level, the wording, and the confirmation workflow.
4
+ ---
5
+
6
+ # Generate Changesets
7
+
8
+ The only user-facing published package is the CLI: `@moonshot-ai/kimi-code`. All other `@moonshot-ai/*` packages (sdk, kosong, kaos, oauth, telemetry, and so on) are internal.
9
+
10
+ ## 1. Whether to Write
11
+
12
+ Rule of thumb: **if users cannot perceive the change, write no changeset.** A changeset is a user-facing changelog entry, not a shipping gate — internal changes merged to main ship with the next release anyway, so skipping loses nothing.
13
+
14
+ Do not write:
15
+ - Docs-only or tests-only changes that never enter the shipped artifact.
16
+ - Changes internal to core/server packages — architecture, protocols, refactors, config/journal/wire mechanics — unless they fix a bug users care about.
17
+ - When you are unsure whether users can perceive a change, ask first.
18
+
19
+ Do write: user-perceivable new features or behavior changes, and internal-package changes that fix a user-useful bug or change CLI output/behavior (list `@moonshot-ai/kimi-code` for those).
20
+
21
+ ## 2. What to Write
22
+
23
+ Create a short kebab-case file under `.changeset/`:
24
+
25
+ ```markdown
26
+ ---
27
+ "@moonshot-ai/kimi-code": patch
28
+ ---
29
+
30
+ Fix occasional loss of tool call results in long conversations.
31
+ ```
32
+
33
+ Wording:
34
+ - One short, user-facing English sentence that states only what changed. Drop trailing clauses that explain the cause, the benefit, or the mechanism.
35
+ - New features: say plainly what it is plus one line on how to use it, e.g. `Add the /foo slash command to list active sessions. Run /foo to see them.`
36
+ - Experimental features: also state how to enable them (the flag, config key, or env var).
37
+ - No file, class, or function names, and no PR numbers. No vague words like refactor, optimize, or improve. No real internal identifiers — use neutral placeholders such as `example.com` or `YOUR_API_KEY`.
38
+ - Internal packages' own changelogs (such as the sdk) are not curated for end users — write those entries honestly and technically.
39
+ - One logical change per changeset; split unrelated changes into separate files.
40
+
41
+ ## 3. Bump Level
42
+
43
+ - `patch`: bug fixes, small improvements, configuration additions to existing features — when in doubt, use this.
44
+ - `minor`: a real new capability users could not do before (a new slash command, a new subcommand, a new mode).
45
+ - `major`: **never write it.** If you think a change qualifies, stop and ask the user; without explicit approval fall back to `minor`, or to `patch` if `minor` is also unclear.
46
+
47
+ ## 4. Which Package
48
+
49
+ - An internal change enters the CLI bundle and is user-perceivable → list `@moonshot-ai/kimi-code`.
50
+ - An internal change does not enter the CLI or is not user-perceivable → write nothing; if it is written, list only that internal package.
51
+ - Never mix packages ignored in `.changeset/config.json` with non-ignored packages in one frontmatter.
52
+ - pi-tui exception: pi-tui-only changes list `@moonshot-ai/pi-tui`; if the same change is also visible to CLI users, write a separate CLI changeset (two files, never mixed).
53
+ - kimi-inspect and the vis packages never appear in a changeset.
54
+
55
+ ## 5. Workflow
56
+
57
+ 1. Run `git status` / `git diff --name-only` to see which packages actually changed.
58
+ 2. Apply section 1; if no changeset is needed, stop.
59
+ 3. Pick the package and the bump, and write the one sentence.
60
+ 4. **Show the changeset text to whoever requested the work and get their confirmation before committing.**
61
+ 5. Do not guess at changes you do not understand: finish the parts that are clear, then list what is unclear and ask whether you may dig into the code.
62
+
63
+ Before a release, review the accumulated `.changeset/` entries and delete the non-user-facing ones — the release PR regenerates from `.changeset/` on main, so deleting a file removes its changelog entry without touching shipped code.
.agents/skills/gen-docs/SKILL.md ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: gen-docs
3
+ description: Update Kimi Code CLI user documentation after meaningful code changes that affect product behavior or user experience.
4
+ ---
5
+
6
+ # Gen Docs
7
+
8
+ ## Overview
9
+
10
+ This repository maintains bilingual user documentation under `docs/`. `docs/en/` and `docs/zh/` are mirrored pairs for most pages; update both in the same change. **Changelog is the exception** — English is the source, and Chinese is translated from English.
11
+
12
+ Use this skill to update the corresponding documentation whenever the codebase has changes that affect product behavior or user experience.
13
+
14
+ For a **full pre-release audit** of all pages (detecting hallucinations and coverage gaps), use the `audit-docs` skill instead.
15
+
16
+ ## Prerequisites
17
+
18
+ This skill depends on the following being in place. If any are missing, stop and report to the user before continuing:
19
+
20
+ - `docs/` directory with `docs/zh/`, `docs/en/`, and `docs/.vitepress/config.ts` set up (VitePress site).
21
+ - `docs/AGENTS.md` style guide — defines source-of-truth rules, terminology table, typography, and writing style.
22
+ - `docs/scripts/sync-changelog.mjs` — auto-syncs root `CHANGELOG.md` to `docs/en/release-notes/changelog.md`.
23
+ - `translate-docs` skill in `.agents/skills/` — handles bilingual synchronization.
24
+
25
+ ## Workflow
26
+
27
+ 1. **Inspect changes**
28
+
29
+ - `git log main..HEAD --oneline` — commits on the current branch
30
+ - `git diff main..HEAD --stat` — file-level scope
31
+ - `ls .changeset/*.md` (excluding `README.md`) — pending changeset entries
32
+ - Read `CHANGELOG.md` and any subpackage `packages/*/CHANGELOG.md` for already-recorded entries.
33
+
34
+ 2. **Understand user-facing impact**
35
+
36
+ For each change, read the actual implementation when needed; **do not infer behavior from commit messages or PR titles alone**. Skip:
37
+
38
+ - Internal refactors with no externally visible behavior change
39
+ - Tests, CI, type-only changes
40
+ - Tooling / build-system changes that do not change how users invoke the CLI
41
+
42
+ If after the scan you conclude there is no user-facing impact, say so and stop.
43
+
44
+ 3. **Sync English changelog**
45
+
46
+ Run:
47
+
48
+ ```bash
49
+ node docs/scripts/sync-changelog.mjs
50
+ ```
51
+
52
+ This updates `docs/en/release-notes/changelog.md` from the root `CHANGELOG.md`. Never edit the docs changelog by hand.
53
+
54
+ 4. **Update user docs**
55
+
56
+ Following the rules in `docs/AGENTS.md`, edit the affected pages in whichever locale you are working in, then sync the mirror. Match terminology with the term table in `docs/AGENTS.md` and the existing wording in surrounding pages.
57
+
58
+ Cover all relevant sections:
59
+
60
+ - Guides (getting-started, use cases, interaction, sessions, IDE integration)
61
+ - Customization (skills, agents, MCP, hooks, plugins, etc.)
62
+ - Configuration (config files, env vars, providers, data locations)
63
+ - Reference (CLI subcommands, slash commands, keyboard shortcuts)
64
+ - Release notes (`docs/zh/release-notes/breaking-changes.md` if a breaking change is involved)
65
+
66
+ 5. **Sync bilingual content**
67
+
68
+ Invoke the `translate-docs` skill. It will:
69
+
70
+ - Sync updated non-changelog pages between `docs/en/` and `docs/zh/`
71
+ - Translate the English changelog → Chinese under `docs/zh/release-notes/changelog.md`
72
+
73
+ ## Rules and conventions
74
+
75
+ - **Locale sync**: Non-changelog pages stay mirrored between `docs/en/` and `docs/zh/`. Changelog flows English → Chinese.
76
+ - **Terminology**: Use the term table in `docs/AGENTS.md` exactly. Do not invent new translations or use synonyms.
77
+ - **Scope discipline**: Only update sections affected by the recent changes. Do not opportunistically rewrite unrelated docs.
78
+ - **Public examples**: Never write real internal endpoints, key names, account names, or service names into docs. Use neutral placeholders such as `https://api.example.com/v1`, `https://registry.example.com/v1/models/api.json`, `example.test`, and `YOUR_API_KEY`.
79
+ - **Breaking changes**: If any change is breaking, also update `docs/en/release-notes/breaking-changes.md` (under `## Unreleased`) with `**Affected**` + `**Migration**` subsections, and mirror it in `docs/zh/release-notes/breaking-changes.md`.
80
+ - **Do not edit auto-synced files**: `docs/en/release-notes/changelog.md` is regenerated by the sync script; any manual edit will be overwritten.
81
+
82
+ ## Common mistakes
83
+
84
+ - Describing what code changed instead of what the user can now do (or can no longer do).
85
+ - Adding a new section heading per feature instead of weaving the change into existing prose.
86
+ - Updating only one locale and leaving its mirror stale.
87
+ - Editing only the mirror to fix wording that should be corrected in the locale you changed first.
88
+ - Inventing new terminology that drifts from the `docs/AGENTS.md` term table.
89
+ - Using real internal values in examples instead of neutral `example` placeholders.
.agents/skills/pre-changelog/SKILL.md ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: pre-changelog
3
+ description: Use before merging a kimi-code release PR to preview the user-facing CLI changelog in Chinese. Reads the changelog that changesets pre-generated in the release PR, then reuses sync-changelog's strip / classify / translate logic to render a Chinese preview. Writes no files.
4
+ ---
5
+
6
+ # Pre-Changelog
7
+
8
+ Preview the user-facing **Chinese** changelog of an open `kimi-code` release PR **before** it is merged. Read-only: this skill writes no files and commits nothing.
9
+
10
+ This skill reuses `sync-changelog`'s strip / classify / translate rules. Read `sync-changelog` first; only the data source (release PR diff instead of a published `CHANGELOG.md`) and the output (preview instead of docs files) differ.
11
+
12
+ ## Workflow
13
+
14
+ ### 1. Locate the release PR
15
+
16
+ ```bash
17
+ gh pr list --state open --search "ci: release packages in:title" \
18
+ --json number,title,url,headRefName,baseRefName
19
+ ```
20
+
21
+ Pick the one with `headRefName: changeset-release/main`; record `number`, `url` as `<RELEASE>`. If none is open, nothing to preview — stop.
22
+
23
+ ### 2. Read the pre-generated CLI changelog block
24
+
25
+ changesets already pre-generates `apps/kimi-code/CHANGELOG.md` inside the release PR. Extract the new version block from the diff:
26
+
27
+ ```bash
28
+ gh api repos/MoonshotAI/kimi-code/pulls/<RELEASE>/files \
29
+ --jq '.[] | select(.filename=="apps/kimi-code/CHANGELOG.md") | .patch'
30
+ ```
31
+
32
+ Take the added lines (`+`) from the top `## <version>` down to (but not including) the next `## `. That is the version block to preview.
33
+
34
+ If the CLI changelog is not in the diff (for example an SDK-only release), stop and tell the user — there is no user-facing CLI changelog to preview.
35
+
36
+ ### 3. Render the Chinese preview (reuse `sync-changelog`)
37
+
38
+ Process the version block exactly as `sync-changelog` does for the docs site, but only in memory:
39
+
40
+ - **Strip** (`sync-changelog` step 3): drop the H1, the `### Patch Changes` / `### Minor Changes` / `### Major Changes` subheadings, PR links, and commit-hash links; keep only each entry's body text. The `Thanks [@user](...)!` credit (including the multi-author form) must be removed every time. Within each entry, drop SDK-only and provider-internal sentences (SDK capability mapping / API exposure, provider wire-format mechanics, internal XML markers, hook/event payload mechanics such as what an event reports or carries) and keep only the user-facing effect and required constraints.
41
+ - **Merge and deduplicate** (`sync-changelog` step 4): merge micro-tweaks to the same surface into one higher-level entry; when three or more fixes target the same UI area or the same class of problem, merge them into one higher-level fix entry (do not merge broad or genuinely distinct fixes); and drop a server/API entry that only backs a web feature already listed.
42
+ - **Collapse low-signal entries** (`sync-changelog` step 4): keep standalone only entries that pass both gates — the reader-action test (the reader must do or re-evaluate something) and the channel test (the product cannot push it into the user's path: hidden controls, habit invalidations, capabilities users would not know to seek — a control merely sitting in the UI is not surfacing, users do not explore). Polish keeps only must-react items; experiences the product shows at the moment of need (recovery cards, post-install guidance) fold. Fixes keep only behavior-change entries (readers must update a habit, config, or workaround); loud failures fold (the fix itself notifies the victim), and silent past damage folds too — the changelog does not repair the past, and a notice that names no locatable instance and no realistic action is noise, not diligence. Section sizes follow density defaults (about 2 polish, 3 fixes) that yield to genuinely qualifying entries — flag the overflow for the reviewer instead of folding to hit the number. Fold everything else into one catch-all line placed last under 修复 — `修复了一些已知问题。` (or `修复了一些已知问题,并做了若干细节优化。` when non-fix entries were also collapsed; when nothing folded is a fix, place it under 优化 instead as `做了若干细节优化和内部改进。`), followed by a separate pointer sentence: `更详细的变更记录见 [GitHub](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-code/CHANGELOG.md)。` (file link, no version anchor; before the release PR merges, the target does not yet contain this version's block — expected for a preview).
43
+ - **Classify** (`sync-changelog` step 4): bucket into Features / Bug Fixes / Polish / Refactors / Other; order within each section by reader value (in Polish, user-visible improvements before protocol/internal adjustments).
44
+ - **Translate** (`sync-changelog` step 6): translate entry bodies to Chinese; keep one sentence per entry with a parallel rhythm within a section; section headings become 新功能 / 修复 / 优化 / 重构 / 其他.
45
+
46
+ If an upstream entry is not in English, flag it and stop (changeset entries must be English).
47
+
48
+ ### 4. Output
49
+
50
+ Print the preview directly. Use `<version>(预览)` as the heading because the version is not released yet. Write `无` for empty sections. Do not write any file.
51
+
52
+ After the preview block, append a reviewer-only section titled `### 审稿参考(不进入文档)`: list every entry folded into the catch-all (short English title, one line each), note any section that exceeds the density defaults, and flag borderline calls for the reviewer to confirm. This breakdown is how reviewers see what was folded — before merge, the catch-all pointer's target does not yet contain the version's block. Never write this section into the docs pages.
53
+
54
+ The preview is pasted into chat tools (for example Lark), where relative docs links do not resolve. Rewrite every docs link to its absolute published URL: map `../<path>.md[#anchor]` to `https://moonshotai.github.io/kimi-code/zh/<path>.html[#anchor]` — for example `../configuration/config-files.md#loop-control` → `https://moonshotai.github.io/kimi-code/zh/configuration/config-files.html#loop-control`. Never emit raw relative paths, and never wrap a link in backticks; code-style the link text inside the brackets instead ([`loop_control`](...)).
55
+
56
+ ```
57
+ 发版 PR: <url>
58
+
59
+ ## <version>(预览)
60
+
61
+ ### 新功能
62
+ - ...
63
+
64
+ ### 修复
65
+ - ...
66
+ ```
67
+
68
+ ## Rules
69
+
70
+ - Read-only. Never write `CHANGELOG.md`, docs files, or commit anything.
71
+ - Classification, ordering, and translation follow `sync-changelog` exactly — do not reword or reclassify beyond what it specifies.
72
+ - If the release PR has no CLI changelog diff, report it and stop.
.agents/skills/sync-changelog/SKILL.md ADDED
@@ -0,0 +1,488 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: sync-changelog
3
+ description: Use after a release succeeds, when maintainers need to sync apps/kimi-code/CHANGELOG.md into docs/en/release-notes/changelog.md and docs/zh/release-notes/changelog.md, then open a PR on a dedicated branch.
4
+ ---
5
+
6
+ # Sync Changelog
7
+
8
+ ## Overview
9
+
10
+ `kimi-code` uses changesets for versioning. Each package gets its own `CHANGELOG.md`. The user-facing CLI package, `@moonshot-ai/kimi-code`, writes its changelog here:
11
+
12
+ ```text
13
+ apps/kimi-code/CHANGELOG.md
14
+ ```
15
+
16
+ This file is the **only upstream source** for the documentation-site changelog. Internal package changelogs such as `packages/*/CHANGELOG.md` do not go into the documentation site.
17
+
18
+ After the release flow finishes (Release PR merged → `Version Packages` completed → npm publish succeeded), maintainers manually run this skill to copy the new CLI changelog entries into the docs site, translate the English increment into Chinese, wait for an optional human review, then commit on a dedicated branch and open a PR.
19
+
20
+ ## When To Use
21
+
22
+ - A new version has been published to npm.
23
+ - The top of `apps/kimi-code/CHANGELOG.md` contains version blocks that are not yet in `docs/en/release-notes/changelog.md`.
24
+ - The `gen-docs` flow does not run this automatically; maintainers must explicitly do it after release.
25
+
26
+ Do **not** run this before the Release PR is merged. At that point, changesets has not yet written the new version into `apps/kimi-code/CHANGELOG.md`.
27
+
28
+ ## Source And Targets
29
+
30
+ | File | Role | Edited by |
31
+ |---|---|---|
32
+ | `apps/kimi-code/CHANGELOG.md` | **Only upstream source**, generated by changesets | Never edit manually |
33
+ | `docs/en/release-notes/changelog.md` | English docs changelog; source of truth for docs | This skill |
34
+ | `docs/zh/release-notes/changelog.md` | Chinese docs changelog, translated from English | This skill, following `translate-docs` |
35
+
36
+ Core rule: the English docs changelog is the source of truth, and Chinese is translated from English. This matches `translate-docs`.
37
+
38
+ ## Preconditions
39
+
40
+ Before editing, confirm:
41
+
42
+ - The released version exists on npm (`npm view @moonshot-ai/kimi-code versions --json`) or has a matching GitHub Release tag.
43
+ - The top of `apps/kimi-code/CHANGELOG.md` is that new version.
44
+
45
+ If any condition is not true, stop and confirm with the user.
46
+
47
+ Do **not** edit or commit directly on `main`. All sync work happens on a dedicated branch created in step 1.
48
+
49
+ ## Workflow
50
+
51
+ ### 1. Prepare Branch
52
+
53
+ Start from an up-to-date default branch:
54
+
55
+ ```bash
56
+ git fetch origin
57
+ git checkout main
58
+ git pull --ff-only origin main
59
+ ```
60
+
61
+ Before creating the branch, peek at the version range so the branch name matches the newest version being synced:
62
+
63
+ ```bash
64
+ rg '^## ' apps/kimi-code/CHANGELOG.md | head -5
65
+ rg '^## ' docs/en/release-notes/changelog.md | head -5
66
+ ```
67
+
68
+ Name the branch after the newest upstream version that is not yet in the English docs page:
69
+
70
+ ```text
71
+ docs/changelog-sync-<newest-version>
72
+ ```
73
+
74
+ Example: syncing `0.2.1` only → `docs/changelog-sync-0.2.1`.
75
+
76
+ ```bash
77
+ git checkout -b docs/changelog-sync-<newest-version>
78
+ ```
79
+
80
+ If the branch already exists locally or on the remote, stop and confirm with the user instead of reusing it.
81
+
82
+ ### 2. Find The Version Range
83
+
84
+ Use the same version lists from step 1. Confirm:
85
+
86
+ - First sync: copy all upstream version blocks into the English page.
87
+ - Incremental sync: copy every upstream version block above the latest version already present in the English page.
88
+
89
+ Use upstream order: newest version first.
90
+
91
+ ### 3. Strip Decorations And Extract Entry Text
92
+
93
+ Upstream entries look like this:
94
+
95
+ ```markdown
96
+ - [#317](https://github.com/...) [`2f51db4`](https://github.com/...) Thanks [@user](https://github.com/...)! - Clean up lint warnings ...
97
+ ```
98
+
99
+ Changesets may add a `Thanks ...!` credit, but it must be removed every time. Keep:
100
+
101
+ - Version headings such as `## 0.2.0`.
102
+ - Only the body text of each entry, after the PR/hash decoration and any `Thanks ...!` credit have been removed.
103
+
104
+ Remove:
105
+
106
+ - The upstream H1 `# @moonshot-ai/kimi-code` because the docs page already has `# Changelog`.
107
+ - Changesets subheadings such as `### Patch Changes`, `### Minor Changes`, and `### Major Changes`.
108
+ - PR links such as `[#317](...)`.
109
+ - Commit hash links such as ``[`2f51db4`](...)``.
110
+ - The `Thanks [@user](...)!` credit, including the multi-author form `Thanks [@a](...), [@b](...)!`. Drop the whole `Thanks ...!` segment every time, regardless of whether the feature is enabled.
111
+
112
+ After stripping, each entry is `- <body text>`.
113
+
114
+ Drop SDK-only and provider-internal detail. This changelog serves `@moonshot-ai/kimi-code` CLI and web users. Within an entry, keep only what CLI/web users can perceive, and remove sentences that document internals instead of user-visible behavior. Apply this on both the English and Chinese pages:
115
+
116
+ - Drop sentences about how the SDK maps a capability, builds model aliases, or exposes a flag through an API such as `getExperimentalFeatures()` — that belongs in the SDK changelog, not here.
117
+ - Drop provider / wire-format implementation mechanics (XML markers like `<tools_added>`, protocol field explanations, "the wire protocol is unchanged", cache-hit mechanics) unless they are the behavior a user perceives.
118
+ - Drop hook/event payload mechanics — clauses about what extra fields an event payload carries or what an event reports in a specific case (for example "enrich hook payloads with the session title and client type", "`SessionEnd` reports `archive` when a session is archived"). Keep the new events or capability itself and how to configure it.
119
+ - Keep the user-facing effect and any constraints users must follow (for example "question texts must be unique").
120
+
121
+ Do not change facts or drop a real user-facing behavior — only trim the internal-only scaffolding. For over-long, internal-heavy entries, this trim applies on the English page too, not only in translation.
122
+
123
+ Upstream language rule: `gen-changesets` requires changelog entries to be English. If the upstream CLI changelog contains a non-English entry, stop and report it to the user. Do not silently rewrite it while syncing docs.
124
+
125
+ Public-text rule: do not copy real internal endpoints, key names, account names, or service names into docs changelogs. Replace examples with neutral placeholders such as `example.com`, `example.test`, or `YOUR_API_KEY` while preserving the user-visible meaning.
126
+
127
+ ### 4. Merge, Deduplicate, And Classify Entries
128
+
129
+ Before classifying, merge related entries and drop redundant ones from the user-facing changelog:
130
+
131
+ - **Curate for end users: collapse low-signal entries into one catch-all line.** The docs changelog is the only curated, user-facing outlet; the full entry list always remains in the upstream package changelog, so hiding detail here loses nothing. Apply two gates to every candidate entry. Gate 1, the reader-action test: **after reading this, is there something the reader must do, or something they must re-evaluate?** Gate 2, the channel test: **is the changelog the only channel that can deliver this?** The changelog is the channel of last resort — when the product itself surfaces the information in context, at the moment of need, to exactly the affected users, the entry is redundant no matter how real the improvement is. "Surfaced" means pushed into the user's path, not merely present on screen: an event-triggered card, prompt, or post-install screen forces the encounter, while a toggle, menu item, command, or settings page only waits to be found. Users do not explore — a capability that lives only in ambient UI is effectively undiscoverable, so the changelog must announce it. What in-product surfacing cannot deliver: hidden controls (env vars, config keys, opt-out flags nobody would find unprompted), invalidations of existing habits or expectations (in-product discovery comes as confusion), and capabilities users would not know to seek. An entry that fails either gate folds. Anchor both gates to the changelog's reader, never to the bug's victim: someone who hit a loud failure does not need the changelog to confirm the fix — the product working again is the notification — and a reader who never hit it gets nothing from the entry.
132
+ - `Features`: keep when users would try it or must react to it — new capabilities create demand readers did not know to seek. Collapse only behavior that takes effect solely behind an experimental flag.
133
+ - `Polish`: keep only must-react items — a notification users may want to turn off, a behavior change to a command they already use, a default flip with an opt-out. Fold improved experiences the product surfaces in context (recovery cards, post-install guidance, progress or status displays): they are discovered at the moment of need, and pre-reading about them helps nobody. Also fold subtle or transient tweaks (status wording, spacing, animations) and internal-behavior adjustments — nobody acts on them.
134
+ - `Bug Fixes`: keep only **behavior-change** fixes — the fix changes how something works going forward, so readers must update a habit, a config, or a widely-adopted workaround. Everything else folds, for one of two opposite reasons. Loud failures (crashes, refusals, interrupted runs): the fix itself notifies whoever was hit — announcement value falls as bug visibility rises. Silent past damage (dropped data, wrong results the user never noticed): the changelog cannot repair the past, and in this product the notice names no locatable instance and no realistic action — users cannot enumerate which old sessions were affected, and they do not audit finished sessions; a "some past outputs may be wrong" line is anxiety without an outlet, not diligence. The rare exception is a retrospective notice with a concrete, locatable action (for example rotating a token after a credential-handling flaw); keep those. Never keep a fix merely because it was severe, and never keep one because the bug class feels important.
135
+ - Do not grade entries by engineering importance. Severity and effort are already represented upstream; the curated changelog is not a credit ledger — its only job is to change what the reader does or knows.
136
+ - **Density, not quota.** Standalone sections stay short so the changelog actually gets read — as a default, expect about 2 Polish and 3 Bug Fixes entries per version, while `Features` is gated by the test alone and has no count. The defaults yield whenever more entries genuinely pass the reader-action test: keep them and flag the overflow for the human reviewer; never fold a qualifying entry just to hit the number, and never pad a section to reach it. The reviewer owns the final cutoff — the curator's job is to surface the borderline calls, not to resolve them silently.
137
+ - Everything else collapses into a single catch-all bullet placed last under `Bug Fixes`: `Fix several known issues.` When entries beyond fixes were also collapsed, use `Fix several known issues and make various refinements.` instead (Chinese: `修复了一些已知问题。` / `修复了一些已知问题,并做了若干细节优化。`). End the catch-all line with a pointer to the upstream file so folded entries stay reachable, phrased as a separate short sentence — `See the [changelog on GitHub](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-code/CHANGELOG.md) for more technical entries.` (Chinese: `更详细的变更记录见 [GitHub](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-code/CHANGELOG.md)。`). Link the file itself, never a per-version anchor — GitHub's generated heading anchors are fragile. Keep the pointer wording restrained ("more technical entries"): upstream only contains changes that received a changeset, so never claim the list is complete.
138
+ - If no fix survives, the `Bug Fixes` section is the catch-all line alone; if the whole version has no user-facing change, the version block is a single section with that line. Match the catch-all to what was folded — never claim fixes that did not happen: when the folded entries include fixes, use the forms above under `Bug Fixes`; when everything folded is polish or internal work, place the catch-all under `Polish` as `Make several refinements and internal improvements.` (Chinese: `做了若干细节优化和内部改进。`).
139
+ - **Merge micro-tweaks to the same surface.** Collapse several small tweaks to the same UI area or feature into one concise entry at the higher level. For example, "change the composer's default height" and "change the composer's default font" merge into "Polish the composer's default styling." Use the most specific common ancestor (composer, settings page, tool card, and so on). Classify the merged entry by its combined effect
140
+ - **Merge same-surface or same-kind fixes when you have three or more.** The `Bug Fixes` section tends to accumulate many narrow UI/polish fixes that read as noise when listed one by one. When three or more fixes target the same area (for example several tool cards in the TUI, or the web session/conversation surface) or the same class of problem (for example several "jumping/flickering/collapsing during streaming" fixes), merge them into one higher-level entry. Examples:
141
+ - "Fix the Bash tool card collapsing...", "Fix the Edit tool card jumping in height...", "Fix the Edit tool card flickering while its result streams in" → "Fix several TUI tool cards jumping, flickering, or collapsing in height when results stream in or end with short output."
142
+ - "Fix the collapsed sidebar not hiding...", "Stop the chat history from replaying its entrance animation...", "Fix tool components jumping the conversation when expanded/collapsed" → "Fix several layout and display glitches when switching sessions, including the collapsed sidebar not hiding, the chat history replaying its entrance animation, and tool components jumping the conversation."
143
+ - Classify the merged fixes as `Bug Fixes`.
144
+ - **Do not over-merge.** Leave a fix standalone when it is broad, high-value, or genuinely distinct (for example model/provider tool-calling bugs, session-list corruption, file-completion gaps). Merging is for low-reader-value, similar-shape fixes that read as a wall of similar bullets. A merged fix entry must still pass the standalone test from the catch-all rule above; if the merged group is low-signal too, fold it into the catch-all line instead of listing it.
145
+ - **Drop server/API plumbing covered by a web entry.** If one entry adds a web UI feature (for example, an Archived sessions page) and another entry only adds the server or REST/WebSocket endpoints that exist solely to power that web feature, keep the web UI entry and drop the API entry. CLI and web users perceive the web page; the backing API is implementation detail with no independent user value on this changelog. Keep the API entry only when it has independent user value — a new public endpoint that SDK or server consumers call directly, or a capability usable outside the web feature. When unsure, keep both and let the reviewer decide.
146
+
147
+ The docs changelog uses five section types:
148
+
149
+ | English section | Chinese section | Meaning |
150
+ |---|---|---|
151
+ | `### Features` | `### 新功能` | New user-facing functionality, such as a new command, flag, mode, or capability that did not exist before |
152
+ | `### Polish` | `### 优化` | User-visible improvements to existing functionality, including UX adjustments, behavior tweaks, and performance improvements that are not fixes or new capabilities |
153
+ | `### Bug Fixes` | `### 修复` | Fixes for behavior that was broken |
154
+ | `### Refactors` | `### 重构` | Internal changes with no user-visible behavior change, including build, CI, tests, dependency cleanup, and internal renames |
155
+ | `### Other` | `### 其他` | Anything that does not fit above, such as CDN/endpoint swaps and docs-related artifacts |
156
+
157
+ With the catch-all rule above, `Refactors` and `Other` rarely appear in newly synced versions: entries with no user-perceivable effect fold into the catch-all, and an entry that does change user-perceivable default behavior (for example an engine default flip with an opt-out flag) is classified by that effect, usually `Polish`. Reserve `Other` for genuinely unclassifiable but user-facing entries. Older versions keep whatever sections they already have — do not rewrite history.
158
+
159
+ Classification process:
160
+
161
+ 1. Classify from the stripped entry text first.
162
+ 2. If unclear, inspect the related commit or PR:
163
+ - Use the stripped commit hash with `git show <hash>`.
164
+ - Or use the PR number with `gh pr view <NNN>`.
165
+ 3. If it is still unclear, put it in `Other`. Do not guess or force entries into `Features`.
166
+
167
+ Features vs. Polish: ask whether the entry introduces something the user could not do before. If yes (new command, flag, mode, viewer, or capability), use `Features`. If it only improves an existing surface (a UI panel that already existed, an existing prompt, an existing tool card, an existing payload pipeline), use `Polish`. Verbs like `Add` do not automatically mean `Features` — a small visual addition to an existing UI is still polish.
168
+
169
+ Default-behavior changes: changing the default value of an existing capability (for example flipping a feature on by default) is usually `Polish`, because the capability already existed. Use `Features` only when the new default materially changes the out-of-box experience for most users in a way they could not get before. When genuinely ambiguous, flag it and confirm with the reviewer rather than guessing.
170
+
171
+ Keyword hints:
172
+
173
+ - **Features**: `Add ... command/flag/option/mode/viewer`, `Introduce`, `Support`, `Allow`, `Enable`, `Implement`, `New ... command/flag/option`
174
+ - **Bug Fixes**: `Fix`, `Resolve`, `Correct`, `Address`, `Prevent ... from`, `Stop ... from`, `... no longer ...`
175
+ - **Polish**: `Polish`, `Optimize`, `Improve`, `Enhance`, `Speed up`, `Reduce`, `Cap`, `Shorten`, `Wrap`, `Clarify`, `Tweak`, `Adjust`, `Offload`, `Show ... in existing surface`, performance and UX adjustments to existing features
176
+ - **Refactors**: `Refactor`, `Rename`, `Clean up`, `Simplify`, `Remove unused`, `Migrate to`, `Unify`, `Restructure`, `Internal`, dependency bumps, pure CI/build/test changes
177
+ - **Other**: docs artifacts, CDN/endpoint switches, anything that genuinely fits no other section
178
+
179
+ Within each version, section order is:
180
+
181
+ ```text
182
+ Features → Polish → Bug Fixes → Refactors → Other
183
+ ```
184
+
185
+ Omit empty sections. Within each section, order entries by reader value, not upstream order:
186
+
187
+ 1. Put the most valuable, obvious, and larger changes first.
188
+ 2. Prefer broad user-visible features, workflow-changing fixes, high-frequency bugs, and large cross-cutting improvements over small polish, narrow edge cases, and internal cleanup.
189
+ 3. Within `Polish`, put directly user-visible UX or performance improvements (something users can see or feel) before protocol or internal-behavior adjustments (something that makes the model or pipeline behave more reliably but is invisible to users).
190
+ 4. If entries have similar value, preserve upstream order.
191
+
192
+ Do not reword or exaggerate entries just to make them look more important; only reorder existing entries.
193
+
194
+ ### 5. Write The English Page
195
+
196
+ Never change the English page header:
197
+
198
+ ```markdown
199
+ # Changelog
200
+
201
+ This page documents the changes in each Kimi Code CLI release.
202
+ ```
203
+
204
+ Insert new version blocks immediately after the header paragraph and before the previous latest version.
205
+
206
+ Every version heading must carry its release date in parentheses:
207
+
208
+ ```text
209
+ ## <version> (YYYY-MM-DD)
210
+ ```
211
+
212
+ Take the date from the version's published GitHub Release tag, not from when you run the sync:
213
+
214
+ ```bash
215
+ git log -1 --format=%cs "@moonshot-ai/kimi-code@<version>"
216
+ ```
217
+
218
+ Use the half-width parenthesis form ` (YYYY-MM-DD)` on the English page. Never invent or guess a date; if the tag is missing, stop and confirm with the user.
219
+
220
+ Example:
221
+
222
+ ```markdown
223
+ ## 0.2.0 (2026-05-26)
224
+
225
+ ### Bug Fixes
226
+
227
+ - Fix the TUI not restoring the current todo list after resuming a session.
228
+
229
+ ### Refactors
230
+
231
+ - Clean up lint warnings across the CLI, SDK examples, and bundled runtime code without changing product behavior.
232
+ - Update the native release workflow to use current GitHub artifact actions.
233
+ ```
234
+
235
+ Doc links: an entry that changes a documented config surface may end with a pointer to the docs page — `see [X](...) for details` (Chinese: `详见 [X](...)。`). Keep it a real Markdown link into the docs tree with a relative path (for example `../configuration/config-files.md#loop-control`). When the link text is a config key or another identifier, code-style the text inside the brackets: [`loop_control`](../configuration/config-files.md#loop-control). Never wrap the whole link in backticks — `` `[loop_control](...)` `` renders as raw inline code that exposes the relative path instead of a clickable link.
236
+
237
+ ### 6. Translate The Increment Into Chinese
238
+
239
+ After updating the English page, translate only the newly added English content into `docs/zh/release-notes/changelog.md`.
240
+
241
+ Follow `translate-docs`, direction `en → zh`. Changelog direction is English-to-Chinese even though many other docs flows use Chinese-to-English.
242
+
243
+ Chinese page requirements:
244
+
245
+ - Header:
246
+
247
+ ```markdown
248
+ # 变更记录
249
+
250
+ 本页记录 Kimi Code CLI 每个版本的变更内容。
251
+ ```
252
+
253
+ - Preserve version headings including the release date, but use full-width parentheses on the Chinese page, such as `## 0.2.0(2026-05-26)`. The date must match the English page; only the parenthesis style differs (half-width `()` in English, full-width `()` in Chinese).
254
+ - Translate section headings exactly:
255
+ - `### Features` → `### 新功能`
256
+ - `### Bug Fixes` → `### 修复`
257
+ - `### Polish` → `### 优化`
258
+ - `### Refactors` → `### 重构`
259
+ - `### Other` → `### 其他`
260
+ - The Chinese page must mirror the English page 1:1 for versions, sections, section order, entry order, and entry counts.
261
+ - Keep the classification and entry order from the English page. Do not reclassify or reorder while translating.
262
+ - Translate only entry body text. Do not add entries that are not present in English.
263
+ - Follow `docs/AGENTS.md` for Chinese typography: full-width punctuation, spaces between Chinese and English, and the glossary.
264
+
265
+ #### Chinese wording style
266
+
267
+ Structural fidelity does not mean literal translation. The Chinese entries should read like a concise, idiomatic Chinese changelog. Keep the same facts as the English entry, but rephrase for natural Chinese prose.
268
+
269
+ Guidelines:
270
+
271
+ - **One entry, one sentence.** Avoid chaining multiple effects with commas or semicolons. If the English entry is long, split it into shorter sentences or keep only the most important effect.
272
+ - **Drop SDK-only and provider-internal detail.** Apply the trim from step 3 while translating: keep the user-facing effect and required constraints, drop SDK-mapping sentences, provider / wire-format mechanics, and internal XML markers. A long internal entry should collapse to one short Chinese sentence about what the user gets.
273
+ - **Prefer common changelog verbs**: 新增、支持、修复、优化、改进、调整.
274
+ - **Avoid indirect "through... make..." structures**. Do not write "通过 X,使 Y"; prefer direct cause-effect or just state the result.
275
+ - Bad: `通过缓存已渲染消息行,使终端在长篇对话中保持响应。`
276
+ - Better: `缓存已渲染消息行,提升长对话下终端的响应速度。`
277
+ - **Be specific, not vague**. Prefer concrete actions over abstract quality words.
278
+ - Bad: `加固默认系统提示词和内置工具描述。`
279
+ - Better: `优化默认系统提示词与内置工具描述,避免 Agent 阻塞后台任务。`
280
+ - **Name concrete files or config keys when it helps clarity**.
281
+ - Bad: `插件现在可以在其清单中声明 hooks。`
282
+ - Better: `插件现支持在 kimi.plugin.json 中声明生命周期 hooks。`
283
+ - **Include required argument placeholders in CLI options**.
284
+ - Bad: `--allowed-host`
285
+ - Better: `--allowed-host <host>`
286
+ - **Keep usage hints to one short clause**.
287
+ - Bad: `传入 --allowed-host 以允许额外的 host。例如 ... (多句展开)`
288
+ - Better: `例如 kimi web --allowed-host example.com。`
289
+ - **Do not translate technical identifiers**: keep command names, flag names, file names, env vars, config keys as-is.
290
+ - **Keep parallel rhythm within a section.** When several entries fix similar web surfaces (layout, animation, sizing), phrase them with a consistent structure (for example 修复 <问题>,现 <行为>) so the section reads as a tidy list rather than a mix of shapes.
291
+
292
+ Example — translating a feature entry:
293
+
294
+ English source:
295
+
296
+ ```markdown
297
+ - Add a --allowed-host flag to kimi web that lets extra Host header values pass the DNS-rebinding check, and include allow guidance in the 403 error message. Pass --allowed-host <host> to allow an extra host.
298
+ ```
299
+
300
+ Before (literal, wordy):
301
+
302
+ ```markdown
303
+ - 为 `kimi web` 新增 `--allowed-host` 标志,允许额外的 Host 请求头值通过 DNS 重绑定检查,并在 403 错误消息中包含允许指引。传入 `--allowed-host <host>` 以允许额外的 host。例如 `kimi web --allowed-host example.com`。
304
+ ```
305
+
306
+ After (concise, idiomatic):
307
+
308
+ ```markdown
309
+ - `kimi web` 新增 `--allowed-host <host>` 选项,可将指定 Host 加入 DNS 重绑定白名单;403 错误会提示如何通过 `--allowed-host` 或 `KIMI_CODE_ALLOWED_HOSTS` 放行,例如 `kimi web --allowed-host example.com`。
310
+ ```
311
+
312
+ ### 7. Verify
313
+
314
+ Review:
315
+
316
+ ```bash
317
+ git diff docs/en/release-notes/changelog.md docs/zh/release-notes/changelog.md
318
+ ```
319
+
320
+ Check:
321
+
322
+ - Versions and version counts match between English and Chinese.
323
+ - Every version heading carries its release date from the published tag, with half-width parentheses in English and full-width in Chinese.
324
+ - Each version has the same section set and order on both pages.
325
+ - Each section has the same number of entries on both pages.
326
+ - Within each section, the most valuable, obvious, and larger entries appear before smaller or narrower entries.
327
+ - Low-signal entries were collapsed into the single catch-all line, placed last under `Bug Fixes` — or under `Polish` when nothing folded is a fix (both the reader-action test and the channel test applied); the catch-all wording matches what was folded and never claims fixes that did not happen; section sizes stay within the density defaults (about 2 Polish, 3 Bug Fixes) unless extra qualifying entries were deliberately kept and flagged for review. The catch-all line ends with the upstream changelog pointer (file link, no version anchor).
328
+ - PR links and commit hashes were stripped.
329
+ - No `Thanks ...!` credit remains (remove it every time).
330
+ - Real internal identifiers were replaced with neutral placeholders.
331
+ - Doc links are real Markdown links (code-styled text inside the brackets when needed), never wrapped in backticks.
332
+ - There are no empty sections.
333
+ - Markdown indentation and blank lines are intact.
334
+
335
+ Then run the docs build:
336
+
337
+ ```bash
338
+ pnpm --filter docs run build
339
+ ```
340
+
341
+ ### 8. Human Review Checkpoint
342
+
343
+ After verification passes, **before committing**, ask the user whether they want to review the sync result. Use `AskQuestion` with options such as:
344
+
345
+ - **Review first** — show the diff and wait for the user to finish checking.
346
+ - **Skip review, commit and open PR** — proceed directly to steps 9 and 10.
347
+
348
+ If the user chooses review:
349
+
350
+ 1. Show the uncommitted diff:
351
+
352
+ ```bash
353
+ git diff docs/en/release-notes/changelog.md docs/zh/release-notes/changelog.md
354
+ ```
355
+
356
+ 2. Summarize synced versions, section counts, and anything that needed manual classification. List every entry folded into a catch-all line (short titles, one line each), any section that exceeds the density defaults, and every borderline call flagged during curation — the reviewer cannot own a cutoff they cannot see.
357
+ 3. Tell the user to reply when they are done reviewing, or to ask for edits.
358
+ 4. Do **not** commit, push, or open a PR until the user explicitly says review is complete, or asks to proceed.
359
+
360
+ If the user requests edits during review, make the changes, re-run verification from step 7, and return to this checkpoint.
361
+
362
+ ### 9. Commit
363
+
364
+ Only run this step when the user skipped review or confirmed review is complete.
365
+
366
+ Stage only the changelog docs files:
367
+
368
+ ```bash
369
+ git add docs/en/release-notes/changelog.md docs/zh/release-notes/changelog.md
370
+ ```
371
+
372
+ Use a neutral docs-sync commit message:
373
+
374
+ ```text
375
+ docs(changelog): sync <version range> from apps/kimi-code/CHANGELOG.md
376
+ ```
377
+
378
+ Do **not** create a changeset for changelog docs sync. Docs sync does not enter the bundle.
379
+
380
+ ### 10. Push And Open PR
381
+
382
+ Run immediately after step 9.
383
+
384
+ Push the branch:
385
+
386
+ ```bash
387
+ git push -u origin HEAD
388
+ ```
389
+
390
+ Create the PR with `gh pr create`. Title follows Conventional Commits:
391
+
392
+ ```text
393
+ docs(changelog): sync <version range> from apps/kimi-code/CHANGELOG.md
394
+ ```
395
+
396
+ Fill in `.github/pull_request_template.md`. For changelog sync PRs:
397
+
398
+ - **Related Issue**: write `N/A — post-release docs maintenance` (no issue required).
399
+ - **Problem**: the docs-site changelog is behind the published CLI release(s).
400
+ - **What changed**: list synced version(s), note English source + Chinese translation, and mention verification (`pnpm --filter docs run build`).
401
+ - **Checklist**: check CONTRIBUTING; explain no issue, no tests, no changeset, and that `gen-docs` is not needed because this is the dedicated changelog sync flow.
402
+
403
+ Example body:
404
+
405
+ ```markdown
406
+ ## Related Issue
407
+
408
+ N/A — post-release docs maintenance
409
+
410
+ ## Problem
411
+
412
+ The docs-site changelog has not yet been synced for `<version range>` after the npm release.
413
+
414
+ ## What changed
415
+
416
+ - Synced `<version range>` from `apps/kimi-code/CHANGELOG.md` into `docs/en/release-notes/changelog.md`
417
+ - Translated the new English increment into `docs/zh/release-notes/changelog.md`
418
+ - Verified with `pnpm --filter docs run build`
419
+
420
+ ## Checklist
421
+
422
+ - [x] I have read the CONTRIBUTING document.
423
+ - [x] I have linked a related issue, or explained the problem above.
424
+ - [ ] I have added tests that prove my feature works. (N/A — docs-only sync)
425
+ - [x] Ran `gen-changesets` skill, or this PR needs no changeset. (No changeset — docs sync is out of bundle)
426
+ - [x] Ran `gen-docs` skill, or this PR needs no doc update. (This PR is the dedicated changelog sync)
427
+ ```
428
+
429
+ Return the PR URL to the user when done.
430
+
431
+ ## Rules
432
+
433
+ - The English docs changelog is the source of truth.
434
+ - Never edit upstream `apps/kimi-code/CHANGELOG.md`.
435
+ - Do not backfill unreleased `.changeset/*.md` drafts into the docs site.
436
+ - If upstream wording is wrong, leave upstream alone and fix it in a future changeset.
437
+ - Always sync on a `docs/changelog-sync-*` branch and open a PR; never push changelog docs sync directly to `main`.
438
+ - Wait for the human review checkpoint before committing, pushing, or opening a PR.
439
+
440
+ ## Common Mistakes
441
+
442
+ | Mistake | Fix |
443
+ |---|---|
444
+ | Adding entries directly to the English docs page without reading upstream | Use `apps/kimi-code/CHANGELOG.md` as the source |
445
+ | Copying PR links or commit hashes into docs | Strip them; keep only body text |
446
+ | Leaving the `Thanks ...!` credit in docs | Remove it every time, including the multi-author form |
447
+ | Leaving near-duplicate micro-tweaks as separate bullets | Merge small tweaks to the same surface into one higher-level entry (e.g. composer height + font → composer's default styling) |
448
+ | Listing many narrow fixes to the same surface as separate bullets | When three or more fixes target the same UI area or the same class of problem, merge them into one higher-level fix entry; keep genuinely distinct or high-value fixes standalone |
449
+ | Listing low-signal fixes or internal changes as standalone bullets | Collapse them into the single catch-all line (`Fix several known issues.`) placed last under Bug Fixes; treat the section-size defaults (about 2 Polish, 3 Bug Fixes) as a density guard, not a quota |
450
+ | Folding a qualifying entry just to hit the section-size default | The defaults are density guards; keep entries that genuinely pass the reader-action test and flag the overflow for the human reviewer |
451
+ | Keeping a fix because it was severe or hard-won | Severity makes the announcement redundant — the fix itself notifies whoever was hit; keep only behavior-change fixes and retrospective notices with a concrete, locatable action |
452
+ | Keeping an improvement the product surfaces in context (recovery cards, post-install guidance, progress displays) | The product is the better channel — right users, moment of need; fold it (channel test) |
453
+ | Folding a new capability because its control is visible somewhere in the UI | Visible is not discoverable — users do not explore; a toggle, menu item, or settings page that only waits to be found needs the changelog announcement |
454
+ | Keeping a silent-impact fix out of diligence (dropped data, wrong results the user never noticed) | The changelog does not repair the past; if the notice names no locatable instance and no realistic action, it is anxiety without an outlet — fold it |
455
+ | Overstating the catch-all pointer (for example claiming the upstream changelog is complete) | Keep the pointer restrained — `See the [changelog on GitHub](...) for more technical entries.`; upstream only contains changes that received a changeset |
456
+ | Writing `Fix several known issues.` when nothing folded is a fix | Never claim fixes that did not happen; all-polish/internal folds go under Polish as `Make several refinements and internal improvements.` |
457
+ | Listing a server/API entry that only backs a web feature already listed | Drop the API entry and keep the web UI entry, unless the API has independent user value |
458
+ | Rewording upstream English entries | Upstream is frozen; copy the body text unless the user explicitly asks otherwise |
459
+ | Leaving English text untranslated in the Chinese page | The Chinese page must be fully Chinese except preserved technical terms |
460
+ | Editing upstream changelog text | Do not edit upstream |
461
+ | Losing two-space indentation in multi-line list items | Restore indentation so Markdown lists stay valid |
462
+ | Copying `### Patch Changes` into docs | Remove changesets headings and classify under Features / Bug Fixes / Polish / Refactors / Other |
463
+ | Guessing unclear entries as Features | Inspect commit/PR; if still unclear, use Other |
464
+ | Treating any `Add ...` line as Features | If the entry only adds a small element to an existing UI/surface, use Polish |
465
+ | Filing UX or performance tweaks under Other | Use Polish for user-visible improvements to existing functionality |
466
+ | Preserving upstream order when a small entry hides a larger change | Reorder within the section so the highest-value, most obvious items appear first |
467
+ | Reclassifying entries while translating | Chinese classification must mirror English |
468
+ | Leaving empty sections | Delete sections with no entries |
469
+ | Putting everything under Other for convenience | Classify what can be classified first |
470
+ | Translating tool names, command names, or config keys | Keep them as written |
471
+ | Wrapping a whole doc link in backticks | Code-style the link text inside the brackets instead, so the link stays clickable: [`loop_control`](...) |
472
+ | Keeping hook/event payload-mechanics clauses | Drop what an event reports or carries; keep the new capability and how to configure it |
473
+ | Creating a changeset for docs sync | Do not create one |
474
+ | Committing or pushing directly on `main` | Create `docs/changelog-sync-<version>`, commit there, then open a PR |
475
+ | Committing or opening a PR before the user skips review or confirms review is done | Wait at the human review checkpoint |
476
+ | Using curly quotes or half-width Chinese punctuation | Follow `docs/AGENTS.md` |
477
+ | Omitting the release date from a version heading, or guessing it | Add ` (YYYY-MM-DD)` (full-width `()` in Chinese) taken from the published tag |
478
+
479
+ ## Stop Signals
480
+
481
+ - The top version in `apps/kimi-code/CHANGELOG.md` is not published on npm or GitHub Releases.
482
+ - You are about to edit `apps/kimi-code/CHANGELOG.md`.
483
+ - You are about to add docs sync to a changeset.
484
+ - English and Chinese versions, entry counts, or section sets do not match.
485
+ - A section is empty.
486
+ - A Chinese term is uncertain and `docs/AGENTS.md` does not answer it.
487
+ - A `docs/changelog-sync-*` branch already exists for the same version and you cannot confirm whether it is stale.
488
+ - The user asked to review but has not yet confirmed review is complete.
.agents/skills/tdd/SKILL.md ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: tdd
3
+ description: Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
4
+ ---
5
+
6
+ # Test-Driven Development
7
+
8
+ TDD is the red → green loop. This skill is the reference that makes that loop produce tests worth keeping: what a good test is, where tests go, the anti-patterns, and the rules of the loop. Every section applies on every cycle: consult them before and during the loop, not after.
9
+
10
+ When exploring the codebase, read `CONTEXT.md` (if it exists) so test names and interface vocabulary match the project's domain language, and respect ADRs in the area you're touching.
11
+
12
+ ## What a good test is
13
+
14
+ Tests verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't. A good test reads like a specification: "user can checkout with valid cart" tells you exactly what capability exists, and it survives refactors because it doesn't care about internal structure.
15
+
16
+ See [tests.md](tests.md) for examples and [mocking.md](mocking.md) for mocking guidelines.
17
+
18
+ ## Seams: where tests go
19
+
20
+ A **seam** is the public boundary you test at: the interface where you observe behavior without reaching inside. Tests live at seams, never against internals.
21
+
22
+ **Test only at pre-agreed seams.** Before writing any test, write down the seams under test and confirm them with the user. No test is written at an unconfirmed seam. You can't test everything, so agreeing the seams up front is how testing effort lands on the critical paths and complex logic instead of every edge case.
23
+
24
+ Ask: "What's the public interface, and which seams should we test?"
25
+
26
+ When the shape of that interface is itself in question (how deep the module is, where the seam belongs, what the interface should expose), call the Skill tool with "codebase-design" for the vocabulary. It is the shared source of the module, interface, depth, seam, adapter, leverage and locality terms, and it is a reference to consult, not a session to run.
27
+
28
+ ## Anti-patterns
29
+
30
+ - **Implementation-coupled**: mocks internal collaborators, tests private methods, or verifies through a side channel (querying the database instead of using the interface). The tell: the test breaks when you refactor but behavior hasn't changed.
31
+ - **Tautological**: the assertion recomputes the expected value the way the code does (`expect(add(a, b)).toBe(a + b)`, a snapshot derived by hand the same way, a constant asserted equal to itself), so it passes by construction and can never disagree with the code. Expected values must come from an independent source of truth: a known-good literal, a worked example, the spec.
32
+ - **Horizontal slicing**: writing all tests first, then all implementation. Bulk tests verify _imagined_ behavior: you test the _shape_ of things rather than user-facing behavior, the tests go insensitive to real changes, and you commit to test structure before understanding the implementation. Work in **vertical slices** instead: one test → one implementation → repeat, each test a **tracer bullet** that responds to what the last cycle taught you.
33
+
34
+ ## Rules of the loop
35
+
36
+ - **Red before green.** Write the failing test first, then only enough code to pass it. Don't anticipate future tests or add speculative features.
37
+ - **One slice at a time.** One seam, one test, one minimal implementation per cycle.
38
+ - **Refactoring is not part of the loop.** It belongs to the review stage (see the `code-review` skill), not the red → green implementation cycle.
.agents/skills/tdd/mocking.md ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # When to Mock
2
+
3
+ Mock at **system boundaries** only:
4
+
5
+ - External APIs (payment, email, etc.)
6
+ - Databases (sometimes - prefer test DB)
7
+ - Time/randomness
8
+ - File system (sometimes)
9
+
10
+ Don't mock:
11
+
12
+ - Your own classes/modules
13
+ - Internal collaborators
14
+ - Anything you control
15
+
16
+ ## Designing for Mockability
17
+
18
+ At system boundaries, design interfaces that are easy to mock:
19
+
20
+ **1. Use dependency injection**
21
+
22
+ Pass external dependencies in rather than creating them internally:
23
+
24
+ ```typescript
25
+ // Easy to mock
26
+ function processPayment(order, paymentClient) {
27
+ return paymentClient.charge(order.total);
28
+ }
29
+
30
+ // Hard to mock
31
+ function processPayment(order) {
32
+ const client = new StripeClient(process.env.STRIPE_KEY);
33
+ return client.charge(order.total);
34
+ }
35
+ ```
36
+
37
+ **2. Prefer SDK-style interfaces over generic fetchers**
38
+
39
+ Create specific functions for each external operation instead of one generic function with conditional logic:
40
+
41
+ ```typescript
42
+ // GOOD: Each function is independently mockable
43
+ const api = {
44
+ getUser: (id) => fetch(`/users/${id}`),
45
+ getOrders: (userId) => fetch(`/users/${userId}/orders`),
46
+ createOrder: (data) => fetch('/orders', { method: 'POST', body: data }),
47
+ };
48
+
49
+ // BAD: Mocking requires conditional logic inside the mock
50
+ const api = {
51
+ fetch: (endpoint, options) => fetch(endpoint, options),
52
+ };
53
+ ```
54
+
55
+ The SDK approach means:
56
+ - Each mock returns one specific shape
57
+ - No conditional logic in test setup
58
+ - Easier to see which endpoints a test exercises
59
+ - Type safety per endpoint
.agents/skills/tdd/tests.md ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Good and Bad Tests
2
+
3
+ ## Good Tests
4
+
5
+ **Integration-style**: Test through real interfaces, not mocks of internal parts.
6
+
7
+ ```typescript
8
+ // GOOD: Tests observable behavior
9
+ test("user can checkout with valid cart", async () => {
10
+ const cart = createCart();
11
+ cart.add(product);
12
+ const result = await checkout(cart, paymentMethod);
13
+ expect(result.status).toBe("confirmed");
14
+ });
15
+ ```
16
+
17
+ Characteristics:
18
+
19
+ - Tests behavior users/callers care about
20
+ - Uses public API only
21
+ - Survives internal refactors
22
+ - Describes WHAT, not HOW
23
+ - One logical assertion per test
24
+
25
+ ## Bad Tests
26
+
27
+ **Implementation-detail tests**: Coupled to internal structure.
28
+
29
+ ```typescript
30
+ // BAD: Tests implementation details
31
+ test("checkout calls paymentService.process", async () => {
32
+ const mockPayment = jest.mock(paymentService);
33
+ await checkout(cart, payment);
34
+ expect(mockPayment.process).toHaveBeenCalledWith(cart.total);
35
+ });
36
+ ```
37
+
38
+ Red flags:
39
+
40
+ - Mocking internal collaborators
41
+ - Testing private methods
42
+ - Asserting on call counts/order
43
+ - Test breaks when refactoring without behavior change
44
+ - Test name describes HOW not WHAT
45
+ - Verifying through external means instead of interface
46
+
47
+ ```typescript
48
+ // BAD: Bypasses interface to verify
49
+ test("createUser saves to database", async () => {
50
+ await createUser({ name: "Alice" });
51
+ const row = await db.query("SELECT * FROM users WHERE name = ?", ["Alice"]);
52
+ expect(row).toBeDefined();
53
+ });
54
+
55
+ // GOOD: Verifies through interface
56
+ test("createUser makes user retrievable", async () => {
57
+ const user = await createUser({ name: "Alice" });
58
+ const retrieved = await getUser(user.id);
59
+ expect(retrieved.name).toBe("Alice");
60
+ });
61
+ ```
62
+
63
+ **Tautological tests**: Expected value restates the implementation, so the test passes by construction.
64
+
65
+ ```typescript
66
+ // BAD: Expected value is recomputed the way the code computes it
67
+ test("calculateTotal sums line items", () => {
68
+ const items = [{ price: 10 }, { price: 5 }];
69
+ const expected = items.reduce((sum, i) => sum + i.price, 0);
70
+ expect(calculateTotal(items)).toBe(expected);
71
+ });
72
+
73
+ // GOOD: Expected value is an independent, known literal
74
+ test("calculateTotal sums line items", () => {
75
+ expect(calculateTotal([{ price: 10 }, { price: 5 }])).toBe(15);
76
+ });
77
+ ```
.agents/skills/translate-docs/SKILL.md ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: translate-docs
3
+ description: Translate and sync bilingual user documentation between docs/zh/ and docs/en/ following the source-of-truth rules in docs/AGENTS.md.
4
+ ---
5
+
6
+ # Translate Docs
7
+
8
+ ## Overview
9
+
10
+ This repository keeps bilingual user documentation under `docs/zh/` and `docs/en/`. This skill synchronizes the two locales, page by page, after either side has been updated.
11
+
12
+ This skill is invoked by both `gen-docs` (incremental updates) and `audit-docs` (full pre-release audit) to keep locale mirrors in sync.
13
+
14
+ ## Prerequisites
15
+
16
+ If any of the following are missing, stop and report to the user before continuing:
17
+
18
+ - `docs/zh/` and `docs/en/` mirrored directory structure.
19
+ - `docs/AGENTS.md` — terminology table, typography rules, and source-of-truth rules.
20
+
21
+ ## Locale sync rules
22
+
23
+ - **Changelog** (`release-notes/changelog.md`): English is the source. Translate to Chinese.
24
+ - **Breaking changes** (`release-notes/breaking-changes.md`): English is the source. Translate to Chinese.
25
+ - **All other pages**: `docs/en/` and `docs/zh/` are mirrored pairs. After either side changes, update the other locale in the same change.
26
+
27
+ When non-changelog pages change in either locale, sync the mirror before release. When the English changelog changes, sync the Chinese changelog.
28
+
29
+ ## Workflow
30
+
31
+ 1. **Detect what needs syncing**
32
+
33
+ - `git diff main..HEAD --stat docs/` — see which files changed
34
+ - For each changed file under `docs/en/` or `docs/zh/`, locate its mirror in the other locale (same relative path).
35
+
36
+ 2. **Translate page by page, section by section**
37
+
38
+ - Keep heading hierarchy, list structure, code blocks, callout blocks, and link targets identical between the two versions.
39
+ - When in doubt about a technical term, **read the actual code** to confirm behavior rather than guessing.
40
+
41
+ 3. **Apply terminology and typography rules from `docs/AGENTS.md`**
42
+
43
+ - Use the term table exactly. Do not invent translations or use synonyms.
44
+ - English H2+ uses sentence case (proper nouns excepted, per the term table).
45
+ - Chinese typography: full-width punctuation (`,。;:?!()`), space between Chinese and ASCII (letters / numbers / inline code / links).
46
+ - Callout titles (`::: tip` / `::: warning` / `::: info` / `::: danger`) use the short Chinese labels from `docs/AGENTS.md`.
47
+
48
+ 4. **Verify**
49
+
50
+ - `git diff docs/` — scan for terminology drift or punctuation regressions.
51
+ - Run the docs build if available (`pnpm --filter docs run build` or equivalent) to catch broken links and Markdown errors.
52
+
53
+ ## Rules and conventions
54
+
55
+ - **Do not one-sided fixes**: if the changed locale has an unclear or incorrect statement, fix it there first; do not patch only the mirror.
56
+ - **Match style, not just words**: Chinese docs use a narrative tone (see `docs/AGENTS.md` writing-style examples); preserve that tone in Chinese; preserve sentence-case headings and concise English style in English.
57
+ - **Code blocks and identifiers stay as-is**: do not translate code, command names, flag names, or file paths.
58
+ - **Public examples**: Do not introduce real internal endpoints, key names, account names, or service names while translating. Keep or replace them with neutral placeholders such as `example.com`, `example.test`, and `YOUR_API_KEY` in both locales.
59
+
60
+ ## Common mistakes
61
+
62
+ - Rewriting only the mirror because a phrase feels awkward in the target language — fix the changed locale first, then sync.
63
+ - Letting English headings slip into Title Case (only sentence case is allowed for H2+).
64
+ - Forgetting to add spaces between Chinese characters and inline code or English words.
65
+ - Translating proper nouns listed in the term table (`Wire`, `MCP`, `ACP`, `JSON`, `OAuth`, `macOS`, `uv`, etc.).
66
+ - Updating only one direction and leaving the other locale stale — always finish all pages flagged by the diff.
67
+ - Copying real internal values into the mirror instead of using neutral `example` placeholders.
.agents/skills/write-tui/DESIGN.md ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TUI 设计规范(Design Spec)
2
+
3
+ > 本目录所有 dialog / selector / 输入框的**单一真值源**。新增或改造交互组件前先读本文件,提交前对照文末「自查清单」。
4
+ > 基准组件:`components/dialogs/model-selector.ts`(`/model`)。所有列表型 dialog 的头部、hint、搜索、选中/当前态都以它为准对齐。
5
+
6
+ ---
7
+
8
+ ## 1. 视觉状态
9
+
10
+ | 语义 | 规范 | 常量 / token |
11
+ |---|---|---|
12
+ | 选中项指针 | `❯ `(`primary`) | `constant/symbols.ts` → `SELECT_POINTER` |
13
+ | 选中项文字 | `primary` + bold | `chalk.hex(colors.primary).bold` |
14
+ | 当前 / 激活项 | 行尾 ` ← current`(`success`) | `constant/symbols.ts` → `CURRENT_MARK` |
15
+ | 危险项 / 操作 | `error`(选中再加 bold) | `chalk.hex(colors.error)` |
16
+ | 危险确认 `[y/N]` | `warning` + bold | `chalk.hex(colors.warning)` |
17
+ | 开关项状态:开 | 名称后 ` enabled`(`success`) | `chalk.hex(colors.success)` |
18
+ | 开关项状态:关 | 名称后 ` disabled`(`textDim`) | `chalk.hex(colors.textDim)` |
19
+ | 列表 / 选择器边框 | 平直 `─`(`primary`),仅顶/底各一条 | — |
20
+ | 输入框边框 | 圆角 `╭ ╮ ╰ ╯`(`primary`) | — |
21
+
22
+ - **不要**自造选中指针(`>` / `▶` / `→` 等);统一用 `SELECT_POINTER`。
23
+ - **不要**用 `● ` / `(current)` 表示当前项;统一用 `CURRENT_MARK`(行尾、`success`、前置一个空格)。
24
+ - 当前项与选中项**互相独立**:当前项是「现在生效的值」(行尾 marker),选中项是「光标所在行」(指针 + 高亮);两者可同时落在同一行。
25
+
26
+ ## 2. 颜色
27
+
28
+ - 一律使用**语义 token**:`chalk.hex(colors.<token>)`。仓库 `chalk-named-color-guard` 已强制此约定,**禁止** `chalk.red` / `chalk.gray` 等 named color。
29
+ - `ThemeStyles`(`state.theme.styles.*()`)是可选的便捷封装;用与不用都可,但颜色必须来自 `ColorPalette` token。
30
+ - 可用语义 token 见 `theme/colors.ts`:`primary` `accent` `text` `textStrong` `textDim` `textMuted` `border` `borderFocus` `success` `warning` `error` `status` …
31
+ - **hint 行不做键位高亮**:整行 `textMuted`,不给 `Enter` / `Esc` / `D` 等键位单独上色。
32
+
33
+ ## 3. 列表 dialog 标准布局
34
+
35
+ 以 `model-selector` 为准,自上而下逐行固定为:
36
+
37
+ ```
38
+ ───────────────────────────────────────── ① 顶部边框(primary,整宽 ─)
39
+ Select a model (type to search) ② 标题(primary+bold)+ 可搜索且无 query 时的后缀(textMuted)
40
+ ↑↓ navigate · Enter select · Esc cancel ③ hint(textMuted,紧贴标题,无键位高亮)
41
+ ④ 空行
42
+ Search: gpt ⑤ 搜索行:仅在有 query 时出现(` Search: ` primary + query text)
43
+ ❯ GPT-5 openai ⑥ 列表项:指针 + 名称(左)+ 次要列(右,textMuted)
44
+ Kimi K2 Kimi Code ← current 当前项行尾 ` ← current`(success)
45
+ ⑦ 空行
46
+ ▼ 3 more ⑧ 滚动 / 匹配指示:无 query 时 `▼ N more`,有 query 时 `x / y`
47
+ ───────────────────────────────────────── ⑨ 底部边框(primary,整宽 ─)
48
+ ```
49
+
50
+ 硬性约定:
51
+
52
+ - **头部只有顶部一条 `─`**。标题下方紧跟 hint,**不得**再插一条 `─`。整个 dialog 全宽 `─` 仅 2 条(顶 + 底)。
53
+ - **`(type to search)` 只出现在标题后缀**(可搜索且 query 为空时);hint 行**不再**重复出现「type to search」。
54
+ - **`Search:` 行在空行之下、列表之上**,只在有 query 时渲染。
55
+ - hint 紧贴标题(中间无空行);hint 与正文之间有 1 空行。
56
+ - 每行最终经 `truncateToWidth(line, width)`,CJK / 窄终端不超宽。
57
+
58
+ ## 4. hint 行与文案词汇(英文 UI)
59
+
60
+ 每段 hint 形如「**键位 + 描述**」,段间用 ` · `(单空格中点)分隔。
61
+
62
+ | 动作 | 键位 token | 描述词 | 完整片段 |
63
+ |---|---|---|---|
64
+ | 移动 | `↑↓` | navigate | `↑↓ navigate` |
65
+ | 翻页 | `←→` 或 `PgUp/PgDn` | page | `←→ page` |
66
+ | 确认 / 选中 | `Enter` | select | `Enter select` |
67
+ | 取消 / 关闭 | `Esc` | cancel | `Esc cancel` |
68
+ | 删除 | `D` | delete | `D delete` |
69
+ | 清空搜索 | `Backspace` | clear | `Backspace clear` |
70
+ | 切 provider | `Tab` | toggle provider | `Tab toggle provider` |
71
+ | 搜索(标题后缀) | 打字 | — | `(type to search)` |
72
+
73
+ - **键位 token 首字母大写**(`Enter` / `Esc` / `Tab` / `Backspace` / `D`),**描述词全小写**(navigate / select / cancel / page / delete / clear);方向符 `↑↓` / `←→` 原样。
74
+ - 方向符统一 `↑↓`(不用 `▲/▼`)。
75
+ - 「离开对话框」统一只说 `cancel`(不混用 close / back / exit / dismiss)。业务语义(如审批的 reject)例外。
76
+ - hint 随状态精简:可搜索列表无 query 时,「type to search」在标题后缀已出现,hint 不重复;有 query 时 hint 追加 `Backspace clear`。
77
+
78
+ ## 5. Tab 条(`/model` 的 provider 切换)
79
+
80
+ `tabbed-model-selector` 在 flat `model-selector` 外包一层 provider tab,样式对齐 **AskUserQuestion** 的 tab:
81
+
82
+ ```
83
+ Select a model (type to search)
84
+ Tab toggle provider · ↑↓ navigate · Enter select · Esc cancel ← hint 首项即 Tab 切换
85
+ ← 空行
86
+ All Kimi Code openai ← tab 条:激活项填充背景(primary 底 + text 字 + bold),其余 textMuted
87
+ ← 空行
88
+ ❯ ...
89
+ ```
90
+
91
+ - tab 条位置:**在 hint 行下方**,且**上下各一空行**(与 hint、与列表都隔开)。
92
+ - 激活 tab:`chalk.bgHex(colors.primary).hex(colors.text).bold(\` ${label} \`)`;非激活:`chalk.hex(colors.textMuted)`。两者可见宽度一致,切换不抖动。
93
+ - 第一个 tab 恒为 `All`(聚合所有 provider);**默认停在 `All`**。仅当显式传 `initialTabId`(如 `/provider` 新增完跳转)才停在指定 provider tab。
94
+ - `Tab` / `Shift+Tab` 循环切换;hint 行首项即 `Tab toggle provider`。
95
+ - 当前模型在所在 tab 内仍以 `❯` + ` ← current` 标记,切 tab 不丢失定位。
96
+
97
+ ## 6. 键位
98
+
99
+ | 动作 | 键 | 判定方式 |
100
+ |---|---|---|
101
+ | 移动 | `↑` / `↓` | `matchesKey(data, Key.up/down)` |
102
+ | 翻页 | `PgUp` / `PgDn` | `matchesKey(data, Key.pageUp/pageDown)` |
103
+ | 确认 / 选中 | `Enter` | `matchesKey(data, Key.enter)` |
104
+ | 取消 / 关闭 | `Esc` | `matchesKey(data, Key.escape)` |
105
+ | 删除 | `D` | `printableChar(data) === 'D'`(也接受 `'d'`) |
106
+ | 搜索 | 打字 | `printableChar(data)` |
107
+
108
+ - **字符比较必须经 `printableChar()`**(Kitty 协议),由 `printable-key-guard` 强制;功能键用 `matchesKey(data, Key.*)`。
109
+ - **`Esc` 两段式**:有 query 时先清空 query(`list.clearQuery()`),无 query 时才 `onCancel()`。
110
+ - `←` / `→` 不固定语义:无翻页结构的组件里承担「值切换」(如 `/model` 的 thinking on/off);`choice-picker` 这类无横向值的列表里用作翻页。**不要**在有 thinking 切换的组件里又拿 `←→` 翻页。
111
+ - **删除键统一用字母 `D`**(`/provider`、`/plugins` 一致)。字母键要求该列表**不可 type-to-search**(否则会打进搜索框)——当前所有带删除动作的列表都不可搜索;若某列表既要搜索又要删除,删除须改用非打印键。
112
+
113
+ ## 7. 开关列表与多选(toggle / multi-select)
114
+
115
+ 适用于「每行可独立开 / 关」的列表(如 `/plugins` 的已装插件、MCP server 列表)。区别于单选(`Enter` 选中即提交并关闭),开关列表用 `Space` 就地切换每行状态,dialog 不关闭。
116
+
117
+ ```
118
+ Plugins
119
+ ↑↓ navigate · Space toggle · Enter details · Esc cancel
120
+ ← 空行
121
+ Installed plugins (2) ← 分区标题(textStrong / 加粗)
122
+ ❯ Kimi Datasource enabled ← 选中行(❯ + primary+bold 名称)+ 状态标签(success)
123
+ id kimi-datasource · 1 skill · MCP 1/1 · via code.kimi.com · official ← 次要信息行(textMuted,` · ` 分隔)
124
+ Superpowers disabled ← 未选中行(text 名称)+ 关态标签(textDim)
125
+ id superpowers · 14 skills · via code.kimi.com · curated
126
+ ```
127
+
128
+ 约定:
129
+
130
+ - **`Space` 切换当前行状态**(开 ↔ 关),即时生效、dialog 保持打开;hint 含 `Space toggle`。
131
+ - **状态标签**紧跟名称、空 2 格:开 ` enabled`(`success`)、关 ` disabled`(`textDim`)。其它语义(如 `installed`=success、`install…`=primary)按 `statusStyle` 同源处理。
132
+ - `Enter` 在开关列表里另作他用(如「查看详情」`Enter details`),不承担 toggle。
133
+ - 多套独立动作时(toggle / 详情 / 删除 / 进子菜单),hint 逐项列全,键位首字母大写:`Space toggle · Enter details · D remove`(参照第 4 节大小写规则)。
134
+ - 行下可附 1 行次要信息(id / 数量 / 来源 / 信任级),`textMuted`、` · ` 分隔。
135
+
136
+ ## 8. Thinking 控件(`/model` 专属)
137
+
138
+ 列表下方展示当前选中模型的 thinking 三态,外观固定 `[ On ] Off` 段式:
139
+
140
+ - 标题:`Thinking (←→ to switch)`(仅 `toggle` 态显示括号提示);其余态只显示 `Thinking`。
141
+ - `toggle`:`[ On ] Off` / `On [ Off ]`,激活段 `primary+bold`。
142
+ - `always-on`:`[ Always on ]`。
143
+ - `unsupported`:`[ Off ]` + `unsupported`(textMuted)。
144
+ - `←` / `→` 翻转草稿;提交时经 `effectiveThinking()` 归一(always-on→true、unsupported→false)。
145
+
146
+ ## 9. 输入框(多字段)
147
+
148
+ - 圆角盒 `╭ ╮ ╰ ╯`(`primary`)。
149
+ - 字段切换:`Tab` / `Shift+Tab` / `↑` / `↓`。
150
+ - `Enter`:非末段→推进到下一字段;末段→提交。
151
+ - 取消:`Esc` / `Ctrl+C` / `Ctrl+D`。
152
+ - footer 随焦点动态:非末段显示 `Enter next`,末段显示 `Enter submit`。
153
+ - 必填校验按字段顺序定位(如 custom-registry:URL 空→定位 URL,token 空→定位 token),错误用对应的子提示态。
154
+
155
+ ## 10. 共享组件(优先复用,不另起炉灶)
156
+
157
+ | 形态 | 组件 |
158
+ |---|---|
159
+ | 列表光标 / 搜索 / 翻页状态机 | `utils/searchable-list.ts` → `SearchableList` |
160
+ | 分页视图 | `utils/paging.ts` → `pageView` |
161
+ | Kitty 可打印字符 | `utils/printable-key.ts` → `printableChar` / `isPrintableChar`(含 guard) |
162
+ | 选中指针 / 当前项标记 | `constant/symbols.ts` → `SELECT_POINTER` / `CURRENT_MARK` |
163
+
164
+ 新列表组件**必须复用 `SearchableList`**(光标 / 搜索 / 翻页),并手工对齐本文件第 3–8 节的布局、键位、文案。
165
+
166
+ ## 11. 新增 / 改造 dialog 自查清单
167
+
168
+ - [ ] 头部按第 3 节:顶部一条 `─`、标题(+`(type to search)` 后缀)、hint、空行、`Search:` 行、列表、底部一条 `─`;标题下**无**内层 `─`。
169
+ - [ ] hint 整行 `textMuted`,**不**做键位高亮;键位首字母大写、描述词小写、` · ` 分隔。
170
+ - [ ] 选中指针用 `SELECT_POINTER`,当前项用 `CURRENT_MARK`,未自造 `>` / `▶` / `→` / `● ` / `(current)`。
171
+ - [ ] 颜色全部来自 `colors.<token>`,无 named color。
172
+ - [ ] 键位:`↑↓` 移动、`PgUp/PgDn` 翻页、`Enter` 确认、`Esc` 取消(可搜索列表 `Esc` 两段式:先清 query 再关闭)、`D` 删除;字符比较经 `printableChar()`。
173
+ - [ ] 「离开对话框」只说 `cancel`,不混用 close / back / exit / dismiss。
174
+ - [ ] 开关列表用 `Space toggle` 就地切换、不关闭;状态标签 ` enabled`(`success`) / ` disabled`(`textDim`) 紧跟名称空 2 格(见第 7 节)。
175
+ - [ ] 长列表有滚动 / 翻页指示(`▼ N more` 或 `x / y`),空态文案明确(`No matches` 等)。
176
+ - [ ] 每行经 `truncateToWidth(line, width)`,CJK / 窄终端下不超宽。
177
+ - [ ] 复用 `SearchableList`;输入框圆角盒,多字段支持 `Tab/↑↓` 切换、Enter 推进 / 末段提交。
178
+ - [ ] 有对应的组件测试(render 快照 + handleInput 键行为)。
.agents/skills/write-tui/SKILL.md ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: write-tui
3
+ description: Use when writing or modifying the kimi-code terminal UI in apps/kimi-code/src/tui — components, dialogs/selectors, slash commands, themes, streaming render, or the KimiTUI controllers. Covers the architecture, where new features go, test placement, the theme system mechanics, and the dialog interaction/visual spec (DESIGN.md).
4
+ ---
5
+
6
+ # Write TUI (apps/kimi-code)
7
+
8
+ The terminal UI lives in `apps/kimi-code/src/tui`. Before writing TUI code, read `apps/kimi-code/AGENTS.md` for the always-on **map, module boundaries, and hard constraints** (printable-key decoding, no chalk named colors, etc.). This skill is the **how-to**: architecture orientation, feature routing, test placement, theme mechanics, and the dialog spec.
9
+
10
+ For any list dialog, selector, input box, or status/toggle list, the interaction and visual rules are normative — see **[DESIGN.md](./DESIGN.md)** in this folder and follow its self-check list before submitting.
11
+
12
+ ## Architecture
13
+
14
+ `KimiTUI` is a **coordinator** that wires state, layout, session, and dialogs together and delegates heavy logic to controllers.
15
+
16
+ - `src/tui/kimi-tui.ts` — the `KimiTUI` coordinator. Holds `state`, owns startup/shutdown order, layout/editor wiring, user-input entry, sending/queueing, session lifecycle, and the slash-command handler dispatch. It should **not** accumulate event-routing or rendering logic — those live in controllers.
17
+ - `src/tui/tui-state.ts` — `TUIState`, `createTUIState`, `createInitialAppState`. The single global UI state shape. Before adding a new global field, decide whether it truly belongs here vs. local component state.
18
+ - `src/tui/controllers/` — the independently-testable responsibilities. Each controller owns one slice:
19
+ - `session-event-handler.ts` — routes SDK session events (`handleEvent` dispatch + the per-event `handleXxx`). Concrete event handling goes here, not in `KimiTUI`.
20
+ - `streaming-ui.ts` — streaming render: assistant delta, thinking, tool call / result, compaction, subagent, background agent, transcript aggregation.
21
+ - `session-replay.ts` — resume/replay orchestration; drives replay records through the same live render hooks. Stateless replay parsing/limiting/projection helpers belong in `src/tui/utils/message-replay.ts`.
22
+ - `tasks-browser.ts` — the tasks browser controller.
23
+ - `editor-keyboard.ts` — editor keyboard handling, exit shortcuts, external editor, clipboard image.
24
+ - `auth-flow.ts` — login/auth orchestration (`refreshConfigAfterLogin`, etc.).
25
+ - `src/tui/commands/` — slash-command declaration, parsing, ordering, and dynamic skill-command generation. Parsing and types only; execution is dispatched from `KimiTUI`'s slash-command handler section, and complex execution sinks into `utils` or focused components.
26
+ - `src/tui/components/` — pi-tui components by UI type: `chrome/` (footer, todo, welcome, loader, device code), `dialogs/` (selectors, approval/question panels, settings popups that replace the editor), `editor/` (input box + mention provider), `media/` (image, diff, code highlight), `messages/` (transcript blocks + tool-renderers), `panes/` (activity, queue).
27
+ - `src/tui/reverse-rpc/` — adapts SDK approval/question callbacks into UI panel data and the user's choice back into an SDK response.
28
+ - `src/tui/theme/` — themes, color tokens, style helpers, pi-tui markdown theme, terminal-background detection. The single source of truth for color.
29
+ - `src/tui/utils/` — TUI-only utilities (need `TUIState` or a component). App-wide, UI-independent helpers go in `src/utils/`.
30
+
31
+ When a controller or `KimiTUI` section keeps growing, split pure functions, state projections, and presentation components into the matching directory rather than expanding the file.
32
+
33
+ ## Where new features go
34
+
35
+ The feature type decides the landing spot:
36
+
37
+ - **CLI arguments** → `src/cli/commands.ts` / `src/cli/options.ts`, passed into the TUI via `src/cli/run-shell.ts`. The CLI never operates on the session directly.
38
+ - **CLI subcommands** → `src/cli/sub/`, non-interactive only; reach core via `@moonshot-ai/kimi-code-sdk`.
39
+ - **Slash commands** → declare/parse/type under `src/tui/commands/`; add the execution entry in `KimiTUI`'s slash-command handler section; sink complex logic into `utils` or a focused component.
40
+ - **Skill-derived commands** → hook into `buildSkillSlashCommands` / the skill command map; do not hard-code a single skill.
41
+ - **Transcript message types** → define the shape in `src/tui/types.ts`, add/extend a `components/messages/` component, register the renderer in the transcript builder.
42
+ - **Tool-result display** → extend `components/messages/tool-renderers/registry.ts` and the renderer; do not stack branches inside `ToolCallComponent`.
43
+ - **Popup / selector** → `components/dialogs/`, mounted via `mountEditorReplacement`; follow [DESIGN.md](./DESIGN.md). If triggered by an SDK callback, check whether `reverse-rpc/` needs an adapter/controller/handler.
44
+ - **SDK event handling** → add the dispatch in `session-event-handler.ts`'s `handleEvent`, then the matching `handleXxx`.
45
+ - **Streaming render** → `controllers/streaming-ui.ts`.
46
+ - **Session start / resume behavior** → the session-management section of `KimiTUI`; replay behavior → `controllers/session-replay.ts`, reusing live render paths.
47
+ - **Status bar / activity / queue** → `chrome/footer`, `panes/activity`, `panes/queue`, and the matching `updateXxx`.
48
+ - **Configuration option** → read/write + schema in `src/tui/config.ts`, then the settings UI; persist through `saveTuiConfig` (a component never writes the config file itself).
49
+ - **Constants** → shared CLI/TUI non-copy constants in `src/constant/`; TUI-only non-copy constants in `src/tui/constant/`. Component-local copy, option labels, help text, dialog titles/footers stay next to their component — do not centralize copy into a global module.
50
+ - **General capability** → no TUI-state dependency → `src/utils/`; depends on TUI state or a component → `src/tui/utils/`.
51
+
52
+ ## Test placement
53
+
54
+ - Component behavior tests sit next to the component's existing tests (`test/tui/components/...`).
55
+ - Command parsing tests → `test/tui/commands/`.
56
+ - reverse-rpc tests → `test/tui/reverse-rpc/`.
57
+ - Pure utility tests → next to the corresponding utils tests.
58
+ - Do not create a generic `some-feature.test.ts` just to land a small feature; extend the nearest existing test file.
59
+
60
+ ## Theme system mechanics
61
+
62
+ Themes are managed centrally under `src/tui/theme/`:
63
+
64
+ - `colors.ts` — semantic tokens: `ColorPalette`, `darkColors`, `lightColors`.
65
+ - `styles.ts` — common chalk helpers built on top of `ColorPalette`.
66
+ - `pi-tui-theme.ts` — the markdown/pi-tui theme config.
67
+ - `terminal-background.ts` — terminal background detection used by auto resolution.
68
+ - `bundle.ts` — packs `colors`, `styles`, `markdownTheme` into a `KimiTUIThemeBundle`.
69
+ - `index.ts` / `detect.ts` — theme type and auto/dark/light resolution.
70
+
71
+ > **Keep the color-token set in sync.** `ColorPalette` in `colors.ts` is the source of truth for color tokens. When you add, rename, or remove one, update its mirrors in the same change: the custom-theme JSON schema (`apps/kimi-code/src/tui/theme/theme-schema.json`), the token tables in the custom-theme docs (`docs/en/customization/themes.md` and `docs/zh/customization/themes.md`), and the token table in the `custom-theme` built-in skill (`packages/agent-core-v2/src/features/skill/catalog/builtin/custom-theme.md`).
72
+
73
+ Apply / switch flow:
74
+
75
+ - UI entry: `ThemeSelectorComponent` → `handleThemeCommand` → `applyThemeChoice`.
76
+ - The real apply step is `KimiTUI.applyTheme`: it updates `state.theme`, `state.appState.theme`, and notifies components to refresh their palette.
77
+ - Persist the choice through `saveTuiConfig` — a component must not write the config file itself.
78
+
79
+ > The **hard color rules** (no chalk named colors, contrast ratios, no module-top-level cached styled functions, add a `ColorPalette` token before inventing a color) are normative and guard-enforced — they live in `apps/kimi-code/AGENTS.md`. This skill only covers the mechanics.
80
+
81
+ ## Before you submit
82
+
83
+ - Run lint / format / test on the files you changed.
84
+ - For any dialog/selector/input/toggle list, walk the self-check list at the end of [DESIGN.md](./DESIGN.md).
85
+ - Keep `printableChar()` for printable-key comparisons (CI guard) and `chalk.hex(colors.<token>)` for color (CI guard).
.gitattributes CHANGED
@@ -8,3 +8,8 @@
8
  *.gif binary
9
  *.ico binary
10
  *.png binary
 
 
 
 
 
 
8
  *.gif binary
9
  *.ico binary
10
  *.png binary
11
+ docs/media/kimi-rc-banner.jpg filter=lfs diff=lfs merge=lfs -text
12
+ docs/media/kimi-web-ui.jpg filter=lfs diff=lfs merge=lfs -text
13
+ docs/media/provider-manager.jpg filter=lfs diff=lfs merge=lfs -text
14
+ docs/media/intro.gif filter=lfs diff=lfs merge=lfs -text
15
+ apps/kimi-code/dist-web/assets/NotoSansSC_wght_-BkPpiACN.woff2 filter=lfs diff=lfs merge=lfs -text
apps/kimi-code/dist-web/assets/NotoSansSC_wght_-BkPpiACN.woff2 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:43c2f58299a21aaa962886e536c9e69f3c284f6cb6be39c57ce54a89d05205aa
3
+ size 7782876
docs/.vitepress/config.ts ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { defineConfig } from 'vitepress'
2
+ import { withMermaid } from 'vitepress-plugin-mermaid'
3
+ import llmstxt from 'vitepress-plugin-llms'
4
+
5
+ const rawBase = process.env.VITEPRESS_BASE
6
+ const base = rawBase
7
+ ? rawBase.startsWith('/')
8
+ ? rawBase.endsWith('/') ? rawBase : `${rawBase}/`
9
+ : `/${rawBase}/`
10
+ : '/'
11
+
12
+ const mermaidOptimizeDeps = [
13
+ '@braintree/sanitize-url',
14
+ 'dayjs',
15
+ 'debug',
16
+ 'cytoscape-cose-bilkent',
17
+ 'cytoscape',
18
+ ]
19
+
20
+ const config = withMermaid(defineConfig({
21
+ base,
22
+ title: 'Kimi Code CLI Docs',
23
+ description: 'Kimi Code CLI Documentation',
24
+
25
+ head: [
26
+ ['link', { rel: 'icon', type: 'image/x-icon', href: `${base}favicon.ico` }],
27
+ ['meta', { name: 'theme-color', content: '#0a7aff' }],
28
+ ],
29
+
30
+ srcExclude: ['AGENTS.md', 'superpowers/**'],
31
+
32
+ locales: {
33
+ zh: {
34
+ label: '简体中文',
35
+ lang: 'zh-CN',
36
+ link: '/zh/',
37
+ title: 'Kimi Code CLI 文档',
38
+ description: 'Kimi Code CLI 用户文档',
39
+ themeConfig: {
40
+ nav: [
41
+ { text: '指南', link: '/zh/guides/getting-started', activeMatch: '/zh/guides/' },
42
+ { text: '定制化', link: '/zh/customization/mcp', activeMatch: '/zh/customization/' },
43
+ { text: '配置', link: '/zh/configuration/config-files', activeMatch: '/zh/configuration/' },
44
+ { text: '参考手册', link: '/zh/reference/kimi-command', activeMatch: '/zh/reference/' },
45
+ { text: '发布说明', link: '/zh/release-notes/changelog', activeMatch: '/zh/release-notes/' },
46
+ ],
47
+ sidebar: {
48
+ '/zh/guides/': [
49
+ {
50
+ text: '指南',
51
+ items: [
52
+ { text: '开始使用', link: '/zh/guides/getting-started' },
53
+ { text: '从 kimi-cli 迁移', link: '/zh/guides/migration' },
54
+ { text: '常见使用案例', link: '/zh/guides/use-cases' },
55
+ { text: '交互与输入', link: '/zh/guides/interaction' },
56
+ { text: '会话与上下文', link: '/zh/guides/sessions' },
57
+ { text: '在 IDE 中使用', link: '/zh/guides/ides' },
58
+ { text: '在网页中使用', link: '/zh/guides/web' },
59
+ { text: '远程控制', link: '/zh/guides/remote-control' },
60
+ ],
61
+ },
62
+ ],
63
+ '/zh/customization/': [
64
+ {
65
+ text: '定制化',
66
+ items: [
67
+ { text: 'Model Context Protocol', link: '/zh/customization/mcp' },
68
+ { text: 'Agent Skills', link: '/zh/customization/skills' },
69
+ { text: 'Plugins', link: '/zh/customization/plugins' },
70
+ { text: 'Agent 与 subagent', link: '/zh/customization/agents' },
71
+ { text: 'Hooks', link: '/zh/customization/hooks' },
72
+ { text: '自定义主题', link: '/zh/customization/themes' },
73
+ ],
74
+ },
75
+ ],
76
+ '/zh/configuration/': [
77
+ {
78
+ text: '配置',
79
+ items: [
80
+ { text: '配置文件', link: '/zh/configuration/config-files' },
81
+ { text: '平台与模型', link: '/zh/configuration/providers' },
82
+ { text: '配置覆盖', link: '/zh/configuration/overrides' },
83
+ { text: '环境变量', link: '/zh/configuration/env-vars' },
84
+ { text: '数据路径', link: '/zh/configuration/data-locations' },
85
+ ],
86
+ },
87
+ ],
88
+ '/zh/reference/': [
89
+ {
90
+ text: '参考手册',
91
+ items: [
92
+ { text: 'kimi 命令', link: '/zh/reference/kimi-command' },
93
+ { text: 'kimi acp 子命令', link: '/zh/reference/kimi-acp' },
94
+ { text: '服务 API', link: '/zh/reference/server-api' },
95
+ { text: '内置工具', link: '/zh/reference/tools' },
96
+ { text: '斜杠命令', link: '/zh/reference/slash-commands' },
97
+ { text: '键盘快捷键', link: '/zh/reference/keyboard' },
98
+ ],
99
+ },
100
+ ],
101
+ '/zh/release-notes/': [
102
+ {
103
+ text: '发布说明',
104
+ items: [
105
+ { text: '变更记录', link: '/zh/release-notes/changelog' },
106
+ ],
107
+ },
108
+ ],
109
+ },
110
+ },
111
+ },
112
+ en: {
113
+ label: 'English',
114
+ lang: 'en-US',
115
+ link: '/en/',
116
+ title: 'Kimi Code CLI Docs',
117
+ description: 'Kimi Code CLI User Documentation',
118
+ themeConfig: {
119
+ nav: [
120
+ { text: 'Guides', link: '/en/guides/getting-started', activeMatch: '/en/guides/' },
121
+ { text: 'Customization', link: '/en/customization/mcp', activeMatch: '/en/customization/' },
122
+ { text: 'Configuration', link: '/en/configuration/config-files', activeMatch: '/en/configuration/' },
123
+ { text: 'Reference', link: '/en/reference/kimi-command', activeMatch: '/en/reference/' },
124
+ { text: 'Release Notes', link: '/en/release-notes/changelog', activeMatch: '/en/release-notes/' },
125
+ ],
126
+ sidebar: {
127
+ '/en/guides/': [
128
+ {
129
+ text: 'Guides',
130
+ items: [
131
+ { text: 'Getting Started', link: '/en/guides/getting-started' },
132
+ { text: 'Migrating from kimi-cli', link: '/en/guides/migration' },
133
+ { text: 'Common Use Cases', link: '/en/guides/use-cases' },
134
+ { text: 'Interaction and Input', link: '/en/guides/interaction' },
135
+ { text: 'Sessions and Context', link: '/en/guides/sessions' },
136
+ { text: 'Using in IDEs', link: '/en/guides/ides' },
137
+ { text: 'Using Kimi Code in the browser', link: '/en/guides/web' },
138
+ { text: 'Remote Control', link: '/en/guides/remote-control' },
139
+ ],
140
+ },
141
+ ],
142
+ '/en/customization/': [
143
+ {
144
+ text: 'Customization',
145
+ items: [
146
+ { text: 'Model Context Protocol', link: '/en/customization/mcp' },
147
+ { text: 'Agent Skills', link: '/en/customization/skills' },
148
+ { text: 'Plugins', link: '/en/customization/plugins' },
149
+ { text: 'Agents and Subagents', link: '/en/customization/agents' },
150
+ { text: 'Hooks', link: '/en/customization/hooks' },
151
+ { text: 'Custom Themes', link: '/en/customization/themes' },
152
+ ],
153
+ },
154
+ ],
155
+ '/en/configuration/': [
156
+ {
157
+ text: 'Configuration',
158
+ items: [
159
+ { text: 'Config Files', link: '/en/configuration/config-files' },
160
+ { text: 'Providers and Models', link: '/en/configuration/providers' },
161
+ { text: 'Config Overrides', link: '/en/configuration/overrides' },
162
+ { text: 'Environment Variables', link: '/en/configuration/env-vars' },
163
+ { text: 'Data Locations', link: '/en/configuration/data-locations' },
164
+ ],
165
+ },
166
+ ],
167
+ '/en/reference/': [
168
+ {
169
+ text: 'Reference',
170
+ items: [
171
+ { text: 'kimi Command', link: '/en/reference/kimi-command' },
172
+ { text: 'kimi acp Subcommand', link: '/en/reference/kimi-acp' },
173
+ { text: 'Server API', link: '/en/reference/server-api' },
174
+ { text: 'Built-in Tools', link: '/en/reference/tools' },
175
+ { text: 'Slash Commands', link: '/en/reference/slash-commands' },
176
+ { text: 'Keyboard Shortcuts', link: '/en/reference/keyboard' },
177
+ ],
178
+ },
179
+ ],
180
+ '/en/release-notes/': [
181
+ {
182
+ text: 'Release Notes',
183
+ items: [
184
+ { text: 'Changelog', link: '/en/release-notes/changelog' },
185
+ ],
186
+ },
187
+ ],
188
+ },
189
+ },
190
+ },
191
+ },
192
+
193
+ themeConfig: {
194
+ outline: [2, 3],
195
+ search: { provider: 'local' },
196
+ socialLinks: [
197
+ { icon: 'github', link: 'https://github.com/MoonshotAI/kimi-code' },
198
+ ],
199
+ },
200
+
201
+ vite: {
202
+ optimizeDeps: {
203
+ include: mermaidOptimizeDeps.map((dep) => `mermaid > ${dep}`),
204
+ },
205
+ plugins: [llmstxt()],
206
+ },
207
+ }))
208
+
209
+ if (config.vite?.optimizeDeps?.include) {
210
+ config.vite.optimizeDeps.include = config.vite.optimizeDeps.include.filter(
211
+ (dep) => !mermaidOptimizeDeps.includes(dep),
212
+ )
213
+ }
214
+
215
+ export default config
docs/.vitepress/theme/Kimi.png ADDED
docs/.vitepress/theme/components/HomeFeatures.vue ADDED
@@ -0,0 +1,319 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script setup lang="ts">
2
+ import { useData, withBase } from 'vitepress'
3
+ import { computed } from 'vue'
4
+
5
+ const { lang } = useData()
6
+ const isZh = computed(() => lang.value.startsWith('zh'))
7
+
8
+ interface Highlight {
9
+ icon: string
10
+ title: string
11
+ desc: string
12
+ }
13
+
14
+ interface Feature {
15
+ icon: string
16
+ title: string
17
+ desc: string
18
+ href: string
19
+ }
20
+
21
+ const highlights = computed<Highlight[]>(() => isZh.value
22
+ ? [
23
+ {
24
+ icon: '⚡',
25
+ title: '极速轻量',
26
+ desc: '一行命令装好的单文件 CLI,毫秒级启动,无需 Node.js,零环境干扰。',
27
+ },
28
+ {
29
+ icon: '🎬',
30
+ title: '视频也能输入',
31
+ desc: '屏幕录像、演示视频拖进对话——画面替你说清需求。',
32
+ },
33
+ {
34
+ icon: '🎨',
35
+ title: '精致 TUI',
36
+ desc: '为长时间、专注的 Agent 会话精心打磨的交互界面。',
37
+ },
38
+ ]
39
+ : [
40
+ {
41
+ icon: '⚡',
42
+ title: 'Fast & lightweight',
43
+ desc: 'Single-binary install with millisecond startup — no Node.js, no PATH gymnastics.',
44
+ },
45
+ {
46
+ icon: '🎬',
47
+ title: 'Video input',
48
+ desc: 'Drop a screen recording or demo clip in chat; the agent reads the frames and acts on them.',
49
+ },
50
+ {
51
+ icon: '🎨',
52
+ title: 'Polished TUI',
53
+ desc: 'A carefully tuned interface designed for long, focused agent sessions.',
54
+ },
55
+ ])
56
+
57
+ const features = computed<Feature[]>(() => isZh.value
58
+ ? [
59
+ {
60
+ icon: '🧩',
61
+ title: 'Agent Skills',
62
+ desc: '把团队的工作流程封装成 Kimi 随时调用的技能,不必每次都重新解释。',
63
+ href: '/zh/customization/skills',
64
+ },
65
+ {
66
+ icon: '🪝',
67
+ title: 'Hooks',
68
+ desc: '在生命周期关键点注入脚本,做格式化、审批、通知或任意自定义逻辑。',
69
+ href: '/zh/customization/hooks',
70
+ },
71
+ {
72
+ icon: '🤖',
73
+ title: 'Sub-agents',
74
+ desc: '并行派发独立任务,每个子 agent 自带上下文,主对话保持清爽。',
75
+ href: '/zh/customization/agents',
76
+ },
77
+ {
78
+ icon: '🔌',
79
+ title: 'MCP',
80
+ desc: '通过 Model Context Protocol 接入任意工具、数据源与企业系统。',
81
+ href: '/zh/customization/mcp',
82
+ }
83
+ ]
84
+ : [
85
+ {
86
+ icon: '🧩',
87
+ title: 'Agent Skills',
88
+ desc: "Package your team's workflows into skills Kimi can invoke on demand.",
89
+ href: '/en/customization/skills',
90
+ },
91
+ {
92
+ icon: '🪝',
93
+ title: 'Hooks',
94
+ desc: 'Inject scripts at lifecycle checkpoints — formatting, approvals, notifications, anything.',
95
+ href: '/en/customization/hooks',
96
+ },
97
+ {
98
+ icon: '🤖',
99
+ title: 'Sub-agents',
100
+ desc: 'Dispatch isolated tasks in parallel, each with its own context — main thread stays clean.',
101
+ href: '/en/customization/agents',
102
+ },
103
+ {
104
+ icon: '🔌',
105
+ title: 'MCP',
106
+ desc: 'Plug in any tool, data source, or enterprise system via the Model Context Protocol.',
107
+ href: '/en/customization/mcp',
108
+ }
109
+ ])
110
+
111
+ const highlightsTitle = computed(() => isZh.value ? '开箱即得' : 'Ready out of the box')
112
+ const highlightsLede = computed(() => isZh.value
113
+ ? '装好就能用,关键能力默认就绪。'
114
+ : 'Install once. The essentials are already there.')
115
+
116
+ const featuresTitle = computed(() => isZh.value ? '按需扩展' : 'Extend it your way')
117
+ const featuresLede = computed(() => isZh.value
118
+ ? '内置可编程的扩展点,按自己的方式塑造工作流。'
119
+ : 'Programmable extension points to shape the workflow around you.')
120
+
121
+ const ctaText = computed(() => isZh.value ? '了解' : 'Learn more')
122
+ </script>
123
+
124
+ <template>
125
+ <section class="KimiHome__section KimiHighlights">
126
+ <h2 class="KimiHome__sectionTitle">{{ highlightsTitle }}</h2>
127
+ <p class="KimiHome__sectionLede">{{ highlightsLede }}</p>
128
+ <div class="KimiHighlights__grid">
129
+ <div
130
+ v-for="h in highlights"
131
+ :key="h.title"
132
+ class="KimiHighlights__card"
133
+ >
134
+ <div class="KimiHighlights__icon" aria-hidden="true">{{ h.icon }}</div>
135
+ <h3 class="KimiHighlights__title">{{ h.title }}</h3>
136
+ <p class="KimiHighlights__desc">{{ h.desc }}</p>
137
+ </div>
138
+ </div>
139
+ </section>
140
+
141
+ <section class="KimiHome__section KimiFeatures">
142
+ <h2 class="KimiHome__sectionTitle">{{ featuresTitle }}</h2>
143
+ <p class="KimiHome__sectionLede">{{ featuresLede }}</p>
144
+ <div class="KimiFeatures__grid">
145
+ <a
146
+ v-for="f in features"
147
+ :key="f.title"
148
+ class="KimiFeatures__card"
149
+ :href="withBase(f.href)"
150
+ >
151
+ <div class="KimiFeatures__icon" aria-hidden="true">{{ f.icon }}</div>
152
+ <h3 class="KimiFeatures__title">{{ f.title }}</h3>
153
+ <p class="KimiFeatures__desc">{{ f.desc }}</p>
154
+ <span class="KimiFeatures__cta">
155
+ {{ ctaText }}
156
+ <svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true">
157
+ <path d="M6 3l5 5-5 5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
158
+ </svg>
159
+ </span>
160
+ </a>
161
+ </div>
162
+ </section>
163
+ </template>
164
+
165
+ <style scoped>
166
+ /* === Highlights (top section: non-clickable product attributes) === */
167
+ .KimiHighlights__grid {
168
+ display: grid;
169
+ grid-template-columns: repeat(3, minmax(0, 1fr));
170
+ gap: 16px;
171
+ }
172
+
173
+ @media (max-width: 720px) {
174
+ .KimiHighlights__grid {
175
+ grid-template-columns: 1fr;
176
+ }
177
+ }
178
+
179
+ .KimiHighlights__card {
180
+ display: flex;
181
+ flex-direction: column;
182
+ align-items: flex-start;
183
+ padding: 22px 22px 24px;
184
+ border-radius: var(--kimi-radius-card);
185
+ border: 1px solid var(--vp-c-divider);
186
+ background: var(--vp-c-bg-soft);
187
+ }
188
+
189
+ .KimiHighlights__icon {
190
+ display: inline-flex;
191
+ align-items: center;
192
+ justify-content: center;
193
+ width: 36px;
194
+ height: 36px;
195
+ border-radius: 10px;
196
+ background: var(--kimi-brand-soft);
197
+ font-size: 18px;
198
+ margin-bottom: 14px;
199
+ }
200
+
201
+ .KimiHighlights__title {
202
+ font-size: 16px;
203
+ font-weight: 700;
204
+ letter-spacing: -0.01em;
205
+ margin: 0 0 6px;
206
+ color: var(--vp-c-text-1);
207
+ }
208
+
209
+ .KimiHighlights__desc {
210
+ font-size: 14px;
211
+ line-height: 1.55;
212
+ color: var(--vp-c-text-2);
213
+ margin: 0;
214
+ }
215
+
216
+ /* === Features (bottom section: clickable extension points) === */
217
+ .KimiFeatures__grid {
218
+ display: grid;
219
+ grid-template-columns: repeat(4, minmax(0, 1fr));
220
+ gap: 20px;
221
+ }
222
+
223
+ @media (max-width: 1024px) {
224
+ .KimiFeatures__grid {
225
+ grid-template-columns: repeat(2, minmax(0, 1fr));
226
+ }
227
+ }
228
+ @media (max-width: 640px) {
229
+ .KimiFeatures__grid {
230
+ grid-template-columns: 1fr;
231
+ }
232
+ }
233
+
234
+ .KimiFeatures__card {
235
+ position: relative;
236
+ display: flex;
237
+ flex-direction: column;
238
+ align-items: flex-start;
239
+ padding: 28px 24px 26px;
240
+ border-radius: var(--kimi-radius-card);
241
+ border: 1px solid var(--vp-c-divider);
242
+ background: var(--vp-c-bg);
243
+ color: var(--vp-c-text-1);
244
+ text-decoration: none;
245
+ transition: transform var(--kimi-transition), border-color var(--kimi-transition),
246
+ box-shadow var(--kimi-transition), background var(--kimi-transition);
247
+ overflow: hidden;
248
+ }
249
+
250
+ .KimiFeatures__card::before {
251
+ content: '';
252
+ position: absolute;
253
+ inset: 0;
254
+ background: var(--kimi-brand-gradient-soft);
255
+ opacity: 0;
256
+ transition: opacity var(--kimi-transition);
257
+ pointer-events: none;
258
+ border-radius: inherit;
259
+ }
260
+
261
+ .KimiFeatures__card:hover {
262
+ transform: translateY(-3px);
263
+ border-color: var(--vp-c-brand-1);
264
+ box-shadow: var(--vp-shadow-3);
265
+ }
266
+ .KimiFeatures__card:hover::before {
267
+ opacity: 1;
268
+ }
269
+
270
+ .KimiFeatures__icon {
271
+ position: relative;
272
+ z-index: 1;
273
+ display: inline-flex;
274
+ align-items: center;
275
+ justify-content: center;
276
+ width: 44px;
277
+ height: 44px;
278
+ border-radius: 12px;
279
+ background: var(--kimi-brand-soft);
280
+ font-size: 22px;
281
+ margin-bottom: 18px;
282
+ }
283
+
284
+ .KimiFeatures__title {
285
+ position: relative;
286
+ z-index: 1;
287
+ font-size: 18px;
288
+ font-weight: 700;
289
+ letter-spacing: -0.015em;
290
+ margin: 0 0 8px;
291
+ color: var(--vp-c-text-1);
292
+ }
293
+
294
+ .KimiFeatures__desc {
295
+ position: relative;
296
+ z-index: 1;
297
+ font-size: 14.5px;
298
+ line-height: 1.6;
299
+ color: var(--vp-c-text-2);
300
+ margin: 0 0 20px;
301
+ }
302
+
303
+ .KimiFeatures__cta {
304
+ position: relative;
305
+ z-index: 1;
306
+ display: inline-flex;
307
+ align-items: center;
308
+ gap: 6px;
309
+ font-size: 14px;
310
+ font-weight: 600;
311
+ color: var(--vp-c-brand-1);
312
+ margin-top: auto;
313
+ transition: transform var(--kimi-transition);
314
+ }
315
+
316
+ .KimiFeatures__card:hover .KimiFeatures__cta {
317
+ transform: translateX(3px);
318
+ }
319
+ </style>
docs/.vitepress/theme/components/HomeHero.vue ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script setup lang="ts">
2
+ import { useData, withBase } from 'vitepress'
3
+ import { computed } from 'vue'
4
+ import KimiLogo from './KimiLogo.vue'
5
+
6
+ const { lang } = useData()
7
+
8
+ const isZh = computed(() => lang.value.startsWith('zh'))
9
+
10
+ const copy = computed(() => isZh.value
11
+ ? {
12
+ titleLead: 'Kimi',
13
+ titleAccent: 'Code',
14
+ titleTail: ' CLI',
15
+ tagline: 'The Starting Point for Next-Gen Agents',
16
+ primaryText: '开始使用',
17
+ primaryHref: '/zh/guides/getting-started',
18
+ secondaryText: '在 GitHub 查看',
19
+ secondaryHref: 'https://github.com/MoonshotAI/kimi-code',
20
+ }
21
+ : {
22
+ titleLead: 'Kimi',
23
+ titleAccent: 'Code',
24
+ titleTail: ' CLI',
25
+ tagline: 'The Starting Point for Next-Gen Agents',
26
+ primaryText: 'Get started',
27
+ primaryHref: '/en/guides/getting-started',
28
+ secondaryText: 'View on GitHub',
29
+ secondaryHref: 'https://github.com/MoonshotAI/kimi-code',
30
+ })
31
+ </script>
32
+
33
+ <template>
34
+ <section class="KimiHero">
35
+ <div class="KimiHero__halo" aria-hidden="true" />
36
+ <div class="KimiHero__inner">
37
+ <div class="KimiHero__logo">
38
+ <KimiLogo :size="64" />
39
+ </div>
40
+ <h1 class="KimiHero__title">
41
+ {{ copy.titleLead }}&nbsp;<span class="KimiHero__accent">{{ copy.titleAccent }}</span>{{ copy.titleTail }}
42
+ </h1>
43
+ <p class="KimiHero__tagline">{{ copy.tagline }}</p>
44
+ <div class="KimiHero__actions">
45
+ <a class="KimiBtn KimiBtn--primary" :href="withBase(copy.primaryHref)">
46
+ {{ copy.primaryText }}
47
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true">
48
+ <path d="M6 3l5 5-5 5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
49
+ </svg>
50
+ </a>
51
+ <a class="KimiBtn KimiBtn--ghost" :href="copy.secondaryHref" target="_blank" rel="noopener">
52
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true">
53
+ <path d="M8 .2C3.58.2 0 3.78 0 8.2c0 3.54 2.3 6.54 5.48 7.6.4.07.55-.17.55-.38l-.01-1.5c-2.23.49-2.7-.95-2.7-.95-.37-.93-.9-1.18-.9-1.18-.73-.5.06-.49.06-.49.81.06 1.24.83 1.24.83.72 1.23 1.88.88 2.34.67.07-.52.28-.88.51-1.08-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.13 0 0 .67-.21 2.2.82a7.65 7.65 0 014 0c1.53-1.03 2.2-.82 2.2-.82.44 1.11.16 1.93.08 2.13.51.56.82 1.28.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.55.74.55 1.49l-.01 2.21c0 .21.15.46.55.38C13.7 14.74 16 11.74 16 8.2 16 3.78 12.42.2 8 .2z" />
54
+ </svg>
55
+ {{ copy.secondaryText }}
56
+ </a>
57
+ </div>
58
+ </div>
59
+ </section>
60
+ </template>
61
+
62
+ <style scoped>
63
+ .KimiHero {
64
+ position: relative;
65
+ padding: clamp(72px, 12vw, 140px) 0 clamp(48px, 8vw, 96px);
66
+ overflow: hidden;
67
+ }
68
+
69
+ .KimiHero__halo {
70
+ position: absolute;
71
+ top: -120px;
72
+ left: 50%;
73
+ width: 900px;
74
+ height: 600px;
75
+ transform: translateX(-50%);
76
+ background:
77
+ radial-gradient(closest-side, rgba(10, 122, 255, 0.22), transparent 70%),
78
+ radial-gradient(closest-side, rgba(129, 196, 255, 0.20) 30%, transparent 75%);
79
+ filter: blur(40px);
80
+ pointer-events: none;
81
+ z-index: 0;
82
+ opacity: 0.55;
83
+ }
84
+ :global(.dark) .KimiHero__halo {
85
+ opacity: 0.85;
86
+ background:
87
+ radial-gradient(closest-side, rgba(61, 149, 255, 0.36), transparent 70%),
88
+ radial-gradient(closest-side, rgba(129, 196, 255, 0.30) 30%, transparent 75%);
89
+ }
90
+
91
+ .KimiHero__inner {
92
+ position: relative;
93
+ z-index: 1;
94
+ display: flex;
95
+ flex-direction: column;
96
+ align-items: center;
97
+ text-align: center;
98
+ }
99
+
100
+ .KimiHero__logo {
101
+ margin-bottom: 28px;
102
+ filter: drop-shadow(0 12px 32px rgba(10, 122, 255, 0.28));
103
+ }
104
+
105
+ .KimiHero__title {
106
+ font-size: clamp(40px, 7vw, 84px);
107
+ font-weight: 700;
108
+ letter-spacing: -0.035em;
109
+ line-height: 1.05;
110
+ margin: 0 0 20px;
111
+ color: var(--vp-c-text-1);
112
+ max-width: 18ch;
113
+ }
114
+
115
+ .KimiHero__accent {
116
+ background: var(--kimi-brand-gradient);
117
+ background-clip: text;
118
+ -webkit-background-clip: text;
119
+ -webkit-text-fill-color: transparent;
120
+ color: transparent;
121
+ }
122
+
123
+ .KimiHero__tagline {
124
+ font-size: clamp(16px, 1.5vw, 20px);
125
+ line-height: 1.55;
126
+ color: var(--vp-c-text-2);
127
+ max-width: 620px;
128
+ margin: 0 0 40px;
129
+ }
130
+
131
+ .KimiHero__actions {
132
+ display: flex;
133
+ gap: 14px;
134
+ flex-wrap: wrap;
135
+ justify-content: center;
136
+ }
137
+
138
+ @media (max-width: 480px) {
139
+ .KimiHero__actions {
140
+ width: 100%;
141
+ flex-direction: column;
142
+ }
143
+ .KimiHero__actions .KimiBtn {
144
+ width: 100%;
145
+ }
146
+ }
147
+ </style>
docs/.vitepress/theme/components/HomeLayout.vue ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script setup lang="ts">
2
+ import DefaultTheme from 'vitepress/theme'
3
+ import { useData } from 'vitepress'
4
+ import HomeHero from './HomeHero.vue'
5
+ import HomeFeatures from './HomeFeatures.vue'
6
+ import HomeQuickStart from './HomeQuickStart.vue'
7
+
8
+ const { Layout } = DefaultTheme
9
+ const { frontmatter } = useData()
10
+ </script>
11
+
12
+ <template>
13
+ <Layout>
14
+ <template v-if="frontmatter.layout === 'home'" #home-hero-before>
15
+ <div class="KimiHome">
16
+ <HomeHero />
17
+ </div>
18
+ </template>
19
+
20
+ <template v-if="frontmatter.layout === 'home'" #home-features-after>
21
+ <div class="KimiHome">
22
+ <HomeQuickStart />
23
+ <HomeFeatures />
24
+ </div>
25
+ </template>
26
+ </Layout>
27
+ </template>
28
+
29
+ <style>
30
+ /* Hide the default hero + features rendered by VitePress when our custom home is active.
31
+ We keep frontmatter.layout: home so VitePress still applies layout-specific behavior. */
32
+ .VPHome > .VPHero {
33
+ display: none;
34
+ }
35
+ .VPHome > .VPFeatures {
36
+ display: none;
37
+ }
38
+ </style>
docs/.vitepress/theme/components/HomeQuickStart.vue ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script setup lang="ts">
2
+ import { useData, withBase } from 'vitepress'
3
+ import { computed, ref } from 'vue'
4
+
5
+ const { lang } = useData()
6
+ const isZh = computed(() => lang.value.startsWith('zh'))
7
+
8
+ const installMacCommand = 'curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash'
9
+ const installWinCommand = 'irm https://code.kimi.com/kimi-code/install.ps1 | iex'
10
+ const runCommand = 'kimi'
11
+
12
+ const copy = computed(() => isZh.value
13
+ ? {
14
+ title: '一行命令开始',
15
+ lede: '装好之后跑 kimi,立刻在你当前的项目里开聊。',
16
+ macLabel: 'macOS / Linux',
17
+ winLabel: 'Windows (PowerShell)',
18
+ runLabel: '在任意目录运行',
19
+ copyHint: '复制',
20
+ copiedHint: '已复制',
21
+ ctaText: '查看完整安装指南',
22
+ ctaHref: '/zh/guides/getting-started',
23
+ }
24
+ : {
25
+ title: 'Get started in one line',
26
+ lede: 'Once installed, run kimi inside any project to start a conversation.',
27
+ macLabel: 'macOS / Linux',
28
+ winLabel: 'Windows (PowerShell)',
29
+ runLabel: 'Run anywhere',
30
+ copyHint: 'Copy',
31
+ copiedHint: 'Copied',
32
+ ctaText: 'Read the full install guide',
33
+ ctaHref: '/en/guides/getting-started',
34
+ })
35
+
36
+ const copiedKey = ref<string | null>(null)
37
+ let copiedTimer: ReturnType<typeof setTimeout> | null = null
38
+
39
+ function copyText(value: string, key: string) {
40
+ if (typeof navigator === 'undefined' || !navigator.clipboard) return
41
+ navigator.clipboard.writeText(value).then(() => {
42
+ copiedKey.value = key
43
+ if (copiedTimer) clearTimeout(copiedTimer)
44
+ copiedTimer = setTimeout(() => { copiedKey.value = null }, 1600)
45
+ })
46
+ }
47
+ </script>
48
+
49
+ <template>
50
+ <section class="KimiHome__section KimiQuick">
51
+ <h2 class="KimiHome__sectionTitle">{{ copy.title }}</h2>
52
+ <p class="KimiHome__sectionLede">{{ copy.lede }}</p>
53
+
54
+ <div class="KimiQuick__installs">
55
+ <div class="KimiQuick__block">
56
+ <div class="KimiQuick__label">{{ copy.macLabel }}</div>
57
+ <div class="KimiQuick__cmd">
58
+ <code><span class="KimiQuick__prompt">$</span> {{ installMacCommand }}</code>
59
+ <button
60
+ type="button"
61
+ class="KimiQuick__copy"
62
+ @click="copyText(installMacCommand, 'mac')"
63
+ :aria-label="copy.copyHint"
64
+ >
65
+ <template v-if="copiedKey === 'mac'">{{ copy.copiedHint }}</template>
66
+ <template v-else>{{ copy.copyHint }}</template>
67
+ </button>
68
+ </div>
69
+ </div>
70
+
71
+ <div class="KimiQuick__block">
72
+ <div class="KimiQuick__label">{{ copy.winLabel }}</div>
73
+ <div class="KimiQuick__cmd">
74
+ <code><span class="KimiQuick__prompt">PS&gt;</span> {{ installWinCommand }}</code>
75
+ <button
76
+ type="button"
77
+ class="KimiQuick__copy"
78
+ @click="copyText(installWinCommand, 'win')"
79
+ :aria-label="copy.copyHint"
80
+ >
81
+ <template v-if="copiedKey === 'win'">{{ copy.copiedHint }}</template>
82
+ <template v-else>{{ copy.copyHint }}</template>
83
+ </button>
84
+ </div>
85
+ </div>
86
+ </div>
87
+
88
+ <div class="KimiQuick__block KimiQuick__block--run">
89
+ <div class="KimiQuick__label">{{ copy.runLabel }}</div>
90
+ <div class="KimiQuick__cmd">
91
+ <code><span class="KimiQuick__prompt">$</span> {{ runCommand }}</code>
92
+ <button
93
+ type="button"
94
+ class="KimiQuick__copy"
95
+ @click="copyText(runCommand, 'run')"
96
+ :aria-label="copy.copyHint"
97
+ >
98
+ <template v-if="copiedKey === 'run'">{{ copy.copiedHint }}</template>
99
+ <template v-else>{{ copy.copyHint }}</template>
100
+ </button>
101
+ </div>
102
+ </div>
103
+
104
+ <a class="KimiQuick__more" :href="withBase(copy.ctaHref)">
105
+ {{ copy.ctaText }}
106
+ <svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true">
107
+ <path d="M6 3l5 5-5 5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
108
+ </svg>
109
+ </a>
110
+ </section>
111
+ </template>
112
+
113
+ <style scoped>
114
+ .KimiQuick__installs {
115
+ display: flex;
116
+ flex-direction: column;
117
+ gap: 16px;
118
+ margin-bottom: 16px;
119
+ }
120
+
121
+ .KimiQuick__block {
122
+ display: flex;
123
+ flex-direction: column;
124
+ gap: 10px;
125
+ }
126
+
127
+ .KimiQuick__block--run {
128
+ margin-bottom: 28px;
129
+ }
130
+
131
+ .KimiQuick__label {
132
+ font-size: 13px;
133
+ font-weight: 600;
134
+ letter-spacing: 0.02em;
135
+ text-transform: uppercase;
136
+ color: var(--vp-c-text-3);
137
+ }
138
+
139
+ .KimiQuick__cmd {
140
+ position: relative;
141
+ display: flex;
142
+ align-items: center;
143
+ padding: 18px 22px;
144
+ background: var(--vp-c-bg-soft);
145
+ border: 1px solid var(--vp-c-divider);
146
+ border-radius: var(--kimi-radius-code);
147
+ font-family: var(--vp-font-family-mono);
148
+ font-size: 14.5px;
149
+ line-height: 1.4;
150
+ color: var(--vp-c-text-1);
151
+ overflow: hidden;
152
+ transition: border-color var(--kimi-transition), box-shadow var(--kimi-transition);
153
+ }
154
+ .KimiQuick__cmd:hover {
155
+ border-color: var(--vp-c-brand-1);
156
+ box-shadow: var(--vp-shadow-2);
157
+ }
158
+ .KimiQuick__cmd code {
159
+ flex: 1;
160
+ white-space: pre;
161
+ overflow-x: auto;
162
+ background: transparent !important;
163
+ color: inherit;
164
+ padding: 0;
165
+ font-size: inherit;
166
+ font-family: inherit;
167
+ border-radius: 0;
168
+ }
169
+ .KimiQuick__prompt {
170
+ color: var(--vp-c-brand-1);
171
+ margin-right: 8px;
172
+ user-select: none;
173
+ font-weight: 600;
174
+ }
175
+
176
+ .KimiQuick__copy {
177
+ flex: none;
178
+ margin-left: 12px;
179
+ padding: 6px 12px;
180
+ font-size: 12px;
181
+ font-weight: 600;
182
+ font-family: var(--vp-font-family-base);
183
+ letter-spacing: 0.01em;
184
+ color: var(--vp-c-text-2);
185
+ background: var(--vp-c-bg);
186
+ border: 1px solid var(--vp-c-divider);
187
+ border-radius: 8px;
188
+ cursor: pointer;
189
+ transition: color var(--kimi-transition), border-color var(--kimi-transition), background var(--kimi-transition);
190
+ }
191
+ .KimiQuick__copy:hover {
192
+ color: var(--vp-c-brand-1);
193
+ border-color: var(--vp-c-brand-1);
194
+ }
195
+
196
+ .KimiQuick__more {
197
+ display: inline-flex;
198
+ align-items: center;
199
+ gap: 6px;
200
+ font-size: 15px;
201
+ font-weight: 600;
202
+ color: var(--vp-c-brand-1);
203
+ text-decoration: none;
204
+ transition: transform var(--kimi-transition), color var(--kimi-transition);
205
+ }
206
+ .KimiQuick__more:hover {
207
+ color: var(--vp-c-brand-2);
208
+ transform: translateX(3px);
209
+ }
210
+ </style>
docs/.vitepress/theme/components/KimiLogo.vue ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script setup lang="ts">
2
+ import logoUrl from '../Kimi.png'
3
+
4
+ withDefaults(defineProps<{ size?: number }>(), { size: 56 })
5
+ </script>
6
+
7
+ <template>
8
+ <img
9
+ class="KimiLogo"
10
+ :src="logoUrl"
11
+ :width="size"
12
+ :height="size"
13
+ alt="Kimi"
14
+ />
15
+ </template>
16
+
17
+ <style scoped>
18
+ .KimiLogo {
19
+ display: block;
20
+ object-fit: contain;
21
+ }
22
+ </style>
docs/.vitepress/theme/index.ts ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { Theme } from 'vitepress'
2
+ import DefaultTheme from 'vitepress/theme'
3
+ import HomeLayout from './components/HomeLayout.vue'
4
+
5
+ import './styles/vars.css'
6
+ import './styles/base.css'
7
+ import './styles/home.css'
8
+
9
+ export default {
10
+ extends: DefaultTheme,
11
+ Layout: HomeLayout,
12
+ } satisfies Theme
docs/.vitepress/theme/styles/base.css ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Base overrides applied to all pages.
3
+ * Touches links, inline code, code blocks, custom blocks, blockquotes, navbar, sidebar.
4
+ */
5
+
6
+ html {
7
+ font-feature-settings: 'cv11', 'ss01', 'ss03';
8
+ -webkit-font-smoothing: antialiased;
9
+ -moz-osx-font-smoothing: grayscale;
10
+ }
11
+
12
+ body {
13
+ font-family: var(--vp-font-family-base);
14
+ }
15
+
16
+ /* --- Top navbar: blur + remove the hard bottom line --- */
17
+ .VPNav,
18
+ .VPNavBar {
19
+ background: rgba(255, 255, 255, 0.72) !important;
20
+ backdrop-filter: saturate(180%) blur(14px);
21
+ -webkit-backdrop-filter: saturate(180%) blur(14px);
22
+ }
23
+ .dark .VPNav,
24
+ .dark .VPNavBar {
25
+ background: rgba(13, 17, 23, 0.72) !important;
26
+ }
27
+ .VPNavBar.has-sidebar .content,
28
+ .VPNavBar:not(.home) {
29
+ border-bottom: 1px solid var(--vp-c-divider);
30
+ }
31
+
32
+ /* --- Sidebar: brand-tinted active item, slim left accent bar --- */
33
+ .VPSidebarItem.is-active > .item .link .text,
34
+ .VPSidebarItem.is-active > .item > .text {
35
+ color: var(--vp-c-brand-1);
36
+ font-weight: 600;
37
+ }
38
+ .VPSidebarItem.is-link.is-active > .item {
39
+ position: relative;
40
+ }
41
+ .VPSidebarItem.is-link.is-active > .item::before {
42
+ content: '';
43
+ position: absolute;
44
+ left: -14px;
45
+ top: 50%;
46
+ transform: translateY(-50%);
47
+ width: 3px;
48
+ height: 16px;
49
+ border-radius: 2px;
50
+ background: var(--kimi-brand-gradient);
51
+ }
52
+
53
+ /* --- Headings: tighter tracking, no underline on h2 --- */
54
+ .vp-doc h1,
55
+ .vp-doc h2,
56
+ .vp-doc h3 {
57
+ letter-spacing: -0.02em;
58
+ }
59
+ .vp-doc h2 {
60
+ border-top: none;
61
+ padding-top: 24px;
62
+ margin-top: 48px;
63
+ }
64
+
65
+ /* --- Links --- */
66
+ .vp-doc a:not(.header-anchor) {
67
+ color: var(--vp-c-brand-1);
68
+ text-decoration: underline;
69
+ text-decoration-color: transparent;
70
+ text-underline-offset: 4px;
71
+ text-decoration-thickness: 2px;
72
+ transition: text-decoration-color var(--kimi-transition), color var(--kimi-transition);
73
+ font-weight: 500;
74
+ }
75
+ .vp-doc a:not(.header-anchor):hover {
76
+ color: var(--vp-c-brand-2);
77
+ text-decoration-color: currentColor;
78
+ }
79
+
80
+ /* --- Inline code --- */
81
+ .vp-doc :not(pre) > code {
82
+ background: var(--kimi-brand-soft);
83
+ color: var(--vp-c-brand-1);
84
+ padding: 2px 6px;
85
+ border-radius: 6px;
86
+ font-weight: 500;
87
+ font-size: 0.875em;
88
+ border: none;
89
+ }
90
+
91
+ /* Inline code inside headings: drop the chip, keep just the brand-colored monospace word */
92
+ .vp-doc :is(h1, h2, h3, h4, h5, h6) code {
93
+ background: transparent;
94
+ padding: 0;
95
+ border-radius: 0;
96
+ font-size: 0.9em;
97
+ font-weight: inherit;
98
+ color: var(--vp-c-brand-1);
99
+ }
100
+
101
+ /* --- Code blocks --- */
102
+ .vp-doc div[class*='language-'] {
103
+ border-radius: var(--kimi-radius-code);
104
+ background: var(--vp-c-bg-soft);
105
+ margin: 20px 0;
106
+ box-shadow: var(--vp-shadow-1);
107
+ }
108
+ .vp-doc div[class*='language-'] pre {
109
+ padding: 20px 24px;
110
+ }
111
+ .vp-doc div[class*='language-'] code {
112
+ font-family: var(--vp-font-family-mono);
113
+ font-size: 13.5px;
114
+ line-height: 1.7;
115
+ }
116
+ .vp-doc div[class*='language-'] .lang {
117
+ color: var(--vp-c-text-3);
118
+ font-size: 12px;
119
+ }
120
+ .vp-doc div[class*='language-'] button.copy {
121
+ border-radius: 8px;
122
+ }
123
+
124
+ /* --- Blockquote --- */
125
+ .vp-doc blockquote {
126
+ border-left: 3px solid var(--vp-c-brand-1);
127
+ background: var(--kimi-brand-soft);
128
+ padding: 14px 18px;
129
+ border-radius: 0 var(--kimi-radius-code) var(--kimi-radius-code) 0;
130
+ margin: 20px 0;
131
+ }
132
+ .vp-doc blockquote > p {
133
+ color: var(--vp-c-text-2);
134
+ margin: 0;
135
+ }
136
+
137
+ /* --- Custom blocks (tip / warning / danger / info) --- */
138
+ .vp-doc .custom-block {
139
+ border-radius: var(--kimi-radius-code);
140
+ border: none;
141
+ padding: 16px 20px;
142
+ margin: 20px 0;
143
+ }
144
+ .vp-doc .custom-block .custom-block-title {
145
+ font-weight: 600;
146
+ letter-spacing: -0.005em;
147
+ }
148
+ .vp-doc .custom-block.tip {
149
+ background: rgba(10, 122, 255, 0.08);
150
+ color: var(--vp-c-text-1);
151
+ }
152
+ .dark .vp-doc .custom-block.tip {
153
+ background: rgba(61, 149, 255, 0.12);
154
+ }
155
+ .vp-doc .custom-block.warning {
156
+ background: rgba(234, 179, 8, 0.10);
157
+ color: var(--vp-c-text-1);
158
+ }
159
+ .vp-doc .custom-block.danger {
160
+ background: rgba(239, 68, 68, 0.10);
161
+ color: var(--vp-c-text-1);
162
+ }
163
+ .vp-doc .custom-block.info {
164
+ background: rgba(148, 163, 184, 0.12);
165
+ color: var(--vp-c-text-1);
166
+ }
167
+ .vp-doc .custom-block.tip .custom-block-title { color: var(--vp-c-brand-1); }
168
+ .vp-doc .custom-block.warning .custom-block-title { color: #ca8a04; }
169
+ .vp-doc .custom-block.danger .custom-block-title { color: #dc2626; }
170
+ .dark .vp-doc .custom-block.warning .custom-block-title { color: #eab308; }
171
+ .dark .vp-doc .custom-block.danger .custom-block-title { color: #ef4444; }
172
+
173
+ /* --- Tables --- */
174
+ .vp-doc table {
175
+ border-radius: var(--kimi-radius-code);
176
+ overflow: hidden;
177
+ border-collapse: separate;
178
+ border-spacing: 0;
179
+ display: table;
180
+ width: 100%;
181
+ }
182
+ .vp-doc tr {
183
+ background: transparent !important;
184
+ border-top: 1px solid var(--vp-c-divider);
185
+ }
186
+ .vp-doc tr:first-child { border-top: none; }
187
+ .vp-doc th {
188
+ background: var(--vp-c-bg-soft);
189
+ font-weight: 600;
190
+ color: var(--vp-c-text-1);
191
+ }
192
+
193
+ /* --- Outline / TOC --- */
194
+ .VPDocAsideOutline .outline-link.active,
195
+ .VPDocAsideOutline .outline-link:hover {
196
+ color: var(--vp-c-brand-1);
197
+ }
198
+
199
+ /* --- Buttons globally (e.g. hero CTAs) --- */
200
+ .VPButton.brand {
201
+ background: var(--kimi-brand-gradient) !important;
202
+ border: none !important;
203
+ box-shadow: var(--vp-shadow-3);
204
+ transition: transform var(--kimi-transition), box-shadow var(--kimi-transition);
205
+ }
206
+ .VPButton.brand:hover {
207
+ transform: translateY(-2px);
208
+ box-shadow: var(--vp-shadow-4);
209
+ }
210
+ .VPButton.alt {
211
+ background: transparent !important;
212
+ border: 1px solid var(--vp-c-divider) !important;
213
+ color: var(--vp-c-text-1) !important;
214
+ transition: border-color var(--kimi-transition), transform var(--kimi-transition);
215
+ }
216
+ .VPButton.alt:hover {
217
+ border-color: var(--vp-c-brand-1) !important;
218
+ transform: translateY(-2px);
219
+ }
220
+
221
+ /* --- Hero default frontmatter (used as fallback when custom Home not rendered) --- */
222
+ .VPHero .name,
223
+ .VPHero .text {
224
+ letter-spacing: -0.03em;
225
+ }
226
+
227
+ /* --- Footer --- */
228
+ .VPFooter {
229
+ border-top: 1px solid var(--vp-c-divider);
230
+ background: transparent;
231
+ }
232
+
233
+ /* --- Step rail (numbered steps on guides/web) --- */
234
+ .vp-doc .step-num {
235
+ display: inline-flex;
236
+ align-items: center;
237
+ justify-content: center;
238
+ width: 1.45em;
239
+ height: 1.45em;
240
+ border-radius: 50%;
241
+ background: #f4f5f7;
242
+ color: #8a919c;
243
+ font-size: 0.85em;
244
+ font-weight: 500;
245
+ line-height: 1;
246
+ margin-right: 0.6em;
247
+ vertical-align: 0.1em;
248
+ }
249
+ .vp-doc .step {
250
+ position: relative;
251
+ border-left: 2px solid #f0f2f5;
252
+ padding-left: 1.4em;
253
+ margin-left: 0.75em;
254
+ padding-bottom: 0.6em;
255
+ }
256
+ .vp-doc .step:last-of-type {
257
+ border-left-color: transparent;
258
+ }
259
+ .vp-doc .step .step-num {
260
+ position: absolute;
261
+ left: -0.78em;
262
+ top: 0.15em;
263
+ margin-right: 0;
264
+ }
265
+
266
+ /* --- Feature compare table (fixed-width ✓ columns on guides/web) --- */
267
+ .feature-compare-table table {
268
+ table-layout: fixed;
269
+ width: 100%;
270
+ }
271
+ .feature-compare-table th:nth-child(1),
272
+ .feature-compare-table td:nth-child(1) {
273
+ width: 8em;
274
+ white-space: nowrap;
275
+ }
276
+ .feature-compare-table th:nth-child(2),
277
+ .feature-compare-table td:nth-child(2),
278
+ .feature-compare-table th:nth-child(3),
279
+ .feature-compare-table td:nth-child(3) {
280
+ width: 4.5em;
281
+ text-align: center;
282
+ }
docs/.vitepress/theme/styles/home.css ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Home-only styles. Scoped CSS in components handles most rules;
3
+ * shared utilities and layout container live here.
4
+ */
5
+
6
+ .KimiHome {
7
+ --section-px: clamp(20px, 5vw, 64px);
8
+ --section-py: clamp(28px, 4vw, 56px);
9
+ position: relative;
10
+ padding: 0 var(--section-px);
11
+ }
12
+
13
+ .KimiHome__section {
14
+ max-width: 1152px;
15
+ margin: 0 auto;
16
+ padding: var(--section-py) 0;
17
+ position: relative;
18
+ }
19
+
20
+ .KimiHome__sectionTitle {
21
+ font-size: clamp(28px, 4vw, 40px);
22
+ font-weight: 700;
23
+ letter-spacing: -0.03em;
24
+ margin: 0 0 12px;
25
+ color: var(--vp-c-text-1);
26
+ }
27
+
28
+ .KimiHome__sectionLede {
29
+ font-size: 17px;
30
+ color: var(--vp-c-text-2);
31
+ margin: 0 0 40px;
32
+ max-width: 640px;
33
+ line-height: 1.6;
34
+ }
35
+
36
+ .KimiBtn {
37
+ display: inline-flex;
38
+ align-items: center;
39
+ justify-content: center;
40
+ gap: 8px;
41
+ height: 48px;
42
+ padding: 0 22px;
43
+ border-radius: var(--kimi-radius-button);
44
+ font-size: 15px;
45
+ font-weight: 600;
46
+ letter-spacing: -0.005em;
47
+ text-decoration: none;
48
+ transition: transform var(--kimi-transition), box-shadow var(--kimi-transition),
49
+ border-color var(--kimi-transition), background var(--kimi-transition);
50
+ white-space: nowrap;
51
+ cursor: pointer;
52
+ border: 1px solid transparent;
53
+ }
54
+ .KimiBtn--primary {
55
+ color: #ffffff;
56
+ background: var(--kimi-brand-gradient);
57
+ box-shadow: var(--vp-shadow-3);
58
+ border: 0;
59
+ }
60
+ .KimiBtn--primary:hover {
61
+ transform: translateY(-2px);
62
+ box-shadow: var(--vp-shadow-4);
63
+ color: #ffffff;
64
+ }
65
+ .KimiBtn--ghost {
66
+ color: var(--vp-c-text-1);
67
+ background: transparent;
68
+ border-color: var(--vp-c-divider);
69
+ }
70
+ .KimiBtn--ghost:hover {
71
+ border-color: var(--vp-c-brand-1);
72
+ transform: translateY(-2px);
73
+ color: var(--vp-c-text-1);
74
+ }
75
+ .KimiBtn--link {
76
+ color: var(--vp-c-brand-1);
77
+ height: auto;
78
+ padding: 0;
79
+ background: transparent;
80
+ border: none;
81
+ }
82
+ .KimiBtn--link:hover {
83
+ color: var(--vp-c-brand-2);
84
+ transform: translateX(2px);
85
+ }
docs/.vitepress/theme/styles/vars.css ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Design tokens for the Kimi Code docs theme.
3
+ * Light + dark live side by side; VitePress toggles the .dark class on <html>.
4
+ */
5
+
6
+ :root {
7
+ /* Brand palette — cool blue family from design board */
8
+ --kimi-brand-1: #0a7aff; /* primary */
9
+ --kimi-brand-2: #5baeff; /* mid */
10
+ --kimi-brand-3: #81c4ff; /* soft sky */
11
+ --kimi-brand-deep: #043153; /* deep navy (anchor for dark surfaces) */
12
+ --kimi-brand-whisper: #eff8ff; /* near-white blue (light tints) */
13
+ --kimi-brand-gradient: linear-gradient(135deg, #0a7aff 0%, #5baeff 60%, #81c4ff 100%);
14
+ --kimi-brand-gradient-soft: linear-gradient(135deg, rgba(10, 122, 255, 0.14) 0%, rgba(91, 174, 255, 0.12) 60%, rgba(129, 196, 255, 0.10) 100%);
15
+ --kimi-brand-soft: rgba(10, 122, 255, 0.10);
16
+ --kimi-brand-soft-strong: rgba(10, 122, 255, 0.16);
17
+
18
+ /* Shape */
19
+ --kimi-radius-card: 16px;
20
+ --kimi-radius-button: 10px;
21
+ --kimi-radius-chip: 999px;
22
+ --kimi-radius-code: 12px;
23
+ --kimi-transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
24
+
25
+ /* Typography */
26
+ --vp-font-family-base:
27
+ 'Inter', -apple-system, BlinkMacSystemFont,
28
+ 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei',
29
+ 'Helvetica Neue', 'Segoe UI', Arial, sans-serif;
30
+ --vp-font-family-mono:
31
+ ui-monospace, SFMono-Regular, 'SF Mono',
32
+ Menlo, Consolas, 'Liberation Mono', 'Courier New', monospace;
33
+
34
+ /* Surfaces (light) — clean white + subtle blue-tinted off-white */
35
+ --vp-c-bg: #ffffff;
36
+ --vp-c-bg-alt: #f6f9fd;
37
+ --vp-c-bg-elv: #ffffff;
38
+ --vp-c-bg-soft: #eff5fc;
39
+
40
+ /* Text (light) */
41
+ --vp-c-text-1: #0b1a30;
42
+ --vp-c-text-2: #475569;
43
+ --vp-c-text-3: #94a3b8;
44
+
45
+ /* Borders (light) — picked up from palette E1E3E6 */
46
+ --vp-c-divider: #e1e3e6;
47
+ --vp-c-gutter: #e1e3e6;
48
+ --vp-c-border: #e1e3e6;
49
+
50
+ /* Brand applied to VitePress vars (light) */
51
+ --vp-c-brand-1: var(--kimi-brand-1);
52
+ --vp-c-brand-2: var(--kimi-brand-2);
53
+ --vp-c-brand-3: #006ae3; /* hover, slightly deeper than primary */
54
+ --vp-c-brand-soft: var(--kimi-brand-soft);
55
+
56
+ /* Shadows (light) — no negative spread, avoids "kink" at rounded corners */
57
+ --vp-shadow-1: 0 1px 2px rgba(11, 26, 48, 0.04);
58
+ --vp-shadow-2: 0 6px 20px rgba(10, 122, 255, 0.15);
59
+ --vp-shadow-3: 0 10px 28px rgba(10, 122, 255, 0.22);
60
+ --vp-shadow-4: 0 18px 44px rgba(10, 122, 255, 0.30);
61
+
62
+ /* Buttons (light) */
63
+ --vp-button-brand-bg: var(--kimi-brand-1);
64
+ --vp-button-brand-hover-bg: var(--vp-c-brand-3);
65
+ --vp-button-brand-active-bg: var(--vp-c-brand-3);
66
+ --vp-button-brand-border: transparent;
67
+ --vp-button-brand-hover-border: transparent;
68
+ --vp-button-brand-text: #ffffff;
69
+ --vp-button-brand-hover-text: #ffffff;
70
+ --vp-button-brand-active-text: #ffffff;
71
+
72
+ /* Custom blocks tinting (light) */
73
+ --vp-custom-block-tip-border: transparent;
74
+ --vp-custom-block-tip-text: var(--vp-c-text-1);
75
+ --vp-custom-block-tip-bg: rgba(10, 122, 255, 0.07);
76
+ --vp-custom-block-tip-code-bg: rgba(10, 122, 255, 0.10);
77
+ }
78
+
79
+ .dark {
80
+ /* Surfaces (dark) — neutral dark with subtle navy undertone */
81
+ --vp-c-bg: #0a1422;
82
+ --vp-c-bg-alt: #0f1b2e;
83
+ --vp-c-bg-elv: #0f1b2e;
84
+ --vp-c-bg-soft: #15263f;
85
+
86
+ /* Text (dark) — avoid pure white */
87
+ --vp-c-text-1: #e2e8f0;
88
+ --vp-c-text-2: #94a3b8;
89
+ --vp-c-text-3: #64748b;
90
+
91
+ /* Borders (dark) — navy-leaning to stay in family */
92
+ --vp-c-divider: #1b2e47;
93
+ --vp-c-gutter: #1b2e47;
94
+ --vp-c-border: #1b2e47;
95
+
96
+ /* Brand applied (dark) — keep the pure blue family, brightened */
97
+ --vp-c-brand-1: #3d95ff;
98
+ --vp-c-brand-2: #81c4ff;
99
+ --vp-c-brand-3: #5baeff;
100
+ --vp-c-brand-soft: rgba(61, 149, 255, 0.16);
101
+
102
+ /* Softs (dark) */
103
+ --kimi-brand-soft: rgba(61, 149, 255, 0.16);
104
+ --kimi-brand-soft-strong: rgba(61, 149, 255, 0.22);
105
+
106
+ /* Shadows (dark) — brand-tinted glow, no negative spread */
107
+ --vp-shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
108
+ --vp-shadow-2: 0 6px 24px rgba(61, 149, 255, 0.22);
109
+ --vp-shadow-3: 0 10px 32px rgba(61, 149, 255, 0.32);
110
+ --vp-shadow-4: 0 18px 48px rgba(61, 149, 255, 0.42);
111
+
112
+ /* Buttons (dark) */
113
+ --vp-button-brand-bg: var(--kimi-brand-1);
114
+ --vp-button-brand-hover-bg: #1f8cff;
115
+ --vp-button-brand-active-bg: #1f8cff;
116
+
117
+ /* Custom blocks tinting (dark) */
118
+ --vp-custom-block-tip-bg: rgba(61, 149, 255, 0.12);
119
+ --vp-custom-block-tip-code-bg: rgba(61, 149, 255, 0.16);
120
+ }
docs/en/configuration/config-files.md ADDED
@@ -0,0 +1,619 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Configuration files
2
+
3
+ Kimi Code CLI writes all long-term preferences into TOML (plain-text configuration) files under `~/.kimi-code/`: runtime settings live in `config.toml`, and terminal-UI preferences live in a companion `tui.toml`.
4
+
5
+ ## Config file location
6
+
7
+ The CLI reads configuration from `~/.kimi-code/config.toml`, created automatically on first run. To relocate the data directory, override it with the `KIMI_CODE_HOME` environment variable:
8
+
9
+ ```sh
10
+ export KIMI_CODE_HOME=/path/to/kimi-home
11
+ ```
12
+
13
+ The config file path then becomes `$KIMI_CODE_HOME/config.toml`. Regardless of where the directory lives, the file name is always `config.toml`.
14
+
15
+ ::: tip
16
+ TOML field names always use snake_case, for example `default_model` and `max_context_size`. If a key contains `.`, you must quote it (for example `[models."gpt-4.1"]`); otherwise TOML treats `.` as a nested table separator.
17
+ :::
18
+
19
+ ## Complete example
20
+
21
+ The following example covers the most commonly used configuration fields. You can copy it and adjust as needed:
22
+
23
+ ```toml
24
+ default_model = "kimi-code/k3"
25
+ default_permission_mode = "manual"
26
+ default_plan_mode = false
27
+ merge_all_available_skills = true
28
+ telemetry = true
29
+
30
+ [providers."managed:kimi-code"]
31
+ type = "kimi"
32
+ base_url = "https://api.kimi.com/coding/v1"
33
+ api_key = ""
34
+
35
+ [models."kimi-code/k3"]
36
+ provider = "managed:kimi-code"
37
+ model = "k3"
38
+ max_context_size = 1048576
39
+ capabilities = [ "thinking", "always_thinking", "image_in", "video_in", "tool_use" ]
40
+ display_name = "K3"
41
+ support_efforts = [ "low", "high", "max" ]
42
+ default_effort = "max"
43
+
44
+ [models."kimi-code/kimi-for-coding"]
45
+ provider = "managed:kimi-code"
46
+ model = "kimi-for-coding"
47
+ max_context_size = 262144
48
+ capabilities = [ "thinking", "always_thinking", "image_in", "video_in", "tool_use" ]
49
+
50
+ [models."kimi-code/kimi-for-coding-highspeed"]
51
+ provider = "managed:kimi-code"
52
+ model = "kimi-for-coding-highspeed"
53
+ max_context_size = 262144
54
+ capabilities = [ "thinking", "always_thinking", "image_in", "video_in", "tool_use" ]
55
+
56
+ [thinking]
57
+ enabled = true
58
+ effort = "high"
59
+ keep = "all"
60
+
61
+ [loop_control]
62
+ max_attempts_per_step = 10
63
+ reserved_context_size = 50000
64
+
65
+ [background]
66
+ max_running_tasks = 4
67
+ keep_alive_on_exit = false
68
+
69
+ [services.moonshot_search]
70
+ base_url = "https://api.kimi.com/coding/v1/search"
71
+ api_key = ""
72
+
73
+ [services.moonshot_fetch]
74
+ base_url = "https://api.kimi.com/coding/v1/fetch"
75
+ api_key = ""
76
+
77
+ [[permission.rules]]
78
+ decision = "allow"
79
+ pattern = "Read"
80
+
81
+ [[permission.rules]]
82
+ decision = "deny"
83
+ pattern = "Bash(rm -rf*)"
84
+
85
+ [[hooks]]
86
+ event = "PreToolUse"
87
+ matcher = "Bash"
88
+ command = "node ~/.kimi-code/hooks/check-bash.mjs"
89
+ timeout = 5
90
+ ```
91
+
92
+ ## Top-level fields
93
+
94
+ Fields in the config file fall into two categories: **top-level scalars** that directly control default behavior, and **nested tables** (`providers`, `models`, `thinking`, etc.) that each have their own structure, described individually in the sections below.
95
+
96
+ | Field | Type | Default | Description |
97
+ | --- | --- | --- | --- |
98
+ | `default_model` | `string` | — | Default model alias; must be defined in `models` |
99
+ | `default_permission_mode` | `string` | `manual` | Default permission mode for new sessions: `manual`, `yolo`, or `auto`. See [the three permission modes](../guides/interaction.md#the-three-permission-modes) |
100
+ | `default_plan_mode` | `boolean` | `false` | Whether new sessions start in [Plan mode](../guides/interaction.md#plan-mode) by default |
101
+ | `merge_all_available_skills` | `boolean` | `true` | Whether to merge Agent Skills from all available directories |
102
+ | `extra_skill_dirs` | `array<string>` | — | Extra skill search directories, layered on top of the default directories |
103
+ | `extra_agent_dirs` | `array<string>` | — | Extra custom agent search directories, layered on top of the default directories |
104
+ | `builtin_product_skills` | `boolean` | `true` | Whether the built-in skills that document Kimi Code itself are offered to the model |
105
+ | `telemetry` | `boolean` | `true` | Whether anonymous telemetry is enabled; disabled only when explicitly set to `false` |
106
+ | [`providers`](#providers) | `table` | `{}` | API provider table |
107
+ | [`models`](#models) | `table` | — | Model alias table |
108
+ | [`thinking`](#thinking) | `table` | — | Default parameters for Thinking mode |
109
+ | [`loop_control`](#loop_control) | `table` | — | Agent loop control parameters |
110
+ | [`background`](#background) | `table` | — | Background task runtime parameters |
111
+ | [`tools`](#tools) | `table` | — | Global tool switch |
112
+ | [`image`](#image) | `table` | — | Image compression parameters |
113
+ | [`services`](#services) | `table` | — | Built-in external service configuration |
114
+ | [`permission`](#permission) | `table` | — | Initial permission rules |
115
+ | [`hooks`](../customization/hooks.md) | `array<table>` | — | Lifecycle hooks |
116
+ | [`identity`](#identity) | `table` | — | Custom agent identity |
117
+
118
+ ## `providers`
119
+
120
+ Each entry in the `providers` table defines an API provider, keyed by a unique name. The CLI reads credentials only from here. It does **not** fall back to shell environment variables automatically: running `export KIMI_API_KEY` in the terminal does not give any provider its key; you must write it explicitly in the config file (see [Config overrides](./overrides.md#provider-credentials)).
121
+
122
+ | Field | Type | Required | Description |
123
+ | --- | --- | --- | --- |
124
+ | `type` | `string` | Yes | Provider type: `kimi`, `anthropic`, `openai`, `openai_responses`, `google-genai`, `vertexai` |
125
+ | `api_key` | `string` | No | API key, written in plain text in the config file |
126
+ | `base_url` | `string` | No | API base URL |
127
+ | `oauth` | `table` | No | OAuth credential reference (`storage` and `key` fields); injected automatically by the login flow, so you normally never write this by hand |
128
+ | `env` | `table<string, string>` | No | Fallback source for provider credentials; see the `env` sub-table |
129
+ | `custom_headers` | `table<string, string>` | No | Custom HTTP headers attached to each request |
130
+
131
+ **`env` sub-table**: You can write provider-conventional key names (such as `KIMI_API_KEY`) inside `[providers.<name>.env]` as a fallback source for `api_key` / `base_url`. This sub-table is **read only from the config file** and does not modify the shell environment:
132
+
133
+ ```toml
134
+ [providers.kimi.env]
135
+ KIMI_API_KEY = "sk-xxx"
136
+ KIMI_BASE_URL = "https://api.moonshot.ai/v1"
137
+ ```
138
+
139
+ Priority: `api_key` field > `env` sub-table key > if both are absent, startup fails with an error.
140
+
141
+ ## `models`
142
+
143
+ Each entry in the `models` table defines a model alias (the name used in `default_model` or the `-m` flag), keyed by a unique name.
144
+
145
+ | Field | Type | Required | Description |
146
+ | --- | --- | --- | --- |
147
+ | `provider` | `string` | Yes | Name of the provider to use; must be defined in `providers` |
148
+ | `model` | `string` | Yes | Model identifier sent to the server when calling the API |
149
+ | `max_context_size` | `integer` | Yes | Maximum context length in tokens; must be at least 1 |
150
+ | `max_input_size` | `integer` | No | Declared per-request input limit; compaction, context-overflow checks, and usage ratios prefer it, completion budgeting keeps the total window |
151
+ | `max_output_size` | `integer` | No | Per-request output token cap (maps to `max_tokens`); currently only the `anthropic` provider reads it |
152
+ | `capabilities` | `array<string>` | No | Capability tags added explicitly: `thinking`, `always_thinking`, `image_in`, `video_in`, `audio_in`, `tool_use`, `dynamically_loaded_tools`; only ever added, never removed |
153
+ | `support_efforts` | `array<string>` | No | Thinking effort levels the model accepts; unsupported values fall back to `default_effort`, out-of-list values fail; managed refreshes may rewrite it (pin via overrides) |
154
+ | `default_effort` | `string` | No | Default thinking effort for the model; managed and open-platform refreshes may rewrite it. Pin via [model overrides](#model-overrides) |
155
+ | `off_effort` | `string` | No | Effort value sent on the wire to disable thinking (e.g. `none` for xai grok); the only way to actually stop reasoning on models that reason by default |
156
+ | `base_url` | `string` | No | Per-model endpoint override (written by catalog imports); takes precedence over the provider's `base_url`, only effective together with `protocol` |
157
+ | `display_name` | `string` | No | Name shown in the UI; falls back to `model` when unset |
158
+ | `reasoning_key` | `string` | No | `openai` provider only; set when the gateway returns reasoning content under a non-standard field name (`reasoning_content` and friends are auto-detected) |
159
+ | `adaptive_thinking` | `boolean` | No | `anthropic` provider only; force adaptive thinking on or off, omit to infer from the model name (Claude ≥ 4.6 uses adaptive) |
160
+
161
+ When an alias contains `.`, use a quoted key:
162
+
163
+ ```toml
164
+ [models."gpt-4.1"]
165
+ provider = "openai"
166
+ model = "gpt-4.1"
167
+ max_context_size = 1047576
168
+ ```
169
+
170
+ ### Model overrides
171
+
172
+ Use `[models."<alias>".overrides]` for user overrides that must survive provider-model refreshes. Runtime consumers read the effective value: the override when present, otherwise the top-level field.
173
+
174
+ ```toml
175
+ [models."kimi-code/kimi-for-coding"]
176
+ provider = "managed:kimi-code"
177
+ model = "kimi-for-coding"
178
+ max_context_size = 262144
179
+
180
+ [models."kimi-code/kimi-for-coding".overrides]
181
+ max_context_size = 131072
182
+ display_name = "Kimi for Coding (custom)"
183
+ ```
184
+
185
+ `[models."<alias>".overrides]` accepts ordinary model fields such as `max_context_size`, `max_input_size`, `max_output_size`, `capabilities`, `display_name`, `reasoning_key`, `adaptive_thinking`, `support_efforts`, `default_effort`, and `off_effort`. It does not accept identity / routing fields: `provider`, `model`, `protocol`, `beta_api`, and `base_url`.
186
+
187
+ You can also switch models temporarily without touching the config file: setting `KIMI_MODEL_*` environment variables synthesizes a temporary provider in memory that does not persist after restart. See [Define a model from environment variables](./env-vars.md#define-a-model-from-environment-variables-kimi_model_).
188
+
189
+ ## `secondary_model`
190
+
191
+ Subagents inherit the model the main agent is running by default. The `[secondary_model]` section makes this configurable: it offers subagents a pool of candidate models plus a default binding. Typically that is a cheaper model for subtasks that do not need the main model's capability.
192
+
193
+ ### Subagent model pool
194
+
195
+ The pool is always available and needs no opt-in; with no `[secondary_model]` keys configured, subagents simply inherit the caller's model.
196
+
197
+ The minimal configuration is one line. A lone `default_model` is a pool with a single entry:
198
+
199
+ ```toml
200
+ [secondary_model]
201
+ default_model = "kimi-code/kimi-for-coding-highspeed"
202
+ ```
203
+
204
+ | Field | Type | Default | Description |
205
+ | --- | --- | --- | --- |
206
+ | `default_model` | `string` | — | The default model for subagents |
207
+ | `models` | `table<string, string>` | — | Subagent model pool; each key is the alias of a configured [`[models]`](#models) entry, each value a selection hint |
208
+ | `force` | `boolean` | `false` | Pin every subagent to `default_model`, taking the choice away from the main agent |
209
+ | `default_effort` | `string` | — | The thinking effort every spawned subagent binds with; outranks the bound model entry's own `default_effort` |
210
+
211
+ Constraints between the fields:
212
+
213
+ - `default_model`: required when a `models` table is configured, and must be one of its keys.
214
+ - `models`: values may be Chinese or English; an empty string lists the alias with no hint.
215
+ - `force`: requires `default_model` and cannot be combined with a `models` table: the table exists to offer a choice, and force removes it.
216
+ - `default_effort` is section-wide: every spawn binds it regardless of the chosen pool entry (or the forced model). For per-entry efforts, leave it unset and use model variants (see below).
217
+ - `primary` is a reserved alias (see below) and cannot be a pool key.
218
+
219
+ Pool aliases reference the current `[models]` table: if a provider is later deleted or logged out, or its refreshed model list no longer contains an alias, session startup fails with a configuration error naming the broken alias. Fix or remove the entry to recover. The `[secondary_model]` section itself is never rewritten automatically.
220
+
221
+ In the interactive TUI, the [`/secondary-model`](../reference/slash-commands.md) command (alias `/subagent-model`) opens a model selector: the choice is written to `default_model` (when a models table exists and the picked alias is not in it, an entry with an empty description is added), and newly spawned subagents pick up the new default immediately, no session restart needed.
222
+
223
+ A configured pool (an explicit `models` table or a lone `default_model`) enables model selection: the `Agent` / `AgentSwarm` tools gain a `model` parameter, and the tool description lists the pool (the default marked `[default]`) so the main agent can choose per spawn. Pool keys can only reference configured [`[models]`](#models) entries. The `kimi-code/*` aliases below are provisioned by `/login`:
224
+
225
+ ```toml
226
+ [secondary_model]
227
+ default_model = "kimi-code/kimi-for-coding-highspeed"
228
+ [secondary_model.models]
229
+ "kimi-code/k3" = "Pick this for hard problems. Strong at complex reasoning, algorithm design, deep debugging, math, and systematic challenges."
230
+ "kimi-code/kimi-for-coding-highspeed" = "Fast but priced higher. Good for latency-sensitive tasks: daily refactoring, code explanation, small edits, and summaries."
231
+ "kimi-code/kimi-for-coding" = "A balanced coding workhorse. Good for most feature development and code-change tasks."
232
+ ```
233
+
234
+ A spawn resolves the subagent's model in this order:
235
+
236
+ 1. An explicit `model` passed in the tool call
237
+ 2. `default_model`
238
+
239
+ Rules for the `model` parameter:
240
+
241
+ - It accepts any pool alias, or `"primary"`, the model the caller itself is running; always valid even when not in the pool.
242
+ - When neither `default_model` nor `models` is configured, the parameter is not advertised and subagents inherit the caller's model.
243
+ - Binding a pool alias does not inherit the caller's thinking effort. The section's `default_effort` wins when set. Otherwise, `[thinking].enabled = false` keeps Thinking off; when Thinking is enabled, resolution continues with the bound model entry's `default_effort`, the global `[thinking].effort`, then the middle of the bound model's `support_efforts`.
244
+ - `"primary"` inherits both the model and the effort level from the caller.
245
+ - A value that is neither a pool alias nor `"primary"` fails the spawn with an error listing the available choices.
246
+
247
+ To take the choice away from the main agent and run every subagent on one fixed model, add `force = true`:
248
+
249
+ ```toml
250
+ [secondary_model]
251
+ default_model = "kimi-code/kimi-for-coding-highspeed"
252
+ force = true
253
+ ```
254
+
255
+ With `force` set, the `model` parameter is not advertised (just like when nothing is configured) and every spawn binds `default_model`; an explicit `model` argument, `"primary"` included, is rejected with an error.
256
+
257
+ ### Different thinking efforts per pool entry
258
+
259
+ Binding a pool alias lands the subagent on the bound model's default effort. You can exploit this by registering a "variant" entry for the same underlying model, so the main agent picks the thinking level together with the alias:
260
+
261
+ 1. Register a second entry for the same underlying model in [`[models]`](#models), overriding only `default_effort` via [`[models."<alias>".overrides]`](#model-overrides).
262
+ 2. List both the original alias and the variant alias in the pool.
263
+
264
+ ```toml
265
+ # "kimi-code/k3" is provisioned by /login (default: high); this registers
266
+ # a max-effort variant of the same model
267
+ [models.k3-max]
268
+ provider = "managed:kimi-code"
269
+ model = "k3"
270
+ max_context_size = 1048576
271
+ capabilities = [ "thinking", "always_thinking", "image_in", "video_in", "tool_use" ]
272
+ support_efforts = [ "low", "high", "max" ]
273
+
274
+ [models.k3-max.overrides]
275
+ default_effort = "max"
276
+
277
+ [secondary_model]
278
+ default_model = "kimi-code/k3"
279
+ [secondary_model.models]
280
+ "kimi-code/k3" = "Default high effort. Good for most implementation, analysis, and multi-turn interaction tasks."
281
+ k3-max = "The same model at max thinking effort. Good for the hardest subtasks."
282
+ ```
283
+
284
+ Two prerequisites:
285
+
286
+ - The underlying model must declare `support_efforts` (under `managed:kimi-code` only the k3 family currently declares effort levels).
287
+ - The variant is a standalone entry and does not inherit fields from the entry it points at: copy `capabilities`, `support_efforts`, and the other metadata over in full, otherwise `default_effort` has no effect (it must be a member of `support_efforts`).
288
+
289
+ Note the asymmetry between the main agent and pool-bound subagents: for the main agent, a configured global `[thinking].effort` overrides the variant's `default_effort`; for subagents the variant's `default_effort` wins over the global value, and only `[secondary_model].default_effort` outranks it. Value and fallback rules follow the [`[models]` entry's `default_effort`](#models).
290
+
291
+ ::: warning Note
292
+ Configuration errors fail loudly instead of falling back silently. Session creation, resume, and fork all fail at startup when:
293
+
294
+ - `default_model` is missing, is not a pool key, or a pool key does not resolve to a configured [`[models]`](#models) entry;
295
+ - `force` is set without `default_model`, or combined with a `models` table.
296
+ :::
297
+
298
+ ## `thinking`
299
+
300
+ `thinking` sets the global default behavior for Thinking mode.
301
+
302
+ | Field | Type | Default | Description |
303
+ | --- | --- | --- | --- |
304
+ | `enabled` | `boolean` | `true` | Whether Thinking is enabled by default for new sessions; set to `false` to force Thinking off |
305
+ | `effort` | `string` | — | Thinking effort: `low` / `medium` / `high` / `xhigh` / `max`; falls back to the model default when not in its supported list |
306
+ | `keep` | `string` | `"all"` | Preserved Thinking passthrough: `kimi` sends it as `thinking.keep`, `anthropic` as a `clear_thinking_20251015` edit (routes to the beta Messages API). An off-value disables it; overridden by `KIMI_MODEL_THINKING_KEEP`; injected only while Thinking is on |
307
+
308
+ <details><summary>Deprecated fields</summary>
309
+
310
+ | Field | Deprecated in | Description |
311
+ | --- | --- | --- |
312
+ | `default_thinking` | 0.21.0 | Top-level boolean, replaced by `[thinking] enabled`. Migrate `default_thinking = true` to `enabled = true`, and `default_thinking = false` to `enabled = false`. |
313
+ | `thinking.mode` | 0.21.0 | One of `auto` / `on` / `off`, replaced by `[thinking] enabled`. `mode = "off"` becomes `enabled = false`; `mode = "on"` and `mode = "auto"` are equivalent to `enabled = true` (the default) and can be removed. |
314
+ | `loop_control.max_retries_per_step` | 0.32.0 | Replaced by `loop_control.max_attempts_per_step` (the value was always a total-attempt limit, including the first try). The old key is ignored and reports a warning on startup; rename it in `config.toml`. |
315
+ | `loop_control.max_steps_per_run` | 0.32.0 | Replaced by `loop_control.max_steps_per_turn`. The old key is ignored and reports a warning on startup; rename it in `config.toml`. |
316
+
317
+ </details>
318
+
319
+ ## `loop_control`
320
+
321
+ `loop_control` governs the step count limit, the per-step attempt limit, and the thresholds and attempt limit for automatic context compaction in the Agent execution loop.
322
+
323
+ | Field | Type | Default | Description |
324
+ | --- | --- | --- | --- |
325
+ | `max_steps_per_turn` | `integer` | — | Maximum steps per turn; unset or `0` means unlimited |
326
+ | `max_attempts_per_step` | `integer` | `10` | Maximum total attempts for a failing step, including the initial attempt |
327
+ | `reserved_context_size` | `integer` | — | Number of tokens reserved for model output; automatic compaction is triggered when the remaining context window falls below this value |
328
+ | `compaction_max_attempts` | `integer` | `5` | Maximum total attempts for a failing compaction request, including the initial attempt |
329
+
330
+ `max_steps_per_turn` can be overridden by the `KIMI_LOOP_MAX_STEPS_PER_TURN` environment variable, and `max_attempts_per_step` by `KIMI_LOOP_MAX_ATTEMPTS_PER_STEP`; both take higher priority than the config file. The former `KIMI_LOOP_MAX_RETRIES_PER_STEP` variable is deprecated but still honored (with a startup warning) when the new one is unset.
331
+
332
+ Retries only apply to transient failures: connection errors, timeouts, HTTP 429 rate limits, and 5xx server errors. A 429 caused by an exhausted quota or insufficient account balance is not retried and fails immediately, since it cannot succeed until the account is recharged.
333
+
334
+ ## `token_counting`
335
+
336
+ `token_counting` selects which context token count is reported externally, the value behind the context-size display. Internal logic (automatic compaction triggers, budgets, and overflow backoff) always uses both provider-reported usage and estimates, regardless of this setting.
337
+
338
+ | Field | Type | Default | Description |
339
+ | --- | --- | --- | --- |
340
+ | `strategy` | `"measured+estimated" \| "measured" \| "estimated"` | `"measured+estimated"` | `measured+estimated` combines measured usage with an estimate of the unmeasured tail; `measured` reports provider usage alone, updated when a request completes; `estimated` is a pure estimate, for providers that do not report usage |
341
+
342
+ `strategy` can be overridden by the `KIMI_TOKEN_COUNTING_STRATEGY` environment variable, which takes higher priority than `config.toml`.
343
+
344
+ ## `background`
345
+
346
+ `background` controls the concurrency behavior of background tasks (launched via the `Bash` tool or the `Agent` tool's `run_in_background=true` parameter).
347
+
348
+ | Field | Type | Default | Description |
349
+ | --- | --- | --- | --- |
350
+ | `max_running_tasks` | `integer` | — | Maximum number of background tasks running concurrently |
351
+ | `keep_alive_on_exit` | `boolean` | `false` | Whether to keep still-running background tasks when the session closes; in print mode only a fallback when `print_background_mode` is unset (`true` = `drain`) |
352
+ | `kill_grace_period_ms` | `integer` | `5000` | Grace period in milliseconds after a task is asked to terminate; still-running tasks are force-stopped when it elapses |
353
+ | `bash_auto_background_on_timeout` | `boolean` | `true` | Move a foreground `Bash` command to a background task on timeout instead of killing it; set to `false` to kill timed-out foreground commands instead |
354
+ | `bash_task_timeout_s` | `integer` | `600` | Default timeout (seconds) for background `Bash` tasks when the call omits `timeout`; `0` means no timeout. Explicit per-call `timeout` values are unaffected; print mode defaults to `0` |
355
+ | `print_background_mode` | `"exit" \| "drain" \| "steer"` | `"steer"` | Print mode only: how pending background tasks are handled when the main agent's turn ends; `"exit"` exits immediately, `"drain"` waits for terminal states without feeding results back, `"steer"` injects completions as synthetic user messages steering new turns until none are pending |
356
+ | `print_wait_ceiling_s` | `integer` | `2147483` | Wall-clock ceiling (seconds) for the print-mode wait/steer loop; no effect outside print mode or with `"exit"` |
357
+ | `print_max_turns` | `integer` | `100000` | Maximum number of new turns triggered by background-task completions in `"steer"` mode; keeps the steering loop bounded |
358
+
359
+ `keep_alive_on_exit` can be overridden by the `KIMI_CODE_BACKGROUND_KEEP_ALIVE_ON_EXIT` environment variable, `max_running_tasks` by `KIMI_CODE_BACKGROUND_MAX_RUNNING_TASKS`, `bash_task_timeout_s` by `KIMI_CODE_BACKGROUND_BASH_TASK_TIMEOUT_S`, and `print_background_mode`, `print_wait_ceiling_s`, and `print_max_turns` by `KIMI_CODE_BACKGROUND_PRINT_BACKGROUND_MODE`, `KIMI_CODE_BACKGROUND_PRINT_WAIT_CEILING_S`, and `KIMI_CODE_BACKGROUND_PRINT_MAX_TURNS`; all take higher priority than `config.toml`.
360
+
361
+ In print mode (`kimi -p "<prompt>"`), Kimi Code stays alive after the main agent's turn as long as background tasks are still pending: each completion is fed back to the main agent as a synthetic user message, steering it into a new turn (`print_background_mode = "steer"` by default), and the run exits once a turn ends with nothing pending. The loop is bounded by `print_wait_ceiling_s` and `print_max_turns`, both effectively unbounded by default. Background work is never killed by a wall-clock cap in print mode either: background `Bash` tasks default to no timeout (`bash_task_timeout_s = 0`), and subagents run without a timeout (`[subagent] timeout_ms` and `[swarm] timeout_ms` both default to `0` unless explicitly set), so only the model itself stops a task. Set `print_background_mode` to `"drain"` to wait for tasks without feeding results back, or `"exit"` to end the run as soon as the main agent finishes.
362
+
363
+ ## `subagent`
364
+
365
+ `subagent` controls how subagents spawned by the `Agent` tool run.
366
+
367
+ | Field | Type | Default | Description |
368
+ | --- | --- | --- | --- |
369
+ | `timeout_ms` | `integer` | `7200000` (2 hours) | Maximum wall-clock time (milliseconds) a single `Agent` subagent may run before it is settled as `timed_out`; `0` means no timeout |
370
+
371
+ `timeout_ms` can be overridden by the `KIMI_SUBAGENT_TIMEOUT_MS` environment variable, which takes higher priority than `config.toml`.
372
+
373
+ ## `swarm`
374
+
375
+ `swarm` controls how subagents launched by the `AgentSwarm` tool run, independently of `[subagent]`.
376
+
377
+ | Field | Type | Default | Description |
378
+ | --- | --- | --- | --- |
379
+ | `timeout_ms` | `integer` | `7200000` (2 hours) | Maximum wall-clock time (milliseconds) a single `AgentSwarm` subagent may run; on timeout it is aborted and the aggregated report marks `Subagent timed out.`; `0` means no timeout |
380
+
381
+ `timeout_ms` can be overridden by the `KIMI_CODE_SWARM_TIMEOUT_MS` environment variable, which takes higher priority than `config.toml`.
382
+
383
+ ## `mcp`
384
+
385
+ | Field | Type | Default | Description |
386
+ | --- | --- | --- | --- |
387
+ | `startup_timeout_ms` | `integer` | `30000` (30 seconds) | Global default connection (startup + tool discovery) timeout in milliseconds for all MCP servers; a per-server `startupTimeoutMs` in `mcp.json` wins |
388
+ | `tool_timeout_ms` | `integer` | `60000` (60 seconds) | Global default single tool-call timeout in milliseconds for all MCP servers; a per-server `toolTimeoutMs` in `mcp.json` wins |
389
+
390
+ `startup_timeout_ms` and `tool_timeout_ms` can be overridden by the `KIMI_MCP_STARTUP_TIMEOUT_MS` and `KIMI_MCP_TOOL_TIMEOUT_MS` environment variables respectively, which take higher priority than `config.toml`. See [MCP](../customization/mcp.md) for the full MCP server configuration.
391
+
392
+ ## `identity`
393
+
394
+ Customizes how the agent identifies itself. Leave it unset and nothing changes.
395
+
396
+ | Field | Type | Default | Description |
397
+ | --- | --- | --- | --- |
398
+ | `name` | `string` | — | Display name the agent calls itself in the system prompt (fills the `${product_name}` slot, including in your own `SYSTEM.md` and agent files) |
399
+ | `slug` | `string` | derived from `name` | Machine identifier in protocol fields (`User-Agent` product token, MCP client name); derived from `name` when omitted: lowercased, non-alphanumeric runs folded to `-` |
400
+
401
+ ```toml
402
+ [identity]
403
+ name = "Acme Dev Agent"
404
+ slug = "acme-dev" # optional
405
+ ```
406
+
407
+ Both fields can be set through the `KIMI_CODE_IDENTITY_NAME` and `KIMI_CODE_IDENTITY_SLUG` environment variables, which take higher priority than `config.toml` and are never written back to it, making them convenient for containers and CI, where writing a config file is awkward.
408
+
409
+ A name that contains no ASCII letters or digits (for example a purely Chinese name) leaves nothing to derive a slug from and falls back to `agent`; write `slug` explicitly if you need a specific protocol token.
410
+
411
+ The identity is resolved once at startup and holds for the life of the process: it is announced to MCP servers and providers when connections are made, so it cannot change midway. Edits to this section take effect on the next start, for new sessions: a resumed session keeps the system prompt it was recorded with, since its past turns already speak under that identity. Likewise, an MCP OAuth authorization keeps the client registration it was granted under; reset that server's authentication to register under the new identity.
412
+
413
+ This section is read by the `agent-core-v2` engine, which powers every Kimi Code surface.
414
+
415
+ ## `tools`
416
+
417
+ `tools` is the global tool switch: it applies to every agent in all sessions and intersects with each agent's own `tools` / `disallowedTools` policy.
418
+
419
+ | Field | Type | Default | Description |
420
+ | --- | --- | --- | --- |
421
+ | `enabled` | `array<string>` | — | Global allowlist: when non-empty, only the listed tools are available; omitting the field or setting an empty array imposes no constraint |
422
+ | `disabled` | `array<string>` | — | Global denylist, applied after `enabled` |
423
+
424
+ Name matching follows the same rules as the same-named fields in an agent file: built-in tools match by exact name (such as `Read`), and MCP tools match with globs (such as `mcp__github__*`). Three entry shapes never match anything and are reported with a warning: a wildcard outside an `mcp__` pattern (`enabled = ["*"]` disables every tool, `disabled = ["*"]` disables none), an `mcp__` literal missing the tool segment (`mcp__github`; use `mcp__github__*` for a whole server), and a name no registered or built-in tool has (matching is case-sensitive).
425
+
426
+ ```toml
427
+ [tools]
428
+ disabled = ["EnterPlanMode", "ExitPlanMode", "mcp__github__*"]
429
+ ```
430
+
431
+ ::: warning Note
432
+ Like the `tools` / `disallowedTools` fields of an agent file, this section shapes the tools shown to the model and is enforced again before execution. [Permission rules](#permission) remain a separate control for operations that require approval.
433
+ :::
434
+
435
+ ## `read`
436
+
437
+ `read` controls the character limits for the [`Read` tool](../reference/tools.md). The limit includes file content, line numbers, and the status block; it does not impose a separate line-count or UTF-8 byte limit.
438
+
439
+ | Field | Type | Default | Description |
440
+ | --- | --- | --- | --- |
441
+ | `default_max_chars` | `integer` | `100000` | Character budget when the tool call omits `max_chars` |
442
+ | `max_chars` | `integer` | `500000` | Maximum character budget a tool call may request |
443
+
444
+ ```toml
445
+ [read]
446
+ default_max_chars = 100000
447
+ max_chars = 500000
448
+ ```
449
+
450
+ Both values must be positive integers. A call's `max_chars` overrides the default, but is capped at the configured maximum; the result reports the effective budget. If the configured default exceeds the maximum, the maximum also limits default reads. Raise `default_max_chars` when you want larger documents to be returned in one call without the agent requesting a larger budget.
451
+
452
+ ## `image`
453
+
454
+ `image` controls how images are compressed before being sent to the model, across every ingestion point (pasted images, `ReadMediaFile` reads, images in MCP tool results, and so on).
455
+
456
+ | Field | Type | Default | Description |
457
+ | --- | --- | --- | --- |
458
+ | `max_edge_px` | `integer` | `2000` | Longest-edge ceiling in pixels; larger images scale down proportionally. Raising it preserves more detail at the cost of larger request bodies |
459
+ | `read_byte_budget` | `integer` | `262144` (256 KB) | Per-image byte budget for images the model reads for itself (`ReadMediaFile` default reads); `region` and `full_resolution` read-backs are exempt |
460
+
461
+ `max_edge_px` can be overridden by the `KIMI_IMAGE_MAX_EDGE_PX` environment variable and `read_byte_budget` by `KIMI_IMAGE_READ_BYTE_BUDGET`; both take higher priority than `config.toml`.
462
+
463
+ ## `database`
464
+
465
+ `database` controls the embedded storage engines behind session indexing and global search. Both keys default to `true` and act as kill switches that fall back to the legacy behavior when set to `false`.
466
+
467
+ | Field | Type | Default | Description |
468
+ | --- | --- | --- | --- |
469
+ | `base` | `boolean` | `true` | Use the minidb-backed read model for session indexing; `false` falls back to reading session metadata directly |
470
+ | `search` | `boolean` | `true` | Run the global search index in a dedicated worker thread; `false` runs it in the server process |
471
+
472
+ `base` can be overridden by the `KIMI_CODE_PERSISTENCE_MINIDB_READMODEL` environment variable and `search` by `KIMI_CODE_SEARCH_WORKER`; both take higher priority than `config.toml`.
473
+
474
+ <!--
475
+ ## `experimental`
476
+
477
+ `experimental` stores persistent overrides for experimental-feature flags. Currently, `micro_compaction` is the only user-facing entry and defaults to `false`; set it to `true` to enable automatic trimming of older large tool results.
478
+
479
+ | Field | Type | Default | Description |
480
+ | --- | --- | --- | --- |
481
+ | `micro_compaction` | `boolean` | `false` | Trim older large tool results from context while preserving recent conversation |
482
+ -->
483
+
484
+ ## `services`
485
+
486
+ `services` configures two built-in services: web search (`moonshot_search`) and web fetch (`moonshot_fetch`). Only these two fixed keys are recognized; other keys are ignored. Both entries share the same fields:
487
+
488
+ | Field | Type | Required | Description |
489
+ | --- | --- | --- | --- |
490
+ | `base_url` | `string` | No | Service API URL |
491
+ | `api_key` | `string` | No | API key |
492
+ | `oauth` | `table` | No | OAuth credential reference, same structure as `providers.*.oauth` |
493
+ | `custom_headers` | `table<string, string>` | No | Custom HTTP headers attached to each request |
494
+
495
+ `base_url` and `api_key` can also come from environment variables, which take priority over the config file: `KIMI_WEB_SEARCH_BASE_URL` / `KIMI_WEB_SEARCH_API_KEY` for `moonshot_search`, and `KIMI_WEB_FETCH_BASE_URL` / `KIMI_WEB_FETCH_API_KEY` for `moonshot_fetch`. An env base URL defines a separate service endpoint, so the persisted API key, OAuth reference, and custom headers are not forwarded to it; set the matching env API key when that endpoint requires authentication. An env API key without an env base URL keeps the configured endpoint and custom headers but replaces both configured credential forms. Setting the base URL and API key through env without any config section also enables the service.
496
+
497
+ ```toml
498
+ [services.moonshot_search]
499
+ base_url = "https://api.moonshot.cn/v1/search"
500
+ api_key = "sk-xxx"
501
+
502
+ [services.moonshot_fetch]
503
+ base_url = "https://api.moonshot.cn/v1/fetch"
504
+ api_key = "sk-xxx"
505
+ ```
506
+
507
+ ## `permission`
508
+
509
+ `permission` sets permission rules that are automatically loaded when a session starts, controlling whether the Agent needs user confirmation before calling a tool. Rules are written as a `[[permission.rules]]` array of tables, matched in order; the first matching rule takes effect.
510
+
511
+ You can also set `dangerous_command_guard = false` under `[permission]` to turn off the built-in dangerous-command policy entirely (no dangerous-command confirmation in Always Ask and Ask When Needed mode; the policy is never active in Never Ask mode); the default is `true`. An environment variable `KIMI_CODE_DANGEROUS_COMMAND_GUARD=false` overrides the file setting and restores the behavior before the policy was introduced. Use this switch only for environments that already gate commands outside the agent.
512
+
513
+ | Field | Type | Required | Description |
514
+ | --- | --- | --- | --- |
515
+ | `decision` | `string` | Yes | Action on match: `allow` (permit immediately), `deny` (reject immediately), `ask` (prompt each time) |
516
+ | `scope` | `string` | No | Rule scope: `turn-override`, `session-runtime`, `project`, `user`; defaults to `user` |
517
+ | `pattern` | `string` | Yes | Match pattern in the form `ToolName` or `ToolName(arg-pattern)`, e.g. `Read` or `Bash(rm -rf*)` |
518
+ | `reason` | `string` | No | Rule description for debugging and auditing |
519
+
520
+ Built-in tool names are listed in [Built-in tools](../reference/tools.md). Most built-in tools that accept rule arguments define their own matching subject, such as `Bash(command-pattern)` or `Read(path-pattern)`. `AgentSwarm`, MCP tools, and custom tools can only be matched by tool name; argument patterns are not supported for them.
521
+
522
+ ```toml
523
+ [[permission.rules]]
524
+ decision = "allow"
525
+ pattern = "Read"
526
+
527
+ [[permission.rules]]
528
+ decision = "allow"
529
+ pattern = "Grep"
530
+
531
+ [[permission.rules]]
532
+ decision = "deny"
533
+ pattern = "Bash(rm -rf*)"
534
+
535
+ [[permission.rules]]
536
+ decision = "ask"
537
+ pattern = "Bash"
538
+ ```
539
+
540
+ ::: tip
541
+ MCP server declarations are configured in `~/.kimi-code/mcp.json` or the project-local `.kimi-code/mcp.json`, not in `config.toml`. The interactive configuration entry point is `/mcp-config`; see [Model Context Protocol](../customization/mcp.md).
542
+ :::
543
+
544
+ ## `tui.toml`
545
+
546
+ Alongside `config.toml`, the CLI keeps terminal-UI and client preferences in a companion `tui.toml` in the same directory (`~/.kimi-code/tui.toml`, or `$KIMI_CODE_HOME/tui.toml` when overridden). It is created with defaults on first run, and the interactive commands `/config`, `/theme`, and `/editor` write to it for you, so you rarely need to edit it by hand. If the file is malformed, the CLI falls back to defaults and shows a notice instead of failing to start.
547
+
548
+ | Field | Type | Default | Description |
549
+ | --- | --- | --- | --- |
550
+ | `theme` | `string` | `auto` | Color theme: `auto`, `dark`, `light`, or the name of a [custom theme](../customization/themes.md) |
551
+ | `render_latex` | `boolean` | `true` | Render LaTeX math expressions in Markdown messages as Unicode text; `false` keeps the raw source |
552
+ | `disable_paste_burst` | `boolean` | `false` | Disable the non-bracketed paste-burst fallback that keeps rapid multi-line pastes from submitting line by line |
553
+ | `cache_expiry_hint` | `boolean` | `true` | On resume or when submitting after a long idle stretch, warn that the context cache may have expired and offer to compact or start a new session (v2 engine only) |
554
+ | `disable_feedback_survey` | `boolean` | `false` | Disable the occasional session rating prompt above the input box |
555
+ | `[editor].command` | `string` | `""` | External editor command for composing long input; empty falls back to `$VISUAL` / `$EDITOR` |
556
+ | `[notifications].enabled` | `boolean` | `true` | Whether desktop notifications are sent |
557
+ | `[notifications].notification_condition` | `string` | `unfocused` | When to notify: `unfocused` (only when the terminal is not focused) or `always` |
558
+ | `[upgrade].auto_install` | `boolean` | `true` | Whether new versions are installed automatically |
559
+ | `[status_line].items` | `string[]` | `[]` | Built-in slots on the first footer line and their order: `mode`, `goal`, `model`, `tasks`, `cwd`, `git`, `tips`; unknown ids are skipped with a warning |
560
+ | `[status_line].command` | `string` | `""` | Custom status line command: its first stdout line replaces the footer, and a JSON snapshot is passed on stdin; capped at 300ms, throttled to once per second, failures fall back to the built-in layout |
561
+
562
+ <details>
563
+ <summary>Fields in the stdin JSON snapshot</summary>
564
+
565
+ Model, cwd, git branch, permission mode, plan mode, context usage, session id, version.
566
+
567
+ </details>
568
+
569
+ ```toml
570
+ # ~/.kimi-code/tui.toml
571
+ theme = "auto" # "auto" | "dark" | "light" | custom theme name
572
+ render_latex = true # false keeps LaTeX math in messages as raw source
573
+ disable_paste_burst = false # true disables non-bracketed paste-burst fallback
574
+ cache_expiry_hint = true # false disables the "cache expired" dialog on resume / idle submit
575
+ disable_feedback_survey = false # true hides the occasional session rating prompt
576
+
577
+ [editor]
578
+ command = "" # empty uses $VISUAL / $EDITOR
579
+
580
+ [notifications]
581
+ enabled = true
582
+ notification_condition = "unfocused" # "unfocused" | "always"
583
+
584
+ [upgrade]
585
+ auto_install = true
586
+
587
+ # [status_line]
588
+ # items = ["mode", "goal", "model", "tasks", "cwd", "git", "tips"]
589
+ # command = "~/.kimi-code/statusline.sh"
590
+ ```
591
+
592
+ Changes apply on the next start, or immediately with `/reload-tui` (which reloads only `tui.toml`); `/reload` reloads both `config.toml` and `tui.toml`.
593
+
594
+ ## Project-local configuration
595
+
596
+ In addition to the user-level files under `~/.kimi-code`, Kimi Code reads a project-local configuration file at `<project-root>/.kimi-code/local.toml`. It holds settings that are specific to one project checkout and typically should not be shared with teammates.
597
+
598
+ The file is created automatically when you add an extra workspace directory with [`/add-dir`](../reference/slash-commands.md) and choose to remember it for the project. You rarely need to edit it by hand.
599
+
600
+ ### `[workspace]`
601
+
602
+ The `[workspace]` table groups project-level workspace settings:
603
+
604
+ | Field | Type | Required | Description |
605
+ | --- | --- | --- | --- |
606
+ | `additional_dir` | `array<string>` | No | Additional workspace directories (absolute paths); written automatically when you confirm "remember this directory" in `/add-dir`, and available in every session of this project |
607
+
608
+ ```toml
609
+ [workspace]
610
+ additional_dir = ["/absolute/path/to/shared"]
611
+ ```
612
+
613
+ Because directories are stored as absolute paths, which are specific to your machine, we recommend adding `.kimi-code/local.toml` to your project's `.gitignore` so it is not committed.
614
+
615
+ ## Next steps
616
+
617
+ - [Providers and models](./providers.md) — connection examples for each provider type (Kimi, Claude, OpenAI, Gemini)
618
+ - [Config overrides](./overrides.md) — priority rules for CLI options, config file, and environment variables
619
+ - [Environment variables](./env-vars.md) — complete list of runtime variables like `KIMI_CODE_HOME`
docs/en/configuration/data-locations.md ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Data locations
2
+
3
+ Kimi Code CLI stores the config file, session history, login credentials, diagnostic logs, and other runtime data under `~/.kimi-code/`. This page helps you understand where each type of data lives, what it is for, and how to clean up or relocate it when needed.
4
+
5
+ ## Data root directory
6
+
7
+ The default data root is `~/.kimi-code/`. The actual path varies by platform:
8
+
9
+ - macOS: `/Users/<name>/.kimi-code`
10
+ - Linux: `/home/<name>/.kimi-code`
11
+ - Windows: `C:\Users\<name>\.kimi-code`
12
+
13
+ If you need to move the data directory elsewhere (for example, to isolate configs for different projects with independent environments), set `KIMI_CODE_HOME`:
14
+
15
+ ```sh
16
+ export KIMI_CODE_HOME="$HOME/.config/kimi-code"
17
+ ```
18
+
19
+ Once set, **all** Kimi Code data lands under the new path: config, sessions, logs, OAuth credentials, Kimi-specific user Skills, global `AGENTS.md`, and more. For the full reference on `KIMI_CODE_HOME`, see [Environment variables](./env-vars.md).
20
+
21
+ ::: tip Note
22
+
23
+ **Generic `.agents` resources** stay under the real OS home so they can be shared across tools. For example, user-level generic Skills remain at `~/.agents/skills/`, while Kimi-specific user Skills move with `KIMI_CODE_HOME` as `$KIMI_CODE_HOME/skills/`.
24
+ :::
25
+
26
+ ## Directory layout
27
+
28
+ ```
29
+ $KIMI_CODE_HOME (default: ~/.kimi-code)
30
+ ├── config.toml # User configuration
31
+ ├── tui.toml # Terminal UI preferences (including auto-update toggle)
32
+ ├── AGENTS.md # Global Kimi-specific agent instructions (optional)
33
+ ├── mcp.json # User-level MCP server declarations (optional)
34
+ ├── skills/ # Kimi-specific user-level Skills (optional)
35
+ ├── plugins/
36
+ │ ├── installed.json # Installed plugin records and enabled state
37
+ │ └── managed/ # Plugin copies installed from zip/local paths
38
+ ├── session_index.jsonl # Session index
39
+ ├── credentials/ # OAuth credentials (dir 0700, files 0600)
40
+ │ ├── <name>.json
41
+ │ └── mcp/
42
+ │ └── <key>-<suffix>.json
43
+ ├── sessions/ # Session data (see below)
44
+ │ └── <workDirKey>/<sessionId>/
45
+ ├── bin/
46
+ │ ├── rg # managed ripgrep binary for Grep (rg.exe on Windows)
47
+ │ └── fd # managed fd binary for file references (fd.exe on Windows)
48
+ ├── logs/
49
+ │ └── kimi-code.log # Global diagnostic log
50
+ ├── updates/
51
+ │ ├── latest.json
52
+ │ ├── install.json
53
+ │ ├── install.lock
54
+ │ └── rollout.log
55
+ └── user-history/
56
+ └── <md5(workDir)>.jsonl
57
+ ```
58
+
59
+ ## File descriptions
60
+
61
+ Each top-level file under the data root serves a specific purpose; most are managed automatically by the CLI:
62
+
63
+ - **`config.toml`**: the main runtime configuration file, storing user-level settings such as providers, models, and loop control. See [Configuration files](./config-files.md).
64
+ - **`tui.toml`**: terminal UI client preferences, including `[upgrade].auto_install` (auto-update, on by default). You can disable it in `/settings` or by manually setting `auto_install = false`.
65
+ - **`AGENTS.md`**: global Kimi-specific agent instructions. This file moves with `KIMI_CODE_HOME`; generic cross-tool instructions can still live under `~/.agents/AGENTS.md`.
66
+ - **`mcp.json`**: user-level MCP server declarations, merged with the project-local `.kimi-code/mcp.json` on startup. See [MCP](../customization/mcp.md).
67
+ - **`skills/`**: Kimi-specific user-level Skills. This directory moves with `KIMI_CODE_HOME`; generic cross-tool Skills can still live under `~/.agents/skills/`. See [Agent Skills](../customization/skills.md).
68
+ - **`plugins/installed.json`**: records installed plugins, each plugin's enabled state, and MCP server capability state changes made via `/plugins` or `/plugins mcp disable|enable`. Files installed from local paths or zip URLs are copied to `plugins/managed/<id>/`. See [Plugins](../customization/plugins.md).
69
+ - **`credentials/`**: OAuth credential directory, with permissions `0o700` (directory) / `0o600` (files), readable and writable only by the current user. Managed provider credentials are stored as `credentials/<name>.json`; MCP server credentials are stored under `credentials/mcp/`. Credentials are written using an atomic flow (tmp → fsync → rename) to prevent corruption.
70
+
71
+ ## Session data
72
+
73
+ Each session's data is stored under `sessions/<workDirKey>/<sessionId>/`, and a top-level `session_index.jsonl` index is maintained (one record per line, each containing `sessionId`, `sessionDir`, and `workDir`). `workDirKey` is a bucket name derived from the working directory path, in the format `wd_<slug>_<first-12-chars-of-sha256>`.
74
+
75
+ Inside each session directory:
76
+
77
+ - **`state.json`**: session metadata including title, `lastPrompt`, creation/update timestamps, and `forkedFrom`.
78
+ - **`upcoming-goals.json`**: the TUI-only queue created by `/goal next <objective>`. It is not part of the agent conversation until a queued goal is promoted after the current goal completes.
79
+ - **`agents/main/wire.jsonl`**: the main Agent's complete communication record, used for session resumption and replay.
80
+ - **`agents/main/plans/`**: plan files written in Plan mode, named by plan id (`<id>.md`).
81
+ - **`agents/agent-0/` etc.**: sub-Agent instance directories, each containing their own `wire.jsonl`.
82
+ - **`logs/kimi-code.log`**: diagnostic log for this session; only present when a diagnostic event occurs.
83
+ - **`tasks/`**: background task persistence. `tasks/<task_id>.json` stores status/pid/exit code; `tasks/<task_id>/output.log` stores output.
84
+ - **`cron/`**: scheduled task persistence; reloaded into the scheduler when the session is resumed with `kimi --session`. See [Scheduled tasks](../reference/tools.md#scheduled-tasks).
85
+
86
+ ## Built-in tool cache
87
+
88
+ The first time the `Grep` tool needs ripgrep, the CLI can automatically download `rg` and cache it at `bin/rg` (`bin/rg.exe` on Windows). File-reference completion in the terminal UI uses `fd`; the CLI downloads and caches it at `bin/fd` (`bin/fd.exe` on Windows) in the background when needed. Subsequent runs reuse the cached binaries. `rg` prefers the system `PATH` before the cache, while `fd` checks the managed cache before falling back to system `fd` / `fdfind`. Deleting the `bin/` directory triggers a fresh download on the next use.
89
+
90
+ ## Logs and update state
91
+
92
+ - **`logs/kimi-code.log`** (global): records startup, login, export, and other cross-session events.
93
+ - **`<sessionDir>/logs/kimi-code.log`** (session-level): records diagnostic events within a single session.
94
+
95
+ When reporting a bug, prefer exporting the relevant session with `kimi export` (see [kimi command](../reference/kimi-command.md)); the session log is included in the export by default. Add `--no-include-global-log` if you do not want to share the global log.
96
+
97
+ The files under `updates/` (`latest.json`, `install.json`, `install.lock`, `rollout.log`) are maintained automatically by the auto-update mechanism and normally do not need manual editing. `rollout.log` records which staged-rollout case each update check hit, which helps explain when a device will receive a new release.
98
+
99
+ ## Input history
100
+
101
+ Terminal input history is saved separately per working directory, at `user-history/<md5(workDir)>.jsonl`. It is used to browse previously typed prompts in the terminal UI using the arrow keys.
102
+
103
+ ## Clearing data
104
+
105
+ Deleting the data root directory (`~/.kimi-code/` or the path set by `KIMI_CODE_HOME`) removes all runtime data. To clear only part of the data:
106
+
107
+ | Goal | Action |
108
+ | --- | --- |
109
+ | Reset configuration | Delete `~/.kimi-code/config.toml` |
110
+ | Reset terminal UI preferences | Delete `~/.kimi-code/tui.toml` |
111
+ | Clear all sessions | Delete `~/.kimi-code/sessions/` and `session_index.jsonl` |
112
+ | Clear diagnostic logs | Delete `~/.kimi-code/logs/` |
113
+ | Clear input history | Delete `~/.kimi-code/user-history/` |
114
+ | Reset update state | Delete `~/.kimi-code/updates/latest.json` |
115
+ | Force re-download of managed `rg` and `fd` | Delete `~/.kimi-code/bin/` |
116
+ | Clear provider OAuth login state | Run `/logout`, or delete the corresponding `credentials/<name>.json` |
117
+ | Clear MCP server OAuth login state | Delete `credentials/mcp/` (`/logout` does not clear MCP credentials) |
118
+ | Remove user-level MCP declarations | Delete `$KIMI_CODE_HOME/mcp.json` (default `~/.kimi-code/mcp.json`) |
119
+ | Clear global Kimi-specific agent instructions | Delete `$KIMI_CODE_HOME/AGENTS.md` (default `~/.kimi-code/AGENTS.md`) |
120
+ | Clear plugin install records | Delete `$KIMI_CODE_HOME/plugins/` (local plugin source directories are not affected) |
121
+ | Clear Kimi-specific user-level Skills | Delete `$KIMI_CODE_HOME/skills/` (default `~/.kimi-code/skills/`) |
122
+
123
+ ## Next steps
124
+
125
+ - [Configuration files](./config-files.md) — full reference for `config.toml` fields
126
+ - [Environment variables](./env-vars.md) — detailed usage of `KIMI_CODE_HOME` and related path variables
docs/en/configuration/env-vars.md ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Environment variables
2
+
3
+ Kimi Code CLI uses environment variables to control a small number of runtime behaviors: relocating the data directory, turning off telemetry, and temporarily switching models without touching the config file.
4
+
5
+ ::: warning Important: API keys are not configured here
6
+ Credential variables such as `KIMI_API_KEY`, `ANTHROPIC_API_KEY`, and `OPENAI_API_KEY` are **not** read automatically from shell environment variables. Running `export KIMI_API_KEY=xxx` in the terminal does not give any provider its key. They must be written in `config.toml` under `[providers.<name>]` or the `[providers.<name>.env]` sub-table.
7
+
8
+ The only exception is the `KIMI_MODEL_*` family, an explicit channel that *does* read credentials from the shell. See [Define a model from environment variables](#define-a-model-from-environment-variables-kimi_model_).
9
+
10
+ For background, see [Config overrides: provider credentials](./overrides.md#provider-credentials).
11
+ :::
12
+
13
+ ## Core paths
14
+
15
+ ### `KIMI_CODE_HOME`
16
+
17
+ Overrides the data root directory; the default is `~/.kimi-code`. Once set, the config file, sessions, logs, OAuth credentials, and all other data land under the new path:
18
+
19
+ ```sh
20
+ export KIMI_CODE_HOME="/path/to/custom/kimi-code"
21
+ ```
22
+
23
+ > Make sure the directory is writable. Multiple `kimi` instances sharing the same `KIMI_CODE_HOME` will share config and credential files.
24
+
25
+ For the complete data directory structure, see [Data locations](./data-locations.md).
26
+
27
+ ### `KIMI_DISABLE_TELEMETRY`
28
+
29
+ Set to `1` to turn off anonymous telemetry reporting (also accepts `true`, `yes`, `y`, case-insensitive):
30
+
31
+ ```sh
32
+ export KIMI_DISABLE_TELEMETRY=1
33
+ ```
34
+
35
+ ### `KIMI_MODEL_*` family
36
+
37
+ Switch models temporarily without modifying `config.toml`: when `KIMI_MODEL_NAME` is set, the CLI synthesizes a temporary provider in memory, and the change does not persist after restart. See [Define a model from environment variables](#define-a-model-from-environment-variables-kimi_model_).
38
+
39
+ ### `KIMI_CODE_CUSTOM_HEADERS`
40
+
41
+ ::: info Added
42
+ Added in 0.20.2.
43
+ :::
44
+
45
+ Attaches custom HTTP headers to every outbound model request: both LLM chat requests (across all provider protocols) and `/models` listing requests carry them. Useful when a gateway routes by header, for example to pin a specific cluster:
46
+
47
+ ```sh
48
+ export KIMI_CODE_CUSTOM_HEADERS=$'X-Gateway-Cluster: my-cluster\nX-Custom-Tag: debug'
49
+ ```
50
+
51
+ The format mirrors `ANTHROPIC_CUSTOM_HEADERS`: newline-separated `Name: Value` lines. Names and values are trimmed, and lines without a colon are ignored.
52
+
53
+ > Precedence: the Kimi identity headers (`User-Agent`, `X-Msh-*`) and a provider's `custom_headers` in `config.toml` (see [Config files](./config-files.md#providers)) override same-named entries here. Authentication is protocol-dependent: on the `kimi`, `openai`, and `openai_responses` protocols an exact `Authorization` entry replaces the generated bearer token, while `/models` listing requests keep their own authentication. A case variant such as `authorization` is never treated as the same name. It merges with the real header, which can break requests. Do not use this variable for authentication or other reserved headers. Use `custom_headers` when headers need to differ per provider.
54
+
55
+ ## Provider credential key names (written in config.toml)
56
+
57
+ The key names below are not read directly from the shell. They are key names written inside the `[providers.<name>.env]` sub-table of `config.toml`, serving as fallback values for `api_key` / `base_url`. The CLI reads only from the config file, not from `process.env`.
58
+
59
+ This design lets you keep familiar key name conventions while centralizing secret management in the config file:
60
+
61
+ ```toml
62
+ [providers.kimi.env]
63
+ KIMI_API_KEY = "sk-xxx"
64
+ KIMI_BASE_URL = "https://api.moonshot.ai/v1"
65
+ ```
66
+
67
+ Key names per provider:
68
+
69
+ | Key | Applicable provider | Default |
70
+ | --- | --- | --- |
71
+ | `KIMI_API_KEY` | Kimi / Moonshot | None |
72
+ | `KIMI_BASE_URL` | Kimi / Moonshot | `https://api.moonshot.ai/v1` |
73
+ | `ANTHROPIC_API_KEY` | Anthropic | None |
74
+ | `ANTHROPIC_BASE_URL` | Anthropic | Follows Anthropic SDK default |
75
+ | `OPENAI_API_KEY` | OpenAI (`openai` and `openai_responses`) | None |
76
+ | `OPENAI_BASE_URL` | OpenAI (`openai` and `openai_responses`) | `https://api.openai.com/v1` |
77
+ | `GOOGLE_API_KEY` | Google GenAI, Vertex AI | None |
78
+ | `VERTEXAI_API_KEY` | Vertex AI | None |
79
+ | `GOOGLE_CLOUD_PROJECT` | Vertex AI | None |
80
+ | `GOOGLE_CLOUD_LOCATION` | Vertex AI | None |
81
+
82
+ ::: warning
83
+ `GOOGLE_APPLICATION_CREDENTIALS` (path to a service account JSON file) is the only exception that goes through the system environment variable mechanism. It is read by the Google SDK directly via the standard ADC flow; the CLI does not participate. All other key names must be placed in the `[providers.<name>.env]` sub-table to take effect.
84
+ :::
85
+
86
+ For the full provider type and field reference, see [Providers and models](./providers.md).
87
+
88
+ ## OAuth and managed services
89
+
90
+ This group of variables redirects OAuth authentication and managed service endpoints to a self-hosted or test environment. They are not needed for everyday use.
91
+
92
+ | Variable | Purpose | Default |
93
+ | --- | --- | --- |
94
+ | `KIMI_CODE_OAUTH_HOST` | OAuth auth host; highest priority | Falls back to `KIMI_OAUTH_HOST` when unset |
95
+ | `KIMI_OAUTH_HOST` | OAuth auth host; fallback for `KIMI_CODE_OAUTH_HOST` | Falls back to `https://auth.kimi.com` when unset |
96
+ | `KIMI_CODE_BASE_URL` | Managed API base URL used after OAuth login | `https://api.kimi.com/coding/v1` |
97
+
98
+ ::: warning
99
+ `KIMI_CODE_BASE_URL` (OAuth-managed service, targeting `kimi.com`) and `KIMI_BASE_URL` (direct API key connection, targeting `moonshot.ai`) are two distinct variables. Use each one in its appropriate context.
100
+ :::
101
+
102
+ ## Define a model from environment variables (`KIMI_MODEL_*`)
103
+
104
+ Want to switch models for testing without touching `config.toml`? When `KIMI_MODEL_NAME` is set, the CLI synthesizes a temporary provider and model alias from the `KIMI_MODEL_*` variables in memory; nothing is written back to the config file. These variables take priority over `default_model` in `config.toml`, but the `-m <alias>` option at startup still has the highest priority.
105
+
106
+ ```sh
107
+ export KIMI_MODEL_NAME="kimi-for-coding"
108
+ export KIMI_MODEL_API_KEY="YOUR_API_KEY"
109
+ export KIMI_MODEL_BASE_URL="https://api.example.com/v1"
110
+ export KIMI_MODEL_MAX_CONTEXT_SIZE="262144"
111
+ export KIMI_MODEL_CAPABILITIES="image_in,thinking"
112
+ kimi
113
+ ```
114
+
115
+ Complete variable list:
116
+
117
+ | Variable | Required | Purpose | Default |
118
+ | --- | --- | --- | --- |
119
+ | `KIMI_MODEL_NAME` | Yes (also the enable switch) | Model id sent to the API | — |
120
+ | `KIMI_MODEL_API_KEY` | Yes | API key | — |
121
+ | `KIMI_MODEL_PROVIDER_TYPE` | No | Provider type: `kimi`, `anthropic`, `openai` | `kimi` |
122
+ | `KIMI_MODEL_BASE_URL` | No | API base URL | Each type has its own default |
123
+ | `KIMI_MODEL_MAX_CONTEXT_SIZE` | No | Maximum context length (tokens) | `262144` (256 K) |
124
+ | `KIMI_MODEL_CAPABILITIES` | No | Comma-separated capability tags, unioned with auto-detected capabilities | `image_in,thinking` |
125
+ | `KIMI_MODEL_DISPLAY_NAME` | No | Name shown in `/model` | Falls back to `KIMI_MODEL_NAME` |
126
+ | `KIMI_MODEL_MAX_OUTPUT_SIZE` | No | Per-request output cap (`anthropic` only); when set, overrides the built-in Claude ceiling | Model default |
127
+ | `KIMI_MODEL_REASONING_KEY` | No | Reasoning field name override (`openai` only) | Auto-detected |
128
+ | `KIMI_MODEL_THINKING_EFFORT` | No | Thinking effort level: `low`/`medium`/`high`/`xhigh`/`max` | — |
129
+ | `KIMI_MODEL_ADAPTIVE_THINKING` | No | Force adaptive thinking on or off (`anthropic` only) | Inferred from model name |
130
+
131
+ If `KIMI_MODEL_NAME` is set but a required variable is missing, startup fails immediately with a clear error message.
132
+
133
+ ## Runtime switches
134
+
135
+ Switches that control the behavior of subsystems such as telemetry, background tasks, and the plugin marketplace:
136
+
137
+ | Variable | Purpose | Valid values |
138
+ | --- | --- | --- |
139
+ | `KIMI_DISABLE_TELEMETRY` | Disable anonymous telemetry reporting | `1`, `true`, `yes`, `y` (case-insensitive) |
140
+ | `KIMI_CODE_PASSWORD` | Parallel auth credential for `kimi web`, recommended when binding beyond loopback (see [Security notes](../guides/web.md#security-notes)) | Any non-empty string; when unset, only the token is valid |
141
+ | `KIMI_CODE_BACKGROUND_KEEP_ALIVE_ON_EXIT` | Keep background tasks when the session closes; higher priority than `config.toml` (default: stop them on exit) | Truthy: `1`/`true`/`yes`/`on`; falsy: `0`/`false`/`no`/`off` |
142
+ | `KIMI_CODE_BACKGROUND_MAX_RUNNING_TASKS` | Cap on concurrently running background tasks; higher priority than `[background] max_running_tasks` (unset = no cap) | Positive integer; invalid values are ignored |
143
+ | `KIMI_CODE_BACKGROUND_BASH_TASK_TIMEOUT_S` | Default timeout (seconds) for background `Bash` tasks, also used to re-arm foreground commands moved to the background; higher priority than `[task] bash_task_timeout_s` (`0` = no timeout) | Non-negative integer; invalid values are ignored |
144
+ | `KIMI_CODE_BACKGROUND_PRINT_BACKGROUND_MODE` | What `kimi -p` does while background tasks are still pending after the main turn; higher priority than `[task] print_background_mode` | `exit`, `drain`, or `steer`; invalid values are ignored |
145
+ | `KIMI_CODE_BACKGROUND_PRINT_WAIT_CEILING_S` | Wall-clock ceiling (seconds) for the print-mode drain/steer wait; higher priority than `[task] print_wait_ceiling_s` | Positive integer; invalid values are ignored |
146
+ | `KIMI_CODE_BACKGROUND_PRINT_MAX_TURNS` | Max number of new turns triggered by background-task completions in print mode; higher priority than `[task] print_max_turns` | Positive integer; invalid values are ignored |
147
+ | `KIMI_IMAGE_MAX_EDGE_PX` | Longest-edge ceiling (px) for image compression; higher priority than `[image] max_edge_px` (default `2000`) | Positive integer; invalid values are ignored |
148
+ | `KIMI_IMAGE_READ_BYTE_BUDGET` | Per-image byte budget for model-initiated image reads; higher priority than `[image] read_byte_budget` (default `262144`) | Positive integer; invalid values are ignored |
149
+ | `KIMI_CODE_PLUGIN_MARKETPLACE_URL` | Override the marketplace JSON loaded by `/plugins`; default `https://code.kimi.com/kimi-code/plugins/marketplace.json` | Also accepts `http://`, `file://` URLs, and local paths |
150
+ | `KIMI_CODE_AGENT_SWARM_MAX_CONCURRENCY` | Cap on AgentSwarm subagents running concurrently during the initial ramp; unset = no cap | Positive integer; invalid values fail fast |
151
+ | `KIMI_CODE_SUBAGENT_SCOPE_CACHE_SIZE` | How many completed subagent scopes stay resident for fast resume; older ones are evicted and rebuilt from persisted state on demand (default `32`; `0` or negative = never evict) | Integer; invalid values fail fast |
152
+ | `KIMI_CODE_SUBAGENT_SCOPE_EVICT_TIMEOUT_MS` | Max wall-clock time (ms) a single subagent scope eviction may take before the eviction queue skips it and moves on (default `15000`) | Positive integer; invalid values fail fast |
153
+ | `KIMI_SUBAGENT_TIMEOUT_MS` | Max wall-clock time (ms) a single `Agent` subagent may run; higher priority than `[subagent] timeout_ms` | Positive integer; invalid values fall back to the config or default |
154
+ | `KIMI_CODE_SWARM_TIMEOUT_MS` | Max wall-clock time (ms) an `AgentSwarm` subagent may run; higher priority than `[swarm] timeout_ms` | Positive integer; invalid values fall back to the config or default |
155
+ | `KIMI_CODE_IDENTITY_NAME` | Name the agent calls itself in the system prompt; higher priority than `[identity] name`, never written back | Any non-empty string; blank values read as unset |
156
+ | `KIMI_CODE_IDENTITY_SLUG` | `User-Agent` product token and MCP client name; higher priority than `[identity] slug`; derived from the name when unset | Any non-empty string; normalized to lowercase with non-alphanumeric runs folded to `-` |
157
+ | `KIMI_CODE_BUILTIN_PRODUCT_SKILLS` | Offer the built-in skills documenting Kimi Code itself to the model; higher priority than `builtin_product_skills` | Truthy: `1`/`true`/`yes`/`on`; falsy: `0`/`false`/`no`/`off` |
158
+ | `KIMI_CODE_TUI_FULL_SCREEN` | Experimental fullscreen UI: scrollable transcript, mouse selection, clickable links, Ctrl-Shift-F search | `1` enables it; anything else keeps the regular inline UI |
159
+ | `KIMI_CODE_EXPERIMENTAL_SUBAGENT_FORK` | Experimental `fork` parameter on `Agent`/`AgentSwarm`: start the subagent from a snapshot of the caller's history instead of an empty context; `KIMI_CODE_EXPERIMENTAL_FLAG=1` also enables it | Truthy: `1`/`true`/`yes`/`on`; falsy: `0`/`false`/`no`/`off` |
160
+ | `KIMI_CODE_EXPERIMENTAL_TOOL_SELECT` | Experimental on-demand tool loading: tools of MCP servers marked `deferred: true` stay out of the top-level tool list and are loaded via `select_tools`; also requires the model to declare the `dynamically_loaded_tools` capability — see [MCP](../customization/mcp.md#loading-tools-on-demand) | Truthy: `1`/`true`/`yes`/`on`; falsy: `0`/`false`/`no`/`off` |
161
+ | `KIMI_CODE_SEARCH_WORKER` | Run the global search index in a dedicated worker thread; higher priority than `[database] search` (default `true`) | Truthy: `1`/`true`/`yes`/`on`; falsy: `0`/`false`/`no`/`off` |
162
+ | `KIMI_CODE_PERSISTENCE_MINIDB_READMODEL` | Use the minidb-backed read model for session indexing; higher priority than `[database] base` (default `true`) | Truthy: `1`/`true`/`yes`/`on`; falsy: `0`/`false`/`no`/`off` |
163
+ | `KIMI_MCP_STARTUP_TIMEOUT_MS` | Global default connection timeout (ms) for MCP servers; overrides the config file, but `mcp.json` `startupTimeoutMs` still wins | Integer from `1` to `2147483647`; invalid values are ignored |
164
+ | `KIMI_MCP_TOOL_TIMEOUT_MS` | Global default single tool-call timeout (ms) for MCP servers; overrides the config file, but `mcp.json` `toolTimeoutMs` still wins | Integer from `1` to `2147483647`; invalid values are ignored |
165
+ | `KIMI_LOOP_MAX_STEPS_PER_TURN` | Max Agent steps per turn; higher priority than `[loop_control] max_steps_per_turn` (`0` = unlimited) | Non-negative integer; invalid values are ignored |
166
+ | `KIMI_LOOP_MAX_ATTEMPTS_PER_STEP` | Max total attempts for a failing step (including the first); higher priority than `[loop_control] max_attempts_per_step` | Non-negative integer; invalid values are ignored |
167
+ | `KIMI_CODE_INFINITE_RETRY` | Retry failed LLM requests indefinitely; exponential backoff (32 s cap) honoring `Retry-After`; aborting still cancels immediately | Truthy: `1`/`true`/`yes`/`on`; falsy: `0`/`false`/`no`/`off` |
168
+ | `KIMI_TOKEN_COUNTING_STRATEGY` | Context token count reported externally; higher priority than `[token_counting] strategy` | `measured+estimated`, `measured`, `estimated` (case-insensitive); invalid values are ignored |
169
+ | `KIMI_WEB_SEARCH_BASE_URL` | Web search (`WebSearch`) service API URL; higher priority than the config file; credentials and custom headers not forwarded | Non-blank string; blank values are ignored |
170
+ | `KIMI_WEB_SEARCH_API_KEY` | Web search (`WebSearch`) service API key; replaces both the configured key and the OAuth credential | Non-blank string; blank values are ignored |
171
+ | `KIMI_WEB_FETCH_BASE_URL` | Web fetch (`FetchURL`) service API URL; higher priority than the config file; credentials not forwarded. Without an endpoint, signed-in users get the managed Kimi OAuth fetch service before direct local requests | Non-blank string; blank values are ignored |
172
+ | `KIMI_WEB_FETCH_API_KEY` | Web fetch (`FetchURL`) service API key; replaces both the configured key and the OAuth credential | Non-blank string; blank values are ignored |
173
+ | `KIMI_CODE_EXPERIMENTAL_FLAG` | Enable all registered experimental features for this process | `1`, `true`, `yes`, `on` |
174
+ | `KIMI_SHELL_PATH` | Override the Git Bash path on Windows (used when auto-detection fails) | Absolute path |
175
+ | `KIMI_MODEL_MAX_COMPLETION_TOKENS` | Hard cap on `max_completion_tokens` per LLM step; applies to the `kimi` provider only | Positive integer; `0` or negative disables clamping |
176
+ | `KIMI_MODEL_TEMPERATURE` | Sampling temperature for every request; `kimi` provider only (global, independent of `KIMI_MODEL_NAME`) | Number, e.g. `0.3` |
177
+ | `KIMI_MODEL_TOP_P` | Nucleus-sampling `top_p` for every request; `kimi` provider only (global) | Number, e.g. `0.95` |
178
+ | `KIMI_MODEL_THINKING_EFFORT` | Force a thinking effort (`thinking.effort`), bypassing the model's declared `support_efforts`; `kimi` provider only | An effort value, e.g. `max` |
179
+ | `KIMI_MODEL_THINKING_KEEP` | Preserved-thinking passthrough: `thinking.keep` on `kimi`, a `clear_thinking_20251015` edit on `anthropic`; overrides `[thinking] keep` | A value the API accepts, e.g. `all`; an off-value (`false`/`0`/`no`/`off`/`none`/`null`) disables it |
180
+ | `KIMI_CODE_NO_AUTO_UPDATE` | Fully disable the update preflight: no check, background install, or prompt. Legacy alias `KIMI_CLI_NO_AUTO_UPDATE` also honored | Truthy: `1`/`true`/`yes`/`on` |
181
+ | `KIMI_DISABLE_CRON` | Disable the scheduled-task tool (`CronCreate` rejects new schedules; existing tasks do not fire) | `1` to disable |
182
+
183
+ The `KIMI_CODE_INFINITE_RETRY`, `KIMI_CODE_IDENTITY_*`, and `KIMI_CODE_BUILTIN_PRODUCT_SKILLS` variables are read by the `agent-core-v2` engine.
184
+
185
+ ## Diagnostic logs
186
+
187
+ These variables control log level and file rotation, read once at process startup:
188
+
189
+ | Variable | Purpose | Default |
190
+ | --- | --- | --- |
191
+ | `KIMI_LOG_LEVEL` | Log level: `off`, `error`, `warn`, `info`, `debug` | `info` |
192
+ | `KIMI_LOG_GLOBAL_MAX_BYTES` | Maximum bytes per global log file | `6291456` (6 MB) |
193
+ | `KIMI_LOG_GLOBAL_FILES` | Number of global log files to retain | `5` |
194
+ | `KIMI_LOG_SESSION_MAX_BYTES` | Maximum bytes per session log file | `5242880` (5 MB) |
195
+ | `KIMI_LOG_SESSION_FILES` | Number of session log files to retain | `3` |
196
+
197
+ ## System environment variables
198
+
199
+ The CLI also reads several standard system variables to detect the runtime environment; it does not modify them:
200
+
201
+ - `HOME`: used to resolve the default data path
202
+ - `VISUAL`, `EDITOR`: external editor command (`VISUAL` takes precedence)
203
+ - `PATH`: used to locate dependencies such as `rg`, `fd`, `fdfind`, and `git`; on Windows, Git Bash detection checks each `git.exe` found on `PATH`, including package-manager shims such as Scoop
204
+ - `NO_COLOR`, `FORCE_COLOR`: control color output (following the [no-color.org](https://no-color.org) convention)
205
+ - `CI`: when non-empty and not `"0"`, disables theme detection and falls back to the dark theme
206
+ - `TERM_PROGRAM`, `TERM`, `TMUX`: detect terminal features and notification support
207
+ - `DISPLAY`, `WAYLAND_DISPLAY`, `XDG_SESSION_TYPE`: detect Linux graphical sessions (for clipboard and image features)
208
+ - `WSL_DISTRO_NAME`, `WSLENV`: detect WSL for the clipboard PowerShell bridge
209
+ - `LOCALAPPDATA`: used on Windows as a fallback when probing for the Git Bash installation path
210
+
211
+ ## HTTP proxy
212
+
213
+ Kimi Code honors the standard proxy environment variables for all outbound traffic: model API calls, MCP servers, web tools, telemetry, sign-in, and update checks:
214
+
215
+ - `HTTP_PROXY` / `http_proxy`: proxy for `http://` requests
216
+ - `HTTPS_PROXY` / `https_proxy`: proxy for `https://` requests
217
+ - `ALL_PROXY` / `all_proxy`: fallback proxy used when the scheme-specific variable is unset; this is where a SOCKS proxy is usually set
218
+ - `NO_PROXY` / `no_proxy`: comma-separated hosts that bypass the proxy
219
+
220
+ ### Proxy types and precedence
221
+
222
+ Both HTTP(S) and SOCKS proxies are supported. A SOCKS proxy is recognized by its scheme: `socks5://`, `socks5h://`, `socks4://`, or `socks://` (an alias for `socks5://`). It is typically set via `ALL_PROXY` (the form used by tools like Clash and V2RayN). An HTTP(S) proxy takes precedence over `ALL_PROXY` for HTTP/HTTPS traffic.
223
+
224
+ ### Activation conditions and loopback addresses
225
+
226
+ The proxy is applied only when one of these variables is set; otherwise connections are made directly. Loopback hosts (`localhost`, `127.0.0.1`, `::1`) always bypass the proxy, so a local server such as a localhost MCP server keeps working when a proxy is configured. Add your own internal hosts to `NO_PROXY` to exempt them too.
227
+
228
+ ### MCP child processes
229
+
230
+ Stdio MCP servers that run as Node child processes honor `HTTP_PROXY` / `HTTPS_PROXY` / `NO_PROXY` automatically when the child's Node version supports `NODE_USE_ENV_PROXY` (Node ≥ 22.21 or ≥ 24.5); SOCKS proxying applies to Kimi Code's own traffic only.
231
+
232
+ ## Next steps
233
+
234
+ - [Config overrides](./overrides.md) — how environment variables, CLI options, and the config file interact by priority
235
+ - [Data locations](./data-locations.md) — directory structure affected by `KIMI_CODE_HOME`
236
+ - [Providers and models](./providers.md) — full connection examples per provider type
docs/en/configuration/overrides.md ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Config overrides
2
+
3
+ Kimi Code CLI has three places where runtime parameters can be influenced: the config file, command-line options, and environment variables. They are not a simple priority stack: the three serve different scenarios and have non-overlapping scopes:
4
+
5
+ - **Config file** stores long-term preferences (model, keys, loop control, etc.); takes effect on every startup
6
+ - **Command-line options** make one-off changes for the current startup; discarded after exit
7
+ - **Environment variables** primarily handle data directory location, OAuth endpoint switching, and a small number of runtime switches. They are **not a general fallback mechanism for config fields**.
8
+
9
+ This distinction matters: many users run `export KIMI_API_KEY=xxx` in the shell expecting the CLI to pick it up automatically, but it does not. See [Provider credentials](#provider-credentials) below for why.
10
+
11
+ ## Three roles of environment variables
12
+
13
+ Environment variables fall into three categories by function and cannot be collapsed into a single linear priority order:
14
+
15
+ 1. **Locating the config file**: `KIMI_CODE_HOME` sets the data root directory, making the config file path `$KIMI_CODE_HOME/config.toml`. This step runs before all other resolution and is not a fallback for individual parameters.
16
+ 2. **Runtime switches**: A small set of variables like `KIMI_DISABLE_TELEMETRY` directly shut down the corresponding subsystem. Even if `config.toml` has `telemetry = true`, a truthy value for this variable disables telemetry. The semantics are "additionally disable", not "ordinary override".
17
+ 3. **Runtime endpoints and diagnostics**: Variables like `KIMI_CODE_OAUTH_HOST`, `KIMI_CODE_BASE_URL`, and `KIMI_LOG_LEVEL` are read when the OAuth or logging subsystems initialize. For the full list, see [Environment variables](./env-vars.md).
18
+
19
+ ## Priority for ordinary runtime parameters
20
+
21
+ For ordinary runtime parameters such as model alias, Plan mode, permission mode, and Skills directories, priority from highest to lowest is:
22
+
23
+ 1. **Command-line options** (`-m`, `--plan`, `--yolo`, etc.): apply only to the current startup
24
+ 2. **User config file** (`~/.kimi-code/config.toml`): stores long-term preferences
25
+
26
+ A small number of environment variables explicitly override specific config file fields. For example, `KIMI_CODE_BACKGROUND_KEEP_ALIVE_ON_EXIT` has higher priority than `[background].keep_alive_on_exit`. These exceptions are noted in [Environment variables](./env-vars.md) and in the relevant field descriptions in [Configuration files](./config-files.md).
27
+
28
+ ::: warning
29
+ **Ordinary runtime parameters do not fall back to shell environment variables.** Provider `api_key` / `base_url` are read only from `config.toml` (including the `[providers.<name>.env]` sub-table) and do not fall back to `export`-ed shell variables. The only exception is the explicit `KIMI_MODEL_*` channel; see [Define a model from environment variables](./env-vars.md#define-a-model-from-environment-variables-kimi_model_).
30
+ :::
31
+
32
+ The CLI currently reads a single user-level config file and has no project-level config file mechanism. To isolate config between different projects, point `KIMI_CODE_HOME` at different data directories; see [Common scenarios](#common-scenarios) below.
33
+
34
+ ## Provider credentials
35
+
36
+ Provider credentials (`api_key`, `base_url`) follow their own resolution rules, separate from the ordinary parameter priority chain.
37
+
38
+ For a single provider, credentials are resolved in this order:
39
+
40
+ 1. `[providers.<name>].api_key`: key written directly in the config file; highest priority
41
+ 2. The matching key inside the `[providers.<name>.env]` sub-table (`KIMI_API_KEY`, `ANTHROPIC_API_KEY`, etc.): consulted only when `api_key` is empty
42
+ 3. If both are absent, startup fails with an error indicating the provider is missing credentials
43
+
44
+ `base_url` is resolved the same way: first `[providers.<name>].base_url`, then the `*_BASE_URL` key in `[providers.<name>.env]`.
45
+
46
+ > The `[providers.<name>.env]` sub-table is just a TOML section in the config file and does not write anything into the shell environment. It is only consulted when the corresponding direct field (`api_key` / `base_url`) is empty.
47
+
48
+ For the full list of credential key names, see [Environment variables: provider credential key names](./env-vars.md#provider-credential-key-names-written-in-configtoml).
49
+
50
+ ## Command-line options
51
+
52
+ Options passed at startup have the highest priority and apply only to the current session:
53
+
54
+ | Option | Effect |
55
+ | --- | --- |
56
+ | `-S, --session [id]` | Resume a specific session; enters interactive selection when no id is given |
57
+ | `-c, --continue` | Resume the last session for the current working directory |
58
+ | `-y, --yolo` | Ask When Needed mode: routine edits and commands run automatically; the agent may still ask questions |
59
+ | `--auto` | Never Ask mode: never interrupts you; the agent will not ask questions |
60
+ | `--plan` | Start in Plan mode |
61
+ | `-m, --model <model>` | Use a specific model alias for this session |
62
+ | `-p, --prompt <prompt>` | Run in non-interactive mode: execute a single prompt and exit |
63
+ | `--output-format <format>` | Output format for `-p` mode: `text` or `stream-json` |
64
+ | `--skills-dir <dir>` | Replace auto-discovered Skills directories (repeatable; applies to this session only) |
65
+
66
+ Mutual exclusion rules (startup fails if violated):
67
+
68
+ - `--output-format` can only be used with `-p`
69
+ - `--prompt` cannot be combined with `--yolo` or `--plan`
70
+ - `--continue` and `--session` cannot be used together
71
+ - In non-prompt mode, `--yolo` and `--plan` cannot be combined with `--continue` or `--session`
72
+
73
+ ::: tip
74
+ `--skills-dir` is a one-shot replacement that only affects the current startup. To persistently add search directories, write `extra_skill_dirs` in `config.toml` (see [Agent Skills](../customization/skills.md)).
75
+ :::
76
+
77
+ ## Common scenarios
78
+
79
+ **Isolated test environment**: use a separate data directory to avoid polluting the main config and sessions:
80
+
81
+ ```sh
82
+ KIMI_CODE_HOME="$PWD/.kimi-sandbox" kimi
83
+ ```
84
+
85
+ **One-off test key**: since provider credentials are read only from the config file, write a test key into the `env` sub-table:
86
+
87
+ ```toml
88
+ [providers.kimi.env]
89
+ KIMI_API_KEY = "sk-test"
90
+ ```
91
+
92
+ **Skip approval for batch tasks**:
93
+
94
+ ```sh
95
+ kimi --yolo -p "Batch rename the following files..."
96
+ ```
97
+
98
+ **Enter Plan mode temporarily** (to make it permanent, set `default_plan_mode = true` in the config file):
99
+
100
+ ```sh
101
+ kimi --plan
102
+ ```
103
+
104
+ ## Next steps
105
+
106
+ - [Configuration files](./config-files.md) — complete reference for all configurable fields
107
+ - [Environment variables](./env-vars.md) — full list and description of `KIMI_CODE_HOME` and related variables
docs/en/configuration/providers.md ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Providers and models
2
+
3
+ Kimi Code CLI supports connecting to multiple LLM platforms simultaneously: one-click login via the Kimi Code managed service, connecting Claude with an Anthropic API key, or connecting third-party inference services via the OpenAI-compatible protocol. Each provider corresponds to a specific API protocol; models are declared on top of providers with their own name, context length, and capabilities. This page explains how to configure each type of provider in `config.toml`.
4
+
5
+ ## Supported provider types
6
+
7
+ The `type` field in the `providers` table determines which protocol implementation to use:
8
+
9
+ | Type | Protocol | Typical use |
10
+ | --- | --- | --- |
11
+ | [`kimi`](#kimi) | OpenAI-compatible | Kimi Code managed service, Kimi Platform API key |
12
+ | [`anthropic`](#anthropic) | Anthropic Messages | Claude model family |
13
+ | [`openai`](#openai) | OpenAI Chat Completions | OpenAI and compatible services, DeepSeek, Qwen, etc. |
14
+ | [`openai_responses`](#openai_responses) | OpenAI Responses API | OpenAI's newer Responses interface |
15
+ | [`google-genai`](#google-genai) | Google GenAI | Gemini API |
16
+ | [`vertexai`](#vertexai) | Google GenAI on Vertex | Google Cloud Vertex AI |
17
+
18
+ All providers communicate with models in streaming mode by default. Capabilities such as thinking, vision, and tool use are matched automatically by model name prefix, so you typically do not need to declare them manually.
19
+
20
+ **Credential priority**: `api_key` direct field > `[providers.<name>.env]` sub-table key > if both are absent, startup fails with an error. The CLI does not fall back to shell environment variables for credentials. See [Config overrides: provider credentials](./overrides.md#provider-credentials).
21
+
22
+ ## `/provider` — interactive provider management
23
+
24
+ Prefer not to edit TOML by hand? Type `/provider` in the TUI to open the **provider manager**, where you can interactively add or remove providers.
25
+
26
+ ![The /provider provider manager](../../media/provider-manager.jpg)
27
+
28
+ The manager displays providers as a list of entries grouped by source. Navigation:
29
+
30
+ - ↑/↓ to move the cursor, ←/→ to page
31
+ - `d` to delete the current provider (with `[y/N]` confirmation)
32
+ - Press Enter on the `[ Add New Platform ]` row to add a new provider
33
+
34
+ Two paths when adding:
35
+
36
+ - **Known third-party provider**: fetches the model catalog from [models.dev](https://models.dev/), select a provider → enter an API key → select a default model. Vendors whose protocol the catalog does not declare (e.g. xai, openrouter, and other vendor-specific SDKs) are imported as OpenAI-compatible with a "guessed" note; when the catalog provides no usable endpoint, a base URL prompt appears first; proprietary protocols (Amazon Bedrock, Cohere) and unrecognized explicit protocols are refused. Deprecated and alpha-status models are excluded from the import list. If the public catalog is unreachable, the CLI falls back to a built-in snapshot of the catalog, so the import still works offline or in blocked networks
37
+ - **Custom registry (api.json)**: paste a custom registry URL and Bearer token; the CLI automatically creates the `providers` / `models` entries. On later startup, providers from the same registry URL are refreshed together, so upstream provider additions, removals, and model metadata changes are synced.
38
+
39
+ ::: warning
40
+ Kimi Code OAuth managed accounts logged in via `/login` do not appear in `/provider`. Use `/login` and `/logout` to manage them.
41
+ :::
42
+
43
+ The same operations are also available in non-interactive environments via the shell command: [`kimi provider`](../reference/kimi-command.md#kimi-provider).
44
+
45
+ ## `kimi`
46
+
47
+ For connecting to Moonshot AI's OpenAI-compatible interface, including the Kimi Code managed service and Kimi Platform API keys.
48
+
49
+ - Default `base_url`: `https://api.moonshot.ai/v1`
50
+ - Credential key names: `KIMI_API_KEY`, `KIMI_BASE_URL`
51
+ - Additional capability: supports video upload
52
+
53
+ ```toml
54
+ [providers.kimi]
55
+ type = "kimi"
56
+ base_url = "https://api.moonshot.ai/v1"
57
+ api_key = "sk-xxxxx"
58
+ ```
59
+
60
+ > When using the Kimi Code managed service, running `/login` automatically configures `base_url` and credentials, so no manual setup is needed.
61
+
62
+ ## `anthropic`
63
+
64
+ For connecting to the Claude API. Standard Claude models automatically enable vision, tool use, and Thinking (where supported); custom or uncovered models need `capabilities` declared explicitly on `[models.<alias>]`.
65
+
66
+ - Default `base_url`: follows Anthropic SDK default
67
+ - Credential key names: `ANTHROPIC_API_KEY`, `ANTHROPIC_BASE_URL`
68
+ - Default `max_tokens`: inferred per model. To override, set `max_output_size` on the model alias
69
+
70
+ ```toml
71
+ [providers.anthropic]
72
+ type = "anthropic"
73
+ api_key = "sk-ant-xxxxx"
74
+
75
+ [models."claude-opus-4-7"]
76
+ provider = "anthropic"
77
+ model = "claude-opus-4-7"
78
+ max_context_size = 200000
79
+ # max_output_size = 32000 # optional; omit to use the model-inferred default
80
+ ```
81
+
82
+ ## `openai`
83
+
84
+ For connecting to the OpenAI Chat Completions protocol, as well as any third-party service compatible with that protocol (override `base_url` as needed).
85
+
86
+ Third-party reasoning models (DeepSeek, Qwen, One API, etc.) work out of the box: the CLI automatically handles the `reasoning_content` field and `reasoning_effort` injection. If your gateway returns reasoning content under a non-standard field name, set `reasoning_key` on the model alias to override.
87
+
88
+ - Default `base_url`: `https://api.openai.com/v1`
89
+ - Credential key names: `OPENAI_API_KEY`, `OPENAI_BASE_URL`
90
+
91
+ ```toml
92
+ [providers.openai]
93
+ type = "openai"
94
+ base_url = "https://api.openai.com/v1"
95
+ api_key = "sk-xxxxx"
96
+ ```
97
+
98
+ ## `openai_responses`
99
+
100
+ Corresponds to OpenAI's newer Responses API, always operating in streaming mode. Configuration is the same as `openai`.
101
+
102
+ - Default `base_url`: `https://api.openai.com/v1`
103
+ - Credential key names: `OPENAI_API_KEY`, `OPENAI_BASE_URL`
104
+
105
+ ```toml
106
+ [providers.openai-responses]
107
+ type = "openai_responses"
108
+ base_url = "https://api.openai.com/v1"
109
+ api_key = "sk-xxxxx"
110
+ ```
111
+
112
+ ## `google-genai`
113
+
114
+ For connecting directly to the Google Gemini API. Thinking, vision, and multimodal capabilities are auto-detected by model name.
115
+
116
+ - Credential key name: `GOOGLE_API_KEY`
117
+
118
+ ```toml
119
+ [providers.gemini]
120
+ type = "google-genai"
121
+ api_key = "xxxxx"
122
+ ```
123
+
124
+ To route through a Gemini-compatible proxy or gateway, set `base_url` (or the `GOOGLE_GEMINI_BASE_URL` env var); when omitted, the SDK default `https://generativelanguage.googleapis.com` is used.
125
+
126
+ > Give the **host root only**. The Google GenAI SDK appends the API version and path itself (e.g. `/v1beta/models/<model>:generateContent`), so a trailing `/v1beta` would produce a doubled `/v1beta/v1beta/…`.
127
+
128
+ ```toml
129
+ [providers.gemini]
130
+ type = "google-genai"
131
+ api_key = "xxxxx"
132
+ base_url = "https://your-gateway.example"
133
+ ```
134
+
135
+ ## `vertexai`
136
+
137
+ Shares the same implementation as `google-genai`; setting `type = "vertexai"` switches to the Vertex AI access path.
138
+
139
+ Authentication follows the standard Google Cloud ADC flow (`gcloud auth application-default login` or a `GOOGLE_APPLICATION_CREDENTIALS` service account JSON); this part is unrelated to Kimi Code. **The project ID and region must be written in the `[providers.vertexai.env]` sub-table**. Simply `export GOOGLE_CLOUD_PROJECT` in the shell will not be read by the CLI.
140
+
141
+ ```toml
142
+ [providers.vertexai]
143
+ type = "vertexai"
144
+
145
+ [providers.vertexai.env]
146
+ GOOGLE_CLOUD_PROJECT = "my-gcp-project"
147
+ GOOGLE_CLOUD_LOCATION = "us-central1"
148
+ ```
149
+
150
+ ```sh
151
+ gcloud auth application-default login # one-time authentication
152
+ kimi
153
+ ```
154
+
155
+ To route Vertex requests through a custom (e.g. proxied) endpoint, set `base_url` (or the `GOOGLE_VERTEX_BASE_URL` env var); when omitted, the SDK default regional `*-aiplatform.googleapis.com` host is used. As with `google-genai`, give the host root only. The SDK appends `/v1beta1/publishers/google/models/…` itself.
156
+
157
+ ## OAuth and credential injection
158
+
159
+ The Kimi Code managed service uses OAuth rather than static API keys. After running `/login`, the built-in authentication toolchain automatically writes and refreshes credentials, so no manual configuration is needed in `config.toml` for this.
160
+
161
+ ## Next steps
162
+
163
+ - [Configuration files](./config-files.md) — full field reference for the `providers` and `models` tables
164
+ - [Config overrides](./overrides.md) — credential resolution priority rules for providers
165
+ - [Environment variables](./env-vars.md) — credential key names per provider type
docs/en/customization/agents.md ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Agents and Sub-Agents
2
+
3
+ Every session in Kimi Code CLI is driven by a **main Agent**. The main Agent understands the user's intent, plans steps, calls tools, and when needed dispatches **sub-agents** to handle more focused sub-tasks, such as exploring an unfamiliar codebase, reviewing multiple implementations in parallel, or planning a large refactor without touching the main context.
4
+
5
+ A sub-agent receives a task description from the main Agent, works in its own isolated context, and then returns its conclusions. It does not communicate with the user directly, and its intermediate reasoning and tool call records do not mix into the main Agent's history.
6
+
7
+ ## Built-in Sub-Agents
8
+
9
+ Kimi Code CLI includes three built-in sub-agents, ready to use out of the box, each aimed at a different task shape:
10
+
11
+ - **`coder`**: The default sub-agent, a general-purpose software engineering assistant that can read and write files, execute commands, search code, and land concrete changes.
12
+ - **`explore`**: Dedicated to codebase exploration; performs read-only operations only and does not modify any files. Ideal for quickly searching, reading, and summarizing a repository without touching files.
13
+ - **`plan`**: Dedicated to implementation planning and architecture design; even shell commands are not available, keeping the focus on "figuring out how to do something" rather than "actually doing it."
14
+
15
+ Beyond the three types, three conventions govern how sub-agents work: tool boundaries, delegation depth, and completion timing.
16
+
17
+ A `coder` sub-agent shares most of the main Agent's tool set: it can run shell commands in the background, maintain todo lists, enter Plan mode, and invoke Agent Skills. The three built-in sub-agents cannot dispatch further sub-agents.
18
+
19
+ By default a custom agent inherits the built-in delegation allowlist (`coder`, `explore`, `plan`), whose members cannot dispatch further either, so delegation chains always terminate and unbounded recursive spawning is impossible without an explicit opt-in. A custom agent can opt into deeper chains by declaring an explicit [`subagents`](#agent-file-format) allowlist.
20
+
21
+ If a sub-agent finishes its turn while background tasks are still running, its run only reports completion after those tasks settle, so the parent receives the result after the underlying work has actually finished.
22
+
23
+ ## How to Invoke
24
+
25
+ The full pipeline has only three stages (dispatch, approval, and collection), and none of them require manual management.
26
+
27
+ Sub-agents are scheduled automatically by the main Agent, based on task complexity, context consumption, and sub-task independence. They are dispatched at the right moment without the user having to specify one.
28
+
29
+ Each dispatch is presented in the terminal as an approval request (unless it matches an allow rule or Ask When Needed mode is active), giving you a chance to review the task description. You can also instruct the main Agent directly in conversation to use a specific sub-agent, for example: "Use explore to map out the relevant files before making any changes."
30
+
31
+ Sub-agents support running in the background: results are automatically returned to the main Agent upon completion, with no manual polling needed. You can also call back an existing sub-agent instance to continue the same task.
32
+
33
+ ## Context Isolation and Resource Cost
34
+
35
+ Each sub-agent has a fully independent context window. It can only see the task description explicitly passed by the main Agent and cannot see the main Agent's conversation history. The sub-agent's own intermediate reasoning and tool call records do not flow back; only the final result appears in the main Agent's context.
36
+
37
+ This isolation provides two benefits:
38
+
39
+ - **The main Agent's context stays lean** and is not filled with large volumes of exploratory logs during long sessions.
40
+ - **Multiple sub-agents can run in parallel** without interfering with each other.
41
+
42
+ Note that each sub-agent independently consumes model tokens. For simple tasks, there is no need to dispatch a sub-agent; the main Agent handles them more economically.
43
+
44
+ ## Permission Inheritance
45
+
46
+ Sub-agent permission rules are inherited from the main Agent: "always allow" rules that the main Agent has accepted via `/permission` or through an approval dialog automatically propagate to all sub-agents it dispatches, so sub-agents do not need to re-approve the same types of tool calls. The `Agent` tool itself is allowed by default, enabling the main Agent to delegate multiple times without interrupting the user.
47
+
48
+ If you need a particular type of tool to be permanently unavailable inside sub-agents, tighten the corresponding permission rule on the main Agent.
49
+
50
+ ## Custom Agents
51
+
52
+ Beyond the three built-in sub-agents, you can define your own agents as Markdown files. Each file describes one agent: the frontmatter (YAML metadata at the top of the file) declares its name, description, and tool access, and the file body is its system prompt. The main Agent discovers custom agents automatically alongside the built-in ones, so they can be delegated to as sub-agents. They can also be selected as the main Agent at startup.
53
+
54
+ ### Agent Locations
55
+
56
+ Kimi Code CLI discovers agent files by scope; more specific scopes take higher priority: **Explicit (`--agent-file`) > Project > Extra > User > Plugin > Built-in**. When two files define the same `name`, the higher-priority scope wins. Each directory is scanned recursively for `.md` files.
57
+
58
+ **User level** (applies to all projects):
59
+ - `$KIMI_CODE_HOME/agents/` (default: `~/.kimi-code/agents/`)
60
+ - `~/.agents/agents/`
61
+
62
+ The Kimi-specific user agent directory moves with `KIMI_CODE_HOME`, while the generic `~/.agents/agents/` directory stays under the real OS home so it can be shared across tools.
63
+
64
+ **Project level** (project root = the nearest directory containing `.git`, searching upward from the working directory):
65
+ - `.kimi-code/agents/`
66
+ - `.agents/agents/`
67
+
68
+ **Extra directories**: Declared via `extra_agent_dirs` at the top level of `config.toml`:
69
+
70
+ ```toml
71
+ extra_agent_dirs = ["~/team-agents", ".agents/team-agents"]
72
+ ```
73
+
74
+ **Plugin level**: directories declared in an enabled plugin's manifest `agents` field (when omitted, the `agents/` directory under the plugin root is picked up automatically); see [Plugin Agents](./plugins.md#plugin-agents). Plugin agents outrank only the built-in agents.
75
+
76
+ **Built-in agents** are distributed with the CLI and have the lowest priority. A directory-discovered file does not override a same-name built-in Agent unless its frontmatter declares `override: true`. A file loaded through `--agent-file` is treated as explicit launch intent, may override a same-name built-in Agent, outranks every directory scope, and applies to the current launch only.
77
+
78
+ Separately, `$KIMI_CODE_HOME/SYSTEM.md` permanently overrides the default main agent's system prompt; it is not part of agent-file discovery. Its precedence interactions are covered in the [SYSTEM.md section](#overriding-the-main-agents-system-prompt-with-systemmd).
79
+
80
+ ::: warning Trust model
81
+ Agent files are prompt configuration, and project-level files come from the repository itself, including repositories you have just cloned and do not trust yet. A project-scoped file can take over a built-in agent entirely: naming it `agent.md` with `override: true` replaces the **default main agent's whole system prompt**, and `coder.md` with `override: true` replaces the default sub-agent type. Unlike `AGENTS.md` content, which is injected into the prompt as reference data, an override file *is* the system prompt, and a file without a `tools` list keeps every tool. Review `.kimi-code/agents/` and `.agents/agents/` in unfamiliar repositories with the same caution you would apply to scripts, before running Kimi Code inside them.
82
+ :::
83
+
84
+ ### Agent File Format
85
+
86
+ An agent file is plain Markdown with a frontmatter block:
87
+
88
+ ```markdown
89
+ ---
90
+ name: reviewer
91
+ description: Strict code reviewer that reports severity-ranked findings
92
+ whenToUse: Code reviews and PR checks
93
+ override: false
94
+ tools:
95
+ - Read
96
+ - Grep
97
+ - Glob
98
+ - mcp__github__*
99
+ disallowedTools:
100
+ - Bash
101
+ ---
102
+
103
+ You are a strict code reviewer. Read the diff, then report findings grouped by severity…
104
+ ```
105
+
106
+ Frontmatter fields:
107
+
108
+ | Field | Required | Description |
109
+ | --- | --- | --- |
110
+ | `name` | no | Unique kebab-case identifier; defaults to the file name without its extension. A file with a missing or non-kebab-case name is skipped with a warning |
111
+ | `description` | yes | What the agent does, shown to the main Agent when it picks a sub-agent. Write it to guide delegation decisions |
112
+ | `whenToUse` | no | Extra hint describing when the agent should be used |
113
+ | `override` | no | Whether the file may replace a same-name built-in Agent; defaults to `false`. `--agent-file` does not need it |
114
+ | `tools` | no | Tool allowlist (`Read`, `Bash`); MCP tools match as globs (`mcp__github__*`). YAML list or comma-separated string; omit or use a lone `*` to allow all tools, `tools: []` disables all tools |
115
+ | `disallowedTools` | no | Denylist with the same syntax and matching rules, applied after `tools` |
116
+ | `subagents` | no | Sub-agent allowlist, same syntax as `tools`. Omit to inherit the built-in default (`coder`, `explore`, `plan`); a lone `*` allows every type. The main agent's effective list also includes every discovered custom agent |
117
+
118
+ Built-in and user tools match by exact, case-sensitive name; entries starting with `mcp__` match MCP tools as globs. Three entry shapes never match anything and are reported with a warning when the profile takes effect:
119
+
120
+ - A wildcard outside an `mcp__` pattern: a bare `*` in `disallowedTools` disables nothing.
121
+ - An incomplete `mcp__` literal: `mcp__github` matches nothing; use `mcp__github__*` for the whole server.
122
+ - A name no registered or built-in tool has, usually a typo such as `read` instead of `Read`.
123
+
124
+ The body is the agent's system prompt, and it is rendered as a template each time the prompt is built: `${var}` placeholders substitute live context values. Unknown variables stay verbatim, a bare `$` is never special, and a variable with no context value renders as an empty string. `${base_prompt}` embeds the effective default system prompt (the built-in default, or your `SYSTEM.md` override when present), so a file can wrap the default behavior instead of replacing it. If the file replaces the default prompt but should still honor instructions contributed by enabled plugins, place `${plugin_sections}` where those instructions should appear. The available variables are listed in the [SYSTEM.md section](#overriding-the-main-agents-system-prompt-with-systemmd).
125
+
126
+ Unknown fields are ignored, so newer files stay readable by older versions. Fields from other agent tools (such as Claude Code's `model` or OpenCode's `mode`) are ignored the same way, the comma-separated `tools` form keeps Claude Code-style agent files loadable, and a missing `name` falls back to the file name so OpenCode-style files load too. A minimal file with `description` and a body works across tools.
127
+
128
+ A file with invalid content discovered in a directory is skipped with a warning and does not affect other files. A file passed explicitly via `--agent-file` must be valid, otherwise the CLI reports the error and exits.
129
+
130
+ ::: warning Note
131
+ `tools` and `disallowedTools` shape the tools shown to the model and are enforced again before execution. `subagents` works the same way: the `Agent` tool lists only the sub-agent types the caller may delegate to, and both `Agent` and `AgentSwarm` re-check the allowlist before dispatching; resuming an existing sub-agent is exempt. Permission rules remain a separate control for operations that require approval.
132
+ :::
133
+
134
+ Custom agents delegated as sub-agents run without the built-in sub-agent framing ("your final message is the entire handoff"). If you write an agent meant for delegation, state in the body that its last message should be the complete, self-contained result for the caller.
135
+
136
+ ### Selecting the Main Agent
137
+
138
+ Two CLI flags select which agent drives a new session, in both print mode (`kimi -p`) and the interactive TUI:
139
+
140
+ - **`--agent <name>`**: Start the session with the named agent as the main Agent. The name can refer to a built-in agent or to any discovered file; an unknown name fails with an error listing the available agents.
141
+ - **`--agent-file <path>`**: Load one agent file at the highest priority for this launch and start with it. The flag accepts exactly one file: it cannot be repeated, and it cannot be combined with `--agent`.
142
+
143
+ Both flags only apply when starting a new session: neither can be combined with `--session`/`--continue`. The agent is bound at session creation, and resuming restores the bound agent automatically, so no flag is needed (or allowed) on resume.
144
+
145
+ For example:
146
+
147
+ ```sh
148
+ kimi --agent reviewer
149
+ kimi -p --agent reviewer "Review the changes on this branch"
150
+ ```
151
+
152
+ The bound agent is the session's identity: it is fixed at the session's first bind and cannot be switched later. In the TUI the flags bind only the startup session; a session created later in the same process (for example via `/new`) starts with the default agent.
153
+
154
+ For main-agent customization, reference `${base_prompt}` in the body so the environment, workspace-instruction, Skill, and plugin injections already present in the effective default prompt stay in effect. When you want to replace the default prompt but keep only plugin-contributed instructions, use `${plugin_sections}` instead. A body without `${base_prompt}` or `${plugin_sections}` owns the entire prompt and excludes plugin instructions, which fits self-contained sub-agents.
155
+
156
+ ### Overriding the main agent's system prompt with SYSTEM.md
157
+
158
+ To override the main agent's system prompt permanently, without passing `--agent` or `--agent-file` on every launch, write a `$KIMI_CODE_HOME/SYSTEM.md` file (default: `~/.kimi-code/SYSTEM.md`; it moves with `KIMI_CODE_HOME`). While the file exists and is non-empty, it fully replaces the built-in default main agent's system prompt (and only the prompt: the description, tool set, and sub-agent delegation allowlist are inherited from the built-in defaults). SYSTEM.md takes effect in every launch mode, including interactive TUI sessions.
159
+
160
+ SYSTEM.md is a plain Markdown body; no frontmatter is required or read. A missing or empty file has no effect, and a read failure falls back to the built-in prompt with a warning.
161
+
162
+ Explicit intent still outranks it:
163
+
164
+ - A project-scoped same-name agent file declaring `override: true`, and any file passed via `--agent-file`, rank ahead of SYSTEM.md.
165
+ - Selecting another agent with `--agent` bypasses SYSTEM.md entirely.
166
+ - Within the user scope itself, SYSTEM.md wins over a same-name file discovered in the `agents/` directories.
167
+
168
+ Like the body of a regular agent file, SYSTEM.md is rendered as a template each time the prompt is built, and `${var}` placeholders in the body are substituted from the live context:
169
+
170
+ | Variable | Content |
171
+ | --- | --- |
172
+ | `${skills}` | The merged Agent Skills injection; empty when the `Skill` tool is unavailable |
173
+ | `${agents_md}` | Content of the workspace instruction files (such as `AGENTS.md`) |
174
+ | `${cwd}` | Current working directory |
175
+ | `${cwd_listing}` | Listing of the working directory |
176
+ | `${os}` | Operating system kind |
177
+ | `${shell}` | Shell name and path, for example `bash (\`/bin/bash\`)` |
178
+ | `${now}` | Current time (ISO format) |
179
+ | `${additional_dirs_info}` | Additional directories added to the workspace; empty when there are none |
180
+ | `${base_prompt}` | The default system prompt. Inside `SYSTEM.md` itself this is the built-in default; inside an agent file it is the effective default (the built-in default, or your `SYSTEM.md` override when present) |
181
+ | `${plugin_sections}` | A complete Plugin Instructions block contributed by enabled plugins; empty when no enabled plugin contributes instructions |
182
+
183
+ Unknown variables stay verbatim, a bare `$` is never special, and a variable with no context value renders as an empty string. Four pre-composed blocks (`${windows_notes}`, `${additional_dirs_section}`, `${skills_section}`, and `${plugin_sections}`) render the matching built-in prompt section, or an empty string when it does not apply. The built-in default prompt already includes `${plugin_sections}`, so do not add it again when `${base_prompt}` already expands to that prompt. The variables are enough to rebuild the skeleton of the built-in prompt, for example:
184
+
185
+ ```markdown
186
+ You are Kimi, running at ${cwd} on ${os}.
187
+
188
+ ${agents_md}
189
+
190
+ ${skills}
191
+
192
+ ${plugin_sections}
193
+ ```
194
+
195
+ ## Instruction Files
196
+
197
+ Global Kimi-specific instructions can live at `$KIMI_CODE_HOME/AGENTS.md` (default: `~/.kimi-code/AGENTS.md`). When you relocate the data root with `KIMI_CODE_HOME`, this global instruction file moves with it. Generic cross-tool instructions can still live under `~/.agents/AGENTS.md` in the real OS home, and project-level instructions remain under the project tree, for example `.kimi-code/AGENTS.md` or `AGENTS.md`.
198
+
199
+ ## Storage Location in the Session Directory
200
+
201
+ Sub-agent runtime state is persisted to the `agents/` subdirectory of the current session directory. Each sub-agent instance has its own directory, which contains a `wire.jsonl` file that records prompts, message history, and final state in chronological order. Background sub-agents also expose their lifecycle status through a `tasks/` subdirectory.
202
+
203
+ ::: warning Note
204
+ Session directories, wire files, and task records are all local debug materials that may contain user prompts, command output, repository paths, tool return values, or traces of credentials. Do not commit these files directly to public repositories, issues, or chat logs; redact sensitive information before sharing.
205
+ :::
206
+
207
+ ## Next steps
208
+
209
+ - [Hooks](./hooks.md) — Trigger local script notifications or interceptions at key points such as sub-agent completion
210
+ - [Agent Skills](./skills.md) — Inject specialized knowledge and workflows into sub-agents
docs/en/customization/datasource.md ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ head:
3
+ - - meta
4
+ - http-equiv: refresh
5
+ content: 0; url=./plugins.html#kimi-datasource
6
+ ---
7
+
8
+ # Kimi Datasource
9
+
10
+ This page has moved to [Plugins: Kimi Datasource](./plugins.md#kimi-datasource).
docs/en/customization/hooks.md ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Hooks
2
+
3
+ Hooks are an automatic trigger mechanism: you tell Kimi Code CLI in advance "whenever X happens, run this script." The script runs on your local machine, and you can put any logic inside it. Typical use cases:
4
+
5
+ - **Security interception**: Before the Agent executes a shell command, check whether it contains dangerous operations (such as `rm -rf`) and block execution if so
6
+ - **Desktop notifications**: When a background task completes, pop up a system notification to bring you back to review the results
7
+ - **Automatic checks**: Each time the user submits a message, automatically append some background information to the context (such as the current Git branch)
8
+
9
+ ## How Hooks Work
10
+
11
+ Configuring a hook rule requires specifying three things: **which event to trigger on**, **which targets to match**, and **which script to run**.
12
+
13
+ When triggered, the CLI packages the event's details (trigger reason, tool name, command content, etc.) into JSON and passes it to your script via **standard input** (stdin). The script reads this information and decides how to respond.
14
+
15
+ The script's response is determined by two things:
16
+
17
+ - **Exit code**: `0` means allow, `2` means block, other non-zero values default to allow
18
+ - **Standard output** (stdout): can include explanatory text
19
+
20
+ Even if the script errors or times out, the CLI **will not interrupt your work** as a result. This "allow on failure" design is called fail-open, preventing hook errors from becoming blockers.
21
+
22
+ ::: warning Note
23
+ Precisely because of fail-open, Hooks are suitable for alerts and lightweight interception, but **should not be used as the sole security barrier**. For truly high-risk operations, rely on permission approvals and manual confirmation.
24
+ :::
25
+
26
+ ## Quick Start: A Minimal Hook
27
+
28
+ The following hook flashes a notification in the terminal title bar each time a background task completes (macOS requires `terminal-notifier` to be installed):
29
+
30
+ ```toml
31
+ # Written in ~/.kimi-code/config.toml
32
+ [[hooks]]
33
+ event = "Notification" # Trigger: when a background task status changes
34
+ matcher = "task\\.completed" # Only care about "completed" notifications
35
+ command = "terminal-notifier -title Kimi -message 'Task done'"
36
+ ```
37
+
38
+ Save the config, start a new session, and a notification will appear the next time a background task completes.
39
+
40
+ ## Configuration
41
+
42
+ All hook rules are written in the `[[hooks]]` array in `~/.kimi-code/config.toml`, where each entry is one rule:
43
+
44
+ | Field | Type | Required | Description |
45
+ | --- | --- | --- | --- |
46
+ | `event` | `string` | Yes | Trigger event name; must be one of the events in the [event reference](#event-reference) |
47
+ | `matcher` | `string` | No | A regular expression to filter event targets; if omitted, matches all |
48
+ | `command` | `string` | Yes | The shell command to run when triggered |
49
+ | `timeout` | `integer` | No | Timeout in seconds, range 1–600; defaults to 30 seconds |
50
+
51
+ `[[hooks]]` only allows these four fields; extra fields will cause the config file to fail to load.
52
+
53
+ **When multiple rules match the same event**, all matching hooks run in parallel; multiple rules with identical `command` values run only once.
54
+
55
+ The working directory for hook commands is the current session's project directory.
56
+
57
+ <details>
58
+ <summary>Process group and timeout handling</summary>
59
+
60
+ On non-Windows platforms, hook processes run in a separate process group; on timeout, the CLI first sends a signal to give the script a chance to clean up, then forcibly terminates it.
61
+
62
+ </details>
63
+
64
+ ### Event Data Format
65
+
66
+ Each time a hook triggers, the CLI passes the following base information to the script via stdin:
67
+
68
+ ```json
69
+ {
70
+ "hook_event_name": "PreToolUse",
71
+ "session_id": "session_abc",
72
+ "session_title": "Fix the login page",
73
+ "client_type": "kimi_code_cli",
74
+ "cwd": "/path/to/project"
75
+ }
76
+ ```
77
+
78
+ Specific events will also include additional fields (such as tool name and command content); see the [event reference](#event-reference). All field names use snake_case.
79
+
80
+ ## Return Values
81
+
82
+ After the script exits, the CLI determines the hook's intent based on the exit code:
83
+
84
+ | Exit code | Meaning | CLI behavior |
85
+ | --- | --- | --- |
86
+ | `0` | Normal exit, allow | Continue execution; stdout content (if any) may be appended to context |
87
+ | `2` | Intentional block | Stop the current operation; stderr content (printed via `console.error`) is used as the reason for blocking |
88
+ | Other non-zero | Script error | Default allow (fail-open) |
89
+ | Timeout or crash | Script exception | Default allow (fail-open) |
90
+
91
+ You can also return a JSON object via stdout to block:
92
+
93
+ ```json
94
+ {
95
+ "hookSpecificOutput": {
96
+ "permissionDecision": "deny",
97
+ "permissionDecisionReason": "Please use rg instead of grep"
98
+ }
99
+ }
100
+ ```
101
+
102
+ ::: info Which events support blocking?
103
+ Only **blockable events** (`PreToolUse`, `Stop`, `UserPromptSubmit`) have return values that affect the main flow. All other events are **observation-only events**: they fire and forget, and the main flow is unaffected regardless of what the script returns.
104
+ :::
105
+
106
+ ## Event Reference
107
+
108
+ | Event | Matcher matches | Supports blocking? | Description |
109
+ | --- | --- | --- | --- |
110
+ | `UserPromptSubmit` | The text submitted by the user | ✓ | Triggered when the user sends a message; returned text is appended to context; blocking skips the model call this turn |
111
+ | `UserPromptQueued` | The queued prompt text | — | Triggered when a message is queued while a turn is still running; payload includes `prompt_id`, `prompt`, `queue_length` |
112
+ | `PreToolUse` | Tool name | ✓ | Triggered before a tool call (before permission checks); the tool will not execute if blocked |
113
+ | `Stop` | Empty string | ✓ | Triggered when the model is about to end the turn; if blocked, a message can be appended to let the model continue |
114
+ | `TurnStarted` | Turn origin kind (e.g. `user`, `task`, `system_trigger`) | — | Triggered when a new turn begins; payload includes `turn_id`, `origin_kind`, `origin_name`, `prompt` |
115
+ | `PostToolUse` | Tool name | — | Triggered after a tool executes successfully |
116
+ | `PostToolUseFailure` | Tool name | — | Triggered after a tool fails or is blocked |
117
+ | `PermissionRequest` | Tool name | — | Triggered just before waiting for user approval |
118
+ | `PermissionResult` | Tool name | — | Triggered after approval completes |
119
+ | `SessionStart` | `startup` or `resume` | — | Triggered after a session starts or resumes; payload includes `source`, `model`, `profile` |
120
+ | `SessionEnd` | `exit` or `archive` | — | Triggered after a session closes; `archive` means the session was archived rather than exited |
121
+ | `SessionHeartbeat` | Empty string | — | Triggered every 60 seconds while the session is alive; the timer runs only when this event is configured; payload includes `uptime_ms` |
122
+ | `SubagentStart` | Sub-agent name | — | Triggered before a sub-agent starts running |
123
+ | `SubagentStop` | Sub-agent name | — | Triggered after a sub-agent completes successfully |
124
+ | `TaskStarted` | Task kind (`agent`, `process`, or `question`) | — | Triggered when a background task starts; payload includes `task_id`, `description`, `detached` |
125
+ | `StopFailure` | Error type | — | Triggered after the current turn fails due to an error |
126
+ | `Interrupt` | Empty string | — | Triggered when the user interrupts the turn (e.g. pressing Esc); not fired for timeouts or programmatic aborts; fires in place of `Stop`; payload includes `reason` |
127
+ | `PreCompact` | `manual` or `auto` | — | Triggered before context compaction begins; return values are completely ignored |
128
+ | `PostCompact` | `manual` or `auto` | — | Triggered after context compaction completes |
129
+ | `Notification` | Notification type (e.g. `task.completed`) | — | Triggered when a background task status changes |
130
+
131
+ ## Example: Blocking Dangerous Shell Commands
132
+
133
+ The following hook checks the command content before the Agent calls the `Bash` tool and blocks it if `rm -rf` is detected:
134
+
135
+ ```toml
136
+ [[hooks]]
137
+ event = "PreToolUse"
138
+ matcher = "Bash"
139
+ command = "node ~/.kimi-code/hooks/block-dangerous-bash.mjs"
140
+ timeout = 5
141
+ ```
142
+
143
+ ```js
144
+ // block-dangerous-bash.mjs
145
+ // Read event data passed by the CLI from stdin
146
+ let input = '';
147
+ process.stdin.on('data', (chunk) => { input += chunk; });
148
+ process.stdin.on('end', () => {
149
+ const payload = JSON.parse(input); // Parse event data
150
+ const command = payload.tool_input?.command ?? '';
151
+
152
+ if (command.includes('rm -rf')) {
153
+ // Explain the blocking reason via stderr; exit code 2 means block
154
+ console.error('Dangerous command detected, blocked');
155
+ process.exit(2);
156
+ }
157
+ // Normal exit (exit code 0) means allow
158
+ });
159
+ ```
160
+
161
+ After blocking, Kimi Code CLI writes the blocking reason back into the context, and the model can use this to choose a safer alternative.
162
+
163
+ ::: warning Note
164
+ This example only demonstrates the blocking mechanism and is not a production-grade security parser. Real scenarios are better served by whitelists, or a dedicated shell parser to handle quoting, variable expansion, and multi-command sequences.
165
+ :::
166
+
167
+ ## Next steps
168
+
169
+ - [Configuration](#configuration) — Full field reference for `[[hooks]]` in `config.toml`
170
+ - [Agents and sub-agents](./agents.md) — Use the `SubagentStop` event to trigger notifications after a sub-agent completes
docs/en/customization/mcp.md ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Model Context Protocol
2
+
3
+ [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) is an open protocol that lets models safely call tools exposed by external processes or services: reading GitHub issues, querying databases, or operating the local file system. Kimi Code CLI acts as an MCP client to connect these external tools and exposes them to the Agent alongside built-in tools (`Read`, `Bash`, `Grep`, etc.) with no behavioral difference.
4
+
5
+ MCP tool results can include text (`content`) and structured data (`structuredContent`). Kimi Code CLI makes both available to the agent and omits the structured copy only when it can confirm that a text block already contains the same complete JSON value. Text summaries and media do not replace structured records.
6
+
7
+ Kimi Code CLI preserves embedded MCP attachments that cannot be delivered directly because of format or size limits. Embedded images, audio, and video are saved even when they can be delivered unchanged, because provider conversion or later history reduction may omit them. Session-attachment readers remain available without workspace filesystem access when the model supports the corresponding content. Originals are retained in the session's media storage instead of an evictable image cache. Saved originals, including images preserved during compression, have absolute paths and stable `kimi-file://` references. Pass a reference as the `path` to `Read` or `ReadMediaFile`; bytes are read from the current session's storage even when the workspace runtime cannot access it. Pagination keeps the reference, including after a fork. For binary formats that `Read` cannot open, its error includes a server-local path when available; an external converter must have access to that filesystem. Text attachments such as CSV, HTML, JSON, and plain SVG use readable extensions.
8
+
9
+ Attachment paths and compression details share the tool-output budget. Large lists are saved to a text file, with a short pointer that remains visible when accompanying text is shortened; the agent can pass the list’s `kimi-file://` reference to `Read` and page through it. Canceling the tool stops subsequent attachment processing and signals active writes. If decoding or saving fails, the result explicitly reports that the original could not be preserved while retaining other usable output. Resource links are not automatically downloaded.
10
+
11
+ ## Connection Methods
12
+
13
+ Kimi Code CLI supports three MCP server connection methods:
14
+
15
+ - **stdio**: The CLI starts the local MCP server as a child process and communicates via standard input/output. Suitable for local command-line tools.
16
+ - **HTTP**: The CLI connects to an already-running HTTP endpoint. Suitable for remote services or processes that need to run persistently.
17
+ - **SSE**: The CLI connects to a legacy HTTP+SSE endpoint (Server-Sent Events, a streaming HTTP mechanism). Prefer HTTP for new MCP servers, but use `transport: "sse"` when a service still exposes only the older SSE transport.
18
+
19
+ ## Configuration
20
+
21
+ MCP server configuration is written in `mcp.json`, at two levels:
22
+
23
+ - **User level**: `~/.kimi-code/mcp.json` (or `$KIMI_CODE_HOME/mcp.json`), shared across projects
24
+ - **Project level**: `.kimi-code/mcp.json` in the working directory, effective only for the current repository
25
+
26
+ Entries with the same name: the project-level entry takes precedence and overrides the user-level entry.
27
+
28
+ Run `/mcp-config` in the TUI to interactively add, edit, or delete servers without manually editing the JSON file. Run `/mcp` to view the connection status of all current servers.
29
+
30
+ Deleting a server from the configuration does not interrupt open sessions: the server stays listed in `/mcp` as `removed`, its tools remain visible there, and calls to them fail with a removal notice, while new sessions do not register the tools at all. Conversely, a server added mid-session by editing `mcp.json` or installing a plugin is not registered in already-open sessions; it only joins sessions created later.
31
+
32
+ When Kimi Code finds project-level MCP servers in an untrusted folder, it shows each server's transport and launch target in the workspace trust prompt. The prompt defaults to `Trust this folder`; review the listed command and arguments or remote URL before confirming. Trusting the folder enables the project-level MCP servers for that workspace.
33
+
34
+ Structure of `mcp.json`:
35
+
36
+ ```json
37
+ {
38
+ "mcpServers": {
39
+ "filesystem": {
40
+ "command": "npx",
41
+ "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
42
+ },
43
+ "linear": {
44
+ "url": "https://mcp.linear.app/mcp"
45
+ },
46
+ "legacy-events": {
47
+ "transport": "sse",
48
+ "url": "https://mcp.example.com/sse"
49
+ }
50
+ }
51
+ }
52
+ ```
53
+
54
+ Entries with a `command` field are stdio servers; entries with a `url` field and no `transport` are HTTP servers. For legacy SSE servers, set `transport` to `"sse"` explicitly.
55
+
56
+ Optional fields:
57
+
58
+ | Field | Type | Applies to | Description |
59
+ | --- | --- | --- | --- |
60
+ | `env` | `Record<string, string>` | stdio | Environment variables injected into the child process |
61
+ | `cwd` | `string` | stdio | Working directory for the child process |
62
+ | `headers` | `Record<string, string>` | HTTP, SSE | Static request headers appended to every request |
63
+ | `bearerTokenEnvVar` | `string` | HTTP, SSE | Name of an environment variable that contains a bearer token |
64
+ | `enabled` | `boolean` | All | Set to `false` to disable this server |
65
+ | `deferred` | `boolean` | All | Experimental: set to `true` to let the model load this server's tools on demand. Defaults to `false` (always exposed inline). Prerequisites and behavior: [Loading tools on demand](#loading-tools-on-demand) |
66
+ | `startupTimeoutMs` | `number` | All | Connection timeout from `1` to `2147483647` milliseconds; default `30000` |
67
+ | `toolTimeoutMs` | `number` | All | Timeout from `1` to `2147483647` milliseconds for a single tool call |
68
+ | `enabledTools` | `string[]` | All | Tool allowlist |
69
+ | `disabledTools` | `string[]` | All | Tool blocklist |
70
+
71
+ You do not have to set the connection timeout or the single tool-call timeout per server: `[mcp] startup_timeout_ms` / `[mcp] tool_timeout_ms` in `config.toml` or the `KIMI_MCP_STARTUP_TIMEOUT_MS` / `KIMI_MCP_TOOL_TIMEOUT_MS` environment variables change the global defaults. Precedence is: per-server field > environment variable > `config.toml` > built-in default. See [Configuration files](../configuration/config-files.md#mcp).
72
+
73
+ HTTP and SSE servers support providing static credentials via `headers` or `bearerTokenEnvVar`. When OAuth is needed, run `/mcp-config login <server-name>` to complete browser-based authorization.
74
+
75
+ Plugins can also declare MCP servers in their manifest. Servers declared by a plugin are enabled by default and can be disabled or re-enabled in `/plugins`: disabling or removing one makes calls from open sessions fail with a removal notice, and adding or enabling a server connects it in open sessions right away. See [Plugins](./plugins.md#mcp-servers-in-plugins) for details.
76
+
77
+ ::: warning Note
78
+ stdio entries in a project-level `.kimi-code/mcp.json` execute local commands when a session starts. Only enable these in repositories you trust.
79
+ :::
80
+
81
+ ## Loading tools on demand
82
+
83
+ By default, every tool of a server goes straight into the model's top-level tool list; with many connected servers — or a single server that exposes many tools — those definitions occupy context for the whole session. Marking a server as deferred keeps its tools out of the top-level list: the model first sees a manifest of loadable tools, loads full definitions on demand through the built-in `select_tools` tool, and can call them in the same turn once loaded.
84
+
85
+ Loading tools on demand is experimental and takes effect only when both prerequisites are met:
86
+
87
+ - The `tool-select` experimental flag is on: set `KIMI_CODE_EXPERIMENTAL_TOOL_SELECT=1`, or write `tool-select = true` under `[experimental]` in `config.toml`; the master switch `KIMI_CODE_EXPERIMENTAL_FLAG=1` enables it too.
88
+ - The current model declares the `dynamically_loaded_tools` capability: official models declare it automatically; for other models, add it to `capabilities` in `config.toml` — see [Configuration files](../configuration/config-files.md#models).
89
+
90
+ With both prerequisites met, set `deferred: true` on the server entry in `mcp.json`:
91
+
92
+ ```json
93
+ {
94
+ "mcpServers": {
95
+ "github": {
96
+ "url": "https://mcp.example.com/mcp",
97
+ "deferred": true
98
+ }
99
+ }
100
+ }
101
+ ```
102
+
103
+ Servers without `deferred` are unaffected and always exposed inline; when a prerequisite is missing, the field is ignored with the same result. The authentication tool exposed by an OAuth server before authorization completes follows the same field.
104
+
105
+ ## Tool Naming and Permissions
106
+
107
+ MCP tools are named in the format `mcp__<server>__<tool>`, for example `mcp__github__create_issue`. Permission rules support `*` and `**` wildcards, for example `mcp__github__*` matches all tools under that server. MCP tool parameters are not included in permission matching.
108
+
109
+ Calls that do not match any permission rule trigger an approval request. Selecting "Approve for this session" in the approval dialog automatically allows subsequent calls of the same kind within the current session.
110
+
111
+ You can also pre-configure permanent rules in `[[permission.rules]]` in `config.toml`:
112
+
113
+ ```toml
114
+ [[permission.rules]]
115
+ decision = "allow"
116
+ pattern = "mcp__github__*"
117
+
118
+ [[permission.rules]]
119
+ decision = "deny"
120
+ pattern = "mcp__filesystem__write_file"
121
+ ```
122
+
123
+ For the full permission rule syntax, see [Configuration files](../configuration/config-files.md#permission).
124
+
125
+ ## Security
126
+
127
+ When connecting to external MCP servers, be aware of:
128
+
129
+ - Only connect to servers from trusted sources
130
+ - Verify that tool names and parameters look reasonable in approval requests
131
+ - Keep manual approval for high-risk tools (file writes, command execution, etc.); avoid using `mcp__*` wildcards to allow all tools at once
132
+
133
+ ::: warning Note
134
+ In [Ask When Needed mode](../guides/interaction.md#the-three-permission-modes), MCP tool calls are automatically approved. Only use this mode when you fully trust the MCP servers you have connected.
135
+ :::
136
+
137
+ ## Next steps
138
+
139
+ - [Plugins](./plugins.md) — Declare MCP servers in a plugin manifest to package and distribute them together
140
+ - [Configuration files](../configuration/config-files.md#permission) — Full field reference for permission rules
docs/en/customization/plugins.md ADDED
@@ -0,0 +1,500 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Plugins
2
+
3
+ Plugins package reusable Kimi Code CLI capabilities into installable units: they can add [Agent Skills](./skills.md), custom [agents](./agents.md), automatically load a specified Skill at session start, contribute system-prompt instructions, and declare MCP servers to provide real tool capabilities. They are ideal for sharing workflows with a team, connecting to external services, or installing extensions from the [official plugins](#official-plugins).
4
+
5
+ ## Installation and Management
6
+
7
+ Run `/plugins` in the TUI to open the plugin manager. It is a single panel with four tabs, switched with `Tab` / `Shift-Tab`:
8
+
9
+ - **Installed**: Manage installed plugins
10
+ - **Official**: Kimi-maintained marketplace plugins
11
+ - **Curated**: Third-party plugins from Kimi partners in the default marketplace
12
+ - **Custom**: Install from a URL
13
+
14
+ Common keys:
15
+
16
+ | Key | Action |
17
+ | --- | --- |
18
+ | `Tab` / `Shift-Tab` | Switch between the Installed / Official / Curated / Custom tabs |
19
+ | `Space` | Enable or disable the selected installed plugin (Installed tab) |
20
+ | `D` | Remove the selected installed plugin (Installed tab) |
21
+ | `M` | Manage MCP servers for the selected plugin (Installed tab) |
22
+ | `R` | Reload `installed.json` and all manifests (Installed tab) |
23
+ | `Enter` | Installed: update if available, or view details · Official/Curated: install or update · Custom: install |
24
+ | `I` | View plugin details (Installed tab) |
25
+ | `Esc` | Go back or cancel |
26
+
27
+ You can also use slash commands directly:
28
+
29
+ | Command | Description |
30
+ | --- | --- |
31
+ | `/plugins` | Open the interactive plugin manager |
32
+ | `/plugins list` | List installed plugins |
33
+ | `/plugins install <path-or-url>` | Install from a local directory, zip URL, or GitHub repository URL |
34
+ | `/plugins marketplace [source]` | Browse the official marketplace, or pass a custom marketplace JSON path or URL |
35
+ | `/plugins info <id>` | View plugin details and diagnostics |
36
+ | `/plugins enable <id>` | Enable a plugin |
37
+ | `/plugins disable <id>` | Disable a plugin |
38
+ | `/plugins remove <id>` | Remove a plugin (requires confirmation) |
39
+ | `/plugins reload` | Reload `installed.json` and all plugin manifests |
40
+ | `/plugins mcp enable <id> <server>` | Enable an MCP server declared by a plugin |
41
+ | `/plugins mcp disable <id> <server>` | Disable an MCP server declared by a plugin |
42
+
43
+ ### Installing from GitHub
44
+
45
+ Use `/plugins install <url>` to install directly from a GitHub repository. Four URL forms are supported:
46
+
47
+ - `https://github.com/<owner>/<repo>`: Install the latest release; falls back to the default branch if no release exists
48
+ - `https://github.com/<owner>/<repo>/tree/<ref>`: Install a specific branch, tag, or short commit SHA
49
+ - `https://github.com/<owner>/<repo>/releases/tag/<tag>`: Pin to a specific tag
50
+ - `https://github.com/<owner>/<repo>/commit/<sha>`: Pin to a specific commit
51
+
52
+ Network requests only go through `github.com` redirects and `codeload.github.com` downloads; `api.github.com` is not called.
53
+
54
+ ### Notes
55
+
56
+ - Plugin changes apply after `/reload` or in new sessions. After installing, enabling/disabling, or removing a plugin, run `/reload` or `/new`; the current session will not update.
57
+ - Local installations are copied to `$KIMI_CODE_HOME/plugins/managed/<id>/`, and the CLI always runs from this managed copy. Editing the original source directory after installation has no effect; you must reinstall.
58
+ - Removing a plugin only deletes the installation record; the managed copy and original source files remain on disk.
59
+ - Plugins are currently installed per-user and apply to all projects; project-level installation scope is not yet supported.
60
+
61
+ ### Custom marketplace JSON
62
+
63
+ Pass a custom marketplace JSON path or URL to `/plugins marketplace <source>`, or set [`KIMI_CODE_PLUGIN_MARKETPLACE_URL`](../configuration/env-vars.md) to override the default catalog. Each entry in the `plugins` array needs an `id` and a `source` (local path, zip URL, or GitHub URL):
64
+
65
+ ```json
66
+ {
67
+ "version": "2",
68
+ "plugins": [
69
+ {
70
+ "id": "my-plugin",
71
+ "displayName": "My Plugin",
72
+ "source": "./my-plugin"
73
+ }
74
+ ]
75
+ }
76
+ ```
77
+
78
+ ## Official Plugins
79
+
80
+ Official plugins are plugins and built-in product capabilities maintained by Kimi. There are currently three:
81
+
82
+ - **[Kimi Datasource](#kimi-datasource)**: Query financial market data, financial news, macroeconomic indicators, corporate registration records, academic literature, Chinese laws and regulations, and official data from intergovernmental organizations in natural language
83
+ - **[Kimi Browser Extension](#kimi-browser-extension)**: Let AI drive your own browser to get web tasks done
84
+ - **[Kimi Computer Use](#kimi-computer-use)**: Let AI operate your desktop apps (macOS and Windows)
85
+
86
+ ### Installation and Upgrade
87
+
88
+ All official plugins share the same installation and upgrade flow:
89
+
90
+ 1. Run `/plugins` and press `Tab` to select **Official**
91
+ 2. Find the plugin you want and press `Enter` to install
92
+ 3. After installation completes, run `/reload` or `/new` to activate it
93
+
94
+ ::: info Note
95
+ Kimi Browser Extension installs in two parts: after the steps above, you also need to [install the browser extension](#install-the-browser-extension) before it works.
96
+ :::
97
+
98
+ Official plugins do not update automatically. When an update is available, you'll be prompted the next time you use the old version. To upgrade, repeat the installation steps above.
99
+
100
+ ### Kimi Datasource <Badge type="tip" text="v3.4.0" />
101
+
102
+ Kimi Datasource is the official Kimi Code data plugin, letting you query financial market data, financial news, macroeconomic indicators, corporate registration records, academic literature, Chinese laws and regulations, and official data from intergovernmental organizations in natural language. No manual API calls or data accounts required.
103
+
104
+ Sources include authoritative institutions and leading databases such as the World Bank, IMF, OECD, FRED, WHO, FAO, the National Bureau of Statistics of China, Wind, S&P Capital IQ, SEC EDGAR, Caixin, Xinhua Finance, and Hundsun Juyuan, all traceable to their original publishers.
105
+
106
+ You must first complete OAuth login with a Kimi Code account via `/login`; data queries consume your Kimi Code plan quota.
107
+
108
+ #### How to use
109
+
110
+ 1. Describe your need in natural language, and Kimi Code will automatically invoke the data capabilities
111
+ 2. Explicitly trigger the data query skill with `/skill:kimi-datasource`
112
+
113
+ #### What you can do
114
+
115
+ ::: details **Live market research** — Want to run a quantitative analysis on a stock?
116
+ Pull three years of daily closing prices, MACD, and KDJ signals in a single query, no third-party data platforms needed.
117
+ :::
118
+
119
+ ::: details **Cross-country macro comparison** — Studying supply-chain shifts across China, India, and Vietnam?
120
+ Get complete GDP growth, trade volume, and demographic time-series for multiple countries from World Bank data spanning 50+ years, all in one go.
121
+ :::
122
+
123
+ ::: details **Pre-contract risk check** — Need to vet a counterparty minutes before signing?
124
+ Type the company name and instantly get business registration, equity structure, litigation disputes, and credit blacklist status, right when you need it.
125
+ :::
126
+
127
+ ::: details **Literature review acceleration** — Tracing the research arc of RLHF for a paper?
128
+ Get the most-cited papers, key authors, and core findings in seconds, so your literature review outline takes shape in half the time.
129
+ :::
130
+
131
+ ::: details **On-the-spot legal lookup** — Need to confirm the statute behind a residence-right contract dispute?
132
+ Pinpoint the relevant Civil Code articles (full text, authority level, and validity) in one query, then pull a few comparable precedents to back them up, without digging through statute databases.
133
+ :::
134
+
135
+ ::: details **Institutional-grade US equity research** — Writing a deep dive on a US stock?
136
+ Pull the annual report, standardized financial metrics, top-50 holders, and consensus estimates in one go, no more juggling multiple data terminals.
137
+ :::
138
+
139
+ ::: details **Financial news and industry data** — Tracking market hotspots or policy moves?
140
+ Query Caixin's market news, bond/fund/futures data, and listed-company supply-chain relationships, plus news, policies, announcements, and market flashes from the Xinhua Finance national financial information platform. All sources are authoritative and traceable.
141
+ :::
142
+
143
+ ::: details **Standards lookup** — Need to check compliance against Chinese standards?
144
+ Look up national (GB), industry, local, and association standards by number or topic, with status and full-text entry points.
145
+ :::
146
+
147
+ #### Coverage
148
+
149
+ | Category | Scope |
150
+ |---|---|
151
+ | Stocks & financial markets | Wind, S&P Capital IQ, SEC EDGAR; A-share/HK/US quotes, indicators, financials, valuation, estimates; 8,000+ US-listed filings |
152
+ | Financial news & industry data | Caixin, Xinhua Finance; market news and flashes, company announcements, regulatory policy, bond/fund/futures data, credit-violation records, supply-chain ties |
153
+ | Macroeconomics | World Bank, IMF, OECD, FRED, China's NBS, WHO, FAO; 50+ years, 189 countries; national/provincial/municipal China indicators (GDP, trade, population, exchange rates, CPI, balance of payments) |
154
+ | China standards | National (GB), industry, local, and association standards: IDs, titles, status, details; official full text for some GB and public association standards |
155
+ | Corporate data | Registration, equity chain, legal risk, and related-entity graph for mainland Chinese companies |
156
+ | Academic literature | Millions of papers in physics, mathematics, CS, quantitative finance, economics, including preprints |
157
+ | Legal | Yuandian Legal and other leading legal databases: Chinese laws, regulations, judicial cases; statute search across authority levels; ordinary and authoritative case search |
158
+ | Smart screening | Gildata and other well-known databases: natural-language screening of stocks, funds, and fund managers; macro-industry data, research reports, announcements, news |
159
+
160
+ #### Billing and limitations
161
+
162
+ - Data queries are billed per call and consume Kimi Code account credits
163
+ - The plugin provides read-only queries; no write or trading functionality is available
164
+ - Technical indicators and real-time prices are only available during active trading hours
165
+ - AI-generated output is for reference only and does not constitute investment or business advice
166
+
167
+ <a id="kimi-webbridge"></a>
168
+
169
+ ### Kimi Browser Extension <Badge type="tip" text="v1.11.4" />
170
+
171
+ Kimi Browser Extension lets AI drive your browser directly: not an emulator, not a crawler, but the browser you use every day, with your login sessions and cookies. AI can open pages, read content, click buttons, fill in forms, and take screenshots just like you do, taking repetitive web operations off your hands. See the [Kimi Browser Extension site](https://www.kimi.com/features/webbridge) for a product overview.
172
+
173
+ #### Install the browser extension
174
+
175
+ After installing via `/plugins`, you also need the Kimi Browser Extension in your browser before AI can drive it. There are two ways to install it:
176
+
177
+ **Option 1: Install from a store (recommended)**
178
+
179
+ Open the [Chrome Web Store](https://chromewebstore.google.com/detail/kimi-webbridge/fldmhceldgbpfpkbgopacenieobmligc) or [Edge Add-ons](https://microsoftedge.microsoft.com/addons/detail/kimi-webbridge/bnlffdbcfnanfbknnlaflhlhkocccckg) page and click Add.
180
+
181
+ **Option 2: Install manually**
182
+
183
+ Use this when you can't reach the stores:
184
+
185
+ 1. [Download the extension package](https://kimi-web-img.moonshot.cn/webbridge/latest/extension/kimi-webbridge-extension.zip) and unzip it
186
+ 2. Type `chrome://extensions/` in the address bar to open the extensions page, then turn on **Developer mode** in the top-right corner
187
+
188
+ ![Turn on Developer mode](../../media/webbridge-dev-mode.jpeg)
189
+
190
+ 3. Click **Load unpacked** in the top-left corner and select the unzipped `kimi-webbridge-extension` folder
191
+
192
+ ![Load the unpacked extension](../../media/webbridge-load-unpacked.jpeg)
193
+
194
+ 4. Once installed, the Kimi Browser Extension icon appears in the browser toolbar. Seeing the icon means the installation succeeded, and AI can start working on web pages for you.
195
+
196
+ ![The Kimi Browser Extension icon in the browser toolbar](../../media/webbridge-install-success.jpeg)
197
+
198
+ #### What you can do
199
+
200
+ - **Web automation**: Just say what you need, and AI clicks through pages, fills in forms, reads content, and takes screenshots for you
201
+ - **Social trending research**: Automatically browse trending topics on X (Twitter), Weibo, and Xiaohongshu, open the top-liked posts one by one to screenshot and extract key viewpoints, then organize everything into a research library with topic suggestions
202
+ - **Job listing collection**: Filter positions on recruiting sites by keyword, city, and job type, and organize titles, links, companies, salaries, and application methods into a table
203
+ - **Competitive analysis**: Batch-question multiple AI products and collect their answers to build side-by-side comparison reports
204
+ - **Flight price comparison**: Query the same itinerary across multiple travel platforms, record airlines, departure/arrival times, and links sorted by price, and get recommended options
205
+
206
+ ### Kimi Computer Use <Badge type="tip" text="v0.5.4" />
207
+
208
+ Kimi Computer Use lets AI operate your desktop apps directly, clicking, dragging, scrolling, and typing. The macOS version works silently in the background without taking over your mouse (a few popup actions may still bring an app to the foreground); see [the notes below](#notes-for-the-windows-version) for how the Windows version differs.
209
+
210
+ #### Authorization (macOS)
211
+
212
+ The first time you use Kimi Computer Use after installation, it shows an authorization window. Just follow the prompts:
213
+
214
+ 1. Click **Authorize** next to **Accessibility** and **Screen Recording**, and enable both permissions in System Settings: the former lets it perform clicks, typing, and scrolling; the latter lets it read screen content and locate UI elements
215
+ 2. Turn on the **Kimi Code** switch under "Connect local agents", then restart Kimi Code for it to take effect
216
+
217
+ <div style="max-width: 380px; margin: 0 auto;">
218
+
219
+ ![Kimi Computer Use authorization window](../../media/kimi-computer-use-auth.jpeg)
220
+
221
+ </div>
222
+
223
+ #### Notes for the Windows version
224
+
225
+ The Windows version (WinCU) installs differently from the macOS one: run `/plugins install https://cdn.kimi.com/kimi-computer-use-windows/latest/kimi-cu-win-plugin.zip` in Kimi Code, then restart after installation. A few things to know before using it:
226
+
227
+ - **It may briefly take over your mouse and keyboard**: Unlike the macOS version, the Windows version cannot reliably inject input in the background; it may briefly activate the target window and use your real mouse and keyboard while performing actions
228
+ - **System requirements**: Windows 10 version 1903 (Build 18362) or later, or Windows 11, x64; a real interactive desktop session is required, and Windows Server needs Desktop Experience
229
+ - **No extra permissions needed**: Windows does not require the Accessibility and Screen Recording grants that macOS does
230
+ - **Matching privilege level**: If the target app runs as administrator, KimiCU must run at the same privilege level
231
+
232
+ #### What you can do
233
+
234
+ - **Organize and enter information**: Have AI gather scattered information into Notes, spreadsheets, or your note-taking app, instead of typing everything in by hand
235
+ - **Walk through site and app flows**: After changing a page, let AI click through the key flows and screenshot each step to confirm rendering and navigation work
236
+ - **Handle repetitive operations**: Repeatedly opening, copying, pasting, and checking can run silently in the background without taking over your mouse
237
+ - **Run fixed-step tasks**: For flows with clear steps, spell them out and AI follows along; for example, ask AI to open NetEase Cloud Music and play a specific song
238
+ - **Handle software that has no API**: Plenty of professional tools and internal systems have no CLI or API at all; what used to require your own clicking can now be handed to AI, like trimming the first three seconds off a clip in Final Cut Pro and exporting it
239
+
240
+ ::: warning Note
241
+ Don't hand it anything involving money, accounts, or publishing, such as payments and transfers, deleting important files, changing passwords, or posting content. To judge whether a task is suitable, check three things: the result is verifiable, the action is reversible, and the risk of getting it wrong is low.
242
+ :::
243
+
244
+ ## Plugin Manifest
245
+
246
+ A plugin is a directory or zip file containing a manifest. The manifest can be placed at either of the following locations:
247
+
248
+ ```text
249
+ <plugin_root>/kimi.plugin.json
250
+ <plugin_root>/.kimi-plugin/plugin.json
251
+ ```
252
+
253
+ When both files exist, `kimi.plugin.json` takes precedence.
254
+
255
+ Example:
256
+
257
+ ```json
258
+ {
259
+ "name": "kimi-finance",
260
+ "version": "1.0.0",
261
+ "description": "Finance data and analysis workflows for Kimi Code CLI",
262
+ "skills": "./skills/",
263
+ "systemPromptPath": "./SYSTEM.md",
264
+ "sessionStart": {
265
+ "skill": "using-finance"
266
+ },
267
+ "interface": {
268
+ "displayName": "Kimi Finance",
269
+ "shortDescription": "Market data and financial analysis workflows"
270
+ }
271
+ }
272
+ ```
273
+
274
+ Supported fields:
275
+
276
+ | Field | Description |
277
+ | --- | --- |
278
+ | `name` | Required; serves as the plugin id. Must match `[a-z0-9][a-z0-9_-]{0,63}` |
279
+ | `version`, `description`, `keywords`, `author`, `homepage`, `license` | Display metadata |
280
+ | `interface` | Shown in `/plugins`: `displayName`, `shortDescription`, `longDescription`, `developerName`, `websiteURL` |
281
+ | `skills` | One or more `./` paths within the plugin root; if omitted, root `SKILL.md` is the single Skill root |
282
+ | `agents` | One or more `./` paths within the plugin root, pointing to [agent files](./agents.md#custom-agents); if omitted, `agents/` is auto-discovered |
283
+ | `sessionStart.skill` | Loads the specified plugin Skill into the main Agent when a new or resumed session starts |
284
+ | `skillInstructions` | Additional instructions appended whenever a Skill from this plugin is loaded |
285
+ | `systemPrompt` | Inline instructions contributed to the agent's system prompt while the plugin is enabled |
286
+ | `systemPromptPath` | A `./` path to a UTF-8 text file; content is appended after `systemPrompt` when both are present |
287
+ | `mcpServers` | MCP server declarations; enabled by default, can be disabled from `/plugins` |
288
+ | `hooks` | Hook rules run on lifecycle events while enabled; see [Hooks in Plugins](#hooks-in-plugins) |
289
+ | `commands` | One or more `./` paths to a directory or `.md` file; registers the Markdown files inside as slash commands. See [Plugin Slash Commands](#plugin-slash-commands) |
290
+
291
+ Unsupported runtime fields such as `tools`, `apps`, `inject`, and `configFile` appear as diagnostics and are ignored.
292
+
293
+ ### System-prompt instructions
294
+
295
+ Plugins inject instructions into the agent's system prompt through the `systemPrompt` and `systemPromptPath` fields. This section covers three parts: writing format and read timing, size limits, and the differences between the two engines.
296
+
297
+ ### Writing format and read timing
298
+
299
+ Use `systemPrompt` for a short inline instruction, or `systemPromptPath` to keep longer instructions in a file inside the plugin root. If both fields are present, the inline text appears first, followed by the file content. The file content is read when the plugin is installed or reloaded, so edits take effect only after `/plugins reload`. For example:
300
+
301
+ ```json
302
+ {
303
+ "name": "code-review",
304
+ "systemPromptPath": "./SYSTEM.md"
305
+ }
306
+ ```
307
+
308
+ The built-in agent prompt includes instructions from enabled plugins automatically. A custom `SYSTEM.md` or agent file owns its template, so include `${plugin_sections}` where plugin-contributed instructions should appear. If the custom template includes `${base_prompt}` and that effective default already contains the plugin block, do not add `${plugin_sections}` again. See [Custom agents and SYSTEM.md](./agents.md#overriding-the-main-agents-system-prompt-with-systemmd) for the complete variable table.
309
+
310
+ ### Size limits
311
+
312
+ Each field (the inline `systemPrompt` and the `systemPromptPath` file) is limited to 32 KB (UTF-8 bytes): oversized content is ignored and reported in the plugin diagnostics. Across all enabled plugins, one prompt build injects at most 64 KB of instructions; contributions beyond the budget are skipped with a warning, including a single plugin whose inline text and file together exceed that budget.
313
+
314
+ ### Differences between the two engines
315
+
316
+ System-prompt contributions take effect on every Kimi Code surface: the interactive TUI, `kimi -p`, and `kimi web` all run on the v2 engine.
317
+
318
+ <details>
319
+ <summary>Instruction refresh behavior under the two engines</summary>
320
+
321
+ New sessions and newly created agents read the contributions from the plugins currently enabled. An in-flight request keeps its existing system prompt. `/plugins reload` refreshes the plugin skill list and requests prompt rebuilds for live agents; use it when you need the change to converge deliberately before the next turn.
322
+
323
+ On the v2 engine, installing, enabling, disabling, or removing a plugin updates the catalog immediately, and a later prompt rebuild (for example after compaction or a tool-policy change) may pick up the new sections. The legacy engine keeps each live session's plugin snapshot until `/plugins reload` or a new session. A resumed session starts from its persisted prompt, and later rebuilds follow the engine-specific behavior above. Toggling a plugin's MCP server does not change system-prompt sections.
324
+
325
+ </details>
326
+
327
+ ## Plugin Slash Commands
328
+
329
+ Slash commands save a prompt you use often as a `/command`, so you can trigger it by typing the command instead of retyping the whole thing.
330
+
331
+ Here is a minimal end-to-end example. The plugin's directory structure:
332
+
333
+ ```text
334
+ kimi-finance/
335
+ kimi.plugin.json
336
+ commands/
337
+ report.md
338
+ ```
339
+
340
+ In the manifest (`kimi.plugin.json`), the `commands` field points to where the command files live:
341
+
342
+ ```json
343
+ {
344
+ "name": "kimi-finance",
345
+ "version": "1.0.0",
346
+ "commands": "./commands/"
347
+ }
348
+ ```
349
+
350
+ The command file `commands/report.md`. The block between the two `---` lines at the top is frontmatter (metadata describing the command); everything below is the prompt sent to the Agent:
351
+
352
+ ```markdown
353
+ ---
354
+ description: Pull and summarize a stock's latest financials
355
+ ---
356
+
357
+ Pull the latest financials for $ARGUMENTS and summarize revenue, profit, and key risks.
358
+ ```
359
+
360
+ After installing and enabling the plugin, type this in the chat:
361
+
362
+ ```text
363
+ /kimi-finance:report TSLA
364
+ ```
365
+
366
+ Kimi replaces `$ARGUMENTS` in the body with `TSLA`, then runs the prompt. The three details below cover each step.
367
+
368
+ ### Declaring Commands (the `commands` field)
369
+
370
+ `commands` takes a single `./` path or an array of paths, each pointing to a directory or `.md` file inside the plugin root:
371
+
372
+ - Pointing at a **directory**: collects every `.md` file under it recursively; each becomes one command.
373
+ - Pointing at a **single `.md` file**: registers just that one.
374
+ - Pointing at a non-`.md` file or a missing path: appears as a diagnostic (shown in the `/plugins` panel) and is ignored.
375
+
376
+ ### Writing a Command File
377
+
378
+ A command file has two parts: an optional **frontmatter** (the metadata between the two `---` lines at the top, where you set `name` and `description`) and the **body** (the prompt after the `---`). When a field is omitted, it falls back as follows:
379
+
380
+ - `name` (the command name): derived from the file's path relative to the declared `commands` path (without `.md`, using `/` separators), e.g. `commands/frontend/component.md` → `frontend/component`. A `name` set in the frontmatter takes precedence.
381
+ - `description` (shown in the command list): the first non-empty line of the body (truncated past 240 characters); if the body is empty too, `No description provided.` is shown.
382
+
383
+ ### Running Commands and Passing Arguments
384
+
385
+ Commands are prefixed with the plugin id (their namespace) and registered as `<plugin>:<command>`, so the command above is actually `/kimi-finance:report`. This keeps same-named commands from different plugins from colliding.
386
+
387
+ Whatever you type after the command replaces `$ARGUMENTS` in the body (above, `TSLA` replaces `$ARGUMENTS`). If the body has no `$ARGUMENTS` but you pass arguments anyway, they are not dropped; they are appended to the end of the body as `ARGUMENTS: <what you typed>`.
388
+
389
+ ## Skills and Session Start
390
+
391
+ Plugin Skills use the same `SKILL.md` format as ordinary [Agent Skills](./skills.md). A typical directory structure:
392
+
393
+ ```text
394
+ my-plugin/
395
+ kimi.plugin.json
396
+ skills/
397
+ using-my-plugin/
398
+ SKILL.md
399
+ another-workflow/
400
+ SKILL.md
401
+ ```
402
+
403
+ `sessionStart.skill` loads a plugin Skill into the main Agent at session start, making it suitable for initialization instructions, workflow rules, or mapping terminology from other tools to Kimi Code CLI. It only injects text; it does not execute code.
404
+
405
+ Regardless of how a Skill is loaded (`sessionStart.skill`, `/skill:<name>`, or automatic model invocation), `skillInstructions` appears alongside that plugin's Skill.
406
+
407
+ ## Plugin Agents
408
+
409
+ A plugin can ship custom agents: declare one or more `./` directories in the manifest's `agents` field (or simply place an `agents/` directory under the plugin root). The agent files inside use the same format as [custom agents](./agents.md#custom-agents) and, while the plugin is enabled, are discovered automatically and can be delegated to as sub-agents by the main Agent.
410
+
411
+ ```text
412
+ my-plugin/
413
+ kimi.plugin.json
414
+ agents/
415
+ reviewer.md
416
+ ```
417
+
418
+ Plugin agents rank below every other file source: on a name collision, user-level, extra, project-level, and `--agent-file` agents all win over the plugin-provided one, and replacing a built-in agent still requires an explicit `override: true` in the frontmatter. After installing, enabling, disabling, or removing a plugin, the agent list refreshes in a new session (or on `/reload`); on the v2 engine the live session also refreshes after `/plugins reload`.
419
+
420
+ ## MCP Servers in Plugins
421
+
422
+ When a plugin needs real tool capabilities, it can declare `mcpServers` in its manifest, reusing the [MCP](./mcp.md) schema.
423
+
424
+ Stdio server (local command):
425
+
426
+ ```json
427
+ {
428
+ "mcpServers": {
429
+ "finance": {
430
+ "command": "uvx",
431
+ "args": ["kimi-finance-mcp"]
432
+ }
433
+ }
434
+ }
435
+ ```
436
+
437
+ HTTP server (remote service):
438
+
439
+ ```json
440
+ {
441
+ "mcpServers": {
442
+ "docs": {
443
+ "url": "https://example.com/mcp"
444
+ }
445
+ }
446
+ }
447
+ ```
448
+
449
+ For stdio servers, `command` can be a command on `PATH` or a path starting with `./` within the plugin root directory. `cwd` likewise must start with `./` and be within the plugin root directory; otherwise the server is ignored.
450
+
451
+ Plugin MCP servers start after `/reload` or in new sessions. To enable or disable a server:
452
+
453
+ ```sh
454
+ /plugins mcp disable kimi-finance finance
455
+ /reload
456
+
457
+ /plugins mcp enable kimi-finance finance
458
+ /reload
459
+ ```
460
+
461
+ ## Hooks in Plugins
462
+
463
+ A plugin can declare hook rules in its manifest that run on lifecycle events while the plugin is enabled. Each entry uses the same fields as a [`[[hooks]]` rule in `config.toml`](./hooks.md#configuration) (`event`, `matcher`, `command`, `timeout`):
464
+
465
+ ```json
466
+ {
467
+ "hooks": [
468
+ {
469
+ "event": "PreToolUse",
470
+ "matcher": "Bash",
471
+ "command": "node ./hooks/check-bash.mjs",
472
+ "timeout": 5
473
+ }
474
+ ]
475
+ }
476
+ ```
477
+
478
+ Plugin hooks reuse the same mechanism as global hooks. See [Hooks](./hooks.md) for the event list, the stdin JSON payload, and how exit codes and return values affect the main flow. The differences are:
479
+
480
+ - A plugin's hooks are active only while the plugin is **enabled**; disabling the plugin stops its hooks.
481
+ - Each hook runs with its working directory set to the plugin root, so `command` can use `./` paths inside the plugin.
482
+ - The hook process receives two extra environment variables: `KIMI_CODE_HOME` and `KIMI_PLUGIN_ROOT` (the plugin root directory).
483
+
484
+ Installing a plugin never runs its hooks by itself. They only fire when their matching event occurs while the plugin is enabled.
485
+
486
+ ## Security Model
487
+
488
+ Plugins have a limited loading scope. The following operations do not occur during installation or session startup:
489
+
490
+ - Command-type plugin tools and legacy tool runtimes are not executed
491
+ - All paths must remain within the plugin root directory after symbolic link resolution
492
+ - MCP servers of enabled plugins start after `/reload` or in new sessions and can be disabled at any time from `/plugins`
493
+ - Broken manifests or unsafe paths appear in `/plugins info <id>` diagnostics and do not affect other sessions
494
+
495
+ ## Next steps
496
+
497
+ - [Agent Skills](./skills.md) — Learn the `SKILL.md` format and write Skills that ship with your plugins
498
+ - [Custom agents](./agents.md) — Agent file format and directory-scope precedence
499
+ - [MCP](./mcp.md) — The schema that MCP server declarations in plugins reuse
500
+ - [Hooks](./hooks.md) — The global hook mechanism that plugin hooks reuse
docs/en/customization/skills.md ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Agent Skills
2
+
3
+ Agent Skills are a lightweight mechanism for extending model capabilities in Kimi Code CLI. A Skill is a Markdown document with YAML frontmatter that describes a specialized area of knowledge or a workflow: a project's code style guidelines, a PR review process, or a commit message format.
4
+
5
+ Compared to pasting the same instructions into a prompt every time, Skills offer the advantage of keeping content in a file, enabling reuse across projects and teams, allowing instant loading via a slash command, and letting the model invoke them automatically when needed.
6
+
7
+ ## Creating a Skill
8
+
9
+ Skill files must be placed in a [known scan directory](#skill-locations). Two file structures are supported:
10
+
11
+ - **Directory form (recommended)**: Create a subdirectory under the skills directory with the main file named `SKILL.md`, and place scripts, reference material, and other supporting files alongside it.
12
+ - **Flat form**: Skip the subdirectory and drop a single `.md` file directly into the skills directory — handy for simple Skills that need no supporting files.
13
+
14
+ Both structures register a Skill; they differ only in how the files are organized:
15
+
16
+ ```text
17
+ skills/
18
+ ├── review-pr/ # Directory form → Skill name review-pr
19
+ │ ├── SKILL.md # Main file
20
+ │ └── checklist.md # Supporting file, referenced via ${KIMI_SKILL_DIR}
21
+ └── commit.md # Flat form → Skill name commit
22
+ ```
23
+
24
+ How the Skill name is derived:
25
+
26
+ - Directory form: from the required frontmatter `name` field (see the table below); by convention the subdirectory carries the same name — `review-pr/SKILL.md` with `name: review-pr` registers as `review-pr`.
27
+ - Flat form: `name` may be omitted, falling back to the filename without the `.md` extension — `commit.md` registers as `commit`. The extension is stripped only from the registered Skill name; the file on disk must keep its `.md` extension to be picked up by the scanner, so don't actually create an extensionless `commit` file.
28
+ - When both `<name>/SKILL.md` and `<name>.md` exist in the same directory, the directory form wins and the flat file is ignored.
29
+
30
+ Two limitations of the flat form:
31
+
32
+ - Only `.md` files placed directly at the top level of a skills directory are recognized; loose `.md` files inside subdirectories (other than `SKILL.md`) are not treated as Skills.
33
+ - A flat Skill has no directory of its own, so `${KIMI_SKILL_DIR}` points at the skills directory itself — switch to the directory form whenever the Skill needs supporting files.
34
+
35
+ ### File Format
36
+
37
+ `SKILL.md` consists of two parts: YAML frontmatter and a Markdown body:
38
+
39
+ ```markdown
40
+ ---
41
+ name: code-style
42
+ description: Project code style guidelines defining naming, indentation, comments, and file organization
43
+ type: prompt
44
+ whenToUse: When the user asks me to write, modify, or review project source code
45
+ disableModelInvocation: false
46
+ arguments:
47
+ - target
48
+ - mode
49
+ ---
50
+
51
+ Please handle code according to the following guidelines:
52
+
53
+ - Use 2-space indentation
54
+ - Variable names use `camelCase`, type names use `PascalCase`
55
+ - Public functions must have TSDoc comments
56
+ - Lines must not exceed 100 characters
57
+ ```
58
+
59
+ ### Frontmatter Fields
60
+
61
+ | Field | Description |
62
+ | --- | --- |
63
+ | `name` | Skill name (case-insensitive). Required in directory-form `SKILL.md`; flat `.md` falls back to the filename without the `.md` extension |
64
+ | `description` | One-line summary the model uses to decide when to invoke. Required in directory-form `SKILL.md`; flat `.md` falls back to the first non-empty body line (up to 240 characters) |
65
+ | `type` | Skill type: `prompt` (default), `inline` (same as `prompt`), `flow` (manual invocation only). Other values are skipped |
66
+ | `whenToUse` | Description of when the Skill should be triggered. Also accepts `when-to-use` and `when_to_use` |
67
+ | `disableModelInvocation` | If `true`, blocks automatic model invocation. Also accepts `disable-model-invocation`, `disable_model_invocation` |
68
+ | `arguments` | Named parameters; a string array or whitespace-separated string (e.g., `arguments: target mode`). Once declared, readable in the body as `$<name>` |
69
+
70
+ ::: warning Note
71
+ In a directory-form `SKILL.md`, both `name` and `description` **must** be explicitly provided. Omitting either one will cause parsing to fail.
72
+ :::
73
+
74
+ ### Body Placeholders
75
+
76
+ Before the body is sent to the model, a small set of placeholders are expanded:
77
+
78
+ - `$ARGUMENTS`: The full raw argument string passed at invocation
79
+ - `$ARGUMENTS[0]`, `$ARGUMENTS[1]` and shorthand `$0`, `$1`: Positional arguments after whitespace tokenization (zero-indexed)
80
+ - `$<name>`: Named parameters declared in `arguments`
81
+ - `${KIMI_SKILL_DIR}`: The directory containing the current Skill file
82
+
83
+ Positional arguments support single and double quoting, so in `/skill:commit "fix login" patch`, `$0` expands to `fix login`. If the body contains no argument placeholders, text passed at invocation is appended to the end of the body as `\n\nARGUMENTS: <text>`.
84
+
85
+ ## Skill Locations
86
+
87
+ Kimi Code CLI scans four tiers by scope; more specific scopes take higher priority: **Project > User > Extra > Built-in**
88
+
89
+ **User level** (applies to all projects):
90
+ - `$KIMI_CODE_HOME/skills/` (default: `~/.kimi-code/skills/`)
91
+ - `~/.agents/skills/`
92
+
93
+ The Kimi-specific user Skill directory moves with `KIMI_CODE_HOME`, so isolated data roots also get isolated Kimi-specific Skills. The generic `~/.agents/skills/` directory stays under the real OS home so it can be shared across tools.
94
+
95
+ **Project level** (project root = the nearest directory containing `.git`, searching upward from the working directory):
96
+ - `.kimi-code/skills/`
97
+ - `.agents/skills/`
98
+
99
+ **Extra directories**: Declared via `extra_skill_dirs` at the top level of `config.toml`:
100
+
101
+ ```toml
102
+ extra_skill_dirs = ["~/team-skills", ".agents/team-skills"]
103
+ ```
104
+
105
+ **Built-in Skills** are distributed with the CLI and have the lowest priority. They provide out-of-the-box workflows for common tasks: configuring MCP servers, customizing the TUI theme, and editing config files. See [Built-in skill commands](../reference/slash-commands.md#built-in-skill-commands) for the full list. Those describing Kimi Code itself can be turned off with the top-level [`builtin_product_skills`](../configuration/config-files.md#top-level-fields) field.
106
+
107
+ ## Invoking a Skill
108
+
109
+ Users can invoke a Skill manually with a slash command:
110
+
111
+ ```
112
+ /skill:code-style
113
+ /skill:git-commits fix concurrency issue in login endpoint
114
+ ```
115
+
116
+ The model can also invoke a Skill automatically based on `description` and `whenToUse` (unless `disableModelInvocation` is `true` or `type` is `flow`). Skill invocations allow up to 3 levels of nesting; beyond that they are terminated.
117
+
118
+ ## Complete Example
119
+
120
+ ```markdown
121
+ ---
122
+ name: review-pr
123
+ description: Review a Pull Request according to team standards and produce a structured review report
124
+ type: prompt
125
+ whenToUse: When the user asks me to review a PR, inspect code changes, or evaluate commit quality
126
+ arguments:
127
+ - pr_ref
128
+ ---
129
+
130
+ Please review the PR the user specified: $pr_ref
131
+
132
+ 1. Fetch and read the full diff for `$pr_ref`.
133
+ 2. Check each of the following items:
134
+ - Whether corresponding test cases are included
135
+ - Whether public API documentation has been updated
136
+ - Whether new dependencies have been introduced; if so, state the reason
137
+ - Whether error handling covers edge cases
138
+ 3. Refer to the checklist in the same directory: `references/checklist.md`
139
+ 4. Produce a review report containing:
140
+ - Overall conclusion (approve / request changes / comment)
141
+ - Required changes (blocking)
142
+ - Suggested improvements (non-blocking)
143
+ - Noteworthy positives
144
+ ```
145
+
146
+ Save this as `$KIMI_CODE_HOME/skills/review-pr/SKILL.md` (or `~/.kimi-code/skills/review-pr/SKILL.md` when `KIMI_CODE_HOME` is unset), place the checklist at `references/checklist.md` in the same directory, and after starting a new session you can invoke it with `/skill:review-pr #1234`, where `#1234` is expanded into `$pr_ref`.
147
+
148
+ ## Next steps
149
+
150
+ - [Plugins](./plugins.md) — Package Skills into installable units to share with your team
151
+ - [Agents and sub-agents](./agents.md) — How Skills influence sub-agent behavior
docs/en/customization/themes.md ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Custom Themes
2
+
3
+ Kimi Code CLI can use a built-in color scheme or a custom JSON theme file. Custom files live in the themes directory and appear in `/theme` alongside the built-in choices.
4
+
5
+ ## Built-in color tokens
6
+
7
+ Custom themes can override the tokens below. The `dark` and `light` columns show the built-in values; `auto` resolves to one of those palettes at startup, and falls back to `dark` when terminal background detection is unavailable.
8
+
9
+ | Token | `dark` | `light` | What it controls |
10
+ | --- | --- | --- | --- |
11
+ | `primary` | `#4FA8FF` | `#1565C0` | The most-used color. Links, inline code, selected items in dialogs, focus borders, badges, spinners |
12
+ | `accent` | `#5BC0BE` | `#00838F` | Secondary highlight. Approval `▶` prefix, device-code box, image placeholder, panes, registry import |
13
+ | `text` | `#E0E0E0` | `#1A1A1A` | Body text. Dialog bodies, todo titles, footer model label, Markdown headings, list bullets |
14
+ | `textStrong` | `#F5F5F5` | `#1A1A1A` | Emphasized / bold text. Input dialogs, status messages |
15
+ | `textDim` | `#888888` | `#454545` | Secondary, dimmed text. Thinking, hints, completed todos, Markdown quotes, footer status bar |
16
+ | `textMuted` | `#6B6B6B` | `#5F5F5F` | Faintest text. Counters, scroll info, Markdown link URLs, code-block borders |
17
+ | `border` | `#5A5A5A` | `#737373` | Pane and editor borders, Markdown horizontal rule |
18
+ | `borderFocus` | `#E8A838` | `#92660A` | Focus / attention border, currently only the approval panel |
19
+ | `success` | `#4EC87E` | `#0E7A38` | Success state. `✓`, "enabled", completed |
20
+ | `warning` | `#E8A838` | `#92660A` | Warning state. Ask When Needed/Never Ask badges, stale markers, Plan mode hint |
21
+ | `error` | `#E85454` | `#B91C1C` | Error state. Error messages, failed tool output |
22
+ | `diffAdded` | `#4EC87E` | `#0E7A38` | Diff added lines |
23
+ | `diffRemoved` | `#E85454` | `#B91C1C` | Diff removed lines |
24
+ | `diffAddedStrong` | `#7AD99B` | `#0E7A38` | Diff intra-line changed words, added and bold |
25
+ | `diffRemovedStrong` | `#F08585` | `#B91C1C` | Diff intra-line changed words, removed and bold |
26
+ | `diffGutter` | `#6B6B6B` | `#737373` | Diff line-number gutter |
27
+ | `diffMeta` | `#888888` | `#5F5F5F` | Diff meta / hunk headers |
28
+ | `roleUser` | `#FFCB6B` | `#9A4A00` | User message bullet and text, skill-activation name |
29
+ | `shellMode` | `#BD93F9` | `#7C3AED` | Shell mode (`!`) prompt, editor border, and the echoed `$ command` line |
30
+
31
+ ## Use the custom-theme skill
32
+
33
+ You do not need to write the JSON by hand. Run the built-in `/custom-theme [extra text]` skill command to enter the custom-theme workflow; the skill can choose colors, write the file under `~/.kimi-code/themes/`, validate the hex values, and tell you how to apply it.
34
+
35
+ Example invocations:
36
+
37
+ - `/custom-theme Create a warm dark theme with amber accents.`
38
+ - `/custom-theme Make a light theme based on Solarized, but keep errors easy to see.`
39
+ - `/custom-theme Tweak my ember theme so diffs have higher contrast.`
40
+
41
+ After activation, the skill usually asks whether you want a light or dark base, what mood or palette you prefer, and whether you have exact colors to include. If you use it to edit an existing theme, make sure it reads and backs up the file before overwriting it.
42
+
43
+ ## Create a theme
44
+
45
+ Add a `.json` file to the themes directory:
46
+
47
+ - `~/.kimi-code/themes/`
48
+ - or `$KIMI_CODE_HOME/themes/` when the `KIMI_CODE_HOME` environment variable is set
49
+
50
+ Create the directory if it does not exist. **The filename is the theme name**: `ember.json` appears in `/theme` as `Custom: ember`.
51
+
52
+ A minimal theme only sets the colors you want to change; the rest fall back to the **base palette** (`dark` by default):
53
+
54
+ ```json
55
+ {
56
+ "name": "ember",
57
+ "colors": {
58
+ "primary": "#83A598",
59
+ "accent": "#FE8019"
60
+ }
61
+ }
62
+ ```
63
+
64
+ Fields:
65
+
66
+ - `name` (required): the theme identifier.
67
+ - `displayName` (optional): a human-readable name.
68
+ - `base` (optional): the built-in palette that unspecified tokens inherit, `"dark"` (default) or `"light"`. Set `"base": "light"` when you are building a **light** theme so the tokens you leave out stay readable on a light background (otherwise they fall back to the dark palette).
69
+ - `colors` (optional): the color tokens to override, each a 6-digit hex value (e.g. `#FE8019`).
70
+
71
+ Use the token names from [Built-in color tokens](#built-in-color-tokens). Any token you omit falls back to the selected base palette, so partial themes are fine:
72
+
73
+ ```json
74
+ {
75
+ "name": "just-blue",
76
+ "colors": {
77
+ "primary": "#3B82F6",
78
+ "roleUser": "#3B82F6"
79
+ }
80
+ }
81
+ ```
82
+
83
+ ## Select a theme
84
+
85
+ Two ways:
86
+
87
+ 1. **The `/theme` command** (recommended): opens the theme picker, where custom themes appear as `Custom: <filename>`. The picker **re-scans the themes directory every time it opens**, so a theme file you just added shows up **without a restart**.
88
+ 2. **[`tui.toml`](../configuration/config-files.md#tuitoml)**: set `theme` to your theme name:
89
+
90
+ ```toml
91
+ # ~/.kimi-code/tui.toml
92
+ theme = "ember"
93
+ ```
94
+
95
+ ## What happens on errors
96
+
97
+ Custom themes are designed to never get in your way:
98
+
99
+ - **An invalid color value** (not `#` followed by 6 hex digits): that one entry is silently skipped and falls back to the selected base palette; the rest of the colors still apply.
100
+ - **An unrecognized token**: ignored, with no effect on other colors.
101
+ - **A missing custom theme file or malformed JSON**: silently falls back to the built-in `dark` palette. It does not retry `auto`.
102
+
103
+ ## Editing the active theme
104
+
105
+ If you edit the theme file that is **currently active**, the change is not reloaded automatically. To apply the new colors:
106
+
107
+ - run `/reload-tui`, which reloads `tui.toml` and re-applies the current theme (including re-reading the theme file); or
108
+ - switch to another theme in `/theme` and back.
109
+
110
+ ::: warning Note
111
+ Re-selecting the **same** theme in `/theme` does not reload it (you get a "Theme unchanged" message). To reload changes to the active theme, use one of the two methods above.
112
+ :::
113
+
114
+ ## Next steps
115
+
116
+ - [Configuration files](../configuration/config-files.md#tuitoml) — Full field reference for `tui.toml`, including the `theme` option
docs/en/guides/getting-started.md ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Getting started
2
+
3
+ ## What is Kimi Code CLI
4
+
5
+ Kimi Code CLI is an AI agent that runs in the terminal, helping you carry out software development tasks and day-to-day terminal operations — reading and modifying code, running shell commands, searching files, fetching web pages, and autonomously planning and adjusting its next steps based on feedback as it works.
6
+
7
+ It fits scenarios such as:
8
+
9
+ - **Writing and modifying code**: implementing new features, fixing bugs, completing refactors
10
+ - **Understanding a project**: exploring an unfamiliar codebase and answering questions about architecture and implementation
11
+ - **Automating tasks**: batch-processing files, running builds and tests, chaining multiple scripts together
12
+
13
+ The CLI is written in TypeScript, distributed via npm, and runs on Node.js.
14
+
15
+ ## Installation
16
+
17
+ Two installation options are available: the official install script (recommended, no pre-installed Node.js required) and a global npm install.
18
+
19
+ ::: tip Before you install
20
+ Kimi Code CLI is a fully interactive TUI application. For the best visual experience, run it in a terminal with true-color and ligature support, such as [Kitty](https://sw.kovidgoyal.net/kitty/) or [Ghostty](https://ghostty.org/).
21
+ :::
22
+
23
+ ### Install script (recommended)
24
+
25
+ ::: code-group
26
+
27
+ ```sh [macOS / Linux]
28
+ curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash
29
+ ```
30
+
31
+ ```powershell [Windows (PowerShell)]
32
+ irm https://code.kimi.com/kimi-code/install.ps1 | iex
33
+ ```
34
+
35
+ :::
36
+
37
+ > On Windows, install [Git for Windows](https://gitforwindows.org/) before first launch. Kimi Code CLI uses the bundled Git Bash as its shell environment; if Git Bash is installed in a custom location, set `KIMI_SHELL_PATH` to the absolute path of `bash.exe`.
38
+
39
+ The script automatically downloads the latest release, verifies the checksum, and places the `kimi` executable on your `PATH`.
40
+
41
+ ### npm installation
42
+
43
+ Requires Node.js 22.19.0 or later:
44
+
45
+ ```sh
46
+ node --version
47
+ ```
48
+
49
+ ::: code-group
50
+
51
+ ```sh [npm]
52
+ npm install -g @moonshot-ai/kimi-code
53
+ ```
54
+
55
+ ```sh [pnpm]
56
+ pnpm add -g @moonshot-ai/kimi-code
57
+ ```
58
+
59
+ :::
60
+
61
+ ## First launch
62
+
63
+ Move into your project directory and run `kimi` to start the interactive UI:
64
+
65
+ ```sh
66
+ cd your-project
67
+ kimi
68
+ ```
69
+
70
+ To run a single instruction without entering the interactive UI, use `-p`:
71
+
72
+ ```sh
73
+ kimi -p "Take a look at this project's directory structure"
74
+ ```
75
+
76
+ To resume the previous session, add `-c`:
77
+
78
+ ```sh
79
+ kimi -c
80
+ ```
81
+
82
+ On first launch you need to configure an API source. In the interactive UI, enter `/login` to begin the login flow:
83
+
84
+ ```
85
+ /login
86
+ ```
87
+
88
+ `/login` opens a platform selector supporting two options:
89
+
90
+ - **Kimi Code (OAuth)** — device-code flow; open the link on any device, sign in, and enter the code to authorize
91
+ - **Kimi Platform API key** — enter an API key from `platform.kimi.com` or `platform.kimi.ai`
92
+
93
+ To sign out, enter `/logout` to clear the current credentials.
94
+
95
+ ::: tip Using other AI providers
96
+ If you want to connect Anthropic, OpenAI, Google, or other providers, edit `~/.kimi-code/config.toml` directly to configure the API key. See [Providers and models](../configuration/providers.md) for details. For the full reference of all config options, see [Configuration files](../configuration/config-files.md), [Environment variables](../configuration/env-vars.md), and [Configuration overrides](../configuration/overrides.md).
97
+ :::
98
+
99
+ ## Your first conversation
100
+
101
+ Once logged in, describe a task in natural language. A good starting point is to let Kimi Code CLI familiarize itself with the project:
102
+
103
+ ```
104
+ Take a look at this project's directory structure and briefly describe what each directory is for.
105
+ ```
106
+
107
+ Kimi Code CLI automatically calls file-reading, search, and other tools to browse the relevant content before responding. Read-only operations are executed automatically by default without requiring confirmation. For operations that modify files or run shell commands, it asks for your confirmation before proceeding.
108
+
109
+ You can also describe a more concrete task directly:
110
+
111
+ ```
112
+ Add a function in src/utils that converts any string to kebab-case, and add a unit test for it.
113
+ ```
114
+
115
+ Kimi Code CLI plans the steps, modifies the code, runs the tests, and tells you what it did at each step.
116
+
117
+ ::: tip Not sure what to do? Type `/help`
118
+ Type `/help` at any time to open the built-in command and keyboard shortcut panel. Use `↑`/`↓` to browse and `Esc` to close. To exit, type `/exit`, press `Ctrl-C` twice, or press `Ctrl-D` with the input box empty.
119
+ :::
120
+
121
+ ## Common commands and keyboard shortcuts
122
+
123
+ For a first-time user, the following is all you need to know:
124
+
125
+ **Session commands**
126
+
127
+ | Command | Description |
128
+ | --- | --- |
129
+ | `/new` | Start a new session, clearing the current context |
130
+ | `/sessions` | Browse session history and choose one to resume |
131
+ | `/model` | Switch the current model |
132
+ | `/compact` | Manually compress the context to free up tokens |
133
+ | `/fork` | Fork the current session into an independent copy with full history (you stay in the current session) |
134
+
135
+ **Most-used keyboard shortcuts**
136
+
137
+ | Shortcut | Description |
138
+ | --- | --- |
139
+ | `Esc` | Interrupt streaming output / close a popup |
140
+ | `Ctrl-C` | Interrupt output; press twice while idle to exit |
141
+ | `Shift-Tab` | Toggle Plan mode |
142
+ | `Ctrl-S` | Inject a message mid-stream without waiting for the current response to finish |
143
+ | `Ctrl-O` | Collapse / expand tool output and compaction summaries |
144
+
145
+ For the full list, type `/help` or visit [Slash commands reference](../reference/slash-commands.md) and [Keyboard shortcuts](../reference/keyboard.md).
146
+
147
+ ## Where data is stored
148
+
149
+ Kimi Code CLI stores its local data under `~/.kimi-code/` by default — config files, session records, logs, and the update cache. To move it elsewhere, point to a new path via the `KIMI_CODE_HOME` environment variable. For the full directory layout, see [Data locations](../configuration/data-locations.md) and [Environment variables](../configuration/env-vars.md).
150
+
151
+ ## Upgrade and uninstall
152
+
153
+ After installation, verify that the executable is ready:
154
+
155
+ ```sh
156
+ kimi --version
157
+ ```
158
+
159
+ **Upgrade**: run `kimi upgrade` — the CLI checks for the latest version and presents update options. Choose `Install update now` to upgrade based on your current install source. You can also upgrade directly via the package manager:
160
+
161
+ ```sh
162
+ npm install -g @moonshot-ai/kimi-code@latest
163
+ ```
164
+
165
+ **Uninstall**: if you installed via the script, delete the `kimi` executable. If you installed via npm:
166
+
167
+ ```sh
168
+ npm uninstall -g @moonshot-ai/kimi-code
169
+ ```
170
+
171
+ ## Next steps
172
+
173
+ - [Interaction and input](./interaction.md) — input box operations, approval flow, Plan mode, and Ask When Needed mode explained
174
+ - [Sessions and context](./sessions.md) — resuming sessions, compressing context, exporting sessions
175
+ - [Common use cases](./use-cases.md) — prompt examples for typical tasks
docs/en/guides/ides.md ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Using Kimi Code CLI in IDEs
2
+
3
+ Kimi Code CLI supports integration into IDEs via the [Agent Client Protocol (ACP)](https://agentclientprotocol.com/), letting you use AI-assisted coding directly inside your editor.
4
+
5
+ ## Prerequisites
6
+
7
+ Before configuring your IDE, make sure Kimi Code CLI is installed and you have completed the login setup.
8
+
9
+ The ACP server is exposed as the `kimi acp` subcommand. The IDE launches it as a child process and communicates over stdin/stdout using JSON-RPC. Each time the IDE creates a session, the CLI reuses its existing authentication state — no need to log in again.
10
+
11
+ ::: tip Path note
12
+ Child processes launched from an IDE GUI on macOS typically do **not** inherit the terminal shell's `PATH`. If `kimi` is not in a system directory like `/usr/local/bin`, use the absolute path in your IDE configuration. Run `which kimi` in a terminal to find the active path.
13
+ :::
14
+
15
+ ## Using Kimi Code CLI in Zed
16
+
17
+ [Zed](https://zed.dev/) is a modern editor with native ACP support.
18
+
19
+ Add the following to Zed's config file at `~/.config/zed/settings.json`:
20
+
21
+ ```json
22
+ {
23
+ "agent_servers": {
24
+ "Kimi Code CLI": {
25
+ "type": "custom",
26
+ "command": "kimi",
27
+ "args": ["acp"],
28
+ "env": {}
29
+ }
30
+ }
31
+ }
32
+ ```
33
+
34
+ Configuration fields:
35
+
36
+ - `type`: fixed value `"custom"`
37
+ - `command`: path to the Kimi Code CLI executable. If `kimi` is not on `PATH`, use the full path (e.g. `/Users/you/.local/bin/kimi`).
38
+ - `args`: startup arguments. The `acp` subcommand switches the CLI into ACP mode.
39
+ - `env`: additional environment variables; usually leave this empty. Zed injects a default environment automatically.
40
+
41
+ After saving, open a new conversation in Zed's Agent panel and it will launch a `Kimi Code CLI` ACP subprocess using the configuration above. MCP servers declared in Zed's `agent_servers` section are also forwarded to the kimi side via the ACP protocol.
42
+
43
+ ## Using Kimi Code CLI in JetBrains IDEs
44
+
45
+ JetBrains IDEs (IntelliJ IDEA, PyCharm, WebStorm, etc.) support ACP through the AI chat plugin.
46
+
47
+ If you do not have a JetBrains AI subscription, you can enable `llm.enable.mock.response` in the Registry to access the AI chat panel in ACP-only scenarios. Press Shift twice and search for "Registry" to open it.
48
+
49
+ In the AI chat panel menu, click **Configure ACP agents** and add the following configuration:
50
+
51
+ ```json
52
+ {
53
+ "agent_servers": {
54
+ "Kimi Code CLI": {
55
+ "command": "~/.local/bin/kimi",
56
+ "args": ["acp"],
57
+ "env": {}
58
+ }
59
+ }
60
+ }
61
+ ```
62
+
63
+ JetBrains is strict about the `command` field — always use an **absolute path**, which you can get by running `which kimi` in a terminal. After saving, `Kimi Code CLI` will appear in the AI chat's agent selector.
64
+
65
+ ## Using Kimi Code CLI in Paseo
66
+
67
+ [Paseo](https://paseo.sh/) is a self-hosted orchestrator that runs and supervises agent CLIs from your desktop, web, and mobile. It connects to Kimi Code CLI over ACP, the same way an IDE does.
68
+
69
+ Pick **Kimi Code CLI** from Paseo's built-in ACP provider catalog, or add a custom provider in `~/.paseo/config.json`:
70
+
71
+ ```json
72
+ {
73
+ "agents": {
74
+ "providers": {
75
+ "kimi": {
76
+ "extends": "acp",
77
+ "label": "Kimi Code CLI",
78
+ "command": ["kimi", "acp"]
79
+ }
80
+ }
81
+ }
82
+ }
83
+ ```
84
+
85
+ Paseo's generic ACP adapter does not drive the login flow, so complete the terminal login first (see [Prerequisites](#prerequisites)) — otherwise session creation fails with `Authentication required`.
86
+
87
+ ## Troubleshooting
88
+
89
+ - **Session disconnects immediately / IDE shows "agent exited"**: usually a wrong `command` path or a missing login. Run `kimi acp` in a terminal first to verify — if it blocks waiting for stdin, the CLI itself is fine and the problem is in the IDE configuration; if it exits immediately with an error, follow the error message (most commonly you need to run `/login`).
90
+ - **IDE shows "auth required"**: the CLI has no usable authentication token. Exit the IDE, run `kimi` in a terminal to complete login, then restart the IDE.
91
+ - **MCP tools not visible**: check the [`kimi acp` reference](../reference/kimi-acp.md) capability table to confirm that the MCP transport type configured in your IDE is supported. The Kimi Code CLI ACP server currently supports `http`, `stdio`, and `sse` transports; `acp` transport MCP servers are silently dropped and a warning is written to the log.
92
+
93
+ ## Next steps
94
+
95
+ - [kimi acp reference](../reference/kimi-acp.md) — ACP capability matrix and method coverage details
96
+ - [kimi command reference](../reference/kimi-command.md) — full subcommand list
docs/en/guides/interaction.md ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Interaction and input
2
+
3
+ Kimi Code CLI runs as an interactive TUI (terminal user interface) built around three components: the input box, the conversation view, and the status bar. This page covers how to enter text, paste media, navigate the approval flow, and switch between modes.
4
+
5
+ ## Input box basics
6
+
7
+ The input box accepts free-form text. Press `Enter` to send, or `Shift-Enter` / `Ctrl-J` to insert a newline. When the input box is empty, press `↑` / `↓` to browse the input history for the current working directory, including previous shell commands.
8
+
9
+ **Exiting the CLI**: press `Ctrl-D` with the input box empty, press `Ctrl-C` twice while idle, or type `/exit`. Pressing `Ctrl-C` or `Esc` during streaming output interrupts the current turn — it does not exit the program.
10
+
11
+ ## Pasting images and video
12
+
13
+ Kimi Code CLI supports pasting images and video directly into the input box, so you can discuss screenshots, UI mockups, architecture diagrams, or code demos without uploading or converting files first.
14
+
15
+ **Video input is a distinctive Kimi Code capability** — you can paste a video clip and have the model analyze its content, UI flow, or code walkthrough.
16
+
17
+ How to paste:
18
+
19
+ - **macOS / Linux**: `Ctrl-V`
20
+ - **Windows**: `Alt-V`
21
+
22
+ After pasting, the input box shows a placeholder that you can edit like normal text; on submit, the placeholder is replaced with the actual content. A plain-text clipboard falls back to ordinary paste. Media support depends on the current model's multimodal capabilities (`image_in` / `video_in`); it is enabled by default when you are logged in to a Kimi Code account.
23
+
24
+ If a conversation accumulates more than 20 MB of media, the oldest images and videos are omitted from requests automatically, and a warning is shown when this happens.
25
+
26
+ ## Slash commands
27
+
28
+ Type `/` to open the completion menu — it filters as you type, `Esc` closes it, and unmatched input goes to the agent as a regular message. Common commands:
29
+
30
+ | Command | Action |
31
+ | --- | --- |
32
+ | `/new` | Start a new session |
33
+ | `/sessions` | Browse and resume past sessions |
34
+ | `/compact` | Compact the current session's context |
35
+ | `/undo` | Undo recent prompts |
36
+ | `/model` | Switch the model used in the current session |
37
+ | `/plan` | Toggle Plan mode (plan first, then execute) |
38
+ | `/yolo` | Open the permission mode list with Ask When Needed preselected (routine edits and commands run automatically) |
39
+ | `/goal` | Start or manage goal mode |
40
+ | `/help` | Show all commands |
41
+
42
+ Active [Agent Skills](../customization/skills.md) are also registered as slash commands (e.g. `/skill:<name>`). For the full list, see [Slash commands reference](../reference/slash-commands.md).
43
+
44
+ ## File references
45
+
46
+ Type `@` to trigger file-path completion; the selected path is inserted in relative form, and the agent loads the file content directly when it reads your message.
47
+
48
+ - **Where it works**: both git and non-git directories; hidden paths are included, `.git` is excluded
49
+ - **Folder suggestions**: end with `/`, so you can keep completing paths inside them
50
+ - **Fallback**: while the fast search helper is still downloading, Kimi Code falls back to a basic filesystem scan
51
+
52
+ > `@` references and slash commands are two separate mechanisms: `@` gives the agent file context, while `/` invokes built-in features or Skills.
53
+
54
+ ## Approval flow
55
+
56
+ When the agent calls a tool that has side effects — modifying files, running commands — the TUI displays an approval panel for your confirmation.
57
+
58
+ - **Approve**: select with the arrow keys and press `Enter`, or press `1` / `2` / `3` to choose directly
59
+ - **Reject**: `Esc`, `Ctrl-C`, or `Ctrl-D`
60
+ - **Approve for this session**: auto-approves the same kind of call for the rest of the session
61
+ - **Permanent rules**: add allow / deny entries in [Configuration files](../configuration/config-files.md#permission)
62
+
63
+ Approvals are not triggered for regular tool calls in Ask When Needed mode, nor for writes to plan files in Plan mode.
64
+
65
+ ### The three permission modes
66
+
67
+ **Always Ask mode** (formerly Manual) is the default: read-only operations run automatically, while every other action — editing files, running commands — asks for your confirmation one by one. Use it when you want full control over every change.
68
+
69
+ **Ask When Needed mode** (formerly YOLO), enabled with `/yolo`, auto-approves regular tool calls, making it suitable for batch tasks you know are safe. It still asks before sensitive actions — accessing sensitive files such as `.env` or SSH keys, running dangerous commands such as `shutdown` or `rm -rf`, or exiting Plan mode — and the agent can still ask you questions.
70
+
71
+ **Never Ask mode** (formerly Auto), enabled with `/auto`, is the fully unattended mode: every tool approval is handled automatically, including sensitive files and plan exits, and the agent never asks you questions — it decides everything on its own. The built-in dangerous-command guard asks for your confirmation before commands such as `shutdown`, `reboot`, or `rm -rf` in Always Ask and Ask When Needed mode; in Never Ask mode these commands run without interruption.
72
+
73
+
74
+ ## Mode switching
75
+
76
+ ### Plan mode
77
+
78
+ In Plan mode the agent first outputs an action plan and waits for your approval before modifying any files — useful for complex or high-risk tasks.
79
+
80
+ - Toggle: `Shift-Tab` or `/plan`
81
+ - Clear the current plan: `/plan clear` (only while idle)
82
+
83
+ After producing a plan the agent pauses for your review — you can approve it, reject it, or ask for revisions. Exiting Plan mode requires your confirmation even if Ask When Needed mode is also active. Never Ask mode is the exception: plan exits are approved automatically and marked as "Auto-approved" in the transcript.
84
+
85
+ ### Shell mode
86
+
87
+ Shell mode lets you run terminal commands without leaving the conversation. The command output is written into the conversation context, so the agent can see the results in later turns.
88
+
89
+ - Enter: type `!` in an empty input box, or paste a command that starts with `!`.
90
+ - Exit: press `Backspace` or `Esc` in an empty input box; submitting a command also returns you to normal mode automatically.
91
+ - Run in background: while a command is running, press `Ctrl+B` to move it to a background task.
92
+ - Recall previous commands: with the input box empty in shell mode, press `↑` to browse earlier shell commands; recalling one keeps you in shell mode so it runs as a command again.
93
+ - Long output: when a finished command's output is too long, the output card collapses automatically; press `Ctrl-O` to expand or collapse it together with tool output.
94
+
95
+ In shell mode the input box shows a `!` prompt on the left and the border turns violet. For example, you can run `!gh auth login` to sign in to the GitHub CLI without opening a new terminal, so Kimi can use `gh` afterward.
96
+
97
+ ### Goal mode
98
+
99
+ A goal keeps the agent working toward a defined outcome across turns — a normal prompt says what to do next, a goal says what must become true. Use `/goal` for tasks with a clear finish line and verifiable evidence, like fixing a batch of failing tests or tracking down why a build fails. For one-off edits or single-answer questions, a normal prompt is usually better.
100
+
101
+ Write the objective after `/goal`, naming the finish line and the stop condition (up to 4000 characters; longer input is rejected and stays in the input box for editing):
102
+
103
+ ```sh
104
+ /goal Fix every checkout-regression bug, add or update tests for each fix, then run the checkout test suite
105
+ ```
106
+
107
+ Avoid broad objectives like `/goal find every bug in this codebase` — with no success criteria, the agent may block immediately or work far longer than expected. Clearly impossible goals (like `/goal prove that 1 + 1 = 3`) are marked as blocked right away.
108
+
109
+ Common management commands:
110
+
111
+ | Command | Action |
112
+ | --- | --- |
113
+ | `/goal` or `/goal status` | Show the current goal and its progress |
114
+ | `/goal pause` / `/goal resume` | Pause / resume the goal |
115
+ | `/goal cancel` | Cancel the goal (asks for confirmation; a cancelled goal cannot be resumed) |
116
+ | `/goal replace <objective>` | Replace the current goal |
117
+ | `/goal next <objective>` | Queue a follow-up goal that starts when the current one completes |
118
+
119
+ A goal stops in three ways: **complete** — achieved, cleared, and summarized; **paused** — you paused it, interrupted a turn, or an error occurred; **blocked** — the agent can't continue as stated and writes a short message explaining why. The time budget only ticks while the goal is active and the session is open — closing the session or pausing the goal stops the clock, and `/goal resume` continues with the remaining budget after you reopen the session.
120
+
121
+ In the web UI, the goal bar below the conversation lets you pause, resume, or cancel the goal directly; click it to expand details, including budget progress when a token budget is configured.
122
+
123
+ Use `/goal next <objective>` to line up follow-up work without interrupting the current goal — queued goals stay invisible to the agent until the current one completes, then the first starts automatically. `/goal next manage` opens an interactive manager to reorder, edit, or delete queued goals (arrow keys to browse, `Space` to select, `E` to edit, `D` to delete, `Esc` to cancel). Queued goals never start while the current goal is paused, cancelled, or blocked.
124
+
125
+ > Tip: in `manual` permission mode a goal may stop at tool approvals; non-interactive mode only supports creating goals (`kimi -p "/goal ..."`) — exit code `0` on complete, `3` on blocked, `6` on paused.
126
+
127
+ ## During streaming output
128
+
129
+ The input box remains usable while the agent is thinking or calling tools, and supports the following extra actions:
130
+
131
+ - **`Ctrl-S`**: inject the content in the input box into the running turn immediately, without waiting for it to finish
132
+ - **`Esc` / `Ctrl-C`**: interrupt the current turn
133
+ - **`Ctrl-O`**: globally toggle the collapsed/expanded state of tool output and compaction summaries
134
+
135
+ When the agent is waiting for background tasks through `WaitFor`, pressing `Ctrl-S` ends that wait early. Background tasks keep running and existing tool results are preserved. If other foreground tools remain in the same batch, the agent processes your message after they return.
136
+
137
+ ## External editor
138
+
139
+ Press `Ctrl-G` to send the current input content to an external editor. When you save and close, the text is written back into the input box; if you close without saving, the original content is preserved. This is handy when you need to enter large blocks of text or content with complex formatting.
140
+
141
+ Editor priority: `/editor` config → `$VISUAL` environment variable → `$EDITOR` environment variable. If none are set, run `/editor` first to choose a default.
142
+
143
+ ## Next steps
144
+
145
+ - [Keyboard shortcuts](../reference/keyboard.md) — full quick-reference table of all shortcuts
146
+ - [Slash commands](../reference/slash-commands.md) — all built-in commands with descriptions and aliases
147
+ - [Sessions and context](./sessions.md) — how to resume sessions, compress context, and export conversations
docs/en/guides/migration.md ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Migrating from kimi-cli
2
+
3
+ ::: info
4
+ Kimi Code CLI has gone through a major version upgrade — moving from Python/uv to Node.js, bringing a simpler install experience, faster startup, and a redesigned terminal UI. The legacy version will gradually be phased out, so we recommend upgrading as soon as possible.
5
+ :::
6
+
7
+ If you are migrating from the legacy version, follow the steps below — a single command migrates your config, MCP servers, and session history to the new version.
8
+
9
+ ## What's new
10
+
11
+ - **No more Python / uv**: Rebuilt on Node.js — no Python environment needed, simpler to install
12
+ - **Native binary, works out of the box**: Faster startup, lighter footprint
13
+ - **Redesigned terminal UI**: Smoother, more responsive experience
14
+ - **Full data migration**: Config, MCP servers, and session history all carry over seamlessly
15
+
16
+ ## How to migrate
17
+
18
+ There are two ways to migrate.
19
+
20
+ The **first time you run `kimi`** after installing kimi-code, it automatically checks whether kimi-cli data exists under `~/.kimi/`. If it finds any, a migration prompt appears, and you can choose to migrate now, do it later, or never be asked again.
21
+
22
+ You can also **run it manually at any time**:
23
+
24
+ ```sh
25
+ kimi migrate
26
+ ```
27
+
28
+ You can choose whether to migrate chat sessions as well. If you don't need the history yet, pick **Config only**; otherwise pick **Config + N sessions** to bring everything across in one go. A summary is printed at the end.
29
+
30
+ ## What happens during migration
31
+
32
+ **What gets migrated**: configuration (`config.toml`), MCP server configuration, input history, and whichever chat sessions you chose to migrate.
33
+
34
+ **What does not get migrated**: OAuth login credentials and MCP service authorizations are not copied, so you will need to run `/login` again and re-authorize MCP servers after migrating. kimi-cli plugins are also out of scope.
35
+
36
+ ::: tip
37
+ Migration **never modifies or deletes** any of the old data under `~/.kimi/`. kimi-cli keeps working as before, and the two do not interfere with each other. Migration can also be run repeatedly — sessions that have already been migrated are not imported again.
38
+ :::
39
+
40
+ After migration, sessions imported from kimi-cli are tagged with `[imported]` in the session picker so you can tell them apart from new ones.
docs/en/guides/remote-control.md ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Remote Control
2
+
3
+ Start Kimi Code CLI with remote control enabled by running `kimi rc` in a terminal — it generates a link that can remotely control this machine. Scan the QR code with your phone to open the link, or visit it directly on another device. After opening the link, log in with the same Kimi account as in your local Kimi Code CLI to check on task progress, handle approvals, continue conversations, or start new sessions. Tasks always run on your machine — the web page is just a remote window.
4
+
5
+ ## Getting started
6
+
7
+ ### Prerequisites
8
+
9
+ Before turning on Remote Control, make sure your machine meets the following conditions:
10
+
11
+ - **Kimi Code CLI installed**: see [Getting started](../guides/getting-started.md)
12
+ - **Logged in to your Kimi account with a paid membership**: Remote Control requires a paid membership and is not available to free users
13
+ - **Machine stays awake and online**: Remote Control depends on a persistent connection between your machine and the Kimi service; remote sessions are unavailable after shutdown, sleep, or network loss
14
+
15
+ ### Step 1: Start Remote Control
16
+
17
+ Start it on your machine in any of the following ways — they are equivalent: each starts a foreground process and prints the remote access info.
18
+
19
+ - **`kimi rc`** (alias `kimi remote`): start Remote Control directly
20
+ - **`kimi web --remote-control`**: equivalent to `kimi rc` — starts the local web interface and exposes it to the public internet at the same time
21
+ - **`/remote-control`** (alias `/rc`): use while already in a CLI session to hand the current session over to the remote interface
22
+
23
+ Once started, the terminal prints the access URL (like `https://code-rc.kimi.com/devices/<device ID>/`), a QR code, and the device name (the machine's hostname), and the default browser opens the URL automatically (use `--no-open` to skip). Besides the terminal rendering, the QR code is also saved as a PNG file (the path is printed in the startup output) — if the QR code doesn't render properly in your terminal, open that file instead.
24
+
25
+ ![Terminal output after starting kimi rc: QR code and connection status](../../media/kimi-rc-banner.jpg)
26
+
27
+ ::: warning Note
28
+ The Remote Control link is a remote control entry point to this machine — anyone who has it may control your sessions and files. Do not share it with others or post it anywhere public.
29
+ :::
30
+
31
+ Two limitations:
32
+
33
+ - Only one Remote Control instance can run per machine. Starting it again reports the existing instance and prints the link already in use — see [How to turn off Remote Control](#how-to-turn-off-remote-control) for how to stop the old one
34
+ - Remote Control cannot be combined with `--dangerous-bypass-auth`, and it only binds to the loopback address (`--host` LAN sharing is not supported — remote access goes through the Kimi relay service)
35
+
36
+ ### Step 2: Connect from another device
37
+
38
+ 1. Open the access URL from the startup output in a browser on your phone or another computer — on a phone, you can also scan the QR code in the terminal directly.
39
+ 2. Log in with the same Kimi account as on the machine.
40
+ 3. After logging in, pick this machine in the device list (shown by its hostname) to see its sessions and start working.
41
+
42
+ Remote Control works in the browser.
43
+
44
+ ::: info Device limit
45
+ Each account currently supports up to about **3 devices**.
46
+ :::
47
+
48
+ ### How to turn off Remote Control
49
+
50
+ Remote Control is a foreground process; how you stop it depends on whether you can find the terminal that started it:
51
+
52
+ - **The terminal is still there**: press `Ctrl+C` in that terminal (or just close the window) — the device immediately goes offline from the remote list
53
+ - **Can't find the terminal**: the single-instance lock file `~/.kimi-code/server/rc.json` records the process pid and the link in use (the error from starting a second instance prints both as well) — run `kill <pid>`
54
+ - **The process already died** (power loss, crash, …): the stale lock file is cleaned up automatically on the next start — nothing to delete by hand
55
+
56
+ To start a fresh instance, stop the old one in any of the ways above and run `kimi rc` again — there is no dedicated restart command. The device ID is derived from the machine's data directory, so the device and its access URL stay the same. The web-side device management and revocation UI is subject to the final release.
57
+
58
+ ## What you can do in a remote session
59
+
60
+ Remote sessions have essentially the same capabilities as local ones:
61
+
62
+ - **Send new tasks**: describe what you need; the task runs on your machine
63
+ - **Watch progress**: execution steps and tools in use are shown in real time
64
+ - **Continue the conversation**: follow up on existing sessions
65
+ - **Inspect tool calls**: expand the input and output of each tool execution
66
+ - **Handle approvals**: approve or deny file edits, Shell execution, and other confirmation requests right in the web page
67
+ - **Interrupt or stop tasks**: stop the running task at any time
68
+ - **Check subagent / workflow status**: track subagents or workflows dispatched by the task in the task panel
69
+
70
+ ## What happens on your machine
71
+
72
+ Remote Control is only a remote window — all computation and file operations still happen on your machine. The boundaries:
73
+
74
+ | Content | Happens locally |
75
+ | --- | --- |
76
+ | Reading project files | Yes |
77
+ | Modifying project files | Yes |
78
+ | Running Shell commands | Yes |
79
+ | Using local MCP | Yes |
80
+ | Phone or browser UI | No |
81
+ | Session sync | Via the Kimi service |
82
+
83
+ ## Disconnects, sleep, and recovery
84
+
85
+ - **Closing the browser**: the task keeps running on your machine. Reopen the access URL to get the session view back
86
+ - **Machine loses network**: while offline, the remote UI disconnects and becomes unusable. The Remote Control process and the local server keep running, but an in-flight task may stall or fail because model requests can't get out. Once the network is back, the machine reconnects to the relay automatically — just refresh the remote page, no restart needed
87
+ - **Machine sleeps**: the Remote Control connection drops and tasks may pause or fail. Set the computer to never sleep in system settings, or keep it awake while in use
88
+ - **Local process exits**: pressing `Ctrl+C` or closing the terminal stops Remote Control and takes the device off the remote list. Restart it to recover
89
+ - **End the remote connection but keep the local task**: just close the web page — the local task is unaffected
90
+
91
+ ## What's the difference between Remote Control and Kimi Code Web?
92
+
93
+ [Kimi Code Web](../guides/web.md) is the graphical interface on your machine or LAN; Remote Control extends it to any device on the public internet:
94
+
95
+ | | Kimi Code Web | Remote Control |
96
+ | --- | --- | --- |
97
+ | Access scope | `localhost`, or the LAN with `--host` | Any device on the public internet (via the Kimi relay) |
98
+ | How to start | Run `kimi web` in a terminal | `kimi rc`, `kimi web --remote-control`, or `/remote-control` in the CLI |
99
+ | Authentication | Local token | Log in with the same Kimi account |
100
+ | Where data and execution live | Your machine | Your machine (the web page is just a remote window) |
101
+ | Typical scenario | GUI in a local browser | Following up remotely from a phone, tablet, or another computer |
102
+
103
+ For the web interface's features, see [Using Kimi Code in the browser](../guides/web.md).
104
+
105
+ ## Security and permissions
106
+
107
+ ### How remote devices authenticate
108
+
109
+ A remote device must log in with the same Kimi account as the machine to view and control sessions. Your devices are never exposed to other accounts, and there is no public link that works without logging in.
110
+
111
+ ### Does the access URL contain sensitive information
112
+
113
+ The access URL itself contains no session data or local token — everything is shown per account permissions after login. But it is a remote control entry point to this machine, and the startup output also warns you not to share it.
114
+
115
+ ## FAQ
116
+
117
+ ### The link won't open from inside WeChat — what do I do?
118
+
119
+ WeChat's in-app browser restricts some external webpages under its own security policies, so the Remote Control access URL (`https://code-rc.kimi.com/…`) opened directly in WeChat may be blocked with a "web page access stopped" notice.
120
+
121
+ The fix: tap the "…" menu in the top-right corner and open the page in your default browser, or copy the link and paste it into a system browser such as Safari or Chrome. The same applies when scanning the startup QR code with WeChat's scanner — open it in a browser to get the full session functionality.
122
+
123
+ ### Does the task stop when I close the browser?
124
+
125
+ No. The browser is just a window — the task runs on your machine. Closing the page doesn't affect it; reopen the link to get the view back.
126
+
127
+ ### Can I keep going after closing the local terminal?
128
+
129
+ No. Remote Control depends on the Remote Control process on your machine staying alive; once the process exits, the remote connection drops. Restart it to recover.
130
+
131
+ ### Can a phone access local files directly?
132
+
133
+ No. The phone has no direct channel to your machine's file system: what you see on the phone is the content rendered inside the session interface (such as diffs and file cards after the AI edits files), while all file reads/writes and command execution happen on the machine. The phone cannot browse, open, or download local files outside of a session.
134
+
135
+ ### How to troubleshoot a failed remote connection
136
+
137
+ Check in this order:
138
+
139
+ 1. **Wake state**: make sure the machine is awake and hasn't gone to sleep
140
+ 2. **Network connectivity**: can the machine reach the internet
141
+ 3. **Process status**: is the Remote Control process running on the machine
142
+ 4. **Account match**: is the web side logged in with the same Kimi account
143
+ 5. **Firewall and proxy**: is your corporate network or proxy blocking `code-rc.kimi.com`
144
+
145
+ ## Next steps
146
+
147
+ - [Using Kimi Code in the browser](../guides/web.md) — Remote Control opens the same web interface; learn what the interface itself can do
docs/en/guides/sessions.md ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Sessions and context
2
+
3
+ Kimi Code CLI persists every conversation as a "session" — storing message history and metadata so you can close the terminal and pick up right where you left off. This page covers how to resume sessions, manage context, and export or fork sessions.
4
+
5
+ ## Session storage
6
+
7
+ All sessions are saved under `$KIMI_CODE_HOME/sessions/` (default: `~/.kimi-code/sessions/`), grouped by working directory:
8
+
9
+ ```text
10
+ ~/.kimi-code/
11
+ ├── config.toml
12
+ ├── session_index.jsonl
13
+ └── sessions/
14
+ └── <workDirKey>/
15
+ └── <sessionId>/
16
+ ├── state.json
17
+ └── agents/
18
+ ├── main/
19
+ │ └── wire.jsonl
20
+ └── <subagentId>/
21
+ └── wire.jsonl
22
+ ```
23
+
24
+ - `state.json`: session metadata such as title and creation time.
25
+ - `agents/*/wire.jsonl`: the agent event stream, used for session recovery and replay. It also carries a request trace — the tool schemas, request parameters, and MCP tool listings sent to the model — for debugging.
26
+
27
+ ::: warning
28
+ Do not manually edit files inside the `sessions/` directory — doing so may prevent sessions from being restored correctly.
29
+ :::
30
+
31
+ ## Starting and resuming sessions
32
+
33
+ Every time you run `kimi` directly it creates a new session. To resume a previous session, use one of the following:
34
+
35
+ **Resume the most recent session in the current directory:**
36
+
37
+ ```sh
38
+ kimi --continue
39
+ ```
40
+
41
+ **Resume a specific session by ID:**
42
+
43
+ ```sh
44
+ kimi --session abc123
45
+ ```
46
+
47
+ **Interactively browse session history and choose one:**
48
+
49
+ ```sh
50
+ kimi --session
51
+ ```
52
+
53
+ ::: warning
54
+ `--continue` and `--session` are mutually exclusive.
55
+ :::
56
+
57
+ ## Switching sessions inside the TUI
58
+
59
+ You can manage sessions without leaving the terminal. The following slash commands are available only when the agent is idle:
60
+
61
+ - **`/new`** (alias `/clear`): switch to a new session, discarding the current context.
62
+ - **`/sessions`** (alias `/resume`): browse and resume a previous session.
63
+ - **`/fork`**: fork the current session (see below).
64
+ - **`/title <text>`** (alias `/rename`): set a session title for easier identification; without arguments, displays the current title.
65
+
66
+ ## Context compression
67
+
68
+ As a conversation grows, Kimi Code CLI automatically compresses the message history when the context approaches the window limit, freeing up token space. You can also trigger compression manually at any time:
69
+
70
+ ```
71
+ /compact
72
+ ```
73
+
74
+ You can pass a hint to tell the model what to prioritize when compressing:
75
+
76
+ ```
77
+ /compact Keep the discussion about database migrations
78
+ ```
79
+
80
+ ## Forking a session
81
+
82
+ To explore a new direction without disrupting the current conversation, use `/fork`:
83
+
84
+ ```
85
+ /fork
86
+ ```
87
+
88
+ Forking does not switch you away: you stay in the original session and the conversation continues untouched. The fork is an independent copy you can switch to at any time using `/sessions`. A saved `/goal` is not copied to the fork. Start a new goal there if you want autonomous goal work.
89
+
90
+ After forking, the CLI prints a ready-to-run `kimi --resume` command (also copied to the clipboard) so you can enter the fork directly from a new terminal process.
91
+
92
+ ## Exporting a session
93
+
94
+ Use `kimi export` to package a session as a ZIP file — useful for sharing, archiving, or filing a bug report:
95
+
96
+ ```sh
97
+ kimi export <sessionId>
98
+ ```
99
+
100
+ Omitting `sessionId` exports the most recent session in the current directory (with an interactive confirmation prompt; add `-y` to skip). Use `-o` to specify an output path:
101
+
102
+ ```sh
103
+ kimi export <sessionId> -o ~/Desktop/my-session.zip
104
+ ```
105
+
106
+ The export includes all files in the session directory, including diagnostic logs. The global diagnostic log (`~/.kimi-code/logs/kimi-code.log`) is also bundled by default; add `--no-include-global-log` to exclude it.
107
+
108
+ You can also export from inside the TUI without leaving the interactive session:
109
+
110
+ - **`/export-debug-zip`**: produces the same debug ZIP as `kimi export`.
111
+ - **`/export-md`** (alias `/export`): exports the conversation as a human-readable Markdown file, suitable for sharing or archiving. Accepts an optional path argument; without one, it writes to `kimi-export-<short-id>-<timestamp>.md` in the current working directory.
112
+
113
+ In the web UI, `/export` downloads the current session as a diagnostic ZIP. It includes the persisted session data, diagnostic logs, and a bounded metadata-only `logs/kimi-web.jsonl` record of key browser events. Prompt text, WebSocket payloads, and console arguments are not copied into this browser log. This web command differs from the TUI `/export` alias above.
114
+
115
+ ::: tip
116
+ Exported files may contain code, command output, and file paths that are sensitive. Review the content before sharing.
117
+ :::
118
+
119
+ ## Next steps
120
+
121
+ - [Data locations](../configuration/data-locations.md) — full directory layout for session files
122
+ - [kimi command reference](../reference/kimi-command.md) — complete parameter reference for `--continue`, `--session`, `export`, and other commands
docs/en/guides/use-cases.md ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Common use cases
2
+
3
+ This page collects typical Kimi Code CLI scenarios along with ready-to-use prompt examples — copy them as-is or adapt them to your needs.
4
+
5
+ ## Understanding an unfamiliar project
6
+
7
+ When taking over an unfamiliar repository, a good first step is to use `kimi --plan` or press `Shift-Tab` to enter Plan mode, so the agent outputs a research plan before touching anything:
8
+
9
+ ```
10
+ Give me an overview of this repository's architecture. Specifically:
11
+ 1. Where is the entry point and what happens at startup?
12
+ 2. How do the main modules depend on each other?
13
+ 3. How are configuration and data loaded?
14
+ Finally, draw a simple module dependency diagram.
15
+ ```
16
+
17
+ You can also focus on a specific question:
18
+
19
+ ```
20
+ How does the event loop in src/runtime work? Where do events originate, and what consumes them?
21
+ ```
22
+
23
+ ```
24
+ How is "permission approval" implemented in this project? Which files are involved, and what are the key types?
25
+ ```
26
+
27
+ For large-scale investigations, you can have the main agent dispatch **sub-agents** to handle sub-tasks in parallel. See [Agents and sub-agents](../customization/agents.md).
28
+
29
+ ## Implementing a new feature
30
+
31
+ Describe the requirement and acceptance criteria clearly. For complex changes, use Plan mode to confirm the approach before execution:
32
+
33
+ ```
34
+ Add a retry utility under src/utils:
35
+ - Signature: retry<T>(fn: () => Promise<T>, options): Promise<T>
36
+ - Options: maxAttempts, initialDelayMs, backoffFactor
37
+ - On failure, throw the error from the last attempt
38
+ - Add a unit test suite covering: success on first try, success after retries, and all attempts failing
39
+ ```
40
+
41
+ If the result isn't right, just describe what you want changed — no need to edit manually:
42
+
43
+ ```
44
+ The backoff calculation used a fixed value. I'd like to add some jitter to avoid the thundering-herd effect. Update the implementation and the tests.
45
+ ```
46
+
47
+ ## Fixing a bug
48
+
49
+ Give the symptom, reproduction steps, and expected behavior all at once to avoid back-and-forth clarification:
50
+
51
+ ```
52
+ Running npm test occasionally produces this error:
53
+
54
+ TypeError: Cannot read properties of undefined (reading 'id')
55
+ at SessionStore.update (src/session/store.ts:142:18)
56
+
57
+ It only appears in test cases that concurrently trigger multiple updates. Please locate the cause and fix it, then run the full test suite to confirm.
58
+ ```
59
+
60
+ When the root cause is unclear, ask the agent to investigate before making changes:
61
+
62
+ ```
63
+ User feedback: after a successful login, the first page refresh sends you back to the login page; a second refresh works fine. Please find the most likely causes first and list the most suspicious locations. I'll confirm the direction before you start making changes.
64
+ ```
65
+
66
+ For purely mechanical tasks, you can let the agent run freely:
67
+
68
+ ```
69
+ Run the test suite, fix every failing test case, then run it again to confirm everything is green.
70
+ ```
71
+
72
+ ## Writing tests and refactoring
73
+
74
+ Tasks with clear boundaries and explicit acceptance criteria are particularly well-suited for the agent:
75
+
76
+ ```
77
+ src/parser/markdown.ts currently has almost no tests. Please add a unit test suite covering: normal paragraphs, nested lists, code blocks, tables, blockquotes, and mixed content. Follow the testing style already used in the project.
78
+ ```
79
+
80
+ ```
81
+ Extract the repeated "read body → validate → log → respond" pattern in src/handlers into a middleware. Run the tests afterwards to make sure existing behavior is unchanged.
82
+ ```
83
+
84
+ For multi-file refactors, use Plan mode first to confirm the approach. You can also `/fork` the session into an experimental branch and switch to it from `/sessions` — forking itself never disrupts the original session, so you can simply switch back if you don't like the result.
85
+
86
+ ## One-off scripts and automation
87
+
88
+ Batch file edits, statistics collection, and research comparisons can all be done with a single prompt:
89
+
90
+ ```
91
+ Change all var declarations in .js files under src to const or let, preferring const where possible. Run lint once you're done to confirm.
92
+ ```
93
+
94
+ ```
95
+ Analyze the access logs in logs/ from the past 7 days. For each API path, compute the call count, p50, and p99 response times, and output the results as a Markdown table.
96
+ ```
97
+
98
+ ```
99
+ Research the main dependency injection options for TypeScript (tsyringe, inversify, awilix). Compare them across three dimensions: API style, decorator requirements, and runtime overhead. Give me a recommendation that fits on one page.
100
+ ```
101
+
102
+ For batch tasks you know are safe, use `--yolo` or `/yolo` to skip approval prompts, or add pre-approved allowlist rules for specific tools in [Configuration files](../configuration/config-files.md#permission).
103
+
104
+ ## Scheduled tasks and reminders
105
+
106
+ Inside an interactive session, you can ask the agent to set one-time reminders or recurring tasks. The agent generates a cron expression in your local timezone and re-injects the prompt into the same session when it fires:
107
+
108
+ ```
109
+ Remind me at 2:30 PM to check the deployment.
110
+ ```
111
+
112
+ ```
113
+ Every weekday at 9 AM, summarize recent CI failures for me.
114
+ ```
115
+
116
+ ```
117
+ Check the production health endpoint every hour and let me know if anything looks wrong.
118
+ ```
119
+
120
+ ```
121
+ Come back in about 10 minutes and check whether the build has finished.
122
+ ```
123
+
124
+ Scheduled tasks are bound to their session — closing the terminal is fine, and they are reloaded and continue firing when you resume the same session with `kimi --session`. They are not carried into brand-new sessions. Recurring tasks expire after 7 days — the agent receives a `stale` signal on the final trigger and decides whether to stop or renew based on your original instructions.
125
+
126
+ To see what tasks are currently pending, just ask the agent (it calls the read-only `CronList` tool). To cancel a task, tell the agent to remove it or reference its 8-character ID. For the full tool reference, see [Scheduled tasks](../reference/tools.md#scheduled-tasks). The global kill switch is `KIMI_DISABLE_CRON=1`.
127
+
128
+ ## Generating and maintaining documentation
129
+
130
+ ```
131
+ I just changed the interface signature in src/auth/login.ts. Please update the corresponding JSDoc, the example code in README, and any paragraphs in docs/en/guides that mention this interface.
132
+ ```
133
+
134
+ ```
135
+ For every public function under src/api that is missing a docstring, add a documentation comment following the style of the existing ones.
136
+ ```
137
+
138
+ ```
139
+ Based on the command implementations in src/cli, generate a draft command reference listing each subcommand, its arguments, and default values. Put it in docs/en/reference for me to review later.
140
+ ```
141
+
142
+ When you need a record or a retrospective, use `kimi export <sessionId>` to package the session as a ZIP, or use `/export-md` inside the TUI to export a readable Markdown transcript.
143
+
144
+ ## Next steps
145
+
146
+ - [Agents and sub-agents](../customization/agents.md) — how to have the agent dispatch sub-tasks for parallel execution
147
+ - [Hooks](../customization/hooks.md) — trigger local scripts at task-completion and other lifecycle points
148
+ - [Built-in tools](../reference/tools.md) — full reference of all tools the agent can call
docs/en/guides/web.md ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Using Kimi Code in the browser
2
+
3
+ Kimi Code Web is the browser-based graphical interface built into Kimi Code CLI: run `kimi web` in a terminal, and you can start sessions, chat, handle approvals, and review file changes in a browser — a friendlier interface, while sessions and data still live entirely on your machine.
4
+
5
+ ![Kimi Code Web UI](../../media/kimi-web-ui.jpg)
6
+
7
+ ## Getting started
8
+
9
+ <div class="step">
10
+ <span class="step-num">1</span> <strong>Install Kimi Code CLI and log in</strong>
11
+
12
+ `kimi web` is a built-in CLI command — it isn't available without the CLI. See [Getting started](./getting-started.md) for installation and login.
13
+ </div>
14
+
15
+ <div class="step">
16
+ <span class="step-num">2</span> <strong>Run <code>kimi web</code> in a terminal</strong>
17
+
18
+ If you're already in the CLI, you can also type `/web` to hand the current session off to the browser.
19
+ </div>
20
+
21
+ <div class="step">
22
+ <span class="step-num">3</span> <strong>The web UI opens in your default browser once ready</strong>
23
+
24
+ The startup banner prints the access URL — if the browser doesn't open by itself, copy this URL and open it manually:
25
+
26
+ ```text
27
+ Local: http://127.0.0.1:58627/#token=...
28
+ Token: ...
29
+ Stop: Ctrl+C
30
+ ```
31
+
32
+ ::: warning
33
+ The `#token=` fragment is the access credential — don't share it. Stop the server with `Ctrl+C` in the terminal.
34
+ :::
35
+ </div>
36
+
37
+ ### Startup options
38
+
39
+ | Option | Description |
40
+ | --- | --- |
41
+ | `--port <port>` | Bind port; defaults to `58627`, auto-increments when taken |
42
+ | `--host [host]` | Let phones, tablets, or other computers on the same LAN access the web address; you can also specify an IP, e.g. `--host 192.168.1.10` |
43
+ | `--no-open` | Don't open the browser when ready |
44
+ | `--log-level <level>` | Enable server logs at the given level; off by default |
45
+
46
+ ### Common slash commands
47
+
48
+ | Slash command | Description |
49
+ | --- | --- |
50
+ | `/new` | Start a new session |
51
+ | `/goal` | Enter Goal mode and keep working toward the same objective across turns |
52
+ | `/compact` | Compact the current session's context |
53
+ | `/tower` | Tower multi-agent collaboration (experimental); `/tower <base-branch>` sets the base branch |
54
+ | `/export` | Export the session content and troubleshooting logs as a ZIP |
55
+ | `/remote-control` | Enable remote control to access the local web session remotely |
56
+
57
+ ## Relationship with the CLI
58
+
59
+ The web UI and the CLI share the same login state, configuration (`config.toml`), and session data.
60
+
61
+ The web UI supports only a subset of the CLI's slash commands — see [Common slash commands](#common-slash-commands) above. Everything else usually has a point-and-click equivalent in the UI (the settings page, the model picker, the account menu, the task panel).
62
+
63
+ How the two sides compare:
64
+
65
+ <div class="feature-compare-table">
66
+
67
+ | Feature | CLI | Web | Notes |
68
+ | --- | --- | --- | --- |
69
+ | Streaming chat | ✓ | ✓ | Web renders rich formats incrementally (tables, code highlighting, diffs, tool cards) |
70
+ | Session management | ✓ | ✓ | Web lets you archive less-used sessions away; the archive page sorts them by time and you can restore them anytime; the Open / Done / Workspaces tabs are a Lab experiment (off by default) — enable them on the settings Lab page |
71
+ | Approvals | ✓ | ✓ | Web handles them with clicks in the UI — no commands needed |
72
+ | Background tasks | ✓ | ✓ | Web shows live progress in the task panel |
73
+ | Files and changes | ✓ | ✓ | Web has a changed-files summary card and per-file diffs |
74
+ | Settings | ✓ | ✓ | Web adds a settings UI (providers, account & usage, Lab experiments) |
75
+ | Global search | — | ✓ | Web searches across sessions and workspaces |
76
+ | Mobile layout | — | ✓ | With LAN sharing on (`--host`), it works in phone browsers on the same network |
77
+
78
+ </div>
79
+
80
+ ## Security notes
81
+
82
+ - **Set a parallel credential**: when binding a LAN address, also set the `KIMI_CODE_PASSWORD` environment variable; the server then rate-limits authentication failures automatically.
83
+ - **Don't disable authentication entirely**: `--dangerous-bypass-auth` turns off all authentication — anyone who can reach the port can control your sessions, file system, and shell. Only use it on trusted networks or behind your own authenticating proxy. See the [kimi command reference](../reference/kimi-command.md#kimi-web).
84
+
85
+ ## FAQ
86
+
87
+ ### The port is already taken
88
+
89
+ Nothing to do. `kimi web` automatically retries with the next port (58628, 58629, …) — just use the address printed in the startup banner.
90
+
91
+ ### The URL won't open in the browser
92
+
93
+ First check the server is still running in the terminal (it runs in the foreground there). Copy the full URL including the `#token=` part; opening only `http://127.0.0.1:58627` lands on a token input page, where pasting the `Token` value from the banner also works.
94
+
95
+ ### How to recover from an invalid token
96
+
97
+ Run `kimi web rotate-token` to generate a new token, then open the new banner URL. All running instances switch to the new token automatically — no restart needed.
98
+
99
+ ### Other devices on the same Wi-Fi can't connect
100
+
101
+ Make sure you started with `--host` (bare is fine), and use the LAN URL from the banner (like `http://192.168.x.x:58627/#token=...`). If it still fails, check that the machine's firewall allows the port, and that both devices are really on the same network segment — guest Wi-Fi, VPNs, and switching to a 4G/5G hotspot all isolate devices.
102
+
103
+ ## Next steps
104
+
105
+ - [Server API](../reference/server-api.md) — REST / WebSocket APIs for scripts and third-party integrations (experimental)
106
+ - [kimi command](../reference/kimi-command.md#kimi-web) — all `kimi web` command-line options
107
+ - [Remote Control](./remote-control.md) — remotely view and take over local sessions from any device over the public internet
docs/en/index.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ layout: home
3
+ hero:
4
+ name: Kimi Code CLI
5
+ text: The Starting Point for Next-Gen Agents
6
+ actions:
7
+ - theme: brand
8
+ text: Get started
9
+ link: guides/getting-started
10
+ - theme: alt
11
+ text: GitHub
12
+ link: https://github.com/MoonshotAI/kimi-code
13
+ ---
docs/en/reference/keyboard.md ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Keyboard Shortcuts
2
+
3
+ Kimi Code CLI's TUI interactive mode supports a set of keyboard shortcuts. The shortcuts are organized into five groups by usage context: general input, mode switching, during streaming, tool output control, the approval panel, and popup navigation. Type `/help` in the TUI at any time to open the built-in shortcut reference.
4
+
5
+ ## General Shortcuts
6
+
7
+ The following keys are always available in the input box:
8
+
9
+ | Shortcut | Function |
10
+ | --- | --- |
11
+ | `Enter` | Submit the current input |
12
+ | `Shift-Enter` / `Ctrl-J` | Insert a newline in the input |
13
+ | `↑` / `↓` | Browse input history |
14
+ | `Esc` | Close a popup / cancel completion / interrupt streaming output or context compaction |
15
+ | `Ctrl-C` | Interrupt the current streaming output, or clear the input box |
16
+ | `Ctrl-D` | Exit Kimi Code CLI when the input box is empty |
17
+ | `Ctrl-T` | Expand or collapse the todo list when it is truncated |
18
+ | `Ctrl-P` | Previous page in the experimental `Updates` panel when it has multiple pages |
19
+ | `Ctrl-N` | Next page in the experimental `Updates` panel when it has multiple pages |
20
+
21
+ Pressing `Ctrl-C` **during streaming** cancels immediately — no second confirmation needed.
22
+
23
+ **Exiting the program** (pressing `Ctrl-C` with an empty input box, or pressing `Ctrl-D`) uses a double-press confirmation mechanism: after the first press, a prompt appears in the status bar; a second press of the same key actually exits. Pressing any other key in between clears the confirmation state.
24
+
25
+ ## Mode Switching
26
+
27
+ | Shortcut | Function |
28
+ | --- | --- |
29
+ | `Shift-Tab` | Toggle Plan mode |
30
+ | `!` | Enter shell mode (in an empty input box) |
31
+
32
+ Press `Shift-Tab` to enable or disable Plan mode. When enabled, the Agent prioritizes read-only tools for research and planning and can write to the current plan file; `Bash` is subject to the current permission mode and regular rules, without any additional separate approval triggered by Plan mode. Simply toggling does not create an empty plan file. Press `Shift-Tab` again to exit Plan mode.
33
+
34
+ Type `!` in an empty input box to enter shell mode and run terminal commands directly; while a command is running, press `Ctrl+B` to move it to a background task. See [Interaction and input](../guides/interaction.md#shell-mode).
35
+
36
+ ## Input & Editing
37
+
38
+ | Shortcut | Function |
39
+ | --- | --- |
40
+ | `Ctrl-G` | Edit the current input in an external editor |
41
+ | `Ctrl-V` | Paste an image or video from the clipboard (Unix / macOS) |
42
+ | `Alt-V` | Paste an image or video from the clipboard (Windows) |
43
+ | `Ctrl--` | Undo |
44
+ | `Esc` `Esc` | Open the undo selector (double-press while idle) |
45
+
46
+ Pressing `Ctrl-G` opens an external editor, selected according to the following priority:
47
+
48
+ 1. The editor configured via the `/editor` command
49
+ 2. The `$VISUAL` environment variable
50
+ 3. The `$EDITOR` environment variable
51
+
52
+ After saving and exiting, the edited content replaces the input box; exiting without saving leaves the input unchanged.
53
+
54
+ When pasting an image or video, a placeholder is shown in the input box — the actual media data is sent to the model when the message is submitted. The system clipboard is read first; on Linux, Wayland and X11 are tried; on WSL, PowerShell is also used as a fallback to read the Windows clipboard.
55
+
56
+ ## During Streaming
57
+
58
+ While streaming output is active, the input box can still receive input and supports the following additional operations:
59
+
60
+ | Shortcut | Function |
61
+ | --- | --- |
62
+ | `Ctrl-S` | Steer: inject the current input directly into the running turn |
63
+ | `Esc` | Interrupt the current streaming output |
64
+ | `Ctrl-C` | Interrupt the current streaming output |
65
+
66
+ Pressing `Ctrl-S` causes the model to see your message at the next interruptible point, without waiting for the current turn to finish.
67
+
68
+ ## Tool Output
69
+
70
+ | Shortcut | Function |
71
+ | --- | --- |
72
+ | `Ctrl-O` | Expand or collapse tool output, shell command output, and compaction summaries |
73
+
74
+ When collapsed tool call results or shell command outputs exist in the history, press `Ctrl-O` to toggle between collapsed and expanded views. After compaction, the same shortcut shows or hides the compaction summary in the compaction block.
75
+
76
+ ## Approval Panel
77
+
78
+ When the Agent initiates a tool call that requires confirmation, the TUI displays an approval panel. For the full approval workflow, see [Interaction & Input](../guides/interaction.md#approval-flow). The available keys inside the panel are:
79
+
80
+ | Shortcut | Function |
81
+ | --- | --- |
82
+ | `↑` / `↓` | Move the cursor between candidate options |
83
+ | `Enter` | Confirm the currently selected option |
84
+ | `1` ~ `9` | Directly select the option at the corresponding index |
85
+ | `Esc` / `Ctrl-C` / `Ctrl-D` | Reject the current request |
86
+ | `Ctrl-E` | Expand or collapse the full content when the panel contains a diff or file preview |
87
+ | `Ctrl-O` | Toggle the collapsed state of other tool output |
88
+
89
+ Options that require feedback (such as "Reject" or "Revise") switch to a feedback input state after confirmation: type the feedback text and press `Enter` to submit; press `Esc` to exit feedback input and return to the candidate list.
90
+
91
+ ## Popup Mode
92
+
93
+ After opening the help panel with `/help`, use the following keys to navigate and close it:
94
+
95
+ | Shortcut | Function |
96
+ | --- | --- |
97
+ | `↑` / `↓` | Scroll one line at a time |
98
+ | `PageUp` / `PageDown` | Scroll 10 lines at a time |
99
+ | `Esc` / `Enter` / `q` / `Q` | Close the panel |
100
+
101
+ ## Next steps
102
+
103
+ - [Slash Commands](./slash-commands.md) — Quick reference for built-in TUI control commands
104
+ - [`kimi` Command](./kimi-command.md) — Complete reference for startup flags and subcommands
docs/en/reference/kimi-acp.md ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # `kimi acp` Subcommand
2
+
3
+ `kimi acp` switches Kimi Code CLI to **ACP (Agent Client Protocol)** mode: it communicates with an ACP client (such as Zed, JetBrains AI Chat, etc.) via JSON-RPC over stdin/stdout, letting the IDE directly drive kimi's sessions, prompts, and tool calls.
4
+
5
+ ```sh
6
+ kimi acp
7
+ ```
8
+
9
+ Once started, the command prints no banner and immediately waits for the ACP client to send an `initialize` request on stdin. Logs are written to stderr (as well as the diagnostic log under `~/.kimi-code/logs/`), so the ACP channel itself stays clean.
10
+
11
+ ::: tip Who calls this?
12
+ You typically do not need to run `kimi acp` manually — this command is the subprocess entry point for IDEs. For IDE-side configuration, see [Using in IDEs](../guides/ides.md).
13
+ :::
14
+
15
+ ## Capability matrix
16
+
17
+ The table below lists the capabilities declared by the ACP server. The `agentCapabilities` field is returned in full in the `initialize` response, so the IDE can adjust its UI accordingly.
18
+
19
+ | Capability | Value | Description |
20
+ | --- | --- | --- |
21
+ | `loadSession` | `true` | Supports `session/load` to resume an existing session, replaying history on load |
22
+ | `promptCapabilities.image` | `true` | Supports ACP `image` content blocks (base64 + mimeType) |
23
+ | `promptCapabilities.audio` | `false` | Audio prompts not yet supported |
24
+ | `promptCapabilities.embeddedContext` | `true` | Client may send `resource`/`resource_link` embedded resource blocks; text content is injected into the prompt as `<resource uri="...">...</resource>`; blob resources are dropped with a warn |
25
+ | `sessionCapabilities.list` | `{}` | Supports `session/list` to enumerate the current user's sessions |
26
+ | `sessionCapabilities.resume` | `{}` | Supports `session/resume` to reattach to a session without history replay |
27
+ | `sessionCapabilities.close` | `{}` | Supports `session/close` to tear down a live session |
28
+ | `sessionCapabilities.delete` | `{}` | Supports `session/delete` to permanently remove a session |
29
+ | `sessionCapabilities.fork` | `{}` | Supports `session/fork` to branch an existing session |
30
+ | `sessionCapabilities.additionalDirectories` | `{}` | Extra working directories; honored on `session/new` only |
31
+ | `mcpCapabilities.http` | `true` | Forwards HTTP MCP services configured by the IDE |
32
+ | `mcpCapabilities.sse` | `true` | Forwards legacy SSE MCP services configured by the IDE |
33
+ | `auth.logout` | `{}` | Supports ACP `logout` to drop the managed provider's token |
34
+
35
+ ## ACP method coverage
36
+
37
+ With `@agentclientprotocol/sdk@1.x`, the ACP method set is organized by namespace: `core` and `session` cover the main agent flow, while `providers`, `nes` (inline-edit prediction), and `document` (buffer sync) are optional extension surfaces. On the client side, reverse-RPC methods are grouped under `session`, `fs`, `terminal`, and `elicitation`.
38
+
39
+ **Summary: the ACP server implements the full core (3/3) and session (11/11) agent-side surface, 10/11 client reverse-RPC methods, and the `session/set_model` extension. Not implemented: `providers/*`, `nes/*`, `document/*`, and `elicitation/complete` — requests for them return `methodNotFound`.**
40
+
41
+ ### Core agent-side — IDE → agent (3 / 3)
42
+
43
+ | Method | Implemented | Description |
44
+ | --- | --- | --- |
45
+ | `initialize` | Yes | Version negotiation; returns `agentInfo: { name: 'Kimi Code CLI', version }`, capability matrix, and `authMethods` (first-class `type:'terminal'` plus the legacy `_meta['terminal-auth']` fallback) |
46
+ | `authenticate` | Yes | Validates `method_id='login'`; returns `authRequired (-32000)` if the token is missing, `invalidParams (-32602)` for an unknown ID |
47
+ | `logout` | Yes | Drops the managed provider's token; subsequent gated calls return `auth_required` again |
48
+
49
+ ### Session agent-side — IDE → agent (11 / 11)
50
+
51
+ | Method | Implemented | Description |
52
+ | --- | --- | --- |
53
+ | `session/new` | Yes | Accepts `cwd` / `mcpServers` / `additionalDirectories`; returns `sessionId` + `configOptions[]` + `modes` |
54
+ | `session/load` | Yes | Restores a session from disk and replays history via `session/update` before the response settles |
55
+ | `session/resume` | Yes | Lightweight sibling of `session/load`; skips history replay |
56
+ | `session/list` | Yes | Enumerates sessions on disk, filterable by `cwd` |
57
+ | `session/fork` | Yes | Branches a source session; `cwd` / `additionalDirectories` / `mcpServers` on the request are ignored with a warning |
58
+ | `session/close` | Yes | Best-effort teardown: cancels any in-flight turn, disposes per-session resources, and closes the live session; an unknown id is not an error |
59
+ | `session/delete` | Yes | Permanently removes a session and its persisted data; an unknown id returns `invalidParams (-32602)` |
60
+ | `session/prompt` | Yes | Accepts `text` / `image` / `resource` / `resource_link` content blocks; streams `agent_message_chunk` |
61
+ | `session/cancel` | Yes | Interrupts the current turn (a JSON-RPC `$/cancel_request` for a prompt lands in the same cancel path) |
62
+ | `session/set_mode` | Yes | Validates `modeId`; the same underlying mode switch as `set_config_option({configId:'mode'})` |
63
+ | `session/set_config_option` | Yes | Unified model / thinking / mode picker dispatcher |
64
+
65
+ ### Client-side reverse-RPC — agent → IDE (10 / 11)
66
+
67
+ | Method | Implemented | Description |
68
+ | --- | --- | --- |
69
+ | `session/update` | Yes | Streams `agent_message_chunk` / `tool_call*` / `plan` / `config_option_update` / `available_commands_update` |
70
+ | `session/request_permission` | Yes | Shared channel for tool approval and question prompts |
71
+ | `fs/read_text_file` | Yes | Engine file reads are routed to the client when it advertises `fsCapabilities` |
72
+ | `fs/write_text_file` | Yes | Engine file writes are routed to the client |
73
+ | `terminal/create` · `output` · `release` · `kill` · `wait_for_exit` | Yes | Shell executions reverse-RPC to the client when it advertises `clientCapabilities.terminal` |
74
+ | `elicitation/create` | Yes | Ask-user questions go through the native form when the client advertises `elicitation.form`; RPC failures fall back to `session/request_permission` |
75
+ | `elicitation/complete` | No | |
76
+
77
+ ### Extension methods
78
+
79
+ | Method | Implemented | Description |
80
+ | --- | --- | --- |
81
+ | `session/set_model` | Yes | Carried over from the ACP 0.23 unstable surface as an extension method; equivalent to `set_config_option({configId:'model'})` |
82
+
83
+ All methods not listed above return `methodNotFound`.
84
+
85
+ ## MCP forwarding
86
+
87
+ When an ACP client provides `mcpServers` in `session/new` or `session/load`, the ACP server performs the following conversions:
88
+
89
+ - `http` → kimi's `transport: 'http'` configuration
90
+ - `stdio` → kimi's `transport: 'stdio'` configuration
91
+ - `sse` → kimi's `transport: 'sse'` configuration
92
+ - `acp` → discarded with a warn log entry
93
+
94
+ ## Next steps
95
+
96
+ - [Using in IDEs](../guides/ides.md) — Zed / JetBrains configuration steps and troubleshooting
97
+ - [`kimi` Command Reference](./kimi-command.md) — Complete subcommand list
docs/en/reference/kimi-command.md ADDED
@@ -0,0 +1,384 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # `kimi` Command
2
+
3
+ `kimi` is the main command for Kimi Code CLI, used to start an interactive session in the terminal. Running it without any arguments opens a new session in the current working directory; combined with different flags, you can resume a previous session, skip approvals, start in Plan mode, or load Skills from a custom directory.
4
+
5
+ ```sh
6
+ kimi [options]
7
+ kimi <subcommand> [options]
8
+ ```
9
+
10
+ ## Main Command Options
11
+
12
+ All flags are optional — run `kimi` directly to enter an interactive session:
13
+
14
+ | Option | Short | Description |
15
+ | --- | --- | --- |
16
+ | `--version` | `-V` | Print the version number and exit |
17
+ | `--help` | `-h` | Show help information and exit |
18
+ | `--session [id]` | `-S` | Resume a session. With an ID, opens that session directly; without an ID, enters an interactive selector |
19
+ | `--continue` | `-c` | Continue the most recent session in the current working directory, without specifying an ID manually |
20
+ | `--model <model>` | `-m` | Specify a model alias for this launch. When omitted, new sessions use `default_model` from the config file |
21
+ | `--prompt <prompt>` | `-p` | Run a single prompt non-interactively and stream the Assistant output to stdout. This mode does not open the TUI |
22
+ | `--output-format <format>` | | Set the non-interactive output format; supports `text` and `stream-json`. Can only be used with `--prompt`; defaults to `text` |
23
+ | `--yolo` | `-y` | Start in Ask When Needed mode: routine edits and commands run automatically; risky actions, questions, and plans still ask |
24
+ | `--auto` | | Start in Never Ask mode: never interrupts you; everything runs and is decided automatically |
25
+ | `--plan` | | Start a new session in Plan mode — the AI will prioritize read-only tools for exploration and planning |
26
+ | `--skills-dir <dir>` | | Load Skills from the specified directory, replacing the automatically discovered user and project directories. Can be repeated |
27
+ | `--agent <name>` | | Start a new session with the specified agent as the main Agent. Cannot be combined with `--session`/`--continue` |
28
+ | `--agent-file <path>` | | Load a custom agent from a Markdown file for the new session and select it. Cannot be repeated or combined with `--agent`, `--session`, or `--continue` |
29
+ | `--add-dir <dir>` | | Add an extra workspace directory for this session. Relative paths resolve against the current working directory. Can be repeated |
30
+
31
+ `-r` / `--resume` is a hidden alias for `--session`; `--yes` and `--auto-approve` are hidden aliases for `--yolo` and are not shown in help output.
32
+
33
+ ::: warning
34
+ `--yolo` skips human approval for regular tool calls, including file writes and shell command execution. Use it only in trusted working directories. Plan mode exit approval is not bypassed by `--yolo`; `Bash` inside Plan mode is handled under the regular allow rules.
35
+ :::
36
+
37
+ ### Flag Conflict Rules
38
+
39
+ The following combinations are rejected at startup:
40
+
41
+ - `--continue` and `--session` are mutually exclusive — both mean "resume a previous session"
42
+ - `--yolo` and `--auto` are mutually exclusive — the two permission modes cannot be combined
43
+ - `--prompt` cannot be used with `--yolo`, `--auto`, or `--plan` — non-interactive mode uses `auto` permission by default
44
+ - `--output-format` can only be used together with `--prompt`
45
+
46
+ When resuming a session, you can override its saved permission or plan mode by adding `--auto`, `--yolo`, or `--plan`. For example, `kimi --continue --auto` resumes the latest session and switches it to Never Ask mode.
47
+
48
+ ## Common Usage
49
+
50
+ Start a new session directly:
51
+
52
+ ```sh
53
+ kimi
54
+ ```
55
+
56
+ Pick up where you left off (automatically finds the most recent session in the current directory):
57
+
58
+ ```sh
59
+ kimi --continue
60
+ ```
61
+
62
+ Choose from the session history list, or specify a known ID directly:
63
+
64
+ ```sh
65
+ kimi --session
66
+ kimi --session 01HZ...XYZ
67
+ ```
68
+
69
+ Skip approval prompts — suitable for batch tasks that are known to be safe:
70
+
71
+ ```sh
72
+ kimi --yolo
73
+ ```
74
+
75
+ Let the Agent handle everything autonomously, without asking the user questions:
76
+
77
+ ```sh
78
+ kimi --auto
79
+ ```
80
+
81
+ Read the code and produce an implementation plan before making any file changes:
82
+
83
+ ```sh
84
+ kimi --plan
85
+ ```
86
+
87
+ ### Custom Skills Directories
88
+
89
+ There are two ways to specify Skills directories, with different semantics:
90
+
91
+ - **`--skills-dir <dir>`** (CLI flag): **Replaces** the automatically discovered user and project directories for this launch only. Can be repeated to stack multiple directories:
92
+
93
+ ```sh
94
+ kimi --skills-dir /path/to/team-skills --skills-dir ./local-skills
95
+ ```
96
+
97
+ - **`extra_skill_dirs`** (`config.toml`): **Adds** directories on top of the automatically discovered ones, taking effect permanently. Suitable for configuring team-shared Skills. See [Agent Skills](../customization/skills.md).
98
+
99
+ ### Custom Agents
100
+
101
+ `--agent` and `--agent-file` select which agent drives a new session, in both print mode (`kimi -p`) and the interactive TUI:
102
+
103
+ ```sh
104
+ kimi --agent reviewer
105
+ kimi -p --agent reviewer "Review the changes on this branch"
106
+ ```
107
+
108
+ `--agent-file` registers a single agent file at the highest priority for this launch only and selects it; the flag cannot be repeated, and `--agent` and `--agent-file` are mutually exclusive. Both flags only apply when starting a new session — neither can be combined with `--session`/`--continue`, because the agent is bound at session creation and resuming restores the bound agent automatically. The selection is fixed at the session's first bind and cannot be switched later; in the TUI the flags bind only the startup session, and a session created later in the same process (for example via `/new`) starts with the default agent. See [Agents and Sub-Agents](../customization/agents.md#custom-agents) for the agent file format and discovery directories.
109
+
110
+ ## Non-Interactive Execution
111
+
112
+ When running a single prompt in a script or CI environment, use `-p`:
113
+
114
+ ```sh
115
+ kimi -p "Summarize the current repository status"
116
+ ```
117
+
118
+ Output uses a transcript style: thinking content and Assistant text are both prefixed with `• `, and wrapped lines are indented by two spaces. Assistant text goes to stdout; thinking, tool progress, and "resuming session" notices go to stderr. In `-p` mode, no human approval is requested — regular tool calls are handled under the `auto` permission policy, while static deny rules remain in effect.
119
+
120
+ Temporarily switch the model:
121
+
122
+ ```sh
123
+ kimi -m kimi-code/kimi-for-coding -p "Explain the latest diff"
124
+ ```
125
+
126
+ When you need to parse output programmatically, use the `stream-json` format — each line on stdout is a JSON object:
127
+
128
+ ```sh
129
+ kimi -p "List changed files" --output-format stream-json
130
+ ```
131
+
132
+ In `stream-json` mode, regular replies produce an Assistant message; when the model calls a tool, an Assistant message with `tool_calls` is emitted first, followed by the corresponding Tool message, then subsequent Assistant messages. Thinking content is not written to JSONL; tool progress and "resuming session" notices are still written to stderr.
133
+
134
+ ## Subcommands
135
+
136
+ `kimi` provides the following subcommands: `login` (non-interactive login), `acp` (ACP IDE mode), `web` (run the local REST/WebSocket/web service in the foreground and open the web UI), `doctor` (validate configuration files), `export` (export a session), `migrate` (migrate legacy data), `upgrade` (check for updates), and `provider` (manage providers).
137
+
138
+ ### `kimi login`
139
+
140
+ Log in to Kimi Code OAuth via the RFC 8628 device-code flow, without entering the TUI. The command issues a device authorization request, prints the verification URL and user code to stderr, then polls until the browser-side authorization is complete. The generated token is written to the same local location as TUI `/login` and is loaded automatically the next time `kimi` starts.
141
+
142
+ ```sh
143
+ kimi login
144
+ ```
145
+
146
+ This subcommand has no flags. Press `Ctrl-C` at any time during polling to cancel; the exit code is `1` on cancellation or failure, and `0` on success.
147
+
148
+ ### `kimi acp`
149
+
150
+ Switch Kimi Code CLI to ACP (Agent Client Protocol) mode, communicating with an IDE via JSON-RPC over stdin/stdout so the editor can directly drive kimi's sessions and tool calls. You typically do not need to run this manually — the IDE starts it as a subprocess entry point. For configuration, see [Using in IDEs](../guides/ides.md); for technical details, see the [kimi acp reference](./kimi-acp.md).
151
+
152
+ ```sh
153
+ kimi acp
154
+ ```
155
+
156
+ ### `kimi web`
157
+
158
+ Run the local Kimi server in the foreground of the current terminal — a single process that exposes the REST + WebSocket API and serves the web UI from the same origin — and open the web UI in the default browser once it is ready. The command stays attached to the terminal and shuts down cleanly on `SIGINT` / `SIGTERM` (e.g. `Ctrl-C`).
159
+
160
+ When the server is running, `GET /openapi.json` returns the REST OpenAPI document and `GET /asyncapi.json` returns the local WebSocket AsyncAPI document. For an end-to-end walkthrough of driving sessions over the API, see [Server API: Drive a session over the API](./server-api.md#drive-a-session-over-the-api); for the protocol details, see the [Server API](./server-api.md) reference.
161
+
162
+ ```sh
163
+ kimi web # run the server in the foreground and open the browser
164
+ kimi web --no-open # don't open the browser
165
+ kimi web --port 58628 # pick a specific bind port
166
+ ```
167
+
168
+ Multiple instances can share one home directory: each registers itself under `~/.kimi-code/server/instances/`, and a busy port is retried with `port + 1` (58628, 58629, …).
169
+
170
+ | Option | Description |
171
+ | --- | --- |
172
+ | `--port <port>` | Bind port; defaults to `58627`; a busy port is retried with `+1` |
173
+ | `--host [host]` | Bind host; omit for `127.0.0.1` (this machine only), pass a bare `--host` for `0.0.0.0` (all interfaces) |
174
+ | `--allowed-host <host...>` | Extra Host header values allowed through the DNS-rebinding check; repeatable or comma-separated |
175
+ | `--log-level <level>` | Enable server logs at the selected level; omitted by default |
176
+ | `--debug-endpoints` | Mount `/api/v1/debug/*` routes (off by default) |
177
+ | `--dangerous-bypass-auth` | Disable bearer-token auth on all REST and WebSocket routes so the web UI connects without a token; only for trusted networks or behind an authenticating proxy |
178
+ | `--web-title <title>` | Custom browser tab title for the web UI; defaults to the workspace directory name |
179
+ | `--no-open` | Do not open the browser once the server is ready |
180
+
181
+ `kimi web` binds to local loopback only by default and prints the bearer token in the startup banner; the web UI authenticates automatically via the `#token=` URL fragment.
182
+
183
+ ::: info
184
+ The `kimi server` command tree is deprecated: any `kimi server …` invocation (including all legacy subcommands) only prints a deprecation notice and exits with code 1 — use `kimi web` instead. The one exception is `kimi server kill`, which stays functional for stopping servers started by a version before 0.28.0. The notice will be removed in the next major version of Kimi Code.
185
+ :::
186
+
187
+ ::: danger
188
+ `--dangerous-bypass-auth` disables authentication entirely. Anyone who can reach the port gets full access to your sessions, filesystem, and shell. Only use it on a trusted network or behind your own authenticating reverse proxy, and stop the server with `Ctrl+C` when you are done.
189
+ :::
190
+
191
+ #### `kimi server kill`
192
+
193
+ Deprecated — only stops a server started by a version before 0.28.0. Those versions could leave a background server behind, recorded in the legacy single-instance lock at `~/.kimi-code/server/lock`; the command first tries `POST /api/v1/shutdown` for a graceful exit, then signals the recorded pid with SIGTERM, escalating to SIGKILL when needed, and removes the lock file once the process is confirmed dead. Servers started by `kimi web` run in the foreground — stop them with `Ctrl+C` instead.
194
+
195
+ #### `kimi web rotate-token`
196
+
197
+ Generate a new persistent bearer token (written to `~/.kimi-code/server.token`); the previous token stops working immediately. The token is shared by the whole home directory, so every running instance picks the new one up on its next auth check — no restart needed.
198
+
199
+ ### `kimi doctor`
200
+
201
+ Validate `config.toml` and `tui.toml` without starting the TUI or modifying either file. By default, the command checks the files under `KIMI_CODE_HOME` (or `~/.kimi-code` when the environment variable is unset). Missing default files are reported as skipped because built-in defaults can apply.
202
+
203
+ ```sh
204
+ kimi doctor
205
+ ```
206
+
207
+ | Command | Description |
208
+ | --- | --- |
209
+ | `kimi doctor` | Validate the default `config.toml` and `tui.toml` |
210
+ | `kimi doctor config [path]` | Validate only `config.toml`, using `path` instead of the default file when provided |
211
+ | `kimi doctor tui [path]` | Validate only `tui.toml`, using `path` instead of the default file when provided |
212
+
213
+ When an explicit path is passed, the file must exist. The command exits with `0` when all checked files are valid or skipped, and `1` when any requested file is missing or invalid.
214
+
215
+ ```sh
216
+ # Check the default config files
217
+ kimi doctor
218
+
219
+ # Check only the default runtime config
220
+ kimi doctor config
221
+
222
+ # Check a candidate TUI config before replacing the live config
223
+ kimi doctor tui ./tui.toml
224
+ ```
225
+
226
+ ### `kimi export`
227
+
228
+ Package a session into a ZIP file for sharing, archiving, or submitting bug reports.
229
+
230
+ ```sh
231
+ kimi export [sessionId] [options]
232
+ ```
233
+
234
+ | Parameter / Option | Short | Description |
235
+ | --- | --- | --- |
236
+ | `sessionId` | | The ID of the session to export. When omitted, the most recent session in the current working directory is automatically selected and requires confirmation |
237
+ | `--output <path>` | `-o` | Output ZIP file path. When omitted, writes to a default filename in the current directory |
238
+ | `--yes` | `-y` | Skip the confirmation prompt for the default session and export directly |
239
+ | `--no-include-global-log` | | Do not include the global diagnostic log. Included by default |
240
+
241
+ The export contains all files in the target session directory. The global diagnostic log (`~/.kimi-code/logs/kimi-code.log`) is included by default because it may contain events from other sessions or projects; add `--no-include-global-log` if you do not want to share it.
242
+
243
+ ```sh
244
+ # Export the most recent session in the current directory, skipping confirmation
245
+ kimi export -y
246
+
247
+ # Export a specific session to a custom path
248
+ kimi export 01HZ...XYZ -o ./bug-report.zip
249
+
250
+ # Exclude the global diagnostic log
251
+ kimi export 01HZ...XYZ -o ./bug-report.zip --no-include-global-log
252
+ ```
253
+
254
+ ### `kimi migrate`
255
+
256
+ Migrate local data from a legacy kimi-cli installation to kimi-code, including session history and configuration files. Runs entirely interactively, guiding you through the full process.
257
+
258
+ ```sh
259
+ kimi migrate
260
+ ```
261
+
262
+ For full migration instructions, see [Migrating from kimi-cli](../guides/migration.md).
263
+
264
+ ### `kimi upgrade`
265
+
266
+ Immediately check for the latest version and display an update prompt; exits after you make a selection. `kimi update` is an alias for this command.
267
+
268
+ ```sh
269
+ kimi upgrade [-y]
270
+ ```
271
+
272
+ For global npm, pnpm, yarn, and bun installations, `kimi upgrade` shows update options; selecting `Install update now` runs the corresponding foreground install command. For native installations (including Windows), it downloads and verifies the new binary in the foreground and swaps it in on the next start. When the current installation method cannot be upgraded automatically, the manual update command is printed instead. Pass `-y, --yes` to skip the confirmation prompt and install the update directly.
273
+
274
+ ### `kimi vis`
275
+
276
+ Launch the session visualizer in your browser to inspect a session as it unfolds. The command starts an in-process server pointed at your local sessions, prints the URL, opens your browser, and keeps running until you press `Ctrl-C`.
277
+
278
+ ```sh
279
+ kimi vis [sessionId] [options]
280
+ ```
281
+
282
+ | Parameter / Option | Description |
283
+ | --- | --- |
284
+ | `sessionId` | Open the visualizer directly to this session. When omitted, it opens the home view listing your sessions |
285
+ | `--port <number>` | Port to bind. By default an available port is picked automatically |
286
+ | `--host <host>` | Host to bind. Default: `127.0.0.1` |
287
+ | `--no-open` | Do not open the browser automatically; just print the URL |
288
+
289
+ ```sh
290
+ # Start the visualizer and open the browser at the home view
291
+ kimi vis
292
+
293
+ # Open directly to a specific session
294
+ kimi vis 01HZ...XYZ
295
+
296
+ # Bind a fixed port and host without opening a browser (e.g. on a remote host)
297
+ kimi vis --host 0.0.0.0 --port 8123 --no-open
298
+ ```
299
+
300
+ ### `kimi provider`
301
+
302
+ Manage providers in the shell — the non-interactive equivalent of `/provider` in the TUI. Suitable for scripted deployments, CI initialization, and one-line setup on a new machine.
303
+
304
+ ```sh
305
+ kimi provider <action> [options]
306
+ ```
307
+
308
+ Five actions are available:
309
+
310
+ #### `kimi provider add <url>`
311
+
312
+ Bulk-import all providers from a custom registry (`api.json`). The command fetches the registry, creates a `[providers.<id>]` and `[models.<alias>]` entry for each item, and writes `source` metadata so the TUI refreshes providers and models from the same registry URL automatically on next startup.
313
+
314
+ | Parameter / Option | Description |
315
+ | --- | --- |
316
+ | `<url>` | Registry URL |
317
+ | `--api-key <key>` | Bearer token for accessing the registry. Falls back to the `KIMI_REGISTRY_API_KEY` environment variable if not provided; required |
318
+
319
+ ```sh
320
+ kimi provider add https://registry.example.com/v1/models/api.json --api-key YOUR_KEY
321
+
322
+ # Or via environment variable (suitable for CI / .envrc)
323
+ KIMI_REGISTRY_API_KEY=YOUR_KEY kimi provider add https://registry.example.com/v1/models/api.json
324
+ ```
325
+
326
+ If a provider ID already exists, it is removed and re-created. The default model is not set automatically; you can select one later with `-m` or `/model` in the TUI.
327
+
328
+ #### `kimi provider remove <providerId>`
329
+
330
+ Remove the specified provider and all its model aliases. If the removed provider is the one referenced by `default_model`, `default_model` is also cleared.
331
+
332
+ ```sh
333
+ kimi provider remove kohub
334
+ ```
335
+
336
+ #### `kimi provider list`
337
+
338
+ Print each configured provider on a separate line, including type, model count, and source. Add `--json` to output the raw `providers` and `models` tables for programmatic processing.
339
+
340
+ ```sh
341
+ kimi provider list
342
+ kimi provider list --json | jq '.providers | keys'
343
+ ```
344
+
345
+ #### `kimi provider catalog list [providerId]`
346
+
347
+ Browse the public [models.dev](https://models.dev/) model catalog without modifying any configuration. Without an argument, lists all providers along with their protocol type and model count; with a `providerId`, lists all models under that provider along with their context window and capabilities. If the catalog URL cannot be reached, a built-in snapshot of the catalog is used instead.
348
+
349
+ | Parameter / Option | Description |
350
+ | --- | --- |
351
+ | `[providerId]` | Optional — the provider ID to inspect |
352
+ | `--filter <substring>` | Case-insensitive substring filter on ID or name |
353
+ | `--url <url>` | Override the catalog URL; defaults to `https://models.dev/api.json` |
354
+ | `--json` | Output matching entries as JSON |
355
+
356
+ ```sh
357
+ kimi provider catalog list
358
+ kimi provider catalog list --filter anthropic
359
+ kimi provider catalog list anthropic
360
+ ```
361
+
362
+ #### `kimi provider catalog add <providerId>`
363
+
364
+ Import a known provider directly from the catalog by ID. The protocol type, base URL, and model information are all supplied by the catalog — only an API key is required. Vendors whose protocol the catalog does not declare (e.g. xai, openrouter, and other vendor-specific SDKs) are imported as OpenAI-compatible and the output notes the guess; when the catalog provides no usable endpoint, `--base-url` is required. Proprietary protocols (e.g. Amazon Bedrock) cannot be imported. When the public catalog is unreachable, the import uses the built-in snapshot, so it still works offline or in blocked networks.
365
+
366
+ | Parameter / Option | Description |
367
+ | --- | --- |
368
+ | `<providerId>` | Provider ID in the catalog, e.g., `anthropic`, `openai` |
369
+ | `--api-key <key>` | Provider API key. Falls back to `KIMI_REGISTRY_API_KEY` if not provided; required |
370
+ | `--default-model <modelId>` | Optional — set `default_model` to `<providerId>/<modelId>` after import |
371
+ | `--base-url <url>` | Override the catalog endpoint; required when the catalog declares none (or only an env placeholder) |
372
+ | `--url <url>` | Override the catalog URL; defaults to `https://models.dev/api.json` |
373
+
374
+ ```sh
375
+ kimi provider catalog list anthropic # Browse available models first
376
+ kimi provider catalog add anthropic --api-key sk-ant-... --default-model claude-opus-4-7
377
+ ```
378
+
379
+ ## Next steps
380
+
381
+ - [Slash Commands](./slash-commands.md) — Quick reference for control commands in the interactive TUI
382
+ - [Configuration Files](../configuration/config-files.md) — Persistent configuration for `default_model`, permission mode, and other startup parameters
383
+ - [Agent Skills](../customization/skills.md) — Skill file format for directories loaded via `--skills-dir`
384
+ - [Agents and Sub-Agents](../customization/agents.md) — Built-in sub-agents, custom agent files, and main Agent selection via `--agent`
docs/en/reference/server-api.md ADDED
The diff for this file is too large to render. See raw diff
 
docs/en/reference/slash-commands.md ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Slash Commands
2
+
3
+ Slash commands are built-in control commands provided by Kimi Code CLI in the interactive TUI, covering account configuration, session management, mode switching, information queries, and more. Type `/` in the input box to trigger command completion — the candidate list filters in real time as you continue typing; command aliases are also matched.
4
+
5
+ After typing the full command name, press `Enter` to execute. If the `/`-prefixed input does not match any built-in or Skill command, it is sent to the Agent as a regular message.
6
+
7
+ ::: tip
8
+ Some commands are only available in the idle state. Executing these commands while a session is streaming output or compacting context will be blocked — press `Esc` or `Ctrl-C` to interrupt first. The "Always available" column in the tables below indicates commands that are also available during streaming.
9
+ :::
10
+
11
+ ## Account & Configuration
12
+
13
+ | Command | Alias | Description | Always available |
14
+ | --- | --- | --- | --- |
15
+ | `/login` | — | Select an account or platform and log in: Kimi Code uses OAuth device-code flow; Kimi Platform uses API key login | No |
16
+ | `/logout` | — | Clear credentials for the currently selected account | No |
17
+ | `/provider` | — | Open the interactive provider manager to view, add, and remove configured providers. See [Platforms & Models — `/provider` and provider management](../configuration/providers.md#provider-—-interactive-provider-management) | Yes |
18
+ | `/model` | — | Switch the LLM model used in the current session | Yes |
19
+ | `/secondary-model` | `/subagent-model` | Pick the default model for subagents (writes `[secondary_model] default_model`; see the [subagent model pool](../configuration/config-files.md#subagent-model-pool)) | Yes |
20
+ | `/settings` | `/config` | Open the settings panel inside the TUI | Yes |
21
+ | `/experiments` | `/experimental` | Open the experimental feature panel | Yes |
22
+ | `/permission` | — | Select a permission mode | Yes |
23
+ | `/editor` | — | Configure the external editor launched by `Ctrl-G` | Yes |
24
+ | `/theme` | — | Switch the terminal UI color theme | Yes |
25
+
26
+ ## Session Management
27
+
28
+ | Command | Alias | Description | Always available |
29
+ | --- | --- | --- | --- |
30
+ | `/new` | `/clear` | Start a fresh session, discarding the current context | No |
31
+ | `/sessions` | `/resume` | Browse historical sessions and switch to / restore one | No |
32
+ | `/tasks` | `/task` | Browse the background task list | Yes |
33
+ | `/fork` | — | Fork a new session from the current one, preserving the full conversation history; you stay in the current session | No |
34
+ | `/title [<text>]` | `/rename` | Without arguments, display the current session title; with an argument, set a new title (max 200 characters) | Yes |
35
+ | `/compact [<instruction>]` | — | Compact the current conversation context to free up token usage; an optional custom instruction can hint to the model what to preserve | No |
36
+ | `/undo [<count>]` | — | Undo recent prompts from the active context. Without a count, opens a selector; with a count, undoes that many prompts. Prompts before the last compaction cannot be undone. Undoing also rolls back the todo list and plan mode state produced by those prompts (code changes are not reverted) | No |
37
+ | `/reload` | — | Reload the current session and apply the latest `config.toml` settings (providers, models, etc.) and `tui.toml` UI preferences, without restarting the CLI | No |
38
+ | `/reload-tui` | — | Reload only the `tui.toml` UI preferences (theme, editor, notifications, etc.) without rebuilding the session | Yes |
39
+ | `/init` | — | Analyze the current codebase and generate `AGENTS.md` | No |
40
+ | `/export-md [<path>]` | `/export` | Export the current session as a Markdown file | No |
41
+ | `/export-debug-zip` | — | Export the current session as a debug ZIP archive (same behavior as [`kimi export`](./kimi-command.md#kimi-export)) | No |
42
+ | `/copy` | — | Copy the last assistant message to the clipboard | No |
43
+ | `/add-dir [<path>]` | — | Add an extra workspace directory to the current session. Run without a path (or with `list`) to list configured directories. When adding, choose whether to remember the directory for the project in `.kimi-code/local.toml` | No |
44
+ | `/web` | — | Open the current session in the web UI: pick a running server to connect to, or start a new foreground server after the TUI exits. See [`kimi web`](./kimi-command.md#kimi-web) | Yes |
45
+
46
+ ## Modes & Run Control
47
+
48
+ | Command | Alias | Description | Always available |
49
+ | --- | --- | --- | --- |
50
+ | `/yolo` | `/yes` | Open the permission mode list with Ask When Needed preselected; press `Enter` to confirm. In this mode, routine edits and commands run automatically; risky actions, questions, and plans still ask | Yes |
51
+ | `/auto` | — | Open the permission mode list with Never Ask preselected; press `Enter` to confirm. In this mode, Kimi never interrupts you; everything runs and is decided automatically | Yes |
52
+ | `/plan [on\|off]` | — | Toggle Plan mode. Without arguments, flips the current state; explicitly passing `on`/`off` forces the setting. Simply toggling does not create an empty plan file | Yes |
53
+ | `/plan clear` | — | Clear the current plan | No |
54
+ | `/swarm on\|off` | — | Turn swarm mode on or off without sending a prompt. | Yes |
55
+ | `/swarm <task>` | — | Turn swarm mode on, then send `<task>` as a normal prompt. If the turn completes normally, swarm mode turns off automatically. In `manual` permission mode, Kimi Code asks whether to switch to Ask When Needed or Never Ask mode before starting. | No |
56
+ | `/goal [...]` | — | Start or manage an autonomous goal | See below |
57
+
58
+ ::: warning
59
+ `/yolo` skips approval for regular tool calls. Please make sure you understand the potential risks before enabling it. Plan mode exit approval is not bypassed by `/yolo`; `Bash` inside Plan mode is still subject to the regular `/yolo` allow rules.
60
+ :::
61
+
62
+ ## Autonomous Goal
63
+
64
+ `/goal` starts or manages goal mode: a persistent objective that Kimi Code works toward across automatically continuing turns. For usage guidance and examples, see [Interaction and input: Goal mode](../guides/interaction.md#goal-mode).
65
+
66
+ ```sh
67
+ /goal Update the checkout docs, run docs build, and stop if still blocked after 20 turns
68
+ ```
69
+
70
+ | Command | Action | Availability |
71
+ | --- | --- | --- |
72
+ | `/goal` or `/goal status` | Display the current goal along with its status, elapsed time, turn count, and token count | Always available |
73
+ | `/goal pause` | Pause an active goal and keep it | Always available |
74
+ | `/goal resume` | Resume a paused or blocked goal | Idle only |
75
+ | `/goal cancel` | Remove the current goal | Always available |
76
+ | `/goal replace <objective>` | Replace the saved goal with a new objective | Idle only |
77
+ | `/goal next <objective>` | Queue an upcoming goal for this session. If no goal is active, start it immediately. The agent does not see queued goals until the current goal completes | Always available |
78
+ | `/goal next manage` | Open the upcoming-goal manager. Use <kbd>↑</kbd> / <kbd>↓</kbd> to browse, <kbd>Space</kbd> to select a goal for moving, selected <kbd>↑</kbd> / <kbd>↓</kbd> to reorder it, <kbd>E</kbd> to edit, <kbd>D</kbd> to delete, and <kbd>Esc</kbd> to cancel. In the edit field, use <kbd>Shift-Enter</kbd> or <kbd>Ctrl-J</kbd> for a new line and <kbd>Enter</kbd> to save | Always available |
79
+
80
+ The words `status`, `pause`, `resume`, `cancel`, `replace`, and `next` act as subcommands only when they are the first word after `/goal`. If your objective needs to start with one of those words, put `--` before it:
81
+
82
+ ```sh
83
+ /goal -- cancel the old rollout note after the new docs are published
84
+ ```
85
+
86
+ If an upcoming goal needs to start with `manage`, put `--` after `next`:
87
+
88
+ ```sh
89
+ /goal next -- manage the release checklist
90
+ ```
91
+
92
+ In non-interactive prompt mode, only the create forms start goal mode:
93
+
94
+ ```sh
95
+ kimi -p "/goal Fix the failing checkout test"
96
+ ```
97
+
98
+ Prompt mode exits with code `0` when the goal completes, `3` when it blocks, and `6` when it pauses. Other `/goal` subcommands, including `next`, are TUI controls and are not handled by `kimi -p`.
99
+
100
+ ## Information & Status
101
+
102
+ | Command | Alias | Description | Always available |
103
+ | --- | --- | --- | --- |
104
+ | `/help` | `/h`, `/?` | Show keyboard shortcuts and all available commands | Yes |
105
+ | `/btw [question]` | — | Open a side conversation in a forked sub-Agent without affecting the current main Agent turn; without a question, opens the panel first to wait for input | Yes |
106
+ | `/usage` | — | Show token usage, context consumption, and quota information | Yes |
107
+ | `/status` | — | Show the current session runtime state: version, model, working directory, permission mode, etc. | Yes |
108
+ | `/mcp` | — | List MCP servers and their connection status in the current session | Yes |
109
+ | `/plugins` | — | Open the interactive plugin manager | Yes |
110
+ | `/version` | — | Display the Kimi Code CLI version number | Yes |
111
+ | `/feedback` | `/bug` | Submit feedback with optional diagnostic logs and codebase context | Yes |
112
+
113
+ ## Exit
114
+
115
+ | Command | Alias | Description | Always available |
116
+ | --- | --- | --- | --- |
117
+ | `/exit` | `/quit`, `/q` | Exit Kimi Code CLI | No |
118
+
119
+ ## Built-in skill commands
120
+
121
+ Kimi Code CLI ships with a set of built-in Skills that appear directly as `/<name>` slash commands. Unlike external Skills, they do not require the `skill:` prefix and are available out of the box.
122
+
123
+ | Command | Description |
124
+ | --- | --- |
125
+ | `/mcp-config` | Configure MCP servers and handle MCP OAuth login. See [MCP](../customization/mcp.md) |
126
+ | `/custom-theme [<text>]` | Create or edit a custom TUI color theme. See [Themes](../customization/themes.md) |
127
+ | `/update-config` | Inspect or edit `config.toml` (model, provider, permission, hooks) and `tui.toml` (theme, editor, notifications, auto-update) |
128
+ | `/check-kimi-code-docs` | Answer Kimi Code product questions (CLI usage, configuration, membership, error codes) against the official docs |
129
+ | `/import-from-cc-codex` | Import Claude Code and Codex instructions, skills, and MCP settings into Kimi Code |
130
+ | `/sub-skill` | Discover and reorganize the local skill inventory into hierarchical sub-skill bundles. Includes `/sub-skill.review` (read-only proposal) and `/sub-skill.consolidate` (apply the reorganization) |
131
+
132
+ All built-in Skill commands are only available in the idle state.
133
+
134
+ ## Skill Dynamic Commands
135
+
136
+ Activated external Skills are automatically registered as slash commands. Ordinary external Skills use the `skill:` namespace prefix:
137
+
138
+ ```
139
+ /skill:<name> [extra text]
140
+ ```
141
+
142
+ For example, `/skill:code-style` loads the Skill named `code-style` and sends it to the Agent; any text appended after the command is concatenated to the Skill prompt.
143
+
144
+ External sub-skills appear directly in the slash command panel with dotted names:
145
+
146
+ ```
147
+ /<parent-skill>.<sub-skill> [extra text]
148
+ ```
149
+
150
+ For example, a child Skill named `review` inside a parent Skill named `code-style` is shown as `/code-style.review`. The dotted command name is derived from the hierarchy; the child `SKILL.md` can keep its local `name`.
151
+
152
+ For convenience, external Skill commands also support a shorthand form that omits the `skill:` prefix — `/<name>` — as long as the name is not taken by a system slash command. That is, `/code-style` falls back to matching `/skill:code-style`.
153
+
154
+ Built-in Skills shipped with Kimi Code CLI appear directly as `/<name>` in the slash command panel. For example, `/mcp-config` helps configure MCP servers and handle MCP OAuth login, and `/custom-theme [extra text]` invokes the custom-theme workflow to create or edit a TUI theme.
155
+
156
+ ::: info
157
+ External Skill commands entered while the agent is busy are queued behind the running turn instead of being rejected — press `Ctrl-S` to steer a queued command into the running turn immediately. `flow`-type Skills are also exposed via `/skill:<name>` — there is no separate `/flow:` namespace.
158
+ :::
159
+
160
+ For installing and authoring Skills, see [Agent Skills](../customization/skills.md).
161
+
162
+ ## Next steps
163
+
164
+ - [Keyboard Shortcuts](./keyboard.md) — Quick reference for TUI keyboard operations
165
+ - [Built-in Tools](./tools.md) — Complete reference for tools the Agent can call
docs/en/reference/tools.md ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Built-in Tools
2
+
3
+ Built-in tools are the tool set provided by Kimi Code CLI alongside its core engine — no MCP server installation required. The Agent automatically selects and calls these tools based on the task at hand during each conversation; users can inspect the details of each tool call through the approval interface.
4
+
5
+ Compared to MCP tools, built-in tools are managed directly by the runtime, their lifecycle is bound to the session, and no external process is required. Both follow the same unified approval mechanism: **read-only tools** (such as `Read`, `Grep`, `Glob`) are automatically allowed by default, while **write and execution tools** (such as `Write`, `Edit`, `Bash`) require user approval by default. In Ask When Needed mode, approval for regular tool calls is skipped; Plan mode exit approval is not affected.
6
+
7
+ ## File Tools
8
+
9
+ File tools handle reading, writing, and searching the local filesystem — the foundation for code analysis and modification tasks.
10
+
11
+ | Tool | Default Approval | Description |
12
+ | --- | --- | --- |
13
+ | `Read` | Auto-allow | Read a text file's contents |
14
+ | `Write` | Requires approval | Create or overwrite a file |
15
+ | `Edit` | Requires approval | Precise string replacement |
16
+ | `Grep` | Auto-allow | Full-text search powered by ripgrep |
17
+ | `Glob` | Auto-allow | Find files by glob pattern |
18
+ | `ReadMediaFile` | Auto-allow | Read an image or video file |
19
+
20
+ **`Read`** accepts a file path (`path`) plus optional `line_offset` (starting line number; negative values count from the end), `column_offset` (zero-based position within the first line of a forward read), `n_lines` (requested number of source lines), and `max_chars` (maximum characters in the result, including line numbers and status). Omitting `n_lines` reads toward the end of the file. The default is 100,000 characters, and calls can request up to 500,000; both values can be changed in the [`read` configuration](../configuration/config-files.md#read). Characters and column offsets use JavaScript string length in the displayed text, excluding the line-number prefix for column offsets: common letters and Chinese characters count as one, while many emoji count as two.
21
+
22
+ `Read` prefers complete lines and its results are not shortened again by the general tool-output limit. A line that cannot fit on its own page is returned in fragments; the status reports the column range and `Next Read` arguments to retrieve the rest without raising the budget. Join fragments of the same line without adding a newline. A partial line remains in the requested `n_lines` range until its ending is returned. Invalid column positions return an error rather than skipping content.
23
+
24
+ Tail reads return the newest complete lines in the requested range first. If no complete line fits, the result includes forward `Next Read` arguments for the unread range; `column_offset` cannot be combined with a negative `line_offset`. Continuation positions refer to the current file contents, so start a new read if the file changes. If a tail read reports that the file changed during reading, retry against the updated file. UTF-16 LE/BE files up to 10 MiB are checked with strict decoding first. If decoding fails, `Read` returns readable text with malformed sequences replaced by `�`, and every page warns that decoding was lossy and the text may differ from the original. The warning counts toward the character budget; a literal `�` in a valid file does not trigger it. Use `ReadMediaFile` for images or videos.
25
+
26
+ **`Write`** accepts `path`, `content`, and an optional `mode` (`overwrite` or `append`; defaults to overwrite). Missing parent directories are created automatically; `append` mode appends content to the end of the file without automatically adding a newline. Writing to an existing file — in either `overwrite` or `append` mode — requires a prior `Read` of that file in the session; the write is rejected if the file changed on disk since the last read, while creating a new file is exempt.
27
+
28
+ **`Edit`** accepts `path`, `old_string` (the exact text to replace), and `new_string` (the replacement text). By default it replaces only one unique match; if the same content appears multiple times in the file, the tool returns an error and suggests using `replace_all: true`. `old_string` and `new_string` must not be identical. The target file must have been read with `Read` earlier in the session, and the edit is rejected if the file changed on disk since that read.
29
+
30
+ **`Grep`** invokes ripgrep to search file contents, supporting regular expressions (`pattern`), a search path (`path`), file type filtering (`type`, e.g., `ts`, `py`), glob filtering (`glob`), and output mode (`output_mode`: `files_with_matches` / `content` / `count_matches`; defaults to `files_with_matches`). `content` mode supports context lines (`-A`, `-B`, `-C`), case-insensitive matching (`-i`), line numbers (`-n`, default true), and multiline matching (`multiline`). All modes support `offset` + `head_limit` pagination; `head_limit` defaults to 250 and `0` means unlimited. Sensitive files such as `.env` files and private keys are automatically filtered out; set `include_ignored=true` to search files ignored by `.gitignore`, though sensitive files remain filtered.
31
+
32
+ **`Glob`** matches files in a specified directory (`path`; defaults to the working directory) by glob pattern (`pattern`). Results are sorted by modification time in descending order, returning 100 entries by default. It respects `.gitignore`, `.ignore`, and `.rgignore` by default; set `include_ignored=true` to include ignored files such as build outputs, while sensitive files remain filtered. Brace patterns such as `*.{ts,tsx}` are supported, and broad wildcard patterns are allowed.
33
+
34
+ Use `offset` (default 0) and `head_limit` (default 100) to page through matching paths; the result provides the next offset when more matches are available. Set `head_limit: 0` to remove the match-count limit. The character limit still applies: pages end at a complete path and provide the next offset when necessary. Large pages are saved to a file that the agent can read with `Read`. Each call searches the current filesystem again, so file changes can shift results between pages. Timeouts, unreadable directories, or the output capture limit can still leave the search incomplete; the result warns about these cases, and increasing the offset cannot recover uncollected paths.
35
+
36
+ **`ReadMediaFile`** sends an image or video to the model as multimodal content. It accepts `path`, plus optional image-detail controls such as `region` and `full_resolution`; the file size limit is 100 MB. Default image reads are compressed to the configured model limits. If automatic compression cannot meet those limits safely, the tool returns an error without sending the original image and directs the model to create and read a smaller copy. Availability depends on the current model's vision capabilities (`image_in` / `video_in`).
37
+
38
+ ## Shell
39
+
40
+ | Tool | Default Approval | Description |
41
+ | --- | --- | --- |
42
+ | `Bash` | Requires approval | Execute a shell command |
43
+
44
+ **`Bash`** is the most permission-demanding tool and also the most general-purpose. Parameters:
45
+
46
+ - `command` (required): the shell command to execute
47
+ - `cwd`: working directory
48
+ - `timeout`: timeout in milliseconds; foreground default is 60 seconds, maximum is 5 minutes
49
+ - `run_in_background`: whether to run as a background task; background tasks default to a 10-minute timeout (no timeout by default in print mode `kimi -p`)
50
+ - `description`: background task description; required when `run_in_background=true`
51
+ - `disable_timeout`: whether to remove the timeout limit for background tasks
52
+
53
+ Foreground mode blocks the current turn until the command completes or times out, and the TUI streams stdout and stderr into the running `Bash` tool card while the command is still active. By default, a foreground command that hits its timeout is not killed — it keeps running as a background task (bounded by the 600s default background timeout); to restore kill-on-timeout, set [`bash_auto_background_on_timeout`](../configuration/config-files.md#background) to `false` under `[background]`. The 600s background default is configurable via [`bash_task_timeout_s`](../configuration/config-files.md#background) (`0` = no timeout) and defaults to no timeout in print mode (`kimi -p`). Background mode returns a task ID immediately and automatically notifies the Agent when the task finishes. stdin is always closed — interactive commands receive EOF immediately. A two-phase termination strategy (SIGTERM → 5-second grace period → SIGKILL) ensures reliable process cleanup when a task is stopped or hits its background timeout. On Windows, Git Bash is used by default.
54
+
55
+ ## Web Tools
56
+
57
+ | Tool | Default Approval | Description |
58
+ | --- | --- | --- |
59
+ | `WebSearch` | Auto-allow | Web search |
60
+ | `FetchURL` | Auto-allow | Fetch the content of a specified URL |
61
+
62
+ **`WebSearch`** accepts `query` (search terms). Requires the host to provide a search implementation; when not injected, the tool does not appear in the tool list.
63
+
64
+ **`FetchURL`** accepts a single `url` parameter and returns the page content. For HTML pages, the host extracts the body text rather than returning the full HTML; plain text or Markdown pages are passed through directly. Also requires a host-provided implementation.
65
+
66
+ ## Plan Mode
67
+
68
+ | Tool | Default Approval | Description |
69
+ | --- | --- | --- |
70
+ | `EnterPlanMode` | Auto-allow | Enter Plan mode |
71
+ | `ExitPlanMode` | Auto-allow (requires user to confirm the plan) | Exit Plan mode and submit the plan |
72
+
73
+ Plan mode is a constrained working state: once entered, `Write` and `Edit` are restricted to writing the current plan file only, and `TaskStop` is blocked entirely. All other tools (including `Bash`) are still governed by the current permission rules.
74
+
75
+ **`EnterPlanMode`** accepts no parameters; upon success it returns workflow guidance and the plan file path.
76
+
77
+ **`ExitPlanMode`** reads the current plan file, presents the plan to the user for approval, then exits Plan mode. The optional `options` parameter lets the Agent offer 1–3 alternative approaches (each with a `label` and `description`; `label` max 80 characters) for the user to choose from during approval. Labels must be unique and cannot use reserved words such as `Approve`, `Reject`, `Reject and Exit`, or `Revise`.
78
+
79
+ ## State Management
80
+
81
+ | Tool | Default Approval | Description |
82
+ | --- | --- | --- |
83
+ | `TodoList` | Auto-allow | Manage a task to-do list |
84
+
85
+ **`TodoList`** maintains a visible subtask list across multi-step operations; state is stored within the Agent session. The `todos` parameter accepts an array where each item has a `title` and `status` (`pending` / `in_progress` / `done`). Omitting `todos` queries the current list; passing an empty array clears it.
86
+
87
+ ## Collaboration Tools
88
+
89
+ Collaboration tools handle inter-Agent coordination, user interaction, and Skill invocation.
90
+
91
+ | Tool | Default Approval | Description |
92
+ | --- | --- | --- |
93
+ | `Agent` | Auto-allow | Spawn a sub-Agent to execute a subtask |
94
+ | `AgentSwarm` | Auto-allow in swarm mode; otherwise requires approval | Launch item-based subagents or resume existing subagents |
95
+ | `AskUserQuestion` | Auto-allow | Ask the user a question to gather structured input |
96
+ | `NotifyUser` | Auto-allow | Show the user a short progress update mid-turn |
97
+ | `Skill` | Auto-allow | Invoke a registered inline Skill |
98
+
99
+ **`Agent`** delegates a subtask to a sub-Agent. Required parameters: `prompt` (complete task description) and `description` (a 3–5 word short summary). Optional parameters: `subagent_type` (defaults to `coder`), `resume` (ID of an existing Agent to resume; mutually exclusive with `subagent_type`), `run_in_background` (defaults to false), and `model` (available when a [subagent model pool](../configuration/config-files.md#subagent-model-pool) is configured — either a `[secondary_model.models]` table or a lone `default_model`: a pool alias, or `"primary"` for the model the caller itself is running; ignored when resuming). Without it, the subagent binds the pool's `default_model`; without a configured pool, subagents always inherit the caller's model. Agent tasks time out after 2 hours by default; the limit is configurable via `[subagent] timeout_ms` in `config.toml` (`0` = no timeout, or the `KIMI_SUBAGENT_TIMEOUT_MS` env var), and defaults to no timeout in print mode (`kimi -p`). In foreground mode the parent Agent waits for the sub-Agent to complete before continuing; in background mode a task ID is returned immediately and the result is automatically delivered back to the main Agent via a synthetic User message when done. When several foreground `Agent` calls run in the same step, the TUI groups them and shows each subagent's running, waiting, completed, or failed status with elapsed time. See [Agent & Sub-Agents](../customization/agents.md) for details.
100
+
101
+ **`AgentSwarm`** launches subagents from a shared `prompt_template` and an `items` array, resumes existing subagents through `resume_agent_ids`, or combines both in one call. The template must contain the `{{item}}` placeholder; each item replaces that placeholder and launches one new subagent. Pass `subagent_type` to choose the profile used by every spawned subagent in the swarm, or omit it to use `coder`. Pass `model` (available when a [subagent model pool](../configuration/config-files.md#subagent-model-pool) is configured — a `[secondary_model.models]` table or a lone `default_model`) to run item-spawned subagents on a pool alias or on the caller's own model (`"primary"`). Without it, item-spawned subagents bind the pool's `default_model`; without a configured pool, they inherit the caller's model. Resumed subagents keep their own model. Without `resume_agent_ids`, the tool requires at least 2 items; with `resume_agent_ids`, it can resume one or more existing subagents. The tool supports up to 128 total subagents, waits for all subagents to finish, and returns an aggregated report. Each subagent times out after 2 hours by default; the limit is configurable via [`[swarm] timeout_ms`](../configuration/config-files.md#swarm) in `config.toml` (`0` = no timeout, or the `KIMI_CODE_SWARM_TIMEOUT_MS` env var), and defaults to no timeout in print mode (`kimi -p`). A timed-out subagent is aborted and marked as failed in the aggregated report. In the TUI, foreground swarms show a live `Agent swarm` progress panel above the input box. If a model response calls `AgentSwarm`, that call must be the only tool call in the response; to run multiple swarms, call one `AgentSwarm`, wait for its result, then call the next, or combine the work into one swarm when a single template can cover it. In `manual` permission mode, `AgentSwarm` calls outside active swarm mode request approval unless a permission rule allows them; while swarm mode is active, `AgentSwarm` itself is auto-approved. Permission rules match `AgentSwarm` by tool name only — argument patterns such as `AgentSwarm(swarm)` are not supported. By default the tool ramps up concurrency without an upper limit (5 subagents start immediately, then 1 more every 700 ms); set `KIMI_CODE_AGENT_SWARM_MAX_CONCURRENCY` to a positive integer to cap how many subagents run at the same time during that ramp, or leave it unset for no cap. If it is set to a value that is not a positive integer, the AgentSwarm call fails fast.
102
+
103
+ **`AskUserQuestion`** asks the user a structured multiple-choice question — useful for disambiguation or option selection. The `questions` parameter accepts 1–4 questions; each question requires `question` (ending with `?`), `options` (2–4 choices, each with a `label` and `description`), and optional `header` (max 12 characters) and `multi_select` (defaults to false). An "Other" option is appended automatically. Setting `background` to true starts a background question task and returns a task ID immediately; the question stays open after the turn ends, and the answer is delivered to the Agent as a notification once the user responds. When the host does not support interactive questioning, a failure message is returned and the Agent should ask the user directly in a text reply instead.
104
+
105
+ **`NotifyUser`** lets the main Agent and subagents send short progress updates using a single `message` parameter with light Markdown. The TUI's `Updates` panel keeps every update in order, including multiple messages from the same source. Subagent messages show their existing agent ID, such as `[agent-7]`, on the same line as the message. Main-agent messages have no prefix. Complete messages remain available through pagination rather than being replaced by a one-line preview.
106
+
107
+ The panel defaults to the latest page and groups rendered message rows from the end, up to eight per page. For ten one-line updates, the first page contains two and the last page contains eight. Short pages use only the space their content needs. Press `Ctrl-P` for the previous page and `Ctrl-N` for the next page. Paging happens in the panel without changing input focus or the draft, and stops at the first and last pages instead of wrapping. While you read older pages, newly appended updates keep the existing page boundaries and show a count. Returning to the latest page fills it from the end again and resumes following new updates. When there is only one page, these keys retain their normal editor behavior.
108
+
109
+ Finishing a turn leaves the messages and selected page visible. The next main-agent turn clears them; child turns do not clear the panel. New sessions, `/clear`, and reopening a session start with an empty panel. Updates appear only after a successful tool result confirms display; argument fragments are not shown while awaiting approval. Failed, interrupted, or suppressed notifications do not enter the panel, and the transcript preserves whether each call displayed an update. Important findings still belong in the final reply or the subagent's handoff.
110
+
111
+ The entire feature is experimental and off by default. Enable it with `KIMI_CODE_EXPERIMENTAL_NOTIFY_USER=1`, `[experimental] notify_user = true` in `config.toml`, or `/experiments` before creating a TUI session. Sessions created while it is disabled have neither the tool nor its prompt guidance.
112
+
113
+ Existing sessions keep their notification tool availability and prompt unchanged, including after reopening. Turning the feature off hides the panel and disables its paging shortcuts; any existing `NotifyUser` calls finish normally and report that the update was not displayed. Turning it back on restores display for sessions that already have the tool. If a session was created with the feature disabled, start a new session to use Updates. Changing only this flag in `/experiments` does not reload the session.
114
+
115
+ **`Skill`** allows the Agent to actively invoke a registered inline-type Skill. Accepts `skill` (the Skill name) and optional `args` (additional argument text). Only `type = "inline"` Skills can be called via this tool; Skills with `disableModelInvocation: true` are rejected. Maximum nesting depth is 3 levels. See [Agent Skills](../customization/skills.md) for details.
116
+
117
+ ## Background Tasks
118
+
119
+ Background task tools manage tasks started via `Bash`, `Agent`, or `AskUserQuestion`. When a task reaches a terminal state, its status and saved output path (or, for questions, the answer itself) are automatically delivered back to the Agent; use `TaskOutput` to check progress early, or `WaitFor` to wait for a result inside the current turn.
120
+
121
+ | Tool | Default Approval | Description |
122
+ | --- | --- | --- |
123
+ | `TaskList` | Auto-allow | List background tasks |
124
+ | `TaskOutput` | Auto-allow | View the output of a background task |
125
+ | `TaskStop` | Requires approval | Stop a running background task |
126
+ | `WaitFor` | Auto-allow | Wait for background tasks to finish |
127
+
128
+ **`TaskList`** returns the list of background tasks. Optional parameters: `active_only` (defaults to true; lists only running tasks) and `limit` (defaults to 20; range 1–100).
129
+
130
+ **`TaskOutput`** returns the status and output of a task given its `task_id`. The inline preview includes at most the most recent 32 KB of content; the full log is saved to disk, and the tool also returns an `output_path` with a suggestion to use `Read` for paginated access. The call is always non-blocking — it returns the current snapshot immediately, and task completion is delivered via automatic notification.
131
+
132
+ **`TaskStop`** accepts a `task_id` and optional `reason` (defaults to `Stopped by TaskStop`). Safe to call on tasks that are already in a terminal state.
133
+
134
+ **`WaitFor`** suspends the current turn until a background task finishes, the timeout elapses, or a steer message arrives. Parameters: `timeout` (required, in seconds, max 600) and optional `task_id`. Without `task_id`, the wait ends as soon as any background task that was running at call time finishes; when no background tasks are running, it returns immediately. A timeout is not an error — the result lists the tasks still running, and the Agent can wait again or do other work meanwhile. Steering (`Ctrl-S` in the terminal) ends the wait early; background tasks keep running and still notify the agent on completion. A task whose result was reported by `WaitFor` does not also produce an automatic completion notification.
135
+
136
+ ## Scheduled Tasks
137
+
138
+ Scheduled task tools allow the Agent to re-inject a prompt into the current session at a future time — either as a one-time reminder or as a recurring cron-triggered task (periodic checks, daily reports, deployment monitoring, etc.). Schedules are bound to the session and remain active when you resume it with `kimi --session`, but are not carried into a brand-new session. A single session can hold at most 50 active scheduled tasks. Set `KIMI_DISABLE_CRON=1` to disable them entirely; see [Environment Variables](../configuration/env-vars.md#runtime-switches).
139
+
140
+ | Tool | Default Approval | Description |
141
+ | --- | --- | --- |
142
+ | `CronCreate` | Requires approval | Schedule a prompt to fire at a future time |
143
+ | `CronList` | Auto-allow | List scheduled tasks |
144
+ | `CronDelete` | Requires approval | Cancel a scheduled task |
145
+
146
+ **`CronCreate`** accepts `cron` (a standard 5-field cron expression in the user's local timezone: `minute hour day-of-month month day-of-week`), `prompt` (the text to inject when triggered; UTF-8 limit 8 KB), and optional `recurring` (defaults to `true`; pass `false` for a one-time reminder that auto-deletes after firing). On success, returns an 8-hex-digit `id`, a human-readable `humanSchedule` (e.g., `every 5 minutes`), and `nextFireAt` (the ISO timestamp of the next fire time).
147
+
148
+ To prevent all users from firing at the same time on the hour, the scheduler applies deterministic jitter: recurring tasks are shifted forward by `min(10% of the period, 15 minutes)`; one-time tasks that fall exactly on `:00` or `:30` are moved forward by up to 90 seconds. If the scheduler misses several fire times (e.g., because the laptop was sleeping), it fires only once on wake-up — the prompt is wrapped in a `<cron-fire>` envelope with a `coalescedCount`. Recurring tasks that have been alive for more than 7 days fire one final time with `stale="true"` and are then automatically deleted; call `CronCreate` again to keep them.
149
+
150
+ **`CronList`** is a read-only tool that accepts no parameters. It returns one record per active task with fields: `id`, `cron`, `humanSchedule`, `nextFireAt`, `recurring`, `ageDays`, and `stale`. Records are separated by `---` and sorted by schedule time.
151
+
152
+ **`CronDelete`** accepts a single `id`. For recurring tasks, all future fires stop immediately; for one-time tasks, the pending fire is cancelled. One-time tasks that have already fired are auto-deleted, so calling `CronDelete` on an already-fired one-time task returns `No cron job with id ...`. Deletion is irreversible — use `CronCreate` again to restore. `CronDelete` is also blocked in Plan mode.
153
+
154
+ ## Next steps
155
+
156
+ - [Agent & Sub-Agents](../customization/agents.md) — Scheduling mechanics and context isolation for the `Agent` tool
157
+ - [Hooks](../customization/hooks.md) — Trigger local scripts before and after tool calls
158
+ - [Slash Commands](./slash-commands.md) — Quick reference for TUI built-in control commands