DSH HUB
HomePlugin StorePlugin PacksCommunityRankingsResourcesPublish Guide
Plugin source
Back to catalog

2927683690myn-rgb /

2927683690myn-rgb/dsh-file-index

Verified

DSH 插件:侧边栏「文件」页,汇总所有会话出现过的文件,Word / 其他两个标签;docx 与 md 点开即读,带阅读进度、断点续读和「已读完」标记

★ 0 Stars0 Forks0 IssuesN/A Community rating0 Confirmed installs
View on GitHub
READMESource: main@6f4d9756

dsh-file-index(文件)

侧边栏「自动化任务」下面多一行 文件:把所有对话里出现过的文件汇总到一页,按 Word / 其他 分两组。

  • 数据来源:~/.dsh/sessions/*/session-*/session.v4.jsonl.zstd(所有会话,不只当前这个)。
  • 统计哪些文件:present 交付的文件、write/edit 写出的文件、用户消息里的附件,以及日志里出现过的绝对路径(限 ~/.dsh/workspaces 与 ~/.dsh/attachments 内)。
  • 底部居中一个半透明小胶囊,只显示「读了多少」的百分比数字;滚动时亮一下,停手 1.2 秒淡到 34%,读到 100% 变绿;一屏就到底的短文档不显示。
  • 每篇阅读页最下面都有「完」+「读完了,标记一下」:点一下把这篇标成已读完(再点一下撤销),列表里该文件名字前面会出现绿色的「已读完」。标记存在 ~/.dsh/file-index-state.json,删掉这个文件就全部清零。
  • 阅读页会记住读到哪儿:关闭标签页或切走时把滚动位置存进 localStorage(键 dsh-file-index:pos:<绝对路径>),下次点开同一个文件自动跳回去。
  • 点一行 → 新标签页直接读:.docx 与 .md 现场转成网页(/file-index/view),pdf/图片内联,其他类型走下载。
  • 刷新按钮重新扫描;宿主侧有 20 秒缓存,?refresh=1 跳过。

路由

路由 作用
GET /file-index/list JSON:{ok, scannedAt, sessionCount, counts:{word,other}, files:[…]}
GET /file-index/view?path=<abs> docx / md → 排版好的 HTML 页面;其余 302 到 /open
GET /file-index/open?path=<abs> 返回文件字节;只允许 ~/.dsh 下 workspaces / attachments / cache

实现要点

  • docx 不装依赖:lib/docx.js 自己读 zip 中央目录(inflateRawSync 解 deflate),再按块解析 word/document.xml —— 标题样式、粗斜体、换行、表格都保留,页眉页脚/批注不显示。
  • 会话日志是 zstd 多帧追加(每条记录一帧,魔数 28 b5 2f fd):zlib.zstdDecompressSync 一次只解一帧,所以按魔数切帧后逐帧解压,再按行 JSON 解析,尾部半帧跳过。
  • 路径比较前统一 realpathSync:这台机器 /data/user/0/<pkg> 与 /data/data/<pkg> 是同一目录的两种写法。
  • 去重按 文件名:字节数;已删除的文件只在它是 present 交付物或附件时保留,并标红显示。

安装(本机试用)

ln -sfn ~/.dsh/plugins/dsh-file-index ~/.dsh/profiles/web/node_modules/dsh-file-index
# 然后在 profile 的 cordis.patch.yml 末尾追加:
# - insert:
#     - id: file-index
#       name: dsh-file-index

新加插件条目只在 DSH 启动时生效:装完要重启一次 DSH。之后改代码可以按界面上的刷新按钮热换。

安装(本地)

三处就够了,不用打包、不用 registry:

  1. 源码放 ~/.dsh/plugins/dsh-file-index/;
  2. ~/.dsh/profiles/web/package.json 的 dependencies 里声明 "dsh-file-index": "file:../../plugins/dsh-file-index"(本地链接,不走网络);
  3. ~/.dsh/profiles/web/cordis.patch.yml 末尾 - insert: [{id: file-index, name: dsh-file-index}],把它插进插件图。

node 侧解析验证:req.resolve('dsh-file-index') → ~/.dsh/plugins/dsh-file-index/lib/index.js; dsh --profile web --dump-config | grep file-index 有且只有一条。

装完要重启一次 DSH(这个 profile 只在启动时应用插件图);之后改代码按刷新按钮热换即可。

—/ 5

No ratings yet

Verified DSH bundle

Commit 6f4d97568abd

Community comments

No comments yet. Be the first to write one.

DSH HUB

A community index for DSH plugins. Not an official GitHub or DeepSeek AI product.

CommunityResourcesAPIAbout