import { tool } from "../tool.js"; import { getInternalBridgeConfig } from "../internalBridge.js"; export default tool({ description: "维护已验证、可复用、非敏感的通用执行方法。事件业务处置 Skill 由 Server 经任务 MCP 分发,不在此复制或覆盖。支持 list、write_skill、remove_skill、append_pattern、remove_pattern、write_reference、remove_reference、write_script、remove_script。", args: { action: tool.schema .enum([ "list", "write_skill", "remove_skill", "append_pattern", "remove_pattern", "write_reference", "remove_reference", "write_script", "remove_script", ]) .describe("Skill maintenance operation."), reason: tool.schema .string() .describe( "Why this skill maintenance action is justified for future reuse.", ), skill_path: tool.schema .string() .describe( "Target skill directory path relative to .opencode/skills. Use 'workflow' for the workflow index, or '__root__' for the root skills index.", ), pattern: tool.schema .string() .optional() .describe("Pattern text used by append_pattern."), target_id: tool.schema .string() .optional() .describe("Stable learned pattern id used by remove_pattern."), file_path: tool.schema .string() .optional() .describe( "Asset file path. For references use references/*.md; for scripts use scripts/*.py.", ), content: tool.schema .string() .optional() .describe( "Content used by write_skill, write_reference, or write_script.", ), }, async execute(args, context) { const { baseUrl, internalToken } = getInternalBridgeConfig(); const response = await fetch(`${baseUrl}/internal/tools/skill-manager`, { method: "POST", headers: { "Content-Type": "application/json", "x-agent-internal-token": internalToken }, body: JSON.stringify({ session_id: context.sessionID, input: args }), }); const text = await response.text(); if (!response.ok) throw new Error(`learning tool failed (${response.status}): ${text}`); return text; }, });