### Trigger Chat Setup from Accounts Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/parser/test/node/fixtures/chatSetup.ts.getStructure.html An action to initiate Copilot setup directly from the Accounts context menu. This is displayed when Copilot is not installed or the user is signed out. ```typescript class ChatSetupFromAccountsAction extends Action2 { constructor() { super({ id: 'workbench.action.chat.triggerSetupFromAccounts', title: localize2('triggerChatSetupFromAccounts', "Sign in to use Copilot..."), menu: { id: MenuId.AccountsContext, group: '2_copilot', when: ContextKeyExpr.and( ChatContextKeys.Setup.hidden.negate(), ChatContextKeys.Setup.installed.negate(), ChatContextKeys.Entitlement.signedOut ) } }); } override async run(accessor: ServicesAccessor): Promise { const commandService = accessor.get(ICommandService); return commandService.executeCommand(CHAT_SETUP_ACTION_ID); } } ``` -------------------------------- ### Hook Configuration Example Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/assets/prompts/skills/agent-customization/references/hooks.md Example of a hook configuration file demonstrating how to define a command to run before tool use. ```APIDOC ## Configuration Format ```json { "hooks": { "PreToolUse": [ { "type": "command", "command": "./scripts/validate-tool.sh", "timeout": 15 } ] } } ``` Each hook command supports: - `type` (must be `command`) - `command` (default) - `windows`, `linux`, `osx` (platform overrides) - `cwd`, `env`, `timeout` ``` -------------------------------- ### Invoke Chat Setup Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/parser/test/node/fixtures/chatSetup.ts.getStructure.html Initiates the chat setup process and logs telemetry. ```typescript private async doInvokeWithSetup(request: IChatAgentRequest, progress: (part: IChatProgress) => void, chatService: IChatService, languageModelsService: ILanguageModelsService, chatWidgetService: IChatWidgetService, chatAgentService: IChatAgentService, languageModelToolsService: ILanguageModelToolsService): Promise { this.telemetryService.publicLog2('workbenchActionExecuted', { id: CHAT_SETUP_ACTION_ID, from: 'chat' }); const requestModel = chatWidgetService.getWidgetBySessionId(request.sessionId)?.viewModel?.model.getRequests().at(-1); const setupListener = Event.runAndSubscribe(this.controller.value.onDidChange, (() => { switch (this.controller.value.step) { case ChatSetupStep.SigningIn: pro ``` -------------------------------- ### Trigger Chat Setup Action Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/parser/test/node/fixtures/chatSetup.ts.getStructure.html Defines an action to trigger the Copilot setup process, including showing the Copilot view and handling potential setup errors with a retry option. This action is available when Copilot setup is not yet installed. ```typescript class ChatSetupTriggerAction extends Action2 { constructor() { super({ id: CHAT_SETUP_ACTION_ID, title: CHAT_SETUP_ACTION_LABEL, category: CHAT_CATEGORY, f1: true, precondition: chatSetupTriggerContext }); } override async run(accessor: ServicesAccessor, mode: ChatMode): Promise { const viewsService = accessor.get(IViewsService); const layoutService = accessor.get(IWorkbenchLayoutService); const instantiationService = accessor.get(IInstantiationService); const dialogService = accessor.get(IDialogService); const commandService = accessor.get(ICommandService); const lifecycleService = accessor.get(ILifecycleService); await context.update({ hidden: false }); const chatWidgetPromise = showCopilotView(viewsService, layoutService); if (mode) { const chatWidget = await chatWidgetPromise; chatWidget?.input.setChatMode(mode); } const setup = ChatSetup.getInstance(instantiationService, context, controller); const { success } = await setup.run(); if (success === false && !lifecycleService.willShutdown) { const { confirmed } = await dialogService.confirm({ type: Severity.Error, message: localize('setupErrorDialog', "Copilot setup failed. Would you like to try again?"), primaryButton: localize('retry', "Retry"), }); if (confirmed) { commandService.executeCommand(CHAT_SETUP_ACTION_ID); } } } } ``` -------------------------------- ### Install @vscode/chat-lib Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/chat-lib/README.md Install the @vscode/chat-lib package using npm. ```bash npm install @vscode/chat-lib ``` -------------------------------- ### Register Setup Tool Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/parser/test/node/fixtures/chatSetup.ts.getStructure.html Registers a tool implementation using the instantiation service and tool service. ```typescript static registerTools(instantiationService: IInstantiationService, toolData: IToolData): { disposable: IDisposable; tool: SetupTool } { return instantiationService.invokeFunction(accessor => { const disposables = new DisposableStore(); const toolService = accessor.get(ILanguageModelToolsService); disposables.add(toolService.registerToolData(toolData)); const tool = instantiationService.createInstance(SetupTool); disposables.add(toolService.registerToolImplementation(toolData.id, tool)); return { tool, disposable: disposables }; }); } ``` -------------------------------- ### Setup Chat Agent Initialization Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/parser/test/node/fixtures/chatSetup.ts.getStructure.html Initializes the SetupChatAgent, which is responsible for managing the Copilot chat experience, including handling setup requirements. ```typescript private static readonly SETUP_NEEDED_MESSAGE = new MarkdownString(localize('settingUpCopilotNeeded', "You need to set up Copilot to use Chat.")); ``` -------------------------------- ### Install VS Code Extension by ID Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/assets/prompts/skills/install-vscode-extension/SKILL.md Use the `copilot_runVscodeCommand` tool to execute the `workbench.extensions.installExtension` command. Pass the extension ID and an options object to specify installation preferences like enabling the extension or installing a pre-release version. Set `skipCheck` to true to bypass command existence checks. ```javascript copilot_runVscodeCommand("workbench.extensions.installExtension", ["ms-python.python", { "enable": true, "installPreReleaseVersion": false }], {"skipCheck": true}) ``` -------------------------------- ### Trigger Chat Setup Without Dialog Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/parser/test/node/fixtures/chatSetup.ts.getStructure.html An action to initiate Copilot setup without displaying a dialog, useful for programmatic triggers. It ensures the Copilot view is shown and the setup process is started. ```typescript class ChatSetupTriggerWithoutDialogAction extends Action2 { constructor() { super({ id: 'workbench.action.chat.triggerSetupWithoutDialog', title: CHAT_SETUP_ACTION_LABEL, precondition: chatSetupTriggerContext }); } override async run(accessor: ServicesAccessor): Promise { const viewsService = accessor.get(IViewsService); const layoutService = accessor.get(IWorkbenchLayoutService); const instantiationService = accessor.get(IInstantiationService); await context.update({ hidden: false }); const chatWidget = await showCopilotView(viewsService, layoutService); ChatSetup.getInstance(instantiationService, context, controller).skipDialog(); chatWidget?.acceptInput(localize('setupCopilot', "Set up Copilot.")); } } ``` -------------------------------- ### Copilot Chat Setup Logic Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/parser/test/node/fixtures/chatSetup.ts.getStructure.html Handles the orchestration of the setup process, including progress tracking, authentication, and workspace trust verification. ```typescript @IProgressService private readonly progressService: IProgressService, @IActivityService private readonly activityService: IActivityService, @ICommandService private readonly commandService: ICommandService, @IWorkspaceTrustRequestService private readonly workspaceTrustRequestService: IWorkspaceTrustRequestService, @IDialogService private readonly dialogService: IDialogService, @IConfigurationService private readonly configurationService: IConfigurationService, @ILifecycleService private readonly lifecycleService: ILifecycleService, @IQuickInputService private readonly quickInputService: IQuickInputService, ) { super(); this.registerListeners(); } private registerListeners(): void { this._register(this.context.onDidChange(() => this._onDidChange.fire())); } private setStep(step: ChatSetupStep): void { if (this._step === step) { return; } this._step = step; this._onDidChange.fire(); } async setup(options?: { forceSignIn?: boolean }): Promise { const watch = new StopWatch(false); const title = localize('setupChatProgress', "Getting Copilot ready..."); const badge = this.activityService.showViewContainerActivity(CHAT_SIDEBAR_PANEL_ID, { badge: new ProgressBadge(() => title), }); try { return await this.progressService.withProgress({ location: ProgressLocation.Window, command: CHAT_OPEN_ACTION_ID, title, }, () => this.doSetup(options ?? {}, watch)); } finally { badge.dispose(); } } private async doSetup(options: { forceSignIn?: boolean }, watch: StopWatch): Promise { this.context.suspend(); // reduces flicker let success = false; try { const providerId = ChatEntitlementRequests.providerId(this.configurationService); let session: AuthenticationSession | undefined; let entitlement: ChatEntitlement | undefined; // Entitlement Unknown or `forceSignIn`: we need to sign-in user if (this.context.state.entitlement === ChatEntitlement.Unknown || options.forceSignIn) { this.setStep(ChatSetupStep.SigningIn); const result = await this.signIn(providerId); if (!result.session) { this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'failedNotSignedIn', installDuration: watch.elapsed(), signUpErrorCode: undefined }); return false; } session = result.session; entitlement = result.entitlement; } const trusted = await this.workspaceTrustRequestService.requestWorkspaceTrust({ message: localize('copilotWorkspaceTrust', "Copilot is currently only supported in trusted workspaces.") }); if (!trusted) { this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'failedNotTrusted', installDuration: watch.elapsed(), signUpErrorCode: undefined }); return false; } // Install this.setStep(ChatSetupStep.Installing); success = await this.install(session, entitlement ?? this.context.state.entitlement, providerId, watch); } finally { this.setStep(ChatSetupStep.Initial); this.context.resume(); } return success; } private async signIn(providerId: string): Promise<{ session: AuthenticationSession | undefined; entitlement: ChatEntitlement | undefined }> { let session: AuthenticationSession | undefined; let entitlements; try { ({ session, entitlements } = await this.requests.signIn()); } catch (e) { this.logService.error(`[chat setup] signIn: error ${e}`); } if (!session && !this.lifecycleService.willShutdown) { const { confirmed } = await this.dialogService.confirm({ type: Severity.Error, message: localize('unknownSignInError', "Failed to sign in to {0}. Would you like to try again?", ChatEntitlementRequests.providerId(this.configurationService) === defaultChat.enterpriseProviderId ? defaultChat.enterpriseProviderName : defaultChat.providerName), detail: localize('unknownSignInErrorDetail', "You must be signed in to use Copilot."), primaryButton: localize('retry', "Retry") }); if (confirmed) { return this.signIn(providerId); } } return { session, entitlement: entitlements?.entitlement }; } private async install(session: AuthenticationSession | undefined, entitlement: ChatEntitlement, providerId: string, watch: StopWatch): Promise { const wasInstalled = this.context.state.installed; let signUpResult: boolean | { errorCode: number } | undefined = undefined; try { if ( entitlement !== ChatEntitlement.Limited && // User is not signed up to Copilot Free entitlement !== ChatEntitlement.Pro && // User is not signed up to Copilot Pro entitlement !== ChatEntitlement.Unavailable // User is eligible for Copilot Free ) { if (!session) { try { session = (await this.authenticationService.getSessions(providerId)).at(0); } catch (error) { // ignore - errors can throw if a provider is not registered } if (!session) { this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'failedNoSession', installDuration: watch.elapsed(), signUpErrorCode: undefined }); return false; // unexpected } } signUpResult = await this.requests.signUpLimited(session); if (typeof signUpResult !== 'boolean' /* error */) { this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'faile ``` -------------------------------- ### Discovery Event Log Examples Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/assets/prompts/skills/troubleshoot/SKILL.md Example JSONL entries for discovery events, which track the loading of instructions, skills, and agents. ```jsonl {"ts":1773200251309,"dur":0,"sid":"62f52dec","type":"discovery","name":"Load Instructions","spanId":"2cb1f2f4","status":"ok","attrs":{"details":"Resolved 0 instructions in 0.0ms | folders: [/c:/Users/user/.copilot/instructions, /workspace/.github/instructions]","category":"discovery","source":"core"}} {"ts":1773200251415,"dur":0,"sid":"62f52dec","type":"discovery","name":"Load Agents","spanId":"38a897d8","status":"ok","attrs":{"details":"Resolved 3 agents in 0.0ms | loaded: [Plan, Ask, Explore] | folders: [/workspace/.github/agents]","category":"discovery","source":"core"}} {"ts":1773200251431,"dur":0,"sid":"62f52dec","type":"discovery","name":"Load Skills","spanId":"472eb225","status":"ok","attrs":{"details":"Resolved 6 skills in 0.0ms | loaded: [agent-customization, troubleshoot, ...]","category":"discovery","source":"core"}} ``` -------------------------------- ### Install Copilot Chat Extension Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/parser/test/node/fixtures/chatSetup.ts.getStructure.html Installs the default Copilot Chat extension. Handles potential errors during installation and logs the outcome. ```typescript await this.doInstall(); } catch (error) { this.logService.error(`[chat setup] install: error ${error}`); this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: isCancellationError(error) ? 'cancelled' : 'failedInstall', installDuration: watch.elapsed(), signUpErrorCode: undefined }); return false; } if (typeof signUpResult === 'boolean') { this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: wasInstalled && !signUpResult ? 'alreadyInstalled' : 'installed', installDuration: watch.elapsed(), signUpErrorCode: undefined }); } if (wasInstalled && signUpResult === true) { refreshTokens(this.commandService); } return true; } private async doInstall(): Promise { let error: Error | undefined; try { await this.extensionsWorkbenchService.install(defaultChat.extensionId, { enable: true, isApplicationScoped: true, // install into all profiles isMachineScoped: false, // do not ask to sync installEverywhere: true, // install in local and remote installPreReleaseVersion: this.productService.quality !== 'stable' }, ChatViewId); } catch (e) { this.logService.error(`[chat setup] install: error ${error}`); error = e; } if (error) { if (!this.lifecycleService.willShutdown) { const { confirmed } = await this.dialogService.confirm({ type: Severity.Error, message: localize('unknownSetupError', "An error occurred while setting up Copilot. Would you like to try again?"), detail: error && !isCancellationError(error) ? toErrorMessage(error) : undefined, primaryButton: localize('retry', "Retry") }); if (confirmed) { return this.doInstall(); } } throw error; } } ``` -------------------------------- ### Setup VS Code Extension Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/assets/prompts/skills/project-setup-info-local/SKILL.md Use this command to scaffold a new VS Code extension project. It supports various extension types and package managers. ```bash npx --package yo --package generator-code -- yo code . --skipOpen ``` -------------------------------- ### ChatSetup Class Definition Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/parser/test/node/fixtures/chatSetup.ts.getStructure.html Defines the ChatSetup class responsible for managing the chat setup process. It includes methods for getting an instance, skipping dialogs, running the setup, and handling different setup strategies. ```typescript CancellationToken): Promise { return Promise.resolve(undefined); } } enum ChatSetupStrategy { Canceled = 0, DefaultSetup = 1, SetupWithoutEnterpriseProvider = 2, SetupWithEnterpriseProvider = 3 } interface IChatSetupResult { readonly success: boolean | undefined; readonly dialogSkipped: boolean; } class ChatSetup { private static instance: ChatSetup | undefined = undefined; static getInstance(instantiationService: IInstantiationService, context: ChatEntitlementContext, controller: Lazy): ChatSetup { let instance = ChatSetup.instance; if (!instance) { instance = ChatSetup.instance = instantiationService.invokeFunction(accessor => { return new ChatSetup(context, controller, instantiationService, accessor.get(ITelemetryService), accessor.get(IContextMenuService), accessor.get(IWorkbenchLayoutService), accessor.get(IKeybindingService), accessor.get(IChatEntitlementService), accessor.get(ILogService), accessor.get(IConfigurationService)); }); } return instance; } private pendingRun: Promise | undefined = undefined; private skipDialogOnce = false; private constructor( private readonly context: ChatEntitlementContext, private readonly controller: Lazy, @IInstantiationService private readonly instantiationService: IInstantiationService, @ITelemetryService private readonly telemetryService: ITelemetryService, @IContextMenuService private readonly contextMenuService: IContextMenuService, @ILayoutService private readonly layoutService: IWorkbenchLayoutService, @IKeybindingService private readonly keybindingService: IKeybindingService, @IChatEntitlementService private readonly chatEntitlementService: IChatEntitlementService, @ILogService private readonly logService: ILogService, @IConfigurationService private readonly configurationService: IConfigurationService ) { } skipDialog(): void { this.skipDialogOnce = true; } async run(): Promise { if (this.pendingRun) { return this.pendingRun; } this.pendingRun = this.doRun(); try { return await this.pendingRun; } finally { this.pendingRun = undefined; } } private async doRun(): Promise { const dialogSkipped = this.skipDialogOnce; this.skipDialogOnce = false; let setupStrategy: ChatSetupStrategy; if (dialogSkipped || this.chatEntitlementService.entitlement === ChatEntitlement.Pro || this.chatEntitlementService.entitlement === ChatEntitlement.Limited) { setupStrategy = ChatSetupStrategy.DefaultSetup; // existing pro/free users setup without a dialog } else { setupStrategy = await this.showDialog(); } if (setupStrategy === ChatSetupStrategy.DefaultSetup && ChatEntitlementRequests.providerId(this.configurationService) === defaultChat.enterpriseProviderId) { setupStrategy = ChatSetupStrategy.SetupWithEnterpriseProvider; // users with a configured provider go through provider setup } let success = undefined; try { switch (setupStrategy) { case ChatSetupStrategy.SetupWithEnterpriseProvider: success = await this.controller.value.setupWithProvider({ useEnterpriseProvider: true }); break; case ChatSetupStrategy.SetupWithoutEnterpriseProvider: success = await this.controller.value.setupWithProvider({ useEnterpriseProvider: false }); break; case ChatSetupStrategy.DefaultSetup: success = await this.controller.value.setup(); break; } } catch (error) { this.logService.error(\`[chat setup] Error during setup: ${toErrorMessage(error)}\`); success = false; } return { success, dialogSkipped }; } private async showDialog(): Promise { const disposables = new DisposableStore(); let result: ChatSetupStrategy | undefined = undefined; const buttons = \[this.getPrimaryButton(), localize('maybeLater', "Maybe Later")\]; const dialog = disposables.add(new Dialog( this.layoutService.activeContainer, this.getDialogTitle(), buttons, createWorkbenchDialogOptions({ type: 'none', icon: Codicon.copilotLarge, cancelId: buttons.length - 1, renderBody: body => body.appendChild(this.createDialog(disposables)), primaryButtonDropdown: { contextMenuProvider: this.contextMenuService, addPrimaryActionToDropdown: false, actions: \[ toAction({ id: 'setupWithProvider', label: localize('setupWithProvider', "Sign in with a {0} Account", defaultChat.providerName), run: () => result = ChatSetupStrategy.SetupWithoutEnterpriseProvider }), toAction({ id: 'setupWithEnterpriseProvider', label: localize('setupWithEnterpriseProvider', "Sign in with a {0} Account", defaultChat.enterpriseProviderName), run: () => result = ChatSetupStrategy.SetupWithEnterpriseProvider }), ] } }, this.keybindingService, this.layoutService) )); const { button } = await dialog.show(); disposables.dispose(); return button === 0 ? result ?? ChatSetupStrategy.DefaultSetup : ChatSetupStrategy.Canceled; } private getPrimaryButton(): string { if (this.context.state.entitlement === ChatEntitlement.Unknown) { return localize('signInButton', "Sign in"); } return localize('useCopilotButton', "Use Copilot"); } private getDialogTitle(): string { if (this.context.state.entitlement === ChatEntitlement.Unknown) { return this.context.state.registered ? localize('signUp ``` -------------------------------- ### Create Chat Setup Dialog UI Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/parser/test/node/fixtures/chatSetup.ts.getStructure.html Constructs the HTML dialog element for Copilot setup, including header, terms, and privacy settings using Markdown rendering. ```typescript private createDialog(disposables: DisposableStore): HTMLElement { const element = $('.chat-setup-dialog'); const markdown = this.instantiationService.createInstance(MarkdownRenderer, {}); // Header const header = localize({ key: 'headerDialog', comment: ['{Locked="[Copilot]({0})"}'] }, "[Copilot]({0}) is your AI pair programmer. Write code faster with completions, fix bugs and build new features across multiple files, and learn about your codebase through chat.", defaultChat.documentationUrl); element.appendChild($('p.setup-header', undefined, disposables.add(markdown.render(new MarkdownString(header, { isTrusted: true }))).element)); // Terms const terms = localize({ key: 'terms', comment: ['{Locked="["}', '{Locked="]({0})"}', '{Locked="]({1})"}'] }, "By continuing, you agree to the [Terms]({0}) and [Privacy Policy]({1}).", defaultChat.termsStatementUrl, defaultChat.privacyStatementUrl); element.appendChild($('p.setup-legal', undefined, disposables.add(markdown.render(new MarkdownString(terms, { isTrusted: true }))).element)); // SKU Settings if (this.telemetryService.telemetryLevel !== TelemetryLevel.NONE) { const settings = localize({ key: 'settings', comment: ['{Locked="["}', '{Locked="]({0})"}', '{Locked="]({1})"}'] }, "Copilot Free and Pro may show [public code]({0}) suggestions and we may use your data for product improvement. You can change these [settings]({1}) at any time.", defaultChat.publicCodeMatchesUrl, defaultChat.manageSettingsUrl); element.appendChild($('p.setup-settings', undefined, disposables.add(markdown.render(new MarkdownString(settings, { isTrusted: true }))).element)); } return element; } ``` -------------------------------- ### PreToolUse Hook Output Example Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/assets/prompts/skills/agent-customization/references/hooks.md Example output for the PreToolUse hook event. This specifies permission decisions and reasons for user confirmation. ```json { "hookSpecificOutput": { "hookEventName": "PreToolUse", "permissionDecision": "ask", "permissionDecisionReason": "Needs user confirmation" } } ``` -------------------------------- ### Start Jaeger Docker Container Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/docs/monitoring/agent_monitoring.md Run this command to start a Jaeger Docker container, exposing the necessary ports for OTLP ingestion and the Jaeger UI. ```bash docker run -d --name jaeger -p 16686:16686 -p 4318:4318 jaegertracing/jaeger:latest ``` -------------------------------- ### PreToolUse Hook Output Example Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/assets/prompts/skills/agent-customization/references/hooks.md Example of the expected JSON output from a hook during the PreToolUse event, specifying permission decisions. ```APIDOC ## Input / Output Contract Hooks receive JSON on stdin and can return JSON on stdout. - Common output: `continue`, `stopReason`, `systemMessage` - `PreToolUse` permissions are read from `hookSpecificOutput.permissionDecision` (`allow` | `ask` | `deny`) - `PostToolUse` output can block further processing with `decision: block` `PreToolUse` example output: ```json { "hookSpecificOutput": { "hookEventName": "PreToolUse", "permissionDecision": "ask", "permissionDecisionReason": "Needs user confirmation" } } ``` Exit codes: - `0` success - `2` blocking error - Other values produce non-blocking warnings ``` -------------------------------- ### Start Aspire Dashboard Container Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/docs/monitoring/agent_monitoring.md Launches the Aspire Dashboard container to serve as a local OTLP endpoint for trace visualization. ```bash docker run --rm -d \ -p 18888:18888 \ -p 4317:18889 \ --name aspire-dashboard \ mcr.microsoft.com/dotnet/aspire-dashboard:latest ``` -------------------------------- ### Execute Pipeline Usage Example Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/notebook/test/node/fixtures/large_cell_after.ipynb Demonstrates how to invoke the pipeline function and retrieve the resulting DataFrame. ```python # 3. Usage Example df_pipeline = run_pipeline() df_pipeline ``` -------------------------------- ### Start OTel Collector for Azure Application Insights Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/docs/monitoring/agent_monitoring.md Configures the connection string and launches the OTel collector using Docker Compose. ```bash export APPLICATIONINSIGHTS_CONNECTION_STRING="InstrumentationKey=...;IngestionEndpoint=..." cd docs/monitoring docker compose up -d ``` -------------------------------- ### Configure a Command Hook Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/assets/prompts/skills/agent-customization/references/hooks.md Example of configuring a command hook to run a script before tool use. Specify the command, timeout, and platform-specific overrides if needed. ```json { "hooks": { "PreToolUse": [ { "type": "command", "command": "./scripts/validate-tool.sh", "timeout": 15 } ] } } ``` -------------------------------- ### copilot.tests.getSetupConfirmation Command Source: https://github.com/microsoft/vscode-copilot-chat/wiki/Package.json-Copilot-Contributions Details the `copilot.tests.getSetupConfirmation` command, used for confirming test setup or when no tests are initially present. ```APIDOC ## `copilot.tests.getSetupConfirmation(uri?: vscode.Uri)` Command ### Description This command ID is called by Copilot in two primary scenarios: 1. When the `/tests` command is run and no tests are detected in the workspace. 2. As the final step following a `/setupTests` invocation. Extensions should implement this command to guide the user through test confirmation or initial setup. ### Method Command Execution (Invoked by Copilot) ### Endpoint N/A (Command ID) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Return Value Extensions should return an object conforming to the `ReturnValue` schema: ```ts type ReturnValue = { message: string; command: vscode.Command; } | undefined; ``` - **message** (string): A message presented to the user, for example, "Confirm your Python testing framework to enable test discovery.". Note that Copilot may rephrase this message. - **command** (vscode.Command): A command that will be available to the user as a button, allowing them to proceed with the suggested action. ### Request Example N/A (Command invocation) ### Response #### Success Response (200) N/A (Command return value) #### Response Example ```json { "message": "Confirm your Python testing framework to enable test discovery.", "command": { "command": "myExtension.confirmTestFramework", "title": "Confirm Framework" } } ``` ``` -------------------------------- ### Log session start events Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/assets/prompts/skills/troubleshoot/SKILL.md Records metadata at the beginning of a session, such as version information. ```jsonl {"ts":1773200251300,"dur":0,"sid":"62f52dec","type":"session_start","name":"session_start","spanId":"session-start-62f52dec","status":"ok","attrs":{"copilotVersion":"0.43.2026033104","vscodeVersion":"1.99.0"}} ``` -------------------------------- ### Define Tool Arguments for Invocation Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/test/simulation/tools/README.md Example of specifying a tool name and its arguments for direct invocation within the harness. ```jsonc { "tool": "read_file", "args": { "files": [ { "filePath": "./test/testFile1.ts" } ] } } ``` -------------------------------- ### Verify .NET Version Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/extension/mcp/test/vscode-node/fixtures/snapshots/nuget-readme.md Run this command in your terminal to check your installed .NET version. The MCP server requires .NET 10 Preview 6 or later. ```bash dotnet --info ``` -------------------------------- ### Hide Chat Setup Action Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/parser/test/node/fixtures/chatSetup.ts.getStructure.html Defines an action to hide the Copilot setup prompt. This action is available in the Chat Title Bar Menu when Copilot setup is not installed and not hidden. ```typescript class ChatSetupHideAction extends Action2 { static readonly ID = 'workbench.action.chat.hideSetup'; static readonly TITLE = localize2('hideChatSetup', "Hide Copilot"); constructor() { super({ id: ChatSetupHideAction.ID, title: ChatSetupHideAction.TITLE, f1: true, category: CHAT_CATEGORY, precondition: ContextKeyExpr.and(ChatContextKeys.Setup.installed.negate(), ChatContextKeys.Setup.hidden.negate()), menu: { id: MenuId.ChatTitleBarMenu, group: 'z_hide', order: 1, when: ChatContextKeys.Setup.installed.negate() } }); } override async run(accessor: ServicesAccessor): Promise { const viewsDescriptorService = accessor.get(IViewDescriptorService); const layoutService = accessor.get(IWorkbenchLayoutService); const dialogSer ``` -------------------------------- ### DLL Main Entry Point Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/parser/test/node/fixtures/dllmain.cpp.getStructure.html Handles initialization and cleanup for the DLL. It sets up logging, checks for Wine/DXVK, applies game quirks, and detects NVIDIA hardware. ```cpp BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { HMODULE handle = nullptr; switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: if (loadCount > 1) { LOG_INFO("DLL_PROCESS_ATTACH from module: {0:X}, count: {1}", (UINT64)hModule, loadCount); return TRUE; } dllModule = hModule; processId = GetCurrentProcessId(); DisableThreadLibraryCalls(hModule); if (Config::Instance()->FGType.value_or_default() == FGType::OptiFG && Config::Instance()->FGDisableOverlays.value_or_default()) SetEnvironmentVariable(L"SteamNoOverlayUIDrawing", L"1"); loadCount++; #ifdef VER_PRE_RELEASE // Enable file logging for pre builds Config::Instance()->LogToFile.set_volatile_value(true); // Set log level to debug if (Config::Instance()->LogLevel.value_or_default() > 1) Config::Instance()->LogLevel.set_volatile_value(1); #endif PrepareLogger(); spdlog::warn("{0} loaded", VER_PRODUCT_NAME); spdlog::warn("---------------------------------"); spdlog::warn("OptiScaler is freely downloadable from"); spdlog::warn("GitHub : https://github.com/cdozdil/OptiScaler/releases"); spdlog::warn("Nexus : https://www.nexusmods.com/site/mods/986"); spdlog::warn("If you paid for these files, you've been scammed!"); spdlog::warn("DO NOT USE IN MULTIPLAYER GAMES"); spdlog::warn(""); spdlog::warn("LogLevel: {0}", Config::Instance()->LogLevel.value_or_default()); // Check for Wine skipGetModuleHandle = true; spdlog::info(""); State::Instance().isRunningOnLinux = IsRunningOnWine(); State::Instance().isRunningOnDXVK = State::Instance().isRunningOnLinux; skipGetModuleHandle = false; // Temporary fix for Linux & DXVK if (State::Instance().isRunningOnDXVK || State::Instance().isRunningOnLinux) Config::Instance()->UseHQFont.set_volatile_value(false); spdlog::info(""); CheckQuirks(); // Check if real DLSS available if (Config::Instance()->DLSSEnabled.value_or_default()) { spdlog::info(""); State::Instance().isRunningOnNvidia = isNvidia(); if (State::Instance().isRunningOnNvidia) { spdlog::info("Running on Nvidia, setting DLSS as default upscaler and disabling spoofing options set to auto"); Config::Instance()->DLSSEnabled.set_volatile_value(true); if (!Config::Instance()->DxgiSpoofing.has_value()) Conf ``` -------------------------------- ### copilot.tests.setupTests Command Source: https://github.com/microsoft/vscode-copilot-chat/wiki/Package.json-Copilot-Contributions Details the `copilot.tests.setupTests` command, which allows extensions to provide a custom flow for setting up tests. ```APIDOC ## `copilot.tests.setupTests` Command ### Description This command ID is invoked by Copilot when a user initiates a test setup process using the `/setupTests` command. If this command is defined in the extension's `package.json`, it will be executed instead of the default Copilot test setup flow. Extensions should aim to keep the interaction within the panel chat, potentially by triggering the `workbench.action.chat.open` command. ### Method Command Execution (Invoked by Copilot) ### Endpoint N/A (Command ID) ### Return Value Extensions can return a `ReturnValue` object: ```ts type ReturnValue = { message: string; command?: vscode.Command; } | undefined; ``` - **message** (string): A message to be displayed to the user. - **command** (vscode.Command, optional): A command to be presented to the user as a button, offering an alternative to the default test setup flow. ``` -------------------------------- ### Copilot Integration in package.json Source: https://github.com/microsoft/vscode-copilot-chat/wiki/Package.json-Copilot-Contributions Define the 'copilot' section in your extension's package.json to configure Copilot Chat integration. This example shows how to specify a command ID for test setup confirmation. ```json { "name": "my-cool-extension", "copilot": { "tests": { "getSetupConfirmation": "my-cool-extension.setupConfirmationCommand" } } } ``` -------------------------------- ### Initializing FFX Vulkan Proxy Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/parser/test/node/fixtures/dllmain.cpp.getStructure.html Loads the amd_fidelityfx_vk.dll module and initializes the FFX Vulkan proxy. ```cpp ffxVkModule = nullptr; ffxVkModule = GetModuleHandle(L"amd_fidelityfx_vk.dll"); if (ffxVkModule != nullptr) { LOG_DEBUG("amd_fidelityfx_vk.dll already in memory"); FfxApiProxy::InitFfxVk(ffxVkModule); } } ``` -------------------------------- ### Configure Python Project with Setuptools Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/test/simulation/fixtures/notebook/fixing/fixing10.ipynb Use this snippet to define project metadata, version, author, dependencies, and optional features for your Python package. ```python from setuptools import setup setup( name="Demo", license="MIT", version="0.1.2", author_email="sebastien@eustace.io", url="https://github.com/demo/demo", packages=["demo"], platforms={'platform' : 8}, install_requires=["pendulum>=1.4.4"], extras_require={"foo": ["cleo"], "bar": ["tomlkit"]}, ) ``` -------------------------------- ### Import Data Libraries Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/notebook/test/node/fixtures/data_processing_before.ipynb Initializes the environment with pandas and numpy. ```python import pandas as pd import numpy as np ``` -------------------------------- ### Initializing NVNGX Proxy Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/parser/test/node/fixtures/dllmain.cpp.getStructure.html Loads either \'_nvngx.dll\' or \'nvngx.dll\' and initializes the NVNGX proxy. ```cpp nvngxModule = nullptr; nvngxModule = GetModuleHandle(L"\_nvngx.dll"); if (nvngxModule == nullptr) nvngxModule = GetModuleHandle(L"nvngx.dll"); if (nvngxModule != nullptr) { LOG_DEBUG("nvngx.dll already in memory"); NVNGXProxy::InitNVNGX(nvngxModule); } } ``` -------------------------------- ### Register URL Link Handler for Chat Setup Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/parser/test/node/fixtures/chatSetup.ts.getStructure.html Registers a handler for specific URL schemes to manage chat setup deep links. It validates the URL scheme and authority, logs telemetry, and executes the chat setup command with provided parameters. ```typescript this._register(ExtensionUrlHandlerOverrideRegistry.registerHandler({ canHandleURL: url => { return url.scheme === this.productService.urlProtocol && equalsIgnoreCase(url.authority, defaultChat.chatExtensionId); }, handleURL: async url => { const params = new URLSearchParams(url.query); this.telemetryService.publicLog2('workbenchActionExecuted', { id: CHAT_SETUP_ACTION_ID, from: 'url', detail: params.get('referrer') ?? undefined }); await this.commandService.executeCommand(CHAT_SETUP_ACTION_ID, validateChatMode(params.get('mode'))); return true; } })); ``` -------------------------------- ### Agent File Format Example Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/extension/chatSessions/claude/CLAUDE_SESSION_USER_GUIDE.md Defines the structure for an agent configuration file using Markdown with YAML frontmatter. Specify agent name, description, model, and allowed tools. ```markdown --- name: test-writer description: "Writes comprehensive unit tests for TypeScript code" model: sonnet allowedTools: - Read - Grep - Glob - Edit - Write - Bash --- You are a test-writing specialist. When given a source file, analyze its exports and write comprehensive unit tests covering edge cases, error paths, and typical usage. Use Vitest as the test framework. ``` -------------------------------- ### Import Data Visualization Libraries Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/notebook/test/node/fixtures/data_visualization_after.ipynb Initializes the environment with pandas, matplotlib, and seaborn. ```python import pandas as pd import matplotlib.pyplot as plt import seaborn as sns ``` -------------------------------- ### DLL Entry Point and Initialization Logic Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/parser/test/node/fixtures/dllmain.cpp.getStructure.html Handles DLL process attachment, configuration of DLSS/FSR hooks, and cleanup during detachment. ```cpp ig::Instance()->DxgiSpoofing.set_volatile_value(false); isNvngxAvailable = true; } else { spdlog::info("Not running on Nvidia, disabling DLSS"); Config::Instance()->DLSSEnabled.set_volatile_value(false); } } if (!Config::Instance()->OverrideNvapiDll.has_value()) { spdlog::info("OverrideNvapiDll not set, setting it to: {}", !State::Instance().isRunningOnNvidia ? "true" : "false"); Config::Instance()->OverrideNvapiDll.set_volatile_value(!State::Instance().isRunningOnNvidia); } // Check for working mode and attach hooks spdlog::info(""); CheckWorkingMode(); spdlog::info(""); if (!State::Instance().nvngxExists && !Config::Instance()->DxgiSpoofing.has_value()) { LOG_WARN("No nvngx.dll found disabling spoofing!"); Config::Instance()->DxgiSpoofing.set_volatile_value(false); } spdlog::info(""); handle = GetModuleHandle(fsr2NamesW[0].c_str()); if (handle != nullptr) HookFSR2Inputs(handle); handle = GetModuleHandle(fsr2BENamesW[0].c_str()); if (handle != nullptr) HookFSR2Dx12Inputs(handle); spdlog::info(""); HookFSR2ExeInputs(); handle = GetModuleHandle(fsr3NamesW[0].c_str()); if (handle != nullptr) HookFSR3Inputs(handle); handle = GetModuleHandle(fsr3BENamesW[0].c_str()); if (handle != nullptr) HookFSR3Dx12Inputs(handle); HookFSR3ExeInputs(); //HookFfxExeInputs(); // Initial state of FSR-FG State::Instance().activeFgType = Config::Instance()->FGType.value_or_default(); for (size_t i = 0; i < 300; i++) { State::Instance().frameTimes.push_back(0.0f); State::Instance().upscaleTimes.push_back(0.0f); } spdlog::info(""); spdlog::info("Init done"); spdlog::info("---------------------------------------------"); spdlog::info(""); break; case DLL_PROCESS_DETACH: // Unhooking and cleaning stuff causing issues during shutdown. // Disabled for now to check if it cause any issues UnhookApis(); unhookStreamline(); unhookGdi32(); DetachHooks(); if (skHandle != nullptr) FreeLibrary(skHandle); if (reshadeHandle != nullptr) FreeLibrary(reshadeHandle); spdlog::info(""); spdlog::info("DLL_PROCESS_DETACH"); spdlog::info("Unloading OptiScaler"); CloseLogger(); break; case DLL_THREAD_ATTACH: LOG_DEBUG_ONLY("DLL_THREAD_ATTACH from module: {0:X}, count: {1}", (UINT64)hModule, loadCount); break; case DLL_THREAD_DETACH: LOG_DEBUG_ONLY("DLL_THREAD_DETACH from module: {0:X}, count: {1}", (UINT64)hModule, loadCount); break; default: LOG_WARN("Call reason: {0:X}", ul_reason_for_call); break; } return TRUE; } ``` -------------------------------- ### Initialize Sales DataFrame Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/notebook/test/node/fixtures/data_processing_before.ipynb Creates a sample DataFrame containing customer IDs, sales figures, and regions. ```python data = pd.DataFrame({ 'customer_id': [101, 102, 103], 'sales': [250.0, 130.0, 400.0], 'region': ['North', 'East', 'West'] }) data.head() ``` -------------------------------- ### Initializing FFX DX12 Proxy Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/platform/parser/test/node/fixtures/dllmain.cpp.getStructure.html Loads the amd_fidelityfx_dx12.dll module and initializes the FFX DX12 proxy. ```cpp ffxDx12Module = nullptr; ffxDx12Module = GetModuleHandle(L"amd_fidelityfx_dx12.dll"); if (ffxDx12Module != nullptr) { LOG_DEBUG("amd_fidelityfx_dx12.dll already in memory"); FfxApiProxy::InitFfxDx12(ffxDx12Module); } } ``` -------------------------------- ### Prompt Frontmatter Configuration Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/assets/prompts/skills/agent-customization/references/prompts.md Configure prompt metadata like description, name, argument hint, agent type, model, and tools. The 'description' field is recommended for discoverability. ```yaml --- description: "" name: "Prompt Name" argument-hint: "Task..." agent: "agent" model: "GPT-5 (copilot)" tools: [search, web] --- ``` -------------------------------- ### Get Chat Editing Session Entry Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/extension/tools/node/test/editFileToolUtilsFixtures/multi-sr-bug-actual.txt Retrieves a modified file entry from the session's entries based on a URI. Handles cell URIs by parsing them to get the notebook URI. ```typescript private _getEntry(uri: URI): IModifiedFileEntry | undefined { uri = CellUri.parse(uri)?.notebook ?? uri; return this._entriesObs.get().find(e => isEqual(e.modifiedURI, uri)); } public getEntry(uri: URI): IModifiedFileEntry | undefined { return this._getEntry(uri); } ``` -------------------------------- ### Bash Hook Script Example Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/extension/chatSessions/claude/CLAUDE_SESSION_USER_GUIDE.md A bash script to be used as a lifecycle hook. This example blocks the execution of Bash commands that use 'rm -rf' by checking the input and exiting with code 2. ```bash #!/bin/bash # .claude/hooks/safe-bash.sh INPUT=$(cat) COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command') if echo "$COMMAND" | grep -q "rm -rf"; then echo "Blocked: rm -rf is not allowed" >&2 exit 2 fi exit 0 ``` -------------------------------- ### Starting Streaming Edits with VS Code Copilot Chat Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/src/extension/tools/node/test/editFileToolUtilsFixtures/multi-sr-bug-original.txt Initiates the process for streaming edits to a resource. It uses a sequencer to manage the order of operations and handles the start of edits, including accessibility signals. ```typescript startStreamingEdits(resource: URI, responseModel: IChatResponseModel, inUndoStop: string | undefined): IStreamingEdits { const completePromise = new DeferredPromise(); const startPromise = new DeferredPromise(); // Sequence all edits made this this resource in this streaming edits instance, // and also sequence the resource overall in the rare (currently invalid?) case // that edits are made in parallel to the same resource, const sequencer = new ThrottledSequencer(15, 1000); sequencer.queue(() => startPromise.p); this._streamingEditLocks.queue(resource.toString(), async () => { if (!this.isDisposed) { await this._acceptStreamingEditsStart(responseModel, inUndoStop, resource); } startPromise.complete(); return completePromise.p; }); let didComplete = false; return { pushText: (edits, isLastEdits) => { sequencer.queue(async () => { if (!this.isDisposed) { await this._acceptEdits(resource, edits, isLastEdits, responseModel); } }); }, pushNotebookCellText: (cell, edits, isLastEdits) => { sequencer.queue(async () => { if (!this.isDisposed) { await this._acceptEdits(cell, edits, isLastEdits, responseModel); } }); }, pushNotebook: (edits, isLastEdits) => { sequencer.queue(async () => { if (!this.isDisposed) { await this._acceptEdits(resource, edits, isLastEdits, responseModel); } }); }, pushFileDelete: (uri) => { sequencer.queue(async () => { if (!this.isDisposed) { await this._acceptFileDelete(uri, responseModel); } }); }, pushFileCreate: (uri) => { sequencer.queue(async () => { if (!this.isDisposed) { await this._acceptFileCreate(uri, responseModel); } }); }, pushFileRename: (oldUri, newUri) => { sequencer.queue(async () => { if (!this.isDisposed) { await this._acceptFileRename(oldUri, newUri, responseModel); } }); }, complete: () => { if (didComplete) { return; } didComplete = true; sequencer.queue(async () => { if (!this.isDisposed) { ``` -------------------------------- ### copilot_chat.cloud.session.invoke Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/docs/monitoring/agent_monitoring.md Emitted when a cloud/remote agent session is started. ```APIDOC ## copilot_chat.cloud.session.invoke ### Description Emitted when a cloud/remote agent session is started. ### Attributes - **partner_agent** (string) - `copilot`, `claude`, or `codex` - **model** (string) - Model identifier - **request_id** (string) - Chat request identifier ``` -------------------------------- ### Get Number of Columns Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/test/scenarios/test-notebook-tools/Chipotle.solution.ipynb Retrieve the total number of columns in the DataFrame. ```python chipo.shape[1] ``` -------------------------------- ### Get Dataset Dimensions Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/test/scenarios/test-notebooks/Chipotle.solution.ipynb Retrieve the number of rows and columns in the DataFrame. ```python chipo.shape[0] ``` ```python chipo.shape[1] ``` -------------------------------- ### Log turn boundaries Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/assets/prompts/skills/troubleshoot/SKILL.md Marks the start and end of tool-calling loop iterations. ```jsonl {"ts":1773200251400,"dur":0,"sid":"62f52dec","type":"turn_start","name":"turn_start:0","spanId":"turn-start-X-0","status":"ok","attrs":{"turnId":"0"}} {"ts":1773200255000,"dur":0,"sid":"62f52dec","type":"turn_end","name":"turn_end:0","spanId":"turn-end-X-0","status":"ok","attrs":{"turnId":"0"}} ``` -------------------------------- ### Get Number of Observations Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/test/scenarios/test-notebook-tools/Chipotle.solution.ipynb Retrieve the total number of rows (observations) in the DataFrame. ```python chipo.shape[0] ``` -------------------------------- ### Create a pandas DataFrame Source: https://github.com/microsoft/vscode-copilot-chat/blob/main/test/simulation/fixtures/notebook/plot.ipynb Initializes a DataFrame from a dictionary. Requires the pandas library to be installed. ```python import pandas as pd # create a dataframe with sample data df = pd.DataFrame({'Name': ['Alice', 'Bob', 'Charlie'], 'Age': [25, 30, 35], 'Gender': ['F', 'M', 'M']}) print(df) ```