dsh-hive-panel 0.2.3 → 0.3.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/lib/index.js CHANGED
@@ -517,6 +517,19 @@ function optionalNumber(value, field, min, max, fallback) {
517
517
  return number
518
518
  }
519
519
 
520
+ /**
521
+ * Plan size: a whole number of 0 or more; 0 means the planner has no card
522
+ * cap, so it must reach `--max-cards` unchanged. Empty/omitted = 50.
523
+ */
524
+ function planMaxCards(value) {
525
+ if (value === undefined || value === null || value === '') return 50
526
+ const number = typeof value === 'number' ? value : Number(value)
527
+ if (!Number.isSafeInteger(number) || number < 0) {
528
+ throw invalid('maxCards', 'must be an integer of 0 or more (0 = unlimited)')
529
+ }
530
+ return number
531
+ }
532
+
520
533
  function idArg(value, field = 'id') {
521
534
  const text = requiredString(value, field, 128)
522
535
  if (!ID_RE.test(text)) throw invalid(field, 'must match ' + String(ID_RE))
@@ -619,7 +632,7 @@ const ACTION_BUILDERS = Object.freeze({
619
632
  return { bin: 'tasks', argv }
620
633
  },
621
634
  plan: payload => {
622
- const argv = ['plan', '--goal', requiredString(payload.goal, 'goal', 4000), '--max-cards', String(optionalNumber(payload.maxCards, 'maxCards', 1, 64, 8))]
635
+ const argv = ['plan', '--goal', requiredString(payload.goal, 'goal', 4000), '--max-cards', String(planMaxCards(payload.maxCards))]
623
636
  if (payload.apply === true) argv.push('--apply')
624
637
  return { bin: 'run', argv }
625
638
  },
package/lib/queen.js CHANGED
@@ -22,7 +22,7 @@
22
22
  * history, so compaction cannot shadow it.
23
23
  *
24
24
  * The workspace role file is LOW-TRUST: the injected text names its absolute
25
- * source path, says it is untrusted, and is capped at 4096 characters
25
+ * source path, says it is untrusted, and is capped at 16384 characters
26
26
  * (annotation included).
27
27
  *
28
28
  * @module dsh-hive-panel/queen
@@ -37,7 +37,7 @@ export const QUEEN_SECTION = 'hive:queen'
37
37
  export const QUEEN_ORDER = 520
38
38
 
39
39
  /** Hard cap for the injected role text, annotation included. */
40
- export const QUEEN_MAX_CHARS = 4096
40
+ export const QUEEN_MAX_CHARS = 16384
41
41
 
42
42
  /** Workspace-relative role file written by `hive init`. */
43
43
  export const QUEEN_ROLE_PATH = path.join('.hive', 'roles', 'queen.md')
@@ -51,10 +51,10 @@ export const QUEEN_SOURCE_AUTO = 'auto'
51
51
  export const QUEEN_SOURCE_MANUAL = 'manual'
52
52
 
53
53
  /** Built-in role used when the workspace file is missing or unreadable. */
54
- export const QUEEN_FALLBACK_ROLE = '# Queen\n\nYou plan, you do not code. Split goals into cards; do not edit files or commit.\n'
54
+ export const QUEEN_FALLBACK_ROLE = '# Queen\n\nYou plan and coordinate; you never write code. Split work into fine-grained cards that each carry an acceptance command, then order, supervise, review and report. Load the hive-queen skill for the full responsibility matrix and commands. Do not edit code, do not commit, do not claim or finish cards.\n'
55
55
 
56
56
  /** Short exit hint appended to every rendered role. */
57
- export const QUEEN_EXIT_HINT = '\n\n[hive] Queen mode: plan and split cards only; do not edit code or commit. Exit with /queen off.'
57
+ export const QUEEN_EXIT_HINT = '\n\n[hive] Queen mode: plan, split, order, supervise, review, report; never edit code or commit. Fine-grained cards; every card needs an acceptance command. Load the hive-queen skill. Exit with /queen off.'
58
58
 
59
59
  /**
60
60
  * Build the injected prompt text for one Session.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-hive-panel",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
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",
@@ -46,7 +46,7 @@ function makeCtx({ agents, cwdOf, shell }) {
46
46
  }
47
47
 
48
48
  // ── the documented reference implementation (mirrors QUEEN-ACTIVATION §1) ─────
49
- const EXIT_HINT = '\n\n女王模式规则:只规划、拆卡;不改代码、不 commit。退出:/queen off。'
49
+ const EXIT_HINT = '\n\n[hive] Queen mode: plan, split, order, supervise, review, report; never edit code or commit. Fine-grained cards; every card needs an acceptance command. Load the hive-queen skill. Exit with /queen off.'
50
50
 
51
51
  function createQueen(ctx) {
52
52
  const queen = new Map()
@@ -85,7 +85,7 @@ function createQueen(ctx) {
85
85
 
86
86
  function readRole(cwd) {
87
87
  const file = path.join(cwd, '.hive/roles/queen.md')
88
- return fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : '# Queen\n\nYou plan, you do not code.'
88
+ return fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : '# Queen\n\nYou plan and coordinate; you never write code.'
89
89
  }
90
90
 
91
91
  async function ensureInitialised(ctx, agent) {
@@ -100,7 +100,7 @@ async function ensureInitialised(ctx, agent) {
100
100
  // ── fixture + checks ─────────────────────────────────────────────────────────
101
101
  const repo = fs.mkdtempSync(path.join(os.tmpdir(), 'queen-activation-'))
102
102
  fs.mkdirSync(path.join(repo, '.hive/roles'), { recursive: true })
103
- fs.writeFileSync(path.join(repo, '.hive/roles/queen.md'), '# Queen\n\nYou plan, you do not code.\n')
103
+ fs.writeFileSync(path.join(repo, '.hive/roles/queen.md'), '# Queen\n\nYou plan and coordinate; you never write code. Split work into fine-grained cards.\n')
104
104
  const shellState = { initialised: false, initExit: 0 }
105
105
  const agents = new Map([['s1', { id: 's1', session: { id: 's1' } }], ['s2', { id: 's2', session: { id: 's2' } }]])
106
106
  const ctx = makeCtx({ agents: { get: id => agents.get(id) }, cwdOf: () => repo, shell: makeShell(shellState) })
@@ -118,7 +118,8 @@ assert.equal(queen.queen.size, 0, 'failed verification must not activate')
118
118
  shellState.initialised = true
119
119
  await queen.enter(agents.get('s1'))
120
120
  const text = textFor('s1')
121
- assert.match(text, /You plan, you do not code/)
121
+ assert.match(text, /You plan and coordinate/)
122
+ assert.ok(text.includes('Fine-grained cards; every card needs an acceptance command.'))
122
123
  assert.ok(text.includes('/queen off'))
123
124
  assert.equal(textFor('s2'), '')
124
125
  console.log('ok 2 - enter() verifies refs/hive/v1 and renders .hive/roles/queen.md from the next assembly')
@@ -210,7 +210,7 @@ ok('host half has no proxy code; exports the native route + action allowlist')
210
210
  const fixture = mkdtempSync(join(os.tmpdir(), 'dsh-hive-panel-'))
211
211
  const repo = join(fixture, 'repo')
212
212
  mkdirSync(join(repo, '.hive', 'roles'), { recursive: true })
213
- writeFileSync(join(repo, '.hive', 'roles', 'queen.md'), '# Queen\n\nYou plan, you do not code.\n')
213
+ writeFileSync(join(repo, '.hive', 'roles', 'queen.md'), '# Queen\n\nYou plan and coordinate; you never write code. Split work into fine-grained cards.\n')
214
214
  writeFileSync(join(repo, '.hive', 'events.jsonl'), '{"ts":"2026-01-01T00:00:00.000Z","kind":"task_add","task":"c1","actor":"w1"}\n{"ts":"2026-01-02T00:00:00.000Z","kind":"task_done","task":"c1","actor":"w1"}\n')
215
215
  writeFileSync(join(repo, '.hive', 'limits.json'), JSON.stringify({ coder: 2, tester: 0 }))
216
216
  const other = join(fixture, 'other')
@@ -594,6 +594,32 @@ async function call(route, { method = 'GET', query = {}, body } = {}) {
594
594
  ok('actions validate every argument, quote argv tokens, and keep { ok, code, stdout, stderr }')
595
595
  }
596
596
 
597
+ // ── 9b. plan max-cards: 50 default, 0 = unlimited ───────────────────────────
598
+ {
599
+ assert.equal(
600
+ host.commandForAction('plan', { goal: 'ship it' }),
601
+ "'hive-run' 'plan' '--goal' 'ship it' '--max-cards' '50'",
602
+ 'plan must default to 50 cards',
603
+ )
604
+ assert.equal(
605
+ host.commandForAction('plan', { goal: 'ship it', maxCards: 0 }),
606
+ "'hive-run' 'plan' '--goal' 'ship it' '--max-cards' '0'",
607
+ 'maxCards=0 (unlimited) must reach argv unchanged',
608
+ )
609
+ assert.equal(
610
+ host.commandForAction('plan', { goal: 'ship it', maxCards: 8 }),
611
+ "'hive-run' 'plan' '--goal' 'ship it' '--max-cards' '8'",
612
+ )
613
+ for (const maxCards of [-1, 1.5, 'many']) {
614
+ assert.throws(
615
+ () => host.commandForAction('plan', { goal: 'ship it', maxCards }),
616
+ /0 or more/,
617
+ 'plan must reject maxCards ' + String(maxCards),
618
+ )
619
+ }
620
+ ok('plan defaults --max-cards to 50 and forwards 0 (unlimited) unchanged')
621
+ }
622
+
597
623
  // ── 10. action failure keeps the same envelope ──────────────────────────────
598
624
  {
599
625
  const shim = createCtx({
@@ -836,6 +862,11 @@ async function call(route, { method = 'GET', query = {}, body } = {}) {
836
862
  const queenSection = shim.sections.find(section => section.name === 'hive:queen')
837
863
  assert.ok(queenSection, 'the hive:queen system-prompt section is not registered')
838
864
  assert.equal(queenSection.order, 520)
865
+ const queenModule = await import(pathToFileURL(files.queen).href + '?verify=' + Date.now())
866
+ assert.equal(queenModule.QUEEN_MAX_CHARS, 16384, 'the injected role text cap must be 16384 characters')
867
+ assert.match(queenModule.QUEEN_FALLBACK_ROLE, /You plan and coordinate; you never write code/)
868
+ assert.match(queenModule.QUEEN_FALLBACK_ROLE, /Load the hive-queen skill/)
869
+ assert.ok(queenModule.QUEEN_EXIT_HINT.includes('Exit with /queen off.'))
839
870
  const agent = { session: { id: 's-live' } }
840
871
  const otherAgent = { session: { id: 's-other' } }
841
872
  assert.equal(queenSection.text({ agent }), '')
@@ -843,10 +874,12 @@ async function call(route, { method = 'GET', query = {}, body } = {}) {
843
874
  assert.equal(init.status, 200)
844
875
  assert.equal(init.body.ok, true)
845
876
  const text = queenSection.text({ agent })
846
- assert.match(text, /You plan, you do not code/)
877
+ assert.match(text, /You plan and coordinate/)
847
878
  assert.ok(text.includes(join(repo, '.hive', 'roles', 'queen.md')), 'the role text must name its source path')
848
879
  assert.ok(text.includes('untrusted'), 'the role text must be marked as low-trust workspace text')
849
- assert.ok(text.length <= 4096, 'the role text must be capped at 4096 characters')
880
+ assert.ok(text.length <= 16384, 'the role text must be capped at 16384 characters')
881
+ assert.ok(text.includes('Fine-grained cards; every card needs an acceptance command.'), 'the exit hint must carry the coordinator contract')
882
+ assert.ok(text.includes('Exit with /queen off.'), 'the exit hint must name /queen off')
850
883
  assert.equal(queenSection.text({ agent: otherAgent }), '', 'queen mode must not leak to another Session')
851
884
 
852
885
  const off = shim.commands.get('queen').handler({ agent, rawInput: ' off ', signal: {}, attachments: [], commandId: 'cmd-1' })
@@ -859,7 +892,17 @@ async function call(route, { method = 'GET', query = {}, body } = {}) {
859
892
  assert.equal(exited.status, 200)
860
893
  assert.deepEqual(exited.body, { ok: true, code: 0, stdout: '', stderr: '' })
861
894
  assert.equal(queenSection.text({ agent }), '')
862
- ok('init + refs/hive/v1 marks only that Session; /queen off and name=queen-off both clear it')
895
+
896
+ // A repository without .hive/roles/queen.md falls back to the coordinator contract.
897
+ const fallbackOn = await call(route, { method: 'POST', query: { op: 'action', name: 'queen-on', sessionId: 's-other' }, body: {} })
898
+ assert.equal(fallbackOn.status, 200)
899
+ const fallbackText = queenSection.text({ agent: otherAgent })
900
+ assert.ok(fallbackText.includes('missing; built-in fallback'), 'a missing role file must be labelled as the built-in fallback')
901
+ assert.match(fallbackText, /You plan and coordinate; you never write code/)
902
+ assert.match(fallbackText, /fine-grained cards that each carry an acceptance command/)
903
+ assert.match(fallbackText, /Load the hive-queen skill/)
904
+ assert.ok(fallbackText.length <= 16384)
905
+ ok('init + refs/hive/v1 marks only that Session; /queen off and name=queen-off both clear it; a missing role file uses the coordinator fallback')
863
906
  }
864
907
 
865
908
  // ── 12b. role truncation ────────────────────────────────────────────────────
@@ -876,9 +919,9 @@ async function call(route, { method = 'GET', query = {}, body } = {}) {
876
919
  await call(route, { method: 'POST', query: { op: 'action', name: 'init', sessionId: 's-long' }, body: {} })
877
920
  const section = shim.sections.find(entry => entry.name === 'hive:queen')
878
921
  const text = section.text({ agent: { session: { id: 's-long' } } })
879
- assert.ok(text.length <= 4096, 'a 20k role file must be truncated to 4096 characters')
922
+ assert.ok(text.length <= 16384, 'a 20k role file must be truncated to 16384 characters')
880
923
  assert.ok(text.includes('truncated'), 'truncation must be signalled in the prompt text')
881
- ok('a 20k role file is truncated to 4096 characters and marked truncated')
924
+ ok('a 20k role file is truncated to 16384 characters and marked truncated')
882
925
  }
883
926
 
884
927
  // ── 12c. snapshot auto-queen / explicit off / queen-on ─────────────────────
@@ -894,7 +937,7 @@ async function call(route, { method = 'GET', query = {}, body } = {}) {
894
937
  const first = await snapshot()
895
938
  assert.equal(first.status, 200)
896
939
  assert.deepEqual(first.body.queen, { active: true, source: 'auto', repo })
897
- assert.match(section.text({ agent }), /You plan, you do not code/)
940
+ assert.match(section.text({ agent }), /You plan and coordinate/)
898
941
 
899
942
  // Repeated polling is idempotent: the auto state stays, it never flips source.
900
943
  const second = await snapshot()
package/src/panel.css CHANGED
@@ -1097,3 +1097,37 @@ dialog.hive-dialog .hive-dialog-body { flex: 1 1 auto; min-height: 0; overflow:
1097
1097
  .hive-card-run-output { max-height: 20lh; overflow: auto; }
1098
1098
  .hive-card-actions { flex-wrap: wrap; justify-content: flex-end; }
1099
1099
 
1100
+ /* Virtual lanes: fixed 26px cards, 2px gaps, 28px stride. */
1101
+ .hive-lane-cards {
1102
+ display: block;
1103
+ flex: 1 1 auto;
1104
+ min-height: 0;
1105
+ padding: 7px;
1106
+ overflow-x: hidden;
1107
+ overflow-y: auto;
1108
+ }
1109
+ .hive-lane-virtual { position: relative; width: 100%; min-width: 0; }
1110
+ .hive-lane-virtual .hive-card {
1111
+ position: absolute;
1112
+ left: 0;
1113
+ right: 0;
1114
+ display: flex;
1115
+ align-items: center;
1116
+ height: 26px;
1117
+ min-height: 26px;
1118
+ padding: 2px 8px;
1119
+ overflow: hidden;
1120
+ border-radius: var(--hive-radius-sm);
1121
+ }
1122
+ .hive-lane-virtual .hive-card-title {
1123
+ width: 100%;
1124
+ overflow: hidden;
1125
+ font-size: 12px;
1126
+ line-height: 16px;
1127
+ text-overflow: ellipsis;
1128
+ white-space: nowrap;
1129
+ }
1130
+
1131
+ .hive-agent-count { font: inherit; cursor: pointer; }
1132
+ .hive-agent-count:disabled { cursor: default; }
1133
+