diff --git a/README.md b/README.md index b0c6e84..ecf6aa9 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Configure API credentials for your desired LLM provider. See the [Installation G **Example (Gemini):** ```bash -cli-code-agent setup --provider=gemini YOUR_GOOGLE_API_KEY +cli-code setup --provider=gemini YOUR_GOOGLE_API_KEY ``` Configuration is typically stored in `~/.config/cli-code/config.yaml`, but can be overridden by environment variables or a custom file path. @@ -62,13 +62,13 @@ Configuration is typically stored in `~/.config/cli-code/config.yaml`, but can b Start an interactive chat session: ```bash # Use default provider/model -cli-code-agent +cli-code # Specify provider (uses provider's default model) -cli-code-agent --provider=ollama +cli-code --provider=ollama # Specify provider and model -cli-code-agent --provider=ollama --model llama3 +cli-code --provider=ollama --model llama3 ``` **Interactive Commands:** @@ -93,4 +93,4 @@ Contributions are welcome! Please see the [Contributing Guide](docs/contributing ## License -MIT \ No newline at end of file +MIT diff --git a/docs/install.md b/docs/install.md index 4ea510f..3c3b01e 100644 --- a/docs/install.md +++ b/docs/install.md @@ -25,7 +25,7 @@ Before using CLI-Code, you need to set up credentials for your chosen provider: ### For Gemini: ```bash -cli-code-agent setup --provider=gemini YOUR_GOOGLE_API_KEY +cli-code setup --provider=gemini YOUR_GOOGLE_API_KEY ``` To get a Google API key for Gemini: @@ -36,7 +36,7 @@ To get a Google API key for Gemini: ### For Ollama: ```bash -cli-code-agent setup --provider=ollama http://localhost:11434/v1 +cli-code setup --provider=ollama http://localhost:11434/v1 ``` Make sure your Ollama server is running and accessible at the specified URL. @@ -47,35 +47,35 @@ Make sure your Ollama server is running and accessible at the specified URL. ```bash # Start with default provider and model -cli-code-agent +cli-code # Start with a specific provider -cli-code-agent --provider=ollama +cli-code --provider=ollama # Start with a specific provider and model -cli-code-agent --provider=gemini --model models/gemini-2.5-pro-exp-03-25 -cli-code-agent --provider=ollama --model llama3 +cli-code --provider=gemini --model models/gemini-2.5-pro-exp-03-25 +cli-code --provider=ollama --model llama3 ``` ### Setting Default Preferences ```bash # Set default provider -cli-code-agent set-default-provider gemini +cli-code set-default-provider gemini # Set default model for a provider -cli-code-agent set-default-model --provider=gemini models/gemini-2.5-pro-exp-03-25 -cli-code-agent set-default-model --provider=ollama llama3 +cli-code set-default-model --provider=gemini models/gemini-2.5-pro-exp-03-25 +cli-code set-default-model --provider=ollama llama3 ``` ### Listing Available Models ```bash # List models for Gemini -cli-code-agent list-models --provider=gemini +cli-code list-models --provider=gemini # List models for Ollama -cli-code-agent list-models --provider=ollama +cli-code list-models --provider=ollama ``` ### Available Commands @@ -89,7 +89,7 @@ During an interactive session, you can use these commands: ### Config File -Configuration is stored in `~/.config/cli-code-agent/config.yaml` with this structure: +Configuration is stored in `~/.config/cli-code/config.yaml` with this structure: ```yaml google_api_key: YOUR_GEMINI_API_KEY_HERE @@ -121,9 +121,9 @@ CLI_CODE_OLLAMA_DEFAULT_MODEL=llama3.2:latest If you encounter issues: -1. Verify your API credentials are correct: `cat ~/.config/cli-code-agent/config.yaml` +1. Verify your API credentials are correct: `cat ~/.config/cli-code/config.yaml` 2. Ensure you have a working internet connection 3. Check that you have Python 3.9+ installed: `python --version` 4. For Ollama, ensure the Ollama server is running: `curl http://localhost:11434/v1/models` -For more help, visit: https://github.com/BlueCentre/cli-code \ No newline at end of file +For more help, visit: https://github.com/BlueCentre/cli-code diff --git a/docs/releases.md b/docs/releases.md index 4a37da1..282c4a7 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -10,7 +10,7 @@ Starting with version 0.2.0, the CLI Code Agent project uses GitHub Actions to a Here's a step-by-step record of the process used for the 0.3.0 release: -1. **Prepared Changes**: +1. **Prepared Changes**: - Completed all feature and bug fix work in the feature branch (`fix/gemini`) - Ensured all tests were passing and linting issues were fixed - Merged the feature branch into main via PR #24 @@ -18,7 +18,7 @@ Here's a step-by-step record of the process used for the 0.3.0 release: 2. **Version Bump and Changelog Update**: ```bash # Update version in pyproject.toml from 0.2.3 to 0.3.0 - + # Add new entry in docs/changelog.md with all significant changes: ## [0.3.0] - Improved Gemini error handling and UI feedback @@ -59,7 +59,7 @@ With version 0.3.0, we optimized the GitHub Actions workflow to reduce redundant # Trigger on specific events only on: push: - branches: + branches: - "main" tags: [ "v*" ] # Trigger on tags starting with v pull_request: @@ -130,7 +130,7 @@ Before the automated publishing will work, you need to configure publishing cred - Set up a new pending publisher: - Select GitHub Actions as the publisher - Enter your GitHub organization/username and repository name - - Enter "publish" as the environment name + - Enter "publish" as the environment name - Save the publisher settings - Set environment variable `USE_TRUSTED_PUBLISHING=true` @@ -242,7 +242,7 @@ After publishing, verify the package works correctly: # Create a fresh virtual environment python -m venv test_install_env source test_install_env/bin/activate # On Windows: test_install_env\Scripts\activate - + # Install the package directly from PyPI pip install cli-code-agent==x.y.z ``` @@ -251,9 +251,9 @@ After publishing, verify the package works correctly: ```bash # Verify the version is correct python -c "import cli_code; print(cli_code.__version__)" - + # Verify CLI command works - cli-code-agent --help + cli-code --help ``` ## Manual Publishing (Fallback) @@ -266,4 +266,4 @@ python -m build # Publish to PyPI (requires PyPI credentials) python -m twine upload dist/cli_code_agent-VERSION* -``` \ No newline at end of file +``` diff --git a/pr_body.txt b/pr_body.txt deleted file mode 100644 index 4c88f3e..0000000 --- a/pr_body.txt +++ /dev/null @@ -1,29 +0,0 @@ -# Refactor Agent Loop to Reduce Cognitive Complexity - -This PR addresses the SonarCloud issue related to high cognitive complexity in the `_execute_agent_loop` function within the GeminiModel class. The function had a complexity score of 26, whereas SonarCloud recommends a maximum of 15. - -## Changes Made - -1. Refactored `_execute_agent_loop` into three distinct methods: - - `_execute_agent_loop`: Now manages the main loop structure and outcome handling - - `_process_agent_iteration`: Handles a single iteration of the agent loop - - `_process_candidate_response`: Processes a single response candidate - -2. Introduced a clear result pattern using tuples with result types: - - `"error"`: Error that terminates processing - - `"continue"`: Continue the loop with updated state - - `"complete"`: Task is complete, return the final value - - `"task_completed"`: Set the task_completed flag - -3. Added comprehensive tests in a new file: `tests/models/test_gemini_agent_loop.py` - -## Benefits - -- Reduced cognitive complexity from 26 to well below the threshold of 15 -- Improved code maintainability with clearer responsibilities for each function -- Enhanced testability with more focused, single-responsibility methods -- Added comprehensive test coverage for the refactored methods - -## Note - -This refactoring maintains all original functionality while making the code structure cleaner and more maintainable. diff --git a/pyproject.toml b/pyproject.toml index 9578610..c4ab7d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,7 @@ dev = [ # This makes the `cli-code` command run the `cli` function in `main.py` [project.scripts] -cli-code-agent = "cli_code.main:cli" +cli-code = "cli_code.main:cli" # Remove the automatic package finding # [tool.setuptools.packages.find] diff --git a/src/cli_code/main.py b/src/cli_code/main.py index ff6abdf..a8ba09d 100644 --- a/src/cli_code/main.py +++ b/src/cli_code/main.py @@ -53,14 +53,14 @@ [medium_blue] - ░▒▓██████▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓██████▓▒░ ░▒▓██████▓▒░░▒▓███████▓▒░░▒▓████████▓▒░ -░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ -░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ -░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓██████▓▒░ -░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ -░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ - ░▒▓██████▓▒░░▒▓████████▓▒░▒▓█▓▒░ ░▒▓██████▓▒░ ░▒▓██████▓▒░░▒▓███████▓▒░░▒▓████████▓▒░ - + ░▒▓██████▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓██████▓▒░ ░▒▓██████▓▒░░▒▓███████▓▒░░▒▓████████▓▒░ +░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ +░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ +░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓██████▓▒░ +░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ +░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ + ░▒▓██████▓▒░░▒▓████████▓▒░▒▓█▓▒░ ░▒▓██████▓▒░ ░▒▓██████▓▒░░▒▓███████▓▒░░▒▓████████▓▒░ + [/medium_blue] """ # --- End ASCII Art --- @@ -408,10 +408,10 @@ def show_help(provider: str): /help CLI Commands: - cli-code-agent setup API_KEY - cli-code-agent list-models - cli-code-agent set-default-model NAME - cli-code-agent --model NAME + cli-code setup API_KEY + cli-code list-models + cli-code set-default-model NAME + cli-code --model NAME Workflow Hint: Analyze → Plan → Execute → Verify → Summarize