Skip to content
dsh.fish
Bundle

@peanutsdou/dsh-selection-tutor

DSH 划词学习小窗:选中文字后弹出“解释/翻译”,在当前会话的临时隐藏分支中追问,关窗即销毁。

Source
PeanutsDou
License
MIT
Updated
Updated 21 days ago

Readme

# dsh-selection-tutor

选中对话里的任意文字,浮出「解释 / 翻译」两个按钮;点击后在当前会话上方打开一个可拖动、可缩放的学习小窗。小窗是当前主会话的一个**隐藏临时分支**:

- 不出现在会话列表;
- 不向主会话写入任何消息,不影响主会话上下文与缓存;
- 模型固定继承主会话的 provider / model / maxTokens / 工作目录;
- 小窗创建时会把主会话**已完成轮次**做一次固定快照注入子会话(标题栏有「已继承 N 轮」标记);主会话正在生成的当前轮不进入快照,首轮生成中则上下文为空,创建后不随主会话动态变化;

- **不继承主会话的 agent preset,也不带任何工具**:小窗是一个纯文字解释/翻译会话,选中的原文不会触发工具调用;
- 只能切换思考强度(off / high / max);
- 翻译窗口先预览选中原文,可选择目标语言(自动 / 中 / 英 / 日 / 韩 / 法 / 德 / 西)并补充翻译要求后再开始;
- 解释模式第一轮会把选中原文作为只读数据,后续提问以普通追问继续;
- 回答自动复制、思考过程默认折叠、发送失败自动恢复草稿;
- 关闭小窗即销毁该临时分支;`Esc` 关闭,`Enter` 发送,`Ctrl/Cmd+Enter` 也发送;
- 标题栏可「置顶」:置顶后切换主会话不会自动关闭小窗,且关闭前会二次确认,避免误触丢失;
- 页面刷新、关闭标签页时会尽力销毁对应分支;主进程重启后不恢复历史,旧窗口最多 15 秒无轮询即可被新窗口回收;
- 小窗历史不持久化,重启后不恢复。

## 配置

「设置 → 自定义模型配置 → 划词学习小窗」可设置新小窗的默认思考强度(默认 off)与翻译默认目标语言(默认自动检测)。该设置页签由 `dsh-custom-model-config` 提供。

## 构建

```bash
pnpm install
pnpm run build
pnpm test
```

## 安装

```bash
dsh plugin --profile web add github:PeanutsDou/dsh-selection-tutor
```

或者手动将本插件与 `dsh-custom-model-config` 加入 profile 的 cordis patch 层,然后重启 `dsh web` 并刷新页面。

Install

dsh plugin --profile web add github:PeanutsDou/dsh-selection-tutor

Profile: web

  • This package builds from source on install. pnpm will ask you to allow its build script — that is permission to run the package’s code on your machine, outside the agent sandbox. Only allow sources you trust.
  • This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.
Source