AutoPilot AI is a VS Code extension that adds a sidebar chat assistant for coding tasks. It can answer general questions, explain selected code, refactor snippets, generate documentation, and apply generated code into the active editor.
- Sidebar chat view inside VS Code (
AutoPilot AIactivity bar item) - OpenAI-backed chat with API-key sign-in flow
- Context-aware prompting:
none: no editor context for general questionsselection: selected code context when relevantfile: current file context for file-wide questions
- Hybrid request routing:
- Heuristic classifier
- Optional mini-model router for ambiguous requests
- Task-aware response depth:
quick,normal,deep
- Selection-based editor actions:
- Explain selection
- Refactor selection
- Document selection
- "Apply Code" button on generated code blocks to insert/replace in editor
For a deeper explanation of the codebase, architecture, request flow, project-aware retrieval, and edit-planning workflow, see docs/DEVELOPER_GUIDE.md.
- VS Code
^1.100.0 - Node.js 20+
- An OpenAI Project API key (for example
sk-proj-...)
- Clone and install dependencies:
npm install- Compile:
npm run compile- Run extension in development:
- Press
F5in VS Code to launch the Extension Development Host.
- In the extension UI, click Sign In and provide:
- Email address (stored with MongoDB chat history records)
- OpenAI Project API key (stored in VS Code global state)
The extension contributes these commands:
autopilot-searchbar.search— Open AutoPilot AIautopilot-searchbar.logout— Logoutautopilot-searchbar.explainSelection— Explain with AutoPilot AIautopilot-searchbar.refactorCode— Refactor Code with AutoPilot AIautopilot-searchbar.documentSelection— Document It with AutoPilot AIautopilot-searchbar.applyCode— Apply Code from AutoPilot AI
Selection commands are also available in the editor context menu when text is selected.
This extension contributes the following settings:
autopilot.apiKey(string): API key field (primary sign-in uses secure global state flow).autopilot.enableAiRouter(boolean, defaulttrue): Enables mini-model request classification when heuristics are uncertain.autopilot.routerModel(string, defaultgpt-4o-mini): Model used for the lightweight request router.autopilot.chatHistoryApiUrl(string, default empty): Base URL of the chat history API. Leave empty to disable persistence.autopilot.chatHistoryApiKey(string, default empty): Bearer token sent to the chat history API.
Chat history is stored via the backend API in the api/ folder. Firebase Spark can host static files only; the REST API must run on a host that supports server code, such as Blaze Functions, Cloudflare Workers, Render, or Vercel.
For normal chat messages, the extension plans each request before sending it to the main model:
- Detect intent/context need (
none/selection/file) - Detect response depth (
quick/normal/deep) - Build minimal prompt payload
- Send to OpenAI
This reduces unnecessary token usage and improves latency versus always attaching full-file context.
npm run compile— Build extensionnpm run watch— Build in watch modenpm run package— Production bundlenpm run lint— Lint sourcenpm run check-types— Type-check onlynpm run test— Run extension tests
Ensure at least the following are set:
namedisplayNamepublisherversionengines.vscode
npx vsce packageThis generates a file like:
autopilot-ai-<version>.vsix
- Create/manage publisher: https://marketplace.visualstudio.com/manage
- Create Azure DevOps PAT with Marketplace publish permissions
- Publish:
npx vsce publish -p <YOUR_PAT>- If authentication fails, verify you are using a valid OpenAI Project API key.
- If responses are empty due to token limits, ask a narrower question or reduce file/selection size.
- If network errors occur, check proxy/firewall settings in your environment.
- API key is read from VS Code global state in this extension.
- Email is read from VS Code global state and included in chat history API records when persistence is configured.
- MongoDB credentials belong on the API server (
api/.env), never in the extension package. - Review your organization policy before using personal or shared keys.
See LICENSE (add one before marketplace publish if missing).