返回目录
生活娱乐 插件

dsh-media-rescue

BrainZombie/dsh-media-rescue

Repair broken markdown image paths in DeepSeek Harness (dsh): shadows GET /api/file, five-tier name matching, prevention inside tool results, escape-proof /ws/ URLs.

Stars
0
Forks
0
Issues
0
更新
8 天前

PROJECT TOPICS

项目标签

INSTALL REFERENCE

安装参考

未验证
dsh plugin --profile web add github:BrainZombie/dsh-media-rescue

该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。

PROJECT README

README

dsh-media-rescue

DeepSeek Harness(dsh)插件:修好「图片无法预览」。

回复正文里的 markdown 图片走 GET /api/file?path=<绝对路径>,文件找不到就 404,卡片回落成 image.failed(文案「图片无法预览」,前面是 alt)。最常见的成因不是内容被拦,而是路径本身不存在:图生成了,只是落在别处,正文却按约定拼了一个工作区路径。

它做三件事

  1. 接管 /api/file(kind: 'prefix',DSH 路由 exact → longest prefix → fallback),只有在内置处理器返回 404 时才介入。
  2. 五层匹配找到真实文件:原名 → 去掉生成器帧号 → 别名(正文把输出目录名粘进了文件名)→ 前缀(文件名被截短)→ 还原被 Markdown 吃掉的分隔符。候选先过组合文件系统探测,歧义就放弃,不猜。
  3. 预防:tools/post-execute 里,任何工具结果出现真实存在的媒体路径时,追加一份可直接粘贴的 markdown 图片语法;另外注册 GET /ws/<绝对路径> 直贴路由(纯 http URL,不会被转义吃掉分隔符)。

找到之后:目标在工作区内就把真实文件拷到正文引用的位置(只创建、不覆盖),否则把请求改写到真实路径——状态码、缓存、Content-Type、字节上限全部沿用内置实现。

三种来源:工具结果索引(运行时)→ roots 目录(显式配置)→ 历史会话索引(经 sessionQuery,让装上插件之前就写坏的会话也能恢复)。

安装

# 直接从 GitHub 装
dsh plugin add --profile <你的 profile> git+https://github.com/BrainZombie/dsh-media-rescue.git

# 或者从本地目录装
dsh plugin add --profile <你的 profile> /path/to/dsh-media-rescue

或:插件 → 添加插件,选这个目录。

最小配置(cordis.patch.yml 或插件配置):

roots:
  - 'D:\your\generator\output'
materialize: workspace

roots 填图片实际落盘的目录;不填也会靠工具结果索引和历史会话索引工作。

工具

media_rescue:

  • status —— 路由是否接管、/ws 是否可用、索引规模、最近事件;
  • resolve + path —— 只查不写,看一条路径会解析到哪个真实文件、命中哪一层;
  • probe + path —— 端到端跑一遍 404 → 救援 → 回写,并额外测一次 /ws。

限制

  • 只按文件名匹配,不比对图像内容;同名多处取「目录名提示 → 最新修改」;歧义放弃。
  • 救援在显示层:消息文本不改写,导出 markdown 时旧路径仍是旧路径(除非已被拷成真文件)。
  • 磁盘上确实不存在的文件无法恢复。
  • 与同样接管 /api/file 的插件(如 dsh-file-path-repair)互斥:重复路由注册会抛错。

详细机制、配置表与实测记录见 docs/DETAIL.md。

English

Repairs broken markdown image paths in DeepSeek Harness. The plugin shadows GET /api/file (longest-prefix route, only acting on 404) and resolves the missing name through five tiers — exact, frame-counter-insensitive, directory-glued alias, stem prefix, and Markdown-escape restoration — probing every candidate through the composed filesystem and refusing to guess when ambiguous. It also prevents the failure at the source by appending ready-to-paste Markdown to tool results, and exposes GET /ws/<absolute path> for an escape-proof URL form.

MIT licensed.

CLASSIFICATION EVIDENCE

分类依据

项目类型插件
功能分类生活娱乐
规则置信度高

系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: image。