Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

👻 Ghostwriter — Local-First AI Coding Assistant

Zero Cloud. Zero Cost. Zero Compromise.

Ghostwriter is a VS Code extension that gives you a fully local AI coding assistant — powered by LanceDB, Transformers.js, and Ollama. Your code never leaves your machine.


✨ Features

Feature Description
🔍 Semantic Search Ask questions in plain English, get relevant code snippets back
🧠 RAG Pipeline Retrieves top-K context chunks before prompting the LLM
Incremental Indexing Only re-indexes files that changed (mtime tracking)
👻 Ghost Text Completions AI-powered inline suggestions as you type
🔒 100% Local LanceDB + Transformers.js + Ollama — everything runs on your CPU
🧵 Worker Threads Embedding runs in a background thread — UI never freezes
📁 .gitignore Aware Respects your .gitignore, never indexes node_modules

🚀 Setup

Prerequisites

  1. Ollama — Install from ollama.ai and pull a model:

    ollama pull codellama
    # or: ollama pull llama3, mistral, deepseek-coder
  2. Node.js 18+ — Required for the extension host

Install & Run

# 1. Clone or open this folder in VS Code
cd ghostwriter

# 2. Install dependencies
npm install

# 3. Compile TypeScript
npm run compile

# 4. Press F5 in VS Code to launch the Extension Development Host

First Use

  1. Click the 👻 Ghostwriter icon in the Activity Bar
  2. Click ⚡ Index Workspace to vectorize your codebase
  3. Ask a question: "How does the auth middleware work?"

⚙️ Configuration

Open VS Code Settings (Ctrl+,) and search for ghostwriter:

Setting Default Description
ghostwriter.ollamaUrl http://localhost:11434 Ollama server URL
ghostwriter.ollamaModel codellama Model to use
ghostwriter.chunkSize 800 Characters per chunk
ghostwriter.chunkOverlap 80 Overlap between chunks
ghostwriter.topK 5 Context snippets per query
ghostwriter.enableInlineCompletions true Ghost text completions

🏗️ Architecture

Extension Host
├── extension.ts              # Activation, commands, watcher
├── GhostwriterViewProvider.ts # Sidebar WebView bridge
└── src/services/
    ├── LocalIndex.ts          # LanceDB — vector storage & search
    ├── Embedder.ts            # Worker thread bridge singleton
    ├── Indexer.ts             # Crawler + chunker (gitignore-aware)
    ├── OllamaClient.ts        # Streaming HTTP client for Ollama
    └── RagPipeline.ts         # Query → embed → retrieve → prompt → stream
    
src/workers/
    └── embedder.worker.ts     # CPU-isolated Transformers.js worker

media/webview/
    ├── index.html             # Sidebar panel HTML (injected by provider)
    ├── main.js                # Webview JS — streaming token rendering
    └── style.css              # Terminal ghost aesthetic

🔑 How the RAG Pipeline Works

User: "Where is the login logic?"
         │
         ▼
[Embedder] → 384-dim vector
         │
         ▼
[LanceDB] → top-5 nearest code chunks
         │
         ▼
[Context Sandwich Prompt]
  <<< SYSTEM >>> You are Ghostwriter. Use ONLY provided code.
  <<< CONTEXT >>> File: src/auth.ts | Lines 10-25: [snippet]
  <<< USER QUERY >>> Where is the login logic?
         │
         ▼
[Ollama streaming] → tokens appear in real-time in sidebar

🛠️ Commands

Command Description
Ghostwriter: Index Workspace Crawl + vectorize the current project
Ghostwriter: Clear Index Wipe the LanceDB index
Ghostwriter: Show Status Show model, Ollama, and index stats

📄 License

MIT © Ghostwriter Contributors

About

VS Code extension that understands your entire local codebase context without sending the whole thing to an LLM

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages