This project provides a Copilot-like experience within VS Code using a local or network Ollama API. The extension supports both Chat Participant (chat) and inline code completion (ghost text) features.
- Install dependencies:
npm install- Compile:
npm run compile- Development / Debug (Extension Development Host):
- After opening the project in VS Code, press
F5. A new VS Code window (Extension Development Host) will open with the extension loaded.
- Configure settings (in development host or normal VS Code settings):
{
"lucid.ollamaEndpoint": "http://<OLLAMA_HOST>:11434",
"lucid.ollamaApiKey": "llm-...",
"lucid.ollamaExtraHeaders": { "X-Request-Source": "post_text_script" },
"lucid.enableInlineCompletion": true,
"lucid.inlineCompletionTemperature": 0.2,
"lucid.inlineCompletionDebounceMs": 350,
"lucid.inlineCompletionMaxRemoteChars": 3500,
"lucid.logUnmaskedHeaders": false,
"lucid.enableStreamingStatus": false,
"lucid.ollamaApiKeyHeaderName": ""
}Configuration settings (detailed)
Below are the primary configuration options you can set in VS Code's Settings (settings.json) or via environment variables where noted. Each entry includes the default value and a short explanation with examples.
-
lucid.ollamaEndpoint(string) — Default:"http://<OLLAMA_HOST>:11434"- Description: The HTTP endpoint for your Ollama API. Include host and port as appropriate.
- Example:
"http://localhost:11434"or"http://10.0.0.5:11434".
-
lucid.ollamaApiKey(string) — Default:""(empty)- Description: Optional API key used to authenticate requests to Ollama. You can alternatively supply the key via the
OLLAMA_API_KEYenvironment variable. - Example:
"llm-xxxxxxxxxxxx".
- Description: Optional API key used to authenticate requests to Ollama. You can alternatively supply the key via the
-
lucid.ollamaApiKeyHeaderName(string) — Default:"Authorization"- Description: The header name to use when sending the API key. Some deployments or proxies expect a custom header name (for example
X-API-Key). The extension will add this header with the value fromlucid.ollamaApiKeyorOLLAMA_API_KEY. - Example:
"X-API-Key"or"Authorization".
- Description: The header name to use when sending the API key. Some deployments or proxies expect a custom header name (for example
-
lucid.ollamaExtraHeaders(object) — Default:{}- Description: Additional HTTP headers to send with each request to Ollama. This can be used for tracing, routing, or proxy requirements.
- Environment variable alternative:
OLLAMA_EXTRA_HEADERS(JSON string). - Example:
{ "X-Request-Source": "post_text_script", "X-Tenant-Id": "tenant-123" }.
-
lucid.enableInlineCompletion(boolean) — Default:true- Description: Enable inline (ghost text) code completions within the editor. When enabled, the extension may present inline suggestions drawn from the configured Ollama model.
-
lucid.inlineCompletionTemperature(number) — Default:0.2- Description: Sampling temperature for inline completions. Lower values are more deterministic, higher values produce more diverse suggestions (range
0-2).
- Description: Sampling temperature for inline completions. Lower values are more deterministic, higher values produce more diverse suggestions (range
-
lucid.inlineCompletionDebounceMs(number) — Default:350- Description: Minimum delay (in milliseconds) between remote inline completion requests. Increase this if Ollama cannot keep up with keystrokes.
-
lucid.inlineCompletionMaxRemoteChars(number) — Default:3500- Description: Maximum combined prefix + suffix characters that will be sent to Ollama for generating inline completions. Larger files will fall back to the lightweight local heuristic to avoid latency.
-
lucid.logUnmaskedHeaders(boolean) — Default:false- Description: When
true, sensitive headers such as the API key will be logged in full within the extension logs. This is useful for debugging but should be disabled in production environments.
- Description: When
-
lucid.logUnmaskedHeadersInDev(boolean) — Default:true- Description: Allow unmasked header logging when the extension runs in development mode (e.g., when launched from the Extension Development Host). This provides a safer default for day-to-day development while keeping production logs sanitized.
-
lucid.enableStreamingStatus(boolean) — Default:false- Description: Controls whether the chat view shows a streaming status indicator (spinner and disabled send button) while receiving chunked/streaming responses from Ollama. Enable this if you want a visual streaming indicator in the webview.
Notes:
- The extension always sets
Content-Type: application/jsonon requests unless overridden inlucid.ollamaExtraHeaders. - If you use environment variables (
OLLAMA_API_KEY,OLLAMA_EXTRA_HEADERS), the extension will prefer explicit settings insettings.jsonwhen present.
- Using the extension in a normal VS Code window (packaging):
npm run compile
npm install -g vsce
vsce package
# install the generated .vsix
code --install-extension lucid-vsx-x.x.x.vsix- Open the Chat panel in the development host (F5) window and chat with
@lucid. - To test code completion, type in any code file; if
lucid.enableInlineCompletionis enabled, ghost text suggestions should appear.
OLLAMA_EXTRA_HEADERS: Additional headers in JSON format. Example:
export OLLAMA_EXTRA_HEADERS='{"X-Request-Source":"post_text_script"}'OLLAMA_API_KEY: API key (can also be provided vialucid.ollamaApiKeysetting):
export OLLAMA_API_KEY='tn-llm-...'The extension automatically adds the Content-Type: application/json header (if not specified in settings) and sends the API key with the X-API-Key header.
Responses from Ollama can be in chunks (NDJSON or line-based). You can simulate streaming by running a test server within the project:
// tiny-stream-server.js
const http = require("http");
http
.createServer((req, res) => {
res.writeHead(200, { "Content-Type": "application/json" });
res.write(
JSON.stringify({
choices: [{ message: { role: "assistant", content: "Hello" } }],
}) + "\n"
);
setTimeout(() => {
res.write(
JSON.stringify({
choices: [
{
message: {
role: "assistant",
content: " How can I help you?",
},
},
],
}) + "\n"
);
res.end();
}, 500);
})
.listen(8089);
// run: node tiny-stream-server.jsYou can test the extension with F5 by running this server and setting lucid.ollamaEndpoint to http://localhost:8089; incoming chunks will be displayed instantly.
- Create a
.vsixwithvsce packageand install it withcode --install-extension. - If you want to publish to the Marketplace, you can use
vsce publish(updatepackage.jsonmetadata before publishing).
- View logs in the Extension Development Host console:
Help → Toggle Developer ToolsorDebug Console. - If the server returns a JSON parse error, the extension automatically adds
Content-Type: application/json; if you still get an error, check the endpoint path and expected body format.
- If you set
lucid.logUnmaskedHeaderstotrue, sensitive headers (e.g.,X-API-Key) will be clearly visible in the logs. Keep it disabled in Production.