dsh-hive-panel 0.0.0-stage → 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file. The format is
4
+ based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project
5
+ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.1.0] - 2026-12-04
8
+
9
+ First public snapshot.
10
+
11
+ ### Added
12
+
13
+ - A Hive (蜂群) conversation view in DSH Web, scoped to the current Session: board
14
+ lanes, card details, event tail, per-role supervisor strip and Hive initialisation.
15
+ - A host half that resolves the Session working directory and reads Hive state
16
+ through DSH's shell seam; no separate port, proxy or dashboard service.
17
+ - An allowlisted action catalog (init, add, plan, claim, done, fail, retry, block,
18
+ renew, mode, learn, recall, verdict, run, commit, doctor) with per-field argument
19
+ validation and single-token quoting. Read-only by default (`writable: false`).
20
+ - Queen mode: a successful initialisation marks the calling Session as queen, injects
21
+ `<repo>/.hive/roles/queen.md` as a system-prompt section for that Session only
22
+ (capped at 4096 characters) and is exited with `/queen off`.
23
+ - Offline verification (`npm run check`) with a Cordis-shaped shim: route
24
+ registration, Session cwd, sandbox policy, allowlist and quoting, read-only
25
+ semantics, response contracts, cold Sessions and the queen lifecycle.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tommy
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,247 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # dsh-hive-panel
4
+
5
+ **English** · [简体中文](README.zh-CN.md)
6
+
7
+ **A Hive board and a queen inside DSH Web.** One conversation view that reads the Hive
8
+ state of the Session's repository, initialises it, and turns a goal into task cards.
9
+
10
+ [![CI](https://img.shields.io/github/actions/workflow/status/d86e/dsh-hive-panel/ci.yml?style=for-the-badge&logo=github)](https://github.com/d86e/dsh-hive-panel/actions)
11
+ [![npm](https://img.shields.io/npm/v/dsh-hive-panel?style=for-the-badge&logo=npm&color=cb3837)](https://www.npmjs.com/package/dsh-hive-panel)
12
+ [![License](https://img.shields.io/badge/license-MIT-yellow?style=for-the-badge)](LICENSE)
13
+ [![Node](https://img.shields.io/badge/node-%3E%3D22.19-brightgreen?style=for-the-badge&logo=node.js)](https://nodejs.org)
14
+
15
+ </div>
16
+
17
+ ---
18
+
19
+ [Hive](https://github.com/d86e/hive) coordinates a swarm of coding agents inside git: task
20
+ cards, path leases, a presence board and a commit-time merge, all as refs and files in the
21
+ repository itself. **dsh-hive-panel** brings that state into DSH Web as one conversation
22
+ view, so you can watch the board, plan with a queen and act on cards without leaving the
23
+ Session.
24
+
25
+ Two halves install together:
26
+
27
+ - a **host half** inside the DSH process, which resolves the current Session's repository,
28
+ reads Hive state and runs a fixed catalog of Hive commands through DSH's own shell seam;
29
+ - a **browser half** that adds the Hive (蜂群) view to the conversation.
30
+
31
+ The repository is always the Session's working directory: the browser never sends a path
32
+ and nothing is configured per project. There is no extra port, no sidecar dashboard and no
33
+ second source of truth — every card, lease and event stays in git and `.hive/`, exactly as
34
+ the Hive CLI writes them.
35
+
36
+ ## What you get
37
+
38
+ | Capability | What it means |
39
+ | --- | --- |
40
+ | **A Hive tab in the conversation** | Board lanes (pending, claimed, done, blocked, failed), card details and the event tail, scoped to the Session's repository |
41
+ | **Initialise from the tab** | Run `hive init` on an uninitialised repository and start using it immediately |
42
+ | **Queen mode** | After initialisation, the current Session plans and splits goals into cards instead of writing code; `/queen off` exits |
43
+ | **Card actions** | Claim, complete, fail, retry, block, renew, run a round and more — from the card you are looking at |
44
+ | **Runner strip** | When [dsh-hive-runner](https://github.com/d86e/dsh-hive-runner) is installed, per-repository supervisor state (idle, running, paused), live worker counts and pause/resume |
45
+ | **Read-only by default** | Watching the board is safe out of the box; mutations are opt-in |
46
+
47
+ ## Requirements
48
+
49
+ - DSH Web with the `desktop` (or `web`) profile, version 0.2.2-rc.5 — the version the
50
+ plugin declares compatibility with.
51
+ - Node 22.19 or newer (the DSH runtime).
52
+ - The Hive CLI packages: [`@d86e/hive`](https://github.com/d86e/hive) and
53
+ [hive-tasks](https://github.com/d86e/hive-tasks). `hive-runner` and `merge-on-commit`
54
+ are optional; their actions are disabled when the binaries are not configured.
55
+ - [dsh-hive-runner](https://github.com/d86e/dsh-hive-runner) is optional; it adds the
56
+ resident supervisor and its status strip.
57
+
58
+ ## Install
59
+
60
+ The **desktop** profile is managed by the DSH Desktop application, so
61
+ `dsh plugin --profile desktop ...` refuses to edit it. Edit it by hand:
62
+
63
+ 1. In `~/.dsh/profiles/desktop/package.json`, add the linked checkout to
64
+ `dependencies` and the package name to `dsh.profile.bundles`:
65
+
66
+ ```diff
67
+ "dependencies": {
68
+ + "dsh-hive-panel": "link:/path/to/dsh-hive-panel",
69
+ },
70
+ "dsh": {
71
+ "profile": {
72
+ "bundles": [
73
+ + "dsh-hive-panel"
74
+ ]
75
+ }
76
+ }
77
+ ```
78
+
79
+ Keep the JSON valid: leave the trailing comma only when another entry follows.
80
+
81
+ 2. Install the profile dependencies:
82
+
83
+ ```bash
84
+ cd ~/.dsh/profiles/desktop && pnpm install
85
+ ```
86
+
87
+ 3. Quit DSH Desktop completely and start it again. Refreshing the page is not enough:
88
+ host plugins and browser bundles are loaded at startup.
89
+
90
+ After the restart the conversation view has an extra **Hive** entry (labelled 蜂群 in a
91
+ Chinese UI).
92
+
93
+ For a CLI-managed profile such as `web`, the same two edits work; the profile just
94
+ restarts with `dsh web` instead of the desktop app.
95
+
96
+ ## Five-minute quickstart
97
+
98
+ 1. **Install** the plugin as above and restart DSH.
99
+ 2. **Open a Session** in a git repository you want the swarm to work on. The Session's cwd
100
+ is the repository; the panel never asks for a path.
101
+ 3. **Open the Hive view.** On a repository that is not initialised yet, click
102
+ **Initialise Hive**. This writes the role files, hooks and coordination refs — and
103
+ needs writes enabled (see [Configuration](#configuration)).
104
+ 4. **Become the queen.** A successful initialisation marks the current Session as the
105
+ queen: it only plans and splits cards, it does not edit code. Tell it a goal in the
106
+ conversation, or use **Give the queen a goal**, preview the plan and write the cards.
107
+ 5. **Work the board.** Cards appear in their lanes; open one to see details and the actions
108
+ available for its state. If `dsh-hive-runner` is installed, its strip at the top shows
109
+ each repository's supervisor state and lets you pause or resume it.
110
+ 6. `/queen off` returns the Session to normal coding; the Hive view keeps working.
111
+
112
+ ## Configuration
113
+
114
+ The plugin ships defaults (read-only). Override them in your profile's
115
+ `cordis.patch.yml` by plugin id:
116
+
117
+ ```yaml
118
+ - id: hive-panel
119
+ name: dsh-hive-panel
120
+ config:
121
+ writable: true
122
+ bins:
123
+ hive: /path/to/hive/bin/hive.js
124
+ tasks: /path/to/hive-tasks/bin/hive-tasks.js
125
+ run: /path/to/hive-runner/bin/hive-run.js
126
+ moc: /path/to/merge-on-commit/bin/moc.js
127
+ ```
128
+
129
+ Restart DSH after changing the config.
130
+
131
+ | Key | Default | Meaning |
132
+ | --- | --- | --- |
133
+ | `writable` | `false` | Allow mutating actions (init, add, claim, done, fail, mode, ...). When false the board is still readable and mutations are hidden or rejected |
134
+ | `bins.hive` | `hive` from PATH | `hive` executable: PATH name or absolute path |
135
+ | `bins.tasks` | `hive-tasks` from PATH | `hive-tasks` executable |
136
+ | `bins.run` | `hive-run` from PATH | `hive-run` executable (the run action) |
137
+ | `bins.moc` | `moc` from PATH | `moc` executable (merge-on-commit hooks) |
138
+
139
+ DSH's host process usually does not inherit your shell PATH, so configure absolute paths
140
+ for the Hive binaries if the board is empty or actions fail with a command-not-found
141
+ error.
142
+
143
+ ## Architecture
144
+
145
+ ```
146
+ DSH Web (browser)
147
+ conversation view
148
+ └── Hive / 蜂群 tab ──── board · cards · events · runner strip
149
+ │
150
+ │ same-origin request, authenticated by the DSH Session
151
+ ▼
152
+ DSH host process
153
+ dsh-hive-panel (host half)
154
+ ├── Session -> working directory (the browser never sends a path)
155
+ ├── fixed action catalog + validation (no shell interpolation)
156
+ └── DSH shell seam ── sandbox · credential scrubbing · timeout · output cap · cancel
157
+ │
158
+ ▼
159
+ hive · hive-tasks · hive-run · moc
160
+ │
161
+ ▼
162
+ git: refs/hive/v1/** + .hive/ (the only state)
163
+ ```
164
+
165
+ Nothing is stored by the plugin. Queen mode is an in-memory switch in the host process, so
166
+ a restart ends it (fail-safe) and no Session log is ever modified.
167
+
168
+ ## Relationship to the other Hive projects
169
+
170
+ | Project | What it does | How this panel relates |
171
+ | --- | --- | --- |
172
+ | [hive](https://github.com/d86e/hive) | One CLI entry point: init, roles, tasks, run, board, commit, doctor | The panel runs `hive init` and board reads through it |
173
+ | [hive-tasks](https://github.com/d86e/hive-tasks) | Task cards with dependencies, priority and acceptance | Cards are what the board displays and the actions mutate |
174
+ | [hive-consensus](https://github.com/d86e/hive-consensus) | Path leases, presence board, freeze mode, shared lessons | Claim/renew and the board shown in the tab come from it |
175
+ | [hive-runner](https://github.com/d86e/hive-runner) | One execution round per invocation (`hive-run --once`) | The run action starts one round when the binary is configured |
176
+ | [merge-on-commit](https://github.com/d86e/merge-on-commit) | Three-way merge at commit time | Optional `moc` binary; not required for the board |
177
+ | [hive-panel](https://github.com/d86e/hive-panel) | Standalone read-only board outside DSH | Not needed. This plugin is the DSH-native surface; the standalone board can still be used separately |
178
+ | [dsh-hive-runner](https://github.com/d86e/dsh-hive-runner) | Resident supervisor + subagent workers in DSH | Optional: adds the Runner strip and pause/resume |
179
+
180
+ ## FAQ
181
+
182
+ **The Hive view does not appear.** The client bundle is loaded at startup. Check that both
183
+ `dependencies` and `dsh.profile.bundles` contain `dsh-hive-panel`, that
184
+ `pnpm install` succeeded in the profile, and that DSH was fully restarted. The DSH log
185
+ lines prefixed with `[hive-panel]` say whether the host half mounted.
186
+
187
+ **The board is empty.** Check `initialised` in the view. A repository that is not under
188
+ git, or has not been initialised, shows an initialise button. If the repository is
189
+ initialised but empty, the Hive binaries are probably not reachable from the host process:
190
+ run `hive-tasks list --json` in a terminal, then set `bins` to absolute paths.
191
+
192
+ **Every button is disabled or the view says read-only.** `writable` is still `false`.
193
+ Set it to `true` in the profile config and restart DSH. Read-only mode also disables the
194
+ initialise button.
195
+
196
+ **"Connection lost" or no snapshot.** The panel resolves the repository from the Session.
197
+ Keep a live Session open, or reopen the cold Session so its recorded working directory can
198
+ be read. If it still fails, check the DSH log and that the plugin version matches the
199
+ installed DSH (0.2.2-rc.5).
200
+
201
+ **Do I need the standalone `hive-panel`?** No. That project is a separate board served
202
+ outside DSH. This plugin reads the same refs and files and adds the actions DSH allows.
203
+
204
+ **Does it write anything into my repository?** Only the commands you trigger — for
205
+ example initialisation writes the Hive role files, hooks and refs, exactly as the Hive CLI
206
+ does. Queen mode stores nothing.
207
+
208
+ **Can several Sessions use it at once?** Yes. Each Session is scoped to its own working
209
+ directory, and queen mode applies only to the Session that initialised the repository.
210
+
211
+ ## Security
212
+
213
+ - The browser can only pick an action name and validated argument values. The host builds
214
+ a fixed command for each action; arguments are validated per field and quoted as single
215
+ tokens, never interpolated as shell syntax.
216
+ - Commands execute through DSH's shell seam, so the Session's sandbox policy, credential
217
+ scrubbing, timeout, output cap and cancellation all apply. The plugin never spawns a
218
+ process itself.
219
+ - Panel-triggered actions do not go through DSH approval and are not written to the
220
+ Session audit log. The security boundary is the Session sandbox plus the host-side
221
+ action allowlist; `writable: true` hands the panel repo-scoped command ability. Keep it
222
+ `false` when you only need to watch.
223
+ - The queen role text comes from `<repo>/.hive/roles/queen.md` and is treated as
224
+ low-trust input: it is labelled as untrusted, has a built-in fallback and is capped at
225
+ 4096 characters.
226
+ - If you expose DSH Web beyond your machine, add authentication or a reverse proxy at the
227
+ DSH layer first.
228
+
229
+ ## Development
230
+
231
+ ```bash
232
+ npm run check # node --check on the entry points + the offline verification shim
233
+ npm pack --dry-run # inspect the published contents
234
+ ```
235
+
236
+ `scripts/verify.mjs` runs 20 checks against a Cordis-shaped shim: route registration,
237
+ Session cwd resolution, sandbox policy, the action allowlist and quoting, read-only
238
+ semantics, response contracts, cold Sessions and the queen lifecycle. It never starts or
239
+ restarts a DSH process.
240
+
241
+ The browser bundle `lib/client.js` is generated: after editing `src/`, run
242
+ `node scripts/build-client.mjs`. The wire protocol is specified in [SPEC.md](SPEC.md);
243
+ implementation notes and DSH evidence are in [docs/DESIGN.md](docs/DESIGN.md).
244
+
245
+ ## License
246
+
247
+ MIT © Tommy. See [LICENSE](LICENSE).
@@ -0,0 +1,190 @@
1
+ <div align="center">
2
+
3
+ # dsh-hive-panel
4
+
5
+ [English](README.md) · **简体中文**
6
+
7
+ **DSH Web 里的 Hive 看板与女王。** 一个会话视图,读取当前 Session 所在仓库的 Hive 状态、初始化仓库,并把目标拆成任务卡。
8
+
9
+ [![CI](https://img.shields.io/github/actions/workflow/status/d86e/dsh-hive-panel/ci.yml?style=for-the-badge&logo=github)](https://github.com/d86e/dsh-hive-panel/actions)
10
+ [![npm](https://img.shields.io/npm/v/dsh-hive-panel?style=for-the-badge&logo=npm&color=cb3837)](https://www.npmjs.com/package/dsh-hive-panel)
11
+ [![License](https://img.shields.io/badge/license-MIT-yellow?style=for-the-badge)](LICENSE)
12
+ [![Node](https://img.shields.io/badge/node-%3E%3D22.19-brightgreen?style=for-the-badge&logo=node.js)](https://nodejs.org)
13
+
14
+ </div>
15
+
16
+ ---
17
+
18
+ [Hive](https://github.com/d86e/hive) 让一群 AI agent 在 git 里自我协调:任务卡、路径租约、在场看板、提交时合并,全部是仓库里的 refs 和文件。**dsh-hive-panel** 把这套状态搬进 DSH Web 的一个会话视图:不用离开 Session,就能看看板、和女王一起规划、直接对任务卡动手。
19
+
20
+ 两半一起安装:
21
+
22
+ - **host 半**运行在 DSH 进程里:把当前 Session 的仓库解析出来,读取 Hive 状态,并只通过 DSH 自己的 shell 执行层运行一份固定目录里的 Hive 命令;
23
+ - **浏览器半**在会话里加一个 Hive(蜂群)视图。
24
+
25
+ 仓库永远是当前 Session 的工作目录:浏览器不传路径,也不需要按项目配置。没有额外端口、没有独立看板服务、没有第二份真相——任务卡、租约和事件都留在 git 和 `.hive/` 里,和 Hive CLI 写下的完全一致。
26
+
27
+ ## 能做什么
28
+
29
+ | 能力 | 说明 |
30
+ | --- | --- |
31
+ | **会话里的 Hive 标签页** | 按状态分列的看板(pending / claimed / done / blocked / failed)、任务卡详情和事件尾,作用域是当前 Session 的仓库 |
32
+ | **在标签页里初始化** | 对没初始化过的仓库执行 `hive init`,立刻可用 |
33
+ | **女王模式** | 初始化成功后当前会话只规划、只拆卡,不写代码;`/queen off` 退出 |
34
+ | **任务卡动作** | 认领、完成、失败、重试、阻塞、续租、跑一轮等,都从正在看的那张卡上发起 |
35
+ | **Runner 状态条** | 装了 [dsh-hive-runner](https://github.com/d86e/dsh-hive-runner) 时,顶部显示每个仓库的 supervisor 状态(空闲 / 运行 / 暂停)、在飞 worker 数,并能暂停/恢复 |
36
+ | **默认只读** | 开箱即看是安全的;写操作需要显式打开 |
37
+
38
+ ## 环境要求
39
+
40
+ - DSH Web,`desktop`(或 `web`)profile,版本 0.2.2-rc.5——插件声明的兼容版本。
41
+ - Node 22.19 或更新(DSH 运行时)。
42
+ - Hive 命令行包:[`@d86e/hive`](https://github.com/d86e/hive) 与
43
+ [hive-tasks](https://github.com/d86e/hive-tasks)。`hive-runner` 和
44
+ `merge-on-commit` 是可选的,没配置对应二进制时相关动作不可用。
45
+ - [dsh-hive-runner](https://github.com/d86e/dsh-hive-runner) 可选:装了才有常驻 supervisor 和状态条。
46
+
47
+ ## 安装
48
+
49
+ **desktop** profile 由 DSH Desktop 应用独占管理,`dsh plugin --profile desktop ...` 会拒绝修改,需要手工编辑:
50
+
51
+ 1. 在 `~/.dsh/profiles/desktop/package.json` 的 `dependencies` 里加这个仓库的 link,并在 `dsh.profile.bundles` 里加包名:
52
+
53
+ ```diff
54
+ "dependencies": {
55
+ + "dsh-hive-panel": "link:/path/to/dsh-hive-panel",
56
+ },
57
+ "dsh": {
58
+ "profile": {
59
+ "bundles": [
60
+ + "dsh-hive-panel"
61
+ ]
62
+ }
63
+ }
64
+ ```
65
+
66
+ JSON 逗号按实际位置调整:新行后面还有依赖就保留行尾逗号,是最后一项就去掉。
67
+
68
+ 2. 在 profile 目录安装依赖:
69
+
70
+ ```bash
71
+ cd ~/.dsh/profiles/desktop && pnpm install
72
+ ```
73
+
74
+ 3. 完全退出并重新打开 DSH Desktop。刷新页面不够:host 插件和浏览器 bundle 都在启动时装载。
75
+
76
+ 重启后会话视图里会多出 **Hive** 一项(中文界面显示「蜂群」)。
77
+
78
+ CLI 管理的 profile(例如 `web`)同样改这两处;只是重启方式换成 `dsh web`,而不是桌面应用。
79
+
80
+ ## 五分钟上手
81
+
82
+ 1. **安装**插件并重启 DSH(见上)。
83
+ 2. **开会话**:在要协调的 git 仓库里开一个 Session。会话的 cwd 就是仓库,面板不会问你要路径。
84
+ 3. **打开 Hive 视图**。仓库还没初始化时,点「初始化 Hive」,它会写入角色文件、钩子和协调 refs——需要先打开写权限(见[配置](#配置))。
85
+ 4. **进入女王模式**:初始化成功会把当前会话标记为女王,它只规划、只拆卡,不改代码。直接在对话里说目标,或者点「给女王下目标」,先预览计划、确认后写入任务卡。
86
+ 5. **用看板干活**:任务卡出现在对应分栏;点开卡片看详情和该状态可用的动作。装了 `dsh-hive-runner` 时,顶部状态条显示各仓库的 supervisor 状态,可以直接暂停/恢复。
87
+ 6. `/queen off` 让会话回到普通编码模式;Hive 视图照常工作。
88
+
89
+ ## 配置
90
+
91
+ 插件自带默认值(只读)。要改就在 profile 的 `cordis.patch.yml` 里按插件 id 覆盖:
92
+
93
+ ```yaml
94
+ - id: hive-panel
95
+ name: dsh-hive-panel
96
+ config:
97
+ writable: true
98
+ bins:
99
+ hive: /path/to/hive/bin/hive.js
100
+ tasks: /path/to/hive-tasks/bin/hive-tasks.js
101
+ run: /path/to/hive-runner/bin/hive-run.js
102
+ moc: /path/to/merge-on-commit/bin/moc.js
103
+ ```
104
+
105
+ 改完重启 DSH 生效。
106
+
107
+ | 配置项 | 默认 | 含义 |
108
+ | --- | --- | --- |
109
+ | `writable` | `false` | 是否允许写动作(init、add、claim、done、fail、mode……)。关闭时看板仍可读,写动作被隐藏或拒绝 |
110
+ | `bins.hive` | PATH 上的 `hive` | `hive` 可执行文件:PATH 名或绝对路径 |
111
+ | `bins.tasks` | PATH 上的 `hive-tasks` | `hive-tasks` 可执行文件 |
112
+ | `bins.run` | PATH 上的 `hive-run` | `hive-run` 可执行文件(跑一轮动作) |
113
+ | `bins.moc` | PATH 上的 `moc` | `moc` 可执行文件(merge-on-commit) |
114
+
115
+ DSH 宿主进程通常拿不到你 shell 的 PATH:如果看板是空的、动作报 command not found,就把 Hive 二进制配成绝对路径。
116
+
117
+ ## 架构
118
+
119
+ ```
120
+ DSH Web(浏览器)
121
+ 会话视图
122
+ └── Hive / 蜂群 标签页 ──── 看板 · 任务卡 · 事件 · Runner 状态条
123
+ │
124
+ │ 同源请求,由 DSH Session 认证
125
+ ▼
126
+ DSH 宿主进程
127
+ dsh-hive-panel(host 半)
128
+ ├── Session -> 工作目录 (浏览器从不传路径)
129
+ ├── 固定动作目录 + 参数校验 (不拼 shell 语法)
130
+ └── DSH shell 执行层 ── sandbox · 凭证擦除 · 超时 · 输出上限 · 取消
131
+ │
132
+ ▼
133
+ hive · hive-tasks · hive-run · moc
134
+ │
135
+ ▼
136
+ git: refs/hive/v1/** + .hive/ (唯一的状态)
137
+ ```
138
+
139
+ 插件自己不存任何状态。女王模式只是宿主进程里的内存开关,重启即退出(fail-safe),也不会改动会话日志。
140
+
141
+ ## 与 Hive 其他仓库的关系
142
+
143
+ | 仓库 | 作用 | 与本面板的关系 |
144
+ | --- | --- | --- |
145
+ | [hive](https://github.com/d86e/hive) | 统一入口:init、roles、tasks、run、board、commit、doctor | 面板通过它执行 `hive init` 和看板读取 |
146
+ | [hive-tasks](https://github.com/d86e/hive-tasks) | 带依赖、优先级、验收命令的任务卡 | 看板展示、动作操作的就是这些卡 |
147
+ | [hive-consensus](https://github.com/d86e/hive-consensus) | 路径租约、在场看板、冻结模式、共享经验 | 认领/续租和标签页里的看板来自它 |
148
+ | [hive-runner](https://github.com/d86e/hive-runner) | 每次调用跑一轮执行(`hive-run --once`) | 配置了二进制时,「跑一轮」动作会调用它 |
149
+ | [merge-on-commit](https://github.com/d86e/merge-on-commit) | 提交时三方合并 | 可选的 `moc` 二进制,看板不依赖它 |
150
+ | [hive-panel](https://github.com/d86e/hive-panel) | DSH 之外的独立只读看板 | 不需要装。本插件是 DSH 原生界面,独立看板仍可单独使用 |
151
+ | [dsh-hive-runner](https://github.com/d86e/dsh-hive-runner) | DSH 里的常驻 supervisor + subagent worker | 可选:提供 Runner 状态条和暂停/恢复 |
152
+
153
+ ## 常见问题
154
+
155
+ **Hive 视图没出现。** 浏览器 bundle 在启动时装载。确认 profile 的 `dependencies` 和 `dsh.profile.bundles` 两处都有 `dsh-hive-panel`、`pnpm install` 成功、DSH 是完全重启的。DSH 日志里 `[hive-panel]` 前缀的行会说明 host 半有没有挂上。
156
+
157
+ **看板是空的。** 先看视图里的 `initialised`。仓库不在 git 下、或还没初始化时会显示初始化按钮;已初始化但空,通常是宿主进程找不到 Hive 二进制——先在终端跑 `hive-tasks list --json`,再把 `bins` 配成绝对路径。
158
+
159
+ **按钮全灰 / 提示只读。** `writable` 还是 `false`。在 profile 配置里改成 `true` 并重启 DSH。只读模式下「初始化 Hive」也不可用。
160
+
161
+ **提示连接断开或拿不到快照。** 面板从 Session 解析仓库:保持 Session 活着,或重新打开冷会话,让记录的工作目录可读。仍然失败就看 DSH 日志,并确认插件版本与安装的 DSH(0.2.2-rc.5)匹配。
162
+
163
+ **还需要装独立的 `hive-panel` 吗?** 不需要。那是 DSH 之外的独立看板;本插件读同一份 refs 和文件,并额外提供 DSH 允许的动作。
164
+
165
+ **它会往我的仓库里写东西吗?** 只写你触发的命令——例如初始化会写入 Hive 的角色文件、钩子和 refs,和 Hive CLI 的行为一致。女王模式不存任何东西。
166
+
167
+ **多个会话能同时用吗?** 能。每个会话只作用于自己的工作目录,女王模式只影响初始化该仓库的那个会话。
168
+
169
+ ## 安全
170
+
171
+ - 浏览器只能选动作名和合法的参数值。host 侧为每个动作构造固定命令,参数逐项校验、作为单个 token 加引号,绝不拼进 shell 语法。
172
+ - 命令经 DSH 的 shell 执行层执行:当前 Session 的 sandbox 策略、凭证擦除、超时、输出上限和取消都会生效。插件自己不 spawn 进程。
173
+ - 面板触发的动作**不经过审批**,也不写进会话审计。安全边界是「当前 Session sandbox + host 侧动作白名单」;`writable: true` 相当于把仓库范围内的命令能力交给这个看板。只需要看时保持 `false`。
174
+ - 女王角色文本来自 `<repo>/.hive/roles/queen.md`,按低信任输入处理:带不可信标注、缺失时用内置兜底、总长上限 4096 字符。
175
+ - 要把 DSH Web 暴露到本机之外,先在 DSH 层做认证或反向代理。
176
+
177
+ ## 开发
178
+
179
+ ```bash
180
+ npm run check # 入口语法检查 + 离线验证
181
+ npm pack --dry-run # 检查发布内容
182
+ ```
183
+
184
+ `scripts/verify.mjs` 在 Cordis 形状的 shim 上跑 20 项检查:路由注册、Session cwd 解析、sandbox 策略、动作白名单与转义、只读语义、响应契约、冷会话和女王生命周期。不会启动或重启任何 DSH 进程。
185
+
186
+ 浏览器 bundle `lib/client.js` 是生成物:改完 `src/` 后跑 `node scripts/build-client.mjs`。线上协议见 [SPEC.md](SPEC.md),实现说明和 DSH 实测证据见 [docs/DESIGN.md](docs/DESIGN.md)。
187
+
188
+ ## License
189
+
190
+ MIT © Tommy,见 [LICENSE](LICENSE)。
package/SPEC.md ADDED
@@ -0,0 +1,175 @@
1
+ # dsh-hive-panel — protocol specification
2
+
3
+ Status: 0.1.0, verified against DSH 0.2.2-rc.5.
4
+
5
+ This document is normative for the browser/host contract of the plugin. It is written
6
+ for maintainers: user documentation is [README.md](README.md) and
7
+ [README.zh-CN.md](README.zh-CN.md) and deliberately omits these details. Rationale,
8
+ host-API evidence and the 0.2.2-rc.5 divergences are recorded in
9
+ [docs/DESIGN.md](docs/DESIGN.md).
10
+
11
+ ## 1. Package contract
12
+
13
+ | Field | Value | Meaning |
14
+ | --- | --- | --- |
15
+ | `name` | `dsh-hive-panel` | Also the browser module id: the loader factory id must equal it |
16
+ | `type` | `module` | ESM host half |
17
+ | `exports["."]` | `./lib/index.js` | Cordis host plugin (`name`, `inject`, `apply`) |
18
+ | `exports["./client"]` | `./lib/client.js` | Browser bundle served as the plugin client script |
19
+ | `dsh.bundle.patch` | `./cordis.patch.yml` | Inserts the host plugin entry (`id: hive-panel`) into the composition |
20
+ | `dsh.client.platform` | `web` | Only value DSH accepts for a client bundle |
21
+ | `dsh.client.inject` | conversation + locale client modules | Module-graph predecessors, not Cordis service dependencies |
22
+ | `dsh.compatibility.dsh` | `0.2.2-rc.5` | Host API generation this contract was verified against |
23
+
24
+ The browser bundle is a CJS-in-factory module:
25
+
26
+ ```js
27
+ window.__ModuleLoader__.load({
28
+ id: 'dsh-hive-panel',
29
+ factory: (require) => ({ name, apply, inject }),
30
+ })
31
+ ```
32
+
33
+ `require` resolves only platform seeds and already materialised modules; this plugin
34
+ requires `react` only.
35
+
36
+ ## 2. Session resolution
37
+
38
+ Every request carries a `sessionId`. The browser never sends a filesystem path.
39
+
40
+ 1. Live Session: `ctx.sessions.get(sessionId)` then
41
+ `ctx.workingDirectory.get(session)` gives the effective cwd (including a `cd`).
42
+ 2. Cold Session: `ctx.get('sessionPersistence').stat(sessionId).header.cwd` gives the
43
+ project recorded at creation; a later `cd` is not visible until the Session resumes.
44
+ 3. Neither: `400`, code `hive/session-unknown`.
45
+
46
+ ## 3. Transport
47
+
48
+ The host half registers one exact same-origin Connection Fetch route:
49
+
50
+ - path: `/api/hive`
51
+ - methods: `GET`, `POST`
52
+ - request body: buffered
53
+
54
+ The DSH connection layer authenticates the request (session cookie, owner peer) before
55
+ the handler runs; the plugin opens no port and registers no raw HTTP server. There is no
56
+ separate dashboard service and no proxy.
57
+
58
+ Requests:
59
+
60
+ | Request | Response |
61
+ | --- | --- |
62
+ | `GET ?op=snapshot&sessionId=<id>` | `200` snapshot object (§4) |
63
+ | `GET ?op=actions&sessionId=<id>` | `200 { writable, actions, repo }` |
64
+ | `POST ?op=action&name=<action>&sessionId=<id>` with a JSON body | `200` action envelope (§5) |
65
+ | unknown `op` | `400 { ok:false, error:{ code:'hive/unknown-op', message } }` |
66
+ | wrong method | `405` |
67
+ | invalid JSON body | `400` |
68
+
69
+ `name=queen-off` is accepted in read-only mode because it only touches host memory.
70
+
71
+ ## 4. Snapshot
72
+
73
+ The snapshot is assembled from fixed CLI reads in the Session cwd and always has exactly
74
+ these top-level fields:
75
+
76
+ ```json
77
+ {
78
+ "at": "2026-12-04T00:00:00.000Z",
79
+ "repo": "/abs/repo",
80
+ "initialised": true,
81
+ "mode": "free",
82
+ "board": {},
83
+ "tasks": {},
84
+ "stats": {},
85
+ "events": [],
86
+ "writable": false
87
+ }
88
+ ```
89
+
90
+ - `initialised` — `refs/hive/v1` exists in the repository (a refs probe), not a guess.
91
+ - `board`, `tasks`, `stats` — parsed JSON from the configured Hive binaries.
92
+ - `events` — the newest 80 lines of `<cwd>/.hive/events.jsonl`, newest first.
93
+ - `writable` — the plugin configuration (`false` by default).
94
+ - An uninitialised repository returns the same shape with empty reads after only the
95
+ refs probe.
96
+
97
+ ## 5. Action envelope
98
+
99
+ ```json
100
+ { "ok": true, "code": 0, "stdout": "", "stderr": "" }
101
+ ```
102
+
103
+ - A nonzero CLI exit maps to `ok:false` with the same envelope and the CLI's exit code.
104
+ - In read-only mode a mutating action returns `403` with
105
+ `{ ok:false, code:2, stdout:'', stderr:'read-only: hive-panel writable=false' }` and
106
+ spawns nothing.
107
+
108
+ ## 6. Action catalog
109
+
110
+ Actions: `init add plan claim done fail retry block renew mode learn recall verdict run
111
+ commit doctor` plus the host-memory action `queen-off`.
112
+
113
+ For every action the host builds one fixed command template. Each argument field is
114
+ validated (id, agent, ttl, sha, ref mode, integer ranges, string length, NUL) and every
115
+ token is single-quoted before it enters the shell seam:
116
+
117
+ ```js
118
+ quote(value) = "'" + String(value).replaceAll("'", "'\\''") + "'"
119
+ command = [bin, ...argv].map(quote).join(' ')
120
+ ```
121
+
122
+ Invalid input is rejected with `400` before execution. `bins` (hive, hive-tasks,
123
+ hive-run, moc) come only from trusted host configuration and must each be a single
124
+ executable token: a PATH name or an absolute path.
125
+
126
+ ## 7. Execution
127
+
128
+ Every command runs through DSH's shell seam:
129
+
130
+ ```js
131
+ const request = {
132
+ command,
133
+ workdir: cwd,
134
+ timeoutMs: 30_000,
135
+ stdoutMaxBytes: 4 * 1024 * 1024,
136
+ signal: request.signal,
137
+ }
138
+ request.sandboxPolicy = ctx.sandboxPolicy.resolve({ session })
139
+ const spec = ctx.shell.resolve(request)
140
+ const result = await (await ctx.shell.execute(spec)).result()
141
+ ```
142
+
143
+ No `node:child_process` fallback exists: if `ctx.shell` is missing, `apply` throws
144
+ instead of bypassing the Session sandbox policy, credential scrubbing, timeout, output
145
+ cap and cancellation.
146
+
147
+ ## 8. Queen mode
148
+
149
+ - Trigger: a successful `init` action followed by the `refs/hive/v1` probe.
150
+ - State: `Map<SessionId, roleText>` in host memory only — no custom Session event is
151
+ appended, so a Session log always stays resumable.
152
+ - Injection: a system-prompt section `hive:queen` (order 520) that renders text only
153
+ for the queen Session and an empty string for every other Session, evaluated on each
154
+ prompt assembly. It does not enter the conversation history.
155
+ - Role text: `<cwd>/.hive/roles/queen.md`, prefixed with an "untrusted role file"
156
+ label, capped at 4096 characters and marked `[truncated]` when cut; a built-in
157
+ fallback is labelled when the file is missing.
158
+ - Exit: `/queen off` (calling Session only), `queen-off` action, `agent/disposed`,
159
+ or process restart (memory is not persisted: fail-safe).
160
+
161
+ ## 9. Security invariants
162
+
163
+ - The browser cannot choose a command, cwd, executable, env or shell fragment.
164
+ - No request-scoped cwd comes from the client; the host derives it from the Session.
165
+ - Reads are always allowed; mutations require `writable: true`.
166
+ - Panel actions bypass DSH approval and are not written to the Session audit log; the
167
+ boundary is the Session sandbox plus the host-side allowlist.
168
+ - The route is same-origin and owner-peer only (enforced by DSH's connection layer).
169
+
170
+ ## 10. Compatibility
171
+
172
+ Host APIs used: `connection.fetch.register`, `sessions`, `workingDirectory`,
173
+ `shell`, `systemPrompt.section`, `commands.register`, `agents`. `sandboxPolicy`
174
+ and `sessionPersistence` are optional and read through `ctx.get`. A DSH upgrade can
175
+ change any of these: re-run `npm run check` against the installed DSH before releasing.