wezard 2.8.6 → 2.8.7

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.
Files changed (65) hide show
  1. package/CLAUDE.md +1 -1
  2. package/README.md +2 -0
  3. package/cli/wezard.sh +7 -0
  4. package/dist/cli/codex-hook.js +6 -1
  5. package/dist/cli/codex-hook.js.map +1 -1
  6. package/dist/cli/sync.js +37 -7
  7. package/dist/cli/sync.js.map +1 -1
  8. package/dist/daemon/approval.js +83 -69
  9. package/dist/daemon/approval.js.map +1 -1
  10. package/dist/daemon/danger.js +20 -3
  11. package/dist/daemon/danger.js.map +1 -1
  12. package/dist/daemon/http.js +5 -1
  13. package/dist/daemon/http.js.map +1 -1
  14. package/dist/daemon/inbound.js +33 -0
  15. package/dist/daemon/inbound.js.map +1 -1
  16. package/dist/daemon/index.js +11 -7
  17. package/dist/daemon/index.js.map +1 -1
  18. package/dist/daemon/mcp-http.js +77 -0
  19. package/dist/daemon/mcp-http.js.map +1 -0
  20. package/dist/daemon/message-events.js +1 -1
  21. package/dist/daemon/message-events.js.map +1 -1
  22. package/dist/daemon/mirror-bridge.js +53 -19
  23. package/dist/daemon/mirror-bridge.js.map +1 -1
  24. package/dist/daemon/peers.js +9 -8
  25. package/dist/daemon/peers.js.map +1 -1
  26. package/dist/daemon/pending.js.map +1 -1
  27. package/dist/daemon/picker-policy.js +16 -6
  28. package/dist/daemon/picker-policy.js.map +1 -1
  29. package/dist/daemon/repl-script.js +22 -0
  30. package/dist/daemon/repl-script.js.map +1 -0
  31. package/dist/daemon/router.js +15 -6
  32. package/dist/daemon/router.js.map +1 -1
  33. package/dist/daemon/session-cache.js.map +1 -1
  34. package/dist/daemon/spawn-tmux.js +5 -1
  35. package/dist/daemon/spawn-tmux.js.map +1 -1
  36. package/dist/daemon/steward-guard.js +2 -13
  37. package/dist/daemon/steward-guard.js.map +1 -1
  38. package/dist/daemon/wizard.js +1 -1
  39. package/dist/daemon/wizard.js.map +1 -1
  40. package/dist/mcp/server.js +5 -667
  41. package/dist/mcp/server.js.map +1 -1
  42. package/dist/mcp/tools.js +688 -0
  43. package/dist/mcp/tools.js.map +1 -0
  44. package/dist/shared/chat-view.js +1 -1
  45. package/dist/shared/chat-view.js.map +1 -1
  46. package/dist/shared/config.js +16 -2
  47. package/dist/shared/config.js.map +1 -1
  48. package/dist/shared/detail-render.js +2 -1
  49. package/dist/shared/detail-render.js.map +1 -1
  50. package/dist/shared/hook-mode.js +31 -0
  51. package/dist/shared/hook-mode.js.map +1 -0
  52. package/dist/shared/modal-pane.js +79 -9
  53. package/dist/shared/modal-pane.js.map +1 -1
  54. package/dist/shared/plan.js +4 -0
  55. package/dist/shared/plan.js.map +1 -1
  56. package/dist/shared/tool-hints.js +13 -4
  57. package/dist/shared/tool-hints.js.map +1 -1
  58. package/dist/shared/turn-state.js +1 -1
  59. package/dist/shared/turn-state.js.map +1 -1
  60. package/dist/shared/world.js +3 -2
  61. package/dist/shared/world.js.map +1 -1
  62. package/hooks/pre-tool-use.sh +48 -5
  63. package/package.json +1 -1
  64. package/web/chat.css +88 -20
  65. package/web/chat.js +136 -18
package/web/chat.css CHANGED
@@ -765,31 +765,99 @@ button.mchip.rcpt:hover { text-decoration: underline }
765
765
  .plan-state-paused .plan-state-tag { color: #8250df; background: #fbefff; }
766
766
  .plan-state-completed .plan-state-tag { color: #1a7f37; background: #dafbe1; }
767
767
  .plan-state-canceled .plan-state-tag { color: #cf222e; background: #ffebe9; }
768
- .plan-graph { max-width: 100%; margin-top: 8px; overflow: auto; overscroll-behavior-inline: contain; border: 1px solid var(--line); border-radius: 9px; background: #f8fafc }
768
+ /* DAG 自上而下: 根层在最上, 依赖逐层向下; 同层并排、宽随内容。
769
+ 层间留出箭头走的竖向空隙 (row-gap), 节点多时在 .plan-graph 盒内滚动, 不撑破页面。 */
770
+ .plan-graph { max-width: 100%; max-height: clamp(360px, 65vh, 860px); margin-top: 8px; overflow: auto; overscroll-behavior: contain; border: 1px solid #e7ebf1; border-radius: 10px; background: #fafbfc }
769
771
  .plan-graph-inner { position: relative; width: max-content; min-width: 100%; padding: 12px; }
770
772
  .plan-edges { position: absolute; z-index: 0; inset: 0; overflow: visible; pointer-events: none; }
771
- .plan-edge { fill: none; stroke: #8c98a8; stroke-width: 1.6; }
772
- .plan-arrow-tip { fill: #8c98a8; }
773
- .plan-layers { position: relative; z-index: 1; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(210px, 260px); align-items: start; gap: 28px; width: max-content; }
774
- .plan-layer { display: grid; align-content: start; gap: 12px; min-width: 0; }
775
- .plan-node { min-width: 0; padding: 10px; border: 1px solid #d0d7de; border-left: 3px solid #8c98a8; border-radius: 8px; background: #fff; box-shadow: 0 1px 2px #1f23280d; overflow-wrap: anywhere; }
776
- .plan-node-head { display: flex; align-items: flex-start; gap: 7px; min-width: 0; }
777
- .plan-node-head > b { min-width: 0; flex: 1; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; font-size: 13px; line-height: 1.45; }
778
- .plan-node .task-tag { flex: none; white-space: nowrap; }
779
- .plan-node.task-pending { border-left-color: #8c959f; }
780
- .plan-node.task-in_progress { border-left-color: #0969da; background: #f6faff; }
781
- .plan-node.task-completed { border-left-color: #1a7f37; background: #f6fff8; }
782
- .plan-node.task-canceled { border-left-color: #cf222e; background: #fff8f8; }
783
- .plan-deps { display: block; margin-top: 7px; color: var(--faint); font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
784
- .plan-node-desc, .plan-progress, .plan-result { margin: 7px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--mute); font-size: 12px; line-height: 1.5; }
785
- .plan-progress b, .plan-result b { display: block; color: var(--ink); font-size: 11px; }
773
+ /* 边线比卡边 (--line) 更浅一档、箭头小一号同色 —— 线退到背景层, 卡是主体。 */
774
+ .plan-edge { fill: none; stroke: #dee3ea; stroke-width: 1.2; }
775
+ .plan-arrow-tip { fill: #dee3ea; }
776
+ .plan-layers { position: relative; z-index: 1; display: grid; grid-auto-flow: row; gap: 60px; width: max-content; min-width: 100%; }
777
+ .plan-layer { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(184px, 240px); align-items: stretch; column-gap: 12px; justify-content: center; min-width: 0; }
778
+ /* 节点一律同一套静态样式: 无 per-status 底色/边色 (状态只压在徽标上), 无高亮/选中/pulse。
779
+ flex 纵列 + min-height(按"meta+两行标题+footer"撑满, ~90px): 同层 stretch 等高之外,
780
+ 跨层也保持统一高度; footer 靠 margin-top:auto 贴卡底, 卡内留白落在标题与注脚之间。 */
781
+ .plan-node { display: flex; flex-direction: column; min-width: 0; min-height: 90px; padding: 7px 10px 5px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }
782
+ .plan-node:hover { border-color: #b9c3d3 }
783
+ .plan-node:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px }
784
+ /* 第一行 meta: 徽标 | 执行者 —— 同一文字高度轴, 间距 6px; model·ctx 已挪去卡底 footer。 */
785
+ .pn-meta { display: flex; align-items: center; gap: 6px; min-width: 0; }
786
+ /* 状态徽标 (基础形态, 详情浮层用): 字形分态 (○/◔/✓/✕), 配色沿用 rolepage 状态色。 */
787
+ .task-badge { flex: none; white-space: nowrap; font-size: 10px; line-height: 1.6; padding: 0 6px; border-radius: 999px; }
788
+ .task-badge.tb-pending { color: #57606a; background: #eff1f3; }
789
+ .task-badge.tb-in_progress { color: #0969da; background: #ddf4ff; }
790
+ .task-badge.tb-completed { color: #1a7f37; background: #dafbe1; }
791
+ .task-badge.tb-canceled { color: #cf222e; background: #ffebe9; }
792
+ /* 卡内状态: 去胶囊 —— 只剩字形+颜色+小字, 这一行的"实体"只剩执行者头像。
793
+ 放在 tb-* 之后压掉它的底色 (同特异度, 后者胜)。 */
794
+ .pn-meta .task-badge { height: auto; line-height: inherit; font-size: 10.5px; padding: 0; border-radius: 0; background: none; }
795
+ /* 执行者: 复用 .wchip 的读法 (头像 emoji + .名字), 但卡内去实体 —— 无底无框,
796
+ 名字 11px 中灰; 可点的 (go) 靠指针与 hover 下划线示意, 不再靠蓝字蓝框
797
+ (进行中的状态蓝与执行者蓝曾在此撞色)。owner 兜底淡一档 + owner 标;
798
+ 名字认不出 → 纯文本, 同样 11px 中灰、降透明度, 形状语汇与 chip 一致。 */
799
+ .pn-ex { display: inline-flex; align-items: center; gap: 4px; flex: 0 1 auto; min-width: 0; }
800
+ /* 注: 头像 emoji 与名字是同一文本节点同一行盒 (Range 实测不可分离) —— 本就共基线;
801
+ 3x 下可见的"抖"是 emoji 字形自身在基线上方的光学偏移 (字体度量), CSS 改不动,
802
+ 除非给头像单独包元素 (需改共享的 wizChip, 影响所有 chip, 超出本轮)。 */
803
+ .pn-ex .wchip { height: auto; max-width: 100%; padding: 0; font-size: 11px; gap: 4px; background: none; border-color: transparent; color: var(--mute); }
804
+ .pn-ex .wchip.go { border-color: transparent; color: var(--mute); }
805
+ .pn-ex .wchip.go:hover { background: none; border-color: transparent; color: var(--ink); text-decoration: underline; }
806
+ .pn-ex.is-owner { opacity: .72 }
807
+ .pn-ex-plain { font-size: 11px; color: var(--mute); opacity: .82; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
808
+ .ex-mark { font-style: normal; font-size: 11px; line-height: inherit; color: var(--mute); padding-left: 2px; flex: none }
809
+ /* 卡底 footer: model · ctx 注脚 —— 无衬线 11px、--mute (比旧 --faint 深一档);
810
+ 等宽只给 model id 那一小段, ctx 去图标只留数字 (tabular-nums), 分隔符收紧不留大片空隙;
811
+ 仍单行省略。model 是实际模型 id, ctx 与用量条同口径。 */
812
+ .pn-foot { margin-top: auto; padding-top: 3px; border-top: 1px solid #eef1f5;
813
+ font-size: 11px; line-height: 1.35; color: var(--mute); text-align: left;
814
+ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
815
+ /* 空 footer 也生成一个真实行盒 (NBSP): 与有文字的 footer 同高, 同层注脚线严格齐平 ——
816
+ min-height 做不到 (不含行盒, 差一条 line-height)。 */
817
+ .pn-foot:empty::before { content: '\00a0'; }
818
+ .pn-foot .pn-model { font-family: ui-monospace, Menlo, monospace; font-size: 10px; }
819
+ .pn-foot .pn-ctx { font-variant-numeric: tabular-nums; }
820
+ .pn-foot .pn-sep { font-style: normal; color: var(--faint); margin: 0 4px; }
821
+ /* 第二行: 标题, 最多两行再省略 (全文在 title 悬停) —— 全卡视觉重心。
822
+ 左对齐: 与 meta 行、footer 共用同一左轴, 多卡并排时整列左缘整齐 (居中会让三行各有一条轴)。 */
823
+ .pn-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
824
+ margin: 3px 0 0; min-width: 0; font-size: 12px; font-weight: 600; line-height: 17px; text-align: left; overflow-wrap: anywhere; }
825
+ .pn-dot { font-style: normal; color: var(--faint); flex: none }
826
+
827
+ /* ── 任务详情浮层 ── */
828
+ .task-detail { display: none; }
829
+ .task-detail.on { display: block; }
830
+ .td-backdrop { position: fixed; inset: 0; z-index: 60; background: #1c243055; }
831
+ .td-card { position: fixed; z-index: 61; left: 50%; top: 50%; transform: translate(-50%, -50%);
832
+ width: min(560px, calc(100vw - 28px)); max-height: min(78vh, 720px); overflow-y: auto;
833
+ background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 12px; }
834
+ .td-close { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border: 0; border-radius: 7px;
835
+ background: transparent; color: var(--mute); font-size: 13px; line-height: 1; cursor: pointer; }
836
+ .td-close:hover { background: var(--paper); color: var(--ink); }
837
+ .td-card h4 { margin: 2px 30px 8px 0; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
838
+ .td-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
839
+ .td-pause { font-size: 11px; color: #8250df; }
840
+ .td-sec { margin-top: 10px; border-top: 1px solid #eef1f5; padding-top: 8px; }
841
+ .td-sec h5 { margin: 0 0 5px; font-size: 11px; font-weight: 600; color: var(--mute); }
842
+ .td-sec p { margin: 0; font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
843
+ .td-sec ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; }
844
+ .td-sec li { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 12px; }
845
+ .td-sec li > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
846
+ .td-ex { display: flex; align-items: center; gap: 6px; }
847
+ .td-ex-meta { margin-top: 5px; font-size: 11px; color: var(--faint); display: flex; align-items: baseline; gap: 6px; min-width: 0; flex-wrap: wrap; }
848
+ .td-ex-meta .pn-model { font-family: ui-monospace, Menlo, monospace; }
849
+ .td-ex-plain { font-size: 12px; color: var(--mute); }
850
+ .td-foot { margin-top: 12px; padding-top: 8px; border-top: 1px solid #eef1f5; font-size: 11px; color: var(--faint); line-height: 1.6; }
786
851
  .plan-graph-empty { margin-top: 8px; }
787
852
  @media (max-width: 600px) {
853
+ .plan-graph { max-height: clamp(320px, 60vh, 720px); }
788
854
  .plan-graph-inner { padding: 10px; }
789
- .plan-layers { grid-auto-columns: minmax(0, min(260px, calc(100vw - 122px))); gap: 24px; }
790
- .plan-node { padding: 10px; }
791
- .plan-node-head > b { font-size: 13px; }
792
- .plan-node-desc, .plan-progress, .plan-result { font-size: 12px; }
855
+ .plan-layers { gap: 48px; }
856
+ .plan-layer { grid-auto-columns: minmax(0, min(240px, calc(100vw - 122px))); column-gap: 10px; }
857
+ .plan-node { padding: 7px 8px 6px; }
858
+ .pn-title { font-size: 11.5px; }
859
+ .td-card { top: auto; bottom: 0; left: 0; right: 0; transform: none;
860
+ width: auto; max-height: 82vh; border-radius: 14px 14px 0 0; border-bottom: 0; }
793
861
  }
794
862
  @keyframes flash { 0% { box-shadow: 0 0 0 4px #9a670055 } 100% { box-shadow: 0 0 0 4px #9a670000 } }
795
863
  .tc-time {
package/web/chat.js CHANGED
@@ -2107,6 +2107,20 @@
2107
2107
  '</div>';
2108
2108
  };
2109
2109
  var PLAN_OPEN = {};
2110
+ // plan 节点状态徽标的字形: ○ 未动 / ◔ 进行 / ✓ 完 / ✕ 取消 —— 形状先分态, 颜色只是加强 (色弱可辨)。
2111
+ var TASK_BADGE = { pending: '○', in_progress: '◔', completed: '✓', canceled: '✕' };
2112
+ var TASK_WORD = { pending: '待处理', in_progress: '进行中', completed: '已完成', canceled: '已取消' };
2113
+ var planOwnerNode = function (p) {
2114
+ return (W.nodes || []).filter(function (n) { return n.target === p.owner; })[0] || null;
2115
+ };
2116
+ // 执行者解析: task.executor (wizard 全局名字, 带不带点都行, 大小写不敏感) → world 节点;
2117
+ // 没写 → plan owner (owner: true, 展示时淡一档并标 owner); 写了但名册里认不出 → 保留名字纯文本, 不造头像。
2118
+ var executorOf = function (t, ownerNode) {
2119
+ if (!t.executor) return { node: ownerNode, owner: true, name: '' };
2120
+ var want = String(t.executor).replace(/^\./, '').toLowerCase();
2121
+ var hit = (W.nodes || []).filter(function (n) { return String(n.name || '').replace(/^\./, '').toLowerCase() === want; })[0] || null;
2122
+ return { node: hit, owner: false, name: String(t.executor).replace(/^\./, '') };
2123
+ };
2110
2124
  var taskHTML = function (x) {
2111
2125
  var lines = String(x.prompt || '').split('\n');
2112
2126
  var head = x.note || lines[0];
@@ -2142,19 +2156,23 @@
2142
2156
  var byId = Object.create(null), bounds = innerGraph.getBoundingClientRect();
2143
2157
  Array.prototype.forEach.call(nodes, function (node) {
2144
2158
  var box = node.getBoundingClientRect();
2159
+ // 自上而下: 锚点是节点的下沿/上沿中点 —— 边从上游底部垂到下游顶部。
2145
2160
  byId[node.getAttribute('data-task-id')] = {
2146
- left: box.left - bounds.left + innerGraph.scrollLeft,
2147
- right: box.right - bounds.left + innerGraph.scrollLeft,
2148
- y: (box.top + box.bottom) / 2 - bounds.top + innerGraph.scrollTop
2161
+ cx: box.left + box.width / 2 - bounds.left,
2162
+ bottom: box.bottom - bounds.top,
2163
+ top: box.top - bounds.top
2149
2164
  };
2150
2165
  });
2151
- var width = Math.max(innerGraph.scrollWidth, innerGraph.clientWidth);
2152
- var height = Math.max(innerGraph.scrollHeight, innerGraph.clientHeight);
2166
+ // 尺寸只看 inner 自身 (clientWidth/Height 已含 padding, 且 width:max-content 时就是内容宽):
2167
+ // 不能用 scrollWidth —— svg 是 inner 的绝对定位子元素, 它自己的溢出会反过来把 scrollWidth 撑住,
2168
+ // 缩窗后 svg 就粘在旧宽度上, 图盒出现一段滚不到底的空白。
2169
+ var width = innerGraph.clientWidth;
2170
+ var height = innerGraph.clientHeight;
2153
2171
  svg.setAttribute('width', width); svg.setAttribute('height', height); svg.setAttribute('viewBox', '0 0 ' + width + ' ' + height);
2154
2172
  var markerId = 'plan-arrow-' + Array.prototype.indexOf.call(planEl.querySelectorAll('.plan-graph-inner'), innerGraph);
2155
2173
  var defs = document.createElementNS('http://www.w3.org/2000/svg', 'defs');
2156
2174
  var marker = document.createElementNS('http://www.w3.org/2000/svg', 'marker');
2157
- marker.setAttribute('id', markerId); marker.setAttribute('viewBox', '0 0 8 8'); marker.setAttribute('refX', '7'); marker.setAttribute('refY', '4'); marker.setAttribute('markerWidth', '7'); marker.setAttribute('markerHeight', '7'); marker.setAttribute('orient', 'auto');
2175
+ marker.setAttribute('id', markerId); marker.setAttribute('viewBox', '0 0 8 8'); marker.setAttribute('refX', '7'); marker.setAttribute('refY', '4'); marker.setAttribute('markerWidth', '5.5'); marker.setAttribute('markerHeight', '5.5'); marker.setAttribute('orient', 'auto');
2158
2176
  var tip = document.createElementNS('http://www.w3.org/2000/svg', 'path');
2159
2177
  tip.setAttribute('d', 'M0 0L8 4L0 8Z'); tip.setAttribute('class', 'plan-arrow-tip'); marker.appendChild(tip); defs.appendChild(marker); svg.appendChild(defs);
2160
2178
  Array.prototype.forEach.call(nodes, function (node) {
@@ -2164,9 +2182,9 @@
2164
2182
  dependencies.forEach(function (dependency) {
2165
2183
  var source = byId[dependency];
2166
2184
  if (!source || !target) return;
2167
- var x1 = source.right, x2 = target.left, bend = Math.max(24, (x2 - x1) * 0.45);
2185
+ var x1 = source.cx, x2 = target.cx, y1 = source.bottom, y2 = target.top, bend = Math.max(18, (y2 - y1) * 0.42);
2168
2186
  var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
2169
- path.setAttribute('d', 'M' + x1 + ' ' + source.y + ' C' + (x1 + bend) + ' ' + source.y + ' ' + (x2 - bend) + ' ' + target.y + ' ' + x2 + ' ' + target.y);
2187
+ path.setAttribute('d', 'M' + x1 + ' ' + y1 + ' C' + x1 + ' ' + (y1 + bend) + ' ' + x2 + ' ' + (y2 - bend) + ' ' + x2 + ' ' + y2);
2170
2188
  path.setAttribute('class', 'plan-edge'); path.setAttribute('marker-end', 'url(#' + markerId + ')'); svg.appendChild(path);
2171
2189
  });
2172
2190
  });
@@ -2179,6 +2197,64 @@
2179
2197
  };
2180
2198
  window.addEventListener('resize', redrawPlanEdges);
2181
2199
 
2200
+ // ── 任务详情浮层: 卡片被压到一眼可扫, 详尽信息 (描述/依赖/进度/结果/执行者/计划账) 都在这里。
2201
+ // 每一节都有真实数据才渲染; 没有的字段整节不出。backdrop / ✕ / Esc 三种关法。 ──
2202
+ var taskDetail = null;
2203
+ var hideTaskDetail = function () {
2204
+ if (!taskDetail || !taskDetail.classList.contains('on')) return;
2205
+ taskDetail.classList.remove('on');
2206
+ document.removeEventListener('keydown', taskDetail._esc);
2207
+ };
2208
+ var showTaskDetail = function (p, t) {
2209
+ if (!taskDetail) {
2210
+ taskDetail = document.createElement('div');
2211
+ taskDetail.className = 'task-detail';
2212
+ taskDetail.innerHTML = '<div class="td-backdrop"></div><div class="td-card" role="dialog" aria-modal="true" aria-label="任务详情"></div>';
2213
+ taskDetail.querySelector('.td-backdrop').onclick = hideTaskDetail;
2214
+ document.body.appendChild(taskDetail);
2215
+ }
2216
+ var badge = function (s) {
2217
+ return '<span class="task-badge tb-' + esc(s) + '">' + esc(TASK_BADGE[s] || '•') + ' ' + esc(TASK_WORD[s] || s) + '</span>';
2218
+ };
2219
+ var tasksById = Object.create(null);
2220
+ (p.tasks || []).forEach(function (x) { tasksById[x.id] = x; });
2221
+ var known = function (id) { return Object.prototype.hasOwnProperty.call(tasksById, id); };
2222
+ var li = function (x) { return '<li>' + badge(x.status) + '<span title="' + esc(x.title) + '">' + esc(x.title) + '</span></li>'; };
2223
+ var ups = (t.dependsOn || []).filter(known).map(function (id) { return li(tasksById[id]); });
2224
+ var downs = (p.tasks || []).filter(function (x) { return (x.dependsOn || []).indexOf(t.id) >= 0; }).map(li);
2225
+ var ex = executorOf(t, planOwnerNode(p));
2226
+ var planState = { active: '进行中', paused: '已暂停', completed: '已完成', canceled: '已取消' }[p.state] || p.state;
2227
+ var exBody = ex.node
2228
+ ? '<div class="td-ex">' + wizChip(ex.node.target) + (ex.owner ? '<i class="ex-mark" title="未指派执行者, 显示 plan owner">· owner</i>' : '') + '</div>' +
2229
+ '<div class="td-ex-meta">' + [
2230
+ ex.node.model ? '<span title="模型 ' + esc(ex.node.model) + '">' + esc(ex.node.model) + '</span>' : '',
2231
+ ex.node.ctx ? '<span title="上下文 — 最近一次请求送入的 input + 缓存">📄 ' + esc(fmtTok(ex.node.ctx)) + '</span>' : '',
2232
+ ].filter(Boolean).join('<i class="pn-dot">·</i>') + '</div>'
2233
+ : (ex.name ? '<div class="td-ex-plain" title="执行者名字此刻不在 world 名册">' + esc(ex.name) + '</div>' : '');
2234
+ var sec = function (h, body) { return body ? '<div class="td-sec"><h5>' + h + '</h5>' + body + '</div>' : ''; };
2235
+ taskDetail.querySelector('.td-card').innerHTML =
2236
+ '<button class="td-close" aria-label="关闭详情">✕</button>' +
2237
+ '<h4 title="' + esc(t.title) + '">' + esc(t.title) + '</h4>' +
2238
+ '<div class="td-row">' + badge(t.status) +
2239
+ (p.state === 'paused' ? '<span class="td-pause" title="整个 plan 暂停中">计划已暂停' + (p.reason ? ' · ' + esc(p.reason) : '') + '</span>' : '') + '</div>' +
2240
+ sec('执行者', exBody) +
2241
+ sec('上游依赖', ups.length ? '<ul>' + ups.join('') + '</ul>' : '') +
2242
+ sec('下游任务', downs.length ? '<ul>' + downs.join('') + '</ul>' : '') +
2243
+ sec('描述', t.description ? '<p>' + esc(t.description) + '</p>' : '') +
2244
+ sec('进度', t.progress ? '<p>' + esc(t.progress) + '</p>' : '') +
2245
+ sec('结果', t.result ? '<p>' + esc(t.result) + '</p>' : '') +
2246
+ '<div class="td-foot" title="task 本身不记时间, 这里是 plan 一级的账">计划 ' + esc(p.title) + ' · ' + esc(planState) + ' · r' + esc(p.revision) +
2247
+ ' · 更新 ' + esc(fmtClock(p.updatedAt)) + ' · 创建 ' + esc(fmtClock(p.createdAt)) + '</div>';
2248
+ var card = taskDetail.querySelector('.td-card');
2249
+ card.querySelector('.td-close').onclick = hideTaskDetail;
2250
+ card.querySelectorAll('.wchip.go').forEach(function (c) {
2251
+ c.onclick = function (ev) { ev.stopPropagation(); hideTaskDetail(); openNode(c.getAttribute('data-t')); };
2252
+ });
2253
+ taskDetail._esc = function (e) { if (e.key === 'Escape') hideTaskDetail(); };
2254
+ document.addEventListener('keydown', taskDetail._esc);
2255
+ taskDetail.classList.add('on');
2256
+ };
2257
+
2182
2258
  // 日程与只读 plans 跟着 wizard owner 走。
2183
2259
  var renderPlan = function () {
2184
2260
  var ss = (W.schedules || []).filter(function (x) { return (x.owner || x.createdBy || x.target) === ROLE; });
@@ -2222,18 +2298,53 @@
2222
2298
  }
2223
2299
  var layers = [];
2224
2300
  tasks.forEach(function (task) { (layers[rank[task.id]] || (layers[rank[task.id]] = [])).push(task); });
2225
- var graph = tasks.length ? '<div class="plan-graph" role="region" aria-label="' + esc(p.title) + ' 任务依赖图,可横向滚动">' +
2301
+ // 节点上的 model / ctx 与执行者: task.executor 优先 (executorOf), 没写 / 解不出退 plan owner;
2302
+ // world 节点里没有它、或它没有带 usage 的轮次, 对应项就不渲染, 不造假值。
2303
+ var ownerNode = planOwnerNode(p);
2304
+ // 同层排序 (barycenter): 节点尽量落在它的上游正下方 —— 边更接近竖直、少交叉少穿字。
2305
+ var above = Object.create(null);
2306
+ layers.forEach(function (items, li) {
2307
+ if (li) {
2308
+ var idx = Object.create(null);
2309
+ items.forEach(function (t, i) { idx[t.id] = i; });
2310
+ var bar = function (t) {
2311
+ var ds = (t.dependsOn || []).filter(function (d) { return above[d] !== undefined; });
2312
+ return ds.length ? ds.reduce(function (s, d) { return s + above[d]; }, 0) / ds.length : idx[t.id];
2313
+ };
2314
+ items.sort(function (a, b) { return bar(a) - bar(b) || idx[a.id] - idx[b.id]; });
2315
+ }
2316
+ items.forEach(function (t, i) { above[t.id] = i; });
2317
+ });
2318
+ var graph = tasks.length ? '<div class="plan-graph" role="region" aria-label="' + esc(p.title) + ' 任务依赖图,可滚动">' +
2226
2319
  '<div class="plan-graph-inner"><svg class="plan-edges" aria-hidden="true"></svg><div class="plan-layers">' +
2227
2320
  layers.map(function (items) {
2228
2321
  return '<div class="plan-layer">' + items.map(function (t) {
2229
- var status = { pending: '待处理', in_progress: '进行中', completed: '已完成', canceled: '已取消' }[t.status] || t.status;
2322
+ var status = TASK_WORD[t.status] || t.status;
2323
+ var glyph = TASK_BADGE[t.status] || '•';
2230
2324
  var deps = (t.dependsOn || []).filter(function (dep) { return Object.prototype.hasOwnProperty.call(taskTitles, dep); });
2231
- return '<article class="plan-node task-' + esc(t.status) + '" data-task-id="' + esc(t.id) + '" data-depends-on="' + esc(JSON.stringify(deps)) + '">' +
2232
- '<div class="plan-node-head"><b>' + esc(t.title) + '</b><span class="tag task-tag">' + esc(status) + '</span></div>' +
2233
- (deps.length ? '<small class="plan-deps">依赖:' + esc(deps.map(function (dep) { return taskTitles[dep]; }).join('、')) + '</small>' : '') +
2234
- (t.description ? '<p class="plan-node-desc">' + esc(t.description) + '</p>' : '') +
2235
- (t.progress ? '<p class="plan-progress"><b>进度</b>' + esc(t.progress) + '</p>' : '') +
2236
- (t.result ? '<p class="plan-result"><b>结果</b>' + esc(t.result) + '</p>' : '') +
2325
+ var ex = executorOf(t, ownerNode);
2326
+ // 第一行 meta: 徽标 | 执行者 | model·ctx (右对齐, 弹性收缩); 第二行: 标题 (两行截断)。
2327
+ var exEl = ex.node
2328
+ ? wizChip(ex.node.target) + (ex.owner ? '<i class="ex-mark" title="未指派执行者, 显示 plan owner">· owner</i>' : '')
2329
+ : (ex.name ? '<span class="pn-ex-plain" title="执行者名字此刻不在 world 名册">' + esc(ex.name) + '</span>' : '');
2330
+ var mcParts = ex.node ? [
2331
+ ex.node.model ? '<span class="pn-model">' + esc(ex.node.model) + '</span>' : '',
2332
+ ex.node.ctx ? '<span class="pn-ctx">ctx ' + esc(fmtTok(ex.node.ctx)) + '</span>' : '',
2333
+ ].filter(Boolean) : [];
2334
+ var mcTitle = ex.node ? [
2335
+ ex.node.model ? '模型 ' + ex.node.model : '',
2336
+ ex.node.ctx ? '上下文 ' + fmtTok(ex.node.ctx) + ' (最近一次请求送入的 input + 缓存)' : '',
2337
+ ].filter(Boolean).join(' · ') : '';
2338
+ // 卡片只留一眼可扫的两行 —— 其余 (描述/依赖/进度/结果/时间) 在详情浮层。
2339
+ return '<article class="plan-node task-' + esc(t.status) + '" data-task-id="' + esc(t.id) + '" data-plan="' + esc(p.id) + '" data-depends-on="' + esc(JSON.stringify(deps)) + '" tabindex="0" role="button" aria-label="查看任务 ' + esc(t.title) + ' 详情">' +
2340
+ '<div class="pn-meta">' +
2341
+ '<span class="task-badge tb-' + esc(t.status) + '" title="' + esc(status) + '">' + esc(glyph) + ' ' + esc(status) + '</span>' +
2342
+ (exEl ? '<span class="pn-ex' + (ex.owner ? ' is-owner' : '') + '">' + exEl + '</span>' : '') +
2343
+ '</div>' +
2344
+ '<b class="pn-title" title="' + esc(t.title) + '">' + esc(t.title) + '</b>' +
2345
+ // footer 永远渲染: 没有 model/ctx 就留空行 —— 空行仍占位 (min-height), 保证同层卡片等高、
2346
+ // 注脚分隔线在同层各卡同一高度; 不编占位值。
2347
+ '<div class="pn-foot"' + (mcTitle ? ' title="' + esc(mcTitle) + '"' : '') + '>' + (mcParts.length ? mcParts.join('<i class="pn-sep">·</i>') : '') + '</div>' +
2237
2348
  '</article>';
2238
2349
  }).join('') + '</div>';
2239
2350
  }).join('') + '</div></div></div>' : '<div class="pempty plan-graph-empty">任务图为空 · 完成 0 / 0 · 取消 0</div>';
@@ -2242,7 +2353,7 @@
2242
2353
  (p.description ? '<p>' + esc(p.description) + '</p>' : '') +
2243
2354
  (p.state === 'paused' && p.reason ? '<p class="plan-reason">暂停原因:' + esc(p.reason) + '</p>' : '') +
2244
2355
  '<div class="plan-counts">完成 ' + completed + ' / ' + tasks.length + ' · 取消 ' + canceled + ' · 进行中 ' + inProgress + ' · 待处理 ' + pending + '</div>' +
2245
- '<div class="plan-graph-note">箭头从前置任务指向依赖它的任务 · 左右滑动看全图</div>' + graph + '</div></article>';
2356
+ '<div class="plan-graph-note">箭头从前置任务指向依赖它的任务 · 根在上、依赖逐层向下 · 点击节点看详情</div>' + graph + '</div></article>';
2246
2357
  }).join('') : '<div class="pempty">' + esc(roleName(ROLE)) + ' 名下没有 plans</div>';
2247
2358
  var html = stats + '<section class="psec"><h3>Plans<span>' + ps.length + '</span></h3>' + planCards + '</section>' +
2248
2359
  '<section class="psec">' +
@@ -2259,7 +2370,14 @@
2259
2370
  planEl.querySelectorAll('.plan-graph').forEach(function (graph) { planResizeObserver.observe(graph); });
2260
2371
  }
2261
2372
  planEl.querySelectorAll('.wchip.go').forEach(function (c) {
2262
- c.onclick = function () { openNode(c.getAttribute('data-t')); };
2373
+ c.onclick = function (ev) { ev.stopPropagation(); openNode(c.getAttribute('data-t')); };
2374
+ });
2375
+ planEl.querySelectorAll('.plan-node').forEach(function (n) {
2376
+ n.onclick = function () {
2377
+ var p = ps.filter(function (x) { return x.id === n.getAttribute('data-plan'); })[0];
2378
+ var t = p && (p.tasks || []).filter(function (x) { return x.id === n.getAttribute('data-task-id'); })[0];
2379
+ if (p && t) showTaskDetail(p, t);
2380
+ };
2263
2381
  });
2264
2382
  redrawPlanEdges();
2265
2383
  planEl.querySelectorAll('.pprompt').forEach(function (d) {