Zum Hauptinhalt springen
A

dsh-style-mirror

anjiaqi0926/dsh-style-mirror

Reads a PDF/Word/text corpus library, picks the matching scene (paper, official document, fiction, chat) from each message, and writes the reply in that corpus style while removing common AI mannerisms.

Installation

dsh plugin --profile web add github:anjiaqi0926/dsh-style-mirror

README

dsh-style-mirror(文风镜像)

A DeepSeek Harness (DSH) bundle. It adds a「文风」switch beside the model selector: the plugin reads a corpus library (PDF / Word / WPS / plain text), groups folders into scenes (academic paper, official document, fiction, chat, news, tech doc), picks the scene that matches your latest message, and injects a writing brief so replies follow that corpus's style with fewer AI mannerisms. Nothing is uploaded; the corpus is read locally.

输入框模型选择器旁一个开关。打开后,插件把参考库里的文档读成“文风基线”,注册为系统提示段落 style-mirror,让此后所有回答按该文风书写;关掉后该段落长度为零。

  • 素材格式:.pdf、.docx、.doc、.wps、.txt、.md、.csv、.json、.html(扩展名不可靠时按文件头识别,.docx 实为老 Word 也能读)。子文件夹一并读取。
  • PDF:优先调用系统的 pdftotext(TeX Live / poppler 自带,质量最好);找不到时用内置解析器(纯 Node,无依赖,支持 ToUnicode、FlateDecode、对象流、Form XObject)。扫描件(无文字层)会报“没有可用的文字层”。
  • 场景自动识别:直接把参考库根目录当作素材目录时,每个子文件夹算一个「场景风格集」(如 论文写作/课题组风格、小说写作/绳文、普通对话/…)。每次组装提示词前读最近一条用户消息,先判断场景(学术论文 / 机关文书 / 小说叙事 / 口语对话 / 新闻资讯 / 技术文档 / 通用),再在同场景的素材集里取素材最多的那个;判定把握不大时提示词里附「场景对照表」,让模型在明显不符时自行改用。面板可手动锁定某个场景。
  • 统计口径:按素材语言切换口径(中文按字、英文按词),统计句长分布、段落长度、标点密度、层级与序号习惯、高频衔接词、常用词与常见词组、数字写法;另取若干原文段落作风格样例。
  • 写作规则:按场景给规则(学术论文 / 机关文书 / 小说 / 对话 / 新闻 / 技术文档),并统一压掉“首先、其次、综上所述、赋能抓手、不仅……更是……”一类 AI 腔。
  • 状态:$DSH_HOME/plugin-data/dsh-style-mirror/state.json;抽出的文本缓存在同目录 cache/,重启不重解析 PDF。
  • 场景锁定按会话隔离:面板里点某个场景只对当前对话生效,切换对话不会互相影响;「自动」时每个对话各自识别,没有明显场景词的消息会沿用本对话上一次识别的场景。
  • 兼容性:engines.dsh 声明为 >=0.2.2-rc.3 <0.3.0,与当前 DSH 0.2.2 系列对齐。
  • 无第三方依赖,仅用 Node 内置模块。

安装

从 npm 安装(发布后可用):

dsh plugin --profile desktop add dsh-style-mirror

本地目录安装:

dsh plugin --profile desktop add "link:<本目录绝对路径>"

配置(patch 行)

- insert:
    - id: style-mirror
      name: 'dsh-style-mirror'
      config:
        materialsDir: 'H:\语料参考库'   # 参考库根目录(按子文件夹分场景)
        intensity: standard             # lite | standard | strict
        maxPromptChars: 7000
        pdfMaxPages: 40                 # 每个 PDF 最多读多少页
        pdfTool: auto                   # auto(优先 pdftotext)| builtin | off
        enabledOnFirstUse: false

界面里选过的参考库优先于 materialsDir;intensity、maxPromptChars、pdfMaxPages、pdfTool 以 patch 或界面设置中较新的一个为准。

目录

index.js          Host 半:系统提示段 + HTTP 接口
client.js         Client 半:开关胶囊与面板
lib/extract.js    文本抽取入口(PDF/Word/WPS/纯文本,带缓存)
lib/pdf.js        内置 PDF 解析器
lib/style.js      文风统计、场景化写作规则、提示词组装
lib/scene.js      场景(体裁)判断与素材集打分
lib/session.js    从当前会话读最近一条用户消息
lib/store.js      状态、参考库扫描、场景风格集、提示词缓存

License

MIT

Ähnliche Plugins