1
- import { homedir } from 'os' ;
2
1
import { arch } from 'process' ;
3
2
import type { ConfigurationChangeEvent } from 'vscode' ;
4
3
import { version as codeVersion , Disposable , env , ProgressLocation , Uri , window , workspace } from 'vscode' ;
@@ -93,7 +92,7 @@ export class GkCliIntegrationProvider implements Disposable {
93
92
return ;
94
93
}
95
94
96
- await this . container . storage . store ( 'ai:mcp:attemptInstall' , 'attempted' ) ;
95
+ void this . container . storage . store ( 'ai:mcp:attemptInstall' , 'attempted' ) . catch ( ) ;
97
96
98
97
if ( configuration . get ( 'ai.enabled' ) === false ) {
99
98
const message = 'Cannot install MCP: AI is disabled in settings' ;
@@ -260,7 +259,7 @@ export class GkCliIntegrationProvider implements Disposable {
260
259
261
260
// Check using stat to make sure the newly extracted file exists.
262
261
await workspace . fs . stat ( mcpExtractedPath ) ;
263
- await this . container . storage . store ( 'ai:mcp:installPath' , mcpExtractedFolderPath . fsPath ) ;
262
+ void this . container . storage . store ( 'ai:mcp:installPath' , mcpExtractedFolderPath . fsPath ) . catch ( ) ;
264
263
} catch ( error ) {
265
264
const errorMsg = `Failed to extract MCP installer: ${ error } ` ;
266
265
Logger . error ( errorMsg ) ;
@@ -289,10 +288,6 @@ export class GkCliIntegrationProvider implements Disposable {
289
288
}
290
289
}
291
290
292
- // Get the VS Code settings.json file path in case we are on VSCode Insiders
293
- // TODO: Use this path to point to the current vscode profile's settings.json once the API supports it.
294
- const settingsPath = `${ this . container . context . globalStorageUri . fsPath } \\..\\..\\settings.json` ;
295
-
296
291
// Configure the MCP server in settings.json
297
292
try {
298
293
const installOutput = await run (
@@ -303,59 +298,9 @@ export class GkCliIntegrationProvider implements Disposable {
303
298
) ;
304
299
const directory = installOutput . match ( / D i r e c t o r y : ( .* ) / ) ;
305
300
let directoryPath ;
306
- if ( directory != null ) {
307
- try {
308
- directoryPath = directory [ 1 ] ;
309
- await this . container . storage . store ( 'gk:cli:installedPath' , directoryPath ) ;
310
- // Add to PATH
311
- if ( platform === 'windows' ) {
312
- await run (
313
- 'powershell.exe' ,
314
- [
315
- '-Command' ,
316
- `[Environment]::SetEnvironmentVariable('Path', $env:Path + ';${ directoryPath } ', [EnvironmentVariableTarget]::User)` ,
317
- ] ,
318
- 'utf8' ,
319
- ) ;
320
- } else {
321
- // For Unix-like systems, detect and modify the appropriate shell profile
322
- const homeDir = homedir ( ) ;
323
- // Try to detect which shell profile exists and is in use
324
- const possibleProfiles = [
325
- { path : `${ homeDir } /.zshrc` , shell : 'zsh' } ,
326
- { path : `${ homeDir } /.zprofile` , shell : 'zsh' } ,
327
- { path : `${ homeDir } /.bashrc` , shell : 'bash' } ,
328
- { path : `${ homeDir } /.profile` , shell : 'sh' } ,
329
- ] ;
330
-
331
- // Find the first profile that exists
332
- let shellProfile ;
333
- for ( const profile of possibleProfiles ) {
334
- try {
335
- await workspace . fs . stat ( Uri . file ( profile . path ) ) ;
336
- shellProfile = profile . path ;
337
- break ;
338
- } catch {
339
- // Profile doesn't exist, try next one
340
- }
341
- }
342
-
343
- if ( shellProfile != null ) {
344
- await run (
345
- 'sh' ,
346
- [
347
- '-c' ,
348
- `echo '# Added by GitLens for MCP support' >> ${ shellProfile } && echo 'export PATH="$PATH:${ directoryPath } "' >> ${ shellProfile } ` ,
349
- ] ,
350
- 'utf8' ,
351
- ) ;
352
- } else {
353
- Logger . warn ( 'MCP Install: Failed to find shell profile to update PATH' ) ;
354
- }
355
- }
356
- } catch ( error ) {
357
- Logger . warn ( `MCP Install: Failed to add directory to PATH: ${ error } ` ) ;
358
- }
301
+ if ( directory != null && directory . length > 1 ) {
302
+ directoryPath = directory [ 1 ] ;
303
+ void this . container . storage . store ( 'gk:cli:installedPath' , directoryPath ) . catch ( ) ;
359
304
} else {
360
305
Logger . warn ( 'MCP Install: Failed to find directory in install output' ) ;
361
306
if ( appName === 'vscode' ) {
@@ -375,7 +320,7 @@ export class GkCliIntegrationProvider implements Disposable {
375
320
} else {
376
321
await run (
377
322
platform === 'windows' ? mcpFileName : `./${ mcpFileName } ` ,
378
- [ 'mcp' , 'install' , appName , ... ( isInsiders ? [ '--file-path' , settingsPath ] : [ ] ) ] ,
323
+ [ 'mcp' , 'install' , appName ] ,
379
324
'utf8' ,
380
325
{ cwd : mcpExtractedFolderPath . fsPath } ,
381
326
) ;
@@ -425,7 +370,7 @@ export class GkCliIntegrationProvider implements Disposable {
425
370
}
426
371
427
372
// Show success notification if not silent
428
- await this . container . storage . store ( 'ai:mcp:attemptInstall' , 'completed' ) ;
373
+ void this . container . storage . store ( 'ai:mcp:attemptInstall' , 'completed' ) . catch ( ) ;
429
374
void window . showInformationMessage ( 'GitKraken MCP integration installed successfully' ) ;
430
375
} catch ( error ) {
431
376
Logger . error ( `Error during MCP installation: ${ error } ` ) ;
0 commit comments