Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@
"Failed to delete file: {0}": "Failed to delete file: {0}",
"Failed to delete item \"{0}\".": "Failed to delete item \"{0}\".",
"Failed to delete secrets for item \"{0}\".": "Failed to delete secrets for item \"{0}\".",
"Failed to deploy LLM instruction files: {0}": "Failed to deploy LLM instruction files: {0}",
"Failed to extract the account endpoint from the selected node.": "Failed to extract the account endpoint from the selected node.",
"Failed to extract the connection string from the selected account.": "Failed to extract the connection string from the selected account.",
"Failed to find a matching Azure Resources API for version \"{0}\".": "Failed to find a matching Azure Resources API for version \"{0}\".",
Expand Down Expand Up @@ -614,7 +613,6 @@
"No history": "No history",
"No index metrics available": "No index metrics available",
"No language models available. Please ensure you have access to Copilot.": "No language models available. Please ensure you have access to Copilot.",
"No LLM instructions (.md) files found to copy": "No LLM instructions (.md) files found to copy",
"No location selected. Please pick a location before provisioning.": "No location selected. Please pick a location before provisioning.",
"No matching resources found.": "No matching resources found.",
"No properties available for filtering.": "No properties available for filtering.",
Expand Down Expand Up @@ -843,7 +841,6 @@
"Some sample items were not inserted successfully:": "Some sample items were not inserted successfully:",
"Some selected files are outside the workspace. Would you like to copy them to the migration project?": "Some selected files are outside the workspace. Would you like to copy them to the migration project?",
"Sorted by:": "Sorted by:",
"Source folder not found: {0}": "Source folder not found: {0}",
"Specified character lengths should be 1 character or greater.": "Specified character lengths should be 1 character or greater.",
"Start Migration": "Start Migration",
"Stats": "Stats",
Expand All @@ -863,7 +860,6 @@
"subscription": "subscription",
"Subscription: {0}": "Subscription: {0}",
"Subscription: {id}": "Subscription: {id}",
"Successfully copied {0} LLM instructions (.md) files": "Successfully copied {0} LLM instructions (.md) files",
"Successfully created resource group \"{0}\".": "Successfully created resource group \"{0}\".",
"Successfully created role assignment \"{0}\" for the {1} resource \"{2}\".": "Successfully created role assignment \"{0}\" for the {1} resource \"{2}\".",
"Successfully created storage account \"{0}\" with sku \"{1}\".": "Successfully created storage account \"{0}\" with sku \"{1}\".",
Expand Down Expand Up @@ -991,7 +987,6 @@
"Unexpected status code: {0}": "Unexpected status code: {0}",
"Unknown error": "Unknown error",
"Unknown Error": "Unknown Error",
"Unknown error occurred": "Unknown error occurred",
"Unknown migration command: {name}": "Unknown migration command: {name}",
"Unknown operation: {0}": "Unknown operation: {0}",
"Unsupported Account": "Unsupported Account",
Expand Down
15 changes: 0 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -480,16 +480,6 @@
"command": "cosmosDB.importDocument",
"title": "%cosmosdb.command.document.import%"
},
{
"category": "CosmosDB AI",
"command": "cosmosDB.ai.deployInstructionFiles",
"title": "%cosmosdb.command.ai.deploy_instruction_files%"
},
{
"category": "CosmosDB AI",
"command": "cosmosDB.ai.removeInstructionFiles",
"title": "%cosmosdb.command.ai.remove_instruction_files%"
},
{
"category": "Cosmos DB",
"command": "cosmosDB.deleteAllSavedSchemas",
Expand Down Expand Up @@ -914,11 +904,6 @@
"default": 6128,
"description": "%cosmosdb.configuration.cosmosDB.shell.mcp.port%"
},
"cosmosDB.manageLLMAssets": {
"type": "boolean",
"default": true,
"markdownDescription": "%cosmosdb.configuration.manage-llm-assets%"
},
"cosmosDB.queryEditor.generateSchemaBasedOnQueries": {
"type": "boolean",
"default": true,
Expand Down
Empty file removed resources/llm-assets/.gitkeep
Empty file.
10 changes: 0 additions & 10 deletions src/commands/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ import * as l10n from '@vscode/l10n';
import * as vscode from 'vscode';
import { CosmosDbChatParticipant } from '../chat';
import { doubleClickDebounceDelay } from '../constants';
import {
deployLLMInstructionsFiles,
removeLLMInstructionsFiles,
} from '../cosmosdb/commands/deployLLMInstructionsFiles';
import { ext } from '../extensionVariables';
import { QueryEditorTab } from '../panels/QueryEditorTab';
import { copyConnectionString } from './copyConnectionString/copyConnectionString';
Expand Down Expand Up @@ -82,7 +78,6 @@ export function registerCommands(): void {
registerCommandWithTreeNodeUnwrapping('azureDatabases.filterTreeItems', filterTreeItems);
registerCommandWithTreeNodeUnwrapping('azureDatabases.sortTreeItems', sortTreeItems);

registerLLMAssetsCommands();
registerChatButtonCommands();
registerMigrationCommands();
}
Expand Down Expand Up @@ -135,11 +130,6 @@ export function registerTriggerCommands() {
registerCommandWithTreeNodeUnwrapping('cosmosDB.deleteTrigger', cosmosDBDeleteTrigger);
}

export function registerLLMAssetsCommands() {
registerCommand('cosmosDB.ai.deployInstructionFiles', deployLLMInstructionsFiles);
registerCommand('cosmosDB.ai.removeInstructionFiles', removeLLMInstructionsFiles);
}

export function registerChatButtonCommands() {
// Command to apply the suggested query (update current editor)
// Note: Chat buttons pass arguments directly, so we use vscode.commands.registerCommand
Expand Down
70 changes: 70 additions & 0 deletions src/cosmosdb/commands/cleanupLLMInstructionsFiles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { callWithTelemetryAndErrorHandling } from '@microsoft/vscode-azext-utils';
import * as crypto from 'crypto';
import * as fs from 'fs';
import * as path from 'path';
import { ext } from '../../extensionVariables';

const LLM_ASSETS_MANIFEST_KEY = 'llm.assets.manifest';
const INSTRUCTIONS_FILENAME = 'azurecosmosdb.instructions.md';
const EXPECTED_MD5 = 'A54B319AD86975EB072A681AFA9CB553';

/**
* Cleans up the obsolete LLM instructions file that was previously deployed
* to the VS Code prompts folder by older versions of this extension.
*
* - Deletes the file only if its MD5 hash matches the known unmodified hash
* - Clears the obsolete manifest key from globalState
*
* This is idempotent and safe to call on every activation.
*/
export async function cleanupLLMInstructionsFiles(): Promise<void> {
await callWithTelemetryAndErrorHandling('cosmosDB.llmInstructions.cleanup', async (context) => {
context.errorHandling.suppressDisplay = true;
context.errorHandling.rethrow = false;

// Remove the file if it exists and hasn't been modified
const promptFolder = getPromptFolder();
const filePath = path.join(promptFolder, INSTRUCTIONS_FILENAME);

Comment thread
Copilot marked this conversation as resolved.
// Mask file paths from any error telemetry (fs errors often include paths)
context.valuesToMask.push(promptFolder, filePath);
const fileExists = fs.existsSync(filePath);
context.telemetry.properties.fileFound = String(fileExists);

if (fileExists) {
const content = fs.readFileSync(filePath);
const actualMd5 = crypto.createHash('md5').update(content).digest('hex').toUpperCase();
const md5Matched = actualMd5 === EXPECTED_MD5;
context.telemetry.properties.md5Matched = String(md5Matched);
ext.outputChannel.info(
`Found existing instructions file "${INSTRUCTIONS_FILENAME}" in prompts folder (md5Matched=${md5Matched})`,
);

if (md5Matched) {
fs.unlinkSync(filePath);
context.telemetry.properties.fileDeleted = String(true);
ext.outputChannel.info(
`Deleted obsolete instructions file "${INSTRUCTIONS_FILENAME}" from prompts folder`,
);
}
}

// Clear the obsolete manifest from globalState
await ext.context.globalState.update(LLM_ASSETS_MANIFEST_KEY, undefined);
});
}

/**
* Returns the VS Code user-level prompts folder, matching the path used
* by the old deployLLMInstructionsFiles logic.
*/
function getPromptFolder(): string {
const globalStorageUri = ext.context.globalStorageUri;
const userFolder = path.dirname(globalStorageUri.fsPath);
return path.join(userFolder, '..', 'prompts');
}
Loading
Loading