Skip to content

feat: add diagnostic hints and suggestions system#362

Open
RAprogramm wants to merge 40 commits intomainfrom
feature/diagnostics
Open

feat: add diagnostic hints and suggestions system#362
RAprogramm wants to merge 40 commits intomainfrom
feature/diagnostics

Conversation

@RAprogramm
Copy link
Owner

@RAprogramm RAprogramm commented Jan 23, 2026

No description provided.

Adds rich diagnostic capabilities inspired by compiler diagnostics:
- Hint: contextual advice explaining errors
- Suggestion: actionable fixes with optional commands
- DocLink: documentation URLs
- DiagnosticVisibility: dev/staging/prod filtering
- Colored output in Local mode
- Zero-cost when unused (Option<Box<Diagnostics>>)
Add a CLI tool to help Rust learners understand compiler errors:
- `masterror check` - runs cargo check with friendly explanations
- `masterror explain E0382` - explains specific error codes
- `masterror list` - lists known error codes by category

Features:
- Multi-language support (en, ru)
- Colored terminal output with NO_COLOR support
- Knowledge base for common errors (E0382, E0308, E0502, E0499, E0106, E0597)
- Direct links to official Rust documentation
Example project with intentional Rust errors (E0382, E0502, E0499)
to test masterror-cli functionality.

Excluded from workspace to avoid CI failures on intentional errors.
- Refactor into modules: commands, knowledge, locale, output, parser, sections
- Add multi-language support (en, ru, ko) as cargo features
- Add display section toggles (why, fix, link, translation) as features
- Add show-original feature to optionally display compiler output
- Translate full compiler error messages for non-English locales
- Add pre-commit checks: actionlint, no_std compatibility
- Add cargo-masterror binary for `cargo masterror` usage
- Add PKGBUILD and .SRCINFO for AUR distribution
- Add errors module with 6 categories: Ownership, Borrowing, Lifetimes, Types, Traits, Resolution
- Add raprogramm module with 15 best practices (RA001-RA015) from RustManifest
- Add practice command to list and show best practices
- Extend explain command to handle both E* and RA* codes
- Remove legacy knowledge.rs, use LocalizedText for i18n
- Unify output formatting for errors and practices
- Expand cli-test-errors example with more error cases
- Remove masterror-cli from workspace
- Remove examples/cli-test-errors
- Add link to https://github.com/RAprogramm/masterror-cli in README
RAprogramm and others added 21 commits January 24, 2026 11:41
- masterror-knowledge: compiler error explanations database
  - 31 rustc errors (E0xxx) with translations (en/ru/ko)
  - 15 best practices (RA001-RA015)
  - i18n system with zero-allocation static strings

- masterror-cli: cargo subcommand for error explanations
  - `cargo masterror check` - check with explanations
  - `masterror explain E0502` - explain specific error
  - `masterror init` - interactive setup with first-run detection
  - Layered config: CLI args > env > .masterror.toml > global

- Feature `knowledge` in masterror re-exports the knowledge crate
- Add changes job with dorny/paths-filter for file change detection
- Compute dependency graph: template→derive→masterror, knowledge→cli
- Skip jobs when no relevant changes detected
- Add masterror-knowledge and masterror-cli to CRATES publish list
- Update release workflow to use $CRATES variable
- Fix no-std tests to only check masterror crate
- Add Step Summary with change detection table
- Fix rustdoc warning for private InlineVec link
- constructors.rs: new, with, bare
- modifiers.rs: with_code, with_retry_after_secs, with_www_authenticate, redactable
- metadata.rs: with_field, with_fields, redact_field, with_metadata
- context.rs: with_context, with_source, with_source_arc, with_backtrace
- details.rs: with_details_json, with_details, with_details_text
- diagnostics.rs: with_hint, with_suggestion, with_docs, with_related_code
- tests.rs: comprehensive tests for all builder methods (42 tests)

Also fix doctest in masterror-knowledge using correct crate name
- mod.rs: module exports and public interface
- mode.rs: DisplayMode enum and detection
- helpers.rs: write_json_escaped, write_metadata_value
- prod.rs: production JSON formatting
- local.rs: human-readable local/dev formatting
- staging.rs: staging JSON with context
- tests.rs: 49 comprehensive display tests
- mod.rs: module documentation and style re-export
- std_style.rs: color styling with owo_colors (std feature)
- nostd_style.rs: passthrough styling for no-std
- tests.rs: 23 comprehensive tests for both variants
- Add tests for hints, suggestions, doc links, related codes in local format
- Improve local.rs coverage from 46% to 92%
- Note: env-based mode detection tests omitted due to #![deny(unsafe_code)]
- Add README.md for masterror-knowledge with learning curve image
- Add masterror-knowledge to workspace crates table
- Update masterror-cli description with install instructions
- Add CLI links to Russian and Korean READMEs
Add comprehensive tests for:
- inline_vec: all storage variants, iterators, mutations
- metadata: field types, redaction, serialization
- app_code: hash, equality, parsing edge cases
- kind: all variants for http_status and label
- result_ext: context preservation, error wrapping
- response/problem_json: metadata sanitization, redaction
The local format was outputting "Error: {kind}" but AppErrorKind's Display
already provides the formatted kind label. This caused duplicate "Error:"
when users added their own prefix.
- Unified colored/plain display formatting in local.rs using
  conditional style module import (removes ~100 lines)
- Replaced repetitive nostd_style functions with identity_style macro
  (reduces 82 lines to 30)

Total reduction: ~78 lines of duplicated code
- Added write_metadata_json helper function
- Removed duplicate metadata formatting from prod.rs and staging.rs
- Reduces code by ~10 lines while improving maintainability
Replace 12 repetitive identity functions with macro invocation.
Reduces code by 34 lines.
Replace 8 repetitive match arms with reuse of existing methods.
Reduces code by 67 lines.
- Add print_title, print_category_header, print_code_title, print_label,
  print_dimmed helper functions
- Refactor list.rs and practice.rs to use shared helpers
- Eliminates repeated if colored { ... } else { ... } pattern
- Add MockServer test helper for reqwest tests (replaces 8 TCP setup copies)
- Unify colored style tests with test_style_produces_output macro
- Unify nostd style tests with test_style_returns_plain macro
- Extract generic extract_single_attr for attribute parsing
- Consolidate variant_pattern with binding parameter
- Add shared fmt_wrapper method for display test wrappers
- Add tokio io-util feature for test async I/O
- Add write_json_header helper for JSON formatting (prod/staging)
- Add make_timeout_error helper for tokio tests
- Remove duplicated message encoding logic from prod.rs and staging.rs
RAprogramm and others added 11 commits February 2, 2026 10:09
- Reformat backtrace output: → function at file:line
- Add colored styling for backtrace (arrow, function, location)
- Add clickable hyperlinks (editor:// scheme) for terminal support
- Unify Display impl using fmt_local from display module
- Update READMEs with accurate output examples and WezTerm config
- Use let-else pattern instead of map_err chains
- Simplify InlineVec::IntoIter to delegate to Vec::IntoIter
- Add ExactSizeIterator and DoubleEndedIterator for IntoIter
- Add optional `phf` dependency for compile-time perfect hash maps
- Conditionally use phf::Map or slice-based linear search
- Update README with new feature in feature list
- masterror-derive and masterror-template now optional deps
- New "derive" feature (enabled by default)
- Without derive: 28 deps vs 34 with derive
- Fix broken intra-doc link in masterror-rustc
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.

1 participant