How aws/aws-toolkit-vscode works
Project type and purpose
• This is a monorepo hosting two VS Code extensions—“Amazon Q” and “AWS Toolkit”—plus shared libraries and plugins.
• It provides IDE integrations: inline code suggestions, chat‑based code generation, security scanning, AWS resource browsing, Lambda debugging, CloudFormation/SAM editing, etc.
• It is implemented in TypeScript and runs inside the VS Code Extension Host, with some code running in Webviews (browser contexts).
File structure
• Top‑level folders:
– packages/amazonq – Amazon Q extension
– packages/toolkit – AWS Toolkit extension
– packages/core – shared utilities, common VS Code activation, AWS‑SDK clients, telemetry, LSP support, webview generators, sam/CFN support, chat DB
– plugins – custom ESLint rules
– src.gen – auto‑generated AWS streaming client SDKs
– .github, buildspec, scripts – CI/CD configuration and release pipelines
– docs, designs – architecture documentation and design proposals
• Tests are organized under each package, with unit, integration, E2E, and lint checks.
• Build tooling: webpack configs, tsconfig, copyFiles scripts, generateServiceClient scripts.
Read README for additional insights
• Amazon Q uses the generated streaming client (src.gen/@amzn/amazon-q-developer-streaming-client) to communicate with the Amazon Q AI backend.
• AWS Toolkit uses shared/core clients to communicate with IAM, EC2, S3, Lambda, CloudWatch, Step Functions, etc.
• Both extensions register VS Code commands, controllers, and Webview UIs.
Main components and interactions
A. VS Code IDE UI
– User input: keypresses, command palette, explorer clicks
– Hosts Webview panels (chat, code actions, security panel)
B. VS Code Extension Host (Node.js process)
– amazonq extension activation
– toolkit extension activation
– shared/core activation code, global services (telemetry, AWS client builder, credential manager)
– command registrations & handlers (commands.ts)
– controllers & providers layer (chat controllers, LSP controllers, code lenses, decorators)
C. Webview contexts (Browser)
– Chat UI, code suggestion UI, security/fix UI
– Message dispatcher to Extension Host via postMessage
D. Language Server Protocol (LSP) support
– shared LSP installer & resolver
– language server client & server modules (for inline completions, CFN templates)
E. AWS‐SDK Client Layer
– shared/clients/* clients for each AWS service
– credential providers (IAM, SSO, AWS Builder ID)
F. Generative AI Services
– Amazon Q API (via amazon‑q‑developer‑streaming‑client)
– CodeWhisperer streaming client
G. Local Tooling
– SAM CLI integration for Lambda debugging (shared/sam/cli)
H. CI/CD & Release
– GitHub Actions & AWS CodeBuild (buildspec files)
– Marketplace publishing steps in buildspec/release
Architectural patterns and principles
• Monorepo modularity: clear package boundaries (amazonq, toolkit, core).
• Layered architecture: UI (Webview + VS Code commands) → controllers → service clients → external APIs.
• MVC‑like separation in chat features: models (session, constants), controllers (messenger, session), views (UI connectors, message listeners).
• Shared services via dependency injection in core: telemetry, AWS client builder, credential manager.
• Code generation: src.gen for AWS streaming clients; build scripts auto‑generate service clients and configuration attributes.