Skip to content

Releases: yfwu2020/dsh-selection-explain

v0.2.0

Choose a tag to compare

@github-actions github-actions released this 27 Sep 07:51

侧边栏网页里也能划词(0.2.0)

侧边栏里显示的网页——内置「文档预览」的 HTML 文件预览、以及别的插件渲染的生成网页
(如「图解」)——现在选中文字同样会浮出 ✦ 解读,解释用的是那个网页自己的上下文
(选区前后各 1500 字,【】标出选中部分)。

为什么以前不行:这些网页都渲染在不透明源沙箱 iframe 里(sandbox="allow-scripts",
刻意没有 allow-same-origin),父页面拿不到它的文档,顶层 window.getSelection() 永远是空的。
0.2.0 改为往被渲染的文档里注入一段桥脚本:帧内读选区 + 就地采上下文,postMessage 报给
父页面,坐标换算后复用同一套浮标与面板。追问、历史、升格都照常。

覆盖与安全边界

谁渲染的网页 是否覆盖
内置文档预览的 HTML 文件(srcdoc / 交互式 blob: bootstrap) ✅
别的插件在侧边栏渲染的生成网页(blob: + 它自己已开 allow-scripts,如「图解」) ✅
内置浏览器 tab 里的外部站点、路由 URL 的第三方预览器 ⛔ 没有任何注入手段 / 不碰别人的资源改写
  • 帧始终是不透明源,不加 allow-same-origin:网页读不到 GUI 的 DOM / Cookie / localStorage
  • 别人插件的沙箱只桥不加权限(只认它本来就开了 allow-scripts 的帧)
  • 新配置 bridgeSidebarPreview(默认 true),关掉即不注入

时机与主会话对齐

  • 拖拽划词期间不弹,松手后才浮出(位置取最终选区末端)
  • 在网页里点一下 → 按下就收;点另一个网页也收
  • 只有用户动作(mouseup/keyup/selectionchange)能清空;滚动/轮询只重报位置
    —— 页面重绘的瞬时抖动不会让浮标"自己消失"

顺手修掉

  • 上下文改走 DOM 取文本并跳过 script/style(否则交互式预览会把整段页面 JS 当上下文喂给模型)
  • 重发 blob 时保留原 content-type(charset 丢了、页面又没写 meta 的话整页中文会乱码)

测试

576 条断言。新增 scripts/test-bridge.mjs(离线单测:注入位置 / CSP 放宽范围 / 沙箱 token /
上下文与坐标 / 浮现消失的闸门)与 scripts/smoke-bridge.mjs(真浏览器冒烟:三种网页形态 +
沙箱 / CSP / 跨不透明源 postMessage / document.write 冲监听 + 浮现与消失的消息顺序断言;
无 Chrome 自动 SKIP)。

v0.1.3

Choose a tag to compare

@github-actions github-actions released this 24 Sep 07:14

DSH 划词解读 v0.1.3

完整说明见仓库首页 README.md。

本版全部是文档与资产更新,无代码改动。

安装

curl -LO https://github.com/yfwu2020/dsh-selection-explain/releases/download/v0.1.3/yfwu2020-dsh-selection-explain-0.1.3.tgz
mkdir -p ~/.dsh/plugins/dsh-selection-explain
tar -xzf yfwu2020-dsh-selection-explain-0.1.3.tgz -C ~/.dsh/plugins/dsh-selection-explain --strip-components=1
dsh plugin --profile web add ~/.dsh/plugins/dsh-selection-explain

或从 npm:npm install @yfwu2020/dsh-selection-explain@0.1.3

本版内容

  • README 重写为面向使用者的公开版,并新增 4 张功能演示图:
    首轮翻译 / 详解与追问 / 代码注释 / 网页模式
  • 新增「输出偏好:Markdown ↔ 网页」章节,讲清两档的实际语义
    (默认 Markdown;网页档是"网页优先"而非"一律网页")与网页输出的优点
  • 演示图由 scripts/build-demo-pages.mjs 生成:样式直接从 lib/client.js 抽取真实 CSS,
    DOM 结构照渲染器写,Chrome 无头 2x 截图 + crop-png.mjs 裁切
    (四边纯白、宽度统一 540)
  • assets/ 随包发布——README 在 npm 上引用的相对路径图片才能显示
  • 修正过期内容:断言数 463 → 489、脚本表补 test-prompt.mjs

校验

  • 489 条断言全绿(filters 27 / prompt 25 / client / transcript / guard 14)
  • tsc --noEmit 通过
  • provenance:SLSA v1 签名,由 GitHub Actions 构建

v0.1.2

Choose a tag to compare

@yfwu2020 yfwu2020 released this 24 Sep 01:45

DSH 划词解读 v0.1.2

完整说明见仓库首页 README.md。

安装

curl -LO https://github.com/yfwu2020/dsh-selection-explain/releases/download/v0.1.2/yfwu2020-dsh-selection-explain-0.1.2.tgz
mkdir -p ~/.dsh/plugins/dsh-selection-explain
tar -xzf yfwu2020-dsh-selection-explain-0.1.2.tgz -C ~/.dsh/plugins/dsh-selection-explain --strip-components=1
dsh plugin --profile web add ~/.dsh/plugins/dsh-selection-explain

或从 npm:npm install @yfwu2020/dsh-selection-explain@0.1.2

本版内容

修复

  • 从「最近」列表回放时面板不再跳到右下角胶囊上方:点列表里的一条时,
    面板原先被重新锚到状态胶囊上(列表本身是贴着面板摆的,面板一跳两者关系就错位)。
    现在从列表进入保持原位,从胶囊进入仍锚到胶囊上方。

重构(不影响使用)

  • 提示词抽出独立模块 src/prompts.ts(原混在 2500+ 行的 src/index.ts 里)
  • 新增 25 条提示词契约测试(断言总数 463 → 489):把两节结构标题、结论条格式、
    音标规则、详解来源判断、追问网页模式要求等关键约束固化成断言,误删即 CI 红
  • 删除已弃用的 TWO_LAYER_RULE 死代码(只定义、从未被任何提示词引用)
  • 开发资料(docs/、PROMPTS.md)移出公开仓库,仅本地保留

校验

  • 489 条断言全绿(filters 27 / prompt 25 / client / transcript / guard 14)
  • tsc --noEmit 通过
  • provenance:SLSA v1 签名,由 GitHub Actions 构建

v0.1.1

Choose a tag to compare

@yfwu2020 yfwu2020 released this 24 Sep 01:45

DSH 划词解读 v0.1.1

完整说明见仓库首页 README.md。

这是首次由 GitHub Actions 自动发布(Trusted Publishing / OIDC + provenance)。

安装

curl -LO https://github.com/yfwu2020/dsh-selection-explain/releases/download/v0.1.1/yfwu2020-dsh-selection-explain-0.1.1.tgz
mkdir -p ~/.dsh/plugins/dsh-selection-explain
tar -xzf yfwu2020-dsh-selection-explain-0.1.1.tgz -C ~/.dsh/plugins/dsh-selection-explain --strip-components=1
dsh plugin --profile web add ~/.dsh/plugins/dsh-selection-explain

或从 npm:npm install @yfwu2020/dsh-selection-explain@0.1.1

本版内容

  • 测试可在无宿主环境运行:客户端集成测试先探测 DSH 是否在跑,不可达则跳过在线断言
    并打印说明(原来会 ECONNREFUSED 直接崩掉 CI 流水线)
  • CI 修复:build.sh 的运行时探测与 tsc 探测原先不看项目自己的 node_modules;
    链接步骤在探测结果为自身时会自引用(Too many levels of symbolic links)
  • 依赖钉版本:@deepseek-ai/* 固定到 0.1.5-rc.3(npm 上这些包的 latest 仍是
    0.0.1-rc.x,API 更旧,会编译失败)

校验

  • 4 套件断言全绿;tsc --noEmit 通过
  • provenance:SLSA v1 签名,由 GitHub Actions 构建(可在 npm 上 npm audit signatures 验证)

dsh-selection-explain v0.1.0

Choose a tag to compare

@yfwu2020 yfwu2020 released this 23 Sep 14:37

DSH 划词解读 v0.1.0

在 DSH Web 界面里选中任意文字,就地得到专业翻译 + 这段文字在当前上下文里到底是什么意思,还能接着追问、或一键升格成正式会话。

完整说明见仓库首页 README.md。

安装

curl -LO https://github.com/yfwu2020/dsh-selection-explain/releases/download/v0.1.0/yfwu2020-dsh-selection-explain-0.1.0.tgz
mkdir -p ~/.dsh/plugins/dsh-selection-explain
tar -xzf yfwu2020-dsh-selection-explain-0.1.0.tgz -C ~/.dsh/plugins/dsh-selection-explain --strip-components=1
dsh plugin --profile web add ~/.dsh/plugins/dsh-selection-explain

这个包里有什么

  • lib/index.js(host 半,tsc 编译)+ lib/client.js(client 半,手写 ModuleLoader bundle)—— 装完即可用,无需构建
  • src/、scripts/、skills/web-design/、cordis.patch.yml、README.md

校验

  • 测试:4 套件 463 条断言全绿(filters / client / transcript / guard)
  • 类型检查:tsc --noEmit 通过
  • sha256:edc4d42bfbd7736b97b636da40db6c1a299b48872e0c1065042a54ae9759531a

包名变更

包名从 @dsh-external/dsh-selection-explain 改为 @yfwu2020/dsh-selection-explain
(@dsh-external 是第三方在 npm 上持有的 scope,用它发布会 403)。安装包文件名同步变为
yfwu2020-dsh-selection-explain-0.1.0.tgz,旧文件名已从本 Release 移除。