Skip to content

Conversation

@sujay-d07
Copy link
Collaborator

@sujay-d07 sujay-d07 commented Dec 26, 2025

Related Issue

Closes #367

Summary

Merged [cortex doctor] into [cortex status] to eliminate redundant commands and reduce user confusion. The [cortex status]command now provides comprehensive system health checks including:

  • System Configuration: API provider (Claude/OpenAI/Ollama) + Firejail security
  • Python & Dependencies: Version compatibility + [requirements.txt] packages
  • GPU & Acceleration: NVIDIA/AMD drivers + CUDA/ROCm detection
  • AI & Services: Ollama installation and status
  • System Resources: Disk space + memory (RAM)
  • Breaking Change: Removed [cortex doctor] command (functionality moved to [cortex status]

Changes:

  • Enhanced [SystemDoctor] class with [_check_security_tools()] method
  • Removed [doctor] command parser and routing from CLI
  • Updated help text: "Show comprehensive system status and health checks"
  • Updated [COMMANDS.md] documentation
  • Added tests for new security tools check

Old Output:

cortex status
image

cortex doctor
image

New Output:

# New Merged cortex status command
cortex status
image

Summary by CodeRabbit

  • New Features

    • Status now runs comprehensive health checks with a new System Configuration phase (API provider detection, security tool checks like Firejail, dependency, GPU/acceleration, AI services including Ollama).
  • Removed

    • The separate doctor command has been removed; its checks are integrated into status.
  • Documentation

    • Command docs updated to describe consolidated status output, new subsections, and exit-code meanings.
  • Tests

    • Added tests for security tool detection and updated exit-code coverage.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings December 26, 2025 08:41
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 26, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

The cortex doctor command was removed and its health checks were merged into cortex status, which now delegates to SystemDoctor.run_checks(). A new System Configuration phase (API provider and Firejail checks) was added; docs and tests were updated accordingly.

Changes

Cohort / File(s) Summary
CLI consolidation
cortex/cli.py
Removed CortexCLI.doctor() and doctor subcommand wiring; status now invokes SystemDoctor.run_checks() and help text updated.
Health check enhancements
cortex/doctor.py
Added System Configuration phase; added _check_security_tools() (Firejail); moved/reworked _check_api_keys() (handles CORTEX_PROVIDER="ollama"); reordered checks.
Documentation updates
docs/COMMANDS.md
Replaced cortex doctor content with expanded cortex status sections (system configuration, security tools, Python/deps, GPU/accel, AI services, resources, exit codes); updated workflows/examples.
Tests
tests/test_doctor.py
Added tests for Firejail present/absent; included _check_security_tools in exit-code tests; updated docstrings to reference SystemDoctor used by cortex status.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI as CortexCLI
    participant Doctor as SystemDoctor
    participant Sys as System

    User->>CLI: cortex status
    CLI->>Doctor: run_checks()

    rect rgb(240,248,255)
    Note over Doctor,Sys: System Configuration
    Doctor->>Sys: _check_api_keys()
    Sys-->>Doctor: provider / Ollama status
    Doctor->>Sys: _check_security_tools()
    Sys-->>Doctor: Firejail path or missing
    end

    rect rgb(245,245,220)
    Note over Doctor,Sys: Diagnostics & Health Checks
    Doctor->>Sys: _check_python_version()
    Sys-->>Doctor: version result
    Doctor->>Sys: _check_gpu_drivers()
    Sys-->>Doctor: GPU result
    Doctor->>Sys: other checks...
    Sys-->>Doctor: aggregated results
    end

    Doctor-->>CLI: aggregated report (PASS/WARN/FAIL) + exit code
    CLI-->>User: formatted status output
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • mikejmorgan-ai
  • Suyashd999

"I nibbled at two commands, then made them one,
Status now hops and health checks get done. 🥕
Firejail sniffed, APIs checked, all in a run,
Diagnostics hum in orderly fun,
A tidy burrow — system checks all won."

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 69.23% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: consolidating doctor and status commands into a single command.
Description check ✅ Passed The description covers all required sections, explains the consolidation, lists changes, and includes before/after screenshots.
Linked Issues check ✅ Passed Code changes fully implement the requirements: removed doctor command, integrated health checks into status, added Firejail check, and updated documentation.
Out of Scope Changes check ✅ Passed All changes directly support the consolidation objective with no extraneous modifications beyond the scope of merging doctor functionality into status.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

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 consolidates the cortex doctor and cortex status commands into a single, comprehensive cortex status command, eliminating redundancy and reducing user confusion.

Key Changes:

  • The cortex status command now includes all health checks previously performed by cortex doctor, providing comprehensive system diagnostics including API configuration, security tools, Python dependencies, GPU/CUDA detection, Ollama status, and system resources
  • Added _check_security_tools() method to check Firejail availability as part of system configuration checks
  • Removed the standalone cortex doctor command from CLI routing and argument parsing

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
cortex/doctor.py Enhanced with new _check_security_tools() method and reorganized check execution order to prioritize system configuration (API keys and security tools)
cortex/cli.py Removed doctor() method and command routing; updated status() to invoke comprehensive health checks via SystemDoctor
tests/test_doctor.py Added test coverage for new security tools check functionality and updated exit code tests to patch the new method
docs/COMMANDS.md Consolidated documentation by removing separate cortex doctor section and expanding cortex status documentation with comprehensive health check details

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
cortex/cli.py (2)

1196-1196: Remove stale doctor command from help table.

The doctor command has been removed and its functionality merged into status, but the help table still lists it. This will confuse users who try to run cortex doctor.

🔎 Proposed fix
     table.add_row("cache stats", "Show LLM cache statistics")
     table.add_row("stack <name>", "Install the stack")
-    table.add_row("doctor", "System health check")

1238-1238: Update NETWORK_COMMANDS to replace doctor with status.

The doctor command no longer exists. Since status now runs comprehensive health checks (including Ollama API check), consider replacing doctor with status in this list.

🔎 Proposed fix
-        NETWORK_COMMANDS = ["install", "update", "upgrade", "search", "doctor", "stack"]
+        NETWORK_COMMANDS = ["install", "update", "upgrade", "search", "status", "stack"]
🧹 Nitpick comments (1)
cortex/doctor.py (1)

21-40: Update class docstring to include security tools check.

The docstring lists all checks performed but doesn't mention the new Firejail/security tools check added in _check_security_tools(). Consider adding it for completeness.

     Checks for:
     - Python version compatibility
     - Required Python dependencies
     - GPU drivers (NVIDIA/AMD)
     - CUDA/ROCm availability
     - Ollama installation and status
     - API key configuration
+    - Security tools (Firejail)
     - Disk space availability
     - System memory
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1a146dd and 24f1afb.

📒 Files selected for processing (4)
  • cortex/cli.py
  • cortex/doctor.py
  • docs/COMMANDS.md
  • tests/test_doctor.py
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Follow PEP 8 style guide
Type hints required in Python code
Docstrings required for all public APIs

Files:

  • cortex/doctor.py
  • tests/test_doctor.py
  • cortex/cli.py
tests/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Maintain >80% test coverage for pull requests

Files:

  • tests/test_doctor.py
🧬 Code graph analysis (2)
tests/test_doctor.py (1)
cortex/doctor.py (1)
  • _check_security_tools (339-349)
cortex/cli.py (1)
cortex/doctor.py (2)
  • SystemDoctor (21-478)
  • run_checks (48-103)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build Package
  • GitHub Check: Agent
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.10)
  • GitHub Check: test (3.12)
🔇 Additional comments (9)
cortex/doctor.py (3)

75-78: LGTM!

Good reorganization - placing system configuration checks (API provider and security tools) before dependency and GPU checks provides a logical flow for diagnostics.


327-337: LGTM!

The Ollama provider fallback logic is correctly implemented - checks the CORTEX_PROVIDER environment variable and provides appropriate messaging for local Ollama users versus those who need to configure API keys.


339-349: LGTM!

The _check_security_tools() method follows the established pattern of other check methods, correctly uses shutil.which() for tool detection, and provides actionable installation guidance.

docs/COMMANDS.md (2)

102-136: LGTM!

Documentation is comprehensive and accurately reflects the consolidated cortex status command. The check categories, descriptions, and exit codes align with the SystemDoctor implementation.


386-390: LGTM!

The First-Time Setup workflow is correctly updated to use the consolidated cortex status command, removing the previously separate health check step.

tests/test_doctor.py (2)

88-99: LGTM!

Good test coverage for the new _check_security_tools() method - tests both the success path (Firejail available) and the warning path (Firejail not installed) with appropriate mocking.


109-119: LGTM!

The _check_security_tools patch is correctly added to maintain test isolation and follows the existing pattern for mocking check methods in exit code tests.

cortex/cli.py (2)

790-798: LGTM!

The status() method correctly delegates to SystemDoctor.run_checks(), consolidating all health check functionality into the status command as intended by the PR.


1270-1273: LGTM!

The status parser help text correctly reflects the consolidated functionality.

sujay-d07 and others added 2 commits December 26, 2025 14:17
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cortex/cli.py (1)

1196-1196: Remove stale doctor command from help table.

The doctor command was removed and merged into status, but it's still listed in the help output. This will confuse users who try to run cortex doctor and get an error.

Proposed fix
     table.add_row("notify", "Manage desktop notifications")
     table.add_row("env", "Manage environment variables")
     table.add_row("cache stats", "Show LLM cache statistics")
     table.add_row("stack <name>", "Install the stack")
-    table.add_row("doctor", "System health check")
🧹 Nitpick comments (2)
cortex/cli.py (2)

790-798: Add return type hint.

Per coding guidelines, type hints are required. The method should specify -> int since run_checks() returns an integer exit code.

Proposed fix
-    def status(self):
+    def status(self) -> int:
         """Show comprehensive system status and run health checks"""
         from cortex.doctor import SystemDoctor

1238-1238: Remove stale doctor from NETWORK_COMMANDS.

The doctor command was removed, but it's still listed in NETWORK_COMMANDS. While harmless, this is dead code that should be cleaned up for consistency.

Proposed fix
-        NETWORK_COMMANDS = ["install", "update", "upgrade", "search", "doctor", "stack"]
+        NETWORK_COMMANDS = ["install", "update", "upgrade", "search", "stack"]
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 24f1afb and bc63f9d.

📒 Files selected for processing (1)
  • cortex/cli.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Follow PEP 8 style guide
Type hints required in Python code
Docstrings required for all public APIs

Files:

  • cortex/cli.py
🧬 Code graph analysis (1)
cortex/cli.py (1)
cortex/doctor.py (2)
  • SystemDoctor (21-478)
  • run_checks (48-103)
🪛 GitHub Actions: CI
cortex/cli.py

[error] 1-1: Black formatting check failed. 1 file would be reformatted. Command: 'black --check . --exclude "(venv|.venv|build|dist)"'.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: test (3.10)
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.12)
🔇 Additional comments (2)
cortex/cli.py (2)

1270-1273: LGTM!

The status command parser is correctly configured without storing to an unused variable, and the help text accurately reflects the consolidated functionality.


1270-1273: Add docstring and type hints to the main() function.

The main() function (line 1220) is missing both a docstring and a return type hint, violating the coding guidelines requiring type hints in all Python code and docstrings for all public APIs. Lines 1270-1273 themselves are properly formatted.

Likely an incorrect or invalid review comment.

@sonarqubecloud
Copy link

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cortex/cli.py (1)

1196-1196: Remove obsolete "doctor" command from help table.

The help table still displays the doctor command at line 1196, but this command was removed and merged into status as per the PR objectives. This creates a misleading user experience where the help suggests a command that no longer exists.

🔎 Proposed fix
-    table.add_row("doctor", "System health check")

The status command already covers health checks, so this line should be removed entirely.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bc63f9d and bc2ba16.

📒 Files selected for processing (1)
  • cortex/cli.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Follow PEP 8 style guide
Type hints required in Python code
Docstrings required for all public APIs

Files:

  • cortex/cli.py
🧬 Code graph analysis (1)
cortex/cli.py (1)
cortex/doctor.py (2)
  • SystemDoctor (21-478)
  • run_checks (48-103)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build Package
  • GitHub Check: test (3.10)
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.12)

@Suyashd999 Suyashd999 self-requested a review December 27, 2025 09:44
@Suyashd999 Suyashd999 merged commit 4916766 into cortexlinux:main Dec 27, 2025
13 checks passed
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.

[FEATURE] Merge cortex doctor into cortex status

2 participants