dsh-skill-hub 0.3.19 → 0.3.21

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 (51) hide show
  1. package/CONTRIBUTING.md +1 -1
  2. package/README.md +4 -3
  3. package/README.zh.md +4 -3
  4. package/lib/client.js +10 -6
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +428 -156
  7. package/lib/types/client/api.d.ts +3 -3
  8. package/lib/types/protocol/config.d.ts +17 -11
  9. package/lib/types/protocol/market.d.ts +11 -0
  10. package/lib/types/protocol/sources.d.ts +5 -0
  11. package/lib/types/protocol.d.ts +1 -1
  12. package/lib/types/reconcile.d.ts +24 -0
  13. package/lib/types/repo/github-client.d.ts +11 -4
  14. package/lib/types/repo.d.ts +1 -1
  15. package/lib/types/routes/deps.d.ts +6 -1
  16. package/lib/types/routes/route-state.d.ts +22 -2
  17. package/lib/types/skillfs/scan.d.ts +32 -5
  18. package/lib/types/skillfs.d.ts +34 -2
  19. package/lib/types/store/migrate.d.ts +1 -1
  20. package/lib/types/store/store.d.ts +10 -5
  21. package/package.json +21 -20
  22. package/src/client/api.ts +4 -3
  23. package/src/client/panel/hooks/useMarketFlow.ts +4 -2
  24. package/src/client/settings-card.tsx +2 -1
  25. package/src/client/settings-form.ts +6 -3
  26. package/src/index.ts +12 -2
  27. package/src/protocol/config.ts +27 -24
  28. package/src/protocol/market.ts +12 -0
  29. package/src/protocol/sources.ts +5 -0
  30. package/src/protocol.ts +1 -0
  31. package/src/reconcile.test.ts +74 -1
  32. package/src/reconcile.ts +50 -1
  33. package/src/repo/github-client.ts +26 -14
  34. package/src/repo.test.ts +20 -1
  35. package/src/repo.ts +1 -1
  36. package/src/routes/catalog-data.ts +7 -4
  37. package/src/routes/catalog.ts +51 -28
  38. package/src/routes/deps.ts +7 -2
  39. package/src/routes/market.ts +13 -2
  40. package/src/routes/repo-import.ts +17 -30
  41. package/src/routes/route-state.test.ts +4 -4
  42. package/src/routes/route-state.ts +45 -10
  43. package/src/routes/sources.ts +79 -23
  44. package/src/routes.test.ts +300 -0
  45. package/src/skillfs/scan.ts +119 -17
  46. package/src/skillfs.test.ts +64 -3
  47. package/src/skillfs.ts +51 -8
  48. package/src/store/migrate.ts +6 -4
  49. package/src/store/store.ts +21 -11
  50. package/src/store.test.ts +17 -1
  51. package/src/update.ts +6 -6
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 (258 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
 
package/README.md CHANGED
@@ -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 # 258 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
@@ -108,7 +108,7 @@ GitHub 仓库 ──扫描/导入──▶ ~/.dsh/skills
108
108
 
109
109
  ```bash
110
110
  npm run typecheck # tsc --noEmit
111
- npm test # 258 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
@@ -61,6 +61,10 @@ window.__ModuleLoader__.load({
61
61
  * `ctx.settings.update(HUB_ENTRY_ID, …)`.
62
62
  */
63
63
  const HUB_ENTRY_ID = "skill-hub";
64
+ /** HEX color validation shared by host routes and the settings card. */
65
+ const HEX_COLOR_RE = /^#[0-9a-f]{6}$/i;
66
+ /** GitHub token validation shared by host routes and the settings card. */
67
+ const GITHUB_TOKEN_RE = /^[A-Za-z0-9_\-]{8,255}$/;
64
68
  //#endregion
65
69
  //#region src/protocol/sources.ts
66
70
  /** 项目级技能来源(它们有 workspace 归属,不属于「个人」组)。 */
@@ -161,7 +165,7 @@ window.__ModuleLoader__.load({
161
165
  market() {
162
166
  return this.get(SKILL_HUB_API.market);
163
167
  }
164
- /** Add a market source repo; resolves with the fresh list. */
168
+ /** Add a market source repo; resolves with the fresh list plus the resolved slug. */
165
169
  addMarketSource(repo) {
166
170
  return this.post(SKILL_HUB_API.marketSource, { repo });
167
171
  }
@@ -1542,7 +1546,7 @@ window.__ModuleLoader__.load({
1542
1546
  });
1543
1547
  }
1544
1548
  function ColorField(props) {
1545
- const value = /^#[0-9a-f]{6}$/i.test(props.text) ? props.text : props.defaultColor;
1549
+ const value = HEX_COLOR_RE.test(props.text) ? props.text : props.defaultColor;
1546
1550
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1547
1551
  className: settings_card_module_css_default.field,
1548
1552
  children: [
@@ -2360,9 +2364,9 @@ window.__ModuleLoader__.load({
2360
2364
  function colorField(field) {
2361
2365
  return {
2362
2366
  field,
2363
- format: (value) => typeof value === "string" && /^#[0-9a-f]{6}$/i.test(value) ? value : "",
2367
+ format: (value) => typeof value === "string" && HEX_COLOR_RE.test(value) ? value : "",
2364
2368
  parse: (text) => {
2365
- if (/^#[0-9a-f]{6}$/i.test(text)) return {
2369
+ if (HEX_COLOR_RE.test(text)) return {
2366
2370
  kind: "set",
2367
2371
  value: text
2368
2372
  };
@@ -2381,7 +2385,7 @@ window.__ModuleLoader__.load({
2381
2385
  parse: (text) => {
2382
2386
  const trimmed = text.trim();
2383
2387
  if (trimmed === "") return void 0;
2384
- if (!/^[A-Za-z0-9_-]{8,255}$/.test(trimmed)) return void 0;
2388
+ if (!GITHUB_TOKEN_RE.test(trimmed)) return void 0;
2385
2389
  return {
2386
2390
  kind: "set",
2387
2391
  value: trimmed
@@ -6424,7 +6428,7 @@ window.__ModuleLoader__.load({
6424
6428
  setNewSourceName("");
6425
6429
  setRepoResult(null);
6426
6430
  setRepoSelected(/* @__PURE__ */ new Set());
6427
- const slug = result.repos[result.repos.length - 1].repo;
6431
+ const slug = result.repo;
6428
6432
  setScanningRepo(slug);
6429
6433
  setRepoDiscoverState({ status: "scanning" });
6430
6434
  try {