Repository navigation
feat: CLI Polish - Color Themes, Verbose Mode, and Terminal UX - #97
Conversation
- Add lib/themes.js with 5 built-in themes: default, minimal, high-contrast, dracula, monokai - Add --theme <name> global flag for switching color themes - Add --verbose flag for extra diagnostic info (MATCH, LENGTH, KEY) - Update formatter.js to accept theme and verbose options - Support ERRLENS_THEME and ERRLENS_VERBOSE env vars for runtime injection - Update README with new CLI options, theme docs, and verbose mode - All existing --json and --lang flags remain fully functional
…on, remove broken link - bin/index.js: use theme colors (headerText, unknownText, rawText, errorText, signalText, successText) for all CLI fallback paths instead of hardcoded chalk.red/cyan/gray - lib/auto.js: normalize thrown objects via err.stack first, matching injector.js behavior - lib/themes.js: remove unused chalk import - README.md: fix broken #color-themes link fragment in Global Options table
|
Important Review skippedNo new commits to review since the last review. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe CLI and runtime handlers now support five color themes and verbose diagnostics. Theme selection is validated case-insensitively. ChangesTheme and diagnostics
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant ThemeHelpers
participant Formatter
User->>CLI: Provide theme and verbose options
CLI->>ThemeHelpers: Validate and resolve theme
ThemeHelpers-->>CLI: Return theme styles
CLI->>Formatter: Format matched error with options
Formatter-->>User: Print themed diagnostic output
CLI-->>User: Print sanitized JSON when requested
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR polishes the ErrLens CLI UX by introducing configurable color themes and a verbose diagnostics mode, wiring both through the CLI and runtime injection paths while updating documentation accordingly.
Changes:
- Added theme definitions and helpers to resolve/validate themes.
- Added
--themeand--verboseglobal CLI flags and propagated options into formatted output. - Added
ERRLENS_THEME/ERRLENS_VERBOSEsupport forauto/injector, plus README updates describing new UX features.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents new --theme / --verbose flags and env var configuration, plus theme/verbose sections. |
| lib/themes.js | Adds built-in theme palette definitions and theme resolution/validation helpers. |
| bin/index.js | Introduces global CLI flags (--theme, --verbose), validates theme input, and threads options into formatting paths. |
| lib/formatter.js | Updates formatter to accept { theme, verbose } options and uses theme-driven chalk styles; appends verbose metadata. |
| lib/injector.js | Adds env-driven theme/verbose support for runtime crash analysis output. |
| lib/auto.js | Adds env-driven theme/verbose support and normalizes thrown objects via err.stack/err.message. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (verbose) { | ||
| const matchBlock = ` | ||
| ${chalk[theme.id].bold("🔎 MATCH:")} ${chalk[theme.exampleCode](error.match)}`; | ||
|
|
||
| ${chalk.green.bold("✅ FIXES:")} | ||
| ${fixList} | ||
| const metaBlock = ` | ||
| ${chalk[theme.id].bold("📏 LENGTH:")} ${error.match.length} chars | ||
| ${chalk[theme.id].bold("🏷️ KEY:")} ${error.match}`; | ||
|
|
| function resolveTheme(name) { | ||
| if (!name) return THEMES.default; | ||
| const normalized = name.toLowerCase(); | ||
| if (THEMES[normalized]) return THEMES[normalized]; | ||
| return THEMES.default; | ||
| } | ||
|
|
||
| function isValidTheme(name) { | ||
| if (!name) return true; | ||
| return THEME_NAMES.includes(name.toLowerCase()); | ||
| } |
- matcher.js: add matchedText field to each match (exact case-preserved substring from input) - formatter.js: verbose block renders MATCH from matchedText, KEY from DB phrase (no longer duplicates) - themes.js: harden resolveTheme() with typeof check + hasOwnProperty to prevent __proto__/constructor attacks
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@bin/index.js`:
- Around line 100-103: Preserve the JSON match schema by introducing one shared
serializer that removes the enumerable matchedText property before
JSON.stringify, while retaining it for verbose presentation where applicable.
Apply the serializer to bin/index.js lines 100-103 (normal run output), 85-89
(signal termination output), and 163-168 (analyze output), and add regression
coverage for all three branches.
- Line 192: Update the CLI entry point around program.parse to call
program.parseAsync for the async run and analyze handlers, and attach failure
handling that reports rejected imports or action errors and exits with a
non-zero status.
In `@lib/auto.js`:
- Around line 14-17: Use a single safe thrown-value normalizer for all three
sites: update lib/auto.js lines 14-17 to replace the direct String(err)
fallback, and update both lib/injector.js lines 14-17 and 38-41 to normalize
object exceptions or rejections before passing them to findError. Ensure values
lacking stack and message are handled without throwing and still undergo
analysis.
In `@README.md`:
- Around line 110-117: Update the README heading above the options table to
avoid presenting --lang as a global option; rename the heading to “Options” or
separate command-local options from root-level options. Keep the existing
--json, --theme, --verbose, and --lang descriptions accurate while making clear
that --lang applies only to run and analyze.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: da121f5c-f520-44aa-9b97-e8cd02714b5f
📒 Files selected for processing (7)
README.mdbin/index.jslib/auto.jslib/formatter.jslib/injector.jslib/matcher.jslib/themes.js
| ### Global Options | ||
|
|
||
| | Flag | Description | | ||
| |------|-------------| | ||
| | `--json` | Output raw JSON (no colors, no boxes) — perfect for CI/CD pipelines | | ||
| | `--theme <name>` | Pick a color theme (see the Color Themes section below) | | ||
| | `--verbose` | Show extra diagnostic info for each matched error | | ||
| | `--lang <code>` | Output language (e.g. `hi`, `es`, `fr`) — available on `run` and `analyze` | |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Do not label --lang as a global option.
--lang is declared on the run and analyze commands in bin/index.js at Lines 41 and 151. Rename this heading to Options or separate command-local options from root options. This prevents users from inferring unsupported syntax such as errlens --lang es analyze ....
Proposed documentation fix
-### Global Options
+### Options📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ### Global Options | |
| | Flag | Description | | |
| |------|-------------| | |
| | `--json` | Output raw JSON (no colors, no boxes) — perfect for CI/CD pipelines | | |
| | `--theme <name>` | Pick a color theme (see the Color Themes section below) | | |
| | `--verbose` | Show extra diagnostic info for each matched error | | |
| | `--lang <code>` | Output language (e.g. `hi`, `es`, `fr`) — available on `run` and `analyze` | | |
| ### Options | |
| | Flag | Description | | |
| |------|-------------| | |
| | `--json` | Output raw JSON (no colors, no boxes) — perfect for CI/CD pipelines | | |
| | `--theme <name>` | Pick a color theme (see the Color Themes section below) | | |
| | `--verbose` | Show extra diagnostic info for each matched error | | |
| | `--lang <code>` | Output language (e.g. `hi`, `es`, `fr`) — available on `run` and `analyze` | |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@README.md` around lines 110 - 117, Update the README heading above the
options table to avoid presenting --lang as a global option; rename the heading
to “Options” or separate command-local options from root-level options. Keep the
existing --json, --theme, --verbose, and --lang descriptions accurate while
making clear that --lang applies only to run and analyze.
…ADME - bin/index.js: add sanitizeMatches() to strip matchedText from JSON output (preserves existing JSON contract) - bin/index.js: use program.parseAsync() with .catch() for async action handlers - lib/auto.js: add safeStringify() that catches toString() throws on broken objects - lib/injector.js: add safeStringify() to both uncaughtException and unhandledRejection handlers - README.md: rename 'Global Options' to 'Options' (--lang is command-local, not global)
|
@coderabbitai review |
|
Summary
Closes #54
Adds color themes, verbose diagnostic mode, and overall CLI polish to ErrLens.
Changes
New: lib/themes.js
Updated: bin/index.js
Updated: lib/formatter.js
Updated: lib/auto.js and lib/injector.js
Updated: README.md
Testing
All existing functionality verified:
Summary by CodeRabbit
New Features
--theme,--verbose, and--langcommand-line options, plus environment configuration.Documentation