Skip to content

feat(cli): add doctor subcommand#3

Merged
sunjin12 merged 2 commits intomainfrom
feat/cli-doctor
Apr 20, 2026
Merged

feat(cli): add doctor subcommand#3
sunjin12 merged 2 commits intomainfrom
feat/cli-doctor

Conversation

@sunjin12
Copy link
Copy Markdown
Owner

Summary

  • New ossmate doctor subcommand — self-diagnoses the 6 most common first-run failures: Python version, ossmate install, gh CLI + auth, MCP server reachability (python -m ossmate_mcp --selftest), project-root detection, .ossmate/ artifact dir writability
  • Reports ✓/⚠/✗ with remediation hints via rich; --json flag for CI use
  • Exits 0 when healthy, 1 on any hard failure (warns don't trip exit)
  • Motivated by Phase 9 onboarding-friction review ("12 surfaces are overwhelming for new users")

Changes

  • cli/ossmate/src/ossmate/diagnostics.py (new) — 6 pure (project_root) -> CheckResult functions + run_all composer + render_pretty / render_json
  • cli/ossmate/src/ossmate/cli.py — wired doctor Typer subcommand (lazy import, no SDK round-trip)
  • tests/test_doctor.py (new) — 15 hermetic tests; tests/test_cli.py — added doctor to CLI-only allowlist (1 line)
  • CHANGELOG.md [Unreleased]/Added, README.md / README.en.md Quickstart troubleshooting line
  • No new dependenciesrich was already declared; first direct use in the CLI

Test plan

  • python -m pytest tests/ — 176 passed, ~13s (161 existing + 15 new)
  • python -m ossmate doctor --cwd <repo> — all 6 ✓, exit 0
  • python -m ossmate doctor --json --cwd <repo> — valid JSON schema, 6 checks
  • python -m ossmate doctor --cwd \$HOMEproject root ⚠, .ossmate writable ⚠ (skipped gracefully), exit 0
  • python -m ossmate --helpdoctor appears in subcommand list

🤖 Generated with Claude Code

sunjin12 and others added 2 commits April 20, 2026 13:12
Self-diagnoses the 6 most common first-run failures — missing Python 3.11+,
missing `ossmate` install, missing/unauthed `gh` CLI, broken MCP server,
missing `.claude/commands/`, `.ossmate/` permission errors. Reports
green/yellow/red with remediation hints; `--json` for CI. Exits 0 when
healthy, 1 on any hard fail. Motivated by Phase 9 onboarding-friction review.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Main's CI has been failing since Phase 7 (3 consecutive runs on main:
4ea7191 / a6787ea / f8fba38) from two independent bugs that the new
doctor PR surfaced:

1. tests/test_plugin_manifest.py::test_referenced_hook_scripts_exist
   The regex captured a trailing `\` from the JSON-escaped `\"` after each
   `${CLAUDE_PLUGIN_ROOT}/...` path. Windows pathlib normalized it away, so
   the bug was invisible locally; Linux/macOS pathlib treated `\` as a
   literal character and the existence check failed. Fix: exclude `\` from
   the regex character class.

2. Widespread ruff violations
   - B008 in cli.py (9x) — Typer's idiom calls `_common_*()` helpers in
     argument defaults, which is unavoidable. Added a per-file-ignore in
     cli/ossmate/pyproject.toml rather than uglifying the call sites.
   - E501 in cli.py (3x) — broken into multi-line `@app.command(...)` decls.
   - E741 in user_prompt_router.py (1x) — `l` → `lbl`.
   - F401 in three test files and I001 in several modules — ruff --fix.

Also drops a fragile `assert '--json' in result.output` from
test_help_lists_doctor: rich's help-table renderer wraps flag names across
ANSI sequences at narrow CI terminal widths, making the literal substring
match unreliable. The --json flag is still exercised end-to-end by
test_json_output_schema_via_clirunner.

Local: 176 passed, ruff all-clear.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sunjin12 sunjin12 merged commit 793b134 into main Apr 20, 2026
11 checks passed
@sunjin12 sunjin12 deleted the feat/cli-doctor branch April 20, 2026 04:30
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