rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:Elycheng/dsh-article-annotator
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
在 DSH 右侧栏批注 Markdown / Word / PowerPoint / PDF 文稿:整句、词组、任意几个字都能选中批注,把「这几个字要改」的意见变成 Agent 能读、能执行、能勾销的批注,反复出现的意见再沉淀成长期写作风格记忆。
现有 AI 改稿的常见问题是「意见悬空」:人在对话框里说「第二段太啰嗦」,模型得自己猜是哪一句;改完之后意见也没有落点,下一次又从头说过。
这个插件把链路钉在原文的具体文字上:
发给 Agent 修改 把待处理批注写成一条输入框草稿(只写草稿,不自动发送);Agent 通过工具读取每条意见、改稿、把处理过的批注标为已解决。.md / .markdown / .txt / .docx / .pptx / .pdf,并列出最近打开的文件。要求:DSH 0.2.0-rc.2 或更新;Node.js ≥ 20。
首次公开发布前 npm 上还没有这个包;在此之前请用下面的「从本地源码」方式安装。
dsh plugin --profile web add dsh-article-annotator
装完重启一次 DSH(或等待 Profile HMR 重载),刷新页面,右侧栏引导页里即可看到「文稿批注」。
dsh plugin --profile <profile> add dsh-article-annotator
git clone https://github.com/Elycheng/dsh-article-annotator.git
cd dsh-article-annotator
npm install
npm run build
# 装进本机 profile(默认 ~/.dsh/profiles/desktop;可用 --profile web 等)
node scripts/install-local.mjs --profile-dir "$HOME/.dsh/profiles/web"
install-local.mjs 只做三件事:把当前 checkout 作为 link: 依赖写进 profile 的 package.json、在 dsh.profile.bundles 里选中它、运行 pnpm install --ignore-scripts。它不会手写 loader 行——选中 bundle 时插件自带的 cordis.patch.yml 会插入;重复手写会报 duplicate loader id。
卸载:
node scripts/uninstall-local.mjs --profile-dir "$HOME/.dsh/profiles/web"
package.json 增加依赖:"dsh-article-annotator": "link:<checkout-path>",并把 "dsh-article-annotator" 加进 dsh.profile.bundles;pnpm install --ignore-scripts;保存。article_review_resolve 勾销批注、调用 writing_style_add 记录风格规则。Agent 工具要在新会话(或插件加载后的会话)里才可见;加载前已开始的会话看不到新注册的工具。
| 工具 | 作用 |
|---|---|
article_review |
读取当前文稿的批注(位置、覆盖的原文片段、意见、状态)和风格记忆;Word/PPT/PDF 默认连全文一起返回。省略 file 时用本会话最近打开的一篇。 |
article_read |
读取全文(带 [bN] 段落编号、页码 / 幻灯片分隔)。适合模型自己的文件工具读不了的 docx/pptx/pdf。 |
article_review_resolve |
改完后把批注 id 标为已解决。 |
article_review_save_revision |
把改好的全文写成源文件旁边的 <原名>.revised.md(二进制文稿的交付方式)。 |
writing_style_add |
记录一条可复用的表达规则(自动去重)。 |
writing_style_get |
读取全部风格规则。 |
「发给 Agent 修改」生成的草稿自带完整指令:读批注 → 改稿(Markdown/TXT 直接改原文件;Word/PPT/PDF 写 .revised.md)→ 勾销批注 → 归纳风格规则 → 汇报改了什么。
$DSH_HOME/article-annotator/(默认 ~/.dsh/article-annotator):| 路径 | 内容 |
|---|---|
annotations/<sha1>.json |
每篇文稿的批注与状态(按绝对路径哈希) |
style.json |
长期写作风格记忆 |
recent.json |
最近打开的文稿 |
sessions.json |
每个会话最近打开的一篇(工具默认目标) |
npm run check:privacy 扫描绝对路径、邮箱、令牌形态等敏感片段。| 格式 | 读取方式 | 写回方式 |
|---|---|---|
| Markdown / TXT | 纯 Node 解析(标题、段落、列表、代码块、表格;剥离行内 Markdown 语法但保留文字) | Agent 直接改原文件 |
| DOCX | 零依赖 ZIP 读取 + word/document.xml 段落/标题提取 |
Agent 写 .revised.md |
| PPTX | 零依赖 ZIP 读取 + 按 presentation.xml 顺序提取幻灯片段落 |
同上 |
宿主机 Python + pypdf 提取(pdftotext 兜底) |
同上 |
.doc / .ppt(会提示改用原生预览或另存为 docx/pptx)。pypdf 或 poppler 的 pdftotext;纯图片 PDF 没有可提取文字。。!?…; 与后置引号/括号切分;英文 . 只在像句号时才切(v1.2、README.md、e.g. 不会误切)。批注按「段落 id + 字符范围 + 覆盖文字」保存,整句和任意选中片段用同一套锚点;文章改过、位置漂移后先按精确位置校验,再按覆盖文字(忽略空白/标点差异)重新锚定;找不到的批注标记「定位失效」但不会丢。旧版按句子保存的批注会自动迁移到范围模型。在 profile 的 cordis.patch.yml 里可以覆盖(或直接改插件 bundle patch 行):
- id: article-annotator
name: dsh-article-annotator
config:
injectStyle: true # 风格记忆是否进入系统提示
maxStyleRules: 12 # 提示里最多列几条
maxArticleBytes: 41943040
maxBlocks: 1500
enableTools: true # 是否注册 Agent 工具
lib/index.js host 半入口:Standard Schema 配置、按需注入 webServer / tools / systemPrompt
lib/api.js /article-annotator/api/{probe,list,open,comment,style,recent},同源围栏 + JSON 信封
lib/tools.js 6 个 Agent 工具(defineTool 从宿主安装目录按需解析,找不到只降级工具)
lib/extract.js Markdown/TXT/DOCX/PPTX/PDF → blocks + sentences
lib/pdf.js Python(pypdf) / pdftotext 文本提取
lib/zip.js 最小 ZIP 读取器(central directory + raw inflate)
lib/sentences.js 确定性句子切分(中文/英文、超长软切)
lib/store.js 批注 / 风格记忆 / 最近文件 / 修订稿(原子写、容量上限)
lib/status.js 运行期状态,probe 接口原样返回,便于排障
src/client/index.tsx 右侧栏页面(一个 vendor-CJS bundle,只 require 平台基线 react)
scripts/build-client.mjs tsc → 包进 window.__ModuleLoader__.load 工厂
插件不修改 DSH 源码,只作为 profile bundle 挂载;卸载即净。宿主依赖全部通过 ctx.inject / ctx.get 按需接入,缺少某项能力时对应功能降级而不是整插件加载失败。
react,不引入自己的前端依赖。npm install # typescript + react/react-dom/jsdom(测试与构建用)
npm run build # 生成 lib/client.js
npm test # 37 项离线测试
npm run check:privacy
测试覆盖:句子切分、四种格式提取(含真实 PDF)、批注存储与重锚定、API 围栏与全流程、插件入口接线、客户端 bundle 注册,以及 jsdom + 真实 React 的完整批注流程。PDF 测试需要能启动 Python;受限环境下会跳过并说明。
.revised.md 交付,避免破坏二进制版式。Markdown 文稿才是真·原地修改。sidebarRightTabs / slots 服务;缺失时页面不注册,而不是报错。pdftotext)。dsh-article-annotator adds an Article Review page to DSH's native right sidebar: it turns Markdown / DOCX / PPTX / PDF articles into sentence-addressable text, lets you annotate any sentence, and hands the open review to the agent as a composer draft. Six agent tools let the model read every comment, revise the article (in place for Markdown, as <name>.revised.md for binary formats), resolve the comments, and record recurring wording preferences into a long-term style memory that is injected into later prompts. Everything stays local: no network calls, no telemetry, annotations under $DSH_HOME/article-annotator.
MIT — see LICENSE.
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。