@@ -2,7 +2,6 @@ import { arch } from 'process';
22import type { ConfigurationChangeEvent } from 'vscode' ;
33import { Disposable , env , ProgressLocation , Uri , window , workspace } from 'vscode' ;
44import type { Container } from '../../../../container' ;
5- import type { SubscriptionChangeEvent } from '../../../../plus/gk/subscriptionService' ;
65import { registerCommand } from '../../../../system/-webview/command' ;
76import { configuration } from '../../../../system/-webview/configuration' ;
87import { getContext } from '../../../../system/-webview/context' ;
@@ -28,7 +27,6 @@ export class GkCliIntegrationProvider implements Disposable {
2827 this . _disposable = Disposable . from (
2928 configuration . onDidChange ( e => this . onConfigurationChanged ( e ) ) ,
3029 ...this . registerCommands ( ) ,
31- this . container . subscription . onDidChange ( this . onSubscriptionChanged , this ) ,
3230 ) ;
3331
3432 this . onConfigurationChanged ( ) ;
@@ -145,6 +143,8 @@ export class GkCliIntegrationProvider implements Disposable {
145143 }
146144 }
147145
146+ const mcpFileName = platform === 'windows' ? 'gk.exe' : 'gk' ;
147+
148148 // Wrap the main installation process with progress indicator if not silent
149149 const installationTask = async ( ) => {
150150 let mcpInstallerPath : Uri | undefined ;
@@ -219,10 +219,10 @@ export class GkCliIntegrationProvider implements Disposable {
219219 'utf8' ,
220220 ) ;
221221 }
222- // The gk.exe file should be in a subfolder named after the installer file name
222+ // The gk file should be in a subfolder named after the installer file name
223223 const extractedFolderName = installerFileName . replace ( / \. z i p $ / , '' ) ;
224224 mcpExtractedFolderPath = Uri . joinPath ( this . container . context . globalStorageUri , extractedFolderName ) ;
225- mcpExtractedPath = Uri . joinPath ( mcpExtractedFolderPath , 'gk.exe' ) ;
225+ mcpExtractedPath = Uri . joinPath ( mcpExtractedFolderPath , mcpFileName ) ;
226226
227227 // Check using stat to make sure the newly extracted file exists.
228228 await workspace . fs . stat ( mcpExtractedPath ) ;
@@ -260,7 +260,7 @@ export class GkCliIntegrationProvider implements Disposable {
260260
261261 // Configure the MCP server in settings.json
262262 try {
263- const installOutput = await run ( 'gk.exe' , [ 'install' ] , 'utf8' , { cwd : mcpExtractedFolderPath . fsPath } ) ;
263+ const installOutput = await run ( mcpFileName , [ 'install' ] , 'utf8' , { cwd : mcpExtractedFolderPath . fsPath } ) ;
264264 const directory = installOutput . match ( / D i r e c t o r y : ( .* ) / ) ;
265265 if ( directory != null ) {
266266 try {
@@ -289,11 +289,11 @@ export class GkCliIntegrationProvider implements Disposable {
289289 Logger . warn ( 'Failed to find directory in GK install output' ) ;
290290 }
291291
292- await run ( 'gk.exe' , [ 'mcp' , 'install' , appName , ...isInsiders ? [ '--file-path' , settingsPath ] : [ ] ] , 'utf8' , { cwd : mcpExtractedFolderPath . fsPath } ) ;
292+ await run ( mcpFileName , [ 'mcp' , 'install' , appName , ...isInsiders ? [ '--file-path' , settingsPath ] : [ ] ] , 'utf8' , { cwd : mcpExtractedFolderPath . fsPath } ) ;
293293
294294 const gkAuth = ( await this . container . subscription . getAuthenticationSession ( ) ) ?. accessToken ;
295295 if ( gkAuth != null ) {
296- await run ( 'gk.exe' , [ 'auth' , 'login' , '-t' , gkAuth ] , 'utf8' , { cwd : mcpExtractedFolderPath . fsPath } ) ;
296+ await run ( mcpFileName , [ 'auth' , 'login' , '-t' , gkAuth ] , 'utf8' , { cwd : mcpExtractedFolderPath . fsPath } ) ;
297297 }
298298 } catch {
299299 // Try alternative execution methods based on platform
@@ -309,8 +309,7 @@ export class GkCliIntegrationProvider implements Disposable {
309309 'mcp' ,
310310 'install' ,
311311 appName ,
312- /*'--file-path',
313- settingsPath,*/
312+ ...isInsiders ? [ '--file-path' , settingsPath ] : [ ] ,
314313 ] ,
315314 'utf8' ,
316315 ) ;
@@ -319,7 +318,7 @@ export class GkCliIntegrationProvider implements Disposable {
319318 await run (
320319 '/bin/sh' ,
321320 // ['-c', `"${mcpExtractedPath.fsPath}" mcp install vscode --file-path "${settingsPath}"`],
322- [ '-c' , `"${ mcpExtractedPath . fsPath } " mcp install ${ appName } ` ] ,
321+ [ '-c' , `"${ mcpExtractedPath . fsPath } " mcp install ${ appName } ${ isInsiders ? `--file-path ${ settingsPath } ` : '' } ` ] ,
323322 'utf8' ,
324323 ) ;
325324 }
@@ -389,23 +388,6 @@ export class GkCliIntegrationProvider implements Disposable {
389388 }
390389 }
391390
392- private async onSubscriptionChanged ( e : SubscriptionChangeEvent ) : Promise < void > {
393- const mcpInstallStatus = this . container . storage . get ( 'ai:mcp:attemptInstall' ) ;
394- if ( e . current ?. account ?. id !== e . previous ?. account ?. id && mcpInstallStatus === 'completed' ) {
395- try {
396- await run ( 'gk' , [ 'auth' , 'logout' ] , 'utf8' ) ;
397- } catch { }
398- if ( e . current ?. account ?. id !== null ) {
399- const currentSessionToken = ( await this . container . subscription . getAuthenticationSession ( ) ) ?. accessToken ;
400- if ( currentSessionToken != null ) {
401- try {
402- await run ( 'gk' , [ 'auth' , 'login' , '-t' , currentSessionToken ] , 'utf8' ) ;
403- } catch { }
404- }
405- }
406- }
407- }
408-
409391 private registerCommands ( ) : Disposable [ ] {
410392 return [ registerCommand ( 'gitlens.ai.mcp.install' , ( ) => this . installMCPIfNeeded ( ) ) ] ;
411393 }
0 commit comments