ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / extensions / copilot / src / extension / prompts / node / test / summarizeDocument.spec.ts 423 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
import * as fs from 'fs/promises' ;
import { describe, expect, test } from 'vitest' ;
import * as path from '../../../../util/vs/base/common/path' ;
import { OffsetRange } from '../../../../util/vs/editor/common/core/ranges/offsetRange' ;
import { SummarizedDocumentLineNumberStyle } from '../inline/summarizedDocument/implementation' ;
import { RemovableNode } from '../inline/summarizedDocument/summarizeDocument' ;
import { fileVariableCostFn } from '../panel/fileVariable' ;
import { fixture fromFixtureOld generateSummarizedDocument generateSummarizedDocumentAndExtractGoodSelection generateSummarizedDocuments getSummarizedSnapshotPath loadFile selectionDocPathInFixture summarizedDocPathInFixture
filename
result
filename
alwaysUseEllipsisForElisions
result text filename
file filePath languageId
result file alwaysUseEllipsisForElisions
result text file
file filePath languageId
result file alwaysUseEllipsisForElisions
result text file
file filePath languageId
result file alwaysUseEllipsisForElisions
result text file
file filePath languageId
result file
result text file
file filePath languageId
result file lineNumberStyle SummarizedDocumentLineNumberStyle OmittedRanges
result text file
file filePath languageId
result file lineNumberStyle SummarizedDocumentLineNumberStyle Full
result text file
file filePath languageId
result file
result text file
file filePath languageId
result file
result text file
file filePath languageId
result file
costFnOverride fileVariableCostFn
result text file
file filePath languageId
result file
result text file
file filePath languageId
result file alwaysUseEllipsisForElisions
result text file
filename
otherCode selectedCode
filename
otherCode filename
selectedCode filename
filename
otherCode selectedCode
filename
otherCode filename
selectedCode filename
filename
otherCode selectedCode
filename
otherCode filename
selectedCode filename
filename
otherCode selectedCode
filename
otherCode filename
selectedCode
filename
otherCode selectedCode
filename
insertSpaces
tabSize
otherCode filename
selectedCode filename
filename
otherCode selectedCode
filename
otherCode filename
selectedCode filename
filename
otherCode selectedCode
filename
otherCode filename
selectedCode filename
filename
otherCode selectedCode
filename
otherCode filename
selectedCode filename
filename
otherCode selectedCode
filename
otherCode filename
selectedCode filename
filename
otherCode selectedCode
filename
otherCode filename
selectedCode filename
filename
result
filename
result text
viewport OffsetRange
n RemovableNode currentScore
n range viewport
filename
result
filename
Number
costFnOverride
result text filename
node RemovableNode currentScore
node kind node kind currentScore
filename
result
filename
costFnOverride
result text filename
node RemovableNode currentScore
node kind currentScore
filename
result
filename
costFnOverride
result text filename
filenames
files
filePath filenames languageId
filePath filenames languageId
docs
filePromise files
selection
filePromise files
selection
docs length
i i docs length i
document docs i
document originalText files i contents
document text filenames i
filenames
files
filePath filenames languageId
filePath filenames languageId
docs
filePromise files
selection
filePromise files
selection
node currentCost document
document uri path filenames
docs length
i i docs length i
document docs i
document originalText files i contents
document text filenames i
test
reposWithLangs Record repoPath language
repoPath path __dirname language
repoPath path __dirname language
langToExts Record
repoPath language reposWithLangs
exts langToExts language
pathToDir AsyncGenerator
dirEntries fs pathToDir withFileTypes
entry dirEntries
entry
path pathToDir entry name
exts ext entry parentPath entry name entry name ext
path pathToDir entry name
path pathToDir entry name
i
filePath repoPath
i
i
file filePath languageId language
fileLines file contents
selection Math fileLines length Math fileLines Math fileLines length length
result file selection alwaysUseEllipsisForElisions
result text file
e
e
DEFAULT_CHAR_LIMIT
,
,
,
,
,
,
,
,
,
}
from
'./utils'
;
describe
(
'createSummarizedDocument[visualizable]'
,
(
)
=>
{
test
(
'[tsx] can summarize public fields'
,
async
(
)
=>
{
const
=
'simpleClass.tsx'
;
const
=
await
generateSummarizedDocument
(
fromFixtureOld
(
,
'typescriptreact'
)
,
[
9
,
0
]
,
1
,
{
:
true
}
)
;
await
expect
(
.
)
.
toMatchFileSnapshot
(
summarizedDocPathInFixture
(
)
)
;
}
)
;
test
(
'[cpp] CppNoExtraSemicolons'
,
async
(
)
=>
{
const
=
await
loadFile
(
{
:
fixture
(
'cppNoExtraSemicolons.cpp'
)
,
:
'cpp'
}
)
;
const
=
await
generateSummarizedDocument
(
,
[
50
,
0
]
,
628
,
{
:
true
}
)
;
await
expect
(
.
)
.
toMatchFileSnapshot
(
getSummarizedSnapshotPath
(
)
)
;
}
)
;
test
(
'[cpp] Do not throw invalid range error'
,
async
(
)
=>
{
const
=
await
loadFile
(
{
:
fixture
(
'problem1.cpp'
)
,
:
'cpp'
}
)
;
const
=
await
generateSummarizedDocument
(
,
[
17
,
10
]
,
10
,
{
:
true
}
)
;
await
expect
(
.
)
.
toMatchFileSnapshot
(
getSummarizedSnapshotPath
(
)
)
;
}
)
;
test
(
'[cpp] Do not throw invalid range error - 2'
,
async
(
)
=>
{
const
=
await
loadFile
(
{
:
fixture
(
'problem2.cpp'
)
,
:
'cpp'
}
)
;
const
=
await
generateSummarizedDocument
(
,
[
6
,
19
]
,
100
,
{
:
true
}
)
;
await
expect
(
.
)
.
toMatchFileSnapshot
(
getSummarizedSnapshotPath
(
)
)
;
}
)
;
test
(
'should include nearby code - strings.test.ts'
,
async
(
)
=>
{
const
=
await
loadFile
(
{
:
fixture
(
'strings.test-example.ts'
)
,
:
'typescript'
}
)
;
const
=
await
generateSummarizedDocument
(
,
[
344
,
0
]
)
;
await
expect
(
.
)
.
toMatchFileSnapshot
(
getSummarizedSnapshotPath
(
)
)
;
}
)
;
test
(
'should include nearby code - strings.test.ts - SummarizedDocumentLineNumberStyle.OmittedRanges'
,
async
(
)
=>
{
const
=
await
loadFile
(
{
:
fixture
(
'strings.test-example.ts'
)
,
:
'typescript'
}
)
;
const
=
await
generateSummarizedDocument
(
,
[
344
,
0
]
,
undefined
,
{
:
.
}
)
;
await
expect
(
.
)
.
toMatchFileSnapshot
(
getSummarizedSnapshotPath
(
,
'2'
)
)
;
}
)
;
test
(
'should include nearby code - strings.test.ts - SummarizedDocumentLineNumberStyle.Full'
,
async
(
)
=>
{
const
=
await
loadFile
(
{
:
fixture
(
'strings.test-example.ts'
)
,
:
'typescript'
}
)
;
const
=
await
generateSummarizedDocument
(
,
[
344
,
0
]
,
undefined
,
{
:
.
}
)
;
await
expect
(
.
)
.
toMatchFileSnapshot
(
getSummarizedSnapshotPath
(
,
'3'
)
)
;
}
)
;
test
(
'should include whitespace touching the selection - codeEditorWidget.ts'
,
async
(
)
=>
{
const
=
await
loadFile
(
{
:
fixture
(
'codeEditorWidget.ts'
)
,
:
'typescript'
}
)
;
const
=
await
generateSummarizedDocument
(
,
[
1085
,
2
,
1089
,
3
]
)
;
await
expect
(
.
)
.
toMatchFileSnapshot
(
getSummarizedSnapshotPath
(
,
'1'
)
)
;
}
)
;
test
(
'should not select parent node when the selection contains children but starts/ends in whitespace - codeEditorWidget.ts'
,
async
(
)
=>
{
const
=
await
loadFile
(
{
:
fixture
(
'codeEditorWidget.ts'
)
,
:
'typescript'
}
)
;
const
=
await
generateSummarizedDocument
(
,
[
211
,
0
,
213
,
0
]
)
;
await
expect
(
.
)
.
toMatchFileSnapshot
(
getSummarizedSnapshotPath
(
,
'2'
)
)
;
}
)
;
test
(
'no selection - codeEditorWidget.ts'
,
async
(
)
=>
{
const
=
await
loadFile
(
{
:
fixture
(
'codeEditorWidget.ts'
)
,
:
'typescript'
}
)
;
const
=
await
generateSummarizedDocument
(
,
undefined
,
DEFAULT_CHAR_LIMIT
,
{
:
,
}
)
;
await
expect
(
.
)
.
toMatchFileSnapshot
(
getSummarizedSnapshotPath
(
,
'3'
)
)
;
}
)
;
test
(
'should select at least one node - codeEditorWidget.ts'
,
async
(
)
=>
{
const
=
await
loadFile
(
{
:
fixture
(
'editorGroupWatermark.ts'
)
,
:
'typescript'
}
)
;
const
=
await
generateSummarizedDocument
(
,
[
24
,
0
]
)
;
await
expect
(
.
)
.
toMatchFileSnapshot
(
getSummarizedSnapshotPath
(
)
)
;
}
)
;
test
(
'issue #6614: Should include ... only once when eliding code'
,
async
(
)
=>
{
const
=
await
loadFile
(
{
:
fixture
(
'view.css'
)
,
:
'css'
}
)
;
const
=
await
generateSummarizedDocument
(
,
[
225
,
0
,
237
,
15
]
,
0
,
{
:
false
}
)
;
await
expect
(
.
)
.
toMatchFileSnapshot
(
getSummarizedSnapshotPath
(
)
)
;
}
)
;
test
(
'should expand selection end to closing brace - extHost.api.impl.ts'
,
async
(
)
=>
{
const
=
'extHost.api.impl.ts'
;
const
[
,
]
=
await
generateSummarizedDocumentAndExtractGoodSelection
(
fromFixtureOld
(
,
'typescript'
)
,
[
696
,
0
,
711
,
0
]
)
;
await
expect
(
)
.
toMatchFileSnapshot
(
summarizedDocPathInFixture
(
)
)
;
await
expect
(
)
.
toMatchFileSnapshot
(
selectionDocPathInFixture
(
)
)
;
}
)
;
test
(
'should expand selection when it sits on identifier - webview/index.ts'
,
async
(
)
=>
{
const
=
'webview-index.ts'
;
const
[
,
]
=
await
generateSummarizedDocumentAndExtractGoodSelection
(
fromFixtureOld
(
,
'typescript'
)
,
[
47
,
14
]
)
;
await
expect
(
)
.
toMatchFileSnapshot
(
summarizedDocPathInFixture
(
)
)
;
await
expect
(
)
.
toMatchFileSnapshot
(
selectionDocPathInFixture
(
)
)
;
}
)
;
test
(
'should not expand selection to the left in whitespace - pullRequestModel.ts'
,
async
(
)
=>
{
const
=
'pullRequestModel.ts'
;
const
[
,
]
=
await
generateSummarizedDocumentAndExtractGoodSelection
(
fromFixtureOld
(
,
'typescript'
)
,
[
1071
,
0
]
)
;
await
expect
(
)
.
toMatchFileSnapshot
(
summarizedDocPathInFixture
(
)
)
;
await
expect
(
)
.
toMatchFileSnapshot
(
selectionDocPathInFixture
(
)
)
;
}
)
;
test
(
'should not expand selection to select whitespace - keybindingParser.ts'
,
async
(
)
=>
{
const
=
'keybindingParser.ts'
;
const
[
,
]
=
await
generateSummarizedDocumentAndExtractGoodSelection
(
fromFixtureOld
(
,
'typescript'
)
,
[
15
,
8
]
)
;
await
expect
(
)
.
toMatchFileSnapshot
(
summarizedDocPathInFixture
(
)
)
;
expect
(
)
.
toMatchInlineSnapshot
(
` "" `
)
;
}
)
;
test
(
'should expand selection start to opening brace - BasketService.cs'
,
async
(
)
=>
{
const
=
'BasketService.cs'
;
const
[
,
]
=
await
generateSummarizedDocumentAndExtractGoodSelection
(
fromFixtureOld
(
,
'csharp'
,
{
:
true
,
:
4
,
}
)
,
[
44
,
5
]
)
;
await
expect
(
)
.
toMatchFileSnapshot
(
summarizedDocPathInFixture
(
)
)
;
await
expect
(
)
.
toMatchFileSnapshot
(
selectionDocPathInFixture
(
)
)
;
}
)
;
test
(
'should not expand end selection to select whitespace - pseudoStartStopConversationCallbackTest.ts'
,
async
(
)
=>
{
const
=
'pseudoStartStopConversationCallbackTest.ts'
;
const
[
,
]
=
await
generateSummarizedDocumentAndExtractGoodSelection
(
fromFixtureOld
(
,
'typescript'
)
,
[
125
,
0
,
132
,
0
]
)
;
await
expect
(
)
.
toMatchFileSnapshot
(
summarizedDocPathInFixture
(
)
)
;
await
expect
(
)
.
toMatchFileSnapshot
(
selectionDocPathInFixture
(
)
)
;
}
)
;
test
(
'issue #5755: should not expand selection from property to the entire interface'
,
async
(
)
=>
{
const
=
'vscode.proposed.chatParticipantAdditions.d.ts'
;
const
[
,
]
=
await
generateSummarizedDocumentAndExtractGoodSelection
(
fromFixtureOld
(
,
'typescript'
)
,
[
158
,
0
,
166
,
0
]
)
;
await
expect
(
)
.
toMatchFileSnapshot
(
summarizedDocPathInFixture
(
)
)
;
await
expect
(
)
.
toMatchFileSnapshot
(
selectionDocPathInFixture
(
)
)
;
}
)
;
test
(
'issue #5710: should move the start of the selection to next line'
,
async
(
)
=>
{
const
=
'5710.ts'
;
const
[
,
]
=
await
generateSummarizedDocumentAndExtractGoodSelection
(
fromFixtureOld
(
,
'typescript'
)
,
[
7
,
66
,
10
,
5
]
,
)
;
await
expect
(
)
.
toMatchFileSnapshot
(
summarizedDocPathInFixture
(
)
)
;
await
expect
(
)
.
toMatchFileSnapshot
(
selectionDocPathInFixture
(
)
)
;
}
)
;
test
(
'issue #7487: should not expand selection outside the React element'
,
async
(
)
=>
{
const
=
'EditForm.tsx'
;
const
[
,
]
=
await
generateSummarizedDocumentAndExtractGoodSelection
(
fromFixtureOld
(
,
'typescriptreact'
)
,
[
138
,
0
,
147
,
17
]
)
;
await
expect
(
)
.
toMatchFileSnapshot
(
summarizedDocPathInFixture
(
)
)
;
await
expect
(
)
.
toMatchFileSnapshot
(
selectionDocPathInFixture
(
)
)
;
}
)
;
test
(
'issue #6614: should not expand selection to entire HTML document'
,
async
(
)
=>
{
const
=
'workbench-dev.html'
;
const
[
,
]
=
await
generateSummarizedDocumentAndExtractGoodSelection
(
fromFixtureOld
(
,
'html'
)
,
[
75
,
4
,
75
,
4
]
)
;
await
expect
(
)
.
toMatchFileSnapshot
(
summarizedDocPathInFixture
(
)
)
;
await
expect
(
)
.
toMatchFileSnapshot
(
selectionDocPathInFixture
(
)
)
;
}
)
;
}
)
;
describe
(
'cutoff cost'
,
(
)
=>
{
test
(
'Everything is too expensive'
,
async
(
)
=>
{
const
=
'map.ts'
;
const
=
await
generateSummarizedDocument
(
fromFixtureOld
(
,
'typescript'
)
,
undefined
,
DEFAULT_CHAR_LIMIT
,
{
costFnOverride
:
(
)
=>
false
}
)
;
expect
(
.
)
.
toBe
(
''
)
;
}
)
;
test
(
'cutoff cost is respected'
,
async
(
)
=>
{
const
=
.
ofStartAndLength
(
0
,
1323
)
;
function
costFnOverride
(
:
,
:
number
)
{
if
(
.
.
intersectsOrTouches
(
)
)
{
return
1
;
}
else
{
return
false
;
}
}
const
=
'map.ts'
;
const
=
await
generateSummarizedDocument
(
fromFixtureOld
(
,
'typescript'
)
,
undefined
,
.
MAX_SAFE_INTEGER
,
{
}
)
;
await
expect
(
.
)
.
toMatchFileSnapshot
(
summarizedDocPathInFixture
(
)
+
'.view-port'
)
;
}
)
;
}
)
;
describe
(
'/tests summarization[visualizable]'
,
(
)
=>
{
test
(
'keep constructor & method signatures'
,
async
(
)
=>
{
function
costFnOverride
(
:
,
:
number
)
{
return
.
===
'constructor'
||
.
===
'method_definition'
?
0
:
;
}
const
=
'bracketPairsTree.ts'
;
const
=
await
generateSummarizedDocument
(
fromFixtureOld
(
,
'typescript'
)
,
[
88
,
4
,
102
,
5
]
,
DEFAULT_CHAR_LIMIT
,
{
}
)
;
await
expect
(
.
)
.
toMatchFileSnapshot
(
summarizedDocPathInFixture
(
)
)
;
}
)
;
test
(
'keep constructor - 2'
,
async
(
)
=>
{
function
costFnOverride
(
:
,
:
number
)
{
return
.
===
'constructor'
?
0
:
;
}
const
=
'map.ts'
;
const
=
await
generateSummarizedDocument
(
fromFixtureOld
(
,
'typescript'
)
,
[
671
,
0
,
725
,
1
]
,
DEFAULT_CHAR_LIMIT
,
{
}
)
;
await
expect
(
.
)
.
toMatchFileSnapshot
(
summarizedDocPathInFixture
(
)
)
;
}
)
;
}
)
;
describe
(
'createSummarizedDocuments'
,
(
)
=>
{
test
(
'summarize two document equally'
,
async
(
)
=>
{
const
:
string
[
]
=
[
'editorGroupWatermark.ts'
,
'strings.test-example.ts'
]
;
const
=
[
await
loadFile
(
{
:
fixture
(
[
0
]
)
,
:
'typescript'
}
)
,
await
loadFile
(
{
:
fixture
(
[
1
]
)
,
:
'typescript'
}
)
]
;
const
=
await
generateSummarizedDocuments
(
[
{
:
[
0
]
,
:
[
24
,
0
]
}
,
{
:
[
1
]
,
:
[
344
,
0
]
}
,
]
)
;
expect
(
.
)
.
toBe
(
2
)
;
for
(
let
=
0
;
<
.
;
++
)
{
const
=
[
]
;
expect
(
.
)
.
toBe
(
[
]
.
)
;
await
expect
(
.
)
.
toMatchFileSnapshot
(
summarizedDocPathInFixture
(
[
]
+
'.round1'
)
)
;
}
}
)
;
test
(
'summarize two document un-equally'
,
async
(
)
=>
{
const
:
string
[
]
=
[
'editorGroupWatermark.ts'
,
'strings.test-example.ts'
]
;
const
=
[
await
loadFile
(
{
:
fixture
(
[
0
]
)
,
:
'typescript'
}
)
,
await
loadFile
(
{
:
fixture
(
[
1
]
)
,
:
'typescript'
}
)
]
;
const
=
await
generateSummarizedDocuments
(
[
{
:
[
0
]
,
:
[
24
,
0
]
}
,
{
:
[
1
]
,
:
[
344
,
0
]
}
,
]
,
5000
,
{
costFnOverride
(
,
,
)
{
if
(
.
.
.
includes
(
[
1
]
)
)
{
return
1
;
}
return
100
;
}
,
}
)
;
expect
(
.
)
.
toBe
(
2
)
;
for
(
let
=
0
;
<
.
;
++
)
{
const
=
[
]
;
expect
(
.
)
.
toBe
(
[
]
.
)
;
await
expect
(
.
)
.
toMatchFileSnapshot
(
summarizedDocPathInFixture
(
[
]
+
'.round2'
)
)
;
}
}
)
;
.
skip
(
'run on repositories'
,
async
(
)
=>
{
const
N_FILES_LIMIT
=
1500
;
const
:
<
string
,
{
:
string
;
:
string
}
>
=
{
'vscode-copilot'
:
{
:
.
join
(
,
'../../../../../src/'
)
,
:
'typescript'
}
,
'llama.cpp'
:
{
:
.
join
(
,
'../../../../../../llama.cpp/src'
)
,
:
'cpp'
}
,
}
;
const
:
<
string
,
string
[
]
>
=
{
'cpp'
:
[
'cpp'
,
'h'
]
,
'typescript'
:
[
'ts'
,
'tsx'
]
,
}
;
const
{
,
}
=
[
'vscode-copilot'
]
;
const
=
[
]
;
async
function
*
traverseDirectory
(
:
string
)
:
<
string
>
{
const
=
await
.
readdir
(
,
{
:
true
}
)
;
for
(
const
of
)
{
if
(
.
isDirectory
(
)
)
{
yield
*
traverseDirectory
(
.
join
(
,
.
)
)
;
}
else
if
(
.
some
(
=>
!
.
.
includes
(
'fixture'
)
&&
!
.
.
includes
(
'.summarized.'
)
&&
.
.
endsWith
(
'.'
+
)
)
)
{
console
.
log
(
.
join
(
,
.
)
)
;
yield
.
join
(
,
.
)
;
}
}
}
let
=
-
1
;
for
await
(
const
of
traverseDirectory
(
)
)
{
++
;
try
{
if
(
>
N_FILES_LIMIT
)
{
break
;
}
const
=
await
loadFile
(
{
,
:
}
)
;
const
=
.
.
split
(
'\n'
)
;
const
:
[
number
,
number
]
=
[
.
floor
(
.
/
2
)
,
.
floor
(
[
.
floor
(
.
/
2
)
]
.
/
2
)
]
;
const
=
await
generateSummarizedDocument
(
,
,
400
,
{
:
true
}
)
;
await
expect
(
.
)
.
toMatchFileSnapshot
(
getSummarizedSnapshotPath
(
)
)
;
}
catch
(
)
{
console
.
log
(
` processing ${ filePath} threw error `
,
)
;
}
}
}
)
;
}
)
;