The Effect service Host plugins use to run the git CLI, the git counterpart of @dshfiles/jj-cli.
It replaces the git runners jj-integration and git-worktrees each carried. It is a plain library: bundle it into a
Host entry (host.bundleDependencies); it depends only on effect and never on a plugin.
| Method | Result |
|---|---|
run(command) |
GitOutput; a non-zero exit is a value. Fails GitRunFailed (spawn, output read, timeout, truncation). |
exec(command) |
Stdout on exit 0, otherwise GitCommandFailed with flag-value-redacted args and credential-redacted stderr. |
Git needs ChildProcessSpawner (effect/process). Host plugins use dshx's DshChildProcessSpawner, which resolves the
bare git through DSH's subprocess runtime; tests use NodeServices.layer from @effect/platform-node.
const program = Effect.gen(function* () {
const git = yield* Git
return yield* git.exec({ args: ['worktree', 'list', '--porcelain'], cwd })
})
program.pipe(Effect.provide(Git.layer))Every run:
- runs
git -c core.quotePath=false …with stdin ignored andGIT_TERMINAL_PROMPT=0, no editor and no pager, so it never waits for a terminal;command.envadds variables over the spawner's environment (a scratchGIT_INDEX_FILE); - sets
GIT_SSH_COMMAND='ssh -o BatchMode=yes'unless the Host environment already hasGIT_SSH_COMMANDorGIT_SSH, so an ssh passphrase or host-key prompt fails fast instead of waiting on/dev/ttyuntil the timeout. git lets this variable win overcore.sshCommand: if you set a custom ssh command in git config, setGIT_SSH_COMMAND(with-o BatchMode=yes) in DSH's environment instead, and load keys intossh-agentso batch mode can use them; - caps stdout at 512 KB (
maxStdoutBytes; a longer one fails asoutput-truncated, or withonStdoutLimit: 'truncate'keeps the head and setsstdoutTruncated) and stderr at 64 KB; - stops after two minutes (
timeoutper command or layer) and kills the process, with a 1.5 s grace; - is one
git <verb>client span (first subcommand word) with value-free attributes: executable, up to two subcommand words, flag names, argument count andprocess.exit.code. Paths and values never reach a span.
redactGitStderr removes URL credentials, authorization values and secret-looking assignments: fetch prints remote
URLs.
pnpm --dir plugins/@dshfiles/git-cli test