File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed
Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change 11import * as path from "path"
22import * as vscode from "vscode"
33import { promises as fs } from "fs"
4- import { modes , ModeConfig } from "../../../shared/modes"
4+ import { ModeConfig , getAllModesWithPrompts } from "../../../shared/modes"
55
66export async function getModesSection ( context : vscode . ExtensionContext ) : Promise < string > {
77 const settingsDir = path . join ( context . globalStorageUri . fsPath , "settings" )
88 await fs . mkdir ( settingsDir , { recursive : true } )
99 const customModesPath = path . join ( settingsDir , "cline_custom_modes.json" )
1010
11+ // Get all modes with their overrides from extension state
12+ const allModes = await getAllModesWithPrompts ( context )
13+
1114 return `====
1215
1316MODES
1417
15- - When referring to modes, always use their display names. The built-in modes are:
16- ${ modes . map ( ( mode : ModeConfig ) => ` * "${ mode . name } " mode - ${ mode . roleDefinition . split ( "." ) [ 0 ] } ` ) . join ( "\n" ) }
17- Custom modes will be referred to by their configured name property.
18+ - These are the currently available modes:
19+ ${ allModes . map ( ( mode : ModeConfig ) => ` * "${ mode . name } " mode (${ mode . slug } ) - ${ mode . roleDefinition . split ( "." ) [ 0 ] } ` ) . join ( "\n" ) }
1820
1921- Custom modes can be configured in two ways:
2022 1. Globally via '${ customModesPath } ' (created automatically on startup)
Original file line number Diff line number Diff line change 1+ import * as vscode from "vscode"
12import { TOOL_GROUPS , ToolGroup , ALWAYS_AVAILABLE_TOOLS } from "./tool-groups"
23
34// Mode types
@@ -239,6 +240,19 @@ export const defaultPrompts: Readonly<CustomModePrompts> = Object.freeze(
239240 ) ,
240241)
241242
243+ // Helper function to get all modes with their prompt overrides from extension state
244+ export async function getAllModesWithPrompts ( context : vscode . ExtensionContext ) : Promise < ModeConfig [ ] > {
245+ const customModes = ( await context . globalState . get < ModeConfig [ ] > ( "customModes" ) ) || [ ]
246+ const customModePrompts = ( await context . globalState . get < CustomModePrompts > ( "customModePrompts" ) ) || { }
247+
248+ const allModes = getAllModes ( customModes )
249+ return allModes . map ( ( mode ) => ( {
250+ ...mode ,
251+ roleDefinition : customModePrompts [ mode . slug ] ?. roleDefinition ?? mode . roleDefinition ,
252+ customInstructions : customModePrompts [ mode . slug ] ?. customInstructions ?? mode . customInstructions ,
253+ } ) )
254+ }
255+
242256// Helper function to safely get role definition
243257export function getRoleDefinition ( modeSlug : string , customModes ?: ModeConfig [ ] ) : string {
244258 const mode = getModeBySlug ( modeSlug , customModes )
You can’t perform that action at this time.
0 commit comments