Replay & verify
bugcapsule CLI
One standalone CLI replays capsules from Flutter, Android, iOS and web. Installing it does not require Dart or Flutter. The standalone download is version 0.4.2.
Install
With Node.js 20 or newer:
npm install -g @bugcapsule/cli@0.4.1
bugcapsule --version
bugcapsule login
The first command downloads a checksum-verified standalone executable from GitHub. It is cached under ~/.bugcapsule/bin; later commands use that copy, so local inspection works offline. Supported hosts: macOS Apple Silicon and Intel, Linux ARM64 and x64, and Windows x64. The npm wrapper version is 0.4.1; its native CLI reports 0.4.2.
Without Node, download your executable and its .sha256 file from the CLI release, verify its SHA-256, rename it to bugcapsule (bugcapsule.exe on Windows), and put it on PATH. On macOS/Linux, also run chmod +x bugcapsule.
Replay/build commands need the target app's tools: Flutter for Flutter apps, the Android SDK and JDK for Android, Xcode on macOS for iOS, or Node and Playwright for web. Login, downloads and local inspection do not need these SDKs.
The CLI embeds its pinned patch compiler; no separate engine checkout is needed. Local patch compilation and inspection require Node.js 24 or newer on PATH, including when using the standalone executable. The npm wrapper itself requires Node.js 20 or newer. Use bugcapsule patch doctor to check the local toolchain, or --node /path/to/node to select Node explicitly.
Replacing a Dart global installation: run dart pub global deactivate bug_capsule (or bug_capsule_cli for the older package), then install the npm CLI. Existing Flutter projects can still use dart run bug_capsule:bugcapsule.
Log in
bugcapsule login
Like firebase login, it signs you in through the browser:
- The CLI prints a code such as
BCDF-GHJKand opens BugCapsule in your browser. Sign in there if you aren't already. - Check the code on the page matches the one in your terminal, pick the project and choose Authorize CLI.
- The terminal confirms within a few seconds:
✓ Signed in as you@example.com to project "Shop".
The CLI now holds a personal token (bcp_…) for that project. It acts as you, never beyond your role, can read and download capsules and record replay results, and is valid for 90 days. It's listed as CLI · <your machine> in Project Settings › Keys & CLI access, where you can revoke it. Signing in again from the same machine and project replaces it. To work in another project, run bugcapsule login again and pick that project.
bugcapsule login --no-browser # over SSH: open the printed address on any device
bugcapsule login --url https://bugs.example.com # a self-hosted BugCapsule
bugcapsule logout # revoke the token and remove it from this machine
A sign-in request lasts 10 minutes. Cancel on the page and the CLI stops with nothing saved.
Without a browser or in CI, pass a token instead. Create a personal token in Project Settings › Keys & CLI access, or a service token (bcv_…) for CI, and run bugcapsule login --token <token>, or set BUGCAPSULE_TOKEN. An SDK token (bcsdk.v1.…) goes in your app, not here. Projects without people and roles still accept --secret-key bcs_… (and --ingest-key for push).
Credentials go to ~/.bugcapsule/config.json (mode 600; USERPROFILE on Windows); BUGCAPSULE_URL and BUGCAPSULE_TOKEN override the file. --url defaults to BUGCAPSULE_URL, then the saved login, then https://api.bugcapsule.com. An expired or revoked token is refused with a message saying so: run bugcapsule login again.
Commands
| Command | What it does | Key options |
|---|---|---|
inspect <file|id|share-url> | Failure, eligibility, capabilities, dependencies (spec v2), network, timeline | --json, --timeline N (40) |
run <ref> | Replay; expects REPRODUCED. Builds the capsule's commit in a temporary git worktree. | -n (3), --[no-]pin, --report-to <serverId> |
verify <ref> | Replay on your working tree; expects FIXED | -n (5), --report-to |
regress add <ref> | Keeps the capsule as a regression test in bugcapsule/regressions.json + bugcapsule/regressions/<id>.bugcapsule | -p, --name |
regress list | Tests and their last result | -p |
regress run | Runs every active test; exit 1 on any failure | -n (2), --include-quarantined |
gate | Verify the release against fixed issues and upload the gate report; see release gate | --release, --platform, --junit, --json, --fail-on |
patch <command> | Build, inspect, validate and explicitly request delivery of registered module/surface patches; see patch commands | --config, --project, --json |
login | Sign in through the browser and save a personal token for one project | --no-browser, --url, --token |
logout | Revoke the CLI's personal token and remove it from this machine | |
list | Your project's capsules, newest first | --status, --mode, --eligibility, --limit (25) |
pull <id|url> | Download a .bugcapsule | -o |
push <file> | Upload a local capsule (ingest key) | |
share <id> | Expiring public download link | --hours (72, max 720) |
capture | Show or change remote capture config | --on, --off, --sample-rate |
bugcapsule capture --on turns the kill switch on, which disables capture. --off resumes capture. With no flag it prints the current config. Production sampling: bugcapsule capture --sample-rate 0.05.
Launch options (run, verify, regress run)
| Option | Default | Meaning |
|---|---|---|
--runtime | detected | flutter, android, ios, web |
-d, --device | Simulator name/UDID, Android serial/AVD/model | |
-p, --project | . | Project root (where bugcapsule.json lives) |
-t, --target, --flavor, --dart-define | lib/main.dart | Flutter build options |
--apk + --test-apk, --xctestrun, --app-url | Prebuilt artifacts (Android, iOS, web); skip build and pinning | |
--attempt-timeout | recorded duration + settle + 45 s | Seconds per attempt |
--lan | off | Bind the replay server on the LAN (physical devices) |
--strategy | auto | auto, pointer, semantic |
--settle | 8 | Seconds to wait for the failure after the last input |
--lenient-network | off | Send unrecorded requests to the real network (still reported) |
--[no-]compress-idle | on | Shrink idle gaps over 1.5 s |
--baseline-runs (verify) | 3 | Attempts on the capsule's own commit first; FIXED needs every one to reproduce. Reused for 7 days. See verdict v2 |
--accept-qualified (verify) | off | Exit 0 for FIXED (QUALIFIED) too |
--verdict-v1 | off | Old rules without a baseline, for one minor release. Refused in CI unless BUGCAPSULE_ALLOW_VERDICT_V1=1 |
-v, --verbose |
Patch commands
The patch engine replaces logic and surfaces registered in the original app binary. It does not patch arbitrary Dart, Kotlin or Swift code. The installed SDK, immutable base-build inventory and trusted signing roots must already be configured. patch init scaffolds configuration; it does not modify your native application or provision signing keys.
bugcapsule patch doctor
bugcapsule patch init --platform flutter
bugcapsule patch build --help
bugcapsule patch inspect build/fix.bcpatch --json
Use --platform android or --platform ios for native projects. Patch commands read bugcapsule.patch.json by default; select another file with --config. The bundled compiler is the default. --engine or BUGCAPSULE_PATCH_ENGINE is an explicit override for an engine checkout, not an installation prerequisite.
| Command | Purpose and required inputs |
|---|---|
patch doctor [--online] | Check Node and the local compiler; optionally check backend patch access. |
patch base register <manifest.json> | Register the immutable inventory of the actual installed base build. |
patch classify | Classify committed changes using --registered, --repo and --base-rev; --head-rev defaults to HEAD. |
patch build | Classify, compile and sign for an exact registered --base. Requires a clean committed source checkout, --base-rev, --source, signing inputs and output settings; see --help. The default profile is internal. |
patch inspect <file.bcpatch> | Inspect a local artifact. Inspection alone is not deployment approval or runtime acceptance. |
patch upload <file.bcpatch> | Upload the artifact and immutable source review; supports a resumable --state file. Uploading does not deploy. |
patch validate <artifact-id> --capsule <capsule-id> | Start exact-patch validation. Read it with patch validate <validation-id> --get, or submit real evidence with --evidence <file.json>. Starting validation does not imply a pass. |
patch plan <artifact-id> --environment <name> | Create an unpublished deployment plan. --stages uses increasing basis points ending at 10000; the default is 100,500,2500,10000. |
patch deploy <deployment-id> | Explicitly request deployment with --reason and --expected-version; backend validation, roles and approval still apply. |
patch status <deployment-id> | Read deployment state and receipt coverage. Publication is not proof that every installation activated the patch or is healthy. |
patch rollback <deployment-id> | Request signed rollback with --reason, --expected-version and exactly one of --to-base or --to-digest. Offline devices remain unknown until they reconnect. |
Validation mutations, planning, deployment and rollback require an authorized person session; a saved CLI/CI token is not enough. Use Emergency Recovery in the dashboard, or the documented ephemeral BUGCAPSULE_PATCH_SESSION_TOKEN with an explicit project. The CLI does not save that session or bypass expiry, roles or second-person approval. See patch setup and delivery for the full workflow.
For replay evidence, run, verify and gate accept --patch-artifact <file.bcpatch> to pin attempts to that artifact. Delegated signers also need the archived --patch-keyring and --patch-keyring-signature. Without a patch artifact, attempts run the bundled base. Use actual baseline, fix and regression results; neither build nor upload fabricates validation evidence.
Exit codes
| Code | run | verify | Also |
|---|---|---|---|
0 | REPRODUCED | FIXED | Any successful non-replay command |
1 | NOT REPRODUCED | STILL FAILING | API, state and socket errors; a failing regress run |
2 | FLAKY | FLAKY | |
3 | INCONCLUSIVE / INCOMPATIBLE | INCONCLUSIVE / INCOMPATIBLE | Invalid capsule file |
4 | — | FIXED (QUALIFIED) | 0 with --accept-qualified |
5 | UNSAFE | UNSAFE | Live traffic was allowed during replay |
64 | Usage error | ||
130 | Interrupted (Ctrl-C); the attempt's processes are killed and cleaned up | ||
How attempts become verdicts: Verdicts & divergences.
Spec v2 capsules (interaction dependencies)
Available in CLI 0.4.1. Capsules that recorded WebSockets, platform channels or native SDKs are spec v2, and earlier CLIs refuse them. Update the CLI on every machine and CI job before the apps start writing them.
inspect lists each dependency: id, kind, the adapter and adapter version that recorded it, its payload schema, coverage, the package versions it was tested with, and every gap. Required dependencies are marked •, capture-only ones ·. Gaps also appear under eligibility as dependency.<id>. --json includes the full manifest.dependencies.
Dependencies spec v2: replay needs these adapters in the build
• ws websocket bug_capsule.web_socket_channel 0.5.0 schema 1 partial tested: web_socket_channel 3.0.3
gap payload.binaryMetadata ×2 binary frames recorded as metadata
• channels platform.channel bug_capsule.platform_channels 0.5.0 schema 1 complete
Preflight. run, verify and regress run build the app as usual; the replaying SDK then checks every required dependency before your app code starts. When the build lacks an adapter, or its adapter can't replay the recorded schema, or a connection was open at a periodic checkpoint, the attempt ends INCOMPATIBLE (exit 3) with a message naming the dependency and the reason code dependency.unsupported:
Why:
• incompatible: dependency.unsupported: bug_capsule.web_socket_channel (dependency "ws") is not set up in this build; add the adapter to BugCapsule.init
reason codes: dependency.unsupported
Add the same integrations to the replayed build (or, for dependency.unrestorable, capture a capsule whose window starts at launch). During replay, interactions are served offline only: --lenient-network applies to HTTP and never lets a socket, channel or SDK call through. verify records its reason codes with the run, and a run with interaction divergences never marks the capsule fixed; see interaction divergences.
Which runtime, which code
--runtime, else"runtime"inbugcapsule.jsonat the project root, else detection:pubspec.yaml→ flutter,settings.gradle(.kts)→ android,*.xcodeproj/*.xcworkspace→ ios,package.json→ web.- A capsule replays only in the runtime that captured it. Otherwise:
INCOMPATIBLE(runtime.mismatch, exit 3) without building anything. runbuildsmanifest.source.gitShain a temporary git worktree when the project is a git checkout and the commit exists (--no-pinreplays the working tree).verifyandregress runbuild the working tree.- The build gets the commit it's made from: Flutter
--dart-define=BUGCAPSULE_GIT_SHA, Android-PbugcapsuleGitSha, iOS build settingBUGCAPSULE_GIT_SHA, web envBUGCAPSULE_GIT_SHA. A commit other than the capsule's is the expectedbuild.gitShadivergence.
bugcapsule.json
At the project root. Not needed for Flutter apps that use the defaults.
{
"runtime": "android",
"android": { "applicationId": "com.example.shop" },
"timeouts": { "buildSeconds": 1200, "attemptSeconds": 120 }
}
| Key | Default | Meaning |
|---|---|---|
applicationId | required | |
gradleDir | . | Gradle root, relative to this file |
module / moduleDir | app | Module path / directory for APK lookup |
variant | debug | |
testApplicationId | <applicationId>.test | |
runner, testClass | BugCapsule runner / test | |
avd | Booted headless when no device is running | |
gradleArgs, emulatorArgs | [] | Lists |
sdkDir | ANDROID_HOME, local.properties, ~/Library/Android/sdk | |
bootTimeoutSeconds | "300" | Write it as a string: the CLI reads this key as a string and rejects a JSON number |
Env BUGCAPSULE_ANDROID_GRADLE_ARGS appends Gradle arguments for one run.
| Key | Default | Meaning |
|---|---|---|
project / workspace | -project / -workspace | |
scheme | required | Builds the app and the UI test target |
configuration | Debug | Must define DEBUG |
bundleId | from the built app | Required with --xctestrun |
replayTest | <uiTestTarget>/BugCapsuleReplayTests/testReplay | uiTestTarget defaults to UITests; set one of them |
simulator | first booted iPhone | Name substring or UDID |
derivedDataPath | $TMPDIR/bugcapsule-ios-<hash> | Reused across runs |
startupSeconds | 120 | Added to each attempt's budget |
buildSettings | Map of extra settings |
Env BUGCAPSULE_IOS_BUILD_SETTINGS='K=V K2=V2' adds settings for one run.
| Key | Default | Meaning |
|---|---|---|
url | http://127.0.0.1:4317/ | Where the served app lives |
installCommand + installDir | Run when node_modules is missing (pinned worktrees) | |
buildCommand, serveCommand | ||
readyTimeoutSeconds | 60 | Integer |
allowOrigins | Origins the page may load besides the app's | |
runner | @bugcapsule/web-replay bin | |
headed | false | Watch the browser |
env | Map passed to every command | |
browser | chromium | Only Chromium |
No section needed. Use -t, --flavor and --dart-define on the command line. timeouts applies as for every runtime.
| Shared key | Default |
|---|---|
timeouts.buildSeconds | 1200 |
timeouts.attemptSeconds | recorded duration + settle + 45 s |
Replay protocol and safety
Protocol v1.1, identical across runtimes:
BUGCAPSULE_REPLAY_URL = http://127.0.0.1:<port>/a/<token>
GET <base>/settings → ReplaySettings JSON (attemptId, runtime, strategy, …)
GET <base>/capsule → .bugcapsule bytes
POST <base>/result → ReplayReport JSON (204; 409 wrong attemptId; 410 attempt closed)
- The server binds 127.0.0.1 on a random port (
--lanfor physical devices). Android emulators reach it throughadb reverse(removed on exit). - Every attempt gets a new 32-byte token and a new
attemptId. Other tokens get 404; a report is accepted once; a late report from a killed attempt can never count for the next one. - Requests with an
Originheader are refused (403), so no web page can talk to the server. - Fallback result channel:
BUGCAPSULE_RESULT::{json}on stdout (Flutter), in instrumentation status (Android) or the XCUITest log (iOS), accepted only from the process launched for the armed attempt. - Attempt isolation: Flutter relaunches, Android
pm clear, iOS uninstall, web fresh browser context. A missing report, crash or timeout is anerrorattempt, never evidence of a fix.
Local safety
CLI 0.4.2 never writes, runs or opens something a capsule or a server chose:
- A stdout result line counts only when it carries the armed attempt's random id, and the result body is read with a size cap.
- Capsule file names are validated before anything is written.
- Pinned source worktrees live under
~/.bugcapsule/pins(owner-only) and are reused only when the commit and the repository match. - Downloads are capped at 256 MiB, with a 60-second stall limit.
- Credentials in
~/.bugcapsule/config.jsonare written owner-only (0600), atomically. bugcapsule loginopens only an https page on your BugCapsule site (http only between local hosts).- Web replay blocks every live request by default.
--allow-live <url substring>on the web runner lets matching requests through for debugging, reports them asreplay.unsafe_liveand makes the run UNSAFE.
Environment variables
| Variable | Used for |
|---|---|
BUGCAPSULE_URL, BUGCAPSULE_SECRET_KEY, BUGCAPSULE_INGEST_KEY | Credentials (override ~/.bugcapsule/config.json) |
BUGCAPSULE_ANDROID_GRADLE_ARGS, ANDROID_HOME, ANDROID_SDK_ROOT | Android launcher |
BUGCAPSULE_IOS_BUILD_SETTINGS | iOS launcher |
NO_COLOR | Plain output |
BUGCAPSULE_GIT_SHA, BUGCAPSULE_GIT_DIRTY, BUGCAPSULE_REPLAY_URL | Set by the CLI for the app being built or replayed |
Replay and source maps
The npm package @bugcapsule/cli installs bugcapsule for all runtimes and keeps bugcapsule-cli sourcemaps for existing build scripts. Source maps also work through bugcapsule sourcemaps.
Flutter symbol commands
| Command | Purpose |
|---|---|
bugcapsule symbols new-id | Create the ID embedded in an obfuscated Flutter build. |
bugcapsule symbols upload --split-debug-info build/symbols | Upload matching release symbols; supports --obfuscation-map, --obfuscation-id, --release and --dry-run. |
See Release symbols and source maps for the complete build sequence.