From 92acd07452194cefc2b86fe700ff1a6f0b0a3453 Mon Sep 17 00:00:00 2001 From: qer Date: Sun, 5 Jul 2026 11:42:09 +0800 Subject: [PATCH] feat(web): ship kimi-web2 as the bundled web assets on this branch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - copy-web-assets.mjs now copies the static apps/kimi-web2 app into dist-web (no Vue build step needed); dev-only files are excluded. - live.js: on http(s) pages, try the same-origin server even without a token; a 401 opens the token dialog, which persists the token and reloads — so the server-hosted build connects out of the box. - Verified end-to-end against a protected local server (401 -> token dialog -> live workspaces/sessions/history over REST + WS). --- .changeset/web2-bundled-ui.md | 5 ++++ apps/kimi-code/package.json | 2 +- apps/kimi-code/scripts/copy-web-assets.mjs | 24 ++++++++++------- apps/kimi-web2/app.js | 8 +++--- apps/kimi-web2/index.html | 2 +- apps/kimi-web2/live.js | 30 ++++++++++++++++++---- 6 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 .changeset/web2-bundled-ui.md diff --git a/.changeset/web2-bundled-ui.md b/.changeset/web2-bundled-ui.md new file mode 100644 index 000000000..f043a6a09 --- /dev/null +++ b/.changeset/web2-bundled-ui.md @@ -0,0 +1,5 @@ +--- +"@moonshot-ai/kimi-code": minor +--- + +web: Replace the bundled web UI with the design-first kimi-web2 prototype built from the Kimi Design System. Run kimi web and open the printed URL to try it. diff --git a/apps/kimi-code/package.json b/apps/kimi-code/package.json index 70accd50a..8e833b779 100644 --- a/apps/kimi-code/package.json +++ b/apps/kimi-code/package.json @@ -49,7 +49,7 @@ "provenance": true }, "scripts": { - "build": "pnpm -C ../kimi-web run build && tsdown && node scripts/copy-native-assets.mjs && node scripts/copy-web-assets.mjs", + "build": "tsdown && node scripts/copy-native-assets.mjs && node scripts/copy-web-assets.mjs", "prebuild": "node scripts/build-vis-asset.mjs", "catalog:update": "node scripts/update-catalog.mjs --out dist/built-in-catalog.json", "smoke": "node scripts/smoke.mjs", diff --git a/apps/kimi-code/scripts/copy-web-assets.mjs b/apps/kimi-code/scripts/copy-web-assets.mjs index d82f40de0..69ec1e765 100644 --- a/apps/kimi-code/scripts/copy-web-assets.mjs +++ b/apps/kimi-code/scripts/copy-web-assets.mjs @@ -1,27 +1,33 @@ import { cp, rm, stat } from 'node:fs/promises'; -import { dirname, resolve } from 'node:path'; +import { basename, dirname, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; const appRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..'); const repoRoot = resolve(appRoot, '../..'); -const source = resolve(repoRoot, 'apps/kimi-web/dist'); +// This branch ships the design-first kimi-web2 UI as the bundled web assets. +// kimi-web2 is a static, no-build app, so it is copied directly (no dist step). +const source = resolve(repoRoot, 'apps/kimi-web2'); const target = resolve(appRoot, 'dist-web'); -async function assertBuiltWeb() { +// Dev/docs files that should not ship in the web asset bundle. +const EXCLUDE = new Set(['serve.mjs', 'README.md', 'CONVENTIONS.md']); + +async function assertWebSource() { try { const info = await stat(resolve(source, 'index.html')); if (!info.isFile()) { throw new Error('index.html is not a file'); } } catch { - throw new Error( - `Kimi web build output was not found at ${source}. Run \`pnpm --filter @moonshot-ai/kimi-web run build\` first.`, - ); + throw new Error(`Kimi web assets were not found at ${source}.`); } } -await assertBuiltWeb(); +await assertWebSource(); await rm(target, { recursive: true, force: true }); -await cp(source, target, { recursive: true }); +await cp(source, target, { + recursive: true, + filter: (src) => !EXCLUDE.has(basename(src)), +}); -console.log(`Copied Kimi web assets to ${target}`); +console.log(`Copied Kimi web assets (kimi-web2) to ${target}`); diff --git a/apps/kimi-web2/app.js b/apps/kimi-web2/app.js index 080502d72..63e60a151 100644 --- a/apps/kimi-web2/app.js +++ b/apps/kimi-web2/app.js @@ -517,9 +517,11 @@ /* ----------------------------- server auth ---------------------------- */ function connectToken() { - S.set({ authed: true }); - closeOverlays(); - toast('已连接(stub)', 'success'); + var inp = $('[data-token-input]'); + var v = inp && inp.value.trim(); + if (!v) { toast('请输入 Token', 'error'); return; } + try { localStorage.setItem('kimi2-token', v); } catch (err) {} + location.reload(); } /* ----------------------------- delegated clicks ----------------------- */ diff --git a/apps/kimi-web2/index.html b/apps/kimi-web2/index.html index 529f5f054..852c179ba 100644 --- a/apps/kimi-web2/index.html +++ b/apps/kimi-web2/index.html @@ -459,7 +459,7 @@