mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
cleanup prompt file contributions (#268671)
This commit is contained in:
committed by
GitHub
parent
b70865659e
commit
7de09762d9
@@ -52,7 +52,7 @@ import { ILanguageModelStatsService, LanguageModelStatsService } from '../common
|
||||
import { ILanguageModelToolsService } from '../common/languageModelToolsService.js';
|
||||
import { PromptsConfig } from '../common/promptSyntax/config/config.js';
|
||||
import { INSTRUCTIONS_DEFAULT_SOURCE_FOLDER, INSTRUCTION_FILE_EXTENSION, MODE_DEFAULT_SOURCE_FOLDER, MODE_FILE_EXTENSION, PROMPT_DEFAULT_SOURCE_FOLDER, PROMPT_FILE_EXTENSION } from '../common/promptSyntax/config/promptFileLocations.js';
|
||||
import { registerPromptFileContributions } from '../common/promptSyntax/promptFileContributions.js';
|
||||
import { PromptLanguageFeaturesProvider } from '../common/promptSyntax/promptFileContributions.js';
|
||||
import { INSTRUCTIONS_DOCUMENTATION_URL, MODE_DOCUMENTATION_URL, PROMPT_DOCUMENTATION_URL } from '../common/promptSyntax/promptTypes.js';
|
||||
import { IPromptsService } from '../common/promptSyntax/service/promptsService.js';
|
||||
import { PromptsService } from '../common/promptSyntax/service/promptsServiceImpl.js';
|
||||
@@ -918,6 +918,7 @@ registerWorkbenchContribution2(PromptUrlHandler.ID, PromptUrlHandler, WorkbenchP
|
||||
registerWorkbenchContribution2(ChatSessionsView.ID, ChatSessionsView, WorkbenchPhase.AfterRestored);
|
||||
registerWorkbenchContribution2(ChatEditingNotebookFileSystemProviderContrib.ID, ChatEditingNotebookFileSystemProviderContrib, WorkbenchPhase.BlockStartup);
|
||||
registerWorkbenchContribution2(UserToolSetsContributions.ID, UserToolSetsContributions, WorkbenchPhase.Eventually);
|
||||
registerWorkbenchContribution2(PromptLanguageFeaturesProvider.ID, PromptLanguageFeaturesProvider, WorkbenchPhase.Eventually);
|
||||
|
||||
registerChatActions();
|
||||
registerChatAccessibilityActions();
|
||||
@@ -968,10 +969,6 @@ registerSingleton(IChatTodoListService, ChatTodoListService, InstantiationType.D
|
||||
registerSingleton(IChatOutputRendererService, ChatOutputRendererService, InstantiationType.Delayed);
|
||||
registerSingleton(IChatLayoutService, ChatLayoutService, InstantiationType.Delayed);
|
||||
|
||||
|
||||
registerPromptFileContributions();
|
||||
|
||||
|
||||
registerAction2(ConfigureToolSets);
|
||||
registerAction2(RenameChatSessionAction);
|
||||
registerAction2(DeleteChatSessionAction);
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { assert } from '../../../../../../base/common/assert.js';
|
||||
import { ILogService } from '../../../../../../platform/log/common/log.js';
|
||||
import { asBoolean, PromptsConfig } from './config.js';
|
||||
import { IWorkbenchContribution } from '../../../../../common/contributions.js';
|
||||
import { IConfigurationService } from '../../../../../../platform/configuration/common/configuration.js';
|
||||
|
||||
/**
|
||||
* Contribution that migrates the old config setting value to a new one.
|
||||
*
|
||||
* Note! This is a temporary logic and can be removed on ~2026-04-29.
|
||||
*/
|
||||
export class ConfigMigration implements IWorkbenchContribution {
|
||||
constructor(
|
||||
@ILogService private readonly logService: ILogService,
|
||||
@IConfigurationService private readonly configService: IConfigurationService,
|
||||
) {
|
||||
// migrate the old config setting value to a new one
|
||||
this.migrateConfig()
|
||||
.catch((error) => {
|
||||
this.logService.warn('failed to migrate config setting value.', error);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The main function that implements the migration logic.
|
||||
*/
|
||||
private async migrateConfig(): Promise<void> {
|
||||
const value = await this.configService.getValue(PromptsConfig.KEY);
|
||||
|
||||
// if setting is not set, nothing to do
|
||||
if ((value === undefined) || (value === null)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if the setting value is a boolean, we don't need to do
|
||||
// anything since it is already a valid configuration value
|
||||
if ((typeof value === 'boolean') || (asBoolean(value) !== undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// in the old setting logic an array of strings was treated
|
||||
// as a list of locations, so we need to migrate that
|
||||
if (Array.isArray(value)) {
|
||||
|
||||
// copy array values into a map of paths
|
||||
const locationsValue: Record<string, boolean> = {};
|
||||
for (const filePath of value) {
|
||||
if (typeof filePath !== 'string') {
|
||||
continue;
|
||||
}
|
||||
const trimmedValue = filePath.trim();
|
||||
if (!trimmedValue) {
|
||||
continue;
|
||||
}
|
||||
|
||||
locationsValue[trimmedValue] = true;
|
||||
}
|
||||
|
||||
await this.configService.updateValue(PromptsConfig.KEY, true);
|
||||
await this.configService.updateValue(PromptsConfig.PROMPT_LOCATIONS_KEY, locationsValue);
|
||||
return;
|
||||
}
|
||||
|
||||
// in the old setting logic an object was treated as a map
|
||||
// of `location -> boolean`, so we need to migrate that
|
||||
if (typeof value === 'object') {
|
||||
// sanity check on the contents of value variable - while
|
||||
// we've handled the 'null' case above this assertion is
|
||||
// here to prevent churn when this block is moved around
|
||||
assert(
|
||||
value !== null,
|
||||
'Object value must not be a null.',
|
||||
);
|
||||
|
||||
// copy object values into a map of paths
|
||||
const locationsValue: Record<string, boolean> = {};
|
||||
for (const [location, enabled] of Object.entries(value)) {
|
||||
// if the old location enabled value wasn't a boolean
|
||||
// then ignore it as it is not a valid value
|
||||
if ((typeof enabled !== 'boolean') || (asBoolean(enabled) === undefined)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const trimmedValue = location.trim();
|
||||
if (!trimmedValue) {
|
||||
continue;
|
||||
}
|
||||
|
||||
locationsValue[trimmedValue] = enabled;
|
||||
}
|
||||
|
||||
await this.configService.updateValue(PromptsConfig.KEY, true);
|
||||
await this.configService.updateValue(PromptsConfig.PROMPT_LOCATIONS_KEY, locationsValue);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// in the old setting logic a string was treated as a single
|
||||
// location path, so we need to migrate that
|
||||
if (typeof value === 'string') {
|
||||
// sanity check on the contents of value variable - while
|
||||
// we've handled the 'boolean' case above this assertion is
|
||||
// here to prevent churn when this block is moved around
|
||||
assert(
|
||||
asBoolean(value) === undefined,
|
||||
`String value must not be a boolean, got '${value}'.`,
|
||||
);
|
||||
|
||||
await this.configService.updateValue(PromptsConfig.KEY, true);
|
||||
await this.configService.updateValue(PromptsConfig.PROMPT_LOCATIONS_KEY, { [value]: true });
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-10
@@ -4,35 +4,30 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { CancellationToken } from '../../../../../../base/common/cancellation.js';
|
||||
import { Disposable } from '../../../../../../base/common/lifecycle.js';
|
||||
import { Position } from '../../../../../../editor/common/core/position.js';
|
||||
import { Range } from '../../../../../../editor/common/core/range.js';
|
||||
import { Definition, DefinitionProvider } from '../../../../../../editor/common/languages.js';
|
||||
import { ITextModel } from '../../../../../../editor/common/model.js';
|
||||
import { ILanguageFeaturesService } from '../../../../../../editor/common/services/languageFeatures.js';
|
||||
import { IChatModeService } from '../../chatModes.js';
|
||||
import { ALL_PROMPTS_LANGUAGE_SELECTOR, getPromptsTypeForLanguageId } from '../promptTypes.js';
|
||||
import { getPromptsTypeForLanguageId } from '../promptTypes.js';
|
||||
import { IPromptsService } from '../service/promptsService.js';
|
||||
|
||||
export class PromptHeaderDefinitionProvider extends Disposable implements DefinitionProvider {
|
||||
export class PromptHeaderDefinitionProvider implements DefinitionProvider {
|
||||
/**
|
||||
* Debug display name for this provider.
|
||||
*/
|
||||
public readonly _debugDisplayName: string = 'PromptHeaderHoverProvider';
|
||||
public readonly _debugDisplayName: string = 'PromptHeaderDefinitionProvider';
|
||||
|
||||
constructor(
|
||||
@IPromptsService private readonly promptsService: IPromptsService,
|
||||
@ILanguageFeaturesService private readonly languageService: ILanguageFeaturesService,
|
||||
@IChatModeService private readonly chatModeService: IChatModeService,
|
||||
) {
|
||||
super();
|
||||
|
||||
this._register(this.languageService.definitionProvider.register(ALL_PROMPTS_LANGUAGE_SELECTOR, this));
|
||||
}
|
||||
|
||||
async provideDefinition(model: ITextModel, position: Position, token: CancellationToken): Promise<Definition | undefined> {
|
||||
const promptType = getPromptsTypeForLanguageId(model.getLanguageId());
|
||||
if (!promptType) {
|
||||
// if the model is not a prompt, we don't provide any completions
|
||||
// if the model is not a prompt, we don't provide any definitions
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
+2
-8
@@ -5,12 +5,10 @@
|
||||
|
||||
import { dirname, extUri } from '../../../../../../base/common/resources.js';
|
||||
import { ITextModel } from '../../../../../../editor/common/model.js';
|
||||
import { Disposable } from '../../../../../../base/common/lifecycle.js';
|
||||
import { ALL_PROMPTS_LANGUAGE_SELECTOR, PromptsType } from '../promptTypes.js';
|
||||
import { PromptsType } from '../promptTypes.js';
|
||||
import { Position } from '../../../../../../editor/common/core/position.js';
|
||||
import { IFileService } from '../../../../../../platform/files/common/files.js';
|
||||
import { CancellationToken } from '../../../../../../base/common/cancellation.js';
|
||||
import { ILanguageFeaturesService } from '../../../../../../editor/common/services/languageFeatures.js';
|
||||
import { CompletionContext, CompletionItem, CompletionItemKind, CompletionItemProvider, CompletionList } from '../../../../../../editor/common/languages.js';
|
||||
import { Range } from '../../../../../../editor/common/core/range.js';
|
||||
import { CharCode } from '../../../../../../base/common/charCode.js';
|
||||
@@ -24,7 +22,7 @@ import { getPromptFileType } from '../config/promptFileLocations.js';
|
||||
* - #file: paths to files and folders in the workspace
|
||||
* - # tool names
|
||||
*/
|
||||
export class PromptBodyAutocompletion extends Disposable implements CompletionItemProvider {
|
||||
export class PromptBodyAutocompletion implements CompletionItemProvider {
|
||||
/**
|
||||
* Debug display name for this provider.
|
||||
*/
|
||||
@@ -37,12 +35,8 @@ export class PromptBodyAutocompletion extends Disposable implements CompletionIt
|
||||
|
||||
constructor(
|
||||
@IFileService private readonly fileService: IFileService,
|
||||
@ILanguageFeaturesService private readonly languageService: ILanguageFeaturesService,
|
||||
@ILanguageModelToolsService private readonly languageModelToolsService: ILanguageModelToolsService,
|
||||
) {
|
||||
super();
|
||||
|
||||
this._register(this.languageService.completionProvider.register(ALL_PROMPTS_LANGUAGE_SELECTOR, this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+4
-10
@@ -4,38 +4,32 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { CancellationToken } from '../../../../../../base/common/cancellation.js';
|
||||
import { Disposable } from '../../../../../../base/common/lifecycle.js';
|
||||
import { Range } from '../../../../../../editor/common/core/range.js';
|
||||
import { CodeActionContext, CodeActionList, CodeActionProvider, ProviderResult, TextEdit, WorkspaceEdit } from '../../../../../../editor/common/languages.js';
|
||||
import { ITextModel } from '../../../../../../editor/common/model.js';
|
||||
import { ILanguageFeaturesService } from '../../../../../../editor/common/services/languageFeatures.js';
|
||||
import { localize } from '../../../../../../nls.js';
|
||||
import { ILanguageModelToolsService } from '../../languageModelToolsService.js';
|
||||
import { ALL_PROMPTS_LANGUAGE_SELECTOR, getPromptsTypeForLanguageId } from '../promptTypes.js';
|
||||
import { getPromptsTypeForLanguageId } from '../promptTypes.js';
|
||||
import { IPromptsService } from '../service/promptsService.js';
|
||||
import { IValue } from '../service/newPromptsParser.js';
|
||||
import { Selection } from '../../../../../../editor/common/core/selection.js';
|
||||
|
||||
export class PromptCodeActionProvider extends Disposable implements CodeActionProvider {
|
||||
export class PromptCodeActionProvider implements CodeActionProvider {
|
||||
/**
|
||||
* Debug display name for this provider.
|
||||
*/
|
||||
public readonly _debugDisplayName: string = 'PromptHoverProvider';
|
||||
public readonly _debugDisplayName: string = 'PromptCodeActionProvider';
|
||||
|
||||
constructor(
|
||||
@IPromptsService private readonly promptsService: IPromptsService,
|
||||
@ILanguageFeaturesService private readonly languageService: ILanguageFeaturesService,
|
||||
@ILanguageModelToolsService private readonly languageModelToolsService: ILanguageModelToolsService
|
||||
) {
|
||||
super();
|
||||
|
||||
this._register(this.languageService.codeActionProvider.register(ALL_PROMPTS_LANGUAGE_SELECTOR, this));
|
||||
}
|
||||
|
||||
provideCodeActions(model: ITextModel, range: Range | Selection, context: CodeActionContext, token: CancellationToken): ProviderResult<CodeActionList> {
|
||||
const promptType = getPromptsTypeForLanguageId(model.getLanguageId());
|
||||
if (!promptType) {
|
||||
// if the model is not a prompt, we don't provide any hovers
|
||||
// if the model is not a prompt, we don't provide any code actions
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
+3
-9
@@ -4,14 +4,12 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { CancellationToken } from '../../../../../../base/common/cancellation.js';
|
||||
import { Disposable } from '../../../../../../base/common/lifecycle.js';
|
||||
import { DocumentSemanticTokensProvider, ProviderResult, SemanticTokens, SemanticTokensLegend } from '../../../../../../editor/common/languages.js';
|
||||
import { ITextModel } from '../../../../../../editor/common/model.js';
|
||||
import { ILanguageFeaturesService } from '../../../../../../editor/common/services/languageFeatures.js';
|
||||
import { ALL_PROMPTS_LANGUAGE_SELECTOR, getPromptsTypeForLanguageId } from '../promptTypes.js';
|
||||
import { getPromptsTypeForLanguageId } from '../promptTypes.js';
|
||||
import { IPromptsService } from '../service/promptsService.js';
|
||||
|
||||
export class PromptDocumentSemanticTokensProvider extends Disposable implements DocumentSemanticTokensProvider {
|
||||
export class PromptDocumentSemanticTokensProvider implements DocumentSemanticTokensProvider {
|
||||
/**
|
||||
* Debug display name for this provider.
|
||||
*/
|
||||
@@ -19,17 +17,13 @@ export class PromptDocumentSemanticTokensProvider extends Disposable implements
|
||||
|
||||
constructor(
|
||||
@IPromptsService private readonly promptsService: IPromptsService,
|
||||
@ILanguageFeaturesService private readonly languageService: ILanguageFeaturesService,
|
||||
) {
|
||||
super();
|
||||
|
||||
this._register(this.languageService.documentSemanticTokensProvider.register(ALL_PROMPTS_LANGUAGE_SELECTOR, this));
|
||||
}
|
||||
|
||||
provideDocumentSemanticTokens(model: ITextModel, lastResultId: string | null, token: CancellationToken): ProviderResult<SemanticTokens> {
|
||||
const promptType = getPromptsTypeForLanguageId(model.getLanguageId());
|
||||
if (!promptType) {
|
||||
// if the model is not a prompt, we don't provide any completions
|
||||
// if the model is not a prompt, we don't provide any semantic tokens
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
+3
-9
@@ -5,22 +5,20 @@
|
||||
|
||||
import { CancellationToken } from '../../../../../../base/common/cancellation.js';
|
||||
import { CharCode } from '../../../../../../base/common/charCode.js';
|
||||
import { Disposable } from '../../../../../../base/common/lifecycle.js';
|
||||
import { Position } from '../../../../../../editor/common/core/position.js';
|
||||
import { Range } from '../../../../../../editor/common/core/range.js';
|
||||
import { CompletionContext, CompletionItem, CompletionItemInsertTextRule, CompletionItemKind, CompletionItemProvider, CompletionList } from '../../../../../../editor/common/languages.js';
|
||||
import { ITextModel } from '../../../../../../editor/common/model.js';
|
||||
import { ILanguageFeaturesService } from '../../../../../../editor/common/services/languageFeatures.js';
|
||||
import { ILanguageModelChatMetadata, ILanguageModelsService } from '../../languageModels.js';
|
||||
import { ILanguageModelToolsService } from '../../languageModelToolsService.js';
|
||||
import { IChatModeService } from '../../chatModes.js';
|
||||
import { ALL_PROMPTS_LANGUAGE_SELECTOR, getPromptsTypeForLanguageId, PromptsType } from '../promptTypes.js';
|
||||
import { getPromptsTypeForLanguageId, PromptsType } from '../promptTypes.js';
|
||||
import { IPromptsService } from '../service/promptsService.js';
|
||||
import { Iterable } from '../../../../../../base/common/iterator.js';
|
||||
import { PromptHeader } from '../service/newPromptsParser.js';
|
||||
import { getValidAttributeNames } from '../service/promptValidator.js';
|
||||
import { getValidAttributeNames } from './promptValidator.js';
|
||||
|
||||
export class PromptHeaderAutocompletion extends Disposable implements CompletionItemProvider {
|
||||
export class PromptHeaderAutocompletion implements CompletionItemProvider {
|
||||
/**
|
||||
* Debug display name for this provider.
|
||||
*/
|
||||
@@ -33,14 +31,10 @@ export class PromptHeaderAutocompletion extends Disposable implements Completion
|
||||
|
||||
constructor(
|
||||
@IPromptsService private readonly promptsService: IPromptsService,
|
||||
@ILanguageFeaturesService private readonly languageService: ILanguageFeaturesService,
|
||||
@ILanguageModelsService private readonly languageModelsService: ILanguageModelsService,
|
||||
@ILanguageModelToolsService private readonly languageModelToolsService: ILanguageModelToolsService,
|
||||
@IChatModeService private readonly chatModeService: IChatModeService,
|
||||
) {
|
||||
super();
|
||||
|
||||
this._register(this.languageService.completionProvider.register(ALL_PROMPTS_LANGUAGE_SELECTOR, this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,21 +5,19 @@
|
||||
|
||||
import { CancellationToken } from '../../../../../../base/common/cancellation.js';
|
||||
import { MarkdownString } from '../../../../../../base/common/htmlContent.js';
|
||||
import { Disposable } from '../../../../../../base/common/lifecycle.js';
|
||||
import { Position } from '../../../../../../editor/common/core/position.js';
|
||||
import { Range } from '../../../../../../editor/common/core/range.js';
|
||||
import { Hover, HoverContext, HoverProvider } from '../../../../../../editor/common/languages.js';
|
||||
import { ITextModel } from '../../../../../../editor/common/model.js';
|
||||
import { ILanguageFeaturesService } from '../../../../../../editor/common/services/languageFeatures.js';
|
||||
import { localize } from '../../../../../../nls.js';
|
||||
import { ILanguageModelChatMetadata, ILanguageModelsService } from '../../languageModels.js';
|
||||
import { ILanguageModelToolsService, ToolSet } from '../../languageModelToolsService.js';
|
||||
import { IChatModeService, isBuiltinChatMode } from '../../chatModes.js';
|
||||
import { ALL_PROMPTS_LANGUAGE_SELECTOR, getPromptsTypeForLanguageId, PromptsType } from '../promptTypes.js';
|
||||
import { getPromptsTypeForLanguageId, PromptsType } from '../promptTypes.js';
|
||||
import { IPromptsService } from '../service/promptsService.js';
|
||||
import { IHeaderAttribute, PromptBody, PromptHeader } from '../service/newPromptsParser.js';
|
||||
|
||||
export class PromptHoverProvider extends Disposable implements HoverProvider {
|
||||
export class PromptHoverProvider implements HoverProvider {
|
||||
/**
|
||||
* Debug display name for this provider.
|
||||
*/
|
||||
@@ -27,14 +25,10 @@ export class PromptHoverProvider extends Disposable implements HoverProvider {
|
||||
|
||||
constructor(
|
||||
@IPromptsService private readonly promptsService: IPromptsService,
|
||||
@ILanguageFeaturesService private readonly languageService: ILanguageFeaturesService,
|
||||
@ILanguageModelToolsService private readonly languageModelToolsService: ILanguageModelToolsService,
|
||||
@ILanguageModelsService private readonly languageModelsService: ILanguageModelsService,
|
||||
@IChatModeService private readonly chatModeService: IChatModeService,
|
||||
) {
|
||||
super();
|
||||
|
||||
this._register(this.languageService.hoverProvider.register(ALL_PROMPTS_LANGUAGE_SELECTOR, this));
|
||||
}
|
||||
|
||||
private createHover(contents: string, range: Range): Hover {
|
||||
|
||||
+1
-7
@@ -7,20 +7,14 @@ import { IPromptsService } from '../service/promptsService.js';
|
||||
import { ITextModel } from '../../../../../../editor/common/model.js';
|
||||
import { CancellationToken } from '../../../../../../base/common/cancellation.js';
|
||||
import { ILink, ILinksList, LinkProvider } from '../../../../../../editor/common/languages.js';
|
||||
import { ALL_PROMPTS_LANGUAGE_SELECTOR } from '../promptTypes.js';
|
||||
import { Disposable } from '../../../../../../base/common/lifecycle.js';
|
||||
import { ILanguageFeaturesService } from '../../../../../../editor/common/services/languageFeatures.js';
|
||||
|
||||
/**
|
||||
* Provides link references for prompt files.
|
||||
*/
|
||||
export class PromptLinkProvider extends Disposable implements LinkProvider {
|
||||
export class PromptLinkProvider implements LinkProvider {
|
||||
constructor(
|
||||
@ILanguageFeaturesService languageService: ILanguageFeaturesService,
|
||||
@IPromptsService private readonly promptsService: IPromptsService,
|
||||
) {
|
||||
super();
|
||||
this._register(languageService.linkProvider.register(ALL_PROMPTS_LANGUAGE_SELECTOR, this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -17,13 +17,13 @@ import { ChatModeKind } from '../../constants.js';
|
||||
import { ILanguageModelChatMetadata, ILanguageModelsService } from '../../languageModels.js';
|
||||
import { ILanguageModelToolsService } from '../../languageModelToolsService.js';
|
||||
import { getPromptsTypeForLanguageId, PromptsType } from '../promptTypes.js';
|
||||
import { IArrayValue, IHeaderAttribute, ParsedPromptFile } from './newPromptsParser.js';
|
||||
import { IArrayValue, IHeaderAttribute, ParsedPromptFile } from '../service/newPromptsParser.js';
|
||||
import { PromptsConfig } from '../config/config.js';
|
||||
import { Disposable, DisposableStore, toDisposable } from '../../../../../../base/common/lifecycle.js';
|
||||
import { Delayer } from '../../../../../../base/common/async.js';
|
||||
import { ResourceMap } from '../../../../../../base/common/map.js';
|
||||
import { IFileService } from '../../../../../../platform/files/common/files.js';
|
||||
import { IPromptsService } from './promptsService.js';
|
||||
import { IPromptsService } from '../service/promptsService.js';
|
||||
import { ILabelService } from '../../../../../../platform/label/common/label.js';
|
||||
|
||||
const MARKERS_OWNER_ID = 'prompts-diagnostics-provider';
|
||||
@@ -3,47 +3,37 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ConfigMigration } from './config/configMigration.js';
|
||||
import { Registry } from '../../../../../platform/registry/common/platform.js';
|
||||
import { LifecyclePhase } from '../../../../services/lifecycle/common/lifecycle.js';
|
||||
import { IWorkbenchContributionsRegistry, Extensions, IWorkbenchContribution } from '../../../../common/contributions.js';
|
||||
import { IWorkbenchContribution } from '../../../../common/contributions.js';
|
||||
import { PromptLinkProvider } from './languageProviders/promptLinkProvider.js';
|
||||
import { PromptBodyAutocompletion } from './languageProviders/promptBodyAutocompletion.js';
|
||||
import { PromptHeaderAutocompletion } from './languageProviders/promptHeaderAutocompletion.js';
|
||||
import { PromptHoverProvider } from './languageProviders/promptHovers.js';
|
||||
import { PromptHeaderDefinitionProvider } from './languageProviders/PromptHeaderDefinitionProvider.js';
|
||||
import { PromptValidatorContribution } from './service/promptValidator.js';
|
||||
import { PromptValidatorContribution } from './languageProviders/promptValidator.js';
|
||||
import { PromptDocumentSemanticTokensProvider } from './languageProviders/promptDocumentSemanticTokensProvider.js';
|
||||
import { PromptCodeActionProvider } from './languageProviders/promptCodeActions.js';
|
||||
import { ILanguageFeaturesService } from '../../../../../editor/common/services/languageFeatures.js';
|
||||
import { Disposable } from '../../../../../base/common/lifecycle.js';
|
||||
import { ALL_PROMPTS_LANGUAGE_SELECTOR } from './promptTypes.js';
|
||||
import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';
|
||||
|
||||
export class PromptLanguageFeaturesProvider extends Disposable implements IWorkbenchContribution {
|
||||
static readonly ID = 'chat.promptLanguageFeatures';
|
||||
|
||||
/**
|
||||
* Function that registers all prompt-file related contributions.
|
||||
*/
|
||||
export function registerPromptFileContributions(): void {
|
||||
constructor(
|
||||
@ILanguageFeaturesService languageService: ILanguageFeaturesService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
) {
|
||||
super();
|
||||
|
||||
// all language constributions
|
||||
this._register(languageService.linkProvider.register(ALL_PROMPTS_LANGUAGE_SELECTOR, instantiationService.createInstance(PromptLinkProvider)));
|
||||
this._register(languageService.completionProvider.register(ALL_PROMPTS_LANGUAGE_SELECTOR, instantiationService.createInstance(PromptBodyAutocompletion)));
|
||||
this._register(languageService.completionProvider.register(ALL_PROMPTS_LANGUAGE_SELECTOR, instantiationService.createInstance(PromptHeaderAutocompletion)));
|
||||
this._register(languageService.hoverProvider.register(ALL_PROMPTS_LANGUAGE_SELECTOR, instantiationService.createInstance(PromptHoverProvider)));
|
||||
this._register(languageService.definitionProvider.register(ALL_PROMPTS_LANGUAGE_SELECTOR, instantiationService.createInstance(PromptHeaderDefinitionProvider)));
|
||||
this._register(languageService.documentSemanticTokensProvider.register(ALL_PROMPTS_LANGUAGE_SELECTOR, instantiationService.createInstance(PromptDocumentSemanticTokensProvider)));
|
||||
this._register(languageService.codeActionProvider.register(ALL_PROMPTS_LANGUAGE_SELECTOR, instantiationService.createInstance(PromptCodeActionProvider)));
|
||||
|
||||
registerContribution(PromptLinkProvider);
|
||||
registerContribution(PromptValidatorContribution);
|
||||
|
||||
registerContribution(PromptBodyAutocompletion);
|
||||
registerContribution(PromptHeaderAutocompletion);
|
||||
registerContribution(PromptHoverProvider);
|
||||
registerContribution(PromptHeaderDefinitionProvider);
|
||||
registerContribution(PromptDocumentSemanticTokensProvider);
|
||||
registerContribution(PromptCodeActionProvider);
|
||||
registerContribution(ConfigMigration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Type for a generic workbench contribution.
|
||||
*/
|
||||
export type TContribution = new (...args: any[]) => IWorkbenchContribution;
|
||||
|
||||
/**
|
||||
* Register a specific workbench contribution.
|
||||
*/
|
||||
function registerContribution(contribution: TContribution): void {
|
||||
Registry.as<IWorkbenchContributionsRegistry>(Extensions.Workbench).registerWorkbenchContribution(contribution, LifecyclePhase.Eventually);
|
||||
this._register(instantiationService.createInstance(PromptValidatorContribution));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../../base/test/common/utils.js';
|
||||
import { URI } from '../../../../../../base/common/uri.js';
|
||||
import { NewPromptsParser } from '../../../common/promptSyntax/service/newPromptsParser.js';
|
||||
import { PromptValidator } from '../../../common/promptSyntax/service/promptValidator.js';
|
||||
import { PromptValidator } from '../../../common/promptSyntax/languageProviders/promptValidator.js';
|
||||
import { TestInstantiationService } from '../../../../../../platform/instantiation/test/common/instantiationServiceMock.js';
|
||||
import { TestConfigurationService } from '../../../../../../platform/configuration/test/common/testConfigurationService.js';
|
||||
import { PromptsConfig } from '../../../common/promptSyntax/config/config.js';
|
||||
|
||||
Reference in New Issue
Block a user