PromptSight AIPrompt governance for VS Code — every token is checked before it is spent. PromptSight sits between you and the LLM. Before a prompt is sent it tries to avoid the call entirely (local prompt cache), reduce it (lossless compression, deduplication, secret redaction), and govern it (token/cost thresholds, session budgets, team policy) — then stops so you decide. Nothing is sent until you choose.
Features
Everything runs locally and in-process — no Python, no subprocesses, no network calls, and nothing leaves your machine without your explicit decision. Installation
From the Marketplace (recommended):
Or from the command line:
Building from source (contributors):
Then reload VS Code ( How to UseIn Copilot Chat —
|
| Button | What it does |
|---|---|
| 💾 Use cached solution | Reuses the best cached answer — 0 tokens spent |
| ✅ Allow — send original | Sends your prompt unchanged |
| ♻ Reframe — send optimized | Sends the trimmed, compact-encoded, secret-redacted version |
| (ignore) | Nothing is sent |
Slash command shortcuts:
| Command | What happens |
|---|---|
@promptsight <prompt> |
Pre-flight report only — you decide after |
@promptsight /send <prompt> |
Pre-flight, then sends original prompt |
@promptsight /optimize <prompt> |
Pre-flight, then sends optimized prompt |
@promptsight /cached <prompt> |
Reuses the best cached solution — costs 0 tokens |
@promptsight /helpful <prompt> |
Rates the last cached answer 👍 — raises its confidence |
@promptsight /unhelpful <prompt> |
Rates the last cached answer 👎 — lowers its confidence |
After /cached, 👍/👎 rating buttons appear automatically — the cache learns which answers are worth reusing.
In Agent Mode — #promptsight
- Switch Copilot Chat to Agent mode
- Add
#promptsightto your message:#promptsight Refactor all files in this repo to use async/await - A gate dialog appears with Allow, Reframe, and Deny options:
- Allow — agent proceeds with your original request
- Reframe — agent uses the optimized prompt instead
- Deny — agent stops; adjust your prompt and retry
Settings
Open VS Code Settings (Ctrl+,) and search for promptsight:
| Setting | Default | Description |
|---|---|---|
promptsight.defaultModel |
gpt-4.1-mini |
Fallback model for token/cost estimates (the active chat model wins) |
promptsight.warnThreshold |
8000 |
Token count that triggers a ⚠ WARN |
promptsight.blockThreshold |
12000 |
Token count that triggers a 🔴 BLOCK |
promptsight.policyPath |
(bundled) | Path to a custom policy.json (a workspace .promptsight/policy.json is auto-detected) |
promptsight.pricingPath |
(bundled) | Path to a custom pricing.json |
promptsight.cacheEnabled |
true |
Look up / store prompt-solution pairs in the local cache |
promptsight.sessionBudgetTokens |
150000 |
Cumulative session token budget; sends over budget require confirmation (0 disables) |
Team policy via git
Create .promptsight/policy.json in your repository root and commit it — every teammate with PromptSight gets the same governance rules automatically:
{
"warn_total_tokens": 8000,
"block_total_tokens": 12000,
"hard_block": true,
"allowed_models": ["gpt-4.1", "gpt-4.1-mini", "gpt-4o-mini"],
"max_duplicate_ratio": 0.2
}
Troubleshooting
| Problem | Fix |
|---|---|
@promptsight does not appear in chat |
Reload window: Ctrl+Shift+P → Developer: Reload Window |
| Extension not visible in Extensions panel | Reinstall from the Marketplace and reload |
code command not found |
Run Shell Command: Install 'code' command in PATH from Command Palette |
Uninstall
code --uninstall-extension HemantSagar.promptsight-ai
Then reload VS Code: Ctrl+Shift+P → Developer: Reload Window.
Running the Tests
node --test test/
Repository Layout
PromptSight_AI/
├── package.json Extension manifest (chat participant + agent tool)
├── extension.js Chat participant, agent gate, cache UX, session budget
├── build-vsix.ps1 Packages the extension into a .vsix
├── src/ In-process analyzer (no external dependencies)
│ ├── analyzer.js Pre-flight orchestrator (tokens → cost → policy → optimization)
│ ├── tokenizer.js Token counting + output estimation
│ ├── classifier.js Input type / complexity / duplication detection
│ ├── costEstimator.js Per-model pricing → cost
│ ├── policyValidator.js ALLOW / WARN / BLOCK decision
│ ├── optimizer.js Safe cleanup, model routing, secret detection/redaction
│ ├── promptCache.js Local JSON prompt-solution cache (0-token reuse, LRU-capped)
│ └── compactEncoder.js JSON → compact tabular lossless compression
├── analyzer/
│ └── config/
│ ├── policy.json Threshold and rule configuration
│ ├── pricing.json Per-model token pricing
│ └── model_rules.json Model routing rules
└── test/
└── analyzer.test.js node:test suite
Notes
- Token counts are heuristic (≈¾ word per token); output-token, cost, and CO₂e figures are estimates for pre-flight awareness only.
- The analyzer runs fully in-process — no Python, no subprocesses, no network calls.
- The optimizer only performs deterministic, zero-token edits: deduplication, whitespace cleanup, repeated-line collapsing, lossless compact re-encoding of JSON, and secret masking. No LLM is used to optimize prompts.
- Secret detection is best-effort; high-severity matches are masked in the optimized prompt and always redacted in the report.
- The prompt cache is a local JSON file (per-machine, under VS Code global storage, capped at 500 entries). Nothing is uploaded anywhere.
- GitHub Copilot Chat is required to use the
@promptsightparticipant and#promptsighttool.