Skip to content

feat: add standard CLI mode with JSON output for AI agents and automation#921

Open
parsoncryptoai wants to merge 14 commits intotronprotocol:developfrom
parsoncryptoai:develop
Open

feat: add standard CLI mode with JSON output for AI agents and automation#921
parsoncryptoai wants to merge 14 commits intotronprotocol:developfrom
parsoncryptoai:develop

Conversation

@parsoncryptoai
Copy link
Copy Markdown

Summary

  • Standard CLI mode: Non-interactive, scriptable CLI (java -jar wallet-cli.jar --network nile get-account --address TXyz...) alongside the existing
    REPL mode. Supports --output json for structured output, --network for network selection, and --quiet flag. Designed for AI agents, scripts, and
    CI/CD pipelines.
  • Command framework: CommandRegistry/CommandDefinition pattern with fluent builder API. Commands organized by domain in cli/commands/ (Query,
    Transaction, Wallet, Staking, Contract, Exchange, Proposal, Witness, Misc). Supports aliases, typed options, and fuzzy command suggestion on typos.
  • JSON output envelope: All commands produce {"success":true,"data":...} or {"success":false,"error":"..."} in JSON mode, with stdout/stderr
    suppression to guarantee machine-parseable output.
  • Active wallet management: Persistent active wallet selection via set-active-wallet / list-wallets commands, stored in
    Wallet/active_wallet.conf.
  • QA verification suite: Shell-based parity tests (qa/) comparing REPL vs standard CLI output across text and JSON modes, with semantic comparison
    for format-independent validation.
  • Transfer USDT command: New transfer-usdt command for TRC20 USDT transfers with automatic contract address resolution per network.

Test plan

  • Build passes: ./gradlew build
  • Standard CLI text mode: java -jar build/libs/wallet-cli.jar --network nile get-account --address <addr>
  • Standard CLI JSON mode: java -jar build/libs/wallet-cli.jar --output json --network nile get-account --address <addr>
  • REPL mode still works: ./gradlew run
  • QA parity tests pass: TRON_TEST_APIKEY=<key> bash qa/run.sh verify
  • Active wallet commands: set-active-wallet, list-wallets
  • Transfer USDT: transfer-usdt --to <addr> --amount 1

HarukaMa and others added 11 commits April 1, 2026 15:47
Add a non-interactive standard CLI framework (--output json, --private-key,
--mnemonic flags) alongside the existing interactive REPL. Includes a bash
harness that verifies all 120+ commands across help, text, JSON, on-chain
transactions, REPL parity, and wallet management (321 tests, 315 pass, 0 fail).

Key changes:
- New cli/ package: StandardCliRunner, OutputFormatter, CommandRegistry,
  and per-domain command files (Query, Transaction, Staking, etc.)
- JSON mode suppresses stray System.out/err from WalletApi layer so only
  structured OutputFormatter output reaches stdout
- Remove debug print from AbiUtil.parseMethod() that contaminated stdout
- Harness scripts (harness/) for automated three-way parity verification
- Updated .gitignore for runtime artifacts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ments

Rename harness/ → qa/ across shell scripts, Java classes, docs, and build config.
Fix vote-witness QA test that extracted keystore address instead of witness address
by filtering "keystore" lines from list-witnesses output. Add lock/unlock commands,
improve GlobalOptions parsing, and update CLAUDE.md baseline.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…d auth options

Move JSON stream suppression earlier in StandardCliRunner to cover network
init and authentication (not just command execution), remove --private-key
and --mnemonic global options, and update QA/plan docs to reflect current
test baseline (321 tests, 314 passed, 1 failed, 6 skipped).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Simplify protobuf formatting to use Utils.formatMessageString for both
modes, suppress info messages in JSON mode, and update spec/plan docs
to clarify the strict JSON-only contract.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add text+JSON parity, JSON field validation, round-trip verification
(set then get-active-wallet), and error case tests (no args, both args,
invalid address) for wallet management commands.
Replace login/logout/backup/export commands with list-wallet, set-active-wallet,
and get-active-wallet for multi-wallet support. Implement transfer-usdt with
automatic energy estimation. Update CLAUDE.md docs and add QA tests for new
transaction commands.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Skip unit tests and QA verification when no code files (src/, build.gradle, *.java) have changed. Consolidates two separate hook blocks into one.
… to JSON errors

WalletApi.listWallets filtered to skip the .active-wallet config file,
which was incorrectly treated as a wallet keystore. OutputFormatter.error()
and usageError() now include "success": false in JSON output for consistent
envelope format.
@lxcmyf
Copy link
Copy Markdown
Contributor

lxcmyf commented Apr 3, 2026

This PR is currently under review.
Separately, wallet-cli also has some related MCP plans on our side. The general idea is to expose selected wallet-cli capabilities as MCP services, so they can be called directly from AI chat interfaces or other agent-based workflows, instead of being limited to traditional interactive CLI usage. We are still working through the design and scope, and we will share updates as things move forward.

HarukaMa and others added 3 commits April 3, 2026 17:05
…defaults

- OutputFormatter.success() now wraps jsonData in {"success":true,"data":{...}}
  envelope for consistent API response format
- OutputFormatter.protobuf() outputs single-line valid JSON via
  JsonFormat.printToString in JSON mode (was using formatJson which
  introduced illegal newlines inside string values)
- deploy-contract defaults token-id to empty string (matching REPL behavior)
  and origin-energy-limit to 1 (TRON requires > 0)
- add --force support for reset-wallet and clear-wallet-keystore
- de-interactivize standard CLI transaction signing with permission-id support
- align wallet command JSON schema with success/data envelope
- add standard CLI change-password command and QA coverage
- improve QA command counting, skip reasons, and stale result cleanup
- add --case support to qa/run.sh for targeted reruns
- strengthen transaction QA side-effect checks
- make send-coin JSON return txid and verify send-coin-balance via tx receipt fallback
- update QA reports and fix report documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants