@@ -2,7 +2,6 @@ import { arch } from 'process';
2
2
import type { ConfigurationChangeEvent } from 'vscode' ;
3
3
import { Disposable , env , ProgressLocation , Uri , window , workspace } from 'vscode' ;
4
4
import type { Container } from '../../../../container' ;
5
- import type { SubscriptionChangeEvent } from '../../../../plus/gk/subscriptionService' ;
6
5
import { registerCommand } from '../../../../system/-webview/command' ;
7
6
import { configuration } from '../../../../system/-webview/configuration' ;
8
7
import { getContext } from '../../../../system/-webview/context' ;
@@ -28,7 +27,6 @@ export class GkCliIntegrationProvider implements Disposable {
28
27
this . _disposable = Disposable . from (
29
28
configuration . onDidChange ( e => this . onConfigurationChanged ( e ) ) ,
30
29
...this . registerCommands ( ) ,
31
- this . container . subscription . onDidChange ( this . onSubscriptionChanged , this ) ,
32
30
) ;
33
31
34
32
this . onConfigurationChanged ( ) ;
@@ -145,6 +143,8 @@ export class GkCliIntegrationProvider implements Disposable {
145
143
}
146
144
}
147
145
146
+ const mcpFileName = platform === 'windows' ? 'gk.exe' : 'gk' ;
147
+
148
148
// Wrap the main installation process with progress indicator if not silent
149
149
const installationTask = async ( ) => {
150
150
let mcpInstallerPath : Uri | undefined ;
@@ -219,10 +219,10 @@ export class GkCliIntegrationProvider implements Disposable {
219
219
'utf8' ,
220
220
) ;
221
221
}
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
223
223
const extractedFolderName = installerFileName . replace ( / \. z i p $ / , '' ) ;
224
224
mcpExtractedFolderPath = Uri . joinPath ( this . container . context . globalStorageUri , extractedFolderName ) ;
225
- mcpExtractedPath = Uri . joinPath ( mcpExtractedFolderPath , 'gk.exe' ) ;
225
+ mcpExtractedPath = Uri . joinPath ( mcpExtractedFolderPath , mcpFileName ) ;
226
226
227
227
// Check using stat to make sure the newly extracted file exists.
228
228
await workspace . fs . stat ( mcpExtractedPath ) ;
@@ -260,7 +260,7 @@ export class GkCliIntegrationProvider implements Disposable {
260
260
261
261
// Configure the MCP server in settings.json
262
262
try {
263
- const installOutput = await run ( 'gk.exe' , [ 'install' ] , 'utf8' , { cwd : mcpExtractedFolderPath . fsPath } ) ;
263
+ const installOutput = await run ( mcpFileName , [ 'install' ] , 'utf8' , { cwd : mcpExtractedFolderPath . fsPath } ) ;
264
264
const directory = installOutput . match ( / D i r e c t o r y : ( .* ) / ) ;
265
265
if ( directory != null ) {
266
266
try {
@@ -289,11 +289,11 @@ export class GkCliIntegrationProvider implements Disposable {
289
289
Logger . warn ( 'Failed to find directory in GK install output' ) ;
290
290
}
291
291
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 } ) ;
293
293
294
294
const gkAuth = ( await this . container . subscription . getAuthenticationSession ( ) ) ?. accessToken ;
295
295
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 } ) ;
297
297
}
298
298
} catch {
299
299
// Try alternative execution methods based on platform
@@ -309,8 +309,7 @@ export class GkCliIntegrationProvider implements Disposable {
309
309
'mcp' ,
310
310
'install' ,
311
311
appName ,
312
- /*'--file-path',
313
- settingsPath,*/
312
+ ...isInsiders ? [ '--file-path' , settingsPath ] : [ ] ,
314
313
] ,
315
314
'utf8' ,
316
315
) ;
@@ -319,7 +318,7 @@ export class GkCliIntegrationProvider implements Disposable {
319
318
await run (
320
319
'/bin/sh' ,
321
320
// ['-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 } ` : '' } ` ] ,
323
322
'utf8' ,
324
323
) ;
325
324
}
@@ -389,23 +388,6 @@ export class GkCliIntegrationProvider implements Disposable {
389
388
}
390
389
}
391
390
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
-
409
391
private registerCommands ( ) : Disposable [ ] {
410
392
return [ registerCommand ( 'gitlens.ai.mcp.install' , ( ) => this . installMCPIfNeeded ( ) ) ] ;
411
393
}
0 commit comments