Quick Start
1
Simple Usage
Enable change tracking on an autonomous agent —
full_auto turns on snapshots automatically:2
With Configuration
Use
AutonomyConfig for explicit control, or call FileSnapshot directly:3
Re-root After a Workspace
Agent.__init__ roots change tracking at os.getcwd(). Attach a per-session directory later, then call set_snapshot_root() so undo() restores the right place:Re-rooting Change Tracking
set_snapshot_root(project_path) re-roots undo/redo/diff at a directory known only after construction — the moment a bot, gateway, or custom wrapper attaches a per-chat Workspace.
Returns
bool — True when a snapshot manager is rooted at the given path, False if construction failed (e.g. git unavailable).
Re-rooting clears the undo/redo stacks — they belong to the previous root. The old shadow repo is orphaned (still on disk under
~/.praisonai/snapshots/), and only future changes are tracked at the new root.Bot / Gateway Workspaces
Bots and gateways callAgent.set_snapshot_root(workspace.root) from apply_bot_smart_defaults() immediately after attaching the per-chat Workspace. So /undo in a Slack, Discord, or Telegram chat reverts files in that chat’s workspace — never the gateway’s process cwd.
Custom wrappers that attach a workspace after Agent.__init__ should do the same:
How It Works
Git must be available on
PATH. If shadow-repo init fails, tracking is skipped silently and undo() returns False.Restore Guarantees
restore() (and agent.undo()) rebuilds the project to exactly the target snapshot’s tree:
The ignored-file guarantee is what makes
agent.undo() safe to call in projects that keep secrets in .env. Both _sync_files() and restore() build their exclusion set from _build_ignore_patterns(), so a file the snapshot never tracked can never be pruned by a restore.Common Patterns
Selective restore
List recent snapshots
Best Practices
Prefer agent undo for autonomous runs
Prefer agent undo for autonomous runs
When using
autonomy="full_auto", call agent.undo() rather than manual restore() — the agent maintains an undo/redo stack across iterations.Snapshot before risky edits
Snapshot before risky edits
Call
track(message=...) (or run the agent once) before bulk refactors so you have a named rollback point.Respects .gitignore
Respects .gitignore
The shadow repo honours
.gitignore patterns plus built-in defaults (.git, __pycache__, node_modules, venv, .venv, .pytest_cache, .mypy_cache). Ignored files are neither snapshotted nor pruned by restore(). A .env file that lives outside version control survives every undo() / restore().Clean up when finished
Clean up when finished
Call
snapshot.cleanup() to remove the shadow repository if you no longer need history for a project.Re-root after attaching a workspace
Re-root after attaching a workspace
Agent.__init__ roots the snapshot at os.getcwd(). If you attach a Workspace (or any per-session root) later, call agent.set_snapshot_root(str(workspace.root)) immediately — otherwise agent.undo() restores files in the wrong directory. Re-rooting clears the undo/redo stacks; rooting at the current directory is a no-op.Related
File Editing
Safe find-and-replace tools agents use before snapshots capture the result
Autonomy Loop
Configure
track_changes and autonomous file-editing levels
