READMESource: main@03d5ee19
dsh-paste-names
Paste a non-image file or folder into the DSH chat composer → get a native @path reference instead of the "PNG/JPG/WebP/GIF only" error.
在 DSH(DeepSeek Harness)Web 聊天输入框里粘贴非图片文件或文件夹时,本插件会把它解析成 DSH 原生 @ 文件引用,替代默认的「仅支持 PNG、JPG、WebP、GIF 格式的图片」报错。
行为
| 粘贴内容 | 结果 |
|---|---|
| 工作区内的文件 | @相对/路径/文件名(与手动 @ 选择完全等价) |
| 文件件夹 | @目录/(目录引用,带尾斜杠) |
| 含空格的路径 | @"my docs/readme.md" 引号语法 |
| 解析失败(工作区外 / 无匹配 / 超时) | 回退插入纯文件名 |
| 截图 / png / jpg / webp / gif | 不干预,走 DSH 原生图片附件流程 |
| 纯文本 | 不干预 |
多条目粘贴时以空格分隔逐个插入。同名候选取路径最短者(与 @ 菜单首选一致)。
工作原理
插件分两半:
- 浏览器半(
lib/client.js):在 document 捕获阶段拦截输入框的paste事件(先于 DSH 自带处理),识别剪贴板里的文件/文件夹条目,解析后以@语法插入草稿。会话 id 通过粘贴目标沿 React fiber 上溯取得。 - 宿主半(
lib/index.js):注册GET /plugins/dsh-paste-names/resolve深度解析路由。
路径解析分两级:
- 快查:DSH 自带
remote.fileReferences@ 搜索索引(毫秒级;但索引有 10,000 条 BFS 截断,大仓库深层文件覆盖不到); - 深度兜底:宿主半用
node:fs按 basename 全量扫描会话 cwd(排除.git/node_modules;400,000 条 / 4 秒双上限;实测约 1s / 78k 条目),弥补索引截断。
安装
方式一:dsh plugin add(推荐)
dsh plugin --profile web add git+https://github.com/PaoMoXML/dsh-paste-names.git
(本包的 package.json 声明了 dsh.bundle.patch,dsh plugin add 会自动接线。)
方式二:手动
克隆仓库到 profile 的插件目录:
git clone https://github.com/PaoMoXML/dsh-paste-names.git ~/.dsh/profiles/web/plugins/dsh-paste-names在
~/.dsh/profiles/web/package.json的dependencies里加一行,然后在该目录执行pnpm install:"dsh-paste-names": "link:plugins/dsh-paste-names"在
~/.dsh/profiles/web/cordis.patch.yml末尾追加:- insert: - id: paste-names name: dsh-paste-names重启
dsh web并硬刷新页面(Ctrl+Shift+R)。
已知取舍
- 同名文件/目录取路径最短者,不弹选择菜单;
- 扫描包含构建产物(如
target/、dist/),如需排除可自行在lib/index.js的EXCLUDED集合中添加; - 深度解析首扫约 1 秒(按仓库规模浮动),索引内条目毫秒级。
License
MIT
No comments yet. Be the first to write one.