mirror of
https://github.com/MoonshotAI/kimi-code.git
synced 2026-08-30 04:22:51 +00:00
chore(scripts): require KIMI_CODE_REPO in sync:web, drop dead copy-web-dist
- sync-web-to-kimi-code.mjs: KIMI_CODE_REPO is now required (no more ../kimi-code-2 default), the target is validated as a kimi-code checkout, errors are in Chinese, and a reminder to open a PR in the kimi-code repo prints after a successful sync - Remove apps/desktop/scripts/copy-web-dist.mjs and the web-dist .gitignore entry: the desktop renderer builds from src/renderer into desktop-dist, so the web-dist copy flow is dead - README.md / AGENTS.md updated to match
This commit is contained in:
parent
1fb9d5e177
commit
ada047e90e
5 changed files with 31 additions and 37 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,7 +3,6 @@ dist
|
|||
out
|
||||
dist-app
|
||||
resources-stage
|
||||
web-dist
|
||||
.DS_Store
|
||||
*.log
|
||||
coverage
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
- `apps/web`:浏览器 Web UI(`@moonshot-ai/kimi-web`,Vue 3 + Vite + vue-i18n)。dev 时 Vite 把 `/api/v1`(REST + WS)代理到 `KIMI_SERVER_URL`(默认 `http://127.0.0.1:58627`)。
|
||||
- `packages/*`:`@moonshot-ai/{web-core,web-i18n,web-markdown,web-ui}` + `vite-preset`(exports→src,被 apps/web 与 desktop renderer 复用)。
|
||||
- `kimi-code/`:git submodule(核心仓)。`kimi-code/packages/*` 提供 `kap-server`、`agent-core-v2`、`kimi-code-sdk` 等源码。
|
||||
- `scripts/sync-web-to-kimi-code.mjs`:`apps/web/dist` → `<kimi-code checkout>/apps/kimi-code/dist-web`(`KIMI_CODE_REPO` 指定目标,默认 `../kimi-code-2`)。
|
||||
- `scripts/sync-web-to-kimi-code.mjs`:`apps/web/dist` → `<kimi-code checkout>/apps/kimi-code/dist-web`(`KIMI_CODE_REPO` 必传,指定目标 checkout)。
|
||||
|
||||
## 常用命令
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ Kimi Code 客户端仓库:桌面端(`apps/desktop`)+ Web UI(`apps/web`
|
|||
|
||||
- **本仓库是 Web UI 和桌面端源码的主仓库**。这两个应用此前住在 kimi-code 仓库(`apps/kimi-web` / `apps/kimi-desktop`),今后 web/desktop 的开发都在本仓库进行。
|
||||
- **kimi-code 是 CLI / server / agent 的主仓库**,以 submodule 钉在本仓库根目录,其 `packages/*` 通过 pnpm workspace 直接以源码链接进来——desktop 的 Electron 主进程会把其中的 server(`kap-server`、`agent-core-v2` 等)打包为内嵌 server。
|
||||
- **web 产物分发**:`pnpm sync:web`(`scripts/sync-web-to-kimi-code.mjs`)把 `apps/web/dist` 拷贝到一个 kimi-code checkout 的 `apps/kimi-code/dist-web`,用 `KIMI_CODE_REPO` 指定目标 checkout(默认 `../kimi-code-2`)。
|
||||
- **web 产物分发**:`pnpm sync:web`(`scripts/sync-web-to-kimi-code.mjs`)把 `apps/web/dist` 拷贝到一个 kimi-code checkout 的 `apps/kimi-code/dist-web`,用 `KIMI_CODE_REPO` 指定目标 checkout(必传)。
|
||||
|
||||
## 快速开始
|
||||
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
import { cp, rm, stat } from 'node:fs/promises';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const desktopRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const repoRoot = resolve(desktopRoot, '../..');
|
||||
const source = resolve(repoRoot, 'apps/web/dist');
|
||||
const target = resolve(desktopRoot, 'web-dist');
|
||||
|
||||
async function assertBuiltWeb() {
|
||||
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(
|
||||
`Web build output was not found at ${source}. Run \`pnpm --filter @moonshot-ai/kimi-web run build\` first.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
await assertBuiltWeb();
|
||||
await rm(target, { recursive: true, force: true });
|
||||
await cp(source, target, { recursive: true });
|
||||
|
||||
console.log(`Copied web assets to ${target}`);
|
||||
|
|
@ -4,12 +4,20 @@ import { fileURLToPath } from 'node:url';
|
|||
|
||||
const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const source = resolve(repoRoot, 'apps/web/dist');
|
||||
// Dev default: sibling checkout `../kimi-code-2` (the kimi-code repo where the
|
||||
// split branch lives). Override with KIMI_CODE_REPO to point at any checkout.
|
||||
// Target kimi-code checkout is REQUIRED via KIMI_CODE_REPO — there is no
|
||||
// default, so a sync never lands in the wrong clone.
|
||||
const kimiCodeRepo = process.env.KIMI_CODE_REPO
|
||||
? resolve(process.env.KIMI_CODE_REPO)
|
||||
: resolve(repoRoot, '..', 'kimi-code-2');
|
||||
const target = resolve(kimiCodeRepo, 'apps/kimi-code/dist-web');
|
||||
: undefined;
|
||||
|
||||
if (kimiCodeRepo === undefined) {
|
||||
throw new Error(
|
||||
'请设置 KIMI_CODE_REPO 指向你的 kimi-code 仓 checkout,例如:KIMI_CODE_REPO=~/code/kimi-code-5 pnpm sync:web',
|
||||
);
|
||||
}
|
||||
|
||||
const appRoot = resolve(kimiCodeRepo, 'apps/kimi-code');
|
||||
const target = resolve(appRoot, 'dist-web');
|
||||
|
||||
async function assertBuiltWeb() {
|
||||
try {
|
||||
|
|
@ -19,14 +27,28 @@ async function assertBuiltWeb() {
|
|||
}
|
||||
} catch {
|
||||
throw new Error(
|
||||
`Web build output was not found at ${source}. Run \`pnpm --filter @moonshot-ai/kimi-web run build\` first.`,
|
||||
`未找到 web 构建产物 ${source}/index.html,请先运行 \`pnpm --filter @moonshot-ai/kimi-web run build\`。`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function assertKimiCodeRepo() {
|
||||
try {
|
||||
const info = await stat(appRoot);
|
||||
if (!info.isDirectory()) {
|
||||
throw new Error('apps/kimi-code is not a directory');
|
||||
}
|
||||
} catch {
|
||||
throw new Error(
|
||||
`KIMI_CODE_REPO 不像一个 kimi-code 仓 checkout:未找到 ${appRoot}。`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
await assertBuiltWeb();
|
||||
await assertKimiCodeRepo();
|
||||
await rm(target, { recursive: true, force: true });
|
||||
await cp(source, target, { recursive: true });
|
||||
|
||||
console.log(`Synced web assets to kimi-code SEA bundle: ${target}`);
|
||||
console.log('Next: commit the dist-web snapshot inside the kimi-code repo and open a PR.');
|
||||
console.log(`已同步 web 产物到:${target}`);
|
||||
console.log('提醒:完成后在 kimi-code 仓提交 dist-web 变更并创建 PR(该仓 gitignore dist-web,需 `git add -f`)。');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue