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

TypeScript98.2%JavaScript1.8%
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 WeaveRoutes Rust repository context through the tpt-weave index (tpt-weave adopt) — exact signatures/skeletons from one shared index instead of re-parsing in the proxy
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

For how TPT compares on cost with a Claude Pro subscription, see claude-compare.md. Those figures are estimates, not measurements.


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. OpenAI-format clients (Continue, Roo Code) are translated to the Anthropic format for it
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.

Step-by-step guides for each tool, and sample config files, are in examples/: Claude Code, Cline, Roo Code, Continue and local models.


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.dryRunfalseMeasure what the modules would change, but send every request exactly as the client wrote it. Use TPT: Show Token Savings (Last Request) to see the result. No cached answers are returned, and Memory Weaver uses only its local extractive backend
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.geminiApiKey, tpt.groqApiKey, tpt.mistralApiKey, tpt.glmApiKey, tpt.mimoApiKey, tpt.deepseekApiKey, tpt.qwenApiKey, tpt.kimiApiKey, tpt.grokApiKey""Keys for the other hosted providers

Keys are stored in VS Code's SecretStorage. A key still in settings.json is moved there on first run, and the key settings are deprecated. TPT: Run Setup Wizard sets them.

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 Weave

For repositories indexed with tpt-weave adopt (Rust workspaces), tool results for .rs files are replaced by representations from the shared index instead of re-parsing here. Requires the tpt-weave CLI on PATH (or set tpt.weave.cliPath).

SettingDefaultDescription
tpt.weave.enabledfalseRoute Rust repository context through tpt-weave when the workspace is indexed
tpt.weave.cliPathtpt-weavePath to the tpt-weave CLI binary
tpt.weave.level2Representation level: 2 signatures (compact), 3 skeleton (full signatures + types, more tokens)

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.memoryWeaver.anthropicSummaryModelclaude-haiku-4-5-20251001Model used by the proxy backend for Anthropic requests
tpt.memoryWeaver.openaiSummaryModelgpt-4o-miniModel used by the proxy backend for OpenAI-format requests
tpt.memoryWeaver.ollamaModelllama3Model used by the Ollama backend

TPT Router

SettingDefaultDescription
tpt.router.enabledfalseEnable heuristic routing
tpt.router.rules[]Array of routing rules (see below). When empty, built-in defaults apply

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.

Cross-session recall (opt-in)

SettingDefaultDescription
tpt.memoryWeaver.recall.enabledfalseOn the first turn of a new conversation, add the Memory Weaver summaries from earlier sessions that share words with the request, to the system prompt. Adds tokens and changes the prompt, so it is off by default

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 Token Shield — Semantic Cache (opt-in)

SettingDefaultDescription
tpt.tokenShield.semanticCache.enabledfalseAlso match prompts by embedding similarity, using a local Ollama model
tpt.tokenShield.semanticCache.similarityThreshold0.92Cosine similarity needed for a semantic hit
tpt.tokenShield.semanticCache.ollamaModelnomic-embed-textEmbedding model
tpt.tokenShield.semanticCache.ollamaBaseUrlhttp://localhost:11434Ollama server for embeddings

TPT Cost Budget

SettingDefaultDescription
tpt.costBudget.dailyLimitUsd0Warn when daily spend passes this amount (0 disables)
tpt.costBudget.monthlyLimitUsd0Warn when monthly spend passes this amount (0 disables)
tpt.costBudget.hardStopfalseReject requests with HTTP 429 once a limit is reached, instead of only warning
tpt.costBudget.quotaPollingIntervalSec180How often quota is polled

TPT Forge

SettingDefaultDescription
tpt.forge.autoUpdatetrueOn activation, re-install the Forge entries already installed in this workspace from the registry. This makes a network request to the registry when entries are installed
tpt.forge.registryUrl""Registry index URL. Empty uses the official registry. Must be https and cannot point at a private address

A registry entry with a sha256 pin is checked against the downloaded bytes. An entry without one has no integrity check: a background refresh skips it, and TPT: Browse Forge asks you to confirm before installing it. An unpinned remote entry cannot replace a built-in of the same name.

Installed entries take effect as follows:

TypeEffect
router-ruleUsed as the router rules when tpt.router.rules is empty
vault-patternAdded to the Vault's custom patterns
system-promptReplaces the Silent Edit schema text when Silent Edit is on

Installing an entry is your consent to it. Router rules can send requests to another provider, and system prompts change what the model is told, so read an entry before installing it.

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: Copy Session TokenCopy the X-TPT-Token value
TPT: Copy Claude Code Setup SnippetCopy environment variables for Claude Code (PowerShell or bash)
TPT: Clear Local CacheWipe the Token Shield prompt cache
TPT: Show Memory Weaver SummariesOpen .tpt/memory.json, the summaries Memory Weaver has written
TPT: Clear Memory Weaver HistoryClear the summaries Memory Weaver keeps (asks first)
TPT: Clear Request LedgerDelete the local request ledger
TPT: Export Ledger to CSVWrite every ledger row to a CSV file
TPT: Export Monthly Summary to DownloadsWrite a per-month usage summary to your Downloads folder
TPT: Apply Settings PresetApply Frugal, Privacy-first, Local only (Ollama) or Anthropic tiering
TPT: Configure ModelsPick the models TPT uses
TPT: Run Setup WizardChoose a provider, enter a key and test the connection
TPT: Reset Credentials & ProviderRemove stored keys and the provider choice
TPT: Test ConnectionSend a test request through the proxy
TPT: Test Vault Patterns on SelectionShow what the Vault would redact in the selected text
TPT: Show Token Savings (Last Request)Per-stage size of the last request: what each module saved, or added
TPT: Suggest Settings From HistoryRead the measured requests and print suggestions for Memory Weaver and the router. Nothing is changed; needs 20 measured requests
TPT: Export Savings Report (This Month)Write a Markdown report of what each module removed this month, to Downloads. Figures are estimates, not billed tokens
TPT: Show Workspace PolicyShow whether the repository's tpt-policy.json is present, valid, trusted, and what it would apply. A broken file is named here
TPT: Inspect Last RequestDump the last request's processed body and module actions to the Output Channel
TPT: Show Prompt DiffCompare the original and processed prompt side by side
TPT: Auto-Configure ClineSet Cline's provider, base URL and headers to use TPT
TPT: Open SettingsOpen the tpt.* settings
TPT: Browse ForgeInstall community configs from the registry

Troubleshooting

Requests fail with HTTP 401. The client did not send the current session token. The token changes every time the extension activates. Run TPT: Copy Session Token and update the client, or run TPT: Copy Claude Code Setup Snippet again. The token can be sent as X-TPT-Token, as Authorization: Bearer, or as x-api-key.

The port is not 7331. Port 7331 was in use, so TPT took the next free port. The URL is in the TPT Command Center Output Channel. Copy the current URL with TPT: Copy Proxy URL to Clipboard.

A terminal still points at an old URL or token. TPT writes the environment into new terminals only. Close the terminal and open a new one.

Costs or routing look wrong. Turn on tpt.terminal.verboseLogging and run TPT: Inspect Last Request. The output lists each module's action and any router override.


FAQ

Does TPT send my code anywhere else? Requests go from the local proxy to the provider you chose, and nowhere else. TPT also makes two other kinds of network call: it fetches model pricing from OpenRouter once a day, and it checks the Forge registry when Forge auto-update is on and entries are installed. Turn auto-update off with tpt.forge.autoUpdate if you do not want the registry call.

Why are Router and Silent Edit off? Routing changes which model answers, and Silent Edit changes how edits are applied. Both are worth turning on once you have looked at what they do in the Output Channel.

Does routing to another provider need that provider's key? Yes. A rule that sends a request to OpenAI, for example, needs tpt.openaiApiKey. Without it, the request is not sent to that provider.

Are secrets redacted when the other modules are off? Yes. Vault is its own setting and runs before the other modules. Redaction is pattern-based, so use TPT: Test Vault Patterns on Selection to check that a particular secret format is caught.

Where is my data? In .tpt/ in the workspace, and nowhere else. See Local Files.


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.


Team Policy

A repository can share settings through a tpt-policy.json file at its root, which you commit:

{
  "vault": { "customRegex": ["acme-key-[A-Za-z0-9]{32}"] },
  "costBudget": { "dailyLimitUsd": 5 },
  "dryRun": false
}

A policy can only tighten your settings: it adds Vault patterns, lowers cost budgets, and can turn dry run on. It cannot add router rules or change the provider, so a repository cannot send your code to another provider. The policy applies only after you choose Trust and apply when VS Code asks. The trust is for that exact file, so a changed policy asks again. A file that is not valid JSON is ignored, with a warning. TPT: Show Workspace Policy says what TPT made of it.


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

Dual-licensed under either of MIT or Apache 2.0, at your option.