Skip to content

Conversation

@Kesavaraja67
Copy link

@Kesavaraja67 Kesavaraja67 commented Dec 24, 2025

I have implemented the interactive installation assistant script requested in Issue #140.

Features:

  • Auto-detects OS (Windows/Linux/Mac).
  • Asks user for Hardware (GPU/CPU) and Interface (CLI/Web) preference.
  • Generates correct pip install commands based on inputs.

/claim #140

Summary by CodeRabbit

Release Notes

  • New Features
    • Added an interactive installation assistant that guides users through setting up Cortex with tailored steps based on their operating system, GPU/accelerator choice, and preferred interface option.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 24, 2025

📝 Walkthrough

Walkthrough

A new interactive installation assistant script is introduced in cortex/install_tutor.py. The script guides users through OS detection, GPU/accelerator selection, and interface preference, then outputs OS-tailored prerequisites, virtual environment setup, and installation commands with appropriate GPU-specific configurations.

Changes

Cohort / File(s) Summary
Interactive Installation Assistant
cortex/install_tutor.py
New module with print_header(), get_user_choice(), and generate_guide() functions. Implements interactive wizard for guiding installation with OS detection, GPU/accelerator type selection, and UI preference prompting. Includes input validation, OS-specific command generation, and GPU-specific extra-index URL injection for CUDA/ROCm.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • mikejmorgan-ai
  • Sahilbhatane

Poem

🐰✨ A tutor script hops onto the stage,
Guiding users through install's grand page!
Windows, Linux, Mac—pick your way,
CUDA sparks and ROCm play.
Now cortex setup's just a hop away! 🚀

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is missing the required 'Related Issue' section format and checklist items specified in the template, though it covers key features and includes an issue reference. Restructure the description to follow the template: add 'Related Issue' section with 'Closes #140' format, add a 'Summary' section, and include the required checklist with test and PR title format validations.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change (Installation Tutor Script) and references the related issue (#140), directly matching the PR's primary objective.
✨ 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.

@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: 5

🧹 Nitpick comments (3)
cortex/install_tutor.py (3)

3-3: Remove unused import.

The os module is imported but never used in this file.

🔎 Proposed fix
 import platform
 import sys
-import os

66-74: Consider recommending dry-run verification.

While the script only prints commands (doesn't execute them), you could enhance user safety by suggesting users first run with --dry-run to verify what would be installed, especially since the coding guidelines emphasize "Dry-run by default for all installations in command execution."

🔎 Suggested enhancement
     print("\n3️⃣  Install Cortex Core:")
+    print("   💡 TIP: Add --dry-run to preview changes first")
     install_cmd = "pip install cortex-ai"

As per coding guidelines, dry-run defaults are recommended for installation operations.


88-89: Consider adding error handling for graceful exits.

Adding basic exception handling for KeyboardInterrupt would provide a cleaner user experience if the user wants to exit the assistant early.

🔎 Suggested enhancement
 if __name__ == "__main__":
-    generate_guide()
+    try:
+        generate_guide()
+    except KeyboardInterrupt:
+        print("\n\n⚠️  Installation assistant cancelled by user.")
+        sys.exit(0)
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 287a353 and 823883e.

📒 Files selected for processing (1)
  • cortex/install_tutor.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/install_tutor.py
**/*install*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*install*.py: Dry-run by default for all installations in command execution
No silent sudo execution - require explicit user confirmation
Implement audit logging to ~/.cortex/history.db for all package operations

Files:

  • cortex/install_tutor.py

Comment on lines +5 to +10
def print_header():
print("\n" + "="*50)
print(" 🧠 Cortex AI - Installation Assistant")
print("="*50 + "\n")
print("This tool will help you generate the correct installation commands")
print("based on your hardware and operating system.\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add type hints and docstring.

Per coding guidelines, type hints and docstrings are required for all public APIs.

🔎 Proposed fix
-def print_header():
+def print_header() -> None:
+    """Print the branded header for the Cortex installation assistant."""
     print("\n" + "="*50)
     print("   🧠 Cortex AI - Installation Assistant")
     print("="*50 + "\n")

As per coding guidelines, type hints and docstrings are required for Python code.

🤖 Prompt for AI Agents
In cortex/install_tutor.py around lines 5 to 10, the public function
print_header lacks a docstring and type hints; add a one- or two-line docstring
describing its purpose (prints the installation assistant header) and annotate
its signature with a return type of None (def print_header() -> None:). Ensure
the docstring follows PEP 257 (summary line and optional details) and includes
any relevant behavior; no parameter annotations are needed since it takes no
arguments.

Comment on lines +12 to +24
def get_user_choice(question, options):
print(f"❓ {question}")
for i, opt in enumerate(options, 1):
print(f" {i}. {opt}")

while True:
try:
choice = int(input("\n👉 Enter your choice (number): "))
if 1 <= choice <= len(options):
return options[choice-1]
print("❌ Invalid choice. Please try again.")
except ValueError:
print("❌ Please enter a number.")
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add type hints and docstring.

Per coding guidelines, type hints and docstrings are required for all public APIs.

🔎 Proposed fix
-def get_user_choice(question, options):
+def get_user_choice(question: str, options: list[str]) -> str:
+    """
+    Prompt the user to select one option from a list.
+    
+    Args:
+        question: The question to display to the user.
+        options: List of available options.
+        
+    Returns:
+        The selected option string.
+    """
     print(f"❓ {question}")
     for i, opt in enumerate(options, 1):
         print(f"   {i}. {opt}")

As per coding guidelines, type hints and docstrings are required for Python code.

🤖 Prompt for AI Agents
In cortex/install_tutor.py around lines 12 to 24, add a proper docstring and
type hints for the public function get_user_choice: annotate question as str,
options as a Sequence[str] (or list[str] for Python 3.9+), and the return type
as str; update the function signature accordingly and add a short triple-quoted
docstring describing parameters, return value and behavior (prompts user until a
valid numeric choice is made), and add any needed import from typing (e.g.,
Sequence) at the top of the file.

except ValueError:
print("❌ Please enter a number.")

def generate_guide():
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add type hints and docstring.

Per coding guidelines, type hints and docstrings are required for all public APIs.

🔎 Proposed fix
-def generate_guide():
+def generate_guide() -> None:
+    """
+    Generate an interactive installation guide for Cortex AI.
+    
+    Detects the operating system, prompts for GPU/accelerator type and UI preference,
+    then prints tailored installation commands.
+    """
     print_header()

As per coding guidelines, type hints and docstrings are required for Python code.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def generate_guide():
def generate_guide() -> None:
"""
Generate an interactive installation guide for Cortex AI.
Detects the operating system, prompts for GPU/accelerator type and UI preference,
then prints tailored installation commands.
"""
print_header()
🤖 Prompt for AI Agents
In cortex/install_tutor.py around line 26, add a proper docstring and function
type hints for the public generate_guide function: declare parameter and return
types (or use -> None if it returns nothing) and include a one-line summary plus
short description of parameters/return and behavior in the docstring following
PEP 257; ensure annotations use existing project types or typing imports if
needed.

Comment on lines +48 to +56
# Logic to generate commands
print("1️⃣ Prerequisites:")
if target_os == "Windows":
print(" - Ensure Python 3.10+ is installed (checking: python --version)")
print(" - Install Visual Studio C++ Build Tools")
elif target_os == "Linux":
print(" - sudo apt update && sudo apt install build-essential python3-dev")
elif target_os == "macOS":
print(" - Install Xcode Command Line Tools: xcode-select --install")
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add explicit warning before displaying sudo commands.

The script displays sudo commands without explicit warnings for user review. Per coding guidelines, "No silent sudo execution - require explicit user confirmation." Even though these commands are only printed (not executed), users may copy-paste them without careful review. Add a warning before showing privileged commands.

🔎 Proposed fix
     print("1️⃣  Prerequisites:")
+    print("   ⚠️  NOTE: Review and understand all commands before executing, especially those requiring sudo.")
     if target_os == "Windows":
         print("   - Ensure Python 3.10+ is installed (checking: python --version)")
         print("   - Install Visual Studio C++ Build Tools")

As per coding guidelines, no silent sudo execution is allowed without explicit user confirmation.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Logic to generate commands
print("1️⃣ Prerequisites:")
if target_os == "Windows":
print(" - Ensure Python 3.10+ is installed (checking: python --version)")
print(" - Install Visual Studio C++ Build Tools")
elif target_os == "Linux":
print(" - sudo apt update && sudo apt install build-essential python3-dev")
elif target_os == "macOS":
print(" - Install Xcode Command Line Tools: xcode-select --install")
# Logic to generate commands
print("1️⃣ Prerequisites:")
print(" ⚠️ NOTE: Review and understand all commands before executing, especially those requiring sudo.")
if target_os == "Windows":
print(" - Ensure Python 3.10+ is installed (checking: python --version)")
print(" - Install Visual Studio C++ Build Tools")
elif target_os == "Linux":
print(" - sudo apt update && sudo apt install build-essential python3-dev")
elif target_os == "macOS":
print(" - Install Xcode Command Line Tools: xcode-select --install")
🤖 Prompt for AI Agents
In cortex/install_tutor.py around lines 48 to 56, the script prints privileged
(sudo) commands for Linux without any explicit warning; add a clear warning line
immediately before printing any sudo or privileged commands (e.g., "Warning: the
following commands require sudo/root privileges — review before running") so
users are explicitly alerted before copy-pasting them; ensure the warning is
only printed for target_os == "Linux" (or any branch that prints sudo) and keep
it concise and prominent.

Comment on lines +76 to +82
print("\n4️⃣ Run Cortex:")
if target_ui == "Web UI":
print(" cortex-server --web")
elif target_ui == "API Server":
print(" cortex-server --host 0.0.0.0 --port 8000")
else:
print(" cortex run")
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix string comparison bug that breaks Web UI option.

Line 77 compares target_ui == "Web UI", but the actual option string (defined on Line 41) is "Web UI (Browser-based)". This comparison will never be true, causing Web UI selection to fall through to the CLI command. This is a critical correctness bug.

🔎 Proposed fix
     print("\n4️⃣  Run Cortex:")
-    if target_ui == "Web UI":
+    if target_ui == "Web UI (Browser-based)":
         print("   cortex-server --web")
     elif target_ui == "API Server":
         print("   cortex-server --host 0.0.0.0 --port 8000")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
print("\n4️⃣ Run Cortex:")
if target_ui == "Web UI":
print(" cortex-server --web")
elif target_ui == "API Server":
print(" cortex-server --host 0.0.0.0 --port 8000")
else:
print(" cortex run")
print("\n4️⃣ Run Cortex:")
if target_ui == "Web UI (Browser-based)":
print(" cortex-server --web")
elif target_ui == "API Server":
print(" cortex-server --host 0.0.0.0 --port 8000")
else:
print(" cortex run")
🤖 Prompt for AI Agents
In cortex/install_tutor.py around lines 76 to 82, the if check uses target_ui ==
"Web UI" but the option value defined earlier is "Web UI (Browser-based)", so
the equality never matches and the Web UI branch falls through; fix by comparing
against the exact option string used when setting target_ui (e.g., target_ui ==
"Web UI (Browser-based)"), or use a stable test like target_ui.startswith("Web
UI") or "Web UI" in target_ui to detect the Web UI selection; update the
conditional accordingly so the correct cortex-server --web command is printed.

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