# Tasks — CLI-067: diagnose accuracy — runtime-resolution reuse + both settings levels + exit policy

Spec: `.agents/spec-docs/active/CLI-067-diagnose-accuracy.md`
Test Plan SSOT: the spec's TC table.

- [x] T1 (TC-01): provider check reuses `readProviderSettings` (settings → env-default,
      injected env) — profile with resolvable `$ENV:` reference → ✓ naming the settings
      source; exit 0.
- [x] T2 (TC-02): no profile + recognized env key (injected) → ✓ naming env-default source
      and the env var name — diagnose agrees with CLI-066 runtime synthesis.
- [x] T3 (TC-03): no profile + no env key → ✗ carrying the runtime's own
      `ProviderConfigError` guidance; returned issue count > 0 (exit 1 at dispatch).
- [x] T4 (TC-04): settings check iterates ALL `getProviderSettingsPaths(cwd)` entries —
      corrupt user-level `~/.robota/settings.json` (isolated HOME) flagged invalid JSON
      with its path even when a valid project file exists; issue counted.
- [x] T5 (TC-05): `runDiagnoseCommand` returns the fail count; `cli.ts` dispatch maps
      count > 0 → `process.exitCode = 1`, otherwise 0 (exit-code matrix test).
- [x] T6 (TC-06): full diagnose output never contains the key value (injected known key,
      output scan assertion).
- [x] T7 (TC-07): `packages/agent-cli/docs/SPEC.md` documents the diagnose checks and the
      0/1 exit contract.
- [x] T8: wrap-up — package test/typecheck/lint/build green; PR to develop (squash);
      backlog scenario evidence + move to completed/.

## Test Plan

Authoritative TC table: `.agents/spec-docs/active/CLI-067-diagnose-accuracy.md` (## Test
Plan). Summary: TC-01..TC-06 via `diagnose-command.test.ts` (injected env + temp HOME/cwd
fixtures, fake network dep); TC-05 also covers the `cli.ts` dispatch exit mapping; TC-07 via
SPEC.md diff review at GATE-COMPLETE. User-execution scenario: real binary
`robota diagnose; echo $?` with configured profile (--api-key-env) and env set.
