工作方式
dsh-annotation 运行在浏览器端,全部逻辑位于手写的 client.js bundle 中,不需要构建步骤。package.json 声明 dsh.bundle 和 dsh.client,由 client-modules 注入;Node 端为空实现。插件读取选中的 assistant 文本、批注内容和 composer 草稿,在提交前通过 setDraft 组合消息,不直接修改 composer textarea 的 DOM。
消息与回复
每条批注包含编号、原文和可为空的批注。发送时,插件把批注块与问题交给模型,并注入要求模型返回 Annotation 1: … 至 Annotation N: … 的格式。用户自己的消息气泡会在浏览器绘制前移除批注块,只保留问题和 Annotations ×N chip。回复流结束、data-streaming 被移除后,回复中的 Annotation N: 会变成可悬停 chip。批注数据保存于带有 annotation tag 的最近一条用户消息的 tag.__annotationItems,刷新后会重建。
配置与校验
cordis.patch.yml 只插入插件自身的 id 一次;profile patch 必须保持 []。可用以下命令检查配置和客户端服务:
dsh --profile web --dump-config | rg "id: dsh-annotation"
curl -s -o /dev/null -w '%{http_code}\n' "http://127.0.0.1:3080/plugins/@omdsh-dev/dsh-annotation/client.js"
前一条输出应只有一行,后一条应返回 200。修改插件后需要重启 web service;README 给出的方式是 launchctl kickstart -k "gui/$(id -u)/com.dsh.web"。
交互与兼容性
可跨消息和会话累计任意数量的批注,标记会随滚动重新锚定。Enter 处理包含 isComposing 和 keyCode 229 判断,兼容 IME 输入。插件也支持 dsh-focus-chat 的 focus conversation view,其中 assistant 行使用 [data-focus-flow] 容器和 *_assistant CSS-Modules class。
Written from the project's own documentation and kept in sync with it. Where the two disagree, the source is authoritative — read the README on GitHub