dsh-skill-tag 0.1.4 → 0.1.5

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.
package/README.md CHANGED
@@ -110,10 +110,13 @@ dsh plugin --profile <your-profile> add github:aawef/dsh-skill-manager-tags
110
110
 
111
111
  > 依赖 Node ≥ 20;需要 DSH `0.2.0-rc.1` 及以上(见 `engines.dsh`)。
112
112
  >
113
- > 宿主的 `@deepseek-ai/cordis` 与 `@deepseek-ai/dsh-storage-domain` 都声明为
114
- > **peerDependency**,由 DSH 本体提供,**不要自己安装**:本插件会 `import` 它的 `defineDomain`
115
- > 来注册存储域,必须与宿主使用同一份模块实例,装成 `dependencies` 会把旧版本提到 profile
116
- > 顶层、遮蔽宿主版本,导致 `workspaceController` 等服务无法上台(详见 CHANGELOG 2026-10-21)。
113
+ > 宿主的 `@deepseek-ai/cordis` 声明为 **peerDependency**,由 DSH 本体提供,**不要自己安装**。
114
+ >
115
+ > 存储域 spec 由本插件 `src/storage/domain-spec.js` 本地构造(等价于宿主的 `defineDomain` /
116
+ > `domainTable`),运行时通过 `ctx.storageDomain.open()` 交给宿主打开,**不 import 任何宿主内核包**。
117
+ > 这样 profile 里不会出现与宿主同名的第二份模块副本:早期版本曾 `import`
118
+ > `@deepseek-ai/dsh-storage-domain`,宿主升级(如 `0.2.1-rc.2` → `rc.3`)时那份旧副本会被判定
119
+ > 不兼容并拒绝加载,导致存储域整体不启动、会话与工作区列表全空(详见 CHANGELOG 2026-10-24)。
117
120
 
118
121
  ### 本地开发式安装
119
122
 
@@ -249,7 +252,7 @@ src/storage/ storage domain schema + repository
249
252
  src/reveal.js 拉起系统文件管理器
250
253
  skills/tagging-skills/ 随插件注册给宿主的一个 skill
251
254
  tools/auto-tag.mjs 一键打标签脚本(dry-run 默认)
252
- tests/ node:test,192 项
255
+ tests/ node:test,194 项
253
256
  docs/ 设计文档(见下)
254
257
  images/ README 用的界面截图(不进 npm 包)
255
258
  ```
@@ -271,7 +274,7 @@ images/ README 用的界面截图(不进 npm 包)
271
274
 
272
275
  ```bash
273
276
  npm install
274
- npm test # 192 项
277
+ npm test # 194 项
275
278
  ```
276
279
 
277
280
  测试分两类,都在 `tests/` 下:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-skill-tag",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "给 DSH 的技能(skill)打标签,用一条布尔表达式在「工作区 / 对话」两级选出要下发给模型的技能子集",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -52,14 +52,13 @@
52
52
  "test:unit": "node --test \"tests/*.test.mjs\""
53
53
  },
54
54
  "peerDependencies": {
55
- "@deepseek-ai/cordis": ">=4.0.2 <5",
56
- "@deepseek-ai/dsh-storage-domain": "0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || >=0.3.0 <1.0.0"
55
+ "@deepseek-ai/cordis": ">=4.0.2 <5"
57
56
  },
58
57
  "dependencies": {
59
58
  "zod": "^3.25.76"
60
59
  },
61
60
  "engines": {
62
61
  "node": ">=20",
63
- "dsh": "0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || >=0.2.1 <1.0.0"
62
+ "dsh": ">=0.2.0-rc.1 <1.0.0"
64
63
  }
65
64
  }
@@ -0,0 +1,73 @@
1
+ // skill-tag-plugin — 本地 domain spec 构造器
2
+ //
3
+ // 为什么不用 @deepseek-ai/dsh-storage-domain:
4
+ //
5
+ // 宿主已经通过 ctx.storageDomain.open(spec) 把 domain 能力注入进来了,插件真正
6
+ // 需要的只是把 spec 构造宿主认识的形状:
7
+ //
8
+ // { name, version, tables: { <tableName>: { valueSchema } }, global?, layout?, ... }
9
+ //
10
+ // 而宿主的 defineDomain 只做「校验 + 原样返回」,domainTable 只做
11
+ // `{ valueSchema: schema }`。为了这两个纯函数去 import 内核包,会让 pnpm 必须
12
+ // 在 profile 里再装一份 @deepseek-ai/dsh-storage-domain 实体,与宿主内置的同名
13
+ // 模块形成「同一模块两份不同版本」——宿主每次升级(rc.2 → rc.3)都会因为旧副本
14
+ // 被运行时判定不兼容而拒绝加载该插件,导致存储域整体不启动、会话与工作区列表
15
+ // 全空。该故障在 0.2.0-rc.2 时代已经发生过一次(见 profiles/desktop/
16
+ // pnpm-workspace.yaml 的 historical 注释),当时的做法是挪版本号 + 人工提醒,
17
+ // 属于在地基上缝补。
18
+ //
19
+ // 现在改为本地等价实现,插件对宿主内核包零 import 依赖:升级宿主不再需要同步
20
+ // 任何版本号,也不再有双份模块。
21
+ //
22
+ // 校验规则与宿主保持一致(宿主 @deepseek-ai/dsh-storage 的 UNIT_NAME_RE 为
23
+ // /^[a-z][a-z0-9_]*$/;domain 名与表名都必须匹配)。宿主在 open() 时仍会二次
24
+ // 校验,这里的校验只是让配置错误在模块加载时就暴露。
25
+
26
+ const UNIT_NAME_RE = /^[a-z][a-z0-9_]*$/;
27
+
28
+ /**
29
+ * 声明一张表:宿主只要求 { valueSchema } 这一层包装。
30
+ * @param {import("zod").ZodTypeAny} schema - 行记录的 zod schema
31
+ */
32
+ export function domainTable(schema) {
33
+ return { valueSchema: schema };
34
+ }
35
+
36
+ /**
37
+ * 声明一个 domain:校验后原样返回 spec(与宿主 defineDomain 行为一致)。
38
+ * @param {object} spec - { name, version, tables, global?, layout?, compatibleVersions?, invalidRecords? }
39
+ */
40
+ export function defineDomain(spec) {
41
+ if (!UNIT_NAME_RE.test(spec.name)) {
42
+ throw new Error(`domain name '${spec.name}' must match ${UNIT_NAME_RE}`);
43
+ }
44
+ if (!Number.isInteger(spec.version) || spec.version < 0) {
45
+ throw new Error(`domain '${spec.name}' version must be a non-negative integer, got ${spec.version}`);
46
+ }
47
+ for (const compat of spec.compatibleVersions ?? []) {
48
+ if (!Number.isInteger(compat) || compat < 0 || compat >= spec.version) {
49
+ throw new Error(
50
+ `domain '${spec.name}' compatibleVersions entries must be non-negative integers below version ${spec.version}, got ${compat}`,
51
+ );
52
+ }
53
+ }
54
+ if (spec.layout !== void 0 && spec.layout !== "single" && spec.layout !== "per-record") {
55
+ throw new Error(`domain '${spec.name}' layout must be 'single' or 'per-record', got ${spec.layout}`);
56
+ }
57
+ if (spec.invalidRecords !== void 0 && spec.invalidRecords !== "backup-and-skip") {
58
+ throw new Error(`domain '${spec.name}' invalidRecords must be 'backup-and-skip' when present, got ${spec.invalidRecords}`);
59
+ }
60
+ for (const table of Object.keys(spec.tables)) {
61
+ if (!UNIT_NAME_RE.test(table)) {
62
+ throw new Error(`domain '${spec.name}' table name '${table}' must match ${UNIT_NAME_RE}`);
63
+ }
64
+ }
65
+ // 宿主的 global schema 不接受 null:null 是介质的「从未写入」哨兵,
66
+ // 存进去的 null 无法与「不存在」区分,重新打开会静默回落到 initial。
67
+ if (spec.global !== void 0 && spec.global.schema.safeParse(null).success) {
68
+ throw new Error(
69
+ `domain '${spec.name}' global schema must not accept null: null is the medium's "never written" sentinel`,
70
+ );
71
+ }
72
+ return spec;
73
+ }
@@ -1,8 +1,11 @@
1
1
  // skill-tag-plugin — storage domain schema (spec §12: 9 entity classes)
2
2
  //
3
- // Backed by @deepseek-ai/dsh-storage-domain defineDomain (evidence:
4
- // docs/evidence/extract-dsh-storage-domain.js — zod record schemas, KvTable
5
- // get/put/delete/update/entries, domain/changed events, caller closes).
3
+ // Spec 形状由本仓库 src/storage/domain-spec.js 本地构造,刻意不 import 宿主内核包
4
+ // @deepseek-ai/dsh-storage-domain(原因见该文件头部注释)。运行时通过
5
+ // ctx.storageDomain.open(skillTagDomain) 交给宿主打开。
6
+ //
7
+ // KvTable 能力(get/put/delete/update/entries、domain/changed 事件、caller closes)
8
+ // 来自宿主注入的 domain handle,见 docs/evidence/extract-dsh-storage-domain.js。
6
9
  //
7
10
  // Entity → table mapping (§12 table, one row per entity unless noted):
8
11
  // tags 全局标签 {tagId, name, createdAt} key=tagId
@@ -15,7 +18,7 @@
15
18
  // "不要求必须用四张独立数据表"; they must persist, which they do here.)
16
19
 
17
20
  import { z } from "zod";
18
- import { defineDomain, domainTable } from "@deepseek-ai/dsh-storage-domain";
21
+ import { defineDomain, domainTable } from "./domain-spec.js";
19
22
 
20
23
  // ── record schemas ──────────────────────────────────────────────────────────
21
24