dsh-hive-panel 0.1.3 → 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/CHANGELOG.md CHANGED
@@ -1,9 +1,48 @@
1
+ ## [0.1.5] - 2026-12-04
2
+
3
+ ### Added
4
+
5
+ - A roles snapshot view and the roles-add action (including an optional role description);
6
+ card removal is now part of the allowlisted action catalog.
7
+ - Card details open in a centered modal, the new-task form keeps its values on validation
8
+ errors, and the task cap is labelled "Max tasks".
9
+ - The panel mirrors the standalone board: inlined supervisor, settings gear in the toolbar,
10
+ pause as a toolbar action, simplified menu and unified icons.
11
+
12
+ ### Fixed
13
+
14
+ - Settings action button alignment.
15
+ - 25 checks now cover the roles snapshot view, roles-add and the remove allowlist.
16
+
17
+ ## [Unreleased]
18
+
19
+ ### Added
20
+
21
+ - `remove` panel action: deletes a task card through `hive tasks rm <id>` (the hive
22
+ router forwards `tasks` to hive-tasks) with a strict lowercase card-id check
23
+ (`^[a-z0-9][a-z0-9-]{1,63}$`) and no `--force`. The CLI stderr reaches the panel
24
+ unchanged: a claimed card's refusal, and a second delete's "not found", both keep
25
+ `ok:false, code:2` plus that stderr. The shared renderer's drawer exposes the action
26
+ as a red button with a second confirmation. `lib/client.js` rebuilt.
27
+
28
+ ## [0.1.4] - 2026-12-04
29
+
30
+ ### Changed
31
+
32
+ - The queen notice can be dismissed permanently per repository (kept in the browser's
33
+ localStorage); the notice no longer carries a `/queen off` button, and the exit
34
+ instructions moved into the view's `...` menu. Browser bundle rebuilt.
35
+
1
36
  # Changelog
2
37
 
3
38
  All notable changes to this project are documented in this file. The format is
4
39
  based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project
5
40
  adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
41
 
42
+ ### Published
43
+
44
+ - npm: `dsh-hive-panel@0.1.4` on 2026-12-04.
45
+
7
46
  ## [0.1.3] - 2026-12-04
8
47
 
9
48
  ### Fixed
@@ -11,6 +50,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
11
50
  - Chinese terminology synced with the final standalone-panel wording: agents are 智能体,
12
51
  workers are Agent in English; queen stays 女王. Browser bundle rebuilt.
13
52
 
53
+ ### Published
54
+
55
+ - npm: `dsh-hive-panel@0.1.3` on 2026-12-04.
56
+
14
57
  ## [0.1.2] - 2026-12-04
15
58
 
16
59
  ### Fixed
@@ -18,6 +61,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
18
61
  - Chinese terminology: the queen is labelled 女王 again and worker labels stay 工蜂;
19
62
  the browser bundle was rebuilt so the tab matches the standalone panel wording.
20
63
 
64
+ ### Published
65
+
66
+ - npm: `dsh-hive-panel@0.1.2` on 2026-12-04.
67
+
21
68
  ## [0.1.1] - 2026-12-04
22
69
 
23
70
  ### Added
package/SPEC.md CHANGED
@@ -85,7 +85,14 @@ these top-level fields:
85
85
  "stats": {},
86
86
  "events": [],
87
87
  "writable": false,
88
- "queen": { "active": true, "source": "auto", "repo": "/abs/repo" }
88
+ "queen": { "active": true, "source": "auto", "repo": "/abs/repo" },
89
+ "roles": {
90
+ "list": [
91
+ { "name": "coder", "adapter": null, "model": null, "prompt": ".hive/roles/coder.md", "promptExists": true, "limit": 2 }
92
+ ],
93
+ "limits": { "coder": 2 },
94
+ "error": null
95
+ }
89
96
  }
90
97
  ```
91
98
 
@@ -97,8 +104,17 @@ these top-level fields:
97
104
  `source` is `"auto"` (snapshot auto-activation), `"manual"` (`init`, `queen-on`,
98
105
  `/queen on`) or `null` (inactive), and `repo` repeats the resolved Session cwd.
99
106
  The field is always present on a `200` snapshot.
107
+ - `roles` — the settings roles view. `list` is `hive roles list --json` normalized to
108
+ `{ name, adapter: string|null, model: string|null, prompt: string|null,
109
+ promptExists: boolean, limit: number|null }`; `limits` is the persisted
110
+ `<cwd>/.hive/limits.json` map (`role -> 0..999`); `error` is `null` or a
111
+ diagnostic string (CLI failure, malformed roles output, malformed limits file).
112
+ `limit` is `null` when the file has no entry — effective limits (config fallback,
113
+ runtime counts) are exposed by the hive-runner supervisor status endpoint instead.
114
+ A successful `roles-add` shows up here on the next poll.
100
115
  - An uninitialised repository returns the same shape with empty reads after only the
101
- refs probe; `queen` may still be active there after an explicit activation.
116
+ refs probe; `roles` is then `{ list: [], limits: {}, error: null }`; `queen` may
117
+ still be active there after an explicit activation.
102
118
 
103
119
  ## 5. Action envelope
104
120
 
@@ -119,7 +135,58 @@ these top-level fields:
119
135
  ## 6. Action catalog
120
136
 
121
137
  Actions: `init add plan claim done fail retry block renew mode learn recall verdict run
122
- commit doctor` plus the host-memory actions `queen-on` and `queen-off`.
138
+ commit doctor roles-add remove` plus the host-memory actions `queen-on` and `queen-off`.
139
+
140
+ ### 6.1 `roles-add`
141
+
142
+ `POST ?op=action&name=roles-add&sessionId=<id>` with JSON body:
143
+
144
+ ```json
145
+ { "name": "reviewer", "adapter": "claude", "model": "claude-x", "description": "Reviews pull requests" }
146
+ ```
147
+
148
+ Maps to `hive roles add <name> [--adapter <adapter>] [--model <model>]
149
+ [--description <text>]` in the Session cwd through the shell seam (argv tokens,
150
+ single-quoted; no shell interpolation).
151
+
152
+ - `name` (required) — `^[a-z][a-z0-9-]{1,31}$` (2–32 chars).
153
+ - `adapter` (optional) — one of `dsh`, `claude`, `codex`; omitted keeps the CLI
154
+ default (`dsh`).
155
+ - `model` (optional) — `^[A-Za-z0-9._:-]{1,64}$`.
156
+ - `description` (optional) — free-form responsibility text, at most **2000**
157
+ characters; `""`, `null` and an omitted field all mean "not provided" and emit no
158
+ `--description` token. Longer values or non-strings are rejected with `400`
159
+ `hive/invalid-argument`. When present it is passed as one argv token, so spaces,
160
+ quotes and hyphens are preserved literally (the hive CLI trims it and writes it under
161
+ `## Contract` in `.hive/roles/<name>.md`; an empty `--description` would itself be a
162
+ CLI error, which is why the host omits the flag instead).
163
+ - `--force` is never sent: an existing role makes the CLI exit `2` with
164
+ `role "<name>" already exists; use --force to update it` on stderr, which the action
165
+ envelope returns unchanged (`ok:false`, `code:2`, that stderr).
166
+ - Success: `200 { ok:true, code:0, stdout:"added role …\nwrote .hive/roles/<name>.md\n",
167
+ stderr:"" }`; the new role appears under snapshot `roles.list` on the next poll.
168
+ Mutating action: requires `writable: true`, otherwise `403` read-only.
169
+
170
+ ### 6.2 `remove`
171
+
172
+ `POST ?op=action&name=remove&sessionId=<id>` with JSON body:
173
+
174
+ ```json
175
+ { "id": "auth-takes-an-object-dea2" }
176
+ ```
177
+
178
+ Maps to `hive tasks rm <id>` in the Session cwd: the `hive` router forwards `tasks` to
179
+ hive-tasks (`bin: 'hive'`, argv `['tasks', 'rm', <id>]`), through the same shell seam.
180
+
181
+ - `id` (required) — `^[a-z0-9][a-z0-9-]{1,63}$`. The rule is deliberately stricter than
182
+ the general card id space (`ID_RE`) because this action is destructive.
183
+ - `--force` is never sent. A claimed card is refused by the CLI (exit `2`, stderr
184
+ `task … is claimed by …; release or reopen it first, or use --force`), and the CLI
185
+ stderr reaches the panel unchanged as `ok:false, code:2`. A second delete reports
186
+ `no such task` the same way: the action never silently succeeds twice.
187
+ - Success: `200 { ok:true, code:0, stdout:"<id> deleted [<state>] <title>\n", stderr:"" }`.
188
+ The card disappears from the next snapshot poll. Mutating action: requires
189
+ `writable: true`, otherwise `403` read-only.
123
190
 
124
191
  For every action the host builds one fixed command template. Each argument field is
125
192
  validated (id, agent, ttl, sha, ref mode, integer ranges, string length, NUL) and every
package/docs/DESIGN.md CHANGED
@@ -158,7 +158,7 @@ interface ConnectionFetchRoute {
158
158
 
159
159
  | 请求 | 响应 |
160
160
  | --- | --- |
161
- | `GET /api/hive?op=snapshot&sessionId=<id>` | 快照 JSON,字段固定 `{ at, repo, initialised, mode, board, tasks, stats, events, writable, queen }` |
161
+ | `GET /api/hive?op=snapshot&sessionId=<id>` | 快照 JSON,字段固定 `{ at, repo, initialised, mode, board, tasks, stats, events, writable, queen, roles }` |
162
162
  | `GET /api/hive?op=actions&sessionId=<id>` | `{ writable, autoQueen, actions: string[], repo }` |
163
163
  | `POST /api/hive?op=action&name=<name>&sessionId=<id>`(JSON body) | 动作结果 `{ ok, code, stdout, stderr }` |
164
164
  | 未知 `op` | `400 { ok:false, error:{ code:'hive/unknown-op', message } }` |
@@ -170,6 +170,12 @@ interface ConnectionFetchRoute {
170
170
  每次 `op=snapshot` 在返回前按 §6 做一次自动激活检查。
171
171
  - 动作失败时 `code` 为 `2`,`stderr` 以稳定前缀 `hive/<code>: ` 开头(如
172
172
  `hive/session-unknown: …`、`hive/unknown-action: …`);CLI 非 0 退出则沿用退出码。
173
+ - 快照里的 `roles` 是设置页角色视图的数据源:
174
+ `{ list: [{ name, adapter, model, prompt, promptExists, limit }], limits, error }`。
175
+ `list` 来自固定命令 `hive roles list --json`(只列已初始化仓库),`limits` 来自
176
+ `<cwd>/.hive/limits.json`(0..999 的 `role -> n`),`limit` 为空表示该文件没有条目;
177
+ **effective** 限额(config 兜底、运行时队列)由 hive-runner 的 `/api/hive-runner?op=status` 提供。
178
+ `roles-add` 成功后下一次轮询即可看到新角色,无需额外刷新接口。
173
179
  - 事件历史从 `<cwd>/.hive/events.jsonl` 读最近 80 条,倒序返回(沿用原 `hive-panel/src/data.js` 的语义)。
174
180
 
175
181
  ### 4.3 认证边界
@@ -214,9 +220,9 @@ child_process 会绕过 Session sandbox mode、凭证擦除、超时/输出上
214
220
 
215
221
  | 用途 | 固定命令 |
216
222
  | --- | --- |
217
- | 快照 | `hive board --json`、`hive-tasks list --json`、`hive-tasks stats --json` |
223
+ | 快照 | `hive board --json`、`hive-tasks list --json`、`hive-tasks stats --json`、`hive roles list --json` |
218
224
  | 快照探针 | `git for-each-ref --format=%(refname) refs/hive/v1`、`git cat-file -p refs/hive/v1/mode` |
219
- | 动作 | `init add plan claim done fail retry block renew mode learn recall verdict run commit doctor` |
225
+ | 动作 | `init add plan claim done fail retry block renew mode learn recall verdict run commit doctor roles-add` |
220
226
 
221
227
  动作表沿用 `hive-panel/src/actions.js` 的 argv 构造;每个字段先校验(id/agent/ttl/sha/mode/整数范围/
222
228
  字符串长度/NUL),再作为独立 argv token 用单引号严格转义:
@@ -230,6 +236,14 @@ command = [bin, ...argv].map(quote).join(' ')
230
236
  不会变成 shell 语法。`bins`(hive/hive-tasks/hive-run/moc)只能来自受信 host 配置,必须是单个可执行
231
237
  token(PATH 名或绝对路径)。
232
238
 
239
+ `roles-add` 是唯一新增的角色写动作:body `{ name, adapter?, model?, description? }` 映射为
240
+ `hive roles add <name> [--adapter dsh|claude|codex] [--model M] [--description TEXT]`;`name` 必须匹配
241
+ `^[a-z][a-z0-9-]{1,31}$`,`adapter` 只允许 `dsh|claude|codex`,`model` 只允许
242
+ `[A-Za-z0-9._:-]{1,64}`,`description` 是可选自由文本(≤2000 字符;`""`/`null`/省略都等价于
243
+ 不传,因此不会生成空的 `--description` token;CLI 会把它写进 `.hive/roles/<name>.md` 的
244
+ `## Contract` 段)。绝不发送 `--force`:已存在的角色由 CLI 以退出码 2 + stderr 返回,
245
+ 动作信封原样带回(`ok:false, code:2, stderr:"hive roles: role \"name\" already exists; …"`)。
246
+
233
247
  ### 5.4 权限与审计(明确取舍)
234
248
 
235
249
  - 有:Session sandbox policy(read-only 会话里的写命令会被沙箱拒绝,`result.sandbox.denied` 可在结果里
@@ -322,13 +336,14 @@ npm run check
322
336
  # ok - node --check lib/queen.js
323
337
  # ok - node --check lib/client.js
324
338
  # ...
325
- # 22 checks passed
339
+ # 24 checks passed
326
340
  ```
327
341
 
328
342
  覆盖:语法、package/bundle 声明、无代理残留、client bundle 的 `/api/hive` URL 与 Session 注入、
329
343
  Connection Fetch 路由注册、快照走 `ctx.shell` 且 cwd/policy 正确、冷会话 cwd、未知 op/会话 400、
330
344
  只读语义、动作参数校验与 argv 转义、失败信封、无 `ctx.shell` 拒绝挂载、女王激活/隔离/退出/截断,
331
- 以及 snapshot 自动激活、显式关闭后的抑制、`queen-off` 幂等、`autoQueen=false` 与手动 `queen-on`。
345
+ 以及 snapshot 自动激活、显式关闭后的抑制、`queen-off` 幂等、`autoQueen=false` 与手动 `queen-on`、
346
+ `roles` 快照(角色列表 + 持久限额)、`roles-add` 的参数校验/argv/仓库 cwd、重复角色的 CLI stderr 透传。
332
347
 
333
348
  不启动、不重启任何 DSH 进程,也不写运行中的 `~/.dsh`。
334
349