@sparkelf/dsh-genui 0.11.4-patch.2 → 0.13.0-sparkelf.2

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 (111) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/ICON-NAMES.md +30 -0
  3. package/README.md +26 -28
  4. package/README.zh-CN.md +26 -28
  5. package/SKILL.md +128 -19
  6. package/THIRD_PARTY_NOTICES.md +42 -0
  7. package/assets/genui-icon.svg +20 -0
  8. package/assets/genui-logo.svg +18 -0
  9. package/lib/assets/icons.js +1 -0
  10. package/lib/assets/mermaid.js +325 -325
  11. package/lib/assets/standalone-runtime.js +10 -9
  12. package/lib/client.js +32 -31
  13. package/lib/index.js +489 -80
  14. package/lib/types/client/action-context.d.ts +1 -1
  15. package/lib/types/client/artifact/types.d.ts +1 -1
  16. package/lib/types/client/asset-loader.d.ts +2 -2
  17. package/lib/types/client/blocks/blocks.d.ts +12 -0
  18. package/lib/types/client/blocks/icon.d.ts +4 -0
  19. package/lib/types/client/dom-fence.d.ts +2 -1
  20. package/lib/types/client/fence-render.d.ts +5 -21
  21. package/lib/types/client/file-address.d.ts +4 -0
  22. package/lib/types/client/file-link-context.d.ts +49 -0
  23. package/lib/types/client/file-link.d.ts +17 -0
  24. package/lib/types/client/gallery.d.ts +8 -2
  25. package/lib/types/client/genui-runtime/diagnostics.d.ts +1 -1
  26. package/lib/types/client/genui-runtime/limits.d.ts +4 -0
  27. package/lib/types/client/genui-runtime/schema.d.ts +14 -1
  28. package/lib/types/client/guard.d.ts +4 -1
  29. package/lib/types/client/i18n/en.d.ts +5 -1
  30. package/lib/types/client/i18n/index.d.ts +1 -1
  31. package/lib/types/client/icons/asset-icons.d.ts +1 -0
  32. package/lib/types/client/icons/icon-data-full.d.ts +23 -0
  33. package/lib/types/client/icons/icon-data.d.ts +24 -0
  34. package/lib/types/client/icons/icon-lazy.d.ts +18 -0
  35. package/lib/types/client/icons/icon-names-full.d.ts +12 -0
  36. package/lib/types/client/index.d.ts +5 -15
  37. package/lib/types/client/inline.d.ts +1 -1
  38. package/lib/types/client/mermaid-colors.d.ts +2 -0
  39. package/lib/types/client/mermaid-core.d.ts +2 -1
  40. package/lib/types/client/mermaid-lazy.d.ts +5 -1
  41. package/lib/types/client/panel-command.d.ts +21 -1
  42. package/lib/types/client/panel.d.ts +6 -1
  43. package/lib/types/client/primitive-adapter.d.ts +0 -2
  44. package/lib/types/client/session-resolver.d.ts +13 -2
  45. package/lib/types/client/source-fence.d.ts +1 -1
  46. package/lib/types/client/spec.d.ts +107 -3
  47. package/lib/types/client/standalone/asset-loader.d.ts +1 -1
  48. package/lib/types/client/standalone/primitive-adapter.d.ts +0 -4
  49. package/lib/types/plugin/fence-feedback.d.ts +11 -7
  50. package/lib/types/plugin/index.d.ts +6 -2
  51. package/lib/types/shared/fence-language.d.ts +14 -0
  52. package/lib/types/shared/fence-repair.d.ts +2 -1
  53. package/lib/types/shared/fence-resolve.d.ts +1 -1
  54. package/package.json +92 -83
  55. package/src/client/EChartNode.tsx +17 -3
  56. package/src/client/GenuiBlock.module.css +411 -76
  57. package/src/client/action-context.ts +5 -15
  58. package/src/client/artifact/ArtifactExport.module.css +34 -3
  59. package/src/client/artifact/ExportableGenuiBlock.tsx +23 -2
  60. package/src/client/artifact/portability.ts +6 -1
  61. package/src/client/artifact/types.ts +1 -1
  62. package/src/client/asset-loader.ts +3 -3
  63. package/src/client/blocks/advanced.tsx +101 -14
  64. package/src/client/blocks/blocks.tsx +143 -0
  65. package/src/client/blocks/charts.tsx +22 -6
  66. package/src/client/blocks/icon.tsx +93 -0
  67. package/src/client/blocks/image.tsx +1 -0
  68. package/src/client/blocks/render-node.tsx +84 -52
  69. package/src/client/dom-fence.tsx +546 -72
  70. package/src/client/fence-render.tsx +5 -21
  71. package/src/client/file-address.ts +37 -0
  72. package/src/client/file-link-context.tsx +116 -0
  73. package/src/client/file-link.ts +46 -0
  74. package/src/client/gallery.ts +161 -133
  75. package/src/client/genui-runtime/diagnostics.ts +1 -1
  76. package/src/client/genui-runtime/limits.ts +4 -0
  77. package/src/client/genui-runtime/normalize.ts +42 -6
  78. package/src/client/genui-runtime/schema.ts +39 -7
  79. package/src/client/guard.ts +170 -15
  80. package/src/client/i18n/en.ts +5 -1
  81. package/src/client/i18n/index.ts +1 -1
  82. package/src/client/i18n/zh.ts +5 -1
  83. package/src/client/icons/asset-icons.ts +16 -0
  84. package/src/client/icons/icon-data-full.ts +5715 -0
  85. package/src/client/icons/icon-data.ts +507 -0
  86. package/src/client/icons/icon-lazy.ts +80 -0
  87. package/src/client/icons/icon-names-full.ts +12 -0
  88. package/src/client/index.tsx +27 -51
  89. package/src/client/inline.ts +17 -6
  90. package/src/client/mermaid-colors.ts +40 -0
  91. package/src/client/mermaid-core.ts +69 -61
  92. package/src/client/mermaid-lazy.ts +99 -4
  93. package/src/client/panel-command.ts +16 -2
  94. package/src/client/panel.tsx +18 -5
  95. package/src/client/primitive-adapter.ts +0 -11
  96. package/src/client/session-resolver.ts +12 -21
  97. package/src/client/source-fence.ts +4 -2
  98. package/src/client/spec.ts +116 -2
  99. package/src/client/standalone/asset-loader.ts +1 -1
  100. package/src/client/standalone/primitive-adapter.tsx +1 -9
  101. package/src/client/table-details.ts +4 -3
  102. package/src/plugin/fence-feedback.ts +60 -14
  103. package/src/plugin/index.ts +45 -20
  104. package/src/plugin/tool.ts +11 -2
  105. package/src/shared/fence-language.ts +30 -0
  106. package/src/shared/fence-repair.ts +37 -1
  107. package/src/shared/fence-resolve.ts +1 -1
  108. package/tsdown.config.ts +7 -8
  109. package/lib/invariant.js +0 -19
  110. package/lib/types/plugin/invariant.d.ts +0 -15
  111. package/src/plugin/invariant.ts +0 -30
package/lib/index.js CHANGED
@@ -6,6 +6,7 @@ import { createHash, randomUUID } from "node:crypto";
6
6
  //#region src/client/genui-runtime/schema.ts
7
7
  /** Canonical enum domains shared by schema validation and repair. */
8
8
  const TEXT_SIZES = [
9
+ "display",
9
10
  "h1",
10
11
  "h2",
11
12
  "h3",
@@ -13,6 +14,11 @@ const TEXT_SIZES = [
13
14
  "muted",
14
15
  "caption"
15
16
  ];
17
+ const TEXT_ALIGNS = [
18
+ "left",
19
+ "center",
20
+ "right"
21
+ ];
16
22
  const BUTTON_TONES = [
17
23
  "primary",
18
24
  "danger",
@@ -142,6 +148,46 @@ const CARD_TONES = [
142
148
  "warning",
143
149
  "danger"
144
150
  ];
151
+ /** Text run tones (semantic colour without a badge). */
152
+ const TEXT_TONES = [
153
+ "danger",
154
+ "success",
155
+ "warning",
156
+ "info",
157
+ "muted"
158
+ ];
159
+ /** Arrow directions. */
160
+ const ARROW_DIRS = ["down", "right"];
161
+ /** Row main-axis alignment values. */
162
+ const ROW_JUSTIFY = [
163
+ "start",
164
+ "center",
165
+ "end",
166
+ "between"
167
+ ];
168
+ /** Block-row paint modes: filled cells, or outlined cells for bit grids. */
169
+ const BLOCKS_VARIANTS = [
170
+ "fill",
171
+ "outline",
172
+ "plain"
173
+ ];
174
+ /** 单格强调的语义档位。 */
175
+ const BLOCK_CELL_TONES = [
176
+ "accent",
177
+ "success",
178
+ "warning",
179
+ "danger",
180
+ "muted"
181
+ ];
182
+ /** Icon tones: the four semantic roles plus neutral/muted text colours. */
183
+ const ICON_TONES = [
184
+ "default",
185
+ "muted",
186
+ "info",
187
+ "success",
188
+ "warning",
189
+ "danger"
190
+ ];
145
191
  /** Hero cover tones. */
146
192
  const HERO_TONES = [
147
193
  "accent",
@@ -217,6 +263,12 @@ const timelineRecordSchema = recordSchema(["title"], {
217
263
  desc: "string",
218
264
  time: "string"
219
265
  });
266
+ const blocksRowSchema = recordSchema(["cells"], {
267
+ label: "string",
268
+ cells: "array",
269
+ color: "string",
270
+ variant: "string"
271
+ }, {}, { variant: BLOCKS_VARIANTS }, { title: "label" });
220
272
  const diffRecordSchema = recordSchema(["path", "newText"], {
221
273
  path: "string",
222
274
  oldText: "string-or-null",
@@ -318,6 +370,12 @@ const GENUI_SPEC_SCHEMA = schema(["items"], {
318
370
  * diagnostics, where erased interfaces are unavailable.
319
371
  */
320
372
  const COMPONENT_SCHEMAS = {
373
+ arrow: schema([], {
374
+ ...nodeFields,
375
+ dir: "string",
376
+ length: "number",
377
+ label: "string"
378
+ }, { direction: "dir" }, { enums: { dir: ARROW_DIRS } }),
321
379
  accordion: schema(["items"], {
322
380
  ...nodeFields,
323
381
  items: "array"
@@ -378,9 +436,11 @@ const COMPONENT_SCHEMAS = {
378
436
  card: schema(["items"], {
379
437
  ...nodeFields,
380
438
  title: "string",
439
+ eyebrow: "string",
381
440
  items: "nodes",
382
441
  tone: "string",
383
- accent: "string"
442
+ accent: "string",
443
+ flat: "boolean"
384
444
  }, {
385
445
  label: "title",
386
446
  content: "items"
@@ -429,7 +489,8 @@ const COMPONENT_SCHEMAS = {
429
489
  col: schema(["items"], {
430
490
  ...nodeFields,
431
491
  items: "nodes",
432
- gap: "number"
492
+ gap: "number",
493
+ width: "number"
433
494
  }),
434
495
  copy: schema(["text"], {
435
496
  ...nodeFields,
@@ -468,7 +529,13 @@ const COMPONENT_SCHEMAS = {
468
529
  items: "diffs",
469
530
  files: "diffs"
470
531
  }, { nested: { diffs: diffRecordSchema } }),
471
- divider: schema([], nodeFields),
532
+ divider: schema([], {
533
+ ...nodeFields,
534
+ label: "string"
535
+ }, {
536
+ title: "label",
537
+ text: "label"
538
+ }),
472
539
  echart: schema([], {
473
540
  ...nodeFields,
474
541
  title: "string",
@@ -497,10 +564,29 @@ const COMPONENT_SCHEMAS = {
497
564
  cols: "number",
498
565
  items: "nodes"
499
566
  }),
567
+ blocks: schema(["rows"], {
568
+ ...nodeFields,
569
+ rows: "array",
570
+ columns: "number",
571
+ caption: "string",
572
+ title: "string"
573
+ }, {
574
+ items: "rows",
575
+ data: "rows"
576
+ }, { nested: { rows: blocksRowSchema } }),
577
+ icon: schema(["name"], {
578
+ ...nodeFields,
579
+ name: "string",
580
+ label: "string",
581
+ tone: "string",
582
+ size: "number",
583
+ tile: "boolean"
584
+ }, { icon: "name" }, { enums: { tone: ICON_TONES } }),
500
585
  image: schema(["src"], {
501
586
  ...nodeFields,
502
587
  src: "string",
503
- alt: "string"
588
+ alt: "string",
589
+ caption: "string"
504
590
  }, {
505
591
  url: "src",
506
592
  link: "src"
@@ -590,8 +676,9 @@ const COMPONENT_SCHEMAS = {
590
676
  ...nodeFields,
591
677
  items: "nodes",
592
678
  wrap: "boolean",
593
- spacer: "boolean"
594
- }),
679
+ spacer: "boolean",
680
+ justify: "string"
681
+ }, {}, { enums: { justify: ROW_JUSTIFY } }),
595
682
  scene3d: schema(["meshes"], {
596
683
  ...nodeFields,
597
684
  title: "string",
@@ -678,8 +765,15 @@ const COMPONENT_SCHEMAS = {
678
765
  ...nodeFields,
679
766
  content: "string",
680
767
  size: "string",
681
- center: "boolean"
682
- }, { text: "content" }, { enums: { size: TEXT_SIZES } }),
768
+ center: "boolean",
769
+ align: "string",
770
+ tone: "string",
771
+ mono: "boolean"
772
+ }, { text: "content" }, { enums: {
773
+ size: TEXT_SIZES,
774
+ align: TEXT_ALIGNS,
775
+ tone: TEXT_TONES
776
+ } }),
683
777
  textarea: schema([], {
684
778
  ...nodeFields,
685
779
  label: "string",
@@ -826,6 +920,10 @@ const GENUI_LIMITS = {
826
920
  maxKeyValuePairs: 24,
827
921
  /** Maximum `file-tree` nesting. */
828
922
  maxTreeDepth: 6,
923
+ /** Maximum `blocks` figure rows / cells per row. Cells are data, not nodes,
924
+ * so a wide figure still costs one node against `maxNodes`. */
925
+ maxBlocksRows: 14,
926
+ maxBlocksCells: 16,
829
927
  /** Maximum `diagram` nodes / edges / zones / focal accents. */
830
928
  maxDiagramNodes: 9,
831
929
  maxDiagramEdges: 12,
@@ -891,7 +989,7 @@ function repairColumnValues(value) {
891
989
  if (typeof item === "string") columns.push(item.slice(0, 128));
892
990
  else if (item !== null && typeof item === "object") {
893
991
  const column = item;
894
- const label = typeof column.label === "string" ? column.label : typeof column.value === "string" ? column.value : typeof column.title === "string" ? column.title : JSON.stringify(item);
992
+ const label = typeof column.label === "string" ? column.label : typeof column.value === "string" ? column.value : typeof column.title === "string" ? column.title : typeof column.name === "string" && column.name !== "" ? column.name : JSON.stringify(item);
895
993
  columns.push(label.slice(0, 128));
896
994
  }
897
995
  }
@@ -943,7 +1041,8 @@ function columnKeyOf(value) {
943
1041
  "key",
944
1042
  "dataIndex",
945
1043
  "title",
946
- "label"
1044
+ "label",
1045
+ "name"
947
1046
  ]) if (typeof column[key] === "string" && column[key] !== "") return column[key];
948
1047
  }
949
1048
  /** 将 object row 中的值转换为 table 单元格,并保留列位置。 */
@@ -961,7 +1060,8 @@ function columnHeaderText(value) {
961
1060
  "title",
962
1061
  "label",
963
1062
  "key",
964
- "dataIndex"
1063
+ "dataIndex",
1064
+ "name"
965
1065
  ]) if (typeof column[key] === "string" && column[key] !== "") return column[key];
966
1066
  return JSON.stringify(value);
967
1067
  }
@@ -971,9 +1071,34 @@ function columnHeaderText(value) {
971
1071
  function record$1(value) {
972
1072
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
973
1073
  }
974
- function isNode$1(value) {
1074
+ /**
1075
+ * Resolve an explicit component type or a type uniquely identified by fields.
1076
+ *
1077
+ * @param value - Value to inspect without changing it.
1078
+ * @returns The explicit or inferred component type when available.
1079
+ */
1080
+ function nodeTypeOf(value) {
975
1081
  const candidate = record$1(value);
976
- return candidate !== void 0 && typeof candidate.type === "string";
1082
+ if (candidate === void 0) return void 0;
1083
+ if (typeof candidate.type === "string") return candidate.type;
1084
+ if ("type" in candidate) return void 0;
1085
+ const matches = [];
1086
+ if (Array.isArray(candidate.columns) && Array.isArray(candidate.rows)) matches.push("table");
1087
+ if (Array.isArray(candidate.pairs)) matches.push("keyvalue");
1088
+ if (Array.isArray(candidate.steps)) matches.push("steps");
1089
+ if (Array.isArray(candidate.diffs)) matches.push("diff");
1090
+ if (Array.isArray(candidate.meshes)) matches.push("scene3d");
1091
+ if (Array.isArray(candidate.tabs)) matches.push("tabs");
1092
+ return matches.length === 1 ? matches[0] : void 0;
1093
+ }
1094
+ /**
1095
+ * Check whether a value can be treated as a component node.
1096
+ *
1097
+ * @param value - Value to inspect without changing it.
1098
+ * @returns Whether the value has an explicit or uniquely inferred type.
1099
+ */
1100
+ function isNode$1(value) {
1101
+ return nodeTypeOf(value) !== void 0;
977
1102
  }
978
1103
  /** Fields a `stat` keeps when a metric record is folded into its own node. */
979
1104
  const STAT_METRIC_FIELDS = [
@@ -1092,12 +1217,25 @@ function defaultFileTreeDirectories(value) {
1092
1217
  if (out.children !== void 0) out.children = defaultFileTreeDirectories(out.children);
1093
1218
  return out;
1094
1219
  }
1220
+ /**
1221
+ * Normalize one component node and its renderer-reachable children.
1222
+ *
1223
+ * @param value - Raw component or other value.
1224
+ * @param path - Stable diagnostic path for this node.
1225
+ * @param warnings - Alias and structural normalization diagnostics.
1226
+ * @returns The normalized component, or the original value when it is not a node.
1227
+ */
1095
1228
  function normalizeNode(value, path, warnings) {
1096
- if (!isNode$1(value)) return value;
1097
- const type = value.type;
1229
+ const type = nodeTypeOf(value);
1230
+ const candidate = record$1(value);
1231
+ if (type === void 0 || candidate === void 0) return value;
1232
+ const node = typeof candidate.type === "string" ? candidate : {
1233
+ ...candidate,
1234
+ type
1235
+ };
1098
1236
  const definition = COMPONENT_SCHEMAS[type];
1099
- if (definition === void 0) return value;
1100
- const out = normalizeAliasFields(value, path, type, warnings);
1237
+ if (definition === void 0) return node;
1238
+ const out = normalizeAliasFields(node, path, type, warnings);
1101
1239
  for (const [field, nested] of Object.entries(definition.nested)) if (out[field] !== void 0) out[field] = normalizeRecordTree(out[field], nested, `${path}.${field}`, type, warnings);
1102
1240
  const normalizeNodeValue = (child, childPath) => normalizeNode(child, childPath, warnings);
1103
1241
  const normalizeNodeArray = (children, childPath) => Array.isArray(children) ? children.map((child, index) => normalizeNodeValue(child, `${childPath}[${index}]`)) : children;
@@ -1547,6 +1685,46 @@ function opt(key, value) {
1547
1685
  return value === void 0 ? {} : { [key]: value };
1548
1686
  }
1549
1687
  //#endregion
1688
+ //#region src/client/file-link.ts
1689
+ /** Decode a local file destination and its optional first line fragment. */
1690
+ function parseFileLink(value) {
1691
+ if (value.length > 2048) return void 0;
1692
+ const hash = value.indexOf("#");
1693
+ const destination = hash < 0 ? value : value.slice(0, hash);
1694
+ if (destination.includes("?")) return void 0;
1695
+ let path;
1696
+ try {
1697
+ path = decodeURIComponent(destination);
1698
+ } catch {
1699
+ return;
1700
+ }
1701
+ if (path === "" || /[\u0000-\u001f\u007f]/.test(path) || /^[\\/]{2}/.test(path) || /^[a-z][a-z\d+.-]*:/i.test(path) && !/^[a-z]:[\\/]/i.test(path)) return void 0;
1702
+ if (hash < 0) return { path };
1703
+ const match = /^L([1-9]\d*)(?:-L([1-9]\d*))?$/.exec(value.slice(hash + 1));
1704
+ if (match === null) return void 0;
1705
+ const line = Number(match[1]);
1706
+ const end = match[2] === void 0 ? line : Number(match[2]);
1707
+ if (!Number.isSafeInteger(line) || !Number.isSafeInteger(end) || end < line) return void 0;
1708
+ return {
1709
+ path,
1710
+ line
1711
+ };
1712
+ }
1713
+ /** Classify a link destination while preserving the existing external URL policy. */
1714
+ function classifyLinkTarget(value) {
1715
+ const external = safeHref(value);
1716
+ if (external !== void 0) return {
1717
+ type: "external",
1718
+ href: external
1719
+ };
1720
+ if (typeof value !== "string") return { type: "invalid" };
1721
+ const file = parseFileLink(value.trim());
1722
+ return file === void 0 ? { type: "invalid" } : {
1723
+ type: "file",
1724
+ file
1725
+ };
1726
+ }
1727
+ //#endregion
1550
1728
  //#region src/client/guard.ts
1551
1729
  function fieldKindMatches(value, kind) {
1552
1730
  switch (kind) {
@@ -1717,19 +1895,76 @@ function repairNodeFields(value, ctx, depth) {
1717
1895
  type: "text",
1718
1896
  content,
1719
1897
  ...opt("size", enu(v.size, TEXT_SIZES)),
1898
+ ...opt("align", enu(v.align, TEXT_ALIGNS)),
1899
+ ...opt("tone", enu(v.tone, TEXT_TONES)),
1900
+ ...opt("mono", v.mono === true ? true : void 0),
1720
1901
  ...opt("center", v.center === true ? true : void 0)
1721
1902
  };
1722
1903
  }
1904
+ case "icon": {
1905
+ const name = str(v.name, 64);
1906
+ if (name === void 0) return null;
1907
+ return {
1908
+ type: "icon",
1909
+ name,
1910
+ ...opt("label", str(v.label, GENUI_LIMITS.maxString)),
1911
+ ...opt("tone", enu(v.tone, ICON_TONES)),
1912
+ ...opt("size", int(v.size, 8, 96)),
1913
+ ...opt("tile", v.tile === true ? true : void 0)
1914
+ };
1915
+ }
1916
+ case "blocks": {
1917
+ if (!Array.isArray(v.rows)) return null;
1918
+ const rows = v.rows.slice(0, GENUI_LIMITS.maxBlocksRows).flatMap((entry) => {
1919
+ const row = obj(entry);
1920
+ if (row === void 0 || !Array.isArray(row.cells)) return [];
1921
+ return [{
1922
+ cells: row.cells.slice(0, GENUI_LIMITS.maxBlocksCells).map((cell) => {
1923
+ if (cell === null) return null;
1924
+ if (typeof cell === "string") return str(cell, GENUI_LIMITS.maxString) ?? "";
1925
+ const holder = obj(cell);
1926
+ if (holder === void 0) return null;
1927
+ const text = str(holder.text, GENUI_LIMITS.maxString);
1928
+ if (text === void 0) return null;
1929
+ return {
1930
+ text,
1931
+ ...opt("color", color(holder.color)),
1932
+ ...opt("tone", enu(holder.tone, BLOCK_CELL_TONES)),
1933
+ ...opt("sub", str(holder.sub, 128))
1934
+ };
1935
+ }),
1936
+ ...opt("label", str(row.label, 128)),
1937
+ ...opt("color", color(row.color)),
1938
+ ...opt("variant", enu(row.variant, BLOCKS_VARIANTS))
1939
+ }];
1940
+ });
1941
+ if (rows.length === 0) return null;
1942
+ return {
1943
+ type: "blocks",
1944
+ rows,
1945
+ ...opt("columns", int(v.columns, 1, GENUI_LIMITS.maxBlocksCells)),
1946
+ ...opt("title", str(v.title, GENUI_LIMITS.maxString)),
1947
+ ...opt("caption", str(v.caption, GENUI_LIMITS.maxString))
1948
+ };
1949
+ }
1950
+ case "arrow": return {
1951
+ type: "arrow",
1952
+ ...opt("dir", enu(v.dir, ARROW_DIRS)),
1953
+ ...opt("length", int(v.length, 16, 96)),
1954
+ ...opt("label", str(v.label, 200))
1955
+ };
1723
1956
  case "row": return {
1724
1957
  type: "row",
1725
1958
  items: repairItems(v.items, ctx, depth + 1),
1726
1959
  ...opt("wrap", v.wrap === true ? true : void 0),
1727
- ...opt("spacer", v.spacer === true ? true : void 0)
1960
+ ...opt("spacer", v.spacer === true ? true : void 0),
1961
+ ...opt("justify", enu(v.justify, ROW_JUSTIFY))
1728
1962
  };
1729
1963
  case "col": return {
1730
1964
  type: "col",
1731
1965
  items: repairItems(v.items, ctx, depth + 1),
1732
- ...opt("gap", num(v.gap, 0, 96))
1966
+ ...opt("gap", num(v.gap, 0, 96)),
1967
+ ...opt("width", num(v.width, 1, 100))
1733
1968
  };
1734
1969
  case "grid": return {
1735
1970
  type: "grid",
@@ -1739,9 +1974,11 @@ function repairNodeFields(value, ctx, depth) {
1739
1974
  case "card": return {
1740
1975
  type: "card",
1741
1976
  items: repairItems(v.items, ctx, depth + 1),
1977
+ ...opt("eyebrow", str(v.eyebrow, 64)),
1742
1978
  ...opt("title", str(v.title, GENUI_LIMITS.maxString)),
1743
1979
  ...opt("tone", enu(v.tone, CARD_TONES)),
1744
- ...opt("accent", color(v.accent))
1980
+ ...opt("accent", color(v.accent)),
1981
+ ...opt("flat", v.flat === true ? true : void 0)
1745
1982
  };
1746
1983
  case "button": {
1747
1984
  const label = str(v.label, GENUI_LIMITS.maxString);
@@ -1791,10 +2028,11 @@ function repairNodeFields(value, ctx, depth) {
1791
2028
  case "link": {
1792
2029
  const label = str(v.label, GENUI_LIMITS.maxString);
1793
2030
  if (label === void 0) return null;
2031
+ const target = classifyLinkTarget(v.href);
1794
2032
  return {
1795
2033
  type: "link",
1796
2034
  label,
1797
- ...opt("href", safeHref(v.href))
2035
+ ...opt("href", target.type === "external" ? target.href : target.type === "file" ? String(v.href).trim() : void 0)
1798
2036
  };
1799
2037
  }
1800
2038
  case "image": {
@@ -1803,7 +2041,8 @@ function repairNodeFields(value, ctx, depth) {
1803
2041
  return {
1804
2042
  type: "image",
1805
2043
  src,
1806
- ...opt("alt", str(v.alt, GENUI_LIMITS.maxString))
2044
+ ...opt("alt", str(v.alt, GENUI_LIMITS.maxString)),
2045
+ ...opt("caption", str(v.caption, GENUI_LIMITS.maxString))
1807
2046
  };
1808
2047
  }
1809
2048
  case "audio": {
@@ -1878,7 +2117,10 @@ function repairNodeFields(value, ctx, depth) {
1878
2117
  ...opt("target", num(v.target, 0, 100))
1879
2118
  };
1880
2119
  }
1881
- case "divider": return { type: "divider" };
2120
+ case "divider": return {
2121
+ type: "divider",
2122
+ ...opt("label", str(v.label, 64))
2123
+ };
1882
2124
  case "spacer": return { type: "spacer" };
1883
2125
  case "avatar": {
1884
2126
  const name = str(v.name, 64);
@@ -2736,8 +2978,14 @@ const GENUI_NODE_TYPES = GENUI_NATIVE_TYPES;
2736
2978
  * white-listed string, descending the same containers `countGenuiNodes`
2737
2979
  * walks. Callers can inspect field semantics or compare the count with the
2738
2980
  * repaired tree without maintaining another traversal.
2981
+ *
2982
+ * With `familyCaps` (default) the traversal applies the same per-family
2983
+ * policy caps repair enforces (tabs ≤ maxTabs, accordion items ≤
2984
+ * maxAccordionItems): nodes beyond a cap are policy-truncated, not defects,
2985
+ * so the declared-vs-rendered ledger must not count them as vanished (#298).
2739
2986
  */
2740
- function visitDeclaredGenuiNodes(value, cap, visit) {
2987
+ function visitDeclaredGenuiNodes(value, cap, visit, options = {}) {
2988
+ const familyCaps = options.familyCaps !== false;
2741
2989
  let count = 0;
2742
2990
  const declared = (candidate) => {
2743
2991
  const o = obj(candidate);
@@ -2756,9 +3004,13 @@ function visitDeclaredGenuiNodes(value, cap, visit) {
2756
3004
  if (v === void 0) return;
2757
3005
  count += 1;
2758
3006
  visit(v, at);
2759
- if (v.type === "tabs" && Array.isArray(v.tabs)) for (let tab = 0; tab < v.tabs.length; tab++) walkItemsOf(v.tabs[tab], `${at}.tabs[${tab}]`);
2760
- else if (v.type === "accordion" && Array.isArray(v.items)) for (let row = 0; row < v.items.length; row++) walkItemsOf(v.items[row], `${at}.items[${row}]`);
2761
- else if ((v.type === "row" || v.type === "col" || v.type === "grid" || v.type === "card") && Array.isArray(v.items)) walk(v.items, `${at}.items`);
3007
+ if (v.type === "tabs" && Array.isArray(v.tabs)) {
3008
+ const tabCount = familyCaps ? Math.min(v.tabs.length, GENUI_LIMITS.maxTabs) : v.tabs.length;
3009
+ for (let tab = 0; tab < tabCount; tab++) walkItemsOf(v.tabs[tab], `${at}.tabs[${tab}]`);
3010
+ } else if (v.type === "accordion" && Array.isArray(v.items)) {
3011
+ const rowCount = familyCaps ? Math.min(v.items.length, GENUI_LIMITS.maxAccordionItems) : v.items.length;
3012
+ for (let row = 0; row < rowCount; row++) walkItemsOf(v.items[row], `${at}.items[${row}]`);
3013
+ } else if ((v.type === "row" || v.type === "col" || v.type === "grid" || v.type === "card") && Array.isArray(v.items)) walk(v.items, `${at}.items`);
2762
3014
  else if (v.type === "list" && Array.isArray(v.items)) for (let row = 0; row < v.items.length; row++) walkNode(v.items[row], `${at}.items[${row}]`);
2763
3015
  else if (v.type === "table" && Array.isArray(v.details)) {
2764
3016
  const rowCount = tableRowsForDetails(v).length;
@@ -2782,10 +3034,11 @@ function visitDeclaredGenuiNodes(value, cap, visit) {
2782
3034
  * Count white-listed nodes declared by a raw spec before repair drops invalid entries.
2783
3035
  * @param value - raw GenUI spec.
2784
3036
  * @param cap - traversal ceiling.
3037
+ * @param options - `familyCaps: false` counts beyond per-family policy caps too.
2785
3038
  * @returns declared node count up to the ceiling.
2786
3039
  */
2787
- function countDeclaredGenuiNodes(value, cap = Number.POSITIVE_INFINITY) {
2788
- return visitDeclaredGenuiNodes(value, cap, () => {});
3040
+ function countDeclaredGenuiNodes(value, cap = Number.POSITIVE_INFINITY, options = {}) {
3041
+ return visitDeclaredGenuiNodes(value, cap, () => {}, options);
2789
3042
  }
2790
3043
  /** Count native nodes that survived repair, excluding opaque custom nodes. */
2791
3044
  function countRenderedNativeGenuiNodes(value, cap = Number.POSITIVE_INFINITY) {
@@ -2866,18 +3119,25 @@ function processGenuiSpec(value) {
2866
3119
  const repaired = repairCanonicalGenuiSpec(normalized.value);
2867
3120
  const validation = validateCanonicalGenuiSpec(normalized.value);
2868
3121
  const declaredNativeCount = countDeclaredGenuiNodes(normalized.value, GENUI_LIMITS.maxNodes + 1);
3122
+ const uncappedDeclaredCount = countDeclaredGenuiNodes(normalized.value, GENUI_LIMITS.maxNodes + 1, { familyCaps: false });
2869
3123
  const renderedNativeCount = repaired === null ? 0 : countRenderedNativeGenuiNodes(repaired);
2870
3124
  const renderedTotalCount = repaired === null ? 0 : countGenuiNodes(repaired);
2871
3125
  const errors = validation.errors.filter((error) => !error.includes(": unknown type "));
2872
3126
  if (repaired !== null && errors.length === 0) errors.push(...analyzeSubmissionRegistry(repaired).diagnostics);
2873
3127
  if (declaredNativeCount > renderedNativeCount) errors.push(`repair dropped ${declaredNativeCount - renderedNativeCount} declared native node(s): declared ${declaredNativeCount}, rendered ${renderedNativeCount}`);
3128
+ const warnings = [...normalized.warnings, ...diagnoseUnknownGenuiFields(normalized.value)];
3129
+ if (uncappedDeclaredCount > declaredNativeCount) warnings.push({
3130
+ kind: "truncated",
3131
+ path: "spec",
3132
+ message: `策略上限截断:${uncappedDeclaredCount - declaredNativeCount} 个声明节点超出 tabs ≤ ${GENUI_LIMITS.maxTabs} / accordion ≤ ${GENUI_LIMITS.maxAccordionItems} 的上限,未渲染;围栏照常渲染,重发时可拆分为多个组件`
3133
+ });
2874
3134
  return {
2875
3135
  value: normalized.value,
2876
3136
  normalized: normalized.value,
2877
3137
  repaired,
2878
3138
  spec: repaired,
2879
3139
  errors: [...new Set(errors)],
2880
- warnings: [...normalized.warnings, ...diagnoseUnknownGenuiFields(normalized.value)],
3140
+ warnings,
2881
3141
  declaredCount: declaredNativeCount,
2882
3142
  renderedCount: renderedTotalCount,
2883
3143
  declaredNativeCount,
@@ -3200,6 +3460,8 @@ function validateNode(value, depth, at, errors, walk) {
3200
3460
  case "diff":
3201
3461
  if (!Array.isArray(v.diffs)) errors.push(`${at}: type 'diff' requires diffs (array)`);
3202
3462
  break;
3463
+ case "divider":
3464
+ case "spacer": break;
3203
3465
  case "json":
3204
3466
  if (!("value" in v)) errors.push(`${at}: type 'json' requires value`);
3205
3467
  break;
@@ -3244,6 +3506,40 @@ function validateNode(value, depth, at, errors, walk) {
3244
3506
  if (typeof v.question !== "string") errors.push(`${at}: type 'quiz' requires question (string)`);
3245
3507
  if (!Array.isArray(v.options)) errors.push(`${at}: type 'quiz' requires options (array)`);
3246
3508
  break;
3509
+ case "blocks":
3510
+ if (!Array.isArray(v.rows)) {
3511
+ errors.push(`${at}: type 'blocks' requires rows (array)`);
3512
+ break;
3513
+ }
3514
+ isNum("columns");
3515
+ v.rows.forEach((entry, i) => {
3516
+ const row = obj(entry);
3517
+ if (row === void 0) {
3518
+ errors.push(`${at}.rows[${i}] must be an object`);
3519
+ return;
3520
+ }
3521
+ if (!Array.isArray(row.cells)) {
3522
+ errors.push(`${at}.rows[${i}].cells must be an array`);
3523
+ return;
3524
+ }
3525
+ row.cells.forEach((cell, j) => {
3526
+ if (cell === null || typeof cell === "string") return;
3527
+ const holder = obj(cell);
3528
+ if (holder === void 0) {
3529
+ errors.push(`${at}.rows[${i}].cells[${j}] must be a string, null, or object`);
3530
+ return;
3531
+ }
3532
+ if (typeof holder.text !== "string") errors.push(`${at}.rows[${i}].cells[${j}].text must be a string`);
3533
+ if (holder.tone !== void 0 && !BLOCK_CELL_TONES.includes(holder.tone)) errors.push(`${at}.rows[${i}].cells[${j}].tone must be one of ${BLOCK_CELL_TONES.join(", ")}`);
3534
+ if (holder.color !== void 0 && color(holder.color) === void 0) errors.push(`${at}.rows[${i}].cells[${j}].color must be a literal colour or host token`);
3535
+ });
3536
+ });
3537
+ break;
3538
+ case "icon":
3539
+ if (typeof v.name !== "string") errors.push(`${at}: type 'icon' requires name (string)`);
3540
+ isNum("size");
3541
+ break;
3542
+ case "arrow": break;
3247
3543
  case "diagram":
3248
3544
  if (typeof v.kind !== "string") errors.push(`${at}: type 'diagram' requires kind (string)`);
3249
3545
  if (!Array.isArray(v.nodes)) errors.push(`${at}: type 'diagram' requires nodes (array)`);
@@ -3253,7 +3549,7 @@ function validateNode(value, depth, at, errors, walk) {
3253
3549
  if (v.option === void 0 && v.data === void 0 && v.series === void 0 && (!Array.isArray(v.links) || v.links.length === 0)) errors.push(`${at}: type 'echart' requires option, data, series, or links`);
3254
3550
  isNum("height");
3255
3551
  break;
3256
- default: errors.push(`${at}: unknown type '${type}' (custom renderer?)`);
3552
+ default: if (!Object.hasOwn(COMPONENT_SCHEMAS, type)) errors.push(`${at}: unknown type '${type}' (custom renderer?)`);
3257
3553
  }
3258
3554
  const definition = COMPONENT_SCHEMAS[type];
3259
3555
  if (definition !== void 0) validateRegistryFields(v, at, definition, errors);
@@ -3270,6 +3566,7 @@ function validateNode(value, depth, at, errors, walk) {
3270
3566
  * with ASCII quotes (e.g. `对"别名路径"判定失败`), which makes JSON.parse
3271
3567
  * fail near that quote with "Expected ',' or ']'...".
3272
3568
  * 2. Trailing commas before `}` / `]` or at end of input.
3569
+ * 3. Valueless object keys immediately before a complete key-and-colon pair.
3273
3570
  *
3274
3571
  * A shared grammar-aware scan distinguishes object keys from values and
3275
3572
  * checks the continuation after a potential string terminator. Ambiguous
@@ -3292,6 +3589,33 @@ const MAX_QUOTE_LOOKAHEAD = 4096;
3292
3589
  function isJsonSpace(ch) {
3293
3590
  return ch === " " || ch === " " || ch === "\n" || ch === "\r";
3294
3591
  }
3592
+ /** Skip only complete, valueless object keys followed by a valued member. */
3593
+ function skipValuelessKeys(raw, start, limit = raw.length) {
3594
+ let cursor = start;
3595
+ let repairs = 0;
3596
+ while (cursor < limit && raw[cursor] === "\"") {
3597
+ const keyStart = cursor++;
3598
+ while (cursor < limit && raw[cursor] !== "\"") if (raw[cursor] === "\\") cursor += 2;
3599
+ else cursor++;
3600
+ if (cursor >= limit) return null;
3601
+ cursor++;
3602
+ try {
3603
+ JSON.parse(raw.slice(keyStart, cursor));
3604
+ } catch {
3605
+ return null;
3606
+ }
3607
+ while (cursor < limit && isJsonSpace(raw[cursor])) cursor++;
3608
+ if (raw[cursor] === ":") return repairs > 0 ? {
3609
+ start: keyStart,
3610
+ repairs
3611
+ } : null;
3612
+ if (raw[cursor] !== ",") return null;
3613
+ repairs++;
3614
+ cursor++;
3615
+ while (cursor < limit && isJsonSpace(raw[cursor])) cursor++;
3616
+ }
3617
+ return null;
3618
+ }
3295
3619
  /**
3296
3620
  * Quote closure is contextual: only keys may be followed by `:`, and a comma
3297
3621
  * must introduce the next member of the enclosing object/array. Walk closing
@@ -3330,6 +3654,8 @@ function quoteCanClose(raw, index, key, scopes, complete) {
3330
3654
  if (raw[cursor] === scope.closer) return true;
3331
3655
  if (scope.closer === "]") return /["[{tfn\-0-9]/.test(raw[cursor]);
3332
3656
  if (raw[cursor] !== "\"") return false;
3657
+ const valueless = skipValuelessKeys(raw, cursor, limit);
3658
+ if (valueless !== null) cursor = valueless.start;
3333
3659
  cursor++;
3334
3660
  while (cursor < limit) {
3335
3661
  if (raw[cursor] === "\\") {
@@ -3406,6 +3732,14 @@ function scanFenceCandidate(raw, complete, contentQuotes) {
3406
3732
  }
3407
3733
  if (ch === "\"") {
3408
3734
  key = scopes[scopes.length - 1]?.expecting === "key";
3735
+ if (key) {
3736
+ const valueless = skipValuelessKeys(raw, i);
3737
+ if (valueless !== null) {
3738
+ repairs += valueless.repairs;
3739
+ i = valueless.start - 1;
3740
+ continue;
3741
+ }
3742
+ }
3409
3743
  interiorQuote = false;
3410
3744
  inString = true;
3411
3745
  out += ch;
@@ -4132,6 +4466,8 @@ function formatProcessWarnings(processed) {
4132
4466
  const canonicalPath = `${separator < 0 ? "" : warning.path.slice(0, separator + 1)}${warning.canonical}`;
4133
4467
  return warning.message.includes("ignored") ? `warning=alias_ignored path=${warning.path} canonical=${canonicalPath}` : `warning=alias_normalized path=${warning.path} canonical=${canonicalPath}`;
4134
4468
  }
4469
+ if (warning.kind === "unknown-field") return `warning=unknown_field path=${JSON.stringify(warning.path)} detail=${JSON.stringify(warning.message)}`;
4470
+ if (warning.kind === "truncated") return `warning=policy_truncated path=${JSON.stringify(warning.path)} detail=${JSON.stringify(warning.message)}`;
4135
4471
  return `warning=process detail=${JSON.stringify(warning.message)}`;
4136
4472
  });
4137
4473
  }
@@ -4226,7 +4562,7 @@ function createRenderUiTool() {
4226
4562
  * before emitting — turning "render a red banner after the fact" into
4227
4563
  * "verify before you send". Purely local: no LLM, no network, no DOM.
4228
4564
  */
4229
- const VALIDATE_DESCRIPTION = "Validate the JSON body of a ```dsh-ui fence BEFORE emitting it — use for non-trivial specs (≥3 nodes or containing a table); skip for trivial ones (≤2 nodes). Pass the exact JSON text you are about to put inside the fence as the \"spec\" argument (a string). Returns a [genui-validation] protocol block with status, diagnostics, next action, and reply_language=conversation. When invalid JSON is repairable, repaired_json contains the fixed body; emit it only with next=emit_repaired_fence. A warning=block_markdown requires the indicated replacement node and another validation call.";
4565
+ const VALIDATE_DESCRIPTION = "Validate the JSON body of a ```dsh-ui fence BEFORE emitting it — use for non-trivial specs (≥3 nodes or containing a table); skip for trivial ones (≤2 nodes). Pass the exact JSON text you are about to put inside the fence as the \"spec\" argument (a string). Returns a [genui-validation] protocol block with status, diagnostics, next action, and reply_language=conversation. When invalid JSON is repairable, repaired_json contains the fixed body; emit it only with next=emit_repaired_fence. A warning=unknown_field requires fixing the indicated path and another validation call. A warning=block_markdown requires the indicated replacement node and another validation call.";
4230
4566
  const VALIDATE_PARAMETERS = {
4231
4567
  type: "object",
4232
4568
  properties: { spec: {
@@ -4342,6 +4678,7 @@ function createValidateDshUiTool() {
4342
4678
  if (processed.spec !== null && processed.errors.length === 0) {
4343
4679
  const warnings = formatProcessWarnings(processed);
4344
4680
  const inlineWarnings = formatInlineContentWarnings(processed.spec);
4681
+ const requiresCorrection = inlineWarnings.length > 0 || processed.warnings.some((warning) => warning.kind === "unknown-field");
4345
4682
  return `${validationProtocol([
4346
4683
  "status=invalid",
4347
4684
  "error=invalid_json",
@@ -4351,7 +4688,7 @@ function createValidateDshUiTool() {
4351
4688
  ...inlineWarnings,
4352
4689
  "repair=applied",
4353
4690
  `repair_count=${repaired.repairs}`,
4354
- inlineWarnings.length === 0 ? "next=emit_repaired_fence" : "next=fix_and_revalidate"
4691
+ requiresCorrection ? "next=fix_and_revalidate" : "next=emit_repaired_fence"
4355
4692
  ])}\nrepaired_json:\n\`\`\`\n${repaired.text}\n\`\`\``;
4356
4693
  }
4357
4694
  }
@@ -4383,12 +4720,13 @@ function createValidateDshUiTool() {
4383
4720
  }
4384
4721
  const warnings = formatProcessWarnings(processed);
4385
4722
  const inlineWarnings = formatInlineContentWarnings(processed.spec);
4723
+ const requiresCorrection = inlineWarnings.length > 0 || processed.warnings.some((warning) => warning.kind === "unknown-field");
4386
4724
  return validationProtocol([
4387
4725
  "status=valid",
4388
4726
  `rendered=${processed.renderedCount}`,
4389
4727
  ...warnings,
4390
4728
  ...inlineWarnings,
4391
- inlineWarnings.length === 0 ? "next=emit_fence" : "next=fix_and_revalidate"
4729
+ requiresCorrection ? "next=fix_and_revalidate" : "next=emit_fence"
4392
4730
  ]);
4393
4731
  },
4394
4732
  presentCall() {
@@ -4507,7 +4845,7 @@ function parsePartialGenuiSpec(raw) {
4507
4845
  //#region src/shared/fence-resolve.ts
4508
4846
  /**
4509
4847
  * 使用浏览器 renderer 与 Node 侧最终回复反馈守卫共用的流程解析 dsh-ui 围栏正文。
4510
- * @module @changfenhuang/dsh-genui/shared/fence-resolve
4848
+ * @module @sparkelf/dsh-genui/shared/fence-resolve
4511
4849
  */
4512
4850
  /**
4513
4851
  * 对已经解析的值执行规格守卫和坏节点清理。
@@ -4557,17 +4895,47 @@ function resolveFence(raw, options) {
4557
4895
  return reparsed === null ? unresolvedFence() : resolveParsedFence(reparsed);
4558
4896
  }
4559
4897
  //#endregion
4898
+ //#region src/shared/fence-language.ts
4899
+ /** 围栏开头的 `dsh-ui` 标签在书写时可能被带上标点(```dsh-ui> / ```dsh-ui` …)。
4900
+ * 这类标记在 mdast 里原样留在 `lang` 上,严格相等判断会让整条围栏静默退化成
4901
+ * 普通代码块——真实会话里同一个模型可以在一条消息里写出 182 个这样的围栏。
4902
+ * 这里只吸收**标签之后**的标点,`dsh-ui-something` 这样的真实语言名不受影响。 */
4903
+ const GENUI_LABEL_PATTERN = /^dsh-ui$/;
4904
+ const GENUI_TRAILING_PUNCTUATION = /[>`"'.,;:)\]】」』]+$/;
4905
+ /**
4906
+ * 把宿主的围栏语言标记规范化成 GenUI 能识别的写法。
4907
+ *
4908
+ * @param lang - 宿主 markdown 里的原始 language(可能含尾部标点或大小写差异)
4909
+ * @returns 规范化后的语言名;无法规范化时返回输入本身
4910
+ */
4911
+ function normalizeFenceLanguage(lang) {
4912
+ const trimmed = lang.trim();
4913
+ if (GENUI_LABEL_PATTERN.test(trimmed.toLowerCase())) return "dsh-ui";
4914
+ const stripped = trimmed.replace(GENUI_TRAILING_PUNCTUATION, "").trim().toLowerCase();
4915
+ if (GENUI_LABEL_PATTERN.test(stripped)) return "dsh-ui";
4916
+ return lang;
4917
+ }
4918
+ /**
4919
+ * 判断语言标记是否指向 GenUI 围栏。
4920
+ *
4921
+ * @param lang - 宿主暴露的围栏语言(`null` = 围栏没有语言)
4922
+ * @returns 规范化为 `dsh-ui` 时返回 true
4923
+ */
4924
+ function isGenuiFenceLanguage(lang) {
4925
+ return typeof lang === "string" && normalizeFenceLanguage(lang) === "dsh-ui";
4926
+ }
4927
+ //#endregion
4560
4928
  //#region src/plugin/fence-feedback.ts
4561
4929
  /** Plugin name recorded on every message this loop steers. */
4562
- const FEEDBACK_PLUGIN_NAME = "@changfenhuang/dsh-genui";
4930
+ const FEEDBACK_PLUGIN_NAME = "@sparkelf/dsh-genui";
4563
4931
  /** Source kind persisted by this plugin in Session format v4. */
4564
4932
  const FEEDBACK_SOURCE_KIND = `plugin:${FEEDBACK_PLUGIN_NAME}`;
4565
4933
  /** Marker prefix inside the correction text: `[genui-fence-repair #<fingerprint>]`. */
4566
4934
  const MARKER_PREFIX = "[genui-fence-repair #";
4567
4935
  /** Marker prefix written by older plugin versions. */
4568
4936
  const LEGACY_MARKER_PREFIX = "[genui 自修 #";
4569
- /** A fence opener is an info string of exactly `dsh-ui` (≤3 spaces indent). */
4570
- const FENCE_OPEN = /^ {0,3}```[ \t]*dsh-ui[ \t]*$/u;
4937
+ /** Read one language token (≤3 spaces indent); backticks are invalid in a backtick info string. */
4938
+ const FENCE_OPEN = /^ {0,3}```[ \t]*([^` \t]+)[ \t]*$/u;
4571
4939
  /** Any fence closer (the renderer never nests fences in one body). */
4572
4940
  const FENCE_CLOSE = /^ {0,3}```[ \t]*$/u;
4573
4941
  /** Upper bound on fences inspected per reply — a reply is text, not a corpus. */
@@ -4585,7 +4953,8 @@ function extractDshUiFences(text) {
4585
4953
  for (let line = 0; line < lines.length; line++) {
4586
4954
  const current = lines[line] ?? "";
4587
4955
  if (open === null) {
4588
- if (FENCE_OPEN.test(current)) open = {
4956
+ const label = FENCE_OPEN.exec(current)?.[1];
4957
+ if (isGenuiFenceLanguage(label)) open = {
4589
4958
  start: line + 1,
4590
4959
  index: fences.length + 1
4591
4960
  };
@@ -4631,9 +5000,9 @@ function fenceFailures(text) {
4631
5000
  }
4632
5001
  /** `null` when this fence renders; otherwise the reason it does not. */
4633
5002
  function fenceFailureDetail(fence) {
4634
- if (!fence.closed) return "error=unterminated_fence\nrequired=closing_fence";
4635
5003
  const resolution = resolveFence(fence.raw, { settled: true });
4636
5004
  if (resolution.spec !== null) return null;
5005
+ if (!fence.closed) return "error=unterminated_fence\nrequired=closing_fence";
4637
5006
  if (resolution.processed !== null) return droppedNodeFailure(resolution.processed, resolution.value)?.join("\n") ?? ["error=invalid_spec", ...resolution.processed.errors.map((error) => `diagnostic=${JSON.stringify(error)}`)].join("\n");
4638
5007
  return "error=invalid_json\nrepair=failed";
4639
5008
  }
@@ -4710,7 +5079,7 @@ function planFenceFeedback(input) {
4710
5079
  if (input.validatedThisTurn !== true || input.deliveredThisTurn === true) return null;
4711
5080
  if (input.deliveryRemindedTurns?.has(input.turn) === true) return null;
4712
5081
  return {
4713
- text: missingBodyCorrectionText(input.turn, used + 1),
5082
+ text: missingBodyCorrectionText(input.turn, used + 1, input.renderUiToolEnabled ?? true),
4714
5083
  fingerprints: [],
4715
5084
  turn: input.turn,
4716
5085
  kind: "delivery"
@@ -4722,19 +5091,27 @@ function planFenceFeedback(input) {
4722
5091
  *
4723
5092
  * @param turn - turn that reached the boundary.
4724
5093
  * @param attempt - correction number within the shared turn budget.
5094
+ * @param renderUiToolEnabled - whether the correction may recommend `render_ui`.
4725
5095
  * @returns the message text to steer into the running turn.
4726
5096
  */
4727
- function missingBodyCorrectionText(turn, attempt = 1) {
4728
- return `${`${MARKER_PREFIX}turn-${turn}]\n\n[genui-fence-repair]\nstatus=nothing_delivered\nfences=0\nnext=emit_fence_in_body\nrepeat_rendered_content=false\nreply_language=conversation\n\n`}本轮尚未产生正式回答,也没有通过支持的通道交付结果${attempt <= 1 ? "" : `(第 ${attempt} 次提醒)`}。请根据用户当前请求完成正式答复;需要 UI 时,在回答正文输出你最终选定的 dsh-ui 围栏,或明确调用 render_ui。可以修改或放弃此前候选;不能完成时,请在正文说明原因。\n`;
5097
+ function missingBodyCorrectionText(turn, attempt = 1, renderUiToolEnabled = true) {
5098
+ return `${`${MARKER_PREFIX}turn-${turn}]\n\n[genui-fence-repair]\nstatus=nothing_delivered\nfences=0\nnext=emit_fence_in_body\nrepeat_rendered_content=false\nreply_language=conversation\n\n`}本轮尚未产生正式回答,也没有通过支持的通道交付结果${attempt <= 1 ? "" : `(第 ${attempt} 次提醒)`}。请根据用户当前请求完成正式答复;需要 UI 时,在回答正文输出你最终选定的 dsh-ui 围栏${renderUiToolEnabled ? ",或明确调用 render_ui" : ""}。可以修改或放弃此前候选;不能完成时,请在正文说明原因。\n`;
4729
5099
  }
4730
5100
  /**
4731
5101
  * 将 GenUI 回合中仅含 reasoning 的完整响应转换为宿主已有的可重试空响应错误。
4732
5102
  *
5103
+ * 只有回合边界确实还能发送交付提醒时,才放行原始 stop,
5104
+ * 让回合正常结束并走到 `agent/turn-stopping` 边界——那里会 steer 一条交付提醒,
5105
+ * 回合因此继续到下一个 step,模型有机会在同一回合把内容补进正文。
5106
+ * 提醒发过仍然只有 reasoning,才用 EMPTY_RESPONSE 交给宿主重试兜底。
5107
+ *
4733
5108
  * @param options - LLM stream waterfall 拦截的请求。
4734
5109
  * @param source - 本次请求的 provider stream。
4735
- * @returns 原始 stream;仅符合条件的终止 stop 会被改写。
5110
+ * @param state - 当前回合状态;缺省时没有可用提醒,保留宿主重试。
5111
+ * @param feedbackEnabled - 同回合修正是否启用。关闭时没有提醒可用,保持原有改写行为。
5112
+ * @returns 原始 stream;仅在提醒已发出、或提醒不可用时改写 reasoning-only 终止。
4736
5113
  */
4737
- async function* retryReasoningOnlyGenuiStream(options, source) {
5114
+ async function* retryReasoningOnlyGenuiStream(options, source, state, feedbackEnabled = true) {
4738
5115
  const { EMPTY_RESPONSE_CODE, isAgentLoopRequest } = await import("@deepseek-ai/dsh-llm");
4739
5116
  if (!isAgentLoopRequest(options)) {
4740
5117
  yield* source;
@@ -4747,17 +5124,32 @@ async function* retryReasoningOnlyGenuiStream(options, source) {
4747
5124
  if (chunk.block.type === "reasoning") hasReasoningBlock = true;
4748
5125
  else hasOtherBlock = true;
4749
5126
  }
4750
- if (chunk.type === "finish" && chunk.reason.kind === "stop" && hasReasoningBlock && !hasOtherBlock) yield {
4751
- type: "finish",
4752
- reason: {
4753
- kind: "error",
4754
- failure: {
4755
- message: "GenUI turn completed with reasoning only and no deliverable response",
4756
- code: EMPTY_RESPONSE_CODE
4757
- }
5127
+ if (chunk.type === "finish" && chunk.reason.kind === "stop" && hasReasoningBlock && !hasOtherBlock) {
5128
+ if (feedbackEnabled && state !== void 0 && state.currentTurn !== void 0 && state.pendingRenders.size === 0 && planFenceFeedback({
5129
+ text: "",
5130
+ turn: state.currentTurn,
5131
+ correctedSpec: state.correctedSpec,
5132
+ deliveryRemindedTurns: state.deliveryRemindedTurns,
5133
+ validatedThisTurn: state.validatedThisTurn,
5134
+ deliveredThisTurn: state.deliveredThisTurn,
5135
+ aborted: options.signal?.aborted ?? false,
5136
+ correctionsThisTurn: state.correctionsThisTurn,
5137
+ correctionsTurn: state.correctionsTurn
5138
+ })?.kind === "delivery") {
5139
+ yield chunk;
5140
+ continue;
4758
5141
  }
4759
- };
4760
- else yield chunk;
5142
+ yield {
5143
+ type: "finish",
5144
+ reason: {
5145
+ kind: "error",
5146
+ failure: {
5147
+ message: "GenUI turn completed with reasoning only and no deliverable response",
5148
+ code: EMPTY_RESPONSE_CODE
5149
+ }
5150
+ }
5151
+ };
5152
+ } else yield chunk;
4761
5153
  }
4762
5154
  }
4763
5155
  /** Text of one assistant message's text blocks, in order. */
@@ -4854,15 +5246,16 @@ function accountReplayedCorrection(state, turn) {
4854
5246
  }
4855
5247
  /** Identify this plugin's source across current and migrated session shapes. */
4856
5248
  function isFeedbackSource(source) {
4857
- return source?.kind === FEEDBACK_SOURCE_KIND || source?.kind === "plugin" && source.plugin === "@changfenhuang/dsh-genui";
5249
+ return source?.kind === FEEDBACK_SOURCE_KIND || source?.kind === "plugin" && source.plugin === "@sparkelf/dsh-genui";
4858
5250
  }
4859
5251
  /**
4860
5252
  * 注册 GenUI 回合跟踪、宿主重试判定和可选的围栏修正流程。
4861
5253
  *
4862
5254
  * @param ctx - 宿主 Context。
4863
5255
  * @param enabled - 是否启用同回合围栏修正。
5256
+ * @param renderUiToolEnabled - 是否已注册 `render_ui` 工具。
4864
5257
  */
4865
- function installFenceFeedback(ctx, enabled) {
5258
+ function installFenceFeedback(ctx, enabled, renderUiToolEnabled = true) {
4866
5259
  const sessions = /* @__PURE__ */ new Map();
4867
5260
  const stateOf = (sessionId) => {
4868
5261
  let state = sessions.get(sessionId);
@@ -4973,7 +5366,7 @@ function installFenceFeedback(ctx, enabled) {
4973
5366
  if (options.sessionId === void 0 || options.purpose !== void 0) return next();
4974
5367
  const state = sessions.get(String(options.sessionId));
4975
5368
  if (state?.validatedThisTurn !== true || state.isSubagent) return next();
4976
- return retryReasoningOnlyGenuiStream(options, next());
5369
+ return retryReasoningOnlyGenuiStream(options, next(), state, enabled);
4977
5370
  }, { global: true });
4978
5371
  ctx.on("agent/turn-stopping", ({ agent, turn, signal }) => {
4979
5372
  if (!enabled) return;
@@ -4992,7 +5385,8 @@ function installFenceFeedback(ctx, enabled) {
4992
5385
  deliveredThisTurn: state.deliveredThisTurn,
4993
5386
  aborted: signal.aborted,
4994
5387
  correctionsThisTurn: usedThisTurn,
4995
- correctionsTurn: state.correctionsTurn
5388
+ correctionsTurn: state.correctionsTurn,
5389
+ renderUiToolEnabled
4996
5390
  });
4997
5391
  if (plan === null) return;
4998
5392
  for (const fingerprint of plan.fingerprints) state.correctedSpec.add(fingerprint);
@@ -5021,7 +5415,7 @@ function installFenceFeedback(ctx, enabled) {
5021
5415
  * and plugin reloads.
5022
5416
  */
5023
5417
  /** Route prefix under /plugins; anything under it is this plugin's asset. */
5024
- const ASSET_ROUTE_PATH = "/plugins/@changfenhuang/dsh-genui/assets";
5418
+ const ASSET_ROUTE_PATH = "/plugins/@sparkelf/dsh-genui/assets";
5025
5419
  /** Safe flat file names only: no slashes, no traversal, js assets only. */
5026
5420
  const ASSET_FILE_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*\.js$/;
5027
5421
  /** The handler itself (registered via the optional webServer probe). */
@@ -5039,7 +5433,7 @@ async function serveGenuiAsset(req, res) {
5039
5433
  res.end();
5040
5434
  return;
5041
5435
  }
5042
- const rel = pathname.startsWith(`${ASSET_ROUTE_PATH}/`) ? pathname.slice(40) : null;
5436
+ const rel = pathname.startsWith(`${ASSET_ROUTE_PATH}/`) ? pathname.slice(35) : null;
5043
5437
  if (rel === null) {
5044
5438
  res.writeHead(404);
5045
5439
  res.end();
@@ -5064,11 +5458,12 @@ async function serveGenuiAsset(req, res) {
5064
5458
  res.end();
5065
5459
  }
5066
5460
  }
5461
+ const RENDER_UI_TOOL_GUIDANCE = "- Tool channel: render_ui 工具把同一 spec 渲染为工具行卡片;围栏用于回答内联 UI。";
5067
5462
  /** The fence language description injected into every assembled system prompt.
5068
5463
  * Deliberately slim: the `genui` skill carries the full component→field
5069
5464
  * mapping; this section keeps only the contract that must always be
5070
5465
  * present (fence syntax, type whitelist, and critical behavioral rules). */
5071
- const GENUI_SECTION_TEXT = `You can render interactive UI components INSIDE your reply — between paragraphs — by emitting a fenced block with the language tag \`dsh-ui\` containing a JSON spec:
5466
+ const GENUI_SECTION_TEXT = `Render UI inside your reply with a fenced \`dsh-ui\` JSON block:
5072
5467
 
5073
5468
  \`\`\`dsh-ui
5074
5469
  {"title":"<user-language text>","gap":14,"items":[...]}
@@ -5077,21 +5472,23 @@ const GENUI_SECTION_TEXT = `You can render interactive UI components INSIDE your
5077
5472
  Allowed \`type\` values; the \`genui\` skill, when available, carries the full content→component mapping and per-component field details:
5078
5473
 
5079
5474
  - 布局: text · row · col · grid · card · divider · spacer · hero(封面块,一条回答最多一个)
5080
- - 展示: badge · stat · progress · list · table · keyvalue · timeline · file-tree · breadcrumb · callout · steps · diff · json · code · copy · avatar · audio · video
5081
- - 图表: chart {"kind":"bars|line|donut","data":[{"label":"...","value":n}],"series":[{"label":"...","data":[...]}]?,"horizontal":true?,"stacked":true?}(series:bars 分组/堆叠 / line 多序列;horizontal 横向柱) · echart (preset 名或 option 直通,预设清单见 skill) · plot (函数图)
5082
- - 交互: button · input · textarea · select · checkbox · switch · slider · radio · submit · quiz · link · tabs · accordion
5083
- - 高级: mermaid (流程图/时序/甘特/ER 等,关键字见 skill) · diagram (架构/流程图,27 种 kind) · scene3d (3D WebGL)
5475
+ - 展示: badge · stat · progress · list · table · keyvalue · timeline · file-tree · breadcrumb · callout · steps · diff · json · code · copy · avatar · image · audio · video · icon · blocks · arrow
5476
+ - 图表: chart {"kind":"bars|line|donut","data":[{"label":"...","value":n}]}(series:bars 分组/堆叠 / line 多序列) · echart (preset 名或 option 直通,清单见 skill) · plot (函数图) · svg (单图预览)
5477
+ - 交互: button · input · textarea · select · checkbox · switch · slider · radio · submit · quiz · link · tabs · accordion(row.justify / col.width / card.flat 见图元)
5478
+ - 高级: mermaid (流程图/时序/甘特/ER 等,关键字见 skill) · diagram (架构/流程图) · scene3d (3D WebGL)
5084
5479
 
5085
5480
  **默认就该出 UI**:出现下列情况至少出一个围栏:
5086
5481
  - ≥3 条并列要点 → \`list\`;数字对比 → \`table\`;指标/进度/状态 → \`stat\`/\`progress\`/\`badge\`
5087
- - 步骤/时间线 → \`steps\`/\`timeline\`/\`mermaid\`;架构/流程 → \`diagram\` 或 \`mermaid\`;风险/结论 → \`callout\`;代码/改动 → \`code\`/\`diff\`/\`json\`
5088
- - 行内富文本:支持公式、\`code\`、加粗、高亮、链接;禁用 Markdown table / fenced code,改用 table / code / diff / json。
5089
- - 默认无卡:按触发条件使用组件,每个组件承载不同信息;卡片只用于并排项与数据对象,单段文字用标题、正文与间距。
5482
+ - 步骤/时间线 → \`steps\`/\`timeline\`/\`mermaid\`;架构/流程 → \`diagram\` 或 \`mermaid\`;单条风险/结论摘要 → \`callout\`;代码/改动 → \`code\`/\`diff\`/\`json\`
5483
+ - 行内富文本:支持公式、\`code\`、加粗、高亮、链接;禁用 Markdown table 与 fenced code,改用 table/code/diff/json。
5484
+ - 默认无卡:卡片用于并排项、数据对象或需底色的风险清单。
5090
5485
 
5091
- **发回答前最后自检一次**:这段内容里有没有 ≥3 条并列要点、任何对比、任何数字/指标、任何步骤或流程?有就先转成组件再开口。**状态汇报、进度说明、提交与改动清单同样算**。
5092
- - 趋势/占比 → \`chart\`(≤8 点)或 \`echart\`(多序列/要交互时);配色默认跟随主题,只有语义需要时才用 \`palette\`/\`card.accent\`;grid 子节点用 \`"span":2\` 跨列做宽窄混排;数据多时给 \`table\`/\`chart\`/\`list\` 配一个 \`input\`(id) + \`filter\` 绑定,读者能就地筛选。
5486
+ **发回答前最后自检一次**:有没有 ≥3 条并列要点、任何对比、任何数字/指标、任何步骤或流程?有就先转成组件。**状态汇报、进度说明、提交与改动清单同样算**。
5487
+ - 趋势/占比 → \`chart\`(≤8 点)或 \`echart\`;配色跟随主题,语义需要时才用 \`palette\`/\`card.accent\`;grid 子节点用 \`"span":2\` 做宽窄混排;数据多时给 \`table\`/\`list\` 配 \`input\`(id)+\`filter\` 就地筛选。
5488
+ - 多组件回答先套 skill「编排范式」,别一行一个往下堆;章节分隔 \`divider\` 带 \`label\`。
5093
5489
 
5094
- **字段速查**(完整见 genui skill):\`stat\` \`{"label","value","delta"?}\` · \`table\` \`{"columns":[...],"rows":[[...]],"types"?,"details"?,"filter"?,"export"?}\` · \`progress\` \`{"value":0-100,"label"?,"variant"?,"target"?}\` · \`keyvalue\` \`{"pairs":[{"key","value"}]}\` · \`steps\` \`{"steps":[{"title","desc"?}]}\` · \`file-tree\` \`{"items":[{"name","type":"file|dir","children"?}]}\` · \`callout\` \`{"content","tone"?,"title"?}\`
5490
+ **字段速查**(完整见 genui skill):\`stat\` \`{"type":"stat","label","value"}\` · \`table\` \`{"type":"table","columns":[...],"rows":[[...]]}\` · \`progress\` \`{"type":"progress","value":0-100}\` · \`keyvalue\` \`{"type":"keyvalue","pairs":[{"key","value"}]}\` · \`steps\` \`{"type":"steps","steps":[{"title"}]}\` · \`file-tree\` \`{"type":"file-tree","items":[{"name","type":"file|dir"}]}\` · \`callout\` \`{"type":"callout","content"}\`
5491
+ **节点规则:** 组件节点必须带字符串 \`type\`,值为组件名;\`file-tree.items[].type\` 表示 \`file\` 或 \`dir\`。
5095
5492
 
5096
5493
  **字段名写错 = 该组件被丢弃**(其余组件照常渲染):\`callout\` 正文是 \`content\` 不是 text/desc;\`table\` 要 \`columns\`+\`rows\` 不是 items;\`keyvalue\` 记录是 \`{key,value}\` 不是 \`{label,value}\`;\`file-tree\` 记录是 \`{name,type}\` 不是 \`{label}\`;callout tone 是 info/success/warning/error(无 danger)。不确定就调 \`validate_dsh_ui\`。
5097
5494
 
@@ -5104,22 +5501,31 @@ Rules:
5104
5501
  - Durable state: 交互状态按「会话+内容指纹」持久化——刷新/重放恢复;相同内容保留,新内容重置。
5105
5502
  - 卷子模式: 每题一个 radio(group+answer+explanation)+ 一个 submit(groups 全列),本地判分。
5106
5503
  - Secrets ban: 不索取密码、API Key、Token、恢复码;需要时拒绝并解释。
5107
- - Tool channel: render_ui 工具把同一 spec 渲染为工具行卡片;围栏用于回答内联 UI。
5504
+ ${RENDER_UI_TOOL_GUIDANCE}
5108
5505
  - 围栏位置:\`dsh-ui\` 只写在**回答正文**;写在 reasoning/思考块里不渲染、用户看不到——思考里验证好 spec,正文再输出同一份。
5109
5506
  - Panel: "panel":true 只渲染进会话面板 dock 并原地更新;"append":true 追加合并;上限 200 节点/200 次追加,满了发 replace 重建。面板来的 [genui-action] 只回一个 panel:true 围栏 + 至多一行 10 字内确认。`;
5110
5507
  /**
5111
5508
  * Register the GenUI output-language section and the render_ui tool.
5112
5509
  * @param ctx - cordis context.
5113
5510
  */
5114
- const name = "@changfenhuang/dsh-genui";
5511
+ const name = "@sparkelf/dsh-genui";
5115
5512
  const inject = ["systemPrompt"];
5116
5513
  const BUNDLED_SKILL_RANK = 600;
5117
5514
  const BUNDLED_SKILL_PROVIDER = "dsh-genui";
5118
- const BUNDLED_SKILL_DESCRIPTION = "GenUI dsh-ui component/schema reference. Preserve conversation language for all user-visible text.";
5119
5515
  const BUNDLED_SKILL_INVOCATION = {
5120
5516
  modelInvocable: true,
5121
5517
  userInvocable: true
5122
5518
  };
5519
+ /**
5520
+ * The frontmatter field the routing description comes from.
5521
+ *
5522
+ * A second copy of this sentence in code drifted from SKILL.md unnoticed, and the
5523
+ * panel showed the code copy while the model read the same string — so an edit to
5524
+ * the skill's own frontmatter changed nothing. The file is the only source.
5525
+ */
5526
+ function frontmatterField(front, key) {
5527
+ return new RegExp("^\\s*" + key + "\\s*:\\s*(.+?)\\s*$", "mu").exec(front)?.[1]?.replace(/^['"]|['"]$/gu, "");
5528
+ }
5123
5529
  /** Register through the provider path so source=bundled also gets bundled precedence. */
5124
5530
  function bundledSkillProvider() {
5125
5531
  const moduleDirectory = dirname(fileURLToPath(new URL(import.meta.url)));
@@ -5127,11 +5533,13 @@ function bundledSkillProvider() {
5127
5533
  const raw = readFileSync(path, "utf8");
5128
5534
  const end = raw.indexOf("\n---\n", 4);
5129
5535
  if (!raw.startsWith("---\n") || end < 0) throw new Error("genui SKILL.md has invalid frontmatter");
5536
+ const description = frontmatterField(raw.slice(4, end), "description");
5537
+ if (description === void 0) throw new Error("genui SKILL.md frontmatter has no description");
5130
5538
  return {
5131
5539
  name: BUNDLED_SKILL_PROVIDER,
5132
5540
  list: () => Promise.resolve([{
5133
5541
  name: "genui",
5134
- description: BUNDLED_SKILL_DESCRIPTION,
5542
+ description,
5135
5543
  invocation: BUNDLED_SKILL_INVOCATION,
5136
5544
  source: "bundled",
5137
5545
  provider: BUNDLED_SKILL_PROVIDER,
@@ -5145,7 +5553,7 @@ function bundledSkillProvider() {
5145
5553
  }]),
5146
5554
  get: () => Promise.resolve({
5147
5555
  name: "genui",
5148
- description: BUNDLED_SKILL_DESCRIPTION,
5556
+ description,
5149
5557
  invocation: BUNDLED_SKILL_INVOCATION,
5150
5558
  source: "bundled",
5151
5559
  provider: BUNDLED_SKILL_PROVIDER,
@@ -5159,15 +5567,16 @@ function bundledSkillProvider() {
5159
5567
  };
5160
5568
  }
5161
5569
  function apply(ctx, config) {
5570
+ const renderUiToolEnabled = config?.renderUiTool !== false;
5162
5571
  ctx.systemPrompt.section({
5163
5572
  name: "genui:fence",
5164
5573
  order: ctx.systemPrompt.getSectionOrder("STRUCTURED_OUTPUT"),
5165
- text: GENUI_SECTION_TEXT
5574
+ text: renderUiToolEnabled ? GENUI_SECTION_TEXT : GENUI_SECTION_TEXT.replace(`${RENDER_UI_TOOL_GUIDANCE}\n`, "")
5166
5575
  });
5167
- installFenceFeedback(ctx, config?.fenceFeedback !== false);
5576
+ installFenceFeedback(ctx, config?.fenceFeedback !== false, renderUiToolEnabled);
5168
5577
  ctx.inject(["tools"], (toolsCtx) => {
5169
5578
  toolsCtx.effect(function* () {
5170
- yield toolsCtx.tools.register(createRenderUiTool());
5579
+ if (renderUiToolEnabled) yield toolsCtx.tools.register(createRenderUiTool());
5171
5580
  yield toolsCtx.tools.register(createValidateDshUiTool());
5172
5581
  }, "dsh-genui: model tools");
5173
5582
  });