@@ -233,10 +233,12 @@ export class GkCliIntegrationProvider implements Disposable {
233233
234234 // Get the app name
235235 let appName = 'vscode' ;
236+ let isInsiders = false ;
236237 switch ( env . appName ) {
237238 case 'Visual Studio Code' :
239+ break ;
238240 case 'Visual Studio Code - Insiders' :
239- appName = 'vscode' ;
241+ isInsiders = true ;
240242 break ;
241243 case 'Cursor' :
242244 appName = 'cursor' ;
@@ -251,13 +253,42 @@ export class GkCliIntegrationProvider implements Disposable {
251253 }
252254 }
253255
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
255257 // 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` ;
257259
258260 // Configure the MCP server in settings.json
259261 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 } ) ;
261292 } catch {
262293 // Try alternative execution methods based on platform
263294 try {
0 commit comments