Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .agents/skills/gen-changesets/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Use when generating changesets in the kimi-code repository — deci

# Generate Changesets

The only user-facing published package is the CLI: `@moonshot-ai/kimi-code`. All other `@moonshot-ai/*` packages (sdk, agent-core, kosong, kaos, oauth, telemetry, and so on) are internal.
The only user-facing published package is the CLI: `@moonshot-ai/kimi-code`. All other `@moonshot-ai/*` packages (sdk, kosong, kaos, oauth, telemetry, and so on) are internal.

## 1. Whether to Write

Expand Down
2 changes: 1 addition & 1 deletion .agents/skills/write-tui/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Themes are managed centrally under `src/tui/theme/`:
- `bundle.ts` — packs `colors`, `styles`, `markdownTheme` into a `KimiTUIThemeBundle`.
- `index.ts` / `detect.ts` — theme type and auto/dark/light resolution.

> **Keep the color-token set in sync.** `ColorPalette` in `colors.ts` is the source of truth for color tokens. When you add, rename, or remove one, update its mirrors in the same change: the custom-theme JSON schema (`apps/kimi-code/src/tui/theme/theme-schema.json`), the token tables in the custom-theme docs (`docs/en/customization/themes.md` and `docs/zh/customization/themes.md`), and the token table in the `custom-theme` built-in skill (`packages/agent-core/src/skill/builtin/custom-theme.md`).
> **Keep the color-token set in sync.** `ColorPalette` in `colors.ts` is the source of truth for color tokens. When you add, rename, or remove one, update its mirrors in the same change: the custom-theme JSON schema (`apps/kimi-code/src/tui/theme/theme-schema.json`), the token tables in the custom-theme docs (`docs/en/customization/themes.md` and `docs/zh/customization/themes.md`), and the token table in the `custom-theme` built-in skill (`packages/agent-core-v2/src/features/skill/catalog/builtin/custom-theme.md`).

Apply / switch flow:

Expand Down
3 changes: 1 addition & 2 deletions .changeset/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Current publishable packages:

All other workspace packages are private internal packages, are not published to npm, and are excluded via `ignore` in `.changeset/config.json`:

- `@moonshot-ai/agent-core`
- `@moonshot-ai/kaos`
- `@moonshot-ai/kimi-code-oauth`
- `@moonshot-ai/kimi-telemetry`
Expand Down Expand Up @@ -145,7 +144,7 @@ The root-level `pnpm run publish` first runs typecheck, lint, sherif, test, buil
- Changeset files must be committed to the repository — release PRs are only triggered after they're merged.
- Release PRs require human review and merge; they will not publish automatically.
- Do not add release changesets for private internal packages; only select `@moonshot-ai/kimi-code` and `@moonshot-ai/kimi-code-sdk`.
- 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/agent-core` resolves an issue CLI users encounter, add a changeset to `@moonshot-ai/kimi-code` describing the user-visible fix.
- 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.
- `@moonshot-ai/kimi-code` is the official CLI package name; after a global install it provides the `kimi` command.
- Make sure each publishable package on npm has a Trusted Publisher configured.

Expand Down
4 changes: 1 addition & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ This is a TypeScript monorepo built for agent-assisted development. Keep the roo

## Project Map

- `apps/kimi-code`: the CLI / TUI application. It consumes core capabilities through `@moonshot-ai/kimi-code-sdk` and must not depend directly on `@moonshot-ai/agent-core`. When writing or modifying its terminal UI, use the `write-tui` skill (`.agents/skills/write-tui/SKILL.md`).
- `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`).
- 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`.
- `apps/vis`, `apps/vis/server`, `apps/vis/web`: visual debugging tools for sessions and replays.
- `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`.
- `packages/agent-core`: the unified agent engine, including Agent, Session, profile, skills, tools, plan, permission, background, records, the in-process DI service layer (`src/services/`), and other core capabilities. See `packages/agent-core/AGENTS.md`.
- `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.
- `packages/node-sdk`: the public TypeScript SDK and harness.
- `packages/kosong`: the LLM / provider abstraction layer.
Expand Down Expand Up @@ -64,7 +63,6 @@ This is a TypeScript monorepo built for agent-assisted development. Keep the roo
## Experimental Features

- 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`.
- `packages/agent-core` (v1): add the flag to the central registry at `packages/agent-core/src/flags/registry.ts`, then check it with `flags.enabled('my-feature')`.
- `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)`. Current search-index-separation flags: `persistence_minidb_readmodel` (session read model, default on) and `search_worker` (global search worker host, default on).

## Where to Update Instructions
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ All commits and PR titles must follow [Conventional Commits](https://www.convent

| Type | Use for | Example |
|----------|---------------------------------------------|-------------------------------------------|
| feat | A new feature | feat(agent-core): add tool dedup |
| feat | A new feature | feat(agent-core-v2): add tool dedup |
| fix | A bug fix | fix(tui): correct status bar alignment |
| docs | Documentation only | docs: clarify install instructions |
| chore | Tooling / housekeeping | chore: bump dependencies |
| refactor | Internal refactor without behavior change | refactor(kosong): extract retry helper |
| test | Adding or improving tests | test(agent-core): cover skill resolver |
| test | Adding or improving tests | test(agent-core-v2): cover skill resolver |
| ci | CI / build pipeline changes | ci: cache pnpm store |
| build | Build system / artifact changes | build(native): add win32-arm64 target |
| perf | Performance improvement | perf(session): batch event flushes |
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ pnpm install

| 类型 | 用途 | 示例 |
|----------|------------------------------------------|----------------------------------------|
| feat | 新功能 | feat(agent-core): add tool dedup |
| feat | 新功能 | feat(agent-core-v2): add tool dedup |
| fix | bug 修复 | fix(tui): correct status bar alignment |
| docs | 仅文档 | docs: clarify install instructions |
| chore | 工具 / 杂务 | chore: bump dependencies |
| refactor | 无行为变更的内部重构 | refactor(kosong): extract retry helper |
| test | 新增或改进测试 | test(agent-core): cover skill resolver |
| test | 新增或改进测试 | test(agent-core-v2): cover skill resolver |
| ci | CI / 构建流水线变更 | ci: cache pnpm store |
| build | 构建系统 / 产物变更 | build(native): add win32-arm64 target |
| perf | 性能优化 | perf(session): batch event flushes |
Expand Down
2 changes: 1 addition & 1 deletion apps/kimi-code/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Main directories:
- `reverse-rpc` converts SDK approval/question requests into the data shape a UI panel/dialog needs, and converts the user's choice back into an SDK response.
- `theme` is the single source of truth for colors and styles. Components must not bypass the theme system and use chalk named colors directly.
- `utils` holds utility functions with no UI-state dependency. Logic that needs `TUIState` or a component instance must not live under app-level `src/utils`.
- `apps/kimi-code` may only use core capabilities through `@moonshot-ai/kimi-code-sdk`. Do not import `@moonshot-ai/agent-core` directly in app code.
- `apps/kimi-code` may only use core capabilities through `@moonshot-ai/kimi-code-sdk`. Do not import engine packages directly in app code.

## TUI Coding Conventions

Expand Down
2 changes: 1 addition & 1 deletion apps/kimi-code/scripts/dev.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const child = spawn(
tsxCli,
// Use the dev tsconfig whose `include` covers packages/*/src, so tsx's
// esbuild transform sees `experimentalDecorators: true` for DI parameter
// decorators in agent-core. Mirrors `dev:server` in package.json.
// decorators in agent-core-v2. Mirrors `dev:server` in package.json.
'--tsconfig',
resolve(APP_ROOT, 'tsconfig.dev.json'),
'--import',
Expand Down
2 changes: 1 addition & 1 deletion apps/kimi-code/scripts/plugin-manifest-version.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { readFile } from 'node:fs/promises';
import { resolve } from 'node:path';

// Read a local plugin directory's declared version from its manifest, mirroring
// the plugin loader's precedence (packages/agent-core/src/plugin/manifest.ts):
// the plugin loader's precedence (packages/agent-core-v2/src/app/plugin/manager.ts):
// `kimi.plugin.json` is authoritative once it exists, and `.kimi-plugin/plugin.json`
// is only consulted when the root manifest is absent. Returns undefined when no
// manifest is present or the chosen manifest has no version — callers then leave
Expand Down
35 changes: 0 additions & 35 deletions apps/kimi-code/src/cli/experimental-v2.ts

This file was deleted.

46 changes: 3 additions & 43 deletions apps/kimi-code/src/cli/prompt-session.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,13 @@
/**
* Minimal harness/session surface consumed by `kimi -p` (print mode).
*
* `run-prompt.ts` only needs a small subset of the SDK `KimiHarness` / `Session`
* API. Coding the print-mode driver against these narrow interfaces — instead of
* the concrete SDK classes — lets the same driver run on either the legacy
* engine (`createKimiHarness`) or the default agent-core-v2 engine
* (`createPromptHarnessV2`, selected unless `KIMI_CODE_LEGACY_FLAG` is truthy).
* Both the legacy `KimiHarness` / `Session` and the v2 harness structurally
* satisfy these interfaces, so no adapter wrappers are needed on the legacy path.
*/

import type {
ApprovalHandler,
ConfigDiagnostics,
CreateGoalInput,
CreateSessionOptions,
Event,
GetCronTasksResult,
GoalSnapshot,
GoalToolResult,
KimiAuthFacade,
KimiConfig,
ListSessionsOptions,
PermissionMode,
PromptInput,
QuestionHandler,
ResumeSessionInput,
SessionStatus,
Session,
SessionSummary,
TelemetryProperties,
Unsubscribe,
} from '@moonshot-ai/kimi-code-sdk';

export interface PromptHarness {
Expand All @@ -42,25 +20,7 @@ export interface PromptHarness {
getConfig(): Promise<Pick<KimiConfig, 'defaultModel' | 'telemetry'>>;
getConfigDiagnostics(): Promise<ConfigDiagnostics>;
listSessions(options: ListSessionsOptions): Promise<readonly SessionSummary[]>;
createSession(options: CreateSessionOptions): Promise<PromptSession>;
resumeSession(input: ResumeSessionInput): Promise<PromptSession>;
createSession(options: CreateSessionOptions): Promise<Session>;
resumeSession(input: ResumeSessionInput): Promise<Session>;
close(): Promise<void>;
}

export interface PromptSession {
readonly id: string;
readonly workDir: string;

getStatus(): Promise<SessionStatus>;
setModel(model: string): Promise<void>;
setPermission(mode: PermissionMode): Promise<void>;
setApprovalHandler(handler: ApprovalHandler | undefined): void;
setQuestionHandler(handler: QuestionHandler | undefined): void;
onEvent(listener: (event: Event) => void): Unsubscribe;
prompt(input: string | PromptInput): Promise<void>;
waitForBackgroundTasksOnPrint(): Promise<void>;
handlePrintMainTurnCompleted?(): Promise<'finish' | 'continue'>;
createGoal(input: CreateGoalInput): Promise<GoalSnapshot>;
getGoal(): Promise<GoalToolResult>;
getCronTasks(): Promise<GetCronTasksResult>;
}
Loading
Loading