npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dsh-agent-rewind-plugin

v0.3.0

Published

Filesystem transactions for DeepSeek Harness: turn checkpoints, effect diff, rewind, and a settings page.

Readme

dsh-agent-rewind

给 agent 的文件系统事务层:checkpoint → 执行 → 效果 diff → 按窗口回滚。 不是 allow/deny,不是只读/工作区沙箱——它假设 agent 始终全权限,把安全放在“后果可逆”上。

任务开始 ── checkpoint(内容寻址快照)
   │
   ▼
执行(full access,零弹窗)
   │
   ▼
效果 diff(新增/修改/删除,按文件、按大小、按目录)
   │
   ├─ 正常                    → 静默提交
   ├─ 受保护目录被删/大规模删除 → 告警(可选自动恢复)
   └─ 新增文件                → 回滚时可选移入 trash(--trash-added),不直接删

为什么不是权限系统

权限系统判“命令字符串”,事故判“文件后果”。本工具只做后者:

  • 精细:粒度是单个文件,不是整条命令;
  • 准确:Remove-Item -Recurse 会展开成“删了哪些文件、多大、在不在受保护目录”;
  • 不打断:没有审批,没有 allowlist,夜间任务照跑;
  • 可回溯:任何一次 checkpoint 都能一键回滚,新增文件进 trash 而不是消失。

快速开始

cd E:\009workspace\dsh\dsh-agent-rewind

# 1. 初始化(默认保护 ~/.dsh,外加当前目录)
node src/cli.mjs --store E:\dsh-rewind init --force

# 2. 拍基线
node src/cli.mjs --store E:\dsh-rewind checkpoint --label baseline

# 3. 看效果 diff(和上一个 checkpoint 比)
node src/cli.mjs --store E:\dsh-rewind diff

# 4. 和磁盘现状比
node src/cli.mjs --store E:\dsh-rewind current

# 5. 回滚(默认 dry-run;加 --apply 才动手)
node src/cli.mjs --store E:\dsh-rewind rewind --to <checkpoint-id> --apply

自定义根:

node src/cli.mjs --store E:\dsh-rewind init --force `
  --root "dsh=~/.dsh:protect" `
  --root "workspace=E:\009workspace\dsh\dsh-memory-hub"

C 盘关键数据(hot / data 两档)

| 档 | store | 频率 | 覆盖 | |---|---|---|---| | hot | E:\dsh-rewind | 每回合(插件)+ 每 5 分钟(任务) | ~/.dsh(保护)、~/.ssh、.gitconfig、.npmrc、.codex(排除 sqlite/logs)、%APPDATA%\@deepseek-ai(排除缓存) | | data | E:\dsh-rewind-data | 每 30 分钟 | Documents(排除虚拟机磁盘、聊天缓存、构建目录)、Desktop、Pictures、Downloads(排除安装包)、VS Code User(排除缓存)、.mavis |

node src/cli.mjs --store E:\dsh-rewind init --preset hot --force
node src/cli.mjs --store E:\dsh-rewind-data init --preset data --force

实测:hot 基线 195 文件 / 0.4s;data 基线 7919 文件 / 21s / 1.66GB,之后增量 1s。

OneDrive 故意不在 data 档:它是 reparse-point 云盘,读取会触发云端 hydration(第一次实测卡了十分钟),且服务端已有版本历史。需要本地副本时把 ~/OneDrive 加回 roots 并接受下载成本。

命令一览

| 命令 | 作用 | |---|---| | init | 写 config.json(--root id=path[:protect] 可重复) | | checkpoint | 扫描根目录、存新内容、算 diff、按策略告警;--auto-restore 可自动恢复受保护删除 | | diff | 两个 checkpoint 之间的效果差异 | | current | checkpoint 与当前磁盘的差异 | | rewind --to <id> | 恢复到某个 checkpoint(默认 dry-run;默认只恢复缺失/修改的文件,不动新增文件);--trash-added 额外把新增文件移入 trash,实现“完整撤销” | | list / status | 检查点列表 / 配置与最近日志 | | gc | 按 keepCheckpoints 清理旧检查点与无引用对象 | | watch --interval <秒> | 循环 checkpoint(也可交给计划任务) |

存储结构

E:\dsh-rewind\
  config.json
  latest
  journal.jsonl                  # 每次 checkpoint 的一行摘要
  objects/ab/<sha256>            # 内容寻址,跨检查点去重
  checkpoints/<id>/
    manifest.jsonl               # root + 相对路径 + size + mtime + hash
    meta.json
    report.json                  # 本次 diff + 告警
  trash/<id>/<root>/<path>       # 回滚时被“移走”的新增文件

文件未变(size+mtime 相同)时复用上一个 manifest 的 hash,所以只有变化的内容会被读取和复制。

接入 DSH(已完成)

计划任务:scripts/register-task.ps1 已注册 DSH Rewind Checkpoint,每 5 分钟跑一次 checkpoint --label scheduled(LastTaskResult=0,journal 有记录)。

DSH 插件:dsh-plugin/ 是一个 Host bundle(dsh-agent-rewind-plugin),已通过 plugin_manager install_bundle 装进 desktop profile,新增两个工具:

| 工具 | 作用 | |---|---| | dsh_checkpoint | 立即 checkpoint,返回相对上一份的效果 diff 与告警级别 | | dsh_rewind | 不带参数列出检查点;带 to 做 dry-run,apply:true 才恢复,trashAdded:true 连新增文件一起移入 trash |

插件在 session/event 的 turn/end 上自动 checkpoint(每个回合一次),并且通过子进程调用 CLI,所以改引擎代码不需要重装插件。默认每回合约 70ms。

插件配置在 dsh-plugin/cordis.patch.yml(storeDir、cliPath、nodePath、autoCheckpoint、label)。

环境备注:DSH 自带 pnpm 11 与 PATH 上的 pnpm 12 默认 store 规则不同。安装插件前已把 DSH pnpm 的全局 storeDir 固定为 C:\.pnpm-store(%LOCALAPPDATA%\pnpm\config\config.yaml),与 profile 现有 node_modules 对齐。

限制(当前 MVP)

  • 文件级,不覆盖注册表、服务、驱动、磁盘操作;
  • 首次 checkpoint 要读全量文件(之后只读变化部分);
  • 超过 maxFileSize 的文件只记录不复制(无法恢复);
  • 默认排除 .credentials.yaml(避免把密钥复制进备份库);需要时自行加入根目录并自行保护 store 的 ACL;
  • 不是实时 CoW:两次 checkpoint 之间的删除,靠“上一次 checkpoint 的 manifest + 对象”恢复;间隔越短越精确;
  • 策略会忽略临时文件抖动(*.lock、*.tmp、*.wal、*.log、.plugin-manager/、session_projcache/),避免每回合误报;
  • 同一 store 同时只允许一个 checkpoint(lock 文件,崩溃后 30 分钟自动过期),插件与计划任务不会互相踩;
  • 修改 roots 或 exclude 时会自动 rebase:旧清单里消失的条目不算删除,不会误报 PROTECTED_DELETE。

路线图

  1. rewind --since <time> / 按 session 的 provenance 过滤(只撤销某个 agent 某一步的效果);
  2. VSS 卷影作为“兜底快照”(管理员权限时启用,覆盖文件级看不到的内容);
  3. WinFsp / minifilter 做动作级 CoW,消除 checkpoint 间隔;
  4. DSH 插件:turn/end 自动 checkpoint、rewind 工具、UI 里一条“回到 10:26”的时间线;
  5. 策略学习:从历史 diff 学阈值,减少误报。

测试

node --test