From 8d58d6ad4cea96ee64e341b666c41275a648d819 Mon Sep 17 00:00:00 2001 From: liruifengv Date: Tue, 7 Jul 2026 13:37:40 +0800 Subject: [PATCH] chore(dev): open monorepo root when running make dev (#1458) * chore(dev): open monorepo root when running make dev The dev runner spawned the tsx child process with cwd pinned to apps/kimi-code, so the TUI always opened apps/kimi-code as its working directory. Switch the child cwd to the monorepo root and pass the tsconfig, raw-text loader, and entry point as absolute paths so their resolution does not depend on cwd. This only affects the local dev runner; the published CLI is unchanged. * fix(dev): pass --import preload as a file URL Node resolves `--import` preloads as ESM specifiers. On Windows, the absolute path produced by path.resolve() looks like a `c:` URL scheme and crashes the dev CLI with ERR_UNSUPPORTED_ESM_URL_SCHEME before src/main.ts loads. Convert the preload to a file:// URL via pathToFileURL so it resolves on every platform. Addresses codex review on PR #1458. --- apps/kimi-code/scripts/dev.mjs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/kimi-code/scripts/dev.mjs b/apps/kimi-code/scripts/dev.mjs index 1e9ca8c3f..3f50b969c 100644 --- a/apps/kimi-code/scripts/dev.mjs +++ b/apps/kimi-code/scripts/dev.mjs @@ -2,13 +2,16 @@ import { spawn } from 'node:child_process'; import { createRequire } from 'node:module'; import { dirname, resolve } from 'node:path'; -import { fileURLToPath } from 'node:url'; +import { fileURLToPath, pathToFileURL } from 'node:url'; import { startPluginMarketplaceServer } from './dev-plugin-marketplace-server.mjs'; const require = createRequire(import.meta.url); const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url)); const APP_ROOT = resolve(SCRIPT_DIR, '..'); +// Monorepo root. Used as the dev CLI's working directory so `make dev` opens +// the whole repo instead of just apps/kimi-code. +const REPO_ROOT = resolve(APP_ROOT, '../..'); // Runtime variable the CLI reads to locate the marketplace JSON. const MARKETPLACE_ENV = 'KIMI_CODE_PLUGIN_MARKETPLACE_URL'; // Opt-in for dev: point this run at an external marketplace instead of a local one. @@ -48,14 +51,14 @@ const child = spawn( // esbuild transform sees `experimentalDecorators: true` for DI parameter // decorators in agent-core. Mirrors `dev:server` in package.json. '--tsconfig', - './tsconfig.dev.json', + resolve(APP_ROOT, 'tsconfig.dev.json'), '--import', - '../../build/register-raw-text-loader.mjs', - './src/main.ts', + pathToFileURL(resolve(REPO_ROOT, 'build/register-raw-text-loader.mjs')).href, + resolve(APP_ROOT, 'src/main.ts'), ...cliArgs, ], { - cwd: APP_ROOT, + cwd: REPO_ROOT, env, stdio: 'inherit', },