dsh-skill-hub 0.3.20 → 0.3.22

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 (42) hide show
  1. package/CONTRIBUTING.md +2 -2
  2. package/README.md +5 -4
  3. package/README.zh.md +5 -4
  4. package/lib/client.js +2 -2
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +362 -74
  7. package/lib/types/client/locales/settings.d.ts +1 -1
  8. package/lib/types/client/locales.d.ts +1 -1
  9. package/lib/types/protocol/config.d.ts +1 -1
  10. package/lib/types/protocol/sources.d.ts +5 -0
  11. package/lib/types/reconcile.d.ts +24 -0
  12. package/lib/types/routes/deps.d.ts +8 -1
  13. package/lib/types/routes/helpers.d.ts +11 -6
  14. package/lib/types/routes/http.d.ts +27 -2
  15. package/lib/types/routes/route-state.d.ts +22 -2
  16. package/lib/types/routes.d.ts +29 -4
  17. package/lib/types/skillfs/scan.d.ts +26 -0
  18. package/lib/types/skillfs.d.ts +9 -1
  19. package/lib/types/store/migrate.d.ts +1 -1
  20. package/lib/types/store/store.d.ts +10 -5
  21. package/package.json +1 -1
  22. package/src/client/locales/settings.ts +2 -2
  23. package/src/index.ts +26 -4
  24. package/src/protocol/config.ts +1 -1
  25. package/src/protocol/sources.ts +5 -0
  26. package/src/reconcile.test.ts +74 -1
  27. package/src/reconcile.ts +50 -1
  28. package/src/routes/catalog.ts +50 -22
  29. package/src/routes/deps.ts +8 -2
  30. package/src/routes/helpers.ts +18 -7
  31. package/src/routes/http.ts +31 -2
  32. package/src/routes/repo-import.ts +16 -26
  33. package/src/routes/route-state.test.ts +4 -4
  34. package/src/routes/route-state.ts +45 -10
  35. package/src/routes/sources.ts +79 -23
  36. package/src/routes.test.ts +302 -4
  37. package/src/routes.ts +49 -5
  38. package/src/skillfs/scan.ts +91 -2
  39. package/src/skillfs.ts +14 -2
  40. package/src/store/migrate.ts +6 -4
  41. package/src/store/store.ts +21 -11
  42. package/src/store.test.ts +17 -1
package/CONTRIBUTING.md CHANGED
@@ -39,7 +39,7 @@ src/client/locales/ dictionaries by view (common/skills/market/sources/detai
39
39
  ```bash
40
40
  npm install
41
41
  npm run typecheck # tsc --noEmit
42
- npm test # vitest (266 tests across 14 suites)
42
+ npm test # vitest (285 tests across 14 suites)
43
43
  npm run build # tsc declarations + tsdown bundles (lib/index.js + lib/client.js)
44
44
  ```
45
45
 
@@ -59,7 +59,7 @@ npm run build # tsc declarations + tsdown bundles (lib/index.js + lib/clie
59
59
  ## Code style
60
60
 
61
61
  - TypeScript, strict mode. ESM (`"type": "module"`).
62
- - Host routes are loopback-only by construction — keep the trust fence intact.
62
+ - Host routes reuse dsh's own `/api` trust fence (loopback ∪ the listener's bind address ∪ `--trusted-host` authorities ∪ the browser session) — never add a second, stricter check. Issue #17 (every route 403s behind a reverse proxy) came from exactly such a duplicate.
63
63
  - The browser half uses CSS Modules; keep the settings-card chrome family-bucket-compatible.
64
64
  - Comments explain *why* (routing decisions, dsh host behaviors) more than *what*.
65
65
 
package/README.md CHANGED
@@ -77,7 +77,7 @@ GitHub repo ──scan/import──▶ ~/.dsh/skills
77
77
  /api/skill-hub/* ──▶ Panel (Settings → 技能)
78
78
  ```
79
79
 
80
- Host uses only `ctx.skills.snapshot/get`, `ctx.webServer.register`, `ctx.systemPrompt.section`. Loopback-only routes (`127.0.0.1`/`localhost`), JSON.
80
+ Host uses only `ctx.skills.snapshot/get`, `ctx.webServer.register`, `ctx.systemPrompt.section`. Routes sit behind dsh's own `/api` trust fence (loopback / the listener's bind address / `--trusted-host`), JSON.
81
81
 
82
82
  ## HTTP API
83
83
 
@@ -108,7 +108,7 @@ Host uses only `ctx.skills.snapshot/get`, `ctx.webServer.register`, `ctx.systemP
108
108
 
109
109
  ```bash
110
110
  npm run typecheck # tsc --noEmit
111
- npm test # 266 tests, 14 suites
111
+ npm test # 285 tests, 14 suites
112
112
  npm run build # tsc + tsdown → lib/index.js + lib/client.js
113
113
  ```
114
114
 
@@ -117,8 +117,9 @@ npm run build # tsc + tsdown → lib/index.js + lib/client.js
117
117
  ## Troubleshooting
118
118
 
119
119
  - `duplicate loader entry id: skill-hub` — remove the duplicate install (keep one `dsh plugin add` method).
120
- - Skill missing — check the diagnostics section (frontmatter / name mismatch / short description).
121
- - Empty source group — its skills were deleted, or their disabled records were lost (sidecar restored/hand-edited). Startup reconciles `.disabled` files on disk; source groups with no visible member are no longer rendered.
120
+ - Skill missing — check the diagnostics section (frontmatter / name mismatch / short description / two discovery forms claiming the same name: a `<name>/SKILL.md` bundle and a `<name>.md` file can coexist on disk, and the registry keeps only one of them).
121
+ - Empty source group — its skills were deleted, or their disabled records were lost (sidecar restored/hand-edited). Startup reconciles `.disabled` files on disk **and prunes records whose file is gone** (a record left behind by a hand-deleted directory used to be un-actionable: enable, create and delete all failed). Source groups with no visible member are no longer rendered.
122
+ - A skill cannot be created / stays "disabled" — the disabled record pointed at a file that no longer exists. At startup (and on the next enable attempt) the record is repointed at the surviving `.disabled` file, or dropped so the name is free again.
122
123
  - Dots missing in `/` menu — dsh internals changed; catalog still works.
123
124
  - Settings card missing — open the plugin in the Plugins manager (sidebar → 插件 → dsh-skill-hub) and expand the 「技能中枢」 card at the top of the page (collapsed by default). On dsh older than `0.1.7-alpha.1` this plugin does not load at all (the settings API it targets does not exist there).
124
125
 
package/README.zh.md CHANGED
@@ -77,7 +77,7 @@ GitHub 仓库 ──扫描/导入──▶ ~/.dsh/skills
77
77
  /api/skill-hub/* ──▶ 面板(设置 → 技能)
78
78
  ```
79
79
 
80
- 宿主仅用 `ctx.skills.snapshot/get`、`ctx.webServer.register`、`ctx.systemPrompt.section`。路由仅回环(`127.0.0.1`/`localhost`),JSON。
80
+ 宿主仅用 `ctx.skills.snapshot/get`、`ctx.webServer.register`、`ctx.systemPrompt.section`。路由走 dsh 自身的 `/api` 信任栅栏(回环 / 监听器绑定地址 / `--trusted-host`),JSON。
81
81
 
82
82
  ## HTTP API
83
83
 
@@ -108,7 +108,7 @@ GitHub 仓库 ──扫描/导入──▶ ~/.dsh/skills
108
108
 
109
109
  ```bash
110
110
  npm run typecheck # tsc --noEmit
111
- npm test # 266 tests, 14 suites
111
+ npm test # 285 tests, 14 suites
112
112
  npm run build # tsc + tsdown → lib/index.js + lib/client.js
113
113
  ```
114
114
 
@@ -117,8 +117,9 @@ npm run build # tsc + tsdown → lib/index.js + lib/client.js
117
117
  ## 故障排查
118
118
 
119
119
  - `duplicate loader entry id: skill-hub` — 删掉重复安装(只留一种 `dsh plugin add`)。
120
- - 技能不出现 — 看诊断区(缺 frontmatter / 名称不一致 / 描述过短)。
121
- - 来源组空壳 — 组内技能已被删除、或禁用记录丢失(状态文件被恢复/手改)。启动时自动对账磁盘上的 `.disabled` 文件补记录;无可见成员的来源组不再渲染。
120
+ - 技能不出现 — 看诊断区(缺 frontmatter / 名称不一致 / 描述过短 / 两种发现形态抢同一个名字:`<name>/SKILL.md` 目录包与 `<name>.md` 扁平文件可以并存,注册表只会留一个)。
121
+ - 来源组空壳 — 组内技能已被删除、或禁用记录丢失(状态文件被恢复/手改)。启动时自动对账磁盘上的 `.disabled` 文件补记录,**并清掉文件已不存在的死记录**(手工删掉目录后留下的记录以前谁也动不了:启用、新建、删除三条路全失败);无可见成员的来源组不再渲染。
122
+ - 技能建不出来 / 一直显示「已禁用」— 禁用记录指向的文件已经不在了。启动时(以及下一次点「启用」时)会把记录改指到现存的 `.disabled` 文件,找不到就直接删掉记录、把名字释放出来。
122
123
  - `/` 菜单圆点消失 — dsh 内部触发源变更,目录功能不受影响。
123
124
  - 找不到配置卡片 — 在插件管理页打开本插件(侧边栏「插件」→ dsh-skill-hub),展开页面顶部的「技能中枢」卡片(默认折叠)。dsh 低于 `0.1.7-alpha.1` 时本插件无法加载(它所用的 settings API 在旧版不存在)。
124
125
 
package/lib/client.js CHANGED
@@ -612,7 +612,7 @@ window.__ModuleLoader__.load({
612
612
  "settings.statsScanMinutes": "自动统计间隔(分钟)",
613
613
  "settings.statsScanMinutesHint": "后台扫描会话日志的间隔,最小 1 分钟;扫描耗时会自动拉长间隔。",
614
614
  "settings.githubToken": "GitHub Token",
615
- "settings.githubTokenHint": "市场/来源走 GitHub API,匿名每小时 60 次,填 token 后 5000 次。细粒度 token 无需任何权限。明文存本地设置,仅回环可读;留空即匿名(或跟随 GITHUB_TOKEN 环境变量)。",
615
+ "settings.githubTokenHint": "市场/来源走 GitHub API,匿名每小时 60 次,填 token 后 5000 次。细粒度 token 无需任何权限。明文存本地设置,仅经 dsh 的 /api 信任栅栏可读(回环 / 绑定地址 / --trusted-host);留空即匿名(或跟随 GITHUB_TOKEN 环境变量)。",
616
616
  "settings.githubTokenPlaceholder": "ghp_… / github_pat_…(留空为匿名)",
617
617
  "settings.inherit": "继承",
618
618
  "settings.overridden": "已覆盖",
@@ -649,7 +649,7 @@ window.__ModuleLoader__.load({
649
649
  "settings.statsScanMinutes": "Auto stats interval (minutes)",
650
650
  "settings.statsScanMinutesHint": "How often the background session-log scan runs (min 1); heavy scans automatically stretch it.",
651
651
  "settings.githubToken": "GitHub token",
652
- "settings.githubTokenHint": "Market/sources use the GitHub API: 60 req/h anonymous, 5000/hr with a token. A fine-grained token needs no permissions. Stored plaintext in local settings, loopback-only; empty means anonymous (or GITHUB_TOKEN env).",
652
+ "settings.githubTokenHint": "Market/sources use the GitHub API: 60 req/h anonymous, 5000/hr with a token. A fine-grained token needs no permissions. Stored plaintext in local settings, reachable only through dsh's /api trust fence (loopback / bind address / --trusted-host); empty means anonymous (or GITHUB_TOKEN env).",
653
653
  "settings.githubTokenPlaceholder": "ghp_… / github_pat_… (empty = anonymous)",
654
654
  "settings.inherit": "Inherit",
655
655
  "settings.overridden": "Overridden",