Skip to content

feat: extract doctor health-check system into shared crate#569

Merged
matt2e merged 3 commits intomainfrom
doctor
Apr 1, 2026
Merged

feat: extract doctor health-check system into shared crate#569
matt2e merged 3 commits intomainfrom
doctor

Conversation

@matt2e
Copy link
Copy Markdown
Contributor

@matt2e matt2e commented Apr 1, 2026

Summary

  • Extracts the doctor health-check system from the Tauri app (apps/staged/src-tauri/src/doctor.rs) into a standalone shared crate (crates/doctor/)
  • Organizes checks into dedicated modules: types, checks, agents, and resolve
  • Closes a shell injection vector in doctor fix execution by using safe command construction
  • Addresses code review findings across the doctor crate and UI

Test plan

  • Verify all existing doctor checks still pass (git, gh, git-lfs, AI agents)
  • Confirm fix commands execute safely without shell injection risk
  • Validate UI displays check results correctly via updated Tauri commands

🤖 Generated with Claude Code

matt2e and others added 3 commits April 1, 2026 12:52
Create a new crates/doctor/ crate containing the health-check system
for verifying external tool dependencies (git, gh, git-lfs, AI agents,
etc.). The crate exposes:

- types: CheckStatus, DoctorCheck, DoctorReport, FixType, ResolvedBinary
- resolve: binary resolution via login shell and common install paths
- checks: individual health-check functions for git, gh, gh-auth, git-lfs, clonefile
- agents: AI agent checks (goose, claude, codex, pi, amp) and fix command lookup
- run_checks(): async orchestrator that runs all checks in parallel
- execute_fix(): lookup-based fix execution by check ID and fix type
- execute_command(): raw command execution for backward compatibility

The Staged app's doctor.rs is replaced with thin Tauri command wrappers
that delegate to the crate. The existing frontend API (run_doctor_fix
accepting a raw command string) is preserved via execute_command().

The new FixType/fix_type fields on DoctorCheck are additive — the
frontend will simply ignore the extra camelCase JSON field until it
adopts the new API.
Replace the raw command string pattern in the Staged app's doctor fix
flow with the secure check-ID + fix-type pattern already used by goose2.

Backend (doctor.rs):
- Import and re-export FixType from the doctor crate
- Change run_doctor_fix signature from (command: String) to
  (check_id: String, fix_type: FixType)
- Delegate to doctor::execute_fix which looks up the command from
  static definitions server-side

Frontend (commands.ts):
- Add fixType field to DoctorCheck interface
- Update runDoctorFix to accept (checkId, fixType) instead of a raw
  command string

UI (DoctorCheckRow.svelte):
- Fix button visibility now checks check.fixType instead of
  check.fixCommand
- confirmFix sends check.id and check.fixType instead of
  check.fixCommand
- fixCommand remains as a display-only field in the ConfirmDialog

Crate (doctor/src/lib.rs):
- Make execute_command pub(crate) since it is an internal primitive
  and execute_fix is the intended public API
- Narrow fixType parameter from string to 'command' | 'bridge' union
  for compile-time safety in commands.ts
- Gate fix button on both fixType and fixCommand to prevent null
  message in ConfirmDialog when fixCommand is absent
- Extract duplicated clonefile fix command string into a shared
  pub(crate) const to prevent drift between check and lookup

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@matt2e matt2e requested review from baxen and wesbillman as code owners April 1, 2026 03:54
@matt2e matt2e merged commit bfce292 into main Apr 1, 2026
6 checks passed
@matt2e matt2e deleted the doctor branch April 1, 2026 04:00
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