tpt-code-command-center

TypeScript

Local VS Code proxy that intercepts AI coding requests (Cline, Claude Code) to redact secrets, cache prompts, compress context, and smart-route to cheaper models — cutting LLM costs without changing your workflow.

0 stars0 forks0 watchers
ai-cost-optimizationanthropicclaude-codeclinellm-proxyopenaiopenrouterprompt-cachingtoken-optimizationvscode-extension

Languages

TypeScript97.9%JavaScript2.1%
README

TPT Code Command Center

A VS Code extension that acts as a local HTTP proxy between your AI coding tools (Cline, Claude Code) and any LLM provider — intercepting every request to optimise token usage, redact secrets, cache identical prompts, and route traffic intelligently.

Zero DevOps. No hosted backend. No Docker. Everything runs locally inside VS Code.


Features

ModuleWhat it does
TPT VaultRedacts AWS keys, Stripe tokens, GitHub PATs, JWTs, .env secrets, and custom patterns before any LLM sees them
TPT Smart ContextReplaces large file contents in tool calls with compact AST outlines — dramatically reduces tokens sent per request
TPT Token ShieldCaches identical prompts locally (SHA-256 hash match) — zero cost on repeated queries
TPT Memory WeaverAutomatically summarises conversation history when it grows too large — keeps context costs in check
TPT RouterRewrites the target model and provider based on configurable heuristics — send simple tasks to cheap local models
TPT Silent EditIntercepts AI JSON edit instructions and applies them as native undoable VS Code diffs
TPT Prompt CacheMarks the system prompt and stable conversation history with Anthropic cache_control breakpoints to unlock its native prompt-caching discount
TPT ForgeInstall community-maintained router rules, vault patterns, and system prompts from a GitHub registry
TPT TerminalLive pipeline logs in the VS Code Output Channel

Quick Start

1. Install the extension

From the .vsix file:

Extensions panel → ⋯ → Install from VSIX…

Or install from the VS Code Marketplace (coming soon).

2. Set your API key

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

"tpt.upstreamProvider": "openrouter",
"tpt.openrouterApiKey": "sk-or-..."

Supported providers:

Setting valueRoutes to
openrouter (default)OpenRouter — access all models with one key
anthropicAnthropic API directly
openaiOpenAI API directly
deepseekDeepSeek API directly
qwenAlibaba Cloud DashScope (Qwen)
kimiMoonshot AI (Kimi)
grokxAI (Grok)
glmZhipu AI / Z.ai (GLM)
mimoXiaomi MiMo
mistralMistral AI directly
localOllama, LM Studio, or any local OpenAI-compatible server
customAny base URL you specify

3. Connect your AI tools

When the extension activates, it starts a local proxy and prints the URL and session token in the TPT Command Center Output Channel.

Claude Code — the ANTHROPIC_BASE_URL environment variable is injected into all new VS Code terminals automatically. Open a new terminal and run Claude Code as normal.

Cline — open Cline settings and set:

  • Provider: OpenAI Compatible
  • Base URL: http://localhost:7331 (or whatever port is shown in the Output Channel)
  • Add header: X-TPT-Token: <token shown in Output Channel>

Any other OpenAI-compatible tool — point the base URL to http://localhost:7331/v1.


Configuration Reference

All settings are under the tpt.* namespace in VS Code settings (Ctrl+, → search tpt).

Core

SettingDefaultDescription
tpt.enabledtrueMaster switch — bypass all modules when false
tpt.upstreamProvideropenrouterDefault upstream provider
tpt.openrouterApiKey""OpenRouter API key
tpt.anthropicApiKey""Anthropic API key
tpt.openaiApiKey""OpenAI API key
tpt.localBaseUrlhttp://localhost:11434/v1Local model server URL (Ollama default)
tpt.customBaseUrl""Custom upstream base URL
tpt.customApiKey""API key for custom upstream

TPT Vault

SettingDefaultDescription
tpt.vault.enabledtrueEnable secret redaction
tpt.vault.customRegex[]Additional regex patterns to redact

TPT Smart Context

SettingDefaultDescription
tpt.smartContext.enabledtrueEnable AST outline extraction
tpt.smartContext.maxFileSize512000Files larger than this (bytes) are outlined

TPT Token Shield

SettingDefaultDescription
tpt.tokenShield.enabledtrueEnable prompt caching
tpt.tokenShield.maxCacheSizeMB256Maximum local cache size

TPT Memory Weaver

SettingDefaultDescription
tpt.memoryWeaver.enabledtrueEnable context summarisation
tpt.memoryWeaver.tokenThreshold50000Token count that triggers summarisation
tpt.memoryWeaver.fallbackOrder["ollama","proxy","extractive"]Summarisation backend priority

TPT Router

SettingDefaultDescription
tpt.router.enabledfalseEnable heuristic routing
tpt.router.rules[]Array of routing rules (see below)

Router rule format:

{
  "match": {
    "maxTokens": 2000,
    "keywords": ["fix typo", "rename"],
    "extensions": ["md", "txt"]
  },
  "model": "gpt-4o-mini",
  "provider": "openai"
}

Rules are evaluated in order. The first match wins.

TPT Silent Edit

SettingDefaultDescription
tpt.silentEdit.enabledfalseEnable JSON-based silent edits

TPT Prompt Cache

SettingDefaultDescription
tpt.promptCache.enabledtrueAdd Anthropic cache_control breakpoints to the system prompt and stable conversation history

Anthropic and Mistral are the two providers in TPT's list that require an explicit opt-in to get their caching discount — the rest cache automatically upstream with no proxy involvement:

ProviderCaching
AnthropicManual — requires cache_control. TPT Prompt Cache adds this on every Anthropic-format request.
MistralManual — requires a stable prompt_cache_key on requests sharing a prefix (min 64 tokens per cache block). TPT sets this automatically on every Mistral-bound request, derived from the conversation's first message so it stays stable across turns.
OpenAIAutomatic for prompts ≥1024 tokens, no code needed
DeepSeekAutomatic disk-based caching, no code needed
Qwen (DashScope)Automatic implicit caching on the OpenAI-compatible endpoint TPT uses; explicit cache_control is also supported if routed through Qwen's Anthropic-compatible endpoint
Kimi (Moonshot)Automatic prefix caching on kimi-k2.* models, no code needed
Grok (xAI)Automatic, and TPT sends a stable x-grok-conv-id header (derived from the conversation's first message) on every Grok-bound request so repeat turns route to the same server and hit cache more often
GLM (Zhipu/Z.ai)Automatic — cached input billed at 1/5th normal price, no code needed
MiMo (Xiaomi)Automatic prefix caching via the OpenAI-compatible endpoint, no code needed

TPT Forge

SettingDefaultDescription
tpt.forge.autoUpdatetrueAuto-check for community config updates

TPT Terminal

SettingDefaultDescription
tpt.terminal.verboseLoggingfalseShow per-request pipeline detail in Output Channel

Commands

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

CommandDescription
TPT: Toggle Entire Suite On/OffAlso accessible by clicking the status bar icon
TPT: Show DashboardOpen the token stats WebView panel
TPT: Show Token StatsQuick stats notification
TPT: Copy Proxy URL to ClipboardCopy http://localhost:<port> for manual tool setup
TPT: Clear Local CacheWipe the Token Shield prompt cache
TPT: Force Memory Weaver PruneManually trigger context summarisation
TPT: Browse ForgeInstall community configs from the registry

Status Bar

The shield icon in the bottom-right of VS Code shows the current state:

  • Green 🛡 TPT — all modules active
  • Yellow 🛡 TPT (4/6) — some modules active
  • Red 🛡 TPT — suite bypassed

Click to open the toggle menu.


Security

The proxy generates a random session token on every activation. All requests must include this token as the X-TPT-Token header. This prevents other local processes from routing traffic (and your API keys) through the proxy without your knowledge.

The token is printed to the TPT Command Center Output Channel on startup and is automatically injected into new VS Code terminal sessions.


Local Files

TPT stores its data in a .tpt/ folder at the workspace root:

.tpt/
  ledger.db      — token/cost history (sql.js SQLite)
  cache.db       — Token Shield prompt cache (sql.js SQLite)
  memory.json    — Memory Weaver conversation summaries
  forge/         — Installed Forge community configs

Add .tpt/ to your .gitignore to avoid committing local data.


Building from Source

git clone https://github.com/PhillipC05/tpt-code-command-center
cd tpt-code-command-center
npm install
npm run compile

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

To package a .vsix:

npm install -g @vscode/vsce
vsce package

Contributing

See CONTRIBUTING.md.


License

Apache 2.0 — see LICENSE.