Commit d422395
feat(azure.ai.agents): wire azd ai agent doctor command
Lands Phase 4.4 of PR Azure#8057: the user-facing `azd ai agent doctor`
command. Wires the existing doctor package (runner + 6 local checks
from 4.3 / 4.3.1) into Cobra, adds the text/JSON formatters, and
emits a TTY-gated trailing Next: block when all checks pass.
What the user sees
$ azd ai agent doctor
azd ai agent doctor
✓ PASS azd extension reachable
azd extension reachable (version 0.1.29-preview).
✓ PASS azure.yaml present and parseable
azure.yaml parsed (project: <name>).
[...]
✓ PASS agent.yaml valid (per service)
agent.yaml valid for 1 service(s)
Summary: 6 passed, 0 failed, 0 skipped, 0 warned
Next:
azd ai agent invoke <agent> '{"message": "Hello!"}'
↳ invoke the deployed agent
$ azd ai agent doctor --output json
{"schemaVersion":"1.0","remote":false,"redacted":true,"checks":[...]}
$ azd ai agent doctor --output yaml
ERROR: invalid --output value "yaml" (must be 'text' or 'json')
Architecture
- Formatters live in the cmd package, not the doctor subpackage.
The doctor package owns checks + runner only; its types.go
package doc (lines 17-19) explicitly places Cobra wiring and
IO in the parent package.
- doctor.go is the Cobra factory + flag-handling layer; runDoctor
is the testable core (no Cobra ref).
- Exit codes use os.Exit direct (azdext.Run only emits 0 / 1; the
runner's 3-state contract requires explicit os.Exit(2) for the
all-skip case).
- Trailing Next: block: only on exit code 0 (passes + no fails),
only in text output, only on TTY. JSON envelope deliberately
excludes it per the design spec.
- Branch on services: any IsDeployed → filtered ResolveAfterDeploy;
else → ResolveAfterInit. Filtering required because
ResolveAfterDeploy emits show+invoke for every state.Service
unconditionally — mixed deployed/undeployed projects would
otherwise emit broken commands.
What's new
- internal/cmd/doctor.go (+250) — Cobra factory, doctorFlags,
validateDoctorFlags, runDoctor, resolveDoctorTrailing, helpers
(anyServiceDeployed, filterDeployedServices, doctorCachedPayload,
doctorReadmeExists).
- internal/cmd/doctor_format.go (+170) — renderDoctorReport
(output dispatcher), printDoctorReportJSON (envelope),
printDoctorReportText (per-check + summary + trailing Next:),
statusGlyphAndLabel (✓/✗/!/-/?).
- internal/cmd/doctor_format_test.go (+290) — 32 subtests covering
JSON envelope shape, text rendering for pass/fail/skip mixes,
trailing block gating, output-flag routing, glyph mapping, flag
validation, deployed-service filtering.
- internal/cmd/root.go (+1) — rootCmd.AddCommand(newDoctorCommand()).
- cli/azd/.vscode/cspell.yaml (+9) — file-scoped overrides for
doctor.go (nextsteps, undeployed) and doctor_format.go (nextsteps,
UNKN), following the existing per-file override convention.
Pre-flight
✓ gofmt -s clean
✓ go vet clean
✓ go build clean
✓ Full extension cmd tests pass (13.5s)
✓ doctor + nextstep tests pass
✓ golangci-lint 0 issues
✓ cspell 0 issues on new files
Live smoke against the deployed hello-world-python-invocations sample
✓ `azd ai agent doctor` → 6 PASS, exit 0, raw bytes show correct
\r\n\r\n separator between checks and Summary (PowerShell mojibake
on ✓ glyph is console-encoding only; the bytes are valid UTF-8)
✓ `azd ai agent doctor --output json` → well-formed envelope with
schemaVersion 1.0, all 6 checks, no nextStep field
✓ `azd ai agent doctor --output yaml` → exit 1 + clear validation
error
✓ `azd ai agent doctor --help` → full help text with three flag
explanations and exit-code table
Not in scope (deferred to Phase 5)
- --local-only is a no-op; every shipped check is local today.
The flag is exposed early so the Cobra surface locks without
churn when remote checks land.
- --unredacted is reserved for the remote-checks pass.
- Trailing Next: cachedPayload / readmeExists closures pull from
the agent.yaml service path and the .azure/<env> directory;
further refinements (e.g., README detection priority,
cross-platform path handling) can land in a follow-up if
smoke testing surfaces issues.
References
- PR Azure#8057 design spec section "Phase 4 — doctor command, local
checks 1–6" + "Doctor output shape" + "Exit codes & JSON output".
- doctor package contract: internal/cmd/doctor/types.go,
runner.go (ExitCode at lines 171-179).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 7567546 commit d422395
5 files changed
Lines changed: 828 additions & 0 deletions
File tree
- cli/azd
- .vscode
- extensions/azure.ai.agents/internal/cmd
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
415 | 423 | | |
416 | 424 | | |
417 | 425 | | |
| |||
Lines changed: 297 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
0 commit comments