-
Notifications
You must be signed in to change notification settings - Fork 19
feat: shell hotkey integration #297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: shell hotkey integration #297
Conversation
WalkthroughAdds shell hotkey integration (Bash/Zsh) and installer, a CLI bridge to request command suggestions, a shell_integration backend that calls the interpreter, unit tests, and a new CLI notify subcommand for desktop notification management. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Shell as "Shell (Bash/Zsh)"
participant CLI as "cortex CLI"
participant ShellInt as "cortex.shell_integration"
participant Interp as "cortex.interpreter"
User->>Shell: Press Ctrl+L (hotkey)
Shell->>CLI: run `cortex _shell_suggest [current_input]`
CLI->>ShellInt: suggest_command(user_input)
ShellInt->>Interp: interpret(user_input) -- lazy import
Interp-->>ShellInt: interpretation (may include "command")
ShellInt-->>CLI: suggested_command or None
CLI-->>Shell: print suggestion (exit 0) or no output (exit 1)
Shell->>Shell: replace current input with suggestion (if provided)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 7
🧹 Nitpick comments (4)
scripts/cortex_zsh.zsh (1)
16-17: Ctrl+L rebinds the standard "clear screen" shortcut.Binding Ctrl+L will override the default terminal behavior of clearing the screen. Consider documenting this in installation output or offering an alternative keybinding option for users who rely on the default behavior.
scripts/cortex_bash.sh (1)
1-2: Add a shell directive for shellcheck compatibility.While this script is sourced rather than executed directly, adding a shell directive helps static analysis tools and documents the expected shell environment.
+# shellcheck shell=bash # Cortex Bash shell integration # Binds Ctrl+L to send current input to Cortex and replace it with a suggestioncortex/cli.py (1)
133-144: Consider exposing a publicsave_configmethod onNotificationManager.Calling
mgr._save_config()directly couples this code to the private implementation. While the inline comment acknowledges this, a public method would be cleaner.cortex/shell_installer.py (1)
4-5: Both markers are identical, but onlyBASH_MARKERis checked.
BASH_MARKERandZSH_MARKERhave the same value, and_append_if_missingonly checks forBASH_MARKER. This works coincidentally but is confusing. Consider either using a singleMARKERconstant or passing the marker to check as a parameter.-BASH_MARKER = "# >>> cortex shell integration >>>" -ZSH_MARKER = "# >>> cortex shell integration >>>" +SHELL_MARKER = "# >>> cortex shell integration >>>"Then use
SHELL_MARKERconsistently throughout.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
cortex/cli.py(2 hunks)cortex/shell_installer.py(1 hunks)cortex/shell_integration.py(1 hunks)scripts/cortex_bash.sh(1 hunks)scripts/cortex_zsh.zsh(1 hunks)
🧰 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/shell_integration.pycortex/shell_installer.pycortex/cli.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/shell_installer.py
🧬 Code graph analysis (1)
cortex/cli.py (1)
cortex/shell_integration.py (1)
suggest_command(11-48)
🪛 Shellcheck (0.11.0)
scripts/cortex_bash.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
🔇 Additional comments (3)
cortex/shell_integration.py (1)
26-34: Defensive error handling is appropriate for shell integration.The broad
except Exceptioncatches are suitable here since this code runs in a shell hotkey context where any failure should silently returnNonerather than break the user's terminal session.cortex/cli.py (2)
116-131: LGTM: Graceful handling of missing subcommand.The check for
args.notify_actionwith a helpful error message is good defensive coding.
152-158: Good: Time format validation added.The validation using
datetime.strptimewith proper error handling ensures users provide valid HH:MM times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/test_shell_integration.py(1 hunks)
🧰 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:
tests/test_shell_integration.py
tests/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
Maintain >80% test coverage for pull requests
Files:
tests/test_shell_integration.py
🧬 Code graph analysis (1)
tests/test_shell_integration.py (1)
cortex/shell_integration.py (1)
suggest_command(11-48)
|
@pavanimanchala53 resolve the coderabbit suggestions and delete |
|
Hi @Sahilbhatane & @mikejmorgan-ai , This branch is ready for review. Please let me know if everything looks good so we can proceed with the merge. Thanks! |



Summary
Implements shell hotkey integration for Cortex, allowing users to get AI-powered command suggestions directly in their terminal using a configurable hotkey.
Features
cortex --install-integrationcommand for easy setupUsage