This is the GitHub Copilot Chat extension for Visual Studio Code - a VS Code extension that provides conversational AI assistance, a coding agent with many tools, inline editing capabilities, and advanced AI-powered features for VS Code.
- Chat Interface: Conversational AI assistance with chat participants, variables, and slash commands
- Inline Chat: AI-powered editing directly in the editor with
Ctrl+I - Agent Mode: Multi-step autonomous coding tasks
- Edit Mode: Natural language to code
- Code Completions: Next edit suggestions and inline completions
- Language Model Integration: Support for multiple AI models (GPT-4, Claude, Gemini, etc.)
- Context-Aware: Workspace understanding, semantic search, and code analysis
- TypeScript: Primary language (follows VS Code coding standards)
- TSX: Prompts are built using the @vscode/prompt-tsx library
- Node.js: Runtime for extension host and language server features
- WebAssembly: For performance-critical parsing and tokenization
- VS Code Extension API: Extensive use of proposed APIs for chat, language models, and editing
- ESBuild: Bundling and compilation
- Vitest: Unit testing framework
- Python: For notebooks integration and ML evaluation scripts
src/extension/: Main extension implementation, organized by featuresrc/platform/: Shared platform services and utilitiessrc/util/: Common utilities, VS Code API abstractions, and service infrastructure
.esbuild.ts: Build configuration for bundling extension, web worker, and simulation workbenchtsconfig.json: TypeScript configuration extending base config with React JSX settingsvite.config.ts: Test configuration for Vitest unit testspackage.json: Extension manifest with VS Code contributions, dependencies, and scripts
test/: Comprehensive test suite including unit, integration, and simulation testsscript/simulate.sh: Test runner for scenario-based testingnotebooks/: Jupyter notebooks for performance analysis and ML experiments
assets/: Icons, fonts, and visual resourcesCONTRIBUTING.md: Architecture documentation and development guide
Core Chat & Conversation Features:
conversation/: Chat participants, agents, and conversation flow orchestrationinlineChat/: Inline editing features (Ctrl+I) and hints systeminlineEdits/: Advanced inline editing capabilities with streaming edits
Context & Intelligence:
context/: Context resolution for code understanding and workspace analysiscontextKeys/: VS Code context key management for UI stateintents/: Chat participant/slash command implementationsprompts/: Prompt engineering and template systemprompt/: Common prompt utilitiesrelatedFiles/: Related file discovery and context gatheringtypescriptContext/: TypeScript-specific context and analysis
Search & Discovery:
search/: General search functionality within the extensionworkspaceChunkSearch/: Chunked workspace search for large codebasesworkspaceSemanticSearch/: Semantic search across workspace contentworkspaceRecorder/: Recording and tracking workspace interactions
Authentication & Configuration:
authentication/: GitHub authentication and token managementconfiguration/: Settings and configuration managementbyok/: Bring Your Own Key (BYOK) functionality for custom API keys
AI Integration & Endpoints:
endpoint/: AI service endpoints and model selectiontools/: Language model tools and integrationsapi/: Core API abstractions and interfacesmcp/: Model Context Protocol integration
Development & Testing:
testing/: Test generation and execution featurestest/: Extension-specific test utilities and helpers
User Interface & Experience:
commands/: Service for working with VS Code commandscodeBlocks/: Streaming code block processinglinkify/: URL and reference linkificationgetting-started/: Onboarding and setup experienceonboardDebug/: Debug onboarding flowssurvey/: User feedback and survey collection
Specialized Features:
notebook/: Notebook integration and supportreview/: Code review and PR integration featuresrenameSuggestions/: AI-powered rename suggestionsignore/: File and pattern ignore functionalityxtab/: Cross-tab communication and state management
Infrastructure & Utilities:
extension/: Core extension initialization and lifecyclelog/: Logging infrastructure and utilitiestelemetry/: Analytics and usage tracking
VS Code API Type Definitions:
- Multiple
vscode.proposed.*.d.tsfiles for proposed VS Code APIs including chat, language models, embeddings, and various editor integrations
chat/: Core chat services and conversation optionsopenai/: OpenAI API protocol integration and request handlingembedding/: Vector embeddings for semantic searchparser/: Code parsing and AST analysissearch/: Workspace search and indexingtelemetry/: Analytics and usage trackingworkspace/: Workspace understanding and file managementnotebook/: Notebook integrationgit/: Git integration and repository analysis
common/: Shared utilities, service infrastructure, and abstractionsvs/: Utilities borrowed from the microsoft/vscode repo (readonly)
-
Base Activation (
src/extension/extension/vscode/extension.ts):- Checks VS Code version compatibility
- Creates service instantiation infrastructure
- Initializes contribution system
-
Service Registration:
- Platform services (search, parsing, telemetry, etc.)
- Extension-specific services (chat, authentication, etc.)
- VS Code integrations (commands, providers, etc.)
-
Contribution Loading:
- Chat participants
- Language model providers
- Command registrations
- UI contributions (views, menus, etc.)
- Default Agent: Main conversational AI assistant
- Setup Agent: Handles initial Copilot setup and onboarding
- Workspace Agent: Specialized for workspace-wide operations
- Agent Mode: Autonomous multi-step task execution
- Input Parsing: Parse user input for participants, variables, slash commands
- Context Resolution: Gather relevant code context, diagnostics, workspace info
- Prompt Construction: Build prompts with context and intent detection
- Model Interaction: Send requests to appropriate language models
- Response Processing: Parse and interpret AI responses
- Action Execution: Apply code edits, show results, handle follow-ups
- Support for multiple providers (OpenAI, Anthropic, etc.)
- Model selection and switching capabilities
- Quota management and fallback handling
- Custom instruction integration
- Hint System: Smart detection of natural language input for inline suggestions
- Intent Detection: Automatic detection of user intent (explain, fix, refactor, etc.)
- Context Collection: Gather relevant code context around cursor/selection
- Streaming Edits: Real-time application of AI-suggested changes
- Version 2: New implementation with improved UX and hide-on-request functionality
- Indentation: Use tabs, not spaces
- Naming Conventions:
PascalCasefor types and enum valuescamelCasefor functions, methods, properties, and local variables- Use descriptive, whole words in names
- Strings:
- "double quotes" for user-visible strings that need localization
- 'single quotes' for internal strings
- Functions: Use arrow functions
=>over anonymous function expressions - Conditionals: Always use curly braces, opening brace on same line
- Comments: Use JSDoc style for functions, interfaces, enums, and classes
- Custom JSX factory:
vscpp(instead of React.createElement) - Fragment factory:
vscppf - Components follow VS Code theming and styling patterns
- Service-oriented: Heavy use of dependency injection via
IInstantiationService - Contribution-based: Modular system where features register themselves
- Event-driven: Extensive use of VS Code's event system and disposables
- Layered: Clear separation between platform services and extension features
- Unit Tests: Vitest for isolated component testing
- Integration Tests: VS Code extension host tests for API integration
- Simulation Tests: End-to-end scenario testing with
.stest.tsfiles - Fixtures: Comprehensive test fixtures for various scenarios
- Logical Grouping: Features grouped by functionality, not technical layer
- Platform Separation: Different implementations for web vs. Node.js environments
- Test Proximity: Tests close to implementation (
/test/subdirectories) - Clear Interfaces: Strong interface definitions for service boundaries
- Use arrow functions
=>over anonymous function expressions - Only surround arrow function parameters when necessary:
x => x + x // ✓ Correct
(x, y) => x + y // ✓ Correct
<T>(x: T, y: T) => x === y // ✓ Correct
(x) => x + x // ✗ Wrong- Always surround loop and conditional bodies with curly braces
- Open curly braces always go on the same line as whatever necessitates them
- Parenthesized constructs should have no surrounding whitespace
- Single space follows commas, colons, and semicolons
for (let i = 0, n = str.length; i < 10; i++) {
if (x < 10) {
foo();
}
}
function f(x: number, y: string): void { }- Do not export
typesorfunctionsunless you need to share it across multiple components - Do not introduce new
typesorvaluesto the global namespace
The extension uses numerous proposed VS Code APIs for advanced functionality:
chatParticipantPrivate: Private chat participant featureslanguageModelSystem: System messages for LM APIchatProvider: Custom chat provider implementationmappedEditsProvider: Advanced editing capabilitiesinlineCompletionsAdditions: Enhanced inline completionsaiTextSearchProvider: AI-powered search capabilities
- GitHub: Authentication and API access
- Azure: Cloud services and experimentation
- OpenAI: Language model API
- Anthropic: Claude model integration
- Telemetry: Usage analytics and performance monitoring
npm install: Install dependenciesnpm run compile: Development buildnpm run watch:*: Various watch modes for development
npm run test:unit: Unit testsnpm run test:extension: VS Code integration testsnpm run simulate: Scenario-based simulation tests
Chat & Conversation Features:
- Adding new chat features: Start in
src/extension/conversation/ - Chat participants and agents: Look in
src/extension/conversation/for participant implementations - Conversation storage: Modify
src/extension/conversationStore/for persistence features - Inline chat improvements: Look in
src/extension/inlineChat/andsrc/extension/inlineEdits/
Context & Intelligence:
- Context resolution changes: Check
src/extension/context/andsrc/extension/typescriptContext/ - Prompt engineering: Update
src/extension/prompts/andsrc/extension/prompt/ - Intent detection: Modify
src/extension/intents/for user intent classification - Related files discovery: Edit
src/extension/relatedFiles/for context gathering
Search & Discovery:
- Search functionality: Update
src/extension/search/for general search - Workspace search: Modify
src/extension/workspaceChunkSearch/for large codebase search - Semantic search: Edit
src/extension/workspaceSemanticSearch/for AI-powered search - Workspace tracking: Update
src/extension/workspaceRecorder/for interaction recording
Authentication & Configuration:
- Authentication flows: Modify
src/extension/authentication/for GitHub integration - Settings and config: Update
src/extension/configuration/andsrc/extension/settingsSchema/ - BYOK features: Edit
src/extension/byok/for custom API key functionality
AI Integration:
- AI endpoints: Update
src/extension/endpoint/for model selection and routing - Language model tools: Modify
src/extension/tools/for AI tool integrations - API abstractions: Edit
src/extension/api/for core interfaces - MCP integration: Update
src/extension/mcp/for Model Context Protocol features
User Interface:
- VS Code commands: Update
src/extension/commands/for command implementations - Code block rendering: Modify
src/extension/codeBlocks/for code display - Onboarding flows: Edit
src/extension/getting-started/andsrc/extension/onboardDebug/ - Cross-tab features: Update
src/extension/xtab/for multi-tab coordination
Testing & Development:
- Test generation: Modify
src/extension/testing/for AI-powered test creation - Extension tests: Update
src/extension/test/for extension-specific test utilities
Platform Services:
- Core platform services: Extend
src/platform/services for cross-cutting functionality - VS Code integration: Update contribution files and extension activation code
- Configuration: Modify
package.jsoncontributions for VS Code integration
This extension is a complex, multi-layered system that provides comprehensive AI assistance within VS Code. Understanding the service architecture, contribution system, and separation between platform and extension layers is crucial for making effective changes.