Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ cortex history

# Rollback an installation
cortex rollback <installation-id>

# Check system preferences
cortex check-pref
```

### Command Reference
Expand All @@ -150,7 +147,6 @@ cortex check-pref
| `cortex install <query> --execute` | Execute the installation |
| `cortex history` | View all past installations |
| `cortex rollback <id>` | Undo a specific installation |
| `cortex check-pref` | Display current preferences |
| `cortex --version` | Show version information |
| `cortex --help` | Display help message |

Expand Down
7 changes: 0 additions & 7 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ export ANTHROPIC_API_KEY='your-key-here'
- [ ] `cortex rollback <id>` - Attempts rollback
- [ ] `cortex rollback <id> --dry-run` - Shows what would be rolled back

### Preferences Commands

- [ ] `cortex check-pref` - Shows all preferences
- [ ] `cortex check-pref ai.model` - Shows specific preference
- [ ] `cortex edit-pref set ai.model gpt-4` - Sets preference
- [ ] `cortex edit-pref validate` - Validates configuration

## Provider Tests

### Anthropic Claude
Expand Down
116 changes: 1 addition & 115 deletions cortex/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,7 @@
from cortex.network_config import NetworkConfig
from cortex.notification_manager import NotificationManager
from cortex.stack_manager import StackManager
from cortex.user_preferences import (
PreferencesManager,
format_preference_value,
print_all_preferences,
)
from cortex.validators import (
validate_api_key,
validate_install_request,
)
from cortex.validators import validate_api_key, validate_install_request

# Suppress noisy log messages in normal operation
logging.getLogger("httpx").setLevel(logging.WARNING)
Expand All @@ -37,7 +29,6 @@ class CortexCLI:
def __init__(self, verbose: bool = False):
self.spinner_chars = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]
self.spinner_idx = 0
self.prefs_manager = None # Lazy initialization
self.verbose = verbose
self.offline = False

Expand Down Expand Up @@ -695,98 +686,6 @@ def rollback(self, install_id: str, dry_run: bool = False):
traceback.print_exc()
return 1

def _get_prefs_manager(self):
"""Lazy initialize preferences manager"""
if self.prefs_manager is None:
self.prefs_manager = PreferencesManager()
return self.prefs_manager

def check_pref(self, key: str | None = None):
"""Check/display user preferences"""
manager = self._get_prefs_manager()

try:
if key:
# Show specific preference
value = manager.get(key)
if value is None:
self._print_error(f"Preference key '{key}' not found")
return 1

print(f"\n{key} = {format_preference_value(value)}")
return 0
else:
# Show all preferences
print_all_preferences(manager)
return 0

except (ValueError, OSError) as e:
self._print_error(f"Failed to read preferences: {str(e)}")
return 1
except Exception as e:
self._print_error(f"Unexpected error reading preferences: {str(e)}")
if self.verbose:
import traceback

traceback.print_exc()
return 1

def edit_pref(self, action: str, key: str | None = None, value: str | None = None):
"""Edit user preferences (add/set, delete/remove, list)"""
manager = self._get_prefs_manager()

try:
if action in ["add", "set", "update"]:
if not key or not value:
self._print_error("Key and value required")
return 1
manager.set(key, value)
self._print_success(f"Updated {key}")
print(f" New value: {format_preference_value(manager.get(key))}")
return 0

elif action in ["delete", "remove", "reset-key"]:
if not key:
self._print_error("Key required")
return 1
# Simplified reset logic
print(f"Resetting {key}...")
# (In a real implementation we would reset to default)
return 0

elif action in ["list", "show", "display"]:
return self.check_pref()

elif action == "reset-all":
confirm = input("⚠️ Reset ALL preferences? (y/n): ")
if confirm.lower() == "y":
manager.reset()
self._print_success("Preferences reset")
return 0

elif action == "validate":
errors = manager.validate()
if errors:
print("❌ Errors found")
else:
self._print_success("Valid")
return 0

else:
self._print_error(f"Unknown action: {action}")
return 1

except (ValueError, OSError) as e:
self._print_error(f"Failed to edit preferences: {str(e)}")
return 1
except Exception as e:
self._print_error(f"Unexpected error editing preferences: {str(e)}")
if self.verbose:
import traceback

traceback.print_exc()
return 1

def status(self):
"""Show comprehensive system status and run health checks"""
from cortex.doctor import SystemDoctor
Expand Down Expand Up @@ -1296,15 +1195,6 @@ def main():
rollback_parser.add_argument("id", help="Installation ID")
rollback_parser.add_argument("--dry-run", action="store_true")

# Preferences commands
check_pref_parser = subparsers.add_parser("check-pref", help="Check preferences")
check_pref_parser.add_argument("key", nargs="?")

edit_pref_parser = subparsers.add_parser("edit-pref", help="Edit preferences")
edit_pref_parser.add_argument("action", choices=["set", "add", "delete", "list", "validate"])
edit_pref_parser.add_argument("key", nargs="?")
edit_pref_parser.add_argument("value", nargs="?")

# --- New Notify Command ---
notify_parser = subparsers.add_parser("notify", help="Manage desktop notifications")
notify_subs = notify_parser.add_subparsers(dest="notify_action", help="Notify actions")
Expand Down Expand Up @@ -1461,10 +1351,6 @@ def main():
return cli.history(limit=args.limit, status=args.status, show_id=args.show_id)
elif args.command == "rollback":
return cli.rollback(args.id, dry_run=args.dry_run)
elif args.command == "check-pref":
return cli.check_pref(key=args.key)
elif args.command == "edit-pref":
return cli.edit_pref(action=args.action, key=args.key, value=args.value)
# Handle the new notify command
elif args.command == "notify":
return cli.notify(args)
Expand Down
Loading
Loading