Skip to content

Commit f13ad13

Browse files
committed
refactor: complete v1→v2 migration — retire agent-core, unify on agent-core-v2
Remove the v1 engine (packages/agent-core, kaos, acp-adapter, rust-engine, experimental-v2) and finish the v2 migration across the monorepo: - node-sdk: rewire tests off deleted v1 internals onto config-local/legacy copies and agent-core-v2 subpaths; drop orphaned v1-internal tests; fix MCP fixture paths and build:dts pipeline (kaos residue, i18n d.ts) - CLI: run-prompt unified on the v2 native runner; restore the @moonshot-ai/kimi-agent dependency required by SEA packaging; fix apiKey leakage in provider --json (sanitize output) - agent-core-v2: restore goal-turn trimming regression in the SDK's legacy copy (system_trigger/goal_continuation boundary), EXIF display-space dimensions for native sniff, wire v1.6 with toolCallDisplays so replay restores diff/todo previews, jimp TS fallback for image compression when the native addon is unavailable - kimi-agent: load the platform-suffixed native addon in dev (glob instead of fixed name); rust-loop workspace index stays unwired (planned) - i18n: translate 135 remaining hardcoded strings across 5 modules; fix locale-key coverage checks and the t-call coverage script - tests: fix 166 pre-existing failures (Windows path/process semantics, stale assertions, snapshots, platform skips); repair docs build (js-yaml/gray-matter conflict, unclosed HTML in a review doc) and kimi-inspect build (missing i18n-shared dep, FetchLike typing) Validation: typecheck/lint clean, full test suite green across all packages and apps; SEA exe builds and runs.
1 parent cf48774 commit f13ad13

1,218 files changed

Lines changed: 11955 additions & 218468 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.deploy-staging/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
"node-pty": "^1.1.0"
8484
},
8585
"devDependencies": {
86-
"@moonshot-ai/acp-adapter": "workspace:^",
8786
"@moonshot-ai/agent-core": "workspace:^",
8887
"@moonshot-ai/agent-core-v2": "workspace:^",
8988
"@moonshot-ai/kap-server": "workspace:^",

.oxlintrc.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,18 @@
117117
"import/extensions": "off"
118118
}
119119
},
120+
{
121+
"files": [
122+
"packages/agent-core-v2/src/app/workflow/**/*.ts"
123+
],
124+
"rules": {
125+
// `?raw` imports of the builtin .js workflow scripts: oxlint resolves
126+
// the specifier as a module and reports `default`/`extensions` errors
127+
// that do not apply to raw string imports.
128+
"import/default": "off",
129+
"import/extensions": "off"
130+
}
131+
},
120132
{
121133
"files": ["packages/kosong/src/providers/**/*.ts"],
122134

@@ -159,6 +171,9 @@
159171
"eslint/no-unused-vars": "off",
160172
"eslint/no-unsafe-optional-chaining": "off",
161173
"jest/valid-expect": "off",
174+
// Tests legitimately throw non-Error values to verify defensive
175+
// catch-all handlers (e.g. safelyCallListener).
176+
"typescript/only-throw-error": "off",
162177
"unicorn/no-useless-spread": "off",
163178
"import/no-cycle": "off",
164179
"typescript/no-meaningless-void-operator": "off",

AGENTS.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ apps/
7878

7979
#### `apps/kimi-code` — CLI / TUI Application
8080

81-
The main application. 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`).
81+
The main application. Consumes core capabilities through `@moonshot-ai/kimi-code-sdk` and must **not** depend directly on `@moonshot-ai/agent-core-v2` outside the `cli/v2` runner. When writing or modifying its terminal UI, use the `write-tui` skill (`.agents/skills/write-tui/SKILL.md`).
8282

8383
**Source layout:**
8484

@@ -154,7 +154,6 @@ packages/
154154
klient/ — Client SDK (contract-driven facade over agent-core-v2)
155155
kap-server/ — Kimi Code local server (REST + WebSocket)
156156
server/ — Legacy local REST + WebSocket server
157-
acp-adapter/ — Agent Client Protocol adapter (public package)
158157
node-sdk/ — Public TypeScript SDK (@moonshot-ai/kimi-code-sdk)
159158
protocol/ — Shared REST + WS protocol schemas (Zod types)
160159
transcript/ — Isomorphic transcript rendering data layer
@@ -457,7 +456,7 @@ Two dependencies are deliberately removed: `ssh2@1.17.0>cpu-features` and `ssh2@
457456

458457
## Experimental Features
459458

460-
- Gate a not-yet-public feature behind an experimental flag. Add the flag to the registry at `packages/agent-core/src/flags/registry.ts`, then check it with `flags.enabled('my-feature')`.
459+
- Gate a not-yet-public feature behind an experimental flag. Add the flag to the registry at `packages/agent-core-v2/src/app/flag/flagRegistry.ts`, then check it with `flags.enabled('my-feature')`.
461460
- Flags are env-driven and default off:
462461
- `KIMI_CODE_EXPERIMENTAL_<NAME>` toggles one
463462
- `KIMI_CODE_EXPERIMENTAL_FLAG` enables all

apps/kimi-code/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,10 @@
8484
"node-pty": "^1.1.0"
8585
},
8686
"devDependencies": {
87-
"@moonshot-ai/acp-adapter": "workspace:^",
8887
"@moonshot-ai/acp-server": "workspace:^",
8988
"@moonshot-ai/agent-core-v2": "workspace:^",
9089
"@moonshot-ai/i18n-shared": "workspace:^",
9190
"@moonshot-ai/kap-server": "workspace:^",
92-
"@moonshot-ai/kimi-agent": "workspace:^",
9391
"@moonshot-ai/kimi-code-oauth": "workspace:^",
9492
"@moonshot-ai/kimi-code-sdk": "workspace:^",
9593
"@moonshot-ai/kimi-telemetry": "workspace:^",
@@ -113,5 +111,8 @@
113111
},
114112
"engines": {
115113
"node": ">=22.19.0"
114+
},
115+
"dependencies": {
116+
"@moonshot-ai/kimi-agent": "workspace:^"
116117
}
117118
}

apps/kimi-code/src/cli/experimental-v2.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

apps/kimi-code/src/cli/options.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
export type UIMode = 'shell' | 'print';
22
export type PromptOutputFormat = 'text' | 'stream-json';
33

4+
import { t } from '#/i18n';
5+
46
/** Environment variable that sets the default `-p` output format (flag wins). */
57
export const OUTPUT_FORMAT_ENV = 'KIMI_MODEL_OUTPUT_FORMAT';
68

@@ -68,28 +70,28 @@ export function validateOptions(
6870
const prompt = opts.prompt;
6971
const promptMode = prompt !== undefined;
7072
if (promptMode && prompt.trim().length === 0) {
71-
throw new OptionConflictError('Prompt cannot be empty.');
73+
throw new OptionConflictError(t('cli.errors.promptEmpty'));
7274
}
7375
if (opts.model !== undefined && opts.model.trim().length === 0) {
74-
throw new OptionConflictError('Model cannot be empty.');
76+
throw new OptionConflictError(t('cli.errors.modelEmpty'));
7577
}
7678
if (!promptMode && opts.outputFormat !== undefined) {
77-
throw new OptionConflictError('Output format is only supported in prompt mode.');
79+
throw new OptionConflictError(t('cli.errors.outputFormatPromptOnly'));
7880
}
7981
if (promptMode && opts.yolo) {
80-
throw new OptionConflictError('Cannot combine --prompt with --yolo.');
82+
throw new OptionConflictError(t('cli.errors.cannotCombinePromptAndYolo'));
8183
}
8284
if (promptMode && opts.auto) {
83-
throw new OptionConflictError('Cannot combine --prompt with --auto.');
85+
throw new OptionConflictError(t('cli.errors.cannotCombinePromptAndAuto'));
8486
}
8587
if (promptMode && opts.plan) {
86-
throw new OptionConflictError('Cannot combine --prompt with --plan.');
88+
throw new OptionConflictError(t('cli.errors.cannotCombinePromptAndPlan'));
8789
}
8890
if (opts.agent !== undefined && opts.agent.trim().length === 0) {
8991
throw new OptionConflictError('Agent cannot be empty.');
9092
}
9193
if (opts.agentFiles.length > 1) {
92-
throw new OptionConflictError('--agent-file may only be specified once.');
94+
throw new OptionConflictError(t('cli.errors.agentFileOnlyOnce'));
9395
}
9496
if (opts.agentFiles.some((file) => file.trim().length === 0)) {
9597
throw new OptionConflictError('Agent file path cannot be empty.');
@@ -106,13 +108,13 @@ export function validateOptions(
106108
);
107109
}
108110
if (promptMode && opts.session === '') {
109-
throw new OptionConflictError('Cannot use --session without an id in prompt mode.');
111+
throw new OptionConflictError(t('cli.errors.sessionWithoutIdInPromptMode'));
110112
}
111113
if (opts.continue && opts.session !== undefined) {
112-
throw new OptionConflictError('Cannot combine --continue, --session.');
114+
throw new OptionConflictError(t('cli.errors.cannotCombineContinueAndSession'));
113115
}
114116
if (opts.yolo && opts.auto) {
115-
throw new OptionConflictError('Cannot combine --yolo with --auto.');
117+
throw new OptionConflictError(t('cli.errors.cannotCombineYoloAndAuto'));
116118
}
117119
// Validate `KIMI_MODEL_OUTPUT_FORMAT` eagerly in prompt mode so a typo fails
118120
// fast through the friendly `error:` path instead of mid-run.

apps/kimi-code/src/cli/prompt-session.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
/**
22
* Minimal harness/session surface consumed by `kimi -p` (print mode).
33
*
4-
* `run-prompt.ts` only needs a small subset of the SDK `KimiHarness` / `Session`
5-
* API. Coding the print-mode driver against these narrow interfaces — instead of
6-
* the concrete SDK classes — lets the same driver run on either the legacy
7-
* engine (`createKimiHarness`) or the default agent-core-v2 engine
8-
* (`createPromptHarnessV2`, selected unless `KIMI_CODE_LEGACY_FLAG` is truthy).
9-
* Both the legacy `KimiHarness` / `Session` and the v2 harness structurally
10-
* satisfy these interfaces, so no adapter wrappers are needed on the legacy path.
4+
* The v2 print driver (`cli/v2/run-v2-print.ts`) talks to agent-core-v2's
5+
* native DI services directly, so the print-mode path no longer goes through a
6+
* `PromptHarness`-shaped SDK session. This module keeps the type-level view of
7+
* that surface for reference; new print-mode code should target the native
8+
* `ISessionScopeHandle` / `IAgentScopeHandle` interfaces instead.
119
*/
1210

1311
import type {

0 commit comments

Comments
 (0)