@tokamak-private-dapps/private-state-cli 2.4.1 → 2.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 2.4.3 - 2026-06-01
6
+
7
+ - Added pre-submit transaction dry-runs for every transaction-sending CLI command.
8
+ - Added post-proof local prechecks before dry-run for proof-backed commands.
9
+ - Improved dry-run and submit failure messages with decoded revert details when available.
10
+ - Standardized CLI `--json` output so final success and failure results are JSON objects on stdout.
11
+ - Changed progress, warning, and informational events to emit JSON Lines on stderr in `--json` mode.
12
+ - Added structured JSON command-reference output for `help commands --json` and `--help --json`.
13
+
14
+ ## 2.4.2 - 2026-05-30
15
+
16
+ - Changed channel workspace recovery guidance so CLI help, guide output, agent instructions, and documentation direct
17
+ users to registered workspace mirrors before explicit RPC genesis rebuilds.
18
+
5
19
  ## 2.4.1 - 2026-05-30
6
20
 
7
21
  - Classified `UnexpectedCurrentRootVector()` submit reverts as stale channel-root failures with recovery hints that
package/README.md CHANGED
@@ -170,7 +170,8 @@ A common note-use flow after channel policy review is:
170
170
  `channel join` pays any join toll directly from the L1 wallet; `account deposit-bridge` funds later channel liquidity and does not pay the join toll.
171
171
 
172
172
  Use `private-state-cli help commands` for the full command list and required options. `private-state-cli --help`
173
- continues to print the same command list for shell compatibility.
173
+ continues to print the same command list for shell compatibility. Add `--json` to either form to print the command
174
+ reference as structured JSON on stdout.
174
175
 
175
176
  ### Action-impact acknowledgement
176
177
 
@@ -199,7 +200,14 @@ unless the user explicitly understands the compliance implications. Prefer a sel
199
200
 
200
201
  Workspace recovery commands use saved recovery indexes by default. If the local channel workspace is missing,
201
202
  corrupted, or does not contain a usable index, `channel recover-workspace` stops with an explicit error instead of
202
- silently replaying logs from channel genesis. Use `channel recover-workspace --source rpc --from-genesis` only when
203
+ silently replaying logs from channel genesis. When the channel has a registered workspace mirror, recover from the
204
+ mirror first:
205
+
206
+ ```bash
207
+ private-state-cli channel recover-workspace --channel-name <CHANNEL> --network mainnet --source mirror
208
+ ```
209
+
210
+ Use `channel recover-workspace --source rpc --from-genesis` only when no compatible workspace mirror is available and
203
211
  you intentionally want to rebuild channel workspace state from the channel creation block:
204
212
 
205
213
  ```bash
@@ -226,9 +234,9 @@ existing history, while `--from-genesis` overwrites it with one full genesis-to-
226
234
  by replaying from the channel's genesis block because no prior recovery index can exist for a new channel.
227
235
 
228
236
  `channel join` refreshes stale channel workspace state through the saved recovery index before submitting the
229
- registration transaction. For a channel that was created elsewhere, run `channel recover-workspace --source rpc --from-genesis`
230
- once before joining, or recover from a registered workspace mirror; later joins and wallet commands resume from the
231
- saved index instead of silently replaying from genesis.
237
+ registration transaction. For a channel that was created elsewhere, recover from a registered workspace mirror first.
238
+ Use `channel recover-workspace --source rpc --from-genesis` only when no compatible mirror is available; later joins
239
+ and wallet commands resume from the saved index instead of silently replaying from genesis.
232
240
 
233
241
  Wallet commands that need channel state, including `wallet recover-workspace`, `wallet get-meta`,
234
242
  `wallet get-channel-fund`, and `wallet get-notes`, refresh stale local channel workspaces through saved recovery
@@ -517,6 +525,15 @@ LLM agents that guide users through this CLI should read [`agents.md`](agents.md
517
525
  commands. That file contains the agent-specific operating rules, including secret-handling boundaries, onboarding
518
526
  sequence, acknowledgement handling, recovery behavior, and error-response policy.
519
527
 
528
+ When `--json` is used, the CLI follows one output contract for all commands:
529
+
530
+ - the final success result is one JSON object on stdout
531
+ - command failures are one JSON object on stdout with `ok: false`
532
+ - progress, warning, and informational events are JSON Lines on stderr
533
+ - human-readable mode remains the default when `--json` is omitted
534
+
535
+ Agents should parse stdout for the final result and may stream stderr JSONL events to explain progress to the user.
536
+
520
537
  ## Artifacts
521
538
 
522
539
  Proof-backed and channel-mutating commands require full installed bridge, DApp, and Groth16 artifacts. Run
package/agents.md CHANGED
@@ -37,16 +37,20 @@ activity or as a bridge-wide disclosure rule for every DApp.
37
37
  `private-state-cli set rpc --network <NETWORK> --rpc-url <URL> --provider <PROVIDER>`, or with explicit
38
38
  `--log-requests-per-second` and `--block-range-cap` values when the provider is not built in.
39
39
  - A workspace recovery index is the saved block pointer and state-root hash that lets the CLI resume log scanning
40
- without replaying the channel from its creation block. If it is missing, explain `--from-genesis` before using it
41
- because genesis replay can take much longer.
40
+ without replaying the channel from its creation block. If it is missing, check whether the channel has a registered
41
+ workspace mirror before explaining or using `--from-genesis`, because genesis replay can take much longer.
42
42
  - Before guiding a user to run `channel recover-workspace --source rpc --from-genesis`, explain that RPC genesis
43
- recovery can be very slow because it scans channel logs from the creation block. If a channel workspace mirror is
44
- available, try mirror-based recovery first, and use RPC genesis replay only when mirror recovery is unavailable or
45
- unsuitable.
43
+ recovery can be very slow because it scans channel logs from the creation block. Run or suggest
44
+ `channel get-meta --channel-name <CHANNEL> --network <NETWORK>` first; if `workspaceMirror` is set, try
45
+ `channel recover-workspace --channel-name <CHANNEL> --network <NETWORK> --source mirror`. Use RPC genesis replay only
46
+ when no compatible workspace mirror is available.
46
47
  - When the user asks about gas use, transaction fees, transaction cost, or USD cost for private-state CLI commands, run
47
48
  `private-state-cli help transaction-fees --network <NETWORK> --json` and answer from the returned `rows`. If the
48
49
  network is unclear, ask which network to use. Do not tell the user to ask the developer unless the command fails after
49
50
  following the CLI's printed corrective guidance.
51
+ - Prefer `--json` when running commands on behalf of a user. In JSON mode, parse stdout as the final success or failure
52
+ result. Failures use `ok: false` on stdout. Progress, warning, and informational events are emitted as JSON Lines on
53
+ stderr; stream or summarize those events for the human user instead of treating them as fatal by default.
50
54
  - When `channel recover-workspace` or `wallet recover-workspace` is unexpectedly slow, first inspect the RPC provider
51
55
  configured by `set rpc`. Explain that recovery speed is dominated by `eth_getLogs` block range cap and log request
52
56
  rate. Suggest re-running `set rpc` with a provider that supports a larger block range cap, such as Ankr or Chainnodes
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  assertHelpCommandsArgs,
3
3
  assertVersionArgs,
4
+ cliOutput,
4
5
  configureOutput,
5
- formatCliErrorForDisplay,
6
6
  parseArgs,
7
7
  printHelp,
8
8
  printVersion,
@@ -52,11 +52,7 @@ export async function runPrivateStateCli(argv) {
52
52
  }
53
53
  await command(args);
54
54
  } catch (error) {
55
- console.error(formatCliErrorForDisplay(error, args));
55
+ cliOutput.error(error, args);
56
56
  process.exitCode = 1;
57
57
  }
58
58
  }
59
-
60
- export function privateStateCliDispatchTable() {
61
- return COMMANDS;
62
- }
@@ -210,7 +210,7 @@ export const PRIVATE_STATE_CLI_FIELD_CATALOG = Object.freeze({
210
210
  fromGenesis: {
211
211
  label: "Scan From Genesis",
212
212
  type: "checkbox",
213
- hint: "Requires --source rpc. Ignore the local recovery index and replay channel logs from genesis.",
213
+ hint: "Requires --source rpc. Use only when no compatible workspace mirror is available and a full genesis replay is intentional.",
214
214
  option: "--from-genesis",
215
215
  optional: true,
216
216
  },
@@ -233,7 +233,7 @@ export const PRIVATE_STATE_CLI_FIELD_CATALOG = Object.freeze({
233
233
  type: "select",
234
234
  options: ["rpc", "mirror"],
235
235
  valueLabel: "<rpc|mirror>",
236
- hint: "Optional. Defaults to rpc. mirror validates the channel leader's checkpoint manifest and downloads only the needed checkpoint or delta bundle before RPC delta replay.",
236
+ hint: "Use mirror first when a channel workspace mirror is registered. If omitted, the CLI uses rpc and resumes from the local recovery index when available.",
237
237
  option: "--source",
238
238
  optional: true,
239
239
  },
@@ -313,8 +313,11 @@ export const PRIVATE_STATE_CLI_COMMANDS = Object.freeze([
313
313
  id: "help-commands",
314
314
  display: "help commands",
315
315
  description: "Show the private-state CLI command reference.",
316
- fields: [],
317
- usage: "no options",
316
+ fields: ["json"],
317
+ usage: "optional --json",
318
+ help: [
319
+ "Use --json to emit the full command reference as structured JSON on stdout.",
320
+ ],
318
321
  },
319
322
  {
320
323
  id: "help-update",
@@ -429,12 +432,13 @@ export const PRIVATE_STATE_CLI_COMMANDS = Object.freeze([
429
432
  optionalFields: ["source", "fromGenesis", "outputRaw", "publishWorkspaceMirror", "leaderAccount", "output", "force"],
430
433
  usage: "--channel-name, --network, optional --source, optional --from-genesis, optional --output-raw, optional --publish-workspace-mirror with --leader-account and --output, optional --force",
431
434
  help: [
432
- "By default, --source rpc resumes RPC log scanning from the workspace recovery index when available",
435
+ "When a channel workspace mirror is registered, try --source mirror before an explicit RPC genesis rebuild",
433
436
  "--source mirror validates the channel leader's registered checkpoint manifest, downloads only the needed checkpoint or delta bundle, and then replays RPC logs to latest",
437
+ "If --source is omitted, the CLI uses rpc and resumes RPC log scanning from the workspace recovery index when available",
434
438
  "RPC recovery writes a usable channel workspace checkpoint after each RPC log chunk, so interrupted runs can resume from the last completed chunk",
435
439
  "Mirror recovery uses a matching delta bundle when available; otherwise a newer verified full checkpoint replaces the local checkpoint before RPC catch-up",
436
440
  "Fails instead of falling back to genesis when no usable recovery index exists",
437
- "Use --source rpc --from-genesis to ignore the recovery index and replay logs from channel genesis",
441
+ "Use --source rpc --from-genesis only when no compatible workspace mirror is available and you intentionally want to replay logs from channel genesis",
438
442
  "--output-raw with --source rpc appends raw JSON-RPC request and response history to method-specific JSON files under the channel workspace rpcCallHistory directory; eth_getLogs is split by event",
439
443
  "--from-genesis moves the existing local channel workspace to workspace-rebuild-backups before writing the current-format workspace; local secrets are preserved",
440
444
  "--publish-workspace-mirror writes manifest.json, checkpoint.zip, and any needed delta bundle after recovery",
@@ -524,7 +528,7 @@ export const PRIVATE_STATE_CLI_COMMANDS = Object.freeze([
524
528
  usage: "--channel-name, --network, --account, --wallet-secret-path, --acknowledge-action-impact",
525
529
  help: [
526
530
  "Refreshes the local channel workspace through the saved recovery index before joining when the scan fits the 7,200-block pre-command budget",
527
- "Fails instead of replaying from genesis; run channel recover-workspace --source rpc --from-genesis when a genesis rebuild is required",
531
+ "Fails instead of replaying from genesis; recover from a registered workspace mirror first, and use channel recover-workspace --source rpc --from-genesis only when no compatible mirror is available",
528
532
  "--wallet-secret-path is read once for channel-bound L2 spending-key derivation and is not stored in the wallet workspace",
529
533
  "Pays any join toll directly from the L1 wallet, not from bridge-deposited balance",
530
534
  "Prints the immutable policy snapshot before first registration",