Prerequisites
- JJ must be installed and available in your
PATH. Install it withbrew install jj,cargo install jj-cli, or see the JJ installation docs. - The workspace must be a JJ repository (run
jj git initorjj initin your project root). - The attempt you want to revert to must have a recorded JJ pointer. Pointers are only recorded when JJ is available at the time the attempt finishes.
How It Works
- When a task attempt finishes successfully, Smithers runs
jj log -r @ --no-graph --template change_idto capture the current JJ change ID. - This change ID is stored in the
_smithers_attemptstable in thejj_pointercolumn. - When you invoke
smithers revert, Smithers looks up the stored change ID and runsjj restore --from <change_id>to restore the workspace to that state.
CLI Usage
Required Flags
| Flag | Description |
|---|---|
--run-id ID | The run containing the attempt to revert to. |
--node-id ID | The task node whose attempt you want to revert to. |
Optional Flags
| Flag | Default | Description |
|---|---|---|
--attempt N | 1 | The attempt number to revert to (1-indexed). |
--iteration N | 0 | The Ralph iteration number. |
Examples
Revert to the first attempt of task “analyze” in a specific run:Exit Codes
| Code | Meaning |
|---|---|
0 | Revert succeeded. |
1 | Revert failed (attempt not found, no JJ pointer, or JJ command failed). |
Output
The command prints a JSON result to stdout:RevertStarted and RevertFinished events are printed as JSON lines to stdout.
Programmatic Usage
You can also revert programmatically using therevertToAttempt function:
RevertOptions
RevertResult
Events
Revert operations emit two events:RevertStarted— Fired before thejj restorecommand runs. Includes thejjPointerbeing restored to.RevertFinished— Fired after the restore completes. Includessuccess(boolean) anderror(string, if failed).
Troubleshooting
“Attempt has no jjPointer recorded” The attempt finished before JJ was installed, or JJ was not available inPATH when the attempt completed. JJ pointers are only captured opportunistically — if jj log fails, the pointer is silently set to null.
“jj exited with code 1”
The JJ restore command failed. Common causes:
- The change ID no longer exists in the JJ repository (pruned or garbage-collected).
- The workspace is in a conflicted state.
- JJ is not properly configured for the repository.
Related
- Events — RevertStarted and RevertFinished event types.
- VCS Integration — How Smithers integrates with version control.
- CLI — Full CLI reference including the revert command.