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
@@ -0,0 +1,45 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { mkdtempSync, rmSync, existsSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { EMBEDDED_SKILL_FILES, getSkillContent, installSkillFiles } from "./embedded-skill.js";
|
||||
|
||||
describe("embedded-skill - 多文件内嵌 Skill 体系", () => {
|
||||
test("正确内嵌 SKILL.md、agents/openai.yaml 及各领域参考专卷", () => {
|
||||
expect(EMBEDDED_SKILL_FILES["SKILL.md"]).toBeDefined();
|
||||
expect(EMBEDDED_SKILL_FILES["SKILL.md"]).toContain("name: hose-use");
|
||||
expect(getSkillContent()).toContain("name: hose-use");
|
||||
|
||||
expect(EMBEDDED_SKILL_FILES["agents/openai.yaml"]).toBeDefined();
|
||||
expect(EMBEDDED_SKILL_FILES["agents/openai.yaml"]).toContain("hose_cli");
|
||||
|
||||
expect(EMBEDDED_SKILL_FILES["references/auth.md"]).toBeDefined();
|
||||
expect(EMBEDDED_SKILL_FILES["references/auth.md"]).toContain("RSA");
|
||||
|
||||
expect(EMBEDDED_SKILL_FILES["references/bill.md"]).toBeDefined();
|
||||
expect(EMBEDDED_SKILL_FILES["references/bill.md"]).toContain("bill get");
|
||||
|
||||
expect(EMBEDDED_SKILL_FILES["references/workflow.md"]).toBeDefined();
|
||||
expect(EMBEDDED_SKILL_FILES["references/workflow.md"]).toContain("workflow find");
|
||||
|
||||
expect(EMBEDDED_SKILL_FILES["references/service.md"]).toBeDefined();
|
||||
expect(EMBEDDED_SKILL_FILES["references/service.md"]).toContain("POST /api/cli");
|
||||
});
|
||||
|
||||
test("installSkillFiles 递归保留层级结构并落盘到目标目录", () => {
|
||||
const tmp = mkdtempSync(join(tmpdir(), "hose-skill-test-"));
|
||||
try {
|
||||
const res = installSkillFiles(tmp);
|
||||
expect(res.targetDir).toBe(tmp);
|
||||
expect(res.files.length).toBe(6);
|
||||
expect(existsSync(join(tmp, "SKILL.md"))).toBe(true);
|
||||
expect(existsSync(join(tmp, "agents", "openai.yaml"))).toBe(true);
|
||||
expect(existsSync(join(tmp, "references", "auth.md"))).toBe(true);
|
||||
expect(existsSync(join(tmp, "references", "bill.md"))).toBe(true);
|
||||
expect(existsSync(join(tmp, "references", "workflow.md"))).toBe(true);
|
||||
expect(existsSync(join(tmp, "references", "service.md"))).toBe(true);
|
||||
} finally {
|
||||
rmSync(tmp, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,10 +1,21 @@
|
||||
import { existsSync, mkdirSync, writeFileSync, readFileSync } from "node:fs";
|
||||
import { mkdirSync, writeFileSync } from "node:fs";
|
||||
import { homedir } from "node:os";
|
||||
import { dirname, join } from "node:path";
|
||||
|
||||
import skillMain from "../../skills/hose-use/SKILL.md" with { type: "text" };
|
||||
import agentOpenAi from "../../skills/hose-use/agents/openai.yaml" with { type: "text" };
|
||||
import refAuth from "../../skills/hose-use/references/auth.md" with { type: "text" };
|
||||
import refBill from "../../skills/hose-use/references/bill.md" with { type: "text" };
|
||||
import refWorkflow from "../../skills/hose-use/references/workflow.md" with { type: "text" };
|
||||
import refService from "../../skills/hose-use/references/service.md" with { type: "text" };
|
||||
|
||||
export const EMBEDDED_SKILL_FILES: Record<string, string> = {
|
||||
"SKILL.md": skillMain,
|
||||
"agents/openai.yaml": agentOpenAi,
|
||||
"references/auth.md": refAuth,
|
||||
"references/bill.md": refBill,
|
||||
"references/workflow.md": refWorkflow,
|
||||
"references/service.md": refService,
|
||||
};
|
||||
|
||||
export function getSkillContent(): string {
|
||||
|
||||
@@ -153,4 +153,30 @@ describe("hose-use MCP server & hose_cli single-gate pattern", () => {
|
||||
await Promise.allSettled([client.close(), server.close()]);
|
||||
}
|
||||
});
|
||||
|
||||
test("returns empty tools when MCP is disabled via configuration", async () => {
|
||||
const server = createServer({ enabled: false });
|
||||
const client = new Client({ name: "hose-use-test-disabled", version: "1.0.0" });
|
||||
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
||||
|
||||
try {
|
||||
await Promise.all([
|
||||
server.connect(serverTransport),
|
||||
client.connect(clientTransport),
|
||||
]);
|
||||
|
||||
const listed = await client.listTools();
|
||||
expect(listed.tools).toEqual([]);
|
||||
|
||||
const callResult = await client.callTool({
|
||||
name: HOSE_CLI_TOOL_NAME,
|
||||
arguments: { command: "version" },
|
||||
});
|
||||
expect(callResult.isError).toBe(true);
|
||||
const content = callResult.content as Array<{ type: "text"; text: string }>;
|
||||
expect(content[0]?.text).toContain("HOSE_USE_MCP_ENABLED=false");
|
||||
} finally {
|
||||
await Promise.allSettled([client.close(), server.close()]);
|
||||
}
|
||||
});
|
||||
});
|
||||
+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 网关工具调用
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
export const VERSION = "0.5.0";
|
||||
export const VERSION = "0.5.1";
|
||||
Reference in new issue
Block a user