mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 12:50:23 +08:00
feat: 测试版标出 Skill 官方调用方式(/名称与模型 skill 工具)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
9374ca92d4
commit
e4f486b034
4 files changed
+65
-6
No files matched your search
@@ -1,3 +1,7 @@
|
|||||||
|
# 外部参考仓库,禁止提交
|
||||||
|
choirboy-prompt/
|
||||||
|
/choirboy-prompt/
|
||||||
|
|
||||||
node_modules/
|
node_modules/
|
||||||
*.tgz
|
*.tgz
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
|
|||||||
@@ -238,8 +238,8 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
|||||||
"ph.content": "",
|
"ph.content": "",
|
||||||
"btn.saveRule": "保存",
|
"btn.saveRule": "保存",
|
||||||
"skills.title": "Skill",
|
"skills.title": "Skill",
|
||||||
"skills.hint": "官方 Skill 目录。可导入压缩包或文件夹。命中和加载由 DSH 负责。",
|
"skills.hint": "导入到官方目录后,由 DSH 调用:聊天输入 /名称 立即加载;任务对上 description 或 whenToUse 时模型会调 skill 工具。正文写「激活」不会触发。",
|
||||||
"skills.hint.desktop": "当前桌面宿主的官方 Skill 目录。可导入压缩包或文件夹。命中和加载由 DSH 负责。",
|
"skills.hint.desktop": "当前桌面宿主的官方 Skill 目录。聊天输入 /名称 立即加载;任务对上 description 时模型会调 skill 工具。",
|
||||||
"skills.empty": "暂无用户 Skill",
|
"skills.empty": "暂无用户 Skill",
|
||||||
"btn.importZip": "导入压缩包",
|
"btn.importZip": "导入压缩包",
|
||||||
"btn.importFolder": "导入文件夹",
|
"btn.importFolder": "导入文件夹",
|
||||||
@@ -249,6 +249,10 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
|||||||
"err.import.folder": "没读到文件夹里的文件,请直接选 Skill 目录(里面要有 SKILL.md)",
|
"err.import.folder": "没读到文件夹里的文件,请直接选 Skill 目录(里面要有 SKILL.md)",
|
||||||
"skills.pick": "选择 Skill",
|
"skills.pick": "选择 Skill",
|
||||||
"skills.invalid": "官方会忽略:格式不对",
|
"skills.invalid": "官方会忽略:格式不对",
|
||||||
|
"skills.call.slash": "聊天输入 {cmd}",
|
||||||
|
"skills.call.model": "模型可调",
|
||||||
|
"skills.call.modelOff": "模型不可调",
|
||||||
|
"skills.call.userOff": "不可 /名称",
|
||||||
"ph.skill.desc": "description(何时用)",
|
"ph.skill.desc": "description(何时用)",
|
||||||
"btn.saveSkill": "保存",
|
"btn.saveSkill": "保存",
|
||||||
"need.skill.id": "id 必须是 kebab-case,例如 code-review",
|
"need.skill.id": "id 必须是 kebab-case,例如 code-review",
|
||||||
@@ -444,8 +448,8 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
|||||||
"ph.content": "",
|
"ph.content": "",
|
||||||
"btn.saveRule": "Save",
|
"btn.saveRule": "Save",
|
||||||
"skills.title": "Skills",
|
"skills.title": "Skills",
|
||||||
"skills.hint": "Official skill catalog. Import a zip or folder. DSH owns match and load.",
|
"skills.hint": "After import, DSH calls it: type /name in chat to load now; the model calls the skill tool when the task matches description or whenToUse. Writing「激活」in the body does nothing.",
|
||||||
"skills.hint.desktop": "This desktop host’s official skill catalog. Import a zip or folder. DSH owns match and load.",
|
"skills.hint.desktop": "This desktop host’s official skill catalog. Type /name in chat to load; the model calls the skill tool when the task matches the description.",
|
||||||
"skills.empty": "No user skills",
|
"skills.empty": "No user skills",
|
||||||
"btn.importZip": "Import zip",
|
"btn.importZip": "Import zip",
|
||||||
"btn.importFolder": "Import folder",
|
"btn.importFolder": "Import folder",
|
||||||
@@ -455,6 +459,10 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
|||||||
"err.import.folder": "No files were read. Select the skill folder itself (it must contain SKILL.md).",
|
"err.import.folder": "No files were read. Select the skill folder itself (it must contain SKILL.md).",
|
||||||
"skills.pick": "Select a skill",
|
"skills.pick": "Select a skill",
|
||||||
"skills.invalid": "Official catalog will ignore this: invalid format",
|
"skills.invalid": "Official catalog will ignore this: invalid format",
|
||||||
|
"skills.call.slash": "Type {cmd} in chat",
|
||||||
|
"skills.call.model": "Model can load",
|
||||||
|
"skills.call.modelOff": "Hidden from model",
|
||||||
|
"skills.call.userOff": "/name disabled",
|
||||||
"ph.skill.desc": "description (when to use)",
|
"ph.skill.desc": "description (when to use)",
|
||||||
"btn.saveSkill": "Save",
|
"btn.saveSkill": "Save",
|
||||||
"need.skill.id": "id must be kebab-case, e.g. code-review",
|
"need.skill.id": "id must be kebab-case, e.g. code-review",
|
||||||
@@ -1807,6 +1815,12 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
|||||||
h("span", { className: "dshp-rule-meta" },
|
h("span", { className: "dshp-rule-meta" },
|
||||||
(item.valid ? item.description : t("skills.invalid")) + " · " + formatSize(item.size),
|
(item.valid ? item.description : t("skills.invalid")) + " · " + formatSize(item.size),
|
||||||
),
|
),
|
||||||
|
item.valid ? h("span", { className: "dshp-rule-meta" },
|
||||||
|
[
|
||||||
|
item.userInvocable ? t("skills.call.slash", { cmd: "/" + item.id }) : t("skills.call.userOff"),
|
||||||
|
item.modelInvocable ? t("skills.call.model") : t("skills.call.modelOff"),
|
||||||
|
].join(" · "),
|
||||||
|
) : null,
|
||||||
),
|
),
|
||||||
h("div", { className: "dshp-rule-ops" },
|
h("div", { className: "dshp-rule-ops" },
|
||||||
h(Btn, {
|
h(Btn, {
|
||||||
|
|||||||
+10
-1
@@ -518,7 +518,8 @@ function renderSkillsStatus(st) {
|
|||||||
const out = [];
|
const out = [];
|
||||||
out.push("官方用户 Skill / $DSH_HOME/skills");
|
out.push("官方用户 Skill / $DSH_HOME/skills");
|
||||||
out.push(` ${st.skills_dir}`);
|
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("");
|
out.push("");
|
||||||
if (!st.skills.length) {
|
if (!st.skills.length) {
|
||||||
out.push(" (暂无用户 Skill — 用 /skills import <压缩包或文件夹> 或设置页导入)");
|
out.push(" (暂无用户 Skill — 用 /skills import <压缩包或文件夹> 或设置页导入)");
|
||||||
@@ -527,7 +528,14 @@ function renderSkillsStatus(st) {
|
|||||||
for (const item of st.skills) {
|
for (const item of st.skills) {
|
||||||
const mark = item.valid ? "·" : "!";
|
const mark = item.valid ? "·" : "!";
|
||||||
const desc = item.description || "(无说明)";
|
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)})`);
|
out.push(` ${mark} ${item.id} ${desc} (${skills.formatSize(item.size)})`);
|
||||||
|
if (how) out.push(` ${how}`);
|
||||||
if (!item.valid && item.error) out.push(` ${item.error}`);
|
if (!item.valid && item.error) out.push(` ${item.error}`);
|
||||||
}
|
}
|
||||||
return out.join("\n");
|
return out.join("\n");
|
||||||
@@ -600,6 +608,7 @@ async function handleSkillsCommand(rawInput) {
|
|||||||
" /skills import <路径> 导入压缩包或文件夹到官方目录\n" +
|
" /skills import <路径> 导入压缩包或文件夹到官方目录\n" +
|
||||||
" /skills delete <id> 删除该目录(官方会从目录拿掉)\n" +
|
" /skills delete <id> 删除该目录(官方会从目录拿掉)\n" +
|
||||||
" 也可自己删 $DSH_HOME/skills/<id>\n" +
|
" 也可自己删 $DSH_HOME/skills/<id>\n" +
|
||||||
|
" 调用:聊天输入 /<id>,或让模型按 description 调 skill 工具\n" +
|
||||||
" 不注入 systemPrompt,不替代提示词",
|
" 不注入 systemPrompt,不替代提示词",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+33
-1
@@ -106,6 +106,22 @@ function yamlLineField(head, key) {
|
|||||||
return value;
|
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) {
|
export function parseSkillDocument(raw) {
|
||||||
const parts = splitFrontmatter(raw);
|
const parts = splitFrontmatter(raw);
|
||||||
if (!parts) return { ok: false, error: "缺少 YAML frontmatter(须以 --- 包围)" };
|
if (!parts) return { ok: false, error: "缺少 YAML frontmatter(须以 --- 包围)" };
|
||||||
@@ -113,7 +129,20 @@ export function parseSkillDocument(raw) {
|
|||||||
const description = yamlLineField(parts.head, "description");
|
const description = yamlLineField(parts.head, "description");
|
||||||
if (!validSkillName(name)) return { ok: false, error: "frontmatter.name 必须是 kebab-case,例如 code-review" };
|
if (!validSkillName(name)) return { ok: false, error: "frontmatter.name 必须是 kebab-case,例如 code-review" };
|
||||||
if (!description) return { ok: false, error: "frontmatter.description 必填(单行)" };
|
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 = "") {
|
export function renderSkillDocument(id, description, body = "") {
|
||||||
@@ -174,6 +203,9 @@ async function skillFromFile(id, fp, kind) {
|
|||||||
path: fp,
|
path: fp,
|
||||||
content,
|
content,
|
||||||
description: parsed.ok ? parsed.description : "",
|
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,
|
valid: parsed.ok,
|
||||||
error: parsed.ok ? null : parsed.error,
|
error: parsed.ok ? null : parsed.error,
|
||||||
size: Buffer.byteLength(content, "utf8"),
|
size: Buffer.byteLength(content, "utf8"),
|
||||||
|
|||||||
Reference in new issue
Block a user