Skip to content

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

LLM Autocorrect icon

LLM Autocorrect

pritn → print
LLM-powered autocorrect for code in VS Code and Cursor

VS Code Marketplace Open VSX License


Terminal-style control over what you send to the LLM: stage a selection, set modifiers, then E (send now) or Shift+E (enqueue). No inline ghost-text autocomplete.

The extension is the same in VS Code and Cursor — only language server (LSP) setup differs.

Privacy: what is sent to the model provider. With a cloud profile (Groq, Gemini, Anthropic), the line or block being fixed and the code around it are sent to that provider. With the local profile (llama-server / Ollama), nothing is sent to any outside service. Since v0.4.0: secrets in surrounding code are redacted, lines that look like they contain a secret are not sent to cloud profiles, sensitive files (.env, keys, credentials) are never used, and a workspace's settings can no longer redirect your stored API key to another server. If you used v0.3.0 or earlier with a cloud profile: code around your edits may have been sent to that provider unredacted, so a key hardcoded near an edit may have reached the provider you chose, and nowhere else. This mainly matters if you autocorrected config or .env files, or had context.ringEnabled on (which could include your last selection from any file). If so, kindly consider rotating any hardcoded keys. From v0.4.0, recognized secrets are redacted before anything is sent, so you don't need to worry about this going forward. See Privacy.

Features (v0.4.0)

Feature Summary
Line autocorrect On Enter, the line you left may be fixed (typos, syntax, wrong-language idioms). Cascade errors (e.g. return under broken def) redirect to the upstream line, but only to a real syntax error at most 8 lines up. A multi-line statement is sent whole. Brief highlight on change.
Syntax check Built-in tree-sitter parser (Python, JS, TS, Go, Java, Rust, C++) detects syntax errors instantly, even when the language server is quiet; unfinished code (an open bracket) is ignored.
Safer fixes Prompts include the LSP/parser error and names defined in the file. Local checks reject fixes that change string contents, invent names, or rewrite most of a line; an immediate fix that introduces a new nearby error without reducing the error count is undone automatically (queue reviews are excluded).
Logic suggestions Autocorrect: Check for Logic Bugs lists likely logic bugs in Problems with an optional quick fix — never applied on its own.
Privacy Sensitive files (.env, keys, credentials) are never used; secrets in context and diagnostic messages are redacted; secret-bearing lines are not sent to cloud profiles.
Granite Guardian judge Optional second profile scores fix/paste replies (BYOC yes/no). On no, regenerate once; default softApply still writes the candidate (revert via Remove/Revert at Cursor). Staged context notes skip the judge (instruction edits).
Modal menu Double-tap Ctrl / Ctrl+Shift+;, or double-tap Cmd / Cmd+Shift+; on macOS — hotkey-driven workflow without leaving the editor.
Immediate fix A (block) or C (line) — send to LLM immediately, no staging.
Stage Workflow Shift+A (block) or Shift+C (line) → green highlight → set modifiers → E send now or Shift+E enqueue.
Stage Window S → W/S (up/down) A/D (start/end) controls to select a block → E closes selection window and enters staged mode → set modifiers → E send now or Shift+E enqueue.
Stage Modifiers Before finalizing the send, add modifiers: defaults to best-guess fix · D documentation · F caveman · X custom prompt (instruction) · 1–5 context tiers · M / Shift+M LLM profile.
Stage Context 1 nearby lines (default indent-scoped; optional flat window) · 2 enclosing signature chain (e.g. class + def, on by default for fix/docs) · 3 recent edit hunks · 4 open-tab signatures · 5 last large selection snippet. Tiers 3–5 require context.ringEnabled. Caveman staging defaults to nearby only.
Multi-profile LLM Named profiles for Groq, Gemini, Anthropic, local Granite (local), Guardian (guardian), and Ollama. Built-ins live in the extension; profiles holds only your overrides by id (plus custom profiles), and hiddenProfiles hides built-ins. Choose with M / Shift+M before E / Shift+E.
Reasoning mode Per-profile reasoningMode only: off (default) or log (Output only — never applied). No global llm.reasoningMode.
Queue mode (queue.mode) Checkpoint review (reviewChanges, default): enqueue runs the LLM; Q / Shift+Q review proposed edits before apply (amber). Checked items apply; unchecked stay queued. Deferred batch (deferExecution, advanced): enqueue stores tasks only (blue dotted); Q runs selected tasks — LLM + apply.
Per-profile concurrency Each LLM profile has its own async request pool (maxConcurrent: default 1 localhost, 2 cloud). Deferred batch and all LLM calls share the limit — not OS threads, but independent in-flight caps per endpoint.
Region lock Overlapping enqueue prompts first (Replace / Expand & merge in deferred mode / Cancel). Queue border color = LLM profile. Applied fixes live in a revert ledger (tracked through edits) until reverted; a new fix over an earlier one supersedes it.
Queued staged requests Shift+E enqueues (behavior depends on queue.mode). Q = current profile; Shift+Q = all profiles.
Review before apply (Enter) queue.enabled — Enter still autocorrects; uses the active queue.mode (review changes vs defer task).
Manual-only Enter disableAutocorrect — no automatic Enter fixes; call the LLM only when you use menu/staged keys.
LSP or deliberate Automatic: Enter can require language-server evidence or a built-in parser error (line.requireDiagnostic, syntax.useParser); the parser covers syntax errors only. Deliberate: menu/staged sends on demand (fix.requireDiagnostic optional). Off: disableAutocorrect stops Enter autocorrect entirely.
Paste-translate Paste foreign-language code → offer to translate (never silent replace). Faithfulness check rejects invented programs.
Local inference openai-compatible + localhost → 60s default timeout; 2048 default line max_tokens.
Typing harness Autocorrect: Run Typing Harness — replay prepare_plan.py JSON (LeetCode solutions with typos) to stress-test Enter autocorrect. See tests/harness/README.md.

See CHANGELOG.md for release notes (through v0.4.0).

You bring your own API key. Keys live in the editor's secret storage, not in settings files.


Syntax check

The extension parses the file itself with tree-sitter for Python, JavaScript, TypeScript, Go, Java, Rust, and C++, so Enter fixes work even when the language server has not reported yet. C and Zig rely on the language server; C++ keeps the parser. Set autocorrect.syntax.useParser to false to disable parser checks (default: true).

Quick start

  1. Install — VS Code Marketplace, Open VSX, or .vsix.
  2. API key — Command Palette → Autocorrect: Set API Key.
  3. Python LSP — see Language server setup. On Cursor, the first activation may offer Use Cursor defaults (turns off line.requireDiagnostic so Enter works when Anysphere diagnostics are quiet).
  4. Try it — open .py, type pritn("hello" on one line, press Enter on the next.

Status bar (bottom right): on/off, spinner, queue count (3 queued · groq:2 local:1). While menu/staged/capture is active, a persistent key hint stays visible until Esc. Click the Autocorrect item in a mode to open the command menu; otherwise click toggles the extension.

Logs: View → Output → LLM Autocorrect. Skip reasons also appear on the status bar after a paid call fails validation or apply.


Open the menu

Action Keys
Enter menu mode Double-tap Ctrl / Ctrl+Shift+;, or double-tap Cmd / Cmd+Shift+; on macOS
Exit menu (no staged block) Esc

While in menu, staged, or capture mode, the status bar shows a persistent key cheat sheet (until Esc). If letter keys seem ignored, open the menu first (double-tap Ctrl / Ctrl+Shift+;, or double-tap Cmd / Cmd+Shift+; on macOS), or click the Autocorrect status item for the command menu.


Keyboard reference

Menu mode

Key Action
A Fix block — immediate
Shift+A Stage selection → staged mode
C Fix line — immediate
Shift+C Stage cursor line → staged mode
S Staged Window — keyboard block sizing (WASD)
R Edit queued item at cursor
Q Review queue — current profile only
Shift+Q Review queue — all profiles
Esc Exit menu (clears staged block)

Staged mode (after Shift+A, Shift+C, or Staged Window E)

See Stage Modifiers for full tutorials (7–11).

Modifiers

Key Modifier
D Modifier: documentation (docstrings / comment blocks)
F Modifier: caveman (short inline comments)
Shift+D / Shift+F Toggle a docs / caveman follow-up step
(none) Modifier: best-guess fix (default)
X Modifier: custom prompt note (per request; saved with queued items)
1 Context tier: nearby lines (indentScope default; see tutorial 10)
2 Context tier: enclosing signature chain (class / def / …)
3 Context tier: recent edit hunks in this file (ringEnabled)
4 Context tier: imports + signatures from other open tabs (ringEnabled)
5 Context tier: last selection snippet (ringEnabled)
M Cycle LLM profile (choose before send)
Shift+M Pick LLM profile (QuickPick; choose before send)

Send

Key Action
E Send now — apply to file
Shift+E Enqueue — hold for review
A / C Immediate fix shortcuts (skip staging)
S Resize the staged block, keeping all flags
Esc Clear staging (put a re-staged queued item back)

Staged Window (after S)

Key Action
W / S Move selection end up / down
A / D Move to line start / end
E Finish sizing → staged mode (not an LLM send yet)
Esc Cancel Staged Window (restore the old range and flags when resizing)

Visual indicators

In editor Meaning
Green dashed lines Staged block
Colored left border Active LLM profile (blue groq, teal gemini, purple anthropic, orange local, pink ollama, grey guardian)
Markers before the first staged line (inline, horizontal) The ops in run order, each in its colour (blue fix, purple docs, orange caveman), then the active context-tier digits — e.g. fix → docs 1 2. With autocorrect.staged.markerStyle: "letters" the ops show as the keys you pressed instead: ✓ D 1 2 (✓ = fix, D = docs, F = caveman). Hover the markers for the full chain, profile, tiers and X note.
Amber / blue dashed lines Queued edits or tasks — left border color = LLM profile

Status bar shows modifiers and token estimate, e.g. fix · @Groq free · ctx:12 · ~840tok.


Tutorials — command flows

Each tutorial assumes you opened the menu unless noted.

1. Enter line autocorrect (hands-free)

When: You are typing normally and want typos fixed as you go.

  1. Enable autocorrect.line.enabled (default on).
  2. Type a line with a typo, e.g. pritn("hi").
  3. Press Enter on the next line.
  4. After a short debounce, if the language server reports an error/warning or the built-in parser (syntax.useParser) finds a syntax error on the previous line, the extension calls the LLM and may replace that line (brief highlight).

Tips

  • Default line.requireDiagnostic: true — a call needs evidence from the language server OR the built-in parser (syntax.useParser); the parser covers syntax errors only.
  • On Cursor, first launch may offer Use Cursor defaults → sets line.requireDiagnostic to false once (Anysphere diagnostics are often quiet). Decline if Problems already shows reliable squiggles.
  • Set line.requireDiagnostic: false manually to fix on Enter even without language-server or parser evidence. Token cost: every Enter on a non-blank line can trigger an LLM call after debounce, even when the line is already fine (you still pay for the prompt; the extension skips apply if the model returns the same text).
  • When Enter skips for lack of language-server or parser evidence, the status bar explains why (not only the Output channel).
  • Want Enter fixes to queue instead of applying right away? See tutorial 15 — Enter queue mode (queue.enabled + queue.mode).
  • Want to stop Enter fixes entirely and only call the LLM when you ask? See tutorial 16 (disableAutocorrect).

2. Immediate line fix (C)

When: You want one line corrected right now.

  1. Put the cursor on the line (or just below it).
  2. Open the menu → C.
  3. Status bar spins; the line updates or you see “already correct” / “skipped”.

Does not use staged mode. Respects fix.requireDiagnostic if enabled (default off — sends anytime).


3. Immediate block fix (A)

When: You selected a chunk of code and want it fixed immediately (no staging, no modifiers).

  1. Select the lines to fix.
  2. Open the menu → A.
  3. The selection is sent as a block fix; result replaces the selection.

4. Stage a block fix (Shift+A)

When: You selected a block with the mouse and want the full staged workflow — modifiers, then send or enqueue.

  1. Select the code block.
  2. Open the menu → Shift+A — green staged highlight appears.
  3. Set Stage Modifiers (tutorials 7–11) as needed.
  4. E send now (tutorial 12) or Shift+E enqueue (tutorial 13).

5. Stage a single line fix (Shift+C)

When: Same as tutorial 4 but for a single line without selecting manually.

  1. Open the menu → Shift+C — stages the cursor line (or previous non-blank line).
  2. Set Stage Modifiers → E (tutorial 12) or Shift+E (tutorial 13).

6. Stage a custom block selection (S → WASD → E)

When: The block is easier to size with the keyboard than a mouse selection — same modifier → send flow as Stage Workflow, but the block is sized with WASD first.

  1. Open the menu → S — Staged Window starts at cursor.
  2. W / S — extend end up/down; A / D — line start/end.
  3. E — finish sizing → enters staged mode (not an LLM send yet).
  4. Set Stage Modifiers → E (tutorial 12) or Shift+E (tutorial 13).

Stage Modifiers

Set these in staged mode (green highlight) before E or Shift+E (tutorials 12–13). Status bar shows what is active.

Key Modifier
(default) best-guess fix
D documentation — tutorial 7 (press again to switch back to fix)
F caveman — tutorial 8 (press again to switch back to fix)
X Custom prompt (per request) — tutorial 9
1–5 Context tiers — tutorial 10
M / Shift+M LLM profile — tutorial 11

D and F share one op slot: the last one pressed wins (D then F sends caveman only). Every other modifier can be set or changed in any order before sending; only the order of Shift+D / Shift+F follow-ups matters (it is the order the steps run).

Chains

Shift+D adds/removes a docs follow-up; Shift+F adds/removes caveman. Steps appear in order, e.g. fix → docs, with at most two follow-ups. A follow-up cannot be the main op; D / F makes that op primary and removes it from the follow-ups. Each step makes one model call on the previous step's output. The result is applied once at the end; any failed step applies nothing. The X instruction note applies only to the first step.

Editing a staged or queued block

In staged mode, S resizes the existing block using WASD while keeping its op, chain, context tiers, note and profile. E keeps the new range; Esc restores the old range. For a new selection, Esc clears staging; open the menu again and press S.

With the cursor inside a queued item, press R in the menu or run Autocorrect: Edit Queued Item at Cursor (also /edit-queued in the command menu). This pulls a pending task or ready change into staged mode, keeping its flags. Change flags or press S to resize, then E / Shift+E replaces the old item. Esc puts the original item back. Edited buffer text must still match the queued baseline.

Modifier examples

D (docs) and F (caveman) share one op slot — the last one pressed wins; no op key means fix. Shift+D / Shift+F keep the current op and add docs / caveman as a then step. Results below are typical model output; your model's wording will differ.

Staged block (every example starts here):

def total_price(items, tax):
    totl = 0
    for item in itmes:
        totl += item.price
    retrun totl * (1 + tax)
Keys after staging Ops sent Result
E fix typos fixed (total, items, return)
D → E docs rejected — docs altered code — skipped: docs may not change code, so it fails on code with typos. Use the chain below.
Shift+D → E fix → docs typos fixed and a docstring added, applied once
F → E (on correct code) caveman short end-of-line comments, code unchanged
D → F → E caveman F replaced D (one op slot)
D → Shift+F → E docs → caveman docstring, then short comments
X add type hints → E fix + instruction annotations added; logic unchanged (Guardian skipped for instructions)
Shift+D → X use snake_case names → E fix + instruction → docs the instruction applies to the first step only

Shift+D → E (fix → docs):

def total_price(items, tax):
    """Return the total price of items including tax."""
    total = 0
    for item in items:
        total += item.price
    return total * (1 + tax)

F → E (caveman) on the corrected code:

def total_price(items, tax):
    total = 0  # start sum
    for item in items:  # each item
        total += item.price  # add price
    return total * (1 + tax)  # add tax

One Remove or Revert Queued Change at Cursor undoes a whole chain, because it is applied as a single change.

7. Add docstrings (modifier D)

When: Add documentation without changing code lines.

  1. Stage a block (tutorials 4–6).
  2. D — modifier switches to documentation (nearby + signature context on by default). Press D again to go back to fix.
  3. Optional: X (tutorial 9); 1/2 (tutorial 10).
  4. E (tutorial 12) or Shift+E (tutorial 13).

Palette alternative: Autocorrect: Add Docstrings / Comments on a selection (uses docs-oriented default tiers and active profile).

Validation requires every original code line to come back unchanged and in order (only docstrings and comments may be added), so docs on code that still has typos is always rejected — use the fix → docs chain (Shift+D, see Chains) to fix and document in one send. If skipped after a model call, the Output channel shows the model text and a picker offers Copy model text or Force apply.


8. Caveman comments (modifier F)

When: Ultra-short inline comments (# get user, // loop nums).

  1. Stage a block.
  2. F — modifier switches to caveman (nearby context only by default). Press F again to go back to fix.
  3. Optional: X (tutorial 9); press 2 if you want signature context.
  4. E (tutorial 12) or Shift+E (tutorial 13).

The extension keeps your original code and merges only trailing comments from the model (line count is aligned when possible). If the model rewrote code, you get the same recovery picker as docs (Copy / Force apply).

Palette: Autocorrect: Caveman Comments.


9. Custom prompt (modifier X)

When: This send needs a one-off instruction — tighter than the default modifier, specific to the block you are about to send.

  1. Stage a block (tutorials 4–6).
  2. Press X — enter a custom prompt, e.g.:
    • only fix the typo, don't refactor
    • preserve all variable names
    • add types but don't change logic
  3. The note shows in the status bar and is prepended to this request's prompt. With the default fix op, a note switches the request to instruction mode ("edit this block as instructed") and skips Guardian, because it is a deliberate edit rather than a typo fix. With D or F, the note is added as an extra instruction to that op.
  4. E (tutorial 12) or Shift+E (tutorial 13) — custom prompt is sent and saved on queued items.

X is not global context. It applies to one staged send. For conventions on every request, use autocorrect.prompt.prefix (tutorial 17). X stacks on top of the global prefix when both are set.


10. Context tiers (modifiers 1–5)

When: You need more (or less) supplementary context in the prompt. Toggle in staged mode before E / Shift+E (tutorials 12–13).

Key Tier What it adds
1 Nearby Indent-scoped lines around the target by default (context.nearbyMode: indentScope), or a flat window. Includes a few lines below (contextLinesBelow, default 2).
2 Signature Enclosing header chain by default (class + def, …) via context.signatureDepth. On for fix/docs; off for caveman until you press 2.
3 Recent edits Last edit hunks in this file (diff-style snippets)
4 Open tabs Import lines + function/class signatures from other visible editor tabs
5 Yank Text from your last large selection in this session (not clipboard copy)

Tiers 3–5 require "autocorrect.context.ringEnabled": true.

Defaults: nearby + signature on (context.defaultTiers). Caveman staging resets to nearby only. When the token budget is tight, signature is kept before nearby. Output logs which tiers were actually included after budgeting.

Token budget: profile contextPolicy (minimal 512 / standard 1024 / extended 2048 tok) or context.tokenBudget override.


11. Multi-profile LLM (modifiers M, Shift+M)

When: Different models for different jobs — e.g. Groq for quick fixes, local llama-server for large context or reasoning models.

When to pick a profile: During staged mode, before E or Shift+E (tutorials 12–13). M cycles; Shift+M opens QuickPick. The profile you pick is used for that send and recorded on queued items. Use Shift+Q (tutorial 14) to review if you enqueued to multiple profiles.

Setup — use autocorrect.profiles only (do not set legacy provider / model / baseUrl alongside it):

{
  "autocorrect.activeProfile": "local",
  "autocorrect.profiles": [
    {
      "id": "groq",
      "label": "Groq free",
      "provider": "groq",
      "model": "llama-3.1-8b-instant",
      "contextPolicy": "minimal",
      "timeoutMs": 5000,
      "maxConcurrent": 3,
      "reasoningMode": "off"
    },
    {
      "id": "local",
      "label": "llama-server",
      "provider": "openai-compatible",
      "baseUrl": "http://127.0.0.1:8080/v1",
      "model": "local",
      "contextPolicy": "extended",
      "timeoutMs": 60000,
      "maxConcurrent": 1,
      "reasoningMode": "off",
      "maxTokensLine": 2048
    }
  ]
}

Built-in profiles live in the extension: groq, gemini, anthropic, local (Granite 4.1), guardian, ollama. autocorrect.profiles defaults to []; entries override built-ins by id, inheriting omitted fields, or add custom profiles when they have a new id and provider. Built-in updates therefore arrive automatically. A one-time upgrade migration removes unchanged copies saved by older releases and keeps only your overrides. autocorrect.hiddenProfiles (default []) hides profile ids; hiding every profile restores the built-ins.

For example, in User settings:

"autocorrect.profiles": [
  { "id": "groq", "timeoutMs": 3000 },
  { "id": "work", "provider": "openai-compatible", "baseUrl": "http://gpu-box:8000/v1", "label": "Work GPU" }
],
"autocorrect.hiddenProfiles": ["gemini"]

Set API key per cloud profile: Autocorrect: Set API Key. Localhost needs no key.

Reasoning — set per profile: reasoningMode: "off" minimizes thinking tokens (recommended for Enter fixes). "log" writes reasoning to Output → LLM Autocorrect but never applies it.

Usage

  1. Stage a block.
  2. M cycles profiles (updates global activeProfile) or Shift+M picks from list.
  3. E (tutorial 12) / Shift+E (tutorial 13) sends via that profile.

Concurrency: Each profile caps simultaneous LLM requests (maxConcurrent). Defaults: 1 for localhost, 2 for cloud. Deferred batch Q runs tasks in parallel across profiles and up to each profile's limit — not OS threads, but separate async pools per endpoint.

Local llama-server (start the server yourself; the extension does not launch it):

llama-server -m /path/to/model.gguf --host 127.0.0.1 --port 8080

Use an instruct/chat model via /v1/chat/completions. For profiles without their own timeout, autocorrect.timeoutMs: 0 defaults to 60s on localhost. Every built-in profile sets its own timeoutMs, which wins over global autocorrect.timeoutMs. To change a built-in timeout, add an override such as { "id": "local", "timeoutMs": 120000 } to autocorrect.profiles. Line fixes default to 2048 max_tokens on localhost (override with maxTokensLine).

Recommended local setup (Granite 4.1 + Guardian LoRA)

Recommended (VRAM-efficient): run Granite 4.1 8B as the fixer, and score corrections with Granite Guardian as a LoRA on the same base weights — not a second full 8B GGUF. One base + a small adapter uses far less VRAM than two full models, and keeps the judge aligned with the fixer family.

Role What to run Port / profile
Fixer granite-4.1-8b GGUF (Q4_K_M daily / Q8_0 quality) :8080 → profile local
Judge (preferred) Same base GGUF + Guardian LoRA (GGUF adapter via --lora) :8081 → profile guardian
Judge (fallback) Full granite-guardian-4.1-8b GGUF Q4_K_M :8081 → profile guardian

Why LoRA: Guardian is a specialized judge fine-tuned from Granite. Loading it as a LoRA on the fixer base avoids paying ~5GB for a second full model, leaves headroom for longer -c context on a 24GB GPU, and matches IBM’s Guardian-as-adapter packaging (granitelib-guardian).

Serve shape the extension expects (two OpenAI-compatible endpoints):

Fixer   http://127.0.0.1:8080/v1   →  autocorrect.activeProfile = "local"
Judge   http://127.0.0.1:8081/v1   →  autocorrect.guardian.profileId = "guardian"
1) Download base GGUFs

If your llama-cli was built without HTTPS/OpenSSL, use Python instead of -hf:

cd %USERPROFILE%\llama.cpp\models

python -c "from huggingface_hub import hf_hub_download; print(hf_hub_download('ibm-granite/granite-4.1-8b-GGUF','granite-4.1-8b-Q4_K_M.gguf', local_dir='.'))"
python -c "from huggingface_hub import hf_hub_download; print(hf_hub_download('ibm-granite/granite-4.1-8b-GGUF','granite-4.1-8b-Q8_0.gguf', local_dir='.'))"

Or, with an SSL-enabled llama-cli:

llama-cli -hf ibm-granite/granite-4.1-8b-GGUF:Q4_K_M -p "ping" -n 8
llama-cli -hf ibm-granite/granite-4.1-8b-GGUF:Q8_0 -p "ping" -n 8
2) Guardian LoRA (recommended judge)
  1. Download the PEFT LoRA for your Granite 4.1 size from ibm-granite/granitelib-guardian-r1.0 (path under guardian-core/…/lora).
  2. Convert with llama.cpp (convert_lora_to_gguf.py), passing --base to the matching HF base so module names resolve.
  3. Serve the same base GGUF as the fixer family, with the adapter attached:
cd %USERPROFILE%\llama.cpp\build_ninja\bin

REM Fixer (no LoRA)
llama-server.exe -m %USERPROFILE%\llama.cpp\models\granite-4.1-8b-Q4_K_M.gguf --host 127.0.0.1 --port 8080 -c 32768

REM Judge = same base + Guardian LoRA (preferred)
llama-server.exe -m %USERPROFILE%\llama.cpp\models\granite-4.1-8b-Q4_K_M.gguf --lora %USERPROFILE%\llama.cpp\models\guardian-core.gguf --host 127.0.0.1 --port 8081 -c 8192

Use Q8_0 on :8080 if you want a higher-quality fixer; keep the judge on Q4 + LoRA to save VRAM.

3) Fallback: full Guardian GGUF (no LoRA yet)

If you have not converted a LoRA yet, a second full Guardian GGUF still works with the built-in guardian profile:

python -c "from huggingface_hub import hf_hub_download; print(hf_hub_download('ibm-granite/granite-guardian-4.1-8b-GGUF','granite-guardian-4.1-8b-Q4_K_M.gguf', local_dir=r'%USERPROFILE%\\llama.cpp\\models'))"

llama-server.exe -m %USERPROFILE%\llama.cpp\models\granite-guardian-4.1-8b-Q4_K_M.gguf --host 127.0.0.1 --port 8081 -c 8192
4) Extension settings
"autocorrect.activeProfile": "local",
"autocorrect.guardian.enabled": true,
"autocorrect.guardian.profileId": "guardian",
"autocorrect.guardian.maxRetries": 1,
"autocorrect.apply.onReject": "softApply"

softApply (default) still writes a rejected candidate so you can revert; skip only logs. Staged X context notes are treated as instructions (e.g. add typing) and skip Guardian. Leave guardian.enabled false until both servers are up.

Suggested trials on RTX 4090 24GB: Q4 fixer only → Q4 fixer + Guardian LoRA → Q8 fixer + Guardian LoRA (or Q4 full Guardian fallback).


12. Send now (E)

When: You have staged a block (tutorials 4–6) and set Stage Modifiers (tutorials 7–11). You want the LLM result applied to the file immediately.

  1. Green staged highlight must be active.
  2. Press E — sends with current modifiers; result replaces the staged block.

Default modifier is best-guess fix. Status bar shows active modifiers and token estimate.


13. Enqueue send (Shift+E)

When: Same staging and modifiers as tutorial 12, but you want to queue instead of applying immediately. Behavior depends on queue.mode — pick one (mutually exclusive):

Setting value Name Shift+E does Q / Shift+Q does
reviewChanges Checkpoint review (default) Calls LLM now; stores proposed edit (amber) Review edits — apply checked; unchecked stay queued
deferExecution Deferred batch Stores task only — no LLM yet (blue dotted) Run checked tasks — LLM + apply immediately (parallel per profile)
  1. Stage and set modifiers (tutorials 4–11).
  2. Press Shift+E.
  3. Open the menu → Q or Shift+Q (tutorial 14).

14. Review queue — Q (current profile), Shift+Q (all profiles)

When: You enqueued with Shift+E (tutorial 13) or used Enter queue mode (tutorial 15).

Checkpoint review (reviewChanges) — review proposed edits

  1. Open the menu → Q (current profile) or Shift+Q (all).
  2. QuickPick shows longer original → corrected previews.
  3. Checked items apply; unchecked stay queued. Esc leaves the queue unchanged. Use Clear Queued Fixes to drop items.

Deferred batch (deferExecution, advanced) — run queued tasks

  1. Open the menu → Q or Shift+Q.
  2. QuickPick lists pending tasks (op, lines, snippet) — no diff yet.
  3. Checked tasks run (LLM + immediate apply, up to each profile's maxConcurrent); unchecked stay queued.

Palette shortcuts

  • Review Queued Fixes — all profiles (same as Shift+Q).
  • Apply All Queued Fixes — apply all checkpoint review items without picker (deferred batch queue ignored).

15. Enter queue mode (queue.enabled)

When: You want Enter autocorrect to queue instead of applying immediately. Uses the active queue.mode:

  • Checkpoint review — Enter calls LLM; amber lines; Q reviews edits.
  • Deferred batch — Enter queues tasks; blue dotted lines; Q runs tasks in parallel per profile.
  1. Set "autocorrect.queue.enabled": true or run Toggle Review Before Apply Mode.
  2. Type and press Enter as usual.
  3. When ready, Q / Shift+Q (tutorial 14).

Manual C / staged E still apply immediately unless you use Shift+E.


16. Disable Enter autocorrect (disableAutocorrect)

When: You do not want automatic line-by-line corrections while you type. You only want to call the LLM when you deliberately ask — immediate fix (C / A / staged E) or enqueue for later review (staged Shift+E, tutorial 13).

This setting has nothing to do with the queue. It turns off Enter-triggered checks and API calls entirely. That avoids unnecessary LLM use when you are just drafting code.

  1. Set "autocorrect.disableAutocorrect": true or run Toggle Enter Autocorrect Off.
  2. Type normally — Enter does not trigger fixes or queue anything.
  3. When you want a fix: open the menu → C or A for immediate apply, or Shift+A / Shift+C → Stage Modifiers → E or Shift+E.

Status bar shows Autocorrect (manual) while Enter autocorrect is off.


17. Global context (prompt.prefix)

When: Every LLM call should inherit the same project conventions — framework, style, file role — without pressing X each time.

"autocorrect.prompt.prefix": "Flask API. Use type hints. Prefer pathlib."
  • Prepended to every user message (Enter, C, A, staged E, etc.).
  • Groq does not cache this — you pay tokens on each request.
  • Stacks with modifier X when both are set (X is per-send; prefix is global — tutorial 9).

18. Paste-translate

When: You pasted code in the wrong language.

  1. Paste a block that looks like a different language than the file (uncommented — a # int main… Python comment will not detect as C++).
  2. Extension offers to convert — accept or dismiss.
  3. Never replaces without confirmation. Replies that invent unrelated names (e.g. greet for a cout snippet) are rejected unless you Force apply.

Palette: Autocorrect: Translate Selection.


19. Command palette & slash menu

Command Palette — user-facing commands only (internal hotkey commands are hidden). Commands marked "(internal)" are keybinding targets and are not meant to be run from the palette.

Command Effect
Autocorrect: Check for Logic Bugs Review code for logic suggestions
Autocorrect: Clear Logic Suggestions Clear logic suggestions
Autocorrect: Toggle On/Off Toggle the master switch
Autocorrect: Status Bar Click Toggle on/off or open the command menu in a mode
Autocorrect: Set API Key Per profile
Autocorrect: Enter Menu Mode Double-tap Ctrl / Ctrl+Shift+;, or double-tap Cmd / Cmd+Shift+; on macOS
Autocorrect: Review Queued Fixes All profiles
Autocorrect: Apply All Queued Fixes Apply all checkpoint edits (deferred tasks excluded)
Autocorrect: Clear Queued Fixes Empty queue
Autocorrect: Edit Queued Item at Cursor Pull a queued item into staged mode; Esc puts it back
Autocorrect: Remove or Revert Queued Change at Cursor Drop a queued item or revert the matching applied fix
Autocorrect: Toggle Review Before Apply Mode Enter fixes → review before apply
Autocorrect: Toggle Enter Autocorrect Off Toggle automatic Enter fixes
Autocorrect: Run Typing Harness Replay prepare_plan.py JSON for Enter autocorrect stress tests
Autocorrect: Correct Line Near Cursor Immediate line fix
Autocorrect: Correct Selected Block Immediate block fix
Autocorrect: Add Docstrings / Comments Docs on selection / staged
Autocorrect: Caveman Comments Caveman on selection / staged
Autocorrect: Translate Selection Translate selected code to the file language
Autocorrect: Command Menu (QuickPick) /menu, /block, /line, etc.
Autocorrect: Exit Menu Mode Exit the menu and clear staging

Recommended model usage

Autocorrect is surgical line/block repair, not inline ghost-text completion. Pick profiles by job — not every model fits every path.

Job Profile Model / stack Key settings
Enter line fixes (cloud) groq llama-3.1-8b-instant line.requireDiagnostic: true (saves tokens); reasoningMode: "off"; contextPolicy: minimal
Enter line fixes (local / private) local Granite 4.1 8B Q4_K_M on :8080 reasoningMode: "off"; maxTokensLine: 2048; on Cursor set line.requireDiagnostic: false if squiggles are quiet
Quality gate (optional) guardian Guardian LoRA on same base @ :8081 (full Guardian GGUF fallback) guardian.enabled: true; maxRetries: 1; apply.onReject: softApply
Staged block / docs / caveman groq or local Same as above fix.requireDiagnostic: false (default); tiers 1–2 usually enough; use X for one-off instructions
Paste-translate groq or local Same fixer profile Faithfulness prefilter + Guardian when enabled
Not this extension — Granite H-Tiny / FIM autocomplete, 30B dense models Use a separate completion tool; too slow or wrong task for Enter repair

Daily-driver combos

  1. Fastest cloud — Groq only, diagnostic gate on, no Guardian. Good for laptops without a GPU.
  2. Recommended local (24 GB GPU) — Granite 4.1 8B fixer + Guardian LoRA judge (see tutorial 11). One base GGUF + small adapter beats two full 8B models on VRAM.
  3. Hybrid — Groq for quick fixes, local Granite for large staged blocks (M / Shift+M before send).

Always

  • Set reasoningMode: "off" on every fixer profile — reasoning burns max_tokens and yields empty content on local servers.
  • Use named profiles only — remove legacy autocorrect.provider / baseUrl / model so logs show local, not default.
  • Staged X notes are instructions (add types, preserve names) — Guardian skips them by design.

Groq setup (recommended cloud)

  1. console.groq.com → API key (gsk_…).
  2. Autocorrect: Set API Key → groq.

Default model: llama-3.1-8b-instant. Free tier ~30 req/min.

Save tokens: keep line.requireDiagnostic on; use staged tiers sparingly on Groq (contextPolicy: minimal).

Other providers

Provider Notes
gemini Google AI Studio API key
anthropic Anthropic Console API key
openai-compatible Ollama http://localhost:11434/v1, llama-server http://127.0.0.1:8080/v1

Logic suggestions

Run Autocorrect: Check for Logic Bugs to review a staged block, selection, or the function/class around the cursor for likely logic bugs. Suggestions appear in Problems with quick fixes to apply a single-line correction or dismiss it. Nothing is ever applied automatically. Use Autocorrect: Clear Logic Suggestions to clear them.

autocorrect.logic.profileId selects the review profile (default "" uses the active profile); autocorrect.logic.maxIssues limits suggestions per review (default 5).

Privacy

Requests send the target line or block (or source snippet for translation) to the chosen profile. Correction prompts can include nearby lines and enclosing signatures. Optional ring tiers add recent edits, open-tab signatures and the last large selection; autocorrect.context.ringEnabled defaults to false. Enabled prompt options can also send diagnostics, defined names and project or per-request notes. When Guardian is enabled, it receives the original target and candidate reply.

autocorrect.context.excludeGlobs is machine-scoped and defaults to:

["**/.env", "**/.env.*", "**/*.pem", "**/*.key", "**/id_rsa*", "**/id_ed25519*", "**/*.p12", "**/*.pfx", "**/secrets.*", "**/*secret*.json", "**/credentials*", "**/.aws/**", "**/.ssh/**", "**/.npmrc", "**/.pypirc", "**/*.kdbx"]

Matching files are excluded from correction and translation, selection capture, recent edit capture and open-tab context. Paths are matched case-insensitively, including Windows paths.

autocorrect.privacy.redactSecrets defaults to true. It replaces recognized private-key blocks, API tokens, JWTs and quoted secret assignments with «redacted» in supplementary context before compression and budgeting, and in every diagnostic message before prompt formatting. The target itself is preserved for correction or translation.

autocorrect.privacy.skipSecretTargetsForCloud defaults to true: targets containing recognized secrets are skipped for cloud profiles. A profile is local only when its provider is openai-compatible and its URL is recognized as local (for example localhost or a loopback address). A cloud Guardian judge is also skipped for a secret-bearing original, accepting the candidate. Both privacy settings are machine-scoped. Detection uses patterns and cannot identify every possible secret.

Endpoint settings (autocorrect.profiles, legacy provider / model / baseUrl, and guardian.profileId) are machine-scoped, so workspace settings cannot redirect API keys. Keys live in VS Code secret storage and are bound to the endpoint they were saved for; changing that endpoint requires saving the key again.


Settings

Setting Default Description
autocorrect.enabled true Master switch
autocorrect.disableAutocorrect false Stop automatic Enter line fixes; fix on demand only (tutorial 16)
autocorrect.profiles [] Override built-ins by id or add custom endpoints in User settings (tutorial 11).
autocorrect.hiddenProfiles [] Profile ids to hide (machine-scoped).
autocorrect.activeProfile "groq" Active profile id
autocorrect.guardian.enabled false Score fix/paste replies with Granite Guardian before apply
autocorrect.guardian.profileId "guardian" Judge profile (default :8081)
autocorrect.guardian.maxRetries 1 Extra fixer regenerations after Guardian no
autocorrect.apply.verifyAfterApply true Re-check immediate fixes; undo new errors when the error count does not decrease. Queue review is excluded.
autocorrect.apply.verifyWaitMs 2000 Maximum wait for updated diagnostics after a fix (ms).
autocorrect.apply.onReject "softApply" After final reject: softApply (apply + revert) or skip (log only)
autocorrect.provider "groq" Legacy — only if profiles is empty
autocorrect.model "" Legacy model id
autocorrect.baseUrl "" Legacy openai-compatible URL
autocorrect.languages ["python"] Active language IDs
autocorrect.prompt.prefix "" Global context on every request (tutorial 17)
autocorrect.line.enabled true Enter-triggered line fixes
autocorrect.line.requireDiagnostic true Automatic (Enter): need language-server evidence OR a built-in parser (syntax.useParser) error; parser covers syntax only.
autocorrect.fix.requireDiagnostic false Deliberate (menu/staged): when true, need language-server evidence OR a built-in parser (syntax.useParser) error; parser covers syntax only.
autocorrect.line.contextLines 10 Tier 1: max lines above (within nearby mode)
autocorrect.line.contextLinesBelow 2 Tier 1: lines below target
autocorrect.line.maxLineChars 200 Max chars per context line
autocorrect.context.tokenBudget 0 Hard context cap (0 = profile policy)
autocorrect.context.ringEnabled false Enable tiers 3–5
autocorrect.context.nearbyMode "indentScope" indentScope | window
autocorrect.context.signatureDepth "chain" chain | header
autocorrect.context.defaultTiers {"nearby": true, "signature": true, "recentEdits": false, "openTabs": false, "yank": false} Default tier modifiers in staged mode
autocorrect.timeoutMs 0 Global timeout fallback; 0 = auto (5s cloud, 60s localhost). Every built-in sets its own timeoutMs, which takes precedence.
autocorrect.line.debounceMs 800 Delay after Enter before check
autocorrect.queue.mode "reviewChanges" Checkpoint review (default) vs deferred batch (advanced). Unchecked stay queued.
autocorrect.queue.enabled false Enter queues instead of applying; uses queue.mode (tutorial 15)
autocorrect.debug false Scheduling/skip logs and system/user prompts (3000 chars each, may contain code); reasoning requires profile reasoningMode: "log".
autocorrect.paste.enabled true Offer to translate pasted code from another language.
autocorrect.syntax.useParser true Use built-in syntax-error evidence alongside the language server; C relies on the language server.
autocorrect.prompt.includeDiagnostics true Include language-server and parser messages in correction prompts.
autocorrect.prompt.includeNames true Include names defined in the file in fix prompts.
autocorrect.prompt.examples false Include five examples in line fixes only. Off by default: small local models tend to copy the examples into their reply.
autocorrect.line.wholeStatement true Expand targets across open parentheses/brackets or backslash continuations; braces expand only in Python.
autocorrect.logic.profileId "" Logic-review profile; empty uses the active profile.
autocorrect.logic.maxIssues 5 Maximum logic suggestions per review.
autocorrect.staged.markerStyle "names" How staged ops are shown before the first staged line: "names" (fix → docs) or "letters" (✓ D, the keys you pressed). Tier digits follow either way.
autocorrect.fix.localChecks true Check string contents, identifiers, and change size before applying fixes.
autocorrect.context.excludeGlobs ["**/.env", "**/.env.*", "**/*.pem", "**/*.key", "**/id_rsa*", "**/id_ed25519*", "**/*.p12", "**/*.pfx", "**/secrets.*", "**/*secret*.json", "**/credentials*", "**/.aws/**", "**/.ssh/**", "**/.npmrc", "**/.pypirc", "**/*.kdbx"] Exclude matching files from targets and context (machine-scoped).
autocorrect.privacy.redactSecrets true Redact recognized secrets from context and diagnostic messages.
autocorrect.privacy.skipSecretTargetsForCloud true Skip secret-bearing targets for cloud profiles, including Guardian.
autocorrect.line.diagnosticWaitMs 1500 Wait for language-server evidence before skipping Enter (ms); parser syntax evidence can pass immediately.

Profile object fields (inside autocorrect.profiles): id, label, provider, model, baseUrl, contextPolicy, timeoutMs, maxConcurrent, reasoningMode, reasoningEffort, maxTokensLine, maxTokensBlock, color.

Supported languages

Default: python only. Also built-in (less tested): go, java, c, cpp, rust, zig, javascript, typescript.

"autocorrect.languages": ["python", "typescript"]

Language server setup (VS Code vs Cursor)

The extension reads diagnostics from your editor's LSP — it does not ship one.

VS Code (Python)

Step Action
Extensions Python + Pylance
Interpreter Python: Select Interpreter
Settings "python.languageServer": "Pylance"
{
  "python.languageServer": "Pylance",
  "python.analysis.typeCheckingMode": "basic",
  "autocorrect.line.requireDiagnostic": true
}

Cursor (Python)

Use Anysphere Python (anysphere.python), not Pylance.

Usually you do not need to paste JSON — on first activation Autocorrect may offer Use Cursor defaults, which sets autocorrect.line.requireDiagnostic to false so Enter can fix lines when diagnostics are quiet.

Manual fallback (if you dismissed the prompt):

{
  "python.languageServer": "Default",
  "cursorpyright.analysis.typeCheckingMode": "all",
  "autocorrect.line.requireDiagnostic": false
}

Set requireDiagnostic back to true once View → Problems shows errors reliably. With false, every Enter on a non-blank line can burn tokens (see tutorial 1).

Other languages

Add language ID to autocorrect.languages and install the language server (rust-analyzer, gopls, etc.).


How it behaves

Line mode — Enter only; skips blank/comment lines; may add lines for syntax fixes (e.g. missing ) on next line). When diagnostics on the left line are only cascade fallout (unexpected indent, “return outside function”), the fix targets the upstream syntax error instead.

Block mode — Full block replace; line count may grow or shrink.

Context — Nearby context is indent-scoped by default (same/outer indent + enclosing header). The prompt sends raw buffer text and the file language; the model infers typos and wrong-language idioms. Prefer paste-translate for large foreign-language pastes.

Privacy — Code sent to your chosen provider when a correction runs; keys in secret storage.

No auto-suggest — No Tab ghost text or inline prediction.


Troubleshooting

Enable "autocorrect.debug": true and open View → Output → LLM Autocorrect for skip reasons, diagnostic-gate timing, and LLM call logs. Debug mode also logs system/user prompts (up to 3000 characters each), including code: [line] prompt (system):, [line] prompt (user):, [staged] prompt (system):, and [staged] prompt (user):.

Enter / line autocorrect

Problem What to check
Nothing on Enter File must be a real source doc (.py, not Output/Settings). Language ID must be in autocorrect.languages (default: python only). Master switch on (status bar sparkle, not slash). autocorrect.disableAutocorrect must be false (tutorial 16). autocorrect.line.enabled must be true. Wait ~line.debounceMs (default 800ms) after Enter. Blank and comment-only lines are skipped.
Log says no LSP squiggle / status bar skip With default line.requireDiagnostic: true, a call needs language-server evidence OR a built-in parser (syntax.useParser) syntax error on that line. The parser covers syntax errors only. Fix LSP setup (View → Problems), or set line.requireDiagnostic: false (higher token use — tutorial 1). On Cursor, accept the first-run prompt or see Language server setup.
Manual C works, Enter doesn't Automatic Enter uses line.requireDiagnostic; deliberate C uses fix.requireDiagnostic (default off). If LSP is slow, increase autocorrect.line.diagnosticWaitMs (default 1500ms). Or set line.requireDiagnostic: false.
already correct / no edit Model returned the same line or UNCHANGED. Normal — no apply, but you may still have paid for the prompt.
whitespace-only diff / indent no-op Model echoed the target without indent. v0.2.3 reattaches buffer indent and retries the previous line when cascade/root diagnostics point upstream.
empty content — reasoning consumed tokens Reasoning model burned the output budget. Set profile reasoningMode: "off", raise maxTokensLine (localhost default 2048), and confirm Output shows v0.4.0.
Wrong profile / default in logs Remove legacy autocorrect.provider / baseUrl / model when using profiles. Activation should list your profile ids.
Range locked on enqueue Overlapping queued items offer Replace or Cancel. Expand & merge is offered only in deferred mode (queue.mode: deferExecution) for the same profile. A new fix over an earlier applied fix supersedes it.
Remove / revert at cursor Command Palette → Remove or Revert Queued Change at Cursor — drops a queued item, or reverts a ledger entry if the buffer still matches.
Enter does nothing at all (no log) Likely disableAutocorrect: true or line.enabled: false. Status bar shows (manual) when Enter autocorrect is off.

Menu, staged mode, and manual fixes

Problem What to check
Menu keys ignored Open the menu first (double-tap Ctrl / Ctrl+Shift+;, or double-tap Cmd / Cmd+Shift+; on macOS). Keys only work in menu, staged, or capture mode. The status bar keeps a key hint until Esc. Click Autocorrect in a mode for the command menu.
Staged send skipped Deliberate gate: fix.requireDiagnostic: true requires language-server evidence OR a built-in parser (syntax.useParser) syntax error in the block; the parser covers syntax errors only. Default false — sends anytime.
buffer changed — skipped File was edited while the LLM was running. Re-stage and send again.
Paid call but nothing applied Status bar shows the reason. Output has the model text for docs/caveman rejects; use Copy / Force apply when offered.
select a block for A A needs a non-empty selection. Use Shift+A to stage without immediate send, or S Staged Window.
Docs / caveman odd or skipped D rejects output that alters code lines or invents new classes. F merges comments onto your original code and rejects rewrites. Use the recovery picker or X for tighter instructions.

Queue, profiles, and API

Problem What to check
Queue wrong profile Profile is chosen during modifiers (M / Shift+M) before Shift+E. Q shows the current profile's queue only; Shift+Q shows all.
Queue empty after review Unchecked items stay queued. Use Clear Queued Fixes to drop them. Esc cancels without changing the queue.
413 / token limit (Groq) Prompt too large. Disable tiers 3–5; turn off 1/2 if needed; smaller selection; contextPolicy: minimal; lower context.tokenBudget.
LLM timeout / hung Every built-in profile sets timeoutMs, which wins over global autocorrect.timeoutMs. Add an override such as { "id": "local", "timeoutMs": 120000 } to autocorrect.profiles. Profiles without a timeout use the global value (0: ~5s cloud / 60s localhost). Confirm llama-server/Ollama is running and baseUrl ends with /v1.
API key / auth errors Command Palette → Set API Key per profile. Keys live in secret storage, not settings.json.
F5 Extension Development Host API keys and settings are per-window — set the key again in the Extension Development Host, not only the outer IDE.

Settings mix-ups

Problem What to check
queue.enabled vs disableAutocorrect queue.enabled — Enter still autocorrects but queues per queue.mode (tutorial 15). disableAutocorrect — Enter does nothing; you fix on demand only (tutorial 16). They solve different problems.
Paste translate never offers autocorrect.paste.enabled must be true. Only triggers on paste that looks like a different language than the file. Never silent — you must accept the prompt.

Upcoming features

  • Broader language testing (Go, Rust, JS/TS, etc.).
  • Richer queue review (side-by-side diff UI).
  • Optional further micro-context / request sharing — module- or project-wide context belongs in the Cursor agent, not this extension; keep a clear boundary between surgical autocorrect context and agent context.

License

PolyForm Noncommercial 1.0.0 — see LICENSE.

Development

npm install → npm run compile → F5. See CONTRIBUTING.md.

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages