-
-
Notifications
You must be signed in to change notification settings - Fork 28
feat: add Coderrr Doctor diagnostic tool #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Coderrr Doctor | ||
|
|
||
| A built-in diagnostic tool to ensure your environment is ready for AI coding. | ||
|
|
||
| ## Usage | ||
| Run the following to check your setup: | ||
| ```bash | ||
| coderrr doctor | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,36 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| const fs = require('fs'); | ||||||||||||||||||||||||||||||||||||||||||||||
| const path = require('path'); | ||||||||||||||||||||||||||||||||||||||||||||||
| const { execSync } = require('child_process'); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| class CoderrrDoctor { | ||||||||||||||||||||||||||||||||||||||||||||||
| checkEnv() { | ||||||||||||||||||||||||||||||||||||||||||||||
| return fs.existsSync(path.join(process.cwd(), '.env')); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| checkPython() { | ||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||
| const version = execSync('python --version').toString().trim(); | ||||||||||||||||||||||||||||||||||||||||||||||
| return { status: true, version }; | ||||||||||||||||||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||||||||||||||||||
| return { status: false, version: 'Not found' }; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
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' }; | |
| } | |
| 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' }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| const chalk = require('chalk'); | ||
| const doctor = require('./doctor'); | ||
|
|
||
| async function runDiagnostics(backendUrl) { | ||
| console.log('\n' + chalk.blue.bold('🩺 CODERRR DOCTOR - SYSTEM DIAGNOSTICS')); | ||
| console.log(chalk.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')); | ||
|
|
||
| const python = doctor.checkPython(); | ||
| const node = doctor.checkNode(); | ||
| const hasEnv = doctor.checkEnv(); | ||
|
|
||
| console.log(`${python.status ? chalk.green('✔') : chalk.red('✘')} Python: ${python.version}`); | ||
| console.log(`${node.status ? chalk.green('✔') : chalk.red('✘')} Node.js: ${node.version}`); | ||
| console.log(`${hasEnv ? chalk.green('✔') : chalk.red('✘')} Local .env file detected`); | ||
|
|
||
| console.log(chalk.yellow('\nChecking Backend Connectivity...')); | ||
| const backendStatus = await doctor.checkBackend(backendUrl || 'https://coderrr-backend.vercel.app'); | ||
| console.log(`${backendStatus ? chalk.green('✔') : chalk.red('✘')} Backend: ${backendStatus ? 'Connected' : 'Unreachable'}`); | ||
|
|
||
| if (!backendStatus) { | ||
| console.log(chalk.red('\n[!] Advice: Check your internet or custom CODERRR_BACKEND variable.')); | ||
| } | ||
| console.log(chalk.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n')); | ||
| } | ||
|
|
||
| module.exports = { runDiagnostics }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| /** | ||
| * Helps format diagnostic logs for potential export | ||
| */ | ||
| const generateReport = (results) => { | ||
| return `Coderrr Diagnostic Report - ${new Date().toISOString()}\n` + | ||
| `Status: ${results.allPassed ? 'HEALTHY' : 'ISSUES DETECTED'}\n`; | ||
| }; | ||
|
|
||
| module.exports = { generateReport }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| const doctor = require('../src/doctor'); | ||
|
|
||
| describe('Doctor Module', () => { | ||
| test('should detect node version', () => { | ||
| const node = doctor.checkNode(); | ||
| expect(node.status).toBe(true); | ||
| expect(node.version).toContain('v'); | ||
| }); | ||
| }); | ||
|
Comment on lines
+3
to
+9
|
||
There was a problem hiding this comment.
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 doctorsnippet to render incorrectly in many Markdown viewers. Please add a terminating code fence on a new line after thecoderrr doctorcommand so the example displays as a proper fenced code block.