Skip to content

feat: add Coderrr Doctor diagnostic tool#127

Merged
Akash-nath29 merged 3 commits intodevfrom
feature
Jan 30, 2026
Merged

feat: add Coderrr Doctor diagnostic tool#127
Akash-nath29 merged 3 commits intodevfrom
feature

Conversation

@Akash-nath29
Copy link
Owner

This pull request introduces a new diagnostic tool called "Coderrr Doctor" for checking and reporting on the local development environment. It adds both the core logic for environment checks and a user-friendly CLI output, along with basic documentation and initial test coverage.

The most important changes are:

Core Diagnostic Logic:

  • Added the CoderrrDoctor class in src/doctor.js to check for environment file presence, Python installation, Node.js version, and backend connectivity.

User Interface and Reporting:

  • Implemented a CLI diagnostic UI in src/doctorUI.js that runs checks, displays colored status messages, and provides advice if backend connectivity fails.
  • Added a helper in src/utils/doctorHelpers.js to generate a formatted diagnostic report for potential export.

Documentation:

  • Added docs/doctor.md with usage instructions for the new coderrr doctor command.

Testing:

  • Introduced a basic test in test/doctor.test.js to verify Node.js version detection in the doctor module.

Copilot AI review requested due to automatic review settings January 30, 2026 20:59
@vercel
Copy link

vercel bot commented Jan 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
coderrr-backend Ready Ready Preview, Comment Jan 30, 2026 8:59pm

@github-actions
Copy link

🚀 Thanks for opening a Pull Request!

A maintainer will review this soon.

Meanwhile:
✔ Ensure tests are passing
✔ Link related issues
✔ Code follows the project guidelines

Your contribution helps make this project better!

@Akash-nath29 Akash-nath29 merged commit 7d1e588 into dev Jan 30, 2026
35 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces the “Coderrr Doctor” diagnostics feature to help users verify their local environment (Node, Python, .env, and backend connectivity), exposes it via a new CLI command, and adds initial documentation and tests.

Changes:

  • Added CoderrrDoctor core module (src/doctor.js) providing environment checks for .env, Python, Node.js, and backend reachability.
  • Implemented a user-facing diagnostics CLI UI (src/doctorUI.js) wired into the main CLI entrypoint (bin/coderrr.js) as coderrr doctor.
  • Added a basic Jest test for Node version detection and a helper for generating a summarized diagnostics report, plus a brief usage doc page (docs/doctor.md).

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/doctor.js Implements the core diagnostic checks (env file presence, Python version detection, Node version reporting, and backend connectivity using fetch).
src/doctorUI.js Provides a chalk-based CLI UI that runs the doctor checks, prints per-check status, and advises the user when backend connectivity fails.
src/utils/doctorHelpers.js Adds a small helper to generate a timestamped, high-level diagnostics report string from aggregated check results.
bin/coderrr.js Registers the new doctor subcommand and wires it to runDiagnostics, passing through process.env.CODERRR_BACKEND for backend checks.
test/doctor.test.js Introduces a Jest test that asserts checkNode returns a truthy status and a version string containing the Node v prefix.
docs/doctor.md Documents the new coderrr doctor command with a short description and a usage example.

Comment on lines +5 to +8
## Usage
Run the following to check your setup:
```bash
coderrr doctor No newline at end of file
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation code block is missing a closing triple backtick, which will cause the coderrr doctor snippet to render incorrectly in many Markdown viewers. Please add a terminating code fence on a new line after the coderrr doctor command so the example displays as a proper fenced code block.

Copilot uses AI. Check for mistakes.
Comment on lines +3 to +9
describe('Doctor Module', () => {
test('should detect node version', () => {
const node = doctor.checkNode();
expect(node.status).toBe(true);
expect(node.version).toContain('v');
});
}); No newline at end of file
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Doctor Module tests only cover checkNode, but the new diagnostics feature also introduces checkEnv, checkPython, checkBackend, the CLI UI in doctorUI.js, and the report helper in utils/doctorHelpers.js, none of which have any tests despite other modules in this project (e.g., insights and CLI commands) having Jest coverage. To keep diagnostics reliable and prevent regressions, consider adding unit tests that exercise these additional checks (including failure paths, e.g., missing .env or unreachable backend) and at least one test around the doctor CLI command wiring.

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +16
try {
const version = execSync('python --version').toString().trim();
return { status: true, version };
} catch {
return { status: false, version: 'Not found' };
}
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkPython only attempts to run python --version, which will incorrectly report status: false on systems where only python3 is installed (common on many Linux distros) even though a suitable Python 3 runtime is available for the backend. To avoid false negatives in the diagnostics, consider falling back to python3 --version (and possibly py -3 --version on Windows) if the initial python invocation fails, and include which binary was detected in the version string or result payload.

Suggested change
try {
const version = execSync('python --version').toString().trim();
return { status: true, version };
} catch {
return { status: false, version: 'Not found' };
}
const candidates = ['python --version', 'python3 --version'];
if (process.platform === 'win32') {
candidates.push('py -3 --version');
}
for (const cmd of candidates) {
try {
const output = execSync(cmd).toString().trim();
const binary = cmd.split(' ')[0];
return { status: true, version: `${binary}: ${output}` };
} catch (error) {
// Try next candidate
}
}
return { status: false, version: 'Not found' };

Copilot uses AI. Check for mistakes.
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.

2 participants