Skip to content

feat: add optional semantic color to discovery output#177

Merged
kioku merged 5 commits intomainfrom
175/semantic-discovery-colors
Apr 17, 2026
Merged

feat: add optional semantic color to discovery output#177
kioku merged 5 commits intomainfrom
175/semantic-discovery-colors

Conversation

@kioku
Copy link
Copy Markdown
Owner

@kioku kioku commented Apr 17, 2026

Summary

  • add a centralized DiscoveryStyle module for semantic ANSI styling
  • apply optional color to human-facing discovery surfaces (overview, commands, docs, API landing, config api add, and search)
  • gate color by stdout TTY and NO_COLOR, while keeping machine/JSON output uncolored
  • add tests for colored rendering, NO_COLOR disablement, and ANSI-free structured output

Validation

  • cargo test
  • cargo fmt --all --check
  • cargo clippy --all-targets --all-features -- -D warnings

Closes #175

@kioku
Copy link
Copy Markdown
Owner Author

kioku commented Apr 17, 2026

Implementation plan used for this PR (/tmp/plans/aperture-175.md):

Plan
# Issue 175 Implementation Plan

## Summary
Add optional semantic ANSI color to human-facing discovery and onboarding output while keeping structured/machine output uncolored. Color should be centralized, TTY-aware, and disabled when `NO_COLOR` is set.

## Branch
`175/semantic-discovery-colors`

## Implementation Steps
1. Add a centralized discovery styling module (`src/discovery_style.rs`) with:
   - semantic style roles (API title, headings, metadata, next-step labels, HTTP methods, required markers, success/warning)
   - ANSI rendering helpers
   - enablement detection based on `stdout` TTY and `NO_COLOR`
   - unit tests for enablement and rendering behavior
2. Thread optional style support through discovery formatters:
   - update `src/docs.rs` to support styled rendering for overview/reference/docs/help list output
   - keep plain-text generation behavior available for non-colored paths/tests
   - ensure paths/payload-like text remain unstyled
3. Apply style usage in CLI command handlers for required surfaces:
   - `src/cli/commands/docs.rs` (`overview`, `commands`, `docs` text modes)
   - `src/cli/commands/api.rs` landing output next-step guidance
   - `src/cli/commands/config.rs` `config api add` success/partial acceptance/next-step labels
   - `src/search.rs` / `src/cli/commands/search.rs` minimal semantic styling for human-readable results
4. Add/adjust tests to satisfy acceptance criteria:
   - colored TTY case (formatter rendered with forced-enabled style)
   - `NO_COLOR` case (style detection test)
   - machine-output case (assert no ANSI escapes in JSON/structured output)
5. Run targeted tests and full quality gate (`cargo test && cargo fmt && cargo clippy`), then fix any regressions.

## Testing Approach
- Targeted unit/integration tests:
  - discovery style module tests for TTY and `NO_COLOR` behavior
  - docs/search formatting tests for styled output (escape sequences present when style enabled)
  - structured output tests ensuring JSON remains parseable and uncolored
- Full project validation:
  - `cargo test`
  - `cargo fmt --all --check`
  - `cargo clippy --all-targets --all-features -- -D warnings`

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 17, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 93.70861% with 19 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/cli/commands/docs.rs 26.08% 17 Missing ⚠️
src/docs.rs 98.57% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@kioku kioku merged commit 528619c into main Apr 17, 2026
9 checks passed
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.

ux: add optional semantic color to human-facing discovery output

2 participants