How joyceerhl/vscode-mssql-chat works
Project type and purpose
• This is a Visual Studio Code extension named “SQL Chat” written in TypeScript.
• Its purpose is to register a Copilot Chat participant (@mssql), provide a “Summarize Database” smart action, and supply a chat variable (#database) by integrating with the MS SQL VS Code extension and a live SQL Server database.
File structure
• Top-level files:
• package.json / package-lock.json: extension metadata, dependencies, and scripts.
• tsconfig.json & webpack.config.js: TypeScript compiler and bundler configuration.
• .vscodeignore, .gitignore: files excluded from packaging or VCS.
• README.md, CHANGELOG.md, vsc-extension-quickstart.md: documentation and changelog.
• src/ directory:
• extension.ts: main activation entry point that hooks into VS Code’s extension API.
• utils.ts: helper functions for chat message parsing, database summarization logic, etc.
• TypeScript definition files (*.d.ts): provide proposed API typings for VS Code’s chat participant and variable APIs.
README for additional insights
• Features enumerated: registration of @mssql participant, a smart action to summarize the database, and a #database variable.
• Setup instructions reveal dependencies on the MS SQL extension and on VS Code Insiders with proposed APIs enabled.
• No external web service calls—interaction is local: VS Code ↔ MS SQL extension ↔ SQL Server database.
Main components
a. Visual Studio Code Host
b. Copilot Chat API (proposed VS Code Chat APIs)
c. SQL Chat Extension (this project)
• Activation & registration logic (extension.ts)
• Chat participant handler (@mssql)
• Smart Action provider (Summarize Database)
• Chat variable resolver (#database)
• Utility module (utils.ts)
d. MS SQL VS Code Extension (fork)
e. SQL Server database instance
Relationships and interactions
• On activation: extension.ts registers chat participant, smart action, and variable resolver with the Copilot Chat API.
• When user types @mssql in chat: Copilot Chat API calls into SQL Chat’s participant handler → uses MS SQL extension API to inspect the database schema → utils code formats a reply.
• When the “Summarize Database” smart action is invoked: SQL Chat calls MS SQL extension’s API to retrieve metadata → utils to summarize → returns text to Copilot Chat.
• When chat variable #database is used: Copilot asks SQL Chat variable resolver, which queries MS SQL and returns substitution text.
Architectural patterns and design principles
• Extension activation lifecycle: leverage VS Code’s event-driven extension host model.
• Separation of concerns: extension.ts for registration/workflow orchestration, utils.ts for pure logic.
• Dependency on external extension (MS SQL) via VS Code extension API—no direct database driver code inside this project.
• Build pipeline: TypeScript→webpack bundle→VSIX package.