Theia API Documentation v1.73.0
    Preparing search index...

    Implements

    Index

    Constructors

    Properties

    Methods

    addTemplate cleanupEmptyAgentFolders createBuiltInPromptFragmentCustomization createCustomAgentFile createPromptFragmentCustomization doMigrateCustomAgentsYaml editBuiltIn editBuiltInPromptFragmentCustomization editPromptFragmentCustomization editTemplate generateCustomizationId getActivePromptFragmentCustomization getAdditionalTemplateDirectories getAllCustomizations getCustomAgents getCustomAgentScopes getCustomAgentsLocations getCustomizedPromptFragmentIds getDedupedAdditionalScopes getFragmentIdFromFilePath getFragmentIDFromURI getPromptFragmentCustomizationDescription getPromptFragmentCustomizationType getPromptFragmentIDFromResource getTemplateFileExtensions getTemplateFiles getTemplatesDirectoryURI getTemplateURI hashString init isCustomAgentChange isPromptFragmentCustomized isPromptTemplateExtension listScopeRootPromptTemplates loadCustomAgentsFromAgentsDirectory loadCustomAgentsFromDirectory matchesCustomAgentFolder migrateCustomAgentsYaml migrateSingleScope openCustomAgentYaml openInMemoryTemplate parseTemplateWithMetadata processCustomAgentFolders processCustomAgentScope processExistingTemplateDirectory processTemplateDirectory processTemplateFiles provenanceLabel readCustomAgentDefaultFragmentId readCustomAgentFile readCustomAgentPromptVariants removeAllPromptFragmentCustomizations removeCustomizationFromMaps removePromptFragmentCustomization removePromptTemplateSuffix resetBuiltInCustomization resetToCustomization setupDirectoryWatcher update updateConfiguration warnOnceLegacyYaml

    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.

    customAgentDirs: Set<string> = ...

    Built-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.

    customAgentFolderByFragmentId: Map<string, URI> = ...

    For 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.

    envVariablesServer: EnvVariablesServer
    fileService: FileService
    logger: ILogger
    migrationInFlight: undefined | Promise<MigrationReport[]>

    In-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.

    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.

    workspaceService: WorkspaceService
    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

      • Optionalmetadata: CommandPromptFragmentMetadata

        Optional command metadata

      Returns void

    • Remove <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.

      Parameters

      Returns Promise<void>

    • The 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.

      Parameters

      Returns URI[]

    • Whether 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.

      Parameters

      • path: string

        The string form of the changed resource URI

      Returns boolean

    • 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

    • List .prompttemplate files directly inside the given scope directory (one level only). Returns each file's URI along with its filename stem to enable cheap prefix matching during migration.

      Parameters

      Returns Promise<{ stem: string; uri: URI }[]>

    • Load 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.

      Parameters

      Returns Promise<void>

    • Scan <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).

      Parameters

      • activeCustomizationsCopy: Map<string, PromptFragmentCustomization>
      • trackedTemplateURIsCopy: Set<string>
      • allCustomizationsCopy: Map<string, PromptFragmentCustomization>
      • scopeDir: URI
      • priority: number
      • customizationSource: CustomizationSource

      Returns Promise<void>

    • Processes 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.

      Parameters

      • activeCustomizationsCopy: Map<string, PromptFragmentCustomization>
      • trackedTemplateURIsCopy: Set<string>
      • allCustomizationsCopy: Map<string, PromptFragmentCustomization>
      • dirURI: URI

        URI of the agent scope directory

      • priority: number

        Priority level for customizations in this scope

      • customizationSource: CustomizationSource

        Source type of the customization

      Returns Promise<void>

    • Processes an existing directory for template files

      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>

    • 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>

    • Read <agentFolderURI>/agent.md's frontmatter and return the implied default fragment id (<name>_prompt). Returns undefined if the file is missing or invalid.

      Parameters

      • agentFolderURI: URI

      Returns Promise<undefined | string>

    • Scan 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.

      Parameters

      • agentFolderURI: URI

      Returns Promise<CustomAgentPromptVariant[]>

    • 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

    • Sets up file watching for a template directory (works for both existing and non-existing directories)

      Parameters

      • dirURI: URI

        URI of the directory to watch

      • priority: number

        Priority level for customizations in this directory

      • customizationSource: CustomizationSource

        Source type of the customization

      • agentsOnly: boolean = false

        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.

      Returns void