@vscode/chat-lib 0.0.5-5 → 0.0.5-7

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.
Files changed (29) hide show
  1. package/dist/src/_internal/extension/prompt/node/chatMLFetcher.js +4 -4
  2. package/dist/src/_internal/extension/prompt/node/chatMLFetcher.js.map +1 -1
  3. package/dist/src/_internal/extension/xtab/node/xtabProvider.d.ts.map +1 -1
  4. package/dist/src/_internal/extension/xtab/node/xtabProvider.js +14 -3
  5. package/dist/src/_internal/extension/xtab/node/xtabProvider.js.map +1 -1
  6. package/dist/src/_internal/platform/configuration/common/configurationService.d.ts +1 -3
  7. package/dist/src/_internal/platform/configuration/common/configurationService.d.ts.map +1 -1
  8. package/dist/src/_internal/platform/configuration/common/configurationService.js +1 -3
  9. package/dist/src/_internal/platform/configuration/common/configurationService.js.map +1 -1
  10. package/dist/src/_internal/platform/endpoint/common/endpointProvider.d.ts +1 -1
  11. package/dist/src/_internal/platform/endpoint/common/endpointProvider.d.ts.map +1 -1
  12. package/dist/src/_internal/platform/endpoint/node/responsesApi.d.ts.map +1 -1
  13. package/dist/src/_internal/platform/endpoint/node/responsesApi.js +16 -27
  14. package/dist/src/_internal/platform/endpoint/node/responsesApi.js.map +1 -1
  15. package/dist/src/_internal/platform/inlineCompletions/common/api.d.ts +5 -0
  16. package/dist/src/_internal/platform/inlineCompletions/common/api.d.ts.map +1 -1
  17. package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProviders.d.ts +5 -1
  18. package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProviders.d.ts.map +1 -1
  19. package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProviders.js +45 -0
  20. package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProviders.js.map +1 -1
  21. package/dist/src/_internal/platform/languageServer/common/languageContextService.d.ts +12 -0
  22. package/dist/src/_internal/platform/languageServer/common/languageContextService.d.ts.map +1 -1
  23. package/dist/src/_internal/platform/languageServer/common/languageContextService.js.map +1 -1
  24. package/dist/src/package.json +6 -18
  25. package/package.json +1 -1
  26. package/dist/src/_internal/extension/inlineEdits/common/ghNearbyNesProvider.d.ts +0 -16
  27. package/dist/src/_internal/extension/inlineEdits/common/ghNearbyNesProvider.d.ts.map +0 -1
  28. package/dist/src/_internal/extension/inlineEdits/common/ghNearbyNesProvider.js +0 -147
  29. package/dist/src/_internal/extension/inlineEdits/common/ghNearbyNesProvider.js.map +0 -1
@@ -1,147 +0,0 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Microsoft Corporation. All rights reserved.
4
- * Licensed under the MIT License. See License.txt in the project root for license information.
5
- *--------------------------------------------------------------------------------------------*/
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.InformationDelta = void 0;
8
- exports.editWouldDeleteWhatWasJustInserted = editWouldDeleteWhatWasJustInserted;
9
- exports.getInformationDelta = getInformationDelta;
10
- const N_GRAM_UNDO_RATIO_TO_FILTER_OUT = 0.7;
11
- function editWouldDeleteWhatWasJustInserted(activeDocument, lineEdit) {
12
- let edit = lineEdit.toEdit(activeDocument.documentAfterEdits);
13
- // ! important: reduce it to the minimal set of changes
14
- edit = edit.normalizeOnSource(activeDocument.documentAfterEdits.value);
15
- if (!editIsDeletion(edit)) {
16
- return false;
17
- }
18
- // We are deleting something. Is it what was just inserted?
19
- for (let i = activeDocument.recentEdits.edits.length - 1; i >= 0; i--) {
20
- const recentEdit = activeDocument.recentEdits.edits[i];
21
- const rebaseResult = edit.tryRebase(recentEdit);
22
- if (!rebaseResult) {
23
- // the edit we want to do cannot be rebased, which indicates that it would interfere with a recent edit
24
- return true;
25
- }
26
- edit = rebaseResult;
27
- }
28
- return false;
29
- }
30
- function editIsDeletion(edit) {
31
- const deletedChars = edit.replacements.reduce((acc, singleEdit) => acc + singleEdit.replaceRange.length, 0);
32
- const insertedChars = edit.replacements.reduce((acc, singleEdit) => acc + singleEdit.newText.length, 0);
33
- return insertedChars === 0 && deletedChars > 0;
34
- }
35
- /**
36
- * Represents information loss/gain (4-grams) via an edit.
37
- */
38
- class InformationDelta {
39
- constructor(inserted = new Set(), deleted = new Set()) {
40
- this.inserted = inserted;
41
- this.deleted = deleted;
42
- }
43
- combine(other) {
44
- return new InformationDelta(setUnion(this.inserted, other.inserted), setUnion(this.deleted, other.deleted));
45
- }
46
- isUndoneBy(other) {
47
- const otherReallyNewInsertions = setMinus(other.inserted, other.deleted);
48
- const otherReallyDeleted = setMinus(other.deleted, other.inserted);
49
- const otherReallyDeletesMyInserts = setIntersectionCount(otherReallyDeleted, this.inserted);
50
- const otherReallyInsertsMyDeletes = setIntersectionCount(otherReallyNewInsertions, this.deleted);
51
- if (otherReallyDeleted.size > 6 && otherReallyDeletesMyInserts / otherReallyDeleted.size > N_GRAM_UNDO_RATIO_TO_FILTER_OUT) {
52
- return true;
53
- }
54
- if (otherReallyNewInsertions.size > 6 && otherReallyInsertsMyDeletes / otherReallyNewInsertions.size > N_GRAM_UNDO_RATIO_TO_FILTER_OUT) {
55
- return true;
56
- }
57
- return false;
58
- }
59
- }
60
- exports.InformationDelta = InformationDelta;
61
- function getInformationDelta(source, edit) {
62
- const inserted = new Set();
63
- const deleted = new Set();
64
- const tryAddDeleted = (deletedRange) => {
65
- if (!deletedRange) {
66
- return;
67
- }
68
- const deletedText = source.substring(deletedRange.start, deletedRange.endExclusive);
69
- for (let line of deletedText.split(/\r\n|\r|\n/)) {
70
- line = line.trim();
71
- for (const piece of to4grams(line)) {
72
- deleted.add(piece);
73
- }
74
- }
75
- };
76
- const tryAddInserted = (insertedText) => {
77
- for (let line of insertedText.split(/\r\n|\r|\n/)) {
78
- line = line.trim();
79
- for (const piece of to4grams(line)) {
80
- inserted.add(piece);
81
- }
82
- }
83
- };
84
- for (const e of edit.replacements) {
85
- const e1 = e.removeCommonPrefix(source).removeCommonSuffix(source);
86
- const e2 = e.removeCommonSuffix(source).removeCommonPrefix(source);
87
- if (e1.isEmpty) {
88
- continue;
89
- }
90
- tryAddDeleted(e1.replaceRange);
91
- tryAddDeleted(e2.replaceRange);
92
- tryAddDeleted(e1.replaceRange.intersect(e2.replaceRange));
93
- // tryAddInserted(e1.newText);
94
- // tryAddInserted(e2.newText);
95
- // e1 might have a suffix overlap with the prefix of e1
96
- tryAddInserted(trimOverlap(e1.newText, e2.newText));
97
- }
98
- return new InformationDelta(inserted, deleted);
99
- }
100
- function trimOverlap(stringToEliminateEnd, stringToEliminateStart) {
101
- const length = Math.min(stringToEliminateEnd.length, stringToEliminateStart.length);
102
- for (let trimLength = 0; trimLength < length; trimLength++) {
103
- const str1 = stringToEliminateEnd.slice(0, stringToEliminateEnd.length - trimLength);
104
- const str2 = stringToEliminateStart.slice(trimLength);
105
- if (str1 === str2) {
106
- return str1;
107
- }
108
- }
109
- return '';
110
- }
111
- function to4grams(text) {
112
- const result = [];
113
- for (let i = 4; i < text.length; i++) {
114
- const ngram = text.slice(i - 4, i);
115
- result.push(ngram);
116
- }
117
- return result;
118
- }
119
- function setUnion(a, b) {
120
- const result = new Set();
121
- for (const el of a) {
122
- result.add(el);
123
- }
124
- for (const el of b) {
125
- result.add(el);
126
- }
127
- return result;
128
- }
129
- function setMinus(a, b) {
130
- const result = new Set();
131
- for (const el of a) {
132
- if (!b.has(el)) {
133
- result.add(el);
134
- }
135
- }
136
- return result;
137
- }
138
- function setIntersectionCount(a, b) {
139
- let result = 0;
140
- for (const el of a) {
141
- if (b.has(el)) {
142
- result++;
143
- }
144
- }
145
- return result;
146
- }
147
- //# sourceMappingURL=ghNearbyNesProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ghNearbyNesProvider.js","sourceRoot":"","sources":["../../../../../../src/_internal/extension/inlineEdits/common/ghNearbyNesProvider.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAShG,gFAkBC;AAyCD,kDAuCC;AApGD,MAAM,+BAA+B,GAAG,GAAG,CAAC;AAE5C,SAAgB,kCAAkC,CAAC,cAAyC,EAAE,Q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