CodeSprite
CodeSprite is a lightweight VS Code extension that adds three AI coding features without locking you into a specific provider. Point it at any OpenAI-compatible chat completions endpoint, supply your own API key, and pick any model your provider supports.
Built with TypeScript + esbuild. No runtime dependencies. MIT licensed. Requirements
InstallationFrom the MarketplaceSearch for CodeSprite in the VS Code Extensions view ( From a
|
| Setting | Type | Default | Description |
|---|---|---|---|
codesprite.enabled |
boolean | true |
Master switch for all AI features. Click the status bar item to toggle. |
codesprite.inlineEnabled |
boolean | true |
Enable inline ghost-text completions while typing. |
codesprite.commandEnabled |
boolean | true |
Enable the AI Command modal (Ctrl+Shift+I). |
codesprite.commitMessageEnabled |
boolean | true |
Enable the commit message generator in Source Control. |
codesprite.commitMaxTokens |
number | 256 |
Max tokens the model may generate for a commit message (16–4096). |
codesprite.commitMaxDiffLength |
number | 8000 |
Max characters of the git diff sent to the model (512–100000). Larger diffs are truncated. |
codesprite.apiKey |
string | "" |
Required. API key for your provider. Keep this secret. |
codesprite.apiBaseUrl |
string | https://opencode.ai/zen/v1 |
Base URL for an OpenAI-compatible chat completions endpoint. |
codesprite.model |
string | minimax-m2.7 |
Model identifier your provider supports (e.g. gpt-4o-mini, gpt-4o, claude-3.5-sonnet). |
codesprite.maxCompletionTokens |
number | 3072 |
Max tokens the model may generate per request (16–4096). |
codesprite.maxInputTokens |
number | 3072 |
Max tokens for the prompt (prefix + suffix + system message). Context is trimmed to fit (256–32768). |
codesprite.maxContextLines |
number | 10 |
Max prefix/suffix lines sent per request. May be lowered to respect maxInputTokens (4–500). |
codesprite.streamEarlyStop |
boolean | true |
Stop reading the SSE stream as soon as completion is signaled, reducing tail latency. |
codesprite.enabledLanguages |
string[] | ["*"] |
Language IDs where autocomplete is active. Use ["*"] for all, or list specific IDs like ["python", "typescript"]. |
codesprite.debounceDelay |
number | 1000 |
Milliseconds to wait after typing stops before requesting an inline completion (50–2000). Lower = more responsive, higher API usage. Inline only. |
Minimal example (settings.json)
{
"codesprite.apiKey": "sk-your-key-here",
"codesprite.apiBaseUrl": "https://opencode.ai/zen/v1",
"codesprite.model": "minimax-m2.7"
}
Using a different provider
CodeSprite works with any OpenAI-compatible endpoint. For example, to use OpenAI directly:
{
"codesprite.apiKey": "sk-...",
"codesprite.apiBaseUrl": "https://api.openai.com/v1",
"codesprite.model": "gpt-4o-mini"
}
Usage
1. Inline completions
![]()
Just type. After the configured debounce delay, CodeSprite requests a completion and renders it as ghost text. Press Tab to accept. Suggestions are de-duplicated against the code that already follows your cursor, so you never get duplicate lines.
If the status bar shows $(warning) CS, no API key is set. If it shows $(error) CS, the last request failed — hover for details.
2. AI Command modal
![]()
Press Ctrl+Shift+I (macOS: Cmd+Shift+I) with a text editor focused. Type a natural-language instruction, for example:
create a new variable called abcconvert this loop to a list comprehensionadd a docstringNo selection — the generated code is inserted at the cursor.
With a selection — the selected text is replaced with the generated code.
Inserted code is briefly highlighted so you can review it; the highlight clears on the next edit, cursor move, or after 5 seconds. Use Ctrl+Z to undo if it's not what you wanted.
3. Commit message generator
![]()
Open the Source Control panel (Ctrl+Shift+G). Click the sparkle/lightbulb icon in the SCM title bar. CodeSprite reads your staged changes (git diff --cached), falls back to unstaged changes if nothing is staged, and writes a Conventional Commit message into the SCM input box.
The commit message prompt extracts a user-story number from the branch name when it follows the 1234-description pattern, prefixing the message with [1234].
Status bar
A CS indicator in the bottom-left status bar reflects the current state:
| Indicator | Meaning |
|---|---|
$(lightbulb-autofix) CS |
Enabled (tooltip lists active features) |
$(circle-slash) CS |
Globally disabled |
$(loading~spin) CS |
A request is in flight |
$(warning) CS |
No API key configured |
$(error) CS |
Last request failed (hover for the error) |
Click the indicator to toggle the master switch on/off.
Build from source
npm install
npx tsc --noEmit # type-check (esbuild does NOT run tsc)
npm run build # bundle to dist/extension.js with sourcemaps
npm run watch # rebuild on change
npm run vscode:prepublish # production minified bundle
npm run package # production bundle + .vsix
Type-check first, build second. A clean build does not guarantee type safety — esbuild strips types without checking them. Always run npx tsc --noEmit before committing.
Press F5 in VS Code to launch the extension host (runs the default build task, then opens a new window with CodeSprite loaded).
Architecture
Single entrypoint: src/extension.ts → activate() wires up the three features. Each feature owns its own abort controller and shares a single status bar item.
| Module | Role |
|---|---|
api.ts |
All HTTP calls. _fetchAiCompletion() is the single shared pipeline; three thin public wrappers configure it. |
config.ts |
Reads VS Code settings, feature toggles, language filtering. |
context.ts |
Extracts prefix/suffix around the cursor with token-budget trimming. |
tokens.ts |
Char-based token estimation (~4 chars/token) and budget clamping. |
debounce.ts |
Cancellable delay for inline typing debounce. |
types.ts |
Shared interfaces for requests, responses, and config. |
errors.ts |
getErrorMessage() — canonical error normalization. |
statusBar.ts |
resetStatusBarToReady() — canonical status bar reset. |
provider.ts |
Inline completion provider (typing trigger). |
commandHandler.ts |
AI Command modal (Ctrl+Shift+I). |
commitMessage.ts |
Commit message generator (SCM title bar trigger). |
All HTTP traffic flows through one streaming pipeline that auto-detects SSE vs. JSON responses, supports early stream termination, and handles servers that omit Content-Type. See AGENTS.md for the full contributor guide and gotchas.
Privacy
CodeSprite sends the code around your cursor (prefix + suffix, trimmed to your configured token budget) and your natural-language instructions to the API endpoint you configure. No telemetry is collected by the extension itself. Review your provider's data policy before use.
License
MIT © publisher