SaylorTwift HF Staff commited on
Commit
9bd7455
·
verified ·
1 Parent(s): c1a047f

Add files using upload-large-folder tool

Browse files
Files changed (50) hide show
  1. .changeset/README.md +154 -0
  2. .changeset/abort-error-escape.md +5 -0
  3. .changeset/config.json +19 -0
  4. .changeset/diff-fence-palette-colors.md +5 -0
  5. .changeset/fix-steer-message-duplicates.md +5 -0
  6. .changeset/fix-steered-file-attachments-reload.md +5 -0
  7. .changeset/fix-steered-slash-command-missing.md +5 -0
  8. .changeset/fix-undo-transcript.md +5 -0
  9. .changeset/fix-usage-sessionless-message.md +5 -0
  10. .changeset/kimi-image-upload-references.md +5 -0
  11. .changeset/lazy-subagent-scope-eviction.md +5 -0
  12. .changeset/manager-stopped-subagents-report-cancelled.md +5 -0
  13. .changeset/media-request-budget.md +5 -0
  14. .changeset/propagate-user-cancellation-to-tools.md +5 -0
  15. .changeset/rename-webbridge-display-name.md +5 -0
  16. .changeset/survey-kfc-model-id.md +5 -0
  17. .changeset/tower-rework-subagent-card.md +5 -0
  18. .changeset/windows-short-path-watch.md +5 -0
  19. .editorconfig +12 -0
  20. .gitattributes +10 -35
  21. .gitignore +45 -0
  22. .husky/install.mjs +18 -0
  23. .husky/pre-commit +4 -0
  24. .npmrc +3 -0
  25. .nvmrc +1 -0
  26. .oxfmtrc.json +19 -0
  27. .oxlintrc.json +181 -0
  28. AGENTS.md +93 -0
  29. CLAUDE.md +93 -0
  30. CONTRIBUTING.md +102 -0
  31. CONTRIBUTING.zh-CN.md +102 -0
  32. LICENSE +21 -0
  33. Makefile +67 -0
  34. README.md +138 -0
  35. README.zh-CN.md +130 -0
  36. SECURITY.md +33 -0
  37. docs/.gitignore +4 -0
  38. docs/AGENTS.md +328 -0
  39. docs/index.md +29 -0
  40. docs/package.json +19 -0
  41. flake.lock +27 -0
  42. flake.nix +261 -0
  43. package.json +63 -0
  44. plugins/marketplace.json +60 -0
  45. pnpm-lock.yaml +0 -0
  46. pnpm-workspace.yaml +15 -0
  47. scripts/check-service-naming.mjs +70 -0
  48. scripts/fix-node-pty-perms.mjs +46 -0
  49. tsconfig.json +46 -0
  50. vitest.config.ts +25 -0
.changeset/README.md ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Changesets
2
+
3
+ This repository uses [changesets](https://github.com/changesets/changesets) to manage npm package versions and releases.
4
+
5
+ ## Package Publishing Strategy
6
+
7
+ This repository uses an **independent, manually-selected publishing** strategy. When generating a changeset, only select the publishable packages that this change actually affects. The repository's `.changeset/config.json` already filters out internal workspace packages via `ignore`, so only the publishable packages listed below should appear in the `pnpm changeset` prompt.
8
+
9
+ Current publishable packages:
10
+
11
+ | Package | Directory | Description |
12
+ | --- | --- | --- |
13
+ | `@moonshot-ai/kimi-code` | `apps/kimi-code` | CLI / TUI application — provides the `kimi` command after install |
14
+ | `@moonshot-ai/kimi-code-sdk` | `packages/node-sdk` | Public TypeScript SDK |
15
+
16
+ All other workspace packages are private internal packages, are not published to npm, and are excluded via `ignore` in `.changeset/config.json`:
17
+
18
+ - `@moonshot-ai/kaos`
19
+ - `@moonshot-ai/kimi-code-oauth`
20
+ - `@moonshot-ai/kimi-telemetry`
21
+ - `@moonshot-ai/kosong`
22
+ - `@moonshot-ai/migration-legacy`
23
+ - `@moonshot-ai/vis`
24
+ - `@moonshot-ai/vis-server`
25
+ - `@moonshot-ai/vis-web`
26
+
27
+ Version impact from internal dependencies must be judged manually. The published artifacts for CLI and SDK bundle internal workspace packages into the artifact itself; runtime `dependencies` of published packages must not include any `@moonshot-ai/*` internal workspace packages.
28
+
29
+ The repository's `.changeset/config.json` sets `updateInternalDependencies: "patch"`. Because internal packages are not published, you still need to manually select all affected publishable packages in the changeset — do not rely solely on automatic dependency bumps to express user-visible changes.
30
+
31
+ Example scenarios:
32
+
33
+ | Change | Changeset selection |
34
+ | --- | --- |
35
+ | Only modifies TUI behavior in `@moonshot-ai/kimi-code` | Add `patch` / `minor` / `major` to `@moonshot-ai/kimi-code` |
36
+ | Only modifies internal packages, no user-visible change in SDK / CLI | Usually no changeset needed |
37
+ | Internal package fix changes the CLI user experience | Add a changeset to `@moonshot-ai/kimi-code` describing the user-visible fix |
38
+ | Internal package adds a new capability exposed by the SDK | Add a changeset to `@moonshot-ai/kimi-code-sdk` |
39
+ | SDK behavior change affects CLI user experience | Add changesets to both `@moonshot-ai/kimi-code-sdk` and `@moonshot-ai/kimi-code` |
40
+ | Provider abstraction change affects SDK / CLI | Add changesets to the affected `@moonshot-ai/kimi-code-sdk` and/or `@moonshot-ai/kimi-code` |
41
+ | Test-only, internal refactor, docs, or private debug tooling changes | Usually no changeset needed |
42
+ | Bundled official plugin change under `plugins/` (e.g. `kimi-datasource`) | No changeset — the plugin is versioned via its own `kimi.plugin.json` / `plugins/marketplace.json` and shipped through the marketplace CDN, not the npm package |
43
+
44
+ ## Prerequisite: NPM Trusted Publishing (OIDC)
45
+
46
+ This repository uses npm's **Trusted Publishing** (OIDC-based) for publishing — no `NPM_TOKEN` is required.
47
+
48
+ ### Configuration steps
49
+
50
+ 1. Open each publishable package's page on the npm website, e.g. `https://www.npmjs.com/package/@moonshot-ai/kimi-code`.
51
+ 2. Go to **Settings** -> **Publishing access**.
52
+ 3. Find **Automate publishing with GitHub Actions** or **Add trusted publisher**.
53
+ 4. Click **Add a new trusted publisher**.
54
+
55
+ Fill in the following:
56
+
57
+ | Field | Value |
58
+ | --- | --- |
59
+ | GitHub Organization | `MoonshotAI` |
60
+ | GitHub Repository | `kimi-code` |
61
+ | GitHub Workflow | `release.yml` |
62
+ | Environment | leave empty |
63
+
64
+ Each publishable package needs its Trusted Publisher configured once. The current GitHub Actions workflow lives at `.github/workflows/release.yml` and already has `id-token: write` configured.
65
+
66
+ ## Development Workflow
67
+
68
+ ### 1. Implement the feature or fix
69
+
70
+ Complete code, tests, and documentation changes as usual. A changeset is required when the change affects user-visible behavior, public API, dependency ranges, or release artifacts of a publishable package.
71
+
72
+ ### 2. Generate a changeset
73
+
74
+ From the repository root:
75
+
76
+ ```sh
77
+ pnpm changeset
78
+ ```
79
+
80
+ Follow the prompts to choose:
81
+
82
+ - Which publishable packages this change affects;
83
+ - The version bump level:
84
+ - `patch`: bug fixes, small changes, follow-up dependency updates;
85
+ - `minor`: backward-compatible new features;
86
+ - `major`: breaking changes;
87
+ - A user-facing description of the change.
88
+
89
+ The command creates a `.changeset/*.md` file that must be committed alongside the code.
90
+
91
+ ### 3. Commit the changeset
92
+
93
+ ```sh
94
+ git add .changeset/
95
+ git commit -m "chore: add changeset for package release"
96
+ git push
97
+ ```
98
+
99
+ Commit messages must follow Conventional Commit style. Do not include any author/agent identity in the commit message.
100
+
101
+ ### 4. CI generates the release PR
102
+
103
+ Once the changeset file is merged into `main`, `.github/workflows/release.yml` uses `changesets/action@v1` to create or update a release PR.
104
+
105
+ The release PR runs:
106
+
107
+ - `pnpm changeset version`: bumps publishable package versions and updates changelogs;
108
+ - Deletes the consumed `.changeset/*.md` files;
109
+ - Uses the title `[CI]: Release packages`.
110
+
111
+ ### 5. Merge the release PR
112
+
113
+ Once the release PR is merged into `main`, the same workflow runs:
114
+
115
+ - `pnpm install --frozen-lockfile`
116
+ - `pnpm build`
117
+ - `pnpm changeset publish`
118
+
119
+ The packages are then published via npm Trusted Publishing, and a GitHub Release is created.
120
+
121
+ ## Manual Publishing (Not Recommended)
122
+
123
+ Only publish manually when CI is unavailable. Before publishing manually, make sure you are logged into npm locally and using the Node.js and pnpm versions required by the repository.
124
+
125
+ ```sh
126
+ pnpm run version
127
+ pnpm run publish
128
+ ```
129
+
130
+ The underlying changesets commands are:
131
+
132
+ ```sh
133
+ pnpm changeset version
134
+ pnpm changeset publish
135
+ ```
136
+
137
+ The root-level `pnpm run publish` first runs typecheck, lint, sherif, test, build, and package lint, then runs `changeset publish`.
138
+
139
+ ## Notes
140
+
141
+ - Every PR that affects publishable-package behavior or public API should include a corresponding changeset.
142
+ - Changes under `plugins/` (the bundled official plugins such as `kimi-datasource`) do **not** need a changeset: each plugin carries its own version in `kimi.plugin.json` and `plugins/marketplace.json` and is distributed via the marketplace CDN, separately from the `@moonshot-ai/kimi-code` npm package.
143
+ - Changeset files must be committed to the repository — release PRs are only triggered after they're merged.
144
+ - Release PRs require human review and merge; they will not publish automatically.
145
+ - Do not add release changesets for private internal packages; only select `@moonshot-ai/kimi-code` and `@moonshot-ai/kimi-code-sdk`.
146
+ - If a change in an underlying internal package alters user-visible behavior or public API of a publishable package, add a changeset to the affected publishable package. For example, when a bug fixed in `@moonshot-ai/kosong` resolves an issue CLI users encounter, add a changeset to `@moonshot-ai/kimi-code` describing the user-visible fix.
147
+ - `@moonshot-ai/kimi-code` is the official CLI package name; after a global install it provides the `kimi` command.
148
+ - Make sure each publishable package on npm has a Trusted Publisher configured.
149
+
150
+ ## References
151
+
152
+ - [Changesets documentation](https://github.com/changesets/changesets)
153
+ - [Changesets GitHub Action](https://github.com/changesets/action)
154
+ - [npm Trusted Publishing documentation](https://docs.npmjs.com/trusted-publishers)
.changeset/abort-error-escape.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ---
2
+ "@moonshot-ai/kimi-code": patch
3
+ ---
4
+
5
+ Fix an occasional crash when a running turn is canceled.
.changeset/config.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "changelog": ["@changesets/changelog-github", { "repo": "MoonshotAI/kimi-code" }],
3
+ "commit": false,
4
+ "fixed": [],
5
+ "linked": [],
6
+ "access": "public",
7
+ "baseBranch": "main",
8
+ "updateInternalDependencies": "patch",
9
+ "ignore": [
10
+ "@moonshot-ai/vis",
11
+ "@moonshot-ai/vis-server",
12
+ "@moonshot-ai/vis-web",
13
+ "@moonshot-ai/kimi-inspect"
14
+ ],
15
+ "snapshot": {
16
+ "useCalculatedVersion": true,
17
+ "prereleaseTemplate": "{tag}-{commit}"
18
+ }
19
+ }
.changeset/diff-fence-palette-colors.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ---
2
+ "@moonshot-ai/kimi-code": patch
3
+ ---
4
+
5
+ Highlight diff code blocks.
.changeset/fix-steer-message-duplicates.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ---
2
+ "@moonshot-ai/kimi-code": patch
3
+ ---
4
+
5
+ Fix duplicate user messages when steering an ongoing conversation.
.changeset/fix-steered-file-attachments-reload.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ---
2
+ "@moonshot-ai/kimi-code": patch
3
+ ---
4
+
5
+ Fix files attached while steering an ongoing conversation appearing only after a reload.
.changeset/fix-steered-slash-command-missing.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ---
2
+ "@moonshot-ai/kimi-code": patch
3
+ ---
4
+
5
+ Fix slash commands sent while steering an ongoing conversation missing from the transcript.
.changeset/fix-undo-transcript.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ---
2
+ "@moonshot-ai/kimi-code": patch
3
+ ---
4
+
5
+ Fix missing and reappearing chat messages after undoing a steered message.
.changeset/fix-usage-sessionless-message.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ---
2
+ "@moonshot-ai/kimi-code": patch
3
+ ---
4
+
5
+ Fix /usage showing a wrong error message when no session has been created yet.
.changeset/kimi-image-upload-references.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ---
2
+ "@moonshot-ai/kimi-code": patch
3
+ ---
4
+
5
+ Images sent to Kimi models are uploaded as file references instead of inline data, and a warning is shown when media are dropped from a retried request.
.changeset/lazy-subagent-scope-eviction.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ---
2
+ "@moonshot-ai/kimi-code": patch
3
+ ---
4
+
5
+ Limit memory growth from finished subagents.
.changeset/manager-stopped-subagents-report-cancelled.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ---
2
+ "@moonshot-ai/kimi-code": patch
3
+ ---
4
+
5
+ Report background subagents that time out or are stopped as cancelled instead of failed.
.changeset/media-request-budget.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ---
2
+ "@moonshot-ai/kimi-code": patch
3
+ ---
4
+
5
+ When accumulated images and videos exceed the request size budget, the oldest media are omitted from requests with a warning instead of failing.
.changeset/propagate-user-cancellation-to-tools.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ---
2
+ "@moonshot-ai/kimi-code": patch
3
+ ---
4
+
5
+ Report tools and subagents interrupted by the user as cancelled instead of aborted or failed.
.changeset/rename-webbridge-display-name.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ---
2
+ "@moonshot-ai/kimi-code": patch
3
+ ---
4
+
5
+ The built-in browser plugin now appears as "Kimi Browser Extension" in the plugins panel, marketplace catalog, and docs, matching the product rename.
.changeset/survey-kfc-model-id.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ---
2
+ "@moonshot-ai/kimi-code": patch
3
+ ---
4
+
5
+ Feedback surveys now appear at better times in long conversations.
.changeset/tower-rework-subagent-card.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ---
2
+ "@moonshot-ai/kimi-code": patch
3
+ ---
4
+
5
+ Fix tower worker cards wrongly showing "completed" during rework.
.changeset/windows-short-path-watch.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ---
2
+ "@moonshot-ai/kimi-code": patch
3
+ ---
4
+
5
+ Fix a Windows crash when a project or config folder is opened through a short 8.3 path.
.editorconfig ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ end_of_line = lf
6
+ indent_size = 2
7
+ indent_style = space
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.md]
12
+ trim_trailing_whitespace = false
.gitattributes CHANGED
@@ -1,35 +1,10 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
1
+ # Enforce LF line endings in the working tree on every platform so that
2
+ # raw-imported text (e.g. `*.md?raw` templates) is byte-identical on Windows
3
+ # and POSIX. Without this, Git for Windows' default `core.autocrlf=true`
4
+ # checks text files out as CRLF, which shifts token-count snapshots.
5
+ * text=auto eol=lf
6
+
7
+ # Binary assets — never normalize line endings.
8
+ *.gif binary
9
+ *.ico binary
10
+ *.png binary
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.gitignore ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ node_modules/
2
+ dist/
3
+ dist-single/
4
+ dist-native/
5
+ .tmp-api-extractor/
6
+ .contract-types-tmp/
7
+ .local/
8
+ coverage/
9
+ *.tsbuildinfo
10
+ .vitest-results/
11
+ .vite/
12
+ .DS_Store
13
+ .playwright-mcp/
14
+ .claude
15
+ .conductor
16
+ .kimi-stash-dir
17
+ plugins/cdn/
18
+ .worktrees/
19
+ .kimi-code/local.toml
20
+ .kimi-sandbox/
21
+ .vscode/
22
+ !apps/vscode/.vscode/
23
+ !apps/vscode/.vscode/*.json
24
+ apps/vscode/artifacts/
25
+
26
+ Dockerfile
27
+ docker-compose.yml
28
+ .dockerignore
29
+
30
+ docs/superpowers/
31
+ reports/
32
+ .superpowers/
33
+ /plan/
34
+
35
+ # Agent scratch / throwaway files - do not commit
36
+ .tmp/
37
+ HANDOVER*.md
38
+ HANDOFF*.md
39
+ handoff.md
40
+ handover.md
41
+ *-designs.html
42
+ *-design.html
43
+ *-mockup.html
44
+ *-demo.html
45
+ *-demos.html
.husky/install.mjs ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { existsSync } from 'node:fs';
2
+
3
+ if (
4
+ process.env.NODE_ENV === 'production' ||
5
+ process.env.CI === 'true' ||
6
+ process.env.npm_config_production === 'true' ||
7
+ !existsSync('.git')
8
+ ) {
9
+ process.exit(0);
10
+ }
11
+
12
+ try {
13
+ const husky = (await import('husky')).default;
14
+ console.log(husky());
15
+ } catch (error) {
16
+ if (error && error.code === 'ERR_MODULE_NOT_FOUND') process.exit(0);
17
+ throw error;
18
+ }
.husky/pre-commit ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ set -e
2
+
3
+ node scripts/check-no-comments.mjs
4
+ pnpm lint-staged
.npmrc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ auto-install-peers=true
2
+ engine-strict=true
3
+ strict-peer-dependencies=false
.nvmrc ADDED
@@ -0,0 +1 @@
 
 
1
+ 24.15.0
.oxfmtrc.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "$schema": "./node_modules/oxfmt/configuration_schema.json",
3
+ "printWidth": 100,
4
+ "tabWidth": 2,
5
+ "useTabs": false,
6
+ "semi": true,
7
+ "singleQuote": true,
8
+ "trailingComma": "all",
9
+ "bracketSpacing": true,
10
+ "arrowParens": "always",
11
+ "endOfLine": "lf",
12
+ "sortImports": {
13
+ "groups": ["builtin", "external", "internal", ["parent", "sibling", "index"], "unknown"],
14
+ "newlinesBetween": true,
15
+ "order": "asc"
16
+ },
17
+ "sortPackageJson": true,
18
+ "ignorePatterns": ["dist/", "coverage/", "pnpm-lock.yaml", "*.generated.ts"]
19
+ }
.oxlintrc.json ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "$schema": "./node_modules/oxlint/configuration_schema.json",
3
+ "categories": {
4
+ "correctness": "error",
5
+ "suspicious": "warn",
6
+ "pedantic": "warn",
7
+ "perf": "warn"
8
+ },
9
+ "plugins": ["typescript", "import", "unicorn", "promise", "node"],
10
+ "rules": {
11
+ "eslint/no-useless-return": "off",
12
+ "eslint/no-shadow": "off",
13
+ "eslint/eqeqeq": "error",
14
+ "eslint/no-throw-literal": "off",
15
+ "eslint/no-control-regex": "off",
16
+ "typescript/no-misused-promises": "error",
17
+ "typescript/return-await": "error",
18
+ "typescript/only-throw-error": "error",
19
+ "import/no-cycle": "error",
20
+ "import/no-self-import": "error",
21
+ "import/no-unassigned-import": "off",
22
+ "unicorn/prefer-node-protocol": "error",
23
+ "unicorn/no-useless-undefined": "off",
24
+ "unicorn/no-lonely-if": "off",
25
+ "unicorn/no-array-callback-reference": "off",
26
+ "typescript/prefer-promise-reject-errors": "off",
27
+ "typescript/no-unsafe-function-type": "off",
28
+ "typescript/no-unsafe-argument": "off",
29
+ "typescript/no-unsafe-assignment": "off",
30
+ "typescript/no-unsafe-call": "off",
31
+ "typescript/no-unsafe-member-access": "off",
32
+ "typescript/no-unsafe-return": "off",
33
+
34
+ "eslint/no-console": "warn",
35
+ "typescript/no-explicit-any": "off",
36
+ "typescript/no-non-null-assertion": "off",
37
+ "typescript/use-unknown-in-catch-callback-variable": "off",
38
+ "typescript/consistent-type-imports": "off",
39
+ "typescript/ban-types": "off",
40
+ "import/first": "warn",
41
+ "import/extensions": [
42
+ "error",
43
+ "ignorePackages",
44
+ {
45
+ "js": "never",
46
+ "ts": "never",
47
+ "tsx": "never"
48
+ }
49
+ ],
50
+ "import/no-duplicates": "warn",
51
+ "import/no-mutable-exports": "warn",
52
+ "unicorn/error-message": "warn",
53
+ "unicorn/throw-new-error": "warn",
54
+ "unicorn/catch-error-name": "warn",
55
+ "unicorn/prefer-add-event-listener": "off",
56
+ "node/no-new-require": "warn",
57
+ "node/no-path-concat": "warn",
58
+
59
+ "promise/no-callback-in-promise": "warn",
60
+ "promise/valid-params": "warn",
61
+ "promise/no-return-in-finally": "warn",
62
+ "promise/always-return": "off",
63
+
64
+ "eslint/max-classes-per-file": "off",
65
+ "eslint/max-depth": "off",
66
+ "eslint/max-lines": "off",
67
+ "eslint/max-lines-per-function": "off",
68
+ "eslint/max-nested-callbacks": "off",
69
+ "eslint/no-warning-comments": "off",
70
+ "eslint/no-inline-comments": "off",
71
+ "eslint/no-negated-condition": "off",
72
+ "eslint/no-await-in-loop": "off",
73
+ "eslint/require-await": "off",
74
+ "typescript/require-await": "off",
75
+ "eslint/sort-vars": "off",
76
+ "eslint/radix": "off",
77
+ "eslint/symbol-description": "off",
78
+ "typescript/consistent-return": "off",
79
+ "unicorn/consistent-function-scoping": "off",
80
+ "typescript/no-deprecated": "off",
81
+ "typescript/no-unsafe-type-assertion": "off",
82
+ "typescript/strict-boolean-expressions": "off",
83
+ "typescript/no-duplicate-type-constituents": "off",
84
+ "import/max-dependencies": "off"
85
+ },
86
+ "overrides": [
87
+ {
88
+ "files": ["**/examples/**/*.ts", "**/examples/**/*.tsx"],
89
+ "rules": {
90
+ "eslint/no-console": "off"
91
+ }
92
+ },
93
+ {
94
+ // The worker closures: these modules (and everything
95
+ // packages/minidb/src/worker/ and
96
+ // packages/kap-server/src/search/worker/ pull in) are loaded by a bare
97
+ // node:worker_threads Worker under Node's native type stripping with
98
+ // `execArgv: ['--experimental-transform-types']`, which requires
99
+ // explicit `.ts` import specifiers (the strip loader does not remap
100
+ // `.js` -> `.ts`). Keep the exception scoped to exactly those closures.
101
+ "files": [
102
+ "packages/minidb/src/worker/**/*.ts",
103
+ "packages/minidb/src/codec.ts",
104
+ "packages/minidb/src/crc32.ts",
105
+ "packages/minidb/src/trigram.ts",
106
+ "packages/minidb/src/text-postings.ts",
107
+ "packages/minidb/src/text-index/tokenize.ts",
108
+ "packages/minidb/src/gen-codec.ts",
109
+ "packages/kap-server/src/search/worker/**/*.ts",
110
+ "packages/kap-server/src/search/indexCore.ts",
111
+ "packages/kap-server/src/search/match.ts"
112
+ ],
113
+ "rules": {
114
+ "import/extensions": "off"
115
+ }
116
+ },
117
+ {
118
+ "files": ["packages/kosong/src/providers/**/*.ts"],
119
+ "rules": {
120
+ "typescript/no-unsafe-argument": "off",
121
+ "typescript/no-unsafe-assignment": "off",
122
+ "typescript/no-unsafe-call": "off",
123
+ "typescript/no-unsafe-member-access": "off",
124
+ "typescript/no-unsafe-return": "off"
125
+ }
126
+ },
127
+ {
128
+ "files": [
129
+ "**/*.test.ts",
130
+ "**/*.test.tsx",
131
+ "**/*.spec.ts",
132
+ "**/*.spec.tsx",
133
+ "**/test/**/*.ts",
134
+ "**/test/**/*.tsx"
135
+ ],
136
+ "plugins": ["vitest"],
137
+ "rules": {
138
+ "typescript/no-explicit-any": "off",
139
+ "typescript/no-unsafe-assignment": "off",
140
+ "typescript/no-unsafe-argument": "off",
141
+ "typescript/no-non-null-assertion": "off",
142
+ "typescript/unbound-method": "off",
143
+ "typescript/no-redundant-type-constituents": "off",
144
+ "eslint/no-console": "off",
145
+ "eslint/no-promise-executor-return": "off",
146
+ "typescript/no-unsafe-member-access": "off",
147
+ "vitest/require-mock-type-parameters": "off",
148
+ "eslint/no-shadow": "off",
149
+ "unicorn/prefer-event-target": "off",
150
+ "jest/no-disabled-tests": "off",
151
+ "vitest/no-disabled-tests": "off",
152
+ "eslint/no-control-regex": "off",
153
+ "eslint/no-unused-vars": "off",
154
+ "eslint/no-unsafe-optional-chaining": "off",
155
+ "jest/valid-expect": "off",
156
+ "unicorn/no-useless-spread": "off",
157
+ "import/no-cycle": "off",
158
+ "typescript/no-meaningless-void-operator": "off",
159
+ "typescript/require-array-sort-compare": "off",
160
+ "vitest/expect-expect": "error",
161
+ "vitest/no-conditional-tests": "error",
162
+ "vitest/no-focused-tests": "error",
163
+ "vitest/no-identical-title": "error",
164
+ "vitest/valid-expect": "off",
165
+ "vitest/valid-describe-callback": "error",
166
+ "vitest/no-standalone-expect": "error",
167
+ "vitest/warn-todo": "off"
168
+ }
169
+ }
170
+ ],
171
+ "ignorePatterns": [
172
+ "dist/",
173
+ "dist-web/",
174
+ "coverage/",
175
+ "node_modules/",
176
+ "apps/*/scripts/",
177
+ "docs/smoke-archive/",
178
+ "packages/pi-tui/",
179
+ "*.generated.ts"
180
+ ]
181
+ }
AGENTS.md ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Repository-level Agent Guide
2
+
3
+ Reply in the same language as the user.
4
+
5
+ This is a TypeScript monorepo built for agent-assisted development. Keep the root `AGENTS.md` limited to hot-path rules: the project map, hard constraints, and workflow requirements — things every task needs to know.
6
+
7
+ ## Working Principles
8
+
9
+ - Think from first principles. Start from real requirements, code facts, and verification results; if the goal is unclear, discuss it with the user first.
10
+ - Treat code, not documentation, as the source of truth. Unless the user explicitly says otherwise, do not read ordinary Markdown just to understand the implementation.
11
+ - Before making code changes, read the relevant code and the most recent constraints, and follow the nearest `AGENTS.md` in the directory tree.
12
+ - Keep changes focused. Do not slip in unrelated refactors along the way.
13
+ - When committing, do not add any co-author attribution, and do not reveal the identity of the agent in commit messages, PR descriptions, or any explanatory text.
14
+
15
+ ## Project Map
16
+
17
+ - `apps/kimi-code`: the CLI / TUI application. It consumes core capabilities through `@moonshot-ai/kimi-code-sdk` and must not depend directly on engine packages. When writing or modifying its terminal UI, use the `write-tui` skill (`.agents/skills/write-tui/SKILL.md`).
18
+ - the browser web UI: **its source no longer lives in this repo.** It is developed in the code-app repo (`apps/web`) and shipped as the committed, prebuilt bundle `apps/kimi-code/dist-web` (gitignored, force-added), synced from code-app with `KIMI_CODE_REPO=<this checkout> pnpm run sync:web` — sync and commit the bundle in the same change whenever the web UI should ship differently. `apps/kimi-code/scripts/check-web-assets.mjs` guards packaging against a missing bundle. To hack on the web UI against this repo's server, run `pnpm dev:server` here and point code-app's `pnpm dev:web` at it via `KIMI_SERVER_URL`.
19
+ - `apps/vis`, `apps/vis/server`, `apps/vis/web`: visual debugging tools for sessions and replays.
20
+ - `apps/kimi-inspect`: web inspector for the kap-server `/api/v1/debug` RPC surface — workspace/session browser, per-session transcript chat, per-scope Service panels, and the DI unit inspection view. See `apps/kimi-inspect/AGENTS.md`.
21
+ - `packages/agent-core-v2`: the DI × Scope agent engine (the v2 port behind kap-server). Four `LifecycleScope` tiers — `App` / `Workspace` / `Session` / `Agent` (`app/scopes.ts`) — plus the L3 unit layer (`Service`/`Fiber` units, collection contribution points, the Feature seam in `src/features/`); there is no App-level session lifecycle facade — callers compose `ISessionIndex` → `IWorkspaceLifecycleService.handlerFor` → the handler.
22
+ - `packages/node-sdk`: the public TypeScript SDK and harness.
23
+ - `packages/kosong`: the LLM / provider abstraction layer.
24
+ - `packages/kaos`: the execution environment and file/process abstractions.
25
+ - `packages/oauth`: Kimi OAuth and managed auth utilities.
26
+ - `packages/telemetry`: shared client-side telemetry infrastructure.
27
+ - `packages/transcript`: the isomorphic transcript rendering data layer — L1 agent-granular store, L2 idempotent operations, L3 `off/turn/block/delta` subscription granularity, L4 framework-free view registry, plus turn-cursor pagination. Pure TypeScript (browser-safe, no engine imports); the sole owner of the transcript contract types (`src/contract/`) and the op-batch sequencing contract.
28
+ - `packages/kap-server`: the Kimi Code server, backed by `@moonshot-ai/agent-core-v2`; exposes sessions over REST + WebSocket (`/api/v1` + `/api/v1/ws`), plus the `/api/v1/debug/*` reflection RPC surface (`--debug-endpoints`, loopback bind + bearer auth).
29
+ - `packages/remote-control`: the Kimi Remote Control tunnel client — registers this machine with the relay and forwards HTTP/WebSocket traffic to the local server, with a machine-wide single-instance lock; consumed by kap-server (the `/api/v1/remote-control` toggle) and by the CLI (`kimi web --remote-control`).
30
+ - `packages/klient`: the client SDK — a contract-driven facade over agent-core-v2 (`global.*` / `session(id).*` / `agent(id).*`, zod-validated); transport via subpath entry (`@moonshot-ai/klient/ipc|memory`, both return the same `Klient`); also hosts the e2e suites. See `packages/klient/AGENTS.md`.
31
+ - `packages/tree-sitter-bash`: a pure-TypeScript bash parser (no runtime deps, no wasm); `parse(source, { timeoutMs, maxNodes })` runs under a deterministic budget and returns a discriminated `ParseResult` — callers must treat aborted/hasError trees as "cannot analyze" and degrade. Parser only, no safety judgments; see the package README's "Known differences" section.
32
+ - `packages/minidb`: the embedded JSON document store (`MiniDb`) behind kap-server's search index — snapshot + WAL persistence with an exclusive write lock, a larger-than-RAM full-text layer, and persistent index generations. See `packages/minidb/AGENTS.md`.
33
+
34
+ ## Environment Requirements
35
+
36
+ - **Node.js**: `>=24.15.0` (from the root `package.json` `engines`; `.nvmrc` is `24.15.0`, used by nvm / fnm / mise to pick the minimum recommended version).
37
+ - **pnpm**: `10.33.0` (from the root `package.json` `packageManager`).
38
+ - `pnpm install` will fail when the Node version is not satisfied, because `.npmrc` sets `engine-strict=true`.
39
+
40
+ ## Monorepo Workspace Maintenance
41
+
42
+ - `pnpm-workspace.yaml` is the source of truth for workspace membership, but `flake.nix` also contains **hardcoded** `workspacePaths` and `workspaceNames` lists.
43
+ - **Whenever you add or remove a workspace package, you MUST update both `pnpm-workspace.yaml` and `flake.nix` — for every package, including leaf / test / e2e packages that nothing depends on.**
44
+ - `pnpm-workspace.yaml` uses globs (`packages/*`, `apps/*`), so most packages land there automatically; `flake.nix` is fully manual and is where omissions happen.
45
+ - Missing a path in `flake.nix`'s `workspacePaths` will silently drop files from the Nix build's `src` fileset.
46
+ - Missing a name in `flake.nix`'s `workspaceNames` will break `pnpmConfigHook` because dependencies for that workspace will not be fetched.
47
+ - The automated "Check flake.nix workspace sync" (`scripts/check-nix-workspace.mjs`) only validates the transitive dependency **closure of `@moonshot-ai/kimi-code`**. A leaf package outside that closure (e.g. an e2e package nobody imports) slips through even when it is missing from `flake.nix`. A green check is therefore NOT proof that `flake.nix` is fully in sync — keep it updated by hand on every add/remove, do not rely on the check to catch omissions.
48
+
49
+ ## General Coding Rules
50
+
51
+ - `packages/agent-core-v2`, `packages/kap-server`, and `packages/transcript` are comment-free zones: no comments of any kind — no line/block comments, no JSDoc (not even on exported symbols); the only exception is load-bearing lint-suppression directives (`oxlint-disable` / `eslint-disable`), while other tooling directives (`@ts-expect-error`, …) stay banned. Enforced by `scripts/check-no-comments.mjs` over `.ts`/`.tsx`/`.mts`/`.mjs` under `src/`/`test/`/`scripts/`, which runs as part of `pnpm lint`.
52
+ - For optional object properties, pass `undefined` directly instead of using conditional spread.
53
+ - YES: `{ user }`
54
+ - NO: `{ ...(user ? { user } : undefined) }`
55
+ - Optional object properties do not need to additionally allow `undefined` in the type.
56
+ - YES: `interface Options { user?: User }`
57
+ - NO: `interface Options { user?: User | undefined }`
58
+ - Internal methods with only a single parameter should not be turned into options objects just for stylistic uniformity.
59
+ - Split functions only along abstraction levels: each function reads as one level of narrative (Step-down Rule), and a wrapper that adds no new abstraction level — especially one with a single call site — is inlined instead of extracted.
60
+ - Except for a package's `index.ts`, other `index.ts` files should prefer `export * from './module';`.
61
+ - When writing or updating tests, follow the `tdd` skill (`.agents/skills/tdd/SKILL.md`).
62
+ - Do not add too many new test files. Prefer adding tests to the existing test file of the corresponding component or module.
63
+ - When a test fails because of a user modification, default to fixing the test first; do not change the implementation to satisfy an old test unless the implementation truly has a bug.
64
+ - Do not sacrifice code quality for external compatibility unless the user explicitly asks for it. Breaking changes go through changesets and a `major` bump, gated by the rule below.
65
+
66
+ ## Experimental Features
67
+
68
+ - Gate a not-yet-public feature behind an experimental flag. Flags are env-driven and default off: `KIMI_CODE_EXPERIMENTAL_<NAME>` toggles one, `KIMI_CODE_EXPERIMENTAL_FLAG` enables all. Precedence is per-flag env > `[experimental]` config > master env > the flag's `default`. Release by flipping the entry's `default` to `true`.
69
+ - `packages/agent-core-v2` and kap-server modules: there is no central catalog — declare the flag in the owning domain via `registerFlagDefinition` at import time, then check it with `IFlagService.enabled(id)`.
70
+
71
+ ## Where to Update Instructions
72
+
73
+ - Hard rules that affect almost every task: update the root `AGENTS.md`.
74
+ - Rules that only affect a specific directory: update the nearest sub-directory `AGENTS.md`.
75
+ - Project-map entries stay at 1–2 sentences; deep package docs live in the package's own `AGENTS.md`.
76
+ - Keep instruction updates focused and supported by code facts.
77
+
78
+ ## Workflow Requirements
79
+
80
+ - Prefer `rg` / `rg --files` when reading code.
81
+ - When designing changes, follow existing boundaries and local patterns first.
82
+ - In public text and test data, replace real internal identifiers with neutral placeholders such as `example.com`, `example.test`, and `YOUR_API_KEY`. Before opening a PR, ask a read-only agent to audit the diff for context-specific internal identifiers.
83
+ - When creating a PR, the PR title must follow Conventional Commit style, e.g. `chore: remove legacy format commands`.
84
+ - When an AI agent opens or updates a PR, fill in `.github/pull_request_template.md` — link the related issue or explain the problem, then describe what changed. Do not leave placeholder text or submit a generic summary of the diff.
85
+ - Do not submit vague AI-generated PR text. The human author must understand the change well enough to explain the code, edge cases, and why the approach fits this repository.
86
+ - After finishing a task and before submitting a PR, you must run the `gen-changesets` skill (see `.agents/skills/gen-changesets/SKILL.md`) and generate a changeset under `.changeset/` according to its rules.
87
+ - Changesets must strictly follow the rules in `.agents/skills/gen-changesets/SKILL.md`: write one short user-facing sentence that states only what changed, and skip any change users cannot perceive.
88
+ - When generating a changeset, **never** decide on a `major` bump on your own — stop, explain, and get explicit user confirmation first; default to `minor`, fall back to `patch`. See `.agents/skills/gen-changesets/SKILL.md`.
89
+ - Prefer importing via `import ... from '#/...'`, which serves the same purpose as `import ... from '@/...'`.
90
+ - Do not commit throwaway scratch or exploratory files. Never stage:
91
+ - Agent working notes or handoff/summary documents (e.g. `HANDOVER-*.md`, `HANDOFF-*.md`, `handoff.md`).
92
+ - Throwaway UI/UX prototypes or design mockups (e.g. `*-designs.html`, `*-mockup.html`, `*-demo(s).html`) at the repo root or under a `design/` folder. The only tracked `.html` files should be Vite `index.html` entrypoints.
93
+ Before committing or opening a PR, run `git status` and `git diff --staged --stat` and remove anything matching these patterns. Put scratch work under `.tmp/` (gitignored) instead of the repo root or the source tree.
CLAUDE.md ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Repository-level Agent Guide
2
+
3
+ Reply in the same language as the user.
4
+
5
+ This is a TypeScript monorepo built for agent-assisted development. Keep the root `AGENTS.md` limited to hot-path rules: the project map, hard constraints, and workflow requirements — things every task needs to know.
6
+
7
+ ## Working Principles
8
+
9
+ - Think from first principles. Start from real requirements, code facts, and verification results; if the goal is unclear, discuss it with the user first.
10
+ - Treat code, not documentation, as the source of truth. Unless the user explicitly says otherwise, do not read ordinary Markdown just to understand the implementation.
11
+ - Before making code changes, read the relevant code and the most recent constraints, and follow the nearest `AGENTS.md` in the directory tree.
12
+ - Keep changes focused. Do not slip in unrelated refactors along the way.
13
+ - When committing, do not add any co-author attribution, and do not reveal the identity of the agent in commit messages, PR descriptions, or any explanatory text.
14
+
15
+ ## Project Map
16
+
17
+ - `apps/kimi-code`: the CLI / TUI application. It consumes core capabilities through `@moonshot-ai/kimi-code-sdk` and must not depend directly on engine packages. When writing or modifying its terminal UI, use the `write-tui` skill (`.agents/skills/write-tui/SKILL.md`).
18
+ - the browser web UI: **its source no longer lives in this repo.** It is developed in the code-app repo (`apps/web`) and shipped as the committed, prebuilt bundle `apps/kimi-code/dist-web` (gitignored, force-added), synced from code-app with `KIMI_CODE_REPO=<this checkout> pnpm run sync:web` — sync and commit the bundle in the same change whenever the web UI should ship differently. `apps/kimi-code/scripts/check-web-assets.mjs` guards packaging against a missing bundle. To hack on the web UI against this repo's server, run `pnpm dev:server` here and point code-app's `pnpm dev:web` at it via `KIMI_SERVER_URL`.
19
+ - `apps/vis`, `apps/vis/server`, `apps/vis/web`: visual debugging tools for sessions and replays.
20
+ - `apps/kimi-inspect`: web inspector for the kap-server `/api/v1/debug` RPC surface — workspace/session browser, per-session transcript chat, per-scope Service panels, and the DI unit inspection view. See `apps/kimi-inspect/AGENTS.md`.
21
+ - `packages/agent-core-v2`: the DI × Scope agent engine (the v2 port behind kap-server). Four `LifecycleScope` tiers — `App` / `Workspace` / `Session` / `Agent` (`app/scopes.ts`) — plus the L3 unit layer (`Service`/`Fiber` units, collection contribution points, the Feature seam in `src/features/`); there is no App-level session lifecycle facade — callers compose `ISessionIndex` → `IWorkspaceLifecycleService.handlerFor` → the handler.
22
+ - `packages/node-sdk`: the public TypeScript SDK and harness.
23
+ - `packages/kosong`: the LLM / provider abstraction layer.
24
+ - `packages/kaos`: the execution environment and file/process abstractions.
25
+ - `packages/oauth`: Kimi OAuth and managed auth utilities.
26
+ - `packages/telemetry`: shared client-side telemetry infrastructure.
27
+ - `packages/transcript`: the isomorphic transcript rendering data layer — L1 agent-granular store, L2 idempotent operations, L3 `off/turn/block/delta` subscription granularity, L4 framework-free view registry, plus turn-cursor pagination. Pure TypeScript (browser-safe, no engine imports); the sole owner of the transcript contract types (`src/contract/`) and the op-batch sequencing contract.
28
+ - `packages/kap-server`: the Kimi Code server, backed by `@moonshot-ai/agent-core-v2`; exposes sessions over REST + WebSocket (`/api/v1` + `/api/v1/ws`), plus the `/api/v1/debug/*` reflection RPC surface (`--debug-endpoints`, loopback bind + bearer auth).
29
+ - `packages/remote-control`: the Kimi Remote Control tunnel client — registers this machine with the relay and forwards HTTP/WebSocket traffic to the local server, with a machine-wide single-instance lock; consumed by kap-server (the `/api/v1/remote-control` toggle) and by the CLI (`kimi web --remote-control`).
30
+ - `packages/klient`: the client SDK — a contract-driven facade over agent-core-v2 (`global.*` / `session(id).*` / `agent(id).*`, zod-validated); transport via subpath entry (`@moonshot-ai/klient/ipc|memory`, both return the same `Klient`); also hosts the e2e suites. See `packages/klient/AGENTS.md`.
31
+ - `packages/tree-sitter-bash`: a pure-TypeScript bash parser (no runtime deps, no wasm); `parse(source, { timeoutMs, maxNodes })` runs under a deterministic budget and returns a discriminated `ParseResult` — callers must treat aborted/hasError trees as "cannot analyze" and degrade. Parser only, no safety judgments; see the package README's "Known differences" section.
32
+ - `packages/minidb`: the embedded JSON document store (`MiniDb`) behind kap-server's search index — snapshot + WAL persistence with an exclusive write lock, a larger-than-RAM full-text layer, and persistent index generations. See `packages/minidb/AGENTS.md`.
33
+
34
+ ## Environment Requirements
35
+
36
+ - **Node.js**: `>=24.15.0` (from the root `package.json` `engines`; `.nvmrc` is `24.15.0`, used by nvm / fnm / mise to pick the minimum recommended version).
37
+ - **pnpm**: `10.33.0` (from the root `package.json` `packageManager`).
38
+ - `pnpm install` will fail when the Node version is not satisfied, because `.npmrc` sets `engine-strict=true`.
39
+
40
+ ## Monorepo Workspace Maintenance
41
+
42
+ - `pnpm-workspace.yaml` is the source of truth for workspace membership, but `flake.nix` also contains **hardcoded** `workspacePaths` and `workspaceNames` lists.
43
+ - **Whenever you add or remove a workspace package, you MUST update both `pnpm-workspace.yaml` and `flake.nix` — for every package, including leaf / test / e2e packages that nothing depends on.**
44
+ - `pnpm-workspace.yaml` uses globs (`packages/*`, `apps/*`), so most packages land there automatically; `flake.nix` is fully manual and is where omissions happen.
45
+ - Missing a path in `flake.nix`'s `workspacePaths` will silently drop files from the Nix build's `src` fileset.
46
+ - Missing a name in `flake.nix`'s `workspaceNames` will break `pnpmConfigHook` because dependencies for that workspace will not be fetched.
47
+ - The automated "Check flake.nix workspace sync" (`scripts/check-nix-workspace.mjs`) only validates the transitive dependency **closure of `@moonshot-ai/kimi-code`**. A leaf package outside that closure (e.g. an e2e package nobody imports) slips through even when it is missing from `flake.nix`. A green check is therefore NOT proof that `flake.nix` is fully in sync — keep it updated by hand on every add/remove, do not rely on the check to catch omissions.
48
+
49
+ ## General Coding Rules
50
+
51
+ - `packages/agent-core-v2`, `packages/kap-server`, and `packages/transcript` are comment-free zones: no comments of any kind — no line/block comments, no JSDoc (not even on exported symbols); the only exception is load-bearing lint-suppression directives (`oxlint-disable` / `eslint-disable`), while other tooling directives (`@ts-expect-error`, …) stay banned. Enforced by `scripts/check-no-comments.mjs` over `.ts`/`.tsx`/`.mts`/`.mjs` under `src/`/`test/`/`scripts/`, which runs as part of `pnpm lint`.
52
+ - For optional object properties, pass `undefined` directly instead of using conditional spread.
53
+ - YES: `{ user }`
54
+ - NO: `{ ...(user ? { user } : undefined) }`
55
+ - Optional object properties do not need to additionally allow `undefined` in the type.
56
+ - YES: `interface Options { user?: User }`
57
+ - NO: `interface Options { user?: User | undefined }`
58
+ - Internal methods with only a single parameter should not be turned into options objects just for stylistic uniformity.
59
+ - Split functions only along abstraction levels: each function reads as one level of narrative (Step-down Rule), and a wrapper that adds no new abstraction level — especially one with a single call site — is inlined instead of extracted.
60
+ - Except for a package's `index.ts`, other `index.ts` files should prefer `export * from './module';`.
61
+ - When writing or updating tests, follow the `tdd` skill (`.agents/skills/tdd/SKILL.md`).
62
+ - Do not add too many new test files. Prefer adding tests to the existing test file of the corresponding component or module.
63
+ - When a test fails because of a user modification, default to fixing the test first; do not change the implementation to satisfy an old test unless the implementation truly has a bug.
64
+ - Do not sacrifice code quality for external compatibility unless the user explicitly asks for it. Breaking changes go through changesets and a `major` bump, gated by the rule below.
65
+
66
+ ## Experimental Features
67
+
68
+ - Gate a not-yet-public feature behind an experimental flag. Flags are env-driven and default off: `KIMI_CODE_EXPERIMENTAL_<NAME>` toggles one, `KIMI_CODE_EXPERIMENTAL_FLAG` enables all. Precedence is per-flag env > `[experimental]` config > master env > the flag's `default`. Release by flipping the entry's `default` to `true`.
69
+ - `packages/agent-core-v2` and kap-server modules: there is no central catalog — declare the flag in the owning domain via `registerFlagDefinition` at import time, then check it with `IFlagService.enabled(id)`.
70
+
71
+ ## Where to Update Instructions
72
+
73
+ - Hard rules that affect almost every task: update the root `AGENTS.md`.
74
+ - Rules that only affect a specific directory: update the nearest sub-directory `AGENTS.md`.
75
+ - Project-map entries stay at 1–2 sentences; deep package docs live in the package's own `AGENTS.md`.
76
+ - Keep instruction updates focused and supported by code facts.
77
+
78
+ ## Workflow Requirements
79
+
80
+ - Prefer `rg` / `rg --files` when reading code.
81
+ - When designing changes, follow existing boundaries and local patterns first.
82
+ - In public text and test data, replace real internal identifiers with neutral placeholders such as `example.com`, `example.test`, and `YOUR_API_KEY`. Before opening a PR, ask a read-only agent to audit the diff for context-specific internal identifiers.
83
+ - When creating a PR, the PR title must follow Conventional Commit style, e.g. `chore: remove legacy format commands`.
84
+ - When an AI agent opens or updates a PR, fill in `.github/pull_request_template.md` — link the related issue or explain the problem, then describe what changed. Do not leave placeholder text or submit a generic summary of the diff.
85
+ - Do not submit vague AI-generated PR text. The human author must understand the change well enough to explain the code, edge cases, and why the approach fits this repository.
86
+ - After finishing a task and before submitting a PR, you must run the `gen-changesets` skill (see `.agents/skills/gen-changesets/SKILL.md`) and generate a changeset under `.changeset/` according to its rules.
87
+ - Changesets must strictly follow the rules in `.agents/skills/gen-changesets/SKILL.md`: write one short user-facing sentence that states only what changed, and skip any change users cannot perceive.
88
+ - When generating a changeset, **never** decide on a `major` bump on your own — stop, explain, and get explicit user confirmation first; default to `minor`, fall back to `patch`. See `.agents/skills/gen-changesets/SKILL.md`.
89
+ - Prefer importing via `import ... from '#/...'`, which serves the same purpose as `import ... from '@/...'`.
90
+ - Do not commit throwaway scratch or exploratory files. Never stage:
91
+ - Agent working notes or handoff/summary documents (e.g. `HANDOVER-*.md`, `HANDOFF-*.md`, `handoff.md`).
92
+ - Throwaway UI/UX prototypes or design mockups (e.g. `*-designs.html`, `*-mockup.html`, `*-demo(s).html`) at the repo root or under a `design/` folder. The only tracked `.html` files should be Vite `index.html` entrypoints.
93
+ Before committing or opening a PR, run `git status` and `git diff --staged --stat` and remove anything matching these patterns. Put scratch work under `.tmp/` (gitignored) instead of the repo root or the source tree.
CONTRIBUTING.md ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributing to kimi-code
2
+
3
+ [中文版](CONTRIBUTING.zh-CN.md)
4
+
5
+ Thanks for taking the time to contribute! This project moves quickly, and thoughtful contributions from the community are what keep it sharp. The guide below walks you through how we work so your PR has the best chance of landing smoothly.
6
+
7
+ ## Before You Start
8
+
9
+ Kimi Code already has opinions on CLI/TUI behavior, agent workflows, and public APIs. If your change shifts that direction, open an issue first so we can align before you invest time in a PR.
10
+
11
+ We hold AI-assisted contributions to the same standard as hand-written ones. **You should understand what you submit** — what changed, how it behaves at the edges, and why it fits this codebase. If you cannot explain that, the PR is not ready for review.
12
+
13
+ We only merge PRs aligned with the roadmap. Drive-by refactors without context are unlikely to land.
14
+
15
+ **External PRs are accepted for approved bug fixes only.** Open an issue first and wait for a maintainer to approve it with an `/approve` comment, then link that issue in your PR. PRs without an approved linked issue may be closed without review; once the issue is approved, ask a maintainer to reopen your PR.
16
+
17
+ **Discuss first** — open an issue before coding:
18
+
19
+ - Bug fixes, including small or typo-level ones: open a bug issue and wait for a maintainer's `/approve` before opening the PR
20
+ - New features or user-visible behavior changes (regardless of size): external feature PRs are not accepted — features are discussed and decided in issues, and accepted features are implemented by the team or by explicit maintainer invitation
21
+ - Refactors or other changes larger than ~100 lines
22
+ - Public API or compatibility changes
23
+
24
+ ## Project Layout
25
+
26
+ This is a pnpm monorepo. The most relevant entry points are:
27
+
28
+ - `apps/kimi-code` — CLI / TUI
29
+ - `apps/vscode` — VS Code extension
30
+ - `apps/vis` — session debug visualizer
31
+ - `packages/node-sdk` — public TypeScript SDK (`@moonshot-ai/kimi-code-sdk`)
32
+ - `packages/agent-core-v2` — the agent engine (v2, DI Scope architecture); `packages/agent-core` is v1 and being phased out
33
+ - `packages/klient`, `kap-server`, `protocol`, `transcript`, `kosong`, `kaos`, `oauth`, `telemetry` — internal engine packages
34
+ - `docs/` — VitePress bilingual docs site
35
+
36
+ For the full project map, see [AGENTS.md](AGENTS.md).
37
+
38
+ ## Development Setup
39
+
40
+ Prerequisites: Node.js >= 24.15.0, pnpm 10.33.0, Git.
41
+
42
+ ```sh
43
+ git clone https://github.com/MoonshotAI/kimi-code.git
44
+ cd kimi-code
45
+ pnpm install
46
+ ```
47
+
48
+ Useful scripts:
49
+
50
+ - `pnpm dev:cli` — run the CLI in dev mode
51
+ - `pnpm test` — run tests (vitest)
52
+ - `pnpm typecheck` — TypeScript check (note: builds packages first)
53
+ - `pnpm lint` — oxlint
54
+ - `pnpm lint:fix` — oxlint with auto-fix
55
+ - `pnpm build` — build all packages
56
+
57
+ ## Commit Convention
58
+
59
+ All commits and PR titles must follow [Conventional Commits](https://www.conventionalcommits.org/).
60
+
61
+ | Type | Use for | Example |
62
+ |----------|---------------------------------------------|-------------------------------------------|
63
+ | feat | A new feature | feat(agent-core-v2): add tool dedup |
64
+ | fix | A bug fix | fix(tui): correct status bar alignment |
65
+ | docs | Documentation only | docs: clarify install instructions |
66
+ | chore | Tooling / housekeeping | chore: bump dependencies |
67
+ | refactor | Internal refactor without behavior change | refactor(kosong): extract retry helper |
68
+ | test | Adding or improving tests | test(agent-core-v2): cover skill resolver |
69
+ | ci | CI / build pipeline changes | ci: cache pnpm store |
70
+ | build | Build system / artifact changes | build(native): add win32-arm64 target |
71
+ | perf | Performance improvement | perf(session): batch event flushes |
72
+ | style | Formatting only (no logic) | style: apply oxlint --fix |
73
+
74
+ PR titles are enforced by the `pr-title-checker` workflow — a non-conforming title will block merge.
75
+
76
+ ## Changesets
77
+
78
+ This repo uses [changesets](https://github.com/changesets/changesets) to manage versioning and releases.
79
+
80
+ - Every PR that affects release artifacts (code, behavior, public API) **must** include a changeset.
81
+ - Docs-only, test-only, or CI-only PRs may skip changesets.
82
+ - Generate one with `pnpm changeset` and follow the prompts (which packages are touched, which bump level).
83
+ - For repo-specific conventions on package selection and bump levels, see `.changeset/README.md`. When working in this repo with coding agents, use the `gen-changesets` skill.
84
+
85
+ ## Pull Requests
86
+
87
+ Every PR opens with the [PR template](.github/pull_request_template.md). PR titles must follow [Conventional Commits](#commit-convention); CI runs `pnpm lint`, `pnpm typecheck`, and `pnpm test` on every PR. Update user-facing docs in `docs/` when behavior changes — use the `gen-docs` skill when working with coding agents.
88
+
89
+ ## Code Style
90
+
91
+ - TypeScript across the codebase.
92
+ - Linting via `oxlint` (config in `.oxlintrc.json`).
93
+ - Auto-formatting via `pnpm lint:fix`.
94
+ - Follow existing local patterns when the lint rules do not cover a style choice.
95
+
96
+ ## Reporting Security Issues
97
+
98
+ Found a security issue? Please see [SECURITY.md](SECURITY.md) instead of opening a public issue.
99
+
100
+ ## License
101
+
102
+ By contributing to this repository, you agree that your contributions will be licensed under the [MIT License](LICENSE).
CONTRIBUTING.zh-CN.md ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 为 kimi-code 贡献代码
2
+
3
+ [English version](CONTRIBUTING.md)
4
+
5
+ 感谢你花时间参与贡献!这个项目迭代很快,离不开社区认真的贡献。下面的指南介绍我们的工作方式,帮助你的 PR 顺利合入。
6
+
7
+ ## 开始之前
8
+
9
+ Kimi Code 对 CLI/TUI 行为、agent 工作流和公开 API 已有自己的主张。如果你的改动会改变这些方向,请先开 issue 对齐,再投入时间写 PR。
10
+
11
+ 我们对 AI 辅助贡献与手写代码一视同仁。**你应该理解自己提交的内容**——改了什么、边界情况下表现如何、为什么适合这个代码库。如果你解释不清楚,这个 PR 就还没准备好接受评审。
12
+
13
+ 我们只合入与路线图一致的 PR。缺乏上下文背景的顺手重构很难被接受。
14
+
15
+ **外部 PR 仅接受获批准的 bug 修复。** 先开 issue,等待维护者以 `/approve` 评论明确批准,然后在 PR 中链接该 issue。没有已批准关联 issue 的 PR 可能会不经评审直接关闭;issue 获批后,可联系维护者重开你的 PR。
16
+
17
+ **先讨论**——写代码前先开 issue:
18
+
19
+ - bug 修复(包括小的、错别字级别的):先开 bug issue,等待维护者 `/approve` 后再提 PR
20
+ - 新功能或用户可见的行为变更(无论大小):不接受外部 feature PR——功能在 issue 中讨论和决定,被接受的功能由团队实现,或由维护者明确邀请你贡献
21
+ - 重构或其他超过约 100 行的改动
22
+ - 公开 API 或兼容性变更
23
+
24
+ ## 项目结构
25
+
26
+ 本仓库是 pnpm monorepo,最常用的入口:
27
+
28
+ - `apps/kimi-code` — CLI / TUI
29
+ - `apps/vscode` — VS Code 插件
30
+ - `apps/vis` — 会话调试可视化工具
31
+ - `packages/node-sdk` — 公开 TypeScript SDK(`@moonshot-ai/kimi-code-sdk`)
32
+ - `packages/agent-core-v2` — 当前的 agent 引擎(v2,DI Scope 架构);`packages/agent-core` 为 v1,正在逐步废弃
33
+ - `packages/klient`、`kap-server`、`protocol`、`transcript`、`kosong`、`kaos`、`oauth`、`telemetry` — 内部引擎包
34
+ - `docs/` — VitePress 双语文档站
35
+
36
+ 完整项目地图见 [AGENTS.md](AGENTS.md)。
37
+
38
+ ## 开发环境
39
+
40
+ 前置要求:Node.js >= 24.15.0、pnpm 10.33.0、Git。
41
+
42
+ ```sh
43
+ git clone https://github.com/MoonshotAI/kimi-code.git
44
+ cd kimi-code
45
+ pnpm install
46
+ ```
47
+
48
+ 常用脚本:
49
+
50
+ - `pnpm dev:cli` — 开发模式运行 CLI
51
+ - `pnpm test` — 运行测试(vitest)
52
+ - `pnpm typecheck` — TypeScript 检查(注意:会先构建各包)
53
+ - `pnpm lint` — oxlint
54
+ - `pnpm lint:fix` — oxlint 自动修复
55
+ - `pnpm build` — 构建全部包
56
+
57
+ ## 提交规范
58
+
59
+ 所有 commit 和 PR 标题必须遵循 [Conventional Commits](https://www.conventionalcommits.org/)。
60
+
61
+ | 类型 | 用途 | 示例 |
62
+ |----------|------------------------------------------|----------------------------------------|
63
+ | feat | 新功能 | feat(agent-core-v2): add tool dedup |
64
+ | fix | bug 修复 | fix(tui): correct status bar alignment |
65
+ | docs | 仅文档 | docs: clarify install instructions |
66
+ | chore | 工具 / 杂务 | chore: bump dependencies |
67
+ | refactor | 无行为变更的内部重构 | refactor(kosong): extract retry helper |
68
+ | test | 新增或改进测试 | test(agent-core-v2): cover skill resolver |
69
+ | ci | CI / 构建流水线变更 | ci: cache pnpm store |
70
+ | build | 构建系统 / 产物变更 | build(native): add win32-arm64 target |
71
+ | perf | 性能优化 | perf(session): batch event flushes |
72
+ | style | 仅格式化(无逻辑变更) | style: apply oxlint --fix |
73
+
74
+ PR 标题由 `pr-title-checker` 工作流强制校验——不合规的标题会阻止合并。
75
+
76
+ ## Changesets
77
+
78
+ 本仓库使用 [changesets](https://github.com/changesets/changesets) 管理版本与发布。
79
+
80
+ - 每个影响发布产物(代码、行为、公开 API)的 PR **必须**包含 changeset。
81
+ - 仅文档、仅测试或仅 CI 的 PR 可以不加。
82
+ - 用 `pnpm changeset` 生成并按提示操作(涉及哪些包、什么 bump 级别)。
83
+ - 包选择与 bump 级别的仓库约定见 `.changeset/README.md`。在本仓库使用编程 agent 时,使用 `gen-changesets` 技能。
84
+
85
+ ## Pull Requests
86
+
87
+ PR 会自动套用 [PR 模板](.github/pull_request_template.md)。PR 标题必须遵循 [Conventional Commits](#提交规范);每个 PR 的 CI 会运行 `pnpm lint`、`pnpm typecheck` 和 `pnpm test`。行为变更时请同步更新 `docs/` 下的用户文档——使用编程 agent 时使用 `gen-docs` 技能。
88
+
89
+ ## 代码风格
90
+
91
+ - 全仓库 TypeScript。
92
+ - 使用 `oxlint`(配置见 `.oxlintrc.json`)。
93
+ - 用 `pnpm lint:fix` 自动格式化。
94
+ - lint 规则未覆盖的风格选择,跟随周边现有写法。
95
+
96
+ ## 报告安全问题
97
+
98
+ 发现安全问题?请查看 [SECURITY.md](SECURITY.md),不要开公开 issue。
99
+
100
+ ## 许可证
101
+
102
+ 向本仓库贡献即表示你同意你的贡献按 [MIT 许可证](LICENSE) 授权。
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Moonshot AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
Makefile ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .PHONY: prepare build typecheck lint lint-fix lint-pkg sherif test test-watch test-coverage clean changeset version publish release dev vis
2
+
3
+ ## Setup
4
+
5
+ prepare:
6
+ pnpm install
7
+
8
+ ## Build
9
+
10
+ build:
11
+ pnpm run build
12
+
13
+ ## Quality
14
+
15
+ typecheck:
16
+ pnpm run typecheck
17
+
18
+ lint:
19
+ pnpm run lint
20
+
21
+ lint-fix:
22
+ pnpm run lint:fix
23
+
24
+ sherif:
25
+ pnpm run sherif
26
+
27
+ lint-pkg:
28
+ pnpm run lint:pkg
29
+
30
+ ## Test
31
+
32
+ test:
33
+ pnpm run test
34
+
35
+ test-watch:
36
+ pnpm run test:watch
37
+
38
+ test-coverage:
39
+ pnpm run test:coverage
40
+
41
+ ## Clean
42
+
43
+ clean:
44
+ pnpm run clean
45
+
46
+ ## Release
47
+
48
+ changeset:
49
+ pnpm run changeset
50
+
51
+ version:
52
+ pnpm run version
53
+
54
+ publish:
55
+ pnpm run publish
56
+
57
+ release: version publish
58
+
59
+ ## Development
60
+
61
+ dev:
62
+ pnpm run dev:cli
63
+
64
+ ## vis
65
+
66
+ vis:
67
+ pnpm run vis
README.md ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - agent
5
+ - coding-agent
6
+ - cli
7
+ - llm
8
+ - tool-use
9
+ ---
10
+
11
+ > **This is a source mirror.** This Hugging Face repository is not a model checkpoint — it's a read-only mirror of the [`MoonshotAI/kimi-code`](https://github.com/MoonshotAI/kimi-code) GitHub repository, Moonshot AI's terminal coding agent. It is hosted here for visibility on the Hub; the canonical repository, issue tracker, and pull requests all live on GitHub. Please file issues and contribute there, not here.
12
+
13
+ # Kimi Code CLI
14
+
15
+ [![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE) [![Docs](https://img.shields.io/badge/docs-online-blue)](https://moonshotai.github.io/kimi-code/en/) <br>
16
+ [Documentation](https://moonshotai.github.io/kimi-code/en/) · [Issues](https://github.com/MoonshotAI/kimi-code/issues) · [中文](README.zh-CN.md)
17
+
18
+ ![Demo of using Kimi Code](./docs/media/intro.gif)
19
+
20
+ ## What is Kimi Code CLI
21
+
22
+ Kimi Code CLI is an AI coding agent that runs in your terminal — it can read and edit code, run shell commands, search files, fetch web pages, and choose the next step based on the feedback it receives. It works out of the box with Moonshot AI’s Kimi models and can also be configured to use other compatible providers.
23
+
24
+ ## Install
25
+
26
+ Install with the official script. No Node.js required.
27
+
28
+ - **macOS or Linux**:
29
+
30
+ ```sh
31
+ curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash
32
+ ```
33
+
34
+ - **Windows (PowerShell)**:
35
+
36
+ ```powershell
37
+ irm https://code.kimi.com/kimi-code/install.ps1 | iex
38
+ ```
39
+
40
+ > On Windows, install [Git for Windows](https://gitforwindows.org/) before first launch because 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`.
41
+
42
+ Then, run it with a new shell session:
43
+
44
+ ```sh
45
+ kimi --version
46
+ ```
47
+
48
+ For npm install, upgrade, uninstall, see [Getting Started](https://moonshotai.github.io/kimi-code/en/guides/getting-started).
49
+
50
+ ## Quick Start
51
+
52
+ Open a project and start the interactive UI:
53
+
54
+ ```sh
55
+ cd your-project
56
+ kimi
57
+ ```
58
+
59
+ On first launch, run `/login` inside Kimi Code CLI and choose either Kimi Code OAuth or a Moonshot AI Open Platform API key. After login, try your first task:
60
+
61
+ ```
62
+ Take a look at this project and explain its main directories.
63
+ ```
64
+
65
+ ## Key Features
66
+
67
+ - **Single-binary distribution.** Install with one command: no Node.js setup, PATH gymnastics, or global module conflicts.
68
+ - **Blazing-fast startup.** The TUI is ready in milliseconds, so starting a session never feels heavy.
69
+ - **Purpose-built TUI.** A carefully tuned interface, optimized end to end for long, focused agent sessions.
70
+ - **Video input.** Drop a screen recording or demo clip into the chat and let the agent watch what is hard to describe in words — turn a reference clip into a LUT, a long video into a short, a screen recording into working code, and more.
71
+ - **AI-native MCP configuration.** Add, edit, and authenticate Model Context Protocol servers conversationally with `/mcp-config`, without hand-editing JSON.
72
+ - **Rich plugin ecosystem.** Install skills, MCP servers, and data sources from the marketplace or any GitHub repo, with each install's trust level surfaced up front.
73
+ - **Subagents for focused, parallel work.** Dispatch built-in `coder`, `explore`, and `plan` subagents in isolated contexts while keeping the main conversation clean.
74
+ - **Lifecycle hooks.** Run local commands at key points to gate risky tool calls, audit decisions, trigger desktop notifications, or connect to your own automation.
75
+ - **Editor & IDE integration (ACP).** Drive a Kimi Code CLI session straight from Zed, JetBrains, or any [Agent Client Protocol](https://agentclientprotocol.com/) client with `kimi acp`.
76
+
77
+ ## Use it in your editor (ACP)
78
+
79
+ Kimi Code CLI speaks the [Agent Client Protocol](https://agentclientprotocol.com/), so ACP-compatible editors and IDEs (Zed, JetBrains, …) can drive a session over stdio. Log in once, then point your editor at the `kimi acp` subcommand — no extra login needed.
80
+
81
+ For Zed, add this to `~/.config/zed/settings.json`:
82
+
83
+ ```json
84
+ {
85
+ "agent_servers": {
86
+ "Kimi Code CLI": {
87
+ "type": "custom",
88
+ "command": "kimi",
89
+ "args": ["acp"],
90
+ "env": {}
91
+ }
92
+ }
93
+ }
94
+ ```
95
+
96
+ Then open a new conversation in Zed's Agent panel. See [Using in IDEs](https://moonshotai.github.io/kimi-code/en/guides/ides) for JetBrains setup and troubleshooting, and the [`kimi acp` reference](https://moonshotai.github.io/kimi-code/en/reference/kimi-acp) for the full capability matrix.
97
+
98
+ ## Docs
99
+
100
+ - [Getting Started](https://moonshotai.github.io/kimi-code/en/guides/getting-started)
101
+ - [Interaction and approvals](https://moonshotai.github.io/kimi-code/en/guides/interaction)
102
+ - [Sessions](https://moonshotai.github.io/kimi-code/en/guides/sessions)
103
+ - [Using in IDEs (ACP)](https://moonshotai.github.io/kimi-code/en/guides/ides)
104
+ - [Configuration](https://moonshotai.github.io/kimi-code/en/configuration/config-files)
105
+ - [Command reference](https://moonshotai.github.io/kimi-code/en/reference/kimi-command)
106
+
107
+ ## Develop
108
+
109
+ Requirements: Node.js ≥ 24.15.0, pnpm 10.33.0.
110
+
111
+ ```sh
112
+ git clone https://github.com/MoonshotAI/kimi-code.git
113
+ cd kimi-code
114
+ pnpm install
115
+ ```
116
+
117
+ ```sh
118
+ pnpm dev:cli # run the CLI in dev mode
119
+ pnpm test # run tests
120
+ pnpm typecheck # TypeScript check
121
+ pnpm lint # oxlint
122
+ pnpm build # build all packages
123
+ ```
124
+
125
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the full contribution guide.
126
+
127
+ ## Community
128
+
129
+ - [Issues](https://github.com/MoonshotAI/kimi-code/issues)
130
+ - For security vulnerabilities, see [SECURITY.md](SECURITY.md).
131
+
132
+ ## Acknowledgements
133
+
134
+ Our TUI is built on top of [`pi-tui`](https://github.com/earendil-works/pi-mono/tree/main/packages/tui). We thank the authors of `pi-tui` for their valuable work.
135
+
136
+ ## License
137
+
138
+ Released under the [MIT License](LICENSE).
README.zh-CN.md ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Kimi Code CLI
2
+
3
+ [![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE) [![Docs](https://img.shields.io/badge/docs-online-blue)](https://moonshotai.github.io/kimi-code/zh/)
4
+
5
+ [Documentation](https://moonshotai.github.io/kimi-code/zh/) · [Issues](https://github.com/MoonshotAI/kimi-code/issues) · [English](README.md)
6
+
7
+
8
+ ![Kimi Code 的使用演示](./docs/media/intro.gif)
9
+
10
+
11
+ ## 什么是 Kimi Code CLI
12
+
13
+ Kimi Code CLI 是一个运行在终端里的 AI 编程 agent,可以帮你读写代码、执行 shell 命令、检索文件、抓取网页,并根据反馈自主决定下一步动作。开箱即用对接 Moonshot AI 的 Kimi 模型,也可指向其他兼容厂商。
14
+
15
+ ## 安装
16
+
17
+ 推荐使用官方安装脚本,不需要提前安装 Node.js。
18
+
19
+ - **macOS / Linux**:
20
+
21
+ ```sh
22
+ curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash
23
+ ```
24
+
25
+ - **Windows(PowerShell)**:
26
+
27
+ ```powershell
28
+ irm https://code.kimi.com/kimi-code/install.ps1 | iex
29
+ ```
30
+
31
+ > Windows 用户首次启动前还需要安装 [Git for Windows](https://gitforwindows.org/),Kimi Code CLI 会使用其中的 Git Bash 作为 Shell 环境。如果 Git Bash 安装在非标准路径,请把 `KIMI_SHELL_PATH` 设为 `bash.exe` 的绝对路径。
32
+
33
+ 随后在新的终端会话中运行:
34
+
35
+ ```sh
36
+ kimi --version
37
+ ```
38
+
39
+ npm 安装、升级、卸载方式,见[快速上手](https://moonshotai.github.io/kimi-code/zh/guides/getting-started)。
40
+
41
+ ## 快速开始
42
+
43
+ 进入项目目录并启动交互界面:
44
+
45
+ ```sh
46
+ cd your-project
47
+ kimi
48
+ ```
49
+
50
+ 首次启动时,在 Kimi Code CLI 里输入 `/login`,选择 Kimi Code OAuth 或 Moonshot AI Open Platform API 密钥登录。登录完成后,可以先让它熟悉项目:
51
+
52
+ ```
53
+ 帮我看一下这个项目的目录结构,简单介绍一下每个目录是做什么的
54
+ ```
55
+
56
+ ## 核心特性
57
+
58
+ - **二进制发行,零环境依赖** 一行命令安装,不需要预装 Node.js,不用折腾 PATH,也不会和全局模块冲突。
59
+ - **极速启动** TUI 在毫秒级就绪,开一个新会话没有任何心智负担。
60
+ - **精致的 TUI 体验** 端到端打磨的交互界面,专为长时间、专注的 Agent 会话优化。
61
+ - **视频也能输入** 把屏幕录像、演示视频拖进对话,让 Agent 看那些难以用文字描述的东西——把参考片段做成 LUT、把长视频剪成短视频、把录屏变成代码,等等。
62
+ - **AI-native 的 MCP 配置** 通过 `/mcp-config` 对话式添加、编辑、认证 MCP 服务器,无需手写 JSON。
63
+ - **丰富的插件生态** 从插件市场或任意 GitHub 仓库安装 skills、MCP 服务器和数据源,每次安装都会标明来源的信任级别。
64
+ - **子 Agent 聚焦并行工作** 内置 `coder`、`explore`、`plan` 子 Agent 在隔离上下文中处理子任务,主对话保持清爽。
65
+ - **生命周期 hooks** 在关键节点执行本地命令:拦截高风险工具调用、审计决策、发送桌面通知,或对接你自己的自动化脚本。
66
+ - **编辑器 / IDE 集成(ACP)** 用 `kimi acp` 让 Zed、JetBrains 等任意 [Agent Client Protocol](https://agentclientprotocol.com/) 客户端直接驱动会话。
67
+
68
+
69
+ ## 在编辑器里使用(ACP)
70
+
71
+ Kimi Code CLI 支持 [Agent Client Protocol](https://agentclientprotocol.com/),ACP 兼容的编辑器 / IDE(Zed、JetBrains……)可以通过 stdio 直接驱动会话。登录一次后,把编辑器指向 `kimi acp` 子命令即可,无需重复登录。
72
+
73
+ 以 Zed 为例,在 `~/.config/zed/settings.json` 中加入:
74
+
75
+ ```json
76
+ {
77
+ "agent_servers": {
78
+ "Kimi Code CLI": {
79
+ "type": "custom",
80
+ "command": "kimi",
81
+ "args": ["acp"],
82
+ "env": {}
83
+ }
84
+ }
85
+ }
86
+ ```
87
+
88
+ 随后在 Zed 的 Agent 面板新建对话即可。JetBrains 配置与排障见[在 IDE 中使用](https://moonshotai.github.io/kimi-code/zh/guides/ides),完整能力矩阵见 [`kimi acp` 参考](https://moonshotai.github.io/kimi-code/zh/reference/kimi-acp)。
89
+
90
+ ## 文档
91
+
92
+ - [快速上手](https://moonshotai.github.io/kimi-code/zh/guides/getting-started)
93
+ - [交互与审批](https://moonshotai.github.io/kimi-code/zh/guides/interaction)
94
+ - [会话](https://moonshotai.github.io/kimi-code/zh/guides/sessions)
95
+ - [在 IDE 中使用(ACP)](https://moonshotai.github.io/kimi-code/zh/guides/ides)
96
+ - [配置](https://moonshotai.github.io/kimi-code/zh/configuration/config-files)
97
+ - [命令参考](https://moonshotai.github.io/kimi-code/zh/reference/kimi-command)
98
+
99
+ ## 本地开发
100
+
101
+ 环境要求:Node.js ≥ 24.15.0,pnpm 10.33.0。
102
+
103
+ ```sh
104
+ git clone https://github.com/MoonshotAI/kimi-code.git
105
+ cd kimi-code
106
+ pnpm install
107
+ ```
108
+
109
+ ```sh
110
+ pnpm dev:cli # 以开发模式运行 CLI
111
+ pnpm test # 运行测试
112
+ pnpm typecheck # TypeScript 检查
113
+ pnpm lint # 运行 oxlint
114
+ pnpm build # 构建所有包
115
+ ```
116
+
117
+ 完整贡献流程见 [CONTRIBUTING.md](CONTRIBUTING.md)。
118
+
119
+ ## 社区
120
+
121
+ - [Issues](https://github.com/MoonshotAI/kimi-code/issues)
122
+ - 安全漏洞反馈,请见 [SECURITY.md](SECURITY.md)。
123
+
124
+ ## 致谢
125
+
126
+ 我们的 TUI 构建在 [`pi-tui`](https://github.com/earendil-works/pi-mono/tree/main/packages/tui) 之上。我们衷心感谢 `pi-tui` 作者的工作。
127
+
128
+ ## 许可证
129
+
130
+ 基于 [MIT](LICENSE) 协议发布。
SECURITY.md ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Currently, Kimi Code only provides security support for the latest released version.
6
+
7
+ ## Reporting a Vulnerability
8
+
9
+ We take security seriously. **Please do not open a public issue for security vulnerabilities.**
10
+
11
+ Preferred channel:
12
+
13
+ - GitHub Security Advisories — https://github.com/MoonshotAI/kimi-code/security/advisories/new
14
+ (private disclosure, tracked with the codebase)
15
+
16
+ Alternative channel:
17
+
18
+ - Email: code@moonshot.ai (please include "[security]" in the subject)
19
+
20
+ ## What to Include
21
+
22
+ - Affected version (output of `kimi --version`)
23
+ - Reproduction steps
24
+ - Impact assessment
25
+ - Any suggested mitigation
26
+
27
+ ## Our Response
28
+
29
+ We will acknowledge your report and provide an initial assessment as soon as we can.
30
+
31
+ ## Public Disclosure
32
+
33
+ We will coordinate with you on disclosure timing once a fix is ready.
docs/.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ node_modules
2
+ .vitepress/dist
3
+ .vitepress/cache
4
+ .vitepress/.temp
docs/AGENTS.md ADDED
@@ -0,0 +1,328 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Documentation Agent Guide
2
+
3
+ This repository uses VitePress for the documentation site. Most user-facing pages under `docs/en/` and `docs/zh/` are fully written; New or updated content should keep both locales in sync.
4
+
5
+ ## Structure
6
+
7
+ - Locales live under `docs/en/` and `docs/zh/` with mirrored paths and filenames.
8
+ - Main sections (nav + sidebar) are:
9
+ - Guides: getting-started, migration, use-cases, interaction, sessions
10
+ - Customization: mcp, skills, plugins, datasource, agents, hooks
11
+ - Configuration: config-files, providers, overrides, env-vars, data-locations
12
+ - Reference: kimi-command, tools, slash-commands, keyboard
13
+ - Release notes: changelog
14
+ - Navigation and sidebar are defined in `docs/.vitepress/config.ts`. Any new or renamed page must be wired there for both locales.
15
+
16
+ ## Source of truth
17
+
18
+ - **Changelog page**: The English version (`docs/en/release-notes/changelog.md`) is the source of truth; the Chinese changelog should be translated from it. The changelog is currently generated manually by a skill that syncs from the CLI package's `CHANGELOG.md` after each release.
19
+ - **All other pages**: `docs/en/` and `docs/zh/` are mirrored pairs with the same paths, headings, and section structure. Edit whichever locale you are working in, and update the other locale in the same change.
20
+
21
+ Keep both locales in sync before release. Machine-assisted translation is fine; review the locale you changed and its mirror for accuracy, terminology, and broken links.
22
+
23
+ ## Authoring workflow
24
+
25
+ - Each page should keep the section ordering established by surrounding pages. Changelog is the exception because it is generated from release history.
26
+ - For other pages: edit either locale, then update its mirror in the same change.
27
+
28
+ Before rewriting a page, always: (1) understand why the original is structured the way it is, (2) identify what the reader genuinely needs to know, (3) sketch the section structure, then (4) fill in the content. Skip step 1–3 and you will lose content while rearranging format.
29
+
30
+ ## Readers
31
+
32
+ Kimi Code documentation serves two overlapping audiences. Write for both simultaneously.
33
+
34
+ **Technical users** — familiar with the terminal, config files, API keys, and environment variables. Give them commands and paths directly; do not explain basics.
35
+
36
+ **Non-technical AI users** — product managers, designers, operators — who use AI tools but are unfamiliar with terms like "stdin", "exit code", or "regex". They primarily interact through VS Code or config files rather than writing scripts.
37
+
38
+ Both groups share the same behavior: they arrive with a specific goal, scan headings and first sentences before reading further, execute steps in order, and copy-paste code blocks directly. They abandon pages when they hit unexplained jargon.
39
+
40
+ **Writing targets:**
41
+ - Technical users: complete a task in under 5 minutes, no filler.
42
+ - Non-technical users: copy-paste their way to a working setup and roughly understand what it does, without needing to understand the underlying mechanics.
43
+
44
+ **Jargon rule:** On first use, add a plain-English gloss in parentheses. Use the term normally afterwards.
45
+
46
+ > Example: `stdin` (the channel a program reads input from), `exit code` (the status number a program returns when it finishes; 0 means success).
47
+
48
+ ## Naming conventions
49
+
50
+ - Filenames are kebab-case and mirror across locales (same slug in `docs/en/` and `docs/zh/`).
51
+ - Use consistent section labels that match the sidebar titles.
52
+ - Use backticks for flags, commands, subcommands, command arguments, file paths, code identifiers, type names, field names, field values, and keyboard shortcuts.
53
+
54
+ ## Wording conventions
55
+
56
+ - Do not change H1 titles or nav/sidebar labels.
57
+ - English H2+ headings use sentence case (only the first word capitalized unless it is a proper noun). Treat "Wire", "Plan mode", "Thinking mode", and the permission mode names "Always Ask", "Ask When Needed", and "Never Ask" as proper nouns; do not treat "agent" as a proper noun.
58
+ - Chinese H2+ headings keep English words in sentence case; preserve proper nouns listed in the term table below.
59
+ - Use `API key` in English and `API 密钥` in Chinese; keep `JSON`, `JSONL`, `OAuth`, `macOS`, `Node.js`, `npm`, `pnpm`, and `TypeScript` as-is.
60
+ - Use straight double quotes with spaces for quoted content: `"被引内容"` (not curly quotes). Add a space before and after the quoted text when adjacent to CJK characters. Use corner brackets `「」` for special terms (e.g., `「工具」`, `「会话」`).
61
+ - Prefer "终端" over "命令行" in Chinese when both are applicable (e.g., "运行在终端中", "终端界面", "终端操作").
62
+ - Use "工具调用" / "tool call", not "工具使用" / "tool use".
63
+ - Use inline code for tool names (e.g., `Read`, `Grep`, `Bash`).
64
+
65
+ Term mapping (Chinese <-> English, and proper noun handling):
66
+
67
+ | Chinese | English | Proper noun (zh) | Proper noun (en) |
68
+ | --- | --- | --- | --- |
69
+ | Agent | agent | yes | no |
70
+ | main agent | main agent | no | no |
71
+ | subagent | subagent | no | no |
72
+ | Shell | shell | yes | no |
73
+ | Plan 模式 | Plan mode | yes | yes (Plan mode) |
74
+ | 始终询问 | Always Ask | yes | yes |
75
+ | 必要时询问 | Ask When Needed | yes | yes |
76
+ | 完全自动 | Never Ask | yes | yes |
77
+ | Thinking 模式 | Thinking mode | yes | yes (Thinking mode) |
78
+ | MCP | MCP | yes | yes |
79
+ | Kimi Code CLI | Kimi Code CLI | yes | yes |
80
+ | Agent Skills | Agent Skills | yes | yes |
81
+ | Skill | skill | yes | no |
82
+ | 系统提示词 | system prompt | no | no |
83
+ | 提示词 | prompt | no | no |
84
+ | 会话 | session | no | no |
85
+ | 上下文 | context | no | no |
86
+ | API 密钥 | API key | yes | no |
87
+ | JSON | JSON | yes | yes |
88
+ | JSONL | JSONL | yes | yes |
89
+ | OAuth | OAuth | yes | yes |
90
+ | macOS | macOS | yes | yes |
91
+ | TypeScript | TypeScript | yes | yes |
92
+ | Node.js | Node.js | yes | yes |
93
+ | npm | npm | yes | yes |
94
+ | pnpm | pnpm | yes | yes |
95
+ | kimi | kimi | yes | yes |
96
+ | 审批请求 | approval request | no | no |
97
+ | 斜杠命令 | slash command | no | no |
98
+ | 工具调用 | tool call | no | no |
99
+ | Frontmatter | frontmatter | yes | no |
100
+ | User 消息 | user message | yes (User) | no |
101
+ | Assistant 消息 | assistant message | yes (Assistant) | no |
102
+ | Tool 消息 | tool message | yes (Tool) | no |
103
+ | 轮次 | turn | no | no |
104
+ | 供应商 | provider | no | no |
105
+ | Prompt Flow | Prompt Flow | yes | yes |
106
+ | Diff | diff | yes | no |
107
+
108
+ ### Kimi platform rules
109
+
110
+ Two distinct platforms exist and must never be mixed:
111
+
112
+ | | Kimi Code platform | Kimi Open Platform |
113
+ |---|---|---|
114
+ | Audience | Individual developers, subscription-based | Enterprise / product integration, pay-per-token |
115
+ | OpenAI-compatible base URL | `https://api.kimi.com/coding/v1` | `https://api.moonshot.cn/v1` |
116
+ | Anthropic-compatible base URL | `https://api.kimi.com/coding/` | Not supported |
117
+ | API key entry | [Kimi Code console](https://www.kimi.com/code/console) | [platform.kimi.com](https://platform.kimi.com) |
118
+
119
+ Rules:
120
+ - When documenting Kimi Code CLI or VS Code: always use `api.kimi.com/coding/…`. Never write `api.moonshot.cn` in this context.
121
+ - When documenting Open Platform integration: use `api.moonshot.cn/v1`.
122
+ - Distinguish context explicitly: "in Kimi Code CLI / VS Code" vs "in third-party tools / your own product".
123
+ - Product full names: **Kimi Code CLI** and **Kimi Code for VS Code**. Do not abbreviate to "Kimi CLI".
124
+
125
+ ## Typography
126
+
127
+ - **Spacing around mixed content**: Add a space between Chinese characters and English words, numbers, inline code, or links. Exception: no space before full-width punctuation.
128
+ - ✓ 在 TypeScript 中使用 `class` 关键字
129
+ - ✗ 在TypeScript中使用`class`关键字
130
+ - ✓ 详见 [配置文件](./config.md)。
131
+ - ✗ 详见[配置文件](./config.md)。
132
+ - **Full-width punctuation**: Use full-width punctuation in Chinese text: `,。;:?!()` not `, . ; : ? ! ( )`.
133
+ - **Keyboard shortcuts**: Use hyphen between modifier and key (`Ctrl-C`, `Ctrl-D`, `Shift-Tab`, `Alt-V`), not plus sign. Exception: literal application output (e.g., the `Press Ctrl+C again to exit` hint produced by the product itself) keeps its exact rendering.
134
+ - **Code block language**: Always specify language for fenced code blocks (e.g., ` ```sh `, ` ```toml `, ` ```json `, ` ```ts `). Exception: natural language examples (user prompts) may omit the language.
135
+ - **Callout titles**: Use short category titles for callout blocks (`::: tip`, `::: warning`, `::: info`, `::: danger`). Put the detailed description in the block content, not the title.
136
+ - Chinese: use `提示` for tip, `注意` for warning, `说明` for info, `警告` for danger.
137
+ - English: use no title or short words like `Note` for warning.
138
+ - ✓ `::: tip 提示` + content starting with the key point
139
+ - ✓ `::: warning 注意` + content `部分 \`.agents\` 资源不受 \`KIMI_CODE_HOME\` 影响。...`
140
+ - ✗ `::: warning 不影响 .agents` (title too long, should be in content)
141
+ - ✗ `::: tip .agents 路径独立于 KIMI_CODE_HOME` (title too long)
142
+ - **Version info blocks**: For version change callouts, use `::: info` with a category title (Added/Changed/Removed in English; 新增/变更/移除 in Chinese). The content should be a complete sentence.
143
+ - ✓ `::: info 新增` + content `新增于 0.2.0。`
144
+ - ✗ `::: info 新增于 0.2.0` (title too long)
145
+ - ✓ `::: info Changed` + content `Renamed in 0.2.0. ...`
146
+ - ✗ `::: info Renamed in 0.2.0` (title too long)
147
+ - **Callout syntax**: Use `:::` for standalone callouts. `::::` is valid only as the outer fence of a nested container and must be correctly closed; an unclosed or mismatched `::::` breaks page rendering. When nesting is not needed, use a `>` blockquote inside a callout for secondary notes instead.
148
+
149
+ ## Writing style
150
+
151
+ - **Natural narrative**: Organize content like writing an article, guiding readers smoothly through the material.
152
+ - **Avoid fragmentation**: Don't turn every point into a subheading; use paragraph transitions instead. This applies to narrative content — explanations, motivations, and sequential reasoning that flow as connected prose.
153
+ - **Global perspective**: "Getting Started" introduces core concepts only; detailed usage belongs in later pages.
154
+ - **Progressive depth**: Guides → Customization → Configuration → Reference, information deepens gradually.
155
+ - **No nav tip blocks**: VitePress provides automatic prev/next navigation; don't add `::: tip 接下来` blocks at page end. A `## Next steps` section is appropriate when there are closely related follow-on pages — see [Page structure](#page-structure).
156
+ - **One idea per paragraph**: Each paragraph makes one point. 3–4 sentences is the target; split when a paragraph exceeds 5 sentences.
157
+ - **Map before detail**: Every page and every major section should open with one "map" sentence — what this section covers and how it relates to what came before — before expanding into details. Readers should know where they are before they dive in.
158
+
159
+ > ❌ Jump straight to detail: "Credential resolution has three steps: first read `api_key`…"
160
+ >
161
+ > ✓ Map then detail: "Provider credentials follow a separate resolution path from ordinary runtime parameters — the CLI reads only from `config.toml` and never falls back to shell environment variables. The priority order is:…"
162
+
163
+ - **Parallel content needs formatting**: This is the counterpart to "avoid fragmentation" — the distinction is what kind of content you have. Multiple items of the same kind (file descriptions, config field explanations, caveats) written as separate paragraphs with no visual distinction force readers to parse shape instead of meaning. Fix:
164
+ - Each item is "name + one sentence": use an unordered list: `- **Name**: description`
165
+ - Multiple dimensions (name + type + description): use a table
166
+ - Each item is longer than two sentences: use a `###` subheading
167
+
168
+ ### Example: good vs bad
169
+
170
+ Outline prompt:
171
+
172
+ ```
173
+ * Install and upgrade
174
+ * System requirements: Node.js 24.15.0+, recommend pnpm
175
+ * Install, upgrade, uninstall steps
176
+ ```
177
+
178
+ **Bad** (mechanical conversion to headings):
179
+
180
+ ```markdown
181
+ ## Install and upgrade
182
+
183
+ ### System requirements
184
+
185
+ - Node.js 24.15.0+
186
+ - Recommend pnpm
187
+
188
+ ### Install
189
+
190
+ ...
191
+
192
+ ### Upgrade
193
+
194
+ ...
195
+ ```
196
+
197
+ **Good** (natural narrative):
198
+
199
+ ```markdown
200
+ ## Install and upgrade
201
+
202
+ Kimi Code CLI requires Node.js 24.15.0 or later. We recommend using pnpm for installation and management.
203
+
204
+ If you haven't installed pnpm yet, please refer to the pnpm installation docs first. Install Kimi Code CLI:
205
+
206
+ (code block)
207
+
208
+ Verify the installation:
209
+
210
+ (code block)
211
+
212
+ Upgrade to the latest version:
213
+
214
+ (code block)
215
+ ```
216
+
217
+ ## Format decisions
218
+
219
+ Choose the format that matches the content's structure, not the one that looks most thorough.
220
+
221
+ **Ordered list** — steps that must happen in sequence (installation, configuration, migration). Do not nest sub-lists inside steps.
222
+
223
+ **Unordered list** — parallel items with no ordering dependency. Format: `- **Name**: one-sentence description`.
224
+
225
+ **Table** — reference content with multiple dimensions to compare or look up (config fields with name + type + required + description; keyboard shortcuts; platform comparison). Avoid tables when cell content would need to wrap to be readable.
226
+
227
+ **Prose** — explanations, motivations, caveats, anything that flows naturally as connected sentences. Do not convert prose into bullets just to add visual structure.
228
+
229
+ ## Cross-references
230
+
231
+ Readers never read just one page. A complete understanding is usually spread across several pages. Add links wherever they help.
232
+
233
+ **Always link when:**
234
+ 1. A concept mentioned on this page has a full explanation on another page — link to it on first mention, not the second or third. Prefer anchors (`#section`) over page-top links when the relevant content is in a specific section.
235
+ 2. This page gives a brief summary while another page has the full field reference or example — link the summary to the detail.
236
+ 3. A later section on this page depends on a concept defined earlier on this page — back-link with `[term](#anchor)` so readers don't have to scroll.
237
+
238
+ **Do not write:**
239
+ - "See related documentation" — which one? Readers skip this.
240
+ - Link only in a "Next steps" list at the bottom — readers who hit a blocker mid-page won't scroll to the end to find the link.
241
+ - First mention without a link, linked on second or third mention — the first mention is when the reader most wants to click.
242
+
243
+ **Inline links vs "Next steps":** Inline links serve readers who need supplemental information mid-page. A closing "Next steps" section serves readers who finished the page and want natural follow-on reading. Both have a place; neither replaces the other.
244
+
245
+ ## Page structure
246
+
247
+ ```
248
+ # Title (noun phrase, no period)
249
+
250
+ Opening sentence or two + plain-English summary (only when the concept has a learning curve)
251
+
252
+ > blockquote (optional: Beta notice, prerequisites)
253
+
254
+ Supplementary context / use-case list (optional)
255
+
256
+ Diagram (optional)
257
+
258
+ ::: warning Banner (deprecation, breaking change, security notice — after opening content, before first ##)
259
+
260
+ ## First section
261
+
262
+ Body…
263
+
264
+ ## Next steps (optional, only when related pages exist)
265
+ - [Page name](/path) — one sentence describing what the reader can do there
266
+ ```
267
+
268
+ **Banner placement rule:** Banners must appear after all opening content (opening sentences, blockquote, diagram) and before the first `##`. A banner must never be the first thing on the page.
269
+
270
+ ## Content completeness
271
+
272
+ **Default position: keep everything.** When editing a page, every block of original content needs an explicit destination — either retained or consciously removed with a stated reason.
273
+
274
+ **Valid reasons to omit content:**
275
+ - Too low-level / pure implementation detail that users never need to act on
276
+ - Already covered more completely on another page that is linked from here
277
+ - Content is ambiguous or suspected outdated — flag it rather than silently dropping it
278
+
279
+ **Not valid reasons:**
280
+ - "Seems unimportant" — that is a guess, not a reason
281
+ - "I'm not sure about this" — research it rather than omitting it
282
+ - "The page is getting long" — restructure, do not cut
283
+
284
+ If content is omitted, note it explicitly in the PR description or commit message. Do not write omission notices inside the document itself.
285
+
286
+ ## Checklist
287
+
288
+ Run through this before marking any doc change ready for review.
289
+
290
+ ### Format
291
+
292
+ | Problem | Fix |
293
+ |---|---|
294
+ | `::::` unclosed or mismatched | Close the fence or replace with `:::` if nesting is not needed |
295
+ | Nested callout containers | Change inner one to `>` blockquote |
296
+ | Banner before first `##` but also before opening content | Move to after opening sentences / blockquote / diagram |
297
+ | Steps written as unordered list | Change to ordered list |
298
+ | Multi-dimension comparison written as prose | Convert to table |
299
+ | Technical term used without explanation on first occurrence | Add plain-English gloss in parentheses |
300
+ | Cross-reference written as "see …" with no link | Add inline link; prefer anchor to section, not just page top |
301
+ | Concept depends on earlier definition but no back-link | Add `[term](#anchor)` |
302
+ | Changed zh without changing en (or vice versa) | Update both locales |
303
+ | Code block has no language tag | Add language (e.g., `sh`, `toml`, `json`); exception: natural-language prompt examples may omit the tag |
304
+
305
+ ### Kimi-specific consistency
306
+
307
+ Before shipping, verify these values match the rest of the docs:
308
+
309
+ - **Base URL**: matches the [Kimi platform rules](#kimi-platform-rules) table above
310
+ - **Upgrade command**: matches `guides/getting-started.md`
311
+ - **Model ID**: use `kimi-for-coding`, not a versioned model name
312
+ - **Login command**: `/login`, not `/setup`
313
+ - **Product full name**: **Kimi Code CLI** or **Kimi Code for VS Code** — never "Kimi CLI"
314
+ - **Platform URLs**: `api.kimi.com/coding/…` for Kimi Code platform; `api.moonshot.cn/v1` for Open Platform — never mix the two
315
+
316
+ ## Build and preview
317
+
318
+ - Docs are built with VitePress from `docs/`.
319
+ - Common commands (run inside `docs/`):
320
+ - `npm install`
321
+ - `npm run dev`
322
+ - `npm run build`
323
+ - `npm run preview`
324
+ - The build output is `docs/.vitepress/dist`.
325
+
326
+ ## Changelog syncing
327
+
328
+ See `sync-changelog` skill for the changelog generation workflow.
docs/index.md ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ layout: home
3
+ hero:
4
+ name: Kimi Code CLI
5
+ text: ' '
6
+ actions:
7
+ - theme: brand
8
+ text: 简体中文
9
+ link: zh/
10
+ - theme: alt
11
+ text: English
12
+ link: en/
13
+ ---
14
+
15
+ <script setup>
16
+ import { onMounted } from 'vue'
17
+ import { useRouter, withBase } from 'vitepress'
18
+
19
+ const router = useRouter()
20
+
21
+ onMounted(() => {
22
+ const lang = navigator.language || navigator.userLanguage
23
+ if (lang.startsWith('en')) {
24
+ router.go(withBase('/en/'))
25
+ } else {
26
+ router.go(withBase('/zh/'))
27
+ }
28
+ })
29
+ </script>
docs/package.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "kimi-code-docs",
3
+ "private": true,
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vitepress dev",
8
+ "build": "vitepress build",
9
+ "preview": "vitepress preview"
10
+ },
11
+ "devDependencies": {
12
+ "vitepress": "^1.5.0"
13
+ },
14
+ "dependencies": {
15
+ "mermaid": "^11.15.0",
16
+ "vitepress-plugin-llms": "^1.10.0",
17
+ "vitepress-plugin-mermaid": "^2.0.17"
18
+ }
19
+ }
flake.lock ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nodes": {
3
+ "nixpkgs": {
4
+ "locked": {
5
+ "lastModified": 1779102034,
6
+ "narHash": "sha256-vZJZjLo513IeI8hjzHFc6TDezUd4uCE2Eq4SNO3DNNg=",
7
+ "owner": "NixOS",
8
+ "repo": "nixpkgs",
9
+ "rev": "687f05a9184cad4eaf905c48b63649e3a86f5433",
10
+ "type": "github"
11
+ },
12
+ "original": {
13
+ "owner": "NixOS",
14
+ "ref": "nixos-25.11",
15
+ "repo": "nixpkgs",
16
+ "type": "github"
17
+ }
18
+ },
19
+ "root": {
20
+ "inputs": {
21
+ "nixpkgs": "nixpkgs"
22
+ }
23
+ }
24
+ },
25
+ "root": "root",
26
+ "version": 7
27
+ }
flake.nix ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ description = "Kimi Code CLI";
3
+
4
+ inputs = {
5
+ # Pinned to the 25.11 release channel because nixpkgs-unstable currently
6
+ # ships nodejs_24 = 24.14.1, which trips the >= 24.15.0 floor that the
7
+ # native SEA build enforces (see apps/kimi-code/scripts/native/build.mjs).
8
+ nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
9
+ };
10
+
11
+ outputs =
12
+ { self, nixpkgs }:
13
+ let
14
+ lib = nixpkgs.lib;
15
+
16
+ systems = [
17
+ "x86_64-linux"
18
+ "aarch64-linux"
19
+ "x86_64-darwin"
20
+ "aarch64-darwin"
21
+ ];
22
+
23
+ forAllSystems =
24
+ f:
25
+ lib.genAttrs systems (
26
+ system:
27
+ f (import nixpkgs {
28
+ inherit system;
29
+ })
30
+ );
31
+
32
+ minNodeVersion = "24.15.0";
33
+
34
+ # Hardcode to Node.js 24.x; fail the evaluation if the pinned nixpkgs
35
+ # does not offer a new enough 24.x.
36
+ nodejsFor =
37
+ pkgs:
38
+ let
39
+ node = pkgs.nodejs_24;
40
+ in
41
+ if lib.versionAtLeast node.version minNodeVersion then
42
+ node
43
+ else
44
+ throw ''
45
+ Kimi Code requires Node.js >= ${minNodeVersion},
46
+ but nixpkgs only offers ${node.version}.
47
+ Pin a newer nixpkgs revision or update minNodeVersion in flake.nix.
48
+ '';
49
+
50
+ pnpmFor =
51
+ pkgs:
52
+ pkgs.pnpm_10.override {
53
+ nodejs = nodejsFor pkgs;
54
+ };
55
+
56
+ # -------------------------------------------------------------------
57
+ # Workspace members (kept in sync with pnpm-workspace.yaml).
58
+ #
59
+ # HARD REQUIREMENT: whenever you add or remove a workspace package,
60
+ # you MUST update both lists below. Missing a path will break the Nix
61
+ # build (src fileset silently drops files); missing a name will break
62
+ # pnpmConfigHook (dependencies for that workspace won't be fetched).
63
+ # -------------------------------------------------------------------
64
+ workspacePaths = [
65
+ ./packages/acp-server
66
+ ./packages/agent-core-v2
67
+ ./packages/kap-server
68
+ ./packages/kaos
69
+ ./packages/klient
70
+ ./packages/kosong
71
+ ./packages/migration-legacy
72
+ ./packages/minidb
73
+ ./packages/node-sdk
74
+ ./packages/oauth
75
+ ./packages/pi-tui
76
+ ./packages/remote-control
77
+ ./packages/telemetry
78
+ ./packages/transcript
79
+ ./packages/tree-sitter-bash
80
+ ./apps/kimi-code
81
+ ./apps/vscode
82
+ ./apps/kimi-inspect
83
+ ./apps/vis
84
+ ./apps/vis/server
85
+ ./apps/vis/web
86
+ ./docs
87
+ ];
88
+
89
+ workspaceNames = [
90
+ "@moonshot-ai/acp-server"
91
+ "@moonshot-ai/agent-core-v2"
92
+ "@moonshot-ai/kap-server"
93
+ "@moonshot-ai/kaos"
94
+ "@moonshot-ai/kosong"
95
+ "@moonshot-ai/migration-legacy"
96
+ "@moonshot-ai/minidb"
97
+ "@moonshot-ai/kimi-code-sdk"
98
+ "@moonshot-ai/kimi-code-oauth"
99
+ "@moonshot-ai/klient"
100
+ "@moonshot-ai/pi-tui"
101
+ "@moonshot-ai/remote-control"
102
+ "@moonshot-ai/kimi-telemetry"
103
+ "@moonshot-ai/transcript"
104
+ "@moonshot-ai/tree-sitter-bash"
105
+ "@moonshot-ai/kimi-code"
106
+ "kimi-code"
107
+ "@moonshot-ai/kimi-inspect"
108
+ "@moonshot-ai/vis"
109
+ "@moonshot-ai/vis-server"
110
+ "@moonshot-ai/vis-web"
111
+ "kimi-code-docs"
112
+ ];
113
+ in
114
+ {
115
+ packages = forAllSystems (
116
+ pkgs:
117
+ let
118
+ nodejs = nodejsFor pkgs;
119
+ pnpm = pnpmFor pkgs;
120
+ appPackageJson = builtins.fromJSON (builtins.readFile ./apps/kimi-code/package.json);
121
+ nativeTarget =
122
+ if pkgs.stdenv.hostPlatform.isLinux && pkgs.stdenv.hostPlatform.isAarch64 then
123
+ "linux-arm64"
124
+ else if pkgs.stdenv.hostPlatform.isLinux then
125
+ "linux-x64"
126
+ else if pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64 then
127
+ "darwin-arm64"
128
+ else if pkgs.stdenv.hostPlatform.isDarwin then
129
+ "darwin-x64"
130
+ else
131
+ throw "Unsupported Kimi Code native target for ${pkgs.stdenv.hostPlatform.system}";
132
+
133
+ kimi-code = pkgs.stdenv.mkDerivation (finalAttrs: {
134
+ pname = "kimi-code";
135
+ version = appPackageJson.version;
136
+
137
+ src = lib.fileset.toSource {
138
+ root = ./.;
139
+ fileset = lib.fileset.unions (
140
+ [
141
+ ./build
142
+ ./.npmrc
143
+ ./.nvmrc
144
+ ./package.json
145
+ ./pnpm-lock.yaml
146
+ ./pnpm-workspace.yaml
147
+ ./tsconfig.json
148
+ ./vitest.config.ts
149
+ ./LICENSE
150
+ ]
151
+ ++ workspacePaths
152
+ );
153
+ };
154
+
155
+ pnpmWorkspaces = [ "." ] ++ workspaceNames;
156
+
157
+ pnpmDeps = pkgs.fetchPnpmDeps {
158
+ inherit (finalAttrs) pname version src pnpmWorkspaces;
159
+ inherit pnpm;
160
+ fetcherVersion = 3;
161
+ hash = "sha256-LWpsB1Z9nAIFF2/sHv30F2Y9n+87wmg+ypiMFwOQ6M0=";
162
+ };
163
+
164
+ nativeBuildInputs = [
165
+ nodejs
166
+ pnpm
167
+ (pkgs.pnpmConfigHook.override { inherit pnpm; })
168
+ pkgs.makeWrapper
169
+ ]
170
+ # The SEA inject step (postject) invalidates the macOS code
171
+ # signature on the copied Node executable; build.mjs then re-applies
172
+ # an ad-hoc signature via `codesign`. The Nix darwin sandbox does
173
+ # not expose /usr/bin/codesign, so we supply nixpkgs' ad-hoc-only
174
+ # replacement instead.
175
+ ++ lib.optionals pkgs.stdenv.hostPlatform.isDarwin [
176
+ pkgs.darwin.sigtool
177
+ ];
178
+
179
+ # The SEA binary is produced by `postject`-injecting a blob into a
180
+ # plain Node executable. Stripping rewrites section tables and can
181
+ # invalidate the injected blob's offsets, so leave the binary
182
+ # untouched after the build.
183
+ dontStrip = true;
184
+
185
+ buildPhase = ''
186
+ runHook preBuild
187
+ export KIMI_CODE_BUILD_TARGET=${nativeTarget}
188
+ ${lib.optionalString pkgs.stdenv.hostPlatform.isDarwin ''
189
+ # pkgs.darwin.sigtool's codesign supports `--sign -` (ad-hoc)
190
+ # but not the inspection mode (`-dv`) that 05-verify.mjs runs
191
+ # afterwards. Disable the verify step for the Nix build; the
192
+ # release CI keeps it via the unmodified script.
193
+ substituteInPlace apps/kimi-code/scripts/native/build.mjs \
194
+ --replace-fail \
195
+ "await runVerifyStep({ requireGatekeeper: false });" \
196
+ "// runVerifyStep skipped in nix sandbox (sigtool lacks -dv)"
197
+ ''}
198
+ # The SEA blob step (scripts/native/02-sea-blob.mjs) embeds the
199
+ # Kimi web assets from apps/kimi-code/dist-web and fails if that
200
+ # directory is missing. The bundle is committed (synced from the
201
+ # code-app repo) — verify it is in place before producing the
202
+ # native executable.
203
+ node apps/kimi-code/scripts/check-web-assets.mjs
204
+ pnpm --filter=@moonshot-ai/kimi-code run build:native:sea
205
+ runHook postBuild
206
+ '';
207
+
208
+ installPhase = ''
209
+ runHook preInstall
210
+
211
+ install -Dm755 \
212
+ "apps/kimi-code/dist-native/bin/${nativeTarget}/kimi" \
213
+ "$out/bin/kimi"
214
+
215
+ runHook postInstall
216
+ '';
217
+
218
+ postInstall = ''
219
+ wrapProgram $out/bin/kimi --prefix PATH : ${lib.makeBinPath [ pkgs.ripgrep pkgs.fd ]}
220
+ '';
221
+
222
+ meta = {
223
+ description = "Kimi Code CLI";
224
+ homepage = "https://github.com/MoonshotAI/kimi-code";
225
+ license = lib.licenses.mit;
226
+ mainProgram = "kimi";
227
+ platforms = systems;
228
+ };
229
+ });
230
+ in
231
+ {
232
+ inherit kimi-code;
233
+ default = kimi-code;
234
+ }
235
+ );
236
+
237
+ apps = forAllSystems (pkgs: {
238
+ kimi-code = {
239
+ type = "app";
240
+ program = "${self.packages.${pkgs.system}.kimi-code}/bin/kimi";
241
+ };
242
+ default = self.apps.${pkgs.system}.kimi-code;
243
+ });
244
+
245
+ devShells = forAllSystems (pkgs: {
246
+ default =
247
+ let
248
+ nodejs = nodejsFor pkgs;
249
+ pnpm = pnpmFor pkgs;
250
+ in
251
+ pkgs.mkShell {
252
+ packages = [
253
+ nodejs
254
+ pnpm
255
+ pkgs.ripgrep
256
+ pkgs.fd
257
+ ];
258
+ };
259
+ });
260
+ };
261
+ }
package.json ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@moonshot-ai/monorepo",
3
+ "version": "0.1.1",
4
+ "private": true,
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "scripts": {
8
+ "postinstall": "node scripts/fix-node-pty-perms.mjs",
9
+ "build": "pnpm -r run build",
10
+ "build:packages": "pnpm -r --filter './packages/*' run build",
11
+ "dev:cli": "pnpm -C apps/kimi-code run dev",
12
+ "dev:cli:marketplace": "KIMI_CODE_DEV_MARKETPLACE_URL=https://code.kimi.com/kimi-code/plugins/marketplace.json pnpm -C apps/kimi-code run dev",
13
+ "dev:server": "pnpm -C apps/kimi-code run dev:server",
14
+ "dev:kap-server": "pnpm -C apps/kimi-code run dev:kap-server",
15
+ "dev:v2": "pnpm -C apps/kimi-code run dev:kap-server:multi",
16
+ "build:plugin-marketplace": "pnpm -C apps/kimi-code run build:plugin-marketplace",
17
+ "vis": "pnpm -C apps/vis run dev",
18
+ "dev:docs": "pnpm -C docs install --ignore-workspace && pnpm -C docs run dev",
19
+ "typecheck": "pnpm run build:packages && pnpm -r --filter './packages/*' run typecheck && pnpm --filter @moonshot-ai/kimi-code run typecheck && pnpm --filter kimi-code run typecheck && pnpm --filter @moonshot-ai/vis-server run typecheck && pnpm --filter @moonshot-ai/vis-web run typecheck",
20
+ "lint": "node scripts/check-no-comments.mjs && oxlint --type-aware",
21
+ "lint:fix": "pnpm run lint --fix",
22
+ "lint:pkg": "pnpm --filter @moonshot-ai/kimi-code exec publint && npm_config_cache=${TMPDIR:-/tmp}/kimi-code-npm-cache pnpm --filter @moonshot-ai/kimi-code exec attw --pack . --profile node16",
23
+ "sherif": "sherif -i @agentclientprotocol/sdk",
24
+ "test": "vitest run",
25
+ "test:watch": "vitest",
26
+ "test:coverage": "vitest run --coverage",
27
+ "clean": "pnpm -r run clean",
28
+ "changeset": "changeset",
29
+ "version": "changeset version",
30
+ "version:release": "changeset version",
31
+ "publish": "pnpm run typecheck && pnpm run lint && pnpm run sherif && pnpm run test && pnpm run build && pnpm run lint:pkg && changeset publish",
32
+ "prepare": "node .husky/install.mjs"
33
+ },
34
+ "devDependencies": {
35
+ "@arethetypeswrong/cli": "0.18.2",
36
+ "@changesets/changelog-github": "0.7.0",
37
+ "@changesets/cli": "2.30.0",
38
+ "@microsoft/api-extractor": "7.58.7",
39
+ "@types/node": "^22.15.3",
40
+ "@vitest/coverage-v8": "4.1.4",
41
+ "husky": "^9.1.7",
42
+ "lint-staged": "16.4.0",
43
+ "oxlint": "1.59.0",
44
+ "oxlint-tsgolint": "0.20.0",
45
+ "pkg-pr-new": "0.0.75",
46
+ "publint": "0.3.18",
47
+ "sherif": "1.11.1",
48
+ "tsdown": "0.22.0",
49
+ "tsx": "^4.21.0",
50
+ "typescript": "6.0.2",
51
+ "vitest": "4.1.4"
52
+ },
53
+ "lint-staged": {
54
+ "*.{js,jsx,ts,tsx,mjs,cjs,mts,cts}": [
55
+ "oxlint --fix --quiet",
56
+ "oxlint --type-aware --quiet"
57
+ ]
58
+ },
59
+ "engines": {
60
+ "node": ">=24.15.0"
61
+ },
62
+ "packageManager": "pnpm@10.33.0"
63
+ }
plugins/marketplace.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "1",
3
+ "plugins": [
4
+ {
5
+ "id": "kimi-datasource",
6
+ "tier": "official",
7
+ "displayName": "Kimi Datasource",
8
+ "version": "3.4.0",
9
+ "description": "Stocks and financials from Wind, S&P Capital IQ, SEC EDGAR, etc.; news from Caixin, Xinhua Finance; macro from World Bank, IMF, FRED, NBS; corporate, academic, legal data, and more",
10
+ "keywords": ["data", "mcp"],
11
+ "source": "./official/kimi-datasource"
12
+ },
13
+ {
14
+ "id": "kimi-webbridge",
15
+ "tier": "official",
16
+ "displayName": "Kimi Browser Extension",
17
+ "version": "1.11.4",
18
+ "description": "Control your real browser from Kimi Code.",
19
+ "keywords": ["browser", "automation", "webbridge"],
20
+ "source": "./official/kimi-webbridge"
21
+ },
22
+ {
23
+ "id": "superpowers",
24
+ "tier": "curated",
25
+ "displayName": "Superpowers",
26
+ "description": "Planning, TDD, debugging, and delivery workflows for coding agents.",
27
+ "homepage": "https://github.com/obra/superpowers",
28
+ "keywords": ["skills", "planning", "tdd", "debugging", "code-review"],
29
+ "source": "https://github.com/obra/superpowers"
30
+ },
31
+ {
32
+ "id": "vercel-plugin",
33
+ "tier": "curated",
34
+ "displayName": "Vercel Plugin",
35
+ "description": "Comprehensive Vercel ecosystem plugin — skills, agents, and conventions for the Vercel platform.",
36
+ "homepage": "https://vercel.com/docs/agent-resources/vercel-plugin",
37
+ "keywords": ["vercel", "deployment", "nextjs", "skills", "agents"],
38
+ "source": "https://github.com/vercel/vercel-plugin"
39
+ },
40
+ {
41
+ "id": "modern-web-guidance",
42
+ "tier": "curated",
43
+ "displayName": "Modern Web Guidance",
44
+ "description": "Modern web platform expertise, best practices, and browser compatibility data for coding agents, from the Google Chrome team.",
45
+ "homepage": "https://github.com/GoogleChrome/modern-web-guidance",
46
+ "keywords": ["web", "css", "browser", "frontend", "skills"],
47
+ "source": "https://github.com/GoogleChrome/modern-web-guidance"
48
+ },
49
+ {
50
+ "id": "cloudbase",
51
+ "tier": "curated",
52
+ "displayName": "Tencent CloudBase",
53
+ "version": "0.2.0",
54
+ "description": "Build, deploy, and manage Tencent CloudBase apps — databases, cloud functions, storage, auth, and hosting, powered by cloudbase-mcp.",
55
+ "homepage": "https://github.com/TencentCloudBase/CloudBase-AI-Toolkit",
56
+ "keywords": ["cloudbase", "tencent-cloud", "baas", "database", "cloud-function", "mcp"],
57
+ "source": "https://github.com/TencentCloudBase/CloudBase-AI-Toolkit/releases/latest/download/cloudbase-kimi.zip"
58
+ }
59
+ ]
60
+ }
pnpm-lock.yaml ADDED
The diff for this file is too large to render. See raw diff
 
pnpm-workspace.yaml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ packages:
2
+ - packages/*
3
+ - apps/*
4
+ - apps/vis/server
5
+ - apps/vis/web
6
+ - docs
7
+
8
+ catalog:
9
+ zod: 4.3.6
10
+
11
+ overrides:
12
+ "kimi-code>@tailwindcss/vite": "4.1.18"
13
+ "ssh2@1.17.0>cpu-features": "-"
14
+ "ssh2@1.17.0>nan": "-"
15
+ "kimi-code>tailwindcss": "4.1.18"
scripts/check-service-naming.mjs ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Enforce the VS Code-style service naming convention finalized in
4
+ * Phase 5 of the 2026.06.07 services-alignment plan:
5
+ *
6
+ * - packages/services/src/<domain>/<domain>.ts (+ <domain>Service.ts)
7
+ * - packages/kap-server/src/services/<domain>/<domain>.ts (+ <domain>Service.ts)
8
+ *
9
+ * Domain dirs and service-related .ts files must be camelCase — never
10
+ * kebab-case (no `-` in the name). Anything outside these two roots is
11
+ * ignored (test fixtures, etc.).
12
+ *
13
+ * Exit code 0 if clean, 1 with an actionable report otherwise.
14
+ */
15
+
16
+ import { readdirSync, statSync, existsSync } from "node:fs";
17
+ import { resolve, join, relative } from "node:path";
18
+
19
+ const ROOT = resolve(import.meta.dirname, "..");
20
+ const SERVICES_SRC = join(ROOT, "packages/services/src");
21
+ const SERVER_SERVICES_SRC = join(ROOT, "packages/kap-server/src/services");
22
+
23
+ /** @type {Array<{ kind: string, path: string }>} */
24
+ const violations = [];
25
+
26
+ function isKebab(name) {
27
+ return name.includes("-");
28
+ }
29
+
30
+ function report(kind, absPath) {
31
+ violations.push({ kind, path: relative(ROOT, absPath) });
32
+ }
33
+
34
+ /**
35
+ * Both roots are organised as <domain>/<files>.ts plus a few top-level files
36
+ * (index.ts, module.ts, pinoLoggerService.ts). Flag kebab in dir names and in
37
+ * any .ts file directly under a domain dir.
38
+ */
39
+ function scanServicesSrc(srcRoot = SERVICES_SRC) {
40
+ if (!existsSync(srcRoot)) return;
41
+ for (const entry of readdirSync(srcRoot)) {
42
+ const abs = join(srcRoot, entry);
43
+ const st = statSync(abs);
44
+ if (st.isDirectory()) {
45
+ if (isKebab(entry)) report("kebab-dir", abs);
46
+ for (const f of readdirSync(abs)) {
47
+ if (!f.endsWith(".ts")) continue;
48
+ if (isKebab(f)) report("kebab-file", join(abs, f));
49
+ }
50
+ } else if (entry.endsWith(".ts") && isKebab(entry)) {
51
+ report("kebab-file", abs);
52
+ }
53
+ }
54
+ }
55
+
56
+ scanServicesSrc();
57
+ scanServicesSrc(SERVER_SERVICES_SRC);
58
+
59
+ if (violations.length > 0) {
60
+ console.error(
61
+ "Service naming violations (no kebab-case allowed for service files/dirs):"
62
+ );
63
+ for (const v of violations) console.error(` [${v.kind}] ${v.path}`);
64
+ console.error(
65
+ "\nRename to camelCase per VS Code convention: <domain>.ts + <domain>Service.ts."
66
+ );
67
+ process.exit(1);
68
+ }
69
+
70
+ console.log("Service naming check passed.");
scripts/fix-node-pty-perms.mjs ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Restore the executable bit on node-pty's `spawn-helper` prebuilt binaries.
4
+ *
5
+ * Why: on macOS/Linux node-pty launches the shell through a tiny `spawn-helper`
6
+ * executable shipped under `prebuilds/<platform-arch>/`. pnpm's content-
7
+ * addressable store does not preserve the +x mode on these non-bin prebuild
8
+ * assets, so after `pnpm install` the helper lands as 0644 and any PTY spawn
9
+ * fails with "posix_spawnp failed". npm/yarn (and the published tarball) keep
10
+ * the bit, so this is a pnpm-dev-only fixup.
11
+ *
12
+ * Idempotent and never fails the install: any error is logged and ignored.
13
+ */
14
+ import { chmodSync, existsSync, readdirSync, statSync } from 'node:fs';
15
+ import { createRequire } from 'node:module';
16
+ import { dirname, join } from 'node:path';
17
+
18
+ function nodePtyRoot() {
19
+ const require = createRequire(import.meta.url);
20
+ // Resolve from packages/services (where node-pty is declared) so we find the
21
+ // workspace's hoisted copy regardless of where this script runs.
22
+ const entry = require.resolve('node-pty', {
23
+ paths: [join(process.cwd(), 'packages/services'), process.cwd()],
24
+ });
25
+ // .../node-pty/lib/index.js -> .../node-pty
26
+ return dirname(dirname(entry));
27
+ }
28
+
29
+ try {
30
+ const root = nodePtyRoot();
31
+ const prebuilds = join(root, 'prebuilds');
32
+ if (!existsSync(prebuilds)) process.exit(0);
33
+ let fixed = 0;
34
+ for (const arch of readdirSync(prebuilds)) {
35
+ const helper = join(prebuilds, arch, 'spawn-helper');
36
+ if (!existsSync(helper)) continue;
37
+ const mode = statSync(helper).mode;
38
+ if ((mode & 0o111) === 0o111) continue; // already executable
39
+ chmodSync(helper, 0o755);
40
+ fixed++;
41
+ }
42
+ if (fixed > 0) console.log(`[fix-node-pty-perms] made ${fixed} spawn-helper binary(ies) executable`);
43
+ } catch (err) {
44
+ console.warn('[fix-node-pty-perms] skipped:', err instanceof Error ? err.message : String(err));
45
+ }
46
+ process.exit(0);
tsconfig.json ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2024",
4
+ "module": "preserve",
5
+ "moduleResolution": "bundler",
6
+ "allowImportingTsExtensions": true,
7
+ "lib": ["ES2023"],
8
+ "jsx": "react-jsx",
9
+ "jsxImportSource": "react",
10
+
11
+ "strict": true,
12
+ "isolatedModules": true,
13
+ "noUncheckedIndexedAccess": true,
14
+ "noImplicitOverride": true,
15
+ "noPropertyAccessFromIndexSignature": true,
16
+ "noFallthroughCasesInSwitch": true,
17
+ "forceConsistentCasingInFileNames": true,
18
+ "verbatimModuleSyntax": true,
19
+ "experimentalDecorators": true,
20
+
21
+ "declaration": true,
22
+ "sourceMap": true,
23
+ "noEmit": true,
24
+ "skipLibCheck": true,
25
+
26
+ "types": ["node"]
27
+ },
28
+ "include": [
29
+ "packages/*/src/**/*.ts",
30
+ "packages/*/src/**/*.tsx",
31
+ "packages/*/test/**/*.ts",
32
+ "packages/*/test/**/*.tsx",
33
+ "apps/*/src/**/*.ts",
34
+ "apps/*/src/**/*.tsx",
35
+ "apps/*/test/**/*.ts",
36
+ "apps/*/test/**/*.tsx"
37
+ ],
38
+ "exclude": [
39
+ "node_modules",
40
+ "dist",
41
+ "coverage",
42
+ "packages/kosong/test/type-safety-negative.ts",
43
+ "**/*.disabled/**",
44
+ "**/*.disabled"
45
+ ]
46
+ }
vitest.config.ts ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { defineConfig } from 'vitest/config';
2
+ import { vscodeProjects } from './apps/vscode/vitest.projects';
3
+
4
+ export default defineConfig({
5
+ test: {
6
+ projects: [
7
+ 'packages/*',
8
+ '!packages/minidb',
9
+ 'apps/kimi-code',
10
+ 'apps/vis/server',
11
+ 'apps/vis/web',
12
+ ...vscodeProjects,
13
+ ],
14
+ coverage: {
15
+ provider: 'v8',
16
+ include: [
17
+ 'packages/*/src/**/*.ts',
18
+ 'apps/*/src/**/*.ts',
19
+ 'apps/vis/*/src/**/*.{ts,tsx}',
20
+ ],
21
+ exclude: ['**/*.test.ts', '**/*.spec.ts', '**/dist/**'],
22
+ reporter: ['text', 'html'],
23
+ },
24
+ },
25
+ });