AI News AI资讯 1d ago Updated 1d ago 更新于 1天前 41

Show HN: Do-over, undo for AI agent shell commands 展示 HN:Do-over,AI 智能体 Shell 命令的撤销工具

doover is a transaction log for AI agent shell commands that provides true undo capability for destructive operations, filling a critical gap left by existing safety mechanisms It works by snapshotting files before agent commands execute via Claude Code's PreToolUse/PostToolUse hooks, with minimal overhead of just a few milliseconds per command Unlike git or sandboxes, doover protects untracked files, ignored files (.env, local databases), and directories outside version control that other tools doover为AI agent的shell命令提供事务日志和撤销功能,解决现有安全机制无法恢复Bash工具执行结果的缺陷 通过PreToolUse/PostToolUse钩子自动快照文件状态,对agent透明运行,仅在无法完全保护时提示 支持冲突检查、幂等撤销和追加式日志,确保历史不可篡改且可追溯 兼容Claude Code等agent,支持全局和项目级安装,提供完整的命令管理界面

62
Hot 热度
58
Quality 质量
55
Impact 影响力

Analysis 深度分析

TL;DR

  • doover is a transaction log for AI agent shell commands that provides true undo capability for destructive operations, filling a critical gap left by existing safety mechanisms
  • It works by snapshotting files before agent commands execute via Claude Code's PreToolUse/PostToolUse hooks, with minimal overhead of just a few milliseconds per command
  • Unlike git or sandboxes, doover protects untracked files, ignored files (.env, local databases), and directories outside version control that other tools cannot recover
  • The tool is open-source, written in Rust, supports macOS/Linux/WSL, and provides commands for log, undo, redo, diff, status, garbage collection, and pinning of actions
  • Undo operations are conflict-checked, idempotent, append-only, and themselves journaled—ensuring history is never silently rewritten

Why It Matters

AI coding agents increasingly execute shell commands autonomously, but destructive operations like rm -rf have historically been irreversible, creating significant risk for production workflows. doover addresses this by providing a safety net that doesn't block agent capabilities but makes dangerous commands reversible, which is essential for anyone deploying autonomous agents in real development environments.

Technical Details

  • Architecture: doover integrates with Claude Code through PreToolUse and PostToolUse hooks, automatically snapshotting files before destructive commands execute and logging a transaction journal
  • Snapshot strategy: Whole-tree snapshots intelligently skip build directories (target/, node_modules/, .venv/) only when git already ignores them, avoiding wasted time budget on recreatable artifacts while still capturing source files
  • Undo mechanics: Undo is conflict-checked (refuses with exit code 3 if files changed after the target action), idempotent (double-undo is a no-op), and trusts the disk over its own records; undoing an undo enables redo via append-only journaling
  • Implementation: Written in Rust (requires 1.85+), installable via Cargo (--locked for audited dependencies), Homebrew, or prebuilt binaries with SHA256 verification; stores snapshots in ~/.doover
  • Scope: Handles files outside the project directory and untracked/ignored files that git cannot protect, including cases where the agent itself runs git checkout . or git clean -fd to destroy uncommitted work

Industry Insight

  • The rise of autonomous coding agents demands reversible shell execution as a baseline safety feature; doover's approach of non-blocking interception rather than permission-gating represents a pragmatic model for agent safety tooling that preserves productivity while reducing risk
  • As AI agents gain broader access to system operations, transaction-log-style safeguards like doover will likely become standard infrastructure, similar to how database transaction logs became essential for data integrity
  • Developers should adopt doover or equivalent tools immediately when working with agents on projects containing untracked sensitive data (local databases, .env files, test data), since existing safeguards like sandboxes and git checkpoints leave critical gaps in protection

TL;DR

  • doover为AI agent的shell命令提供事务日志和撤销功能,解决现有安全机制无法恢复Bash工具执行结果的缺陷
  • 通过PreToolUse/PostToolUse钩子自动快照文件状态,对agent透明运行,仅在无法完全保护时提示
  • 支持冲突检查、幂等撤销和追加式日志,确保历史不可篡改且可追溯
  • 兼容Claude Code等agent,支持全局和项目级安装,提供完整的命令管理界面

为什么值得看

对AI从业者而言,doover填补了agent安全机制的关键空白,使破坏性shell操作变得可逆,大幅降低agent失控风险。对行业来说,这代表了"安全即服务"的新思路——不阻止agent工作,而是让危险操作可撤销。

技术解析

  • 核心架构:基于Claude Code的PreToolUse/PostToolUse钩子,在shell命令执行前后自动快照文件状态,生成事务日志
  • 快照策略:跳过.git目录(由git管理)、跳过git已忽略的构建目录(target/, node_modules/等),但直接指向这些目录的命令仍会被完整捕获
  • 撤销机制:冲突检查(若文件在操作后被修改则拒绝撤销,除非--force)、幂等性(重复撤销为no-op)、信任磁盘状态而非内部记录
  • 安装与集成:支持Cargo(Rust 1.85+)、Homebrew、预编译二进制;通过doover init添加钩子到~/.claude/settings.json,doover doctor验证端到端功能
  • 命令集:log(查看历史)、undo/redo(撤销/重做)、show/diff(查看详情/差异)、status(存储状态)、gc(清理)、pin/unpin(保留/释放条目)

行业启示

  • AI agent安全设计应从"阻止"转向"可恢复",事务日志模式比权限控制更适配agent的自主性工作流
  • 工具集成需保持透明低侵入,doover仅增加数毫秒延迟且不打断agent流程,这种"静默保护"是用户接受的关键
  • 跨agent通用性:当前针对Claude Code,但钩子模式可适配其他agent框架,形成标准化安全层

Disclaimer: The above content is generated by AI and is for reference only. 免责声明:以上内容由 AI 生成,仅供参考。

Agent Agent Open Source 开源 LLM 大模型 Programming 编程