dsh-skill-hub 0.1.0 → 0.2.0
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 +146 -33
- package/lib/client.js +3477 -436
- package/lib/client.js.map +1 -1
- package/lib/index.js +2408 -366
- package/lib/types/client/SkillHubSettingsCard.d.ts +5 -0
- package/lib/types/client/api-config-scope.d.ts +6 -0
- package/lib/types/client/api.d.ts +44 -2
- package/lib/types/client/grouping.d.ts +64 -0
- package/lib/types/client/locales.d.ts +155 -18
- package/lib/types/client/market-catalog.d.ts +14 -0
- package/lib/types/client/panel/DisabledRow.d.ts +12 -0
- package/lib/types/client/panel/GroupSummary.d.ts +10 -0
- package/lib/types/client/panel/MarketView.d.ts +11 -0
- package/lib/types/client/panel/ScenesView.d.ts +11 -0
- package/lib/types/client/panel/SkillDetailView.d.ts +31 -0
- package/lib/types/client/panel/SkillHubPanel.d.ts +11 -3
- package/lib/types/client/panel/SkillRow.d.ts +11 -0
- package/lib/types/client/panel/SourceStatusBadge.d.ts +18 -0
- package/lib/types/client/panel/SourcesView.d.ts +10 -0
- package/lib/types/client/panel/TagEditorView.d.ts +29 -0
- package/lib/types/client/panel/dialogs.d.ts +73 -0
- package/lib/types/client/panel/format.d.ts +14 -0
- package/lib/types/client/panel/useSkillHub.d.ts +183 -0
- package/lib/types/client/settings-card.d.ts +21 -4
- package/lib/types/client/settings-form.d.ts +2 -0
- package/lib/types/client/settings-nav-icon.d.ts +8 -0
- package/lib/types/index.d.ts +6 -0
- package/lib/types/protocol.d.ts +428 -7
- package/lib/types/provider.d.ts +6 -1
- package/lib/types/repo.d.ts +133 -0
- package/lib/types/routes.d.ts +9 -4
- package/lib/types/skillfs.d.ts +19 -14
- package/lib/types/stats.d.ts +17 -4
- package/lib/types/store.d.ts +112 -6
- package/lib/types/update.d.ts +20 -0
- package/package.json +5 -3
- package/src/client/SkillHubSettingsCard.tsx +61 -8
- package/src/client/api-config-scope.test.ts +79 -0
- package/src/client/api-config-scope.ts +28 -4
- package/src/client/api.ts +239 -9
- package/src/client/grouping.test.ts +109 -0
- package/src/client/grouping.ts +120 -0
- package/src/client/index.tsx +5 -2
- package/src/client/locales.ts +314 -40
- package/src/client/market-catalog.ts +22 -0
- package/src/client/panel/DisabledRow.tsx +32 -0
- package/src/client/panel/GroupSummary.tsx +27 -0
- package/src/client/panel/MarketView.tsx +173 -0
- package/src/client/panel/ScenesView.tsx +75 -0
- package/src/client/panel/SkillDetailView.tsx +95 -0
- package/src/client/panel/SkillHubPanel.tsx +251 -257
- package/src/client/panel/SkillRow.tsx +54 -0
- package/src/client/panel/SourceStatusBadge.tsx +61 -0
- package/src/client/panel/SourcesView.tsx +104 -0
- package/src/client/panel/TagEditorView.tsx +89 -0
- package/src/client/panel/dialogs.tsx +185 -0
- package/src/client/panel/format.ts +31 -0
- package/src/client/panel/panel.module.css +209 -45
- package/src/client/panel/useSkillHub.ts +797 -0
- package/src/client/settings-card.module.css +44 -28
- package/src/client/settings-card.tsx +64 -8
- package/src/client/settings-form.ts +12 -0
- package/src/client/settings-nav-icon.ts +42 -0
- package/src/index.ts +19 -15
- package/src/protocol.ts +460 -7
- package/src/provider.test.ts +2 -4
- package/src/provider.ts +18 -14
- package/src/repo.test.ts +212 -0
- package/src/repo.ts +528 -0
- package/src/routes.test.ts +564 -52
- package/src/routes.ts +999 -153
- package/src/skillfs.test.ts +98 -16
- package/src/skillfs.ts +68 -33
- package/src/stats.test.ts +52 -17
- package/src/stats.ts +55 -18
- package/src/store.test.ts +205 -1
- package/src/store.ts +527 -24
- package/src/update.test.ts +73 -0
- package/src/update.ts +136 -0
package/README.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# dsh-skill-hub
|
|
2
2
|
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://www.npmjs.com/package/dsh-skill-hub"><img alt="npm version" src="https://img.shields.io/npm/v/dsh-skill-hub?color=2f81f7&label=npm"></a>
|
|
5
|
+
<img alt="license" src="https://img.shields.io/npm/l/dsh-skill-hub">
|
|
6
|
+
<img alt="node" src="https://img.shields.io/badge/node-%3E%3D22.19-339933">
|
|
7
|
+
<a href="https://github.com/cheshireez/dsh-skill-hub/actions"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/cheshireez/dsh-skill-hub/ci.yml?branch=main"></a>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
3
10
|
<details>
|
|
4
11
|
<summary><b>English</b>(英文)— 点击在本页展开 / 收起,无需跳转</summary>
|
|
5
12
|
|
|
@@ -20,41 +27,59 @@ their bodies, understand why a skill is missing, and scaffold new ones — all f
|
|
|
20
27
|
| Capability | dsh-skill-manager (read-only) | **dsh-skill-hub (this plugin)** |
|
|
21
28
|
| --- | --- | --- |
|
|
22
29
|
| Catalog source | self-scans disk, user roots only | official `ctx.skills` registry: project / custom / user / bundled + third-party providers |
|
|
23
|
-
| Browse / search | ✅ | ✅ (group by
|
|
24
|
-
| Enable / disable | ❌ | ✅ (renames `SKILL.md`; file never deleted, always restorable) |
|
|
30
|
+
| Browse / search | ✅ | ✅ (group by **tags** or by **source repo**, search + filter in one row) |
|
|
31
|
+
| Enable / disable | ❌ | ✅ (renames `SKILL.md`; file never deleted, always restorable; per-group tri-state switches) |
|
|
25
32
|
| Inspect skill body | ❌ | ✅ |
|
|
26
33
|
| Discovery diagnostics | ❌ | ✅ (missing frontmatter / missing `name`/`description` / invalid name — each reason listed) |
|
|
27
34
|
| New-skill wizard | ❌ | ✅ (writes to `~/.dsh/skills` or `~/.agents/skills`) |
|
|
28
|
-
| Invocation statistics | ❌ | ✅ (per-skill call counts read from session logs) |
|
|
29
|
-
|
|
|
35
|
+
| Invocation statistics | ❌ | ✅ (per-skill call counts read from session logs; group headers summarize) |
|
|
36
|
+
| Upstream source tracking | ❌ | ✅ (repo + commit snapshot; check updates, sync, follow upstream deletion into a restorable trash; delete/restore keeps source + scene membership) |
|
|
37
|
+
| Codex-style market | ❌ | ✅ (built-in market catalog + custom repo sources, scan, one-click import, per-source installed/updatable badges, one-click update-all) |
|
|
30
38
|
| Live updates | — | filesystem-provider watcher, with a 5s panel poll as fallback |
|
|
31
39
|
|
|
32
40
|
## Features
|
|
33
41
|
|
|
34
42
|
- **Full catalog** — every skill the official registry knows: project `.dsh/skills` & `.agents/skills`,
|
|
35
43
|
custom roots, user `~/.dsh/skills` & `~/.agents/skills`, bundled, and third-party providers.
|
|
36
|
-
- **Search & grouping** —
|
|
44
|
+
- **Search & grouping** — one row combines search, source filter, and flat/grouped view; groups are
|
|
45
|
+
user **tags** plus **source collections** (auto-aggregated by upstream repo); uncategorized stays visible.
|
|
46
|
+
- **Group switches** — every group header carries a sliding switch: enable/disable the whole group in one
|
|
47
|
+
click. Closing a group whose member is also enabled elsewhere opens a conflict dialog (close all / keep on →
|
|
48
|
+
the group falls into a half-filled mixed state). Read-only skills are skipped with per-name reports.
|
|
37
49
|
- **Enable / disable** — disable renames `SKILL.md` out of discovery (tracked in a sidecar file), so the
|
|
38
50
|
change survives restarts and is trivially reversible. Files are never deleted.
|
|
51
|
+
- **Source tracking** — skills imported from GitHub (market sources or direct URLs) record the repo, ref,
|
|
52
|
+
and upstream commit snapshot. Check for updates per source (1–2 GitHub API requests, 5-minute throttle),
|
|
53
|
+
sync selected skills (overwrite confirm), and follow upstream deletion into a restorable trash.
|
|
54
|
+
Deleting and restoring a tracked skill keeps its source and scene membership (snapshotted in the
|
|
55
|
+
trash entry). Personal skills (no source) are never tracked.
|
|
56
|
+
- **Market** — codex-style: a built-in catalog of curated repos (one-click add) plus custom repo
|
|
57
|
+
sources (owner/repo or a GitHub URL); scan `skills/` and `design-templates/` roots and import with
|
|
58
|
+
one click. Each source row aggregates its state — installed / updatable / deleted upstream — and
|
|
59
|
+
one "update all" pass syncs every source with pending updates (per-source failures are reported,
|
|
60
|
+
never fatal).
|
|
39
61
|
- **Skill detail** — read a skill’s rendered body straight from disk.
|
|
40
62
|
- **Discovery diagnostics** — the catalog reports *why* a skill was ignored (missing YAML frontmatter,
|
|
41
63
|
missing `name`/`description`, illegal name), per skill.
|
|
42
64
|
- **New-skill wizard** — scaffold a valid skill into `~/.dsh/skills` or `~/.agents/skills` from the GUI.
|
|
43
65
|
- **Invocation statistics** — the panel shows how many times each skill was actually called, read from
|
|
44
66
|
session logs (optional; absent session-query deployments simply omit the data).
|
|
45
|
-
- **Settings card** — enable the plugin
|
|
67
|
+
- **Settings card** — enable the plugin, toggle the agent announcement, and adjust panel display preferences from **Settings → 插件 → Skill Hub**.
|
|
46
68
|
|
|
47
69
|
## How it works
|
|
48
70
|
|
|
49
71
|
```text
|
|
50
72
|
src/
|
|
51
73
|
├── index.ts host entry: inject [webServer, skills, systemPrompt]; system-prompt announcement
|
|
52
|
-
├── routes.ts /api/skill-hub/{catalog,skill,toggle,create,stats,config
|
|
53
|
-
|
|
54
|
-
├──
|
|
74
|
+
├── routes.ts /api/skill-hub/{catalog,skill,toggle,toggle-batch,create,stats,config,
|
|
75
|
+
│ groups,tag*,market*,repo*,sources*,update} (loopback-only fence)
|
|
76
|
+
├── store.ts sidecar state ~/.dsh/dsh-skill-hub.json v3 (disabled, tags, sources, market
|
|
77
|
+
│ sources, trash, runtime config; versioned v1→v2→v3 migrations)
|
|
78
|
+
├── repo.ts GitHub discovery/import + source tracking (latest commit, tree diff, manifest)
|
|
79
|
+
├── skillfs.ts root resolution / toggle rename / trash & restore / scaffold / diagnostics
|
|
55
80
|
├── stats.ts invocation stats: session logs → per-skill call counts (optional sessionQuery)
|
|
56
81
|
├── protocol.ts host ↔ browser shared API contract (types + endpoint table)
|
|
57
|
-
└── client/ browser half: settings card + skill hub panel (React, CSS Modules)
|
|
82
|
+
└── client/ browser half: settings card + skill hub panel (React, CSS Modules, Apple-style)
|
|
58
83
|
```
|
|
59
84
|
|
|
60
85
|
- **Host half** uses only official SDKs: `ctx.skills.snapshot()/get()`, `ctx.webServer.register()`,
|
|
@@ -79,12 +104,20 @@ Requires Node `^22.19.0 || >=24.0.0` and a dsh web deployment (`0.1.0-rc.6` SDK
|
|
|
79
104
|
|
|
80
105
|
Open **Settings → 技能** (Skill Hub) in the dsh web GUI:
|
|
81
106
|
|
|
82
|
-
- **Browse** — the full catalog, searchable and grouped
|
|
107
|
+
- **Browse** — the full catalog, searchable; search, source filter, and flat/grouped view share one row.
|
|
108
|
+
- **Groups** — user tags and source collections (upstream repos). Group headers carry tri-state sliding
|
|
109
|
+
switches (on / off / mixed) with a conflict dialog when closing affects skills enabled elsewhere.
|
|
110
|
+
- **Market** — a built-in catalog of curated repos (one-click add), plus custom sources (add a repo
|
|
111
|
+
source, scan, one-click install) or direct URLs; every import records the upstream repo/commit.
|
|
112
|
+
Each source row shows installed / updatable / deleted-upstream counts; "check all" refreshes every
|
|
113
|
+
source, and "update all" syncs every pending source in one pass.
|
|
114
|
+
- **Trash** — skills removed after upstream deletion (or deleted manually) land in a restorable trash;
|
|
115
|
+
restoring brings back the skill's source and scene membership.
|
|
83
116
|
- **Toggle** — enable/disable any skill from a user-writable root; disabled skills list separately and
|
|
84
117
|
can be re-enabled any time.
|
|
85
118
|
- **Diagnose** — the discovery diagnostics explain why a skill is not showing up.
|
|
86
119
|
- **New skill** — scaffold a new skill from the form and start writing.
|
|
87
|
-
- **Statistics** — per-skill invocation counts when session-query data is available.
|
|
120
|
+
- **Statistics** — per-skill invocation counts when session-query data is available; group headers summarize.
|
|
88
121
|
|
|
89
122
|
The plugin’s own switches live on the **Settings → 插件 → Skill Hub** card:
|
|
90
123
|
|
|
@@ -92,6 +125,10 @@ The plugin’s own switches live on the **Settings → 插件 → Skill Hub** ca
|
|
|
92
125
|
| --- | --- |
|
|
93
126
|
| Enable plugin | Master switch: routes, provider, and announcement all go live with this. |
|
|
94
127
|
| Announce to agent | Adds a system-prompt section so agents know how to collaborate when users mention skill management. |
|
|
128
|
+
| Model / user dot colors | Override the blue/green invocation dot colors used in the panel. |
|
|
129
|
+
| Show invocation count | Show per-skill call-count chips when session stats are available. |
|
|
130
|
+
| Show last-used time | Show relative last-used time on each skill row. |
|
|
131
|
+
| Show group summaries | Show count/last-used summaries after group titles. |
|
|
95
132
|
|
|
96
133
|
## HTTP API
|
|
97
134
|
|
|
@@ -99,31 +136,57 @@ All endpoints are **loopback-only** (`127.0.0.1`/`localhost`) and JSON.
|
|
|
99
136
|
|
|
100
137
|
| Endpoint | Method | Purpose |
|
|
101
138
|
| --- | --- | --- |
|
|
102
|
-
| `/api/skill-hub/catalog` | GET | Full catalog: skills, disabled list, discovery diagnostics
|
|
139
|
+
| `/api/skill-hub/catalog` | GET | Full catalog: skills, disabled list, discovery diagnostics. |
|
|
103
140
|
| `/api/skill-hub/skill?name=` | GET | One skill’s detail (path, provider, body). |
|
|
104
141
|
| `/api/skill-hub/toggle` | POST | Enable/disable a writable skill (`{name, enabled}`). |
|
|
142
|
+
| `/api/skill-hub/toggle-batch` | POST | Enable/disable a whole group in one write (`{names, enabled}`). |
|
|
105
143
|
| `/api/skill-hub/create` | POST | Scaffold a new skill (`{name, description?, root?}`). |
|
|
106
144
|
| `/api/skill-hub/stats` | GET | Per-skill invocation counts (unavailable when session-query is absent). |
|
|
107
145
|
| `/api/skill-hub/config` | GET/POST | Plugin runtime config (`{enabled, announceToAgent}`); `null` clears an override. |
|
|
146
|
+
| `/api/skill-hub/groups` | GET | User tags + source collections + origin map. |
|
|
147
|
+
| `/api/skill-hub/tag` | POST | Create/rename a tag group. |
|
|
148
|
+
| `/api/skill-hub/tag/delete` | POST | Delete a tag group. |
|
|
149
|
+
| `/api/skill-hub/tag/members` | POST | Set a tag’s member list. |
|
|
150
|
+
| `/api/skill-hub/market` | GET | The user’s market source repos. |
|
|
151
|
+
| `/api/skill-hub/market/source` | POST | Add a market source (`{repo}`). |
|
|
152
|
+
| `/api/skill-hub/market/source/delete` | POST | Remove a market source. |
|
|
153
|
+
| `/api/skill-hub/repo?repo=` | GET | Discover importable skills in a GitHub repo. |
|
|
154
|
+
| `/api/skill-hub/repo/import` | POST | Import selected repo skills (records the source). |
|
|
155
|
+
| `/api/skill-hub/sources` | GET | Source records, derived origins/collections, trash. |
|
|
156
|
+
| `/api/skill-hub/sources/check` | POST | Check upstream updates (throttled, 5 min). |
|
|
157
|
+
| `/api/skill-hub/sources/sync` | POST | Sync selected (or all) skills of a source. |
|
|
158
|
+
| `/api/skill-hub/sources/delete` | POST | Follow upstream deletion (moves to trash). |
|
|
159
|
+
| `/api/skill-hub/sources/restore` | POST | Restore a trashed skill. |
|
|
160
|
+
| `/api/skill-hub/update` | GET | Check the plugin’s own latest release. |
|
|
108
161
|
|
|
109
162
|
## Development
|
|
110
163
|
|
|
111
164
|
```bash
|
|
112
165
|
npm install
|
|
113
166
|
npm run typecheck # tsc --noEmit
|
|
114
|
-
npm test # vitest (
|
|
167
|
+
npm test # vitest (151 tests across 9 suites)
|
|
115
168
|
npm run build # tsc declarations + tsdown bundles (lib/index.js + lib/client.js)
|
|
116
169
|
npm pack # build the installable tarball (dsh-skill-hub-<version>.tgz)
|
|
117
170
|
```
|
|
118
171
|
|
|
172
|
+
> **Local testing:** do not run two `dsh web` instances against the same
|
|
173
|
+
> `$DSH_HOME` and the same project directory at the same time. dsh rc.6 has no
|
|
174
|
+
> cross-process session-log lock, and a second instance resuming the same
|
|
175
|
+
> session can write duplicate `seq` rows (`corrupt session log: seq gap in
|
|
176
|
+
> committed region`). Stop the old instance first, or give the preview its own
|
|
177
|
+
> `DSH_HOME`.
|
|
178
|
+
|
|
119
179
|
The test suites cover the route family (including the config route and the disabled gate), the sidecar
|
|
120
180
|
store, skill filesystem operations, the registry provider, and invocation statistics.
|
|
121
181
|
|
|
122
182
|
## Roadmap
|
|
123
183
|
|
|
124
184
|
- **v0.1.0** — full catalog, enable/disable, diagnostics, new-skill wizard, settings card.
|
|
125
|
-
- **v0.2.0** — invocation statistics
|
|
126
|
-
|
|
185
|
+
- **v0.2.0** — invocation statistics · tags/scenes + source-collection grouping with tri-state
|
|
186
|
+
switches · upstream source tracking (check / sync / follow-delete into a restorable trash) ·
|
|
187
|
+
codex-style market with built-in catalog, per-source state badges, and one-click update-all ·
|
|
188
|
+
delete/restore keeps source + scene membership.
|
|
189
|
+
- **Next** — SSE realtime push to replace polling · market catalog expansion · optional auto-update.
|
|
127
190
|
|
|
128
191
|
## License
|
|
129
192
|
|
|
@@ -148,41 +211,56 @@ MIT — see [LICENSE](LICENSE).
|
|
|
148
211
|
| 能力 | dsh-skill-manager(只读版) | **dsh-skill-hub(本插件)** |
|
|
149
212
|
| --- | --- | --- |
|
|
150
213
|
| 目录来源 | 自扫盘,仅用户根 | 官方 `ctx.skills` 注册表:项目 / 自定义 / 用户 / 内置 + 第三方 provider |
|
|
151
|
-
| 浏览 / 搜索 | ✅ |
|
|
152
|
-
| 启用 / 禁用 | ❌ | ✅(重命名 `SKILL.md
|
|
214
|
+
| 浏览 / 搜索 | ✅ | ✅(按分组或按来源仓库分组,搜索 + 筛选一行完成) |
|
|
215
|
+
| 启用 / 禁用 | ❌ | ✅(重命名 `SKILL.md`;文件不删除,可随时恢复;分组/来源头部滑动开关一键整组启停) |
|
|
153
216
|
| 查看技能正文 | ❌ | ✅ |
|
|
154
217
|
| 发现诊断 | ❌ | ✅(缺 frontmatter / 缺 `name`/`description` / 非法名称,逐项列明原因) |
|
|
155
218
|
| 新建技能向导 | ❌ | ✅(写入 `~/.dsh/skills` 或 `~/.agents/skills`) |
|
|
156
|
-
| 触发统计 | ❌ |
|
|
157
|
-
|
|
|
219
|
+
| 触发统计 | ❌ | ✅(从会话日志读每技能实际调用次数;组头汇总) |
|
|
220
|
+
| 来源跟踪 | ❌ | ✅(记录上游 repo + commit 快照;检查更新 / 同步 / 上游删除跟进进回收站;删除→恢复保留来源与场景归属) |
|
|
221
|
+
| 市场(codex 式) | ❌ | ✅(内置市场目录 + 自定义仓库源;扫描、一键导入、每源显示已装/可更新数量、一键全部更新) |
|
|
158
222
|
| 实时更新 | — | 文件系统 provider 的 watcher 驱动,面板 5s 轮询兜底 |
|
|
159
223
|
|
|
160
224
|
## 功能
|
|
161
225
|
|
|
162
226
|
- **完整目录** —— 官方注册表知道的每个技能:项目 `.dsh/skills` 与 `.agents/skills`、自定义根、
|
|
163
227
|
用户 `~/.dsh/skills` 与 `~/.agents/skills`、内置、以及第三方 provider。
|
|
164
|
-
- **搜索与分组** ——
|
|
228
|
+
- **搜索与分组** —— 搜索框、来源筛选、平铺/分组视图合并为一行;分组 = 用户 tag + 来源集合(按上游
|
|
229
|
+
仓库自动聚合),未归类兜底可见。
|
|
230
|
+
- **组开关(三态)** —— 每个分组头部一个滑动开关,一键启用/禁用整组;关闭时若成员在其他组开启,
|
|
231
|
+
弹窗询问(全部关闭 / 保留开启 → 该组开关进入半开混合态)。只读技能跳过并逐名报告。
|
|
165
232
|
- **启用 / 禁用** —— 禁用时把 `SKILL.md` 重命名移出发现范围(记录在 sidecar 文件中),重启后仍然
|
|
166
233
|
生效且可一键恢复。文件从不删除。
|
|
234
|
+
- **来源跟踪** —— 从 GitHub 导入(市场源或直接地址)的技能记录上游 repo 与 commit 快照;按来源
|
|
235
|
+
检查更新(每来源 1–2 次 GitHub API 请求,5 分钟节流)、选择同步(确认覆盖)、上游删除跟进移入
|
|
236
|
+
可恢复的回收站。删除后再恢复的技能会保留来源与场景归属(回收站条目里存有快照)。
|
|
237
|
+
个人技能(无来源记录)不跟踪。
|
|
238
|
+
- **市场(codex 式)** —— 内置市场目录(精选仓库一键添加)+ 自定义仓库源(owner/repo 或 GitHub
|
|
239
|
+
链接),扫描 `skills/` 与 `design-templates/` 根目录,一键导入。每个市场源一行聚合显示
|
|
240
|
+
「已装 N / 可更新 N / 上游已删 N」,顶部支持「检查全部」与「全部更新」(逐个同步,单个来源
|
|
241
|
+
失败不影响其他,汇总报告)。
|
|
167
242
|
- **技能详情** —— 直接从磁盘读取技能的渲染正文。
|
|
168
243
|
- **发现诊断** —— 目录会逐项报告技能被忽略的原因(缺 YAML frontmatter、缺 `name`/`description`、
|
|
169
244
|
非法名称)。
|
|
170
245
|
- **新建技能向导** —— 在 GUI 里把合法技能脚手架写入 `~/.dsh/skills` 或 `~/.agents/skills`。
|
|
171
246
|
- **触发统计** —— 面板显示每个技能被实际调用的次数,数据来自会话日志(可选;没有 session-query
|
|
172
247
|
的部署直接省略该数据)。
|
|
173
|
-
- **设置卡片** —— 在 **设置 → 插件 → Skill Hub** 启用插件、开关向 Agent
|
|
248
|
+
- **设置卡片** —— 在 **设置 → 插件 → Skill Hub** 启用插件、开关向 Agent 的公告、调整面板显示偏好。
|
|
174
249
|
|
|
175
250
|
## 工作原理
|
|
176
251
|
|
|
177
252
|
```text
|
|
178
253
|
src/
|
|
179
254
|
├── index.ts host 入口:inject [webServer, skills, systemPrompt];系统提示公告
|
|
180
|
-
├── routes.ts /api/skill-hub/{catalog,skill,toggle,create,stats,config
|
|
181
|
-
|
|
182
|
-
├──
|
|
255
|
+
├── routes.ts /api/skill-hub/{catalog,skill,toggle,toggle-batch,create,stats,config,
|
|
256
|
+
│ groups,tag*,market*,repo*,sources*,update}(仅回环访问)
|
|
257
|
+
├── store.ts sidecar 状态 v3 ~/.dsh/dsh-skill-hub.json(禁用、tag、sources、市场源、
|
|
258
|
+
│ 回收站、运行时配置;v1→v2→v3 版本化迁移)
|
|
259
|
+
├── repo.ts GitHub 发现/导入 + 来源跟踪(最新 commit、tree 差异、manifest)
|
|
260
|
+
├── skillfs.ts 根目录解析 / 开关重命名 / 回收站 & 恢复 / 脚手架 / 诊断扫描
|
|
183
261
|
├── stats.ts 触发统计:会话日志 → 每技能调用次数(可选 sessionQuery)
|
|
184
262
|
├── protocol.ts host ↔ browser 共享 API 契约(类型 + 端点表)
|
|
185
|
-
└── client/ browser 半边:设置卡片 + 技能中枢面板(React,CSS Modules
|
|
263
|
+
└── client/ browser 半边:设置卡片 + 技能中枢面板(React,CSS Modules,苹果风)
|
|
186
264
|
```
|
|
187
265
|
|
|
188
266
|
- **宿主半边** 只用官方 SDK:`ctx.skills.snapshot()/get()`、`ctx.webServer.register()`、
|
|
@@ -206,11 +284,18 @@ dsh plugin --profile web add dsh-skill-hub
|
|
|
206
284
|
|
|
207
285
|
在 dsh Web GUI 打开 **设置 → 技能**(Skill Hub):
|
|
208
286
|
|
|
209
|
-
- **浏览** ——
|
|
287
|
+
- **浏览** —— 完整目录,可搜索;搜索框、来源筛选、平铺/分组视图合并为一行。
|
|
288
|
+
- **分组** —— 用户标签分组与来源组(上游仓库)。分组头部有三态滑动开关(开 / 半开 / 关),关闭时
|
|
289
|
+
若影响在其他分组开启的技能会弹窗确认(全部关闭 / 保留开启)。
|
|
290
|
+
- **市场** —— 内置市场目录(精选仓库一键添加)+ 自定义来源(添加仓库源 → 扫描 → 一键安装)或直接
|
|
291
|
+
输入仓库地址;每次导入都记录上游 repo/commit。每个市场源行显示已装 / 可更新 / 上游已删数量;
|
|
292
|
+
「检查全部」一次刷新所有来源,「全部更新」一次同步所有待更新来源。
|
|
293
|
+
- **回收站** —— 上游删除跟进移除(或手动删除)的技能进入可恢复的回收站;恢复时自动挂回来源与
|
|
294
|
+
场景分组。
|
|
210
295
|
- **开关** —— 启用/禁用任意用户可写根下的技能;被禁用的技能单独列出,可随时重新启用。
|
|
211
296
|
- **诊断** —— 发现诊断解释某个技能为什么没有出现。
|
|
212
297
|
- **新建** —— 从表单脚手架一个新技能,立即开始编写。
|
|
213
|
-
- **统计** —— 有 session-query
|
|
298
|
+
- **统计** —— 有 session-query 数据时显示每个技能的调用次数;分组标题汇总。
|
|
214
299
|
|
|
215
300
|
插件自身的开关在 **设置 → 插件 → Skill Hub** 卡片上:
|
|
216
301
|
|
|
@@ -218,6 +303,10 @@ dsh plugin --profile web add dsh-skill-hub
|
|
|
218
303
|
| --- | --- |
|
|
219
304
|
| Enable plugin | 总开关:路由、provider 与公告随之启用。 |
|
|
220
305
|
| Announce to agent | 在系统提示中加入本插件说明,用户提到技能管理时 Agent 知道如何协作。 |
|
|
306
|
+
| 模型/用户圆点颜色 | 覆盖面板中蓝色/绿色调用圆点的颜色。 |
|
|
307
|
+
| 显示调用次数 | 有会话统计时显示每个技能的调用次数角标。 |
|
|
308
|
+
| 显示最近调用时间 | 在技能行显示相对最近调用时间。 |
|
|
309
|
+
| 显示分组汇总 | 在分组标题后汇总调用次数与最近调用时间。 |
|
|
221
310
|
|
|
222
311
|
## HTTP API
|
|
223
312
|
|
|
@@ -225,31 +314,55 @@ dsh plugin --profile web add dsh-skill-hub
|
|
|
225
314
|
|
|
226
315
|
| 端点 | 方法 | 用途 |
|
|
227
316
|
| --- | --- | --- |
|
|
228
|
-
| `/api/skill-hub/catalog` | GET |
|
|
317
|
+
| `/api/skill-hub/catalog` | GET | 完整目录:技能、禁用列表、发现诊断。 |
|
|
229
318
|
| `/api/skill-hub/skill?name=` | GET | 单个技能详情(路径、provider、正文)。 |
|
|
230
319
|
| `/api/skill-hub/toggle` | POST | 启用/禁用可写技能(`{name, enabled}`)。 |
|
|
320
|
+
| `/api/skill-hub/toggle-batch` | POST | 一次写入整组启停(`{names, enabled}`)。 |
|
|
231
321
|
| `/api/skill-hub/create` | POST | 脚手架新技能(`{name, description?, root?}`)。 |
|
|
232
322
|
| `/api/skill-hub/stats` | GET | 每技能调用次数(无 session-query 时不可用)。 |
|
|
233
|
-
| `/api/skill-hub/config` | GET/POST | 插件运行时配置(`{enabled, announceToAgent}
|
|
323
|
+
| `/api/skill-hub/config` | GET/POST | 插件运行时配置(`{enabled, announceToAgent}` 等);`null` 清除覆盖。 |
|
|
324
|
+
| `/api/skill-hub/groups` | GET | 用户标签 + 来源组 + origin 映射。 |
|
|
325
|
+
| `/api/skill-hub/tag` | POST | 新建/重命名标签分组。 |
|
|
326
|
+
| `/api/skill-hub/tag/delete` | POST | 删除标签分组。 |
|
|
327
|
+
| `/api/skill-hub/tag/members` | POST | 设置某标签的成员列表。 |
|
|
328
|
+
| `/api/skill-hub/market` | GET | 用户的市场源仓库列表。 |
|
|
329
|
+
| `/api/skill-hub/market/source` | POST | 添加市场源(`{repo}`)。 |
|
|
330
|
+
| `/api/skill-hub/market/source/delete` | POST | 移除市场源。 |
|
|
331
|
+
| `/api/skill-hub/repo?repo=` | GET | 发现 GitHub 仓库中可导入的技能。 |
|
|
332
|
+
| `/api/skill-hub/repo/import` | POST | 导入所选仓库技能(记录来源)。 |
|
|
333
|
+
| `/api/skill-hub/sources` | GET | 来源记录、派生 origin/集合、回收站。 |
|
|
334
|
+
| `/api/skill-hub/sources/check` | POST | 检查上游更新(5 分钟节流)。 |
|
|
335
|
+
| `/api/skill-hub/sources/sync` | POST | 同步某来源所选(或全部)技能。 |
|
|
336
|
+
| `/api/skill-hub/sources/delete` | POST | 跟进上游删除(移入回收站)。 |
|
|
337
|
+
| `/api/skill-hub/sources/restore` | POST | 从回收站恢复技能。 |
|
|
338
|
+
| `/api/skill-hub/sources/trash/clear` | POST | 永久清空回收站。 |
|
|
339
|
+
| `/api/skill-hub/update` | GET | 检查插件自身最新发布。 |
|
|
234
340
|
|
|
235
341
|
## 开发
|
|
236
342
|
|
|
237
343
|
```bash
|
|
238
344
|
npm install
|
|
239
345
|
npm run typecheck # tsc --noEmit
|
|
240
|
-
npm test # vitest(
|
|
346
|
+
npm test # vitest(9 个套件,151 个用例)
|
|
241
347
|
npm run build # tsc 声明 + tsdown 双半边产物(lib/index.js + lib/client.js)
|
|
242
348
|
npm pack # 生成可安装的 tgz(dsh-skill-hub-<version>.tgz)
|
|
243
349
|
```
|
|
244
350
|
|
|
351
|
+
> **本地联调注意:** 不要在同一 `$DSH_HOME` 和同一项目目录下同时运行两个
|
|
352
|
+
> `dsh web` 实例。dsh rc.6 没有跨进程会话日志锁,第二个实例恢复同一会话时会
|
|
353
|
+
> 写入重复 `seq`,导致 `corrupt session log: seq gap in committed region`。
|
|
354
|
+
> 需要预览实例时先停旧实例,或使用独立的 `DSH_HOME`。
|
|
355
|
+
|
|
245
356
|
测试套件覆盖路由家族(含 config 路由与禁用闸门)、sidecar 存储、技能文件系统操作、注册表
|
|
246
357
|
provider 与触发统计。
|
|
247
358
|
|
|
248
359
|
## 路线图
|
|
249
360
|
|
|
250
361
|
- **v0.1.0** —— 完整目录、启用/禁用、诊断、新建向导、设置卡片。
|
|
251
|
-
- **v0.2.0** —— 触发统计
|
|
252
|
-
|
|
362
|
+
- **v0.2.0** —— 触发统计 · tag/场景与来源集合分组(三态开关)· 上游来源跟踪(检查 / 同步 /
|
|
363
|
+
跟进删除进回收站)· codex 式市场(内置目录、每源状态徽章、一键全部更新)· 删除→恢复保留
|
|
364
|
+
来源与场景归属。
|
|
365
|
+
- **Next** —— SSE 实时推送替代轮询 · 内置市场扩充 · 自动更新选项。
|
|
253
366
|
|
|
254
367
|
## License
|
|
255
368
|
|