mirror of
https://github.com/MoonshotAI/kimi-code.git
synced 2026-07-09 17:29:12 +00:00
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.
This commit is contained in:
parent
166e404a92
commit
8d58d6ad4c
1 changed files with 8 additions and 5 deletions
|
|
@ -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',
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue