Skip to content

feat: add /doctor command to diagnose local environment and dependencies - #1154

Closed
MukeshVermaLegit wants to merge 9051 commits into
CodebuffAI:mainfrom
MukeshVermaLegit:main
Closed

feat: add /doctor command to diagnose local environment and dependencies#1154
MukeshVermaLegit wants to merge 9051 commits into
CodebuffAI:mainfrom
MukeshVermaLegit:main

Conversation

@MukeshVermaLegit

@MukeshVermaLegit MukeshVermaLegit commented Aug 30, 2026

Copy link
Copy Markdown

Summary

Adds a new /doctor slash command that helps users diagnose common issues with their local environment.

Closes #1119

Changes

  • New file: cli/src/commands/doctor.ts - Core diagnostic logic
  • New file: cli/src/commands/__tests__/doctor.test.ts - Unit tests
  • Modified: cli/src/commands/command-registry.ts - Register the command
  • Modified: cli/src/data/slash-commands.ts - Add command to slash menu

What it checks

The /doctor command (also invokable as /check or /health) checks:

  1. Platform and runtime - Shows OS, architecture, and Node.js/Bun version
  2. ripgrep (rg) - Required for code search functionality
  3. Git - Availability and repository status
  4. API connectivity - Tests connection to the backend
  5. tmux - Optional but recommended for multiplexing

Example output

Success case:

### Codebuff doctor

✅ All checks passed!

✅ **platform**: linux x64
✅ **runtime**: Bun 1.4.0
✅ **ripgrep (rg)**: Available
✅ **git**: Available
✅ **git repository**: Current directory is a git repository
✅ **tmux**: Available
✅ **API connectivity**: Connected to https://codebuff.com

With issues:

### Codebuff doctor

❌ 1 error(s), 1 warning(s) found

✅ **platform**: linux x64
✅ **runtime**: Bun 1.4.0
❌ **ripgrep (rg)**: ripgrep not found in PATH
   Install it:
     - macOS: brew install ripgrep
     - Ubuntu/Debian: sudo apt install ripgrep
✅ **git**: Available
⚠️ **tmux**: tmux not found
   tmux is optional but recommended for multiplexing...
✅ **API connectivity**: Connected to https://codebuff.com

### Recommendations

Fix the errors above to ensure full functionality.

Testing

All 7 tests pass (6 new tests for doctor command + 1 existing diagnostics test).

codebuff public sync bot added 30 commits August 25, 2026 10:46
Source: CodebuffAI/freebuff-private@e20dcb5811c89bc349a283c8fb8b474f03857eaa
Source: CodebuffAI/freebuff-private@1a9bb08ef45331c94cfa616a7e5f91dbc3375e7b
Source: CodebuffAI/freebuff-private@2204d7f013215d4a9746f87ccadb88422bdbf0ce
Source: CodebuffAI/freebuff-private@d85f7624f6df913150afd97028ce8034caf9401c
Source: CodebuffAI/freebuff-private@496a274da0db56d0465478154dbd368ead06dc33
Source: CodebuffAI/freebuff-private@2479764c0c4dc98e75a5c5778d29d10938b5997e
Source: CodebuffAI/freebuff-private@72cb80a710ca0b69c0ea1c92caa09449ae14ae23
Source: CodebuffAI/freebuff-private@00c76d2a5513197c7f5963463a1511ce8a4086d6
Source: CodebuffAI/freebuff-private@ae3b428c053013f6c40d893c785f6f383a1eefb7
Source: CodebuffAI/freebuff-private@1f928dbc1d0b1c4ae199f3b12111897300092931
Source: CodebuffAI/freebuff-private@23d94d0a7272b2c1460bb5576c0359cf0fe2765a
Source: CodebuffAI/freebuff-private@56076c9423fb9d6b185fb66d4ec7d7818c544aa4
Source: CodebuffAI/freebuff-private@7ac0799f05337a0df3eafe682e030544ce191d2f
Source: CodebuffAI/freebuff-private@2464fed8ca7d9730dfa2226e1c4267353c2b1e85
Source: CodebuffAI/freebuff-private@d6c79c09d66c9187499f37445a7f82a93ae674a1
Source: CodebuffAI/freebuff-private@db635212c3c95b5545a46afd2fffa3e0d345dd48
Source: CodebuffAI/freebuff-private@8602eeac5f86c63dcdf7051675bda726cc8e0b71
Source: CodebuffAI/freebuff-private@03bff2f48d6c40320acc1cb41ca389d222ac2baa
Source: CodebuffAI/freebuff-private@54215700121b04bef2a7857489eb2017d24a113f
Source: CodebuffAI/freebuff-private@4f4f9a6cd4e9c7aa793a32fcdc8438ced2a0f5a2
Source: CodebuffAI/freebuff-private@5f1f82c2fb2bcf95a01ffb6fc28ccfc25619a83e
Source: CodebuffAI/freebuff-private@9d8b240c6862ab9c5c720af7a1facbf85a48a877
Source: CodebuffAI/freebuff-private@1b960fe83deb21c87e4cb615d7789123361ac407
Source: CodebuffAI/freebuff-private@e8b8ef0c39f6e5fd0f1da7fe1d2704027dcbfb16
Source: CodebuffAI/freebuff-private@407268a57ca56f64b87013573c29bc72058fff28
Source: CodebuffAI/freebuff-private@a138234f7d9310b8d2a89a7f9e478badc2f1b3f3
Source: CodebuffAI/freebuff-private@f0d724e3249e82a81fe934e51aa36f8d20d211e2
Source: CodebuffAI/freebuff-private@344142df6218b6602860cfc57dad3cca639ab8fd
Source: CodebuffAI/freebuff-private@ff3695d0b8ae4522891b5384a877cef203c89c34
Source: CodebuffAI/freebuff-private@e66d73be0e1a8e4c453136e031edb6c817cceaeb
codebuff public sync bot added 16 commits August 31, 2026 03:02
Source: CodebuffAI/freebuff-private@70a710b1d0941b7bd3a742dbc8e18f276b602850
Source: CodebuffAI/freebuff-private@3535770948dfde40d9b53936ad8487a3dbb90893
Source: CodebuffAI/freebuff-private@bba508a9f359d5e49230c932ef03fdb733c18bff
Source: CodebuffAI/freebuff-private@741dcfc4f0fc1e7c33d4544fc5ce7259e851c920
Source: CodebuffAI/freebuff-private@d9a3b75bd429ea44aca483addec9b5a3e3bcc79e
Source: CodebuffAI/freebuff-private@b76209dd2ec3f278ef28660c239c4e484572d7b4
Source: CodebuffAI/freebuff-private@ff62cf3506968799272123e6f637cdee6935e48f
Source: CodebuffAI/freebuff-private@d6591b0c4986740a517395811b4fe9d6e5db47b2
Source: CodebuffAI/freebuff-private@87a991308dfe74c4e68cf07c4206d0fc63db1c8a
Source: CodebuffAI/freebuff-private@5c9444e7ef7993a29e064220ef46c3a58af12b7d
Source: CodebuffAI/freebuff-private@e40b501c923f0bd2f33749cf6f081d9e74b42282
Source: CodebuffAI/freebuff-private@a82256a7abc33584a5bb1be29fbbd9c67c2dd8d7
Source: CodebuffAI/freebuff-private@42d9d1db9a7b2895732d49ab7d6ce84162fc81d4
Source: CodebuffAI/freebuff-private@61c0ffffb152a9b77e2ecfcd3d8adb0e4e4cfb87
Source: CodebuffAI/freebuff-private@a40168234a220d145b5ff7cf702b6364184d7296
Source: CodebuffAI/freebuff-private@91527d25716d4282b0e454e92ecf8b2fc8c1c9f1
@codebuff-team

ghost commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Good instinct — a /doctor command that checks rg/git/tmux/runtime is genuinely useful and the output formatting in doctor.ts is clean and readable. Nice touch reusing IS_FREEBUFF for product-agnostic naming.

A few things that need fixing before this is portable:

  1. Tests hit the network. doctor.test.ts calls collectDoctorReport() directly, which internally calls checkConnectivity() and does a real fetch to ${websiteUrl}/api/healthz. In CI or any sandboxed/offline environment this will be slow (5s timeout) or fail outright. Unit tests should mock fetch (or inject the connectivity checker) rather than making a live call to production infra.

  2. Unverified endpoint. /api/healthz is assumed to exist. If the backend doesn't actually expose that route, this check will always report an error/timeout regardless of real connectivity, giving users false negatives. Please confirm the route exists (or use an endpoint the CLI already calls elsewhere, e.g. whatever getWebsiteUrl pairs with in the real auth/version check).

  3. Overlap with existing diagnostics. command-registry.ts already wires up collectProcessDiagnostics/formatProcessDiagnostics for a /diagnostics command. It's worth clarifying in the PR description how /doctor differs and whether the two should share checks (git/tmux availability, etc.) instead of duplicating logic.

  4. execSync calls with fixed command names (rg, git, tmux) are safe from injection since there's no user input, but they're still synchronous and block the event loop — fine for a one-shot CLI command, just worth noting if this pattern spreads.

Substance-wise this is portable once the test/network issues are addressed — the diagnostic logic itself is reasonable and well-organized.

@codebuff-team codebuff-team added bot:triaged Classified by the community triage bot pr:needs-work Right idea, not mergeable as written labels Aug 31, 2026
codebuff public sync bot and others added 6 commits August 31, 2026 17:00
Source: CodebuffAI/freebuff-private@09f98d52aaf28097b9509b34acdcd987ade63586
Source: CodebuffAI/freebuff-private@041104880304c80b39253ac43d4b6ffda95d0d65
Source: CodebuffAI/freebuff-private@59224af313776f1447bb0cd9908143c7c8c42014
Source: CodebuffAI/freebuff-private@e9ae9c9973b2a4201c679519104edbac24e18084
Source: CodebuffAI/freebuff-private@add9a3e8c175b5346ef9c0e1a210da2ce04c4847
- Mock fetch in tests to avoid network calls (addresses "Tests hit the network")
- Add connectivity check test to verify API endpoint usage
- Clarify /doctor vs /diagnostics difference in command description
- Restore test/setup-scm-loader.ts needed for test infrastructure

Closes CodebuffAI#1119

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@MukeshVermaLegit

ghost commented Aug 31, 2026

Copy link
Copy Markdown
Author

Addressed Reviewer Feedback

Thank you for the thorough review! Here's how I've addressed each point:

1. ✅ Tests hitting the network

Fixed: Mocked globalThis.fetch in all tests to avoid network calls. Tests now run in isolation without hitting the production API endpoint.

2. ✅ Unverified endpoint

Confirmed: The /api/healthz endpoint is already used by the SDK's checkConnection() method in sdk/src/client.ts. The doctor command uses the same endpoint, which is verified to exist.

3. ✅ Overlap with existing diagnostics

Clarified: Updated the command description to explicitly mention what /doctor checks: (rg, git, tmux, API). The existing /diagnostics command focuses on process diagnostics (CPU, memory, uptime, active tools), while /doctor focuses on environment/dependency checks. They serve different purposes and complement each other.

4. ✅ execSync calls (noted)

Acknowledged - these are synchronous but acceptable for a one-shot CLI command that runs infrequently.

Additional fix

Restored test/setup-scm-loader.ts which was accidentally deleted in a previous sync but is still referenced in cli/bunfig.toml. This was needed for the test suite to run.


All 11 tests pass (9 new doctor tests + 2 existing diagnostics tests), and typecheck passes (only pre-existing unrelated errors remain).

Generated with Codebuff 🤖
Co-Authored-By: Codebuff noreply@codebuff.com

Keep both doctor imports and new buildSkillPrompt import from upstream.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@victorxheng

ghost commented Aug 31, 2026

Copy link
Copy Markdown

Apologies — this PR was auto-closed by GitHub when we force-pushed a history rewrite of this repository (repository maintenance; every commit SHA changed). That was not a judgment on this PR, and GitHub does not allow us to reopen it because the commits it was based on no longer exist in the new history.

If you'd like to continue with this change: rebase your branch onto the new main (or recreate it from a fresh clone) and open a new PR — feel free to link back to this one for context, and we'll pick up the review there.

Sorry for the churn, and thanks for contributing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:triaged Classified by the community triage bot pr:needs-work Right idea, not mergeable as written

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add /doctor command to diagnose local environment and dependencies

3 participants