mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
Show chat agents/prompts in extension features list (#291643)
This commit is contained in:
committed by
GitHub
parent
5271ac01f0
commit
d944566c4d
@@ -235,6 +235,7 @@ export interface IExtensionContributions {
|
||||
readonly chatPromptFiles?: ReadonlyArray<IChatFileContribution>;
|
||||
readonly chatInstructions?: ReadonlyArray<IChatFileContribution>;
|
||||
readonly chatAgents?: ReadonlyArray<IChatFileContribution>;
|
||||
readonly chatSkills?: ReadonlyArray<IChatFileContribution>;
|
||||
readonly languageModelTools?: ReadonlyArray<IToolContribution>;
|
||||
readonly languageModelToolSets?: ReadonlyArray<IToolSetContribution>;
|
||||
readonly mcpServerDefinitionProviders?: ReadonlyArray<IMcpCollectionContribution>;
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
import { DisposableMap } from '../../../../../base/common/lifecycle.js';
|
||||
import { Disposable, DisposableMap } from '../../../../../base/common/lifecycle.js';
|
||||
import { joinPath, isEqualOrParent } from '../../../../../base/common/resources.js';
|
||||
import { localize } from '../../../../../nls.js';
|
||||
import { ExtensionIdentifier } from '../../../../../platform/extensions/common/extensions.js';
|
||||
import { ExtensionIdentifier, IExtensionManifest } from '../../../../../platform/extensions/common/extensions.js';
|
||||
import { IWorkbenchContribution } from '../../../../common/contributions.js';
|
||||
import * as extensionsRegistry from '../../../../services/extensions/common/extensionsRegistry.js';
|
||||
import { IPromptsService, PromptsStorage } from './service/promptsService.js';
|
||||
@@ -15,6 +15,9 @@ import { PromptsType } from './promptTypes.js';
|
||||
import { UriComponents } from '../../../../../base/common/uri.js';
|
||||
import { CommandsRegistry } from '../../../../../platform/commands/common/commands.js';
|
||||
import { CancellationToken } from '../../../../../base/common/cancellation.js';
|
||||
import { SyncDescriptor } from '../../../../../platform/instantiation/common/descriptors.js';
|
||||
import { Registry } from '../../../../../platform/registry/common/platform.js';
|
||||
import { Extensions, IExtensionFeaturesRegistry, IExtensionFeatureTableRenderer, IRenderedData, IRowData, ITableData } from '../../../../services/extensionManagement/common/extensionFeatures.js';
|
||||
|
||||
interface IRawChatFileContribution {
|
||||
readonly path: string;
|
||||
@@ -162,3 +165,80 @@ CommandsRegistry.registerCommand('_listExtensionPromptFiles', async (accessor):
|
||||
|
||||
return result;
|
||||
});
|
||||
|
||||
class ChatPromptFilesDataRenderer extends Disposable implements IExtensionFeatureTableRenderer {
|
||||
readonly type = 'table';
|
||||
|
||||
constructor(private readonly contributionPoint: ChatContributionPoint) {
|
||||
super();
|
||||
}
|
||||
|
||||
shouldRender(manifest: IExtensionManifest): boolean {
|
||||
return !!manifest.contributes?.[this.contributionPoint];
|
||||
}
|
||||
|
||||
render(manifest: IExtensionManifest): IRenderedData<ITableData> {
|
||||
const contributions = manifest.contributes?.[this.contributionPoint] ?? [];
|
||||
if (!contributions.length) {
|
||||
return { data: { headers: [], rows: [] }, dispose: () => { } };
|
||||
}
|
||||
|
||||
const headers = [
|
||||
localize('chatFilesName', "Name"),
|
||||
localize('chatFilesDescription', "Description"),
|
||||
localize('chatFilesPath', "Path"),
|
||||
];
|
||||
|
||||
const rows: IRowData[][] = contributions.map(d => {
|
||||
return [
|
||||
d.name ?? '-',
|
||||
d.description ?? '-',
|
||||
d.path,
|
||||
];
|
||||
});
|
||||
|
||||
return {
|
||||
data: {
|
||||
headers,
|
||||
rows
|
||||
},
|
||||
dispose: () => { }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Registry.as<IExtensionFeaturesRegistry>(Extensions.ExtensionFeaturesRegistry).registerExtensionFeature({
|
||||
id: ChatContributionPoint.chatPromptFiles,
|
||||
label: localize('chatPromptFiles', "Chat Prompt Files"),
|
||||
access: {
|
||||
canToggle: false
|
||||
},
|
||||
renderer: new SyncDescriptor(ChatPromptFilesDataRenderer, [ChatContributionPoint.chatPromptFiles]),
|
||||
});
|
||||
|
||||
Registry.as<IExtensionFeaturesRegistry>(Extensions.ExtensionFeaturesRegistry).registerExtensionFeature({
|
||||
id: ChatContributionPoint.chatInstructions,
|
||||
label: localize('chatInstructions', "Chat Instructions"),
|
||||
access: {
|
||||
canToggle: false
|
||||
},
|
||||
renderer: new SyncDescriptor(ChatPromptFilesDataRenderer, [ChatContributionPoint.chatInstructions]),
|
||||
});
|
||||
|
||||
Registry.as<IExtensionFeaturesRegistry>(Extensions.ExtensionFeaturesRegistry).registerExtensionFeature({
|
||||
id: ChatContributionPoint.chatAgents,
|
||||
label: localize('chatAgents', "Chat Agents"),
|
||||
access: {
|
||||
canToggle: false
|
||||
},
|
||||
renderer: new SyncDescriptor(ChatPromptFilesDataRenderer, [ChatContributionPoint.chatAgents]),
|
||||
});
|
||||
|
||||
Registry.as<IExtensionFeaturesRegistry>(Extensions.ExtensionFeaturesRegistry).registerExtensionFeature({
|
||||
id: ChatContributionPoint.chatSkills,
|
||||
label: localize('chatSkills', "Chat Skills"),
|
||||
access: {
|
||||
canToggle: false
|
||||
},
|
||||
renderer: new SyncDescriptor(ChatPromptFilesDataRenderer, [ChatContributionPoint.chatSkills]),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user