Skip to content

feat(cli): add doctor command for configuration validation#100

Open
garethpaul wants to merge 5 commits intomainfrom
feat/poe-code-doctor
Open

feat(cli): add doctor command for configuration validation#100
garethpaul wants to merge 5 commits intomainfrom
feat/poe-code-doctor

Conversation

@garethpaul
Copy link
Contributor

Summary

  • Adds poe-code doctor [agent] command that validates the full configuration stack — system directories, config integrity, API keys, agent binaries, config probes, and MCP config files
  • All agent checks are derived from provider config metadata with zero provider branching — no if/case on provider name
  • Implements proper TOML/JSON parsing for MCP config validation via smol-toml
  • Warns when an unknown agent is passed as argument
  • Full SDK parity: exports collectChecks, runChecks, and all types from src/index.ts

Check categories

Category Checks
System Home dir exists, config.json parseable, no corruption backups
Auth API key present, API key valid (HTTP validation)
Agent Binary on PATH, config probe exists, service configured
MCP Config file valid (JSON/TOML), config key present

New files (20)

  • src/sdk/doctor/ — types, checks (system/auth/agent/mcp), collector, runner, index
  • src/cli/commands/doctor.ts — CLI command + output formatting
  • e2e/doctor.test.ts — E2E tests in Docker

Test plan

  • 53 unit tests across 7 test files (system, auth, agent, mcp, collect-checks, run, doctor-command)
  • Full test suite passes (2503 tests, 252 files)
  • Lint passes
  • Screenshots validated (doctor, doctor --help)
  • E2E tests written (4 tests: system/auth checks, agent checks after configure, agent filtering, help text)
  • E2E tests pass in CI (requires Docker + POE_API_KEY)

Adds `poe-code doctor [agent]` to validate the full configuration
stack — system dirs, config integrity, API key, and per-agent binary,
config probe, and model checks. All agent checks are derived from
provider config with zero provider branching.

- System checks: home dir exists, config.json valid, no corruption backups
- Auth checks: API key present, API key valid (HTTP)
- Agent checks: binary exists, config probe, model configured
- Sequential execution with dependency skipping
- SDK exports: collectChecks, runChecks, DoctorResult types
- 42 unit tests across 6 test files
Address code review feedback:
- Rename to accurately reflect what the check does (validates service
  existence in configured_services, not model value)
- Use ScopedLogger type instead of inline shape in logCheckResult
- Provide proper previousResults map in run.test.ts stub context
Add MCP config validation derived from agent-mcp-config package:
- mcpConfigValidCheck: validates MCP config file exists and parses
- mcpCommandExistsCheck: verifies MCP server command binary on PATH
- Automatically discovers MCP config paths per agent
- Export AgentMcpConfig type and resolveConfigPath from agent-mcp-config
Verify doctor command in Docker container:
- System and auth checks run without configured agents
- Agent checks appear after configure
- Agent filtering works with positional argument
- Help text displays correctly
- Fix homeDirCheck description: "Home directory writable" → "Home directory exists"
- Remove dead mcpCommandExistsCheck (not wired into collectChecks)
- Add proper TOML parsing via smol-toml instead of just checking non-empty
- Warn when agent argument doesn't match any known provider
- Align TOML validation with JSON: check configKey presence, report parse errors
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