This guide walks you through testing, packaging, and publishing the newly copied CodeGuard AI VS Code extension.
1. Local Testing and Development
To test the extension locally:
Open the codeguard-ai-extension folder in a new VS Code window.
Make sure your CodeGuard AI backend is running (e.g., at http://localhost:3001).
Press F5 in VS Code. This will open a new window called the Extension Development Host.
In the Extension Development Host window:
Open a project or create a test file (e.g., a JavaScript file with buggy code).
Press Ctrl + Shift + P to open the Command Palette and run CodeGuard AI: Analyze Current File.
The analysis results will be displayed in the results webview panel and the sidebar!
2. Packaging the Extension (.vsix)
Before publishing, you must compile and package the extension into a .vsix file.
Open your terminal in the codeguard-ai-extension directory.
Run the packaging script:
npm run package:local
This generates a file named codeguard-ai-extension-0.0.1.vsix in the directory. You can distribute this file directly to others, who can install it manually in VS Code via:
To publish your extension so anyone can download it from the VS Code Marketplace:
Step 1: Create a Microsoft Account
If you don't have one, sign up for a Microsoft Account at Microsoft Live.
Step 2: Create an Azure DevOps Organization
Go to Azure DevOps and sign in with your Microsoft account.
Create a new organization (e.g., codeguard-ai-org).
Step 3: Generate a Personal Access Token (PAT)
In your Azure DevOps organization page, click the User Settings icon in the top-right corner next to your profile picture and select Personal access tokens.
Click New Token.
Configure the token:
Name: vsce-publisher (or any name you prefer)
Organization: Select All accessible organizations (this is required).
Expiration: Set to 90 days or custom duration.
Scopes: Select Custom defined, scroll down to find Marketplace, and check Acquire and Manage.
Click Create and copy the PAT key immediately (it will not be shown again).