Skip to content

Commit fdcbf4f

Browse files
Fixes install path on vscode insiders and updates PATH
1 parent f02015c commit fdcbf4f

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

src/constants.storage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export type GlobalStorage = {
8181
preVersion: string;
8282
'product:config': Stored<StoredProductConfig>;
8383
'confirm:draft:storage': boolean;
84+
'gk:cli:installedPath': string;
8485
'home:sections:collapsed': string[];
8586
'home:walkthrough:dismissed': boolean;
8687
'launchpad:groups:collapsed': StoredLaunchpadGroup[];

src/env/node/gk/cli/integration.ts

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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(/Directory: (.*)/);
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

Comments
 (0)