Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
84eb3a0
feat: implement smart update recommendations with CLI integration and…
pratyush07-hub Jan 22, 2026
0421c52
chore: cleanup en.yaml to only include new keys and preserve original…
pratyush07-hub Jan 22, 2026
8ceecf8
Merge branch 'main' into feature/smart-update-recommendations-91
pratyush07-hub Jan 22, 2026
ed00f03
refactor: address code review feedback and fix logger error
pratyush07-hub Jan 22, 2026
48adf0a
security: fix potential ReDoS in APT update parsing
pratyush07-hub Jan 22, 2026
41e8041
refactor: address code review feedback, SonarQube concerns, and impro…
pratyush07-hub Jan 22, 2026
ccac5cd
fix: resolve SonarQube Reliability C rating and finalize quality clea…
pratyush07-hub Jan 22, 2026
e5c4f4d
fix: resolve security detection gaps, threshold alignment, and markdo…
pratyush07-hub Jan 22, 2026
acf0d46
Refactor: Resolve SonarQube reliability issues and improve code quality
pratyush07-hub Jan 22, 2026
06a32a8
Refactor: Resolve SonarQube regex, complexity, and nested ternary issues
pratyush07-hub Jan 22, 2026
c837ee2
Merge branch 'main' into feature/smart-update-recommendations-91
Anshgrover23 Jan 23, 2026
ac92639
fix(update-recommender): implement changelog fetching for APT/DNF and…
pratyush07-hub Jan 23, 2026
1327782
fix(update-recommender): handle Debian prerelease markers and add typ…
pratyush07-hub Jan 23, 2026
85fe99e
fix(update-recommender): filter non-package lines in RPM check-update…
pratyush07-hub Jan 23, 2026
7ea2dc8
Merge branch 'main' into feature/smart-update-recommendations-91
Anshgrover23 Jan 23, 2026
121746f
Refactor update recommender: address PR feedback on magic numbers, ti…
pratyush07-hub Jan 23, 2026
721d43a
Fix: ensure --json output is always valid JSON even on error
pratyush07-hub Jan 23, 2026
e04ef9e
Fix: use check_timeout for slow APT operations and support custom tim…
pratyush07-hub Jan 23, 2026
f8c9b1b
Fix: avoid RPM fallback on systems with APT using shutil.which and up…
pratyush07-hub Jan 23, 2026
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ cortex install "tools for video compression"
| **Docker Permission Fixer** | Fix root-owned bind mount issues automatically |
| **Audit Trail** | Complete history in `~/.cortex/history.db` |
| **Hardware-Aware** | Detects GPU, CPU, memory for optimized packages |
| **Smart Update Recommendations** | AI-powered update recommendations and risk assessment |
| **Predictive Error Prevention** | AI-driven checks for potential installation failures |
| **Multi-LLM Support** | Works with Claude, GPT-4, or local Ollama models |

Expand Down Expand Up @@ -167,6 +168,9 @@ cortex history

# Rollback an installation
cortex rollback <installation-id>

# Get smart update recommendations
cortex update recommend
```

### Role Management
Expand All @@ -192,6 +196,7 @@ cortex role set <slug>
| `cortex sandbox <cmd>` | Test packages in Docker sandbox |
| `cortex history` | View all past installations |
| `cortex rollback <id>` | Undo a specific installation |
| `cortex update recommend` | Get AI-powered update recommendations |
| `cortex --version` | Show version information |
| `cortex --help` | Display help message |

Expand Down
53 changes: 53 additions & 0 deletions cortex/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
# Suppress noisy log messages in normal operation
logging.getLogger("httpx").setLevel(logging.WARNING)
logging.getLogger("cortex.installation_history").setLevel(logging.ERROR)
logger = logging.getLogger(__name__)


sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
Expand Down Expand Up @@ -2623,6 +2624,43 @@ def progress_callback(message: str, percent: float) -> None:
)
return 0

elif action == "recommend":
# Smart Update Recommendations (Issue #91)
from cortex.update_recommender import UpdateRecommender, recommend_updates

use_llm = not getattr(args, "no_llm", False)
output_json = getattr(args, "json", False)

if output_json:
try:
llm_router = None
if use_llm:
try:
from cortex.llm_router import LLMRouter

llm_router = LLMRouter()
except ImportError:
pass
except (RuntimeError, ConnectionError) as e:
logger.debug(f"LLM router initialization failed: {e}")

recommender = UpdateRecommender(llm_router=llm_router, verbose=self.verbose)
recommendation = recommender.get_recommendations(use_llm=use_llm)

print(json.dumps(recommendation.to_dict(), indent=2))
return 0
except Exception as e:
error_payload = {
"success": False,
"error": str(e),
"error_type": type(e).__name__,
}
print(json.dumps(error_payload))
return 1
else:
cx_print(t("update_recommend.checking"), "thinking")
return recommend_updates(use_llm=use_llm, verbose=self.verbose)

else:
# Default: show current version and check for updates
cx_print(f"Current version: [cyan]{get_version_string()}[/cyan]", "info")
Expand Down Expand Up @@ -5345,6 +5383,21 @@ def main():

# update backups
update_subs.add_parser("backups", help="List available backups for rollback")

# update recommend - Smart Update Recommendations (Issue #91)
update_recommend_parser = update_subs.add_parser(
"recommend", help="AI-powered update recommendations"
)
update_recommend_parser.add_argument(
"--no-llm",
action="store_true",
help="Disable LLM analysis for recommendations",
)
update_recommend_parser.add_argument(
"--json",
action="store_true",
help="Output recommendations in JSON format",
)
# --------------------------

# WiFi/Bluetooth Driver Matcher
Expand Down
40 changes: 40 additions & 0 deletions cortex/i18n/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,46 @@ progress:
cleaning_up: "Cleaning up..."
# {seconds} - duration
completed_in: "Completed in {seconds} seconds"
# =============================================================================
# Update Recommendations
# =============================================================================
update_recommend:
checking: "Analyzing system for update recommendations..."
no_updates: "All packages are up to date! Your system is healthy."
overall_risk: "Overall risk: {risk}"
total_updates: "Total updates available: {count}"
header: "Update Analysis"

categories:
security: "Security Updates (Apply ASAP)"
immediate: "Safe to Update Now (Low Risk)"
scheduled: "Recommended for Maintenance Window"
deferred: "Hold for Now"
groups: "Related Update Groups"

risks:
low: "LOW"
medium: "MEDIUM"
high: "HIGH"
critical: "CRITICAL"

notes:
security: "security"
warnings: "{count} warnings"
group: "group: {name}"

ai_analysis: "AI Analysis"
more_updates: "... and {count} more"
no_description: "No description available"

recommendations:
security_urgent: "Security update - prioritize installation"
safe_immediate: "Safe to update immediately"
maintenance_window: "Schedule for maintenance window"
consider_deferring: "Consider deferring this update"
major_upgrade: "Major version upgrade: {current} → {new}"
potential_breaking: "Potential breaking changes:"
part_of_group: "Part of {group} update group"

# =============================================================================
# Predictive Error Prevention
Expand Down
Loading