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 / sessionCustomizationDiscovery.test.ts 1202 строк · изменён 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
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
import assert from 'assert' ;
import type { CopilotClient } from '@github/copilot-sdk' ;
import { DeferredPromise, raceTimeout, timeout } from '../../../../base/common/async.js' ;
import { VSBuffer } from '../../../../base/common/buffer.js' ;
import { CancellationToken, CancellationTokenSource } from '../../../../base/common/cancellation.js' ;
import { DisposableStore } from '../../../../base/common/lifecycle.js' ;
import { Schemas } from '../../../../base/common/network.js' ;
import
ensureNoDisposablesAreLeakedInTestSuite
FileService
IFileService
InMemoryFileSystemProvider
TestInstantiationService
ILogService NullLogService
IAgentPluginManager
DiscoveredType SessionCustomizationDiscovery
SessionPluginBundler
mapToParsedPlugin toDiscoveredDirectoryCustomizations
Parameters CopilotClient
disposables
fileService FileService
instantiationService TestInstantiationService
workspace
userHome
pluginBasePath
fileService disposables
memFs disposables
disposables fileService Schemas inMemory memFs
instantiationService disposables
instantiationService IFileService fileService
instantiationService ILogService
workspace scheme Schemas inMemory path
userHome scheme Schemas inMemory path
pluginBasePath scheme Schemas inMemory path
instantiationService IAgentPluginManager basePath pluginBasePath Partial IAgentPluginManager
disposables
path content
uri scheme Schemas inMemory path
fileService uri VSBuffer content
uri
path scheme Schemas inMemory path path
wsCopilotInstructions
wsGeminiInstructions
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
files discovery CancellationToken None
directory directory files file uri file uri type directory type
entry entry type DiscoveredType AgentInstruction
entry entry uri
a b a b
assert files
wsCopilotInstructions
wsGeminiInstructions
a b a b
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome inMemoryPathToUri
client
rpc
agents
agents
id name description path userInvocable
id name description path userInvocable
id name description path userInvocable
instructions sources
skills skills
CopilotClient
customizations discovery client CancellationToken None
agentDirectories customizations customization customization contents
uri uri path
assert agentDirectories length
assert agentDirectories customization customization uri
agentsInAgentsDir agentDirectories customization customization uri
assert agentsInAgentsDir
assert agentsInAgentsDir children child child uri
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome inMemoryPathToUri
client
rpc
agents
paths
agents
instructions
paths
sources
skills
paths
skills
CopilotClient
customizations discovery client CancellationToken None
hookDirectories customizations
customization customization contents
customization
uri customization uri path
children customization children child child uri path
a b a uri b uri
assert hookDirectories
uri children
uri children
uri children
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome inMemoryPathToUri
client
rpc
agents
paths
agents
instructions
paths
path kind
path kind
sources
id label sourcePath applyTo type
id label sourcePath applyTo type
skills
paths
skills
CopilotClient
customizations discovery client CancellationToken None
rules customizations
customization customization contents
customization customization children
child
uri child uri path
alwaysApply child type child alwaysApply
a b a uri b uri
assert rules
uri alwaysApply
uri alwaysApply
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome inMemoryPathToUri
client
rpc
agents
paths
agents
instructions
paths
path kind
path kind
sources
id label sourcePath applyTo type
id label sourcePath applyTo type
skills
paths
skills
CopilotClient
customizations discovery client CancellationToken None
ruleDirectories customizations
customization customization contents
customization
uri customization uri path
children customization children child child uri path
a b a uri b uri
assert ruleDirectories
uri children
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome inMemoryPathToUri
client
rpc
agents
paths path
agents
id name description path userInvocable
instructions
paths
path kind
path kind
path kind
path kind
sources
id label description sourcePath applyTo
skills
paths path
skills
name description path
CopilotClient
customizations discovery client CancellationToken None
directories customizations
customization
contents customization contents
uri customization uri path
writable customization writable
children customization children child child uri path
a b a uri b uri
assert directories
contents uri writable children
contents uri writable children
contents uri writable children
contents uri writable children
contents uri writable children
contents uri writable children
contents uri writable children
contents uri writable children
caseVariantUserHome scheme Schemas inMemory path
discovery disposables instantiationService SessionCustomizationDiscovery workspace caseVariantUserHome inMemoryPathToUri
client
rpc
agents
paths
agents
instructions
paths path kind
sources id label sourcePath type
skills
paths
path
path
skills name description path
CopilotClient
customizations discovery client CancellationToken None
directories customizations
customization customization contents customization contents
customization
contents customization contents
uri customization uri path
children customization children child child uri path
assert directories
contents uri children
contents uri children
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
directories discovery CancellationToken None
actual directories directory
expected actual a b a b a b
assert actual expected
directory directories
actualFiles directory files file file uri
expectedFiles actualFiles a b a b a b
assert actualFiles expectedFiles
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
files discovery CancellationToken None
directory directory files file uri file uri type directory type
entry entry type DiscoveredType AgentInstruction
entry entry uri
a b a b
assert files
scheme Schemas inMemory path
watchCalls resource recursive
originalWatch fileService fileService
disposables fileService watch originalWatch fileService watch
fileService watch resource options
watchCalls resource resource recursive options recursive
resource options
fileService watch
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
discovery CancellationToken None
watched
call watchCalls
previous watched call resource
watched call resource previous call recursive
assert watched workspace
assert watched workspace
assert watched workspace
assert watched workspace
assert watched workspace
assert watched workspace
assert watched workspace
assert watched userHome
assert watched userHome
assert watched userHome
assert watched userHome
assert watched userHome
assert watched userHome
watchCalls
watchDisposeCalls
originalWatch fileService fileService
disposables fileService watch originalWatch fileService watch
fileService watch resource options
watchCalls resource
disposable resource options
watchDisposeCalls
disposable
fileService watch
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
discovery CancellationToken None
watchCallsAfterFirstScan watchCalls length
discovery CancellationToken None
assert watchCalls length watchCallsAfterFirstScan
assert watchDisposeCalls
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
discovery CancellationToken None
changeCount
fired
disposables discovery
changeCount
fired
fired p
assert changeCount
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
discovery CancellationToken None
changeCount
fired
disposables discovery
changeCount
fired
fired p
assert changeCount
agentUri
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
discovery CancellationToken None
changeCount
fired
disposables discovery
changeCount
fired
fileService agentUri
fired p
assert changeCount
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
discovery CancellationToken None
changeCount
fired
disposables discovery
changeCount
fired
fired p
assert changeCount
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
discovery CancellationToken None
changeCount
disposables discovery
changeCount
assert changeCount
fileService scheme Schemas inMemory path
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome inMemoryPathToUri
client
rpc
agents
paths
agents
instructions
paths
sources
skills
paths path
skills
CopilotClient
discovery client CancellationToken None
changeCount
fired
disposables discovery
changeCount
fired
fired p
assert changeCount
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
cancelSource
disposables cancelSource
cancelled discovery cancelSource token
nonCancelled discovery CancellationToken None
cancelSource
assert cancelled
directories nonCancelled
assert directories directory directory type DiscoveredType Agent
wsAgent
wsSkill
wsInstr
wsHook
userAgent
userCopilotSkill
userSkill
userHook
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
directories discovery CancellationToken None
files directories directory directory files file uri file uri type directory type
assert files a b a uri b uri
uri userAgent type DiscoveredType Agent
uri userCopilotSkill type DiscoveredType Skill
uri userHook type DiscoveredType Hook
uri userSkill type DiscoveredType Skill
uri wsAgent type DiscoveredType Agent
uri wsHook type DiscoveredType Hook
uri wsInstr type DiscoveredType Instruction
uri wsSkill type DiscoveredType Skill
a b a uri b uri
assert directories directory directory uri workspace
nestedWsHook
nestedUserHook
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
files discovery CancellationToken None directory directory files file uri file uri type directory type
assert files a b a uri b uri
uri nestedUserHook type DiscoveredType Hook
uri nestedWsHook type DiscoveredType Hook
a b a uri b uri
githubSettings
githubLocalSettings
claudeSettings
claudeLocalSettings
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
files discovery CancellationToken None directory directory files file uri file uri type directory type
assert files a b a uri b uri
uri claudeLocalSettings type DiscoveredType Hook
uri claudeSettings type DiscoveredType Hook
uri githubLocalSettings type DiscoveredType Hook
uri githubSettings type DiscoveredType Hook
a b a uri b uri
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
discovery CancellationToken None
changeCount
fired
disposables discovery
changeCount
fired
fired p
assert changeCount
wsAgent
wsPlainAgent
wsLowerReadmeAgent
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
files discovery CancellationToken None directory directory files file uri file uri type directory type
assert files a b a uri b uri
uri wsAgent type DiscoveredType Agent
uri wsLowerReadmeAgent type DiscoveredType Agent
uri wsPlainAgent type DiscoveredType Agent
a b a uri b uri
wsAgent
wsLegacyMode
wsPrompt
wsInstruction
wsCopilotInstructions
wsSkill
wsSkillLowercase
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
files discovery CancellationToken None directory directory files file uri file uri type directory type
assert files a b a uri b uri
uri wsCopilotInstructions type DiscoveredType Agent
uri wsAgent type DiscoveredType Agent
uri wsInstruction type DiscoveredType Agent
uri wsLegacyMode type DiscoveredType Agent
uri wsPrompt type DiscoveredType Agent
uri wsSkill type DiscoveredType Agent
uri wsSkillLowercase type DiscoveredType Agent
a b a uri b uri
nestedWsInstr
nestedUserInstr
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
files discovery CancellationToken None directory directory files file uri file uri type directory type
assert files a b a uri b uri
uri nestedUserInstr type DiscoveredType Instruction
uri nestedWsInstr type DiscoveredType Instruction
a b a uri b uri
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
bundler disposables instantiationService SessionPluginBundler workspace
result bundler discovery CancellationToken None
assert result
root bundler rootUri
workspaceInstr fileService root
assert workspaceInstr value
userInstr fileService root
assert userInstr value
fileService workspace
fileService userHome
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
directories discovery CancellationToken None
assert directories
directories length
dir directories
assert dir files length
bundler disposables instantiationService SessionPluginBundler workspace
bundler directories
agent
skill
instruction
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
customizations discovery CancellationToken None fileService
plugin customizations
assert plugin
assert plugin agents length
assert plugin skills length
assert plugin instructions length
assert
agentUri plugin agents uri
agentDescription plugin agents description
skillUri plugin skills uri
skillDescription plugin skills description
ruleUri plugin instructions uri
ruleDescription plugin instructions description
agentUri agent
agentDescription
skillUri skill
skillDescription
ruleUri instruction
ruleDescription
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
customizations discovery CancellationToken None fileService
plugin customizations
assert plugin
assert plugin skills length
assert plugin instructions length
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
customizations discovery CancellationToken None fileService
plugin customizations
assert plugin
secondWorkspace scheme Schemas inMemory path
first
second
discovery disposables instantiationService SessionCustomizationDiscovery workspace secondWorkspace userHome file
files discovery CancellationToken None
directory directory type DiscoveredType AgentInstruction
directory directory files file file uri
a b a b
assert files first second a b a b
assert
instantiationService SessionCustomizationDiscovery userHome file
secondWorkspace scheme Schemas inMemory path
primaryHook
discovery disposables instantiationService SessionCustomizationDiscovery workspace secondWorkspace userHome file
hookFiles discovery CancellationToken None
directory directory type DiscoveredType Hook
directory directory files file file uri
a b a b
assert hookFiles primaryHook
secondWorkspace scheme Schemas inMemory path
discovery disposables instantiationService SessionCustomizationDiscovery workspace secondWorkspace userHome inMemoryPathToUri
client
rpc
agents paths agents
instructions paths sources
skills paths skills
CopilotClient
hookChildren discovery client CancellationToken None
customization customization contents
customization customization children child child uri path
assert hookChildren
secondWorkspace scheme Schemas inMemory path
firstFile
secondFile
requestedProjectPaths
discovery disposables instantiationService SessionCustomizationDiscovery workspace secondWorkspace userHome inMemoryPathToUri
client
rpc
agents paths agents
instructions
paths
path kind
path kind
request AgentsDiscoverRequest
requestedProjectPaths request projectPaths
sources
id label sourcePath applyTo type projectPath workspace fsPath
id label sourcePath applyTo type projectPath secondWorkspace fsPath
skills paths skills
CopilotClient
customizations discovery client CancellationToken None
ruleDirectories customizations
customization customization contents
customization
uri customization uri
children customization children child child uri
a b a uri b uri
assert requestedProjectPaths ruleDirectories
requestedProjectPaths workspace fsPath secondWorkspace fsPath
ruleDirectories
uri workspace children firstFile
uri secondWorkspace children secondFile
a b a uri b uri
secondWorkspace scheme Schemas inMemory path
agentProjectPaths
discovery disposables instantiationService SessionCustomizationDiscovery workspace secondWorkspace userHome inMemoryPathToUri
client
rpc
agents
paths
request AgentsDiscoverRequest
agentProjectPaths request projectPaths
agents
id name description path userInvocable
id name description path userInvocable
instructions paths sources
skills
paths
skills
path name description
path name description
CopilotClient
customizations discovery client CancellationToken None
childUris customizations
customization customization children child child uri path
assert agentProjectPaths childUris
agentProjectPaths workspace fsPath secondWorkspace fsPath
childUris
disposables
fileService FileService
instantiationService TestInstantiationService
workspace
userHome
pluginBasePath
fileService disposables
memFs disposables
disposables fileService Schemas inMemory memFs
instantiationService disposables
instantiationService IFileService fileService
instantiationService ILogService
workspace scheme Schemas inMemory path
userHome scheme Schemas inMemory path
pluginBasePath scheme Schemas inMemory path
instantiationService IAgentPluginManager basePath pluginBasePath Partial IAgentPluginManager
disposables
path content
uri scheme Schemas inMemory path
fileService uri VSBuffer content
uri
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
bundler disposables instantiationService SessionPluginBundler workspace
directories discovery CancellationToken None
result bundler directories
assert result
assert result ref name
assert result ref nonce
root bundler rootUri
manifest fileService root
assert manifest value
agent fileService root
assert agent value
skill fileService root
assert skill value
instr fileService root
assert instr value
hook fileService root
assert hook value
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
bundler disposables instantiationService SessionPluginBundler workspace
first bundler discovery CancellationToken None
writeCalls
deleteCalls
originalWriteFile fileService fileService
originalDel fileService fileService
disposables
fileService writeFile originalWriteFile fileService writeFile
fileService del originalDel fileService del
fileService writeFile args Parameters fileService writeFile
writeCalls
args
fileService writeFile
fileService del args Parameters fileService del
deleteCalls
args
fileService del
second bundler discovery CancellationToken None
assert first
assert second
assert
firstNonce first ref nonce
secondNonce second ref nonce
writeCalls
deleteCalls
firstNonce first ref nonce
secondNonce first ref nonce
writeCalls
deleteCalls
discovery disposables instantiationService SessionCustomizationDiscovery workspace userHome file
bundler disposables instantiationService SessionPluginBundler workspace
writeCalls
deleteCalls
originalWriteFile fileService fileService
originalDel fileService fileService
disposables
fileService writeFile originalWriteFile fileService writeFile
fileService del originalDel fileService del
fileService writeFile args Parameters fileService writeFile
writeCalls
args
fileService writeFile
fileService del args Parameters fileService del
deleteCalls
args
fileService del
result bundler discovery CancellationToken None CancellationToken Cancelled
assert result writeCalls deleteCalls result writeCalls deleteCalls
otherWorkspace scheme Schemas inMemory path
a disposables instantiationService SessionPluginBundler workspace
b disposables instantiationService SessionPluginBundler otherWorkspace
assert a rootUri b rootUri
{
URI
}
from
'../../../../base/common/uri.js'
;
import
{
}
from
'../../../../base/test/common/utils.js'
;
import
{
}
from
'../../../files/common/fileService.js'
;
import
{
}
from
'../../../files/common/files.js'
;
import
{
}
from
'../../../files/common/inMemoryFilesystemProvider.js'
;
import
{
}
from
'../../../instantiation/test/common/instantiationServiceMock.js'
;
import
{
,
}
from
'../../../log/common/log.js'
;
import
{
}
from
'../../common/agentPluginManager.js'
;
import
{
,
}
from
'../../node/copilot/sessionCustomizationDiscovery.js'
;
import
{
}
from
'../../node/shared/sessionPluginBundler.js'
;
import
{
,
}
from
'../../node/copilot/copilotAgent.js'
;
type
AgentsDiscoverRequest
=
<
[
'rpc'
]
[
'agents'
]
[
'discover'
]
>
[
0
]
;
suite
(
'SessionCustomizationDiscovery'
,
(
)
=>
{
const
=
new
DisposableStore
(
)
;
let
:
;
let
:
;
let
:
URI
;
let
:
URI
;
let
:
URI
;
setup
(
(
)
=>
{
=
.
add
(
new
FileService
(
new
NullLogService
(
)
)
)
;
const
=
.
add
(
new
InMemoryFileSystemProvider
(
)
)
;
.
add
(
.
registerProvider
(
.
,
)
)
;
=
.
add
(
new
TestInstantiationService
(
)
)
;
.
stub
(
,
)
;
.
stub
(
,
new
NullLogService
(
)
)
;
=
URI
.
from
(
{
:
.
,
:
'/workspace'
}
)
;
=
URI
.
from
(
{
:
.
,
:
'/home'
}
)
;
=
URI
.
from
(
{
:
.
,
:
'/agentPlugins'
}
)
;
.
stub
(
,
{
:
}
as
<
>
)
;
}
)
;
teardown
(
(
)
=>
{
.
clear
(
)
;
}
)
;
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
async
function
seed
(
:
string
,
=
''
)
:
Promise
<
URI
>
{
const
=
URI
.
from
(
{
:
.
,
}
)
;
await
.
writeFile
(
,
.
fromString
(
)
)
;
return
;
}
const
inMemoryPathToUri
=
(
:
string
)
=>
URI
.
from
(
{
:
.
,
:
.
replace
(
/ \\ / g
,
'/'
)
}
)
;
test
(
'discovers supported agent instruction files in workspace roots'
,
async
(
)
=>
{
const
=
await
seed
(
'/workspace/.github/copilot-instructions.md'
,
'workspace copilot instructions'
)
;
const
=
await
seed
(
'/workspace/GEMINI.md'
,
'workspace gemini instructions'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
const
=
(
await
.
scan
(
.
)
)
.
flatMap
(
=>
.
.
map
(
=>
(
{
:
.
,
:
.
}
)
)
)
.
filter
(
=>
.
===
.
)
.
map
(
=>
.
.
toString
(
)
)
.
sort
(
(
,
)
=>
.
localeCompare
(
)
)
;
.
deepStrictEqual
(
,
[
.
toString
(
)
,
.
toString
(
)
,
]
.
sort
(
(
,
)
=>
.
localeCompare
(
)
)
)
;
}
)
;
test
(
'groups discovered customizations by parent folder'
,
async
(
)
=>
{
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
)
)
;
const
=
{
:
{
:
{
discover
:
async
(
)
=>
(
{
:
[
{
:
'one'
,
:
'One'
,
:
''
,
:
'/workspace/.github/agents/one.agent.md'
,
:
false
}
,
{
:
'two'
,
:
'Two'
,
:
''
,
:
'/workspace/.github/agents/two.agent.md'
,
:
true
}
,
{
:
'three'
,
:
'Three'
,
:
''
,
:
'/workspace/.github/other/three.agent.md'
,
:
false
}
,
]
,
}
)
,
}
,
:
{
discover
:
async
(
)
=>
(
{
:
[
]
}
)
}
,
:
{
discover
:
async
(
)
=>
(
{
:
[
]
}
)
}
,
}
,
}
as
unknown
as
;
const
=
await
.
discover
(
,
.
)
;
const
=
.
filter
(
=>
.
===
'agent'
)
;
const
getPath
=
(
:
string
)
=>
URI
.
parse
(
)
.
;
.
strictEqual
(
.
,
2
)
;
.
deepStrictEqual
(
.
map
(
=>
getPath
(
.
)
)
.
sort
(
)
,
[
'/workspace/.github/agents'
,
'/workspace/.github/other'
,
]
)
;
const
=
.
find
(
=>
getPath
(
.
)
===
'/workspace/.github/agents'
)
;
.
ok
(
)
;
.
deepStrictEqual
(
.
?.
map
(
=>
getPath
(
.
)
)
.
sort
(
)
,
[
'/workspace/.github/agents/one.agent.md'
,
'/workspace/.github/agents/two.agent.md'
,
]
)
;
}
)
;
test
(
'discover includes hooks from recursive and fixed hook locations'
,
async
(
)
=>
{
await
seed
(
'/workspace/.github/hooks/pre-tool.json'
,
'{"PreToolUse": []}'
)
;
await
seed
(
'/workspace/.github/copilot/settings.json'
,
'{"hooks": {"PreToolUse": []}}'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
)
)
;
const
=
{
:
{
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
]
}
)
,
}
,
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
]
}
)
,
}
,
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
]
}
)
,
}
,
}
,
}
as
unknown
as
;
const
=
await
.
discover
(
,
.
)
;
const
=
.
filter
(
=>
.
===
'hook'
)
.
map
(
=>
(
{
:
URI
.
parse
(
.
)
.
,
:
(
.
??
[
]
)
.
map
(
=>
URI
.
parse
(
.
)
.
)
.
sort
(
)
,
}
)
)
.
sort
(
(
,
)
=>
.
.
localeCompare
(
.
)
)
;
.
deepStrictEqual
(
,
[
{
:
'/home/.copilot/hooks'
,
:
[
]
}
,
{
:
'/workspace/.github/copilot'
,
:
[
'/workspace/.github/copilot/settings.json'
]
}
,
{
:
'/workspace/.github/hooks'
,
:
[
'/workspace/.github/hooks/pre-tool.json'
]
}
,
]
)
;
}
)
;
test
(
'marks agent instruction rule sources as always apply'
,
async
(
)
=>
{
await
seed
(
'/workspace/AGENTS.md'
,
'workspace agents instructions'
)
;
await
seed
(
'/workspace/.github/instructions/rule.instructions.md'
,
'scoped instruction'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
)
)
;
const
=
{
:
{
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
]
}
)
,
}
,
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
{
:
'/workspace/.github/instructions'
,
:
'directory'
}
,
{
:
'/workspace/AGENTS.md'
,
:
'file'
}
,
]
,
}
)
,
discover
:
async
(
)
=>
(
{
:
[
{
:
'agentInstruction'
,
:
'AGENTS.md'
,
:
'/workspace/AGENTS.md'
,
:
[
]
,
:
'repo'
}
,
{
:
'scopedInstruction'
,
:
'Rule'
,
:
'/workspace/.github/instructions/rule.instructions.md'
,
:
[
'src/**'
]
,
:
'child-instructions'
}
,
]
,
}
)
,
}
,
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
]
}
)
,
}
,
}
,
}
as
unknown
as
;
const
=
await
.
discover
(
,
.
)
;
const
=
.
filter
(
=>
.
===
'rule'
)
.
flatMap
(
=>
.
??
[
]
)
.
map
(
=>
(
{
:
URI
.
parse
(
.
)
.
,
:
.
===
'rule'
?
.
:
undefined
,
}
)
)
.
sort
(
(
,
)
=>
.
.
localeCompare
(
.
)
)
;
.
deepStrictEqual
(
,
[
{
:
'/workspace/.github/instructions/rule.instructions.md'
,
:
false
}
,
{
:
'/workspace/AGENTS.md'
,
:
true
}
,
]
)
;
}
)
;
test
(
'drops missing agent instruction files and empty agent instruction directories'
,
async
(
)
=>
{
await
seed
(
'/workspace/.github/instructions/rule.instructions.md'
,
'scoped instruction'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
)
)
;
const
=
{
:
{
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
]
}
)
,
}
,
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
{
:
'/workspace/.github/instructions'
,
:
'directory'
}
,
{
:
'/workspace/AGENTS.md'
,
:
'file'
}
,
]
,
}
)
,
discover
:
async
(
)
=>
(
{
:
[
{
:
'agentInstruction'
,
:
'AGENTS.md'
,
:
'/workspace/AGENTS.md'
,
:
[
]
,
:
'repo'
}
,
{
:
'scopedInstruction'
,
:
'Rule'
,
:
'/workspace/.github/instructions/rule.instructions.md'
,
:
[
'src/**'
]
,
:
'child-instructions'
}
,
]
,
}
)
,
}
,
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
]
}
)
,
}
,
}
,
}
as
unknown
as
;
const
=
await
.
discover
(
,
.
)
;
const
=
.
filter
(
=>
.
===
'rule'
)
.
map
(
=>
(
{
:
URI
.
parse
(
.
)
.
,
:
(
.
??
[
]
)
.
map
(
=>
URI
.
parse
(
.
)
.
)
.
sort
(
)
,
}
)
)
.
sort
(
(
,
)
=>
.
.
localeCompare
(
.
)
)
;
.
deepStrictEqual
(
,
[
{
:
'/workspace/.github/instructions'
,
:
[
'/workspace/.github/instructions/rule.instructions.md'
]
}
,
]
)
;
}
)
;
test
(
'discover returns working-directory agents, skills, instructions, hooks, and agent instructions'
,
async
(
)
=>
{
await
seed
(
'/workspace/.github/agents/foo.agent.md'
,
'agent body'
)
;
await
seed
(
'/workspace/.github/skills/bar/SKILL.md'
,
'skill body'
)
;
await
seed
(
'/workspace/.github/instructions/baz.instructions.md'
,
'instruction body'
)
;
await
seed
(
'/workspace/.github/hooks/pre-tool.json'
,
'{"PreToolUse": []}'
)
;
await
seed
(
'/workspace/.github/copilot/settings.json'
,
'{"hooks": {"PreToolUse": []}}'
)
;
await
seed
(
'/workspace/.github/copilot-instructions.md'
,
'workspace copilot instructions'
)
;
await
seed
(
'/workspace/AGENTS.md'
,
'workspace agents instructions'
)
;
await
seed
(
'/home/.copilot/copilot-instructions.md'
,
'user copilot instructions'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
)
)
;
const
=
{
:
{
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
{
:
'/workspace/.github/agents'
}
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
{
:
'agent'
,
:
'Agent'
,
:
'agent description'
,
:
'/workspace/.github/agents/foo.agent.md'
,
:
true
}
,
]
,
}
)
,
}
,
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
{
:
'/workspace/.github/instructions'
,
:
'directory'
}
,
{
:
'/workspace/.github/copilot-instructions.md'
,
:
'file'
}
,
{
:
'/workspace/AGENTS.md'
,
:
'file'
}
,
{
:
'/home/.copilot/copilot-instructions.md'
,
:
'file'
}
,
]
,
}
)
,
discover
:
async
(
)
=>
(
{
:
[
{
:
'rule'
,
:
'Rule'
,
:
'rule description'
,
:
'/workspace/.github/instructions/baz.instructions.md'
,
:
[
]
}
,
]
,
}
)
,
}
,
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
{
:
'/workspace/.github/skills'
}
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
{
:
'Skill'
,
:
'skill description'
,
:
'/workspace/.github/skills/bar/SKILL.md'
}
,
]
,
}
)
,
}
,
}
,
}
as
unknown
as
;
const
=
await
.
discover
(
,
.
)
;
const
=
.
map
(
=>
(
{
:
.
,
:
URI
.
parse
(
.
)
.
,
:
.
,
:
(
.
??
[
]
)
.
map
(
=>
URI
.
parse
(
.
)
.
)
.
sort
(
)
,
}
)
)
.
sort
(
(
,
)
=>
.
.
localeCompare
(
.
)
)
;
.
deepStrictEqual
(
,
[
{
:
'rule'
,
:
'/home'
,
:
false
,
:
[
'/home/.copilot/copilot-instructions.md'
]
}
,
{
:
'hook'
,
:
'/home/.copilot/hooks'
,
:
true
,
:
[
]
}
,
{
:
'rule'
,
:
'/workspace'
,
:
false
,
:
[
'/workspace/.github/copilot-instructions.md'
,
'/workspace/AGENTS.md'
]
}
,
{
:
'agent'
,
:
'/workspace/.github/agents'
,
:
true
,
:
[
'/workspace/.github/agents/foo.agent.md'
]
}
,
{
:
'hook'
,
:
'/workspace/.github/copilot'
,
:
true
,
:
[
'/workspace/.github/copilot/settings.json'
]
}
,
{
:
'hook'
,
:
'/workspace/.github/hooks'
,
:
true
,
:
[
'/workspace/.github/hooks/pre-tool.json'
]
}
,
{
:
'rule'
,
:
'/workspace/.github/instructions'
,
:
true
,
:
[
'/workspace/.github/instructions/baz.instructions.md'
]
}
,
{
:
'skill'
,
:
'/workspace/.github/skills'
,
:
true
,
:
[
'/workspace/.github/skills/bar/SKILL.md'
]
}
,
]
)
;
}
)
;
test
(
'discover groups case-variant instructions and nested skills under their roots'
,
async
(
)
=>
{
const
=
URI
.
from
(
{
:
.
,
:
'/HOME'
}
)
;
await
seed
(
'/home/.copilot/copilot-instructions.md'
,
'user copilot instructions'
)
;
await
seed
(
'/workspace/.github/skills/bar/SKILL.md'
,
'skill body'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
)
)
;
const
=
{
:
{
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
]
}
)
,
}
,
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
{
:
'/home/.copilot/copilot-instructions.md'
,
:
'file'
}
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
{
:
'userInstruction'
,
:
'User instruction'
,
:
'/home/.copilot/copilot-instructions.md'
,
:
'home'
}
]
}
)
,
}
,
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
{
:
'/workspace/.github/skills'
}
,
{
:
'/workspace/.github/skills/bar'
}
,
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
{
:
'Skill'
,
:
'skill description'
,
:
'/workspace/.github/skills/bar/SKILL.md'
}
]
}
)
,
}
,
}
,
}
as
unknown
as
;
const
=
await
.
discover
(
,
.
)
;
const
=
.
filter
(
=>
.
===
'rule'
||
.
===
'skill'
)
.
map
(
=>
(
{
:
.
,
:
URI
.
parse
(
.
)
.
,
:
(
.
??
[
]
)
.
map
(
=>
URI
.
parse
(
.
)
.
)
,
}
)
)
;
.
deepStrictEqual
(
,
[
{
:
'rule'
,
:
'/HOME'
,
:
[
'/home/.copilot/copilot-instructions.md'
]
}
,
{
:
'skill'
,
:
'/workspace/.github/skills'
,
:
[
'/workspace/.github/skills/bar/SKILL.md'
]
}
,
]
)
;
}
)
;
test
(
'returns directories sorted by type and URI'
,
async
(
)
=>
{
await
seed
(
'/workspace/.github/agents/aaa.agent.md'
,
'workspace agent a'
)
;
await
seed
(
'/workspace/.github/agents/foo.agent.md'
,
'workspace agent'
)
;
await
seed
(
'/workspace/.github/skills/alpha/SKILL.md'
,
'workspace skill alpha'
)
;
await
seed
(
'/workspace/.github/skills/bar/SKILL.md'
,
'workspace skill'
)
;
await
seed
(
'/workspace/.github/instructions/alpha.instructions.md'
,
'workspace instruction alpha'
)
;
await
seed
(
'/workspace/.github/instructions/baz.instructions.md'
,
'workspace instruction'
)
;
await
seed
(
'/workspace/.github/copilot-instructions.md'
,
'workspace copilot instructions'
)
;
await
seed
(
'/home/.copilot/agents/abc.agent.md'
,
'user agent abc'
)
;
await
seed
(
'/home/.copilot/agents/qux.agent.md'
,
'user agent'
)
;
await
seed
(
'/home/.copilot/skills/alpha/SKILL.md'
,
'user copilot skill'
)
;
await
seed
(
'/home/.agents/skills/aaa/SKILL.md'
,
'user skill aaa'
)
;
await
seed
(
'/home/.agents/skills/zap/SKILL.md'
,
'user skill'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
const
=
await
.
scan
(
.
)
;
const
=
.
map
(
=>
` ${ directory. type } : ${ directory. uri. toString ( ) } `
)
;
const
=
[
...
]
.
sort
(
(
,
)
=>
<
?
-
1
:
>
?
1
:
0
)
;
.
deepStrictEqual
(
,
)
;
for
(
const
of
)
{
const
=
.
.
map
(
=>
.
.
toString
(
)
)
;
const
=
[
...
]
.
sort
(
(
,
)
=>
<
?
-
1
:
>
?
1
:
0
)
;
.
deepStrictEqual
(
,
)
;
}
}
)
;
test
(
'does not discover agent instruction files outside supported roots'
,
async
(
)
=>
{
await
seed
(
'/workspace/.github/copilot-instructions.md'
,
'workspace copilot instructions'
)
;
await
seed
(
'/workspace/docs/AGENTS.md'
,
'unsupported root'
)
;
await
seed
(
'/workspace/.claude/GEMINI.md'
,
'unsupported filename in .claude'
)
;
await
seed
(
'/home/copilot-instructions.md'
,
'unsupported home root'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
const
=
(
await
.
scan
(
.
)
)
.
flatMap
(
=>
.
.
map
(
=>
(
{
:
.
,
:
.
}
)
)
)
.
filter
(
=>
.
===
.
)
.
map
(
=>
.
.
toString
(
)
)
.
sort
(
(
,
)
=>
.
localeCompare
(
)
)
;
.
deepStrictEqual
(
,
[
URI
.
from
(
{
:
.
,
:
'/workspace/.github/copilot-instructions.md'
}
)
.
toString
(
)
,
]
)
;
}
)
;
test
(
'installs watchers for roots that contain discovered customizations'
,
async
(
)
=>
{
await
seed
(
'/workspace/.github/agents/foo.agent.md'
,
'workspace agent'
)
;
await
seed
(
'/workspace/.github/skills/bar/SKILL.md'
,
'workspace skill'
)
;
await
seed
(
'/workspace/.github/instructions/rules.instructions.md'
,
'workspace instruction'
)
;
await
seed
(
'/workspace/.github/hooks/pre-tool.json'
,
'{"PreToolUse": []}'
)
;
await
seed
(
'/workspace/.github/copilot-instructions.md'
,
'workspace copilot instructions'
)
;
await
seed
(
'/workspace/.claude/CLAUDE.md'
,
'workspace claude instruction'
)
;
await
seed
(
'/home/.copilot/agents/user.agent.md'
,
'user agent'
)
;
await
seed
(
'/home/.copilot/skills/copilot-user-skill/SKILL.md'
,
'user copilot skill'
)
;
await
seed
(
'/home/.agents/skills/user-skill/SKILL.md'
,
'user skill'
)
;
await
seed
(
'/home/.copilot/instructions/user.instructions.md'
,
'user instruction'
)
;
await
seed
(
'/home/.copilot/hooks/post-tool.json'
,
'{"PostToolUse": []}'
)
;
await
seed
(
'/home/.copilot/copilot-instructions.md'
,
'user copilot instructions'
)
;
const
:
Array
<
{
:
string
;
:
boolean
}
>
=
[
]
;
const
=
.
watch
.
bind
(
)
;
.
add
(
{
dispose
:
(
)
=>
{
.
=
as
typeof
.
;
}
}
)
;
.
=
(
(
,
)
=>
{
.
push
(
{
:
.
toString
(
)
,
:
?.
===
true
}
)
;
return
originalWatch
(
,
)
;
}
)
as
typeof
.
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
await
.
scan
(
.
)
;
const
=
new
Map< string , boolean >
(
)
;
for
(
const
of
)
{
const
=
.
get
(
.
)
;
.
set
(
.
,
===
true
||
.
)
;
}
.
strictEqual
(
.
get
(
.
toString
(
)
)
,
false
)
;
.
strictEqual
(
.
get
(
URI
.
joinPath
(
,
'.github'
)
.
toString
(
)
)
,
false
)
;
.
strictEqual
(
.
get
(
URI
.
joinPath
(
,
'.claude'
)
.
toString
(
)
)
,
false
)
;
.
strictEqual
(
.
get
(
URI
.
joinPath
(
,
'.github'
,
'agents'
)
.
toString
(
)
)
,
false
)
;
.
strictEqual
(
.
get
(
URI
.
joinPath
(
,
'.github'
,
'skills'
)
.
toString
(
)
)
,
true
)
;
.
strictEqual
(
.
get
(
URI
.
joinPath
(
,
'.github'
,
'instructions'
)
.
toString
(
)
)
,
true
)
;
.
strictEqual
(
.
get
(
URI
.
joinPath
(
,
'.github'
,
'hooks'
)
.
toString
(
)
)
,
true
)
;
.
strictEqual
(
.
get
(
URI
.
joinPath
(
,
'.copilot'
)
.
toString
(
)
)
,
false
)
;
.
strictEqual
(
.
get
(
URI
.
joinPath
(
,
'.copilot'
,
'agents'
)
.
toString
(
)
)
,
false
)
;
.
strictEqual
(
.
get
(
URI
.
joinPath
(
,
'.copilot'
,
'skills'
)
.
toString
(
)
)
,
true
)
;
.
strictEqual
(
.
get
(
URI
.
joinPath
(
,
'.agents'
,
'skills'
)
.
toString
(
)
)
,
true
)
;
.
strictEqual
(
.
get
(
URI
.
joinPath
(
,
'.copilot'
,
'instructions'
)
.
toString
(
)
)
,
true
)
;
.
strictEqual
(
.
get
(
URI
.
joinPath
(
,
'.copilot'
,
'hooks'
)
.
toString
(
)
)
,
true
)
;
}
)
;
test
(
'refresh keeps existing watchers when discovered roots are unchanged'
,
async
(
)
=>
{
await
seed
(
'/workspace/.github/agents/foo.agent.md'
,
'workspace agent'
)
;
const
:
string
[
]
=
[
]
;
let
=
0
;
const
=
.
watch
.
bind
(
)
;
.
add
(
{
dispose
:
(
)
=>
{
.
=
as
typeof
.
;
}
}
)
;
.
=
(
(
,
)
=>
{
.
push
(
.
toString
(
)
)
;
const
=
originalWatch
(
,
)
;
return
{
dispose
:
(
)
=>
{
++
;
.
dispose
(
)
;
}
}
;
}
)
as
typeof
.
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
await
.
scan
(
.
)
;
const
=
.
;
await
.
scan
(
.
)
;
.
strictEqual
(
.
,
,
'expected no new watch registrations for unchanged roots'
)
;
.
strictEqual
(
,
0
,
'expected existing watchers to remain active for unchanged roots'
)
;
}
)
;
test
(
'fires onDidChange when a new agent file is added under a non-recursively watched root'
,
async
(
)
=>
{
await
seed
(
'/workspace/.github/agents/foo.agent.md'
,
'workspace agent'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
await
.
scan
(
.
)
;
await
timeout
(
50
)
;
let
=
0
;
const
=
new
DeferredPromise< void >
(
)
;
.
add
(
.
onDidChange
(
(
)
=>
{
++
;
.
complete
(
)
;
}
)
)
;
await
seed
(
'/workspace/.github/agents/bar.agent.md'
,
'new workspace agent'
)
;
await
raceTimeout
(
.
,
500
)
;
.
strictEqual
(
,
1
,
'expected onDidChange to fire for a new agent file inside the watched directory'
)
;
}
)
;
test
(
'fires onDidChange when an existing agent file is modified under a non-recursively watched root'
,
async
(
)
=>
{
await
seed
(
'/workspace/.github/agents/foo.agent.md'
,
'workspace agent'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
await
.
scan
(
.
)
;
await
timeout
(
50
)
;
let
=
0
;
const
=
new
DeferredPromise< void >
(
)
;
.
add
(
.
onDidChange
(
(
)
=>
{
++
;
.
complete
(
)
;
}
)
)
;
await
seed
(
'/workspace/.github/agents/foo.agent.md'
,
'workspace agent (updated)'
)
;
await
raceTimeout
(
.
,
500
)
;
.
strictEqual
(
,
1
,
'expected onDidChange to fire when an existing agent file is modified'
)
;
}
)
;
test
(
'fires onDidChange when an existing agent file is deleted under a non-recursively watched root'
,
async
(
)
=>
{
const
=
await
seed
(
'/workspace/.github/agents/foo.agent.md'
,
'workspace agent'
)
;
await
seed
(
'/workspace/.github/agents/bar.agent.md'
,
'workspace agent bar'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
await
.
scan
(
.
)
;
await
timeout
(
50
)
;
let
=
0
;
const
=
new
DeferredPromise< void >
(
)
;
.
add
(
.
onDidChange
(
(
)
=>
{
++
;
.
complete
(
)
;
}
)
)
;
await
.
del
(
)
;
await
raceTimeout
(
.
,
500
)
;
.
strictEqual
(
,
1
,
'expected onDidChange to fire when an existing agent file is deleted'
)
;
}
)
;
test
(
'fires onDidChange when AGENTS.md in the workspace root is modified'
,
async
(
)
=>
{
await
seed
(
'/workspace/AGENTS.md'
,
'agents instructions'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
await
.
scan
(
.
)
;
await
timeout
(
50
)
;
let
=
0
;
const
=
new
DeferredPromise< void >
(
)
;
.
add
(
.
onDidChange
(
(
)
=>
{
++
;
.
complete
(
)
;
}
)
)
;
await
seed
(
'/workspace/AGENTS.md'
,
'agents instructions (updated)'
)
;
await
raceTimeout
(
.
,
500
)
;
.
strictEqual
(
,
1
,
'expected onDidChange to fire when AGENTS.md at the workspace root is modified'
)
;
}
)
;
test
(
'does not fire onDidChange for files outside any trigger URI'
,
async
(
)
=>
{
await
seed
(
'/workspace/.github/agents/foo.agent.md'
,
'workspace agent'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
await
.
scan
(
.
)
;
await
timeout
(
50
)
;
let
=
0
;
.
add
(
.
onDidChange
(
(
)
=>
{
++
;
}
)
)
;
await
seed
(
'/workspace/.git/HEAD'
,
'ref: refs/heads/main'
)
;
await
seed
(
'/workspace/.vscode/settings.json'
,
'{}'
)
;
await
seed
(
'/workspace/README.md'
,
'# project'
)
;
await
seed
(
'/workspace/src/index.ts'
,
'export {};'
)
;
await
timeout
(
100
)
;
.
strictEqual
(
,
0
,
'expected onDidChange not to fire for paths outside any trigger URI'
)
;
}
)
;
test
(
'discover mode watches the discovered skill root so new skills fire onDidChange'
,
async
(
)
=>
{
await
.
createFolder
(
URI
.
from
(
{
:
.
,
:
'/workspace/.github/skills'
}
)
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
)
)
;
const
=
{
:
{
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
]
}
)
,
}
,
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
]
}
)
,
}
,
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
{
:
'/workspace/.github/skills'
}
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
]
}
)
,
}
,
}
,
}
as
unknown
as
;
await
.
discover
(
,
.
)
;
await
timeout
(
50
)
;
let
=
0
;
const
=
new
DeferredPromise< void >
(
)
;
.
add
(
.
onDidChange
(
(
)
=>
{
++
;
.
complete
(
)
;
}
)
)
;
await
seed
(
'/workspace/.github/skills/new-skill/SKILL.md'
,
'new workspace skill'
)
;
await
raceTimeout
(
.
,
500
)
;
.
strictEqual
(
,
1
,
'expected onDidChange to fire when a skill is added under the discovered skill root'
)
;
}
)
;
test
(
'cancellation of one caller does not affect another concurrent caller'
,
async
(
)
=>
{
await
seed
(
'/workspace/.github/agents/foo.agent.md'
,
'workspace agent'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
const
=
new
CancellationTokenSource
(
)
;
.
add
(
)
;
const
=
.
scan
(
.
)
;
const
=
.
scan
(
.
)
;
.
cancel
(
)
;
await
.
rejects
(
)
;
const
=
await
;
.
ok
(
.
some
(
=>
.
===
.
)
)
;
}
)
;
test
(
'discovers agents, skills, instructions, and hooks across workspace and home roots'
,
async
(
)
=>
{
const
=
await
seed
(
'/workspace/.github/agents/foo.agent.md'
,
'agent body'
)
;
const
=
await
seed
(
'/workspace/.github/skills/bar/SKILL.md'
,
'skill body'
)
;
const
=
await
seed
(
'/workspace/.github/instructions/baz.instructions.md'
,
'instr body'
)
;
const
=
await
seed
(
'/workspace/.github/hooks/pre-tool.json'
,
'{"PreToolUse": []}'
)
;
const
=
await
seed
(
'/home/.copilot/agents/qux.agent.md'
,
'user agent'
)
;
const
=
await
seed
(
'/home/.copilot/skills/copilot-zap/SKILL.md'
,
'user copilot skill'
)
;
const
=
await
seed
(
'/home/.agents/skills/zap/SKILL.md'
,
'user skill'
)
;
const
=
await
seed
(
'/home/.copilot/hooks/post-tool.json'
,
'{"PostToolUse": []}'
)
;
await
seed
(
'/workspace/.github/agents/not-an-agent.txt'
,
'ignored'
)
;
await
seed
(
'/workspace/.github/hooks/not-a-hook.md'
,
'ignored'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
const
=
await
.
scan
(
.
)
;
const
=
.
flatMap
(
=>
.
.
map
(
=>
(
{
:
.
,
:
.
}
)
)
)
;
.
deepStrictEqual
(
[
...
]
.
sort
(
(
,
)
=>
.
.
toString
(
)
.
localeCompare
(
.
.
toString
(
)
)
)
,
[
{
:
,
:
.
}
,
{
:
,
:
.
}
,
{
:
,
:
.
}
,
{
:
,
:
.
}
,
{
:
,
:
.
}
,
{
:
,
:
.
}
,
{
:
,
:
.
}
,
{
:
,
:
.
}
,
]
.
sort
(
(
,
)
=>
.
.
toString
(
)
.
localeCompare
(
.
.
toString
(
)
)
)
)
;
.
ok
(
.
some
(
=>
.
.
toString
(
)
===
URI
.
joinPath
(
,
'.github'
,
'agents'
)
.
toString
(
)
)
)
;
}
)
;
test
(
'discovers nested .json hook files'
,
async
(
)
=>
{
const
=
await
seed
(
'/workspace/.github/hooks/team/security/pre-tool.json'
,
'{"PreToolUse": []}'
)
;
const
=
await
seed
(
'/home/.copilot/hooks/domain/tools/post-tool.json'
,
'{"PostToolUse": []}'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
const
=
(
await
.
scan
(
.
)
)
.
flatMap
(
=>
.
.
map
(
=>
(
{
:
.
,
:
.
}
)
)
)
;
.
deepStrictEqual
(
[
...
]
.
sort
(
(
,
)
=>
.
.
toString
(
)
.
localeCompare
(
.
.
toString
(
)
)
)
,
[
{
:
,
:
.
}
,
{
:
,
:
.
}
,
]
.
sort
(
(
,
)
=>
.
.
toString
(
)
.
localeCompare
(
.
.
toString
(
)
)
)
)
;
}
)
;
test
(
'discovers hook settings files from fixed workspace locations'
,
async
(
)
=>
{
const
=
await
seed
(
'/workspace/.github/copilot/settings.json'
,
'{"hooks": {"PreToolUse": []}}'
)
;
const
=
await
seed
(
'/workspace/.github/copilot/settings.local.json'
,
'{"hooks": {"PostToolUse": []}}'
)
;
const
=
await
seed
(
'/workspace/.claude/settings.json'
,
'{"hooks": {"SessionStart": []}}'
)
;
const
=
await
seed
(
'/workspace/.claude/settings.local.json'
,
'{"hooks": {"SessionEnd": []}}'
)
;
await
seed
(
'/workspace/.github/copilot/settings.dev.json'
,
'{"hooks": {"Ignored": []}}'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
const
=
(
await
.
scan
(
.
)
)
.
flatMap
(
=>
.
.
map
(
=>
(
{
:
.
,
:
.
}
)
)
)
;
.
deepStrictEqual
(
[
...
]
.
sort
(
(
,
)
=>
.
.
toString
(
)
.
localeCompare
(
.
.
toString
(
)
)
)
,
[
{
:
,
:
.
}
,
{
:
,
:
.
}
,
{
:
,
:
.
}
,
{
:
,
:
.
}
,
]
.
sort
(
(
,
)
=>
.
.
toString
(
)
.
localeCompare
(
.
.
toString
(
)
)
)
)
;
}
)
;
test
(
'fires onDidChange when fixed hook settings file is modified'
,
async
(
)
=>
{
await
seed
(
'/workspace/.github/copilot/settings.json'
,
'{"hooks": {"PreToolUse": []}}'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
await
.
scan
(
.
)
;
await
timeout
(
50
)
;
let
=
0
;
const
=
new
DeferredPromise< void >
(
)
;
.
add
(
.
onDidChange
(
(
)
=>
{
++
;
.
complete
(
)
;
}
)
)
;
await
seed
(
'/workspace/.github/copilot/settings.json'
,
'{"hooks": {"PreToolUse": [{"command": "echo test"}]}}'
)
;
await
raceTimeout
(
.
,
500
)
;
.
strictEqual
(
,
1
,
'expected onDidChange to fire when fixed hook settings file is modified'
)
;
}
)
;
test
(
'excludes exact-case README.md inside agent folders'
,
async
(
)
=>
{
const
=
await
seed
(
'/workspace/.github/agents/foo.agent.md'
,
'agent body'
)
;
const
=
await
seed
(
'/workspace/.github/agents/plain.md'
,
'plain agent body'
)
;
const
=
await
seed
(
'/workspace/.github/agents/readme.md'
,
'docs lower'
)
;
await
seed
(
'/workspace/.github/agents/README.md'
,
'docs'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
const
=
(
await
.
scan
(
.
)
)
.
flatMap
(
=>
.
.
map
(
=>
(
{
:
.
,
:
.
}
)
)
)
;
.
deepStrictEqual
(
[
...
]
.
sort
(
(
,
)
=>
.
.
toString
(
)
.
localeCompare
(
.
.
toString
(
)
)
)
,
[
{
:
,
:
.
}
,
{
:
,
:
.
}
,
{
:
,
:
.
}
,
]
.
sort
(
(
,
)
=>
.
.
toString
(
)
.
localeCompare
(
.
.
toString
(
)
)
)
)
;
}
)
;
test
(
'includes non-README markdown files inside agent folders'
,
async
(
)
=>
{
const
=
await
seed
(
'/workspace/.github/agents/foo.agent.md'
,
'agent body'
)
;
const
=
await
seed
(
'/workspace/.github/agents/legacy.chatmode.md'
,
'legacy mode body'
)
;
const
=
await
seed
(
'/workspace/.github/agents/bar.prompt.md'
,
'prompt body'
)
;
const
=
await
seed
(
'/workspace/.github/agents/baz.instructions.md'
,
'instruction body'
)
;
const
=
await
seed
(
'/workspace/.github/agents/copilot-instructions.md'
,
'copilot instructions body'
)
;
const
=
await
seed
(
'/workspace/.github/agents/SKILL.md'
,
'skill body'
)
;
const
=
await
seed
(
'/workspace/.github/agents/skill.md'
,
'skill body lowercase'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
const
=
(
await
.
scan
(
.
)
)
.
flatMap
(
=>
.
.
map
(
=>
(
{
:
.
,
:
.
}
)
)
)
;
.
deepStrictEqual
(
[
...
]
.
sort
(
(
,
)
=>
.
.
toString
(
)
.
localeCompare
(
.
.
toString
(
)
)
)
,
[
{
:
,
:
.
}
,
{
:
,
:
.
}
,
{
:
,
:
.
}
,
{
:
,
:
.
}
,
{
:
,
:
.
}
,
{
:
,
:
.
}
,
{
:
,
:
.
}
,
]
.
sort
(
(
,
)
=>
.
.
toString
(
)
.
localeCompare
(
.
.
toString
(
)
)
)
)
;
}
)
;
test
(
'discovers nested .instructions.md files'
,
async
(
)
=>
{
const
=
await
seed
(
'/workspace/.github/instructions/team/security/policy.instructions.md'
,
'workspace nested instruction'
)
;
const
=
await
seed
(
'/home/.copilot/instructions/domain/tools/deep.instructions.md'
,
'user nested instruction'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
const
=
(
await
.
scan
(
.
)
)
.
flatMap
(
=>
.
.
map
(
=>
(
{
:
.
,
:
.
}
)
)
)
;
.
deepStrictEqual
(
[
...
]
.
sort
(
(
,
)
=>
.
.
toString
(
)
.
localeCompare
(
.
.
toString
(
)
)
)
,
[
{
:
,
:
.
}
,
{
:
,
:
.
}
,
]
.
sort
(
(
,
)
=>
.
.
toString
(
)
.
localeCompare
(
.
.
toString
(
)
)
)
)
;
}
)
;
test
(
'bundles nested .instructions.md files into rules'
,
async
(
)
=>
{
await
seed
(
'/workspace/.github/instructions/team/security/policy.instructions.md'
,
'workspace nested instruction'
)
;
await
seed
(
'/home/.copilot/instructions/domain/tools/deep.instructions.md'
,
'user nested instruction'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
const
=
.
add
(
.
createInstance
(
,
)
)
;
const
=
await
.
bundle
(
await
.
scan
(
.
)
)
;
.
ok
(
)
;
const
=
.
;
const
=
await
.
readFile
(
URI
.
joinPath
(
,
'rules'
,
'policy.instructions.md'
)
)
;
.
strictEqual
(
.
.
toString
(
)
,
'workspace nested instruction'
)
;
const
=
await
.
readFile
(
URI
.
joinPath
(
,
'rules'
,
'deep.instructions.md'
)
)
;
.
strictEqual
(
.
.
toString
(
)
,
'user nested instruction'
)
;
}
)
;
test
(
'returns undefined when no files were discovered'
,
async
(
)
=>
{
await
.
createFolder
(
)
;
await
.
createFolder
(
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
const
=
await
.
scan
(
.
)
;
.
ok
(
Array
.
isArray
(
)
,
` Expected directories to be an array, got ${ JSON . stringify ( directories) } `
)
;
if
(
.
===
0
)
{
return
;
}
for
(
const
of
)
{
.
strictEqual
(
.
.
,
0
,
` Expected ${ dir. uri. toString ( ) } to have no files `
)
;
}
const
=
.
add
(
.
createInstance
(
,
)
)
;
await
.
bundle
(
)
;
}
)
;
test
(
'maps discovered files to parsed plugin preserving source URIs'
,
async
(
)
=>
{
const
=
await
seed
(
'/workspace/.github/agents/foo.agent.md'
,
'---\nname: Workspace Agent\ndescription: Agent description\n---\nbody'
)
;
const
=
await
seed
(
'/workspace/.github/skills/bar/SKILL.md'
,
'---\nname: Workspace Skill\ndescription: Skill description\n---\nbody'
)
;
const
=
await
seed
(
'/workspace/.github/instructions/baz.instructions.md'
,
'---\nname: Workspace Rule\ndescription: Rule description\nglobs:\n - src/**\n---\nbody'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
const
=
await
toDiscoveredDirectoryCustomizations
(
await
.
scan
(
.
)
,
)
;
const
=
mapToParsedPlugin
(
)
;
.
ok
(
)
;
.
strictEqual
(
.
.
,
1
)
;
.
strictEqual
(
.
.
,
1
)
;
.
strictEqual
(
.
.
,
1
)
;
.
deepStrictEqual
(
{
:
.
[
0
]
.
.
toString
(
)
,
:
.
[
0
]
.
,
:
.
[
0
]
.
.
toString
(
)
,
:
.
[
0
]
.
,
:
.
[
0
]
.
.
toString
(
)
,
:
.
[
0
]
.
,
}
,
{
:
.
toString
(
)
,
:
'Agent description'
,
:
.
toString
(
)
,
:
'Skill description'
,
:
.
toString
(
)
,
:
'Rule description'
,
}
)
;
}
)
;
test
(
'does not include parsed agent-instruction rules in mapToParsedPlugin output'
,
async
(
)
=>
{
await
seed
(
'/workspace/.github/copilot-instructions.md'
,
'workspace instructions'
)
;
await
seed
(
'/workspace/.agents/skills/bar/SKILL.md'
,
'---\nname: bar\ndescription: Skill description\n---\nbody'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
const
=
await
toDiscoveredDirectoryCustomizations
(
await
.
scan
(
.
)
,
)
;
const
=
mapToParsedPlugin
(
)
;
.
ok
(
)
;
.
strictEqual
(
.
.
,
1
)
;
.
strictEqual
(
.
.
,
0
)
;
}
)
;
test
(
'returns undefined from mapToParsedPlugin when all customizations are agent-instruction files'
,
async
(
)
=>
{
await
seed
(
'/workspace/.github/copilot-instructions.md'
,
'workspace instructions'
)
;
await
seed
(
'/home/.copilot/copilot-instructions.md'
,
'user instructions'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
const
=
await
toDiscoveredDirectoryCustomizations
(
await
.
scan
(
.
)
,
)
;
const
=
mapToParsedPlugin
(
)
;
.
strictEqual
(
,
undefined
)
;
}
)
;
test
(
'scan discovers agent instruction files across every working directory'
,
async
(
)
=>
{
const
=
URI
.
from
(
{
:
.
,
:
'/workspace2'
}
)
;
const
=
await
seed
(
'/workspace/.github/copilot-instructions.md'
,
'first'
)
;
const
=
await
seed
(
'/workspace2/.github/copilot-instructions.md'
,
'second'
)
;
const
=
.
add
(
.
createInstance
(
,
[
,
]
,
,
URI
.
)
)
;
const
=
(
await
.
scan
(
.
)
)
.
filter
(
=>
.
===
.
)
.
flatMap
(
=>
.
.
map
(
=>
.
.
toString
(
)
)
)
.
sort
(
(
,
)
=>
.
localeCompare
(
)
)
;
.
deepStrictEqual
(
,
[
.
toString
(
)
,
.
toString
(
)
]
.
sort
(
(
,
)
=>
.
localeCompare
(
)
)
)
;
}
)
;
test
(
'constructor rejects an empty working-directory set (non-empty, primary-first invariant)'
,
(
)
=>
{
.
throws
(
(
)
=>
.
createInstance
(
,
[
]
,
,
URI
.
)
,
/ at least one working directory /
,
)
;
}
)
;
test
(
'scan discovers hooks from the primary working directory only'
,
async
(
)
=>
{
const
=
URI
.
from
(
{
:
.
,
:
'/workspace2'
}
)
;
const
=
await
seed
(
'/workspace/.github/hooks/pre-tool.json'
,
'{"PreToolUse": []}'
)
;
await
seed
(
'/workspace2/.github/hooks/pre-tool.json'
,
'{"PreToolUse": []}'
)
;
const
=
.
add
(
.
createInstance
(
,
[
,
]
,
,
URI
.
)
)
;
const
=
(
await
.
scan
(
.
)
)
.
filter
(
=>
.
===
.
)
.
flatMap
(
=>
.
.
map
(
=>
.
.
toString
(
)
)
)
.
sort
(
(
,
)
=>
.
localeCompare
(
)
)
;
.
deepStrictEqual
(
,
[
.
toString
(
)
]
)
;
}
)
;
test
(
'discover includes hooks from the primary working directory only'
,
async
(
)
=>
{
const
=
URI
.
from
(
{
:
.
,
:
'/workspace2'
}
)
;
await
seed
(
'/workspace/.github/hooks/pre-tool.json'
,
'{"PreToolUse": []}'
)
;
await
seed
(
'/workspace2/.github/hooks/pre-tool.json'
,
'{"PreToolUse": []}'
)
;
const
=
.
add
(
.
createInstance
(
,
[
,
]
,
,
)
)
;
const
=
{
:
{
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
]
}
)
}
,
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
]
}
)
}
,
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
]
}
)
}
,
}
,
}
as
unknown
as
;
const
=
(
await
.
discover
(
,
.
)
)
.
filter
(
=>
.
===
'hook'
)
.
flatMap
(
=>
(
.
??
[
]
)
.
map
(
=>
URI
.
parse
(
.
)
.
)
)
.
sort
(
)
;
.
deepStrictEqual
(
,
[
'/workspace/.github/hooks/pre-tool.json'
]
)
;
}
)
;
test
(
'discover resolves relative instructions against their attributed project root and groups per root'
,
async
(
)
=>
{
const
=
URI
.
from
(
{
:
.
,
:
'/workspace2'
}
)
;
const
=
await
seed
(
'/workspace/.github/copilot-instructions.md'
,
'first'
)
;
const
=
await
seed
(
'/workspace2/.github/copilot-instructions.md'
,
'second'
)
;
let
:
string
[
]
|
undefined
;
const
=
.
add
(
.
createInstance
(
,
[
,
]
,
,
)
)
;
const
=
{
:
{
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
]
}
)
}
,
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
{
:
'/workspace/.github/copilot-instructions.md'
,
:
'file'
}
,
{
:
'/workspace2/.github/copilot-instructions.md'
,
:
'file'
}
,
]
,
}
)
,
discover
:
async
(
:
)
=>
{
=
.
;
return
{
:
[
{
:
'a'
,
:
'A'
,
:
'.github/copilot-instructions.md'
,
:
undefined
,
:
'repo'
,
:
.
}
,
{
:
'b'
,
:
'B'
,
:
'.github/copilot-instructions.md'
,
:
undefined
,
:
'repo'
,
:
.
}
,
]
,
}
;
}
,
}
,
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
]
}
)
}
,
}
,
}
as
unknown
as
;
const
=
await
.
discover
(
,
.
)
;
const
=
.
filter
(
=>
.
===
'rule'
)
.
map
(
=>
(
{
:
.
,
:
(
.
??
[
]
)
.
map
(
=>
.
)
.
sort
(
)
,
}
)
)
.
sort
(
(
,
)
=>
.
.
localeCompare
(
.
)
)
;
.
deepStrictEqual
(
{
,
}
,
{
:
[
.
,
.
]
,
:
[
{
:
.
toString
(
)
,
:
[
.
toString
(
)
]
}
,
{
:
.
toString
(
)
,
:
[
.
toString
(
)
]
}
,
]
.
sort
(
(
,
)
=>
.
.
localeCompare
(
.
)
)
,
}
)
;
}
)
;
test
(
'discover surfaces agents and skills from every working directory in one call'
,
async
(
)
=>
{
const
=
URI
.
from
(
{
:
.
,
:
'/workspace2'
}
)
;
let
:
string
[
]
|
undefined
;
const
=
.
add
(
.
createInstance
(
,
[
,
]
,
,
)
)
;
const
=
{
:
{
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
]
}
)
,
discover
:
async
(
:
)
=>
{
=
.
;
return
{
:
[
{
:
'one'
,
:
'One'
,
:
''
,
:
'/workspace/.github/agents/one.agent.md'
,
:
false
}
,
{
:
'two'
,
:
'Two'
,
:
''
,
:
'/workspace2/.github/agents/two.agent.md'
,
:
false
}
,
]
,
}
;
}
,
}
,
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
]
}
)
}
,
:
{
getDiscoveryPaths
:
async
(
)
=>
(
{
:
[
]
}
)
,
discover
:
async
(
)
=>
(
{
:
[
{
:
'/workspace/.github/skills/a'
,
:
'A'
,
:
''
}
,
{
:
'/workspace2/.github/skills/b'
,
:
'B'
,
:
''
}
,
]
,
}
)
,
}
,
}
,
}
as
unknown
as
;
const
=
await
.
discover
(
,
.
)
;
const
=
.
flatMap
(
=>
(
.
??
[
]
)
.
map
(
=>
URI
.
parse
(
.
)
.
)
)
.
sort
(
)
;
.
deepStrictEqual
(
{
,
}
,
{
:
[
.
,
.
]
,
:
[
'/workspace/.github/agents/one.agent.md'
,
'/workspace/.github/skills/a'
,
'/workspace2/.github/agents/two.agent.md'
,
'/workspace2/.github/skills/b'
,
]
,
}
)
;
}
)
;
}
)
;
suite
(
'SessionPluginBundler'
,
(
)
=>
{
const
=
new
DisposableStore
(
)
;
let
:
;
let
:
;
let
:
URI
;
let
:
URI
;
let
:
URI
;
setup
(
(
)
=>
{
=
.
add
(
new
FileService
(
new
NullLogService
(
)
)
)
;
const
=
.
add
(
new
InMemoryFileSystemProvider
(
)
)
;
.
add
(
.
registerProvider
(
.
,
)
)
;
=
.
add
(
new
TestInstantiationService
(
)
)
;
.
stub
(
,
)
;
.
stub
(
,
new
NullLogService
(
)
)
;
=
URI
.
from
(
{
:
.
,
:
'/workspace'
}
)
;
=
URI
.
from
(
{
:
.
,
:
'/home'
}
)
;
=
URI
.
from
(
{
:
.
,
:
'/agentPlugins'
}
)
;
.
stub
(
,
{
:
}
as
<
>
)
;
}
)
;
teardown
(
(
)
=>
{
.
clear
(
)
;
}
)
;
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
async
function
seed
(
:
string
,
=
''
)
:
Promise
<
URI
>
{
const
=
URI
.
from
(
{
:
.
,
}
)
;
await
.
writeFile
(
,
.
fromString
(
)
)
;
return
;
}
test
(
'bundles discovered files into the synthetic plugin tree'
,
async
(
)
=>
{
await
seed
(
'/workspace/.github/agents/foo.agent.md'
,
'agent body'
)
;
await
seed
(
'/workspace/.github/skills/bar/SKILL.md'
,
'skill body'
)
;
await
seed
(
'/workspace/.github/instructions/baz.instructions.md'
,
'instr body'
)
;
await
seed
(
'/workspace/.github/hooks/pre-tool.json'
,
'{"PreToolUse": []}'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
const
=
.
add
(
.
createInstance
(
,
)
)
;
const
=
await
.
scan
(
.
)
;
const
=
await
.
bundle
(
)
;
.
ok
(
)
;
.
strictEqual
(
.
.
,
'VS Code Synced Data'
)
;
.
ok
(
.
.
)
;
const
=
.
;
const
=
await
.
readFile
(
URI
.
joinPath
(
,
'.plugin'
,
'plugin.json'
)
)
;
.
match
(
.
.
toString
(
)
,
/ "name": "VS Code Synced Data" /
)
;
const
=
await
.
readFile
(
URI
.
joinPath
(
,
'agents'
,
'foo.agent.md'
)
)
;
.
strictEqual
(
.
.
toString
(
)
,
'agent body'
)
;
const
=
await
.
readFile
(
URI
.
joinPath
(
,
'skills'
,
'bar'
,
'SKILL.md'
)
)
;
.
strictEqual
(
.
.
toString
(
)
,
'skill body'
)
;
const
=
await
.
readFile
(
URI
.
joinPath
(
,
'rules'
,
'baz.instructions.md'
)
)
;
.
strictEqual
(
.
.
toString
(
)
,
'instr body'
)
;
const
=
await
.
readFile
(
URI
.
joinPath
(
,
'hooks'
,
'pre-tool.json'
)
)
;
.
strictEqual
(
.
.
toString
(
)
,
'{"PreToolUse": []}'
)
;
}
)
;
test
(
'produces a stable nonce for identical content'
,
async
(
)
=>
{
await
seed
(
'/workspace/.github/agents/foo.agent.md'
,
'agent body'
)
;
await
seed
(
'/workspace/.github/skills/bar/SKILL.md'
,
'skill body'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
const
=
.
add
(
.
createInstance
(
,
)
)
;
const
=
await
.
bundle
(
await
.
scan
(
.
)
)
;
let
=
0
;
let
=
0
;
const
=
.
writeFile
.
bind
(
)
;
const
=
.
del
.
bind
(
)
;
.
add
(
{
dispose
:
(
)
=>
{
.
=
as
typeof
.
;
.
=
as
typeof
.
;
}
}
)
;
.
=
(
(
...
:
<
typeof
.
>
)
=>
{
++
;
return
originalWriteFile
(
...
)
;
}
)
as
typeof
.
;
.
=
(
(
...
:
<
typeof
.
>
)
=>
{
++
;
return
originalDel
(
...
)
;
}
)
as
typeof
.
;
const
=
await
.
bundle
(
await
.
scan
(
.
)
)
;
.
ok
(
)
;
.
ok
(
)
;
.
deepStrictEqual
(
{
:
.
.
,
:
.
.
,
,
,
}
,
{
:
.
.
,
:
.
.
,
:
0
,
:
0
,
}
)
;
}
)
;
test
(
'returns undefined without rewriting when cancelled'
,
async
(
)
=>
{
await
seed
(
'/workspace/.github/agents/foo.agent.md'
,
'agent body'
)
;
const
=
.
add
(
.
createInstance
(
,
[
]
,
,
URI
.
)
)
;
const
=
.
add
(
.
createInstance
(
,
)
)
;
let
=
0
;
let
=
0
;
const
=
.
writeFile
.
bind
(
)
;
const
=
.
del
.
bind
(
)
;
.
add
(
{
dispose
:
(
)
=>
{
.
=
as
typeof
.
;
.
=
as
typeof
.
;
}
}
)
;
.
=
(
(
...
:
<
typeof
.
>
)
=>
{
++
;
return
originalWriteFile
(
...
)
;
}
)
as
typeof
.
;
.
=
(
(
...
:
<
typeof
.
>
)
=>
{
++
;
return
originalDel
(
...
)
;
}
)
as
typeof
.
;
const
=
await
.
bundle
(
await
.
scan
(
.
)
,
.
)
;
.
deepStrictEqual
(
{
,
,
}
,
{
:
undefined
,
:
0
,
:
0
}
)
;
}
)
;
test
(
'different working directories produce different bundle authorities'
,
async
(
)
=>
{
const
=
URI
.
from
(
{
:
.
,
:
'/other-workspace'
}
)
;
const
=
.
add
(
.
createInstance
(
,
)
)
;
const
=
.
add
(
.
createInstance
(
,
)
)
;
.
notStrictEqual
(
.
.
toString
(
)
,
.
.
toString
(
)
)
;
}
)
;
}
)
;