Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:
env:
ANTHROPIC_API_KEY: "test-key-for-ci"
run: |
pytest tests/ -v --tb=short || echo "Some tests may require API keys"
python -m pytest test/ tests/ -v --tb=short
43 changes: 0 additions & 43 deletions .github/workflows/codeql.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LLM/test_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_initialization_openai(self, mock_openai):
def test_initialization_claude(self, mock_anthropic):
interpreter = CommandInterpreter(api_key=self.api_key, provider="claude")
self.assertEqual(interpreter.provider, APIProvider.CLAUDE)
self.assertEqual(interpreter.model, "claude-3-5-sonnet-20241022")
self.assertEqual(interpreter.model, "claude-sonnet-4-20250514")
mock_anthropic.assert_called_once_with(api_key=self.api_key)

@patch('openai.OpenAI')
Expand Down
36 changes: 33 additions & 3 deletions cortex/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
print_all_preferences,
format_preference_value
)
from cortex.preflight_checker import PreflightChecker, format_report, export_report
from cortex.branding import (
console,
cx_print,
Expand Down Expand Up @@ -176,7 +177,11 @@ def notify(self, args):
return 1
# -------------------------------

def install(self, software: str, execute: bool = False, dry_run: bool = False):
def install(self, software: str, execute: bool = False, dry_run: bool = False, simulate: bool = False):
# Handle simulation mode first - no API key needed
if simulate:
return self._run_simulation(software)

# Validate input first
is_valid, error = validate_install_request(software)
if not is_valid:
Expand Down Expand Up @@ -310,6 +315,30 @@ def progress_callback(current, total, step):
history.update_installation(install_id, InstallationStatus.FAILED, str(e))
self._print_error(f"Unexpected error: {str(e)}")
return 1

def _run_simulation(self, software: str) -> int:
"""Run preflight simulation check for installation"""
try:
# Get API key for LLM-powered package info (optional).
api_key = os.environ.get('OPENAI_API_KEY') or os.environ.get('ANTHROPIC_API_KEY')
provider = self._get_provider() if api_key else 'openai'

# Create checker with optional API key for enhanced accuracy
checker = PreflightChecker(api_key=api_key, provider=provider)
report = checker.run_all_checks(software)

# Print formatted report
output = format_report(report, software)
print(output)

# Return error code if blocking issues found
if report.errors:
return 1
return 0

except Exception as e:
self._print_error(f"Simulation failed: {str(e)}")
return 1

def history(self, limit: int = 20, status: Optional[str] = None, show_id: Optional[str] = None):
"""Show installation history"""
Expand Down Expand Up @@ -577,6 +606,7 @@ def main():
install_parser.add_argument('software', type=str, help='Software to install')
install_parser.add_argument('--execute', action='store_true', help='Execute commands')
install_parser.add_argument('--dry-run', action='store_true', help='Show commands only')
install_parser.add_argument('--simulate', action='store_true', help='Simulate installation without making changes')

# History command
history_parser = subparsers.add_parser('history', help='View history')
Expand Down Expand Up @@ -626,14 +656,14 @@ def main():
cli = CortexCLI(verbose=args.verbose)

try:
if args.command == 'install':
return cli.install(args.software, execute=args.execute, dry_run=args.dry_run, simulate=args.simulate)
if args.command == 'demo':
return cli.demo()
elif args.command == 'wizard':
return cli.wizard()
elif args.command == 'status':
return cli.status()
elif args.command == 'install':
return cli.install(args.software, execute=args.execute, dry_run=args.dry_run)
elif args.command == 'history':
return cli.history(limit=args.limit, status=args.status, show_id=args.show_id)
elif args.command == 'rollback':
Expand Down
1 change: 0 additions & 1 deletion cortex/hardware_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ def _load_cache(self) -> Optional[SystemInfo]:
return None

# Check age
age = Path.ctime(self.CACHE_FILE)
import time
if time.time() - self.CACHE_FILE.stat().st_mtime > self.CACHE_MAX_AGE_SECONDS:
return None
Expand Down
Loading
Loading