import { IObservable } from "../../../../base/common/observable.js"; import { IDisposable } from "../../../../base/common/lifecycle.js"; import { Event } from "../../../../base/common/event.js"; import { ThemeIcon } from "../../../../base/common/themables.js"; import { URI } from "../../../../base/common/uri.js"; import { AICustomizationSource } from "./aiCustomizationWorkspaceService.js"; import { PromptsType, Target } from "./promptSyntax/promptTypes.js"; import { IChatPromptSlashCommand, ICustomAgent, IResolvedChatPromptSlashCommand } from "./promptSyntax/service/promptsService.js"; import { IPromptsService } from "./promptSyntax/service/promptsService.service.js"; import { CancellationToken } from "../../../../base/common/cancellation.js"; import { type CustomizationDisabledReason } from "../../../../platform/agentHost/common/customizationEnablement.js"; import type { IMcpServerCustomizationMigrationCandidate, IMcpServerCustomizationMigrationResult, McpServerCustomizationMigration } from "./promptSyntax/service/customizationMigrationService.js"; import type { ICustomizationMarketplaceInstallProvider } from "@codingame/monaco-vscode-chat-service-override/vscode/vs/workbench/contrib/chat/common/customizationMarketplaceInstallService"; import type { ICustomizationMarketplaceSourcePage, ICustomizationMarketplaceSourceQuery, ICustomizationMarketplaceSourceRecoveryAction } from "../../../../platform/customizationMarketplace/common/customizationMarketplaceService.js"; import type { IMcpServerConfiguration } from "../../../../platform/mcp/common/mcpPlatformTypes.js"; import type { AgentModelCatalogStatus } from "@codingame/monaco-vscode-chat-service-override/vscode/vs/platform/agentHost/common/agentModelCatalogStatus"; import { ICustomizationHarnessService } from "./customizationHarnessService.service.js"; /** * Override for a management section's create-button behavior. */ export interface ISectionOverride { /** * Label for the primary button. Required when `commandId` or `rootFile` * is set. Ignored otherwise (the widget uses its default label). */ readonly label?: string; /** When set, the primary button invokes this command (e.g. hooks quick pick). */ readonly commandId?: string; /** When set, the primary button creates this file at the workspace root. */ readonly rootFile?: string; /** * Custom type label for the dropdown workspace/user create actions * (e.g. "Rule" instead of "Instruction"). When undefined, the * section's default type label is used. */ readonly typeLabel?: string; /** * Root-level file shortcuts added to the dropdown (e.g. `['AGENTS.md']`). * Each entry creates a "New {filename}" action that creates the file at * the workspace root. Harnesses that don't support a file simply omit it. */ readonly rootFileShortcuts?: readonly string[]; /** * File extension override for new files created under this section. * When set, files are created with this extension (e.g. `.md` for * Claude rules) instead of the default for the prompt type * (e.g. `.instructions.md`). */ readonly fileExtension?: string; } export interface ICustomizationItemAction { readonly id: string; readonly label: string; readonly tooltip?: string; readonly icon?: ThemeIcon; readonly enabled?: boolean; run(): void | Promise; } export type CustomizationMcpServerCompatibilityKind = "supported" | "partiallySupported" | "unsupported" | "unknown"; export interface ICustomizationMcpServerCompatibility { readonly id: string; readonly kind: CustomizationMcpServerCompatibilityKind; /** Localized reasons for non-supported compatibility states. */ readonly details?: readonly string[]; } export interface ICustomizationMcpServerCompatibilityScope extends IDisposable { readonly servers: IObservable; /** Whether the current server compatibility assessment has settled. */ readonly isResolved: IObservable; } export interface ICustomizationMcpServerCompatibilityProvider { acquire(sessionResource: URI): ICustomizationMcpServerCompatibilityScope | undefined; } export interface ICustomizationMcpServerMigrationProvider { computeMigration(sessionResource: URI, token: CancellationToken): Promise; migrate(sessionResource: URI, candidates: readonly IMcpServerCustomizationMigrationCandidate[]): Promise; } export interface ICustomizationMarketplaceSearchProvider { /** * Returns `undefined` when the provider cannot search in the current session, * allowing the workbench to use its compatibility catalog transport. */ query(sessionResource: URI, options: ICustomizationMarketplaceSourceQuery, token: CancellationToken): Promise; /** Retrieves an ordered saved feed using the same authentication and installation authority as search. */ getFeed?(sessionResource: URI, feedId: string, token: CancellationToken): Promise; /** Optional explicit recovery for the provider's current source failure. */ getRecoveryAction?(): ICustomizationMarketplaceSourceRecoveryAction | undefined; } export interface ICustomizationMarketplaceInfo { readonly name: string; readonly source: string; readonly isDefault: boolean; readonly managed: boolean; readonly available: boolean; } export interface ICustomizationMarketplaceRemoveResult { readonly removed: boolean; readonly dependentPlugins?: readonly string[]; } export interface ICustomizationMarketplaceRefreshResult { readonly name: string; readonly success: boolean; readonly error?: string; } export interface ICustomizationMarketplaceManagementProvider { /** * Fires when provider state that may affect the marketplace list changes. Consumers should * list marketplaces again and treat an identical list as unchanged, because this also fires * for unrelated customization activity such as MCP server status changes. */ readonly onDidChange: Event; /** * Fires when marketplace contents may have changed even if the marketplace list is identical, * for example after a marketplace is added, removed, or refreshed. */ readonly onDidChangeMarketplaces: Event; list(sessionResource: URI): Promise; add(sessionResource: URI, source: string): Promise; queryMarketplace(sessionResource: URI, marketplace: ICustomizationMarketplaceInfo, options: ICustomizationMarketplaceSourceQuery, token: CancellationToken): Promise; remove(sessionResource: URI, name: string, force?: boolean): Promise; refresh(sessionResource: URI, name?: string): Promise; } export interface ICustomizationMcpConfigurationProvider { addGlobal(name: string, config: IMcpServerConfiguration): Promise; } export interface ICustomizationPluginInstallProvider { installFromSource(sessionResource: URI, source: string): Promise; } /** * Describes a single harness option for the UI toggle. */ export interface IHarnessDescriptor { /** * The harness/session-type identifier. */ readonly id: string; readonly label: string; readonly icon: ThemeIcon; /** * The target whose custom agent format this harness supports. */ readonly customAgentTarget?: Target; /** Authoritative model discovery state when supplied by the harness. */ readonly modelCatalogueStatus?: IObservable; /** * Management sections that should be hidden when this harness is active. * For example, Claude does not support prompt files so the Prompts * section is hidden. */ readonly hiddenSections?: readonly string[]; /** * When `true`, the "Generate with AI" sparkle button is hidden and replaced * with a plain "New X" manual-creation button (like sessions). */ readonly hideGenerateButton?: boolean; /** * Per-section overrides for the create button behavior. * * A `commandId` entry replaces the button entirely with a command invocation. * * A `rootFile` entry makes the primary button create a specific file * at the workspace root (e.g. Claude instructions → `CLAUDE.md`). * When combined with `typeLabel`, the dropdown create actions use * that label instead of the section's default (e.g. "Rule" instead * of "Instruction"). */ readonly sectionOverrides?: ReadonlyMap; /** * The chat agent ID that must be registered for this harness to appear. * When `undefined`, the harness is always available (e.g. Local). */ readonly requiredAgentId?: string; /** * When set, this harness is backed by an extension-contributed provider * that can supply customization items directly (bypassing promptsService * discovery and filtering). */ readonly itemProvider?: ICustomizationItemProvider; /** * When `true`, the "Troubleshoot" action is available in item context * menus. This opens chat with the `/troubleshoot` command pre-filled * for the selected customization. */ readonly supportsTroubleshoot?: boolean; /** * When set, this harness uses an opt-out sync model where all eligible * local customizations are synced by default. The UI shows disable * affordances when this harness is active. */ readonly syncProvider?: ICustomizationSyncProvider; /** * Optional plugin-management actions shown in the Plugins section add menu. * Harnesses can use these to add environment-specific commands alongside * the default install-from-source action (for example, configuring plugins on * a remote agent host). The create action remains a separate toolbar button. */ readonly pluginActions?: readonly ICustomizationItemAction[]; /** * Local MCP collection identifiers that do not apply to this harness. * Host-published MCP servers remain visible even when their local counterpart * belongs to a hidden collection. */ readonly hiddenMcpServerCollectionIds?: readonly string[]; /** * Supplies harness-specific compatibility for MCP servers in the active session. */ readonly mcpServerCompatibilityProvider?: ICustomizationMcpServerCompatibilityProvider; /** * Supplies harness-specific MCP server migration behavior. */ readonly mcpServerMigrationProvider?: ICustomizationMcpServerMigrationProvider; /** Provisionally routes harness-owned global MCP configuration. */ readonly mcpConfigurationProvider?: ICustomizationMcpConfigurationProvider; /** Installs plugin sources through the harness instead of VS Code's plugin configuration. */ readonly pluginInstallProvider?: ICustomizationPluginInstallProvider; /** Supplies authoritative installation inventory and mutations for this harness. */ readonly marketplaceInstallProvider?: ICustomizationMarketplaceInstallProvider; /** Supplies a harness-native replacement for the public customization catalog. */ readonly marketplaceSearchProvider?: ICustomizationMarketplaceSearchProvider; /** Supplies authoritative marketplace inventory and mutations for this harness. */ readonly marketplaceManagementProvider?: ICustomizationMarketplaceManagementProvider; } /** * Represents a customization item provided by any source. */ export interface ICustomizationItem { /** Optional stable identity used by list widgets when URI alone is not unique. */ readonly itemKey?: string; readonly uri: URI; readonly type: string; readonly name: string; readonly description?: string; /** Customization source (local, user, extension, plugin, builtin). Set by providers that know the source. */ readonly source: AICustomizationSource; /** The extension identifier that contributed this customization, if any. */ readonly extensionId: string | undefined; /** The URI of the plugin that contributed this customization, if any. */ readonly pluginUri: URI | undefined; /** Human-readable name of the plugin that contributed this customization, if any. */ readonly pluginLabel?: string; /** Server-reported loading status for this customization. */ readonly status?: "loading" | "loaded" | "degraded" | "error"; /** Human-readable status detail (e.g. error message or warning). */ readonly statusMessage?: string; /** Whether this customization is currently enabled. */ readonly enabled?: boolean; /** Host-published reason for a disabled customization. */ readonly disabledReason?: CustomizationDisabledReason; /** When set, items with the same groupKey are displayed under a shared collapsible header. */ readonly groupKey?: string; /** When set, shows a small inline badge next to the item name (e.g. an applyTo glob pattern). */ readonly badge?: string; /** Tooltip shown when hovering the badge. */ readonly badgeTooltip?: string; /** * Whether this customization item can be invoked by the user. * Relevant for prompt / skill and custom agents */ readonly userInvocable?: boolean; /** Optional inline/context-menu actions specific to this item. */ readonly actions?: readonly ICustomizationItemAction[]; } export interface ICustomizationAgentRef { readonly id: string; readonly uri: URI; /** Agent name (from frontmatter `name`, or file-derived) */ readonly name: string; /** Optional short description for UI preview (from frontmatter `description`) */ readonly description?: string; } export type AgentFileToolAvailability = "available" | "unavailable" | "disabled"; export interface IAgentFileToolInventoryEntry { readonly name: string; readonly description?: string; readonly availability: AgentFileToolAvailability; } export declare function isPluginCustomizationItem(item: { readonly type: string; }): boolean; export declare function getCustomizationDisabledLabel(reason: CustomizationDisabledReason | undefined): string; /** * Provider interface for extension-contributed harnesses that supply * customization items directly from their SDK. */ export interface ICustomizationItemProvider { /** * Event that fires when the provider's customizations change. */ readonly onDidChange: Event; /** * Provide the customization items this harness supports. * * @param sessionResource URI of the chat session whose * customizations should be included. Providers that surface * session-scoped state (e.g. an agent host) should read from * this session. */ provideChatSessionCustomizations(sessionResource: URI, token: CancellationToken): Promise; /** * Provide the custom agents this harness supports. * * @param sessionResource URI of the chat session whose * customizations should be included. Providers that surface * session-scoped state (e.g. an agent host) should read from * this session. */ provideCustomAgents?(sessionResource: URI, token: CancellationToken): Promise; /** * Provides the tools accepted by custom agent files for this harness session. * `undefined` means the dynamic inventory is not authoritative yet and must not be used for unknown-value diagnostics. */ provideAgentFileTools?(sessionResource: URI, token: CancellationToken): Promise; /** * Provide the directories where new customization files of the given * type can be created for this session. The result includes both * workspace-scoped and user-scoped folders; the caller is responsible * for partitioning them by storage target. * * @param sessionResource URI of the chat session whose * creation locations should be returned. */ provideSourceFolders?(sessionResource: URI, type: PromptsType, token: CancellationToken): Promise; /** * Returns the readiness of the most recent source-folder discovery for this session. * Providers that do not expose this treat a completed empty result as authoritative. */ getSourceFolderReadiness?(sessionResource: URI): CustomizationSourceFolderReadiness; /** * Returns the opaque workspace group containing a customization. */ getWorkspaceGroupId?(sessionResource: URI, resource: URI): string | undefined; } export type CustomizationSourceFolderReadiness = "loading" | "ready" | "unavailable"; /** * A directory where new customization files of a given type can be created. */ export interface ICustomizationSourceFolder { readonly uri: URI; /** Display label for the picker when multiple folders are offered. */ readonly label: string; /** Customization source for this folder (typically 'local' or 'user' for writable creation locations). */ readonly source: AICustomizationSource; /** Opaque provider-defined identity shared by folders that belong to the same destination. */ readonly destinationGroupId?: string; /** Opaque provider-defined identity shared by folders that belong to the same workspace root. */ readonly workspaceGroupId?: string; } /** * Provider interface for harnesses that use an opt-out sync model. * * Every eligible local customization is synced by default; the user * can disable individual items. The persisted set captures only the * user's opt-outs. */ export interface ICustomizationSyncProvider { readonly onDidChange: Event; isDisabled(uri: URI): boolean; setDisabled(uri: URI, disabled: boolean): void; } /** * Minimal slash-command metadata resolved from the active harness. */ export interface ICustomizationSlashCommand { readonly uri: URI; readonly type: PromptsType.prompt | PromptsType.skill; readonly name: string; readonly description?: string; readonly userInvocable: boolean; readonly sessionTypes?: readonly string[]; } /** * Builds the full source list from the base set (local, user, plugin) * plus any additional sources specific to the window type. * * Core passes `[PromptsStorage.extension]`; sessions passes its * BUILTIN_STORAGE constant. */ /** * Creates a "VS Code" harness descriptor that shows all storage sources * with no user-root restrictions. */ export declare function createVSCodeHarnessDescriptor(): IHarnessDescriptor; /** * Reusable base implementation of {@link ICustomizationHarnessService}. * Concrete registrations only need to supply the list of harness * descriptors and a default harness id. */ export declare class CustomizationHarnessServiceBase implements ICustomizationHarnessService { private readonly promptsService; readonly _serviceBrand: undefined; private readonly _onDidChangeSlashCommands; readonly onDidChangeSlashCommands: Event<{ readonly sessionType: string; }>; private readonly _onDidChangeCustomAgents; readonly onDidChangeCustomAgents: Event<{ readonly sessionType: string; }>; private readonly _providerListeners; private _isDisposed; private readonly _activeSessionResource; readonly activeSessionResource: IObservable; private readonly _activeHarness; readonly activeHarness: IObservable; private readonly _staticHarnesses; private readonly _externalHarnesses; private readonly _availableHarnesses; readonly availableHarnesses: IObservable; constructor(staticHarnesses: readonly IHarnessDescriptor[], defaultHarness: string, promptsService: IPromptsService); private _getAllHarnesses; private _refreshAvailableHarnesses; private _rebindProviderListeners; dispose(): void; registerExternalHarness(descriptor: IHarnessDescriptor): IDisposable; findHarnessById(id: string): IHarnessDescriptor | undefined; getDescriptorForSession(sessionResource: URI): IHarnessDescriptor | undefined; setActiveSession(sessionResource: URI): void; getActiveDescriptor(): IHarnessDescriptor; getSlashCommands(sessionResource: URI, token: CancellationToken): Promise; getCustomAgents(sessionResource: URI, token: CancellationToken): Promise; resolvePromptSlashCommand(name: string, sessionResource: URI, token: CancellationToken): Promise; getSessionResourceForHarness(harnessId: string): URI; }