VCS Detection
Smithers walks up the directory tree fromrootDir looking for .jj or .git. When both exist in the same directory (a colocated repo), Smithers prefers .jj and uses JJ semantics. Pure Git repos work without JJ installed.
VCS Pointer Flow
When a supported VCS is detected:- A task executes, making filesystem changes via agent tools.
- The task completes (success or failure).
- Smithers captures the current revision into
_smithers_attempts.jj_pointer:- JJ: the change ID from
jj log -r @ --template change_id - Git: the commit SHA from
git rev-parse HEAD
- JJ: the change ID from
- The next task continues from this point.
vcs_revision so Smithers can detect workspace drift between a run’s start and a later resume — if the revision changed, the engine warns of a potential durability mismatch.
Recorded Data
| Column | Type | Description |
|---|---|---|
jj_pointer | text (nullable) | JJ change/operation ID after attempt completion. null if JJ unavailable. |
Revert
RevertStarted and RevertFinished events.
Without VCS
jj_pointerisnullfor all attempts.revertfails with an error.- All other Smithers functionality is unaffected.
Setup
Programmatic Helpers
Smithers exports helpers for running rawjj commands, checking repo status, reading/restoring pointers, and managing JJ workspaces. See VCS Helper Reference.
Worktrees
Smithers can isolate each workflow run in its own worktree (a separate checkout sharing the same object store). This lets multiple runs modify the filesystem concurrently without stepping on each other.Git Worktrees
WhenrootDir points to a Git repository, Smithers calls git worktree add to create a new working tree at worktreePath. A named branch (-B) is created from the best available base ref:
baseBranch(if configured)origin/<baseBranch>main/origin/mainHEAD
JJ Workspaces
For JJ repos, Smithers callsworkspaceAdd to create a JJ workspace at worktreePath. When a branch is supplied, it runs jj bookmark set <branch> -r @ to point a bookmark at the new workspace’s working copy.
You can create a workspace at a specific revision:
workspaceAdd tries multiple invocation styles (jj workspace add --name, positional, --wc-path) to stay compatible across JJ versions. Stale workspaces with the same name are forgotten before creating a new one.
Rebase on Resume
When Smithers resumes a workflow that already has a worktree, it syncs the worktree to the current tip of the base branch before continuing:- JJ:
jj git fetchthenjj rebase -d <base> - Git:
git fetch originthengit rebase origin/<base>
main when no baseBranch is configured.
Running Workflows at a Specific Revision
When a run is started, Smithers records the current VCS revision (vcs_revision on the run row). On resume, it checks the current revision against the stored one. A mismatch emits a warning but does not block the resume.
This revision snapshot is available in the database:
JJ Operation ID Tracking
For JJ repos, the pointer stored injj_pointer is the JJ change ID (the stable identifier that persists across amends and rebases), not the operation ID. This means:
- The pointer survives
jj amend,jj rebase, and other history-rewriting commands. jj restore --from <change_id>reliably restores the working copy to the exact post-attempt state.
jj log -r @ --no-graph --template change_id.
Cache Key Integration
VCS pointers are included in the cache key when caching is enabled (<Workflow cache> or { cache: true }):
| Component |
|---|
| Workflow name + nodeId |
| Prompt text or static payload |
| Model ID and parameters |
| Tool allowlist and versions |
| Output schema signature |
| VCS pointer (JJ change ID or Git SHA) |
Next Steps
- Resumability — Crash recovery and state persistence.
- Caching — Cache key mechanics.
- CLI Reference — All CLI commands including
revert.