Skip to content

Repository files navigation

LocalContext — Local LLM context builder

Quick Start Features Architecture Roadmap


Electron Node.js JavaScript License Platform

Pack your codebase into a clean, token-counted prompt — without it ever leaving your machine

LocalContext is a desktop app that turns a project folder into a single, LLM-ready context block. Pick the files you need, watch the exact token count against your model's context window, then export to Markdown or XML and copy it straight into ChatGPT, Claude, Gemini, or any local model. No uploads, no telemetry, no cloud — the scan and the build happen entirely on your device.


📑 Table of Contents


✨ Features

📂 Smart Scan

Point at any project root and LocalContext walks it recursively, honouring your .gitignore on top of sensible defaults (node_modules, dist, build, out, target, .venv, lockfiles, and more). Binary assets and files over 1 MB are detected and auto-excluded, so the tree stays clean.

🔢 Token-Accurate

Selected files are counted with gpt-tokenizer (cl100k / o200k-class BPE, GPT-4 / 4o family), with a chars/4 fallback if the encoder is unavailable. A live estimate updates as you tick files, and a budget bar shows you against a 128k / 200k / 1M window — with an over-budget warning.

🧱 Clean Export

Build a single context block as Markdown (per-file fenced blocks with language detection) or XML (<context> / <file path="…"> structure). One click to copy to clipboard or save to .md / .txt / .xml. A live preview shows the result before you ship it.

☑️ Precise Selection

A checkbox file tree with a filter box and Select All / Clear controls lets you compose exactly the context you want. Text files are pre-selected; binaries are greyed out and skipped automatically.

🔒 Fully Local & Private

Everything runs on-device — there is no network call, no telemetry, no cloud. The Electron shell uses contextIsolation with a minimal preload bridge, so the renderer never touches Node or the filesystem directly.

🖥 Cross-Platform

Built on Electron 33 and plain Node.js, LocalContext runs the same on Windows, macOS and Linux — no build toolchain, native modules, or external services required to get started.


🏗 Architecture

A simple, one-way pipeline: pick a folder, scan it, count tokens, build the block, copy or save.

   ┌──────────────┐     ┌───────────────────────┐     ┌────────────────────────┐
   │  Pick folder │ ──▶ │  Scan + filter        │ ──▶ │  Tokenize              │
   │  (dir:pick)  │     │  .gitignore + defaults │     │  gpt-tokenizer (exact) │
   └──────────────┘     │  binary / >1MB skip    │     │  chars/4 fallback      │
                        └───────────────────────┘     └────────────────────────┘
                                                                  │
                                                                  ▼
                        ┌───────────────────────┐     ┌────────────────────────┐
                        │  Copy / Save          │ ◀── │  Build context         │
                        │  clipboard · .md/.xml  │     │  Markdown  or  XML     │
                        └───────────────────────┘     └────────────────────────┘

Logic lives in pure, IO-light modules under src/*; Electron and all filesystem / dialog / clipboard access stay at the edges (main.js + preload.js).

LocalContext/
├─ main.js          # Electron main: window + IPC (pick / scan / build / copy / save), dialogs, clipboard
├─ preload.js       # secure contextBridge — exposes a minimal `window.lc` API to the renderer
├─ src/
│  ├─ scanner.js    # recursive walk + .gitignore (ignore) + default ignores + binary / size filters
│  ├─ tokenizer.js  # gpt-tokenizer (exact) with chars/4 fallback
│  └─ builder.js    # assemble Markdown / XML context, per-file language detection, token count
└─ renderer/        # UI — index.html · styles.css · app.js (file tree, budget bar, preview)

⚡ Quick Start

Requires Node.js 18+ (ships against Electron 33).

# 1. Clone
git clone https://github.com/DuminAndrew/LocalContext
cd LocalContext

# 2. Install dependencies
npm install

# 3. Launch
npm start          # or: npm run dev  (opens detached DevTools)

🧭 Usage

  1. Open folder — pick your project root; LocalContext scans it instantly, honouring .gitignore.
  2. Select files — tick what you need, or use Select All / Clear and the filter box to narrow down. Binaries and oversized files are skipped for you.
  3. Watch the budget — the live token estimate and the 128k / 200k / 1M budget bar tell you when you are about to overflow the model's context window.
  4. Choose a formatMarkdown for readable, fenced per-file blocks, or XML for structured <file> blocks.
  5. Build — get the exact token count plus a preview of the assembled context.
  6. Copy or Save — drop it straight into your LLM chat, or export to .md / .txt / .xml.

🗺 Roadmap

  • Tauri / Rust v2 — migrate the shell to Tauri for a dramatically lighter, faster binary.
  • Signature compression — strip bodies and keep declarations/signatures to fit huge repos into a window.
  • Custom templates — user-defined output layouts and per-file headers/footers.
  • Git URL clone — paste a repository URL and build context without cloning manually first.
  • Persisted presets — remember selected files and budget per project.
  • Markdown & XML export — fenced per-file Markdown and structured XML blocks.
  • Exact token countinggpt-tokenizer with a graceful chars/4 fallback.
  • .gitignore-aware recursive scan — default ignores, binary detection, 1 MB size cap.

💚 Support / Crypto Donations

If LocalContext saves you time, you can support its development. Replace the placeholders below with your real, verified addresses and QR images before publishing.

Coin Network Address (placeholder)
BTC Bitcoin bc1qXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ETH Ethereum / EVM 0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
USDT TRON (TRC20) TXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
BTC ETH USDT (TRC20)
BTC QR placeholder ETH QR placeholder USDT TRC20 QR placeholder

🔐 Donation Safety

  • Always verify the address on the official release page of this repository — never from forks, issues, or screenshots.
  • Check the network (TRC20 ≠ ERC20): sending on the wrong chain means the funds are lost.
  • A donation is voluntary support — it grants no SLA, no priority support, and is not an investment.
  • Maintainers will never ask for donations in private messages.

📄 License

Released under the MIT License — © Andrew Dumin (DuminAndrew).


If LocalContext helped you, consider leaving a star ⭐

GitHub stars

About

Local desktop tool to build & optimize codebase context for LLMs (token count, .gitignore-aware, Markdown/XML, copy). Electron. 100% local.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages