@@ -233,10 +233,12 @@ export class GkCliIntegrationProvider implements Disposable {
233
233
234
234
// Get the app name
235
235
let appName = 'vscode' ;
236
+ let isInsiders = false ;
236
237
switch ( env . appName ) {
237
238
case 'Visual Studio Code' :
239
+ break ;
238
240
case 'Visual Studio Code - Insiders' :
239
- appName = 'vscode' ;
241
+ isInsiders = true ;
240
242
break ;
241
243
case 'Cursor' :
242
244
appName = 'cursor' ;
@@ -251,13 +253,42 @@ export class GkCliIntegrationProvider implements Disposable {
251
253
}
252
254
}
253
255
254
- // Get the VS Code settings.json file path
256
+ // Get the VS Code settings.json file path in case we are on VSCode Insiders
255
257
// TODO: Use this path to point to the current vscode profile's settings.json once the API supports it.
256
- // const settingsPath = `${this.container.context.globalStorageUri.fsPath}\\..\\..\\settings.json`;
258
+ const settingsPath = `${ this . container . context . globalStorageUri . fsPath } \\..\\..\\settings.json` ;
257
259
258
260
// Configure the MCP server in settings.json
259
261
try {
260
- await run ( 'gk.exe' , [ 'mcp' , 'install' , appName /*, '--file-path', settingsPath*/ ] , 'utf8' , { cwd : mcpExtractedFolderPath . fsPath } ) ;
262
+ const installOutput = await run ( 'gk.exe' , [ 'install' ] , 'utf8' , { cwd : mcpExtractedFolderPath . fsPath } ) ;
263
+ const directory = installOutput . match ( / D i r e c t o r y : ( .* ) / ) ;
264
+ if ( directory != null ) {
265
+ try {
266
+ const directoryPath = directory [ 1 ] ;
267
+ await this . container . storage . store ( 'gk:cli:installedPath' , directoryPath ) ;
268
+ if ( platform === 'windows' ) {
269
+ await run (
270
+ 'powershell.exe' ,
271
+ [
272
+ '-Command' ,
273
+ `[Environment]::SetEnvironmentVariable('Path', $env:Path + ';${ directoryPath } ', [EnvironmentVariableTarget]::User)` ,
274
+ ] ,
275
+ 'utf8' ,
276
+ ) ;
277
+ } else {
278
+ await run (
279
+ 'export' ,
280
+ [ `PATH=$PATH:${ directoryPath } ` ] ,
281
+ 'utf8' ,
282
+ ) ;
283
+ }
284
+ } catch ( error ) {
285
+ Logger . warn ( `Failed to add GK directory to PATH: ${ error } ` ) ;
286
+ }
287
+ } else {
288
+ Logger . warn ( 'Failed to find directory in GK install output' ) ;
289
+ }
290
+
291
+ await run ( 'gk.exe' , [ 'mcp' , 'install' , appName , ...isInsiders ? [ '--file-path' , settingsPath ] : [ ] ] , 'utf8' , { cwd : mcpExtractedFolderPath . fsPath } ) ;
261
292
} catch {
262
293
// Try alternative execution methods based on platform
263
294
try {
0 commit comments