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 / chatSessions / copilotcli / vscode-node / test / copilotCLICustomizationProvider.spec.ts 501 строк · изменён 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
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
import type { SweCustomAgent } from '@github/copilot/sdk' ;
import { afterEach, beforeEach, describe, expect, it } from 'vitest' ;
import * as vscode from 'vscode' ;
import { ILogService } from '../../../../../platform/log/common/logService' ;
import { MockCustomInstructionsService } from '../../../../../platform/test/common/testCustomInstructionsService' ;
import { mock } from '../../../../../util/common/test/simpleMock' ;
import { Emitter } from '../../../../../util/vs/base/common/event'
DisposableStore
CLIAgentInfo ICopilotCLIAgents
CopilotCLICustomizationProvider
MockPromptsService
Agent
Skill
Instructions
Prompt
Hook
Plugins
id
name description displayName Readonly SweCustomAgent
name
displayName displayName name
description
tools
disableModelInvocation
name description displayName CLIAgentInfo
agent name description displayName
sourceUri scheme path
source
extensionId
pluginUri
name fileUri description CLIAgentInfo
agent name description
sourceUri fileUri
source
extensionId
pluginUri
uri name pattern description vscode ChatInstruction
uri name pattern source description
uri name vscode ChatSkill
uri name name source disableModelInvocation
uri vscode ChatHook
uri source
uri vscode ChatPlugin
uri
_onDidChangeAgents
override onDidChangeAgents _onDidChangeAgents event
_agents CLIAgentInfo
agents CLIAgentInfo _agents agents
override CLIAgentInfo _agents
_onDidChangeAgents
_onDidChangeAgents
override
override
_agentInstructions
uris _agentInstructions uris
override _agentInstructions
testSessionResource
disposables DisposableStore
mockPromptsService MockPromptsService
mockCopilotCLIAgents MockCopilotCLIAgents
mockCustomInstructionsService TestCustomInstructionsService
provider CopilotCLICustomizationProvider
originalChatSessionCustomizationType
originalChatSessionCustomizationType vscode Record ChatSessionCustomizationType
vscode Record ChatSessionCustomizationType FakeChatSessionCustomizationType
disposables
mockPromptsService disposables
mockCopilotCLIAgents disposables
mockCustomInstructionsService
provider disposables
mockCopilotCLIAgents
mockCustomInstructionsService
mockPromptsService
userHome
disposables
vscode Record ChatSessionCustomizationType originalChatSessionCustomizationType
CopilotCLICustomizationProvider metadata label
CopilotCLICustomizationProvider metadata iconId
supported CopilotCLICustomizationProvider metadata supportedTypes
supported
supported
supported FakeChatSessionCustomizationType Agent
supported FakeChatSessionCustomizationType Skill
supported FakeChatSessionCustomizationType Instructions
supported FakeChatSessionCustomizationType Hook
supported FakeChatSessionCustomizationType Plugins
mockCopilotCLIAgents
items provider testSessionResource
supported CopilotCLICustomizationProvider metadata supportedTypes t t id
item items
supported item type id
mockCopilotCLIAgents
items provider testSessionResource
builtinItems items i i uri scheme
item builtinItems
item groupKey
items provider testSessionResource
items
mockCopilotCLIAgents
items provider testSessionResource
agentItems items i vscode ChatSessionCustomizationItem i type FakeChatSessionCustomizationType Agent
agentItems
agentItems name
agentItems description
fileUri
mockCopilotCLIAgents fileUri
items provider testSessionResource
agentItems items i vscode ChatSessionCustomizationItem i type FakeChatSessionCustomizationType Agent
agentItems
agentItems uri fileUri
agentItems groupKey
mockCopilotCLIAgents
items provider testSessionResource
agentItems items i vscode ChatSessionCustomizationItem i type FakeChatSessionCustomizationType Agent
agentItems
agentItems uri scheme
agentItems uri path
agentItems groupKey
mockCopilotCLIAgents
items provider testSessionResource
items name
uri
mockPromptsService uri
items provider testSessionResource
items
items uri uri
items type FakeChatSessionCustomizationType Instructions
items groupKey
uri
mockPromptsService uri
items provider testSessionResource
items
items uri uri
items type FakeChatSessionCustomizationType Skill
items name
uri
mockPromptsService uri
items provider testSessionResource
items
items name
mockCopilotCLIAgents
mockPromptsService
mockPromptsService
mockPromptsService
mockPromptsService
items provider testSessionResource
items
uri
mockPromptsService uri
items provider testSessionResource
items
items uri uri
items type FakeChatSessionCustomizationType Hook
items name
mockPromptsService
items provider testSessionResource
items name
mockPromptsService
items provider testSessionResource
hookItems items i vscode ChatSessionCustomizationItem i type FakeChatSessionCustomizationType Hook
hookItems
uri
mockPromptsService uri
items provider testSessionResource
items
items uri uri
items type FakeChatSessionCustomizationType Plugins
items name
uri
mockPromptsService uri
mockCustomInstructionsService uri
items provider testSessionResource
instrItems items i i type FakeChatSessionCustomizationType Instructions
instrItems
instrItems groupKey
instrItems badge
agentsUri
claudeUri
copilotUri
mockPromptsService
mockCustomInstructionsService agentsUri claudeUri copilotUri
items provider testSessionResource
instrItems items i i type FakeChatSessionCustomizationType Instructions
instrItems
instrItems i i groupKey
instrItems i i name
workspaceRoot
agentsUri
claudeUri
existingUris agentsUri claudeUri
testProvider disposables
mockCopilotCLIAgents
mockCustomInstructionsService
mockPromptsService
workspaceRoot
uri existingUris uri
type ctime mtime size
userHome
mockPromptsService
mockCustomInstructionsService
items testProvider testSessionResource
instrItems items i i type FakeChatSessionCustomizationType Instructions
instrItems
instrItems i i groupKey
instrItems i i name
uri
mockPromptsService uri
items provider testSessionResource
instrItems items i i type FakeChatSessionCustomizationType Instructions
instrItems
instrItems groupKey
instrItems badge
instrItems badgeTooltip
uri
mockPromptsService uri
items provider testSessionResource
instrItems items i i type FakeChatSessionCustomizationType Instructions
instrItems
instrItems groupKey
instrItems badge
instrItems badgeTooltip
uri
mockPromptsService uri
items provider testSessionResource
instrItems items i i type FakeChatSessionCustomizationType Instructions
instrItems
instrItems groupKey
instrItems badge
instrItems description
uri
mockPromptsService uri
items provider testSessionResource
instrItems items i i type FakeChatSessionCustomizationType Instructions
instrItems
instrItems description
instrItems badge
agentUri
contextUri
onDemandUri
mockPromptsService agentUri contextUri onDemandUri
mockCustomInstructionsService agentUri
mockPromptsService contextUri
mockPromptsService onDemandUri
items provider testSessionResource
instrItems items i i type FakeChatSessionCustomizationType Instructions
instrItems
agent instrItems i i groupKey
context instrItems i i groupKey
onDemand instrItems i i groupKey
agent
agent uri agentUri
context
context badge
onDemand
onDemand badge
uri
mockPromptsService uri
mockPromptsService uri
items provider testSessionResource
instrItems items i i type FakeChatSessionCustomizationType Instructions
instrItems
instrItems groupKey
instrItems badge
fired
disposables provider fired
mockPromptsService
fired
fired
disposables provider fired
mockPromptsService
fired
fired
disposables provider fired
mockPromptsService
fired
fired
disposables provider fired
mockPromptsService
fired
fired
disposables provider fired
mockPromptsService
fired
fired
disposables provider fired
mockCopilotCLIAgents
fired
;
import
{
}
from
'../../../../../util/vs/base/common/lifecycle'
;
import
{
URI
}
from
'../../../../../util/vs/base/common/uri'
;
import
{
,
}
from
'../../../copilotcli/node/copilotCli'
;
import
{
}
from
'../copilotCLICustomizationProvider'
;
import
{
}
from
'../../../../../platform/promptFiles/test/common/mockPromptsService'
;
class
FakeChatSessionCustomizationType
{
static
readonly
=
new
FakeChatSessionCustomizationType
(
'agent'
)
;
static
readonly
=
new
FakeChatSessionCustomizationType
(
'skill'
)
;
static
readonly
=
new
FakeChatSessionCustomizationType
(
'instructions'
)
;
static
readonly
=
new
FakeChatSessionCustomizationType
(
'prompt'
)
;
static
readonly
=
new
FakeChatSessionCustomizationType
(
'hook'
)
;
static
readonly
=
new
FakeChatSessionCustomizationType
(
'plugins'
)
;
constructor
(
readonly
:
string
)
{
}
}
function
makeSweAgent
(
:
string
,
=
''
,
?
:
string
)
:
<
>
{
return
{
,
:
??
,
,
:
null
,
prompt
:
(
)
=>
Promise
.
resolve
(
''
)
,
:
false
,
}
;
}
function
makeAgentInfo
(
:
string
,
=
''
,
?
:
string
)
:
{
return
{
:
makeSweAgent
(
,
,
)
,
:
URI
.
from
(
{
:
'copilotcli'
,
:
` /agents/ ${ name} `
}
)
,
:
'local'
,
:
undefined
,
:
undefined
,
}
;
}
function
makeFileAgentInfo
(
:
string
,
:
URI
,
=
''
)
:
{
return
{
:
makeSweAgent
(
,
)
,
:
,
:
'local'
,
:
undefined
,
:
undefined
,
}
;
}
function
makeInstruction
(
:
URI
,
:
string
,
:
string
|
undefined
,
?
:
string
)
:
.
{
return
{
,
,
,
:
'local'
,
}
;
}
function
makeSkill
(
:
URI
,
:
string
)
:
.
{
return
{
,
:
,
:
'local'
,
:
false
}
;
}
function
makeHook
(
:
URI
)
:
.
{
return
{
,
:
'local'
}
;
}
function
makePlugin
(
:
URI
)
:
.
{
return
{
}
;
}
class
MockCopilotCLIAgents
extends
mock< ICopilotCLIAgents>
(
)
{
private
readonly
=
new
Emitter< void >
(
)
;
readonly
=
this
.
.
;
private
:
[
]
=
[
]
;
setAgents
(
:
[
]
)
{
this
.
=
;
}
async
getAgents
(
)
:
Promise
<
readonly
[
]
>
{
return
this
.
;
}
fireAgentsChanged
(
)
{
this
.
.
fire
(
)
;
}
dispose
(
)
{
this
.
.
dispose
(
)
;
}
}
class
TestLogService
extends
mock< ILogService>
(
)
{
trace
(
)
{
}
debug
(
)
{
}
}
class
TestCustomInstructionsService
extends
MockCustomInstructionsService
{
private
:
URI
[
]
=
[
]
;
setAgentInstructionUris
(
:
URI
[
]
)
{
this
.
=
;
}
getAgentInstructions
(
)
:
Promise
<
URI
[
]
>
{
return
Promise
.
resolve
(
this
.
)
;
}
}
describe
(
'CopilotCLICustomizationProvider'
,
(
)
=>
{
const
=
URI
.
parse
(
'copilotcli:///test-session'
)
;
let
:
;
let
:
;
let
:
;
let
:
;
let
:
;
let
:
unknown
;
beforeEach
(
(
)
=>
{
=
(
as
<
string
,
unknown
>
)
.
;
(
as
<
string
,
unknown
>
)
.
=
;
=
new
DisposableStore
(
)
;
=
.
add
(
new
MockPromptsService
(
)
)
;
=
.
add
(
new
MockCopilotCLIAgents
(
)
)
;
=
new
TestCustomInstructionsService
(
)
;
=
.
add
(
new
CopilotCLICustomizationProvider
(
,
,
,
new
TestLogService
(
)
,
{
getWorkspaceFolders
:
(
)
=>
[
]
}
as
any
,
{
stat
:
(
)
=>
Promise
.
reject
(
new
Error
(
'not found'
)
)
}
as
any
,
{
:
URI
.
file
(
'/home/test'
)
}
as
any
,
)
)
;
}
)
;
afterEach
(
(
)
=>
{
.
dispose
(
)
;
(
as
<
string
,
unknown
>
)
.
=
;
}
)
;
describe
(
'metadata'
,
(
)
=>
{
it
(
'has correct label and icon'
,
(
)
=>
{
expect
(
.
.
)
.
toBe
(
'Copilot CLI'
)
;
expect
(
.
.
)
.
toBe
(
'copilot'
)
;
}
)
;
it
(
'supports Agent, Skill, Instructions, Hook, and Plugins types'
,
(
)
=>
{
const
=
.
.
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
)
.
toHaveLength
(
5
)
;
expect
(
)
.
toContain
(
.
)
;
expect
(
)
.
toContain
(
.
)
;
expect
(
)
.
toContain
(
.
)
;
expect
(
)
.
toContain
(
.
)
;
expect
(
)
.
toContain
(
.
)
;
}
)
;
it
(
'only returns items whose type is in supportedTypes'
,
async
(
)
=>
{
.
setAgents
(
[
makeAgentInfo
(
'explore'
,
'Explore'
)
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
const
=
new
Set
(
.
.
!
.
map
(
=>
.
)
)
;
for
(
const
of
)
{
expect
(
.
has
(
.
.
)
,
` item " ${ item. name} " has type " ${ item. type. id} " not in supportedTypes `
)
.
toBe
(
true
)
;
}
}
)
;
it
(
'does not set groupKey for items with synthetic URIs (vscode infers grouping)'
,
async
(
)
=>
{
.
setAgents
(
[
makeAgentInfo
(
'explore'
,
'Explore'
)
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
const
=
.
filter
(
=>
.
.
!==
'file'
)
;
for
(
const
of
)
{
expect
(
.
,
` item " ${ item. name} " should not have groupKey (vscode infers) `
)
.
toBeUndefined
(
)
;
}
}
)
;
}
)
;
describe
(
'provideChatSessionCustomizations'
,
(
)
=>
{
it
(
'returns empty array when no files exist'
,
async
(
)
=>
{
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
expect
(
)
.
toEqual
(
[
]
)
;
}
)
;
it
(
'returns agents from ICopilotCLIAgents with source URIs'
,
async
(
)
=>
{
.
setAgents
(
[
makeAgentInfo
(
'explore'
,
'Fast code exploration'
)
,
makeAgentInfo
(
'task'
,
'Multi-step tasks'
)
,
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
const
=
.
filter
(
(
:
.
)
=>
.
===
.
)
;
expect
(
)
.
toHaveLength
(
2
)
;
expect
(
[
0
]
.
)
.
toBe
(
'explore'
)
;
expect
(
[
0
]
.
)
.
toBe
(
'Fast code exploration'
)
;
}
)
;
it
(
'uses file URI from sourceUri for file-backed agents'
,
async
(
)
=>
{
const
=
URI
.
file
(
'/workspace/.github/explore.agent.md'
)
;
.
setAgents
(
[
makeFileAgentInfo
(
'explore'
,
,
'Explore agent'
)
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
const
=
.
filter
(
(
:
.
)
=>
.
===
.
)
;
expect
(
)
.
toHaveLength
(
1
)
;
expect
(
[
0
]
.
)
.
toEqual
(
)
;
expect
(
[
0
]
.
)
.
toBeUndefined
(
)
;
}
)
;
it
(
'uses synthetic URI for SDK-only agents'
,
async
(
)
=>
{
.
setAgents
(
[
makeAgentInfo
(
'task'
,
'Task agent'
)
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
const
=
.
filter
(
(
:
.
)
=>
.
===
.
)
;
expect
(
)
.
toHaveLength
(
1
)
;
expect
(
[
0
]
.
.
)
.
toBe
(
'copilotcli'
)
;
expect
(
[
0
]
.
.
)
.
toBe
(
'/agents/task'
)
;
expect
(
[
0
]
.
)
.
toBeUndefined
(
)
;
}
)
;
it
(
'uses displayName from agents when available'
,
async
(
)
=>
{
.
setAgents
(
[
makeAgentInfo
(
'code-review'
,
'Reviews code'
,
'Code Review'
)
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
expect
(
[
0
]
.
)
.
toBe
(
'Code Review'
)
;
}
)
;
it
(
'returns instructions with on-demand groupKey when no applyTo pattern'
,
async
(
)
=>
{
const
=
URI
.
file
(
'/workspace/.github/copilot-instructions.md'
)
;
.
setInstructions
(
[
makeInstruction
(
,
'copilot-instructions'
,
undefined
)
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
expect
(
)
.
toHaveLength
(
1
)
;
expect
(
[
0
]
.
)
.
toBe
(
)
;
expect
(
[
0
]
.
)
.
toBe
(
.
)
;
expect
(
[
0
]
.
)
.
toBe
(
'on-demand-instructions'
)
;
}
)
;
it
(
'returns skills'
,
async
(
)
=>
{
const
=
URI
.
file
(
'/workspace/.github/skills/lint-check/SKILL.md'
)
;
.
setSkills
(
[
makeSkill
(
,
'lint-check'
)
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
expect
(
)
.
toHaveLength
(
1
)
;
expect
(
[
0
]
.
)
.
toBe
(
)
;
expect
(
[
0
]
.
)
.
toBe
(
.
)
;
expect
(
[
0
]
.
)
.
toBe
(
'lint-check'
)
;
}
)
;
it
(
'derives skill name from parent directory for SKILL.md files'
,
async
(
)
=>
{
const
=
URI
.
file
(
'/workspace/.copilot/skills/my-skill/SKILL.md'
)
;
.
setSkills
(
[
makeSkill
(
,
'my-skill'
)
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
expect
(
)
.
toHaveLength
(
1
)
;
expect
(
[
0
]
.
)
.
toBe
(
'my-skill'
)
;
}
)
;
it
(
'returns all matching types combined'
,
async
(
)
=>
{
.
setAgents
(
[
makeAgentInfo
(
'explore'
,
'Explore'
)
]
)
;
.
setInstructions
(
[
makeInstruction
(
URI
.
file
(
'/workspace/.github/b.instructions.md'
)
,
'b instructions'
,
undefined
)
]
)
;
.
setSkills
(
[
makeSkill
(
URI
.
file
(
'/workspace/.github/skills/c/SKILL.md'
)
,
'c'
)
]
)
;
.
setHooks
(
[
makeHook
(
URI
.
file
(
'/workspace/.copilot/hooks/pre-commit.json'
)
)
]
)
;
.
setPlugins
(
[
makePlugin
(
URI
.
file
(
'/workspace/.copilot/plugins/my-plugin'
)
)
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
expect
(
)
.
toHaveLength
(
5
)
;
}
)
;
it
(
'returns hooks with correct type and name'
,
async
(
)
=>
{
const
=
URI
.
file
(
'/workspace/.copilot/hooks/diagnostics.json'
)
;
.
setHooks
(
[
makeHook
(
)
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
expect
(
)
.
toHaveLength
(
1
)
;
expect
(
[
0
]
.
)
.
toBe
(
)
;
expect
(
[
0
]
.
)
.
toBe
(
.
)
;
expect
(
[
0
]
.
)
.
toBe
(
'diagnostics'
)
;
}
)
;
it
(
'strips .json extension from hook file name'
,
async
(
)
=>
{
.
setHooks
(
[
makeHook
(
URI
.
file
(
'/workspace/.copilot/hooks/security-checks.json'
)
)
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
expect
(
[
0
]
.
)
.
toBe
(
'security-checks'
)
;
}
)
;
it
(
'returns multiple hooks'
,
async
(
)
=>
{
.
setHooks
(
[
makeHook
(
URI
.
file
(
'/workspace/.copilot/hooks/hooks.json'
)
)
,
makeHook
(
URI
.
file
(
'/workspace/.copilot/hooks/diagnostics.json'
)
)
,
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
const
=
.
filter
(
(
:
.
)
=>
.
===
.
)
;
expect
(
)
.
toHaveLength
(
2
)
;
}
)
;
it
(
'returns plugins with correct type and name derived from URI'
,
async
(
)
=>
{
const
=
URI
.
file
(
'/workspace/.copilot/plugins/lint-rules'
)
;
.
setPlugins
(
[
makePlugin
(
)
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
expect
(
)
.
toHaveLength
(
1
)
;
expect
(
[
0
]
.
)
.
toEqual
(
)
;
expect
(
[
0
]
.
)
.
toBe
(
.
)
;
expect
(
[
0
]
.
)
.
toBe
(
'lint-rules'
)
;
}
)
;
}
)
;
describe
(
'instruction groupKeys and badges'
,
(
)
=>
{
it
(
'uses agent-instructions groupKey for copilot-instructions.md files'
,
async
(
)
=>
{
const
=
URI
.
file
(
'/workspace/.github/copilot-instructions.md'
)
;
.
setInstructions
(
[
makeInstruction
(
,
'copilot-instructions'
,
undefined
)
]
)
;
.
setAgentInstructionUris
(
[
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
const
=
.
filter
(
=>
.
===
.
)
;
expect
(
)
.
toHaveLength
(
1
)
;
expect
(
[
0
]
.
)
.
toBe
(
'agent-instructions'
)
;
expect
(
[
0
]
.
)
.
toBeUndefined
(
)
;
}
)
;
it
(
'emits agent instructions not in chatPromptFileService.instructions'
,
async
(
)
=>
{
const
=
URI
.
file
(
'/workspace/AGENTS.md'
)
;
const
=
URI
.
file
(
'/workspace/CLAUDE.md'
)
;
const
=
URI
.
file
(
'/workspace/.github/copilot-instructions.md'
)
;
.
setInstructions
(
[
]
)
;
.
setAgentInstructionUris
(
[
,
,
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
const
=
.
filter
(
=>
.
===
.
)
;
expect
(
)
.
toHaveLength
(
3
)
;
expect
(
.
every
(
=>
.
===
'agent-instructions'
)
)
.
toBe
(
true
)
;
expect
(
.
map
(
=>
.
)
)
.
toEqual
(
[
'AGENTS.md'
,
'CLAUDE.md'
,
'copilot-instructions.md'
]
)
;
}
)
;
it
(
'discovers AGENTS.md and CLAUDE.md from workspace roots via filesystem'
,
async
(
)
=>
{
const
=
URI
.
file
(
'/workspace'
)
;
const
=
URI
.
file
(
'/workspace/AGENTS.md'
)
;
const
=
URI
.
file
(
'/workspace/CLAUDE.md'
)
;
const
=
new
Set
(
[
.
toString
(
)
,
.
toString
(
)
]
)
;
const
=
.
add
(
new
CopilotCLICustomizationProvider
(
,
,
,
new
TestLogService
(
)
,
{
getWorkspaceFolders
:
(
)
=>
[
]
}
as
any
,
{
stat
:
(
:
URI
)
=>
.
has
(
.
toString
(
)
)
?
Promise
.
resolve
(
{
:
1
,
:
0
,
:
0
,
:
0
}
)
:
Promise
.
reject
(
new
Error
(
'not found'
)
)
,
}
as
any
,
{
:
URI
.
file
(
'/home/test'
)
}
as
any
,
)
)
;
.
setInstructions
(
[
]
)
;
.
setAgentInstructionUris
(
[
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
const
=
.
filter
(
=>
.
===
.
)
;
expect
(
)
.
toHaveLength
(
2
)
;
expect
(
.
every
(
=>
.
===
'agent-instructions'
)
)
.
toBe
(
true
)
;
expect
(
.
map
(
=>
.
)
)
.
toEqual
(
[
'AGENTS.md'
,
'CLAUDE.md'
]
)
;
}
)
;
it
(
'uses context-instructions groupKey with badge for instructions with applyTo pattern'
,
async
(
)
=>
{
const
=
URI
.
file
(
'/workspace/.github/style.instructions.md'
)
;
.
setInstructions
(
[
makeInstruction
(
,
'style instructions'
,
'src/**/*.ts'
)
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
const
=
.
filter
(
=>
.
===
.
)
;
expect
(
)
.
toHaveLength
(
1
)
;
expect
(
[
0
]
.
)
.
toBe
(
'context-instructions'
)
;
expect
(
[
0
]
.
)
.
toBe
(
'src/**/*.ts'
)
;
expect
(
[
0
]
.
)
.
toContain
(
'src/**/*.ts'
)
;
}
)
;
it
(
'uses "always added" badge when applyTo is **'
,
async
(
)
=>
{
const
=
URI
.
file
(
'/workspace/.github/global.instructions.md'
)
;
.
setInstructions
(
[
makeInstruction
(
,
'global instructions'
,
'**'
)
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
const
=
.
filter
(
=>
.
===
.
)
;
expect
(
)
.
toHaveLength
(
1
)
;
expect
(
[
0
]
.
)
.
toBe
(
'context-instructions'
)
;
expect
(
[
0
]
.
)
.
toBe
(
'always added'
)
;
expect
(
[
0
]
.
)
.
toContain
(
'every interaction'
)
;
}
)
;
it
(
'uses on-demand-instructions groupKey for instructions without applyTo'
,
async
(
)
=>
{
const
=
URI
.
file
(
'/workspace/.github/refactor.instructions.md'
)
;
.
setInstructions
(
[
makeInstruction
(
,
'refactor instructions'
,
undefined
,
'Refactoring guidelines'
)
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
const
=
.
filter
(
=>
.
===
.
)
;
expect
(
)
.
toHaveLength
(
1
)
;
expect
(
[
0
]
.
)
.
toBe
(
'on-demand-instructions'
)
;
expect
(
[
0
]
.
)
.
toBeUndefined
(
)
;
expect
(
[
0
]
.
)
.
toBe
(
'Refactoring guidelines'
)
;
}
)
;
it
(
'includes description from parsed header'
,
async
(
)
=>
{
const
=
URI
.
file
(
'/workspace/.github/testing.instructions.md'
)
;
.
setInstructions
(
[
makeInstruction
(
,
'testing instructions'
,
'**/*.spec.ts'
,
'Testing standards'
)
]
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
const
=
.
filter
(
=>
.
===
.
)
;
expect
(
)
.
toHaveLength
(
1
)
;
expect
(
[
0
]
.
)
.
toBe
(
'Testing standards'
)
;
expect
(
[
0
]
.
)
.
toBe
(
'**/*.spec.ts'
)
;
}
)
;
it
(
'categorizes mixed instructions correctly'
,
async
(
)
=>
{
const
=
URI
.
file
(
'/workspace/.github/copilot-instructions.md'
)
;
const
=
URI
.
file
(
'/workspace/.github/style.instructions.md'
)
;
const
=
URI
.
file
(
'/workspace/.github/refactor.instructions.md'
)
;
.
setInstructions
(
[
makeInstruction
(
,
'copilot instructions'
,
undefined
)
,
makeInstruction
(
,
'style instructions'
,
'src/**'
)
,
makeInstruction
(
,
'refactor instructions'
,
undefined
)
]
)
;
.
setAgentInstructionUris
(
[
]
)
;
.
setFileContent
(
,
'---\napplyTo: \'src/**\'\n---\nStyle rules.'
)
;
.
setFileContent
(
,
'---\ndescription: Refactoring\n---\nRefactor tips.'
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
const
=
.
filter
(
=>
.
===
.
)
;
expect
(
)
.
toHaveLength
(
3
)
;
const
=
.
find
(
=>
.
===
'agent-instructions'
)
;
const
=
.
find
(
=>
.
===
'context-instructions'
)
;
const
=
.
find
(
=>
.
===
'on-demand-instructions'
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
!
.
)
.
toBe
(
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
!
.
)
.
toBe
(
'src/**'
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
!
.
)
.
toBeUndefined
(
)
;
}
)
;
it
(
'falls back to on-demand-instructions when file has no YAML header'
,
async
(
)
=>
{
const
=
URI
.
file
(
'/workspace/.github/plain.instructions.md'
)
;
.
setInstructions
(
[
makeInstruction
(
,
'plain instructions'
,
undefined
)
]
)
;
.
setFileContent
(
,
'Just plain text, no frontmatter.'
)
;
const
=
await
.
provideChatSessionCustomizations
(
,
undefined
!
)
;
const
=
.
filter
(
=>
.
===
.
)
;
expect
(
)
.
toHaveLength
(
1
)
;
expect
(
[
0
]
.
)
.
toBe
(
'on-demand-instructions'
)
;
expect
(
[
0
]
.
)
.
toBeUndefined
(
)
;
}
)
;
}
)
;
describe
(
'onDidChange'
,
(
)
=>
{
it
(
'fires when custom agents change'
,
(
)
=>
{
let
=
false
;
.
add
(
.
onDidChange
(
(
)
=>
{
=
true
;
}
)
)
;
.
fireCustomAgentsChanged
(
)
;
expect
(
)
.
toBe
(
true
)
;
}
)
;
it
(
'fires when instructions change'
,
(
)
=>
{
let
=
false
;
.
add
(
.
onDidChange
(
(
)
=>
{
=
true
;
}
)
)
;
.
fireInstructionsChanged
(
)
;
expect
(
)
.
toBe
(
true
)
;
}
)
;
it
(
'fires when skills change'
,
(
)
=>
{
let
=
false
;
.
add
(
.
onDidChange
(
(
)
=>
{
=
true
;
}
)
)
;
.
fireSkillsChanged
(
)
;
expect
(
)
.
toBe
(
true
)
;
}
)
;
it
(
'fires when hooks change'
,
(
)
=>
{
let
=
false
;
.
add
(
.
onDidChange
(
(
)
=>
{
=
true
;
}
)
)
;
.
fireHooksChanged
(
)
;
expect
(
)
.
toBe
(
true
)
;
}
)
;
it
(
'fires when plugins change'
,
(
)
=>
{
let
=
false
;
.
add
(
.
onDidChange
(
(
)
=>
{
=
true
;
}
)
)
;
.
firePluginsChanged
(
)
;
expect
(
)
.
toBe
(
true
)
;
}
)
;
it
(
'fires when ICopilotCLIAgents agents change'
,
(
)
=>
{
let
=
false
;
.
add
(
.
onDidChange
(
(
)
=>
{
=
true
;
}
)
)
;
.
fireAgentsChanged
(
)
;
expect
(
)
.
toBe
(
true
)
;
}
)
;
}
)
;
}
)
;