fix: harden CLI parsing, MCP startup and release integrity

This commit is contained in:
gitea committed 2026-10-17 20:32:36 +08:00
1 parent f0902f5f20
commit 103ead0fe5
53 files changed
+3713 -1945

No files matched your search

+7 -15
View File
@@ -1,24 +1,16 @@
import { spawn } from "child_process";
import { join } from "path";
import { usageError } from "../errors.js";
import type { CliParsedArgs, CliResult, CliRunOptions } from "../types.js";
export async function handleMcpCommand(
parsed: CliParsedArgs,
options: CliRunOptions
): Promise<CliResult> {
const appRoot = options.appRoot || process.cwd();
const serverPath = join(appRoot, "src", "server.ts");
console.error("启动 MCP Server on stdio...");
const child = spawn("bun", ["run", serverPath], {
stdio: "inherit",
cwd: appRoot,
env: process.env,
});
await new Promise<void>((resolve) => {
child.on("exit", () => resolve());
});
if (parsed.action && parsed.action !== "serve") {
throw usageError(`未知 mcp 子命令: ${parsed.action}。用法: hose-use mcp [serve]`);
}
// Lazy loading avoids a runner -> registry -> server -> runner startup cycle.
const { startServer } = await import("../../server.js");
await startServer(options);
return { stdout: "", stderr: "", exitCode: 0 };
}