Skip to content

feat: CLI Polish - Color Themes, Verbose Mode, and Terminal UX - #97

Merged
naheel0 merged 4 commits into
BeyteFlow:mainfrom
naheel0:feat/cli-themes-verbose
Aug 10, 2026
Merged

naheel0 merged 4 commits into
BeyteFlow:mainfrom
naheel0:feat/cli-themes-verbose

Conversation

@naheel0

@naheel0 naheel0 commented Aug 8, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #54

Adds color themes, verbose diagnostic mode, and overall CLI polish to ErrLens.

Changes

New: lib/themes.js

  • 5 built-in color themes: default, minimal, high-contrast, dracula, monokai
  • Each theme defines colors for border, title, labels, fix markers, and more
  • resolveTheme() and isValidTheme() helpers for safe lookup

Updated: bin/index.js

  • --theme global flag — pick any built-in theme
  • --verbose global flag — show MATCH, LENGTH, KEY per error
  • Theme validation with clear error on invalid input
  • Both flags flow through to formatError()
  • All fallback output paths use theme colors (headerText, unknownText, rawText, errorText, signalText, successText)

Updated: lib/formatter.js

  • Accepts { theme, verbose } options object
  • Uses theme colors for all chalk calls (border, labels, fix markers, etc.)
  • Verbose mode appends match metadata inside the box

Updated: lib/auto.js and lib/injector.js

  • Read ERRLENS_THEME and ERRLENS_VERBOSE env vars
  • Runtime injection now supports themes without CLI flags
  • auto.js normalizes thrown objects via err.stack (matching injector.js behavior)

Updated: README.md

  • Documented --theme, --verbose, and env var options
  • Added Color Themes section with theme comparison table
  • Added Verbose Mode section
  • Updated Quick Start, Key Features, and Project Structure

Testing

All existing functionality verified:

  • --json output unchanged
  • --lang multilingual output unchanged
  • All 5 themes render without errors
  • --verbose adds diagnostic fields
  • Invalid theme shows available options
  • errlens run and errlens analyze both work with new flags

Summary by CodeRabbit

  • New Features

    • Added selectable color themes, including default, minimal, high-contrast, Dracula, and Monokai.
    • Added verbose diagnostics with expanded match and metadata details.
    • Added --theme, --verbose, and --lang command-line options, plus environment configuration.
    • Applied themed output consistently across errors, crashes, analysis results, and termination messages.
    • Improved matched-error display by showing the matched text.
  • Documentation

    • Expanded setup and CLI documentation with theme descriptions, verbose output details, and quick-start examples.

naheel0 added 2 commits August 9, 2026 00:04
- 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
Copilot AI lite review requested due to automatic review settings August 8, 2026 18:45
@naheel0
naheel0 requested a review from jaseel0 as a code owner August 8, 2026 18:45
@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 259937d1-9806-4424-9e87-6373014d5fca

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The CLI and runtime handlers now support five color themes and verbose diagnostics. Theme selection is validated case-insensitively. formatError accepts options, matched results include preserved text, and JSON output removes matchedText.

Changes

Theme and diagnostics

Layer / File(s) Summary
Theme configuration and resolution
lib/themes.js
Defines five themes and provides theme resolution and validation helpers.
Verbose formatting and match metadata
lib/matcher.js, lib/formatter.js
Preserves matched text and adds themed formatting with optional match metadata.
CLI theme and verbose integration
bin/index.js, README.md
Adds --theme and --verbose to run and analyze, applies themed output, sanitizes JSON matches, and documents the options.
Runtime error handler integration
lib/auto.js, lib/injector.js
Loads theme and verbose settings, normalizes thrown values, and formats uncaught errors and rejections with themed output.

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
Loading

Possibly related PRs

Suggested reviewers: jaseel0

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes implement themes, verbose diagnostics, themed formatting, JSON preservation, environment support, and README updates requested by issue #54.
Out of Scope Changes check ✅ Passed The changes remain within issue #54 scope and directly support CLI output, usability, compatibility, runtime handling, or documentation.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: color themes, verbose mode, and CLI terminal improvements.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added documentation Improvements or additions to documentation core cli labels Aug 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 --theme and --verbose global CLI flags and propagated options into formatted output.
  • Added ERRLENS_THEME / ERRLENS_VERBOSE support for auto/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.

Comment thread lib/formatter.js
Comment on lines +37 to 44
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}`;

Comment thread lib/themes.js
Comment on lines +113 to +123
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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0bdefff and e6ad0ae.

📒 Files selected for processing (7)
  • README.md
  • bin/index.js
  • lib/auto.js
  • lib/formatter.js
  • lib/injector.js
  • lib/matcher.js
  • lib/themes.js

Comment thread bin/index.js Resolved
Comment thread bin/index.js Resolved
Comment thread lib/auto.js Resolved
Comment thread README.md Outdated
Comment on lines +110 to +117
### 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` |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

Suggested change
### 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)
@naheel0

naheel0 commented Aug 10, 2026 •

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@naheel0
naheel0 merged commit 20b801f into BeyteFlow:main Aug 10, 2026
5 checks passed
@naheel0
naheel0 deleted the feat/cli-themes-verbose branch August 10, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli core documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🎨 CLI Polish: Improve ErrLens Terminal Output & User Experience

2 participants