From 492ef9db8261427048f4117683e5f1dce6ae8215 Mon Sep 17 00:00:00 2001 From: QQ Date: Wed, 11 Nov 2026 10:51:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20lib/tools.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tools.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/tools.js b/lib/tools.js index 7b05e4c..2895ee3 100644 --- a/lib/tools.js +++ b/lib/tools.js @@ -254,3 +254,33 @@ function projectsTool(deps) { export function createMemoryTools(deps) { return [searchTool(deps), readTool(deps), addTool(deps), listTool(deps), projectsTool(deps)]; } +/** List the cloud skill center inventory (skills sync keeps local copies current). */ +function skillListTool(deps) { + return { + name: 'skill_list', + description: '列出云端技能中心的全部技能(名称、说明、版本)。技能会自动同步到本机技能目录,由 DSH 直接加载;此工具只用于查看云端有哪些技能。', + parameters: { type: 'object', properties: {}, additionalProperties: false }, + output: { + schema: { type: 'object', properties: { skills: { type: 'array', items: { type: 'object' } } }, required: ['skills'], additionalProperties: true }, + render: renderJson, + }, + async execute() { + requireMemoryToken(deps); + const result = await deps.client().listSkills(); + if (!result.ok) + throw new Error(`技能列表读取失败:${describeError(result.error)}`); + const skills = (result.data.items ?? []).map((item) => ({ + name: item.name, + description: item.description ?? '', + revision: item.revision ?? null, + files: item.files ?? null, + enabled: item.enabled ?? true, + })); + return { skills }; + }, + }; +} +/** Build the skill-facing tools for one plugin instance. */ +export function createSkillTools(deps) { + return [skillListTool(deps)]; +}