Skip to content

feat(cli): enrich ao doctor (#90)#99

Merged
harshitsinghbhandari merged 2 commits into
mainfrom
feat/enrich-ao-doctor-aa-46
Jun 3, 2026
Merged

feat(cli): enrich ao doctor (#90)#99
harshitsinghbhandari merged 2 commits into
mainfrom
feat/enrich-ao-doctor-aa-46

Conversation

@harshitsinghbhandari
Copy link
Copy Markdown
Collaborator

@harshitsinghbhandari harshitsinghbhandari commented Jun 3, 2026

Summary

Closes #90.

  • Add grouped ao doctor sections while keeping existing PASS/WARN/FAIL check lines.
  • Enrich tool checks with git version/minimum validation and zellij version/minimum messaging.
  • Add optional agent harness binary checks for the Go rewrite's configured harnesses (Claude Code and Codex) with version probes.
  • Add data-dir write probe and GitHub token validation via AO_GITHUB_TOKEN/GITHUB_TOKEN or gh auth token, including /user identity and OAuth scopes when available.
  • Extend --json output with section metadata and cover the new checks in CLI tests.

Validation

  • cd backend && go build ./...
  • cd backend && GOLANGCI_LINT_CACHE=$(mktemp -d) go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2 run --path-mode=abs ./internal/cli
  • cd backend && PATH=<go-only temp bin>:/usr/bin:/bin go test -race ./...

Note: per corrected brief, npx @redwoodjs/agent-ci run was not run.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 3, 2026

Greptile Summary

This PR significantly enriches ao doctor with grouped output sections, git version validation, optional agent harness probes (claude-code, codex), a data-dir write probe, and GitHub token validation that resolves from env vars or gh auth token and verifies identity against the GitHub REST API.

  • Section grouping: writeDoctorText tracks the current section header so checks are displayed under labeled groups (Core / Tools / Agent harnesses / GitHub) both in text and JSON (--json) output.
  • GitHub token check: checkGitHubToken resolves a token from AO_GITHUB_TOKEN, GITHUB_TOKEN, or gh auth token, calls GET /user, and reports the authenticated login and OAuth scopes. The DoctorGitHubRESTBase is moved from a mutable package-level variable into the Deps value type, eliminating the previously identified data-race risk.
  • Test isolation: clearDoctorGitHubEnv (including GH_TOKEN) and the new GH_CONFIG_DIR override in the e2e helper prevent real credentials from interfering with test runs.

Confidence Score: 5/5

Safe to merge; the new checks are read-only diagnostics with no side effects beyond a temporary write-probe file that is immediately deleted.

All new code paths are diagnostic-only. Token handling is correct (trimmed, sent over TLS, not logged), response bodies are properly drained via defer, version comparisons use strconv.Atoi with error propagation, and test isolation is thorough. The only open question is whether Aider/OpenCode harnesses were intentionally deferred.

backend/internal/cli/doctor.go — specifically the doctorHarnesses slice, which lists only two of the four harnesses named in the PR description.

Important Files Changed

Filename Overview
backend/internal/cli/doctor.go Major enrichment of ao doctor: adds section grouping, git version validation, harness probes, write-probe for data-dir, and GitHub token validation with HTTP identity check. Implementation is solid; Aider and OpenCode harnesses mentioned in the PR description are absent from doctorHarnesses.
backend/internal/cli/doctor_test.go Comprehensive new unit tests for all added checks; refactors shared setup into doctorContext / githubDoctorServer helpers with proper env isolation via clearDoctorGitHubEnv (now including GH_TOKEN).
backend/internal/cli/e2e_test.go Strips GITHUB_TOKEN, GH_TOKEN, and GH_CONFIG_DIR from the child process environment and injects an isolated GH_CONFIG_DIR, preventing real credentials from leaking into e2e ao doctor runs.
backend/internal/cli/root.go Adds DoctorGitHubRESTBase to the Deps value type, eliminating the previously flagged mutable package-level variable and making the GitHub REST base fully injectable per-context.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[ao doctor] --> B[runDoctor]
    B --> C[Core Section]
    C --> C1[config check]
    C --> C2[data-dir check]
    C2 -->|pass| C3[data-dir-write probe]
    C --> C4[sqlite / checkStore]
    C --> C5[daemon / inspectDaemon]
    B --> D[Tools Section]
    D --> D1[checkGit - git --version - compare >= 2.25.0]
    D --> D2[checkZellij - zellij --version]
    B --> E[Agent harnesses Section]
    E --> E1[checkHarness: claude-code]
    E --> E2[checkHarness: codex]
    B --> F[GitHub Section]
    F --> F1{githubToken}
    F1 -->|AO_GITHUB_TOKEN or GITHUB_TOKEN| F2[use env token]
    F1 -->|gh binary found| F3[gh auth token]
    F1 -->|none| F4[WARN: no token]
    F2 --> F5[GET /user Bearer token]
    F3 --> F5
    F5 -->|200| F6[PASS: login + scopes]
    F5 -->|401/403| F7[FAIL: rejected]
    F5 -->|other| F8[WARN: unexpected status]
    B --> G[writeDoctorText or JSON encode]
Loading

Reviews (2): Last reviewed commit: "fix(cli): address doctor review feedback" | Re-trigger Greptile

Comment thread backend/internal/cli/doctor.go Outdated
Comment thread backend/internal/cli/doctor.go Outdated
Comment thread backend/internal/cli/doctor.go
Comment thread backend/internal/cli/doctor_test.go
Comment thread backend/internal/cli/doctor.go
@harshitsinghbhandari harshitsinghbhandari merged commit 210c9df into main Jun 3, 2026
7 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.

Port missing CLI commands from original AO (read + lifecycle surface)

1 participant