Path: blob/main/extensions/copilot/src/extension/settingsSchema/vscode-node/settingsSchemaFeature.ts
13399 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Uri } from 'vscode';6import { IAuthenticationService } from '../../../platform/authentication/common/authentication';7import { globalConfigRegistry } from '../../../platform/configuration/common/configurationService';8import { JsonSchema } from '../../../platform/configuration/common/jsonSchema';9import { Disposable } from '../../../util/vs/base/common/lifecycle';10import { autorunWithStore, IReader, observableFromEvent } from '../../../util/vs/base/common/observable';11import { VirtualTextDocumentProvider } from '../../inlineEdits/vscode-node/utils/virtualTextDocumentProvider';1213export class SettingsSchemaFeature extends Disposable {14private readonly _copilotToken = observableFromEvent(this, this._authenticationService.onDidAuthenticationChange, () => this._authenticationService.copilotToken);15private readonly _isInternal = this._copilotToken.map(t => !!(t?.isInternal));1617constructor(18@IAuthenticationService private readonly _authenticationService: IAuthenticationService,19) {20super();2122this._register(autorunWithStore((reader, store) => {23const p = store.add(new VirtualTextDocumentProvider('ccsettings'));24const doc = p.createDocumentForUri(Uri.parse('ccsettings://root/schema.json'));25const schema = this._getSchema(reader);26doc.setContent(JSON.stringify(schema));27}));28}2930private _getSchema(reader: IReader): JsonSchema {31const props: Record<string, JsonSchema> = {};3233if (!this._isInternal.read(reader)) {34return {};35} else {36// JSON Schema only for internal users!37for (const c of globalConfigRegistry.configs.values()) {38props[c.fullyQualifiedId] = { description: 'Recognized Advanced Setting.\nIgnore the warning "Unknown Configuration Setting", which cannot be surpressed.', ... (c.validator ? c.validator.toSchema() : {}) };39}4041const schema: JsonSchema = {42type: 'object',43properties: props,44patternProperties: {45'github\.copilot(\.chat)?\.advanced\..*': {46deprecated: true,47description: 'Unknown advanced setting.\nIf you believe this is a supported setting, please file an issue so that it gets registered.',48}49}50};51return schema;52}53}54}555657