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/gen-changesets/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Desktop and `kimi web` share `apps/desktop/src/renderer` and `packages/app-*`, *

Add a `@moonshot-ai/kimi-code` entry **only when the change specifically targets `kimi web`**, and name `kimi web` in the sentence:

- `kimi web` CLI flags, daemon lifecycle, token/host handling, or serving `dist-web`.
- `kimi web` CLI flags, daemon lifecycle, token/host handling, or serving `web-dist`.
- Browser-only behavior: `!isDesktop` branches, web-only routes, browser APIs, CSP, or insecure/non-loopback browser contexts.
- If the change fixes both a web-specific path and desktop, write both entries; otherwise write only `@moonshot-ai/kimi-code`.

Expand Down
2 changes: 1 addition & 1 deletion .agents/skills/write-pr/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ interface SessionEvents {

## UI/UX 变化的视觉证据

用户看到的东西变了,就让 reviewer 直接看到改动前后的样子,不要只用文字描述。涉及范围:TUI(`apps/kimi-code/src/tui`、`packages/pi-tui`)、`apps/vis/web`、`apps/vscode/webview-ui`、`dist-web` 同步,以及用户可见的文本输出(print 模式输出、报错文案、命令行帮助)。
用户看到的东西变了,就让 reviewer 直接看到改动前后的样子,不要只用文字描述。涉及范围:TUI(`apps/kimi-code/src/tui`、`packages/pi-tui`)、`apps/vis/web`、`apps/vscode/webview-ui`、`web-dist` 同步,以及用户可见的文本输出(print 模式输出、报错文案、命令行帮助)。

选能说清变化的最低成本形式:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_native-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ jobs:
github-token: ${{ github.token }}
run-id: ${{ inputs.web-ci-run-id }}
name: cli-web-${{ inputs.sha || github.sha }}
path: apps/kimi-code/dist-web
path: apps/kimi-code/web-dist

- name: Build Kimi web assets
if: inputs.web-ci-run-id == ''
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
uses: actions/upload-artifact@v7
with:
name: cli-web-${{ github.sha }}
path: apps/kimi-code/dist-web/
path: apps/kimi-code/web-dist/
if-no-files-found: error
retention-days: 7
overwrite: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
name: e2e-cli
path: |
apps/kimi-code/dist/
apps/kimi-code/dist-web/
apps/kimi-code/web-dist/
apps/kimi-code/native/
if-no-files-found: error
retention-days: 1
Expand Down
2 changes: 1 addition & 1 deletion .oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@
],
"ignorePatterns": [
"dist/",
"dist-web/",
"web-dist/",
"coverage/",
"node_modules/",
"apps/*/scripts/",
Expand Down
2 changes: 1 addition & 1 deletion .oxlintrc.ratchet.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
],
"ignorePatterns": [
"dist/",
"dist-web/",
"web-dist/",
"coverage/",
"node_modules/",
"apps/*/scripts/",
Expand Down
2 changes: 1 addition & 1 deletion apps/kimi-code/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ src/generated/vis-web-asset.ts
/native/

# Built from the desktop renderer web variant by scripts/sync-web-dist.mjs.
/dist-web/
/web-dist/

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clean up or keep ignoring the legacy Web output

For contributors who previously ran pnpm build or pnpm sync:web, Git preserves the generated apps/kimi-code/dist-web tree when this commit is checked out; replacing its ignore rule makes that entire tree untracked, while the updated sync script only removes web-dist. Subsequent builds therefore leave git status dirty and expose the stale generated JavaScript to repository checks such as the mandatory lint run. Delete the legacy directory during synchronization or retain a migration ignore entry.

AGENTS.md reference: AGENTS.md:L51-L55

Useful? React with 👍 / 👎.

2 changes: 1 addition & 1 deletion apps/kimi-code/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@
## 浏览器 Web UI 产物

- 桌面端与浏览器共用 `apps/desktop/src/renderer`。在仓库根目录运行 `pnpm build:web`,Web 版本会生成到 `apps/desktop/web-dist`。
- 要为 CLI 打包,在仓库根目录运行 `pnpm sync:web`。它通过 `scripts/sync-web-dist.mjs` 构建 Web 版本并复制到 `apps/kimi-code/dist-web`。完整的 `pnpm build` 会在 CLI 的 prebuild 阶段自动同步,`scripts/check-web-assets.mjs` 会在打包时检查入口文件。两个产物目录都由 Git 忽略。
- 要为 CLI 打包,在仓库根目录运行 `pnpm sync:web`。它通过 `scripts/sync-web-dist.mjs` 构建 Web 版本并复制到 `apps/kimi-code/web-dist`。完整的 `pnpm build` 会在 CLI 的 prebuild 阶段自动同步,`scripts/check-web-assets.mjs` 会在打包时检查入口文件。两个产物目录都由 Git 忽略。
- 本地联调时,在仓库根目录分别运行 `pnpm dev:server` 和 `pnpm dev:web`。Web 开发服务器将 `/api/v1` 和 `/api/v2` 代理到 `KIMI_SERVER_URL`,默认地址为 `http://127.0.0.1:58627`。
2 changes: 1 addition & 1 deletion apps/kimi-code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"files": [
"dist",
"dist-web",
"web-dist",
Comment thread
liruifengv marked this conversation as resolved.
Resolved
"native",
"scripts/postinstall.mjs",
"scripts/postinstall",
Expand Down
4 changes: 2 additions & 2 deletions apps/kimi-code/scripts/check-web-assets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

const appRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
const target = resolve(appRoot, 'dist-web');
const target = resolve(appRoot, 'web-dist');

async function assertWebAssets() {
try {
Expand All @@ -13,7 +13,7 @@ async function assertWebAssets() {
}
} catch {
throw new Error(
`未找到 web 产物 ${target}/index.html。dist-web 不再入库,由 desktop renderer 的 web 变体构建:` +
`未找到 web 产物 ${target}/index.html。web-dist 不再入库,由 desktop renderer 的 web 变体构建:` +
'运行 `pnpm sync:web`(或完整 `pnpm build`,其 prebuild 会自动同步)。详见 apps/kimi-code/AGENTS.md。',
);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/kimi-code/scripts/native/manifest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ export function buildWebManifestKey(target) {
}

export function buildWebAssetKey(target, relativePath) {
return `web/${target}/dist-web/${relativePath}`;
return `web/${target}/web-dist/${relativePath}`;
}
2 changes: 1 addition & 1 deletion apps/kimi-code/scripts/native/web-assets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {

export { WEB_ASSET_MANIFEST_VERSION };

const WEB_ASSETS_DIR = 'dist-web';
const WEB_ASSETS_DIR = 'web-dist';

function toPosixPath(path) {
return path.split('\\').join('/');
Expand Down
2 changes: 1 addition & 1 deletion apps/kimi-code/scripts/smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { promisify } from 'node:util';
const execFileAsync = promisify(execFile);
const appRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
const bundlePath = resolve(appRoot, 'dist', 'main.mjs');
const webIndexPath = resolve(appRoot, 'dist-web', 'index.html');
const webIndexPath = resolve(appRoot, 'web-dist', 'index.html');
const packageJson = JSON.parse(await readFile(resolve(appRoot, 'package.json'), 'utf-8'));
const expectedVersion = packageJson.version;

Expand Down
2 changes: 1 addition & 1 deletion apps/kimi-code/scripts/sync-web-dist.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { fileURLToPath } from 'node:url';
const appRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
const repoRoot = resolve(appRoot, '../..');
const source = resolve(repoRoot, 'apps/desktop/web-dist');
const target = resolve(appRoot, 'dist-web');
const target = resolve(appRoot, 'web-dist');

const pnpm = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm';
const build = spawnSync(pnpm, ['--filter', 'kimi-code-app', 'run', 'build:web'], {
Expand Down
2 changes: 1 addition & 1 deletion apps/kimi-code/src/cli/sub/web/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import {
type ServerCliOptions,
} from './shared';

const WEB_ASSETS_DIR = 'dist-web';
const WEB_ASSETS_DIR = 'web-dist';

interface RoutedServer {
readonly address: string;
Expand Down
4 changes: 2 additions & 2 deletions apps/kimi-code/src/native/web-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface WebAssetFile {
export interface WebAssetManifest {
readonly version: typeof WEB_ASSET_MANIFEST_VERSION;
readonly target: string;
readonly root: 'dist-web';
readonly root: 'web-dist';
readonly files: readonly WebAssetFile[];
}

Expand Down Expand Up @@ -133,7 +133,7 @@ export function getEmbeddedWebAssetManifest(
if (manifest.target !== target) {
throw new Error(`Web asset manifest target mismatch: ${manifest.target} !== ${target}`);
}
if (manifest.root !== 'dist-web') {
if (manifest.root !== 'web-dist') {
throw new Error(`Unsupported web asset root: ${manifest.root}`);
}
return manifest as WebAssetManifest;
Expand Down
6 changes: 3 additions & 3 deletions apps/kimi-code/test/cli/web/web.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -757,12 +757,12 @@ describe('shared parsers stay strict', () => {
describe('server web asset directory resolution', () => {
it('uses extracted SEA web assets when available', async () => {
const { resolveServerWebAssetsDir } = await import('#/cli/sub/web/run');
expect(resolveServerWebAssetsDir('/cache/kimi/dist-web')).toBe('/cache/kimi/dist-web');
expect(resolveServerWebAssetsDir('/cache/kimi/web-dist')).toBe('/cache/kimi/web-dist');
});

it('falls back to package dist-web outside SEA mode', async () => {
it('falls back to package web-dist outside SEA mode', async () => {
const { resolveServerWebAssetsDir } = await import('#/cli/sub/web/run');
expect(resolveServerWebAssetsDir(null)).toMatch(/[/\\]dist-web$/);
expect(resolveServerWebAssetsDir(null)).toMatch(/[/\\]web-dist$/);
});

it('returns the assets dir when it is built, dev mode or not', async () => {
Expand Down
8 changes: 4 additions & 4 deletions apps/kimi-code/test/native/web-assets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ function fakeWebAssets(files: Record<string, string>): {
const manifest: WebAssetManifest = {
version: WEB_ASSET_MANIFEST_VERSION,
target: 'test-target',
root: 'dist-web',
root: 'web-dist',
files: Object.entries(files).map(([relativePath, content]) => ({
assetKey: `web/test-target/dist-web/${relativePath}`,
assetKey: `web/test-target/web-dist/${relativePath}`,
relativePath,
sha256: sha256(content),
})),
};
const assets = new Map<string, Buffer>([
['web/test-target/manifest.json', Buffer.from(JSON.stringify(manifest))],
...Object.entries(files).map(([relativePath, content]) => [
`web/test-target/dist-web/${relativePath}`,
`web/test-target/web-dist/${relativePath}`,
Buffer.from(content),
] as const),
]);
Expand All @@ -52,7 +52,7 @@ function fakeWebAssets(files: Record<string, string>): {
}

describe('web assets', () => {
it('extracts embedded web assets into a dist-web cache directory', () => {
it('extracts embedded web assets into a web-dist cache directory', () => {
const dir = mkdtempSync(join(tmpdir(), 'kimi-web-assets-runtime-'));
try {
const { manifest, source } = fakeWebAssets({
Expand Down
28 changes: 14 additions & 14 deletions apps/kimi-code/test/scripts/native/web-assets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ function sha256(bytes: Buffer | string): string {
}

describe('collectWebAssets', () => {
it('collects dist-web files into deterministic SEA asset keys', async () => {
it('collects web-dist files into deterministic SEA asset keys', async () => {
const appRoot = mkdtempSync(join(tmpdir(), 'kimi-web-assets-build-'));
try {
mkdirSync(join(appRoot, 'dist-web', 'assets'), { recursive: true });
writeFileSync(join(appRoot, 'dist-web', 'index.html'), '<div id="app"></div>\n');
writeFileSync(join(appRoot, 'dist-web', 'assets', 'app.js'), 'console.log("ok");\n');
mkdirSync(join(appRoot, 'web-dist', 'assets'), { recursive: true });
writeFileSync(join(appRoot, 'web-dist', 'index.html'), '<div id="app"></div>\n');
writeFileSync(join(appRoot, 'web-dist', 'assets', 'app.js'), 'console.log("ok");\n');

const { manifest, manifestJson, assets } = await collectWebAssets({
appRoot,
Expand All @@ -32,31 +32,31 @@ describe('collectWebAssets', () => {
expect(manifest).toEqual({
version: WEB_ASSET_MANIFEST_VERSION,
target: 'test-target',
root: 'dist-web',
root: 'web-dist',
files: [
{
assetKey: 'web/test-target/dist-web/assets/app.js',
assetKey: 'web/test-target/web-dist/assets/app.js',
relativePath: 'assets/app.js',
sha256: sha256('console.log("ok");\n'),
},
{
assetKey: 'web/test-target/dist-web/index.html',
assetKey: 'web/test-target/web-dist/index.html',
relativePath: 'index.html',
sha256: sha256('<div id="app"></div>\n'),
},
],
});
expect(JSON.parse(manifestJson) as unknown).toEqual(manifest);
expect(assets).toEqual({
'web/test-target/dist-web/assets/app.js': join(appRoot, 'dist-web', 'assets', 'app.js'),
'web/test-target/dist-web/index.html': join(appRoot, 'dist-web', 'index.html'),
'web/test-target/web-dist/assets/app.js': join(appRoot, 'web-dist', 'assets', 'app.js'),
'web/test-target/web-dist/index.html': join(appRoot, 'web-dist', 'index.html'),
});
} finally {
rmSync(appRoot, { recursive: true, force: true });
}
});

it('fails clearly when dist-web has not been built', async () => {
it('fails clearly when web-dist has not been built', async () => {
const appRoot = mkdtempSync(join(tmpdir(), 'kimi-web-assets-missing-'));
try {
await expect(collectWebAssets({ appRoot, target: 'test-target' })).rejects.toThrow(
Expand All @@ -70,17 +70,17 @@ describe('collectWebAssets', () => {
it('keeps manifest JSON parseable and stable', async () => {
const appRoot = mkdtempSync(join(tmpdir(), 'kimi-web-assets-json-'));
try {
mkdirSync(join(appRoot, 'dist-web'), { recursive: true });
writeFileSync(join(appRoot, 'dist-web', 'index.html'), '<html></html>');
mkdirSync(join(appRoot, 'web-dist'), { recursive: true });
writeFileSync(join(appRoot, 'web-dist', 'index.html'), '<html></html>');

const { manifestJson } = await collectWebAssets({ appRoot, target: 'test-target' });

expect(readFileSync(join(appRoot, 'dist-web', 'index.html'), 'utf-8')).toBe('<html></html>');
expect(readFileSync(join(appRoot, 'web-dist', 'index.html'), 'utf-8')).toBe('<html></html>');
expect(manifestJson.endsWith('\n')).toBe(true);
expect(JSON.parse(manifestJson)).toMatchObject({
version: WEB_ASSET_MANIFEST_VERSION,
target: 'test-target',
root: 'dist-web',
root: 'web-dist',
});
} finally {
rmSync(appRoot, { recursive: true, force: true });
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
"// runVerifyStep skipped in nix sandbox (sigtool lacks -dv)"
''}
# The SEA blob step (scripts/native/02-sea-blob.mjs) embeds the
# Kimi web assets from apps/kimi-code/dist-web. The bundle is not
# Kimi web assets from apps/kimi-code/web-dist. The bundle is not
# committed — build it from the desktop renderer's web variant,
# then verify it is in place before producing the native
# executable.
Expand Down
2 changes: 1 addition & 1 deletion scripts/checks/baselines/oxlint-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"globals": {},
"ignorePatterns": [
"dist/",
"dist-web/",
"web-dist/",
"coverage/",
"node_modules/",
"apps/*/scripts/",
Expand Down
2 changes: 1 addition & 1 deletion scripts/checks/instructions.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
{
"file": "apps/kimi-code/AGENTS.md",
"reference": "apps/kimi-code/dist-web",
"reference": "apps/kimi-code/web-dist",
"why": "The web bundle copied into the CLI during prebuild, ignored by Git."
}
]
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/surfaces/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class WebDriver extends PageDriver {
}

export async function startWeb({ home, reopen }: SurfaceLaunch): Promise<SurfaceDriver<'web'>> {
const assets = repoPath('apps', 'kimi-code', 'dist-web', 'index.html');
const assets = repoPath('apps', 'kimi-code', 'web-dist', 'index.html');
if (!existsSync(assets)) throw new Error(`${assets} does not exist; build the web assets first with "pnpm sync:web".`);
const ownPorts = workerWebPorts(test.info().parallelIndex);
const server = await TerminalProcess.start({
Expand Down
Loading