Ollama Editor
AI code assistant for VS Code that uses Ollama (or any OpenAI‑compatible endpoint) to edit your code via the native VS Code API — line‑by‑line, like Copilot.
Features
- Chat panel in VS Code – ask questions or request code changes in natural language.
- Line‑by‑line file editing – insert, update, or delete code at specific line numbers using VS Code's native
TextEditor.edit() API.
- Read‑only terminal – the LLM can run safe commands (
ls, cat, git, grep, etc.) for context, but destructive commands are blocked and automatically redirected to the file editor.
- Tool‑calling loop – uses structured tool calls (
vscode_file_editor, terminal_readonly, file_reader) instead of raw JSON or freeform text.
- Supports multiple backends – works with local Ollama, OpenAI, Azure OpenAI, Groq, Together AI, and any other provider that offers a
/chat/completions endpoint with function calling.
- Session management – multiple chat sessions with history persist across restarts.
Requirements
- Ollama running locally (if you choose the
ollama provider), or
- An API key and endpoint for an OpenAI‑compatible service (if you choose the
openai provider).
- A model that supports tool/function calling (e.g.,
llama3.2, qwen2.5, mistral, gpt-4o, gpt-4-turbo, claude-3-opus via compatible APIs).
Usage
- Open the Command Palette (
Ctrl+Shift+P) and run "Open Ollama Chat".
- Type a message like:
- "Add a greeting function at line 10 of src/app.ts"
- "Explain this code"
- "Refactor this function to use async/await"
- The LLM will call tools to read files, edit code, or run terminal commands as needed.
- All actions are streamed in the chat panel – you can see each tool call and its result in real‑time.
Configuration
Open your VS Code settings and search for ollama-editor. The following options are available:
| Setting |
Default |
Description |
ollama-editor.provider |
"ollama" |
The backend to use: "ollama" for the native Ollama /chat endpoint, or "openai" for any /chat/completions endpoint. |
ollama-editor.endpoint |
"http://localhost:11434" |
API endpoint base URL. For Ollama: http://localhost:11434. For OpenAI-compatible: https://api.openai.com/v1 (do not include /chat/completions — it is auto-appended). |
ollama-editor.model |
"llama3.2" |
Model name to use. For Ollama, this must be a model you have pulled; for OpenAI, it's the model ID (e.g., "gpt-4"). |
ollama-editor.apiKey |
"" |
API key for the endpoint. Leave empty for local Ollama. Required for OpenAI-compatible endpoints (e.g., sk-...). |
Tip: If you are using Azure OpenAI, set endpoint to your Azure deployment URL and apiKey to your Azure API key. The model field should match the deployment name.
How it works
- The extension converts the same tool definitions to either Ollama's
tools format or OpenAI's tools format.
- Both providers are supported with the same prompt and tool execution logic.
Development
git clone <repo>
cd ollama-editor
npm install
npm run watch
# Press F5 in VS Code to launch Extension Dev Host
| |