Skip to content

Apply --max-chars consistently to all commands, skip in --json mode#157

Merged
jancurn merged 2 commits intomainfrom
claude/add-max-chars-option-a52hx
Apr 10, 2026
Merged

Apply --max-chars consistently to all commands, skip in --json mode#157
jancurn merged 2 commits intomainfrom
claude/add-max-chars-option-a52hx

Conversation

@jancurn
Copy link
Copy Markdown
Member

@jancurn jancurn commented Apr 9, 2026

Summary

  • --max-chars truncation now applies consistently to all commands (not just tools-call, prompts-get, resources-read)
  • Truncation is skipped in --json mode to avoid producing invalid JSON
  • Truncation logic moved into formatOutput() so every command gets it for free

Changes

  • Added maxChars to FormatOptions and applied truncation centrally in formatOutput() (human mode only)
  • Passed maxChars through FormatOptions at all formatOutput() call sites that use options.outputMode
  • Removed per-handler truncateOutput() calls and cleaned up unused imports
  • Updated help text: --max-chars <n> Truncate output to n characters (ignored in --json mode)
  • Updated CHANGELOG and README

Test plan

  • npm run lint passes
  • npm run build passes
  • npm run test:unit passes (500/500)
  • CI green (Node 20/22/24, E2E Node/Bun)

https://claude.ai/code/session_01PiFuVVaizRowPPHUwMPKVa

claude added 2 commits April 9, 2026 12:55
… mode

--max-chars now only appears on the commands where it applies (tools-call,
prompts-get, resources-read) rather than as a global option. Truncation is
skipped in --json mode to avoid producing invalid JSON output.

https://claude.ai/code/session_01PiFuVVaizRowPPHUwMPKVa
Move truncation logic into formatOutput() so every command that uses it
gets --max-chars support automatically in human mode. This replaces the
previous per-handler truncation which only covered 3 commands. JSON
output is never truncated to avoid producing invalid JSON.

https://claude.ai/code/session_01PiFuVVaizRowPPHUwMPKVa
@jancurn jancurn changed the title Move --max-chars from global to command-specific options Apply --max-chars consistently to all commands, skip in --json mode Apr 10, 2026
@jancurn jancurn merged commit 7398f89 into main Apr 10, 2026
6 checks passed
@jancurn jancurn deleted the claude/add-max-chars-option-a52hx branch April 10, 2026 13:01
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.

3 participants