dsh-plugin-labels 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +8 -8
  2. package/lib/index.js +18 -13
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  给 DSH(DeepSeek Harness)**已安装插件**配「中文名 + 一句话说明」:官方「插件」页的已安装插件行、插件包卡片与详情页都会**原地显示中文名与中文描述**(由 host 覆盖显示元数据);新装插件会在启动后自动翻译。同时给 **skills(技能)** 补中文说明:`/` 技能菜单里每条技能显示「英文原描述 |中文:<作用>;用法:<怎么用>」。**本插件没有任何 UI 入口**(没有 tab、没有设置项),管理通过 loopback HTTP API 或让 AI 代改。
9
9
 
10
- - 当前版本:**0.9.0**(本仓库即源码目录;通过 `plugin_manager install_bundle` 从 GitHub 或 npm 安装到 DSH profile)
10
+ - 当前版本:**0.9.2**(本仓库即源码目录;通过 `plugin_manager install_bundle` 从 GitHub 或 npm 安装到 DSH profile)
11
11
  - 只支持 DSH 桌面版 Web GUI(开发验证版本 0.2.1-rc.2 / rc.3)
12
12
 
13
13
  ## 功能
@@ -58,17 +58,17 @@ host 启动约 **4 秒**后会自动补一次缺失标签:
58
58
 
59
59
  ## 技能中文翻译
60
60
 
61
- 用户的技能大多是英文。本插件会在技能目录的描述末尾追加中文说明,**`/` 技能菜单里每条技能显示**:
61
+ 用户的技能大多是英文。本插件会在技能目录的描述**前面**加中文说明(`/` 技能菜单会截断长描述,所以中文必须在前),**`/` 技能菜单里每条技能显示**:
62
62
 
63
63
  ```
64
- <英文原描述> |中文:<中文作用>;用法:<怎么用>
64
+ 中文:<中文作用>;用法:<怎么用> | <英文原描述>
65
65
  ```
66
66
 
67
- - **实现**:host 包装 `skills` 服务的 `snapshot`/`list`,命中缓存才追加,未命中保持原样(`/` 菜单走 `skills.list`,模型侧技能目录走同一份 description)。
68
- - **缓存**:`<DSH_HOME>/plugin-labels-skills.json`(独立于插件标签缓存,`version: 1`,UTF-8 无 BOM、原子写);每条 `{zh ≤80 字, usage ≤60 字, source: "ai" | "manual", at}`。
67
+ - **实现**:host 包装 `skills` 服务的 `snapshot`/`list`,命中缓存才加前缀,未命中保持原样(`/` 菜单走 `skills.list`,模型侧技能目录走同一份 description)。
68
+ - **缓存**:`<DSH_HOME>/plugin-labels-skills.json`(独立于插件标签缓存,`version: 1`,UTF-8 无 BOM、原子写);每条 `{zh ≤22 字, usage ≤18 字, source: "ai" | "manual", at}`。菜单只显示一行并截断,所以中文必须短。
69
69
  - **API**(见「使用」):`GET /api/plugin-labels/skills`、`POST /api/plugin-labels/skills/translate`、`POST /api/plugin-labels/skills/label`。
70
70
  - **自动翻译**:启动后约 4 秒的自动任务在补完插件标签后,会再补最多 **10** 条技能说明(`MAX_SKILLS_PER_AUTO`);只补空缺、不覆盖手改;`DSH_PLUGIN_LABELS_AUTO_TRANSLATE=0` 同时关闭插件与技能自动翻译。
71
- - **限制**:只翻译/解释技能的目录描述,**技能正文仍是英文**;模型侧技能目录会把 description 截断到 500 字,追加在末尾的中文通常不会明显增加模型上下文;技能服务(`ctx.get("skills")`)不可用时静默跳过,不影响其它功能。
71
+ - **限制**:只翻译/解释技能的目录描述,**技能正文仍是英文**;模型侧技能目录会把 description 截断到 500 字,中文在前意味着模型看到的是中文说明,英文原文可能被截断;技能服务(`ctx.get("skills")`)不可用时静默跳过,不影响其它功能。
72
72
  - **重启**:host 代码在启动时安装,**需要重启 DSH 一次**;`GET /api/plugin-labels/list` 的 `officialMeta.skills` 可确认包装是否已生效。
73
73
 
74
74
  ## 安装
@@ -76,7 +76,7 @@ host 启动约 **4 秒**后会自动补一次缺失标签:
76
76
  ### 方式一:npm 包(推荐,`npm publish` 后)
77
77
 
78
78
  在 DSH 插件页 → 添加插件 → 填包名 `dsh-plugin-labels`;或在创造模式会话里 `plugin_manager` → `install_bundle` → `target: "dsh-plugin-labels"`。发布后 profile 依赖形如
79
- `"dsh-plugin-labels": "dsh-plugin-labels@^0.9.0"`。
79
+ `"dsh-plugin-labels": "dsh-plugin-labels@^0.9.2"`。
80
80
 
81
81
  ### 方式二:从 Git 仓库安装
82
82
 
@@ -92,7 +92,7 @@ host 启动约 **4 秒**后会自动补一次缺失标签:
92
92
 
93
93
  ## 使用
94
94
 
95
- v0.9.0 起没有 UI 入口,全部通过 7 个 loopback HTTP API 操作(也可以让 AI/脚本代改):
95
+ v0.9.2 起没有 UI 入口,全部通过 7 个 loopback HTTP API 操作(也可以让 AI/脚本代改):
96
96
 
97
97
  ```powershell
98
98
  # 查看已装插件 + 标签 + 诊断字段(officialMeta)
package/lib/index.js CHANGED
@@ -23,13 +23,13 @@
23
23
  * and a concrete first step when useful. The model is told never to invent
24
24
  * menus: when the entry point cannot be inferred it must write 入口以界面为准.
25
25
  *
26
- * Skill translations (v0.9.0): every skill summary gets a Chinese purpose and a
27
- * short usage hint appended to its `description`, so the `/` skill menu shows
28
- * "English original |中文:…;用法:…". They live in their own cache
26
+ * Skill translations (v0.9.1): every skill summary gets a Chinese purpose and a
27
+ * short usage hint prefixed onto its `description`, so the `/` skill menu shows
28
+ * "中文:…;用法:… |English original". They live in their own cache
29
29
  * <DSH_HOME>/plugin-labels-skills.json. Optional `whenToUse` is sent to the
30
30
  * model, the skill body itself is not translated, and the model-side skill
31
- * catalogue truncates descriptions at 500 characters (the appended Chinese
32
- * usually falls past that point, so model context barely grows).
31
+ * catalogue truncates descriptions at 500 characters (the prefixed Chinese is
32
+ * what the model sees; the English tail may be cut, which is intended).
33
33
  *
34
34
  * Display overrides (all failure-safe; marker-detected because Cordis hands out
35
35
  * traceable Proxies whose method references differ on every read):
@@ -75,8 +75,8 @@ const MAX_BODY_BYTES = 65536;
75
75
  const TRANSLATE_TIMEOUT_MS = 120000;
76
76
 
77
77
  const SKILL_CACHE_VERSION = 1;
78
- const MAX_SKILL_ZH = 80;
79
- const MAX_SKILL_USAGE = 60;
78
+ const MAX_SKILL_ZH = 22;
79
+ const MAX_SKILL_USAGE = 18;
80
80
  const MAX_SKILL_DESCRIPTION = 600;
81
81
  const MAX_SKILLS_PER_AUTO = 10;
82
82
 
@@ -96,8 +96,8 @@ const SYSTEM_PROMPT = [
96
96
  const SKILL_SYSTEM_PROMPT = [
97
97
  "You translate DeepSeek Harness (DSH) skill descriptions for a Chinese-speaking user who cannot read English.",
98
98
  "For every skill you receive, produce:",
99
- "1. zh: a Chinese name plus one-line purpose, at most 80 Chinese characters, concrete (no marketing words, no literal package-name translation).",
100
- "2. usage: how and when to use it, at most 60 Chinese characters — for example 对 AI 说\"用 X 技能\" or 输入 /<name>,when the description implies an invocation. Never invent a command that the description does not imply.",
99
+ "1. zh: a short Chinese name plus purpose, at most 22 Chinese characters (prefer 10-16). The skill menu shows only one truncated line, so brevity matters.",
100
+ "2. usage: how and when to use it, at most 18 Chinese characters (prefer 8-14), for example 对 AI 说\"用 X\" or 输入 /<name>. Never invent a command that the description does not imply.",
101
101
  "Answer with strict JSON only, no prose, no markdown fences:",
102
102
  '{"items":[{"name":"<exact skill name>","zh":"...","usage":"..."}]}',
103
103
  ].join("\n");
@@ -898,13 +898,15 @@ export async function translateSkillsPending(ctx, home, limit = MAX_PENDING_PER_
898
898
  }
899
899
  }
900
900
 
901
- /** Append the Chinese purpose/usage to an English skill description. */
901
+ /** Prefix the Chinese purpose/usage so the truncated menu always shows it first. */
902
902
  export function skillDescriptionWithChinese(original, entry) {
903
903
  if (typeof original !== "string" || !entry || typeof entry !== "object") return original;
904
904
  const zh = typeof entry.zh === "string" ? entry.zh.trim() : "";
905
905
  if (zh === "") return original;
906
906
  const usage = typeof entry.usage === "string" ? entry.usage.trim() : "";
907
- return original + " |中文:" + zh + (usage === "" ? "" : ";用法:" + usage);
907
+ const prefix = "中文:" + zh + (usage === "" ? "" : ";用法:" + usage);
908
+ if (original.startsWith(prefix)) return original;
909
+ return prefix + " |" + original;
908
910
  }
909
911
 
910
912
  /** Recover the original English description from an already-injected one. */
@@ -914,8 +916,11 @@ function originalSkillDescription(description, entry) {
914
916
  const zh = typeof entry.zh === "string" ? entry.zh.trim() : "";
915
917
  if (zh === "") return description;
916
918
  const usage = typeof entry.usage === "string" ? entry.usage.trim() : "";
917
- const suffix = " |中文:" + zh + (usage === "" ? "" : ";用法:" + usage);
918
- return description.endsWith(suffix) ? description.slice(0, -suffix.length) : description;
919
+ const prefix = "中文:" + zh + (usage === "" ? "" : ";用法:" + usage);
920
+ if (description.startsWith(prefix + " |")) return description.slice(prefix.length + 3);
921
+ if (description.startsWith(prefix)) return description.slice(prefix.length).replace(/^ |/, "");
922
+ const oldSuffix = " |中文:" + zh + (usage === "" ? "" : ";用法:" + usage);
923
+ return description.endsWith(oldSuffix) ? description.slice(0, -oldSuffix.length) : description;
919
924
  }
920
925
 
921
926
  /** Return a shallow copy of one skill summary with the Chinese suffix applied. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-labels",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Chinese names and one-line explanations for installed DSH plugins; automatic translation and in-place display on the official Plugins page.",