feat: filesystem checkpoints and /rollback command#824
Merged
Conversation
Automatic filesystem snapshots before destructive file operations, with user-facing rollback. Inspired by PR #559 (by @alireza78a). Architecture: - Shadow git repos at ~/.hermes/checkpoints/{hash}/ via GIT_DIR - CheckpointManager: take/list/restore, turn-scoped dedup, pruning - Transparent — the LLM never sees it, no tool schema, no tokens - Once per turn — only first write_file/patch triggers a snapshot Integration: - Config: checkpoints.enabled + checkpoints.max_snapshots - CLI flag: hermes --checkpoints - Trigger: run_agent.py _execute_tool_calls() before write_file/patch - /rollback slash command in CLI + gateway (list, restore by number) - Pre-rollback snapshot auto-created on restore (undo the undo) Safety: - Never blocks file operations — all errors silently logged - Skips root dir, home dir, dirs >50K files - Disables gracefully when git not installed - Shadow repo completely isolated from project git Tests: 35 new tests, all passing (2798 total suite) Docs: feature page, config reference, CLI commands reference
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Automatic filesystem snapshots before destructive file operations, with user-facing rollback via
/rollbackslash command. Inspired by PR #559 (by @alireza78a) — uses their shadow git approach but with a fundamentally different integration.How It Works
When enabled, Hermes takes one snapshot per conversation turn before the first
write_fileorpatchcall. Uses shadow git repos at~/.hermes/checkpoints/viaGIT_DIR+GIT_WORK_TREE— completely isolated from the user's project git.Enabling
hermes --checkpoints # per-session flagRolling Back
Design Decisions
Files Changed
tools/checkpoint_manager.pytests/tools/test_checkpoint_manager.pyrun_agent.py_execute_tool_callsgateway/run.py/rollbackslash command handler + help texthermes_cli/main.py--checkpointsCLI flagwebsite/docs/user-guide/features/checkpoints.mdwebsite/docs/reference/cli-commands.md--checkpointsand/rollbackwebsite/docs/user-guide/configuration.mdNote: Changes to
cli.py,hermes_cli/config.py, andhermes_cli/commands.pywere committed to main already (swept up by a concurrent commit). They include: HermesCLI checkpoints param, config defaults, /rollback handler, and COMMANDS entry.Test Plan
Closes #452.