Skip to content

Commit bbd9416

Browse files
committed
Updates
1 parent 946ceb5 commit bbd9416

File tree

15 files changed

+595
-1025
lines changed

15 files changed

+595
-1025
lines changed

package-lock.json

Lines changed: 8 additions & 495 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4435,7 +4435,7 @@
44354435
"dependencies": {
44364436
"@anthropic-ai/claude-code": "^1.0.120",
44374437
"@anthropic-ai/sdk": "^0.63.0",
4438-
"@github/copilot": "^0.0.343",
4438+
"@github/copilot": "^0.0.352-3",
44394439
"@google/genai": "^1.22.0",
44404440
"@humanwhocodes/gitignore-to-minimatch": "1.0.2",
44414441
"@microsoft/tiktokenizer": "^1.0.10",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Instructions for development with the sdk source
2+
* Copy path to the dist-cli folder `/Users/donjayamanne/Development/vsc/sweagentd/runtime/dist-cli/sdk/index.js`
3+
* Open `vscode-copilot-chat` in VS Code Insiders
4+
* `fnm use` or `nvm use` to switch to the right version of node
5+
* Build the cli tool (e.g. `npm run build:package`)
6+
* Run `npm install /Users/donjayamanne/Development/vsc/sweagentd/runtime/dist-cli/sdk` to install the sdk package from local path
7+
* Run `npm run postinstall` (sometimes you might need to run this manually, for now do this always after installing from local path)
8+
* Modify `esbuild.ts` to exclude the sdk package from being bundled (add the path to the `external` array)
9+
* Modify `copilotcliSessionService.ts` and `copilotcliSession.ts` to import the sdk from the local path instead of `@github/copilot/sdk`
10+
* Exit VS Code completey (don't reload window, you must exit completely)
11+
* Optionally you can shutdown the build tasks & then run them again using `ctrl+shift+b`
12+
* Start VS Code again
13+
* Build tasks will automatically start running
14+
* Start debugging using the debug view and selecting `Launch Copilot Extension`
15+
* Add breakpoints in extension code & step into the sdk code
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { SessionOptions } from '@github/copilot/sdk';
7+
import { IAuthenticationService } from '../../../../platform/authentication/common/authentication';
8+
import { ILogService } from '../../../../platform/log/common/logService';
9+
import { IWorkspaceService } from '../../../../platform/workspace/common/workspaceService';
10+
import { Disposable, IDisposable, toDisposable } from '../../../../util/vs/base/common/lifecycle';
11+
import { getCopilotLogger } from './logger';
12+
13+
export class CopilotCLISessionOptionsService {
14+
constructor(
15+
@IWorkspaceService private readonly workspaceService: IWorkspaceService,
16+
@IAuthenticationService private readonly _authenticationService: IAuthenticationService,
17+
@ILogService private readonly logService: ILogService,
18+
) { }
19+
20+
public async createOptions(options: SessionOptions, permissionHandler: CopilotCLIPermissionsHandler) {
21+
const copilotToken = await this._authenticationService.getCopilotToken();
22+
const workingDirectory = await this.getWorkspaceFolderPath();
23+
const allOptions: SessionOptions = {
24+
copilotToken: copilotToken.token,
25+
env: {
26+
...process.env,
27+
COPILOTCLI_DISABLE_NONESSENTIAL_TRAFFIC: '1'
28+
},
29+
logger: getCopilotLogger(this.logService),
30+
requestPermission: async (permissionRequest) => {
31+
return await permissionHandler.getPermissions(permissionRequest);
32+
},
33+
...options
34+
};
35+
36+
if (workingDirectory) {
37+
allOptions.workingDirectory = workingDirectory;
38+
}
39+
return allOptions;
40+
}
41+
private async getWorkspaceFolderPath() {
42+
if (this.workspaceService.getWorkspaceFolders().length === 0) {
43+
return undefined;
44+
}
45+
if (this.workspaceService.getWorkspaceFolders().length === 1) {
46+
return this.workspaceService.getWorkspaceFolders()[0].fsPath;
47+
}
48+
const folder = await this.workspaceService.showWorkspaceFolderPicker();
49+
return folder?.uri?.fsPath;
50+
}
51+
}
52+
53+
export interface ICopilotCLIPermissions {
54+
onDidRequestPermissions(handler: SessionOptions['requestPermission']): IDisposable;
55+
}
56+
57+
export class CopilotCLIPermissionsHandler extends Disposable implements ICopilotCLIPermissions {
58+
private _handler: SessionOptions['requestPermission'] | undefined;
59+
60+
public onDidRequestPermissions(handler: SessionOptions['requestPermission']): IDisposable {
61+
this._handler = handler;
62+
return this._register(toDisposable(() => {
63+
this._handler = undefined;
64+
}));
65+
}
66+
67+
public async getPermissions(permission: Parameters<NonNullable<SessionOptions['requestPermission']>>[0]): Promise<ReturnType<NonNullable<SessionOptions['requestPermission']>>> {
68+
if (!this._handler) {
69+
return {
70+
kind: "denied-interactively-by-user"
71+
};
72+
}
73+
return await this._handler(permission);
74+
}
75+
}

0 commit comments

Comments
 (0)