A VS Code extension that provides GitHub Copilot-like functionality using locally running Ollama models.
Now with smart project-wide context: The extension automatically gathers code and documentation from your workspace for every AI request, making suggestions and edits much more intelligent and Copilot-like.
-
π€ Chat Interface - Interactive AI chat panel similar to GitHub Copilot
-
π» Code Generation - Generate code from natural language descriptions
-
βοΈ Code Editing - Edit and refactor selected code with AI assistance
-
π Code Explanation - Understand complex code with detailed explanations
-
π Diff Preview - See before/after comparisons before applying changes
-
π¨ Beautiful UI - Modern interface that matches VS Code's theme
-
π Multiple Models - Choose between different Ollama models
-
π§ Project-Wide Context Awareness β AI suggestions and edits use key files from your workspace (README, SETUP, main, server, extension,
.py,.ts,.js,.md). -
π Intelligent Suggestions & Edits β AI can reason about your whole project, not just the current file or cursor.
-
π οΈ Smart Code Actions β Insert, replace, and preview code with context-aware suggestions and diff previews.
- Ollama - Install from https://ollama.ai
- Python 3.8+ - For the backend server
- Node.js 16+ - For building the extension
This extension is configured for:
gemma3:4b- Fast responses, good for quick tasksgemma3:8b- Better quality, slightly slowerdeepseek-r1:8b- Reasoning model, best for complex tasks
ollama pull gemma3:4b
ollama pull gemma3:8b
ollama pull deepseek-r1:8bcd server
pip install -r requirements.txt
python server.pyThe server will start on http://127.0.0.1:5000
cd vscode-extension
npm install
npm run compileThen press F5 to launch the extension in a new VS Code window.
- The extension automatically gathers context from up to 5 key files in your workspace (README, SETUP, main, server, extension,
.py,.ts,.js,.md) for every AI request. - It combines this with the current editor's context and selection.
- The AI will now be able to reason about your whole project, not just the current file or cursor.
This makes code suggestions, edits, and completions much smarter and more Copilot-like!
- Open Command Palette (
Ctrl+Shift+PorCmd+Shift+P) - Type "Local AI Copilot: Chat"
- Start chatting with your AI!
- Explain Code: Select code β Right-click β "AI: Explain Code"
- Edit Code: Select code β Right-click β "AI: Edit Code"
- Generate Code: Place cursor β Right-click β "AI: Generate Code"
- Text Responses: Regular chat messages appear in the chat window
- Code Responses: Code suggestions appear with action buttons:
- Insert at Cursor: Add code at current position
- Replace Selection: Replace selected code with AI suggestion
- Copy: Copy code to clipboard
Choose your preferred model from the dropdown in the chat panel:
- Use smaller models (4b) for faster responses
- Use larger models (8b) for better quality and complex tasks
- VS Code Extension: Provides the UI and integrates with VS Code
- Python Server: Handles communication with Ollama
- Ollama: Runs the AI models locally on your machine
Advanced:
When you ask for code generation, editing, or explanation, the extension:
- Collects relevant code and documentation from your workspace.
- Combines it with your current selection or file context.
- Sends this rich context to the AI backend for smarter, project-aware results.
VS Code Extension (TypeScript)
β
Python Server (Flask)
β
Ollama API (Port 11434)
β
Local AI Models
Edit server/server.py to add or modify models:
MODELS = {
"model-name": "ollama-model-name",
# Add more models here
}Edit vscode-extension/src/webview.html to update the dropdown:
<option value="model-name">Display Name</option>In server/server.py:
app.run(port=5000, debug=True) # Change port hereIn vscode-extension/src/extension.ts:
const SERVER_URL = 'http://127.0.0.1:5000'; // Update port here-
Check if Python dependencies are installed:
pip install -r server/requirements.txt
-
Check if port 5000 is available:
# Windows netstat -ano | findstr :5000 # Mac/Linux lsof -i :5000
-
Verify Ollama is running:
ollama list
-
Check Ollama API:
curl http://localhost:11434/api/tags
-
Test model:
ollama run gemma3:4b "Hello"
-
Check server health:
curl http://127.0.0.1:5000/health
-
Check browser console in VS Code:
- Open Command Palette
- Type "Developer: Toggle Developer Tools"
- Check for errors
-
Rebuild extension:
cd vscode-extension npm run compile
βββ server/
β βββ server.py # Flask server
β βββ requirements.txt # Python dependencies
βββ vscode-extension/
β βββ src/
β β βββ extension.ts # Main extension code
β β βββ webview.html # Chat UI
β β βββ webview.js # Chat logic
β βββ package.json # Extension manifest
β βββ tsconfig.json # TypeScript config
βββ README.md
cd vscode-extension
npm install -g vsce
vsce packageThis creates a .vsix file you can install with:
code --install-extension local-ai-copilot-*.vsixFeel free to submit issues and pull requests!
MIT License
Built with:
- Ollama - Local AI models
- Flask - Python web framework
- VS Code Extension API - Extension framework