diff --git a/.agents/skills/gen-changesets/SKILL.md b/.agents/skills/gen-changesets/SKILL.md index a52cba799fc..e6a3a99318c 100644 --- a/.agents/skills/gen-changesets/SKILL.md +++ b/.agents/skills/gen-changesets/SKILL.md @@ -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`. diff --git a/.agents/skills/write-pr/SKILL.md b/.agents/skills/write-pr/SKILL.md index bf7d46cc9b6..49785d699d2 100644 --- a/.agents/skills/write-pr/SKILL.md +++ b/.agents/skills/write-pr/SKILL.md @@ -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 模式输出、报错文案、命令行帮助)。 选能说清变化的最低成本形式: diff --git a/.github/workflows/_native-build.yml b/.github/workflows/_native-build.yml index e073ebfe7f5..a3a3cee8b25 100644 --- a/.github/workflows/_native-build.yml +++ b/.github/workflows/_native-build.yml @@ -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 == '' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1115c3bd28d..808abd62831 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index c3b86be4453..c301d893559 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -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 diff --git a/.oxlintrc.json b/.oxlintrc.json index 72f87a721d2..5248f1c7847 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -451,7 +451,7 @@ ], "ignorePatterns": [ "dist/", - "dist-web/", + "web-dist/", "coverage/", "node_modules/", "apps/*/scripts/", diff --git a/.oxlintrc.ratchet.json b/.oxlintrc.ratchet.json index 78af0fa0e9c..7226e4e307f 100644 --- a/.oxlintrc.ratchet.json +++ b/.oxlintrc.ratchet.json @@ -162,7 +162,7 @@ ], "ignorePatterns": [ "dist/", - "dist-web/", + "web-dist/", "coverage/", "node_modules/", "apps/*/scripts/", diff --git a/apps/kimi-code/.gitignore b/apps/kimi-code/.gitignore index 462e115bb1b..c1f97e748d8 100644 --- a/apps/kimi-code/.gitignore +++ b/apps/kimi-code/.gitignore @@ -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/ diff --git a/apps/kimi-code/AGENTS.md b/apps/kimi-code/AGENTS.md index ba28ea6e619..4263804662f 100644 --- a/apps/kimi-code/AGENTS.md +++ b/apps/kimi-code/AGENTS.md @@ -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`。 diff --git a/apps/kimi-code/package.json b/apps/kimi-code/package.json index 0669b700ed6..b754de0a727 100644 --- a/apps/kimi-code/package.json +++ b/apps/kimi-code/package.json @@ -27,7 +27,7 @@ }, "files": [ "dist", - "dist-web", + "web-dist", "native", "scripts/postinstall.mjs", "scripts/postinstall", diff --git a/apps/kimi-code/scripts/check-web-assets.mjs b/apps/kimi-code/scripts/check-web-assets.mjs index c441f63baea..8889265d6ed 100644 --- a/apps/kimi-code/scripts/check-web-assets.mjs +++ b/apps/kimi-code/scripts/check-web-assets.mjs @@ -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 { @@ -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。', ); } diff --git a/apps/kimi-code/scripts/native/manifest.mjs b/apps/kimi-code/scripts/native/manifest.mjs index 99f3b3a3d16..327d703459d 100644 --- a/apps/kimi-code/scripts/native/manifest.mjs +++ b/apps/kimi-code/scripts/native/manifest.mjs @@ -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}`; } diff --git a/apps/kimi-code/scripts/native/web-assets.mjs b/apps/kimi-code/scripts/native/web-assets.mjs index 8f8a893c5fb..0bb0f7a0463 100644 --- a/apps/kimi-code/scripts/native/web-assets.mjs +++ b/apps/kimi-code/scripts/native/web-assets.mjs @@ -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('/'); diff --git a/apps/kimi-code/scripts/smoke.mjs b/apps/kimi-code/scripts/smoke.mjs index b89a48fb3da..8368275d210 100644 --- a/apps/kimi-code/scripts/smoke.mjs +++ b/apps/kimi-code/scripts/smoke.mjs @@ -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; diff --git a/apps/kimi-code/scripts/sync-web-dist.mjs b/apps/kimi-code/scripts/sync-web-dist.mjs index aa1581e6f95..d546efdf2e1 100644 --- a/apps/kimi-code/scripts/sync-web-dist.mjs +++ b/apps/kimi-code/scripts/sync-web-dist.mjs @@ -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'], { diff --git a/apps/kimi-code/src/cli/sub/web/run.ts b/apps/kimi-code/src/cli/sub/web/run.ts index b1302b56db0..bfb1922f402 100644 --- a/apps/kimi-code/src/cli/sub/web/run.ts +++ b/apps/kimi-code/src/cli/sub/web/run.ts @@ -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; diff --git a/apps/kimi-code/src/native/web-assets.ts b/apps/kimi-code/src/native/web-assets.ts index 6fb0845e524..81b06f7a3fe 100644 --- a/apps/kimi-code/src/native/web-assets.ts +++ b/apps/kimi-code/src/native/web-assets.ts @@ -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[]; } @@ -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; diff --git a/apps/kimi-code/test/cli/web/web.test.ts b/apps/kimi-code/test/cli/web/web.test.ts index 2a44a610c31..9ed5eb77791 100644 --- a/apps/kimi-code/test/cli/web/web.test.ts +++ b/apps/kimi-code/test/cli/web/web.test.ts @@ -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 () => { diff --git a/apps/kimi-code/test/native/web-assets.test.ts b/apps/kimi-code/test/native/web-assets.test.ts index abe3801feec..55907b2bf7b 100644 --- a/apps/kimi-code/test/native/web-assets.test.ts +++ b/apps/kimi-code/test/native/web-assets.test.ts @@ -24,9 +24,9 @@ function fakeWebAssets(files: Record): { 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), })), @@ -34,7 +34,7 @@ function fakeWebAssets(files: Record): { const assets = new Map([ ['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), ]); @@ -52,7 +52,7 @@ function fakeWebAssets(files: Record): { } 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({ diff --git a/apps/kimi-code/test/scripts/native/web-assets.test.ts b/apps/kimi-code/test/scripts/native/web-assets.test.ts index 2b5bfa9204c..dea69145b48 100644 --- a/apps/kimi-code/test/scripts/native/web-assets.test.ts +++ b/apps/kimi-code/test/scripts/native/web-assets.test.ts @@ -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'), '
\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'), '
\n'); + writeFileSync(join(appRoot, 'web-dist', 'assets', 'app.js'), 'console.log("ok");\n'); const { manifest, manifestJson, assets } = await collectWebAssets({ appRoot, @@ -32,15 +32,15 @@ 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('
\n'), }, @@ -48,15 +48,15 @@ describe('collectWebAssets', () => { }); 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( @@ -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'), ''); + mkdirSync(join(appRoot, 'web-dist'), { recursive: true }); + writeFileSync(join(appRoot, 'web-dist', 'index.html'), ''); const { manifestJson } = await collectWebAssets({ appRoot, target: 'test-target' }); - expect(readFileSync(join(appRoot, 'dist-web', 'index.html'), 'utf-8')).toBe(''); + expect(readFileSync(join(appRoot, 'web-dist', 'index.html'), 'utf-8')).toBe(''); 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 }); diff --git a/flake.nix b/flake.nix index 810e1e4f51b..4441a9ff206 100644 --- a/flake.nix +++ b/flake.nix @@ -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. diff --git a/scripts/checks/baselines/oxlint-config.json b/scripts/checks/baselines/oxlint-config.json index 0eccfd80c37..cda4e35b3e3 100644 --- a/scripts/checks/baselines/oxlint-config.json +++ b/scripts/checks/baselines/oxlint-config.json @@ -15,7 +15,7 @@ "globals": {}, "ignorePatterns": [ "dist/", - "dist-web/", + "web-dist/", "coverage/", "node_modules/", "apps/*/scripts/", diff --git a/scripts/checks/instructions.json b/scripts/checks/instructions.json index c214c458c09..c26934a65b5 100644 --- a/scripts/checks/instructions.json +++ b/scripts/checks/instructions.json @@ -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." } ] diff --git a/tests/e2e/surfaces/web.ts b/tests/e2e/surfaces/web.ts index 6668e303ad6..53b2c331ac2 100644 --- a/tests/e2e/surfaces/web.ts +++ b/tests/e2e/surfaces/web.ts @@ -174,7 +174,7 @@ class WebDriver extends PageDriver { } export async function startWeb({ home, reopen }: SurfaceLaunch): Promise> { - 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({