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:

  1. The CLI prints a code such as BCDF-GHJK and opens BugCapsule in your browser. Sign in there if you aren't already.
  2. Check the code on the page matches the one in your terminal, pick the project and choose Authorize CLI.
  3. 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

CommandWhat it doesKey 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 listTests and their last result-p
regress runRuns every active test; exit 1 on any failure-n (2), --include-quarantined
gateVerify 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
loginSign in through the browser and save a personal token for one project--no-browser, --url, --token
logoutRevoke the CLI's personal token and remove it from this machine
listYour 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)
captureShow 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)

OptionDefaultMeaning
--runtimedetectedflutter, android, ios, web
-d, --deviceSimulator name/UDID, Android serial/AVD/model
-p, --project.Project root (where bugcapsule.json lives)
-t, --target, --flavor, --dart-definelib/main.dartFlutter build options
--apk + --test-apk, --xctestrun, --app-urlPrebuilt artifacts (Android, iOS, web); skip build and pinning
--attempt-timeoutrecorded duration + settle + 45 sSeconds per attempt
--lanoffBind the replay server on the LAN (physical devices)
--strategyautoauto, pointer, semantic
--settle8Seconds to wait for the failure after the last input
--lenient-networkoffSend unrecorded requests to the real network (still reported)
--[no-]compress-idleonShrink idle gaps over 1.5 s
--baseline-runs (verify)3Attempts on the capsule's own commit first; FIXED needs every one to reproduce. Reused for 7 days. See verdict v2
--accept-qualified (verify)offExit 0 for FIXED (QUALIFIED) too
--verdict-v1offOld 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.

CommandPurpose 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 classifyClassify committed changes using --registered, --repo and --base-rev; --head-rev defaults to HEAD.
patch buildClassify, 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

CoderunverifyAlso
0REPRODUCEDFIXEDAny successful non-replay command
1NOT REPRODUCEDSTILL FAILINGAPI, state and socket errors; a failing regress run
2FLAKYFLAKY
3INCONCLUSIVE / INCOMPATIBLEINCONCLUSIVE / INCOMPATIBLEInvalid capsule file
4—FIXED (QUALIFIED)0 with --accept-qualified
5UNSAFEUNSAFELive traffic was allowed during replay
64Usage error
130Interrupted (Ctrl-C); the attempt's processes are killed and cleaned up

How attempts become verdicts: Verdicts & divergences.

Spec v2 capsules (interaction dependencies)

i

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

  1. --runtime, else "runtime" in bugcapsule.json at the project root, else detection: pubspec.yaml → flutter, settings.gradle(.kts) → android, *.xcodeproj/*.xcworkspace → ios, package.json → web.
  2. A capsule replays only in the runtime that captured it. Otherwise: INCOMPATIBLE (runtime.mismatch, exit 3) without building anything.
  3. run builds manifest.source.gitSha in a temporary git worktree when the project is a git checkout and the commit exists (--no-pin replays the working tree). verify and regress run build the working tree.
  4. The build gets the commit it's made from: Flutter --dart-define=BUGCAPSULE_GIT_SHA, Android -PbugcapsuleGitSha, iOS build setting BUGCAPSULE_GIT_SHA, web env BUGCAPSULE_GIT_SHA. A commit other than the capsule's is the expected build.gitSha divergence.

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 }
}
KeyDefaultMeaning
applicationIdrequired
gradleDir.Gradle root, relative to this file
module / moduleDirappModule path / directory for APK lookup
variantdebug
testApplicationId<applicationId>.test
runner, testClassBugCapsule runner / test
avdBooted headless when no device is running
gradleArgs, emulatorArgs[]Lists
sdkDirANDROID_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.

KeyDefaultMeaning
project / workspace-project / -workspace
schemerequiredBuilds the app and the UI test target
configurationDebugMust define DEBUG
bundleIdfrom the built appRequired with --xctestrun
replayTest<uiTestTarget>/BugCapsuleReplayTests/testReplayuiTestTarget defaults to UITests; set one of them
simulatorfirst booted iPhoneName substring or UDID
derivedDataPath$TMPDIR/bugcapsule-ios-<hash>Reused across runs
startupSeconds120Added to each attempt's budget
buildSettingsMap of extra settings

Env BUGCAPSULE_IOS_BUILD_SETTINGS='K=V K2=V2' adds settings for one run.

KeyDefaultMeaning
urlhttp://127.0.0.1:4317/Where the served app lives
installCommand + installDirRun when node_modules is missing (pinned worktrees)
buildCommand, serveCommand
readyTimeoutSeconds60Integer
allowOriginsOrigins the page may load besides the app's
runner@bugcapsule/web-replay bin
headedfalseWatch the browser
envMap passed to every command
browserchromiumOnly Chromium

No section needed. Use -t, --flavor and --dart-define on the command line. timeouts applies as for every runtime.

Shared keyDefault
timeouts.buildSeconds1200
timeouts.attemptSecondsrecorded 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)

Local safety

CLI 0.4.2 never writes, runs or opens something a capsule or a server chose:

Environment variables

VariableUsed for
BUGCAPSULE_URL, BUGCAPSULE_SECRET_KEY, BUGCAPSULE_INGEST_KEYCredentials (override ~/.bugcapsule/config.json)
BUGCAPSULE_ANDROID_GRADLE_ARGS, ANDROID_HOME, ANDROID_SDK_ROOTAndroid launcher
BUGCAPSULE_IOS_BUILD_SETTINGSiOS launcher
NO_COLORPlain output
BUGCAPSULE_GIT_SHA, BUGCAPSULE_GIT_DIRTY, BUGCAPSULE_REPLAY_URLSet 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

CommandPurpose
bugcapsule symbols new-idCreate the ID embedded in an obfuscated Flutter build.
bugcapsule symbols upload --split-debug-info build/symbolsUpload matching release symbols; supports --obfuscation-map, --obfuscation-id, --release and --dry-run.

See Release symbols and source maps for the complete build sequence.