dsh-mosaic 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@
4
4
  > 兼容性分两处表达:`package.json` 的 `engines.dsh` 给机器可读的范围,README「安装」一节给「插件版本 ↔ 实测 Harness 版本」对照表;每次在真实 Harness 上验证后更新这两处。
5
5
  > `0.2.1` 及各 `0.2.1-<标签>` 是改规则前的历史版本,保留用于追溯。
6
6
 
7
+ ## 1.1.3
8
+
9
+ - 设置页的导航图标改用插件自己的 mark(内联 SVG,按面板请求的边长渲染),不再和 General 共用同一个齿轮。注册走 `settings.section.icon`:Harness `0.2.1-rc.5` 还没有这个插槽,注册保持静默,升级到声明它的版本后自动生效。
10
+ - 内部:`useDiagramId` 改名 `useInstanceId`,它现在同时给示意图 marker 和图标渐变生成实例 id。
11
+
7
12
  ## 1.1.2
8
13
 
9
14
  ### 修复
package/README.md CHANGED
@@ -108,13 +108,14 @@ grep -c '"event":"tool.failed"' "$DSH_HOME"/logs/dsh-mosaic/*.jsonl
108
108
 
109
109
  ## 已知边界
110
110
 
111
- - 本插件的 npm 版本独立递增(当前 `1.1.2`),不再与 Harness 版本号对齐;兼容范围由 `package.json` 的 `engines.dsh` 声明,最近一次实测的 Harness 版本见「安装」一节。
111
+ - 本插件的 npm 版本独立递增(当前 `1.1.3`),不再与 Harness 版本号对齐;兼容范围由 `package.json` 的 `engines.dsh` 声明,最近一次实测的 Harness 版本见「安装」一节。
112
112
  - 围栏渲染靠扫描页面里的代码块实现:0.2.1 全系列(实测 rc.3 与 rc.5,master 同样)都没有给插件开放「渲染 fenced code block」的扩展点。工具通道 `render_view` + `tool.call.toolview` 是原生做法,围栏是它的补充。
113
113
  - 从 0.2.1 起代码块由 Shiki 渲染,`<code>` 上**没有** `language-*` 类;识别靠「代码块位于 assistant 行内 + 正文能解析成合法视图 spec」这条路径,用户消息、工具结果、推理块里的代码块都被排除。
114
114
  - `diagram` 与 `chart` 自带缩放/平移:卡片右上角有 `−`/`+`/`⟲`/`⤢`,放大后按住图面拖动即可平移,`Ctrl/⌘ + 滚轮`缩放,双击复位;示意图按原始尺寸渲染,不会被压缩到卡片宽度。触屏上图表区域只拦横向拖动(`touch-action: pan-y`),手指上下划仍然滚动聊天页面。
115
115
  - `widget` 里调用 `window.mosaic.action()` 只有**真实用户手势**之后才会把动作发回模型:Widget 自己也在判断 `navigator.userActivation`,但决定权在宿主——消息的 nonce 就写在 Widget 自己的文档里,模型代码能读出来直接伪造,所以父页面独立再校验一次自己文档的激活状态。确实需要自行提交的 Widget 要在节点上写 `actions: "programmatic"`;无论哪种,整个会话共享「每分钟 10 次、单次 payload 16 KB(按 UTF-8 字节算)」的额度,新开一个 Widget 不会重置。浏览器若不提供 `navigator.userActivation`,非 `programmatic` 的 Widget 会被按「没有手势」处理,按钮不会回模型。
116
116
  - `widget` 是 iframe,拿不到宿主的 `ctx.locale`,因此内部文案由调用方自己写;主题靠宿主令牌值传入。围栏是独立的 React root,切换外观不会触发它重渲染,所以 widget 会观察 `body[data-ds-dark-theme]` 这一个外观属性并在变化时重发令牌——这是插件唯一读取的宿主属性。
117
117
  - Mermaid 资产走包内私有路由 `/dsh-mosaic/assets`;没有 Web 服务时 diagram 回落到内置 SVG 布局。
118
+ - 设置页的导航图标走 `settings.section.icon` 插槽。Harness `0.2.1-rc.5` 的导航图标是写死的映射,没有这个插槽,Mosaic 会落到默认齿轮;升级到声明该插槽的版本(`0.2.2-alpha.3` 起)后自动显示自己的 mark,插件不用再改。
118
119
  - 自有路由(`/prompt`、`/log`)先验 **Host 必须是本机权威**(loopback、监听地址,或 `config.trustedHosts` 里声明的),再验 `Sec-Fetch-Site` 与 `Origin`。只比 Origin 和 Host 挡不住 DNS rebinding:被 rebinding 的页面这两者都等于攻击者域名,看起来完全同源。宿主把 Web 服务绑到非 loopback 地址时,请把对应主机名写进 `config.trustedHosts`,否则这些路由会拒绝请求。
119
120
  - bundle patch 只插入 Mosaic 自己这一行,不改动任何其他插件。若你还装了别的围栏类插件,两者可以对同一段围栏各显一套,按需在 profile 里关掉其中一个即可。
120
121
  - 持久化只用「Host 数据目录里的一个 JSON 文件」,没有走 DSH 的 storageDomain。实测(rc.5):`storageDomain` 可用,但记录校验只在**重新打开**时执行(`put` 不校验);`single` 布局遇到版本变化会直接拒绝打开,`compatibleVersions` 也不适用。对一份 Prompt 来说这些能力换不来收益,反而多一个依赖和三条失败分支。
@@ -158,6 +159,7 @@ dsh plugin --profile desktop add link:/absolute/path/to/dsh-mosaic
158
159
 
159
160
  | 插件版本 | 实测通过的 DeepSeek Harness | 说明 |
160
161
  | --- | --- | --- |
162
+ | `1.1.3` | `0.2.1-rc.5` | 设置页改用插件自己的图标;需要 Harness 声明 `settings.section.icon`,rc.5 尚未提供 |
161
163
  | `1.1.2` | `0.2.1-rc.5` | 修复示意图标签里的括号/方括号/花括号导致解析失败;补上边与消息的可读预算 |
162
164
  | `1.1.1` | `0.2.1-rc.5` | 运行时代码与 `1.1.0` 相同;仅修正发布工作流的无效输入 |
163
165
  | `1.1.0` | `0.2.1-rc.5` | 13 种示意图、PNG/SVG 导出、`warnings=` 可读规模提示、布局修正 |
package/lib/client.js CHANGED
@@ -597,6 +597,33 @@ window.__ModuleLoader__.load({
597
597
  const PROMPT_URL = '/dsh-mosaic/prompt'
598
598
  const PROMPT_LIMIT = 128 * 1024
599
599
 
600
+ /** The plugin's own mark: four tiles on the brand gradient. */
601
+ function MosaicMark({ size = 16 }) {
602
+ const gradientId = useInstanceId('mosaic-mark')
603
+ return h('svg', {
604
+ width: size,
605
+ height: size,
606
+ viewBox: '0 0 64 64',
607
+ 'aria-hidden': 'true',
608
+ focusable: 'false',
609
+ style: { display: 'block' },
610
+ },
611
+ h('defs', null,
612
+ h('linearGradient', { id: gradientId, x1: '0', y1: '0', x2: '1', y2: '1' },
613
+ h('stop', { offset: '0', stopColor: '#1d4ed8' }),
614
+ h('stop', { offset: '1', stopColor: '#0f766e' }))),
615
+ h('rect', { x: 2, y: 2, width: 60, height: 60, rx: 14, fill: `url(#${gradientId})` }),
616
+ h('rect', { x: 10, y: 10, width: 20, height: 20, rx: 5, fill: '#ffffff', fillOpacity: 0.94 }),
617
+ h('rect', { x: 34, y: 10, width: 20, height: 20, rx: 5, fill: '#ffffff', fillOpacity: 0.72 }),
618
+ h('rect', { x: 10, y: 34, width: 20, height: 20, rx: 5, fill: '#ffffff', fillOpacity: 0.72 }),
619
+ h('rect', { x: 34, y: 34, width: 20, height: 20, rx: 5, fill: '#ffffff', fillOpacity: 0.46 }))
620
+ }
621
+
622
+ /** The settings nav glyph, rendered at the edge the shell asks for. */
623
+ function SettingsSectionIcon({ size }) {
624
+ return h(MosaicMark, { size: typeof size === 'number' && size > 0 ? size : 16 })
625
+ }
626
+
600
627
  /**
601
628
  * The model prompt, editable in place. The Host owns the value and persists it, so
602
629
  * the same text is used by every browser and survives a restart; this page only
@@ -3140,15 +3167,15 @@ window.__ModuleLoader__.load({
3140
3167
  }
3141
3168
 
3142
3169
  /**
3143
- * A stable id per component instance. Marker ids live in the document, so
3144
- * two diagrams on one page must not share `#mosaic-arrow`.
3170
+ * A stable id per component instance. SVG ids live in the document, so two
3171
+ * instances on one page must not share `#mosaic-arrow` or a gradient.
3145
3172
  */
3146
- let diagramInstances = 0
3147
- function useDiagramId(prefix) {
3173
+ let instanceIds = 0
3174
+ function useInstanceId(prefix) {
3148
3175
  const ref = useRef(null)
3149
3176
  if (ref.current === null) {
3150
- diagramInstances += 1
3151
- ref.current = `${prefix}-${diagramInstances}`
3177
+ instanceIds += 1
3178
+ ref.current = `${prefix}-${instanceIds}`
3152
3179
  }
3153
3180
  return ref.current
3154
3181
  }
@@ -3379,8 +3406,8 @@ window.__ModuleLoader__.load({
3379
3406
  }
3380
3407
 
3381
3408
  function FlowchartDiagram({ node }) {
3382
- const arrowId = useDiagramId('mosaic-arrow')
3383
- const accentArrowId = useDiagramId('mosaic-arrow-accent')
3409
+ const arrowId = useInstanceId('mosaic-arrow')
3410
+ const accentArrowId = useInstanceId('mosaic-arrow-accent')
3384
3411
  const layout = useMemo(() => {
3385
3412
  const nodes = Array.isArray(node.nodes) ? node.nodes : []
3386
3413
  const edges = Array.isArray(node.edges) ? node.edges : []
@@ -3564,9 +3591,9 @@ window.__ModuleLoader__.load({
3564
3591
  }
3565
3592
 
3566
3593
  function SequenceDiagram({ node }) {
3567
- const syncId = useDiagramId('mosaic-seq-arrow')
3568
- const returnId = useDiagramId('mosaic-seq-arrow-muted')
3569
- const asyncId = useDiagramId('mosaic-seq-arrow-accent')
3594
+ const syncId = useInstanceId('mosaic-seq-arrow')
3595
+ const returnId = useInstanceId('mosaic-seq-arrow-muted')
3596
+ const asyncId = useInstanceId('mosaic-seq-arrow-accent')
3570
3597
  const layout = useMemo(() => {
3571
3598
  const participants = Array.isArray(node.participants) ? node.participants : []
3572
3599
  const messages = Array.isArray(node.messages) ? node.messages : []
@@ -3799,7 +3826,7 @@ window.__ModuleLoader__.load({
3799
3826
  function SwimlaneDiagram({ node }) {
3800
3827
  const lanes = Array.isArray(node.lanes) ? node.lanes : []
3801
3828
  const steps = Array.isArray(node.steps) ? node.steps : []
3802
- const arrowId = useDiagramId('mosaic-swim-arrow')
3829
+ const arrowId = useInstanceId('mosaic-swim-arrow')
3803
3830
  const layout = useMemo(() => layoutSwimlane(lanes, steps), [node.lanes, node.steps])
3804
3831
  const display = diagramDisplaySize(layout.width, layout.height)
3805
3832
  const arrows = []
@@ -4389,6 +4416,12 @@ window.__ModuleLoader__.load({
4389
4416
  label: () => translate('settingsTitle'),
4390
4417
  locale: NS,
4391
4418
  }, MosaicSettings))
4419
+ // Hosts older than the `settings.section.icon` seat never declare it, so this
4420
+ // stays dormant and the shell keeps its default gear for our section.
4421
+ ctx.slots.inject('settings.section.icon', () => ctx.slots.register({
4422
+ name: 'settings.section.icon',
4423
+ id: 'mosaic',
4424
+ }, SettingsSectionIcon))
4392
4425
  ctx.effect(() => installFenceRenderer(ctx, sendAction), 'dsh-mosaic: fence')
4393
4426
  console.info('[mosaic] client active; fence=dsh-view')
4394
4427
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mosaic",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "type": "module",
5
5
  "description": "Lightweight visual answers for DeepSeek Harness: one compact visual style, an editable model prompt, dsh-view components, Mermaid diagrams, a sandboxed HTML/JS escape hatch, local-first interactions, and link-only media cards.",
6
6
  "author": "imwhatiam",