@vscode/chat-lib 0.0.4 → 0.0.5-1
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/byok/node/openAIEndpoint.d.ts +9 -0
- package/dist/src/_internal/extension/byok/node/openAIEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/extension/byok/node/openAIEndpoint.js +136 -1
- package/dist/src/_internal/extension/byok/node/openAIEndpoint.js.map +1 -1
- package/dist/src/_internal/extension/common/constants.d.ts +0 -1
- package/dist/src/_internal/extension/common/constants.d.ts.map +1 -1
- package/dist/src/_internal/extension/common/constants.js +0 -1
- package/dist/src/_internal/extension/common/constants.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nesConfigs.d.ts +0 -4
- package/dist/src/_internal/extension/inlineEdits/node/nesConfigs.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditCache.d.ts +4 -2
- package/dist/src/_internal/extension/inlineEdits/node/nextEditCache.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditCache.js +15 -8
- package/dist/src/_internal/extension/inlineEdits/node/nextEditCache.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.d.ts +0 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.js +9 -60
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.js +7 -3
- 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 +46 -5
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.js.map +1 -1
- package/dist/src/_internal/extension/xtab/common/promptCrafting.d.ts +15 -35
- package/dist/src/_internal/extension/xtab/common/promptCrafting.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/common/promptCrafting.js +47 -147
- package/dist/src/_internal/extension/xtab/common/promptCrafting.js.map +1 -1
- package/dist/src/_internal/extension/xtab/common/systemMessages.d.ts +6 -0
- package/dist/src/_internal/extension/xtab/common/systemMessages.d.ts.map +1 -0
- package/dist/src/_internal/extension/xtab/common/systemMessages.js +104 -0
- package/dist/src/_internal/extension/xtab/common/systemMessages.js.map +1 -0
- package/dist/src/_internal/extension/xtab/common/tags.d.ts +15 -0
- package/dist/src/_internal/extension/xtab/common/tags.d.ts.map +1 -0
- package/dist/src/_internal/extension/xtab/common/tags.js +24 -0
- package/dist/src/_internal/extension/xtab/common/tags.js.map +1 -0
- package/dist/src/_internal/extension/xtab/common/xtabCurrentDocument.d.ts +16 -0
- package/dist/src/_internal/extension/xtab/common/xtabCurrentDocument.d.ts.map +1 -0
- package/dist/src/_internal/extension/xtab/common/xtabCurrentDocument.js +19 -0
- package/dist/src/_internal/extension/xtab/common/xtabCurrentDocument.js.map +1 -0
- package/dist/src/_internal/extension/xtab/node/xtabProvider.d.ts +22 -4
- package/dist/src/_internal/extension/xtab/node/xtabProvider.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabProvider.js +370 -118
- package/dist/src/_internal/extension/xtab/node/xtabProvider.js.map +1 -1
- package/dist/src/_internal/platform/authentication/common/copilotToken.d.ts +1 -0
- package/dist/src/_internal/platform/authentication/common/copilotToken.d.ts.map +1 -1
- package/dist/src/_internal/platform/authentication/common/copilotToken.js +3 -0
- package/dist/src/_internal/platform/authentication/common/copilotToken.js.map +1 -1
- package/dist/src/_internal/platform/authentication/node/copilotTokenManager.d.ts +13 -1
- package/dist/src/_internal/platform/authentication/node/copilotTokenManager.d.ts.map +1 -1
- package/dist/src/_internal/platform/authentication/node/copilotTokenManager.js +39 -9
- package/dist/src/_internal/platform/authentication/node/copilotTokenManager.js.map +1 -1
- package/dist/src/_internal/platform/chat/common/chatMLFetcher.d.ts +0 -1
- package/dist/src/_internal/platform/chat/common/chatMLFetcher.d.ts.map +1 -1
- package/dist/src/_internal/platform/chat/common/chatMLFetcher.js +1 -1
- package/dist/src/_internal/platform/chat/common/chatMLFetcher.js.map +1 -1
- package/dist/src/_internal/platform/chat/common/commonTypes.d.ts.map +1 -1
- package/dist/src/_internal/platform/chat/common/commonTypes.js +3 -1
- package/dist/src/_internal/platform/chat/common/commonTypes.js.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts +23 -11
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.js +25 -15
- package/dist/src/_internal/platform/configuration/common/configurationService.js.map +1 -1
- package/dist/src/_internal/platform/configuration/common/validator.d.ts +6 -0
- package/dist/src/_internal/platform/configuration/common/validator.d.ts.map +1 -1
- package/dist/src/_internal/platform/configuration/common/validator.js +41 -4
- package/dist/src/_internal/platform/configuration/common/validator.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.js +10 -5
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/endpointProvider.d.ts +2 -1
- package/dist/src/_internal/platform/endpoint/common/endpointProvider.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/endpointProvider.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.js +2 -1
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/responsesApi.d.ts +6 -0
- package/dist/src/_internal/platform/endpoint/node/responsesApi.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/responsesApi.js +161 -3
- package/dist/src/_internal/platform/endpoint/node/responsesApi.js.map +1 -1
- package/dist/src/_internal/platform/env/common/envService.d.ts +2 -0
- package/dist/src/_internal/platform/env/common/envService.d.ts.map +1 -1
- package/dist/src/_internal/platform/env/common/envService.js.map +1 -1
- package/dist/src/_internal/platform/env/common/nullEnvService.d.ts +1 -0
- package/dist/src/_internal/platform/env/common/nullEnvService.d.ts.map +1 -1
- package/dist/src/_internal/platform/env/common/nullEnvService.js +3 -0
- package/dist/src/_internal/platform/env/common/nullEnvService.js.map +1 -1
- package/dist/src/_internal/platform/github/common/githubAPI.d.ts +70 -0
- package/dist/src/_internal/platform/github/common/githubAPI.d.ts.map +1 -1
- package/dist/src/_internal/platform/github/common/githubAPI.js +182 -3
- package/dist/src/_internal/platform/github/common/githubAPI.js.map +1 -1
- package/dist/src/_internal/platform/github/common/githubService.d.ts +186 -1
- package/dist/src/_internal/platform/github/common/githubService.d.ts.map +1 -1
- package/dist/src/_internal/platform/github/common/githubService.js +44 -1
- package/dist/src/_internal/platform/github/common/githubService.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/edit.js +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/edit.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/rootedLineEdit.js +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/rootedLineEdit.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.d.ts +11 -0
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.js +8 -1
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/inlineEditLogContext.js +2 -2
- package/dist/src/_internal/platform/inlineEdits/common/inlineEditLogContext.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.d.ts +12 -2
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.js +13 -0
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.js.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetch.d.ts +2 -1
- package/dist/src/_internal/platform/networking/common/fetch.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetch.js +1 -0
- package/dist/src/_internal/platform/networking/common/fetch.js.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetcherService.d.ts +2 -0
- 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 +6 -2
- package/dist/src/_internal/platform/networking/common/networking.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/networking.js +4 -3
- package/dist/src/_internal/platform/networking/common/networking.js.map +1 -1
- package/dist/src/_internal/platform/networking/node/stream.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/node/stream.js +5 -3
- package/dist/src/_internal/platform/networking/node/stream.js.map +1 -1
- package/dist/src/_internal/platform/openai/node/fetch.d.ts +2 -1
- package/dist/src/_internal/platform/openai/node/fetch.d.ts.map +1 -1
- package/dist/src/_internal/platform/openai/node/fetch.js +20 -20
- package/dist/src/_internal/platform/openai/node/fetch.js.map +1 -1
- package/dist/src/_internal/util/common/cache.d.ts +1 -0
- package/dist/src/_internal/util/common/cache.d.ts.map +1 -1
- package/dist/src/_internal/util/common/cache.js +9 -0
- package/dist/src/_internal/util/common/cache.js.map +1 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts +10 -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 +10 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.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 +1 -0
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/async.d.ts +7 -3
- package/dist/src/_internal/util/vs/base/common/async.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/async.js +16 -5
- package/dist/src/_internal/util/vs/base/common/async.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/cache.d.ts +11 -0
- package/dist/src/_internal/util/vs/base/common/cache.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/cache.js +27 -1
- package/dist/src/_internal/util/vs/base/common/cache.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/cancellation.d.ts +21 -0
- package/dist/src/_internal/util/vs/base/common/cancellation.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/cancellation.js +53 -1
- package/dist/src/_internal/util/vs/base/common/cancellation.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/codicons.d.ts +16 -1
- package/dist/src/_internal/util/vs/base/common/codicons.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/codiconsLibrary.d.ts +16 -1
- package/dist/src/_internal/util/vs/base/common/codiconsLibrary.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/codiconsLibrary.js +16 -1
- package/dist/src/_internal/util/vs/base/common/codiconsLibrary.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/errors.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/errors.js +1 -0
- package/dist/src/_internal/util/vs/base/common/errors.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/extpath.js +4 -4
- package/dist/src/_internal/util/vs/base/common/extpath.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/glob.js +1 -1
- package/dist/src/_internal/util/vs/base/common/glob.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/hash.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/htmlContent.d.ts +2 -0
- package/dist/src/_internal/util/vs/base/common/htmlContent.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/htmlContent.js +9 -5
- package/dist/src/_internal/util/vs/base/common/htmlContent.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/lifecycle.d.ts +17 -2
- package/dist/src/_internal/util/vs/base/common/lifecycle.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/lifecycle.js +41 -8
- package/dist/src/_internal/util/vs/base/common/lifecycle.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/map.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/network.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/network.js +1 -0
- package/dist/src/_internal/util/vs/base/common/network.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/numbers.d.ts +0 -45
- package/dist/src/_internal/util/vs/base/common/numbers.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/numbers.js +0 -55
- package/dist/src/_internal/util/vs/base/common/numbers.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/objects.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/base.d.ts +4 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/base.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/base.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/changeTracker.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/changeTracker.js +4 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/changeTracker.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/debugLocation.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/debugLocation.js +1 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/debugLocation.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/debugName.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/debugName.js +1 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/debugName.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/index.js +3 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/index.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/logging/consoleObservableLogger.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/logging/consoleObservableLogger.js +1 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/logging/consoleObservableLogger.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/logging/debugGetDependencyGraph.d.ts +5 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/logging/debugGetDependencyGraph.d.ts.map +1 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/logging/debugGetDependencyGraph.js +71 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/logging/debugGetDependencyGraph.js.map +1 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/logging/debugger/debuggerRpc.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/logging/debugger/debuggerRpc.js +1 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/logging/debugger/debuggerRpc.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/logging/debugger/rpc.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/logging/debugger/rpc.js +1 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/logging/debugger/rpc.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/baseObservable.d.ts +4 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/baseObservable.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/baseObservable.js +8 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/baseObservable.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/derived.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/derived.js +9 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/derived.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/derivedImpl.d.ts +1 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/derivedImpl.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/derivedImpl.js +12 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/derivedImpl.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/observableFromEvent.d.ts +4 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/observableFromEvent.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/observableFromEvent.js +4 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/observableFromEvent.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/reactions/autorunImpl.d.ts +1 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/reactions/autorunImpl.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/reactions/autorunImpl.js +10 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/reactions/autorunImpl.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/set.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/set.js +1 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/set.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/utils/promise.d.ts +1 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/utils/promise.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/utils/promise.js +3 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/utils/promise.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/utils/utilsCancellation.js +2 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/utils/utilsCancellation.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/platform.d.ts +1 -0
- package/dist/src/_internal/util/vs/base/common/platform.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/platform.js +4 -0
- package/dist/src/_internal/util/vs/base/common/platform.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/process.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/stream.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/strings.d.ts +0 -1
- package/dist/src/_internal/util/vs/base/common/strings.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/strings.js +0 -4
- package/dist/src/_internal/util/vs/base/common/strings.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/themables.d.ts +8 -0
- package/dist/src/_internal/util/vs/base/common/themables.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/themables.js +14 -0
- package/dist/src/_internal/util/vs/base/common/themables.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/types.d.ts +4 -0
- package/dist/src/_internal/util/vs/base/common/types.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/types.js +11 -1
- package/dist/src/_internal/util/vs/base/common/types.js.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/edits/edit.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/edits/edit.js +1 -0
- package/dist/src/_internal/util/vs/editor/common/core/edits/edit.js.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/edits/lineEdit.d.ts +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/edits/lineEdit.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/edits/lineEdit.js +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/edits/lineEdit.js.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/edits/stringEdit.d.ts +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/edits/stringEdit.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/edits/stringEdit.js +12 -3
- package/dist/src/_internal/util/vs/editor/common/core/edits/stringEdit.js.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/position.d.ts +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/position.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/position.js +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/position.js.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/range.d.ts +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/range.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/range.js +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/range.js.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/ranges/lineRange.d.ts +3 -3
- package/dist/src/_internal/util/vs/editor/common/core/ranges/lineRange.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/ranges/lineRange.js.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/text/abstractText.d.ts +3 -2
- package/dist/src/_internal/util/vs/editor/common/core/text/abstractText.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/text/abstractText.js +5 -1
- package/dist/src/_internal/util/vs/editor/common/core/text/abstractText.js.map +1 -1
- package/dist/src/_internal/util/vs/platform/instantiation/common/descriptors.d.ts +2 -2
- package/dist/src/_internal/util/vs/platform/instantiation/common/descriptors.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/platform/instantiation/common/descriptors.js.map +1 -1
- package/dist/src/_internal/util/vs/platform/instantiation/common/instantiation.d.ts +8 -1
- package/dist/src/_internal/util/vs/platform/instantiation/common/instantiation.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/platform/instantiation/common/instantiation.js.map +1 -1
- package/dist/src/_internal/util/vs/platform/instantiation/common/instantiationService.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/platform/instantiation/common/instantiationService.js +1 -0
- package/dist/src/_internal/util/vs/platform/instantiation/common/instantiationService.js.map +1 -1
- package/dist/src/_internal/vscodeTypes.d.ts +1 -0
- package/dist/src/_internal/vscodeTypes.d.ts.map +1 -1
- package/dist/src/_internal/vscodeTypes.js +2 -1
- package/dist/src/_internal/vscodeTypes.js.map +1 -1
- package/dist/src/package.json +249 -116
- package/package.json +3 -3
|
@@ -48,12 +48,16 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
48
48
|
var XtabProvider_1;
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
50
|
exports.XtabProvider = void 0;
|
|
51
|
+
exports.findMergeConflictMarkersRange = findMergeConflictMarkersRange;
|
|
52
|
+
const copilot_api_1 = require("@vscode/copilot-api");
|
|
51
53
|
const prompt_tsx_1 = require("@vscode/prompt-tsx");
|
|
54
|
+
const rawTypes_1 = require("@vscode/prompt-tsx/dist/base/output/rawTypes");
|
|
52
55
|
const chatMLFetcher_1 = require("../../../platform/chat/common/chatMLFetcher");
|
|
53
56
|
const commonTypes_1 = require("../../../platform/chat/common/commonTypes");
|
|
54
57
|
const globalStringUtils_1 = require("../../../platform/chat/common/globalStringUtils");
|
|
55
58
|
const configurationService_1 = require("../../../platform/configuration/common/configurationService");
|
|
56
59
|
const diffService_1 = require("../../../platform/diff/common/diffService");
|
|
60
|
+
const chatEndpoint_1 = require("../../../platform/endpoint/node/chatEndpoint");
|
|
57
61
|
const proxyXtabEndpoint_1 = require("../../../platform/endpoint/node/proxyXtabEndpoint");
|
|
58
62
|
const ignoreService_1 = require("../../../platform/ignore/common/ignoreService");
|
|
59
63
|
const xtabPromptOptions = __importStar(require("../../../platform/inlineEdits/common/dataTypes/xtabPromptOptions"));
|
|
@@ -66,12 +70,15 @@ const languageContextService_1 = require("../../../platform/languageServer/commo
|
|
|
66
70
|
const logService_1 = require("../../../platform/log/common/logService");
|
|
67
71
|
const simulationTestContext_1 = require("../../../platform/simulationTestContext/common/simulationTestContext");
|
|
68
72
|
const nullExperimentationService_1 = require("../../../platform/telemetry/common/nullExperimentationService");
|
|
73
|
+
const telemetry_1 = require("../../../platform/telemetry/common/telemetry");
|
|
69
74
|
const workspaceService_1 = require("../../../platform/workspace/common/workspaceService");
|
|
70
75
|
const async_1 = require("../../../util/common/async");
|
|
71
76
|
const errors = __importStar(require("../../../util/common/errors"));
|
|
72
77
|
const result_1 = require("../../../util/common/result");
|
|
78
|
+
const tokenizer_1 = require("../../../util/common/tokenizer");
|
|
73
79
|
const tracing_1 = require("../../../util/common/tracing");
|
|
74
80
|
const async_2 = require("../../../util/vs/base/common/async");
|
|
81
|
+
const cancellation_1 = require("../../../util/vs/base/common/cancellation");
|
|
75
82
|
const stopwatch_1 = require("../../../util/vs/base/common/stopwatch");
|
|
76
83
|
const lineEdit_1 = require("../../../util/vs/editor/common/core/edits/lineEdit");
|
|
77
84
|
const stringEdit_1 = require("../../../util/vs/editor/common/core/edits/stringEdit");
|
|
@@ -86,6 +93,9 @@ const ghNearbyNesProvider_1 = require("../../inlineEdits/common/ghNearbyNesProvi
|
|
|
86
93
|
const nearbyCursorInlineEditProvider_1 = require("../../inlineEdits/common/nearbyCursorInlineEditProvider");
|
|
87
94
|
const importFiltering_1 = require("../../inlineEdits/node/importFiltering");
|
|
88
95
|
const promptCrafting_1 = require("../common/promptCrafting");
|
|
96
|
+
const systemMessages_1 = require("../common/systemMessages");
|
|
97
|
+
const tags_1 = require("../common/tags");
|
|
98
|
+
const xtabCurrentDocument_1 = require("../common/xtabCurrentDocument");
|
|
89
99
|
const xtabEndpoint_1 = require("./xtabEndpoint");
|
|
90
100
|
const xtabUtils_1 = require("./xtabUtils");
|
|
91
101
|
var ResponseTags;
|
|
@@ -105,7 +115,8 @@ var ResponseTags;
|
|
|
105
115
|
let XtabProvider = class XtabProvider {
|
|
106
116
|
static { XtabProvider_1 = this; }
|
|
107
117
|
static { this.ID = configurationService_1.XTabProviderId; }
|
|
108
|
-
|
|
118
|
+
static { this.computeTokens = (s) => Math.floor(s.length / 4); }
|
|
119
|
+
constructor(simulationCtx, instaService, workspaceService, diffService, configService, expService, logService, langCtxService, langDiagService, ignoreService, telemetryService) {
|
|
109
120
|
this.simulationCtx = simulationCtx;
|
|
110
121
|
this.instaService = instaService;
|
|
111
122
|
this.workspaceService = workspaceService;
|
|
@@ -116,6 +127,7 @@ let XtabProvider = class XtabProvider {
|
|
|
116
127
|
this.langCtxService = langCtxService;
|
|
117
128
|
this.langDiagService = langDiagService;
|
|
118
129
|
this.ignoreService = ignoreService;
|
|
130
|
+
this.telemetryService = telemetryService;
|
|
119
131
|
this.ID = XtabProvider_1.ID;
|
|
120
132
|
this.dependsOnSelection = true;
|
|
121
133
|
this.showNextEditPreference = "always" /* ShowNextEditPreference.Always */;
|
|
@@ -190,86 +202,48 @@ let XtabProvider = class XtabProvider {
|
|
|
190
202
|
if (selection === null) {
|
|
191
203
|
return result_1.Result.error(new statelessNextEditProvider_1.NoNextEditReason.Uncategorized(new Error('NoSelection')));
|
|
192
204
|
}
|
|
193
|
-
const
|
|
205
|
+
const promptOptions = this.determineModelConfiguration(activeDocument);
|
|
206
|
+
const endpoint = this.getEndpoint(promptOptions.modelName);
|
|
194
207
|
logContext.setEndpointInfo(typeof endpoint.urlOrRequestMetadata === 'string' ? endpoint.urlOrRequestMetadata : JSON.stringify(endpoint.urlOrRequestMetadata.type), endpoint.model);
|
|
195
208
|
telemetryBuilder.setModelName(endpoint.model);
|
|
196
|
-
const computeTokens = (s) => Math.floor(s.length / 4);
|
|
197
209
|
const cursorPosition = new position_1.Position(selection.endLineNumber, selection.endColumn);
|
|
198
|
-
const
|
|
199
|
-
const
|
|
200
|
-
const currentFileContentLines = currentFileContent.getLines();
|
|
201
|
-
const cursorLineIdx = cursorPosition.lineNumber - 1 /* to convert to 0-based */;
|
|
202
|
-
const cursorLine = currentFileContentLines[cursorLineIdx];
|
|
210
|
+
const currentDocument = new xtabCurrentDocument_1.CurrentDocument(activeDocument.documentAfterEdits, cursorPosition);
|
|
211
|
+
const cursorLine = currentDocument.lines[currentDocument.cursorLineOffset];
|
|
203
212
|
const isCursorAtEndOfLine = cursorPosition.column === cursorLine.trimEnd().length;
|
|
204
213
|
if (isCursorAtEndOfLine) {
|
|
205
214
|
delaySession.setExtraDebounce(this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsExtraDebounceEndOfLine, this.expService));
|
|
206
215
|
}
|
|
207
216
|
telemetryBuilder.setIsCursorAtLineEnd(isCursorAtEndOfLine);
|
|
208
|
-
const areaAroundEditWindowLinesRange = this.computeAreaAroundEditWindowLinesRange(
|
|
209
|
-
const editWindowLinesRange = this.computeEditWindowLinesRange(
|
|
210
|
-
const cursorOriginalLinesOffset = Math.max(0,
|
|
211
|
-
const editWindowLastLineLength =
|
|
212
|
-
const editWindow =
|
|
213
|
-
const editWindowLines =
|
|
217
|
+
const areaAroundEditWindowLinesRange = this.computeAreaAroundEditWindowLinesRange(currentDocument);
|
|
218
|
+
const editWindowLinesRange = this.computeEditWindowLinesRange(currentDocument, request, retryState);
|
|
219
|
+
const cursorOriginalLinesOffset = Math.max(0, currentDocument.cursorLineOffset - editWindowLinesRange.start);
|
|
220
|
+
const editWindowLastLineLength = currentDocument.transformer.getLineLength(editWindowLinesRange.endExclusive);
|
|
221
|
+
const editWindow = currentDocument.transformer.getOffsetRange(new range_1.Range(editWindowLinesRange.start + 1, 1, editWindowLinesRange.endExclusive, editWindowLastLineLength + 1));
|
|
222
|
+
const editWindowLines = currentDocument.lines.slice(editWindowLinesRange.start, editWindowLinesRange.endExclusive);
|
|
214
223
|
// Expected: editWindow.substring(activeDocument.documentAfterEdits.value) === editWindowLines.join('\n')
|
|
215
|
-
const doesIncludeCursorTag = editWindowLines.some(line => line.includes(
|
|
224
|
+
const doesIncludeCursorTag = editWindowLines.some(line => line.includes(tags_1.PromptTags.CURSOR));
|
|
216
225
|
const shouldRemoveCursorTagFromResponse = !doesIncludeCursorTag; // we'd like to remove the tag only if the original edit-window didn't include the tag
|
|
217
|
-
const
|
|
218
|
-
const contentWithCursor = addCursorTagEdit.applyOnText(currentFileContent);
|
|
219
|
-
const contentWithCursorLines = contentWithCursor.getLines();
|
|
220
|
-
const editWindowWithCursorLines = contentWithCursorLines.slice(editWindowLinesRange.start, editWindowLinesRange.endExclusive);
|
|
221
|
-
const areaAroundCodeToEdit = [
|
|
222
|
-
promptCrafting_1.PromptTags.AREA_AROUND.start,
|
|
223
|
-
...contentWithCursorLines.slice(areaAroundEditWindowLinesRange.start, editWindowLinesRange.start),
|
|
224
|
-
promptCrafting_1.PromptTags.EDIT_WINDOW.start,
|
|
225
|
-
...editWindowWithCursorLines,
|
|
226
|
-
promptCrafting_1.PromptTags.EDIT_WINDOW.end,
|
|
227
|
-
...contentWithCursorLines.slice(editWindowLinesRange.endExclusive, areaAroundEditWindowLinesRange.endExclusive),
|
|
228
|
-
promptCrafting_1.PromptTags.AREA_AROUND.end
|
|
229
|
-
].join('\n');
|
|
230
|
-
const promptOptions = this.determinePromptOptions(activeDocument);
|
|
231
|
-
const areaAroundCodeToEditForCurrentFile = promptOptions.currentFile.includeTags
|
|
232
|
-
? areaAroundCodeToEdit
|
|
233
|
-
: [
|
|
234
|
-
...contentWithCursorLines.slice(areaAroundEditWindowLinesRange.start, editWindowLinesRange.start),
|
|
235
|
-
...editWindowLines,
|
|
236
|
-
...contentWithCursorLines.slice(editWindowLinesRange.endExclusive, areaAroundEditWindowLinesRange.endExclusive),
|
|
237
|
-
].join('\n');
|
|
238
|
-
const taggedCurrentFileContentResult = (0, promptCrafting_1.createTaggedCurrentFileContentUsingPagedClipping)(currentFileContentLines, areaAroundCodeToEditForCurrentFile, areaAroundEditWindowLinesRange, computeTokens, promptOptions.pagedClipping.pageSize, promptOptions.currentFile);
|
|
226
|
+
const taggedCurrentFileContentResult = this.constructTaggedFile(currentDocument, editWindowLinesRange, areaAroundEditWindowLinesRange, promptOptions, XtabProvider_1.computeTokens, { includeLineNumbers: false });
|
|
239
227
|
if (taggedCurrentFileContentResult.isError()) {
|
|
240
228
|
return result_1.Result.error(new statelessNextEditProvider_1.NoNextEditReason.PromptTooLarge('currentFile'));
|
|
241
229
|
}
|
|
242
|
-
const { taggedCurrentFileContent, nLines: nLinesCurrentFile } = taggedCurrentFileContentResult.val;
|
|
230
|
+
const { taggedCurrentFileR: { taggedCurrentFileContent, nLines: nLinesCurrentFile }, areaAroundCodeToEdit } = taggedCurrentFileContentResult.val;
|
|
243
231
|
telemetryBuilder.setNLinesOfCurrentFileInPrompt(nLinesCurrentFile);
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
const langCtxPromise = this.getLanguageContext(request, delaySession, activeDocument, cursorPosition, logContext, cancellationToken);
|
|
248
|
-
if (promptOptions.languageContext.enabled) {
|
|
249
|
-
langCtx = await langCtxPromise;
|
|
250
|
-
}
|
|
251
|
-
if (recordingEnabled) {
|
|
252
|
-
logContext.setFileDiagnostics(this.langDiagService.getAllDiagnostics());
|
|
253
|
-
langCtxPromise.then(langCtxs => {
|
|
254
|
-
if (langCtxs) {
|
|
255
|
-
logContext.setLanguageContext(langCtxs);
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
}
|
|
232
|
+
const langCtx = await this.getAndProcessLanguageContext(request, delaySession, activeDocument, cursorPosition, promptOptions, logContext, cancellationToken);
|
|
233
|
+
if (cancellationToken.isCancellationRequested) {
|
|
234
|
+
return result_1.Result.error(new statelessNextEditProvider_1.NoNextEditReason.GotCancelled('afterLanguageContextAwait'));
|
|
259
235
|
}
|
|
260
|
-
const
|
|
236
|
+
const promptPieces = new promptCrafting_1.PromptPieces(currentDocument, editWindowLinesRange, areaAroundEditWindowLinesRange, activeDocument, request.xtabEditHistory, taggedCurrentFileContent, areaAroundCodeToEdit, langCtx, XtabProvider_1.computeTokens, promptOptions);
|
|
237
|
+
const userPrompt = (0, promptCrafting_1.getUserPrompt)(promptPieces);
|
|
261
238
|
const prediction = this.getPredictedOutput(editWindowLines, promptOptions.promptingStrategy);
|
|
262
|
-
const messages =
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
},
|
|
267
|
-
{ role: prompt_tsx_1.Raw.ChatRole.User, content: (0, globalStringUtils_1.toTextParts)(userPrompt) }
|
|
268
|
-
];
|
|
239
|
+
const messages = constructMessages({
|
|
240
|
+
systemMsg: this.pickSystemPrompt(promptOptions.promptingStrategy),
|
|
241
|
+
userMsg: userPrompt,
|
|
242
|
+
});
|
|
269
243
|
logContext.setPrompt(messages);
|
|
270
244
|
telemetryBuilder.setPrompt(messages);
|
|
271
245
|
const HARD_CHAR_LIMIT = 30000 * 4; // 30K tokens, assuming 4 chars per token -- we use approximation here because counting tokens exactly is time-consuming
|
|
272
|
-
const promptCharCount = messages
|
|
246
|
+
const promptCharCount = charCount(messages);
|
|
273
247
|
if (promptCharCount > HARD_CHAR_LIMIT) {
|
|
274
248
|
return result_1.Result.error(new statelessNextEditProvider_1.NoNextEditReason.PromptTooLarge('final'));
|
|
275
249
|
}
|
|
@@ -279,13 +253,73 @@ let XtabProvider = class XtabProvider {
|
|
|
279
253
|
}
|
|
280
254
|
request.fetchIssued = true;
|
|
281
255
|
const cursorLineOffset = cursorPosition.column;
|
|
282
|
-
this.streamEdits(request, pushEdit, endpoint, messages, editWindow, editWindowLines, cursorOriginalLinesOffset, cursorLineOffset, editWindowLinesRange, prediction, {
|
|
256
|
+
this.streamEdits(request, pushEdit, endpoint, messages, editWindow, editWindowLines, cursorOriginalLinesOffset, cursorLineOffset, editWindowLinesRange, promptPieces, prediction, {
|
|
283
257
|
shouldRemoveCursorTagFromResponse,
|
|
284
258
|
promptingStrategy: promptOptions.promptingStrategy,
|
|
285
259
|
retryState,
|
|
286
260
|
}, delaySession, tracer, telemetryBuilder, logContext, cancellationToken);
|
|
287
261
|
return result_1.Result.ok(undefined);
|
|
288
262
|
}
|
|
263
|
+
constructTaggedFile(currentDocument, editWindowLinesRange, areaAroundEditWindowLinesRange, promptOptions, computeTokens, opts) {
|
|
264
|
+
const contentWithCursorAsLinesOriginal = (() => {
|
|
265
|
+
const addCursorTagEdit = stringEdit_1.StringEdit.single(stringEdit_1.StringReplacement.insert(currentDocument.cursorOffset, tags_1.PromptTags.CURSOR));
|
|
266
|
+
const contentWithCursor = addCursorTagEdit.applyOnText(currentDocument.content);
|
|
267
|
+
return contentWithCursor.getLines();
|
|
268
|
+
})();
|
|
269
|
+
const addLineNumbers = (lines) => lines.map((line, idx) => `${idx}| ${line}`);
|
|
270
|
+
const contentWithCursorAsLines = opts.includeLineNumbers
|
|
271
|
+
? addLineNumbers(contentWithCursorAsLinesOriginal)
|
|
272
|
+
: contentWithCursorAsLinesOriginal;
|
|
273
|
+
const editWindowWithCursorAsLines = contentWithCursorAsLines.slice(editWindowLinesRange.start, editWindowLinesRange.endExclusive);
|
|
274
|
+
const areaAroundCodeToEdit = [
|
|
275
|
+
tags_1.PromptTags.AREA_AROUND.start,
|
|
276
|
+
...contentWithCursorAsLines.slice(areaAroundEditWindowLinesRange.start, editWindowLinesRange.start),
|
|
277
|
+
tags_1.PromptTags.EDIT_WINDOW.start,
|
|
278
|
+
...editWindowWithCursorAsLines,
|
|
279
|
+
tags_1.PromptTags.EDIT_WINDOW.end,
|
|
280
|
+
...contentWithCursorAsLines.slice(editWindowLinesRange.endExclusive, areaAroundEditWindowLinesRange.endExclusive),
|
|
281
|
+
tags_1.PromptTags.AREA_AROUND.end
|
|
282
|
+
].join('\n');
|
|
283
|
+
const currentFileContentLines = opts.includeLineNumbers
|
|
284
|
+
? addLineNumbers(currentDocument.lines)
|
|
285
|
+
: currentDocument.lines;
|
|
286
|
+
let areaAroundCodeToEditForCurrentFile;
|
|
287
|
+
if (promptOptions.currentFile.includeTags) {
|
|
288
|
+
areaAroundCodeToEditForCurrentFile = areaAroundCodeToEdit;
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
const editWindowLines = currentFileContentLines.slice(editWindowLinesRange.start, editWindowLinesRange.endExclusive);
|
|
292
|
+
areaAroundCodeToEditForCurrentFile = [
|
|
293
|
+
...contentWithCursorAsLines.slice(areaAroundEditWindowLinesRange.start, editWindowLinesRange.start),
|
|
294
|
+
...editWindowLines,
|
|
295
|
+
...contentWithCursorAsLines.slice(editWindowLinesRange.endExclusive, areaAroundEditWindowLinesRange.endExclusive),
|
|
296
|
+
].join('\n');
|
|
297
|
+
}
|
|
298
|
+
const taggedCurrentFileContentResult = (0, promptCrafting_1.createTaggedCurrentFileContentUsingPagedClipping)(currentFileContentLines, areaAroundCodeToEditForCurrentFile, areaAroundEditWindowLinesRange, computeTokens, promptOptions.pagedClipping.pageSize, promptOptions.currentFile);
|
|
299
|
+
return taggedCurrentFileContentResult.map(taggedCurrentFileR => ({
|
|
300
|
+
taggedCurrentFileR,
|
|
301
|
+
areaAroundCodeToEdit,
|
|
302
|
+
}));
|
|
303
|
+
}
|
|
304
|
+
getAndProcessLanguageContext(request, delaySession, activeDocument, cursorPosition, promptOptions, logContext, cancellationToken) {
|
|
305
|
+
const recordingEnabled = this.configService.getConfig(configurationService_1.ConfigKey.Internal.InlineEditsLogContextRecorderEnabled);
|
|
306
|
+
if (!promptOptions.languageContext.enabled && !recordingEnabled) {
|
|
307
|
+
return Promise.resolve(undefined);
|
|
308
|
+
}
|
|
309
|
+
const langCtxPromise = this.getLanguageContext(request, delaySession, activeDocument, cursorPosition, logContext, cancellationToken);
|
|
310
|
+
// if recording, add diagnostics for the file to the recording and hook up the language context promise to write to the recording
|
|
311
|
+
if (recordingEnabled) {
|
|
312
|
+
logContext.setFileDiagnostics(this.langDiagService.getAllDiagnostics());
|
|
313
|
+
langCtxPromise.then(langCtxs => {
|
|
314
|
+
if (langCtxs) {
|
|
315
|
+
logContext.setLanguageContext(langCtxs);
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
return promptOptions.languageContext.enabled
|
|
320
|
+
? langCtxPromise
|
|
321
|
+
: Promise.resolve(undefined);
|
|
322
|
+
}
|
|
289
323
|
async getLanguageContext(request, delaySession, activeDocument, cursorPosition, logContext, cancellationToken) {
|
|
290
324
|
try {
|
|
291
325
|
const textDoc = this.workspaceService.textDocuments.find(doc => doc.uri.toString() === activeDocument.id.uri);
|
|
@@ -348,8 +382,9 @@ let XtabProvider = class XtabProvider {
|
|
|
348
382
|
}
|
|
349
383
|
}
|
|
350
384
|
async streamEdits(request, pushEdit, endpoint, messages, editWindow, editWindowLines, cursorOriginalLinesOffset, cursorLineOffset, // cursor offset within the line it's in; 1-based
|
|
351
|
-
editWindowLineRange, prediction, opts, delaySession, parentTracer, telemetryBuilder, logContext, cancellationToken) {
|
|
385
|
+
editWindowLineRange, promptPieces, prediction, opts, delaySession, parentTracer, telemetryBuilder, logContext, cancellationToken) {
|
|
352
386
|
const tracer = parentTracer.sub('streamEdits');
|
|
387
|
+
const useFetcher = this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.NextEditSuggestionsFetcher, this.expService) || undefined;
|
|
353
388
|
const fetchStreamSource = new chatMLFetcher_1.FetchStreamSource();
|
|
354
389
|
const fetchRequestStopWatch = new stopwatch_1.StopWatch();
|
|
355
390
|
let responseSoFar = '';
|
|
@@ -386,6 +421,7 @@ let XtabProvider = class XtabProvider {
|
|
|
386
421
|
telemetryProperties: {
|
|
387
422
|
requestId: request.id,
|
|
388
423
|
},
|
|
424
|
+
useFetcher,
|
|
389
425
|
}, cancellationToken);
|
|
390
426
|
telemetryBuilder.setResponse(fetchResultPromise.then((response) => ({ response, ttft })));
|
|
391
427
|
logContext.setFullResponse(fetchResultPromise.then((response) => response.type === commonTypes_1.ChatFetchResponseType.Success ? response.value : undefined));
|
|
@@ -430,7 +466,7 @@ let XtabProvider = class XtabProvider {
|
|
|
430
466
|
logContext.addLog(trace);
|
|
431
467
|
tracer.trace(trace);
|
|
432
468
|
return opts.shouldRemoveCursorTagFromResponse
|
|
433
|
-
? v.replaceAll(
|
|
469
|
+
? v.replaceAll(tags_1.PromptTags.CURSOR, '')
|
|
434
470
|
: v;
|
|
435
471
|
});
|
|
436
472
|
})();
|
|
@@ -453,7 +489,7 @@ let XtabProvider = class XtabProvider {
|
|
|
453
489
|
}
|
|
454
490
|
const trimmedLines = firstLine.value.trim();
|
|
455
491
|
if (trimmedLines === ResponseTags.NO_CHANGE.start) {
|
|
456
|
-
this.pushNoSuggestionsOrRetry(request, editWindow, pushEdit, delaySession, logContext, cancellationToken, telemetryBuilder, opts.retryState);
|
|
492
|
+
await this.pushNoSuggestionsOrRetry(request, editWindow, promptPieces, pushEdit, delaySession, logContext, cancellationToken, telemetryBuilder, opts.retryState);
|
|
457
493
|
return;
|
|
458
494
|
}
|
|
459
495
|
if (trimmedLines === ResponseTags.INSERT.start) {
|
|
@@ -557,7 +593,7 @@ let XtabProvider = class XtabProvider {
|
|
|
557
593
|
pushEdit(result_1.Result.error(new statelessNextEditProvider_1.NoNextEditReason.NoSuggestions(request.documentBeforeEdits, editWindow)));
|
|
558
594
|
}
|
|
559
595
|
else {
|
|
560
|
-
this.pushNoSuggestionsOrRetry(request, editWindow, pushEdit, delaySession, logContext, cancellationToken, telemetryBuilder, opts.retryState);
|
|
596
|
+
await this.pushNoSuggestionsOrRetry(request, editWindow, promptPieces, pushEdit, delaySession, logContext, cancellationToken, telemetryBuilder, opts.retryState);
|
|
561
597
|
}
|
|
562
598
|
}
|
|
563
599
|
catch (err) {
|
|
@@ -567,29 +603,58 @@ let XtabProvider = class XtabProvider {
|
|
|
567
603
|
}
|
|
568
604
|
})();
|
|
569
605
|
}
|
|
570
|
-
pushNoSuggestionsOrRetry(request, editWindow, pushEdit, delaySession, logContext, cancellationToken, telemetryBuilder, retryState) {
|
|
606
|
+
async pushNoSuggestionsOrRetry(request, editWindow, promptPieces, pushEdit, delaySession, logContext, cancellationToken, telemetryBuilder, retryState) {
|
|
571
607
|
const allowRetryWithExpandedWindow = this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabProviderRetryWithNMoreLinesBelow, this.expService);
|
|
572
608
|
// if allowed to retry and not retrying already, flip the retry state and try again
|
|
573
609
|
if (allowRetryWithExpandedWindow && retryState === 0 /* RetryState.NotRetrying */ && request.expandedEditWindowNLines === undefined) {
|
|
574
|
-
this.doGetNextEdit(request, pushEdit, delaySession, logContext, cancellationToken, telemetryBuilder, 1 /* RetryState.
|
|
610
|
+
this.doGetNextEdit(request, pushEdit, delaySession, logContext, cancellationToken, telemetryBuilder, 1 /* RetryState.Retrying */);
|
|
575
611
|
return;
|
|
576
612
|
}
|
|
613
|
+
const nextCursorLinePredictionEnabled = this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsNextCursorPredictionEnabled, this.expService);
|
|
614
|
+
if (nextCursorLinePredictionEnabled && retryState === 0 /* RetryState.NotRetrying */) {
|
|
615
|
+
const nextCursorLineR = await this.predictNextCursorPosition(promptPieces);
|
|
616
|
+
if (nextCursorLineR.isError()) {
|
|
617
|
+
this.tracer.trace(`Predicted next cursor line error: ${nextCursorLineR.err.message}`);
|
|
618
|
+
telemetryBuilder.setNextCursorLineError(nextCursorLineR.err.message);
|
|
619
|
+
}
|
|
620
|
+
else {
|
|
621
|
+
const nextCursorLine = nextCursorLineR.val;
|
|
622
|
+
const lineDistanceFromCursorLine = nextCursorLine - promptPieces.currentDocument.cursorLineOffset;
|
|
623
|
+
telemetryBuilder.setNextCursorLineDistance(lineDistanceFromCursorLine);
|
|
624
|
+
this.tracer.trace(`Predicted next cursor line: ${nextCursorLine}`);
|
|
625
|
+
if (nextCursorLine >= promptPieces.currentDocument.lines.length) { // >= because the line index is zero-based
|
|
626
|
+
this.tracer.trace(`Predicted next cursor line error: exceedsDocumentLines`);
|
|
627
|
+
telemetryBuilder.setNextCursorLineError('exceedsDocumentLines');
|
|
628
|
+
}
|
|
629
|
+
else if (promptPieces.editWindowLinesRange.contains(nextCursorLine)) {
|
|
630
|
+
this.tracer.trace(`Predicted next cursor line error: withinEditWindow`);
|
|
631
|
+
telemetryBuilder.setNextCursorLineError('withinEditWindow');
|
|
632
|
+
}
|
|
633
|
+
else {
|
|
634
|
+
this.doGetNextEditWithSelection(request, new range_1.Range(nextCursorLine + 1, 1, nextCursorLine + 1, 1), pushEdit, delaySession, logContext, cancellationToken, telemetryBuilder, 1 /* RetryState.Retrying */);
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
577
639
|
pushEdit(result_1.Result.error(new statelessNextEditProvider_1.NoNextEditReason.NoSuggestions(request.documentBeforeEdits, editWindow)));
|
|
578
640
|
return;
|
|
579
641
|
}
|
|
580
|
-
computeAreaAroundEditWindowLinesRange(
|
|
642
|
+
computeAreaAroundEditWindowLinesRange(currentDocument) {
|
|
643
|
+
const cursorLine = currentDocument.cursorLineOffset;
|
|
581
644
|
const areaAroundStart = Math.max(0, cursorLine - promptCrafting_1.N_LINES_AS_CONTEXT);
|
|
582
|
-
const areaAroundEndExcl = Math.min(
|
|
645
|
+
const areaAroundEndExcl = Math.min(currentDocument.lines.length, cursorLine + promptCrafting_1.N_LINES_AS_CONTEXT + 1);
|
|
583
646
|
return new offsetRange_1.OffsetRange(areaAroundStart, areaAroundEndExcl);
|
|
584
647
|
}
|
|
585
|
-
computeEditWindowLinesRange(
|
|
648
|
+
computeEditWindowLinesRange(currentDocument, request, retryState) {
|
|
649
|
+
const currentDocLines = currentDocument.lines;
|
|
650
|
+
const cursorLineOffset = currentDocument.cursorLineOffset;
|
|
586
651
|
let nLinesAbove;
|
|
587
652
|
{
|
|
588
653
|
const useVaryingLinesAbove = this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabProviderUseVaryingLinesAbove, this.expService);
|
|
589
654
|
if (useVaryingLinesAbove) {
|
|
590
655
|
nLinesAbove = 0; // default
|
|
591
656
|
for (let i = 0; i < 8; ++i) {
|
|
592
|
-
const lineIdx =
|
|
657
|
+
const lineIdx = cursorLineOffset - i;
|
|
593
658
|
if (lineIdx < 0) {
|
|
594
659
|
break;
|
|
595
660
|
}
|
|
@@ -620,11 +685,28 @@ let XtabProvider = class XtabProvider {
|
|
|
620
685
|
nLinesBelow = promptCrafting_1.N_LINES_BELOW; // default
|
|
621
686
|
}
|
|
622
687
|
}
|
|
623
|
-
if (retryState === 1 /* RetryState.
|
|
688
|
+
if (retryState === 1 /* RetryState.Retrying */) {
|
|
624
689
|
nLinesBelow += this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabProviderRetryWithNMoreLinesBelow, this.expService) ?? 0;
|
|
625
690
|
}
|
|
626
|
-
|
|
627
|
-
|
|
691
|
+
let codeToEditStart = Math.max(0, cursorLineOffset - nLinesAbove);
|
|
692
|
+
let codeToEditEndExcl = Math.min(currentDocLines.length, cursorLineOffset + nLinesBelow + 1);
|
|
693
|
+
const maxMergeConflictLines = this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabMaxMergeConflictLines, this.expService);
|
|
694
|
+
if (maxMergeConflictLines) {
|
|
695
|
+
const tentativeEditWindow = new offsetRange_1.OffsetRange(codeToEditStart, codeToEditEndExcl);
|
|
696
|
+
const mergeConflictRange = findMergeConflictMarkersRange(currentDocLines, tentativeEditWindow, maxMergeConflictLines);
|
|
697
|
+
if (mergeConflictRange) {
|
|
698
|
+
const onlyMergeConflictLines = this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabOnlyMergeConflictLines, this.expService);
|
|
699
|
+
if (onlyMergeConflictLines) {
|
|
700
|
+
this.tracer.trace(`Expanding edit window to include ONLY merge conflict markers: ${mergeConflictRange.toString()}`);
|
|
701
|
+
codeToEditStart = mergeConflictRange.start;
|
|
702
|
+
codeToEditEndExcl = mergeConflictRange.endExclusive;
|
|
703
|
+
}
|
|
704
|
+
else {
|
|
705
|
+
this.tracer.trace(`Expanding edit window to include merge conflict markers: ${mergeConflictRange.toString()}; edit window range [${codeToEditStart}, ${codeToEditEndExcl})`);
|
|
706
|
+
codeToEditEndExcl = Math.max(codeToEditEndExcl, mergeConflictRange.endExclusive);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
}
|
|
628
710
|
return new offsetRange_1.OffsetRange(codeToEditStart, codeToEditEndExcl);
|
|
629
711
|
}
|
|
630
712
|
static mapChatFetcherErrorToNoNextEditReason(fetchError) {
|
|
@@ -650,40 +732,175 @@ let XtabProvider = class XtabProvider {
|
|
|
650
732
|
return new statelessNextEditProvider_1.NoNextEditReason.FetchFailure(errors.fromUnknown(fetchError));
|
|
651
733
|
}
|
|
652
734
|
}
|
|
653
|
-
|
|
735
|
+
determineModelConfiguration(activeDocument) {
|
|
654
736
|
if (this.forceUseDefaultModel) {
|
|
655
|
-
return xtabPromptOptions.DEFAULT_OPTIONS;
|
|
656
|
-
}
|
|
657
|
-
else {
|
|
658
|
-
const promptingStrategy = this.determinePromptingStrategy();
|
|
659
737
|
return {
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
maxTokens: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabCurrentFileMaxTokens, this.expService),
|
|
663
|
-
includeTags: promptingStrategy !== xtabPromptOptions.PromptingStrategy.UnifiedModel /* unified model doesn't use tags in current file */ && this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabIncludeTagsInCurrentFile, this.expService),
|
|
664
|
-
prioritizeAboveCursor: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabPrioritizeAboveCursor, this.expService)
|
|
665
|
-
},
|
|
666
|
-
pagedClipping: {
|
|
667
|
-
pageSize: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabPageSize, this.expService)
|
|
668
|
-
},
|
|
669
|
-
recentlyViewedDocuments: {
|
|
670
|
-
nDocuments: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabNRecentlyViewedDocuments, this.expService),
|
|
671
|
-
maxTokens: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabRecentlyViewedDocumentsMaxTokens, this.expService),
|
|
672
|
-
includeViewedFiles: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabIncludeViewedFiles, this.expService),
|
|
673
|
-
},
|
|
674
|
-
languageContext: this.determineLanguageContextOptions(activeDocument.languageId, {
|
|
675
|
-
enabled: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabLanguageContextEnabled, this.expService),
|
|
676
|
-
enabledLanguages: this.configService.getConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabLanguageContextEnabledLanguages),
|
|
677
|
-
maxTokens: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabLanguageContextMaxTokens, this.expService),
|
|
678
|
-
}),
|
|
679
|
-
diffHistory: {
|
|
680
|
-
nEntries: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabDiffNEntries, this.expService),
|
|
681
|
-
maxTokens: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabDiffMaxTokens, this.expService),
|
|
682
|
-
onlyForDocsInPrompt: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabDiffOnlyForDocsInPrompt, this.expService),
|
|
683
|
-
useRelativePaths: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabDiffUseRelativePaths, this.expService),
|
|
684
|
-
}
|
|
738
|
+
modelName: undefined,
|
|
739
|
+
...xtabPromptOptions.DEFAULT_OPTIONS,
|
|
685
740
|
};
|
|
686
741
|
}
|
|
742
|
+
const promptingStrategy = this.determinePromptingStrategy();
|
|
743
|
+
const sourcedModelConfig = {
|
|
744
|
+
modelName: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabProviderModelName, this.expService),
|
|
745
|
+
promptingStrategy,
|
|
746
|
+
currentFile: {
|
|
747
|
+
maxTokens: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabCurrentFileMaxTokens, this.expService),
|
|
748
|
+
includeTags: promptingStrategy !== xtabPromptOptions.PromptingStrategy.UnifiedModel /* unified model doesn't use tags in current file */ && this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabIncludeTagsInCurrentFile, this.expService),
|
|
749
|
+
prioritizeAboveCursor: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabPrioritizeAboveCursor, this.expService)
|
|
750
|
+
},
|
|
751
|
+
pagedClipping: {
|
|
752
|
+
pageSize: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabPageSize, this.expService)
|
|
753
|
+
},
|
|
754
|
+
recentlyViewedDocuments: {
|
|
755
|
+
nDocuments: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabNRecentlyViewedDocuments, this.expService),
|
|
756
|
+
maxTokens: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabRecentlyViewedDocumentsMaxTokens, this.expService),
|
|
757
|
+
includeViewedFiles: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabIncludeViewedFiles, this.expService),
|
|
758
|
+
},
|
|
759
|
+
languageContext: this.determineLanguageContextOptions(activeDocument.languageId, {
|
|
760
|
+
enabled: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabLanguageContextEnabled, this.expService),
|
|
761
|
+
enabledLanguages: this.configService.getConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabLanguageContextEnabledLanguages),
|
|
762
|
+
maxTokens: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabLanguageContextMaxTokens, this.expService),
|
|
763
|
+
}),
|
|
764
|
+
diffHistory: {
|
|
765
|
+
nEntries: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabDiffNEntries, this.expService),
|
|
766
|
+
maxTokens: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabDiffMaxTokens, this.expService),
|
|
767
|
+
onlyForDocsInPrompt: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabDiffOnlyForDocsInPrompt, this.expService),
|
|
768
|
+
useRelativePaths: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabDiffUseRelativePaths, this.expService),
|
|
769
|
+
},
|
|
770
|
+
includePostScript: true,
|
|
771
|
+
};
|
|
772
|
+
const localOverridingModelConfig = this.configService.getConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabProviderModelConfiguration);
|
|
773
|
+
if (localOverridingModelConfig) {
|
|
774
|
+
return XtabProvider_1.overrideModelConfig(sourcedModelConfig, localOverridingModelConfig);
|
|
775
|
+
}
|
|
776
|
+
const expBasedModelConfig = this.overrideByStringModelConfig(sourcedModelConfig, configurationService_1.ConfigKey.Internal.InlineEditsXtabProviderModelConfigurationString);
|
|
777
|
+
if (expBasedModelConfig) {
|
|
778
|
+
return expBasedModelConfig;
|
|
779
|
+
}
|
|
780
|
+
const defaultModelConfig = this.overrideByStringModelConfig(sourcedModelConfig, configurationService_1.ConfigKey.Internal.InlineEditsXtabProviderDefaultModelConfigurationString);
|
|
781
|
+
if (defaultModelConfig) {
|
|
782
|
+
return defaultModelConfig;
|
|
783
|
+
}
|
|
784
|
+
return sourcedModelConfig;
|
|
785
|
+
}
|
|
786
|
+
overrideByStringModelConfig(originalModelConfig, configKey) {
|
|
787
|
+
const configString = this.configService.getExperimentBasedConfig(configKey, this.expService);
|
|
788
|
+
if (configString === undefined) {
|
|
789
|
+
return undefined;
|
|
790
|
+
}
|
|
791
|
+
let parsedConfig;
|
|
792
|
+
try {
|
|
793
|
+
parsedConfig = JSON.parse(configString);
|
|
794
|
+
}
|
|
795
|
+
catch (e) {
|
|
796
|
+
/* __GDPR__
|
|
797
|
+
"incorrectNesModelConfig" : {
|
|
798
|
+
"owner": "ulugbekna",
|
|
799
|
+
"comment": "Capture if model configuration string is invalid JSON.",
|
|
800
|
+
"configName": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Name of the configuration that failed to parse." },
|
|
801
|
+
"errorMessage": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Error message from JSON.parse." },
|
|
802
|
+
"configValue": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The invalid JSON string." }
|
|
803
|
+
}
|
|
804
|
+
*/
|
|
805
|
+
this.telemetryService.sendMSFTTelemetryEvent('incorrectNesModelConfig', { configName: configKey.id, errorMessage: errors.toString(errors.fromUnknown(e)), configValue: configString });
|
|
806
|
+
}
|
|
807
|
+
if (parsedConfig) {
|
|
808
|
+
return XtabProvider_1.overrideModelConfig(originalModelConfig, parsedConfig);
|
|
809
|
+
}
|
|
810
|
+
return undefined;
|
|
811
|
+
}
|
|
812
|
+
static overrideModelConfig(modelConfig, overridingConfig) {
|
|
813
|
+
return {
|
|
814
|
+
...modelConfig,
|
|
815
|
+
modelName: overridingConfig.modelName,
|
|
816
|
+
promptingStrategy: overridingConfig.promptingStrategy,
|
|
817
|
+
currentFile: {
|
|
818
|
+
...modelConfig.currentFile,
|
|
819
|
+
includeTags: overridingConfig.includeTagsInCurrentFile,
|
|
820
|
+
},
|
|
821
|
+
};
|
|
822
|
+
}
|
|
823
|
+
async predictNextCursorPosition(promptPieces) {
|
|
824
|
+
const tracer = this.tracer.sub('predictNextCursorPosition');
|
|
825
|
+
const systemMessage = 'Your task is to predict the next line number in the current file where the developer is most likely to make their next edit, using the provided context.';
|
|
826
|
+
const currentFileContentR = this.constructTaggedFile(promptPieces.currentDocument, promptPieces.editWindowLinesRange, promptPieces.areaAroundEditWindowLinesRange, {
|
|
827
|
+
...promptPieces.opts,
|
|
828
|
+
currentFile: {
|
|
829
|
+
...promptPieces.opts.currentFile,
|
|
830
|
+
includeTags: false,
|
|
831
|
+
}
|
|
832
|
+
}, XtabProvider_1.computeTokens, { includeLineNumbers: true });
|
|
833
|
+
if (currentFileContentR.isError()) {
|
|
834
|
+
tracer.trace(`Failed to construct tagged file: ${currentFileContentR.err}`);
|
|
835
|
+
return result_1.Result.fromString(currentFileContentR.err);
|
|
836
|
+
}
|
|
837
|
+
const { taggedCurrentFileR: { taggedCurrentFileContent }, areaAroundCodeToEdit } = currentFileContentR.val;
|
|
838
|
+
const newPromptPieces = new promptCrafting_1.PromptPieces(promptPieces.currentDocument, promptPieces.editWindowLinesRange, promptPieces.areaAroundEditWindowLinesRange, promptPieces.activeDoc, promptPieces.xtabHistory, taggedCurrentFileContent, areaAroundCodeToEdit, promptPieces.langCtx, XtabProvider_1.computeTokens, {
|
|
839
|
+
...promptPieces.opts,
|
|
840
|
+
includePostScript: false,
|
|
841
|
+
});
|
|
842
|
+
const userMessage = (0, promptCrafting_1.getUserPrompt)(newPromptPieces);
|
|
843
|
+
const messages = constructMessages({
|
|
844
|
+
systemMsg: systemMessage,
|
|
845
|
+
userMsg: userMessage
|
|
846
|
+
});
|
|
847
|
+
const modelName = this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsNextCursorPredictionModelName, this.expService);
|
|
848
|
+
if (modelName === undefined) {
|
|
849
|
+
tracer.trace('Model name for cursor prediction is not defined; skipping prediction');
|
|
850
|
+
return result_1.Result.fromString('modelNameNotDefined');
|
|
851
|
+
}
|
|
852
|
+
const url = this.configService.getConfig(configurationService_1.ConfigKey.Internal.InlineEditsNextCursorPredictionUrl);
|
|
853
|
+
const secretKey = this.configService.getConfig(configurationService_1.ConfigKey.Internal.InlineEditsNextCursorPredictionApiKey);
|
|
854
|
+
const endpoint = this.instaService.createInstance(chatEndpoint_1.ChatEndpoint, {
|
|
855
|
+
id: modelName,
|
|
856
|
+
name: 'nes.nextCursorPosition',
|
|
857
|
+
urlOrRequestMetadata: url ? url : { type: copilot_api_1.RequestType.ProxyChatCompletions },
|
|
858
|
+
model_picker_enabled: false,
|
|
859
|
+
is_chat_default: false,
|
|
860
|
+
is_chat_fallback: false,
|
|
861
|
+
version: '',
|
|
862
|
+
capabilities: {
|
|
863
|
+
type: 'chat',
|
|
864
|
+
family: '',
|
|
865
|
+
tokenizer: tokenizer_1.TokenizerType.CL100K,
|
|
866
|
+
limits: undefined,
|
|
867
|
+
supports: {
|
|
868
|
+
parallel_tool_calls: false,
|
|
869
|
+
tool_calls: false,
|
|
870
|
+
streaming: true,
|
|
871
|
+
vision: false,
|
|
872
|
+
prediction: false,
|
|
873
|
+
thinking: false
|
|
874
|
+
}
|
|
875
|
+
},
|
|
876
|
+
});
|
|
877
|
+
const response = await endpoint.makeChatRequest2({
|
|
878
|
+
messages,
|
|
879
|
+
debugName: 'nes.nextCursorPosition',
|
|
880
|
+
finishedCb: undefined,
|
|
881
|
+
location: commonTypes_1.ChatLocation.Other,
|
|
882
|
+
requestOptions: secretKey ? {
|
|
883
|
+
secretKey,
|
|
884
|
+
} : undefined,
|
|
885
|
+
}, cancellation_1.CancellationToken.None);
|
|
886
|
+
if (response.type !== commonTypes_1.ChatFetchResponseType.Success) {
|
|
887
|
+
return result_1.Result.fromString(`fetchError:${response.type}`);
|
|
888
|
+
}
|
|
889
|
+
try {
|
|
890
|
+
const trimmed = response.value.trim();
|
|
891
|
+
const lineNumber = parseInt(trimmed, 10);
|
|
892
|
+
if (isNaN(lineNumber)) {
|
|
893
|
+
return result_1.Result.fromString(`gotNaN`);
|
|
894
|
+
}
|
|
895
|
+
if (lineNumber < 0) {
|
|
896
|
+
return result_1.Result.fromString(`negativeLineNumber`);
|
|
897
|
+
}
|
|
898
|
+
return result_1.Result.ok(lineNumber);
|
|
899
|
+
}
|
|
900
|
+
catch (err) {
|
|
901
|
+
tracer.trace(`Failed to parse predicted line number from response '${response.value}': ${err}`);
|
|
902
|
+
return result_1.Result.fromString(`failedToParseLine:"${response.value}". Error ${errors.fromUnknown(err).message}`);
|
|
903
|
+
}
|
|
687
904
|
}
|
|
688
905
|
determinePromptingStrategy() {
|
|
689
906
|
const isXtabUnifiedModel = this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabUseUnifiedModel, this.expService);
|
|
@@ -713,16 +930,16 @@ let XtabProvider = class XtabProvider {
|
|
|
713
930
|
pickSystemPrompt(promptingStrategy) {
|
|
714
931
|
switch (promptingStrategy) {
|
|
715
932
|
case xtabPromptOptions.PromptingStrategy.UnifiedModel:
|
|
716
|
-
return
|
|
933
|
+
return systemMessages_1.unifiedModelSystemPrompt;
|
|
717
934
|
case xtabPromptOptions.PromptingStrategy.Codexv21NesUnified:
|
|
718
935
|
case xtabPromptOptions.PromptingStrategy.SimplifiedSystemPrompt:
|
|
719
|
-
return
|
|
936
|
+
return systemMessages_1.simplifiedPrompt;
|
|
720
937
|
case xtabPromptOptions.PromptingStrategy.Xtab275:
|
|
721
|
-
return
|
|
938
|
+
return systemMessages_1.xtab275SystemPrompt;
|
|
722
939
|
case xtabPromptOptions.PromptingStrategy.Nes41Miniv3:
|
|
723
|
-
return
|
|
940
|
+
return systemMessages_1.nes41Miniv3SystemPrompt;
|
|
724
941
|
default:
|
|
725
|
-
return
|
|
942
|
+
return systemMessages_1.systemPromptTemplate;
|
|
726
943
|
}
|
|
727
944
|
}
|
|
728
945
|
determineLanguageContextOptions(languageId, { enabled, enabledLanguages, maxTokens }) {
|
|
@@ -732,18 +949,14 @@ let XtabProvider = class XtabProvider {
|
|
|
732
949
|
}
|
|
733
950
|
return { enabled, maxTokens };
|
|
734
951
|
}
|
|
735
|
-
getEndpoint() {
|
|
952
|
+
getEndpoint(configuredModelName) {
|
|
736
953
|
const url = this.configService.getConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabProviderUrl);
|
|
737
954
|
const apiKey = this.configService.getConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabProviderApiKey);
|
|
738
955
|
const hasOverriddenUrlAndApiKey = url !== undefined && apiKey !== undefined;
|
|
739
|
-
const configuredModelName = this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabProviderModelName, this.expService);
|
|
740
956
|
if (hasOverriddenUrlAndApiKey) {
|
|
741
957
|
return this.instaService.createInstance(xtabEndpoint_1.XtabEndpoint, url, apiKey, configuredModelName);
|
|
742
958
|
}
|
|
743
|
-
|
|
744
|
-
? undefined
|
|
745
|
-
: this.configService.getExperimentBasedConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabProviderModelName, this.expService);
|
|
746
|
-
return (0, proxyXtabEndpoint_1.createProxyXtabEndpoint)(this.instaService, modelName);
|
|
959
|
+
return (0, proxyXtabEndpoint_1.createProxyXtabEndpoint)(this.instaService, configuredModelName);
|
|
747
960
|
}
|
|
748
961
|
getPredictedOutput(editWindowLines, promptingStrategy) {
|
|
749
962
|
return this.configService.getConfig(configurationService_1.ConfigKey.Internal.InlineEditsXtabProviderUsePrediction)
|
|
@@ -802,6 +1015,45 @@ exports.XtabProvider = XtabProvider = XtabProvider_1 = __decorate([
|
|
|
802
1015
|
__param(6, logService_1.ILogService),
|
|
803
1016
|
__param(7, languageContextProviderService_1.ILanguageContextProviderService),
|
|
804
1017
|
__param(8, languageDiagnosticsService_1.ILanguageDiagnosticsService),
|
|
805
|
-
__param(9, ignoreService_1.IIgnoreService)
|
|
1018
|
+
__param(9, ignoreService_1.IIgnoreService),
|
|
1019
|
+
__param(10, telemetry_1.ITelemetryService)
|
|
806
1020
|
], XtabProvider);
|
|
1021
|
+
/**
|
|
1022
|
+
* Finds the range of lines containing merge conflict markers within a specified edit window.
|
|
1023
|
+
*
|
|
1024
|
+
* @param lines - Array of strings representing the lines of text to search through
|
|
1025
|
+
* @param editWindowRange - The range within which to search for merge conflict markers
|
|
1026
|
+
* @param maxMergeConflictLines - Maximum number of lines to search for conflict markers
|
|
1027
|
+
* @returns An OffsetRange object representing the start and end of the conflict markers, or undefined if not found
|
|
1028
|
+
*/
|
|
1029
|
+
function findMergeConflictMarkersRange(lines, editWindowRange, maxMergeConflictLines) {
|
|
1030
|
+
for (let i = editWindowRange.start; i < Math.min(lines.length, editWindowRange.endExclusive); ++i) {
|
|
1031
|
+
if (!lines[i].startsWith('<<<<<<<')) {
|
|
1032
|
+
continue;
|
|
1033
|
+
}
|
|
1034
|
+
// found start of merge conflict markers -- now find the end
|
|
1035
|
+
for (let j = i + 1; j < lines.length && (j - i) < maxMergeConflictLines; ++j) {
|
|
1036
|
+
if (lines[j].startsWith('>>>>>>>')) {
|
|
1037
|
+
return new offsetRange_1.OffsetRange(i, j + 1 /* because endExclusive */);
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
return undefined;
|
|
1042
|
+
}
|
|
1043
|
+
function constructMessages({ systemMsg, userMsg }) {
|
|
1044
|
+
return [
|
|
1045
|
+
{
|
|
1046
|
+
role: prompt_tsx_1.Raw.ChatRole.System,
|
|
1047
|
+
content: (0, globalStringUtils_1.toTextParts)(systemMsg)
|
|
1048
|
+
},
|
|
1049
|
+
{
|
|
1050
|
+
role: prompt_tsx_1.Raw.ChatRole.User,
|
|
1051
|
+
content: (0, globalStringUtils_1.toTextParts)(userMsg)
|
|
1052
|
+
}
|
|
1053
|
+
];
|
|
1054
|
+
}
|
|
1055
|
+
function charCount(messages) {
|
|
1056
|
+
const promptCharCount = messages.reduce((total, msg) => total + msg.content.reduce((subtotal, part) => subtotal + (part.type === rawTypes_1.ChatCompletionContentPartKind.Text ? part.text.length : 0), 0), 0);
|
|
1057
|
+
return promptCharCount;
|
|
1058
|
+
}
|
|
807
1059
|
//# sourceMappingURL=xtabProvider.js.map
|