diff --git a/.vibe/development-plan-publish-cli.md b/.vibe/development-plan-publish-cli.md index 9a120d0..d6262e4 100644 --- a/.vibe/development-plan-publish-cli.md +++ b/.vibe/development-plan-publish-cli.md @@ -153,6 +153,7 @@ if (args.length === 0) { - [x] Resolve test timeout issues and improve test reliability - [x] Fix remaining test failures in MCP server and E2E tests - [x] Update all test configurations from old format (web_sources, local_path) to new sources format +- [x] Fix CLI routing issue - entry point was not properly awaiting imports ### Completed @@ -164,6 +165,7 @@ if (args.length === 0) { - [x] CLI integration tests working with new entry point architecture - [x] All test failures resolved - MCP server tests (21/21), E2E tests (12/12) - [x] Full test suite passing (178/178 tests, 100% success rate) +- [x] CLI routing issue fixed - entry point now properly routes to CLI vs MCP server ## Key Decisions diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 2adf294..16851c5 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -13,20 +13,26 @@ import { existsSync } from "node:fs"; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); -const args = process.argv.slice(2); +async function main() { + const args = process.argv.slice(2); -if (args.length === 0) { - // No arguments, start MCP server - const isLocal = existsSync(join(__dirname, "../../mcp-server/dist/index.js")); - if (isLocal) { - import("../../mcp-server/dist/index.js"); + if (args.length === 0) { + // No arguments, start MCP server + const isLocal = existsSync( + join(__dirname, "../../mcp-server/dist/index.js"), + ); + if (isLocal) { + await import("../../mcp-server/dist/index.js"); + } else { + // Use string literal to avoid TypeScript resolution issues + const mcpServerModule = "@codemcp/knowledge-mcp-server"; + await import(mcpServerModule); + } } else { - // Use string literal to avoid TypeScript resolution issues - const mcpServerModule = "@codemcp/knowledge-mcp-server"; - import(mcpServerModule); + // Any arguments, run CLI + const { runCli } = await import("./cli.js"); + runCli(); } -} else { - // Any arguments, run CLI - const { runCli } = await import("./cli.js"); - runCli(); } + +main().catch(console.error);