Skip to content

Add rw config doctor command for configuration diagnostics#89

Merged
shadowhand merged 1 commit intomainfrom
claude/suggest-rw-commands-wXQOc
Apr 28, 2026
Merged

Add rw config doctor command for configuration diagnostics#89
shadowhand merged 1 commit intomainfrom
claude/suggest-rw-commands-wXQOc

Conversation

@shadowhand
Copy link
Copy Markdown
Contributor

@shadowhand shadowhand commented Apr 28, 2026

Resolves CL-4

Summary

Adds a new rw config doctor command that runs a fixed sequence of diagnostic checks against the active profile's configuration, credentials, and API connectivity. The command helps users identify and troubleshoot setup issues.

Key Changes

  • New doctor module (src/commands/config/doctor.rs): Implements four sequential checks:

    • profile: Verifies a profile is selected and resolves to an organization + stage
    • auth: Checks that stored credentials exist and (for bearer tokens) aren't expired
    • api: Makes a test request to GET /clinicians/me and reports HTTP status + latency
    • defaults: Lists configured default values (informational only)
  • Check status levels: Introduced CheckStatus enum with five states (Pass, Warn, Fail, Skip, Info) and visual glyphs (✓, ⚠, ✗, -, ℹ)

  • Structured output:

    • Plain text format shows a checklist with glyphs and messages
    • JSON format includes detailed metadata (latency, HTTP status, token expiry, etc.)
    • Sensitive data (tokens, passwords) is never included in output
  • Cascading logic: Later checks are skipped when earlier dependencies fail (e.g., API check skipped if auth check fails)

  • Direct HTTP client: Uses reqwest::Client directly instead of ApiClient to handle broken/missing config and surface non-2xx responses as check failures rather than errors

  • CLI integration: Added Doctor variant to ConfigCommands enum; updated config::dispatch to be async

  • Comprehensive tests: 72 test cases covering profile resolution, auth validation (basic + bearer tokens), API reachability, defaults listing, and integration scenarios

  • Documentation: Updated README with usage examples and check descriptions

Notable Implementation Details

  • Token expiry is checked against system time; expired tokens with refresh tokens warn rather than fail
  • Auth cache is loaded but tokens are never logged or serialized in output
  • API check measures and reports request latency in milliseconds
  • Command exits with non-zero status if any check fails (warnings don't fail)
  • Profile override via --profile flag is supported

https://claude.ai/code/session_01Fj5s8uKf3wiYXUF7oBJBFS

@shadowhand shadowhand added the feature New feature or request label Apr 28, 2026
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@shadowhand shadowhand force-pushed the claude/suggest-rw-commands-wXQOc branch from 5ec666e to debe8aa Compare April 28, 2026 12:27
devin-ai-integration[bot]

This comment was marked as resolved.

Runs four checks against the active profile (or `--profile`) and reports
each as pass/warn/fail/skip/info:

  1. profile  — resolves to organization + stage
  2. auth     — credentials exist and (for bearer) aren't expired
  3. api      — `GET /clinicians/me` returns 2xx, with status + latency
  4. defaults — lists configured `config default` keys (informational)

Later checks skip when an earlier dependency fails. Exits non-zero if
any check fails. Emits structured output under `--json`.
@shadowhand shadowhand force-pushed the claude/suggest-rw-commands-wXQOc branch from debe8aa to 9a77d13 Compare April 28, 2026 12:35
@shadowhand shadowhand merged commit f1d6563 into main Apr 28, 2026
4 checks passed
@shadowhand shadowhand deleted the claude/suggest-rw-commands-wXQOc branch April 28, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants