Skip to content
| Marketplace
Sign in
Visual Studio Code>AI>GitHub Context Compiler CopilotNew to Visual Studio Code? Get it now.
GitHub Context Compiler Copilot

GitHub Context Compiler Copilot

Ritesh Agarwal

|
13 installs
| (1) | Free
Knowledge-graph-powered GitHub Copilot context optimizer — understands code relationships to select smarter, smaller context.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Github Context Compiler Copilot

Made by Ritesh Agarwal — ☕ Buy me a coffee

The intelligent GitHub Copilot optimization layer — Strips VS Code boilerplate, builds a workspace knowledge graph, intelligently filters system prompts, trims chat history, and visualizes context. Pick a model from the ContextCompilerCopilot group and every request is automatically optimised.

What you get: 30–50% token savings per request • Lower API costs • Knowledge graph visualization • Real-time analytics dashboard • Zero setup.

How: VS Code extension. No Python. No Docker. No separate server. Just install and go.


How to Use

  1. Install and reload VS Code — the proxy starts automatically
  2. Open GitHub Copilot Chat (Ctrl+Alt+I / Cmd+Alt+I)
  3. Click the model selector at the bottom of the chat input
  4. Choose any model under the ContextCompilerCopilot group — Claude, GPT-4o, Gemini, etc.
  5. All requests through that model are automatically optimised through the Context Compiler pipeline
  6. Open the Savings Dashboard (http://localhost:8181/dashboard) to see token savings in real time

Features

🔄 Smart Context Compilation

The core pipeline automatically optimizes every request:

  1. Boilerplate Stripping — Removes VS Code injected XML blocks (<environment_info>, <reminderInstructions>, <context>, <editorContext>, <workspace_info>) from user messages
  2. Mode Detection — Auto-classifies requests as agent (with tools) or ask (simple query) mode
  3. LLM-Based Section Extraction — Uses Claude Haiku 4.5 to intelligently identify and filter irrelevant system-prompt sections (skills, agents, instructions, tool directives) — not just regex-based
  4. History Trimming — Truncates old tool-call results beyond a configurable window (default 3 turns) to preserve token budget
  5. Token Counting — Accurate token accounting using cl100k_base encoding (Tiktoken)

Result: 30–50% token reduction per request • Lower API costs • Faster response times

📊 Knowledge Graph Engine

Automatically indexes and visualizes your workspace:

  • Multi-Language Parsing — Extracts symbols and relationships from TypeScript/JavaScript, Python, HCL/Terraform, YAML, and Markdown
  • Graph Visualization — Interactive D3 force-directed graph in VS Code showing files, functions, classes, and their relationships (imports, calls, extends)
  • Related Files Discovery — BFS algorithm finds connected files and symbols up to N hops away — identifies the exact context Copilot needs
  • Incremental Indexing — Only re-indexes changed files via file watcher
  • Multi-Repo Support — Auto-detects container directories with 2+ git repos and indexes across all for cross-repo references

Open in browser: http://localhost:8181/graph for full-screen D3 visualization. Export as self-contained HTML.

💬 Chat Integration

  • Chat Integration — All Copilot models are exposed under a ContextCompilerCopilot group in the model picker; select any model from that group to route requests through the proxy
  • Slash Commands — /stats (token savings summary) and /dashboard (open full dashboard)
  • Free Model Access — Exposes 3 free Copilot models with no deduction from premium context quota
  • Model Picker — See all available Copilot models; free vs. gated models clearly marked
  • Quality-preserving — Removes the wrong context, adds the right context via the knowledge graph — answers are equal or better quality

📈 Real-Time Analytics

All dashboards update live as you chat:

Dashboard URL Features
Savings Dashboard http://localhost:8181/dashboard Total tokens saved, cost savings estimate, savings by mode/model, usage timeline, premium quota gauge
Message Inspector http://localhost:8181/compilation Before/after view of every compiled request; see exactly what was optimized
Copilot Inspector http://localhost:8181/copilot Raw GitHub Copilot API input/output inspector for debugging
Knowledge Graph http://localhost:8181/graph Interactive workspace graph; export as HTML

Metrics tracked:

  • Requests by mode (agent vs. ask)
  • Tokens saved by model (Claude, GPT-5o, Gemini, o1, o3, etc.)
  • Cost savings estimate with 15+ model pricing
  • Per-request latency

🎛️ Sidebar

  • Status View — Live proxy status, port, current model, enable/disable toggle
  • Quick Links — One-click access to Dashboard, Message Inspector, Copilot Inspector, Graph
  • Metrics View — Real-time token reduction stats updated per request
  • Author Info — Quick access to support

🔒 Privacy & Control

  • Exchange Logging — Optional JSONL logs per request (disabled by default for privacy)
  • Model Selection — Choose extraction model (default: Claude Haiku 4.5, configurable)
  • History Window — Configure how many recent turns to keep (default: 3)
  • Tool Result Limit — Set max characters from old tool results (default: 200)
  • Enable/Disable Toggle — Runtime on/off without reloading

How It Works

On activation, the extension:

  1. Starts a lightweight HTTP proxy on localhost:8181 (runs inside the VS Code process)
  2. Indexes your workspace into a knowledge graph (incremental updates via file watcher)
  3. Writes all available Copilot models into chatLanguageModels.json under a ContextCompilerCopilot group — each model URL points to the local proxy
  4. When you pick a model from that group, every request passes through the compilation pipeline: boilerplate → detect → extract → trim → forward to GitHub API
  5. Records anonymized metrics (tokens, latency, cost) to dashboards
  6. On deactivation, stops the proxy
User Chat  →  VS Code Copilot  →  localhost:8181  →  Compilation Pipeline  →  api.githubcopilot.com
                                        ↓
                                   Knowledge Graph
                                   (visualization,
                                    context scoring)
                                        ↓
                                   Dashboards & Metrics

Authentication: Uses VS Code's existing GitHub session — no separate login required.


Prerequisites

  • VS Code 1.95+
  • GitHub Copilot subscription (already signed in)

That's it.


Install

Search "Context Compiler Copilot" in the VS Code Extensions panel, or:

ext install riteshagarwal.vscode-context-compiler-copilot

Or install from .vsix:

code --install-extension vscode-context-compiler-copilot-0.1.0.vsix

Quick Start

  1. Install — Search "Context Compiler Copilot" in VS Code Extensions, or:

    ext install riteshagarwal.vscode-context-compiler-copilot
    
  2. Reload VS Code — The proxy starts automatically and indexes your workspace

  3. Open Copilot Chat — Ctrl+Alt+I / Cmd+Alt+I and pick a model under the ContextCompilerCopilot group

    • All requests through that model are automatically optimized
    • Token savings appear in real-time on the dashboard
  4. View Dashboard — Open http://localhost:8181/dashboard in your browser to see:

    • Tokens saved so far
    • Cost savings estimate
    • Per-model and per-mode breakdowns
    • Knowledge graph
  5. Explore Graph — Open http://localhost:8181/graph to see your workspace's knowledge graph visualization


Commands

Command Keyboard Description
Context Compiler: Toggle On/Off — Enable or disable the proxy
Context Compiler: Show Token Savings — Quick summary notification
Context Compiler: Open Dashboard — Full dashboard in external browser
Context Compiler: Open Graph — Interactive workspace graph

All dashboards also have quick-link buttons in the Status and Metrics sidebar views.


Configuration

Configure via VS Code Settings (Ctrl+,) under Context Compiler Copilot:

Setting Default Description
contextCompilerCopilot.enabled true Enable/disable the proxy (can be toggled at runtime)
contextCompilerCopilot.proxyPort 8181 Local port for the embedded proxy and dashboards
contextCompilerCopilot.recentTurns 3 History trimmer window — how many recent chat turns to preserve (older turns are collapsed)
contextCompilerCopilot.maxToolChars 200 Max characters to keep from old tool results (prevents bloat in history)
contextCompilerCopilot.extractionModel claude-haiku-4.5 LLM model for intelligent section extraction (Haiku is fast and cheap)
contextCompilerCopilot.logExchanges false Write JSONL exchange log (disabled by default for privacy; enable for debugging)

Advanced Setup:

  • Graph visualization auto-updates as files change
  • Knowledge graph indexing respects .gitignore and VS Code's files.exclude settings
  • Multi-repo indexing auto-detects if workspace contains 2+ git repos in subdirectories

Architecture

src/
  extension.ts        — Activation, deactivation, commands, config watcher
  proxy-server.ts     — Embedded HTTP server; orchestrates pipeline per request
  sidebar.ts          — Status & metrics sidebar views with quick-action buttons
  llm-caller.ts       — Adapts vscode.lm API into the LLM extraction interface
  dashboard.ts        — WebView panels for savings, compilation, copilot inspectors
  graph.ts            — Knowledge graph indexing, visualization, export

ContextCompiler-TypeScript (shared library in ../ContextCompiler-TypeScript/):

  • boilerplate-stripper.ts — Regex-based XML block removal
  • mode-detector.ts — Request mode classification
  • extractor.ts — LLM-based section extraction
  • history-trimmer.ts — Chat history optimization
  • token-counter.ts — Accurate token accounting via Tiktoken
  • stats.ts — Metrics aggregation and cost calculation
  • observability.ts — Exchange recording and logging

Development

cd vscode-ContextCompilerCopilot2

# Install (also links the local ContextCompiler-TypeScript library)
npm install

# Build
npm run compile

# Watch mode
npm run watch

# Package .vsix
npm run package

Press F5 in VS Code to launch the Extension Development Host with auto-reload.

Testing dashboards locally:

  • Dashboard: http://localhost:8181/dashboard
  • Graph: http://localhost:8181/graph
  • Compilation Inspector: http://localhost:8181/compilation
  • Copilot Inspector: http://localhost:8181/copilot

FAQ

Q: Does this slow down my Copilot requests?
A: No. The pipeline runs locally in-process on your machine with minimal overhead (~50–100ms). Savings from reduced token size often result in faster API responses.

Q: Is my data safe?
A: Yes. All compilation happens locally in the VS Code process. GitHub Copilot's existing authentication is used; no new credentials are stored.

Q: Can I disable specific pipeline phases?
A: Currently all phases are always active. Future versions will allow per-phase toggles.

Q: What models are supported?
A: All models available via your GitHub Copilot subscription (Claude, GPT-5o, Gemini, o1, o3, etc.). Pricing is automatically calculated for 15+ models.

Q: How accurate is the token counting?
A: Uses the same cl100k_base tokenizer as OpenAI's API (tiktoken library) — accounts for overhead and special tokens.

Q: Does the knowledge graph slow down my IDE?
A: Indexing is incremental and runs in the background. Large codebases (5000+ files) are indexed lazily to avoid UI blocking.

Q: Can I export the knowledge graph?
A: Yes. The graph can be exported as a self-contained HTML file from http://localhost:8181/graph.


Troubleshooting

Issue Solution
Dashboard won't load Check that port 8181 is not in use; change contextCompilerCopilot.proxyPort in settings
Copilot not routing through proxy Make sure you selected a model from the ContextCompilerCopilot group in the model picker (not the default Copilot models)
Knowledge graph not indexing Check files.exclude settings; ensure workspace has valid source files
Low token savings Model selection matters; Claude achieves higher savings than GPT. Check compilation inspector to debug.

Resources

  • MIT License
  • Context Compiler Docs — Shared library documentation
  • GitHub Copilot API Docs — Copilot configuration
  • Support — Report bugs or request features
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft