ProtectedactiveProtectedadditionalStores additional directory paths for loading template files.
ProtectedallTracks all loaded customizations, including overridden ones, mapped by source URI.
ProtectedcustomBuilt-in parent directories scanned for custom agents (.agents, .prompts), independent of
additionalTemplateDirs. Insertion order is preserved so the first entry (.agents)
acts as the default location for newly created agents.
ProtectedcustomFor each known custom-agent prompt fragment id (i.e. <name>_prompt), the URI of the
agent's folder (<scope>/agents/<id>/). Populated as agents are loaded and used to
route customization writes/reads into the agent folder.
Protected ReadonlyenvProtected ReadonlyfileProtected ReadonlyinProtected ReadonlyloggerProtectedmigrationIn-flight migration promise used to serialize migrateCustomAgentsYaml calls.
Multiple sources (initial onStart, onDidChangeCustomAgents events from async template-dir
population) can request migration before the first run finishes; without serialization
they race on the same customAgents.yml, causing one rename to succeed and the others
to fail with ENOENT while concurrently moving fragment files clobber each other.
ReadonlyonEvent fired when custom agents are modified
Protected ReadonlyonReadonlyonEvent fired when a prompt fragment is changed
Protected ReadonlyonProtected ReadonlyopenerProtected ReadonlypreferencesProtectedtemplateContains file extensions that identify prompt template files.
ProtectedtoCollection of disposable resources for cleanup when the service updates or is disposed.
ProtectedtrackedStores URI strings of template files from directories currently being monitored for changes.
ProtectedwatchedMaps URI strings to WatchedFileInfo objects for individually watched template files.
Protected ReadonlyworkspaceProtectedworkspaceStores specific file paths, provided by the settings, that should be treated as templates.
ProtectedaddAdds a template to the customizations map, handling conflicts based on priority
The map to add the customization to
The fragment ID
The template content
The URI of the source file (used to distinguish updates from conflicts)
The map to track all loaded customizations
The customization priority
The source type of the customization
Optionalmetadata: CommandPromptFragmentMetadataOptional command metadata
ProtectedcleanupRemove <scopeDir>/agents/<id>/ directories that contain no agent.md. They are usually
the leftover side effect of a previous migration whose agent.md write failed after the
parent directory had already been created. Removing them lets the next run re-attempt.
Creates a customization based on a built-in fragment
The ID of the built-in fragment to customize
OptionaldefaultContent: stringOptional default content for the customization
Creates <parentDirectory>/agents/<id>/agent.md from a CustomAgentDescription and opens it.
The agent id determines the folder name; the prompt body is written verbatim under the YAML frontmatter.
Creates a new customization for a prompt fragment
The fragment ID to customize
OptionaldefaultContent: stringOptional default content for the customization
ProtecteddoEdits the built-in customization of a prompt fragment
The prompt fragment ID to edit
OptionaldefaultContent: stringOptional default content for the customization
Edits a specific customization of a prompt fragment
The prompt fragment ID
The customization ID to edit
ProtectededitEdits a template by opening it in the editor, creating it if it doesn't exist
The fragment ID
OptionaldefaultContent: stringOptional default content for new templates
ProtectedgenerateGenerates a unique customization ID based on the fragment ID, source URI, and priority
The fragment ID
The source URI of the template
A unique customization ID
Gets the active customized prompt fragment for a given ID
The prompt fragment ID
The active customized fragment or undefined if none exists
Gets the list of additional template directories that are being watched.
Array of directory paths
Gets all customizations for a prompt fragment ordered by priority
The prompt fragment ID
Array of customized fragments ordered by priority (highest first)
Gets all custom agent descriptions
Array of custom agent descriptions
ProtectedgetThe deduplicated parent directories scanned for custom agents, in precedence order:
the built-in customAgentDirs (.agents then .prompts) first, so .agents is both
the discovery winner and the default creation target; then any configured
additionalTemplateDirs that may also hold agents; then the global templates directory.
Independent of the prompt-templates preference, mirroring how skills resolve their folders.
Returns all locations of existing customAgents.yml files and agents/ directories,
plus the canonical locations where new agents would be created (one per scope). Scopes are
returned in precedence order, so the first agents-dir entry is the default creation target.
Gets the IDs of all prompt fragments that have customizations
Array of prompt fragment IDs
ProtectedgetThe additional (workspace) template directories as URIs, excluding any that resolves to the
same location as excluding (typically the global templates directory). A user can point
both the promptTemplates preference and a workspace template directory at the same path;
processing that scope twice would hide priority-1 customizations behind priority-2 copies
(see update) or list the same scope twice in the agent-location picker.
ProtectedgetExtract a fragment ID from a file path
The path to the template file
A fragment ID derived from the file name
ProtectedgetGets the fragment ID from a URI
URI to check
Fragment ID or undefined if not found
Gets information about the description of a customization
The fragment ID
The customization ID
Description of the customization
Gets information about the source/type of a customization
The fragment ID
The customization ID
Type of the customization source
Implementation of the generic getPromptFragmentIDFromResource method in the interface Accepts any resource identifier but only processes URIs
Resource to check
Fragment ID or undefined if not found
Gets the list of file extensions that are considered prompt templates.
Array of file extensions including the leading dot (e.g., '.prompttemplate')
Gets the list of specific template files that are being watched.
Array of file paths
ProtectedgetProtectedgetGets the URI for a specific template file
The fragment ID
URI for the template file
ProtectedhashSimple hash function to generate a short identifier from a string
The string to hash
A string hash
ProtectedinitProtectedisWhether a changed resource path affects custom agents, i.e. it is (or is inside) an agents/
directory, or a legacy customAgents.yml. Matches the agents directory itself (e.g. when the
whole folder is deleted), not only files within it, so removing agents/ triggers a reload.
The string form of the changed resource URI
PromptFragmentCustomizationService interface implementation
ProtectedisChecks if the given file extension is registered as a prompt template extension
The file extension including the leading dot (e.g., '.prompttemplate')
True if the extension is registered as a prompt template extension
ProtectedlistProtectedloadLoad custom agents from <parentDirectory>/agents/<id>/agent.md. Each immediate
subdirectory under agents/ defines one custom agent: the folder name is the
agent id (single source of truth), the file's YAML frontmatter holds the metadata,
and the body is the prompt text. Folders without a readable agent.md are skipped.
ProtectedloadProtectedmatchesAuto-migrate every legacy customAgents.yml reachable from the configured scopes to the new
agents/<id>/agent.md layout. The original content is never deleted:
customAgents.yml.bak, replacing any previous backup;customAgents.yml.bak only if no backup exists yet;
if one already exists the YAML is left in place, so the loader keeps serving it and the next
startup retries the migration.Idempotent: rerunning never overwrites an already-migrated agent file.
ProtectedmigrateUse createCustomAgentFile to author agents in the new
<scope>/agents/<id>/agent.md layout. Retained so existing UI affordances keep
working until they are migrated.
ProtectedopenOpens an in-memory resource with the given content, without creating a file on disk. The file is only created when the user saves in the editor.
ProtectedparseParses a template file that may contain YAML front matter
The raw file content
Parsed metadata and template content
ProtectedprocessScan <dirURI>/agents/<id>/*.prompttemplate files and register each as a customized
prompt fragment so they appear in the Prompt Fragments configuration view and so
editPromptFragmentCustomization / removePromptFragmentCustomization can find their
source URIs.
The reserved filename prompt.prompttemplate maps to the agent's default-variant
fragment id (<agent-name>_prompt read from the sibling agent.md's frontmatter).
Any other .prompttemplate file uses its filename stem as the fragment id (matching
how variants are registered via readCustomAgentPromptVariants).
ProtectedprocessProcesses a built-in custom-agent scope (.agents/.prompts): registers the prompt fragments
inside its agents/<id>/ folders and watches the scope for changes. Unlike
processTemplateDirectory it does not scan loose *.prompttemplate files in the scope
root, so .agents does not become a general prompt-template directory.
URI of the agent scope directory
Priority level for customizations in this scope
Source type of the customization
ProtectedprocessProcesses an existing directory for template files
Map to store active customizations
Set to track URIs being monitored
Map to store all loaded customizations
URI of the directory to process
Priority level for customizations in this directory
Source type of the customization
ProtectedprocessProcesses a directory for template files, adding them to the customizations map and setting up file watching
Map to store active customizations
Set to track URIs being monitored
Map to store all loaded customizations
URI of the directory to process
Priority level for customizations in this directory
Source type of the customization
ProtectedprocessProcess the template files specified by path, watching for changes and loading their content into the customizations map
Map to store active customizations
Set to track URIs being monitored
Map to store all loaded customizations
Map to store file watch information
ProtectedprovenanceExtracts a human-readable provenance label from a source URI. Returns the name of the workspace root that contains the file, falling back to the file's own base name if it is not inside any root.
ProtectedreadRead <agentFolderURI>/agent.md's frontmatter and return the implied default
fragment id (<name>_prompt). Returns undefined if the file is missing or invalid.
ProtectedreadProtectedreadScan an agent folder for sibling .prompttemplate files; each becomes a variant
of the agent's prompt. Variant id = filename stem (e.g. concise.prompttemplate
yields a variant with id concise). Files inside subdirectories are ignored.
The reserved filename prompt.prompttemplate is excluded: it represents the
default-variant customization (overrides agent.md's body), not an extra variant,
and is registered by the prompt-fragment customization scan instead.
Resets a fragment to its built-in version by removing all customizations
The fragment ID to reset
ProtectedremoveRemoves 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.
The URI of the source file being removed
The map of all loaded customizations
The map of active customizations
Optional set of tracked URIs to update
The fragment ID that was removed, or undefined if no customization was found
Removes a specific customization of a prompt fragment
The prompt fragment ID
The customization ID to remove
ProtectedremoveRemoves the prompt template extension from a filename
The filename with extension
The filename without the extension
Resets to a specific customization by removing higher-priority customizations
The fragment ID
The customization ID to reset to
ProtectedsetupSets up file watching for a template directory (works for both existing and non-existing directories)
URI of the directory to watch
Priority level for customizations in this directory
Source type of the customization
When true, only agents/<id>/ prompt files are registered on add; loose
*.prompttemplate files in the scope root are ignored. Used for built-in agent scopes
(.agents) that must not become general prompt-template directories.
ProtectedupdateUpdates the service by reloading all template files and watching for changes
Updates multiple configuration properties at once, triggering only a single update process.
An object containing the properties to update
Promise that resolves when the update is complete
Protectedwarn
Contains the currently active customization, mapped by prompt fragment ID.