Add ucode doctor command to diagnose and fix the local setup - #294
Open
max-rozen-oss-db wants to merge 3 commits into
Open
Add ucode doctor command to diagnose and fix the local setup#294max-rozen-oss-db wants to merge 3 commits into
ucode doctor command to diagnose and fix the local setup#294max-rozen-oss-db wants to merge 3 commits into
Conversation
Mirrors the `brew doctor` / `flutter doctor` / `npm doctor` pattern: run a series of independent checks, print a per-check status (✓/!/✗/•) with an actionable message, and for any problem ucode knows how to fix, prompt the user to apply the fix and report success/failure. Checks: - `uv` on PATH (needed to install/upgrade ucode) - `npm` on PATH (needed to install agent CLIs) - Databricks CLI installed, and its version vs the `databricks aitools` floor - Workspace configured - Each configured coding agent's CLI: installed and up to date - ucode's installed build (offers a reinstall-to-latest from GitHub) Each fix is opt-in — the command reads state until the user says yes to a specific suggestion, and a declined or non-interactive (piped) run changes nothing. Adds read-only public helpers so the doctor doesn't reach into privates: `databricks_cli_version` / `upgrade_databricks_cli` in databricks.py and `tool_binary_installed` / `tool_update_available` / `update_tool_binary` in agents/__init__.py. Co-authored-by: Isaac
Extends `ucode doctor` with three checks that target the most common real-world setup failures: - Databricks auth: validate the configured workspace's credentials up front (the usual launch failure is an expired/invalid token surfacing as a 403 from the agent). Offers to run `databricks auth login`. - Claude auth env collision: warn when `ANTHROPIC_AUTH_TOKEN` / `ANTHROPIC_API_KEY` is set in the environment, since it shadows the credential ucode configures for Claude Code. Advisory only — we can't unset a parent shell's env. - Tracing (mlflow CLI): when tracing is enabled, check the pinned `mlflow` CLI is installed and in range; offers to install it. The auth and tracing checks return None (and are skipped) when they don't apply — no workspace configured, or tracing disabled. Adds read-only public helpers `tracing_mlflow_ok` / `ensure_tracing_mlflow_cli` in agents/__init__.py so the doctor doesn't reach into agent internals. Co-authored-by: Isaac
# Conflicts: # README.md # tests/test_databricks.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
ucode doctor— a health check for the local ucode setup, modeled onbrew doctor/flutter doctor/npm doctor. It runs a series of independent checks, prints a per-check status line, and for any problem it knows how to fix, prompts to apply the fix and reports whether it worked.Checks
uvon PATHnpmon PATHdatabricks aitoolsfloorucode configuredatabricks auth login(the usual launch failure is an expired/invalid token surfacing as a 403 from the agent)ANTHROPIC_AUTH_TOKEN/ANTHROPIC_API_KEYin the envmlflowCLI, when tracing is enabledChecks that don't apply are skipped: credentials/tracing only run when a workspace is configured / tracing is enabled, and the env-collision check only appears when one of those vars is set.
Behavior
✓ <check>: fixedor! <check>: fix did not complete. A failed fix doesn't abort the run or the remaining checks.No problems detected.orN issues found; M fix(es) applied.).Example (healthy machine, piped so prompts default to no):
Implementation notes
New logic lives in
src/ucode/doctor.py;cli.pygets a thindoctorcommand wrapper. To avoid reaching into privates, added read-only public helpers:databricks.py:databricks_cli_version()(report-only, never upgrades) andupgrade_databricks_cli().agents/__init__.py:tool_binary_installed(),tool_update_available(),update_tool_binary(),tracing_mlflow_ok(),ensure_tracing_mlflow_cli().Testing
uv run pytest tests/test_doctor.py tests/test_databricks.py tests/test_cli.py— passing.uv run ruff check .anduv run ruff format --check src/ tests/— clean.tests/test_doctor.pycovers each check's classification (ok/warn/error + whether a fix is offered), the skip-when-not-applicable paths (no workspace, tracing disabled, env var unset/blank), and the doctor flow (applies on accept, skips on decline, reports failure without raising, never prompts on a healthy check).test_mcpordering assertion) fails identically onmain— pre-existing, not touched by this PR.