dsh-hive-panel 1.0.0 → 1.0.1
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 +22 -0
- package/SPEC.md +13 -5
- package/docs/DESIGN.md +14 -4
- package/lib/client.js +8 -0
- package/lib/index.js +40 -3
- package/package.json +1 -1
- package/scripts/verify.mjs +64 -0
- package/src/panel.js +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,24 @@ All notable changes to this project are documented in this file. The format is
|
|
|
4
4
|
based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project
|
|
5
5
|
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [1.0.1] - 2026-12-05
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- `initialised` is now true when the repository has the markers `hive init` actually
|
|
12
|
+
writes — `.hive/roles.yaml` or `.hive/config.json` — even before the first board /
|
|
13
|
+
mode / task write creates a `refs/hive/v1` ref. The same predicate gates the
|
|
14
|
+
post-init queen activation, so a freshly initialised repository becomes the queen
|
|
15
|
+
immediately instead of on the first ref.
|
|
16
|
+
- A successful init now switches the open view to the board immediately (optimistic
|
|
17
|
+
snapshot update) instead of staying on the init card until the next poll.
|
|
18
|
+
|
|
19
|
+
### Tests
|
|
20
|
+
|
|
21
|
+
- 37 checks now cover marker-only initialisation (roles.yaml and config.json), the
|
|
22
|
+
neither-marker case, the immediate post-init transition and the client bundle's
|
|
23
|
+
optimistic switch.
|
|
24
|
+
|
|
7
25
|
## [1.0.0] - 2026-12-04
|
|
8
26
|
|
|
9
27
|
### Stable
|
|
@@ -26,6 +44,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
26
44
|
- The standalone `@d86e/hive-panel` 1.x board can run side by side; both read the same
|
|
27
45
|
refs and `.hive/` files.
|
|
28
46
|
|
|
47
|
+
### Published
|
|
48
|
+
|
|
49
|
+
- npm: `dsh-hive-panel@1.0.0` on 2026-12-04.
|
|
50
|
+
|
|
29
51
|
## [0.3.0] - 2026-12-04
|
|
30
52
|
|
|
31
53
|
### Changed
|
package/SPEC.md
CHANGED
|
@@ -98,7 +98,14 @@ has exactly these top-level fields:
|
|
|
98
98
|
}
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
- `initialised` —
|
|
101
|
+
- `initialised` — the repository is Hive-initialised: either a ref under
|
|
102
|
+
`refs/hive/v1` exists, **or** one of the files `hive init` writes is present —
|
|
103
|
+
`.hive/roles.yaml` or `.hive/config.json`. `hive init` itself writes no git refs
|
|
104
|
+
(the ref appears on the first board/mode/task write), so a refs-only check left a
|
|
105
|
+
freshly initialised repository stuck on the init card; the marker files are equally
|
|
106
|
+
authoritative. A successful `init` action therefore shows `initialised: true` on
|
|
107
|
+
the very next snapshot, and the panel switches to the board immediately instead of
|
|
108
|
+
waiting for that poll.
|
|
102
109
|
- `mode` — the parsed `refs/hive/v1/mode` document (`{ v, mode, reason, since }`), for
|
|
103
110
|
example `{ "mode": "free" }`; `{ "mode": "free" }` when the ref cannot be read or
|
|
104
111
|
parsed.
|
|
@@ -130,10 +137,11 @@ has exactly these top-level fields:
|
|
|
130
137
|
`limit` is `null` when the file has no entry — effective limits (config fallback,
|
|
131
138
|
runtime counts) are exposed by the hive-runner supervisor status endpoint instead.
|
|
132
139
|
A successful `roles-add` shows up here on the next poll.
|
|
133
|
-
- An uninitialised repository
|
|
134
|
-
|
|
135
|
-
`
|
|
136
|
-
`queen` may still be active
|
|
140
|
+
- An uninitialised repository (no ref and no `.hive/roles.yaml`/`.hive/config.json`)
|
|
141
|
+
returns the same shape after only the `refs/hive/v1` probe and the events read:
|
|
142
|
+
`board` is `[]`, `tasks` is `[]`, `stats` is `null`, `boardError` is `null`, and
|
|
143
|
+
`roles` is `{ list: [], limits: {}, error: null }`; `queen` may still be active
|
|
144
|
+
there after an explicit activation.
|
|
137
145
|
|
|
138
146
|
## 5. Action envelope
|
|
139
147
|
|
package/docs/DESIGN.md
CHANGED
|
@@ -183,6 +183,13 @@ interface ConnectionFetchRoute {
|
|
|
183
183
|
`<cwd>/.hive/limits.json`(0..999 的 `role -> n`),`limit` 为空表示该文件没有条目;
|
|
184
184
|
**effective** 限额(config 兜底、运行时队列)由 hive-runner 的 `/api/hive-runner?op=status` 提供。
|
|
185
185
|
`roles-add` 成功后下一次轮询即可看到新角色,无需额外刷新接口。
|
|
186
|
+
- 快照里的 `initialised` **不再只认 `refs/hive/v1`**:`hive init` 只写 `.hive/` 文件与 git hooks,
|
|
187
|
+
第一次 board/mode/task 写入才会出现 ref。因此 `initialised` = ref 非空 **或**
|
|
188
|
+
`<cwd>/.hive/roles.yaml` 存在 **或** `<cwd>/.hive/config.json` 存在(`isHiveInitialised()`)。
|
|
189
|
+
修这个 bug 前,刚 init 的仓库会一直停在“初始化”卡片,重启面板也一样。
|
|
190
|
+
`init` 动作成功后下一次 snapshot 即为 `initialised: true`(marker 已落盘);前端在动作成功时
|
|
191
|
+
还会先用 `{ ...lastSnapshot, initialised: true }` 立即切到看板态,再 `forceRefresh()` 与宿主对账,
|
|
192
|
+
不依赖 3 s 轮询。自动女王/init 后激活用同一判定。
|
|
186
193
|
- 事件历史从 `<cwd>/.hive/events.jsonl` 读最近 80 条,倒序返回(沿用原 `hive-panel/src/data.js` 的语义)。
|
|
187
194
|
|
|
188
195
|
### 4.3 认证边界
|
|
@@ -414,7 +421,7 @@ npm run check
|
|
|
414
421
|
# ok - node --check lib/queen.js
|
|
415
422
|
# ok - node --check lib/client.js
|
|
416
423
|
# ...
|
|
417
|
-
#
|
|
424
|
+
# 37 checks passed
|
|
418
425
|
```
|
|
419
426
|
|
|
420
427
|
覆盖:语法、package/bundle 声明、无代理残留、client bundle 的 `/api/hive` URL 与 Session 注入、
|
|
@@ -424,7 +431,9 @@ Connection Fetch 路由注册、快照走 `ctx.shell` 且 cwd/policy 正确、
|
|
|
424
431
|
只读语义、动作参数校验与 argv 转义、失败信封、无 `ctx.shell` 拒绝挂载、女王激活/隔离/退出/截断,
|
|
425
432
|
以及 snapshot 自动激活、显式关闭后的抑制、`queen-off` 幂等、`autoQueen=false` 与手动 `queen-on`、
|
|
426
433
|
`roles` 快照(角色列表 + 持久限额)、`roles-add`(含 description)的参数校验/argv/仓库 cwd、
|
|
427
|
-
重复角色的 CLI stderr 透传、`roles-remove` 的 argv/非法名/只读 403/CLI 失败透传,以及 `remove` 的卡片 id
|
|
434
|
+
重复角色的 CLI stderr 透传、`roles-remove` 的 argv/非法名/只读 403/CLI 失败透传,以及 `remove` 的卡片 id 校验;
|
|
435
|
+
另有 `initialised` 只靠 `.hive/roles.yaml`/`.hive/config.json` 即为 true、init 动作后立即 true、
|
|
436
|
+
两者与 ref 都无才为 false,以及 client bundle 的 init 成功即时切面检查。
|
|
428
437
|
|
|
429
438
|
不启动、不重启任何 DSH 进程,也不写运行中的 `~/.dsh`。
|
|
430
439
|
|
|
@@ -440,8 +449,9 @@ Connection Fetch 路由注册、快照走 `ctx.shell` 且 cwd/policy 正确、
|
|
|
440
449
|
runner 0.6.4+ 写完 `.hive/runs/<id>.json` 后才会出现按钮。
|
|
441
450
|
- 冷会话只能拿 `header.cwd`;`cd` 后的有效 cwd 在 resume 前不可见。
|
|
442
451
|
- 每次轮询会 spawn 1–5 个 CLI 进程(实测单命令 ~110–124 ms),3 s 间隔足够;多客户端同时打开会叠加。
|
|
443
|
-
-
|
|
444
|
-
|
|
452
|
+
- 自动女王与 `initialised` 共用判定(refs 或 `.hive/` marker):任何已初始化的仓库在该 Session
|
|
453
|
+
第一次快照时即进入女王模式;用户可用 `/queen off`(本进程内抑制)或配置 `autoQueen: false`
|
|
454
|
+
(全局关闭自动)退出该行为。
|
|
445
455
|
- 面板触发的命令**不进会话审计**,也没有 approval;需要硬边界时应把操作建模成 turn 内 tool 调用。
|
|
446
456
|
- `hive`/`hive-tasks` 不在 DSH PATH 时,宿主先按 PATH 名执行,失败后自动用
|
|
447
457
|
`npx -y -p <包> ...` 重试一次;两者都失败才返回带安装提示的非 0 退出码或空数据。显式配置的
|
package/lib/client.js
CHANGED
|
@@ -5563,6 +5563,14 @@ function mount(root, options = {}) {
|
|
|
5563
5563
|
return;
|
|
5564
5564
|
}
|
|
5565
5565
|
|
|
5566
|
+
// The init action succeeded, so the repository IS initialised. Switch the
|
|
5567
|
+
// open panel out of the init card on this render instead of waiting for the
|
|
5568
|
+
// next poll (a freshly initialised repo may have no refs for a while, and a
|
|
5569
|
+
// failed/racy snapshot fetch must not leave the stale init card up).
|
|
5570
|
+
if (lastSnapshot && typeof lastSnapshot === "object") {
|
|
5571
|
+
setSnapshot({ ...lastSnapshot, initialised: true });
|
|
5572
|
+
}
|
|
5573
|
+
|
|
5566
5574
|
queenNotice = true;
|
|
5567
5575
|
initErrorMessage = "";
|
|
5568
5576
|
if (lastModel) {
|
package/lib/index.js
CHANGED
|
@@ -59,6 +59,40 @@ export const SNAPSHOT_READS = Object.freeze({
|
|
|
59
59
|
mode: buildCommand('git', ['cat-file', '-p', 'refs/hive/v1/mode']),
|
|
60
60
|
})
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Files `hive init` writes before any git ref exists. Either one (or a non-empty
|
|
64
|
+
* `refs/hive/v1`) means the repository is initialised for Hive.
|
|
65
|
+
*/
|
|
66
|
+
export const HIVE_INIT_MARKERS = Object.freeze([
|
|
67
|
+
path.join('.hive', 'roles.yaml'),
|
|
68
|
+
path.join('.hive', 'config.json'),
|
|
69
|
+
])
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Whether one repository counts as Hive-initialised.
|
|
73
|
+
*
|
|
74
|
+
* `hive init` only writes `.hive/` files and git hooks; `refs/hive/v1` appears
|
|
75
|
+
* later, on the first board/mode/task write. Checking only the refs kept a
|
|
76
|
+
* freshly initialised repository (and its panel) stuck on the init card, so the
|
|
77
|
+
* marker files count too.
|
|
78
|
+
*
|
|
79
|
+
* @param {string} cwd - resolved Session working directory.
|
|
80
|
+
* @param {string} [refsOutput] - stdout of {@link SNAPSHOT_READS.refs} ('' when it failed/empty).
|
|
81
|
+
* @returns {boolean} true when a ref or a `hive init` marker exists.
|
|
82
|
+
*/
|
|
83
|
+
export function isHiveInitialised(cwd, refsOutput = '') {
|
|
84
|
+
if (typeof refsOutput === 'string' && refsOutput.trim() !== '') return true
|
|
85
|
+
if (typeof cwd !== 'string' || cwd === '') return false
|
|
86
|
+
for (const marker of HIVE_INIT_MARKERS) {
|
|
87
|
+
try {
|
|
88
|
+
if (fs.existsSync(path.join(cwd, marker))) return true
|
|
89
|
+
} catch {
|
|
90
|
+
// A failed probe means "marker absent"; a ref may still have decided true.
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return false
|
|
94
|
+
}
|
|
95
|
+
|
|
62
96
|
/** Default executables; override through the Cordis entry config `bins`. */
|
|
63
97
|
export const DEFAULT_BINS = Object.freeze({
|
|
64
98
|
hive: 'hive',
|
|
@@ -1056,7 +1090,9 @@ export function createBridge(ctx, config = {}) {
|
|
|
1056
1090
|
roles: { list: [], limits: {}, error: null },
|
|
1057
1091
|
}
|
|
1058
1092
|
const refs = await tryExecute(SNAPSHOT_READS.refs, { cwd, session, timeoutMs: PROBE_TIMEOUT_MS, signal })
|
|
1059
|
-
const
|
|
1093
|
+
const refsText = refs !== undefined && refs.exitCode === 0 ? String(refs.stdout?.text ?? '') : ''
|
|
1094
|
+
// hive init writes .hive/roles.yaml (and friends) and no refs yet: accept either signal.
|
|
1095
|
+
const initialised = isHiveInitialised(cwd, refsText)
|
|
1060
1096
|
if (initialised) autoActivateQueen(sessionId, cwd)
|
|
1061
1097
|
payload.queen = queenSnapshot(sessionId, cwd)
|
|
1062
1098
|
if (payload.queen.active) registerQueenSession(sessionId)
|
|
@@ -1116,11 +1152,12 @@ export function createBridge(ctx, config = {}) {
|
|
|
1116
1152
|
}
|
|
1117
1153
|
}
|
|
1118
1154
|
|
|
1119
|
-
/** After a successful init, verify
|
|
1155
|
+
/** After a successful init, verify the repo markers/refs and mark the Session as queen. */
|
|
1120
1156
|
async function activateQueen(sessionId, cwd, session, signal) {
|
|
1121
1157
|
if (queen === undefined || typeof queen.mark !== 'function') return false
|
|
1122
1158
|
const refs = await tryExecute(SNAPSHOT_READS.refs, { cwd, session, timeoutMs: PROBE_TIMEOUT_MS, signal })
|
|
1123
|
-
|
|
1159
|
+
const refsText = refs !== undefined && refs.exitCode === 0 ? String(refs.stdout?.text ?? '') : ''
|
|
1160
|
+
if (!isHiveInitialised(cwd, refsText)) return false
|
|
1124
1161
|
try {
|
|
1125
1162
|
queen.mark({ sessionId, cwd })
|
|
1126
1163
|
registerQueenSession(sessionId)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-hive-panel",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Hive board and queen mode inside DSH Web: a conversation view scoped to the Session's repository, with allowlisted task-card actions over DSH's shell seam.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
package/scripts/verify.mjs
CHANGED
|
@@ -88,9 +88,11 @@ assert.ok(clientSource.includes('uiWorkspace'), 'the client bundle never resolve
|
|
|
88
88
|
assert.ok(clientSource.includes('hiveOpenSession'), 'the client bundle never forwards an open-session callback')
|
|
89
89
|
assert.ok(clientSource.includes('drawer.openChat'), 'the inlined renderer lost the Open agent chat copy')
|
|
90
90
|
assert.ok(clientSource.includes('boardError'), 'the inlined renderer lost the board diagnostic rendering')
|
|
91
|
+
assert.ok(clientSource.includes('initialised: true'), 'the client bundle never switches out of the init card on success')
|
|
91
92
|
assert.equal(clientSource.includes('/hive-panel/api'), false, 'the retired proxy prefix is still in the bundle')
|
|
92
93
|
assert.equal(clientSource.includes('7717'), false, 'the retired 7717 upstream is still in the bundle')
|
|
93
94
|
ok('client bundle uses /api/hive and forwards the Session id')
|
|
95
|
+
ok('the init success path switches the panel to the board immediately')
|
|
94
96
|
|
|
95
97
|
const React = {
|
|
96
98
|
createElement(type, props, ...children) { return { type, props: props ?? {}, children } },
|
|
@@ -514,6 +516,68 @@ async function call(route, { method = 'GET', query = {}, body } = {}) {
|
|
|
514
516
|
ok('each snapshot card carries lastRun read from .hive/runs/<id>.json; worker sessionId/agentName pass through, corrupt/missing/unsafe ids degrade to null')
|
|
515
517
|
}
|
|
516
518
|
|
|
519
|
+
// ── 6d. initialised accepts the files hive init writes (no ref needed) ─────
|
|
520
|
+
{
|
|
521
|
+
const markerOnly = join(fixture, 'marker-roles')
|
|
522
|
+
mkdirSync(join(markerOnly, '.hive'), { recursive: true })
|
|
523
|
+
writeFileSync(join(markerOnly, '.hive', 'roles.yaml'), 'roles: {}\n')
|
|
524
|
+
const configOnly = join(fixture, 'marker-config')
|
|
525
|
+
mkdirSync(join(configOnly, '.hive'), { recursive: true })
|
|
526
|
+
writeFileSync(join(configOnly, '.hive', 'config.json'), '{}\n')
|
|
527
|
+
const plain = join(fixture, 'marker-none')
|
|
528
|
+
mkdirSync(plain, { recursive: true })
|
|
529
|
+
|
|
530
|
+
assert.equal(host.isHiveInitialised(markerOnly, ''), true, '.hive/roles.yaml alone must mean initialised')
|
|
531
|
+
assert.equal(host.isHiveInitialised(configOnly, ''), true, '.hive/config.json alone must mean initialised')
|
|
532
|
+
assert.equal(host.isHiveInitialised(plain, ''), false, 'no marker and no ref must mean uninitialised')
|
|
533
|
+
assert.equal(host.isHiveInitialised(plain, 'refs/hive/v1/mode\n'), true, 'a non-empty ref still means initialised')
|
|
534
|
+
assert.deepEqual(host.HIVE_INIT_MARKERS, ['.hive/roles.yaml', '.hive/config.json'])
|
|
535
|
+
|
|
536
|
+
const shim = createCtx({
|
|
537
|
+
live: new Map([['s-marker', { id: 's-marker', header: { id: 's-marker', cwd: markerOnly } }]]),
|
|
538
|
+
cwdOf: session => session.header.cwd,
|
|
539
|
+
shell: spec => (spec.command.includes("'for-each-ref'") ? { exitCode: 0, stdout: '' } : defaultShellResult(spec)),
|
|
540
|
+
})
|
|
541
|
+
host.apply(shim.ctx, {})
|
|
542
|
+
const outcome = await call(shim.routes.get('/api/hive'), { query: { op: 'snapshot', sessionId: 's-marker' } })
|
|
543
|
+
assert.equal(outcome.status, 200)
|
|
544
|
+
assert.equal(outcome.body.initialised, true, 'a repo whose only Hive state is .hive/roles.yaml must report initialised')
|
|
545
|
+
assert.deepEqual(outcome.body.board, [{ agent: 'w1', state: 'claimed', task: 'c1' }], 'initialised marker repos must fan out to the board read')
|
|
546
|
+
assert.ok(shim.executions.some(execution => execution.command === host.snapshotCliCommands().board))
|
|
547
|
+
ok('a hive init marker (roles.yaml/config.json) marks the repo initialised before any ref exists')
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// ── 6e. a successful init action is initialised immediately ────────────────
|
|
551
|
+
{
|
|
552
|
+
const instantRepo = join(fixture, 'instant-init')
|
|
553
|
+
mkdirSync(instantRepo, { recursive: true })
|
|
554
|
+
const shim = createCtx({
|
|
555
|
+
live: new Map([['s-instant', { id: 's-instant', header: { id: 's-instant', cwd: instantRepo } }]]),
|
|
556
|
+
cwdOf: session => session.header.cwd,
|
|
557
|
+
shell: spec => {
|
|
558
|
+
if (spec.command.includes("'for-each-ref'")) return { exitCode: 0, stdout: '' }
|
|
559
|
+
if (spec.command.includes("'init'")) {
|
|
560
|
+
// hive init writes no refs; only the .hive/ marker files.
|
|
561
|
+
mkdirSync(join(instantRepo, '.hive'), { recursive: true })
|
|
562
|
+
writeFileSync(join(instantRepo, '.hive', 'roles.yaml'), 'roles: {}\n')
|
|
563
|
+
return { exitCode: 0, stdout: 'ok .hive/roles.yaml (created)\n' }
|
|
564
|
+
}
|
|
565
|
+
return defaultShellResult(spec)
|
|
566
|
+
},
|
|
567
|
+
})
|
|
568
|
+
host.apply(shim.ctx, { writable: true })
|
|
569
|
+
const route = shim.routes.get('/api/hive')
|
|
570
|
+
const before = await call(route, { query: { op: 'snapshot', sessionId: 's-instant' } })
|
|
571
|
+
assert.equal(before.body.initialised, false)
|
|
572
|
+
const init = await call(route, { method: 'POST', query: { op: 'action', name: 'init', sessionId: 's-instant' }, body: {} })
|
|
573
|
+
assert.equal(init.status, 200)
|
|
574
|
+
assert.equal(init.body.ok, true)
|
|
575
|
+
const after = await call(route, { query: { op: 'snapshot', sessionId: 's-instant' } })
|
|
576
|
+
assert.equal(after.body.initialised, true, 'init writes .hive/roles.yaml, so the very next snapshot must already be initialised')
|
|
577
|
+
assert.equal(after.body.queen.active, true, 'init also marks the Session as queen from the marker check')
|
|
578
|
+
ok('a successful init action flips the snapshot to initialised immediately (no refs needed)')
|
|
579
|
+
}
|
|
580
|
+
|
|
517
581
|
// ── 7. cold session + unknown session ───────────────────────────────────────
|
|
518
582
|
{
|
|
519
583
|
const shim = createCtx({
|
package/src/panel.js
CHANGED
|
@@ -5490,6 +5490,14 @@ export function mount(root, options = {}) {
|
|
|
5490
5490
|
return;
|
|
5491
5491
|
}
|
|
5492
5492
|
|
|
5493
|
+
// The init action succeeded, so the repository IS initialised. Switch the
|
|
5494
|
+
// open panel out of the init card on this render instead of waiting for the
|
|
5495
|
+
// next poll (a freshly initialised repo may have no refs for a while, and a
|
|
5496
|
+
// failed/racy snapshot fetch must not leave the stale init card up).
|
|
5497
|
+
if (lastSnapshot && typeof lastSnapshot === "object") {
|
|
5498
|
+
setSnapshot({ ...lastSnapshot, initialised: true });
|
|
5499
|
+
}
|
|
5500
|
+
|
|
5493
5501
|
queenNotice = true;
|
|
5494
5502
|
initErrorMessage = "";
|
|
5495
5503
|
if (lastModel) {
|