- every helper accepts an optional
cwdto target a specific repository - spawn failures are normalized instead of throwing, so they are safe to call even when
jjis not installed - workspace helpers try a few command shapes to tolerate JJ version drift
- JJ command helpers return
Effectvalues, so direct callers must provide an EffectCommandExecutorlayer
Import
The rootsmithers-orchestrator facade exports the main JJ helpers:
@effect/platform-bun when using the Bun snippet, or use the equivalent CommandExecutor layer for another runtime.
runJj(args, opts?)
Run an arbitrary jj command and capture its output.
- returns
{ code: 127, stdout: "", stderr: "..." }whenjjcannot be started - does not throw for ordinary process failures
- a raw escape hatch beyond the higher-level helpers below
getJjPointer(cwd?)
Return the current workspace change_id for @, or null when JJ is unavailable or the current directory is not a JJ repo.
revertToJjPointer(pointer, cwd?)
Restore the working copy from a previously recorded JJ pointer. A pointer is a JJ change_id string, as returned by getJjPointer.
jj restore --from <pointer>.
isJjRepo(cwd?)
Detect whether a directory is a readable JJ repository.
workspaceAdd(name, path, opts?)
Create a JJ workspace with a friendly name at a target filesystem path.
- removes an existing workspace with the same name before retrying
- removes the target directory if it exists and creates its parent directory if needed
- tries multiple
jj workspace addsyntaxes to work across JJ versions
workspaceList(cwd?)
List known workspaces for the current JJ repo.
jj workspace list output.
workspaceClose(name, opts?)
Forget a JJ workspace by name.
jj workspace forget <name>.
captureWorkspaceSnapshot(cwd?)
Capture the current JJ working-copy state as a restorable handle. This helper is exported by @smithers-orchestrator/vcs, not by the root facade.
null on failures and timeouts, including non-JJ directories. Smithers uses the commitId and operationId values for workspace durability checkpoints.
findVcsRoot(startDir)
Walk upward from a directory and return the nearest .jj or .git root. JJ wins when both markers exist in the same directory.
resolveGitBinary() and resolveJjBinary()
Resolve the executable Smithers will spawn for VCS commands.
resolveGitBinary() checks SMITHERS_GIT_PATH, then falls back to git on PATH. resolveJjBinary() checks SMITHERS_JJ_PATH, then a bundled @smithers-orchestrator/jj-<platform> package, then jj on PATH.
vcsToolingStatus()
Probe whether the resolved VCS binaries are usable on the current host.
When To Use These Helpers
Use these helpers when your application needs to:- show whether JJ-backed revert is available
- record or inspect a pointer outside the Smithers engine
- manage JJ workspaces directly from an app or integration layer
- check whether JJ or Git tooling is available before starting worktree logic