mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 14:10:37 -07:00
refactor(vscode-ide-companion): Reduce VSIX size and improve build process (#9118)
This commit is contained in:
@@ -1,30 +1,24 @@
|
||||
# Local Development
|
||||
# Local Development ⚙️
|
||||
|
||||
## 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
|
||||
npm install
|
||||
```
|
||||
2. Open this directory (`packages/vscode-ide-companion`) in VS Code.
|
||||
3. Compile the extension:
|
||||
2. **Open in VS Code:** Open this directory (`packages/vscode-ide-companion`) in your VS Code editor.
|
||||
3. **Start Watch Mode:** Run the watch script to compile the extension and monitor changes in both **esbuild** and **TypeScript**:
|
||||
```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
|
||||
npm run watch
|
||||
```
|
||||
|
||||
## Running Tests
|
||||
|
||||
To run the automated tests, run:
|
||||
|
||||
```bash
|
||||
npm run test
|
||||
npm run build
|
||||
```
|
||||
|
||||
@@ -96,18 +96,21 @@
|
||||
"main": "./dist/extension.cjs",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"vscode:prepublish": "npm run generate:notices && npm run check-types && npm run lint && node esbuild.js --production",
|
||||
"build": "npm run compile",
|
||||
"compile": "npm run check-types && npm run lint && node esbuild.js",
|
||||
"watch": "npm-run-all -p watch:*",
|
||||
"prepackage": "npm run generate:notices && npm run check-types && npm run lint && npm run build:prod",
|
||||
"build": "npm run build:dev",
|
||||
"build:dev": "npm run check-types && npm run lint && node esbuild.js",
|
||||
"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:tsc": "tsc --noEmit --watch --project tsconfig.json",
|
||||
"package": "vsce package --no-dependencies",
|
||||
"generate:notices": "node ./scripts/generate-notices.js",
|
||||
"check-types": "tsc --noEmit",
|
||||
"lint": "eslint src",
|
||||
"test": "vitest run",
|
||||
"test:ci": "vitest run --coverage"
|
||||
"test:ci": "vitest run --coverage",
|
||||
"validate:notices": "node ./scripts/validate-notices.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/cors": "^2.8.19",
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import {
|
||||
IdeDiffAcceptedNotificationSchema,
|
||||
IdeDiffClosedNotificationSchema,
|
||||
} from '@google/gemini-cli-core';
|
||||
} from '@google/gemini-cli-core/src/ide/types.js';
|
||||
import { type JSONRPCNotification } from '@modelcontextprotocol/sdk/types.js';
|
||||
import * as path from 'node:path';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
@@ -7,10 +7,15 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import * as vscode from 'vscode';
|
||||
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 () => {
|
||||
const actual = await vi.importActual('@google/gemini-cli-core');
|
||||
vi.mock('@google/gemini-cli-core/src/ide/detect-ide.js', async () => {
|
||||
const actual = await vi.importActual(
|
||||
'@google/gemini-cli-core/src/ide/detect-ide.js',
|
||||
);
|
||||
return {
|
||||
...actual,
|
||||
detectIdeFromEnv: vi.fn(() => IDE_DEFINITIONS.vscode),
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
detectIdeFromEnv,
|
||||
IDE_DEFINITIONS,
|
||||
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 INFO_MESSAGE_SHOWN_KEY = 'geminiCliInfoMessageShown';
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
CloseDiffRequestSchema,
|
||||
IdeContextNotificationSchema,
|
||||
OpenDiffRequestSchema,
|
||||
} from '@google/gemini-cli-core';
|
||||
} from '@google/gemini-cli-core/src/ide/types.js';
|
||||
import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js';
|
||||
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
||||
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
*/
|
||||
|
||||
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;
|
||||
const MAX_SELECTED_TEXT_LENGTH = 16384; // 16 KiB limit
|
||||
|
||||
@@ -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', {
|
||||
cwd: root,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user