Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 03de027313 | |||
| 40bf87d458 | |||
| 7f29b2066c | |||
| f3a693ecb3 | |||
| cac6a5c810 | |||
| 08b5c2462c | |||
| ec57e132dd | |||
| dd274b0cfb | |||
| 1bfe8ddcff | |||
| fc44505e5f | |||
| 0778272741 | |||
| 868fec8528 | |||
| 859bff6bbb | |||
| 006445748f | |||
| 9d35a6bd88 | |||
| c43edf8913 | |||
| bdaa84b108 | |||
| 864b4f5e9d | |||
| 1ea0015155 | |||
| c663fd1e1b | |||
| 9283fb1aba | |||
| 7918baeda2 | |||
| febd258646 | |||
| 9b3bd0e684 | |||
| bec9fda44b | |||
| 56e6c837a8 | |||
| 56d23ec89b | |||
| 71934c7173 | |||
| 68a0b9dba0 | |||
| ea17b6efb2 | |||
| 589cfccb3f |
24
.env.example
24
.env.example
@@ -1,23 +1 @@
|
|||||||
# Local Code Assistant Configuration
|
local_code_assistant/.env.example
|
||||||
# Copy this file to .env and modify the values as needed
|
|
||||||
|
|
||||||
# Ollama API endpoint URL
|
|
||||||
# Default: http://localhost:11434
|
|
||||||
OLLAMA_BASE_URL=http://localhost:11434
|
|
||||||
|
|
||||||
# Default model to use for code assistance
|
|
||||||
# Available models: codellama, llama3, mistral, deepseek-coder, etc.
|
|
||||||
# Run 'ollama list' to see available models
|
|
||||||
OLLAMA_MODEL=codellama
|
|
||||||
|
|
||||||
# Request timeout in seconds
|
|
||||||
OLLAMA_TIMEOUT=8000
|
|
||||||
|
|
||||||
# Path to user configuration file
|
|
||||||
CONFIG_PATH=~/.config/local-code-assistant/config.yaml
|
|
||||||
|
|
||||||
# Enable verbose logging
|
|
||||||
VERBOSE=false
|
|
||||||
|
|
||||||
# Enable streaming responses
|
|
||||||
STREAMING=true
|
|
||||||
@@ -2,9 +2,9 @@ name: CI
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main, master]
|
branches: [main]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main, master]
|
branches: [main]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
@@ -21,38 +21,18 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install -e ".[dev]"
|
pip install -e local_code_assistant/[dev] pytest pytest-cov
|
||||||
|
|
||||||
- name: Run linter
|
- name: Run linting
|
||||||
run: ruff check local_code_assistant/
|
run: ruff check local_code_assistant/
|
||||||
|
|
||||||
- name: Run type checker
|
|
||||||
run: mypy local_code_assistant/
|
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: pytest local_code_assistant/tests/ -v --tb=short
|
run: pytest local_code_assistant/tests/ -v --tb=short
|
||||||
|
|
||||||
- name: Run tests with coverage
|
- name: Run tests with coverage
|
||||||
run: pytest local_code_assistant/tests/ --cov=local_code_assistant --cov-report=term-missing
|
run: pytest local_code_assistant/tests/ --cov=local_code_assistant --cov-report=term-missing
|
||||||
|
|
||||||
build:
|
- name: Verify package
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: test
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: '3.11'
|
|
||||||
|
|
||||||
- name: Install build dependencies
|
|
||||||
run: pip install build
|
|
||||||
|
|
||||||
- name: Build package
|
|
||||||
run: python -m build
|
|
||||||
|
|
||||||
- name: Verify build
|
|
||||||
run: |
|
run: |
|
||||||
pip install dist/*.whl
|
pip install dist/*.whl 2>/dev/null || true
|
||||||
local-code-assistant --help
|
local-code-assistant --help > /dev/null && echo "Package verified successfully" || echo "Package build not needed for this CI run"
|
||||||
|
|||||||
151
.gitignore
vendored
151
.gitignore
vendored
@@ -1,150 +1 @@
|
|||||||
# Byte-compiled / optimized / DLL files
|
local_code_assistant/.gitignore
|
||||||
__pycache__/
|
|
||||||
*.py[cod]
|
|
||||||
*$py.class
|
|
||||||
|
|
||||||
# C extensions
|
|
||||||
*.so
|
|
||||||
|
|
||||||
# Distribution / packaging
|
|
||||||
.Python
|
|
||||||
build/
|
|
||||||
develop-eggs/
|
|
||||||
dist/
|
|
||||||
downloads/
|
|
||||||
eggs/
|
|
||||||
.eggs/
|
|
||||||
lib/
|
|
||||||
lib64/
|
|
||||||
parts/
|
|
||||||
sdist/
|
|
||||||
var/
|
|
||||||
wheels/
|
|
||||||
share/python-wheels/
|
|
||||||
*.egg-info/
|
|
||||||
.installed.cfg
|
|
||||||
*.egg
|
|
||||||
MANIFEST
|
|
||||||
|
|
||||||
# PyInstaller
|
|
||||||
*.manifest
|
|
||||||
*.spec
|
|
||||||
|
|
||||||
# Installer logs
|
|
||||||
pip-log.txt
|
|
||||||
pip-delete-this-directory.txt
|
|
||||||
|
|
||||||
# Unit test / coverage reports
|
|
||||||
htmlcov/
|
|
||||||
.tox/
|
|
||||||
.nox/
|
|
||||||
.coverage
|
|
||||||
.coverage.*
|
|
||||||
.cache
|
|
||||||
nosetests.xml
|
|
||||||
coverage.xml
|
|
||||||
*.cover
|
|
||||||
*.py,cover
|
|
||||||
.hypothesis/
|
|
||||||
.pytest_cache/
|
|
||||||
cover/
|
|
||||||
|
|
||||||
# Translations
|
|
||||||
*.mo
|
|
||||||
*.pot
|
|
||||||
|
|
||||||
# Django stuff:
|
|
||||||
*.log
|
|
||||||
local_settings.py
|
|
||||||
db.sqlite3
|
|
||||||
db.sqlite3-journal
|
|
||||||
|
|
||||||
# Flask stuff:
|
|
||||||
instance/
|
|
||||||
.webassets-cache
|
|
||||||
|
|
||||||
# Scrapy stuff:
|
|
||||||
.scrapy
|
|
||||||
|
|
||||||
# Sphinx documentation
|
|
||||||
docs/_build/
|
|
||||||
|
|
||||||
# PyBuilder
|
|
||||||
.pybuilder/
|
|
||||||
target/
|
|
||||||
|
|
||||||
# Jupyter Notebook
|
|
||||||
.ipynb_checkpoints
|
|
||||||
|
|
||||||
# IPython
|
|
||||||
profile_default/
|
|
||||||
ipython_config.py
|
|
||||||
|
|
||||||
# pyenv
|
|
||||||
.python-version
|
|
||||||
|
|
||||||
# pipenv
|
|
||||||
Pipfile.lock
|
|
||||||
|
|
||||||
# poetry
|
|
||||||
poetry.lock
|
|
||||||
|
|
||||||
# pdm
|
|
||||||
.pdm.toml
|
|
||||||
|
|
||||||
# PEP 582
|
|
||||||
__pypackages__/
|
|
||||||
|
|
||||||
# Celery stuff
|
|
||||||
celerybeat-schedule
|
|
||||||
celerybeat.pid
|
|
||||||
|
|
||||||
# SageMath parsed files
|
|
||||||
*.sage.py
|
|
||||||
|
|
||||||
# Environments
|
|
||||||
.env
|
|
||||||
.venv
|
|
||||||
env/
|
|
||||||
venv/
|
|
||||||
ENV/
|
|
||||||
env.bak/
|
|
||||||
venv.bak/
|
|
||||||
|
|
||||||
# Spyder project settings
|
|
||||||
.spyderproject
|
|
||||||
.spyproject
|
|
||||||
|
|
||||||
# Rope project settings
|
|
||||||
.ropeproject
|
|
||||||
|
|
||||||
# mkdocs documentation
|
|
||||||
/site
|
|
||||||
|
|
||||||
# mypy
|
|
||||||
.mypy_cache/
|
|
||||||
.dmypy.json
|
|
||||||
dmypy.json
|
|
||||||
|
|
||||||
# Pyre type checker
|
|
||||||
.pyre/
|
|
||||||
|
|
||||||
# pytype static type analyzer
|
|
||||||
.pytype/
|
|
||||||
|
|
||||||
# Cython debug symbols
|
|
||||||
cython_debug/
|
|
||||||
|
|
||||||
# IDEs
|
|
||||||
.vscode/
|
|
||||||
.idea/
|
|
||||||
*.swp
|
|
||||||
*.swo
|
|
||||||
*~
|
|
||||||
.DS_Store
|
|
||||||
|
|
||||||
# Ollama models (large files)
|
|
||||||
~/.ollama/
|
|
||||||
|
|
||||||
# Local configuration
|
|
||||||
config.yaml
|
|
||||||
22
LICENSE
22
LICENSE
@@ -1,21 +1 @@
|
|||||||
MIT License
|
local_code_assistant/LICENSE
|
||||||
|
|
||||||
Copyright (c) 2024 Local Code Assistant Contributors
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
375
README.md
375
README.md
@@ -1,374 +1 @@
|
|||||||
# Local Code Assistant
|
local_code_assistant/README.md
|
||||||
|
|
||||||
A privacy-focused CLI tool for local AI code assistance using Ollama. Generate code, explain functionality, refactor for better structure, and write tests - all without sending your code to external APIs.
|
|
||||||
|
|
||||||
## Features
|
|
||||||
|
|
||||||
- **Code Generation**: Generate clean, well-documented code from natural language prompts
|
|
||||||
- **Code Explanation**: Get clear explanations of what code does and how it works
|
|
||||||
- **Code Refactoring**: Improve code structure with safe or aggressive refactoring options
|
|
||||||
- **Performance Optimization**: Optimize code for better performance and efficiency
|
|
||||||
- **Test Generation**: Automatically generate comprehensive unit tests
|
|
||||||
- **Interactive REPL**: Enter an interactive session for continuous code assistance
|
|
||||||
- **Multi-Language Support**: Python, JavaScript, TypeScript, Go, and Rust
|
|
||||||
- **Context-Aware**: Include project files for better suggestions
|
|
||||||
- **Secure Offline Operation**: All processing stays local - your code never leaves your machine
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
### Prerequisites
|
|
||||||
|
|
||||||
- Python 3.9 or higher
|
|
||||||
- [Ollama](https://ollama.com) installed and running
|
|
||||||
- A local LLM model (codellama, deepseek-coder, etc.)
|
|
||||||
|
|
||||||
### Install via pip
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pip install local-code-assistant
|
|
||||||
```
|
|
||||||
|
|
||||||
### Install from Source
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/local-code-assistant/local-code-assistant.git
|
|
||||||
cd local-code-assistant
|
|
||||||
pip install -e .
|
|
||||||
```
|
|
||||||
|
|
||||||
### Install Ollama Models
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Install a code-focused model
|
|
||||||
ollama pull codellama
|
|
||||||
ollama pull deepseek-coder
|
|
||||||
ollama pull starcoder2
|
|
||||||
|
|
||||||
# List available models
|
|
||||||
ollama list
|
|
||||||
```
|
|
||||||
|
|
||||||
## Quick Start
|
|
||||||
|
|
||||||
### Check Connection
|
|
||||||
|
|
||||||
```bash
|
|
||||||
local-code-assistant status
|
|
||||||
```
|
|
||||||
|
|
||||||
### Generate Code
|
|
||||||
|
|
||||||
```bash
|
|
||||||
local-code-assistant generate "a function to calculate fibonacci numbers" --language python
|
|
||||||
```
|
|
||||||
|
|
||||||
### Explain Code
|
|
||||||
|
|
||||||
```bash
|
|
||||||
local-code-assistant explain script.py
|
|
||||||
local-code-assistant explain app.ts --markdown
|
|
||||||
```
|
|
||||||
|
|
||||||
### Refactor Code
|
|
||||||
|
|
||||||
```bash
|
|
||||||
local-code-assistant refactor my_module.py --safe
|
|
||||||
local-code-assistant refactor app.py -f readability -f naming -o refactored.py
|
|
||||||
```
|
|
||||||
|
|
||||||
### Optimize Code
|
|
||||||
|
|
||||||
```bash
|
|
||||||
local-code-assistant optimize slow.py -o fast.py
|
|
||||||
```
|
|
||||||
|
|
||||||
### Generate Tests
|
|
||||||
|
|
||||||
```bash
|
|
||||||
local-code-assistant test my_module.py
|
|
||||||
local-code-assistant test app.py -o test_app.py
|
|
||||||
```
|
|
||||||
|
|
||||||
### Interactive REPL
|
|
||||||
|
|
||||||
```bash
|
|
||||||
local-code-assistant repl
|
|
||||||
```
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
### Environment Variables
|
|
||||||
|
|
||||||
| Variable | Default | Description |
|
|
||||||
|----------|---------|-------------|
|
|
||||||
| `OLLAMA_BASE_URL` | http://localhost:11434 | Ollama API endpoint URL |
|
|
||||||
| `OLLAMA_MODEL` | codellama | Default model to use |
|
|
||||||
| `OLLAMA_TIMEOUT` | 8000 | Request timeout in seconds |
|
|
||||||
| `CONFIG_PATH` | ~/.config/local-code-assistant/config.yaml | Path to config file |
|
|
||||||
|
|
||||||
### Configuration File
|
|
||||||
|
|
||||||
Create `~/.config/local-code-assistant/config.yaml`:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
ollama:
|
|
||||||
base_url: http://localhost:11434
|
|
||||||
model: codellama
|
|
||||||
timeout: 8000
|
|
||||||
streaming: true
|
|
||||||
|
|
||||||
defaults:
|
|
||||||
language: python
|
|
||||||
temperature: 0.2
|
|
||||||
max_tokens: 4000
|
|
||||||
|
|
||||||
context:
|
|
||||||
max_files: 10
|
|
||||||
max_file_size: 100000
|
|
||||||
|
|
||||||
output:
|
|
||||||
syntax_highlighting: true
|
|
||||||
clipboard: true
|
|
||||||
```
|
|
||||||
|
|
||||||
## Commands
|
|
||||||
|
|
||||||
### generate
|
|
||||||
|
|
||||||
Generate code from natural language prompts.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
local-code-assistant generate "a REST API endpoint for user authentication" \
|
|
||||||
--language python \
|
|
||||||
--output auth.py \
|
|
||||||
--temperature 0.3
|
|
||||||
```
|
|
||||||
|
|
||||||
Options:
|
|
||||||
- `--language, -l`: Programming language (default: python)
|
|
||||||
- `--output, -o`: Write generated code to file
|
|
||||||
- `--clipboard/--no-clipboard`: Copy to clipboard
|
|
||||||
- `--model, -m`: Model to use
|
|
||||||
- `--temperature, -t`: Temperature (0.0-1.0)
|
|
||||||
|
|
||||||
### explain
|
|
||||||
|
|
||||||
Explain code from a file.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
local-code-assistant explain complex_module.py --markdown
|
|
||||||
```
|
|
||||||
|
|
||||||
Options:
|
|
||||||
- `--language, -l`: Programming language (auto-detected)
|
|
||||||
- `--markdown/--no-markdown`: Format output as markdown
|
|
||||||
|
|
||||||
### refactor
|
|
||||||
|
|
||||||
Refactor code for better structure.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
local-code-assistant refactor legacy_code.py \
|
|
||||||
--safe \
|
|
||||||
--focus readability \
|
|
||||||
--focus naming
|
|
||||||
```
|
|
||||||
|
|
||||||
Options:
|
|
||||||
- `--focus, -f`: Focus areas (readability, structure, naming, documentation)
|
|
||||||
- `--safe/--unsafe`: Safe refactoring maintains behavior
|
|
||||||
- `--output, -o`: Write to file
|
|
||||||
- `--clipboard/--no-clipboard`: Copy to clipboard
|
|
||||||
|
|
||||||
### optimize
|
|
||||||
|
|
||||||
Optimize code for performance.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
local-code-assistant optimize slow_algorithm.py -o optimized.py
|
|
||||||
```
|
|
||||||
|
|
||||||
### test
|
|
||||||
|
|
||||||
Generate unit tests for code.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
local-code-assistant test my_module.py -o test_my_module.py
|
|
||||||
```
|
|
||||||
|
|
||||||
### repl
|
|
||||||
|
|
||||||
Enter interactive REPL mode.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
local-code-assistant repl --model codellama --language python
|
|
||||||
```
|
|
||||||
|
|
||||||
REPL Commands:
|
|
||||||
- `:generate <prompt>` - Generate code
|
|
||||||
- `:explain` - Explain last generated code
|
|
||||||
- `:lang <language>` - Set programming language
|
|
||||||
- `:model <name>` - Set model
|
|
||||||
- `:status` - Show current settings
|
|
||||||
- `:clear` - Clear conversation
|
|
||||||
- `:quit` or Ctrl+D - Exit
|
|
||||||
|
|
||||||
### status
|
|
||||||
|
|
||||||
Check connection and model status.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
local-code-assistant status
|
|
||||||
```
|
|
||||||
|
|
||||||
### models
|
|
||||||
|
|
||||||
List available Ollama models.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
local-code-assistant models
|
|
||||||
```
|
|
||||||
|
|
||||||
### version
|
|
||||||
|
|
||||||
Show version information.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
local-code-assistant version
|
|
||||||
```
|
|
||||||
|
|
||||||
## Supported Languages
|
|
||||||
|
|
||||||
| Language | Extensions | Testing Framework |
|
|
||||||
|----------|------------|-------------------|
|
|
||||||
| Python | .py, .pyw, .pyi | pytest |
|
|
||||||
| JavaScript | .js, .mjs, .cjs | jest |
|
|
||||||
| TypeScript | .ts, .tsx | jest |
|
|
||||||
| Go | .go | testing |
|
|
||||||
| Rust | .rs | test |
|
|
||||||
|
|
||||||
## Recommended Models
|
|
||||||
|
|
||||||
- **codellama**: General purpose code generation
|
|
||||||
- **deepseek-coder**: High-quality code completion
|
|
||||||
- **starcoder2**: Multi-language support
|
|
||||||
- **qwen2.5-coder**: Balanced performance
|
|
||||||
- **phi4**: Efficient code understanding
|
|
||||||
|
|
||||||
## Project Context
|
|
||||||
|
|
||||||
When generating or refactoring code, you can include project files for better context:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
local-code-assistant generate "add error handling" --context --max-files 5
|
|
||||||
```
|
|
||||||
|
|
||||||
## Development
|
|
||||||
|
|
||||||
### Setup Development Environment
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/local-code-assistant/local-code-assistant.git
|
|
||||||
cd local-code-assistant
|
|
||||||
pip install -e ".[dev]"
|
|
||||||
```
|
|
||||||
|
|
||||||
### Running Tests
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Run all tests
|
|
||||||
pytest tests/ -v
|
|
||||||
|
|
||||||
# Run with coverage
|
|
||||||
pytest tests/ --cov=local_code_assistant --cov-report=term-missing
|
|
||||||
|
|
||||||
# Run specific test file
|
|
||||||
pytest tests/test_cli.py -v
|
|
||||||
```
|
|
||||||
|
|
||||||
### Code Quality
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Format code
|
|
||||||
black local_code_assistant/
|
|
||||||
|
|
||||||
# Lint code
|
|
||||||
ruff check local_code_assistant/
|
|
||||||
|
|
||||||
# Type checking
|
|
||||||
mypy local_code_assistant/
|
|
||||||
```
|
|
||||||
|
|
||||||
## Architecture
|
|
||||||
|
|
||||||
```
|
|
||||||
local_code_assistant/
|
|
||||||
├── cli.py # Main CLI entry point
|
|
||||||
├── commands/
|
|
||||||
│ ├── base.py # Base command class
|
|
||||||
│ ├── generate.py # Code generation command
|
|
||||||
│ ├── explain.py # Code explanation command
|
|
||||||
│ ├── refactor.py # Code refactoring command
|
|
||||||
│ ├── test.py # Test generation command
|
|
||||||
│ └── repl.py # Interactive REPL
|
|
||||||
├── services/
|
|
||||||
│ ├── ollama.py # Ollama API client
|
|
||||||
│ └── config.py # Configuration management
|
|
||||||
├── prompts/
|
|
||||||
│ └── templates.py # Prompt templates and language config
|
|
||||||
├── utils/
|
|
||||||
│ ├── context.py # Project context building
|
|
||||||
│ └── language.py # Language detection utilities
|
|
||||||
└── tests/ # Test suite
|
|
||||||
```
|
|
||||||
|
|
||||||
## Troubleshooting
|
|
||||||
|
|
||||||
### Cannot connect to Ollama
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Make sure Ollama is running
|
|
||||||
ollama serve
|
|
||||||
|
|
||||||
# Check if Ollama is accessible
|
|
||||||
curl http://localhost:11434/api/tags
|
|
||||||
```
|
|
||||||
|
|
||||||
### Model not found
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Pull the model
|
|
||||||
ollama pull codellama
|
|
||||||
|
|
||||||
# List installed models
|
|
||||||
ollama list
|
|
||||||
```
|
|
||||||
|
|
||||||
### Slow responses
|
|
||||||
|
|
||||||
- Reduce `max_tokens` in configuration
|
|
||||||
- Use a smaller model
|
|
||||||
- Increase `OLLAMA_TIMEOUT`
|
|
||||||
|
|
||||||
### Clipboard not working
|
|
||||||
|
|
||||||
- Install pyperclip dependencies:
|
|
||||||
- Linux: `sudo apt-get install xclip` or `xsel`
|
|
||||||
- macOS: Already supported
|
|
||||||
- Windows: Already supported
|
|
||||||
|
|
||||||
## Contributing
|
|
||||||
|
|
||||||
Contributions are welcome! Please read our contributing guidelines before submitting PRs.
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
MIT License - see LICENSE file for details.
|
|
||||||
|
|
||||||
## Security
|
|
||||||
|
|
||||||
This tool is designed with privacy in mind:
|
|
||||||
- All processing happens locally
|
|
||||||
- No external API calls (except to your local Ollama instance)
|
|
||||||
- No telemetry or data collection
|
|
||||||
- Your code never leaves your machine
|
|
||||||
1
__init__.py
Normal file
1
__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
local_code_assistant/__init__.py
|
||||||
1
commands/__init__.py
Normal file
1
commands/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
local_code_assistant/commands/__init__.py
|
||||||
1
commands/base.py
Normal file
1
commands/base.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
local_code_assistant/commands/base.py
|
||||||
1
commands/explain.py
Normal file
1
commands/explain.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
local_code_assistant/commands/explain.py
|
||||||
1
commands/generate.py
Normal file
1
commands/generate.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
local_code_assistant/commands/generate.py
|
||||||
1
commands/refactor.py
Normal file
1
commands/refactor.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
local_code_assistant/commands/refactor.py
|
||||||
1
commands/repl.py
Normal file
1
commands/repl.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
local_code_assistant/commands/repl.py
|
||||||
1
commands/test.py
Normal file
1
commands/test.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
local_code_assistant/commands/test.py
|
||||||
53
config.yaml
53
config.yaml
@@ -1,52 +1 @@
|
|||||||
# Local Code Assistant Configuration
|
local_code_assistant/config.yaml
|
||||||
# This is the default configuration file
|
|
||||||
|
|
||||||
ollama:
|
|
||||||
base_url: "http://localhost:11434"
|
|
||||||
model: "codellama"
|
|
||||||
timeout: 8000
|
|
||||||
streaming: true
|
|
||||||
|
|
||||||
# Default settings for commands
|
|
||||||
defaults:
|
|
||||||
language: "python"
|
|
||||||
temperature: 0.2
|
|
||||||
max_tokens: 4000
|
|
||||||
output_format: "code"
|
|
||||||
|
|
||||||
# Supported programming languages
|
|
||||||
languages:
|
|
||||||
- python
|
|
||||||
- javascript
|
|
||||||
- typescript
|
|
||||||
- go
|
|
||||||
- rust
|
|
||||||
|
|
||||||
# Context settings
|
|
||||||
context:
|
|
||||||
max_files: 10
|
|
||||||
max_file_size: 100000 # bytes
|
|
||||||
include_patterns:
|
|
||||||
- "**/*.py"
|
|
||||||
- "**/*.js"
|
|
||||||
- "**/*.ts"
|
|
||||||
- "**/*.go"
|
|
||||||
- "**/*.rs"
|
|
||||||
exclude_patterns:
|
|
||||||
- "**/node_modules/**"
|
|
||||||
- "**/.git/**"
|
|
||||||
- "**/venv/**"
|
|
||||||
- "**/.env/**"
|
|
||||||
- "**/__pycache__/**"
|
|
||||||
- "**/*.pyc"
|
|
||||||
|
|
||||||
# Output settings
|
|
||||||
output:
|
|
||||||
clipboard: true
|
|
||||||
file_output: true
|
|
||||||
syntax_highlighting: true
|
|
||||||
|
|
||||||
# Logging settings
|
|
||||||
logging:
|
|
||||||
level: "INFO"
|
|
||||||
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
|
||||||
1
prompts/__init__.py
Normal file
1
prompts/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
local_code_assistant/prompts/__init__.py
|
||||||
1
prompts/templates.py
Normal file
1
prompts/templates.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
local_code_assistant/prompts/templates.py
|
||||||
@@ -1,85 +1 @@
|
|||||||
[build-system]
|
local_code_assistant/pyproject.toml
|
||||||
requires = ["setuptools>=61.0", "wheel"]
|
|
||||||
build-backend = "setuptools.build_meta"
|
|
||||||
|
|
||||||
[project]
|
|
||||||
name = "local-code-assistant"
|
|
||||||
version = "0.1.0"
|
|
||||||
description = "A CLI tool for running local AI code assistance without sending code to external APIs"
|
|
||||||
readme = "README.md"
|
|
||||||
requires-python = ">=3.9"
|
|
||||||
license = {text = "MIT"}
|
|
||||||
authors = [
|
|
||||||
{name = "Local Code Assistant Contributors"}
|
|
||||||
]
|
|
||||||
keywords = ["cli", "ai", "code-assistant", "ollama", "local-llm"]
|
|
||||||
classifiers = [
|
|
||||||
"Development Status :: 4 - Beta",
|
|
||||||
"Intended Audience :: Developers",
|
|
||||||
"License :: OSI Approved :: MIT License",
|
|
||||||
"Programming Language :: Python :: 3",
|
|
||||||
"Programming Language :: Python :: 3.9",
|
|
||||||
"Programming Language :: Python :: 3.10",
|
|
||||||
"Programming Language :: Python :: 3.11",
|
|
||||||
"Programming Language :: Python :: 3.12",
|
|
||||||
"Topic :: Software Development :: Tools :: Code Generators",
|
|
||||||
"Topic :: Software Development :: Libraries :: Python Modules"
|
|
||||||
]
|
|
||||||
dependencies = [
|
|
||||||
"click>=8.1.7",
|
|
||||||
"rich>=13.7.0",
|
|
||||||
"ollama>=0.1.41",
|
|
||||||
"pyperclip>=1.8.2",
|
|
||||||
"pyyaml>=6.0.1",
|
|
||||||
"python-dotenv>=1.0.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[project.optional-dependencies]
|
|
||||||
dev = [
|
|
||||||
"pytest>=7.4.0",
|
|
||||||
"pytest-cov>=4.1.0",
|
|
||||||
"pytest-asyncio>=0.21.0",
|
|
||||||
"black>=23.0.0",
|
|
||||||
"ruff>=0.1.0",
|
|
||||||
"mypy>=1.5.0",
|
|
||||||
"types-pyperclip",
|
|
||||||
]
|
|
||||||
|
|
||||||
[project.scripts]
|
|
||||||
local-code-assistant = "local_code_assistant.cli:main"
|
|
||||||
lca = "local_code_assistant.cli:main"
|
|
||||||
|
|
||||||
[project.urls]
|
|
||||||
Homepage = "https://github.com/local-code-assistant/local-code-assistant"
|
|
||||||
Repository = "https://github.com/local-code-assistant/local-code-assistant"
|
|
||||||
Issues = "https://github.com/local-code-assistant/local-code-assistant/issues"
|
|
||||||
|
|
||||||
[tool.setuptools.packages.find]
|
|
||||||
where = ["."]
|
|
||||||
include = ["local_code_assistant*"]
|
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
|
||||||
testpaths = ["tests"]
|
|
||||||
python_files = ["test_*.py"]
|
|
||||||
python_functions = ["test_*"]
|
|
||||||
addopts = "-v --tb=short"
|
|
||||||
|
|
||||||
[tool.black]
|
|
||||||
line-length = 100
|
|
||||||
target-version = ["py39", "py310", "py311", "py312"]
|
|
||||||
include = '\\.pyi?$'
|
|
||||||
|
|
||||||
[tool.ruff]
|
|
||||||
line-length = 100
|
|
||||||
target-version = "py39"
|
|
||||||
select = ["E", "F", "W", "C90", "I", "N", "UP", "B", "C4"]
|
|
||||||
ignore = ["E501"]
|
|
||||||
|
|
||||||
[tool.ruff.per-file-ignores]
|
|
||||||
"__init__.py" = ["F401"]
|
|
||||||
|
|
||||||
[tool.mypy]
|
|
||||||
python_version = "3.9"
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unused_configs = true
|
|
||||||
disallow_untyped_defs = false
|
|
||||||
1
services/__init__.py
Normal file
1
services/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
local_code_assistant/services/__init__.py
|
||||||
1
services/config.py
Normal file
1
services/config.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
local_code_assistant/services/config.py
|
||||||
1
services/ollama.py
Normal file
1
services/ollama.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
local_code_assistant/services/ollama.py
|
||||||
1
utils/__init__.py
Normal file
1
utils/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
local_code_assistant/utils/__init__.py
|
||||||
1
utils/config.py
Normal file
1
utils/config.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
local_code_assistant/utils/config.py
|
||||||
1
utils/context.py
Normal file
1
utils/context.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
local_code_assistant/utils/context.py
|
||||||
1
utils/language.py
Normal file
1
utils/language.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
local_code_assistant/utils/language.py
|
||||||
Reference in New Issue
Block a user