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 -4
View File
@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url";
import { runCli } from "./cli/runner.js";
import { redactSensitiveText, writeStdoutChunk } from "./cli/printer.js";
import { VERSION } from "./version.js";
import type { CliResult } from "./cli/types.js";
import type { CliResult, CliRunOptions } from "./cli/types.js";
export const HOSE_CLI_TOOL_NAME = "hose_cli";
export const HOSE_MCP_MODE_ENV = "HOSE_MCP_MODE";
@@ -118,7 +118,7 @@ export function cliResult(result: CliResult): {
};
}
export function createServer(options: { mode?: string; enabled?: boolean } = {}) {
export function createServer(options: { mode?: string; enabled?: boolean; runtime?: CliRunOptions } = {}) {
const enabled = options.enabled ?? resolveMcpEnabled();
const server = new Server(
@@ -203,6 +203,9 @@ export function createServer(options: { mode?: string; enabled?: boolean } = {})
const result = await runCli(cliArgs, {
appRoot,
entryFile: serverEntryFile,
...options.runtime,
// MCP output belongs to the protocol transport, never a terminal stream.
writeStdout: undefined,
});
return cliResult(result);
} catch (error) {
@@ -217,8 +220,8 @@ export function createServer(options: { mode?: string; enabled?: boolean } = {})
return server;
}
export async function startServer() {
const server = createServer();
export async function startServer(runtime?: CliRunOptions) {
const server = createServer({ runtime });
const transport = new StdioServerTransport();
await server.connect(transport);
console.error(`hose-use MCP Server (v${VERSION}) running on stdio [mode: ${resolveMcpMode()}]`);