Class DefaultPromptFragmentCustomizationService

Implements

Constructors

Properties

activeCustomizations: Map<string, PromptFragmentCustomization> = ...

Contains the currently active customization, mapped by prompt fragment ID.

additionalTemplateDirs: Set<string> = ...

Stores additional directory paths for loading template files.

allCustomizations: Map<string, PromptFragmentCustomization> = ...

Tracks all loaded customizations, including overridden ones, mapped by source URI.

envVariablesServer: EnvVariablesServer
fileService: FileService
onDidChangeCustomAgents: Event<void> = ...

Event fired when custom agents are modified

onDidChangeCustomAgentsEmitter: Emitter<void> = ...
onDidChangePromptFragmentCustomization: Event<string[]> = ...

Event fired when a prompt fragment is changed

onDidChangePromptFragmentCustomizationEmitter: Emitter<string[]> = ...
openerService: OpenerService
preferences: AICorePreferences
templateExtensions: Set<string> = ...

Contains file extensions that identify prompt template files.

toDispose: DisposableCollection = ...

Collection of disposable resources for cleanup when the service updates or is disposed.

trackedTemplateURIs: Set<string> = ...

Stores URI strings of template files from directories currently being monitored for changes.

watchedFiles: Map<string, WatchedFileInfo> = ...

Maps URI strings to WatchedFileInfo objects for individually watched template files.

workspaceTemplateFiles: Set<string> = ...

Stores specific file paths, provided by the settings, that should be treated as templates.

Methods

  • Adds a template to the customizations map, handling conflicts based on priority

    Parameters

    • activeCustomizationsCopy: Map<string, PromptFragmentCustomization>

      The map to add the customization to

    • id: string

      The fragment ID

    • template: string

      The template content

    • sourceUri: string

      The URI of the source file (used to distinguish updates from conflicts)

    • allCustomizationsCopy: Map<string, PromptFragmentCustomization>

      The map to track all loaded customizations

    • priority: number

      The customization priority

    • origin: CustomizationSource

      The source type of the customization

    Returns void

  • Checks if the given file extension is registered as a prompt template extension

    Parameters

    • extension: string

      The file extension including the leading dot (e.g., '.prompttemplate')

    Returns boolean

    True if the extension is registered as a prompt template extension

  • Processes a directory for template files, adding them to the customizations map and setting up file watching

    Parameters

    • activeCustomizationsCopy: Map<string, PromptFragmentCustomization>

      Map to store active customizations

    • trackedTemplateURIsCopy: Set<string>

      Set to track URIs being monitored

    • allCustomizationsCopy: Map<string, PromptFragmentCustomization>

      Map to store all loaded customizations

    • dirURI: URI

      URI of the directory to process

    • priority: number

      Priority level for customizations in this directory

    • customizationSource: CustomizationSource

      Source type of the customization

    Returns Promise<void>

  • Process the template files specified by path, watching for changes and loading their content into the customizations map

    Parameters

    • activeCustomizationsCopy: Map<string, PromptFragmentCustomization>

      Map to store active customizations

    • trackedTemplateURIsCopy: Set<string>

      Set to track URIs being monitored

    • allCustomizationsCopy: Map<string, PromptFragmentCustomization>

      Map to store all loaded customizations

    • watchedFilesCopy: Map<string, WatchedFileInfo>

      Map to store file watch information

    Returns Promise<void>

  • Removes a customization from customizations maps based on the source URI. Also checks for any lower-priority customizations with the same ID that might need to be loaded.

    Parameters

    • sourceUri: string

      The URI of the source file being removed

    • allCustomizationsCopy: Map<string, PromptFragmentCustomization>

      The map of all loaded customizations

    • activeCustomizationsCopy: Map<string, PromptFragmentCustomization>

      The map of active customizations

    • trackedTemplateURIsCopy: Set<string>

      Optional set of tracked URIs to update

    Returns undefined | string

    The fragment ID that was removed, or undefined if no customization was found