diff options
| author | christine betts <[email protected]> | 2025-08-06 17:36:05 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-06 17:36:05 +0000 |
| commit | fde9849d48e3b92377aca2eecfd390ebce288692 (patch) | |
| tree | 90c09c3dfce161ed6adb1d71c33fb432c1708614 /packages/vscode-ide-companion/src/ide-server.ts | |
| parent | 487818df276dc66827ce0f469f84bcae56a70801 (diff) | |
[ide-mode] Add support for in-IDE diff handling in the CLI (#5603)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Diffstat (limited to 'packages/vscode-ide-companion/src/ide-server.ts')
| -rw-r--r-- | packages/vscode-ide-companion/src/ide-server.ts | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/packages/vscode-ide-companion/src/ide-server.ts b/packages/vscode-ide-companion/src/ide-server.ts index 30215ccc..eec99cb3 100644 --- a/packages/vscode-ide-companion/src/ide-server.ts +++ b/packages/vscode-ide-companion/src/ide-server.ts @@ -5,15 +5,13 @@ */ import * as vscode from 'vscode'; +import { IdeContextNotificationSchema } from '@google/gemini-cli-core'; +import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js'; import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js'; -import express, { Request, Response } from 'express'; +import express, { type Request, type Response } from 'express'; import { randomUUID } from 'node:crypto'; -import { - isInitializeRequest, - type JSONRPCNotification, -} from '@modelcontextprotocol/sdk/types.js'; -import { Server as HTTPServer } from 'node:http'; +import { type Server as HTTPServer } from 'node:http'; import { z } from 'zod'; import { DiffManager } from './diff-manager.js'; import { OpenFilesManager } from './open-files-manager.js'; @@ -28,11 +26,12 @@ function sendIdeContextUpdateNotification( ) { const ideContext = openFilesManager.state; - const notification: JSONRPCNotification = { + const notification = IdeContextNotificationSchema.parse({ jsonrpc: '2.0', method: 'ide/contextUpdate', params: ideContext, - }; + }); + log( `Sending IDE context update notification: ${JSON.stringify( notification, @@ -76,7 +75,7 @@ export class IDEServer { }); context.subscriptions.push(onDidChangeSubscription); const onDidChangeDiffSubscription = this.diffManager.onDidChange( - (notification: JSONRPCNotification) => { + (notification) => { for (const transport of Object.values(transports)) { transport.send(notification); } @@ -269,12 +268,13 @@ const createMcpServer = (diffManager: DiffManager) => { }).shape, }, async ({ filePath }: { filePath: string }) => { - await diffManager.closeDiff(filePath); + const content = await diffManager.closeDiff(filePath); + const response = { content: content ?? undefined }; return { content: [ { type: 'text', - text: `Closed diff for ${filePath}`, + text: JSON.stringify(response), }, ], }; |
