@d86e/hive-panel 1.0.8 → 1.0.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d86e/hive-panel",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "A read-only board for a Hive swarm: agents, task lanes and the event tail, served from the refs and files you already have.",
5
5
  "type": "module",
6
6
  "bin": {
package/public/panel.css CHANGED
@@ -1153,3 +1153,19 @@ dialog.hive-dialog .hive-dialog-body { flex: 1 1 auto; min-height: 0; overflow:
1153
1153
  .hive-supervisor-inline-state.is-paused::before { background: var(--hive-warn); }
1154
1154
  .hive-supervisor-inline-state.is-unresponsive::before { background: var(--hive-fg-faint); }
1155
1155
 
1156
+ /* Lightweight markdown in the last-run output. */
1157
+ .hive-markdown { color: var(--hive-fg-soft); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
1158
+ .hive-markdown p { margin: 0 0 8px; white-space: pre-wrap; }
1159
+ .hive-markdown p:last-child { margin-bottom: 0; }
1160
+ .hive-markdown .hive-md-heading { margin: 8px 0 6px; color: var(--hive-fg); font-size: 14px; font-weight: 700; line-height: 1.4; }
1161
+ .hive-markdown h1.hive-md-heading { font-size: 16px; }
1162
+ .hive-markdown h2.hive-md-heading { font-size: 15px; }
1163
+ .hive-markdown .hive-md-list { margin: 0 0 8px; padding-left: 20px; }
1164
+ .hive-markdown .hive-md-list li { margin: 2px 0; }
1165
+ .hive-markdown .hive-md-code-inline { padding: 1px 4px; border: 1px solid var(--hive-line-2); border-radius: var(--hive-radius-sm); background: var(--hive-bg-layer-1); color: var(--hive-fg); font-family: var(--hive-mono); font-size: 11px; }
1166
+ .hive-markdown .hive-md-code-block { max-width: 100%; margin: 8px 0; padding: 10px; overflow-x: auto; border: 1px solid var(--hive-line); border-radius: var(--hive-radius-md); background: var(--hive-bg-layer-1); color: var(--hive-fg); font-family: var(--hive-mono); font-size: 11px; line-height: 1.55; white-space: pre; scrollbar-color: var(--hive-line) transparent; scrollbar-width: thin; }
1167
+ .hive-markdown .hive-md-code-block code { padding: 0; border: 0; background: transparent; color: inherit; font: inherit; white-space: pre; }
1168
+ .hive-markdown .hive-md-quote { margin: 8px 0; padding: 2px 0 2px 10px; border-left: 2px solid var(--hive-line); color: var(--hive-fg-soft); }
1169
+ .hive-markdown .hive-md-link { color: var(--hive-accent); text-decoration: underline; text-underline-offset: 2px; }
1170
+ .hive-markdown .hive-markdown-empty { color: var(--hive-fg-faint); font-size: 12px; }
1171
+
package/public/panel.js CHANGED
@@ -2037,6 +2037,21 @@ dialog.hive-dialog .hive-dialog-body { flex: 1 1 auto; min-height: 0; overflow:
2037
2037
  .hive-supervisor-inline-state.is-normal::before { background: var(--hive-ok); }
2038
2038
  .hive-supervisor-inline-state.is-paused::before { background: var(--hive-warn); }
2039
2039
  .hive-supervisor-inline-state.is-unresponsive::before { background: var(--hive-fg-faint); }
2040
+ /* Lightweight markdown in the last-run output. */
2041
+ .hive-markdown { color: var(--hive-fg-soft); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
2042
+ .hive-markdown p { margin: 0 0 8px; white-space: pre-wrap; }
2043
+ .hive-markdown p:last-child { margin-bottom: 0; }
2044
+ .hive-markdown .hive-md-heading { margin: 8px 0 6px; color: var(--hive-fg); font-size: 14px; font-weight: 700; line-height: 1.4; }
2045
+ .hive-markdown h1.hive-md-heading { font-size: 16px; }
2046
+ .hive-markdown h2.hive-md-heading { font-size: 15px; }
2047
+ .hive-markdown .hive-md-list { margin: 0 0 8px; padding-left: 20px; }
2048
+ .hive-markdown .hive-md-list li { margin: 2px 0; }
2049
+ .hive-markdown .hive-md-code-inline { padding: 1px 4px; border: 1px solid var(--hive-line-2); border-radius: var(--hive-radius-sm); background: var(--hive-bg-layer-1); color: var(--hive-fg); font-family: var(--hive-mono); font-size: 11px; }
2050
+ .hive-markdown .hive-md-code-block { max-width: 100%; margin: 8px 0; padding: 10px; overflow-x: auto; border: 1px solid var(--hive-line); border-radius: var(--hive-radius-md); background: var(--hive-bg-layer-1); color: var(--hive-fg); font-family: var(--hive-mono); font-size: 11px; line-height: 1.55; white-space: pre; scrollbar-color: var(--hive-line) transparent; scrollbar-width: thin; }
2051
+ .hive-markdown .hive-md-code-block code { padding: 0; border: 0; background: transparent; color: inherit; font: inherit; white-space: pre; }
2052
+ .hive-markdown .hive-md-quote { margin: 8px 0; padding: 2px 0 2px 10px; border-left: 2px solid var(--hive-line); color: var(--hive-fg-soft); }
2053
+ .hive-markdown .hive-md-link { color: var(--hive-accent); text-decoration: underline; text-underline-offset: 2px; }
2054
+ .hive-markdown .hive-markdown-empty { color: var(--hive-fg-faint); font-size: 12px; }
2040
2055
  `;
2041
2056
 
2042
2057
  const LANE_LABEL_KEYS = Object.freeze({
@@ -2094,6 +2109,12 @@ export const messages = Object.freeze({
2094
2109
  "stats.byRoleTitle": "by role: ",
2095
2110
  "status.actionFailed": "action failed",
2096
2111
  "status.disconnected": "disconnected",
2112
+ "loading.updating": "Updating",
2113
+ "loading.slow": "Loading · waited {seconds}s",
2114
+ "loading.failed": "Could not load",
2115
+ "loading.retry": "Retry",
2116
+ "loading.retryAria": "Retry loading the board",
2117
+ "loading.aria": "Loading the board",
2097
2118
  "agents.openAria": "Open agent",
2098
2119
  "agents.runningTooltip": "Running {running} / board identities {identities}",
2099
2120
  "agents.fallbackTooltip": "Board identities {identities} (supervisor disconnected or repository not registered)",
@@ -2123,6 +2144,7 @@ export const messages = Object.freeze({
2123
2144
  "drawer.removeClaimed": "A claimed task must be released or reopened before it can be deleted.",
2124
2145
  "drawer.rawJson": "raw json",
2125
2146
  "drawer.lastRun": "Last run",
2147
+ "drawer.noOutput": "(no output)",
2126
2148
  "drawer.runOverlaps": "Also writing",
2127
2149
  "drawer.runLessons": "Read {count} lessons",
2128
2150
  "drawer.runNoLessons": "No lessons to read",
@@ -2358,6 +2380,12 @@ export const messages = Object.freeze({
2358
2380
  "stats.byRoleTitle": "按角色:",
2359
2381
  "status.actionFailed": "操作失败",
2360
2382
  "status.disconnected": "连接断开",
2383
+ "loading.updating": "更新中",
2384
+ "loading.slow": "正在读取 · 已等 {seconds}s",
2385
+ "loading.failed": "读取失败",
2386
+ "loading.retry": "重试",
2387
+ "loading.retryAria": "重试读取看板",
2388
+ "loading.aria": "正在读取看板",
2361
2389
  "agents.openAria": "打开智能体",
2362
2390
  "agents.runningTooltip": "运行中 {running} / 公告板身份 {identities}",
2363
2391
  "agents.fallbackTooltip": "公告板身份 {identities}(监督器未连接或未注册该仓库)",
@@ -2387,6 +2415,7 @@ export const messages = Object.freeze({
2387
2415
  "drawer.removeClaimed": "已认领的任务必须先释放或重开才能删除。",
2388
2416
  "drawer.rawJson": "原始 JSON",
2389
2417
  "drawer.lastRun": "最近一次执行",
2418
+ "drawer.noOutput": "(无输出)",
2390
2419
  "drawer.runOverlaps": "同时写入",
2391
2420
  "drawer.runLessons": "读取了 {count} 条经验",
2392
2421
  "drawer.runNoLessons": "没有可读取的经验",
@@ -3244,15 +3273,6 @@ function supervisorWorkerCount(row) {
3244
3273
  return found ? total : null;
3245
3274
  }
3246
3275
 
3247
- function taskDisplayTitle(title) {
3248
- const full = asString(title);
3249
- if (!full) return full;
3250
- const stripped = full
3251
- .replace(/^[\w.-]+\/[A-Za-z]?\d+\s*[::]\s*/, "")
3252
- .replace(/^[A-Za-z]+-\d+\s*[::]\s*/, "");
3253
- return stripped || full;
3254
- }
3255
-
3256
3276
  function element(doc, tag, className, text) {
3257
3277
  const node = doc.createElement(tag);
3258
3278
  if (className) node.className = className;
@@ -5499,6 +5519,143 @@ export function mount(root, options = {}) {
5499
5519
  * @param {object|null} run - normalized `lastRun` (see normalizeLastRun)
5500
5520
  * @returns {HTMLElement}
5501
5521
  */
5522
+ function safeMarkdownHref(raw) {
5523
+ const href = asString(raw).trim();
5524
+ if (!href) return "";
5525
+ if (/^(https?:\/\/|mailto:)/i.test(href)) return href;
5526
+ if (href.startsWith("#") || href.startsWith("/")) return href;
5527
+ return "";
5528
+ }
5529
+
5530
+ function markdownTextNode(doc, text) {
5531
+ if (typeof doc.createTextNode === "function") return doc.createTextNode(text);
5532
+ const node = doc.createElement("span");
5533
+ node.textContent = text;
5534
+ return node;
5535
+ }
5536
+
5537
+ function appendInlineMarkdown(doc, parent, text) {
5538
+ const pattern = /(\x60[^\x60\n]+\x60|\*\*[^*\n]+\*\*|__[^_\n]+__|\*[^*\n]+\*|_[^_\n]+_|\[[^\]\n]+\]\([^)\n]+\))/g;
5539
+ let last = 0;
5540
+ let match = pattern.exec(text);
5541
+ while (match) {
5542
+ if (match.index > last) parent.appendChild(markdownTextNode(doc, text.slice(last, match.index)));
5543
+ const token = match[0];
5544
+ if (token.startsWith("\x60") && token.endsWith("\x60")) {
5545
+ parent.appendChild(element(doc, "code", "hive-md-code-inline", token.slice(1, -1)));
5546
+ } else if ((token.startsWith("**") && token.endsWith("**")) || (token.startsWith("__") && token.endsWith("__"))) {
5547
+ parent.appendChild(element(doc, "strong", null, token.slice(2, -2)));
5548
+ } else if ((token.startsWith("*") && token.endsWith("*")) || (token.startsWith("_") && token.endsWith("_"))) {
5549
+ parent.appendChild(element(doc, "em", null, token.slice(1, -1)));
5550
+ } else if (token.startsWith("[")) {
5551
+ const link = /^\[([^\]]+)\]\(([^)]+)\)$/.exec(token);
5552
+ const href = link ? safeMarkdownHref(link[2]) : "";
5553
+ if (link && href) {
5554
+ const anchor = element(doc, "a", "hive-md-link", link[1]);
5555
+ setAttr(anchor, "href", href);
5556
+ setAttr(anchor, "rel", "noreferrer noopener");
5557
+ parent.appendChild(anchor);
5558
+ } else {
5559
+ parent.appendChild(markdownTextNode(doc, token));
5560
+ }
5561
+ } else {
5562
+ parent.appendChild(markdownTextNode(doc, token));
5563
+ }
5564
+ last = pattern.lastIndex;
5565
+ match = pattern.exec(text);
5566
+ }
5567
+ if (last < text.length) parent.appendChild(markdownTextNode(doc, text.slice(last)));
5568
+ }
5569
+
5570
+ function renderMarkdownInto(doc, host, source) {
5571
+ const lines = String(source).replace(/\r\n?/g, "\n").split("\n");
5572
+ let index = 0;
5573
+ let paragraph = [];
5574
+ const flushParagraph = () => {
5575
+ if (paragraph.length === 0) return;
5576
+ const p = element(doc, "p", "hive-md-p");
5577
+ appendInlineMarkdown(doc, p, paragraph.join("\n"));
5578
+ host.appendChild(p);
5579
+ paragraph = [];
5580
+ };
5581
+
5582
+ while (index < lines.length) {
5583
+ const line = lines[index];
5584
+ if (/^\s*\x60\x60\x60/.test(line)) {
5585
+ flushParagraph();
5586
+ const fence = /^\s*\x60\x60\x60\s*([^\s]*)/.exec(line);
5587
+ const language = fence ? fence[1] : "";
5588
+ const codeLines = [];
5589
+ index += 1;
5590
+ while (index < lines.length && !/^\s*\x60\x60\x60/.test(lines[index])) {
5591
+ codeLines.push(lines[index]);
5592
+ index += 1;
5593
+ }
5594
+ if (index < lines.length) index += 1;
5595
+ const pre = element(doc, "pre", "hive-md-code-block");
5596
+ if (language) setAttr(pre, "data-lang", language);
5597
+ const code = element(doc, "code", null, codeLines.join("\n"));
5598
+ pre.appendChild(code);
5599
+ host.appendChild(pre);
5600
+ continue;
5601
+ }
5602
+ if (/^\s*$/.test(line)) {
5603
+ flushParagraph();
5604
+ index += 1;
5605
+ continue;
5606
+ }
5607
+ const heading = /^\s*(#{1,6})\s+(.*)$/.exec(line);
5608
+ if (heading) {
5609
+ flushParagraph();
5610
+ const level = heading[1].length;
5611
+ const node = element(doc, "h" + String(level), "hive-md-heading");
5612
+ appendInlineMarkdown(doc, node, heading[2]);
5613
+ host.appendChild(node);
5614
+ index += 1;
5615
+ continue;
5616
+ }
5617
+ if (/^\s*>\s?/.test(line)) {
5618
+ flushParagraph();
5619
+ const quote = element(doc, "blockquote", "hive-md-quote");
5620
+ while (index < lines.length && /^\s*>\s?/.test(lines[index])) {
5621
+ const p = element(doc, "p", "hive-md-p");
5622
+ appendInlineMarkdown(doc, p, lines[index].replace(/^\s*>\s?/, ""));
5623
+ quote.appendChild(p);
5624
+ index += 1;
5625
+ }
5626
+ host.appendChild(quote);
5627
+ continue;
5628
+ }
5629
+ if (/^\s*[-*+]\s+/.test(line)) {
5630
+ flushParagraph();
5631
+ const list = element(doc, "ul", "hive-md-list");
5632
+ while (index < lines.length && /^\s*[-*+]\s+/.test(lines[index])) {
5633
+ const item = element(doc, "li", null);
5634
+ appendInlineMarkdown(doc, item, lines[index].replace(/^\s*[-*+]\s+/, ""));
5635
+ list.appendChild(item);
5636
+ index += 1;
5637
+ }
5638
+ host.appendChild(list);
5639
+ continue;
5640
+ }
5641
+ if (/^\s*\d+[.)]\s+/.test(line)) {
5642
+ flushParagraph();
5643
+ const list = element(doc, "ol", "hive-md-list");
5644
+ while (index < lines.length && /^\s*\d+[.)]\s+/.test(lines[index])) {
5645
+ const item = element(doc, "li", null);
5646
+ appendInlineMarkdown(doc, item, lines[index].replace(/^\s*\d+[.)]\s+/, ""));
5647
+ list.appendChild(item);
5648
+ index += 1;
5649
+ }
5650
+ host.appendChild(list);
5651
+ continue;
5652
+ }
5653
+ paragraph.push(line);
5654
+ index += 1;
5655
+ }
5656
+ flushParagraph();
5657
+ }
5658
+
5502
5659
  function buildRunSection(run, actionHost) {
5503
5660
  const section = element(doc, "div", "hive-card-run");
5504
5661
  const addAction = (node) => {
@@ -5544,7 +5701,14 @@ export function mount(root, options = {}) {
5544
5701
  ? translate("drawer.runLessons").replace("{count}", String(lessonCount))
5545
5702
  : translate("drawer.runNoLessons");
5546
5703
  section.appendChild(element(doc, "div", "hive-card-run-meta", lessonsText));
5547
- section.appendChild(element(doc, "pre", "hive-card-run-output", run.output));
5704
+ const output = element(doc, "div", "hive-card-run-output hive-markdown");
5705
+ const outputText = asString(run.output);
5706
+ if (outputText.trim() === "") {
5707
+ output.appendChild(element(doc, "div", "hive-markdown-empty", translate("drawer.noOutput")));
5708
+ } else {
5709
+ renderMarkdownInto(doc, output, outputText);
5710
+ }
5711
+ section.appendChild(output);
5548
5712
  const foot = element(doc, "div", "hive-card-run-foot");
5549
5713
  const copy = element(doc, "button", "hive-btn hive-btn-ghost hive-card-run-copy", translate("drawer.copyOutput"));
5550
5714
  setAttr(copy, "type", "button");
@@ -6363,8 +6527,7 @@ export function mount(root, options = {}) {
6363
6527
 
6364
6528
  function renderCard(card, lane, existing) {
6365
6529
  const node = existing || element(doc, "article", "hive-card");
6366
- const fullTitle = card.title || translate("card.untitled");
6367
- const title = taskDisplayTitle(fullTitle);
6530
+ const title = card.title || translate("card.untitled");
6368
6531
  if (!existing) {
6369
6532
  setAttr(node, "tabindex", "0");
6370
6533
  setAttr(node, "role", "button");
@@ -6382,8 +6545,8 @@ export function mount(root, options = {}) {
6382
6545
  node._hiveCard = card;
6383
6546
  node._hiveLane = lane;
6384
6547
  node._hiveTitle.textContent = title;
6385
- setAttr(node, "aria-label", translate("card.openAria") + " " + fullTitle);
6386
- setAttr(node, "title", fullTitle);
6548
+ setAttr(node, "aria-label", translate("card.openAria") + " " + title);
6549
+ setAttr(node, "title", title);
6387
6550
  return node;
6388
6551
  }
6389
6552
  function renderStageChips(model) {