refactor(vscode-ide-companion): Reduce VSIX size and improve build process (#9118)

This commit is contained in:
Shreya Keshive
2025-09-22 12:12:43 -04:00
committed by GitHub
parent 92543da28c
commit 9abb165f7b
8 changed files with 42 additions and 33 deletions

View File

@@ -1,30 +1,24 @@
# Local Development # Local Development ⚙️
## Running the Extension ## Running the Extension
To run the extension locally for development: To run the extension locally for development, we recommend using the automatic watch process for continuous compilation:
1. From the root of the repository, install dependencies: 1. **Install Dependencies** (from the root of the repository):
```bash ```bash
npm install npm install
``` ```
2. Open this directory (`packages/vscode-ide-companion`) in VS Code. 2. **Open in VS Code:** Open this directory (`packages/vscode-ide-companion`) in your VS Code editor.
3. Compile the extension: 3. **Start Watch Mode:** Run the watch script to compile the extension and monitor changes in both **esbuild** and **TypeScript**:
```bash ```bash
npm run compile npm run watch
``` ```
4. Press `F5` (fn+f5 on mac) to open a new Extension Development Host window with the extension running. 4. **Launch Host:** Press **`F5`** (or **`fn+F5`** on Mac) to open a new **Extension Development Host** window with the extension running.
To watch for changes and have the extension rebuild automatically, run: ### Manual Build
If you only need to compile the extension once without watching for changes:
```bash ```bash
npm run watch npm run build
```
## Running Tests
To run the automated tests, run:
```bash
npm run test
``` ```

View File

@@ -96,18 +96,21 @@
"main": "./dist/extension.cjs", "main": "./dist/extension.cjs",
"type": "module", "type": "module",
"scripts": { "scripts": {
"vscode:prepublish": "npm run generate:notices && npm run check-types && npm run lint && node esbuild.js --production", "prepackage": "npm run generate:notices && npm run check-types && npm run lint && npm run build:prod",
"build": "npm run compile", "build": "npm run build:dev",
"compile": "npm run check-types && npm run lint && node esbuild.js", "build:dev": "npm run check-types && npm run lint && node esbuild.js",
"watch": "npm-run-all -p watch:*", "build:prod": "node esbuild.js --production",
"generate:notices": "node ./scripts/generate-notices.js",
"prepare": "npm run generate:notices",
"check-types": "tsc --noEmit",
"lint": "eslint src",
"watch": "npm-run-all2 -p watch:*",
"watch:esbuild": "node esbuild.js --watch", "watch:esbuild": "node esbuild.js --watch",
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json", "watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
"package": "vsce package --no-dependencies", "package": "vsce package --no-dependencies",
"generate:notices": "node ./scripts/generate-notices.js",
"check-types": "tsc --noEmit",
"lint": "eslint src",
"test": "vitest run", "test": "vitest run",
"test:ci": "vitest run --coverage" "test:ci": "vitest run --coverage",
"validate:notices": "node ./scripts/validate-notices.js"
}, },
"devDependencies": { "devDependencies": {
"@types/cors": "^2.8.19", "@types/cors": "^2.8.19",

View File

@@ -7,7 +7,7 @@
import { import {
IdeDiffAcceptedNotificationSchema, IdeDiffAcceptedNotificationSchema,
IdeDiffClosedNotificationSchema, IdeDiffClosedNotificationSchema,
} from '@google/gemini-cli-core'; } from '@google/gemini-cli-core/src/ide/types.js';
import { type JSONRPCNotification } from '@modelcontextprotocol/sdk/types.js'; import { type JSONRPCNotification } from '@modelcontextprotocol/sdk/types.js';
import * as path from 'node:path'; import * as path from 'node:path';
import * as vscode from 'vscode'; import * as vscode from 'vscode';

View File

@@ -7,10 +7,15 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import { activate } from './extension.js'; import { activate } from './extension.js';
import { IDE_DEFINITIONS, detectIdeFromEnv } from '@google/gemini-cli-core'; import {
IDE_DEFINITIONS,
detectIdeFromEnv,
} from '@google/gemini-cli-core/src/ide/detect-ide.js';
vi.mock('@google/gemini-cli-core', async () => { vi.mock('@google/gemini-cli-core/src/ide/detect-ide.js', async () => {
const actual = await vi.importActual('@google/gemini-cli-core'); const actual = await vi.importActual(
'@google/gemini-cli-core/src/ide/detect-ide.js',
);
return { return {
...actual, ...actual,
detectIdeFromEnv: vi.fn(() => IDE_DEFINITIONS.vscode), detectIdeFromEnv: vi.fn(() => IDE_DEFINITIONS.vscode),

View File

@@ -13,7 +13,7 @@ import {
detectIdeFromEnv, detectIdeFromEnv,
IDE_DEFINITIONS, IDE_DEFINITIONS,
type IdeInfo, type IdeInfo,
} from '@google/gemini-cli-core'; } from '@google/gemini-cli-core/src/ide/detect-ide.js';
const CLI_IDE_COMPANION_IDENTIFIER = 'Google.gemini-cli-vscode-ide-companion'; const CLI_IDE_COMPANION_IDENTIFIER = 'Google.gemini-cli-vscode-ide-companion';
const INFO_MESSAGE_SHOWN_KEY = 'geminiCliInfoMessageShown'; const INFO_MESSAGE_SHOWN_KEY = 'geminiCliInfoMessageShown';

View File

@@ -9,7 +9,7 @@ import {
CloseDiffRequestSchema, CloseDiffRequestSchema,
IdeContextNotificationSchema, IdeContextNotificationSchema,
OpenDiffRequestSchema, OpenDiffRequestSchema,
} from '@google/gemini-cli-core'; } from '@google/gemini-cli-core/src/ide/types.js';
import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js'; import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js';
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js'; import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';

View File

@@ -5,7 +5,10 @@
*/ */
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import type { File, IdeContext } from '@google/gemini-cli-core'; import type {
File,
IdeContext,
} from '@google/gemini-cli-core/src/ide/types.js';
export const MAX_FILES = 10; export const MAX_FILES = 10;
const MAX_SELECTED_TEXT_LENGTH = 16384; // 16 KiB limit const MAX_SELECTED_TEXT_LENGTH = 16384; // 16 KiB limit

View File

@@ -46,7 +46,11 @@ for (const workspace of rootPackageJson.workspaces) {
} }
} }
// Clean up vsix files in vscode-ide-companion // Clean up vscode-ide-companion package
rmSync(join(root, 'packages/vscode-ide-companion/node_modules'), {
recursive: true,
force: true,
});
const vsixFiles = globSync('packages/vscode-ide-companion/*.vsix', { const vsixFiles = globSync('packages/vscode-ide-companion/*.vsix', {
cwd: root, cwd: root,
}); });