Skip to content
LosEcherPublic

About

Cross-platform command execution normalization for AI agents — one command spec in, one normalized result out, on any platform.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

unirun

Cross-platform command execution normalization for AI agents.

One command spec in, one normalized result out — on any platform (macOS / Linux / Windows, local or SSH-remote), regardless of shell, encoding, or toolchain quirks. Built for agents that need to act on command output, not decode it.

$ unirun run 'echo "中文OK"; exit 42' --json
{"exit_code":42,"stdout":"中文OK\n","stderr":"","timed_out":false,"aborted":false,
 "duration_ms":12,"error_class":null,"hint":null,"encoding":"utf-8","truncated":false,
 "shell_used":"bash"}

Why

Every agent harness (Claude Code, Codex, Cursor, DSH, opencode, …) silently re-solves the same cross-platform execution matrix:

  • timeout doesn't exist on stock macOS (GNU coreutils only);
  • uname doesn't exist on Windows OpenSSH;
  • PowerShell 5.1 emits CLIXML / GBK mojibake instead of UTF-8;
  • cmd.exe eats > before PowerShell ever sees it;
  • PowerShell doesn't propagate native exit codes;
  • Windows' System32\bash.exe is the WSL launcher — with no distro installed it prints a UTF-16LE "no distributions" message and exits 1 (unirun's probe excludes it; real Git Bash still resolves);
  • output formats drift between OS versions (iostat, netstat, …).

unirun makes this matrix a solved, tested, shared problem:

  • argv, never hand-quoted strings — script content reaches the shell as a single -c argument; no outer quoting layer can corrupt it.
  • In-process deadline — no dependency on a GNU timeout binary; timeout is enforced by unirun itself, with whole-tree termination (POSIX: negative-pgid SIGTERM→SIGKILL; Windows: taskkill /T /F).
  • Stable error taxonomy — TIMEOUT, COMMAND_NOT_FOUND, PERMISSION, DEPENDENCY_MISSING, SYNTAX, … plus actionable hints, so an agent can take its next step instead of guessing.
  • Encoding pipeline — BOM sniffing (UTF-8/UTF-16LE/UTF-16BE), clean UTF-8 fast path, CP936/GBK auto-fallback for the usual Windows case (PowerShell 5.1 writes stderr through the OEM page, and Windows OpenSSH answers uname with GBK text), explicit hint for the rest (--output-encoding big5|cp437|cp850|windows-1252|utf-8), and a lossy fallback labeled utf-8-lossy. The encoding label says how the bytes were decoded — gbk is an assumption CP936 could render cleanly, not a verified fact.
  • Capped tail-keeping output — bounded, drained (no pipe deadlock), tail kept and marked truncated — errors cluster at the end. The cap is per stream and uniform across local, SSH and WinRM runs (--max-output N, default 256 KiB).
  • SIGINT = abort — an in-flight process tree is terminated and the result reports aborted: true (agent-safe retry). This covers the remote paths too: a Ctrl-C during ssh signals the ssh client's tree, and during winrm the runspace is abandoned and reported as such (PSRP has no cancel hook, so the hint says the remote script may still be running).
  • Output coalescing — streamed stdout chunks are merged into batches and forwarded on a 128 KiB byte threshold or a 100 ms timer (stderr stays real-time), cutting downstream forwarding overhead without changing content or exit codes. --no-coalesce disables it.
  • Anti pid-reuse kill protection — every child carries a random generation token (in its command line and environment) and its start time is snapshotted. A detached pid (a background-session runner, which outlives whoever started it) is only signalled after the probe confirms it is still that process: otherwise the kill is refused as PID_REUSED, or as IDENTITY_UNVERIFIABLE when this environment can read neither the start time nor the token (a blocked ps/CIM probe) — fail closed rather than signal a pid that may belong to someone else. A child the caller still holds unreaped needs no such gate and is never refused: POSIX keeps its pid allocated until wait and Rust keeps the process handle open on Windows, so the pid provably cannot be someone else's; when the probe cannot confirm it the run says so in hint (tree kill not identity-confirmed: …) instead of leaving the tree alive or claiming a reuse that never happened. Zombies are treated as already gone.
  • unirun probe — the agent's first question answered: what shells, coreutils and tools actually exist here. Every lookup is three-state — found, absent, unreadable — with the unreadable ones listed under unreadable, because "I could not check" must never read as "this host does not have it" (the same distinction the process probe makes).

Each of those differences is written down in docs/PLATFORM-DIFFS.md with the witness it was learned from and the test that keeps it true — the file is a coverage claim, so a row whose test disappeared is a bug.

Install

Prebuilt binaries are attached to each GitHub Release. Assets follow a fixed unirun-<os>-<arch> naming contract so installers (Dockerfiles, deploy scripts, agent toolchains) can resolve the right file deterministically — never a bare unirun:

Asset Platform
unirun-linux-x86_64 Linux x86_64 (glibc)
unirun-linux-x86_64-musl Linux x86_64, static musl — Alpine / distroless Docker
unirun-linux-aarch64-musl Linux arm64, static musl — ARM NAS, Raspberry Pi
unirun-macos-aarch64 macOS Apple Silicon
unirun-windows-x86_64.exe Windows x86_64
# Linux/macOS — pick the asset for your platform
curl -fL -o unirun \
  https://github.com/LosEcher/unirun/releases/latest/download/unirun-linux-x86_64
chmod +x unirun && ./unirun probe

Alpine/Docker install step (static musl build — no glibc needed):

FROM alpine:3.20
RUN apk add --no-cache ca-certificates \
 && wget -qO /usr/local/bin/unirun \
      https://github.com/LosEcher/unirun/releases/latest/download/unirun-linux-x86_64-musl \
 && chmod +x /usr/local/bin/unirun

Or from source (any platform, including macOS Intel):

# From source (Rust 1.88+ — see rust-version in Cargo.toml)
cargo install unirun

# Or build locally
git clone https://github.com/LosEcher/unirun.git
cd unirun && cargo build --release
# binary at target/release/unirun

Usage

unirun run '<command>' [--timeout 30] [--shell bash] [--workdir dir] [--env K=V] [--max-output N] [--output-encoding NAME] [--no-coalesce]
unirun script path/to/script [options]     # shell inferred from extension
unirun lint '<command>' | --stdin | --file P [--json]   # risky-heredoc judgement, runs nothing
unirun probe [--json]                      # host capability snapshot
unirun capabilities [--json]               # what this build can do (for consumers)
unirun mcp                                 # serve MCP over stdio (agents)
unirun acp                                 # serve Agent Client Protocol v1 over stdio
unirun ssh <host> '<script>' [--shell bash|sh|zsh|powershell|pwsh|cmd] [--user U] [--port N] [--identity FILE] [--workdir dir] [--env K=V] [--timeout N] [--max-output N] [--output-encoding NAME]   # remote SSH
unirun winrm <host> '<script>' [opts]      # remote Windows (WinRM; feature: winrm)
unirun bg <start|status|output|kill|wait|list> ...   # background sessions
unirun recipe <list|show|add|rm|path|effective|check> # recipe registry

Argument contract: --flag value and --flag=value are both accepted, and an unknown --flag is a usage error (exit 2) — it is never appended to the command or to the remote script. Use -- when an argument to the command starts with a dash (unirun run 'echo' --json -- --not-a-flag); single-dash tokens like -la are positional, since they belong to the command.

Heredoc guard: content must not cross a parser

A heredoc is the one place a shell accepts payload inline, and every way it can go wrong is silent — the command still exits 0. unirun run|ssh|winrm and the MCP exec.run / exec.script tools therefore scan the command text before spawning, and refuse four shapes:

shape what actually happens
<<EOF (unquoted) with $VAR, `cmd` or \ in the body expanded before the payload is written
the delimiter also appears as a line after the heredoc the body closed early; the rest ran as commands
a heredoc inside $( … ), "…" or backticks the outer quote scan is ambiguous
printf … | python3 - <<'PY' the heredoc replaces stdin, so the piped data is discarded

Exit codes: refused-call = 2 with nothing dispatched (dispatched: false and error_class: "HEREDOC_RISK" in --json). A quoted heredoc with a unique delimiter is the correct spelling and is never flagged. Modes:

unirun run '<cmd>'              # deny (default)
unirun run '<cmd>' --heredoc=warn    # print the finding, run anyway
unirun run '<cmd>' --heredoc=allow   # skip the scan (env: UNIRUN_HEREDOC=)
unirun lint '<cmd>'             # 0 clean · 1 risky · 2 cannot judge — runs nothing
cat script.sh | unirun lint --stdin     # for agent hooks
unirun lint --file deploy/x.sh --file .github/workflows/ci.yml

There is deliberately no rewrite mode: quoting a delimiter changes semantics whenever the body really wants $VAR, and a guard that silently rewrites that would be the same bug it is meant to prevent. The finding carries the substitution instead (write the payload to a file, <<'UNIQUE_DELIM').

The judgement is one pure function (src/heredoc.rs), so a host hook, a CI step and the CLI all gate on the same rule. Hooks pipe the command they are about to run into unirun lint --stdin; nothing in the agent changes.

Consumers: ask what the build can do, don't parse a version

unirun capabilities --json (also MCP exec.capabilities) answers "does this binary reject unknown flags? does its ssh take --workdir? is WinRM compiled in?" with stable capability keys, so a caller never has to keep a version→feature table:

{"unirun":{"version":"0.5.0","schema":1},
 "platform":{"os":"macos","arch":"aarch64"},
 "features":["local-exec","probe","mcp","acp","bg-session","recipe-registry",
             "recipe-toolchain","ssh","ssh-identity","ssh-workdir-env",
             "remote-abort","mcp-cancel","probe-state","session-cursor",
             "ssh-detach",
             "error-taxonomy","output-cap","truncation-flag","transport-error",
             "dispatched","kill-status","exit-code-confidence","drain-timeout",
             "legacy-codepage","encoding-hint","strict-flags"]}

Keys are added, never renamed or removed; schema changes only if the document shape does. A caller that misses a key it needs should fall back to its own precedent behaviour rather than assume the capability is absent.

Upgrading from 0.4.x

Two things changed shape, both deliberate:

  • an unknown --flag is now a usage error (exit 2) instead of being appended to the command or the remote script — that behaviour was indistinguishable from script content and los kept a version table to work around it;
  • ExecResult gained transport_error, transport_stderr, dispatched, kill_status, exit_code_confidence and drain_timeout; if 0.4.x code made a claim that was not true, the 0.5.0 field that replaces it is named in CHANGELOG.md.

MCP — plug into any agent

unirun mcp is a stdio MCP server exposing exec.run, exec.script, exec.probe and the background-session tools session.start, session.status, session.output, session.kill, session.wait, session.list (JSON-RPC 2.0, newline-delimited). exec.capabilities reports what the build can do, same payload as unirun capabilities --json. Calls run on their own threads, so notifications/cancelled really stops a running exec.run (per-request abort flag; the other calls are unaffected) and Ctrl-C shuts the server down with the usual 130. Point any MCP-capable agent at it:

// Claude Desktop / Cursor / DSH mcp config
{ "mcpServers": { "unirun": { "command": "unirun", "args": ["mcp"] } } }

Tools return the normalized ExecResult JSON (exit_code / error_class / hint / encoding / truncated), with isError reflecting the taxonomy class.

ACP — drive it from Zed / Cursor / any ACP v1 client

unirun acp is an Agent Client Protocol v1 server over stdio (baseline surface: initialize, session/new, session/prompt with streamed session/update output, session/cancel). A client sends the command as the prompt text — or as a JSON spec ({"command": "…", "shell": "…", "timeout": 30, "workdir": "…", "env": {…}}) — and receives the normalized result as the final streamed chunk. Any ACP v1 host (Zed, Cursor, …) can be pointed at unirun acp as a "run this command" agent.

Background sessions

Long-running work without blocking the agent loop — start, poll, kill, collect output later:

$ unirun bg start 'pnpm build' --label web-build
session 862718cd5514c7ea4d380 started (pid 12345) — web-build

$ unirun bg status 862718cd5514c7ea4d380          # running | completed | timed_out | aborted | …
$ unirun bg wait 862718cd5514c7ea4d380 --timeout 300 --json
$ unirun bg output 862718cd5514c7ea4d380 --tail 65536
$ unirun bg output 862718cd5514c7ea4d380 --since 0            # then --since <next_cursor>
$ unirun bg kill 862718cd5514c7ea4d380
$ unirun bg list

Sessions live in $UNIRUN_HOME/sessions (default ~/.unirun/sessions), survive the launching CLI, and stream decoded output to stdout.log / stderr.log (1 MiB cap, flagged truncated_log). Logs are append-only and never rotated, so --since <cursor> is stable: the JSON result carries next_cursor, and the next call returns only what was appended after it (reset: true says a stale cursor was resynced). MCP session.output takes the same cursor. The same API is exposed as MCP session.* tools. Exit-code contract for bg wait mirrors the CLI: completed rc mirrors the child, timed out 124, aborted/killed 130.

Remote execution (SSH)

SSH (unirun ssh) runs a script on a remote host with the same normalization guarantees as local execution — exact exit-code propagation, in-process deadline with whole-tree kill, encoding pipeline, stable error taxonomy — and the same payload philosophy (no hand-quoted command strings).

Windows targets get the win-exec knowledge ported to Rust: UTF-16LE -EncodedCommand payloads, auto-injected UTF-8 "golden recipe" (no CLIXML/GBK mojibake), exact exit-code propagation via exit $LASTEXITCODE, and automatic scp + -File fallback for large scripts (UTF-8 BOM so Chinese content works). cmd.exe targets run via temp .bat files.

Unix targets (bash / sh / zsh) stream the script over stdin to <shell> -s, so no outer quoting layer can corrupt it; the script's own exit code propagates exactly. --workdir changes the remote working directory before the script starts, and repeated --env K=V assignments set validated environment keys on the remote shell. Values are escaped per shell; invalid environment variable names are ignored.

unirun ssh linux-host 'echo 中文OK; exit 42' --shell bash --workdir /srv/app --env APP_ENV=prod --json
unirun ssh win-srv 'Write-Output hi' --shell powershell --user admin --port 22 --identity ~/.ssh/id_ed25519 --env APP_ENV=prod

Detached remote runs (POSIX targets)

An ssh-attached long task is reaped when the session ends — a real incident on this fleet (NETWORK-FLEET-AND-TRANSFER-DESIGN-ANALYSIS-2026-09-18.md:445: four large shares silently disappeared when the ssh session closed). --detach starts the script in its own session instead, and records a session so it stays pollable from here:

$ unirun ssh nas 'synoindex -R /volume1' --shell bash --detach --json
{"id":"862718cd5514c7ea4d380","status":"running","pid":4242,"remote":{...}}

$ unirun bg status 862718cd5514c7ea4d380        # probes the remote pid + rc file
$ unirun bg output 862718cd5514c7ea4d380 --since 0
$ unirun bg kill   862718cd5514c7ea4d380        # TERM the group, then KILL

Details worth knowing:

  • the wrapper prefers setsid and falls back to nohup (minimal NAS shells); stdout and stderr are merged into one remote log, and the script's exit status is written to a remote rc file, so bg status reports the real code;
  • bg status maps "process gone with no rc" to interrupted rather than inventing a status, and a failed probe leaves the session running instead of declaring it dead;
  • Windows targets are refused (error_class: UNSUPPORTED, with a hint naming schtasks): persistence there is a scheduled task, a different mechanism with different handles, and pretending would produce runs that look started and die with the session.

Identity options: --user U (user@host), --port N, --identity FILE (-i). Connections are made with BatchMode=yes, StrictHostKeyChecking=accept-new, and ControlMaster=no — a reused connection lives in a detached master daemon, which would break the whole-tree deadline guarantee.

WinRM (unirun winrm, build with --features winrm) is a POC over psrp-rs (PowerShell Remoting Protocol on WS-Management) for hosts that expose WinRM instead of OpenSSH — HTTP 5985 / HTTPS 5986, Basic / NTLM / Kerberos auth:

unirun winrm win-srv 'Get-Process | Select-Object -First 5 Name, Id' \
  --user administrator --password '…' --tls --insecure

Output arrives CLIXML-decoded (clean UTF-8) and the exit code is propagated via a $LASTEXITCODE sentinel; the PSRP error stream becomes stderr, so the normalized ExecResult and taxonomy apply. Known PSRP limit: a top-level exit N terminates the runspace before the sentinel runs — prefer native commands (e.g. cmd /c exit N) to set $LASTEXITCODE.

Per-project adaptation (recipes)

Ship a .unirun/recipe.toml in a project and unirun auto-applies it (toolchain runners, timeouts, output caps, error maps):

schema = 1
extends = ["python"]               # layer a registry recipe underneath (optional)

[toolchains.python]
runner = "uv"
fallbacks = ["python3", "py"]
args = ["run"]

[toolchains.node]
runner = "pnpm"
fallbacks = ["npm", "yarn"]

[conventions]
max_output_bytes = 262144
encoding = "gbk"                   # decode captured output through CP936
                                   # (utf-8 disables the auto GBK fallback)

[timeouts]
default_ms = 30000

[error_maps]                       # project patterns win over the built-in library
"ModuleNotFoundError: *" = { class = "DEPENDENCY_MISSING", hint = "run `uv sync`" }
unirun script main.py --toolchain python --json   # → uv run main.py

Recipe registry (unirun recipe) keeps reusable named recipes in $UNIRUN_HOME/recipes and layers them via extends (deep merge: built-in defaults ← registry layers ← project recipe; toolchains/error_maps merge per key, conventions/timeouts overlay per present field):

unirun recipe add python ~/dotfiles/recipes/python.toml   # register once
unirun recipe list / show python / rm python / path / check
unirun recipe effective --workdir .                        # merged project recipe

Capability results are cached at .unirun/capabilities.json with a drift check (platform + shell paths), so agents stop hitting "it worked yesterday".

Exit-code contract (non-JSON mode)

Situation Exit code
child exit code same rc
timed out 124
aborted (SIGINT) 130
usage error 2
internal error 1

In --json mode unirun exits 0 whenever it itself ran; the full normalized result (including exit_code and error_class) is in the JSON.

Error taxonomy (error_class)

Class When
TIMEOUT deadline elapsed, tree terminated
ABORTED cancelled by caller / SIGINT
COMMAND_NOT_FOUND exit 127, or "command not found"
PERMISSION exit 126 / "Permission denied"
NOT_FOUND "No such file or directory"
DEPENDENCY_MISSING ModuleNotFoundError and friends
SYNTAX shell syntax error
NETWORK unreachable host / repo / registry (P2)
TRANSPORT ssh/scp/winrm failed before the command ran (connect, auth, host key, DNS, upload) — the transport_error flag, with the client's own diagnostics in transport_stderr
PROCESS_UNKILLABLE the tree survived an escalated kill (kill_status: "survived") — it may still be running
COMPILE_ERROR compiler/toolchain diagnostics (P2)
UNKNOWN_FAILURE non-zero exit with unrecognized stderr
(none) success, or explicit non-zero exit w/o evidence

Classification is evidence-based: unirun never invents a class without a confirmed pattern, so an explicit exit 42 stays class-less (rc is the signal). Built-in patterns live in the public error-map library (unirun::error_maps, curated for Python / Node / Rust / Go / TypeScript / Git / network), matched as case-insensitive substrings on whitespace-flattened stderr; project recipe [error_maps] patterns are consulted first (project knowledge beats generic heuristics).

"never ran" vs "ran and failed"

Every result carries transport_error, transport_stderr and dispatched, so a caller can decide whether resubmitting is safe:

  • TRANSPORT + dispatched: false — the ssh/scp/WinRM client failed before the command started (connect refused, DNS, host key, auth, failed upload). stderr holds only the remote's own output; the client's lines are moved to transport_stderr. Retrying the submission is safe.
  • a mid-run Connection closed by …, or a bare ssh exit 255 with no diagnostic of its own, keeps dispatched: true: the command may have executed, so a non-idempotent submission must not be blindly retried.
  • a remote script that itself exits 255 is a remote failure, not a transport error — the same code, distinguished by evidence rather than by the number.

Unkillable trees and untrustworthy zeroes

Two more result fields exist because "the run ended" and "the run is trustworthy and gone" are different claims:

  • kill_status — clean (the tree exited on the first signal), sigkill-escalated (SIGKILL / taskkill /F was needed), survived (still alive after the escalation and a bounded wait: a process in uninterruptible sleep outlives even SIGKILL, and the taxonomy reports PROCESS_UNKILLABLE rather than a tidy TIMEOUT), or unconfirmed (the signal went out but the identity probe could not confirm the pid was still ours). null when no signal was sent.
  • exit_code_confidence — observed when the status is evidence, unknown when a zero came from a local PowerShell run: PowerShell does not propagate native exit codes and the local -Command path appends no exit $LASTEXITCODE, so 0 cannot distinguish "all good" from "a native command failed". The ssh and WinRM paths do apply an exit contract (and the cmd path now appends exit /b %ERRORLEVEL%), so a non-zero status and every remote status stay observed.
  • drain_timeout — the post-exit drain deadline expired before the stream reached EOF, which happens when a grandchild inherited the pipe (sleep 5 &, a daemonised helper). The captured output may be incomplete, and unirun deliberately stops waiting instead of hanging after the command is over.

Retry and "unknown" semantics

unirun itself never retries — it reports. Retry is the caller's decision, and the result says what that decision may rest on:

Result May be retried?
TRANSPORT with dispatched: false yes — nothing ran
TRANSPORT with dispatched: true only if the command is idempotent
TIMEOUT, ABORTED only with an idempotency declaration: the tree was signalled, side effects may exist
PROCESS_UNKILLABLE no — deal with the surviving tree first
SYNTAX, PERMISSION, COMMAND_NOT_FOUND, DEPENDENCY_MISSING no — deterministic; fix the cause
NETWORK, COMPILE_ERROR per the caller's transient-failure policy
exit_code_confidence: "unknown" not a failure: the status was not observed, so a 0 is not proof of success
no error_class with a non-zero exit_code the command's own signal (exit 42); not evidence of a crash

"Unknown" always means not observed, never failed: encoding: "utf-8-lossy", exit_code_confidence: "unknown", kill_status: "unconfirmed" and a missing error_class all describe how much the result can be trusted, and each is paired with the field that is actually evidence.

Performance benchmarks

Library-level (criterion, cargo bench) on this M1 Mac — the full pipeline: spawn + process-group setup, streaming capture, encoding, classification:

Benchmark Time
true through bash ~23 ms
echo hello ~23 ms
Unicode output (中文) ~23 ms
10 MiB output (capped drain) ~35 ms
Timeout + tree-kill latency ~153 ms (100 ms deadline + kill)

End-to-end CLI (scripts/bench.sh, release binary, hyperfine if present else a python timing loop): a bare unirun run 'echo hello' lands at ~16 ms on this host — the normalization pipeline is effectively free next to the shell spawn itself.

Roadmap

  • P0 (released) — local execution normalization: probe, in-process timeout, tree kill, encoding pipeline, taxonomy, CLI --json.
  • P1 (released) — MCP server, SSH-remote transport (win-exec port), per-project recipe system, Windows CI matrix.
  • P2 (released) — error-map library, recipe registry (extends + unirun recipe), background sessions (unirun bg + MCP session.*), ACP v1 server (unirun acp), WinRM provider (psrp-rs POC, winrm feature), performance benchmarks.
  • P3 (released) — Unix SSH remotes (--shell bash|sh|zsh, stdin payload), SSH identity options (--user/--port/--identity), ControlMaster-disabled whole-tree deadline, Unix SSH integration tests.
  • P4 (backlog) — Windows local execution polish, session resume/replay, per-stream caps, recipe schema registry (semver'd), transport plugins.
  • P5 (released as 0.5.0) — the cross-project audit's fixes: truthful truncated on every transport, GBK/OEM decoding, bounded post-exit drain, transport_error / dispatched / kill_status / exit_code_confidence, capabilities --json, remote cancellation, MCP cancellation, ssh --detach, incremental bg output cursors, three-state probe, docs/PLATFORM-DIFFS.md, stable library surface. See CHANGELOG.md for the full list and the breaking changes.

Independent by design: MCP + CLI only, no harness dependency, no telemetry, MIT licensed.

Library

The CLI is a thin shell over the library, and both produce the same normalized result (tests/lib_cli_parity.rs asserts field-by-field equality):

use unirun::{ExecResult, ExecSpec, Shell};
use std::sync::atomic::AtomicBool;

let spec = ExecSpec {
    command: "uv run pytest -q".into(),
    shell: Some(Shell::Bash),
    timeout_ms: 120_000,
    output_encoding: Some("gbk".into()), // captured-output code page
    ..Default::default()
};
let result: ExecResult = unirun::run(&spec);
if result.timed_out || !result.dispatched {
    // safe to resubmit; otherwise a non-idempotent command must not be retried
}
println!("{}", result.error_class.as_deref().unwrap_or("ok"));

// Embedding with your own cancellation (an agent loop, a policy layer):
let cancel = AtomicBool::new(false);
let _ = unirun::run_with_abort(&spec, &cancel);

Stability: the ExecSpec/ExecResult field sets, run*, ssh_run*, probe, session, recipe, capabilities, encoding and the error_class vocabulary are the stable surface; fields are added, never removed or repurposed. See the unirun crate docs for the exact list.

Releasing

Cargo.toml is the single source of truth: the tag must be v<Cargo.toml version>, and CI asserts exactly that before it creates the GitHub Release, so the tag, the crate and the release assets always agree (v0.2.1 is the historical counter-example — a tag with no published crate). The crate itself is published by hand from a clean tree at the tagged commit, because a crates.io release is irreversible (a version can be yanked but never deleted or replaced).

scripts/release.sh makes that sequence fail-closed instead of a checklist:

# 1. bump `version` in Cargo.toml, add the CHANGELOG section, commit
cargo check --all-targets

# 2. verify everything, change nothing (the default): clean tree on main,
#    Cargo.toml = Cargo.lock = planned tag, CHANGELOG entry present,
#    fmt --check, clippy ×2, tests ×2, `cargo publish --dry-run`, and the
#    payload-hygiene gate that keeps internal docs out of the .crate
scripts/release.sh

# 3. push main and the tag once step 2 is green (CI builds the five assets)
scripts/release.sh --push

# 4. after CI is green and the assets exist: publish the crate (irreversible)
cargo publish

Every gate must pass before anything leaves the machine, and --publish (which appends cargo publish to the same run) is a separate flag precisely because that step cannot be undone.

License

MIT © 2026 LosEcher

About

Cross-platform command execution normalization for AI agents — one command spec in, one normalized result out, on any platform.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages