APEX — Adaptive Prompt Engineering eXtension
Structured reasoning, rich context engineering, and prompt amplification — complementing Copilot with zero external API keys.
APEX is a VS Code extension that enhances GitHub Copilot Chat by adding intelligent model routing, workspace-aware context injection, and task-specific prompt engineering. It works entirely within Copilot's ecosystem — no external API keys, no additional billing.
Features
Slash Commands
| Command |
Strategy |
Description |
@apex /debug |
ReAct |
Observe → Think → Act → Verify debugging |
@apex /refactor |
Chain-of-Thought |
Step-by-step refactoring with dependency analysis |
@apex /design |
Tree-of-Thought |
Multiple approaches → compare → recommend |
@apex /test |
Few-Shot |
Test generation matching your project's patterns |
@apex /explain |
Layered |
High-level → implementation → gotchas |
@apex /plan |
Decomposition |
Break complex tasks into sub-steps |
@apex /verify |
Cross-Model Critique |
Review via a different-vendor model |
@apex /init |
Stack Detection |
Generate .github/copilot-instructions.md |
Core Capabilities
- Intent Engine — Zero-PRU-cost heuristic classifier that detects task type and complexity from freeform queries
- Context Maximizer — Collects active file, diagnostics, symbols, git diff, imports, and user
#file: references
- Prompt Amplification — Task-specific reasoning templates (CoT, ToT, ReAct, Few-Shot) injected via
@vscode/prompt-tsx
- Model Router — Budget-aware selection: respects your dropdown choice by default, picks optimal models when opted in
- PRU Governor — Local PRU estimate tracking with 3 budget modes (Eco / Balanced / Performance) and auto-downgrade
- Cross-Model Critique — Sends your response to a different-vendor model for review (when complexity warrants it)
- Agent Mode Tools — 4 tools available to all Copilot participants: workspace context, related files, conventions, test patterns
Budget Modes
| Mode |
Icon |
Behavior |
| Eco |
$(circle-filled) |
Free models only, prompt engineering focus |
| Balanced |
$(warning) |
Tier 1 reviewers for complex tasks |
| Performance |
$(flame) |
Full model routing, cross-model critique |
Requirements
- VS Code
^1.100.0
- GitHub Copilot Chat extension installed and active
- A GitHub Copilot subscription (Free, Pro, or Student plan)
Installation
# Clone and build
git clone <repo-url>
cd apex
npm install
npm run build
# For development
npm run build:dev
# Package for distribution
npm run package
Extension Settings
| Setting |
Type |
Default |
Description |
apex.budgetMode |
eco\|balanced\|performance |
eco |
How aggressively APEX uses premium models |
apex.monthlyBudget |
number (0-300) |
100 |
Max estimated PRU per month |
apex.modelOverride |
never\|always |
never |
never: use your model choice. always: APEX picks optimal models |
apex.enableCritique |
boolean |
true |
Enable cross-model critique pipeline |
apex.critiqueThreshold |
number (0-100) |
30 |
Min complexity score to trigger critique |
apex.enableDecomposition |
boolean |
true |
Enable multi-step task decomposition |
apex.decompositionThreshold |
number (0-100) |
60 |
Min complexity to trigger decomposition |
apex.pipelineDelayMs |
number (0-5000) |
500 |
Delay between pipeline steps (rate limit protection) |
apex.modelCacheTTLHours |
number (1-168) |
24 |
Model discovery cache TTL |
apex.enableTelemetry |
boolean |
true |
Anonymized usage telemetry |
Commands
| Command |
Description |
APEX: Show Budget Details |
View current PRU usage and budget status |
APEX: Reset PRU Budget Estimate |
Reset the monthly PRU estimate to 0 |
APEX: Verify PRU Multipliers |
Show discovered models and their PRU multipliers |
These tools are available to all Copilot participants in agent mode:
| Tool |
Reference |
Description |
apex_collectWorkspaceContext |
#apexContext |
Diagnostics, symbols, git changes |
apex_findRelatedFiles |
#apexRelated |
Import graph and naming pattern analysis |
apex_detectConventions |
#apexConventions |
Naming, error handling, test patterns |
apex_extractTestPatterns |
#apexTests |
Framework, assertions, mocks |
Architecture
User → @apex /debug TypeError
│
▼
apexParticipant.ts
├── ModelRegistry.ensureDiscovered() (lazy, first call only)
├── IntentEngine.classify() (zero-PRU heuristics)
├── ModelRouter.select() (budget-aware routing)
├── resolvePromptReferences() (#file: attachments)
├── ContextMaximizer.collect() (workspace context)
├── renderPrompt(BasePrompt) (prompt-tsx with priorities)
├── sendWithFallback() (retry + fallback chain)
├── performCritique() (optional cross-model review)
└── PruGovernor.record() (budget tracking)
Key Design Decisions
- No
selectChatModels() on activate — consent dialog requires user-initiated action
request.model respected by default — APEX only overrides when user opts in via modelOverride: "always"
- PRU tracking is a local estimate — the extension API cannot query actual remaining balance
@vscode/prompt-tsx alpha — pinned version with renderPrompt() fallback if it breaks
- All model family strings are unverified — Phase 1 go/no-go gate must confirm via real
selectChatModels() call
Development
# Type check
npm run lint
# Build (production)
npm run build
# Build (development, with source maps)
npm run build:dev
# Watch mode
npm run watch
# Package VSIX
npm run package
Testing
# Run tests (requires VS Code test infrastructure)
# Tests use mocked vscode APIs — no real Copilot calls
npx tsc -p tsconfig.test.json --noEmit
Project Structure
src/
├── extension.ts # Entry point
├── core/ # Intent, routing, context, amplification, budget
├── prompts/ # prompt-tsx components (BasePrompt, History, Context, Critique)
├── participant/ # @apex handler, follow-ups, slash commands
├── tools/ # Agent mode tools (4 tools)
├── instructions/ # /init: stack detection, convention inference
├── ui/ # Status bar, notifications
└── utils/ # Logger, config, retry, throttle, git, LSP
templates/ # 10 prompt templates + copilot-instructions.hbs
test/ # Mocha test suite
Known Limitations
- PRU estimates are approximations — actual PRU consumption may differ
- Model family strings are unverified until Phase 1 runtime testing on a real account
- Cross-model critique and task decomposition are hypotheses pending A/B testing
@vscode/prompt-tsx is pre-1.0 alpha — API surface may change
License
MIT