dsh-skills-studio 0.0.0-stage → 0.1.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.
- package/CONTRACT.md +417 -0
- package/LICENSE +21 -0
- package/README.md +195 -2
- package/client.js +3081 -0
- package/cordis.patch.yml +5 -0
- package/icon.svg +18 -0
- package/index.js +68 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +65 -4
- package/src/api.js +1062 -0
- package/src/config.js +221 -0
- package/src/frontmatter.js +419 -0
- package/src/mutate.js +564 -0
- package/src/roots.js +208 -0
- package/src/scan.js +616 -0
- package/src/validate.js +613 -0
package/CONTRACT.md
ADDED
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
# dsh-skills-manager — build contract (v1)
|
|
2
|
+
|
|
3
|
+
A DSH bundle that adds a **Skills** page to Settings: install/edit skills on disk, see
|
|
4
|
+
what agents can actually load, and block conflicting saves before they happen.
|
|
5
|
+
|
|
6
|
+
Read this file before writing code. It is the single source of truth for module boundaries,
|
|
7
|
+
the HTTP contract, conflict rules, and the UI. If you disagree with it, message the Lead
|
|
8
|
+
instead of silently diverging.
|
|
9
|
+
|
|
10
|
+
## Product scope
|
|
11
|
+
|
|
12
|
+
Two surfaces in one section:
|
|
13
|
+
|
|
14
|
+
- **Installed** — every skill discovered in the local DSH skill roots, grouped by root.
|
|
15
|
+
Entries in the writable root are editable/removable; entries in read-only roots are shown
|
|
16
|
+
with a read-only badge.
|
|
17
|
+
- **Available** — (a) skills the live `ctx.skills` registry serves from plugin/bundle
|
|
18
|
+
providers (read-only, "from plugins"), and (b) skills from configured **libraries**
|
|
19
|
+
(skill-pack directories, e.g. the deepseek-stack checkout) which can be **installed** or
|
|
20
|
+
**updated** into the writable root.
|
|
21
|
+
|
|
22
|
+
Add/Edit form writes real `SKILL.md` files, validates the candidate, detects conflicts, and
|
|
23
|
+
persists atomically. After a successful write the host asks `ctx.skills` whether the skill is
|
|
24
|
+
now in the agent catalog (live reload proof) and reports that to the UI.
|
|
25
|
+
|
|
26
|
+
No server-side model calls, no shell execution, no network.
|
|
27
|
+
|
|
28
|
+
## Package layout and ownership
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
dsh-skills-manager/
|
|
32
|
+
package.json Lead
|
|
33
|
+
cordis.patch.yml Lead
|
|
34
|
+
icon.svg Lead
|
|
35
|
+
README.md Lead
|
|
36
|
+
CONTRACT.md Lead
|
|
37
|
+
index.js api-dev plugin entry + webServer registration
|
|
38
|
+
src/config.js api-dev config normalization/defaults
|
|
39
|
+
src/roots.js api-dev root resolution
|
|
40
|
+
src/frontmatter.js api-dev copied parser + serializer (attribution header)
|
|
41
|
+
src/scan.js api-dev root scan, hashes, library scan, status
|
|
42
|
+
src/validate.js api-dev field validation, conflicts, overlap warnings
|
|
43
|
+
src/mutate.js api-dev atomic write/update/delete/install, path safety
|
|
44
|
+
src/api.js api-dev HTTP routing + JSON envelope + registry probe
|
|
45
|
+
test/*.test.js api-dev node --test
|
|
46
|
+
client.js ui-dev settings.section UI (ModuleLoader bundle)
|
|
47
|
+
verify/ verifier independent harness + evidence
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Only edit files in your task's write scope. `client.js` is ui-dev's; `index.js`/`src/` are
|
|
51
|
+
api-dev's. The Lead owns the manifest files and integration.
|
|
52
|
+
|
|
53
|
+
## Runtime facts (verified in the running app, DSH 0.2.1-rc.5)
|
|
54
|
+
|
|
55
|
+
- Settings pages are client plugins registering into the `settings.section` slot.
|
|
56
|
+
- Client module format: `window.__ModuleLoader__.load({ id: '<package name>', factory(require) { … return module.exports } })`,
|
|
57
|
+
module exports `{ name, inject, apply }`. React comes from `require('react')`.
|
|
58
|
+
- Client services: `ctx.get('slots')` (required-ish), `ctx.get('locale')` (optional),
|
|
59
|
+
`ctx.get('sessions')` (optional). Reading a service not listed in `inject` throws, so use
|
|
60
|
+
`ctx.get()` for everything optional and never `ctx.locale` directly.
|
|
61
|
+
- Host web routes: `ctx.webServer.register({ kind: 'prefix', path: '/skills-manager', handler(req, res) })`
|
|
62
|
+
inside `ctx.effect(() => …)`.
|
|
63
|
+
- Host plugin entry: named `export const name`, `export const inject = ['webServer']`,
|
|
64
|
+
`export function apply(ctx, config = {})`. Read optional services with `ctx.get('skills')`.
|
|
65
|
+
- The shipped filesystem skill provider roots/ranks: project `.dsh/skills` (100),
|
|
66
|
+
project `.agents/skills` (200), custom dirs (300), `<dshHome>/skills` (400),
|
|
67
|
+
`<agentsHome>/skills` (500). Bundle = `<root>/<name>/SKILL.md`; flat = `<root>/<name>.md`.
|
|
68
|
+
Only top-level entries are discovered (no recursion).
|
|
69
|
+
- Frontmatter keys: `name` (required, kebab-case), `description` (required),
|
|
70
|
+
`whenToUse`, `disable-model-invocation`, `user-invocable` (YAML booleans). Lower rank wins
|
|
71
|
+
duplicate names. The filesystem provider watches roots and invalidates the registry, so a
|
|
72
|
+
write reaches agents without a restart a moment later.
|
|
73
|
+
- Registry API: `ctx.skills.list({ cwd })` → summaries `{ name, description, provider, path? }`.
|
|
74
|
+
Treat it as optional and defensive; never let it fail a request.
|
|
75
|
+
|
|
76
|
+
`src/frontmatter.js` is a copy of the battle-tested parser from the MIT-licensed
|
|
77
|
+
`dsh-claude-skills` project (`parseFrontmatter`, `parseYamlSubset`, `frontmatterBoolean`,
|
|
78
|
+
`isKebabCase`), with a source header. Add serialization helpers there.
|
|
79
|
+
|
|
80
|
+
## Config (plugin row `config`, all optional)
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
{
|
|
84
|
+
agentsHome: string, // default $DSH_AGENTS_HOME || ~/.agents
|
|
85
|
+
dshHome: string, // default $DSH_HOME || ~/.dsh
|
|
86
|
+
writableRoot: string, // default <agentsHome>/skills
|
|
87
|
+
includeUserDshRoot: true, // scan <dshHome>/skills (read-only)
|
|
88
|
+
includeProjectRoots: true, // only when a cwd is supplied to the API
|
|
89
|
+
customSkillDirs: [], // extra read-only roots, rank 300
|
|
90
|
+
libraries: [ // "Available" installable packs
|
|
91
|
+
// { id: 'deepseek-stack', label: 'deepseek-stack', path: '/abs/path/to/skills' }
|
|
92
|
+
],
|
|
93
|
+
maxSkillBytes: 262144, // instruction file / body cap
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Normalization: reject a non-object config, non-string paths, non-boolean flags, and
|
|
98
|
+
non-array libraries with a thrown `ConfigError` naming the field. Trim paths; expand `~`.
|
|
99
|
+
|
|
100
|
+
Resolved roots (in rank order; stable ids):
|
|
101
|
+
|
|
102
|
+
| id | label | scope | rank | writable |
|
|
103
|
+
|---|---|---|---|---|
|
|
104
|
+
| `project-dsh` | Project (.dsh) | project | 100 | no |
|
|
105
|
+
| `project-agents` | Project (.agents) | project | 200 | no |
|
|
106
|
+
| `custom-<n>` | custom dir basename | custom | 300 | no |
|
|
107
|
+
| `managed` | My skills | managed/read-write | 450 | yes — only when the writable path differs from `<agentsHome>/skills` |
|
|
108
|
+
| `user-dsh` | User (.dsh) | user | 400 | no (skip if `includeUserDshRoot` false) |
|
|
109
|
+
| `user-agents` | User (.agents) | user | 500 | yes when it equals the writable root |
|
|
110
|
+
|
|
111
|
+
Emit only roots that exist OR the writable root (always emit the writable root, `exists:false`
|
|
112
|
+
when missing). Project roots need a `cwd`; without one, skip them.
|
|
113
|
+
|
|
114
|
+
`Root = { id, label, path, scope, rank, writable, exists }`.
|
|
115
|
+
|
|
116
|
+
## HTTP API
|
|
117
|
+
|
|
118
|
+
Prefix `/skills-manager`, JSON only, `cache-control: no-store`, body cap 1 MiB.
|
|
119
|
+
Success envelope `{ ok: true, ... }`. Failure:
|
|
120
|
+
`{ ok: false, error: { code, message, details? } }` with status 400/404/405/413/422/409/500.
|
|
121
|
+
Validation responses additionally carry `{ errors, conflicts, warnings }` (see below).
|
|
122
|
+
|
|
123
|
+
### GET `/skills-manager/api/state?cwd=<abs path>`
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"ok": true,
|
|
128
|
+
"version": 1,
|
|
129
|
+
"generatedAt": "2026-…Z",
|
|
130
|
+
"cwd": "/abs/path or null",
|
|
131
|
+
"roots": [Root],
|
|
132
|
+
"skills": [{
|
|
133
|
+
"id": "<rootId>:<relPath>",
|
|
134
|
+
"name": "ds-mode",
|
|
135
|
+
"description": "…",
|
|
136
|
+
"whenToUse": "…(optional)",
|
|
137
|
+
"modelInvocable": true,
|
|
138
|
+
"userInvocable": true,
|
|
139
|
+
"kind": "bundle" | "flat",
|
|
140
|
+
"rootId": "user-agents",
|
|
141
|
+
"rootLabel": "User (.agents)",
|
|
142
|
+
"scope": "user",
|
|
143
|
+
"rank": 500,
|
|
144
|
+
"path": "/abs/…/SKILL.md",
|
|
145
|
+
"relPath": "ds-mode/SKILL.md",
|
|
146
|
+
"entryName": "ds-mode",
|
|
147
|
+
"writable": true,
|
|
148
|
+
"sha256": "…",
|
|
149
|
+
"size": 1234,
|
|
150
|
+
"updatedAt": "2026-…Z",
|
|
151
|
+
"valid": true,
|
|
152
|
+
"errors": []
|
|
153
|
+
}],
|
|
154
|
+
"libraries": [{
|
|
155
|
+
"id": "deepseek-stack",
|
|
156
|
+
"label": "deepseek-stack",
|
|
157
|
+
"path": "/abs/path",
|
|
158
|
+
"exists": true,
|
|
159
|
+
"kind": "skills",
|
|
160
|
+
"skills": [{
|
|
161
|
+
"name": "ds-plan-loop",
|
|
162
|
+
"description": "…",
|
|
163
|
+
"kind": "bundle" | "flat",
|
|
164
|
+
"relPath": "ds-plan-loop/SKILL.md",
|
|
165
|
+
"sha256": "…",
|
|
166
|
+
"status": "installed" | "update" | "available" | "conflict",
|
|
167
|
+
"installed": { "rootId": "user-agents", "relPath": "…", "sha256": "…" }, // optional
|
|
168
|
+
"conflict": Conflict // optional
|
|
169
|
+
}]
|
|
170
|
+
}],
|
|
171
|
+
"catalog": {
|
|
172
|
+
"available": true,
|
|
173
|
+
"error": null,
|
|
174
|
+
"entries": [{ "name": "mac-design", "description": "…", "provider": "…", "path": "…" }]
|
|
175
|
+
},
|
|
176
|
+
"conflicts": [Conflict],
|
|
177
|
+
"stats": { "skills": 0, "editable": 0, "libraries": 0, "catalog": 0, "conflicts": 0 }
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Invalid skills appear in `skills` with `valid:false` and `errors:[…]`; they are never counted
|
|
182
|
+
as installed for library status, and they never abort the response.
|
|
183
|
+
|
|
184
|
+
### Conflict object
|
|
185
|
+
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"code": "duplicate-name" | "alias-collision" | "overlap",
|
|
189
|
+
"severity": "error" | "warning",
|
|
190
|
+
"name": "ds-mode",
|
|
191
|
+
"message": "Same name in User (.agents) rank 500 and Project (.agents) rank 200; rank 200 wins and shadows the other.",
|
|
192
|
+
"entries": [{ "rootId": "user-agents", "rootLabel": "User (.agents)", "relPath": "ds-mode/SKILL.md", "path": "/abs/…", "rank": 500 }],
|
|
193
|
+
"sharedWords": ["plan", "loop"]
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Rules:
|
|
198
|
+
- `duplicate-name` (error): the same skill name appears in 2+ roots, or twice in one root.
|
|
199
|
+
- `alias-collision` (error): a flat `<name>.md` and a bundle `<name>/` in the same root.
|
|
200
|
+
- `overlap` (warning): description token overlap with another skill. Tokens: lowercase
|
|
201
|
+
alphanumeric words length > 2 minus stop words. Jaccard ≥ 0.5 against another skill →
|
|
202
|
+
warning carrying `sharedWords`. Deduplicate per pair; cap at 5 warnings.
|
|
203
|
+
|
|
204
|
+
### GET `/skills-manager/api/skill?rootId=<id>&relPath=<path>`
|
|
205
|
+
|
|
206
|
+
→ `{ ok: true, root: Root, skill: { …entry, content: "full file text" } }`.
|
|
207
|
+
404 `not-found` when `rootId`/`relPath` does not name a scanned entry.
|
|
208
|
+
|
|
209
|
+
### POST `/skills-manager/api/validate` and `POST /skills-manager/api/save`
|
|
210
|
+
|
|
211
|
+
Body (action `create`):
|
|
212
|
+
|
|
213
|
+
```json
|
|
214
|
+
{ "action": "create", "rootId": "user-agents", "kind": "bundle",
|
|
215
|
+
"name": "my-skill", "description": "…", "whenToUse": "…",
|
|
216
|
+
"modelInvocable": true, "userInvocable": true, "body": "markdown", "force": false }
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Body (action `update`): same plus `"relPath": "my-skill/SKILL.md"` and
|
|
220
|
+
`"expectedSha256": "<sha of the current instruction file>"`; `name` must equal the current
|
|
221
|
+
name (`name-immutable` otherwise); `kind` is derived from the existing entry.
|
|
222
|
+
|
|
223
|
+
`validate` never writes. `save` re-runs the identical validation server-side and writes only
|
|
224
|
+
when there are no `errors` and no `severity:"error"` conflicts (unless `force:true`, which may
|
|
225
|
+
bypass **only** `duplicate-name`/`alias-collision` conflicts, never field errors, stale
|
|
226
|
+
checks, or path problems).
|
|
227
|
+
|
|
228
|
+
Response on validation failure: HTTP 422 (errors) / 409 (blocking conflicts):
|
|
229
|
+
`{ ok:false, errors, conflicts, warnings }`.
|
|
230
|
+
|
|
231
|
+
Response on success:
|
|
232
|
+
|
|
233
|
+
```json
|
|
234
|
+
{ "ok": true,
|
|
235
|
+
"skill": { SkillEntry },
|
|
236
|
+
"registry": { "checked": true, "visible": true, "provider": "filesystem",
|
|
237
|
+
"path": "/abs/…", "catalogCount": 104, "waitedMs": 120 },
|
|
238
|
+
"warnings": [Conflict] }
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
`registry.checked:false` when `ctx.skills` is unavailable; include `reason`.
|
|
242
|
+
Wait up to 2000 ms (poll every 50 ms) for `ctx.skills.list({cwd})` to contain the name after
|
|
243
|
+
create/update; report `visible:false` after the deadline instead of failing the request.
|
|
244
|
+
|
|
245
|
+
Validation rules (produce `errors: [{ field, code, message }]`):
|
|
246
|
+
- `name`: required, `^[a-z0-9]+(?:-[a-z0-9]+)*$`, ≤ 64 chars, not `.`/`..`.
|
|
247
|
+
- `description`: required, trimmed non-empty, ≤ 1024 chars; warning above 300 chars
|
|
248
|
+
(`description-long`) because catalogs cap rendered text.
|
|
249
|
+
- `whenToUse`: optional, ≤ 512 chars.
|
|
250
|
+
- `body`: optional string, ≤ `maxSkillBytes` (utf8 bytes).
|
|
251
|
+
- `rootId`: must exist and be writable.
|
|
252
|
+
- create: computed relPath `<name>/SKILL.md` (bundle) or `<name>.md` (flat); if any entry or
|
|
253
|
+
empty directory already occupies it → `target-exists` (update instead).
|
|
254
|
+
- update: entry must exist in that root, be writable, and sha == `expectedSha256`
|
|
255
|
+
(`stale` otherwise, `not-found` when gone). Never silently overwrite external edits.
|
|
256
|
+
- candidate name equality with any **other** scanned entry → `duplicate-name` conflict (see
|
|
257
|
+
below); if the path is the updated entry itself, ignore.
|
|
258
|
+
|
|
259
|
+
Write format (UTF-8, `\n` endings, mode 0644):
|
|
260
|
+
|
|
261
|
+
```markdown
|
|
262
|
+
---
|
|
263
|
+
name: <name>
|
|
264
|
+
description: <JSON-escaped double-quoted string>
|
|
265
|
+
whenToUse: <quoted> # only when non-empty
|
|
266
|
+
disable-model-invocation: true # only when modelInvocable === false
|
|
267
|
+
user-invocable: false # only when userInvocable === false
|
|
268
|
+
---
|
|
269
|
+
<body trimmed of trailing whitespace>
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### POST `/skills-manager/api/delete`
|
|
273
|
+
|
|
274
|
+
`{ "rootId": "user-agents", "relPath": "my-skill/SKILL.md", "expectedSha256": "…" }`
|
|
275
|
+
→ `{ ok:true, removed: { rootId, relPath, name }, registry: { checked, visible:false, catalogCount, waitedMs } }`.
|
|
276
|
+
Requires a writable root, an existing scanned entry, and a matching sha (`stale`/`not-found`).
|
|
277
|
+
Deleting a bundle removes its own directory; refuse when the resolved path escapes the root,
|
|
278
|
+
is a symlink, or when the bundle directory contains something other than `SKILL.md` and
|
|
279
|
+
regular resource files under the bundle (still allowed: `references/`, `scripts/`, `assets/`,
|
|
280
|
+
any regular files/dirs inside that bundle — just never outside it).
|
|
281
|
+
|
|
282
|
+
### POST `/skills-manager/api/install`
|
|
283
|
+
|
|
284
|
+
`{ "libraryId": "deepseek-stack", "relPath": "ds-plan-loop/SKILL.md", "overwrite": false,
|
|
285
|
+
"expectedSha256": "…", "force": false }`
|
|
286
|
+
|
|
287
|
+
- `available` → copy the library entry into the writable root (bundle dir or flat file).
|
|
288
|
+
- `update` → require `overwrite:true` and `expectedSha256` = sha of the installed instruction
|
|
289
|
+
file; copy over it atomically.
|
|
290
|
+
- `conflict` (same name in a read-only root) → 409 `duplicate-name`; `force:true` may write
|
|
291
|
+
anyway (the UI must state it will be shadowed).
|
|
292
|
+
- `installed` → 409 `already-installed`.
|
|
293
|
+
- Library entries must re-validate against the current filesystem state and the same field
|
|
294
|
+
rules; never trust the state snapshot.
|
|
295
|
+
→ success `{ ok:true, skill: SkillEntry, library: { id, relPath }, registry: {…}, warnings }`.
|
|
296
|
+
|
|
297
|
+
### Path safety (all mutations)
|
|
298
|
+
|
|
299
|
+
- Resolve root path first; resolve target with `path.resolve`; require
|
|
300
|
+
`target === root || target.startsWith(root + path.sep)`. Reject NUL, `..`, absolute
|
|
301
|
+
relPath, and backslashes.
|
|
302
|
+
- `lstat` the containing directory and target; reject symlinks anywhere on the target path
|
|
303
|
+
under the root (walk components with `lstat`).
|
|
304
|
+
- Create parent dirs with `mkdir({recursive:true})` only under the resolved root.
|
|
305
|
+
- Atomic write: temp file `<target>.tmp-<random>` in the same directory, `writeFile` with
|
|
306
|
+
`'wx'`, `rename` over the target; remove the temp on failure. Never write outside the root.
|
|
307
|
+
- Concurrent writes: keep a per-process serialized promise chain for mutations.
|
|
308
|
+
|
|
309
|
+
## Client UI (settings.section)
|
|
310
|
+
|
|
311
|
+
- Register `settings.section` id `skills`, order `40`, label from local dictionary
|
|
312
|
+
("Skills"), locale namespace `settings.skills` when `ctx.get('locale')` exists.
|
|
313
|
+
- `inject = ['slots']`; everything else via `ctx.get()`. Never throw from `apply` or from a
|
|
314
|
+
render when an optional service is missing.
|
|
315
|
+
- Fetch `GET /skills-manager/api/state` on mount, after every mutation, and on manual
|
|
316
|
+
refresh. Same-origin `fetch(url, { credentials: 'same-origin' })`.
|
|
317
|
+
- Layout (translated from the active moodboard language into the DSH settings shell):
|
|
318
|
+
a compact hero row (title from the shell already; use a one-line subtitle), a stat strip
|
|
319
|
+
(installed / available / conflicts), one accent primary button "Add skill", a search
|
|
320
|
+
input, then a segmented control **Installed | Available**. Cards use the host surfaces
|
|
321
|
+
(`--dsw-alias-bg-layer-2`, `--dsw-alias-border-l2`, `--dsw-alias-label-*`,
|
|
322
|
+
`--dsw-alias-interactive-bg-hover`, `--dsw-alias-state-error-primary`,
|
|
323
|
+
`--dsw-alias-state-success-primary`, `--dsw-radius-md`, `--dsw-radius-panel`). Rounded
|
|
324
|
+
cards, generous spacing, one accent for primary actions, tiny eyebrow labels for groups,
|
|
325
|
+
pill buttons for row actions — mirroring the reference card/row rhythm, not its colors.
|
|
326
|
+
- Installed list: groups per root with a tiny eyebrow label + count; each row shows a small
|
|
327
|
+
rounded monogram tile (first letter), name, description (2-line clamp), meta badges
|
|
328
|
+
(bundle/flat, model/user invocation, root, rank), and right-aligned actions:
|
|
329
|
+
Edit / Delete for writable entries, "Read-only" tag otherwise. Search filters name +
|
|
330
|
+
description. Empty state: "No skills found in the scanned roots."
|
|
331
|
+
- Conflicts banner above the list when `conflicts` has entries: error tone for
|
|
332
|
+
duplicate/alias, warning tone for overlap, listing affected names and why. This is the
|
|
333
|
+
"agents cannot find / skills conflict" explanation surface.
|
|
334
|
+
- Available tab: one card per configured library with its skill rows and a status pill:
|
|
335
|
+
Installed / Update / Install. Install calls the API; Update asks for confirmation
|
|
336
|
+
("This replaces the installed copy."), then installs with `overwrite`+expectedSha256.
|
|
337
|
+
Below that, a read-only "From plugins" group lists `catalog.entries` that are not on disk
|
|
338
|
+
(provider shown). Empty state when neither exists: explain how to configure a library path.
|
|
339
|
+
- Add/Edit editor: inline card replacing the list (keeps focus inside the section):
|
|
340
|
+
name (disabled on edit), description textarea, when-to-use (optional), two invocation
|
|
341
|
+
checkboxes (default checked), kind segmented (bundle/flat, create only), root select for
|
|
342
|
+
create (writable roots), body textarea (monospace, min 10 rows), live validation as the
|
|
343
|
+
draft changes (debounce 350 ms → `/validate`), inline field errors, blocking-conflict
|
|
344
|
+
list, warnings list, and a "force save" checkbox that appears only when the blocking
|
|
345
|
+
conflicts are duplicate-name/alias-collision. Save disabled while busy/loading/invalid;
|
|
346
|
+
Cancel returns to the list. On success show a status line "Saved · agents can see it now"
|
|
347
|
+
or a warning when `registry.visible === false`.
|
|
348
|
+
- Delete: inline confirm within the row ("Delete <name>? This removes the file(s)."),
|
|
349
|
+
Delete + Cancel; error is shown inline.
|
|
350
|
+
- Status/announcements: `role="status"`/`aria-live="polite"` for saved/refreshed/errors;
|
|
351
|
+
`role="alert"` for failed actions and conflict banner; every input labelled; focus the
|
|
352
|
+
first field when the editor opens; Escape cancels the editor.
|
|
353
|
+
- All visible strings go through the client dictionaries (`en` and `zh`), including aria
|
|
354
|
+
labels, empty states, status/error messages. No hardcoded English in JSX.
|
|
355
|
+
- Styles: one `<style>` element injected once from `apply` via `ctx.effect`, classes
|
|
356
|
+
prefixed `dsm-`, no global element selectors outside `.dsm-root`; must look correct in
|
|
357
|
+
light and dark theme, keyboard focus visible, no layout shift on hover.
|
|
358
|
+
- Do not import external packages. Do not call the host through `ctx.remote`; plain fetch.
|
|
359
|
+
- Client must degrade cleanly: if `/state` fails, show a retry card with the error message
|
|
360
|
+
(never a blank section). If `props.t` is absent, use the local `en` dictionary.
|
|
361
|
+
|
|
362
|
+
## Tests (api-dev, `node --test`)
|
|
363
|
+
|
|
364
|
+
Cover at minimum:
|
|
365
|
+
- config normalization defaults + rejection cases;
|
|
366
|
+
- root resolution incl. writable-root override, project roots with/without cwd, missing roots;
|
|
367
|
+
- frontmatter parse/serialize round-trip incl. quotes, booleans, whenToUse, empty body;
|
|
368
|
+
- scan: bundle + flat, invalid frontmatter entries reported, sha/size, library status
|
|
369
|
+
installed/update/available/conflict;
|
|
370
|
+
- validate: field errors, target-exists, stale update, name-immutable, duplicate-name
|
|
371
|
+
conflict across roots, force bypass limited to conflicts, overlap warning;
|
|
372
|
+
- mutate: create/update/delete round-trip on tmp dirs; atomic write leaves no temp file;
|
|
373
|
+
stale update rejected; path traversal (`../`, absolute relPath, symlink target) rejected;
|
|
374
|
+
install copies bundle + flat, update requires overwrite+sha, already-installed refused;
|
|
375
|
+
- api: route dispatch with fake req/res (or handler called with mock), JSON envelope,
|
|
376
|
+
method/route/body errors, state payload shape, registry probe with a fake `ctx.skills`
|
|
377
|
+
that eventually returns the new name (visible within timeout) and one that never does
|
|
378
|
+
(visible:false after the deadline — keep the timeout injectable so tests are fast).
|
|
379
|
+
|
|
380
|
+
Tests must not touch `~/.agents` or the real profile; everything under `os.tmpdir()`.
|
|
381
|
+
|
|
382
|
+
## Definition of done
|
|
383
|
+
|
|
384
|
+
- `node --test` green (no deps installed), `node --check index.js client.js`.
|
|
385
|
+
- No writes outside the configured writable root; no secrets/log spam.
|
|
386
|
+
- UI renders from the real host state in a scratch DSH web instance and in the installed
|
|
387
|
+
desktop profile; add/edit/delete/install round-trip verified through the UI.
|
|
388
|
+
- Deepseek-stack skills (29 bundles + 6 alias files) appear under Installed with correct
|
|
389
|
+
names/roots, and library rows show Installed; a conflict attempt is blocked before save.
|
|
390
|
+
- Agents can find a newly added skill: `registry.visible === true` and the catalog count
|
|
391
|
+
grows; the verifier records the evidence.
|
|
392
|
+
|
|
393
|
+
## Post-build deltas (implemented and independently verified)
|
|
394
|
+
|
|
395
|
+
These refine the sections above; the shipped behavior is authoritative and matches
|
|
396
|
+
`SKILLS-VERIFICATION.md`.
|
|
397
|
+
|
|
398
|
+
- `POST /validate` returns **HTTP 200** with `{ ok:false, valid:false, errors, conflicts,
|
|
399
|
+
warnings }` for a well-formed but invalid draft. 4xx stays reserved for malformed requests
|
|
400
|
+
(bad JSON, missing/wrong action, invalid cwd, oversized body). `/save`, `/delete`,
|
|
401
|
+
`/install` keep 422/409/404/413 semantics.
|
|
402
|
+
- The registry probe is three-state: `{checked:true, visible:true}`, `{checked:true,
|
|
403
|
+
visible:false}` after the poll deadline in an observable view, and `{checked:false,
|
|
404
|
+
reason}` when the host-scope `ctx.skills.list()` cannot see the per-session providers that
|
|
405
|
+
serve the scanned roots (the real desktop composition). Coverage is decided by the
|
|
406
|
+
instruction-file `path` each listing entry publishes: it must be inside a scanned root;
|
|
407
|
+
providers that publish no path fall back to a `filesystem`-provider name overlap.
|
|
408
|
+
`state.catalog.coversLocalRoots` exposes the same decision.
|
|
409
|
+
- Plugin-provided catalog entries in `state.catalog.entries` are always shown in the client's
|
|
410
|
+
"From plugins" group, even when `coversLocalRoots` is false; in that case one explanatory
|
|
411
|
+
note is appended instead of hiding the entries.
|
|
412
|
+
- The description warning fires above **500** characters (code `description-truncated`,
|
|
413
|
+
matching the agent catalog's render cap), not 300.
|
|
414
|
+
- A byte-identical copy of a library skill in a read-only root counts as `installed` for that
|
|
415
|
+
library entry; a differing copy reports `conflict` with the shadowing explanation.
|
|
416
|
+
- The extra writable root created when `writableRoot` differs from `<agentsHome>/skills` uses
|
|
417
|
+
`scope: "managed"` and the label "My skills".
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Stijnus
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,196 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-skills-manager
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/Stijnus/dsh-skills-manager/actions/workflows/test.yml) [](https://www.npmjs.com/package/dsh-skills-studio)
|
|
4
|
+
|
|
5
|
+
A **Skills** page for DeepSeek Harness Settings: see every installed agent skill, see what
|
|
6
|
+
the registry actually serves to agents, add or edit skills on disk, and block conflicting
|
|
7
|
+
saves before they happen.
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
## What it adds
|
|
12
|
+
|
|
13
|
+
- **Installed** — every skill discovered in the local DSH skill roots, grouped per root:
|
|
14
|
+
project `.dsh/skills` / `.agents/skills`, custom dirs, `~/.dsh/skills`, `~/.agents/skills`.
|
|
15
|
+
Rows show name, description, bundle vs flat, invocation flags, rank and shadowing; entries
|
|
16
|
+
in the writable root (`~/.agents/skills` by default) have **Edit** and **Delete**.
|
|
17
|
+
- **Available** — skills from configured skill-pack **libraries** (Install / Update /
|
|
18
|
+
Installed), plus read-only skills that plugin bundles contribute to the live registry
|
|
19
|
+
("From plugins").
|
|
20
|
+
- **Add / Edit** — a real form (name, description, when-to-use, invocation flags, body) that
|
|
21
|
+
writes `<root>/<name>/SKILL.md` or `<root>/<name>.md` atomically, with optimistic
|
|
22
|
+
concurrency (`expectedSha256`) so an external edit is never silently overwritten.
|
|
23
|
+
- **Conflicts before save** — duplicate names across roots, flat-vs-bundle alias collisions
|
|
24
|
+
and description-trigger overlap are detected *before* writing; blocking conflicts return
|
|
25
|
+
409 and the UI explains why. "Force save" is offered only for name shadowing, never for
|
|
26
|
+
invalid fields or stale files.
|
|
27
|
+
- **Live proof agents can see it** — after every mutation the host asks `ctx.skills` what the
|
|
28
|
+
registry serves and reports a three-state result: `visible: true` ("Saved · agents can see
|
|
29
|
+
it now"), `visible: false` while a polling deadline is missed, or `checked: false` when the
|
|
30
|
+
host-scope registry view cannot see the per-session filesystem provider at all (the real
|
|
31
|
+
desktop composition). In the last case the UI says the host cannot verify the session
|
|
32
|
+
catalog from here instead of claiming a false negative; the shipped filesystem provider
|
|
33
|
+
watches the written root and surfaces the change to agents on their next step.
|
|
34
|
+
|
|
35
|
+
No model calls, no network, no shell. File writes are restricted to the configured writable
|
|
36
|
+
root, with path/symlink containment and 256 KiB skill / 1 MiB request caps.
|
|
37
|
+
|
|
38
|
+
## Screenshots
|
|
39
|
+
|
|
40
|
+
All captures come from an isolated scratch DSH 0.2.1-rc.5 instance with a copy of the 49-entry
|
|
41
|
+
user skill root plus the deepseek-stack libraries; the app's theme is the only difference in
|
|
42
|
+
the dark frame. Image files live in [`verify/screenshots/`](verify/screenshots/).
|
|
43
|
+
|
|
44
|
+
| Light | Dark |
|
|
45
|
+
|---|---|
|
|
46
|
+
|  |  |
|
|
47
|
+
|
|
48
|
+
| Available tab (libraries + "From plugins") | Add / edit editor with live validation |
|
|
49
|
+
|---|---|
|
|
50
|
+
|  |  |
|
|
51
|
+
|
|
52
|
+
| Duplicate name blocked before saving | Host-scope catalog note (desktop topology) |
|
|
53
|
+
|---|---|
|
|
54
|
+
|  |  |
|
|
55
|
+
|
|
56
|
+
More verification images (saved state, delete confirmation, dark Available tab) are in the same
|
|
57
|
+
directory; the raw evidence and harnesses are described in
|
|
58
|
+
[`SKILLS-VERIFICATION.md`](SKILLS-VERIFICATION.md).
|
|
59
|
+
|
|
60
|
+
## Install
|
|
61
|
+
|
|
62
|
+
### From npm (registry)
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# latest release
|
|
66
|
+
dsh plugin --profile <profile> add dsh-skills-studio
|
|
67
|
+
|
|
68
|
+
# pin a version
|
|
69
|
+
dsh plugin --profile <profile> add dsh-skills-studio@0.1.2
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The project is called **dsh-skills-manager**, but its npm package is **`dsh-skills-studio`**:
|
|
73
|
+
the unscoped `dsh-skills-manager` name belongs to an unrelated third-party plugin, and the
|
|
74
|
+
previous `@stijnus/...` scope has been retired. GitHub and local-link installs remain
|
|
75
|
+
available below.
|
|
76
|
+
|
|
77
|
+
### Local development (web profile, isolated)
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
git clone https://github.com/Stijnus/dsh-skills-manager.git
|
|
81
|
+
cd dsh-skills-manager
|
|
82
|
+
DSH_HOME=/tmp/dsh-skills-dev dsh plugin --profile web add link:$PWD
|
|
83
|
+
DSH_HOME=/tmp/dsh-skills-dev dsh --profile web --port 53999 --no-open
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Or install straight from this repository into an existing profile:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# latest main
|
|
90
|
+
dsh plugin --profile <profile> add github:Stijnus/dsh-skills-manager
|
|
91
|
+
|
|
92
|
+
# pin a released version (recommended for stable installs) — see the Releases page
|
|
93
|
+
dsh plugin --profile <profile> add github:Stijnus/dsh-skills-manager#v0.1.2
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Releases are tagged `vX.Y.Z` ([Releases](https://github.com/Stijnus/dsh-skills-manager/releases)). To upgrade, install the newer tag the same way; a profile reload applies it (HMR picks it up when enabled).
|
|
97
|
+
|
|
98
|
+
> **npm name note:** the package is published as `dsh-skills-studio` because the plain
|
|
99
|
+
> `dsh-skills-manager` name on npm belongs to an unrelated third-party plugin. The GitHub/link
|
|
100
|
+
> forms above are fallbacks for development checkouts.
|
|
101
|
+
|
|
102
|
+
Overlay config for an isolated run (agents home, writable root and libraries):
|
|
103
|
+
|
|
104
|
+
```yaml
|
|
105
|
+
# skills-manager.overlay.yml — pass with --patch
|
|
106
|
+
- id: skills-manager
|
|
107
|
+
config:
|
|
108
|
+
agentsHome: /tmp/dsh-skills-dev/agents
|
|
109
|
+
writableRoot: /tmp/dsh-skills-dev/managed-skills
|
|
110
|
+
libraries:
|
|
111
|
+
- id: deepseek-stack
|
|
112
|
+
label: deepseek-stack
|
|
113
|
+
path: /absolute/path/to/ds-stack/skills
|
|
114
|
+
- id: deepseek-stack-aliases
|
|
115
|
+
label: deepseek-stack aliases
|
|
116
|
+
path: /absolute/path/to/ds-stack/aliases
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Desktop app
|
|
120
|
+
|
|
121
|
+
Use **Settings → Plugins → install bundle** with this directory as the target (the Desktop
|
|
122
|
+
shell performs the package operation and recomposes the app). After installation the
|
|
123
|
+
**Skills** section appears in Settings immediately; a restart is only needed if the shell
|
|
124
|
+
reports `restart-required`.
|
|
125
|
+
|
|
126
|
+
The current live install on this machine uses the hand-managed profile path instead: a
|
|
127
|
+
`node_modules/dsh-skills-manager` symlink plus a profile-patch row (see
|
|
128
|
+
[SKILLS-VERIFICATION.md](SKILLS-VERIFICATION.md) §4). DSH's profile HMR loads both halves
|
|
129
|
+
into the running app without a restart. Durability caveat: because the profile
|
|
130
|
+
`package.json` does not declare the package, a later plugin-manager / pnpm operation can
|
|
131
|
+
prune the symlink; re-run the desktop plugin install (or add the `link:` dependency) after
|
|
132
|
+
such an operation. The profile patch keeps the row, so a restart with the symlink restored
|
|
133
|
+
brings the section back.
|
|
134
|
+
|
|
135
|
+
## Configuration
|
|
136
|
+
|
|
137
|
+
All fields optional. Config is validated at apply time; a malformed value throws instead of
|
|
138
|
+
silently defaulting.
|
|
139
|
+
|
|
140
|
+
| Field | Default | Meaning |
|
|
141
|
+
|---|---|---|
|
|
142
|
+
| `agentsHome` | `$DSH_AGENTS_HOME` or `~/.agents` | User agent config root; `skills/` is the writable root by default |
|
|
143
|
+
| `dshHome` | `$DSH_HOME` or `~/.dsh` | Harness config root; its `skills/` is scanned read-only |
|
|
144
|
+
| `writableRoot` | `<agentsHome>/skills` | The only root this plugin may write to |
|
|
145
|
+
| `includeUserDshRoot` | `true` | Scan `<dshHome>/skills` |
|
|
146
|
+
| `includeProjectRoots` | `true` | Scan project roots when the API call supplies `cwd` |
|
|
147
|
+
| `customSkillDirs` | `[]` | Extra read-only skill roots (rank 300) |
|
|
148
|
+
| `libraries` | `[]` | Installable skill packs: `{ id?, label?, path }` |
|
|
149
|
+
| `maxSkillBytes` | `262144` | Instruction-file / body size cap |
|
|
150
|
+
|
|
151
|
+
Deepseek-stack note: `libraries` pointing at `ds-stack/skills` and `ds-stack/aliases` makes
|
|
152
|
+
the 29 bundle skills and 6 gesture aliases visible in Available, with Installed/Update status
|
|
153
|
+
computed against the writable root. Because the aliases are flat files, install them as a
|
|
154
|
+
separate library entry.
|
|
155
|
+
|
|
156
|
+
## HTTP API (host half, same origin)
|
|
157
|
+
|
|
158
|
+
Prefix `/skills-manager/api`, JSON, `cache-control: no-store`.
|
|
159
|
+
|
|
160
|
+
| Method + path | Purpose |
|
|
161
|
+
|---|---|
|
|
162
|
+
| `GET /state?cwd=` | roots, installed skills, libraries with installed/update/available status, live registry catalog, conflicts, stats |
|
|
163
|
+
| `GET /skill?rootId=&relPath=` | one skill with its full instruction text |
|
|
164
|
+
| `POST /validate` | dry-run field validation + conflicts/warnings for a create/update draft |
|
|
165
|
+
| `POST /save` | create/update (atomic write, optimistic sha, registry visibility probe) |
|
|
166
|
+
| `POST /delete` | remove an entry from a writable root (expected sha required) |
|
|
167
|
+
| `POST /install` | copy a library skill into the writable root (update requires overwrite + expected sha) |
|
|
168
|
+
| `GET /health` | liveness + resolved roots |
|
|
169
|
+
|
|
170
|
+
The full request/response contract, conflict rules and write format are in
|
|
171
|
+
[`CONTRACT.md`](CONTRACT.md).
|
|
172
|
+
|
|
173
|
+
## Verification
|
|
174
|
+
|
|
175
|
+
- Host logic: `node --test` → 105 tests, no dependencies, temp dirs only.
|
|
176
|
+
- Independent end-to-end verification: 61/61 host API assertions against a real scratch DSH
|
|
177
|
+
instance, 28/28 real-browser GUI assertions (add/edit/delete/install, duplicate blocked
|
|
178
|
+
before save, a11y, light+dark), desktop delivery proven live (HMR, no restart), and the
|
|
179
|
+
49-entry installed-skills invariant re-audited: [`SKILLS-VERIFICATION.md`](SKILLS-VERIFICATION.md).
|
|
180
|
+
- Baseline audit of the installed skill roots and the deepseek-stack pack:
|
|
181
|
+
[`SKILLS-AUDIT.md`](SKILLS-AUDIT.md).
|
|
182
|
+
|
|
183
|
+
## Known limitations
|
|
184
|
+
|
|
185
|
+
- Discovery is one level deep per root, matching the shipped filesystem provider
|
|
186
|
+
(`<root>/<name>/SKILL.md`, `<root>/<name>.md`); nested skill trees are not discovered.
|
|
187
|
+
- Project roots need a `cwd`: the page forwards one when the client's optional `sessions`
|
|
188
|
+
service exposes a session workspace, and otherwise shows the user-scope roots it can resolve
|
|
189
|
+
on its own. Root discovery itself is one level deep, matching the shipped provider.
|
|
190
|
+
- The registry visibility probe reports what the host-scope `ctx.skills` view serves. In the
|
|
191
|
+
real desktop composition the local filesystem provider lives in the per-session agent preset
|
|
192
|
+
layer, so the probe truthfully returns `checked:false` and the UI says the session catalog
|
|
193
|
+
cannot be verified from here; the provider's watcher still surfaces the change to agents on
|
|
194
|
+
their next step. A provider that never watches its root would need its own invalidation.
|
|
195
|
+
- The plugin never edits files it does not own: deletions are limited to scanned entries
|
|
196
|
+
under the writable root and require the exact sha256 the UI read.
|