From 6316bbf9afe7d31be44ecfc345de120fe1ddeeb5 Mon Sep 17 00:00:00 2001 From: Oleg Solomko Date: Thu, 30 Jan 2025 17:55:37 -0800 Subject: [PATCH 1/3] [config]: improve setting description and add examples --- .../contrib/chat/browser/chat.contribution.ts | 11 ++--- .../chat/common/promptSyntax/config.ts | 47 +++++++++++++++++-- 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/src/vs/workbench/contrib/chat/browser/chat.contribution.ts b/src/vs/workbench/contrib/chat/browser/chat.contribution.ts index cf1d9b2ebf817..269b6536eab8b 100644 --- a/src/vs/workbench/contrib/chat/browser/chat.contribution.ts +++ b/src/vs/workbench/contrib/chat/browser/chat.contribution.ts @@ -154,14 +154,9 @@ configurationRegistry.registerConfiguration({ default: true }, [PromptFilesConfig.CONFIG_KEY]: { - type: ['string', 'array', 'object', 'boolean', 'null'], - title: nls.localize('chat.promptFiles.setting.title', "Prompt Files"), - markdownDescription: nls.localize( - 'chat.promptFiles.setting.markdownDescription', - "Enable support for attaching reusable prompt files (`*{0}`) for Chat, Edits, and Inline Chat sessions. [Learn More]({1}).", - '.prompt.md', - PromptFilesConfig.DOCUMENTATION_URL, - ), + type: ['boolean', 'object', 'array', 'string', 'null'], + title: PromptFilesConfig.CONFIG_TITLE, + markdownDescription: PromptFilesConfig.CONFIG_DESCRIPTION, default: null, tags: ['experimental'], }, diff --git a/src/vs/workbench/contrib/chat/common/promptSyntax/config.ts b/src/vs/workbench/contrib/chat/common/promptSyntax/config.ts index 1fa52b8fea9b0..60344c9cbfd4a 100644 --- a/src/vs/workbench/contrib/chat/common/promptSyntax/config.ts +++ b/src/vs/workbench/contrib/chat/common/promptSyntax/config.ts @@ -3,6 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import * as nls from '../../../../../nls.js'; +import { PROMPT_SNIPPET_FILE_EXTENSION } from './contentProviders/promptContentsProviderBase.js'; import { IConfigurationService } from '../../../../../platform/configuration/common/configuration.js'; /** @@ -21,21 +23,21 @@ import { IConfigurationService } from '../../../../../platform/configuration/com * (see {@link DEFAULT_LOCATION}): * ```json * { - * "chat.experimental.promptSnippets": true, + * "chat.promptFiles": true, * } * ``` * * Enable the feature, specifying a single prompt files source folder location: * ```json * { - * "chat.experimental.promptSnippets": '.github/prompts', + * "chat.promptFiles": '.github/prompts', * } * ``` * * Enable the feature, specifying multiple prompt files source folder location: * ```json * { - * "chat.experimental.promptSnippets": { + * "chat.promptFiles": { * ".github/prompts" : true, * ".copilot/prompts" : false, * "/Users/legomushroom/repos/prompts" : true, @@ -46,7 +48,7 @@ import { IConfigurationService } from '../../../../../platform/configuration/com * Enable the feature, specifying multiple prompt files source folder location: * ```json * { - * "chat.experimental.promptSnippets": [ + * "chat.promptFiles": [ * ".github/prompts", * ".copilot/prompts", * "/Users/legomushroom/repos/prompts", @@ -64,7 +66,7 @@ import { IConfigurationService } from '../../../../../platform/configuration/com * (see {@link DEFAULT_LOCATION}): * ```json * { - * "chat.experimental.promptSnippets": {}, + * "chat.promptFiles": {}, * } * ``` * @@ -213,6 +215,41 @@ export namespace PromptFilesConfig { return DEFAULT_LOCATION; }; + + const localizationID = `${CONFIG_KEY}.config`; + const descriptionLocalizationID = `${localizationID}.description`; + const usageExample1 = nls.localize( + `${descriptionLocalizationID}.example1`, + "Enable with the default location of the prompt files (`{0}`):\n{1}", + DEFAULT_LOCATION[0], + `\`\`\`json\n{\n "${CONFIG_KEY}": true,\n}\n\`\`\``, + ); + const usageExample2 = nls.localize( + `${descriptionLocalizationID}.example2`, + "Specify custom location(s) of the prompt files:\n{0}", + `\`\`\`json\n{\n "${CONFIG_KEY}": {\n ".github/prompts": true,\n "/Users/vscode/prompts": true,\n}\n\`\`\``, + ); + + /** + * Configuration setting description to use in the settings UI. + */ + export const CONFIG_DESCRIPTION = nls.localize( + descriptionLocalizationID, + "Enable support for attaching reusable prompt files (`*{0}`) for Chat, Edits, and Inline Chat sessions. [Learn More]({1}).\n\nSet to `true` or use the `{ \"/path/to/folder\": boolean }` notation to specify a different path (or a couple of them). Relative paths are resolved from the root folder(s) of your workspace, and the default value of `{2}` is used if no other paths provided.\n### Examples\n{3}\n{4}", + PROMPT_SNIPPET_FILE_EXTENSION, + DOCUMENTATION_URL, + DEFAULT_LOCATION[0], + usageExample1, + usageExample2, + ); + + /** + * Configuration setting title to use in the settings UI. + */ + export const CONFIG_TITLE = nls.localize( + `${localizationID}.title`, + "Prompt Files", + ); } /** From bd43946a62716a3eb13fc3779d07ee5f6dae5fbc Mon Sep 17 00:00:00 2001 From: Oleg Solomko Date: Fri, 31 Jan 2025 09:13:23 -0800 Subject: [PATCH 2/3] [config]: fix localization ID compilation issue --- .../contrib/chat/common/promptSyntax/config.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/contrib/chat/common/promptSyntax/config.ts b/src/vs/workbench/contrib/chat/common/promptSyntax/config.ts index 60344c9cbfd4a..0266398d2cfdd 100644 --- a/src/vs/workbench/contrib/chat/common/promptSyntax/config.ts +++ b/src/vs/workbench/contrib/chat/common/promptSyntax/config.ts @@ -216,16 +216,14 @@ export namespace PromptFilesConfig { return DEFAULT_LOCATION; }; - const localizationID = `${CONFIG_KEY}.config`; - const descriptionLocalizationID = `${localizationID}.description`; const usageExample1 = nls.localize( - `${descriptionLocalizationID}.example1`, + `chat.promptFiles.config.description.example1`, "Enable with the default location of the prompt files (`{0}`):\n{1}", DEFAULT_LOCATION[0], `\`\`\`json\n{\n "${CONFIG_KEY}": true,\n}\n\`\`\``, ); const usageExample2 = nls.localize( - `${descriptionLocalizationID}.example2`, + `chat.promptFiles.config.description.example2`, "Specify custom location(s) of the prompt files:\n{0}", `\`\`\`json\n{\n "${CONFIG_KEY}": {\n ".github/prompts": true,\n "/Users/vscode/prompts": true,\n}\n\`\`\``, ); @@ -234,7 +232,7 @@ export namespace PromptFilesConfig { * Configuration setting description to use in the settings UI. */ export const CONFIG_DESCRIPTION = nls.localize( - descriptionLocalizationID, + 'chat.promptFiles.config.description', "Enable support for attaching reusable prompt files (`*{0}`) for Chat, Edits, and Inline Chat sessions. [Learn More]({1}).\n\nSet to `true` or use the `{ \"/path/to/folder\": boolean }` notation to specify a different path (or a couple of them). Relative paths are resolved from the root folder(s) of your workspace, and the default value of `{2}` is used if no other paths provided.\n### Examples\n{3}\n{4}", PROMPT_SNIPPET_FILE_EXTENSION, DOCUMENTATION_URL, @@ -247,7 +245,7 @@ export namespace PromptFilesConfig { * Configuration setting title to use in the settings UI. */ export const CONFIG_TITLE = nls.localize( - `${localizationID}.title`, + `chat.promptFiles.config.title`, "Prompt Files", ); } From cf25b57a4490732feeda55cf43ffb626298bd0c2 Mon Sep 17 00:00:00 2001 From: Oleg Solomko Date: Fri, 31 Jan 2025 12:54:01 -0800 Subject: [PATCH 3/3] [config]: update the `Examples` header level to h4 --- src/vs/workbench/contrib/chat/common/promptSyntax/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/chat/common/promptSyntax/config.ts b/src/vs/workbench/contrib/chat/common/promptSyntax/config.ts index 0266398d2cfdd..51eb7333f07a7 100644 --- a/src/vs/workbench/contrib/chat/common/promptSyntax/config.ts +++ b/src/vs/workbench/contrib/chat/common/promptSyntax/config.ts @@ -233,7 +233,7 @@ export namespace PromptFilesConfig { */ export const CONFIG_DESCRIPTION = nls.localize( 'chat.promptFiles.config.description', - "Enable support for attaching reusable prompt files (`*{0}`) for Chat, Edits, and Inline Chat sessions. [Learn More]({1}).\n\nSet to `true` or use the `{ \"/path/to/folder\": boolean }` notation to specify a different path (or a couple of them). Relative paths are resolved from the root folder(s) of your workspace, and the default value of `{2}` is used if no other paths provided.\n### Examples\n{3}\n{4}", + "Enable support for attaching reusable prompt files (`*{0}`) for Chat, Edits, and Inline Chat sessions. [Learn More]({1}).\n\nSet to `true` or use the `{ \"/path/to/folder\": boolean }` notation to specify a different path (or a couple of them). Relative paths are resolved from the root folder(s) of your workspace, and the default value of `{2}` is used if no other paths provided.\n#### Examples\n{3}\n{4}", PROMPT_SNIPPET_FILE_EXTENSION, DOCUMENTATION_URL, DEFAULT_LOCATION[0],