- every helper accepts an optional
cwdso you can target a specific repository - spawn failures are normalized instead of throwing, which makes them safe to call even when
jjis not installed - workspace helpers try a few command shapes to tolerate JJ version drift
Import
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
- useful when you need 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.
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
- recreates the target 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>.
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