Skip to content

Repository files navigation

🤖 AI Code Assistant — VS Code Extension

AI-powered code completion, error fixing, real-time analysis, and interactive learning — supporting OpenAI, Google Gemini, and local Ollama models.

Version VS Code License


✨ Features

Feature Shortcut Description
Analyze & Fix Errors Ctrl+Shift+F Sends the active file (or selection) to AI, shows a diff panel, and lists fix suggestions
Quick Fix Selection Ctrl+Shift+Q Fixes only the selected code and replaces it inline
Explain Code Ctrl+Shift+E Beginner-friendly step-by-step explanation of selected code
Context-Aware Complete Ctrl+Shift+Space Generates completion options using imports, function signature, prefix and suffix
Generate Docstring Ctrl+Shift+D Auto-generates JSDoc / Python / Javadoc comments for the function at cursor
💬 Chat Panel (0.2.1) Ctrl+Shift+C Multi-turn conversational assistant — ask follow-up questions about your code
⚡ Provider Benchmark (0.2.1) Command Palette Send the same prompt to all configured providers and compare results side-by-side
🗂 Workspace Analysis (0.2.1) Command Palette Scan every source file and view an aggregated quality report
Inline Completions Automatic Ghost-text suggestions while you type (debounced, smart triggers)
Real-Time Analysis Automatic Errors detected as you type — no need to save first
Learning Center Ctrl+Shift+L Error history, category statistics, and curated learning resources
Quality Score Status bar Live 0–100 quality score with letter grade (A–F) per file

What's New in 0.2.1

  • Chat Panel — Persistent multi-turn AI chat in a side panel. File name and language are sent automatically as context.
  • Provider Benchmark — Compare OpenAI, Gemini, and Ollama on the same prompt simultaneously. Shows latency and token estimates.
  • Workspace Analyzer — Scans all eligible source files (up to 500 lines each) and generates a sortable quality report.
  • Git Diff Mode — Sends only the changed hunks (git diff HEAD) to the AI instead of the entire file, reducing token cost.
  • English codebase — All source comments, error messages, and UI strings are now in English for GitHub discoverability.

🤖 Supported AI Providers

Provider Models API Key
OpenAI gpt-4o, gpt-4o-mini Required (sk-…)
Google Gemini gemini-2.5-flash, gemini-2.5-pro Required (AIza…)
Ollama (local) llama3.2, qwen2.5-coder, deepseek-coder, codestral, mistral, phi4, custom Not required

🚀 Installation

Prerequisites

  • Node.js ≥ 18
  • VS Code ≥ 1.85
  • An API key for OpenAI or Gemini or Ollama running locally

Build from source

git clone https://github.com/your-username/ai-code-assistant.git
cd ai-code-assistant
npm install
npm run compile
npm run package          # produces ai-code-assistant-0.7.0.vsix

Then in VS Code: Extensions → ⋯ → Install from VSIX…

Configure a provider

Open the Command Palette (Ctrl+Shift+P) and run:

AI Assistant: Configure Provider & API Key

Or edit settings.json directly:

{
  "aiAssistant.provider": "openai",
  "aiAssistant.model":    "gpt-4o",
  "aiAssistant.apiKey":   "sk-YOUR_KEY_HERE"
}

For Ollama (no API key needed):

{
  "aiAssistant.provider":   "ollama",
  "aiAssistant.model":      "qwen2.5-coder",
  "aiAssistant.ollamaHost": "http://localhost:11434"
}

⚙️ Settings Reference

Setting Default Description
aiAssistant.provider openai AI provider: openai, gemini, or ollama
aiAssistant.apiKey "" API key (leave empty for Ollama)
aiAssistant.model gpt-4o Model name — must match the selected provider
aiAssistant.ollamaHost http://localhost:11434 Ollama server address
aiAssistant.inlineCompletions true Enable ghost-text inline completions
aiAssistant.completionDebounceMs 800 Delay before inline completion triggers (ms)
aiAssistant.autoAnalyze true Run analysis automatically on file save
aiAssistant.realtimeAnalysis true Detect errors while typing (debounced)
aiAssistant.maxTokens 1024 Maximum tokens for AI responses
aiAssistant.gitDiffMode true Send only changed hunks instead of full file (0.2.1)
aiAssistant.workspaceAnalysis false Enable workspace-wide quality scanning (0.2.1)

🗂️ Project Structure

ai-code-assistant/
├── src/
│   ├── extension.ts              # Entry point — activates all subsystems and registers commands
│   ├── aiClient.ts               # Unified HTTP client for OpenAI / Gemini / Ollama
│   ├── codeAnalyzer.ts           # Fix / explain / complete / diagnostics prompt logic
│   ├── contextBuilder.ts         # Builds rich cursor context (imports, signature, prefix/suffix)
│   ├── diffApplier.ts            # VS Code diff editor + line-by-line patch application
│   ├── diagnosticsManager.ts     # Problems panel integration + CodeAction provider
│   ├── inlineCompletionProvider.ts  # Ghost-text completions with smart trigger debounce
│   ├── realtimeAnalyzer.ts       # Live error detection while typing
│   ├── errorHistoryManager.ts    # Persistent error-category statistics (globalState)
│   ├── qualityScorer.ts          # Status-bar 0-100 quality score with letter grade
│   ├── docstringGenerator.ts     # Language-aware JSDoc / Python / Javadoc generation
│   ├── suggestionPanel.ts        # WebView panel for fix/explain/complete results
│   ├── learningPanel.ts          # WebView learning centre with resource links
│   ├── chatPanel.ts              # ★ NEW: Multi-turn conversational AI chat panel
│   ├── providerBenchmark.ts      # ★ NEW: Side-by-side provider comparison panel
│   ├── workspaceAnalyzer.ts      # ★ NEW: Workspace-wide quality report
│   ├── gitDiffAnalyzer.ts        # ★ NEW: Extract changed hunks via git diff HEAD
│   └── __tests__/
│       ├── codeAnalyzer.test.ts
│       └── diagnosticsManager.test.ts
├── package.json
├── tsconfig.json
└── jest.config.js

🧪 Running Tests

npm test

All 41 unit tests cover:

  • CodeAnalyzer — JSON extraction, result parsing, truncation, sanitisation, diagnostics
  • AIClient — singleton caching, Gemini role merging, Ollama preset models, key prefixes
  • DiagnosticsManager — severity mapping, collection lifecycle
  • ContextBuilder — cursor marker injection, import extraction
  • ErrorHistoryManager — recording, category detection, repeated errors, clear
  • QualityScorer — score calculation, grade thresholds, floor at 0

🏗 Architecture Overview

┌─────────────────────────────────────────────────────┐
│                    VS Code UI Layer                  │
│  SuggestionPanel · ChatPanel · LearningPanel        │
│  BenchmarkPanel  · QualityScorer (status bar)       │
└────────────────────────┬────────────────────────────┘
                         │
┌────────────────────────▼────────────────────────────┐
│              Orchestration (extension.ts)            │
│  Command handlers · Event listeners · Config reads  │
└──┬──────────────┬──────────────┬────────────────────┘
   │              │              │
┌──▼──┐      ┌───▼───┐    ┌─────▼──────┐
│Code │      │Inline │    │ Realtime   │
│Anal.│      │Compl. │    │ Analyzer   │
└──┬──┘      └───┬───┘    └─────┬──────┘
   │              │              │
┌──▼──────────────▼──────────────▼──────┐
│            AIClient                    │
│  OpenAI · Gemini · Ollama             │
│  Retry · Usage tracking · Cost est.  │
└────────────────────────────────────────┘
   │              │
┌──▼──┐      ┌───▼──────────┐
│Git  │      │Diagnostics   │
│Diff │      │Manager       │
│Ana. │      │ErrorHistory  │
└─────┘      │QualityScorer │
             └──────────────┘

🗺 Roadmap

  • JetBrains / IntelliJ port (LSP-based core extraction)
  • Spaced-repetition reminders for recurring error patterns
  • Streaming responses in Chat Panel
  • Multi-file context (send related files alongside the active file)
  • GitHub Copilot Chat API integration

📄 License

MIT © 2025 — contributions welcome.

About

An advanced AI-powered development assistant and workspace analyzer extension for Visual Studio Code, featuring real-time code diagnostics, inline completions, and multi-provider benchmarking.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages