Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .agents/skills/agent-core-dev/flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Gate not-yet-public features behind `IFlagService.enabled(id)`, per the reposito
- `src/flag/flag.ts` — `IFlagService` token + resolver types (`ExperimentalFlagMap`, `ExperimentalFlagConfig`, `ExperimentalFlagSource`, `ExperimentalFeatureState`) + `ExperimentalConfigSchema` / `ExperimentalConfig` (zod).
- `src/flag/flagService.ts` — `FlagService` impl + `MASTER_ENV` (`KIMI_CODE_EXPERIMENTAL_FLAG`) + `EXPERIMENTAL_SECTION` (`experimental`); reads definitions from `IFlagRegistry`; self-registers at App scope.
- `src/flag/index.ts` — **removed (no barrel)**; `src/index.ts` imports the `flag` leafs precisely instead (e.g. `import './flag/flagService'`).
- `src/<domain>/flag.ts` — each domain that owns a flag declares it here and calls `registerFlagDefinition` at the module top level (e.g. `src/agent/toolSelect/flag.ts` or `src/agent/faultInjection/flag.ts`). The directory already names the domain, so the file is just `flag.ts`.
- `src/<domain>/flag.ts` — each domain that owns a flag declares it here and calls `registerFlagDefinition` at the module top level (e.g. `src/agent/toolSelect/flag.ts`). The directory already names the domain, so the file is just `flag.ts`.

## Public surface

Expand Down
5 changes: 5 additions & 0 deletions .changeset/fuzzy-pandas-refresh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@moonshot-ai/kimi-code": patch
---

Fix sporadic "model is not configured" errors when starting kimi web, caused by the background provider-model refresh transiently clearing the model catalog while the first session was being created.
5 changes: 5 additions & 0 deletions .changeset/kimi-web-markstream-monaco.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@moonshot-ai/kimi-code": patch
---

web: Enable Monaco-based highlighting for code blocks, and fix line numbers overlapping or drifting out of alignment in fallback-rendered code blocks.
5 changes: 0 additions & 5 deletions .changeset/plugin-system-prompt-section.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/v1-custom-agent-files.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/v1-secondary-model.md

This file was deleted.

20 changes: 20 additions & 0 deletions apps/kimi-code/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# @moonshot-ai/kimi-code

## 0.31.0

### Minor Changes

- [#2365](https://github.com/MoonshotAI/kimi-code/pull/2365) [`fa2c5ce`](https://github.com/MoonshotAI/kimi-code/commit/fa2c5ce18b70577fa3ada4eb8bdd4993891994ce) Thanks [@7Sageer](https://github.com/7Sageer)! - Add support for plugin-contributed custom agents, discovered automatically and available for sub-agent delegation. Ship an `agents/` directory in the plugin (or declare `agents` paths in the plugin manifest) to provide them.

- [#2314](https://github.com/MoonshotAI/kimi-code/pull/2314) [`02d77b2`](https://github.com/MoonshotAI/kimi-code/commit/02d77b20d941873563f14890e049ffe40cec76e4) Thanks [@7Sageer](https://github.com/7Sageer)! - Allow enabled plugins to contribute agent system-prompt instructions through `systemPrompt` or `systemPromptPath` in `kimi.plugin.json`, effective on both agent engines (the TUI, `kimi -p`, and `kimi web`).

- [#2232](https://github.com/MoonshotAI/kimi-code/pull/2232) [`efac96c`](https://github.com/MoonshotAI/kimi-code/commit/efac96c8a95a3c3ca4e1ae9bce38082498a02b2e) Thanks [@7Sageer](https://github.com/7Sageer)! - Support Markdown-defined custom agents on agent-core.

- [#2232](https://github.com/MoonshotAI/kimi-code/pull/2232) [`efac96c`](https://github.com/MoonshotAI/kimi-code/commit/efac96c8a95a3c3ca4e1ae9bce38082498a02b2e) Thanks [@7Sageer](https://github.com/7Sageer)! - Add the /secondary_model slash command to configure the secondary model used by subagents.

### Patch Changes

- [#2382](https://github.com/MoonshotAI/kimi-code/pull/2382) [`40172c7`](https://github.com/MoonshotAI/kimi-code/commit/40172c7ca96ca981b043b793588dd32e898979fa) Thanks [@liruifengv](https://github.com/liruifengv)! - Fix request headers not being passed correctly on some requests.

- [#2379](https://github.com/MoonshotAI/kimi-code/pull/2379) [`691ec46`](https://github.com/MoonshotAI/kimi-code/commit/691ec4679ea19d6be8ac18f359088384ed3e446d) Thanks [@RealKai42](https://github.com/RealKai42)! - Remove the blocking `block`/`timeout` wait from the TaskOutput tool so checking a background task can no longer stall the conversation; it now always returns an immediate snapshot, and completion still arrives via automatic notification.

- [#2395](https://github.com/MoonshotAI/kimi-code/pull/2395) [`d10b1c1`](https://github.com/MoonshotAI/kimi-code/commit/d10b1c130813dbd6ee8c8599a6a98feb36aea67f) Thanks [@sailist](https://github.com/sailist)! - Fix sessions missing from the session picker when their cached metadata predates the archived flag.

## 0.30.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/kimi-code/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@moonshot-ai/kimi-code",
"version": "0.30.0",
"version": "0.31.0",
"description": "The Starting Point for Next-Gen Agents",
"license": "MIT",
"author": "Moonshot AI",
Expand Down
20 changes: 12 additions & 8 deletions apps/kimi-code/src/cli/sub/web/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,20 @@
import { existsSync } from 'node:fs';
import { join } from 'node:path';

import { hostRequestHeadersSeed } from '@moonshot-ai/agent-core-v2';
import { createServerLogger, startServer, type ServerLogger } from '@moonshot-ai/kap-server';
import { shutdownTelemetry, track } from '@moonshot-ai/kimi-telemetry';
import chalk from 'chalk';
import { type Command } from 'commander';

import { CLI_SHUTDOWN_TIMEOUT_MS } from '#/constant/app';
import { CLI_SHUTDOWN_TIMEOUT_MS, WEB_USER_AGENT_SUFFIX } from '#/constant/app';
import { getNativeWebAssetsDir } from '#/native/web-assets';
import { darkColors } from '#/tui/theme/colors';
import { openUrl as defaultOpenUrl } from '#/utils/open-url';
import { getDataDir } from '#/utils/paths';

import { initializeServerTelemetry } from '../../telemetry';
import {
buildKimiDefaultHeaders,
createKimiCodeHostIdentity,
getHostPackageRoot,
getVersion,
} from '../../version';
Expand Down Expand Up @@ -278,7 +277,16 @@ async function runServerInProcess(
port: options.port,
// Report the CLI's product version as `server_version` (/meta, web UI)
// rather than kap-server's private package version.
version,
serverVersion: version,
// The CLI's host identity: feeds the engine's bootstrap client identity
// and the derived outbound headers (User-Agent + X-Msh-*), so web-UI
// OAuth flows and model / WebSearch requests carry the CLI identity. The
// `web` User-Agent suffix distinguishes web-UI traffic from direct CLI
// runs upstream (same product token, same platform).
hostIdentity: {
...createKimiCodeHostIdentity(version),
userAgentSuffix: WEB_USER_AGENT_SUFFIX,
},
logLevel: options.logLevel,
logger,
debugEndpoints: options.debugEndpoints,
Expand All @@ -291,10 +299,6 @@ async function runServerInProcess(
// `telemetry` toggle). Complements the v1 client registered above, which
// only covers host-level events.
telemetry: true,
// Seed the CLI's Kimi identity headers so the engine's outbound
// requests (model, WebSearch, FetchURL) carry the same User-Agent +
// X-Msh-* identity as direct CLI runs.
seeds: hostRequestHeadersSeed(buildKimiDefaultHeaders(version)),
webAssetsDir,
});
logger.info('serving the REST/WS API and the bundled web UI');
Expand Down
2 changes: 1 addition & 1 deletion apps/kimi-code/src/cli/v2/run-v2-print.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export async function runV2Print(
const identity = createKimiCodeHostIdentity(version);
const hostHeaders = createKimiDefaultHeaders({ homeDir, ...identity });

const { app } = bootstrap({ homeDir, clientVersion: version }, [
const { app } = bootstrap({ homeDir, clientIdentity: identity }, [
...logSeed(logging),
...hostRequestHeadersSeed(hostHeaders),
// `--skillsDir` (v1 print parity): explicit skill dirs replace default
Expand Down
13 changes: 3 additions & 10 deletions apps/kimi-code/src/cli/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
import { existsSync, readFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';

import { createKimiDefaultHeaders, createKimiUserAgent, type KimiHostIdentity } from '@moonshot-ai/kimi-code-oauth';
import { createKimiUserAgent, KIMI_CODE_PLATFORM, type KimiHostIdentity } from '@moonshot-ai/kimi-code-oauth';

import { CLI_USER_AGENT_PRODUCT } from '#/constant/app';

import { getDataDir } from '../utils/paths';
import { KIMI_BUILD_INFO } from './build-info';

const MODULE_DIR = import.meta.dirname;
Expand Down Expand Up @@ -50,8 +49,9 @@ export function getVersion(): string {

export function createKimiCodeHostIdentity(version = getVersion()): KimiHostIdentity {
return {
userAgentProduct: CLI_USER_AGENT_PRODUCT,
productName: CLI_USER_AGENT_PRODUCT,
version,
platform: KIMI_CODE_PLATFORM,
};
}

Expand All @@ -62,10 +62,3 @@ export function createKimiCodeHostIdentity(version = getVersion()): KimiHostIden
export function createKimiCodeUserAgent(version = getVersion()): string {
return createKimiUserAgent(createKimiCodeHostIdentity(version));
}

export function buildKimiDefaultHeaders(version: string): Record<string, string> {
return createKimiDefaultHeaders({
homeDir: getDataDir(),
...createKimiCodeHostIdentity(version),
});
}
4 changes: 4 additions & 0 deletions apps/kimi-code/src/constant/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export const CLI_UI_MODE = 'shell';
// Telemetry ui_mode for the `kimi web` host. Same product
// as the CLI (CLI_USER_AGENT_PRODUCT); the surface is distinguished by ui_mode.
export const WEB_UI_MODE = 'web';
// User-Agent suffix for the `kimi web` host: its requests go out as
// `kimi-code-cli/<version> (web)` so upstream can tell web-UI traffic
// apart from direct CLI runs without changing the product token or platform.
export const WEB_USER_AGENT_SUFFIX = 'web';

// Give telemetry a short flush window without making CLI exit feel stuck.
export const CLI_SHUTDOWN_TIMEOUT_MS = 3000;
Expand Down
8 changes: 6 additions & 2 deletions apps/kimi-code/src/tui/kimi-tui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { writeFileSync } from 'node:fs';
import { join } from 'node:path';

import type { DeviceAuthorization } from '@moonshot-ai/kimi-code-oauth';
import { log } from '@moonshot-ai/kimi-code-sdk';
import type {
ApprovalRequest,
ApprovalResponse,
Expand Down Expand Up @@ -1750,8 +1751,11 @@ export class KimiTUI {
this.state.appState.sessionId,
this.hasSessionContent(),
);
} catch {
/* silently ignore */
} catch (error) {
// The picker must keep working (it renders the empty state), but a
// swallowed failure surfaces as a misleading "No sessions found." —
// keep a log trail so the real error stays discoverable.
log.warn('failed to fetch sessions for picker', { error: String(error) });
} finally {
this.state.loadingSessions = false;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/kimi-code/test/cli/run-shell.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ describe('runShell', () => {
expect(mocks.kimiHarnessConstructor).toHaveBeenCalledWith(
expect.objectContaining({
identity: expect.objectContaining({
userAgentProduct: 'kimi-code-cli',
productName: 'kimi-code-cli',
version: '1.2.3-test',
}),
sessionStartedProperties: { yolo: true, auto: false, plan: true, afk: false },
Expand Down
6 changes: 5 additions & 1 deletion apps/kimi-code/test/cli/v2-run-print.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,11 @@ function makeFakeHarness() {
{
platform: 'linux',
arch: 'x64',
clientVersion: '1.2.3-test',
clientIdentity: {
productName: 'test-product',
version: '1.2.3-test',
platform: 'test_platform',
},
osHomeDir: '/home/test',
getEnv: () => undefined,
},
Expand Down
7 changes: 0 additions & 7 deletions apps/kimi-code/test/cli/version.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { dirname, join } from 'node:path';
import { describe, expect, it } from 'vitest';

import {
buildKimiDefaultHeaders,
createKimiCodeUserAgent,
getHostPackageJsonPath,
getHostPackageRoot,
Expand All @@ -21,12 +20,6 @@ describe('cli version helpers', () => {
expect(getVersion()).toBe(pkg.version);
});

it('builds default headers with the kimi-code-cli user-agent', () => {
const headers = buildKimiDefaultHeaders('1.2.3');

expect(headers['User-Agent']).toBe('kimi-code-cli/1.2.3');
});

it('builds the product user-agent for ad-hoc fetches', () => {
expect(createKimiCodeUserAgent('1.2.3')).toBe('kimi-code-cli/1.2.3');
});
Expand Down
5 changes: 4 additions & 1 deletion apps/kimi-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
"@xterm/addon-fit": "^0.11.0",
"@xterm/xterm": "^6.0.0",
"katex": "^0.17.0",
"markstream-vue": "^1.0.7",
"markstream-vue": "^1.0.9-beta.1",
"mermaid": "^11.15.0",
"monaco-editor": "^0.55.1",
"shiki": "^4.3.0",
"stream-diffs": "^0.0.2",
"stream-markdown": "^0.0.16",
"stream-monaco": "^0.0.49",
"vue": "^3.5.35",
"vue-i18n": "^11.4.5"
},
Expand Down
10 changes: 9 additions & 1 deletion apps/kimi-web/src/components/chat/Markdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,14 @@ const CODE_DARK_THEME = 'github-dark';
// blank placeholders. Pinning `loading` to false drops the skeleton entirely:
// the block renders its plain-text fallback immediately and shiki upgrades it to
// the highlighted version when the highlighter is ready. Streaming blocks are
// unaffected (their `stream` is true, so the skeleton gate was already false).
// unaffected (their `stream` is true, so the skeleton gate was already
// false).
// Chat code blocks show no gutter: line numbers eat 3+ characters of reading
// width and every chat block starts at line 1 anyway. stream-diffs derives its
// gutter from `lineNumbers === false` (boolean, not monaco's 'off' string).
// This rides inside codeBlockProps because markstream 1.0.7 only forwards the
// top-level codeBlockMonacoOptions to the 'monaco' renderer kind — the 'shiki'
// kind's props object omits it, while codeBlockProps reach the same component.
const codeBlockProps = {
showHeader: true,
showCopyButton: true,
Expand All @@ -336,6 +343,7 @@ const codeBlockProps = {
showCollapseButton: false,
showFontSizeButtons: false,
loading: false,
monacoOptions: { lineNumbers: false },
};

// Root cause for the "large session turns into code skeletons" failure:
Expand Down
11 changes: 11 additions & 0 deletions apps/vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
# Changelog

## 0.6.6

### Patch Changes

- [#2393](https://github.com/MoonshotAI/kimi-code/pull/2393) [`6d0a046`](https://github.com/MoonshotAI/kimi-code/commit/6d0a046488edda56219961b253c4787abae7a113) Thanks [@wbxl2000](https://github.com/wbxl2000)! - Fix new users getting stranded on "Model setup required" with no way back to sign-in when the first login finishes authorization but fails to complete model setup; the screen now offers a path back to the sign-in page so login can be retried.
- [#2402](https://github.com/MoonshotAI/kimi-code/pull/2402) [`0f3b106`](https://github.com/MoonshotAI/kimi-code/commit/0f3b106c4260ad626f66bc5c457a535d3163f2bc) Thanks [@wbxl2000](https://github.com/wbxl2000)! - Reword the sign-in waiting message from "Waiting for authorization" to "Waiting for authentication".

- Updated dependencies [[`40172c7`](https://github.com/MoonshotAI/kimi-code/commit/40172c7ca96ca981b043b793588dd32e898979fa)]:
- @moonshot-ai/kimi-code-sdk@0.15.0

## 0.6.5

### Patch Changes

- [#1994](https://github.com/MoonshotAI/kimi-code/pull/1994) [`beeb964`](https://github.com/MoonshotAI/kimi-code/commit/beeb964393c8f9a38c2b1e2273e4415fc434b16d) Thanks [@RealKai42](https://github.com/RealKai42)! - Reduce webview streaming re-render churn: settled assistant messages no longer re-render on every streaming delta, and local images over 10MB are no longer inlined into the webview DOM.
- Updated dependencies [[`ec88d35`](https://github.com/MoonshotAI/kimi-code/commit/ec88d352e8f4dc5e8ffd1212f016138458f69893), [`b5efba7`](https://github.com/MoonshotAI/kimi-code/commit/b5efba7abcaf4041f81ec520097a61e6546e8c50), [`ce0e3ce`](https://github.com/MoonshotAI/kimi-code/commit/ce0e3ceb04223bdaad8e8931bad46eff561055b6), [`e458323`](https://github.com/MoonshotAI/kimi-code/commit/e45832398d0d9cad98dbad1cbf1e5b103a20aace)]:
- @moonshot-ai/kimi-code-sdk@0.14.0

Expand Down
2 changes: 1 addition & 1 deletion apps/vscode/docs/node-sdk-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ stay in the trusted Extension Host.

The runtime constructs the SDK client with:

- `userAgentProduct: "kimi-code-vscode"`
- `productName: "kimi-code-vscode"`
- `version` from `apps/vscode/package.json`
- `uiMode: "vscode"`

Expand Down
2 changes: 1 addition & 1 deletion apps/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publisher": "moonshot-ai",
"displayName": "Kimi Code",
"description": "Official Kimi Code plugin for VS Code",
"version": "0.6.5",
"version": "0.6.6",
"private": true,
"license": "Apache-2.0",
"type": "module",
Expand Down
3 changes: 3 additions & 0 deletions apps/vscode/scripts/vsix-verify.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ function walkSyntax(value, visit) {
function isRuntimeRequire(callee) {
if (callee?.type === 'Identifier') return /^(?:__)?require\d*$/.test(callee.name);
if (callee?.type !== 'MemberExpression' || callee.computed === true) return false;
// `this.require(...)` is an ordinary class method call (e.g. a private field
// accessor in bundled sources), never a CommonJS require of a bare specifier.
if (callee.object?.type === 'ThisExpression') return false;
return callee.property?.type === 'Identifier' && callee.property.name === 'require';
}

Expand Down
3 changes: 2 additions & 1 deletion apps/vscode/src/runtime/kimi-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ export class KimiRuntime {
createKimiHarness({
...(options.homeDir === undefined ? {} : { homeDir: options.homeDir }),
identity: {
userAgentProduct: "kimi-code-vscode",
productName: "kimi-code-vscode",
version: options.version,
platform: "kimi_code_vscode",
},
uiMode: "vscode",
});
Expand Down
Loading
Loading