Skip to content

fix: wallet list routes human-readable summary to stderr, keeps only JSON on stdout#289

Open
yodablocks wants to merge 5 commits intonansen-ai:mainfrom
yodablocks:fix/154-wallet-list-stderr
Open

fix: wallet list routes human-readable summary to stderr, keeps only JSON on stdout#289
yodablocks wants to merge 5 commits intonansen-ai:mainfrom
yodablocks:fix/154-wallet-list-stderr

Conversation

@yodablocks
Copy link
Contributor

Closes #154

Problem

nansen wallet list was outputting human-readable text only (no JSON),
breaking agent pipelines that rely on | jq .

History

This PR completes that TODO

  • Human-readable wallet summary → stderr (interactive users still see it)
  • Clean JSON → stdout (agent pipelines work: nansen wallet list | jq .)

Changes

  • src/wallet.js — added ttyOutput = console.error dep, switched list handler to use it
  • src/__tests__/wallet.test.js — added ttyOutput mock + explicit stderr/stdout separation test
  • .changeset/fix-wallet-list-stderr.md — patch changeset

Tests

929 tests pass, lint clean.

@nansen-pr-reviewer
Copy link

nansen-pr-reviewer bot commented Mar 11, 2026

pr-reviewer Summary

No issues found

The code review completed successfully with no findings.

Review effort: 2/5 (Simple)

Summary

This PR implements the "Hybrid command" pattern for wallet list: human-readable text is routed to ttyOutput (stderr) so interactive users still see it, while the command now returns structured data so runCLI can emit JSON on stdout. The change is focused, well-tested, and documented in AGENTS.md.

Key changes are correct:

  • src/wallet.jsttyOutput is properly destructured with console.error as the default fallback. Both the empty-wallet path and the populated-wallet path now consistently return result, satisfying the framework's undefined-means-no-output contract (lines 1626–1630 of cli.js).
  • src/cli.jswalletDeps = { ...deps, log: output, ttyOutput: errorOutput } correctly wires the resolved output/errorOutput locals rather than the raw deps object. This is also a silent fix for other wallet subcommands (create, delete, etc.) that previously fell back to console.log even when a custom output was injected into runCLI.
  • All affected tests are updated to assert on ttyLines (stderr) and verify the return value, in line with the AGENTS.md "Hybrid commands" rule.

No bugs, security issues, or AGENTS.md violations found.


Token usage: 837 input, 6,235 output, 178,042 cache read, 29,929 cache write

@yodablocks
Copy link
Contributor Author

Note for reviewers: the bot flagged that interactive users will see JSON on stdout alongside human-readable stderr output in a terminal. Happy to add a process.stdout.isTTY guard to suppress JSON in interactive sessions if that matches the intended UX — wanted to check with the team before adding complexity.

@yodablocks yodablocks force-pushed the fix/154-wallet-list-stderr branch from eb66a40 to 11d18af Compare March 12, 2026 00:14
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.

🟡 [Medium] wallet list writes human-readable text + JSON to stdout simultaneously (breaks piping)

2 participants