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
15 changes: 8 additions & 7 deletions apps/kimi-code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@
"type": "module",
"imports": {
"#/tui/theme": "./src/tui/theme/index.ts",
"#/tui/commands": "./src/tui/commands/index.ts",
"#/cli/sub/server": "./src/cli/sub/server/index.ts",
"#/cli/sub/server/*": "./src/cli/sub/server/*.ts",
"#/*": [
"./src/*.ts",
"./src/*/index.ts",
"./src/*.d.ts"
]
"#/generated/vis-web-asset": [
"./src/generated/vis-web-asset.ts",
"./src/generated/vis-web-asset.d.ts"
],
"#/*": "./src/*.ts"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep the declaration fallback for the generated vis asset

In a clean checkout, apps/kimi-code/src/generated/vis-web-asset.ts does not exist; only vis-web-asset.d.ts is checked in, and src/cli/sub/vis.ts imports #/generated/vis-web-asset. With this import map now resolving #/* only to ./src/*.ts, TypeScript treats that import as missing until scripts/build-vis-asset.mjs has been run, but CI typechecks apps/kimi-code/tsconfig.json directly before the app prebuild. Please keep an explicit declaration target for #/generated/vis-web-asset or restore the .d.ts fallback so source-only typecheck/tests still work.

Useful? React with 👍 / 👎.

},
"publishConfig": {
"access": "public",
Expand All @@ -63,8 +64,8 @@
"dev": "node scripts/dev.mjs",
"dev:cli-only": "tsx --import ../../build/register-raw-text-loader.mjs ./src/main.ts",
"dev:server": "tsx --tsconfig ./tsconfig.dev.json --import ../../build/register-raw-text-loader.mjs ./src/main.ts server run --foreground",
"dev:kap-server": "KIMI_CODE_EXPERIMENTAL_FLAG=1 tsx --tsconfig ./tsconfig.dev.json --import ../../build/register-raw-text-loader.mjs --import ../../build/register-hash-imports-loader.mjs ./src/main.ts server run --foreground",
"dev:kap-server:multi": "KIMI_CODE_EXPERIMENTAL_FLAG=1 KIMI_CODE_EXPERIMENTAL_MULTI_SERVER=1 tsx --tsconfig ./tsconfig.dev.json --import ../../build/register-raw-text-loader.mjs --import ../../build/register-hash-imports-loader.mjs ./src/main.ts server run --foreground --port 58628",
"dev:kap-server": "KIMI_CODE_EXPERIMENTAL_FLAG=1 tsx --tsconfig ./tsconfig.dev.json --import ../../build/register-raw-text-loader.mjs ./src/main.ts server run --foreground",
"dev:kap-server:multi": "KIMI_CODE_EXPERIMENTAL_FLAG=1 KIMI_CODE_EXPERIMENTAL_MULTI_SERVER=1 tsx --tsconfig ./tsconfig.dev.json --import ../../build/register-raw-text-loader.mjs ./src/main.ts server run --foreground --port 58628",
"dev:server:restart": "node scripts/dev-server-restart.mjs",
"dev:plugin-marketplace": "node scripts/dev-plugin-marketplace-server.mjs",
"build:plugin-marketplace": "node scripts/build-plugin-marketplace-cdn.mjs",
Expand Down
3 changes: 1 addition & 2 deletions apps/kimi-code/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { resolve } from 'node:path';

import { defineConfig } from 'tsdown';

import { hashImportsPlugin } from '../../build/hash-imports-plugin.mjs';
import { rawTextPlugin } from '../../build/raw-text-plugin.mjs';
import { BUILT_IN_CATALOG_DEFINE, builtInCatalogDefine } from './scripts/built-in-catalog.mjs';

Expand All @@ -24,7 +23,7 @@ export default defineConfig({
'const __dirname = __cjsShimDirname(__filename);',
].join('\n'),
},
plugins: [hashImportsPlugin(), rawTextPlugin()],
plugins: [rawTextPlugin()],
alias: {
'@': resolve(appRoot, 'src'),
},
Expand Down
3 changes: 1 addition & 2 deletions apps/kimi-code/tsdown.native.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { resolve } from 'node:path';

import { defineConfig } from 'tsdown';

import { hashImportsPlugin } from '../../build/hash-imports-plugin.mjs';
import { rawTextPlugin } from '../../build/raw-text-plugin.mjs';
import { BUILT_IN_CATALOG_DEFINE, builtInCatalogDefine } from './scripts/built-in-catalog.mjs';

Expand Down Expand Up @@ -43,7 +42,7 @@ export default defineConfig({
platform: 'node',
target: 'node24',
banner: { js: '#!/usr/bin/env node' },
plugins: [hashImportsPlugin(), rawTextPlugin()],
plugins: [rawTextPlugin()],
alias: {
'@': resolve(appRoot, 'src'),
},
Expand Down
5 changes: 1 addition & 4 deletions apps/vis/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
"license": "MIT",
"type": "module",
"imports": {
"#/*": [
"./src/*.ts",
"./src/*/index.ts"
]
"#/*": "./src/*.ts"
},
"exports": {
".": {
Expand Down
79 changes: 0 additions & 79 deletions build/hash-imports-loader.mjs

This file was deleted.

84 changes: 0 additions & 84 deletions build/hash-imports-plugin.mjs

This file was deleted.

8 changes: 0 additions & 8 deletions build/register-hash-imports-loader.mjs

This file was deleted.

5 changes: 1 addition & 4 deletions packages/acp-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
"author": "Moonshot AI",
"type": "module",
"imports": {
"#/*": [
"./src/*.ts",
"./src/*/index.ts"
]
"#/*": "./src/*.ts"
},
"exports": {
".": {
Expand Down
5 changes: 1 addition & 4 deletions packages/agent-core-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@
],
"type": "module",
"imports": {
"#/*": [
"./src/*.ts",
"./src/*/index.ts"
]
"#/*": "./src/*.ts"
},
"exports": {
".": {
Expand Down
44 changes: 1 addition & 43 deletions packages/agent-core-v2/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,6 @@
import { existsSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { defineConfig, type Plugin } from 'vitest/config';

function findPackageRoot(importer: string | undefined): string | undefined {
if (!importer) return undefined;
let dir = dirname(importer.split('?')[0] ?? importer);
for (;;) {
if (existsSync(join(dir, 'package.json'))) return dir;
const parent = dirname(dir);
if (parent === dir) return undefined;
dir = parent;
}
}

/**
* Resolve `#/` subpath imports the way Node's package.json `imports` field does,
* scoped to the importer's owning package. agent-core-v2 sources and tests
* import each other through the `#/*` alias (e.g. `#/agent/loop`); resolving
* against the importer's package root keeps those aliases pointing at
* agent-core-v2 even when a test inlines a dependency's src.
*
* Tries `src/<sub>.ts` then `src/<sub>/index.ts`, mirroring the
* `"#/*"` → `["./src/*.ts", "./src/<x>/index.ts"]` fallback used by the package.
*/
function hashImportsPlugin(): Plugin {
return {
name: 'resolve-hash-imports',
enforce: 'pre',
resolveId(id, importer) {
if (!id.startsWith('#/')) return null;
const pkgRoot = findPackageRoot(importer);
if (!pkgRoot) return null;
const sub = id.slice(2);
for (const candidate of [`src/${sub}.ts`, `src/${sub}/index.ts`]) {
const full = join(pkgRoot, candidate);
if (existsSync(full)) return full;
}
return null;
},
};
}
import { defineConfig } from 'vitest/config';

export default defineConfig({
plugins: [hashImportsPlugin()],
test: {
name: 'agent-core-v2',
include: ['test/**/*.{test,e2e,integration}.ts'],
Expand Down
21 changes: 17 additions & 4 deletions packages/agent-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,23 @@
],
"type": "module",
"imports": {
"#/*": [
"./src/*.ts",
"./src/*/index.ts"
]
"#/agent": "./src/agent/index.ts",
"#/agent/background": "./src/agent/background/index.ts",
"#/agent/compaction": "./src/agent/compaction/index.ts",
"#/agent/config": "./src/agent/config/index.ts",
"#/agent/context": "./src/agent/context/index.ts",
"#/agent/cron": "./src/agent/cron/index.ts",
"#/agent/goal": "./src/agent/goal/index.ts",
"#/agent/permission": "./src/agent/permission/index.ts",
"#/agent/plan": "./src/agent/plan/index.ts",
"#/agent/swarm": "./src/agent/swarm/index.ts",
"#/agent/tool": "./src/agent/tool/index.ts",
"#/config": "./src/config/index.ts",
"#/flags": "./src/flags/index.ts",
"#/loop": "./src/loop/index.ts",
"#/rpc": "./src/rpc/index.ts",
"#/session": "./src/session/index.ts",
"#/*": "./src/*.ts"
},
"exports": {
".": {
Expand Down
5 changes: 1 addition & 4 deletions packages/kaos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@
],
"type": "module",
"imports": {
"#/*": [
"./src/*.ts",
"./src/*/index.ts"
]
"#/*": "./src/*.ts"
},
"exports": {
".": {
Expand Down
Loading
Loading