Skip to content

Conversation

@CybotTM
Copy link
Member

@CybotTM CybotTM commented Dec 7, 2025

Summary

This PR fixes the doctor command's config file detection and improves the getting-started experience:

  • Auto-detect config files: When --config is not specified, doctor now searches multiple locations:

    • ./ofelia.ini (created by ofelia init)
    • ./config.ini
    • /etc/ofelia/config.ini
    • /etc/ofelia.ini
  • Suggest ofelia init: When no config file is found, the error message now suggests running ofelia init and shows all searched paths

  • README documentation: Added documentation for both init and doctor commands

Problem

Previously, running ofelia init followed by ofelia doctor would fail because:

  1. init creates ./ofelia.ini by default
  2. doctor always checked /etc/ofelia/config.ini (hard-coded default)
  3. Users had no guidance on how to create a config file

Test Plan

  • Run ofelia doctor with ./ofelia.ini present → finds and validates it
  • Run ofelia doctor with no config anywhere → shows ofelia init suggestion
  • Run ofelia doctor --config=/custom/path → uses specified path
  • All existing doctor tests pass

Previously, doctor always checked /etc/ofelia/config.ini even when a
local ./ofelia.ini existed. This was frustrating for users who just
ran `ofelia init` and wanted to verify their setup.

Changes:
- Add config file auto-detection searching: ./ofelia.ini, ./config.ini,
  /etc/ofelia/config.ini, /etc/ofelia.ini (in priority order)
- Suggest `ofelia init` when no config file is found
- Show all searched paths in error hints for clarity
- Add README documentation for init and doctor commands

The doctor command now works seamlessly after running `ofelia init`,
improving the getting-started experience.
Copilot AI review requested due to automatic review settings December 7, 2025 12:51
@github-actions
Copy link

github-actions bot commented Dec 7, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions
Copy link

github-actions bot commented Dec 7, 2025

⚠️ Mutation Testing Results

Mutation Score: 0% (threshold: 60%)

⚠️ Score is below threshold. Consider improving test coverage or test quality.

What is mutation testing?

Mutation testing measures test quality by introducing small changes (mutations) to the code and checking if tests detect them. A higher score means better test effectiveness.

  • Killed mutants: Tests caught the mutation (good!)
  • Survived mutants: Tests missed the mutation (needs improvement)

Copy link

Copilot AI left a comment

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 enhances the doctor command's configuration file discovery and improves the getting-started experience by implementing automatic config file detection and better error messages. The changes address a workflow gap where ofelia init creates ./ofelia.ini but doctor previously only checked /etc/ofelia/config.ini.

Key changes:

  • Auto-detection searches 4 common locations in priority order: ./ofelia.ini, ./config.ini, /etc/ofelia/config.ini, /etc/ofelia.ini
  • Error messages now suggest running ofelia init and display all searched paths
  • Documentation added for both init and doctor commands in README

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
ofelia.go Removed pre-parsed ConfigFile initialization for DoctorCommand to enable auto-detection
cli/doctor.go Added commonConfigPaths list, findConfigFile() helper, and auto-detection logic in Execute(); updated error hints to suggest ofelia init
README.md Added "Interactive Setup" and "Health Diagnostics" sections documenting init and doctor commands with usage examples

Address Copilot review feedback:
- Fix README: change --config to --output for ofelia init command
- Track auto-detection state with configAutoDetected field
- Only show "Searched:" hint when auto-detection was attempted
- Add comprehensive tests for:
  - findConfigFile() with priority order verification
  - Auto-detection finds ./ofelia.ini
  - Auto-detection priority (first in list wins)
  - Auto-detection fallback when no config exists
  - Explicit --config bypasses auto-detection
@CybotTM CybotTM added this pull request to the merge queue Dec 7, 2025
Merged via the queue into main with commit 1651277 Dec 7, 2025
18 checks passed
@CybotTM CybotTM deleted the fix/doctor-init-improvements branch December 7, 2025 23:25
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.

2 participants