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 / tools / node / test / findFiles.spec.tsx 272 строк · изменён 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
import { afterEach, beforeEach, expect, suite, test } from 'vitest' ;
import type * as vscode from 'vscode' ;
import { IEndpointProvider } from '../../../../platform/endpoint/common/endpointProvider' ;
import { RelativePattern } from '../../../../platform/filesystem/common/fileTypes' ;
import { AbstractSearchService , ISearchService } from '../../../../platform/search/common/searchService' ;
import { ITestingServicesAccessor
accessor
collection
workspaceFolder isWindows
collection
collection workspaceFolder
accessor
expected vscode includeExtraPattern modelFamily
modelFamily
collection modelFamily
patterns vscode expected
includeExtraPattern
expected expected
patterns expected
expected expected
patterns expected expected
collection patterns
accessor collection
tool accessor
tool input query toolInvocationToken
workspaceFolder
tool accessor
tool input query toolInvocationToken
workspaceFolder
tool accessor
tool input query workspaceFolder toolInvocationToken
tool accessor
result tool input query toolInvocationToken model mockLanguageModelChat
result
tool accessor
result tool input query toolInvocationToken model mockLanguageModelChat
result
workspaceFolder
tool accessor
result tool input query toolInvocationToken model mockLanguageModelChat
result
workspaceFolder
tool accessor
result tool input query toolInvocationToken model mockLanguageModelChat
result
input context
tool accessor
resolved tool input context
resolved
query
query maxResults
query maxResults
query
query maxResults
accessor
collection
folder1 isWindows
folder2 isWindows
collection
collection folder1 folder2
accessor
searchService
collection searchService
accessor collection
searchService
searchService
tool accessor
tool input query folder1 toolInvocationToken
searchService
searchService pattern
searchService folder1
searchService
tool accessor
tool input query toolInvocationToken
searchService
searchService pattern
searchService folder1
searchService
tool accessor
resolved tool query folder1
tool input resolved toolInvocationToken
searchService
searchService pattern
searchService folder1
searchService
tool accessor
resolved tool query
tool input resolved toolInvocationToken
searchService
searchService pattern
searchService folder1
searchService
tool accessor
tool input query toolInvocationToken
searchService caseInsensitive
expectedPattern vscode vscode
override query vscode options vscode progress vscode vscode token vscode vscode
override query vscode options vscode token vscode vscode
override filePattern vscode vscode options vscode token vscode vscode
expected
actual filePattern filePattern filePattern
actual expected
i i expected i
expected i
actual i expected i
exp expected i
act actual i
act exp
act exp
lastFilePattern vscode
lastOptions vscode
override query vscode options vscode progress vscode vscode token vscode vscode
override query vscode options vscode token vscode vscode
override filePattern vscode vscode options vscode token vscode vscode
filePattern filePattern filePattern
options
,
TestingServiceCollection
}
from
'../../../../platform/test/node/services'
;
import
{ TestWorkspaceService }
from
'../../../../platform/test/node/testWorkspaceService'
;
import
{ IWorkspaceService }
from
'../../../../platform/workspace/common/workspaceService'
;
import
{ CancellationToken }
from
'../../../../util/vs/base/common/cancellation'
;
import
{ isWindows }
from
'../../../../util/vs/base/common/platform'
;
import
{
URI
}
from
'../../../../util/vs/base/common/uri'
;
import
{ SyncDescriptor }
from
'../../../../util/vs/platform/instantiation/common/descriptors'
;
import
{ IInstantiationService }
from
'../../../../util/vs/platform/instantiation/common/instantiation'
;
import
{ createExtensionUnitTestingServices }
from
'../../../test/node/services'
;
import
{ CopilotToolMode }
from
'../../common/toolsRegistry'
;
import
{ FindFilesTool , IFindFilesToolParams }
from
'../findFilesTool'
;
import
{ createMockEndpointProvider, mockLanguageModelChat }
from
'./searchToolTestUtils'
;
suite
(
'FindFiles'
,
(
)
=>
{
let
:
ITestingServicesAccessor
;
let
:
TestingServiceCollection
;
const
=
?
'c:\\test\\workspace'
:
'/test/workspace'
;
beforeEach
(
(
)
=>
{
=
createExtensionUnitTestingServices
(
)
;
.
define
(
IWorkspaceService
,
new
SyncDescriptor
(
TestWorkspaceService
,
[
[
URI
.
file
(
)
]
]
)
)
;
}
)
;
afterEach
(
(
)
=>
{
.
dispose
(
)
;
}
)
;
function
setup
(
:
.
GlobPattern
,
=
true
,
?
:
string
)
{
if
(
)
{
.
define
(
IEndpointProvider
,
createMockEndpointProvider
(
)
)
;
}
const
:
.
GlobPattern
[
]
=
[
]
;
if
(
)
{
if
(
typeof
===
'string'
&&
!
.
endsWith
(
'/**'
)
)
{
.
push
(
+
'/**'
)
;
}
else
if
(
typeof
!==
'string'
&&
!
.
pattern
.
endsWith
(
'/**'
)
)
{
.
push
(
new
RelativePattern
(
.
baseUri
,
.
pattern
+
'/**'
)
)
;
}
}
.
define
(
ISearchService
,
new
TestSearchService
(
)
)
;
=
.
createTestingAccessor
(
)
;
}
test
(
'passes through simple query'
,
async
(
)
=>
{
setup
(
'test/**/*.ts'
,
false
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
FindFilesTool
)
;
await
.
invoke
(
{
:
{
:
'test/**/*.ts'
}
,
:
null
!
,
}
,
CancellationToken
.
None
)
;
}
)
;
test
(
'handles absolute path with glob'
,
async
(
)
=>
{
setup
(
new
RelativePattern
(
URI
.
file
(
)
,
'test/**/*.ts'
)
,
false
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
FindFilesTool
)
;
await
.
invoke
(
{
:
{
:
` ${ workspaceFolder} /test/**/*.ts `
}
,
:
null
!
,
}
,
CancellationToken
.
None
)
;
}
)
;
test
(
'handles absolute path to folder'
,
async
(
)
=>
{
setup
(
new
RelativePattern
(
URI
.
file
(
)
,
''
)
,
false
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
FindFilesTool
)
;
await
.
invoke
(
{
:
{
:
}
,
:
null
!
,
}
,
CancellationToken
.
None
)
;
}
)
;
suite
(
'gpt-4.1 model glob pattern'
,
(
)
=>
{
test
(
'adds extra pattern for gpt-4.1 model with simple query'
,
async
(
)
=>
{
setup
(
'src'
,
true
,
'gpt-4.1'
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
FindFilesTool
)
;
const
=
await
.
invoke
(
{
:
{
:
'src'
}
,
:
null
!
,
:
}
,
CancellationToken
.
None
)
;
expect
(
)
.
toBeDefined
(
)
;
}
)
;
test
(
'adds extra pattern for gpt-4.1 with string query ending in /**'
,
async
(
)
=>
{
setup
(
'src/**'
,
true
,
'gpt-4.1'
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
FindFilesTool
)
;
const
=
await
.
invoke
(
{
:
{
:
'src/**'
}
,
:
null
!
,
:
}
,
CancellationToken
.
None
)
;
expect
(
)
.
toBeDefined
(
)
;
}
)
;
test
(
'adds extra pattern for gpt-4.1 with RelativePattern'
,
async
(
)
=>
{
setup
(
new
RelativePattern
(
URI
.
file
(
)
,
'src'
)
,
true
,
'gpt-4.1'
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
FindFilesTool
)
;
const
=
await
.
invoke
(
{
:
{
:
` ${ workspaceFolder} /src `
}
,
:
null
!
,
:
}
,
CancellationToken
.
None
)
;
expect
(
)
.
toBeDefined
(
)
;
}
)
;
test
(
'does not duplicate extra pattern when RelativePattern already ends with /**'
,
async
(
)
=>
{
setup
(
new
RelativePattern
(
URI
.
file
(
)
,
'src/**'
)
,
true
,
'gpt-4.1'
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
FindFilesTool
)
;
const
=
await
.
invoke
(
{
:
{
:
` ${ workspaceFolder} /src/** `
}
,
:
null
!
,
:
}
,
CancellationToken
.
None
)
;
expect
(
)
.
toBeDefined
(
)
;
}
)
;
}
)
;
suite
(
'resolveInput'
,
(
)
=>
{
beforeEach
(
(
)
=>
{
setup
(
'hello'
)
;
}
)
;
async
function
testIt
(
:
IFindFilesToolParams
,
:
CopilotToolMode
)
{
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
FindFilesTool
)
;
const
=
await
.
resolveInput
(
,
null
!
,
)
;
expect
(
)
.
toMatchSnapshot
(
)
;
}
test
(
'resolveInput with FullContext and no maxResults'
,
async
(
)
=>
{
await
testIt
(
{
:
'hello'
}
,
CopilotToolMode
.
FullContext
)
;
}
)
;
test
(
'resolveInput with FullContext and maxResults < 200'
,
async
(
)
=>
{
await
testIt
(
{
:
'hello'
,
:
50
}
,
CopilotToolMode
.
FullContext
)
;
}
)
;
test
(
'resolveInput with FullContext and maxResults > 200'
,
async
(
)
=>
{
await
testIt
(
{
:
'hello'
,
:
300
}
,
CopilotToolMode
.
FullContext
)
;
}
)
;
test
(
'resolveInput with PartialContext and no maxResults'
,
async
(
)
=>
{
await
testIt
(
{
:
'hello'
}
,
CopilotToolMode
.
PartialContext
)
;
}
)
;
test
(
'resolveInput with PartialContext and maxResults defined'
,
async
(
)
=>
{
await
testIt
(
{
:
'hello'
,
:
123
}
,
CopilotToolMode
.
PartialContext
)
;
}
)
;
}
)
;
}
)
;
suite
(
'FindFiles - absolute workspace folder path'
,
(
)
=>
{
let
:
ITestingServicesAccessor
;
let
:
TestingServiceCollection
;
const
=
?
'c:\\test\\workspace1'
:
'/test/workspace1'
;
const
=
?
'c:\\test\\workspace2'
:
'/test/workspace2'
;
beforeEach
(
(
)
=>
{
=
createExtensionUnitTestingServices
(
)
;
.
define
(
IWorkspaceService
,
new
SyncDescriptor
(
TestWorkspaceService
,
[
[
URI
.
file
(
)
,
URI
.
file
(
)
]
]
)
)
;
}
)
;
afterEach
(
(
)
=>
{
.
dispose
(
)
;
}
)
;
function
setup
(
)
{
const
=
new
RecordingFindFilesSearchService
(
)
;
.
define
(
ISearchService
,
)
;
=
.
createTestingAccessor
(
)
;
return
;
}
test
(
'scopes search to workspace folder when absolute path is used as query'
,
async
(
)
=>
{
const
=
setup
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
FindFilesTool
)
;
await
.
invoke
(
{
:
{
:
}
,
:
null
!
}
,
CancellationToken
.
None
)
;
expect
(
.
lastFilePattern
)
.
toHaveLength
(
1
)
;
expect
(
.
lastFilePattern
!
[
0
]
)
.
toMatchObject
(
{
:
''
}
)
;
expect
(
(
.
lastFilePattern
!
[
0
]
as
RelativePattern
)
.
baseUri
.
path
)
.
toBe
(
URI
.
file
(
)
.
path
)
;
}
)
;
test
(
'scopes search with glob suffix when absolute path includes pattern'
,
async
(
)
=>
{
const
=
setup
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
FindFilesTool
)
;
await
.
invoke
(
{
:
{
:
` ${ folder1} /**/*.ts `
}
,
:
null
!
}
,
CancellationToken
.
None
)
;
expect
(
.
lastFilePattern
)
.
toHaveLength
(
1
)
;
expect
(
.
lastFilePattern
!
[
0
]
)
.
toMatchObject
(
{
:
'**/*.ts'
}
)
;
expect
(
(
.
lastFilePattern
!
[
0
]
as
RelativePattern
)
.
baseUri
.
path
)
.
toBe
(
URI
.
file
(
)
.
path
)
;
}
)
;
test
(
'absolute path survives resolveInput without corruption'
,
async
(
)
=>
{
const
=
setup
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
FindFilesTool
)
;
const
=
await
.
resolveInput
(
{
:
}
,
null
!
,
CopilotToolMode
.
PartialContext
)
;
await
.
invoke
(
{
:
,
:
null
!
}
,
CancellationToken
.
None
)
;
expect
(
.
lastFilePattern
)
.
toHaveLength
(
1
)
;
expect
(
.
lastFilePattern
!
[
0
]
)
.
toMatchObject
(
{
:
''
}
)
;
expect
(
(
.
lastFilePattern
!
[
0
]
as
RelativePattern
)
.
baseUri
.
path
)
.
toBe
(
URI
.
file
(
)
.
path
)
;
}
)
;
test
(
'absolute path with glob survives resolveInput without corruption'
,
async
(
)
=>
{
const
=
setup
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
FindFilesTool
)
;
const
=
await
.
resolveInput
(
{
:
` ${ folder1} /**/*.ts `
}
,
null
!
,
CopilotToolMode
.
PartialContext
)
;
await
.
invoke
(
{
:
,
:
null
!
}
,
CancellationToken
.
None
)
;
expect
(
.
lastFilePattern
)
.
toHaveLength
(
1
)
;
expect
(
.
lastFilePattern
!
[
0
]
)
.
toMatchObject
(
{
:
'**/*.ts'
}
)
;
expect
(
(
.
lastFilePattern
!
[
0
]
as
RelativePattern
)
.
baseUri
.
path
)
.
toBe
(
URI
.
file
(
)
.
path
)
;
}
)
;
test
(
'passes caseInsensitive option to findFiles'
,
async
(
)
=>
{
const
=
setup
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
FindFilesTool
)
;
await
.
invoke
(
{
:
{
:
'src/**/*.ts'
}
,
:
null
!
}
,
CancellationToken
.
None
)
;
expect
(
.
lastOptions
?.
)
.
toBe
(
true
)
;
}
)
;
}
)
;
class
TestSearchService
extends
AbstractSearchService
{
constructor
(
private
readonly
:
.
GlobPattern
|
.
GlobPattern
[
]
)
{
super
(
)
;
}
async
findTextInFiles
(
:
.
TextSearchQuery
,
:
.
FindTextInFilesOptions
,
:
.
Progress
<
.
TextSearchResult
>
,
:
.
CancellationToken
)
:
Promise
<
.
TextSearchComplete
>
{
throw
new
Error
(
'Method not implemented.'
)
;
}
findTextInFiles2
(
:
.
TextSearchQuery2
,
?
:
.
FindTextInFilesOptions2
,
?
:
.
CancellationToken
)
:
.
FindTextInFilesResponse
{
throw
new
Error
(
'Method not implemented.'
)
;
}
async
findFiles
(
:
.
GlobPattern
|
.
GlobPattern
[
]
,
?
:
.
FindFiles2Options
|
undefined
,
?
:
.
CancellationToken
|
undefined
)
:
Promise
<
.
Uri
[
]
>
{
const
=
Array
.
isArray
(
this
.
expectedPattern
)
?
this
.
expectedPattern
:
[
this
.
expectedPattern
]
;
const
=
Array
.
isArray
(
)
?
:
[
]
;
expect
(
.
length
)
.
toBe
(
.
length
)
;
for
(
let
=
0
;
<
.
length
;
++
)
{
if
(
typeof
[
]
===
'string'
)
{
expect
(
[
]
)
.
toBe
(
[
]
)
;
}
else
{
const
=
[
]
as
RelativePattern
;
const
=
[
]
as
RelativePattern
;
expect
(
.
pattern
)
.
toBe
(
.
pattern
)
;
expect
(
.
baseUri
.
path
)
.
toBe
(
.
baseUri
.
path
)
;
}
}
return
[
]
;
}
}
class
RecordingFindFilesSearchService
extends
AbstractSearchService
{
public
:
.
GlobPattern
[
]
|
undefined
;
public
:
.
FindFiles2Options
|
undefined
;
async
findTextInFiles
(
:
.
TextSearchQuery
,
:
.
FindTextInFilesOptions
,
:
.
Progress
<
.
TextSearchResult
>
,
:
.
CancellationToken
)
:
Promise
<
.
TextSearchComplete
>
{
throw
new
Error
(
'Method not implemented.'
)
;
}
findTextInFiles2
(
:
.
TextSearchQuery2
,
?
:
.
FindTextInFilesOptions2
,
?
:
.
CancellationToken
)
:
.
FindTextInFilesResponse
{
throw
new
Error
(
'Method not implemented.'
)
;
}
async
findFiles
(
:
.
GlobPattern
|
.
GlobPattern
[
]
,
?
:
.
FindFiles2Options
|
undefined
,
?
:
.
CancellationToken
|
undefined
)
:
Promise
<
.
Uri
[
]
>
{
this
.
lastFilePattern
=
Array
.
isArray
(
)
?
:
[
]
;
this
.
lastOptions
=
;
return
[
]
;
}
}