feat: 测试版标出 Skill 官方调用方式(/名称与模型 skill 工具)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-09-21 13:30:58 +08:00
1 parent 877c41f7d7
commit 5629c35e22
4 files changed
+65 -6

No files matched your search

+10 -1
View File
@@ -518,7 +518,8 @@ function renderSkillsStatus(st) {
const out = [];
out.push("官方用户 Skill / $DSH_HOME/skills");
out.push(` ${st.skills_dir}`);
out.push(" 命中与加载由官方 skill 工具负责;插件只安装和删除目录。");
out.push(" 插件只安装目录。调用走官方:任务对上 description/whenToUse 时模型调 skill 工具;聊天输入 /名称 立即加载。");
out.push(" 正文里写「激活」不会触发。官方认 name、description、whenToUse、disable-model-invocation、user-invocable。");
out.push("");
if (!st.skills.length) {
out.push(" (暂无用户 Skill — 用 /skills import <压缩包或文件夹> 或设置页导入)");
@@ -527,7 +528,14 @@ function renderSkillsStatus(st) {
for (const item of st.skills) {
const mark = item.valid ? "·" : "!";
const desc = item.description || "(无说明)";
const how = item.valid
? [
item.userInvocable ? `/${item.id}` : "不可 /名称",
item.modelInvocable ? "模型可调" : "模型不可调",
].join(" · ")
: "";
out.push(` ${mark} ${item.id} ${desc} (${skills.formatSize(item.size)})`);
if (how) out.push(` ${how}`);
if (!item.valid && item.error) out.push(` ${item.error}`);
}
return out.join("\n");
@@ -600,6 +608,7 @@ async function handleSkillsCommand(rawInput) {
" /skills import <路径> 导入压缩包或文件夹到官方目录\n" +
" /skills delete <id> 删除该目录(官方会从目录拿掉)\n" +
" 也可自己删 $DSH_HOME/skills/<id>\n" +
" 调用:聊天输入 /<id>,或让模型按 description 调 skill 工具\n" +
" 不注入 systemPrompt,不替代提示词",
};
}
+33 -1
View File
@@ -106,6 +106,22 @@ function yamlLineField(head, key) {
return value;
}
function yamlBoolField(head, key) {
const re = new RegExp(`^${key}:\\s*(.*)$`, "m");
const match = String(head || "").match(re);
if (!match) return { present: false };
let value = match[1].trim();
if ((value.startsWith("\"") && value.endsWith("\"")) || (value.startsWith("'") && value.endsWith("'"))) {
value = value.slice(1, -1).trim();
}
const comment = value.indexOf(" #");
if (comment >= 0) value = value.slice(0, comment).trim();
const norm = value.toLowerCase();
if (["true", "yes", "on", "1"].includes(norm)) return { present: true, value: true };
if (["false", "no", "off", "0"].includes(norm)) return { present: true, value: false };
return { present: true, invalid: true };
}
export function parseSkillDocument(raw) {
const parts = splitFrontmatter(raw);
if (!parts) return { ok: false, error: "缺少 YAML frontmatter(须以 --- 包围)" };
@@ -113,7 +129,20 @@ export function parseSkillDocument(raw) {
const description = yamlLineField(parts.head, "description");
if (!validSkillName(name)) return { ok: false, error: "frontmatter.name 必须是 kebab-case,例如 code-review" };
if (!description) return { ok: false, error: "frontmatter.description 必填(单行)" };
return { ok: true, name, description, body: parts.body, head: parts.head };
const disableModel = yamlBoolField(parts.head, "disable-model-invocation");
const userInvocable = yamlBoolField(parts.head, "user-invocable");
if (disableModel.invalid) return { ok: false, error: "disable-model-invocation 必须是布尔值(true/false)" };
if (userInvocable.invalid) return { ok: false, error: "user-invocable 必须是布尔值(true/false)" };
return {
ok: true,
name,
description,
whenToUse: yamlLineField(parts.head, "whenToUse"),
modelInvocable: disableModel.value !== true,
userInvocable: userInvocable.value !== false,
body: parts.body,
head: parts.head,
};
}
export function renderSkillDocument(id, description, body = "") {
@@ -174,6 +203,9 @@ async function skillFromFile(id, fp, kind) {
path: fp,
content,
description: parsed.ok ? parsed.description : "",
whenToUse: parsed.ok ? parsed.whenToUse : "",
modelInvocable: parsed.ok ? parsed.modelInvocable : false,
userInvocable: parsed.ok ? parsed.userInvocable : false,
valid: parsed.ok,
error: parsed.ok ? null : parsed.error,
size: Buffer.byteLength(content, "utf8"),