TokenOptiPy for VS Code brings the TokenGraph engine into the editor. It scans a Python LLM project locally, highlights token-related findings in the Problems panel, lists the largest prompt and model-call hotspots, and opens the generated interactive graph.
Features
Build a TokenGraph from the current workspace.
Display TG001, TG002, TG003, TG005, TG006, and SEC001 findings as VS Code diagnostics.
Browse token-heavy prompts and model calls through a Quick Pick list.
Jump from a hotspot to the corresponding source line.
Open the local graph.html visualization.
Analyze the current prompt or text file.
Optionally rebuild after saving supported files.
Requirements
VS Code 1.90 or newer.
Python 3.10 or newer.
The TokenOptiPy Python engine available in the configured interpreter.
Use TokenOptiPy: Install or Upgrade Python Engine to install it from the configured pip source.
Getting started
Open a Python LLM project in VS Code.
Run TokenOptiPy: Install or Upgrade Python Engine.
Run TokenOptiPy: Build TokenGraph.
Review findings in the Problems panel.
Run TokenOptiPy: Show Token Hotspots or open the generated graph.
Commands
Command
Purpose
TokenOptiPy: Build TokenGraph
Scan the workspace and refresh diagnostics.
TokenOptiPy: Show Token Hotspots
Rank prompts and model calls by estimated static tokens.
TokenOptiPy: Open Interactive Graph
Open graph.html in the default browser.
TokenOptiPy: Analyze Current File
Run prompt-waste analysis on the active file.
TokenOptiPy: Install or Upgrade Python Engine
Install the Python package using pip.
TokenOptiPy: Clear Diagnostics
Remove TokenOptiPy entries from Problems.
Settings
Setting
Default
Description
tokenoptipy.pythonPath
python
Python executable used by the extension.
tokenoptipy.outputDirectory
tokenoptipy-out
Directory containing generated graph outputs.
tokenoptipy.backend
simple
Token-counting backend.
tokenoptipy.updateBuild
true
Skip unchanged projects.
tokenoptipy.openGraphAfterBuild
true
Open the graph after a manual build.
tokenoptipy.autoBuildOnSave
false
Rebuild after saving supported files.
tokenoptipy.installSource
Git repository
Package source passed to pip.
Development
cd vscode-extension
npm run check
npx @vscode/vsce package
The extension intentionally invokes the existing Python engine instead of duplicating the analyzer in JavaScript. This keeps the CLI and editor results consistent.