ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / src / vs / platform / agentHost / test / node / agentPluginManager.test.ts 336 строк · изменён 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
import assert from 'assert' ;
import { DeferredPromise } from '../../../../base/common/async.js' ;
import { VSBuffer } from '../../../../base/common/buffer.js' ;
import { DisposableStore } from '../../../../base/common/lifecycle.js' ;
import { Schemas } from '../../../../base/common/network.js' ;
import { URI } from '../../../../base/common/uri.js' ;
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../base/test/common/utils.js' ;
import { FileService } from '../../../files/common/fileService.js'
IFileDeleteOptions
InMemoryFileSystemProvider
NullLogService
toAgentClientUri
customizationId
CustomizationType
AgentPluginManager
lockedPaths
cacheReadStarted
operationLog
cacheReadBarrier DeferredPromise
override resource opts IFileDeleteOptions
locked lockedPaths
resource path locked
resource opts
override resource Uint8Array
content resource
cacheReadBarrier resource path
cacheReadStarted
cacheReadBarrier p
operationLog
content
override resource
cacheReadBarrier resource path resource path
operationLog
resource
disposables
fileService FileService
provider LockableInMemoryFileSystemProvider
manager AgentPluginManager
basePath scheme Schemas inMemory path
fileService disposables
provider disposables
disposables fileService Schemas inMemory provider
disposables fileService disposables
manager basePath fileService
disposables
name
scheme Schemas inMemory path
name nonce ClientPluginCustomization
uri name
type CustomizationType Plugin
id uri
uri
name
nonce nonce
name files Record
originalUri scheme Schemas inMemory path
agentClientDir originalUri
fileService agentClientDir
fileName content Object files
fileService agentClientDir fileName VSBuffer content
Set
cachePath basePath
content fileService cachePath
entries uri nonce content value
entries entry entry nonce
results manager
assert results customization load kind
assert results pluginDir
assert results customization load kind
assert results pluginDir
results manager
assert results length
assert results customization load kind
assert results customization load kind results customization load message
assert results pluginDir
results manager
assert results customization load kind
assert results pluginDir
progressCalls PluginCustomization
manager status
progressCalls status
assert progressCalls call call load kind
ref
result1 manager ref
assert result1 pluginDir
result2 manager ref
assert result2 pluginDir
assert result1 pluginDir result2 pluginDir
r1 manager
dir1 r1 pluginDir
r2 manager
dir2 r2 pluginDir
assert dir1 dir2
assert fileService dir2
assert fileService dir1
assert
r1 manager
dir1 r1 pluginDir
provider lockedPaths dir1 path
r2 manager
dir2 r2 pluginDir
assert fileService dir1
assert fileService dir2
assert
r1 manager
dir1 r1 pluginDir
provider lockedPaths dir1 path
manager
provider lockedPaths
manager2 basePath fileService
manager2
assert fileService dir1
assert
r1 manager
dir1 r1 pluginDir
provider lockedPaths dir1 path
manager
provider lockedPaths
fileService dir1 recursive
manager2 basePath fileService
manager2
assert
ref
r1 r2
manager ref
manager ref
assert r1 customization load kind
assert r2 customization load kind
manager
manager2 basePath fileService
cacheReadBarrier provider cacheReadBarrier
firstSync manager2
provider cacheReadStarted p
secondSync manager2
cacheReadBarrier
firstSync secondSync
assert provider operationLog
smallManager basePath fileService
i i i
smallManager
evictedDir basePath
listing fileService evictedDir
assert listing children
pluginDirs listing children c c isDirectory
assert pluginDirs length
smallManager basePath fileService
r1 smallManager
dir1 r1 pluginDir
r2 smallManager
dir2 r2 pluginDir
provider lockedPaths dir1 path
smallManager
assert fileService dir1
assert fileService dir2
ref
manager ref
manager2 basePath fileService
result manager2 ref
assert result customization PluginCustomization load kind
assert result pluginDir
;
import
{
}
from
'../../../files/common/files.js'
;
import
{
}
from
'../../../files/common/inMemoryFilesystemProvider.js'
;
import
{
}
from
'../../../log/common/log.js'
;
import
{
AGENT_CLIENT_SCHEME
,
}
from
'../../common/agentClientUri.js'
;
import
{
,
type
ClientPluginCustomization
,
type
PluginCustomization
}
from
'../../common/state/sessionState.js'
;
import
{
}
from
'../../common/state/protocol/state.js'
;
import
{
}
from
'../../node/agentPluginManager.js'
;
class
LockableInMemoryFileSystemProvider
extends
InMemoryFileSystemProvider
{
readonly
=
new
Set< string >
(
)
;
readonly
=
new
DeferredPromise< void >
(
)
;
readonly
:
string
[
]
=
[
]
;
:
<
void
>
|
undefined
;
async
delete
(
:
URI
,
:
)
:
Promise
<
void
>
{
for
(
const
of
this
.
)
{
if
(
.
.
includes
(
)
)
{
throw
new
Error
(
'EBUSY: resource busy or locked'
)
;
}
}
return
super
.
delete
(
,
)
;
}
async
readFile
(
:
URI
)
:
Promise
<
>
{
const
=
await
super
.
readFile
(
)
;
if
(
this
.
&&
.
.
endsWith
(
'/agentPlugins/cache.json'
)
)
{
this
.
.
complete
(
)
;
await
this
.
.
;
this
.
.
push
(
'cache-read-complete'
)
;
}
return
;
}
async
mkdir
(
:
URI
)
:
Promise
<
void
>
{
if
(
this
.
&&
.
.
includes
(
'/agentPlugins/'
)
&&
!
.
.
endsWith
(
'/cache.json'
)
)
{
this
.
.
push
(
'plugin-materialize'
)
;
}
return
super
.
mkdir
(
)
;
}
}
suite
(
'AgentPluginManager'
,
(
)
=>
{
const
=
new
DisposableStore
(
)
;
let
:
;
let
:
;
let
:
;
const
=
URI
.
from
(
{
:
.
,
:
'/userData'
}
)
;
setup
(
(
)
=>
{
=
.
add
(
new
FileService
(
new
NullLogService
(
)
)
)
;
=
.
add
(
new
LockableInMemoryFileSystemProvider
(
)
)
;
.
add
(
.
registerProvider
(
.
,
)
)
;
.
add
(
.
registerProvider
(
AGENT_CLIENT_SCHEME
,
.
add
(
new
InMemoryFileSystemProvider
(
)
)
)
)
;
=
new
AgentPluginManager
(
,
,
new
NullLogService
(
)
)
;
}
)
;
teardown
(
(
)
=>
.
clear
(
)
)
;
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
function
pluginUri
(
:
string
)
:
string
{
return
URI
.
from
(
{
:
.
,
:
` /plugins/ ${ name} `
}
)
.
toString
(
)
;
}
function
makeRef
(
:
string
,
?
:
string
)
:
{
const
=
pluginUri
(
)
;
return
{
:
.
,
:
customizationId
(
)
,
,
:
` Plugin ${ name} `
,
...
(
!==
undefined
?
{
}
:
{
}
)
,
}
;
}
async
function
seedPluginDir
(
:
string
,
:
<
string
,
string
>
)
:
Promise
<
void
>
{
const
=
URI
.
from
(
{
:
.
,
:
` /plugins/ ${ name} `
}
)
;
const
=
toAgentClientUri
(
,
'test-client'
)
;
await
.
createFolder
(
)
;
for
(
const
[
,
]
of
.
entries
(
)
)
{
await
.
writeFile
(
URI
.
joinPath
(
,
)
,
.
fromString
(
)
)
;
}
}
async
function
readCacheNonces
(
)
:
Promise
<
<
string
>>
{
const
=
URI
.
joinPath
(
,
'agentPlugins'
,
'cache.json'
)
;
const
=
await
.
readFile
(
)
;
const
:
{
:
string
;
:
string
}
[
]
=
JSON
.
parse
(
.
.
toString
(
)
)
;
return
new
Set
(
.
map
(
=>
.
)
)
;
}
suite
(
'syncCustomizations'
,
(
)
=>
{
test
(
'returns loaded status and pluginDir for each synced plugin'
,
async
(
)
=>
{
await
seedPluginDir
(
'alpha'
,
{
'index.js'
:
'a'
}
)
;
await
seedPluginDir
(
'beta'
,
{
'index.js'
:
'b'
}
)
;
const
=
await
.
syncCustomizations
(
'test-client'
,
[
makeRef
(
'alpha'
,
'n1'
)
,
makeRef
(
'beta'
,
'n2'
)
,
]
)
;
.
strictEqual
(
[
0
]
.
.
?.
,
'loaded'
)
;
.
ok
(
[
0
]
.
,
'should have pluginDir'
)
;
.
strictEqual
(
[
1
]
.
.
?.
,
'loaded'
)
;
.
ok
(
[
1
]
.
,
'should have pluginDir'
)
;
}
)
;
test
(
'returns error status without pluginDir when source missing'
,
async
(
)
=>
{
const
=
await
.
syncCustomizations
(
'test-client'
,
[
makeRef
(
'nonexistent'
)
]
)
;
.
strictEqual
(
.
,
1
)
;
.
strictEqual
(
[
0
]
.
.
?.
,
'error'
)
;
.
ok
(
[
0
]
.
.
?.
===
'error'
&&
[
0
]
.
.
.
)
;
.
strictEqual
(
[
0
]
.
,
undefined
)
;
}
)
;
test
(
'mixes loaded and error results'
,
async
(
)
=>
{
await
seedPluginDir
(
'good'
,
{
'index.js'
:
'ok'
}
)
;
const
=
await
.
syncCustomizations
(
'test-client'
,
[
makeRef
(
'good'
,
'n1'
)
,
makeRef
(
'missing'
)
,
]
)
;
.
strictEqual
(
[
1
]
.
.
?.
,
'error'
)
;
.
strictEqual
(
[
1
]
.
,
undefined
)
;
}
)
;
test
(
'fires progress callback with changed customization status'
,
async
(
)
=>
{
await
seedPluginDir
(
'prog'
,
{
'index.js'
:
'content'
}
)
;
const
:
[
]
=
[
]
;
await
.
syncCustomizations
(
'test-client'
,
[
makeRef
(
'prog'
,
'n1'
)
]
,
=>
{
.
push
(
)
;
}
)
;
.
deepStrictEqual
(
.
map
(
=>
.
?.
)
,
[
'loaded'
]
)
;
}
)
;
test
(
'skips copy when nonce matches'
,
async
(
)
=>
{
await
seedPluginDir
(
'cached'
,
{
'index.js'
:
'v1'
}
)
;
const
=
makeRef
(
'cached'
,
'nonce-abc'
)
;
const
=
await
.
syncCustomizations
(
'test-client'
,
[
]
)
;
.
ok
(
[
0
]
.
)
;
const
=
await
.
syncCustomizations
(
'test-client'
,
[
]
)
;
.
ok
(
[
0
]
.
)
;
.
strictEqual
(
[
0
]
.
!
.
toString
(
)
,
[
0
]
.
!
.
toString
(
)
)
;
}
)
;
test
(
'new nonce materializes a fresh subdirectory and evicts the stale one'
,
async
(
)
=>
{
await
seedPluginDir
(
'rev'
,
{
'index.js'
:
'v1'
}
)
;
const
=
await
.
syncCustomizations
(
'test-client'
,
[
makeRef
(
'rev'
,
'nonce-1'
)
]
)
;
const
=
[
0
]
.
!
;
await
seedPluginDir
(
'rev'
,
{
'index.js'
:
'v2'
}
)
;
const
=
await
.
syncCustomizations
(
'test-client'
,
[
makeRef
(
'rev'
,
'nonce-2'
)
]
)
;
const
=
[
0
]
.
!
;
.
notStrictEqual
(
.
toString
(
)
,
.
toString
(
)
,
'new nonce should use a new subdirectory'
)
;
.
strictEqual
(
await
.
exists
(
)
,
true
,
'new nonce subdirectory should exist'
)
;
.
strictEqual
(
await
.
exists
(
)
,
false
,
'stale nonce subdirectory should be evicted'
)
;
.
deepStrictEqual
(
await
readCacheNonces
(
)
,
new
Set
(
[
'nonce-2'
]
)
)
;
}
)
;
test
(
'retains a locked older nonce so both revisions coexist'
,
async
(
)
=>
{
await
seedPluginDir
(
'rev'
,
{
'index.js'
:
'v1'
}
)
;
const
=
await
.
syncCustomizations
(
'test-client'
,
[
makeRef
(
'rev'
,
'nonce-1'
)
]
)
;
const
=
[
0
]
.
!
;
.
.
add
(
.
)
;
await
seedPluginDir
(
'rev'
,
{
'index.js'
:
'v2'
}
)
;
const
=
await
.
syncCustomizations
(
'test-client'
,
[
makeRef
(
'rev'
,
'nonce-2'
)
]
)
;
const
=
[
0
]
.
!
;
.
strictEqual
(
await
.
exists
(
)
,
true
,
'locked older nonce should be retained on disk'
)
;
.
strictEqual
(
await
.
exists
(
)
,
true
,
'new nonce subdirectory should exist'
)
;
.
deepStrictEqual
(
await
readCacheNonces
(
)
,
new
Set
(
[
'nonce-1'
,
'nonce-2'
]
)
)
;
}
)
;
test
(
'evicts a previously locked older nonce on startup once released'
,
async
(
)
=>
{
await
seedPluginDir
(
'rev'
,
{
'index.js'
:
'v1'
}
)
;
const
=
await
.
syncCustomizations
(
'test-client'
,
[
makeRef
(
'rev'
,
'nonce-1'
)
]
)
;
const
=
[
0
]
.
!
;
.
.
add
(
.
)
;
await
seedPluginDir
(
'rev'
,
{
'index.js'
:
'v2'
}
)
;
await
.
syncCustomizations
(
'test-client'
,
[
makeRef
(
'rev'
,
'nonce-2'
)
]
)
;
.
.
clear
(
)
;
const
=
new
AgentPluginManager
(
,
,
new
NullLogService
(
)
)
;
await
.
syncCustomizations
(
'test-client'
,
[
makeRef
(
'rev'
,
'nonce-2'
)
]
)
;
.
strictEqual
(
await
.
exists
(
)
,
false
,
'released older nonce should be evicted on startup'
)
;
.
deepStrictEqual
(
await
readCacheNonces
(
)
,
new
Set
(
[
'nonce-2'
]
)
)
;
}
)
;
test
(
'drops a stale cache entry when its directory is already gone'
,
async
(
)
=>
{
await
seedPluginDir
(
'rev'
,
{
'index.js'
:
'v1'
}
)
;
const
=
await
.
syncCustomizations
(
'test-client'
,
[
makeRef
(
'rev'
,
'nonce-1'
)
]
)
;
const
=
[
0
]
.
!
;
.
.
add
(
.
)
;
await
seedPluginDir
(
'rev'
,
{
'index.js'
:
'v2'
}
)
;
await
.
syncCustomizations
(
'test-client'
,
[
makeRef
(
'rev'
,
'nonce-2'
)
]
)
;
.
.
clear
(
)
;
await
.
del
(
,
{
:
true
}
)
;
const
=
new
AgentPluginManager
(
,
,
new
NullLogService
(
)
)
;
await
.
syncCustomizations
(
'test-client'
,
[
makeRef
(
'rev'
,
'nonce-2'
)
]
)
;
.
deepStrictEqual
(
await
readCacheNonces
(
)
,
new
Set
(
[
'nonce-2'
]
)
)
;
}
)
;
test
(
'serializes concurrent syncs of the same URI'
,
async
(
)
=>
{
await
seedPluginDir
(
'concurrent'
,
{
'index.js'
:
'v1'
}
)
;
const
=
makeRef
(
'concurrent'
,
'n1'
)
;
const
[
,
]
=
await
Promise
.
all
(
[
.
syncCustomizations
(
'test-client'
,
[
]
)
,
.
syncCustomizations
(
'test-client'
,
[
]
)
,
]
)
;
.
strictEqual
(
[
0
]
.
.
?.
,
'loaded'
)
;
.
strictEqual
(
[
0
]
.
.
?.
,
'loaded'
)
;
}
)
;
test
(
'waits for cache initialization before starting concurrent syncs'
,
async
(
)
=>
{
await
seedPluginDir
(
'concurrent'
,
{
'index.js'
:
'v1'
}
)
;
await
.
syncCustomizations
(
'test-client'
,
[
makeRef
(
'concurrent'
,
'n1'
)
]
)
;
const
=
new
AgentPluginManager
(
,
,
new
NullLogService
(
)
)
;
const
=
.
=
new
DeferredPromise< void >
(
)
;
const
=
.
syncCustomizations
(
'test-client'
,
[
makeRef
(
'concurrent'
,
'n2'
)
]
)
;
await
.
.
;
const
=
.
syncCustomizations
(
'test-client'
,
[
makeRef
(
'concurrent'
,
'n2'
)
]
)
;
.
complete
(
)
;
await
Promise
.
all
(
[
,
]
)
;
.
strictEqual
(
.
[
0
]
,
'cache-read-complete'
)
;
}
)
;
}
)
;
suite
(
'LRU eviction'
,
(
)
=>
{
test
(
'evicts least recently used plugins when limit exceeded'
,
async
(
)
=>
{
const
=
new
AgentPluginManager
(
,
,
new
NullLogService
(
)
,
3
)
;
for
(
let
=
1
;
<=
4
;
++
)
{
await
seedPluginDir
(
` plugin- ${ i} `
,
{
'index.js'
:
` p ${ i} `
}
)
;
await
.
syncCustomizations
(
'test-client'
,
[
makeRef
(
` plugin- ${ i} `
,
` n ${ i} `
)
]
)
;
}
const
=
URI
.
joinPath
(
,
'agentPlugins'
)
;
const
=
await
.
resolve
(
)
;
.
ok
(
.
)
;
const
=
.
.
filter
(
=>
.
)
;
.
strictEqual
(
.
,
3
,
'should have exactly 3 plugin dirs after eviction'
)
;
}
)
;
test
(
'retains a locked LRU candidate and skips ahead to evict an unlocked one'
,
async
(
)
=>
{
const
=
new
AgentPluginManager
(
,
,
new
NullLogService
(
)
,
2
)
;
await
seedPluginDir
(
'plugin-1'
,
{
'index.js'
:
'p1'
}
)
;
const
=
await
.
syncCustomizations
(
'client-1'
,
[
makeRef
(
'plugin-1'
,
'n1'
)
]
)
;
const
=
[
0
]
.
!
;
await
seedPluginDir
(
'plugin-2'
,
{
'index.js'
:
'p2'
}
)
;
const
=
await
.
syncCustomizations
(
'client-2'
,
[
makeRef
(
'plugin-2'
,
'n2'
)
]
)
;
const
=
[
0
]
.
!
;
.
.
add
(
.
)
;
await
seedPluginDir
(
'plugin-3'
,
{
'index.js'
:
'p3'
}
)
;
await
.
syncCustomizations
(
'client-3'
,
[
makeRef
(
'plugin-3'
,
'n3'
)
]
)
;
.
strictEqual
(
await
.
exists
(
)
,
true
,
'locked plugin-1 should be retained'
)
;
.
strictEqual
(
await
.
exists
(
)
,
false
,
'unlocked plugin-2 should be evicted'
)
;
}
)
;
}
)
;
suite
(
'cache persistence'
,
(
)
=>
{
test
(
'restores nonce cache from disk on new manager instance'
,
async
(
)
=>
{
await
seedPluginDir
(
'persist1'
,
{
'index.js'
:
'v1'
}
)
;
const
=
makeRef
(
'persist1'
,
'nonce-persist'
)
;
await
.
syncCustomizations
(
'test-client'
,
[
]
)
;
const
=
new
AgentPluginManager
(
,
,
new
NullLogService
(
)
)
;
const
=
await
.
syncCustomizations
(
'test-client'
,
[
]
)
;
.
strictEqual
(
(
[
0
]
.
as
)
.
?.
,
'loaded'
)
;
.
ok
(
[
0
]
.
)
;
}
)
;
}
)
;
}
)
;