Skip to content

Move run in terminal tool to core #252650

Open
@Tyriar

Description

@Tyriar

Currently the run in terminal tool lives in the copilot chat repo, meaning all communication is done over the extension host API. This includes terminal tool specific proposed APIs such as PreparedTerminalToolInvocation and the overhead associated with them. I think we should move this tool to core as that way we don't need to incur the overhead of adding ext APIs for terminal-specific things (special terminal tool renderer and confirmation messages), don't need to work against the limitations of the ext API (eg. no terminal buffer API) and generally have a lot more control.

Here's an example of a tool in core:

export class InstallExtensionsTool implements IToolImpl {
constructor(
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
) { }
async prepareToolInvocation(context: IToolInvocationPreparationContext, token: CancellationToken): Promise<IPreparedToolInvocation | undefined> {
const parameters = context.parameters as InputParams;
return {
confirmationMessages: {
title: localize('installExtensionsTool.confirmationTitle', 'Install Extensions'),
message: new MarkdownString(localize('installExtensionsTool.confirmationMessage', "Review the suggested extensions and click the **Install** button for each extension you wish to add. Once you have finished installing the selected extensions, click **Continue** to proceed.")),
},
toolSpecificData: {
kind: 'extensions',
extensions: parameters.ids
}
};
}
async invoke(invocation: IToolInvocation, _countTokens: CountTokensCallback, _progress: ToolProgress, token: CancellationToken): Promise<IToolResult> {
const input = invocation.parameters as InputParams;
const installed = this.extensionsWorkbenchService.local.filter(e => input.ids.some(id => areSameExtensions({ id }, e.identifier)));
return {
content: [{
kind: 'text',
value: installed.length ? localize('installExtensionsTool.resultMessage', 'Following extensions are installed: {0}', installed.map(e => e.identifier.id).join(', ')) : localize('installExtensionsTool.noResultMessage', 'No extensions were installed.'),
}]
};
}
}

Metadata

Metadata

Assignees

Labels

chat-terminalThe run in terminal tool in chatdebtCode quality issues

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions