feat: release v0.5.1 with multi-file skill system and IDE plugin manifest
🚀 Release / 🚀 Build & Publish Multi-Platform Binaries (push) Has been cancelled
🚀 Release / 🚀 Build & Publish Multi-Platform Binaries (push) Has been cancelled
This commit is contained in:
1 parent
c1dc9f1616
commit
188a0fb5dc
22 files changed
+3912
-187
No files matched your search
+21
-2
@@ -22,11 +22,19 @@ import type { CliResult } from "./cli/types.js";
|
||||
|
||||
export const HOSE_CLI_TOOL_NAME = "hose_cli";
|
||||
export const HOSE_MCP_MODE_ENV = "HOSE_MCP_MODE"; // "single" | "all" | "legacy"
|
||||
export const HOSE_MCP_ENABLED_ENV = "HOSE_USE_MCP_ENABLED";
|
||||
|
||||
export type HoseMcpMode = "single" | "all" | "legacy";
|
||||
|
||||
const serverEntryFile = fileURLToPath(import.meta.url);
|
||||
const appRoot = dirname(dirname(serverEntryFile));
|
||||
const appRoot = serverEntryFile.includes("/dist/mcp/") || serverEntryFile.includes("\\dist\\mcp\\")
|
||||
? dirname(dirname(dirname(serverEntryFile)))
|
||||
: dirname(dirname(serverEntryFile));
|
||||
|
||||
export function resolveMcpEnabled(value = process.env[HOSE_MCP_ENABLED_ENV]): boolean {
|
||||
if (value === undefined) return true;
|
||||
return ["1", "true", "yes", "on"].includes(value.trim().toLowerCase());
|
||||
}
|
||||
|
||||
export function resolveMcpMode(value = process.env[HOSE_MCP_MODE_ENV]): HoseMcpMode {
|
||||
if (!value) return "single";
|
||||
@@ -165,7 +173,8 @@ function formatError(error: unknown): {
|
||||
};
|
||||
}
|
||||
|
||||
export function createServer(options: { mode?: HoseMcpMode } = {}) {
|
||||
export function createServer(options: { mode?: HoseMcpMode; enabled?: boolean } = {}) {
|
||||
const enabled = options.enabled ?? resolveMcpEnabled();
|
||||
const mode = options.mode ?? resolveMcpMode();
|
||||
|
||||
const server = new Server(
|
||||
@@ -184,6 +193,9 @@ export function createServer(options: { mode?: HoseMcpMode } = {}) {
|
||||
|
||||
// 注册工具列表
|
||||
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||
if (!enabled) {
|
||||
return { tools: [] };
|
||||
}
|
||||
const tools: Array<{ name: string; description?: string; inputSchema: any }> = [];
|
||||
|
||||
// 单工具网关
|
||||
@@ -223,6 +235,13 @@ export function createServer(options: { mode?: HoseMcpMode } = {}) {
|
||||
|
||||
// 处理工具调用
|
||||
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
if (!enabled) {
|
||||
return cliResult({
|
||||
stdout: "",
|
||||
stderr: "hose-use MCP 服务在插件配置中已被禁用 (HOSE_USE_MCP_ENABLED=false)",
|
||||
exitCode: 1,
|
||||
});
|
||||
}
|
||||
const { name, arguments: args } = request.params;
|
||||
|
||||
// 1. 处理 hose_cli 网关工具调用
|
||||
|
||||
Reference in new issue
Block a user