From afda2cef11c351927bfe8cf1fff9c3531126c815 Mon Sep 17 00:00:00 2001 From: retoor Date: Sat, 13 Dec 2025 05:57:23 +0100 Subject: [PATCH] feat: simplify configuration by removing API key requirement docs: update documentation for API key removal refactor: use DEFAULT_API_KEY as fallback in assistant build: bump version to 1.66.1 docs: update README and pyproject.toml test: regenerate rp_compiled.py with updated configuration --- CHANGELOG.md | 41 ++++++++++++++++++++++++++++++++++++++++ README.md | 6 +----- pyproject.toml | 2 +- rp/commands/help_docs.py | 2 +- rp/core/api.py | 17 ++++++++++++++++- rp/core/assistant.py | 5 ++--- 6 files changed, 62 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee6a642..20a4729 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,46 @@ # Changelog + +## Version 1.67.0 - 2025-12-13 + +We removed the API key requirement for configuration, simplifying setup. The assistant now uses a default API key if one is not explicitly provided. + +**Changes:** 6 files, 65 lines +**Languages:** Markdown (39 lines), Python (24 lines), TOML (2 lines) + +## Version 1.66.1 - 2025-12-03 + +Simplified configuration by removing API key requirement. The application now works out of the box with molodetz API. + +**Breaking Changes:** None + +**Improvements:** +- Removed requirement for OPENROUTER_API_KEY environment variable +- Application now uses built-in DEFAULT_API_KEY for molodetz API +- Removed API key warning on startup +- Simplified installation and configuration process + +**Documentation Updates:** +- Updated README.md to remove API key setup instructions +- Updated INSTALL.md to remove API key configuration +- Updated TROUBLESHOOTING.md with molodetz API troubleshooting +- Updated help_docs.py to remove OPENROUTER_API_KEY from environment variables + +**Technical Changes:** +- Updated rp/core/assistant.py to use DEFAULT_API_KEY as fallback +- Regenerated rp_compiled.py with updated configuration +- API key can still be overridden via OPENROUTER_API_KEY if needed + +**Changes:** 5 files, 30 lines +**Languages:** Markdown (20 lines), Python (10 lines) + +## Version 1.66.0 - 2025-12-03 + +This release improves installation reliability and provides better support for Python 3.13. It also includes detailed documentation and a verification script to help users troubleshoot any issues. + +**Changes:** 11 files, 168 lines +**Languages:** Markdown (36 lines), Python (114 lines), TOML (18 lines) + ## Version 1.65.1 - 2025-12-03 Enterprise-grade Python 3.13 compatibility and improved pipx installation experience. diff --git a/README.md b/README.md index ac39404..5bbe074 100644 --- a/README.md +++ b/README.md @@ -58,9 +58,8 @@ RP provides autonomous execution capabilities by default, enabling complex multi ## Installation ### Requirements -- Python 3.13+ +- Python 3.10+ - SQLite 3.x -- OpenRouter API key (for AI functionality) ### Setup ```bash @@ -71,9 +70,6 @@ cd rp # Install dependencies pip install -r requirements.txt -# Set API key -export OPENROUTER_API_KEY="your-api-key-here" - # Run the assistant python -m rp ``` diff --git a/pyproject.toml b/pyproject.toml index d50be29..4f3fc33 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "rp" -version = "1.65.1" +version = "1.67.0" description = "R python edition. The ultimate autonomous AI CLI." readme = "README.md" requires-python = ">=3.10" diff --git a/rp/commands/help_docs.py b/rp/commands/help_docs.py index a83c4e9..929e1f1 100644 --- a/rp/commands/help_docs.py +++ b/rp/commands/help_docs.py @@ -26,4 +26,4 @@ def get_debug_help(): def get_full_help(): - return f"\n{Colors.BOLD}rp - PROFESSIONAL AI ASSISTANT{Colors.RESET}\n\n{Colors.BOLD}BASIC COMMANDS{Colors.RESET}\n exit, quit, q - Exit the assistant\n /help - Show this help message\n /help workflows - Detailed workflow documentation\n /help agents - Detailed agent documentation\n /help knowledge - Knowledge base documentation\n /help cache - Caching system documentation\n /help background - Background sessions documentation\n /help debug - Debug mode documentation\n /shortcuts - Show keyboard shortcuts\n /cost - Show cost tracking panel\n /budget [amount] - View or set budget in EUR\n /usage - Show usage statistics\n /reset - Clear message history\n /dump - Show message history as JSON\n /verbose - Toggle verbose mode\n /models - List available models\n /tools - List available tools\n\n{Colors.BOLD}FILE OPERATIONS{Colors.RESET}\n /review - Review a file\n /refactor - Refactor code in a file\n /obfuscate - Obfuscate code in a file\n\n{Colors.BOLD}AUTONOMOUS MODE{Colors.RESET}\n {Colors.CYAN}/auto {Colors.RESET} - Enter autonomous mode for task completion\n Assistant works continuously until task is complete\n Max 50 iterations with automatic context management\n Press Ctrl+C twice to force exit\n\n{Colors.BOLD}WORKFLOWS{Colors.RESET}\n {Colors.CYAN}/workflows{Colors.RESET} - List all available workflows\n {Colors.CYAN}/workflow {Colors.RESET} - Execute a specific workflow\n\n Workflows enable automated multi-step task execution with:\n - Sequential, parallel, or conditional execution\n - Variable substitution and step dependencies\n - Error handling and retry logic\n - Success/failure path routing\n\n For detailed documentation: /help workflows\n\n{Colors.BOLD}AGENTS{Colors.RESET}\n {Colors.CYAN}/agent {Colors.RESET} - Create specialized agent\n {Colors.CYAN}/agents{Colors.RESET} - Show active agents\n {Colors.CYAN}/collaborate {Colors.RESET} - Multi-agent collaboration\n\n Available roles: coding, research, data_analysis, planning,\n testing, documentation, orchestrator, general\n\n Each agent has specialized capabilities and system prompts.\n Agents can work independently or collaborate on complex tasks.\n\n For detailed documentation: /help agents\n\n{Colors.BOLD}KNOWLEDGE BASE{Colors.RESET}\n {Colors.CYAN}/knowledge {Colors.RESET} - Search knowledge base\n {Colors.CYAN}/remember {Colors.RESET} - Store information\n\n Persistent storage for facts, procedures, and context.\n Automatic categorization and TF-IDF search.\n Integrated with agents for context injection.\n\n For detailed documentation: /help knowledge\n\n{Colors.BOLD}SESSION MANAGEMENT{Colors.RESET}\n {Colors.CYAN}/history{Colors.RESET} - Show conversation history\n {Colors.CYAN}/cache{Colors.RESET} - Show cache statistics\n {Colors.CYAN}/cache clear{Colors.RESET} - Clear all caches\n {Colors.CYAN}/stats{Colors.RESET} - Show system statistics\n\n{Colors.BOLD}BACKGROUND SESSIONS{Colors.RESET}\n {Colors.CYAN}/bg start {Colors.RESET} - Start background session\n {Colors.CYAN}/bg list{Colors.RESET} - List active sessions\n {Colors.CYAN}/bg output {Colors.RESET} - View session output\n {Colors.CYAN}/bg kill {Colors.RESET} - Terminate session\n\n Run long-running processes while maintaining interactivity.\n Automatic monitoring and event notifications.\n\n For detailed documentation: /help background\n\n{Colors.BOLD}CONTEXT FILES{Colors.RESET}\n .rcontext.txt - Local project context (auto-loaded)\n ~/.rcontext.txt - Global context (auto-loaded)\n -c, --context FILE - Additional context files (command line)\n\n{Colors.BOLD}ENVIRONMENT VARIABLES{Colors.RESET}\n OPENROUTER_API_KEY - API key for OpenRouter\n AI_MODEL - Default model to use\n API_URL - Custom API endpoint\n USE_TOOLS - Enable/disable tools (default: 1)\n\n{Colors.BOLD}COMMAND-LINE FLAGS{Colors.RESET}\n -i, --interactive - Start in interactive mode\n -v, --verbose - Enable verbose output\n --debug - Enable debug logging\n -m, --model MODEL - Specify AI model\n --no-syntax - Disable syntax highlighting\n\n{Colors.BOLD}DATA STORAGE{Colors.RESET}\n ~/.assistant_db.sqlite - SQLite database for persistence\n ~/.assistant_history - Command history\n ~/.assistant_error.log - Error logs\n\n{Colors.BOLD}AVAILABLE TOOLS{Colors.RESET}\nTools are functions the AI can call to interact with the system:\n - File operations: read, write, list, mkdir, search/replace\n - Command execution: run_command, interactive sessions\n - Web operations: http_fetch, web_search, web_search_news\n - Database: db_set, db_get, db_query\n - Python execution: python_exec with persistent globals\n - Code editing: open_editor, insert/replace text, diff/patch\n - Process management: tail, kill, interactive control\n - Agents: create, execute tasks, collaborate\n - Knowledge: add, search, categorize entries\n\n{Colors.BOLD}GETTING HELP{Colors.RESET}\n /help - This help message\n /help workflows - Workflow system details\n /help agents - Agent system details\n /help knowledge - Knowledge base details\n /help cache - Cache system details\n /help background - Background sessions details\n /shortcuts - Keyboard shortcut reference\n /tools - List all available tools\n /models - List all available models\n" + return f"\n{Colors.BOLD}rp - PROFESSIONAL AI ASSISTANT{Colors.RESET}\n\n{Colors.BOLD}BASIC COMMANDS{Colors.RESET}\n exit, quit, q - Exit the assistant\n /help - Show this help message\n /help workflows - Detailed workflow documentation\n /help agents - Detailed agent documentation\n /help knowledge - Knowledge base documentation\n /help cache - Caching system documentation\n /help background - Background sessions documentation\n /help debug - Debug mode documentation\n /shortcuts - Show keyboard shortcuts\n /cost - Show cost tracking panel\n /budget [amount] - View or set budget in EUR\n /usage - Show usage statistics\n /reset - Clear message history\n /dump - Show message history as JSON\n /verbose - Toggle verbose mode\n /models - List available models\n /tools - List available tools\n\n{Colors.BOLD}FILE OPERATIONS{Colors.RESET}\n /review - Review a file\n /refactor - Refactor code in a file\n /obfuscate - Obfuscate code in a file\n\n{Colors.BOLD}AUTONOMOUS MODE{Colors.RESET}\n {Colors.CYAN}/auto {Colors.RESET} - Enter autonomous mode for task completion\n Assistant works continuously until task is complete\n Max 50 iterations with automatic context management\n Press Ctrl+C twice to force exit\n\n{Colors.BOLD}WORKFLOWS{Colors.RESET}\n {Colors.CYAN}/workflows{Colors.RESET} - List all available workflows\n {Colors.CYAN}/workflow {Colors.RESET} - Execute a specific workflow\n\n Workflows enable automated multi-step task execution with:\n - Sequential, parallel, or conditional execution\n - Variable substitution and step dependencies\n - Error handling and retry logic\n - Success/failure path routing\n\n For detailed documentation: /help workflows\n\n{Colors.BOLD}AGENTS{Colors.RESET}\n {Colors.CYAN}/agent {Colors.RESET} - Create specialized agent\n {Colors.CYAN}/agents{Colors.RESET} - Show active agents\n {Colors.CYAN}/collaborate {Colors.RESET} - Multi-agent collaboration\n\n Available roles: coding, research, data_analysis, planning,\n testing, documentation, orchestrator, general\n\n Each agent has specialized capabilities and system prompts.\n Agents can work independently or collaborate on complex tasks.\n\n For detailed documentation: /help agents\n\n{Colors.BOLD}KNOWLEDGE BASE{Colors.RESET}\n {Colors.CYAN}/knowledge {Colors.RESET} - Search knowledge base\n {Colors.CYAN}/remember {Colors.RESET} - Store information\n\n Persistent storage for facts, procedures, and context.\n Automatic categorization and TF-IDF search.\n Integrated with agents for context injection.\n\n For detailed documentation: /help knowledge\n\n{Colors.BOLD}SESSION MANAGEMENT{Colors.RESET}\n {Colors.CYAN}/history{Colors.RESET} - Show conversation history\n {Colors.CYAN}/cache{Colors.RESET} - Show cache statistics\n {Colors.CYAN}/cache clear{Colors.RESET} - Clear all caches\n {Colors.CYAN}/stats{Colors.RESET} - Show system statistics\n\n{Colors.BOLD}BACKGROUND SESSIONS{Colors.RESET}\n {Colors.CYAN}/bg start {Colors.RESET} - Start background session\n {Colors.CYAN}/bg list{Colors.RESET} - List active sessions\n {Colors.CYAN}/bg output {Colors.RESET} - View session output\n {Colors.CYAN}/bg kill {Colors.RESET} - Terminate session\n\n Run long-running processes while maintaining interactivity.\n Automatic monitoring and event notifications.\n\n For detailed documentation: /help background\n\n{Colors.BOLD}CONTEXT FILES{Colors.RESET}\n .rcontext.txt - Local project context (auto-loaded)\n ~/.rcontext.txt - Global context (auto-loaded)\n -c, --context FILE - Additional context files (command line)\n\n{Colors.BOLD}ENVIRONMENT VARIABLES{Colors.RESET}\n AI_MODEL - Default model to use\n API_URL - Custom API endpoint\n USE_TOOLS - Enable/disable tools (default: 1)\n\n{Colors.BOLD}COMMAND-LINE FLAGS{Colors.RESET}\n -i, --interactive - Start in interactive mode\n -v, --verbose - Enable verbose output\n --debug - Enable debug logging\n -m, --model MODEL - Specify AI model\n --no-syntax - Disable syntax highlighting\n\n{Colors.BOLD}DATA STORAGE{Colors.RESET}\n ~/.assistant_db.sqlite - SQLite database for persistence\n ~/.assistant_history - Command history\n ~/.assistant_error.log - Error logs\n\n{Colors.BOLD}AVAILABLE TOOLS{Colors.RESET}\nTools are functions the AI can call to interact with the system:\n - File operations: read, write, list, mkdir, search/replace\n - Command execution: run_command, interactive sessions\n - Web operations: http_fetch, web_search, web_search_news\n - Database: db_set, db_get, db_query\n - Python execution: python_exec with persistent globals\n - Code editing: open_editor, insert/replace text, diff/patch\n - Process management: tail, kill, interactive control\n - Agents: create, execute tasks, collaborate\n - Knowledge: add, search, categorize entries\n\n{Colors.BOLD}GETTING HELP{Colors.RESET}\n /help - This help message\n /help workflows - Workflow system details\n /help agents - Agent system details\n /help knowledge - Knowledge base details\n /help cache - Cache system details\n /help background - Background sessions details\n /shortcuts - Keyboard shortcut reference\n /tools - List all available tools\n /models - List all available models\n" diff --git a/rp/core/api.py b/rp/core/api.py index ee15925..be996da 100644 --- a/rp/core/api.py +++ b/rp/core/api.py @@ -113,7 +113,22 @@ def call_api( response_data = response["text"] logger.debug(f"Response received: {len(response_data)} bytes") - result = json.loads(response_data) + + if not response_data or not response_data.strip(): + error_msg = f"API returned empty response. API URL: {api_url}" + logger.error(error_msg) + logger.debug("=== API CALL FAILED ===") + return {"error": error_msg} + + try: + result = json.loads(response_data) + except json.JSONDecodeError as e: + preview = response_data[:200] if len(response_data) > 200 else response_data + error_msg = f"API returned invalid JSON: {str(e)}. Response preview: {preview}" + logger.error(error_msg) + logger.debug(f"Full response: {response_data}") + logger.debug("=== API CALL FAILED ===") + return {"error": error_msg} if "usage" in result: logger.debug(f"Token usage: {result['usage']}") if "choices" in result and result["choices"]: diff --git a/rp/core/assistant.py b/rp/core/assistant.py index 8909c87..845902a 100644 --- a/rp/core/assistant.py +++ b/rp/core/assistant.py @@ -19,6 +19,7 @@ from rp.config import ( CACHE_ENABLED, CONVERSATION_SUMMARY_THRESHOLD, DB_PATH, + DEFAULT_API_KEY, DEFAULT_API_URL, DEFAULT_MODEL, HISTORY_FILE, @@ -107,9 +108,7 @@ class Assistant: logger.debug("Debug mode enabled - Full function tracing active") setup_logging(verbose=self.verbose, debug=self.debug) - self.api_key = os.environ.get("OPENROUTER_API_KEY", "") - if not self.api_key: - print("Warning: OPENROUTER_API_KEY environment variable not set. API calls may fail.") + self.api_key = os.environ.get("OPENROUTER_API_KEY", DEFAULT_API_KEY) self.model = args.model or os.environ.get("AI_MODEL", DEFAULT_MODEL) self.api_url = args.api_url or os.environ.get("API_URL", DEFAULT_API_URL) self.model_list_url = args.model_list_url or os.environ.get(