Skip to content

Latest commit

ย 

History

History
120 lines (92 loc) ยท 3.47 KB

File metadata and controls

120 lines (92 loc) ยท 3.47 KB

Copilot Ollama Bridge - Project Overview

๐ŸŽฏ Project Goal

Create a VS Code extension that exposes GitHub Copilot through Ollama-compatible API endpoints, solving the token extraction problem by using VS Code's official Language Model API.

๐Ÿ“ Project Structure

copilot-ollama-bridge/
โ”œโ”€โ”€ package.json              # Extension manifest and dependencies
โ”œโ”€โ”€ tsconfig.json             # TypeScript configuration
โ”œโ”€โ”€ README.md                 # Complete documentation
โ”œโ”€โ”€ setup.sh                  # Automated installation script
โ”œโ”€โ”€ test-api.sh               # API testing script
โ”œโ”€โ”€ .vscode/
โ”‚   โ””โ”€โ”€ launch.json           # VS Code development configuration
โ””โ”€โ”€ src/
    โ””โ”€โ”€ extension.ts          # Main extension implementation

๐Ÿ”ง Key Features

โœ… Ollama-Compatible API

  • GET /api/tags - List available models
  • POST /api/generate - Generate text completions
  • POST /api/chat - Chat-style completions
  • 100% compatible with existing Ollama clients

โœ… VS Code Integration

  • Uses official vscode.lm.selectChatModels() API
  • Automatic GitHub Copilot authentication
  • Status bar integration with server status
  • Output channel for request logging
  • Command palette controls

โœ… No Token Extraction

  • No filesystem token hunting
  • No OS-specific path handling
  • No brittle storage format parsing
  • Official authentication flow through VS Code

๐Ÿš€ Quick Start

  1. Setup the extension:

    cd copilot-ollama-bridge
    ./setup.sh
  2. Restart VS Code - extension auto-starts

  3. Configure Cline:

    • Ollama URL: http://localhost:11434
    • Model: copilot:latest
  4. Test the API:

    ./test-api.sh

๐Ÿ”„ Problem Solved

Before (Manual Token Extraction)

โŒ Brittle filesystem token hunting
โŒ OS-specific path variations  
โŒ Storage format changes breaking app
โŒ Authentication edge cases
โŒ No user consent handling

After (VS Code Extension)

โœ… Official VS Code Language Model API
โœ… Automatic authentication
โœ… Proper user consent dialogs
โœ… Stable, supported interface
โœ… Future-proof implementation

๐Ÿ“Š Usage with Cline

  1. Install and start the extension
  2. Configure Cline with:
    • URL: http://localhost:11434
    • Model: copilot:latest
  3. Use Cline normally - it now uses Copilot through the bridge

๐Ÿ—๏ธ Architecture

Cline โ†’ HTTP Request โ†’ VS Code Extension โ†’ Language Model API โ†’ GitHub Copilot
                         โ†“
                   Ollama Format โ†โ†’ VS Code Format

The extension acts as a translation layer between Ollama's API format and VS Code's Language Model API.

๐ŸŽฎ Commands Available

  • Start Copilot Bridge Server - Start the API server
  • Stop Copilot Bridge Server - Stop the API server
  • Restart Copilot Bridge Server - Restart the API server

๐Ÿ“Š Monitoring

  • Status Bar: Shows server status (๐Ÿค– icon)
  • Output Channel: "Copilot Bridge" for detailed logs
  • Web Interface: http://localhost:11434 for documentation

โœ… Benefits

  1. Reliable: Uses official, stable APIs
  2. Secure: Proper authentication flow
  3. Compatible: Drop-in Ollama replacement
  4. Maintainable: VS Code handles authentication
  5. Future-proof: Official API support

This approach completely eliminates the token extraction problem and provides a robust, officially-supported way to use GitHub Copilot with Ollama-compatible tools like Cline.