diff --git a/package.json b/package.json index f6f27910..e43a8a6f 100644 --- a/package.json +++ b/package.json @@ -514,7 +514,9 @@ "displayName": "Get Python Environment Information", "modelDescription": "Provides details about the Python environment for a specified file or workspace, including environment type, Python version, run command, and installed packages with their versions. Use this tool to determine the correct command for executing Python code in this workspace.", "toolReferenceName": "pythonGetEnvironmentInfo", - "tags": [], + "tags": [ + "ms-python.python" + ], "icon": "$(files)", "canBeReferencedInPrompt": true, "inputSchema": { @@ -533,9 +535,12 @@ { "name": "python_install_package", "displayName": "Install Python Package", + "userDescription": "Installs Python packages in the given workspace", "modelDescription": "Installs Python packages in the given workspace. Use this tool to install packages in the user's chosen environment.", "toolReferenceName": "pythonInstallPackage", - "tags": [], + "tags": [ + "ms-python.python" + ], "icon": "$(package)", "canBeReferencedInPrompt": true, "inputSchema": { @@ -607,4 +612,4 @@ "vscode-jsonrpc": "^9.0.0-next.5", "which": "^4.0.0" } -} +} \ No newline at end of file diff --git a/src/features/copilotTools.ts b/src/features/copilotTools.ts index 257d6a24..fc0891d9 100644 --- a/src/features/copilotTools.ts +++ b/src/features/copilotTools.ts @@ -1,5 +1,6 @@ import { CancellationToken, + l10n, LanguageModelTextPart, LanguageModelTool, LanguageModelToolInvocationOptions, @@ -130,9 +131,8 @@ export class GetEnvironmentInfoTool implements LanguageModelTool, _token: CancellationToken, ): Promise { - const message = 'Preparing to fetch Python environment information...'; return { - invocationMessage: message, + invocationMessage: l10n.t('Fetching Python environment information'), }; } } @@ -242,13 +242,46 @@ export class InstallPackageTool implements LanguageModelTool, _token: CancellationToken, ): Promise { - const packageList = options.input.packageList || []; - const packageCount = packageList.length; - const packageText = packageCount === 1 ? 'package' : 'packages'; - const message = `Preparing to install Python ${packageText}: ${packageList.join(', ')}...`; + const workspacePath = options.input.resourcePath ? Uri.file(options.input.resourcePath) : undefined; + + const packageCount = options.input.packageList.length; + let envName = ''; + try { + const environment = await this.api.getEnvironment(workspacePath); + envName = environment?.displayName || ''; + } catch { + // + } + + let title = ''; + let invocationMessage = ''; + const message = + packageCount === 1 + ? '' + : l10n.t(`The following packages will be installed: {0}`, options.input.packageList.sort().join(', ')); + if (envName) { + title = + packageCount === 1 + ? l10n.t(`Install {0} in {1}?`, options.input.packageList[0], envName) + : l10n.t(`Install packages in {0}?`, envName); + invocationMessage = + packageCount === 1 + ? l10n.t(`Installing {0} in {1}`, options.input.packageList[0], envName) + : l10n.t(`Installing packages {0} in {1}`, options.input.packageList.sort().join(', '), envName); + } else { + title = + options.input.packageList.length === 1 + ? l10n.t(`Install Python package '{0}'?`, options.input.packageList[0]) + : l10n.t(`Install Python packages?`); + invocationMessage = + packageCount === 1 + ? l10n.t(`Installing Python package '{0}'`, options.input.packageList[0]) + : l10n.t(`Installing Python packages: {0}`, options.input.packageList.sort().join(', ')); + } return { - invocationMessage: message, + confirmationMessages: { title, message }, + invocationMessage, }; } }