@vscode/chat-lib 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.d.ts +2 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.js +70 -28
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.d.ts +4 -3
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.js +85 -109
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.js.map +1 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.d.ts.map +1 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.js +14 -6
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.js.map +1 -1
- package/dist/src/_internal/extension/xtab/common/promptCrafting.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/common/promptCrafting.js +6 -5
- package/dist/src/_internal/extension/xtab/common/promptCrafting.js.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabProvider.d.ts +1 -0
- package/dist/src/_internal/extension/xtab/node/xtabProvider.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabProvider.js +44 -42
- package/dist/src/_internal/extension/xtab/node/xtabProvider.js.map +1 -1
- package/dist/src/_internal/platform/authentication/node/copilotTokenManager.d.ts.map +1 -1
- package/dist/src/_internal/platform/authentication/node/copilotTokenManager.js +8 -4
- package/dist/src/_internal/platform/authentication/node/copilotTokenManager.js.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts +8 -0
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.js +11 -3
- package/dist/src/_internal/platform/configuration/common/configurationService.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/capiClient.d.ts +1 -1
- package/dist/src/_internal/platform/endpoint/common/capiClient.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/capiClient.js +2 -2
- package/dist/src/_internal/platform/endpoint/common/capiClient.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.d.ts +4 -0
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.js +7 -0
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/capiClientImpl.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/capiClientImpl.js +1 -1
- package/dist/src/_internal/platform/endpoint/node/capiClientImpl.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.d.ts +1 -1
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/responsesApi.js +10 -4
- package/dist/src/_internal/platform/endpoint/node/responsesApi.js.map +1 -1
- package/dist/src/_internal/platform/env/common/envService.d.ts +5 -0
- package/dist/src/_internal/platform/env/common/envService.d.ts.map +1 -1
- package/dist/src/_internal/platform/env/common/envService.js +2 -1
- package/dist/src/_internal/platform/env/common/envService.js.map +1 -1
- package/dist/src/_internal/platform/env/common/nullEnvService.d.ts +3 -0
- package/dist/src/_internal/platform/env/common/nullEnvService.d.ts.map +1 -1
- package/dist/src/_internal/platform/env/common/nullEnvService.js +8 -1
- package/dist/src/_internal/platform/env/common/nullEnvService.js.map +1 -1
- package/dist/src/_internal/platform/github/common/githubService.d.ts +3 -3
- package/dist/src/_internal/platform/github/common/githubService.d.ts.map +1 -1
- package/dist/src/_internal/platform/github/common/githubService.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.d.ts +0 -3
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.js +0 -5
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.js.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetcherService.d.ts +2 -1
- package/dist/src/_internal/platform/networking/common/fetcherService.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetcherService.js.map +1 -1
- package/dist/src/_internal/platform/networking/common/networking.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/networking.js.map +1 -1
- package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.d.ts +7 -0
- package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.d.ts.map +1 -1
- package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.js +1 -0
- package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.js.map +1 -1
- package/dist/src/_internal/platform/telemetry/common/telemetry.d.ts +1 -0
- package/dist/src/_internal/platform/telemetry/common/telemetry.d.ts.map +1 -1
- package/dist/src/_internal/platform/telemetry/common/telemetry.js.map +1 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts +8 -0
- package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts.map +1 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.js +19 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.js.map +1 -1
- package/dist/src/_internal/util/common/test/shims/enums.d.ts +6 -0
- package/dist/src/_internal/util/common/test/shims/enums.d.ts.map +1 -1
- package/dist/src/_internal/util/common/test/shims/enums.js +8 -1
- package/dist/src/_internal/util/common/test/shims/enums.js.map +1 -1
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.d.ts.map +1 -1
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js +9 -1
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js.map +1 -1
- package/dist/src/_internal/vscodeTypes.d.ts +5 -0
- package/dist/src/_internal/vscodeTypes.d.ts.map +1 -1
- package/dist/src/_internal/vscodeTypes.js +6 -1
- package/dist/src/_internal/vscodeTypes.js.map +1 -1
- package/dist/src/main.d.ts +15 -1
- package/dist/src/main.d.ts.map +1 -1
- package/dist/src/main.js +73 -13
- package/dist/src/main.js.map +1 -1
- package/dist/src/package.json +70 -31
- package/package.json +7 -9
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/fragments.d.ts +0 -42
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/fragments.d.ts.map +0 -1
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/fragments.js +0 -125
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/fragments.js.map +0 -1
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/implementation.d.ts +0 -60
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/implementation.d.ts.map +0 -1
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/implementation.js +0 -416
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/implementation.js.map +0 -1
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/projectedText.d.ts +0 -30
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/projectedText.d.ts.map +0 -1
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/projectedText.js +0 -64
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/projectedText.js.map +0 -1
- package/dist/src/_internal/extension/prompts/node/inline/visualization.d.ts +0 -26
- package/dist/src/_internal/extension/prompts/node/inline/visualization.d.ts.map +0 -1
- package/dist/src/_internal/extension/prompts/node/inline/visualization.js +0 -41
- package/dist/src/_internal/extension/prompts/node/inline/visualization.js.map +0 -1
- package/dist/src/_internal/platform/editing/common/abstractText.d.ts +0 -58
- package/dist/src/_internal/platform/editing/common/abstractText.d.ts.map +0 -1
- package/dist/src/_internal/platform/editing/common/abstractText.js +0 -129
- package/dist/src/_internal/platform/editing/common/abstractText.js.map +0 -1
- package/dist/src/_internal/platform/parser/node/nodes.d.ts +0 -93
- package/dist/src/_internal/platform/parser/node/nodes.d.ts.map +0 -1
- package/dist/src/_internal/platform/parser/node/nodes.js +0 -133
- package/dist/src/_internal/platform/parser/node/nodes.js.map +0 -1
- package/dist/src/_internal/platform/telemetry/common/nullTelemetryService.d.ts +0 -18
- package/dist/src/_internal/platform/telemetry/common/nullTelemetryService.d.ts.map +0 -1
- package/dist/src/_internal/platform/telemetry/common/nullTelemetryService.js +0 -50
- package/dist/src/_internal/platform/telemetry/common/nullTelemetryService.js.map +0 -1
- package/dist/src/_internal/util/common/arrays.d.ts +0 -18
- package/dist/src/_internal/util/common/arrays.d.ts.map +0 -1
- package/dist/src/_internal/util/common/arrays.js +0 -80
- package/dist/src/_internal/util/common/arrays.js.map +0 -1
- package/src/_internal/extension/byok/node/openAIEndpoint.ts +0 -171
- package/src/_internal/extension/common/constants.ts +0 -90
- package/src/_internal/extension/inlineEdits/common/delayer.ts +0 -108
- package/src/_internal/extension/inlineEdits/common/editRebase.ts +0 -268
- package/src/_internal/extension/inlineEdits/common/ghNearbyNesProvider.tsx +0 -163
- package/src/_internal/extension/inlineEdits/common/nearbyCursorInlineEditProvider.ts +0 -225
- package/src/_internal/extension/inlineEdits/common/rejectionCollector.ts +0 -164
- package/src/_internal/extension/inlineEdits/node/debugRecorder.ts +0 -205
- package/src/_internal/extension/inlineEdits/node/importFiltering.ts +0 -25
- package/src/_internal/extension/inlineEdits/node/nesConfigs.ts +0 -12
- package/src/_internal/extension/inlineEdits/node/nextEditCache.ts +0 -278
- package/src/_internal/extension/inlineEdits/node/nextEditProvider.ts +0 -778
- package/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.ts +0 -983
- package/src/_internal/extension/inlineEdits/node/nextEditResult.ts +0 -40
- package/src/_internal/extension/prompt/common/importStatement.ts +0 -25
- package/src/_internal/extension/prompt/node/chatMLFetcher.ts +0 -706
- package/src/_internal/extension/prompts/node/inline/summarizedDocument/fragments.ts +0 -146
- package/src/_internal/extension/prompts/node/inline/summarizedDocument/implementation.ts +0 -527
- package/src/_internal/extension/prompts/node/inline/summarizedDocument/projectedText.ts +0 -76
- package/src/_internal/extension/prompts/node/inline/visualization.ts +0 -65
- package/src/_internal/extension/vscode.proposed.activeComment.d.ts +0 -23
- package/src/_internal/extension/vscode.proposed.aiRelatedInformation.d.ts +0 -49
- package/src/_internal/extension/vscode.proposed.aiSettingsSearch.d.ts +0 -31
- package/src/_internal/extension/vscode.proposed.aiTextSearchProvider.d.ts +0 -41
- package/src/_internal/extension/vscode.proposed.authLearnMore.d.ts +0 -16
- package/src/_internal/extension/vscode.proposed.chatBinaryReferenceData.d.ts +0 -41
- package/src/_internal/extension/vscode.proposed.chatEditing.d.ts +0 -29
- package/src/_internal/extension/vscode.proposed.chatParticipantAdditions.d.ts +0 -636
- package/src/_internal/extension/vscode.proposed.chatParticipantPrivate.d.ts +0 -276
- package/src/_internal/extension/vscode.proposed.chatProvider.d.ts +0 -62
- package/src/_internal/extension/vscode.proposed.chatReadonlyPromptReference.d.ts +0 -17
- package/src/_internal/extension/vscode.proposed.chatReferenceDiagnostic.d.ts +0 -23
- package/src/_internal/extension/vscode.proposed.chatSessionsProvider.d.ts +0 -218
- package/src/_internal/extension/vscode.proposed.chatStatusItem.d.ts +0 -61
- package/src/_internal/extension/vscode.proposed.codeActionAI.d.ts +0 -16
- package/src/_internal/extension/vscode.proposed.commentReveal.d.ts +0 -32
- package/src/_internal/extension/vscode.proposed.contribCommentThreadAdditionalMenu.d.ts +0 -8
- package/src/_internal/extension/vscode.proposed.contribCommentsViewThreadMenus.d.ts +0 -6
- package/src/_internal/extension/vscode.proposed.contribSourceControlInputBoxMenu.d.ts +0 -7
- package/src/_internal/extension/vscode.proposed.dataChannels.d.ts +0 -19
- package/src/_internal/extension/vscode.proposed.defaultChatParticipant.d.ts +0 -52
- package/src/_internal/extension/vscode.proposed.documentFiltersExclusive.d.ts +0 -13
- package/src/_internal/extension/vscode.proposed.embeddings.d.ts +0 -33
- package/src/_internal/extension/vscode.proposed.extensionsAny.d.ts +0 -40
- package/src/_internal/extension/vscode.proposed.findFiles2.d.ts +0 -125
- package/src/_internal/extension/vscode.proposed.findTextInFiles.d.ts +0 -104
- package/src/_internal/extension/vscode.proposed.findTextInFiles2.d.ts +0 -144
- package/src/_internal/extension/vscode.proposed.inlineCompletionsAdditions.d.ts +0 -202
- package/src/_internal/extension/vscode.proposed.interactive.d.ts +0 -11
- package/src/_internal/extension/vscode.proposed.languageModelCapabilities.d.ts +0 -25
- package/src/_internal/extension/vscode.proposed.languageModelDataPart.d.ts +0 -163
- package/src/_internal/extension/vscode.proposed.languageModelSystem.d.ts +0 -17
- package/src/_internal/extension/vscode.proposed.languageModelThinkingPart.d.ts +0 -49
- package/src/_internal/extension/vscode.proposed.languageModelToolResultAudience.d.ts +0 -36
- package/src/_internal/extension/vscode.proposed.mappedEditsProvider.d.ts +0 -110
- package/src/_internal/extension/vscode.proposed.newSymbolNamesProvider.d.ts +0 -47
- package/src/_internal/extension/vscode.proposed.readonlyMessage.d.ts +0 -14
- package/src/_internal/extension/vscode.proposed.resolvers.d.ts +0 -475
- package/src/_internal/extension/vscode.proposed.scmInputBoxValueProvider.d.ts +0 -25
- package/src/_internal/extension/vscode.proposed.taskProblemMatcherStatus.d.ts +0 -42
- package/src/_internal/extension/vscode.proposed.terminalDataWriteEvent.d.ts +0 -32
- package/src/_internal/extension/vscode.proposed.terminalExecuteCommandEvent.d.ts +0 -48
- package/src/_internal/extension/vscode.proposed.terminalQuickFixProvider.d.ts +0 -87
- package/src/_internal/extension/vscode.proposed.terminalSelection.d.ts +0 -16
- package/src/_internal/extension/vscode.proposed.testObserver.d.ts +0 -199
- package/src/_internal/extension/vscode.proposed.textDocumentChangeReason.d.ts +0 -30
- package/src/_internal/extension/vscode.proposed.textSearchProvider.d.ts +0 -281
- package/src/_internal/extension/vscode.proposed.textSearchProvider2.d.ts +0 -297
- package/src/_internal/extension/xtab/common/promptCrafting.ts +0 -670
- package/src/_internal/extension/xtab/node/xtabEndpoint.ts +0 -102
- package/src/_internal/extension/xtab/node/xtabProvider.ts +0 -976
- package/src/_internal/extension/xtab/node/xtabUtils.ts +0 -62
- package/src/_internal/platform/authentication/common/authentication.ts +0 -309
- package/src/_internal/platform/authentication/common/copilotToken.ts +0 -300
- package/src/_internal/platform/authentication/common/copilotTokenManager.ts +0 -59
- package/src/_internal/platform/authentication/common/copilotTokenStore.ts +0 -40
- package/src/_internal/platform/authentication/common/staticGitHubAuthenticationService.ts +0 -96
- package/src/_internal/platform/authentication/node/copilotTokenManager.ts +0 -303
- package/src/_internal/platform/chat/common/chatMLFetcher.ts +0 -124
- package/src/_internal/platform/chat/common/chatQuotaService.ts +0 -63
- package/src/_internal/platform/chat/common/chatQuotaServiceImpl.ts +0 -96
- package/src/_internal/platform/chat/common/commonTypes.ts +0 -353
- package/src/_internal/platform/chat/common/conversationOptions.ts +0 -16
- package/src/_internal/platform/chat/common/globalStringUtils.ts +0 -54
- package/src/_internal/platform/chat/common/interactionService.ts +0 -35
- package/src/_internal/platform/configuration/common/configurationService.ts +0 -803
- package/src/_internal/platform/configuration/common/defaultsOnlyConfigurationService.ts +0 -39
- package/src/_internal/platform/configuration/common/jsonSchema.ts +0 -139
- package/src/_internal/platform/configuration/common/validator.ts +0 -242
- package/src/_internal/platform/diff/common/diffService.ts +0 -41
- package/src/_internal/platform/diff/common/diffWorker.ts +0 -83
- package/src/_internal/platform/diff/node/diffServiceImpl.ts +0 -85
- package/src/_internal/platform/editing/common/abstractText.ts +0 -177
- package/src/_internal/platform/editing/common/notebookDocumentSnapshot.ts +0 -122
- package/src/_internal/platform/editing/common/positionOffsetTransformer.ts +0 -202
- package/src/_internal/platform/editing/common/textDocumentSnapshot.ts +0 -274
- package/src/_internal/platform/endpoint/common/capiClient.ts +0 -37
- package/src/_internal/platform/endpoint/common/chatModelCapabilities.ts +0 -115
- package/src/_internal/platform/endpoint/common/domainService.ts +0 -27
- package/src/_internal/platform/endpoint/common/endpointProvider.ts +0 -104
- package/src/_internal/platform/endpoint/common/endpointTypes.ts +0 -12
- package/src/_internal/platform/endpoint/common/licenseAgreement.ts +0 -11
- package/src/_internal/platform/endpoint/common/statefulMarkerContainer.tsx +0 -85
- package/src/_internal/platform/endpoint/common/thinkingDataContainer.tsx +0 -44
- package/src/_internal/platform/endpoint/node/capiClientImpl.ts +0 -18
- package/src/_internal/platform/endpoint/node/chatEndpoint.ts +0 -435
- package/src/_internal/platform/endpoint/node/domainServiceImpl.ts +0 -80
- package/src/_internal/platform/endpoint/node/proxyXtabEndpoint.ts +0 -43
- package/src/_internal/platform/endpoint/node/responsesApi.ts +0 -326
- package/src/_internal/platform/env/common/envService.ts +0 -134
- package/src/_internal/platform/env/common/nullEnvService.ts +0 -68
- package/src/_internal/platform/env/common/packagejson.ts +0 -49
- package/src/_internal/platform/git/common/gitExtensionService.ts +0 -21
- package/src/_internal/platform/git/common/nullGitExtensionService.ts +0 -20
- package/src/_internal/platform/git/vscode/git.d.ts +0 -414
- package/src/_internal/platform/github/common/githubAPI.ts +0 -44
- package/src/_internal/platform/github/common/githubService.ts +0 -87
- package/src/_internal/platform/github/common/nullOctokitServiceImpl.ts +0 -21
- package/src/_internal/platform/ignore/common/ignoreService.ts +0 -72
- package/src/_internal/platform/inlineCompletions/common/api.ts +0 -198
- package/src/_internal/platform/inlineEdits/common/dataTypes/diagnosticData.ts +0 -32
- package/src/_internal/platform/inlineEdits/common/dataTypes/documentId.ts +0 -52
- package/src/_internal/platform/inlineEdits/common/dataTypes/edit.ts +0 -165
- package/src/_internal/platform/inlineEdits/common/dataTypes/editUtils.ts +0 -74
- package/src/_internal/platform/inlineEdits/common/dataTypes/fetchCancellationError.ts +0 -14
- package/src/_internal/platform/inlineEdits/common/dataTypes/languageContext.ts +0 -107
- package/src/_internal/platform/inlineEdits/common/dataTypes/languageId.ts +0 -14
- package/src/_internal/platform/inlineEdits/common/dataTypes/permutation.ts +0 -69
- package/src/_internal/platform/inlineEdits/common/dataTypes/rootedLineEdit.ts +0 -49
- package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLength.ts +0 -74
- package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/combineTextEditInfos.ts +0 -132
- package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/length.ts +0 -184
- package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/textEditInfo.ts +0 -32
- package/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.ts +0 -89
- package/src/_internal/platform/inlineEdits/common/debugRecorderBookmark.ts +0 -10
- package/src/_internal/platform/inlineEdits/common/editReason.ts +0 -134
- package/src/_internal/platform/inlineEdits/common/inlineEditLogContext.ts +0 -490
- package/src/_internal/platform/inlineEdits/common/observableGit.ts +0 -49
- package/src/_internal/platform/inlineEdits/common/observableWorkspace.ts +0 -239
- package/src/_internal/platform/inlineEdits/common/responseProcessor.ts +0 -249
- package/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.ts +0 -468
- package/src/_internal/platform/inlineEdits/common/statelessNextEditProviders.ts +0 -59
- package/src/_internal/platform/inlineEdits/common/utils/observable.ts +0 -54
- package/src/_internal/platform/inlineEdits/common/utils/stringifyChatMessages.ts +0 -29
- package/src/_internal/platform/inlineEdits/common/utils/utils.ts +0 -56
- package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/historyContextProvider.ts +0 -60
- package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/nesHistoryContextProvider.ts +0 -353
- package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/nesXtabHistoryTracker.ts +0 -176
- package/src/_internal/platform/languageContextProvider/common/languageContextProviderService.ts +0 -25
- package/src/_internal/platform/languageContextProvider/common/nullLanguageContextProviderService.ts +0 -38
- package/src/_internal/platform/languageServer/common/languageContextService.ts +0 -186
- package/src/_internal/platform/languages/common/languageDiagnosticsService.ts +0 -67
- package/src/_internal/platform/languages/common/testLanguageDiagnosticsService.ts +0 -28
- package/src/_internal/platform/log/common/logService.ts +0 -232
- package/src/_internal/platform/nesFetch/common/completionsAPI.ts +0 -78
- package/src/_internal/platform/nesFetch/common/completionsFetchService.ts +0 -118
- package/src/_internal/platform/nesFetch/common/responseStream.ts +0 -151
- package/src/_internal/platform/nesFetch/node/completionsFetchServiceImpl.ts +0 -236
- package/src/_internal/platform/nesFetch/node/streamTransformer.ts +0 -95
- package/src/_internal/platform/networking/common/fetch.ts +0 -349
- package/src/_internal/platform/networking/common/fetcherService.ts +0 -84
- package/src/_internal/platform/networking/common/networking.ts +0 -442
- package/src/_internal/platform/networking/common/openai.ts +0 -273
- package/src/_internal/platform/networking/node/chatStream.ts +0 -137
- package/src/_internal/platform/networking/node/stream.ts +0 -749
- package/src/_internal/platform/notebook/common/alternativeContent.ts +0 -89
- package/src/_internal/platform/notebook/common/alternativeContentFormat.ts +0 -10
- package/src/_internal/platform/notebook/common/alternativeContentProvider.json.ts +0 -262
- package/src/_internal/platform/notebook/common/alternativeContentProvider.text.ts +0 -243
- package/src/_internal/platform/notebook/common/alternativeContentProvider.ts +0 -41
- package/src/_internal/platform/notebook/common/alternativeContentProvider.xml.ts +0 -205
- package/src/_internal/platform/notebook/common/alternativeNotebookDocument.ts +0 -155
- package/src/_internal/platform/notebook/common/helpers.ts +0 -212
- package/src/_internal/platform/notebook/common/notebookService.ts +0 -43
- package/src/_internal/platform/openai/node/fetch.ts +0 -596
- package/src/_internal/platform/parser/node/nodes.ts +0 -190
- package/src/_internal/platform/requestLogger/node/nullRequestLogger.ts +0 -26
- package/src/_internal/platform/requestLogger/node/requestLogger.ts +0 -383
- package/src/_internal/platform/simulationTestContext/common/simulationTestContext.ts +0 -29
- package/src/_internal/platform/snippy/common/snippyService.ts +0 -25
- package/src/_internal/platform/telemetry/common/nullExperimentationService.ts +0 -64
- package/src/_internal/platform/telemetry/common/nullTelemetryService.ts +0 -53
- package/src/_internal/platform/telemetry/common/telemetry.ts +0 -215
- package/src/_internal/platform/telemetry/common/telemetryData.ts +0 -205
- package/src/_internal/platform/thinking/common/thinking.ts +0 -61
- package/src/_internal/platform/thinking/common/thinkingUtils.ts +0 -57
- package/src/_internal/platform/tokenizer/node/parseTikTokens.ts +0 -23
- package/src/_internal/platform/tokenizer/node/tikTokenizerImpl.ts +0 -74
- package/src/_internal/platform/tokenizer/node/tikTokenizerWorker.ts +0 -24
- package/src/_internal/platform/tokenizer/node/tokenizer.ts +0 -357
- package/src/_internal/platform/workspace/common/workspaceService.ts +0 -226
- package/src/_internal/platform/workspaceRecorder/common/workspaceLog.ts +0 -118
- package/src/_internal/util/common/anomalyDetection.ts +0 -112
- package/src/_internal/util/common/arrays.ts +0 -81
- package/src/_internal/util/common/async.ts +0 -155
- package/src/_internal/util/common/cache.ts +0 -183
- package/src/_internal/util/common/crypto.ts +0 -41
- package/src/_internal/util/common/errors.ts +0 -22
- package/src/_internal/util/common/globals.d.ts +0 -12
- package/src/_internal/util/common/imageUtils.ts +0 -154
- package/src/_internal/util/common/languages.ts +0 -940
- package/src/_internal/util/common/notebooks.ts +0 -286
- package/src/_internal/util/common/result.ts +0 -71
- package/src/_internal/util/common/services.ts +0 -43
- package/src/_internal/util/common/test/shims/chatTypes.ts +0 -448
- package/src/_internal/util/common/test/shims/editing.ts +0 -233
- package/src/_internal/util/common/test/shims/enums.ts +0 -61
- package/src/_internal/util/common/test/shims/l10n.ts +0 -37
- package/src/_internal/util/common/test/shims/newSymbolName.ts +0 -23
- package/src/_internal/util/common/test/shims/terminal.ts +0 -33
- package/src/_internal/util/common/test/shims/vscodeTypesShim.ts +0 -115
- package/src/_internal/util/common/time.ts +0 -31
- package/src/_internal/util/common/tokenizer.ts +0 -30
- package/src/_internal/util/common/tracing.ts +0 -52
- package/src/_internal/util/common/types.ts +0 -33
- package/src/_internal/util/common/variableLengthQuantity.ts +0 -40
- package/src/_internal/util/node/worker.ts +0 -130
- package/src/_internal/util/vs/base/common/arrays.ts +0 -926
- package/src/_internal/util/vs/base/common/arraysFind.ts +0 -206
- package/src/_internal/util/vs/base/common/assert.ts +0 -89
- package/src/_internal/util/vs/base/common/async.ts +0 -2582
- package/src/_internal/util/vs/base/common/buffer.ts +0 -501
- package/src/_internal/util/vs/base/common/cache.ts +0 -122
- package/src/_internal/util/vs/base/common/cancellation.ts +0 -150
- package/src/_internal/util/vs/base/common/charCode.ts +0 -452
- package/src/_internal/util/vs/base/common/codicons.ts +0 -66
- package/src/_internal/util/vs/base/common/codiconsLibrary.ts +0 -618
- package/src/_internal/util/vs/base/common/codiconsUtil.ts +0 -30
- package/src/_internal/util/vs/base/common/collections.ts +0 -156
- package/src/_internal/util/vs/base/common/diff/diff.ts +0 -1317
- package/src/_internal/util/vs/base/common/diff/diffChange.ts +0 -62
- package/src/_internal/util/vs/base/common/equals.ts +0 -148
- package/src/_internal/util/vs/base/common/errors.ts +0 -342
- package/src/_internal/util/vs/base/common/event.ts +0 -1782
- package/src/_internal/util/vs/base/common/extpath.ts +0 -425
- package/src/_internal/util/vs/base/common/filters.ts +0 -928
- package/src/_internal/util/vs/base/common/functional.ts +0 -34
- package/src/_internal/util/vs/base/common/glob.ts +0 -839
- package/src/_internal/util/vs/base/common/hash.ts +0 -326
- package/src/_internal/util/vs/base/common/htmlContent.ts +0 -212
- package/src/_internal/util/vs/base/common/iconLabels.ts +0 -118
- package/src/_internal/util/vs/base/common/iterator.ts +0 -196
- package/src/_internal/util/vs/base/common/lazy.ts +0 -59
- package/src/_internal/util/vs/base/common/lifecycle.ts +0 -845
- package/src/_internal/util/vs/base/common/linkedList.ts +0 -144
- package/src/_internal/util/vs/base/common/map.ts +0 -954
- package/src/_internal/util/vs/base/common/marshallingIds.ts +0 -35
- package/src/_internal/util/vs/base/common/mime.ts +0 -136
- package/src/_internal/util/vs/base/common/naturalLanguage/korean.ts +0 -425
- package/src/_internal/util/vs/base/common/network.ts +0 -429
- package/src/_internal/util/vs/base/common/numbers.ts +0 -166
- package/src/_internal/util/vs/base/common/objects.ts +0 -242
- package/src/_internal/util/vs/base/common/observable.ts +0 -10
- package/src/_internal/util/vs/base/common/observableInternal/base.ts +0 -208
- package/src/_internal/util/vs/base/common/observableInternal/changeTracker.ts +0 -96
- package/src/_internal/util/vs/base/common/observableInternal/commonFacade/cancellation.ts +0 -9
- package/src/_internal/util/vs/base/common/observableInternal/commonFacade/deps.ts +0 -12
- package/src/_internal/util/vs/base/common/observableInternal/debugLocation.ts +0 -88
- package/src/_internal/util/vs/base/common/observableInternal/debugName.ts +0 -150
- package/src/_internal/util/vs/base/common/observableInternal/experimental/utils.ts +0 -62
- package/src/_internal/util/vs/base/common/observableInternal/index.ts +0 -61
- package/src/_internal/util/vs/base/common/observableInternal/logging/consoleObservableLogger.ts +0 -388
- package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/debuggerApi.d.ts +0 -154
- package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/debuggerRpc.ts +0 -80
- package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/devToolsLogger.ts +0 -485
- package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/rpc.ts +0 -103
- package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/utils.ts +0 -69
- package/src/_internal/util/vs/base/common/observableInternal/logging/logging.ts +0 -133
- package/src/_internal/util/vs/base/common/observableInternal/map.ts +0 -81
- package/src/_internal/util/vs/base/common/observableInternal/observables/baseObservable.ts +0 -172
- package/src/_internal/util/vs/base/common/observableInternal/observables/constObservable.ts +0 -44
- package/src/_internal/util/vs/base/common/observableInternal/observables/derived.ts +0 -190
- package/src/_internal/util/vs/base/common/observableInternal/observables/derivedImpl.ts +0 -445
- package/src/_internal/util/vs/base/common/observableInternal/observables/lazyObservableValue.ts +0 -154
- package/src/_internal/util/vs/base/common/observableInternal/observables/observableFromEvent.ts +0 -174
- package/src/_internal/util/vs/base/common/observableInternal/observables/observableSignal.ts +0 -67
- package/src/_internal/util/vs/base/common/observableInternal/observables/observableSignalFromEvent.ts +0 -62
- package/src/_internal/util/vs/base/common/observableInternal/observables/observableValue.ts +0 -131
- package/src/_internal/util/vs/base/common/observableInternal/observables/observableValueOpts.ts +0 -37
- package/src/_internal/util/vs/base/common/observableInternal/reactions/autorun.ts +0 -188
- package/src/_internal/util/vs/base/common/observableInternal/reactions/autorunImpl.ts +0 -256
- package/src/_internal/util/vs/base/common/observableInternal/set.ts +0 -78
- package/src/_internal/util/vs/base/common/observableInternal/transaction.ts +0 -115
- package/src/_internal/util/vs/base/common/observableInternal/utils/promise.ts +0 -129
- package/src/_internal/util/vs/base/common/observableInternal/utils/runOnChange.ts +0 -65
- package/src/_internal/util/vs/base/common/observableInternal/utils/utils.ts +0 -281
- package/src/_internal/util/vs/base/common/observableInternal/utils/utilsCancellation.ts +0 -101
- package/src/_internal/util/vs/base/common/observableInternal/utils/valueWithChangeEvent.ts +0 -31
- package/src/_internal/util/vs/base/common/path.ts +0 -1591
- package/src/_internal/util/vs/base/common/platform.ts +0 -282
- package/src/_internal/util/vs/base/common/process.ts +0 -78
- package/src/_internal/util/vs/base/common/resources.ts +0 -446
- package/src/_internal/util/vs/base/common/sequence.ts +0 -36
- package/src/_internal/util/vs/base/common/sseParser.ts +0 -247
- package/src/_internal/util/vs/base/common/stopwatch.ts +0 -43
- package/src/_internal/util/vs/base/common/stream.ts +0 -792
- package/src/_internal/util/vs/base/common/strings.ts +0 -1364
- package/src/_internal/util/vs/base/common/symbols.ts +0 -11
- package/src/_internal/util/vs/base/common/themables.ts +0 -106
- package/src/_internal/util/vs/base/common/types.ts +0 -345
- package/src/_internal/util/vs/base/common/uint.ts +0 -61
- package/src/_internal/util/vs/base/common/uri.ts +0 -752
- package/src/_internal/util/vs/base/common/uuid.ts +0 -72
- package/src/_internal/util/vs/base-common.d.ts +0 -42
- package/src/_internal/util/vs/editor/common/core/editOperation.ts +0 -62
- package/src/_internal/util/vs/editor/common/core/edits/edit.ts +0 -399
- package/src/_internal/util/vs/editor/common/core/edits/lineEdit.ts +0 -414
- package/src/_internal/util/vs/editor/common/core/edits/stringEdit.ts +0 -568
- package/src/_internal/util/vs/editor/common/core/edits/textEdit.ts +0 -411
- package/src/_internal/util/vs/editor/common/core/position.ts +0 -186
- package/src/_internal/util/vs/editor/common/core/range.ts +0 -519
- package/src/_internal/util/vs/editor/common/core/ranges/lineRange.ts +0 -416
- package/src/_internal/util/vs/editor/common/core/ranges/offsetRange.ts +0 -275
- package/src/_internal/util/vs/editor/common/core/text/abstractText.ts +0 -127
- package/src/_internal/util/vs/editor/common/core/text/positionToOffset.ts +0 -26
- package/src/_internal/util/vs/editor/common/core/text/positionToOffsetImpl.ts +0 -144
- package/src/_internal/util/vs/editor/common/core/text/textLength.ts +0 -150
- package/src/_internal/util/vs/editor/common/core/wordHelper.ts +0 -177
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/diffAlgorithm.ts +0 -210
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/dynamicProgrammingDiffing.ts +0 -109
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/myersDiffAlgorithm.ts +0 -178
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/computeMovedLines.ts +0 -331
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/defaultLinesDiffComputer.ts +0 -273
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/heuristicSequenceOptimizations.ts +0 -475
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/lineSequence.ts +0 -47
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/linesSliceCharSequence.ts +0 -248
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/utils.ts +0 -76
- package/src/_internal/util/vs/editor/common/diff/legacyLinesDiffComputer.ts +0 -693
- package/src/_internal/util/vs/editor/common/diff/linesDiffComputer.ts +0 -61
- package/src/_internal/util/vs/editor/common/diff/rangeMapping.ts +0 -418
- package/src/_internal/util/vs/editor/common/model/prefixSumComputer.ts +0 -304
- package/src/_internal/util/vs/nls.messages.ts +0 -21
- package/src/_internal/util/vs/nls.ts +0 -243
- package/src/_internal/util/vs/platform/instantiation/common/descriptors.ts +0 -23
- package/src/_internal/util/vs/platform/instantiation/common/graph.ts +0 -113
- package/src/_internal/util/vs/platform/instantiation/common/instantiation.ts +0 -127
- package/src/_internal/util/vs/platform/instantiation/common/instantiationService.ts +0 -483
- package/src/_internal/util/vs/platform/instantiation/common/serviceCollection.ts +0 -34
- package/src/_internal/util/vs/vscode-globals-nls.d.ts +0 -42
- package/src/_internal/util/vs/vscode-globals-product.d.ts +0 -35
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/diagnostic.ts +0 -109
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/es5ClassCompat.ts +0 -34
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/location.ts +0 -51
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/markdownString.ts +0 -83
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/notebooks.ts +0 -296
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/position.ts +0 -195
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/range.ts +0 -167
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/selection.ts +0 -94
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetString.ts +0 -103
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetTextEdit.ts +0 -44
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/symbolInformation.ts +0 -89
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/textEdit.ts +0 -99
- package/src/_internal/vscodeTypes.ts +0 -100
- package/src/main.ts +0 -207
- package/src/package.json +0 -4063
|
@@ -1,976 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
|
|
6
|
-
import { Raw } from '@vscode/prompt-tsx';
|
|
7
|
-
import { FetchStreamSource } from '../../../platform/chat/common/chatMLFetcher';
|
|
8
|
-
import { ChatFetchError, ChatFetchResponseType, ChatLocation } from '../../../platform/chat/common/commonTypes';
|
|
9
|
-
import { toTextParts } from '../../../platform/chat/common/globalStringUtils';
|
|
10
|
-
import { ConfigKey, IConfigurationService, XTabProviderId } from '../../../platform/configuration/common/configurationService';
|
|
11
|
-
import { IDiffService } from '../../../platform/diff/common/diffService';
|
|
12
|
-
import { createProxyXtabEndpoint } from '../../../platform/endpoint/node/proxyXtabEndpoint';
|
|
13
|
-
import { IIgnoreService } from '../../../platform/ignore/common/ignoreService';
|
|
14
|
-
import { Copilot } from '../../../platform/inlineCompletions/common/api';
|
|
15
|
-
import { LanguageContextEntry, LanguageContextResponse } from '../../../platform/inlineEdits/common/dataTypes/languageContext';
|
|
16
|
-
import { LanguageId } from '../../../platform/inlineEdits/common/dataTypes/languageId';
|
|
17
|
-
import * as xtabPromptOptions from '../../../platform/inlineEdits/common/dataTypes/xtabPromptOptions';
|
|
18
|
-
import { LanguageContextLanguages, LanguageContextOptions } from '../../../platform/inlineEdits/common/dataTypes/xtabPromptOptions';
|
|
19
|
-
import { InlineEditRequestLogContext } from '../../../platform/inlineEdits/common/inlineEditLogContext';
|
|
20
|
-
import { ResponseProcessor } from '../../../platform/inlineEdits/common/responseProcessor';
|
|
21
|
-
import { IStatelessNextEditProvider, NoNextEditReason, PushEdit, ShowNextEditPreference, StatelessNextEditDocument, StatelessNextEditRequest, StatelessNextEditResult, StatelessNextEditTelemetryBuilder } from '../../../platform/inlineEdits/common/statelessNextEditProvider';
|
|
22
|
-
import { IgnoreEmptyLineAndLeadingTrailingWhitespaceChanges, IgnoreWhitespaceOnlyChanges } from '../../../platform/inlineEdits/common/statelessNextEditProviders';
|
|
23
|
-
import { ILanguageContextProviderService } from '../../../platform/languageContextProvider/common/languageContextProviderService';
|
|
24
|
-
import { ILanguageDiagnosticsService } from '../../../platform/languages/common/languageDiagnosticsService';
|
|
25
|
-
import { ContextKind, SnippetContext } from '../../../platform/languageServer/common/languageContextService';
|
|
26
|
-
import { ILogService } from '../../../platform/log/common/logService';
|
|
27
|
-
import { OptionalChatRequestParams, Prediction } from '../../../platform/networking/common/fetch';
|
|
28
|
-
import { IChatEndpoint } from '../../../platform/networking/common/networking';
|
|
29
|
-
import { ISimulationTestContext } from '../../../platform/simulationTestContext/common/simulationTestContext';
|
|
30
|
-
import { IExperimentationService } from '../../../platform/telemetry/common/nullExperimentationService';
|
|
31
|
-
import { IWorkspaceService } from '../../../platform/workspace/common/workspaceService';
|
|
32
|
-
import { raceFilter } from '../../../util/common/async';
|
|
33
|
-
import * as errors from '../../../util/common/errors';
|
|
34
|
-
import { Result } from '../../../util/common/result';
|
|
35
|
-
import { createTracer, ITracer } from '../../../util/common/tracing';
|
|
36
|
-
import { AsyncIterableObject, DeferredPromise, raceTimeout, timeout } from '../../../util/vs/base/common/async';
|
|
37
|
-
import { CancellationToken } from '../../../util/vs/base/common/cancellation';
|
|
38
|
-
import { StopWatch } from '../../../util/vs/base/common/stopwatch';
|
|
39
|
-
import { LineEdit, LineReplacement } from '../../../util/vs/editor/common/core/edits/lineEdit';
|
|
40
|
-
import { StringEdit, StringReplacement } from '../../../util/vs/editor/common/core/edits/stringEdit';
|
|
41
|
-
import { Position } from '../../../util/vs/editor/common/core/position';
|
|
42
|
-
import { Range } from '../../../util/vs/editor/common/core/range';
|
|
43
|
-
import { LineRange } from '../../../util/vs/editor/common/core/ranges/lineRange';
|
|
44
|
-
import { OffsetRange } from '../../../util/vs/editor/common/core/ranges/offsetRange';
|
|
45
|
-
import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation';
|
|
46
|
-
import { Position as VscodePosition } from '../../../util/common/test/shims/vscodeTypesShim';
|
|
47
|
-
import { Delayer, DelaySession } from '../../inlineEdits/common/delayer';
|
|
48
|
-
import { editWouldDeleteWhatWasJustInserted } from '../../inlineEdits/common/ghNearbyNesProvider';
|
|
49
|
-
import { getOrDeduceSelectionFromLastEdit } from '../../inlineEdits/common/nearbyCursorInlineEditProvider';
|
|
50
|
-
import { IgnoreImportChangesAspect } from '../../inlineEdits/node/importFiltering';
|
|
51
|
-
import { AREA_AROUND_END_TAG, AREA_AROUND_START_TAG, CODE_TO_EDIT_END_TAG, CODE_TO_EDIT_START_TAG, createTaggedCurrentFileContentUsingPagedClipping, CURSOR_TAG, getUserPrompt, N_LINES_ABOVE, N_LINES_AS_CONTEXT, N_LINES_BELOW, nes41Miniv3SystemPrompt, simplifiedPrompt, systemPromptTemplate, unifiedModelSystemPrompt, xtab275SystemPrompt } from '../common/promptCrafting';
|
|
52
|
-
import { XtabEndpoint } from './xtabEndpoint';
|
|
53
|
-
import { linesWithBackticksRemoved, toLines } from './xtabUtils';
|
|
54
|
-
|
|
55
|
-
export const IGNORE_TEXT_BEFORE = /```[^\n]*\n/;
|
|
56
|
-
|
|
57
|
-
namespace ResponseTags {
|
|
58
|
-
export const NO_CHANGE = {
|
|
59
|
-
start: '<NO_CHANGE>'
|
|
60
|
-
};
|
|
61
|
-
export const EDIT = {
|
|
62
|
-
start: '<EDIT>',
|
|
63
|
-
end: '</EDIT>'
|
|
64
|
-
};
|
|
65
|
-
export const INSERT = {
|
|
66
|
-
start: '<INSERT>',
|
|
67
|
-
end: '</INSERT>'
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const enum RetryState {
|
|
72
|
-
NotRetrying,
|
|
73
|
-
RetryingWithExpandedWindow
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export class XtabProvider implements IStatelessNextEditProvider {
|
|
77
|
-
|
|
78
|
-
public static readonly ID = XTabProviderId;
|
|
79
|
-
|
|
80
|
-
public readonly ID = XtabProvider.ID;
|
|
81
|
-
|
|
82
|
-
public readonly dependsOnSelection = true;
|
|
83
|
-
public readonly showNextEditPreference = ShowNextEditPreference.Always;
|
|
84
|
-
|
|
85
|
-
private readonly tracer: ITracer;
|
|
86
|
-
private readonly delayer: Delayer;
|
|
87
|
-
|
|
88
|
-
private forceUseDefaultModel: boolean = false;
|
|
89
|
-
|
|
90
|
-
constructor(
|
|
91
|
-
@ISimulationTestContext private readonly simulationCtx: ISimulationTestContext,
|
|
92
|
-
@IInstantiationService private readonly instaService: IInstantiationService,
|
|
93
|
-
@IWorkspaceService private readonly workspaceService: IWorkspaceService,
|
|
94
|
-
@IDiffService private readonly diffService: IDiffService,
|
|
95
|
-
@IConfigurationService private readonly configService: IConfigurationService,
|
|
96
|
-
@IExperimentationService private readonly expService: IExperimentationService,
|
|
97
|
-
@ILogService private readonly logService: ILogService,
|
|
98
|
-
@ILanguageContextProviderService private readonly langCtxService: ILanguageContextProviderService,
|
|
99
|
-
@ILanguageDiagnosticsService private readonly langDiagService: ILanguageDiagnosticsService,
|
|
100
|
-
@IIgnoreService private readonly ignoreService: IIgnoreService,
|
|
101
|
-
) {
|
|
102
|
-
this.delayer = new Delayer(this.configService, this.expService);
|
|
103
|
-
this.tracer = createTracer(['NES', 'XtabProvider'], (s) => this.logService.trace(s));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
public handleAcceptance(): void {
|
|
107
|
-
this.delayer.handleAcceptance();
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
public handleRejection(): void {
|
|
111
|
-
this.delayer.handleRejection();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
public provideNextEdit(request: StatelessNextEditRequest, pushEdit: PushEdit, logContext: InlineEditRequestLogContext, cancellationToken: CancellationToken): Promise<StatelessNextEditResult> {
|
|
115
|
-
const filteringPushEdit: PushEdit = (result) => {
|
|
116
|
-
if (result.isError()) {
|
|
117
|
-
pushEdit(result);
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
const { edit } = result.val;
|
|
121
|
-
const filteredEdits = this.filterEdit(request.getActiveDocument(), [edit]);
|
|
122
|
-
if (filteredEdits.length === 0) { // do not invoke pushEdit
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
pushEdit(result);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
return this._provideNextEdit(request, filteringPushEdit, logContext, cancellationToken);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
private filterEdit(activeDoc: StatelessNextEditDocument, edits: readonly LineReplacement[]): readonly LineReplacement[] {
|
|
132
|
-
type EditFilter = (edits: readonly LineReplacement[]) => readonly LineReplacement[];
|
|
133
|
-
|
|
134
|
-
const filters: EditFilter[] = [
|
|
135
|
-
(edits) => IgnoreImportChangesAspect.filterEdit(activeDoc, edits),
|
|
136
|
-
(edits) => IgnoreEmptyLineAndLeadingTrailingWhitespaceChanges.filterEdit(activeDoc, edits),
|
|
137
|
-
];
|
|
138
|
-
|
|
139
|
-
if (!this.configService.getExperimentBasedConfig(ConfigKey.InlineEditsAllowWhitespaceOnlyChanges, this.expService)) {
|
|
140
|
-
filters.push((edits) => IgnoreWhitespaceOnlyChanges.filterEdit(activeDoc, edits));
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return filters.reduce((acc, filter) => filter(acc), edits);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
public async _provideNextEdit(request: StatelessNextEditRequest, pushEdit: PushEdit, logContext: InlineEditRequestLogContext, cancellationToken: CancellationToken): Promise<StatelessNextEditResult> {
|
|
147
|
-
const telemetry = new StatelessNextEditTelemetryBuilder(request);
|
|
148
|
-
|
|
149
|
-
logContext.setProviderStartTime();
|
|
150
|
-
try {
|
|
151
|
-
if (request.xtabEditHistory.length === 0) {
|
|
152
|
-
return StatelessNextEditResult.noEdit(new NoNextEditReason.ActiveDocumentHasNoEdits(), telemetry);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const delaySession = this.delayer.createDelaySession(request.providerRequestStartDateTime);
|
|
156
|
-
|
|
157
|
-
const nextEditResult = await this.doGetNextEdit(request, pushEdit, delaySession, logContext, cancellationToken, telemetry, RetryState.NotRetrying);
|
|
158
|
-
|
|
159
|
-
if (nextEditResult.isError() && nextEditResult.err instanceof NoNextEditReason.GotCancelled) {
|
|
160
|
-
logContext.setIsSkipped();
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (nextEditResult.isOk()) {
|
|
164
|
-
await this.enforceArtificialDelay(delaySession, telemetry);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return new StatelessNextEditResult(nextEditResult, telemetry.build(nextEditResult));
|
|
168
|
-
} catch (err: unknown) {
|
|
169
|
-
return StatelessNextEditResult.noEdit(new NoNextEditReason.Unexpected(errors.fromUnknown(err)), telemetry);
|
|
170
|
-
} finally {
|
|
171
|
-
logContext.setProviderEndTime();
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
private async doGetNextEdit(
|
|
176
|
-
request: StatelessNextEditRequest,
|
|
177
|
-
pushEdit: PushEdit,
|
|
178
|
-
delaySession: DelaySession,
|
|
179
|
-
logContext: InlineEditRequestLogContext,
|
|
180
|
-
cancellationToken: CancellationToken,
|
|
181
|
-
telemetryBuilder: StatelessNextEditTelemetryBuilder,
|
|
182
|
-
retryState: RetryState,
|
|
183
|
-
): Promise<Result<void, NoNextEditReason>> {
|
|
184
|
-
|
|
185
|
-
const tracer = this.tracer.sub('doGetNextEdit');
|
|
186
|
-
|
|
187
|
-
const activeDocument = request.getActiveDocument();
|
|
188
|
-
|
|
189
|
-
const selection = getOrDeduceSelectionFromLastEdit(activeDocument);
|
|
190
|
-
|
|
191
|
-
if (selection === null) {
|
|
192
|
-
return Result.error(new NoNextEditReason.Uncategorized(new Error('NoSelection')));
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const endpoint = this.getEndpoint();
|
|
196
|
-
logContext.setEndpointInfo(typeof endpoint.urlOrRequestMetadata === 'string' ? endpoint.urlOrRequestMetadata : JSON.stringify(endpoint.urlOrRequestMetadata.type), endpoint.model);
|
|
197
|
-
telemetryBuilder.setModelName(endpoint.model);
|
|
198
|
-
|
|
199
|
-
const computeTokens = (s: string) => Math.floor(s.length / 4);
|
|
200
|
-
|
|
201
|
-
const cursorPosition = new Position(selection.endLineNumber, selection.endColumn);
|
|
202
|
-
|
|
203
|
-
const cursorOffset = activeDocument.documentAfterEdits.getTransformer().getOffset(cursorPosition);
|
|
204
|
-
|
|
205
|
-
const currentFileContent = activeDocument.documentAfterEdits;
|
|
206
|
-
const currentFileContentLines = currentFileContent.getLines();
|
|
207
|
-
|
|
208
|
-
const cursorLineIdx = cursorPosition.lineNumber - 1 /* to convert to 0-based */;
|
|
209
|
-
|
|
210
|
-
const cursorLine = currentFileContentLines[cursorLineIdx];
|
|
211
|
-
const isCursorAtEndOfLine = cursorPosition.column === cursorLine.trimEnd().length;
|
|
212
|
-
if (isCursorAtEndOfLine) {
|
|
213
|
-
delaySession.setExtraDebounce(this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsExtraDebounceEndOfLine, this.expService));
|
|
214
|
-
}
|
|
215
|
-
telemetryBuilder.setIsCursorAtLineEnd(isCursorAtEndOfLine);
|
|
216
|
-
|
|
217
|
-
const areaAroundEditWindowLinesRange = this.computeAreaAroundEditWindowLinesRange(currentFileContentLines, cursorLineIdx);
|
|
218
|
-
|
|
219
|
-
const editWindowLinesRange = this.computeEditWindowLinesRange(currentFileContentLines, cursorLineIdx, request, retryState);
|
|
220
|
-
|
|
221
|
-
const cursorOriginalLinesOffset = Math.max(0, cursorLineIdx - editWindowLinesRange.start);
|
|
222
|
-
const editWindowLastLineLength = activeDocument.documentAfterEdits.getTransformer().getLineLength(editWindowLinesRange.endExclusive);
|
|
223
|
-
const editWindow = activeDocument.documentAfterEdits.getTransformer().getOffsetRange(new Range(editWindowLinesRange.start + 1, 1, editWindowLinesRange.endExclusive, editWindowLastLineLength + 1));
|
|
224
|
-
|
|
225
|
-
const editWindowLines = currentFileContentLines.slice(editWindowLinesRange.start, editWindowLinesRange.endExclusive);
|
|
226
|
-
|
|
227
|
-
// Expected: editWindow.substring(activeDocument.documentAfterEdits.value) === editWindowLines.join('\n')
|
|
228
|
-
|
|
229
|
-
const doesIncludeCursorTag = editWindowLines.some(line => line.includes(CURSOR_TAG));
|
|
230
|
-
const shouldRemoveCursorTagFromResponse = !doesIncludeCursorTag; // we'd like to remove the tag only if the original edit-window didn't include the tag
|
|
231
|
-
|
|
232
|
-
const addCursorTagEdit = StringEdit.single(StringReplacement.insert(cursorOffset, CURSOR_TAG));
|
|
233
|
-
const contentWithCursor = addCursorTagEdit.applyOnText(currentFileContent);
|
|
234
|
-
const contentWithCursorLines = contentWithCursor.getLines();
|
|
235
|
-
|
|
236
|
-
const editWindowWithCursorLines = contentWithCursorLines.slice(editWindowLinesRange.start, editWindowLinesRange.endExclusive);
|
|
237
|
-
|
|
238
|
-
const areaAroundCodeToEdit = [
|
|
239
|
-
AREA_AROUND_START_TAG,
|
|
240
|
-
...contentWithCursorLines.slice(areaAroundEditWindowLinesRange.start, editWindowLinesRange.start),
|
|
241
|
-
CODE_TO_EDIT_START_TAG,
|
|
242
|
-
...editWindowWithCursorLines,
|
|
243
|
-
CODE_TO_EDIT_END_TAG,
|
|
244
|
-
...contentWithCursorLines.slice(editWindowLinesRange.endExclusive, areaAroundEditWindowLinesRange.endExclusive),
|
|
245
|
-
AREA_AROUND_END_TAG
|
|
246
|
-
].join('\n');
|
|
247
|
-
|
|
248
|
-
let promptOptions: xtabPromptOptions.PromptOptions;
|
|
249
|
-
|
|
250
|
-
if (this.forceUseDefaultModel) {
|
|
251
|
-
promptOptions = xtabPromptOptions.DEFAULT_OPTIONS;
|
|
252
|
-
} else {
|
|
253
|
-
const promptingStrategy = this.determinePromptingStrategy({
|
|
254
|
-
isXtabUnifiedModel: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabUseUnifiedModel, this.expService),
|
|
255
|
-
isCodexV21NesUnified: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabCodexV21NesUnified, this.expService),
|
|
256
|
-
useSimplifiedPrompt: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabProviderUseSimplifiedPrompt, this.expService),
|
|
257
|
-
useXtab275Prompting: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabProviderUseXtab275Prompting, this.expService),
|
|
258
|
-
useNes41Miniv3Prompting: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabUseNes41Miniv3Prompting, this.expService),
|
|
259
|
-
});
|
|
260
|
-
promptOptions = {
|
|
261
|
-
promptingStrategy,
|
|
262
|
-
currentFile: {
|
|
263
|
-
maxTokens: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabCurrentFileMaxTokens, this.expService),
|
|
264
|
-
includeTags: promptingStrategy !== xtabPromptOptions.PromptingStrategy.UnifiedModel /* unified model doesn't use tags in current file */ && this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabIncludeTagsInCurrentFile, this.expService),
|
|
265
|
-
prioritizeAboveCursor: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabPrioritizeAboveCursor, this.expService)
|
|
266
|
-
},
|
|
267
|
-
pagedClipping: {
|
|
268
|
-
pageSize: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabPageSize, this.expService)
|
|
269
|
-
},
|
|
270
|
-
recentlyViewedDocuments: {
|
|
271
|
-
nDocuments: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabNRecentlyViewedDocuments, this.expService),
|
|
272
|
-
maxTokens: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabRecentlyViewedDocumentsMaxTokens, this.expService),
|
|
273
|
-
includeViewedFiles: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabIncludeViewedFiles, this.expService),
|
|
274
|
-
},
|
|
275
|
-
languageContext: this.determineLanguageContextOptions(activeDocument.languageId, {
|
|
276
|
-
enabled: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabLanguageContextEnabled, this.expService),
|
|
277
|
-
enabledLanguages: this.configService.getConfig(ConfigKey.Internal.InlineEditsXtabLanguageContextEnabledLanguages),
|
|
278
|
-
maxTokens: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabLanguageContextMaxTokens, this.expService),
|
|
279
|
-
}),
|
|
280
|
-
diffHistory: {
|
|
281
|
-
nEntries: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabDiffNEntries, this.expService),
|
|
282
|
-
maxTokens: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabDiffMaxTokens, this.expService),
|
|
283
|
-
onlyForDocsInPrompt: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabDiffOnlyForDocsInPrompt, this.expService),
|
|
284
|
-
useRelativePaths: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabDiffUseRelativePaths, this.expService),
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
const areaAroundCodeToEditForCurrentFile = promptOptions.currentFile.includeTags
|
|
290
|
-
? areaAroundCodeToEdit
|
|
291
|
-
: [
|
|
292
|
-
...contentWithCursorLines.slice(areaAroundEditWindowLinesRange.start, editWindowLinesRange.start),
|
|
293
|
-
...editWindowLines,
|
|
294
|
-
...contentWithCursorLines.slice(editWindowLinesRange.endExclusive, areaAroundEditWindowLinesRange.endExclusive),
|
|
295
|
-
].join('\n');
|
|
296
|
-
const { taggedCurrentFileContent, nLines: nLinesCurrentFile } = createTaggedCurrentFileContentUsingPagedClipping(
|
|
297
|
-
currentFileContentLines,
|
|
298
|
-
areaAroundCodeToEditForCurrentFile,
|
|
299
|
-
areaAroundEditWindowLinesRange,
|
|
300
|
-
computeTokens,
|
|
301
|
-
promptOptions.pagedClipping.pageSize,
|
|
302
|
-
promptOptions.currentFile,
|
|
303
|
-
);
|
|
304
|
-
telemetryBuilder.setNLinesOfCurrentFileInPrompt(nLinesCurrentFile);
|
|
305
|
-
|
|
306
|
-
const recordingEnabled = this.configService.getConfig<boolean>(ConfigKey.Internal.InlineEditsLogContextRecorderEnabled);
|
|
307
|
-
|
|
308
|
-
let langCtx: LanguageContextResponse | undefined;
|
|
309
|
-
if (promptOptions.languageContext.enabled || recordingEnabled) {
|
|
310
|
-
const langCtxPromise = this.getLanguageContext(request, delaySession, activeDocument, cursorPosition, logContext, cancellationToken, promptOptions);
|
|
311
|
-
|
|
312
|
-
if (promptOptions.languageContext.enabled) {
|
|
313
|
-
langCtx = await langCtxPromise;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
if (recordingEnabled) {
|
|
317
|
-
logContext.setFileDiagnostics(this.langDiagService.getAllDiagnostics());
|
|
318
|
-
langCtxPromise.then(langCtxs => {
|
|
319
|
-
if (langCtxs) {
|
|
320
|
-
logContext.setLanguageContext(langCtxs);
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
const userPrompt = getUserPrompt(request, taggedCurrentFileContent, areaAroundCodeToEdit, langCtx, computeTokens, promptOptions);
|
|
327
|
-
|
|
328
|
-
const prediction = this.getPredictedOutput(editWindowLines, promptOptions.promptingStrategy);
|
|
329
|
-
|
|
330
|
-
const messages = [
|
|
331
|
-
{
|
|
332
|
-
role: Raw.ChatRole.System,
|
|
333
|
-
content: toTextParts(this.pickSystemPrompt(promptOptions.promptingStrategy))
|
|
334
|
-
},
|
|
335
|
-
{ role: Raw.ChatRole.User, content: toTextParts(userPrompt) }
|
|
336
|
-
] satisfies Raw.ChatMessage[];
|
|
337
|
-
|
|
338
|
-
logContext.setPrompt(messages);
|
|
339
|
-
telemetryBuilder.setPrompt(messages);
|
|
340
|
-
|
|
341
|
-
await this.debounce(delaySession, telemetryBuilder);
|
|
342
|
-
if (cancellationToken.isCancellationRequested) {
|
|
343
|
-
return Result.error(new NoNextEditReason.GotCancelled('afterDebounce'));
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
request.fetchIssued = true;
|
|
347
|
-
|
|
348
|
-
const cursorLineOffset = cursorPosition.column;
|
|
349
|
-
this.streamEdits(
|
|
350
|
-
request,
|
|
351
|
-
pushEdit,
|
|
352
|
-
endpoint,
|
|
353
|
-
messages,
|
|
354
|
-
editWindow,
|
|
355
|
-
editWindowLines,
|
|
356
|
-
cursorOriginalLinesOffset,
|
|
357
|
-
cursorLineOffset,
|
|
358
|
-
editWindowLinesRange,
|
|
359
|
-
prediction,
|
|
360
|
-
{
|
|
361
|
-
shouldRemoveCursorTagFromResponse,
|
|
362
|
-
promptingStrategy: promptOptions.promptingStrategy,
|
|
363
|
-
retryState,
|
|
364
|
-
},
|
|
365
|
-
delaySession,
|
|
366
|
-
tracer,
|
|
367
|
-
telemetryBuilder,
|
|
368
|
-
logContext,
|
|
369
|
-
cancellationToken
|
|
370
|
-
);
|
|
371
|
-
return Result.ok<void>(undefined);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
private async getLanguageContext(
|
|
375
|
-
request: StatelessNextEditRequest,
|
|
376
|
-
delaySession: DelaySession,
|
|
377
|
-
activeDocument: StatelessNextEditDocument,
|
|
378
|
-
cursorPosition: Position,
|
|
379
|
-
logContext: InlineEditRequestLogContext,
|
|
380
|
-
cancellationToken: CancellationToken,
|
|
381
|
-
promptOptions: xtabPromptOptions.PromptOptions
|
|
382
|
-
): Promise<LanguageContextResponse | undefined> {
|
|
383
|
-
try {
|
|
384
|
-
const textDoc = this.workspaceService.textDocuments.find(doc => doc.uri.toString() === activeDocument.id.uri);
|
|
385
|
-
if (textDoc === undefined) {
|
|
386
|
-
return undefined;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
const providers = this.langCtxService.getContextProviders(textDoc);
|
|
390
|
-
if (providers.length < 1) {
|
|
391
|
-
return undefined;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
const debounceTime = delaySession.getDebounceTime();
|
|
395
|
-
|
|
396
|
-
const cursorPositionVscode = new VscodePosition(cursorPosition.lineNumber - 1, cursorPosition.column - 1);
|
|
397
|
-
|
|
398
|
-
const ctxRequest: Copilot.ResolveRequest = {
|
|
399
|
-
opportunityId: request.opportunityId,
|
|
400
|
-
completionId: request.id,
|
|
401
|
-
documentContext: {
|
|
402
|
-
uri: textDoc.uri.toString(),
|
|
403
|
-
languageId: textDoc.languageId,
|
|
404
|
-
version: textDoc.version,
|
|
405
|
-
offset: textDoc.offsetAt(cursorPositionVscode)
|
|
406
|
-
},
|
|
407
|
-
activeExperiments: new Map(),
|
|
408
|
-
timeBudget: debounceTime,
|
|
409
|
-
timeoutEnd: Date.now() + debounceTime,
|
|
410
|
-
source: 'nes',
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
const isSnippetIgnored = async (item: SnippetContext): Promise<boolean> => {
|
|
414
|
-
const uris = [item.uri, ...(item.additionalUris ?? [])];
|
|
415
|
-
const isIgnored = await raceFilter(uris.map(uri => this.ignoreService.isCopilotIgnored(uri)), r => r);
|
|
416
|
-
return !!isIgnored;
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
const langCtxItems: LanguageContextEntry[] = [];
|
|
420
|
-
const getContextPromise = async () => {
|
|
421
|
-
const ctxIter = this.langCtxService.getContextItems(textDoc, ctxRequest, cancellationToken);
|
|
422
|
-
for await (const item of ctxIter) {
|
|
423
|
-
if (item.kind === ContextKind.Snippet && await isSnippetIgnored(item)) {
|
|
424
|
-
// If the snippet is ignored, we don't want to include it in the context
|
|
425
|
-
continue;
|
|
426
|
-
}
|
|
427
|
-
langCtxItems.push({ context: item, timeStamp: Date.now(), onTimeout: false });
|
|
428
|
-
}
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
const start = Date.now();
|
|
432
|
-
await raceTimeout(getContextPromise(), debounceTime);
|
|
433
|
-
const end = Date.now();
|
|
434
|
-
|
|
435
|
-
const langCtxOnTimeout = this.langCtxService.getContextItemsOnTimeout(textDoc, ctxRequest);
|
|
436
|
-
for (const item of langCtxOnTimeout) {
|
|
437
|
-
if (item.kind === ContextKind.Snippet && await isSnippetIgnored(item)) {
|
|
438
|
-
// If the snippet is ignored, we don't want to include it in the context
|
|
439
|
-
continue;
|
|
440
|
-
}
|
|
441
|
-
langCtxItems.push({ context: item, timeStamp: end, onTimeout: true });
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
return { start, end, items: langCtxItems };
|
|
445
|
-
|
|
446
|
-
} catch (error: unknown) {
|
|
447
|
-
logContext.setError(errors.fromUnknown(error));
|
|
448
|
-
this.tracer.trace(`Failed to fetch language context: ${error}`);
|
|
449
|
-
return undefined;
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
public async streamEdits(
|
|
454
|
-
request: StatelessNextEditRequest,
|
|
455
|
-
pushEdit: PushEdit,
|
|
456
|
-
endpoint: IChatEndpoint,
|
|
457
|
-
messages: Raw.ChatMessage[],
|
|
458
|
-
editWindow: OffsetRange,
|
|
459
|
-
editWindowLines: string[],
|
|
460
|
-
cursorOriginalLinesOffset: number,
|
|
461
|
-
cursorLineOffset: number, // cursor offset within the line it's in; 1-based
|
|
462
|
-
editWindowLineRange: OffsetRange,
|
|
463
|
-
prediction: Prediction | undefined,
|
|
464
|
-
opts: {
|
|
465
|
-
promptingStrategy: xtabPromptOptions.PromptingStrategy | undefined;
|
|
466
|
-
shouldRemoveCursorTagFromResponse: boolean;
|
|
467
|
-
retryState: RetryState;
|
|
468
|
-
},
|
|
469
|
-
delaySession: DelaySession,
|
|
470
|
-
parentTracer: ITracer,
|
|
471
|
-
telemetryBuilder: StatelessNextEditTelemetryBuilder,
|
|
472
|
-
logContext: InlineEditRequestLogContext,
|
|
473
|
-
cancellationToken: CancellationToken,
|
|
474
|
-
) {
|
|
475
|
-
const tracer = parentTracer.sub('streamEdits');
|
|
476
|
-
|
|
477
|
-
const fetchStreamSource = new FetchStreamSource();
|
|
478
|
-
|
|
479
|
-
const fetchRequestStopWatch = new StopWatch();
|
|
480
|
-
|
|
481
|
-
let responseSoFar = '';
|
|
482
|
-
|
|
483
|
-
let chatResponseFailure: ChatFetchError | undefined;
|
|
484
|
-
|
|
485
|
-
let ttft: number | undefined;
|
|
486
|
-
|
|
487
|
-
const firstTokenReceived = new DeferredPromise<void>();
|
|
488
|
-
|
|
489
|
-
telemetryBuilder.setFetchStartedAt();
|
|
490
|
-
logContext.setFetchStartTime();
|
|
491
|
-
|
|
492
|
-
// we must not await this promise because we want to stream edits as they come in
|
|
493
|
-
const fetchResultPromise = endpoint.makeChatRequest(
|
|
494
|
-
XtabProvider.ID,
|
|
495
|
-
messages,
|
|
496
|
-
async (text, _, delta) => {
|
|
497
|
-
if (!firstTokenReceived.isSettled) {
|
|
498
|
-
firstTokenReceived.complete();
|
|
499
|
-
}
|
|
500
|
-
if (ttft === undefined) {
|
|
501
|
-
ttft = fetchRequestStopWatch.elapsed();
|
|
502
|
-
logContext.addLog(`TTFT ${ttft} ms`);
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
fetchStreamSource.update(text, delta);
|
|
506
|
-
responseSoFar = text;
|
|
507
|
-
logContext.setResponse(responseSoFar);
|
|
508
|
-
return undefined;
|
|
509
|
-
},
|
|
510
|
-
cancellationToken,
|
|
511
|
-
ChatLocation.Other,
|
|
512
|
-
undefined,
|
|
513
|
-
{
|
|
514
|
-
temperature: 0,
|
|
515
|
-
// max_tokens: 256, // `max_tokens` is not supported along with `prediction` - https://platform.openai.com/docs/guides/predicted-outputs#limitations
|
|
516
|
-
stream: true,
|
|
517
|
-
prediction,
|
|
518
|
-
} satisfies OptionalChatRequestParams,
|
|
519
|
-
undefined,
|
|
520
|
-
{
|
|
521
|
-
requestId: request.id,
|
|
522
|
-
}
|
|
523
|
-
);
|
|
524
|
-
|
|
525
|
-
telemetryBuilder.setResponse(fetchResultPromise.then((response) => ({ response, ttft })));
|
|
526
|
-
logContext.setFullResponse(fetchResultPromise.then((response) => response.type === ChatFetchResponseType.Success ? response.value : undefined));
|
|
527
|
-
|
|
528
|
-
const fetchRes = await Promise.race([firstTokenReceived.p, fetchResultPromise]);
|
|
529
|
-
if (fetchRes && fetchRes.type !== ChatFetchResponseType.Success) {
|
|
530
|
-
if (fetchRes.type === ChatFetchResponseType.NotFound &&
|
|
531
|
-
!this.forceUseDefaultModel // if we haven't already forced using the default model; otherwise, this could cause an infinite loop
|
|
532
|
-
) {
|
|
533
|
-
this.forceUseDefaultModel = true;
|
|
534
|
-
return this.doGetNextEdit(request, pushEdit, delaySession, logContext, cancellationToken, telemetryBuilder, opts.retryState); // use the same retry state
|
|
535
|
-
}
|
|
536
|
-
pushEdit(Result.error(XtabProvider.mapChatFetcherErrorToNoNextEditReason(fetchRes)));
|
|
537
|
-
return;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
fetchResultPromise
|
|
541
|
-
.then((response) => {
|
|
542
|
-
// this's a way to signal the edit-pushing code to know if the request failed and
|
|
543
|
-
// it shouldn't push edits constructed from an erroneous response
|
|
544
|
-
chatResponseFailure = response.type !== ChatFetchResponseType.Success ? response : undefined;
|
|
545
|
-
})
|
|
546
|
-
.catch((err: unknown) => {
|
|
547
|
-
// in principle this shouldn't happen because ChatMLFetcher's fetchOne should not throw
|
|
548
|
-
logContext.setError(errors.fromUnknown(err));
|
|
549
|
-
logContext.addLog(`ChatMLFetcher fetch call threw -- this's UNEXPECTED!`);
|
|
550
|
-
|
|
551
|
-
// Properly handle the error by pushing it as a result
|
|
552
|
-
pushEdit(Result.error(new NoNextEditReason.Unexpected(errors.fromUnknown(err))));
|
|
553
|
-
}).finally(() => {
|
|
554
|
-
logContext.setFetchEndTime();
|
|
555
|
-
|
|
556
|
-
if (!firstTokenReceived.isSettled) {
|
|
557
|
-
firstTokenReceived.complete();
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
fetchStreamSource.resolve();
|
|
561
|
-
|
|
562
|
-
logContext.setResponse(responseSoFar);
|
|
563
|
-
});
|
|
564
|
-
|
|
565
|
-
const llmLinesStream = toLines(fetchStreamSource.stream);
|
|
566
|
-
|
|
567
|
-
// logging of times
|
|
568
|
-
// removal of cursor tag if option is set
|
|
569
|
-
const linesStream = (() => {
|
|
570
|
-
let i = 0;
|
|
571
|
-
return llmLinesStream.map((v) => {
|
|
572
|
-
|
|
573
|
-
const trace = `Line ${i++} emitted with latency ${fetchRequestStopWatch.elapsed()} ms`;
|
|
574
|
-
logContext.addLog(trace);
|
|
575
|
-
tracer.trace(trace);
|
|
576
|
-
|
|
577
|
-
return opts.shouldRemoveCursorTagFromResponse
|
|
578
|
-
? v.replaceAll(CURSOR_TAG, '')
|
|
579
|
-
: v;
|
|
580
|
-
});
|
|
581
|
-
})();
|
|
582
|
-
|
|
583
|
-
let cleanedLinesStream: AsyncIterableObject<string>;
|
|
584
|
-
|
|
585
|
-
if (opts.promptingStrategy === xtabPromptOptions.PromptingStrategy.Xtab275) {
|
|
586
|
-
cleanedLinesStream = linesStream;
|
|
587
|
-
} else if (
|
|
588
|
-
opts.promptingStrategy === xtabPromptOptions.PromptingStrategy.UnifiedModel ||
|
|
589
|
-
opts.promptingStrategy === xtabPromptOptions.PromptingStrategy.Codexv21NesUnified ||
|
|
590
|
-
opts.promptingStrategy === xtabPromptOptions.PromptingStrategy.Nes41Miniv3
|
|
591
|
-
) {
|
|
592
|
-
const linesIter = linesStream[Symbol.asyncIterator]();
|
|
593
|
-
const firstLine = await linesIter.next();
|
|
594
|
-
|
|
595
|
-
if (chatResponseFailure !== undefined) { // handle fetch failure
|
|
596
|
-
pushEdit(Result.error(new NoNextEditReason.Unexpected(errors.fromUnknown(chatResponseFailure))));
|
|
597
|
-
return;
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
if (firstLine.done) { // no lines in response -- unexpected case but take as no suggestions
|
|
601
|
-
pushEdit(Result.error(new NoNextEditReason.NoSuggestions(request.documentBeforeEdits, editWindow)));
|
|
602
|
-
return;
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
const trimmedLines = firstLine.value.trim();
|
|
606
|
-
|
|
607
|
-
if (trimmedLines === ResponseTags.NO_CHANGE.start) {
|
|
608
|
-
this.pushNoSuggestionsOrRetry(request, editWindow, pushEdit, delaySession, logContext, cancellationToken, telemetryBuilder, opts.retryState);
|
|
609
|
-
return;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
if (trimmedLines === ResponseTags.INSERT.start) {
|
|
613
|
-
const lineWithCursorContinued = await linesIter.next();
|
|
614
|
-
if (lineWithCursorContinued.done || lineWithCursorContinued.value.includes(ResponseTags.INSERT.end)) {
|
|
615
|
-
pushEdit(Result.error(new NoNextEditReason.NoSuggestions(request.documentBeforeEdits, editWindow)));
|
|
616
|
-
return;
|
|
617
|
-
}
|
|
618
|
-
const edit = new LineReplacement(
|
|
619
|
-
new LineRange(editWindowLineRange.start + cursorOriginalLinesOffset + 1 /* 0-based to 1-based */, editWindowLineRange.start + cursorOriginalLinesOffset + 2),
|
|
620
|
-
[editWindowLines[cursorOriginalLinesOffset].slice(0, cursorLineOffset - 1) + lineWithCursorContinued.value + editWindowLines[cursorOriginalLinesOffset].slice(cursorLineOffset - 1)]
|
|
621
|
-
);
|
|
622
|
-
pushEdit(Result.ok({ edit, window: editWindow }));
|
|
623
|
-
|
|
624
|
-
const lines: string[] = [];
|
|
625
|
-
let v = await linesIter.next();
|
|
626
|
-
while (!v.done) {
|
|
627
|
-
if (v.value.includes(ResponseTags.INSERT.end)) {
|
|
628
|
-
break;
|
|
629
|
-
} else {
|
|
630
|
-
lines.push(v.value);
|
|
631
|
-
}
|
|
632
|
-
v = await linesIter.next();
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
const line = editWindowLineRange.start + cursorOriginalLinesOffset + 2;
|
|
636
|
-
pushEdit(Result.ok({
|
|
637
|
-
edit: new LineReplacement(
|
|
638
|
-
new LineRange(line, line),
|
|
639
|
-
lines
|
|
640
|
-
),
|
|
641
|
-
window: editWindow
|
|
642
|
-
}));
|
|
643
|
-
|
|
644
|
-
pushEdit(Result.error(new NoNextEditReason.NoSuggestions(request.documentBeforeEdits, editWindow)));
|
|
645
|
-
return;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
if (trimmedLines === ResponseTags.EDIT.start) {
|
|
649
|
-
cleanedLinesStream = new AsyncIterableObject(async (emitter) => {
|
|
650
|
-
let v = await linesIter.next();
|
|
651
|
-
while (!v.done) {
|
|
652
|
-
if (v.value.includes(ResponseTags.EDIT.end)) {
|
|
653
|
-
return;
|
|
654
|
-
}
|
|
655
|
-
emitter.emitOne(v.value);
|
|
656
|
-
v = await linesIter.next();
|
|
657
|
-
}
|
|
658
|
-
});
|
|
659
|
-
} else {
|
|
660
|
-
pushEdit(Result.error(new NoNextEditReason.Unexpected(new Error(`unexpected tag ${trimmedLines}`))));
|
|
661
|
-
return;
|
|
662
|
-
}
|
|
663
|
-
} else {
|
|
664
|
-
cleanedLinesStream = linesWithBackticksRemoved(linesStream);
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
const diffOptions: ResponseProcessor.DiffParams = {
|
|
668
|
-
emitFastCursorLineChange: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabProviderEmitFastCursorLineChange, this.expService),
|
|
669
|
-
nLinesToConverge: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabNNonSignificantLinesToConverge, this.expService),
|
|
670
|
-
nSignificantLinesToConverge: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabNSignificantLinesToConverge, this.expService),
|
|
671
|
-
};
|
|
672
|
-
|
|
673
|
-
(async () => {
|
|
674
|
-
let i = 0;
|
|
675
|
-
let hasBeenDelayed = false;
|
|
676
|
-
try {
|
|
677
|
-
for await (const edit of ResponseProcessor.diff(editWindowLines, cleanedLinesStream, cursorOriginalLinesOffset, diffOptions)) {
|
|
678
|
-
|
|
679
|
-
const singleLineEdits: LineReplacement[] = [];
|
|
680
|
-
if (edit.lineRange.startLineNumber === edit.lineRange.endLineNumberExclusive || // we don't want to run diff on insertion
|
|
681
|
-
edit.newLines.length === 0 || // we don't want to run diff on deletion
|
|
682
|
-
edit.lineRange.endLineNumberExclusive - edit.lineRange.startLineNumber === 1 && edit.newLines.length === 1 // we want to run diff on single line edits
|
|
683
|
-
) {
|
|
684
|
-
const singleLineEdit = new LineReplacement(new LineRange(edit.lineRange.startLineNumber + editWindowLineRange.start, edit.lineRange.endLineNumberExclusive + editWindowLineRange.start), edit.newLines);
|
|
685
|
-
singleLineEdits.push(singleLineEdit);
|
|
686
|
-
} else {
|
|
687
|
-
const affectedOriginalLines = editWindowLines.slice(edit.lineRange.startLineNumber - 1, edit.lineRange.endLineNumberExclusive - 1).join('\n');
|
|
688
|
-
|
|
689
|
-
const diffResult = await this.diffService.computeDiff(affectedOriginalLines, edit.newLines.join('\n'), {
|
|
690
|
-
ignoreTrimWhitespace: false,
|
|
691
|
-
maxComputationTimeMs: 0,
|
|
692
|
-
computeMoves: false
|
|
693
|
-
});
|
|
694
|
-
|
|
695
|
-
const translateByNLines = editWindowLineRange.start + edit.lineRange.startLineNumber;
|
|
696
|
-
for (const change of diffResult.changes) {
|
|
697
|
-
const singleLineEdit = new LineReplacement(
|
|
698
|
-
new LineRange(
|
|
699
|
-
translateByNLines + change.original.startLineNumber - 1,
|
|
700
|
-
translateByNLines + change.original.endLineNumberExclusive - 1
|
|
701
|
-
),
|
|
702
|
-
edit.newLines.slice(change.modified.startLineNumber - 1, change.modified.endLineNumberExclusive - 1)
|
|
703
|
-
);
|
|
704
|
-
singleLineEdits.push(singleLineEdit);
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
if (chatResponseFailure) { // do not emit edits if chat response failed
|
|
709
|
-
break;
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
logContext.setResponse(responseSoFar);
|
|
713
|
-
|
|
714
|
-
for (const singleLineEdit of singleLineEdits) {
|
|
715
|
-
const lineEdit = new LineEdit([singleLineEdit]);
|
|
716
|
-
|
|
717
|
-
if (editWouldDeleteWhatWasJustInserted(request.getActiveDocument(), lineEdit)) {
|
|
718
|
-
this.trace(`filtering edit because it would undo previous insertion: ${singleLineEdit.toString()}`, logContext, tracer);
|
|
719
|
-
i++;
|
|
720
|
-
continue;
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
this.trace(`pushing edit #${i}:\n${singleLineEdit.toString()}`, logContext, tracer);
|
|
724
|
-
|
|
725
|
-
if (!hasBeenDelayed) { // delay only the first one
|
|
726
|
-
hasBeenDelayed = true;
|
|
727
|
-
await this.enforceArtificialDelay(delaySession, telemetryBuilder);
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
pushEdit(Result.ok({ edit: singleLineEdit, window: editWindow }));
|
|
731
|
-
i++;
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
if (chatResponseFailure) {
|
|
736
|
-
pushEdit(Result.error(XtabProvider.mapChatFetcherErrorToNoNextEditReason(chatResponseFailure)));
|
|
737
|
-
return;
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
const hadEdits = i > 0;
|
|
741
|
-
if (hadEdits) {
|
|
742
|
-
pushEdit(Result.error(new NoNextEditReason.NoSuggestions(request.documentBeforeEdits, editWindow)));
|
|
743
|
-
} else {
|
|
744
|
-
this.pushNoSuggestionsOrRetry(request, editWindow, pushEdit, delaySession, logContext, cancellationToken, telemetryBuilder, opts.retryState);
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
} catch (err) {
|
|
748
|
-
logContext.setError(err);
|
|
749
|
-
// Properly handle the error by pushing it as a result
|
|
750
|
-
pushEdit(Result.error(new NoNextEditReason.Unexpected(errors.fromUnknown(err))));
|
|
751
|
-
}
|
|
752
|
-
})();
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
private pushNoSuggestionsOrRetry(
|
|
756
|
-
request: StatelessNextEditRequest,
|
|
757
|
-
editWindow: OffsetRange,
|
|
758
|
-
pushEdit: PushEdit,
|
|
759
|
-
delaySession: DelaySession,
|
|
760
|
-
logContext: InlineEditRequestLogContext,
|
|
761
|
-
cancellationToken: CancellationToken,
|
|
762
|
-
telemetryBuilder: StatelessNextEditTelemetryBuilder,
|
|
763
|
-
retryState: RetryState,
|
|
764
|
-
) {
|
|
765
|
-
const allowRetryWithExpandedWindow = this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabProviderRetryWithNMoreLinesBelow, this.expService);
|
|
766
|
-
|
|
767
|
-
// if allowed to retry and not retrying already, flip the retry state and try again
|
|
768
|
-
if (allowRetryWithExpandedWindow && retryState === RetryState.NotRetrying && request.expandedEditWindowNLines === undefined) {
|
|
769
|
-
this.doGetNextEdit(request, pushEdit, delaySession, logContext, cancellationToken, telemetryBuilder, RetryState.RetryingWithExpandedWindow);
|
|
770
|
-
return;
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
pushEdit(Result.error(new NoNextEditReason.NoSuggestions(request.documentBeforeEdits, editWindow)));
|
|
774
|
-
return;
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
private computeAreaAroundEditWindowLinesRange(currentDocLines: string[], cursorLine: number): OffsetRange {
|
|
778
|
-
const areaAroundStart = Math.max(0, cursorLine - N_LINES_AS_CONTEXT);
|
|
779
|
-
const areaAroundEndExcl = Math.min(currentDocLines.length, cursorLine + N_LINES_AS_CONTEXT + 1);
|
|
780
|
-
|
|
781
|
-
return new OffsetRange(areaAroundStart, areaAroundEndExcl);
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
private computeEditWindowLinesRange(currentDocLines: string[], cursorLine: number, request: StatelessNextEditRequest, retryState: RetryState): OffsetRange {
|
|
785
|
-
let nLinesAbove: number;
|
|
786
|
-
{
|
|
787
|
-
const useVaryingLinesAbove = this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabProviderUseVaryingLinesAbove, this.expService);
|
|
788
|
-
|
|
789
|
-
if (useVaryingLinesAbove) {
|
|
790
|
-
nLinesAbove = 0; // default
|
|
791
|
-
|
|
792
|
-
for (let i = 0; i < 8; ++i) {
|
|
793
|
-
const lineIdx = cursorLine - i;
|
|
794
|
-
if (lineIdx < 0) {
|
|
795
|
-
break;
|
|
796
|
-
}
|
|
797
|
-
if (currentDocLines[lineIdx].trim() !== '') {
|
|
798
|
-
nLinesAbove = i;
|
|
799
|
-
break;
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
} else {
|
|
803
|
-
nLinesAbove = (this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabProviderNLinesAbove, this.expService)
|
|
804
|
-
?? N_LINES_ABOVE);
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
let nLinesBelow;
|
|
809
|
-
|
|
810
|
-
if (request.expandedEditWindowNLines !== undefined) {
|
|
811
|
-
this.tracer.trace(`Using expanded nLinesBelow: ${request.expandedEditWindowNLines}`);
|
|
812
|
-
nLinesBelow = request.expandedEditWindowNLines;
|
|
813
|
-
} else {
|
|
814
|
-
const overriddenNLinesBelow = this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabProviderNLinesBelow, this.expService);
|
|
815
|
-
if (overriddenNLinesBelow !== undefined) {
|
|
816
|
-
this.tracer.trace(`Using overridden nLinesBelow: ${overriddenNLinesBelow}`);
|
|
817
|
-
nLinesBelow = overriddenNLinesBelow;
|
|
818
|
-
} else {
|
|
819
|
-
this.tracer.trace(`Using default nLinesBelow: ${N_LINES_BELOW}`);
|
|
820
|
-
nLinesBelow = N_LINES_BELOW; // default
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
if (retryState === RetryState.RetryingWithExpandedWindow) {
|
|
825
|
-
nLinesBelow += this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabProviderRetryWithNMoreLinesBelow, this.expService) ?? 0;
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
const codeToEditStart = Math.max(0, cursorLine - nLinesAbove);
|
|
829
|
-
const codeToEditEndExcl = Math.min(currentDocLines.length, cursorLine + nLinesBelow + 1);
|
|
830
|
-
|
|
831
|
-
return new OffsetRange(codeToEditStart, codeToEditEndExcl);
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
public static getBacktickSection(text: string): string {
|
|
836
|
-
const textTrimmedStart = text.replace(/^\`\`\`[a-zA-Z]*\r?\n/, '');
|
|
837
|
-
const textTrimmedEnd = textTrimmedStart.replace(/(\r?\n)\`\`\`$/, '');
|
|
838
|
-
return textTrimmedEnd;
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
private static mapChatFetcherErrorToNoNextEditReason(fetchError: ChatFetchError): NoNextEditReason {
|
|
842
|
-
switch (fetchError.type) {
|
|
843
|
-
case ChatFetchResponseType.Canceled:
|
|
844
|
-
return new NoNextEditReason.GotCancelled('afterFetchCall');
|
|
845
|
-
case ChatFetchResponseType.OffTopic:
|
|
846
|
-
case ChatFetchResponseType.Filtered:
|
|
847
|
-
case ChatFetchResponseType.PromptFiltered:
|
|
848
|
-
case ChatFetchResponseType.Length:
|
|
849
|
-
case ChatFetchResponseType.RateLimited:
|
|
850
|
-
case ChatFetchResponseType.QuotaExceeded:
|
|
851
|
-
case ChatFetchResponseType.ExtensionBlocked:
|
|
852
|
-
case ChatFetchResponseType.AgentUnauthorized:
|
|
853
|
-
case ChatFetchResponseType.AgentFailedDependency:
|
|
854
|
-
case ChatFetchResponseType.InvalidStatefulMarker:
|
|
855
|
-
return new NoNextEditReason.Uncategorized(errors.fromUnknown(fetchError));
|
|
856
|
-
case ChatFetchResponseType.BadRequest:
|
|
857
|
-
case ChatFetchResponseType.NotFound:
|
|
858
|
-
case ChatFetchResponseType.Failed:
|
|
859
|
-
case ChatFetchResponseType.NetworkError:
|
|
860
|
-
case ChatFetchResponseType.Unknown:
|
|
861
|
-
return new NoNextEditReason.FetchFailure(errors.fromUnknown(fetchError));
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
private determinePromptingStrategy({ isXtabUnifiedModel, isCodexV21NesUnified, useSimplifiedPrompt, useXtab275Prompting, useNes41Miniv3Prompting }: { isXtabUnifiedModel: boolean; isCodexV21NesUnified: boolean; useSimplifiedPrompt: boolean; useXtab275Prompting: boolean; useNes41Miniv3Prompting: boolean }): xtabPromptOptions.PromptingStrategy | undefined {
|
|
866
|
-
if (isXtabUnifiedModel) {
|
|
867
|
-
return xtabPromptOptions.PromptingStrategy.UnifiedModel;
|
|
868
|
-
} else if (isCodexV21NesUnified) {
|
|
869
|
-
return xtabPromptOptions.PromptingStrategy.Codexv21NesUnified;
|
|
870
|
-
} else if (useSimplifiedPrompt) {
|
|
871
|
-
return xtabPromptOptions.PromptingStrategy.SimplifiedSystemPrompt;
|
|
872
|
-
} else if (useXtab275Prompting) {
|
|
873
|
-
return xtabPromptOptions.PromptingStrategy.Xtab275;
|
|
874
|
-
} else if (useNes41Miniv3Prompting) {
|
|
875
|
-
return xtabPromptOptions.PromptingStrategy.Nes41Miniv3;
|
|
876
|
-
} else {
|
|
877
|
-
return undefined;
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
private pickSystemPrompt(promptingStrategy: xtabPromptOptions.PromptingStrategy | undefined): string {
|
|
882
|
-
switch (promptingStrategy) {
|
|
883
|
-
case xtabPromptOptions.PromptingStrategy.UnifiedModel:
|
|
884
|
-
return unifiedModelSystemPrompt;
|
|
885
|
-
case xtabPromptOptions.PromptingStrategy.Codexv21NesUnified:
|
|
886
|
-
case xtabPromptOptions.PromptingStrategy.SimplifiedSystemPrompt:
|
|
887
|
-
return simplifiedPrompt;
|
|
888
|
-
case xtabPromptOptions.PromptingStrategy.Xtab275:
|
|
889
|
-
return xtab275SystemPrompt;
|
|
890
|
-
case xtabPromptOptions.PromptingStrategy.Nes41Miniv3:
|
|
891
|
-
return nes41Miniv3SystemPrompt;
|
|
892
|
-
default:
|
|
893
|
-
return systemPromptTemplate;
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
private determineLanguageContextOptions(languageId: LanguageId, { enabled, enabledLanguages, maxTokens }: { enabled: boolean; enabledLanguages: LanguageContextLanguages; maxTokens: number }): LanguageContextOptions {
|
|
898
|
-
// Some languages are
|
|
899
|
-
if (languageId in enabledLanguages) {
|
|
900
|
-
return { enabled: enabledLanguages[languageId], maxTokens };
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
return { enabled, maxTokens };
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
private getEndpoint() {
|
|
907
|
-
const url = this.configService.getConfig(ConfigKey.Internal.InlineEditsXtabProviderUrl);
|
|
908
|
-
const apiKey = this.configService.getConfig(ConfigKey.Internal.InlineEditsXtabProviderApiKey);
|
|
909
|
-
const hasOverriddenUrlAndApiKey = url !== undefined && apiKey !== undefined;
|
|
910
|
-
|
|
911
|
-
const configuredModelName = this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabProviderModelName, this.expService);
|
|
912
|
-
|
|
913
|
-
if (hasOverriddenUrlAndApiKey) {
|
|
914
|
-
return this.instaService.createInstance(XtabEndpoint, url, apiKey, configuredModelName);
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
const modelName = this.forceUseDefaultModel
|
|
918
|
-
? undefined
|
|
919
|
-
: this.configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsXtabProviderModelName, this.expService);
|
|
920
|
-
|
|
921
|
-
return createProxyXtabEndpoint(this.instaService, modelName);
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
private getPredictedOutput(editWindowLines: string[], promptingStrategy: xtabPromptOptions.PromptingStrategy | undefined): Prediction | undefined {
|
|
925
|
-
return this.configService.getConfig(ConfigKey.Internal.InlineEditsXtabProviderUsePrediction)
|
|
926
|
-
? {
|
|
927
|
-
type: 'content',
|
|
928
|
-
content: XtabProvider.getPredictionContents(editWindowLines, promptingStrategy)
|
|
929
|
-
}
|
|
930
|
-
: undefined;
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
private static getPredictionContents(editWindowLines: readonly string[], promptingStrategy: xtabPromptOptions.PromptingStrategy | undefined): string {
|
|
934
|
-
if (promptingStrategy === xtabPromptOptions.PromptingStrategy.UnifiedModel ||
|
|
935
|
-
promptingStrategy === xtabPromptOptions.PromptingStrategy.Codexv21NesUnified ||
|
|
936
|
-
promptingStrategy === xtabPromptOptions.PromptingStrategy.Nes41Miniv3
|
|
937
|
-
) {
|
|
938
|
-
return ['<EDIT>', ...editWindowLines, '</EDIT>'].join('\n');
|
|
939
|
-
} else if (promptingStrategy === xtabPromptOptions.PromptingStrategy.Xtab275) {
|
|
940
|
-
return editWindowLines.join('\n');
|
|
941
|
-
} else {
|
|
942
|
-
return ['```', ...editWindowLines, '```'].join('\n');
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
private async debounce(delaySession: DelaySession, telemetry: StatelessNextEditTelemetryBuilder) {
|
|
947
|
-
if (this.simulationCtx.isInSimulationTests) {
|
|
948
|
-
return;
|
|
949
|
-
}
|
|
950
|
-
const debounceTime = delaySession.getDebounceTime();
|
|
951
|
-
|
|
952
|
-
this.tracer.trace(`Debouncing for ${debounceTime} ms`);
|
|
953
|
-
telemetry.setDebounceTime(debounceTime);
|
|
954
|
-
|
|
955
|
-
await timeout(debounceTime);
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
private async enforceArtificialDelay(delaySession: DelaySession, telemetry: StatelessNextEditTelemetryBuilder) {
|
|
959
|
-
if (this.simulationCtx.isInSimulationTests) {
|
|
960
|
-
return;
|
|
961
|
-
}
|
|
962
|
-
const artificialDelay = delaySession.getArtificialDelay();
|
|
963
|
-
|
|
964
|
-
this.tracer.trace(`Enforcing artificial delay of ${artificialDelay} ms`);
|
|
965
|
-
telemetry.setArtificialDelay(artificialDelay);
|
|
966
|
-
|
|
967
|
-
if (artificialDelay > 0) {
|
|
968
|
-
await timeout(artificialDelay);
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
private trace(msg: string, logContext: InlineEditRequestLogContext, tracer: ITracer) {
|
|
973
|
-
tracer.trace(msg);
|
|
974
|
-
logContext.addLog(msg);
|
|
975
|
-
}
|
|
976
|
-
}
|