Understand the extension structure and API
mainThe extension is composed of the following key files:
package.json: The manifest file where you declare extension commands, titles, and command names. This allows VS Code to register commands in the command palette.src/extension.ts: The main entry point. It exports anactivatefunction called when the extension is triggered. Insideactivate, you useregisterCommandto bind implementation logic to a command.node_modules/@types/vscode/index.d.ts: The location of the full VS Code API definitions for reference.
Implementation Pattern:
Commands are registered by passing the implementation function as the second parameter to registerCommand within the activate function.
// Inside src/extension.ts
export function activate(context: vscode.ExtensionContext) {
let disposable = vscode.commands.registerCommand('extension.helloWorld', () => {
// Command implementation
});
context.subscriptions.push(disposable);
}