Geany Copilot is an AI-powered assistant integrated into the Geany IDE. Inspired by GitHub Copilot, it leverages advanced language models to provide context-aware code completions and creative copywriting assistance, enhancing your productivity and creativity directly within the Geany editor.
New Enhanced Python Implementation with Agent Capabilities!
git clone https://github.com/skizap/geany-copilot.git
cd geany-copilot
./install.shThe automated installer handles everything: dependency installation, legacy file management, and plugin setup. See INSTALL_GUIDE.md for detailed instructions.
- π€ Agent Intelligence: Multi-turn conversations with context retention
- π Enhanced API Support: DeepSeek, OpenAI, and custom providers
- π¨ Modern UI: GTK-based dialogs with comprehensive functionality
- π‘οΈ Enterprise Security: OS keyring integration, secure API key storage, prompt injection protection
- π Performance Optimization: Intelligent caching, predictive preloading, memory management
- π Advanced Monitoring: Real-time performance metrics, error tracking, health reporting
- π§ Easy Installation: Automated setup with one command
- π οΈ Reliability: Thread-safe operations, graceful error recovery, comprehensive validation
| Feature | Python Version | Lua Version (Legacy) |
|---|---|---|
| Agent Conversations | β Multi-turn with context | β Single requests only |
| API Support | β DeepSeek + OpenAI + Custom | β OpenAI compatible |
| User Interface | β Modern GTK dialogs | β Basic dialogs |
| Security | β Enterprise-grade (keyring, validation) | |
| Performance | β Intelligent caching & optimization | β No optimization |
| Monitoring | β Real-time metrics & health reports | β No monitoring |
| Error Handling | β Comprehensive with recovery | β Basic |
| Installation | β Automated script | |
| Testing | β Full test suite | β No tests |
| Maintenance | β Active development | π Legacy support |
π‘ Recommendation: Use the Python version for new installations. Legacy Lua files are preserved in the OLD/ directory.
The Python version of Geany Copilot features enterprise-grade security, reliability, and performance improvements:
- π Secure API Key Storage: OS keyring integration (Windows Credential Manager, macOS Keychain, Linux Secret Service)
- π Environment Variable Support: Fallback to
DEEPSEEK_API_KEY,OPENAI_API_KEYenvironment variables - π‘οΈ Prompt Injection Protection: Advanced detection and prevention of malicious prompt injection attempts
- π Secure Logging: Automatic sanitization of sensitive data in logs (API keys, tokens, passwords)
- π File Security: Restrictive permissions (600) on configuration files and secure directory creation
- β Input Validation: Comprehensive validation and sanitization of user input and context data
- π§ Intelligent Caching: Smart cache keys with context similarity and predictive preloading
- π Real-time Monitoring: Performance metrics, operation timing, and success/error rate tracking
- π Memory Management: Automatic conversation history limits, cache optimization, and memory cleanup
- βοΈ Auto-Optimization: Periodic performance tuning and resource optimization
- π Cache Efficiency: Hit rate optimization (~30% improvement) and memory usage reduction (~25%)
- π§ Thread Safety: GTK operations guaranteed to run on main thread, preventing UI crashes
- π Graceful Recovery: Automatic error recovery, circuit breaker patterns, and fallback strategies
- π Health Monitoring: Continuous system health assessment with actionable recommendations
β οΈ Graceful Degradation: Non-essential features disabled under high error rates to maintain stability- π Comprehensive Validation: Configuration validation with auto-fix capabilities
- π Performance Metrics: Real-time tracking of response times, cache hit rates, and system performance
- π¨ Error Tracking: Detailed error categorization, trend analysis, and recovery success rates
- π‘ Health Reports: Comprehensive system health reports with optimization recommendations
- π Configuration Validation: Automatic detection and correction of configuration issues
- Quick Start - Python Version
- Security & Performance
- Features
- Installation
- Configuration
- Usage
- Troubleshooting
- Migration Guide
- Dependencies
- Contributing
- License
- Acknowledgements
- Contact
- Multi-turn Conversations: Context-aware conversations with memory retention across interactions
- Intelligent Code Completions: Advanced code suggestions based on your current context and coding patterns
- Creative Copywriting Assistance: Generate and refine creative content with constructive feedback and suggestions
- Context Analysis: Automatic analysis of surrounding code and project context for better suggestions
- Secure Credential Management: OS keyring integration for API key storage with environment variable fallback
- Prompt Injection Protection: Advanced detection and prevention of malicious prompt injection attempts
- Secure Logging: Automatic sanitization of sensitive data in logs and debug output
- Input Validation: Comprehensive validation and sanitization of all user input and context data
- File Security: Secure file permissions and encrypted configuration storage
- Intelligent Caching: Smart caching with predictive preloading and context-aware invalidation
- Memory Management: Automatic conversation history limits and memory optimization
- Thread Safety: GTK operations guaranteed to run on main thread, preventing crashes
- Error Recovery: Graceful error handling with automatic recovery and fallback strategies
- Health Monitoring: Real-time performance metrics and system health assessment
- Modern UI: GTK-based dialogs with comprehensive functionality and responsive design
- Seamless Integration: Works directly within Geany, maintaining your workflow without tool switching
- Configuration Validation: Automatic validation and correction of configuration issues
- Customizable Settings: Easily configure API endpoints, system prompts, and behavior preferences
- Selection Replacement: Option to replace selected text with AI-generated suggestions
π Automated Installation:
git clone https://github.com/skizap/geany-copilot.git
cd geany-copilot
./install.shThe installation script automatically:
- β Checks prerequisites (Python 3.6+, pip, Geany)
- β
Moves legacy Lua files to
OLD/directory - β
Installs Python dependencies (
requests,keyringfor secure API key storage) - β Copies plugin files to appropriate Geany directory
- β Sets secure file permissions (600) on configuration files
- β Verifies installation and runs comprehensive tests
π Prerequisites:
- Geany IDE with GeanyPy plugin support
- Python 3.6+ (Python 3.8+ recommended)
- pip package manager
π Detailed Instructions: See INSTALL_GUIDE.md for comprehensive installation guide.
Prerequisites:
- Geany IDE with Lua scripting support
- Dependencies:
lunajsonlibrary andcURL
Steps:
-
Restore Legacy Files (if you want to use the Lua version):
cp OLD/*.lua ./ -
Install Dependencies:
Ensure that the
lunajsonlibrary is available. You can install it using LuaRocks:luarocks install lunajson
Additionally, ensure that
cURLis installed on your system:# For Debian/Ubuntu sudo apt-get install curl # For macOS using Homebrew brew install curl
-
Place the Plugins in Geany's Plugin Directory:
Copy the Lua scripts (
copilot.luaandcopywriter.lua) to Geany's plugin or script directory, typically located at~/.config/geany/plugins/or a similar path depending on your operating system.mkdir -p ~/.config/geany/plugins/geanylua/geany-copilot/ cp copilot.lua copywriter.lua ~/.config/geany/plugins/geanylua/geany-copilot/
-
Restart Geany:
After placing the plugins, restart Geany in case the lua scripts didn't load automatically.
Geany Copilot features enterprise-grade configuration management with automatic validation, secure credential storage, and health monitoring. The Python version provides enhanced security and user experience compared to the legacy Lua version.
- π Secure API Key Storage: Automatic OS keyring integration (Windows Credential Manager, macOS Keychain, Linux Secret Service)
- π Environment Variable Support: Fallback to
DEEPSEEK_API_KEY,OPENAI_API_KEYenvironment variables - β Automatic Validation: Real-time configuration validation with error detection and auto-fix capabilities
- π Health Monitoring: Configuration health reports with optimization recommendations
- π Secure Permissions: Automatic secure file permissions (600) on all configuration files
-
Code Assistance Settings:
~/.config/geany/plugins/geanylua/geany-copilot/copilot.json -
Copywriting Assistance Settings:
~/.config/geany/plugins/geanylua/geany-copilot/copywriter.json
-
(Optional): Setup shortcuts Open the Keybindings section under Geany Preferences. Scroll down to "Lua Script" sub-section and set the shortcut for both "Copilot" and "Copywriter". For example: backslash and Return respectively.
-
Open Geany Copilot Settings Dialog:
In Geany, you can access the settings dialog through either a plugin menu or a keyboard shortcut. The initial dialog will feature a "Settings" button. Alternatively, you can directly invoke the settings dialog by typing and selecting ".gc conf" anywhere within the editor, followed by activating the keyboard shortcut.
-
Configure API Settings:
- Primary Provider: Choose your preferred AI provider (DeepSeek, OpenAI, or custom)
- Base URL: Enter your API base URL (e.g.,
https://api.deepseek.comfor DeepSeek) - API Key: Your API key is automatically stored securely using:
- OS Keyring (Windows Credential Manager, macOS Keychain, Linux Secret Service) - Recommended
- Environment Variables (
DEEPSEEK_API_KEY,OPENAI_API_KEY) - Secure fallback - Configuration file - Not recommended for production
π Security Note: The plugin automatically detects and uses the most secure storage method available on your system.
π Supported Providers: Any OpenAI-compatible API (DeepSeek, OpenAI, Ollama, llama-server, etc.)
-
Customize System Prompt:
- Code Assistance: Defines the behavior of the AI assistant for coding tasks.
- Copywriting Assistance: Defines the behavior of the AI assistant for copywriting tasks.
-
Behavior Preferences:
- Replace Selection: Choose whether the AI-generated suggestion should replace the currently selected text.
-
Save Settings:
Click the Save button to apply your configurations.
Once installed and configured, Geany Copilot is ready to assist you with both code completions and copywriting tasks.
Geany Copilot for code assistance operates similarly to GitHub Copilot, providing intelligent code suggestions based on your current context within the Geany editor.
-
Select Code Context:
Highlight the code snippet you want the AI to analyze and complete. If no text is selected, Geany Copilot will automatically determine a context around the current caret position.
-
Invoke Geany Copilot:
- Use a designated keyboard shortcut.
- Access via the plugin menu.
-
Review Suggestions:
Geany Copilot will display a dialog with AI-generated code completion options (usually 1). Review the suggestions, select the one that best fits your needs and click Accept.
-
Apply Completion:
Upon selection, the chosen code snippet will replace the original selection.
Geany Copilot also offers creative copywriting assistance, helping you generate and refine written content directly within the Geany editor.
-
Select Text or Position Caret:
- To generate new content, place the caret where you want the text to be inserted.
- To review or refine existing text, highlight the text you wish to work on.
-
Invoke Copywriting Assistant:
- Use a designated keyboard shortcut.
- Access via the plugin menu.
-
Choose an Action:
- Generate Content: Create new text based on the provided context.
- Review Text: Get constructive feedback and suggestions for improvement.
-
Review and Apply Suggestions:
The assistant will display a dialog with AI-generated suggestions. Choose the appropriate option to insert or replace text, depending on your configuration.
- Problem: "API key not found" or authentication errors
- Solutions:
- Check keyring storage:
python3 -c "import keyring; print(keyring.get_password('geany-copilot', 'deepseek_api_key'))" - Use environment variables:
export DEEPSEEK_API_KEY="your-key-here" - Verify API key validity: Test with a simple API call
- Check configuration health: Use the built-in health report feature
- Check keyring storage:
- Problem: Slow responses or high memory usage
- Solutions:
- Check cache efficiency: View cache hit rates in performance stats
- Optimize cache settings: Increase cache size or memory limits
- Monitor system health: Use the built-in health monitoring
- Clear cache: Reset cache if it becomes corrupted
- Problem: Timeouts or connection errors
- Solutions:
- Check network connectivity: Verify internet connection
- Verify API endpoint: Ensure the base URL is correct
- Check firewall settings: Ensure outbound HTTPS is allowed
- Review timeout settings: Adjust timeout values in configuration
- Problem: Plugin freezes or crashes Geany
- Solutions:
- Restart Geany: The plugin includes automatic recovery mechanisms
- Check logs: Review
~/.config/geany/plugins/geany-copilot-python/logs/ - Update GeanyPy: Ensure you have the latest GeanyPy version
- Report issue: Include system details and error logs
The plugin includes comprehensive health monitoring:
# Access health reports through the plugin interface
Tools β Copilot β Health ReportHealth indicators include:
- Configuration validation status
- API connectivity and response times
- Cache efficiency and memory usage
- Error rates and recovery success
- Security status and recommendations
Enable debug mode for detailed troubleshooting:
- Enable debug logging: Set
debug: truein configuration - View logs: Check
~/.config/geany/plugins/geany-copilot-python/logs/geany-copilot-python.log - Monitor performance: Use built-in performance metrics
- Export diagnostics: Generate diagnostic reports for support
The plugin automatically validates configuration and provides recommendations:
- Automatic error detection: Invalid settings are flagged immediately
- Auto-fix capabilities: Common issues are corrected automatically
- Health scoring: Configuration health is scored from 0-100
- Optimization recommendations: Specific suggestions for improvement
If you're currently using the Lua version and want to upgrade to the Python version:
-
Backup Your Configuration (optional):
cp ~/.config/geany/plugins/geanylua/geany-copilot-python/config.json ~/geany-copilot-backup.json
-
Run the Installation Script:
./install.sh
The script automatically moves your Lua files to the
OLD/directory and installs the Python version. -
Reconfigure API Settings:
- Go to Tools β Copilot β Settings in Geany
- Enter your API key and configure preferences
- The Python version supports additional providers like DeepSeek
-
Test the New Features:
- Try the enhanced code assistant with multi-turn conversations
- Explore the improved copywriting interface
- Experience better error handling and logging
If you need to revert to the Lua version:
-
Remove Python Plugin:
rm -rf ~/.config/geany/plugins/geany-copilot-python/ -
Restore Lua Files:
cp OLD/*.lua ./ -
Reconfigure Geany to use the Lua scripts as before.
- Python 3.6+ (Python 3.8+ recommended, automatically checked by installer)
- pip package manager (automatically checked)
- Core Libraries (automatically installed):
- requests - HTTP client for API communication
- keyring - Secure API key storage using OS keyring
- System Dependencies:
- GTK+ 3.0+ (usually system-provided)
- GeanyPy plugin (see GeanyPy Installation Guide below)
- Optional Dependencies (for enhanced features):
- psutil - System monitoring and performance metrics
- cryptography - Enhanced security features
-
Lua: Ensure that Lua is installed and properly configured with Geany.
-
lunajson: A Lua library for JSON encoding and decoding. Install via LuaRocks:
luarocks install lunajson
-
cURL: The plugin uses
cURLto make HTTP requests to the OpenAI API. Ensure thatcURLis installed on your system.# For Debian/Ubuntu sudo apt-get install curl # For macOS using Homebrew brew install curl
Since you're using Linux Mint with Geany 2.1.0, here are the specific steps to install GeanyPy:
# Update package list
sudo apt update
# Install GeanyPy (try these in order)
sudo apt install geany-plugin-py
# OR if the above fails:
sudo apt install geany-plugins
# Install Python GTK dependencies
sudo apt install python3-gi python3-gi-cairo gir1.2-gtk-3.0- Restart Geany completely:
killall geany && geany - Open Plugin Manager: Tools β Plugin Manager
- Look for GeanyPy: Should appear in the plugin list
- Enable GeanyPy: Check the checkbox and click OK
- Test: Look for Python plugin support
If GeanyPy doesn't appear, run our troubleshooting script:
./troubleshoot_geanypy.shThis script will:
- β Detect your exact Linux Mint version
- β Check for GeanyPy packages
- β Install missing dependencies
- β Test Python GTK bindings
- β Create a test plugin to verify functionality
- β Provide specific fixes for your system
Different Linux distributions use different package names:
| Distribution | Package Name |
|---|---|
| Linux Mint/Ubuntu/Debian | geany-plugin-py or geany-plugins |
| Fedora/CentOS | geany-plugins-geanypy |
| Arch Linux | geany-plugins |
| openSUSE | geany-plugin-geanypy |
Check if GeanyPy is installed:
# Check installed packages
dpkg -l | grep geany-plugin
# Look for GeanyPy files
find /usr -name "*geanypy*" 2>/dev/null
find /usr -name "*py.so" 2>/dev/null
# Test Python GTK
python3 -c "import gi; gi.require_version('Gtk', '3.0'); from gi.repository import Gtk; print('GTK OK')"- Check detailed guide: See GEANYPY_INSTALLATION.md
- Use troubleshooting script:
./troubleshoot_geanypy.sh - Fallback to Lua version: Files preserved in
OLD/directory - Report issue: Include your system details and error messages
GeanyPy is special because it's a "plugin framework" that allows Python scripts to act as Geany plugins:
- Regular Geany plugins: Written in C/C++, compiled as
.sofiles - GeanyPy plugins: Written in Python, loaded through GeanyPy framework
- GeanyLua plugins: Written in Lua (what we're migrating from)
Why GeanyPy is Required:
- Our Python plugin uses GeanyPy's API to integrate with Geany
- Without GeanyPy, Python plugins cannot access Geany's interface
- GeanyPy provides the bridge between Python and Geany's C API
Contributions are welcome! If you'd like to contribute to Geany Copilot, please follow these guidelines:
-
Fork the Repository:
Click the Fork button at the top of this page to create a personal copy of the repository.
-
Create a Feature Branch:
git checkout -b feature/your-feature-name
-
Commit Your Changes:
git commit -m "Add your detailed description of the changes" -
Push to Your Fork:
git push origin feature/your-feature-name
-
Open a Pull Request:
Navigate to the original repository and click New Pull Request. Provide a clear description of your changes and submit the pull request.
If you encounter any issues or have suggestions for improvements, please open an issue on GitHub.
This project is licensed under the MIT License. You are free to use, modify, and distribute this software in accordance with the terms of the license.
Security & Privacy: Geany Copilot features enterprise-grade security with OS keyring integration for secure API key storage, automatic sensitive data sanitization, and prompt injection protection. The plugin never logs API keys or sensitive information. Be aware of any costs associated with API usage and review your provider's privacy policy.
- Inspired by Geany IDE and GitHub Copilot.
- Utilizes the lunajson library for JSON handling.
- Powered by OpenAI's language models.
- https://github.com/DevElCuy/geany-copilot
For any queries or support, please reach out to https://github.com/skizap.
Happy Coding and Writing! π