feat(reports): add --max-width and --max-col-width to report get (swamp-club#347)#1391
Conversation
…mp-club#347) Add table width controls to `swamp report get` so wide reports fit laptop terminals without wrapping into illegible noise. `--max-width N` caps total output width via marked-terminal's reflowText. `--max-col-width N` pre-processes markdown tables to truncate individual cells with an ellipsis before rendering. Both flags combine and support env var defaults (SWAMP_REPORT_MAX_WIDTH, SWAMP_REPORT_MAX_COL_WIDTH). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
CLI UX Review
Blocking
None.
Suggestions
-
Terminology inconsistency in flag descriptions (
report_get.tslines 90, 94):--max-widthsays "in columns" while--max-col-widthsays "in characters". Both measure character widths — using consistent phrasing (e.g. both say "characters") would reduce confusion. -
Silent discard of invalid env var values (
report_get.tsparseEnvInt): If a user setsSWAMP_REPORT_MAX_WIDTH=wide(non-numeric), the function returnsundefinedand the flag is silently ignored. AUserErroror at least a log-level warning would help the user notice the misconfiguration.
Verdict
PASS — flags are well-named and consistent with existing (env: VAR) documentation style, error messages are clear and actionable, JSON mode is correctly unaffected, and validation covers both CLI and env var paths.
Condense verbose output mode descriptions and remove redundant JSON shape example to improve skill content score from 77% to 85%. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
CLI UX Review
Blocking
None.
Suggestions
-
--max-width/--max-col-widthare silently ignored with--json— a user who hasSWAMP_REPORT_MAX_WIDTHset in their environment and then runs--jsonwon't get a warning that the flag did nothing. Consider noting the scope in the flag descriptions, e.g.Cap total output width in columns; no-op in JSON mode (env: SWAMP_REPORT_MAX_WIDTH). Not blocking since JSON output is intentionally unaffected and the SKILL.md documents it. -
Example for
--max-col-widthomits--model— the existing--markdownexample includes--model my-serveras context; the new examples use barecost-summarywith no scope flag. Minor inconsistency that could confuse users who wonder how the report is resolved. Just a cosmetic suggestion. -
Non-numeric env var is silently ignored — if
SWAMP_REPORT_MAX_WIDTH=abcis set,parseEnvIntreturnsundefinedand the value is dropped without any diagnostic. A debug-level log message (logger.debug) noting the invalid env var would help users troubleshooting misconfigured environments, but this is low priority.
Verdict
PASS — flags are well-named, description format matches the existing env: SWAMP_REPO_DIR convention, error messages are clear and actionable, JSON mode is correctly unaffected, and the feature composes cleanly with --markdown.
There was a problem hiding this comment.
Code Review
Well-structured PR. The new --max-width and --max-col-width flags are cleanly layered: CLI parses + validates, WidthOptions flows through the renderer factory, and the markdown rendering functions apply truncation/reflow. JSON mode is correctly unaffected.
Blocking Issues
None.
Suggestions
-
renderMarkdownPlainsilently ignoresmaxWidth— If a user passes--max-width 80 --markdown, themaxWidthoption has no effect sincerenderMarkdownPlainonly handlesmaxColWidth. This is technically correct (maxWidth is a terminal-rendering concern), but could surprise users. A debug-level log or a note in the--max-widthhelp text ("applies to log mode only") would make the boundary clearer. -
truncateMarkdownTableCellscounts characters, not display width —stripped.lengthmeasures UTF-16 code units, not visual columns. CJK characters (e.g.,你好) occupy 2 terminal columns each but count as 1 in.length, so amaxColWidthof 10 could render wider than expected. This is an edge case unlikely to affect typical report tables, and fixing it would require a display-width library — fine to leave as-is, just noting it. -
Per-call
Marked()allocation whenmaxWidthis set —renderMarkdownToTerminalcreates a newMarkedinstance on every invocation whenoptions.maxWidthis present (line 44). For a CLI that renders one report this is negligible, but if this function ever gets called in a loop, caching by width value would avoid repeated setup. -
Skill doc trimming — The SKILL.md changes removed the JSON output shape example and the
_errorformat note. These were useful for agents consuming--jsonoutput. Consider keeping a brief pointer to where agents can find the JSON schema (e.g., "seeReportGetEventtype in libswamp").
All four are non-blocking.
Summary
--max-widthand--max-col-widthflags toswamp report getso wide report tables fit laptop terminals without wrapping into illegible noise--max-width Ncaps total output width (tables + reflowed text) via marked-terminal'sreflowTextoption--max-col-width Npre-processes markdown tables to truncate individual cells with…before rendering — works for both log and markdown output modes--max-col-widthtruncates cells first, then--max-widthconstrains total width) and support env var defaults (SWAMP_REPORT_MAX_WIDTH,SWAMP_REPORT_MAX_COL_WIDTH)Test plan
truncateMarkdownTableCells(cell truncation, ellipsis, non-table preservation, separator row skipping, pipes in code spans)renderMarkdownToTerminalwith width options and renderer factory threadingdeno check,deno lint,deno fmtall passCloses swamp-club#347
🤖 Generated with Claude Code