1
>
/*---------------------------------------------------------------------------------------------
config.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import type { IConfigurationService } from '../../../../../../platform/configuration/common/configuration.js';
7
>
import { URI } from '../../../../../../base/common/uri.js';
8
>
import { PromptFileSource, PromptsType } from '../promptTypes.js';
9
>
import { getPromptFileDefaultLocations, IPromptSourceFolder } from './promptFileLocations.js';
10
>
import { PromptsStorage } from '../service/promptsService.js';
11
>
12
>
/**
13
>
* Configuration helper for the `reusable prompts` feature.
14
>
* @see {@link PromptsConfig.PROMPT_LOCATIONS_KEY}, {@link PromptsConfig.INSTRUCTIONS_LOCATION_KEY}, {@link PromptsConfig.MODE_LOCATION_KEY}, or {@link PromptsConfig.PROMPT_FILES_SUGGEST_KEY}.
15
>
*
16
>
* ### Functions
17
>
*
18
>
* - {@link getLocationsValue} allows to current read configuration value
19
>
* - {@link promptSourceFolders} gets list of source folders for prompt files
20
>
* - {@link getPromptFilesRecommendationsValue} gets prompt file recommendation configuration
21
>
*
22
>
* ### File Paths Resolution
23
>
*
24
>
* We resolve only `*.prompt.md` files inside the resulting source folders. Relative paths are resolved
25
>
* relative to:
26
>
*
27
>
* - the current workspace `root`, if applicable, in other words one of the workspace folders
28
>
* can be used as a prompt files source folder
29
>
* - root of each top-level folder in the workspace (if there are multiple workspace folders)
30
>
* - current root folder (if a single folder is open)
31
>
*
32
>
* ### Prompt File Suggestions
33
>
*
34
>
* The `chat.promptFilesRecommendations` setting allows configuring which prompt files to suggest in different contexts:
35
>
*
36
>
* ```json
37
>
* {
38
>
* "chat.promptFilesRecommendations": {
39
>
* "plan": true, // Always suggest
40
>
* "new-page": "resourceExtname == .js", // Suggest for JavaScript files
41
>
* "draft-blog": "resourceLangId == markdown", // Suggest for Markdown files
42
>
* "debug": false // Never suggest
43
>
* }
44
>
* }
45
>
* ```
46
>
*/
47
>
export namespace PromptsConfig {
48
>
/**
49
>
* Configuration key for the locations of reusable prompt files.
50
>
*/
51
>
export const PROMPT_LOCATIONS_KEY = 'chat.promptFilesLocations';
52
>
53
>
/**
54
>
* Configuration key for the locations of instructions files.
55
>
*/
56
>
export const INSTRUCTIONS_LOCATION_KEY = 'chat.instructionsFilesLocations';
57
>
/**
58
>
* Configuration key for the locations of mode files.
59
>
* @deprecated Use {@link AGENTS_LOCATION_KEY} instead
60
>
*/
61
>
export const MODE_LOCATION_KEY = 'chat.modeFilesLocations';
62
>
63
>
/**
64
>
* Configuration key for the locations of agent files (with simplified path support).
65
>
*/
66
>
export const AGENTS_LOCATION_KEY = 'chat.agentFilesLocations';
67
>
68
>
/**
69
>
* Configuration key for the locations of skill folders.
70
>
*/
71
>
export const SKILLS_LOCATION_KEY = 'chat.agentSkillsLocations';
72
>
73
>
/**
74
>
* Configuration key for the locations of hook files.
75
>
*/
76
>
export const HOOKS_LOCATION_KEY = 'chat.hookFilesLocations';
77
>
78
>
/**
79
>
* Configuration key for prompt file suggestions.
80
>
*/
81
>
export const PROMPT_FILES_SUGGEST_KEY = 'chat.promptFilesRecommendations';
82
>
83
>
/**
84
>
* Configuration key for use of the copilot instructions file.
85
>
*/
86
>
export const USE_COPILOT_INSTRUCTION_FILES = 'github.copilot.chat.codeGeneration.useInstructionFiles';
87
>
88
>
/**
89
>
* Configuration key for the AGENTS.md.
90
>
*/
91
>
export const USE_AGENT_MD = 'chat.useAgentsMdFile';
92
>
93
>
/**
94
>
* Configuration key for nested AGENTS.md files.
95
>
*/
96
>
export const USE_NESTED_AGENT_MD = 'chat.useNestedAgentsMdFiles';
97
>
98
>
/**
99
>
* Configuration key for the CLAUDE.md.
100
>
*/
101
>
export const USE_CLAUDE_MD = 'chat.useClaudeMdFile';
102
>
103
>
/**
104
>
* Configuration key for agent skills usage.
105
>
*/
106
>
export const USE_AGENT_SKILLS = 'chat.useAgentSkills';
107
>
108
>
/**
109
>
* Configuration key for chat hooks usage.
110
>
*/
111
>
export const USE_CHAT_HOOKS = 'chat.useHooks';
112
>
113
>
/**
114
>
* Configuration key for enabling Claude hooks.
115
>
*/
116
>
export const USE_CLAUDE_HOOKS = 'chat.useClaudeHooks';
117
>
118
>
/**
119
>
* Configuration key for enabling stronger skill adherence prompt (experimental).
120
>
*/
121
>
export const USE_SKILL_ADHERENCE_PROMPT = 'chat.experimental.useSkillAdherencePrompt';
122
>
123
>
/**
124
>
* Configuration key for including applying instructions.
125
>
*/
126
>
export const INCLUDE_APPLYING_INSTRUCTIONS = 'chat.includeApplyingInstructions';
127
>
128
>
/**
129
>
* Configuration key for including referenced instructions.
130
>
*/
131
>
export const INCLUDE_REFERENCED_INSTRUCTIONS = 'chat.includeReferencedInstructions';
132
>
133
>
/**
134
>
* Search for configuration files in parent repositories of the workspace folder
135
>
*/
136
>
export const USE_CUSTOMIZATIONS_IN_PARENT_REPOS = 'chat.useCustomizationsInParentRepositories';
137
>
138
>
/**
139
>
* Get value of the `reusable prompt locations` configuration setting.
140
>
* @see {@link PROMPT_LOCATIONS_CONFIG_KEY}, {@link INSTRUCTIONS_LOCATIONS_CONFIG_KEY}, {@link MODE_LOCATIONS_CONFIG_KEY}, {@link SKILLS_LOCATION_KEY}.
141
>
*/
142
>
export function getLocationsValue(configService: IConfigurationService, type: PromptsType): Record<string, boolean> | undefined {
143
const key = getPromptFileLocationsConfigKey(type);
144
const configValue = configService.getValue(key);