Bundle
dsh-fullwidth-punctuation
DSH 插件:让 AI 回答输出中文全角标点(用户直接复制回答内容也是全角)。监听 llm/stream 瀑布,在模型输出流上做智能半角→全角转换,跳过代码块/行内代码/数字小数点/URL/时间/markdown 链接,并注入 system prompt 提示模型输出全角。
- Source
- addie-ace
- License
- MIT
- Updated
- Updated 5 days ago
Readme
# dsh-fullwidth-punctuation 让 DeepSeek Harness 的 **AI 回答输出中文全角标点**:回答在界面上是全角,**用户直接复制回答内容也是全角**。面向政务公文、汇报材料等对「标点统一全角」有硬性要求的写作场景。 ## 原理 插件是纯 host 端 Cordis 插件,监听 `llm/stream` 瀑布(`@deepseek-ai/dsh-llm` 官方设计的流拦截点),在**数据源头**把模型输出文本里的半角标点转换为中文全角: - 模型输出 → `llm/stream` 拦截 → 转换 → 写入会话存储 → 渲染到界面 → 复制 - 因为转换发生在源头,界面显示、复制按钮、选中复制拿到的都是同一份全角文本。 同时注入一条 system prompt 提示模型尽量输出全角(双保险,减少后处理负担)。 ## 转换规则(智能全角,不破坏代码/数字/链接) | 输入 | 输出 | 说明 | |---|---|---| | `,` `;` `!` `?` | `,` `;` `!` `?` | 无条件转换 | | `.` | `。` | 数字小数点(`3.14`)、省略号(`...`)不转 | | `:` | `:` | 时间(`10:30`)、URL(`http://`)不转 | | `(` `)` | `(` `)` | markdown 链接 `[text](url)` 内的括号不转 | | `"` | `“` `”` | 配对转换 | | 代码块 `` ``` `` / `~~~` | 不转 | fenced code 整体跳过 | | 行内代码 `` ` `` | 不转 | inline code 跳过 | | 裸 URL | 不转 | `http://example.com/a.b` 保持原样 | | `<` `>` `[` `]` `*` `#` `-` `_` `'` | 不转 | 歧义过大,保守保留 | **只转换 AI 的回答文本**:不转用户输入、不转工具调用的 JSON 参数、不转推理(reasoning)内容。 ## 安装 ```sh # 方式一:本地打包后安装(推荐,离线可用) cd dsh-fullwidth-punctuation npm pack # 生成 dsh-fullwidth-punctuation-0.1.0.tgz dsh plugin --profile web add ./dsh-fullwidth-punctuation-0.1.0.tgz # 方式二:直接用目录安装 dsh plugin --profile web add ./dsh-fullwidth-punctuation ``` 安装后**重启 Web GUI**(或重启 `dsh web`)生效。 ## 卸载 ```sh dsh plugin --profile web remove dsh-fullwidth-punctuation ``` ## 验证 1. 运行单元测试:`node --test test/` 2. 装好后问 AI:「写一段材料,包含逗号、句号、冒号和括号」,观察回答与复制内容均为全角。 3. 再让 AI 输出一段代码块,确认代码块内的半角标点**没有被**改写。 ## 边界说明 - 转换只作用于走标准 `llm/stream` 的模型输出(DeepSeek Harness 的 agent-loop 全部走该路径)。 - 半角双引号 `"` 会被配对成中文引号;英文引文场景如不希望转换,请卸载插件。 - 裸域名(无 `http://` 前缀)中的点号可能被当作句号转换,URL 请写全前缀。 - 首版默认开启,无设置界面;如需开关可后续版本加配置项。 ## 开发 ```sh node --test test/ # 运行测试 ``` 核心文件: - `lib/index.js`:host 插件入口(`llm/stream` 监听 + system prompt 注入) - `lib/fullwidth.js`:转换核心(流式安全状态机)
Install
dsh plugin --profile web add github:addie-ace/dsh-fullwidth-punctuation
Profile: web
With the hub plugin installed, ask your agent to install it by name — it resolves the same plan shown here.
dsh plugin --profile web add github:stvlynn/dsh.fish#path:packages/dsh-plugin-hub
install dsh-fullwidth-punctuation from the hub
- This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.