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 / intents / node / test / backgroundTodoEnablement.spec.ts 346 строк · изменён 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
import { RequestType, type RequestMetadata } from '@vscode/copilot-api' ;
import { afterAll, beforeAll, beforeEach, describe, expect, test } from 'vitest' ;
import { IAuthenticationService } from '../../../../platform/authentication/common/authentication' ;
import { CopilotToken, createTestExtendedTokenInfo } from '../../../../platform/authentication/common/copilotToken' ;
import { setCopilotToken } from '../../../../platform/authentication/common/staticGitHubAuthenticationService' ;
import { ConfigKey, IConfigurationService } from
MockEndpoint
IChatEndpoint
IExperimentationService
ITestingServicesAccessor
TestWorkspaceService
IWorkspaceService
NullWorkspaceFileIndex
IWorkspaceFileIndex
SyncDescriptor
IInstantiationService
createExtensionUnitTestingServices
TestChatRequest
ToolName
AgentIntent AgentIntentInvocation getAgentTools isBackgroundTodoAgentEnabled isTodoToolExplicitlyEnabled
request
request
request
request toolReferences name name
request
request
request toolReferences name
request
request
request toolReferences name ToolName CoreManageTodoList
request
request
request toolReferences name name name
request
request
request tools name
request
capiEndpoint urlOrRequestMetadata type RequestType ChatCompletions modelProvider IChatEndpoint
byokEndpoint urlOrRequestMetadata modelProvider IChatEndpoint
paidToken sku copilot_plan
freeToken sku
noAuthToken sku
copilotToken CopilotToken IAuthenticationService
copilotToken IAuthenticationService
experimentEnabled IConfigurationService
experimentEnabled IConfigurationService
expService IExperimentationService
endpoint IChatEndpoint copilotToken CopilotToken experimentEnabled request TestChatRequest
endpoint experimentEnabled expService copilotToken request
capiEndpoint paidToken
capiEndpoint paidToken
capiEndpoint
capiEndpoint freeToken
capiEndpoint noAuthToken
byokEndpoint paidToken
request
request toolReferences name
capiEndpoint paidToken request
accessor ITestingServicesAccessor
instantiationService IInstantiationService
configService IConfigurationService
mockEndpoint IChatEndpoint
services
services IWorkspaceFileIndex NullWorkspaceFileIndex
services IWorkspaceService
TestWorkspaceService
accessor services
instantiationService accessor IInstantiationService
configService accessor IConfigurationService
paidToken sku copilot_plan
accessor IAuthenticationService paidToken
mockEndpoint instantiationService MockEndpoint
mockEndpoint urlOrRequestMetadata RequestMetadata urlOrRequestMetadata type RequestType ChatCompletions
accessor
configService ConfigKey Advanced BackgroundTodoAgentEnabled
tools name
tools t t name ToolName CoreManageTodoList
configService ConfigKey Advanced BackgroundTodoAgentEnabled
request
tools instantiationService getAgentTools request mockEndpoint
tools
configService ConfigKey Advanced BackgroundTodoAgentEnabled
request
request tools name ToolName CoreManageTodoList
tools instantiationService getAgentTools request mockEndpoint
tools
configService ConfigKey Advanced BackgroundTodoAgentEnabled
request
request toolReferences name
tools instantiationService getAgentTools request mockEndpoint
tools
endpoint promptContext token
AgentIntentInvocation prototype endpoint promptContext token _maybeStartBackgroundTodoAgentPass
endpoint urlOrRequestMetadata type RequestType ChatCompletions modelProvider IChatEndpoint
paidToken sku copilot_plan
request TestChatRequest
request
_getOrCreateBackgroundTodoAgentProcessor processorLookup
configurationService
expService
instantiationService
toolsService
telemetryService
authenticationService copilotToken paidToken
logService
processorLookups
request
request subAgentInvocationId subAgentInvocationId
stub request
processorLookups
stub endpoint conversation sessionId
processorLookups
processorLookups
request
stub request
processorLookups
stub endpoint conversation sessionId
processorLookups
processorLookups
request
request subAgentInvocationId subAgentInvocationId
stub request
processorLookups
stub endpoint conversation sessionId
processorLookups
capiEndpoint urlOrRequestMetadata type RequestType ChatCompletions modelProvider IChatEndpoint
byokEndpoint urlOrRequestMetadata modelProvider IChatEndpoint
paidToken sku copilot_plan
conversation request
AgentIntent prototype conversation request _runFinalBackgroundTodoPass
endpoint IChatEndpoint processor
_backgroundTodoProcessors _id processor
endpointProvider endpoint
configurationService
expService
_authenticationService copilotToken paidToken
conversation sessionId id
endTurnCalls
endTurnCalls
endTurnCalls
processor
request
capiEndpoint processor conversation request
processor endTurnCalls
processor
request
byokEndpoint processor conversation request
processor endTurnCalls
processor
request
request subAgentInvocationId subAgentInvocationId
capiEndpoint processor conversation request
processor endTurnCalls
request
capiEndpoint conversation request
'../../../../platform/configuration/common/configurationService'
;
import
{
}
from
'../../../../platform/endpoint/test/node/mockEndpoint'
;
import
{
}
from
'../../../../platform/networking/common/networking'
;
import
{
}
from
'../../../../platform/telemetry/common/nullExperimentationService'
;
import
{
}
from
'../../../../platform/test/node/services'
;
import
{
}
from
'../../../../platform/test/node/testWorkspaceService'
;
import
{
}
from
'../../../../platform/workspace/common/workspaceService'
;
import
{
}
from
'../../../../platform/workspaceChunkSearch/node/nullWorkspaceFileIndex'
;
import
{
}
from
'../../../../platform/workspaceChunkSearch/node/workspaceFileIndex'
;
import
{
URI
}
from
'../../../../util/vs/base/common/uri'
;
import
{
}
from
'../../../../util/vs/platform/instantiation/common/descriptors'
;
import
{
}
from
'../../../../util/vs/platform/instantiation/common/instantiation'
;
import
{
}
from
'../../../test/node/services'
;
import
{
}
from
'../../../test/node/testHelpers'
;
import
{
}
from
'../../../tools/common/toolNames'
;
import
{
,
,
,
,
}
from
'../agentIntent'
;
describe
(
'isTodoToolExplicitlyEnabled'
,
(
)
=>
{
test
(
'returns false when toolReferences is empty'
,
(
)
=>
{
const
=
new
TestChatRequest
(
'fix the bug'
)
;
expect
(
isTodoToolExplicitlyEnabled
(
)
)
.
toBe
(
false
)
;
}
)
;
test
(
'returns false when toolReferences contains unrelated tools'
,
(
)
=>
{
const
=
new
TestChatRequest
(
'fix the bug'
)
;
(
as
any
)
.
=
[
{
:
'read_file'
}
,
{
:
'codebase'
}
]
;
expect
(
isTodoToolExplicitlyEnabled
(
)
)
.
toBe
(
false
)
;
}
)
;
test
(
'returns true when toolReferences contains #todo reference name'
,
(
)
=>
{
const
=
new
TestChatRequest
(
'fix the bug'
)
;
(
as
any
)
.
=
[
{
:
'todo'
}
]
;
expect
(
isTodoToolExplicitlyEnabled
(
)
)
.
toBe
(
true
)
;
}
)
;
test
(
'returns true when toolReferences contains manage_todo_list tool name'
,
(
)
=>
{
const
=
new
TestChatRequest
(
'fix the bug'
)
;
(
as
any
)
.
=
[
{
:
.
}
]
;
expect
(
isTodoToolExplicitlyEnabled
(
)
)
.
toBe
(
true
)
;
}
)
;
test
(
'returns true when toolReferences has mixed tools including todo'
,
(
)
=>
{
const
=
new
TestChatRequest
(
'fix the bug'
)
;
(
as
any
)
.
=
[
{
:
'read_file'
}
,
{
:
'todo'
}
,
{
:
'codebase'
}
]
;
expect
(
isTodoToolExplicitlyEnabled
(
)
)
.
toBe
(
true
)
;
}
)
;
test
(
'does not treat default tool picker enabled state as explicit enablement'
,
(
)
=>
{
const
=
new
TestChatRequest
(
'fix the bug'
)
;
.
=
new
Map
(
[
[
{
:
'manage_todo_list'
}
as
any
,
true
]
]
)
;
expect
(
isTodoToolExplicitlyEnabled
(
)
)
.
toBe
(
false
)
;
}
)
;
}
)
;
describe
(
'isBackgroundTodoAgentEnabled'
,
(
)
=>
{
const
=
{
:
{
:
.
}
,
:
'copilot'
}
as
unknown
as
;
const
=
{
:
'https://api.example.com/v1/chat'
,
:
'custom'
}
as
unknown
as
;
const
=
new
CopilotToken
(
createTestExtendedTokenInfo
(
{
:
'copilot_individual'
,
:
'individual'
}
)
)
;
const
=
new
CopilotToken
(
createTestExtendedTokenInfo
(
{
:
'free_limited_copilot'
}
)
)
;
const
=
new
CopilotToken
(
createTestExtendedTokenInfo
(
{
:
'no_auth_limited_copilot'
}
)
)
;
function
auth
(
:
|
undefined
)
:
{
return
{
}
as
unknown
as
;
}
function
config
(
:
boolean
)
:
{
return
{
getExperimentBasedConfig
:
(
)
=>
}
as
unknown
as
;
}
const
=
{
}
as
;
function
isEnabled
(
:
,
:
|
undefined
,
:
boolean
,
:
=
new
TestChatRequest
(
'fix the bug'
)
)
:
boolean
{
return
isBackgroundTodoAgentEnabled
(
,
config
(
)
,
,
auth
(
)
,
)
;
}
test
(
'enabled for a signed-in paid user on a CAPI endpoint with the experiment on'
,
(
)
=>
{
expect
(
isEnabled
(
,
,
true
)
)
.
toBe
(
true
)
;
}
)
;
test
(
'disabled when the experiment is off'
,
(
)
=>
{
expect
(
isEnabled
(
,
,
false
)
)
.
toBe
(
false
)
;
}
)
;
test
(
'disabled when there is no Copilot token (signed out)'
,
(
)
=>
{
expect
(
isEnabled
(
,
undefined
,
true
)
)
.
toBe
(
false
)
;
}
)
;
test
(
'disabled for a free-plan user'
,
(
)
=>
{
expect
(
isEnabled
(
,
,
true
)
)
.
toBe
(
false
)
;
}
)
;
test
(
'disabled for a no-auth user'
,
(
)
=>
{
expect
(
isEnabled
(
,
,
true
)
)
.
toBe
(
false
)
;
}
)
;
test
(
'disabled on a non-CAPI (BYOK) endpoint'
,
(
)
=>
{
expect
(
isEnabled
(
,
,
true
)
)
.
toBe
(
false
)
;
}
)
;
test
(
'disabled when #todo is explicitly referenced'
,
(
)
=>
{
const
=
new
TestChatRequest
(
'fix the bug'
)
;
(
as
any
)
.
=
[
{
:
'todo'
}
]
;
expect
(
isEnabled
(
,
,
true
,
)
)
.
toBe
(
false
)
;
}
)
;
}
)
;
describe
(
'getAgentTools background todo enablement'
,
(
)
=>
{
let
:
;
let
:
;
let
:
;
let
:
;
beforeAll
(
(
)
=>
{
const
=
createExtensionUnitTestingServices
(
)
;
.
define
(
,
new
SyncDescriptor
(
)
)
;
.
define
(
,
new
SyncDescriptor
(
,
[
[
URI
.
file
(
'/workspace'
)
]
,
[
]
]
)
)
;
=
.
createTestingAccessor
(
)
;
=
.
get
(
)
;
=
.
get
(
)
;
const
=
new
CopilotToken
(
createTestExtendedTokenInfo
(
{
:
'copilot_individual'
,
:
'individual'
}
)
)
;
setCopilotToken
(
.
get
(
)
,
)
;
=
.
createInstance
(
,
undefined
)
;
(
as
unknown
as
{
:
string
|
}
)
.
=
{
:
.
}
;
}
)
;
afterAll
(
(
)
=>
{
.
dispose
(
)
;
}
)
;
beforeEach
(
(
)
=>
{
.
setConfig
(
.
.
,
false
)
;
}
)
;
function
hasTodoTool
(
:
readonly
{
:
string
}
[
]
)
:
boolean
{
return
.
some
(
=>
.
===
.
)
;
}
test
(
'todo tool is not in enabled tools when experiment is on'
,
async
(
)
=>
{
.
setConfig
(
.
.
,
true
)
;
const
=
new
TestChatRequest
(
'fix the bug'
)
;
const
=
await
.
invokeFunction
(
,
,
)
;
expect
(
hasTodoTool
(
)
)
.
toBe
(
false
)
;
}
)
;
test
(
'todo tool is not in enabled tools when experiment is on even with tool picker default'
,
async
(
)
=>
{
.
setConfig
(
.
.
,
true
)
;
const
=
new
TestChatRequest
(
'fix the bug'
)
;
.
=
new
Map
(
[
[
{
:
.
}
as
any
,
true
]
]
)
;
const
=
await
.
invokeFunction
(
,
,
)
;
expect
(
hasTodoTool
(
)
)
.
toBe
(
false
)
;
}
)
;
test
(
'todo tool is disabled when experiment is on and user has not referenced #todo'
,
async
(
)
=>
{
.
setConfig
(
.
.
,
true
)
;
const
=
new
TestChatRequest
(
'fix the bug'
)
;
(
as
any
)
.
=
[
{
:
'read_file'
}
]
;
const
=
await
.
invokeFunction
(
,
,
)
;
expect
(
hasTodoTool
(
)
)
.
toBe
(
false
)
;
}
)
;
}
)
;
describe
(
'AgentIntentInvocation._maybeStartBackgroundTodoAgentPass subagent guard'
,
(
)
=>
{
function
getMethod
(
)
:
(
this
:
unknown
,
:
unknown
,
:
unknown
,
:
unknown
)
=>
void
{
return
(
.
as
unknown
as
{
_maybeStartBackgroundTodoAgentPass
:
(
this
:
unknown
,
:
unknown
,
:
unknown
,
:
unknown
)
=>
void
}
)
.
;
}
const
=
{
:
{
:
.
}
,
:
''
}
as
unknown
as
;
const
=
new
CopilotToken
(
createTestExtendedTokenInfo
(
{
:
'copilot_individual'
,
:
'individual'
}
)
)
;
function
makeStub
(
:
,
processorLookup
:
(
)
=>
unknown
)
{
return
{
,
:
,
:
{
getExperimentBasedConfig
:
(
)
=>
true
}
,
:
{
}
,
:
{
}
,
:
{
}
,
:
{
}
,
:
{
:
}
,
:
{
debug
:
(
)
=>
{
}
}
,
}
;
}
test
(
'returns early without touching the processor when request is from a subagent'
,
(
)
=>
{
let
=
0
;
const
=
new
TestChatRequest
(
'do work'
)
;
(
as
unknown
as
{
:
string
}
)
.
=
'subagent-uuid-1'
;
const
=
makeStub
(
,
(
)
=>
{
++
;
return
undefined
;
}
)
;
getMethod
(
)
.
call
(
,
,
{
:
{
:
'sess-1'
}
}
,
{
}
)
;
expect
(
)
.
toBe
(
0
)
;
}
)
;
test
(
'proceeds past the guard when the request has no subAgentInvocationId'
,
(
)
=>
{
let
=
0
;
const
=
new
TestChatRequest
(
'do work'
)
;
const
=
makeStub
(
,
(
)
=>
{
++
;
return
undefined
;
}
)
;
getMethod
(
)
.
call
(
,
,
{
:
{
:
'sess-1'
}
}
,
{
}
)
;
expect
(
)
.
toBe
(
1
)
;
}
)
;
test
(
'treats an empty-string subAgentInvocationId as a subagent request'
,
(
)
=>
{
let
=
0
;
const
=
new
TestChatRequest
(
'do work'
)
;
(
as
unknown
as
{
:
string
}
)
.
=
''
;
const
=
makeStub
(
,
(
)
=>
{
++
;
return
undefined
;
}
)
;
getMethod
(
)
.
call
(
,
,
{
:
{
:
'sess-1'
}
}
,
{
}
)
;
expect
(
)
.
toBe
(
0
)
;
}
)
;
}
)
;
describe
(
'AgentIntent._runFinalBackgroundTodoPass model-eligibility guard'
,
(
)
=>
{
const
=
{
:
{
:
.
}
,
:
'copilot'
}
as
unknown
as
;
const
=
{
:
'https://api.example.com/v1/chat'
,
:
'custom'
}
as
unknown
as
;
const
=
new
CopilotToken
(
createTestExtendedTokenInfo
(
{
:
'copilot_individual'
,
:
'individual'
}
)
)
;
function
getMethod
(
)
:
(
this
:
unknown
,
:
unknown
,
:
unknown
)
=>
Promise
<
void
>
{
return
(
.
as
unknown
as
{
_runFinalBackgroundTodoPass
:
(
this
:
unknown
,
:
unknown
,
:
unknown
)
=>
Promise
<
void
>
}
)
.
;
}
function
makeStub
(
:
|
undefined
,
:
unknown
)
{
return
{
:
{
get
:
(
:
string
)
=>
}
,
:
{
getChatEndpoint
:
async
(
)
=>
}
,
:
{
getExperimentBasedConfig
:
(
)
=>
true
}
,
:
{
}
,
:
{
:
}
,
}
;
}
const
=
{
:
'sess-1'
,
getLatestTurn
:
(
)
=>
(
{
:
'turn-1'
}
)
}
;
function
makeProcessor
(
)
{
let
=
0
;
return
{
get
endTurnCalls
(
)
{
return
;
}
,
endTurn
:
async
(
)
=>
{
++
;
}
,
cancel
:
(
)
=>
{
}
,
}
;
}
test
(
'runs the final pass on a CAPI endpoint with paid auth and experiment on'
,
async
(
)
=>
{
const
=
makeProcessor
(
)
;
const
=
new
TestChatRequest
(
'fix the bug'
)
;
await
getMethod
(
)
.
call
(
makeStub
(
,
)
,
,
)
;
expect
(
.
)
.
toBe
(
1
)
;
}
)
;
test
(
'does not run the final pass when the model switched to a BYOK (non-CAPI) endpoint'
,
async
(
)
=>
{
const
=
makeProcessor
(
)
;
const
=
new
TestChatRequest
(
'fix the bug'
)
;
await
getMethod
(
)
.
call
(
makeStub
(
,
)
,
,
)
;
expect
(
.
)
.
toBe
(
0
)
;
}
)
;
test
(
'does not run the final pass for a subagent request'
,
async
(
)
=>
{
const
=
makeProcessor
(
)
;
const
=
new
TestChatRequest
(
'fix the bug'
)
;
(
as
unknown
as
{
:
string
}
)
.
=
'subagent-uuid-1'
;
await
getMethod
(
)
.
call
(
makeStub
(
,
)
,
,
)
;
expect
(
.
)
.
toBe
(
0
)
;
}
)
;
test
(
'does nothing when there is no processor for the session'
,
async
(
)
=>
{
const
=
new
TestChatRequest
(
'fix the bug'
)
;
await
getMethod
(
)
.
call
(
makeStub
(
,
undefined
)
,
,
)
;
}
)
;
}
)
;