Expand description
Filesystem checkpoints via shadow git repos.
Once per agent turn we run git add -A && git commit against a shadow
repo whose GIT_DIR lives outside the user’s working tree (under the
configured data dir). Tools never see this — it’s transparent
infrastructure. Users can /rewind to any prior checkpoint.
Hermes reference: tools/checkpoint_manager.py. This is a focused port:
we cover init, snapshot, list, restore. We do NOT expose per-file restore
or per-checkpoint diff yet.
Isolation: env vars redirect git to the shadow GIT_DIR and keep it from
reading the user’s ~/.gitconfig (no signing prompts, no hooks, no
credential helpers).
Structs§
Functions§
- ensure_
shadow_ repo - Initialise the shadow repo if not already present. Idempotent.
- list
- List the most recent checkpoints (newest first), capped at
limit. - restore
- Restore the working directory to the state at
commit_hash. Validates the hash is a hex string to avoid argument injection. - shadow_
repo_ path - Path to the shadow repo for a given working dir, anchored under the data
dir’s
checkpointssubfolder. Per-(checkpoints_root, working_dir) so two different chats with separate working dirs get separate shadow repos. - snapshot
- Stage everything and commit. Returns the new commit hash, or None if there were no changes to snapshot.