fix(kimi-code): bundle npm package into single entry (#775)

* fix(kimi-code): bundle npm package into single entry

Bundle runtime dependencies into the CLI npm entry file, prepare an npm publish directory without bundled dependencies, and keep clipboard support optional.

* fix(kimi-code): sync npm publish directory lockfile

Update pnpm-lock.yaml for apps/kimi-code publishConfig.directory so CI can install with --frozen-lockfile.

* fix(kimi-code): disable cli declaration output

Stop generating the TypeScript declaration sidecar so the npm package contains only the main.mjs CLI entry artifact.

* fix(kimi-code): move bundled deps to devDependencies

Remove the npm publish directory pre-processing path, keep runtime dependencies as dev-only build inputs for the single-file bundle, and add a manifest regression test.

* fix(kimi-code): make koffi optional

Keep koffi available as an optional native dependency without listing bundled runtime packages as published dependencies.

* fix(kimi-code): use explicit bundle allowlist

Avoid treating every devDependency as a runtime bundle input and list the bundled third-party dependencies explicitly.

* fix(kimi-code): remove manifest regression test

Keep the packaging change focused on the manifest and bundler configuration without an extra package-json regression test.

* fix(kimi-code): only externalize optional deps

Keep tsdown's never-bundle list limited to published optional native dependencies.

* Update tsdown.config.ts

* fix(kimi-code): simplify changeset

Keep the changeset summary focused on optimizing the npm packaging system.
This commit is contained in:
liruifengv 2026-06-15 20:23:13 +08:00 committed by GitHub
parent 8a92db6a0c
commit 3fa1b8ea7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 53 additions and 38 deletions

View file

@ -0,0 +1,5 @@
---
"@moonshot-ai/kimi-code": patch
---
Optimize the npm packaging system.

View file

@ -66,18 +66,12 @@
"e2e:real": "pnpm -w run build:packages && KIMI_E2E_REAL=1 vitest run test/e2e/real-llm-smoke.e2e.test.ts",
"postinstall": "node scripts/postinstall.mjs"
},
"dependencies": {
"@earendil-works/pi-tui": "^0.74.0",
"optionalDependencies": {
"@mariozechner/clipboard": "^0.3.2",
"chalk": "^5.4.1",
"cli-highlight": "^2.1.11",
"commander": "^13.1.0",
"pathe": "^2.0.3",
"semver": "^7.7.4",
"smol-toml": "^1.6.1",
"zod": "^4.3.6"
"koffi": "^2.16.0"
},
"devDependencies": {
"@earendil-works/pi-tui": "^0.74.0",
"@moonshot-ai/acp-adapter": "workspace:^",
"@moonshot-ai/kimi-code-oauth": "workspace:^",
"@moonshot-ai/kimi-code-sdk": "workspace:^",
@ -85,9 +79,16 @@
"@moonshot-ai/migration-legacy": "workspace:^",
"@types/semver": "^7.7.0",
"@types/yazl": "^2.4.6",
"chalk": "^5.4.1",
"cli-highlight": "^2.1.11",
"commander": "^13.1.0",
"pathe": "^2.0.3",
"postject": "1.0.0-alpha.6",
"semver": "^7.7.4",
"smol-toml": "^1.6.1",
"tsx": "^4.21.0",
"yazl": "^3.3.1"
"yazl": "^3.3.1",
"zod": "^4.3.6"
},
"engines": {
"node": ">=22.19.0"

View file

@ -12,6 +12,8 @@ export default defineConfig({
format: ['esm'],
outDir: 'dist',
clean: true,
dts: false,
hash: false,
banner: {
js: [
'#!/usr/bin/env node',
@ -29,7 +31,10 @@ export default defineConfig({
[BUILT_IN_CATALOG_DEFINE]: builtInCatalogDefine(),
},
deps: {
alwaysBundle: [/^@moonshot-ai\//],
neverBundle: [],
onlyBundle: false,
},
outputOptions: {
codeSplitting: false,
entryFileNames: 'main.mjs',
},
});

56
pnpm-lock.yaml generated
View file

@ -65,35 +65,10 @@ importers:
version: 4.1.4(@types/node@22.19.17)(@vitest/coverage-v8@4.1.4)(vite@8.0.8(@types/node@22.19.17)(esbuild@0.27.7)(jiti@2.6.1)(tsx@4.21.0)(yaml@2.8.3))
apps/kimi-code:
dependencies:
devDependencies:
'@earendil-works/pi-tui':
specifier: ^0.74.0
version: 0.74.0
'@mariozechner/clipboard':
specifier: ^0.3.2
version: 0.3.2
chalk:
specifier: ^5.4.1
version: 5.6.2
cli-highlight:
specifier: ^2.1.11
version: 2.1.11
commander:
specifier: ^13.1.0
version: 13.1.0
pathe:
specifier: ^2.0.3
version: 2.0.3
semver:
specifier: ^7.7.4
version: 7.7.4
smol-toml:
specifier: ^1.6.1
version: 1.6.1
zod:
specifier: ^4.3.6
version: 4.3.6
devDependencies:
'@moonshot-ai/acp-adapter':
specifier: workspace:^
version: link:../../packages/acp-adapter
@ -115,15 +90,43 @@ importers:
'@types/yazl':
specifier: ^2.4.6
version: 2.4.6
chalk:
specifier: ^5.4.1
version: 5.6.2
cli-highlight:
specifier: ^2.1.11
version: 2.1.11
commander:
specifier: ^13.1.0
version: 13.1.0
pathe:
specifier: ^2.0.3
version: 2.0.3
postject:
specifier: 1.0.0-alpha.6
version: 1.0.0-alpha.6
semver:
specifier: ^7.7.4
version: 7.7.4
smol-toml:
specifier: ^1.6.1
version: 1.6.1
tsx:
specifier: ^4.21.0
version: 4.21.0
yazl:
specifier: ^3.3.1
version: 3.3.1
zod:
specifier: ^4.3.6
version: 4.3.6
optionalDependencies:
'@mariozechner/clipboard':
specifier: ^0.3.2
version: 0.3.2
koffi:
specifier: ^2.16.0
version: 2.16.0
apps/vis:
devDependencies:
@ -6438,6 +6441,7 @@ snapshots:
'@mariozechner/clipboard-linux-x64-musl': 0.3.2
'@mariozechner/clipboard-win32-arm64-msvc': 0.3.2
'@mariozechner/clipboard-win32-x64-msvc': 0.3.2
optional: true
'@mermaid-js/mermaid-mindmap@9.3.0':
dependencies: