Skip to content

feat(doctor): auto-complete missing config fields with --fix - #380

Merged
Bahtya merged 2 commits into
mainfrom
feature/doctor-config-fix
May 14, 2026
Merged

feat(doctor): auto-complete missing config fields with --fix#380
Bahtya merged 2 commits into
mainfrom
feature/doctor-config-fix

Conversation

@Bahtya

@Bahtya Bahtya commented May 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add kestrel doctor --fix to detect and auto-complete missing config fields
  • Uses toml_edit to incrementally insert missing fields with Chinese comments, preserving existing formatting and values
  • New [5/5] Config completeness check in doctor

Changes

  • crates/kestrel-config/src/documented.rs — New module with all known scalar config fields, their default values and Chinese comments. Provides insert_missing_fields() and apply_fix() functions.
  • crates/kestrel-config/Cargo.toml — Add toml_edit = "0.22" dependency
  • src/commands/doctor.rs — Add 5th check for config completeness, --fix writes back commented TOML
  • src/main.rs — Add --fix flag to Doctor subcommand

Test plan

  • cargo clippy clean, no warnings
  • cargo fmt clean
  • CI passes on all platforms
  • kestrel doctor reports missing fields without modifying file
  • kestrel doctor --fix adds missing fields with Chinese comments
  • Running kestrel doctor again shows "All known fields present"

Bahtya

Bahtya added 2 commits May 14, 2026 19:47
Add `kestrel doctor --fix` that detects missing config fields and
inserts them with Chinese comments explaining each field's purpose.
Uses toml_edit to preserve existing formatting and values.

Bahtya
- Remove agent.provider from auto-insert (empty string would match
  empty-named provider at runtime)
- Replace dead check_and_fix() with lightweight check_missing() for
  read-only mode (avoids unnecessary TOML serialization)
- Write .toml.bak backup before overwriting config with --fix

Bahtya
@Bahtya
Bahtya merged commit 26051a7 into main May 14, 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.

1 participant