ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / extensions / copilot / src / extension / tools / node / test / readFile.spec.tsx 960 строк · изменён 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
import { afterAll, beforeAll, expect, suite, test } from 'vitest' ;
import { ICustomInstructionsService , SkillStorage } from '../../../../platform/customInstructions/common/customInstructionsService' ;
import { IExtensionsService } from '../../../../platform/extensions/common/extensionsService' ;
import { IFileSystemService } from '../../../../platform/filesystem/common/fileSystemService' ;
import { MockFileSystemService } from '../../../../platform/filesystem/node/test/mockFileSystemService' ;
import
accessor
testDoc
emptyDoc
whitespaceDoc
singleLineDoc
largeContent length _ i
largeDoc largeContent
longLine
longLinesContent
longLinesDoc longLinesContent
surrogateBoundaryLine
surrogateBoundaryDoc surrogateBoundaryLine
services
services
testDoc emptyDoc whitespaceDoc singleLineDoc largeDoc longLinesDoc surrogateBoundaryDoc
accessor services
accessor
toolsService accessor
input
filePath
startLine
endLine
result toolsService input toolInvocationToken
accessor result
toolsService accessor
input
filePath
startLine
endLine
result toolsService input toolInvocationToken
accessor result
toolsService accessor
input
filePath
startLine
endLine
result toolsService input toolInvocationToken
accessor result
toolsService accessor
input
filePath
offset
limit
result toolsService input toolInvocationToken
accessor result
toolsService accessor
input
filePath
offset
result toolsService input toolInvocationToken
accessor result
toolsService accessor
input
filePath
result toolsService input toolInvocationToken
accessor result
toolsService accessor
input
filePath
offset
limit
result toolsService input toolInvocationToken
accessor result
toolsService accessor
input
filePath
offset
limit
result toolsService input toolInvocationToken
accessor result
toolsService accessor
input
filePath
offset
limit
result toolsService input toolInvocationToken
resultString accessor result
resultString
resultString
resultString
resultString
toolsService accessor
input
filePath
result toolsService input toolInvocationToken
resultString accessor result
resultString
resultString
resultString
lines resultString
longLines lines l l
l longLines
l
toolsService accessor
input
filePath
result toolsService input toolInvocationToken
resultString accessor result
truncatedLine resultString line line
truncatedLine
toolsService accessor
input
filePath
offset
toolsService input toolInvocationToken
toolsService accessor
input
filePath
offset
toolsService input toolInvocationToken
toolsService accessor
input
filePath
offset
limit
result toolsService input toolInvocationToken
resultString accessor result
resultString
toolsService accessor
input
filePath
offset
toolsService input toolInvocationToken
toolsService accessor
input
filePath
offset
limit
result toolsService input toolInvocationToken
resultString accessor result
resultString
resultString
toolsService accessor
input
filePath
offset
toolsService input toolInvocationToken
toolsService accessor
input
filePath
offset
limit
result toolsService input toolInvocationToken
resultString accessor result
resultString
resultString
testDoc
services
services
testDoc
mockCustomInstructions
mockCustomInstructions
services mockCustomInstructions
testAccessor services
readFileTool testAccessor
input
filePath
result readFileTool
input
result
result
result
testAccessor
testDoc
services
services
testDoc
mockCustomInstructions
services mockCustomInstructions
testAccessor services
readFileTool testAccessor
input
filePath
result readFileTool
input
result
result
result
testAccessor
testDoc
services
services
testDoc
mockCustomInstructions
mockCustomInstructions
services mockCustomInstructions
testAccessor services
readFileTool testAccessor
input
filePath
offset
limit
result readFileTool
input
result
result
result
testAccessor
testDoc
services
services
testDoc
mockCustomInstructions
mockCustomInstructions
services mockCustomInstructions
testAccessor services
readFileTool testAccessor
input
filePath
result readFileTool
input
result
result
result
testAccessor
testDoc
services
services
testDoc
mockCustomInstructions
mockCustomInstructions
services mockCustomInstructions
testAccessor services
readFileTool testAccessor
input
filePath
offset
limit
result readFileTool
input
result
result
result
testAccessor
testDoc
services
services
testDoc
mockCustomInstructions
services mockCustomInstructions
testAccessor services
readFileTool testAccessor
input
filePath
offset
limit
result readFileTool
input
result
result
result
testAccessor
services
mockFs
mockFs
services mockFs
services
testAccessor services
readFileTool testAccessor
input filePath
readFileTool
input toolInvocationToken
testAccessor
services
mockFs
mockFs
services mockFs
services
testAccessor services
readFileTool testAccessor
input filePath
readFileTool
input
testAccessor
uri data
override resource
resource uri
data
resource
binaryUri
binaryData
mockFs binaryUri binaryData
services
services mockFs
services
testAccessor services
readFileTool testAccessor
input filePath
result readFileTool
input toolInvocationToken
text testAccessor result
text
text
testAccessor
binaryUri
binaryData
i i i
binaryData i i
binaryData
mockFs binaryUri binaryData
services
services mockFs
services
testAccessor services
readFileTool testAccessor
input filePath startLine endLine
result readFileTool
input toolInvocationToken
text testAccessor result
text
testAccessor
binaryUri
binaryData
i i i
binaryData i i
binaryData
mockFs binaryUri binaryData
services
services mockFs
services
testAccessor services
readFileTool testAccessor
input filePath offset
result readFileTool
input toolInvocationToken
text testAccessor result
text
testAccessor
binaryUri
binaryData
i i i
binaryData i i
binaryData
mockFs binaryUri binaryData
services
services mockFs
services
testAccessor services
readFileTool testAccessor
input filePath offset limit
result readFileTool
input toolInvocationToken
text testAccessor result
text
text
testAccessor
textUri
textData
mockFs textUri textData
textDoc textUri
services
services mockFs
services
textDoc
testAccessor services
readFileTool testAccessor
input filePath
result readFileTool
input toolInvocationToken
text testAccessor result
text
text
testAccessor
events eventName properties measurements
enhancedEvents eventName properties
internalEvents eventName properties
override eventName properties measurements
eventName properties measurements
override eventName properties
eventName properties
override eventName properties
eventName properties
override eventName properties measurements
eventName properties measurements
skillContent
skillUri
testDoc skillUri skillContent
services
services
testDoc
mockCustomInstructions
mockCustomInstructions skillUri
services mockCustomInstructions
telemetry
services telemetry
testAccessor services
readFileTool testAccessor
input filePath skillUri
readFileTool input toolInvocationToken
event telemetry e e
event
event
event
event
event
event
enhanced telemetry e e
enhanced
enhanced
enhanced skillUri
enhanced
enhanced
enhanced
enhanced
internal telemetry e e
internal
internal
internal skillUri
internal
internal
internal
testAccessor
skillContent
skillUri
testDoc skillUri skillContent
services
services
testDoc
mockCustomInstructions
mockCustomInstructions skillUri
services mockCustomInstructions
telemetry
services telemetry
testAccessor services
readFileTool testAccessor
input filePath skillUri
readFileTool input toolInvocationToken
event telemetry e e
event
event
testAccessor
skillContent
skillUri
testDoc skillUri skillContent
services
services
testDoc
mockCustomInstructions
mockCustomInstructions skillUri
mockCustomInstructions
uri skillUri
skillName
skillFolderUri
extensionId
services mockCustomInstructions
extensionsService
extensionsService
id
packageJSON version
services extensionsService
telemetry
services telemetry
testAccessor services
readFileTool testAccessor
input filePath skillUri
readFileTool input toolInvocationToken
event telemetry e e
event
event
event
event
event
enhanced telemetry e e
enhanced
enhanced
enhanced skillUri
enhanced
enhanced
enhanced
enhanced
internal telemetry e e
internal
internal
internal
internal
internal
internal
testAccessor
telemetry
services
services telemetry
testDoc
services
testDoc
testAccessor services
readFileTool testAccessor
input filePath
readFileTool input toolInvocationToken
skillEvent telemetry e e
skillEvent
enhancedSkillEvent telemetry e e
enhancedSkillEvent
internalSkillEvent telemetry e e
internalSkillEvent
readEvent telemetry e e
readEvent
readEvent
testAccessor
{ NullTelemetryService }
from
'../../../../platform/telemetry/common/nullTelemetryService'
;
import
{ ITelemetryService , TelemetryEventMeasurements , TelemetryEventProperties }
from
'../../../../platform/telemetry/common/telemetry'
;
import
{ MockCustomInstructionsService }
from
'../../../../platform/test/common/testCustomInstructionsService'
;
import
{ TestExtensionsService }
from
'../../../../platform/test/common/testExtensionsService'
;
import
{ ITestingServicesAccessor }
from
'../../../../platform/test/node/services'
;
import
{ TestWorkspaceService }
from
'../../../../platform/test/node/testWorkspaceService'
;
import
{ IWorkspaceService }
from
'../../../../platform/workspace/common/workspaceService'
;
import
{ createTextDocumentData }
from
'../../../../util/common/test/shims/textDocument'
;
import
{ CancellationToken }
from
'../../../../util/vs/base/common/cancellation'
;
import
{
URI
}
from
'../../../../util/vs/base/common/uri'
;
import
{ SyncDescriptor }
from
'../../../../util/vs/platform/instantiation/common/descriptors'
;
import
{ IInstantiationService }
from
'../../../../util/vs/platform/instantiation/common/instantiation'
;
import
{ MarkdownString }
from
'../../../../vscodeTypes'
;
import
{ createExtensionUnitTestingServices }
from
'../../../test/node/services'
;
import
{ ToolName }
from
'../../common/toolNames'
;
import
{ IToolsService }
from
'../../common/toolsService'
;
import
{ IReadFileParamsV1 , IReadFileParamsV2 , ReadFileTool }
from
'../readFileTool'
;
import
{ toolResultToString }
from
'./toolTestUtils'
;
suite
(
'ReadFile'
,
(
)
=>
{
let
:
ITestingServicesAccessor
;
beforeAll
(
(
)
=>
{
const
=
createTextDocumentData
(
URI
.
file
(
'/workspace/file.ts'
)
,
'line 1\nline 2\n\nline 4\nline 5'
,
'ts'
)
.
document
;
const
=
createTextDocumentData
(
URI
.
file
(
'/workspace/empty.ts'
)
,
''
,
'ts'
)
.
document
;
const
=
createTextDocumentData
(
URI
.
file
(
'/workspace/whitespace.ts'
)
,
' \t\n'
,
'ts'
)
.
document
;
const
=
createTextDocumentData
(
URI
.
file
(
'/workspace/single.ts'
)
,
'single line'
,
'ts'
)
.
document
;
const
=
Array
.
from
(
{
:
3000
}
,
(
,
)
=>
` line ${ i + 1 } `
)
.
join
(
'\n'
)
;
const
=
createTextDocumentData
(
URI
.
file
(
'/workspace/large.ts'
)
,
,
'ts'
)
.
document
;
const
=
'x'
.
repeat
(
2500
)
;
const
=
` normal line\n ${ longLine} \nanother normal line\n ${ longLine} `
;
const
=
createTextDocumentData
(
URI
.
file
(
'/workspace/longlines.ts'
)
,
,
'ts'
)
.
document
;
const
=
'x'
.
repeat
(
1999
)
+
'\u{1F6E1}'
+
'tail'
;
const
=
createTextDocumentData
(
URI
.
file
(
'/workspace/surrogate-boundary.ts'
)
,
,
'ts'
)
.
document
;
const
=
createExtensionUnitTestingServices
(
)
;
.
define
(
IWorkspaceService
,
new
SyncDescriptor
(
TestWorkspaceService
,
[
[
URI
.
file
(
'/workspace'
)
]
,
[
,
,
,
,
,
,
]
,
]
)
)
;
=
.
createTestingAccessor
(
)
;
}
)
;
afterAll
(
(
)
=>
{
.
dispose
(
)
;
}
)
;
test
(
'read simple file'
,
async
(
)
=>
{
const
=
.
get
(
IToolsService
)
;
const
:
IReadFileParamsV1
=
{
:
'/workspace/file.ts'
,
:
2
,
:
6
}
;
const
=
await
.
invokeTool
(
ToolName
.
ReadFile
,
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
expect
(
await
toolResultToString
(
,
)
)
.
toMatchInlineSnapshot
(
`
"line 2
line 4
line 5"
`
)
;
}
)
;
test
(
'read empty file'
,
async
(
)
=>
{
const
=
.
get
(
IToolsService
)
;
const
:
IReadFileParamsV1
=
{
:
'/workspace/empty.ts'
,
:
2
,
:
6
}
;
const
=
await
.
invokeTool
(
ToolName
.
ReadFile
,
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
expect
(
await
toolResultToString
(
,
)
)
.
toMatchInlineSnapshot
(
` "(The file \`/workspace/empty.ts\` exists, but is empty)" `
)
;
}
)
;
test
(
'read whitespace file'
,
async
(
)
=>
{
const
=
.
get
(
IToolsService
)
;
const
:
IReadFileParamsV1
=
{
:
'/workspace/whitespace.ts'
,
:
2
,
:
6
}
;
const
=
await
.
invokeTool
(
ToolName
.
ReadFile
,
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
expect
(
await
toolResultToString
(
,
)
)
.
toMatchInlineSnapshot
(
` "(The file \`/workspace/whitespace.ts\` exists, but contains only whitespace)" `
)
;
}
)
;
suite
(
'IReadFileParamsV2'
,
(
)
=>
{
test
(
'read simple file with offset and limit'
,
async
(
)
=>
{
const
=
.
get
(
IToolsService
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/file.ts'
,
:
2
,
:
4
}
;
const
=
await
.
invokeTool
(
ToolName
.
ReadFile
,
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
expect
(
await
toolResultToString
(
,
)
)
.
toMatchInlineSnapshot
(
`
"line 2
line 4
line 5"
`
)
;
}
)
;
test
(
'read simple file with only offset'
,
async
(
)
=>
{
const
=
.
get
(
IToolsService
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/file.ts'
,
:
3
}
;
const
=
await
.
invokeTool
(
ToolName
.
ReadFile
,
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
expect
(
await
toolResultToString
(
,
)
)
.
toMatchInlineSnapshot
(
`
"
line 4
line 5"
`
)
;
}
)
;
test
(
'read simple file without offset or limit'
,
async
(
)
=>
{
const
=
.
get
(
IToolsService
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/file.ts'
}
;
const
=
await
.
invokeTool
(
ToolName
.
ReadFile
,
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
expect
(
await
toolResultToString
(
,
)
)
.
toMatchInlineSnapshot
(
`
"line 1
line 2
line 4
line 5"
`
)
;
}
)
;
test
(
'read empty file'
,
async
(
)
=>
{
const
=
.
get
(
IToolsService
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/empty.ts'
,
:
1
,
:
4
}
;
const
=
await
.
invokeTool
(
ToolName
.
ReadFile
,
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
expect
(
await
toolResultToString
(
,
)
)
.
toMatchInlineSnapshot
(
` "(The file \`/workspace/empty.ts\` exists, but is empty)" `
)
;
}
)
;
test
(
'read whitespace file'
,
async
(
)
=>
{
const
=
.
get
(
IToolsService
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/whitespace.ts'
,
:
1
,
:
2
}
;
const
=
await
.
invokeTool
(
ToolName
.
ReadFile
,
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
expect
(
await
toolResultToString
(
,
)
)
.
toMatchInlineSnapshot
(
` "(The file \`/workspace/whitespace.ts\` exists, but contains only whitespace)" `
)
;
}
)
;
test
(
'read file with limit larger than MAX_LINES_PER_READ should truncate'
,
async
(
)
=>
{
const
=
.
get
(
IToolsService
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/large.ts'
,
:
1
,
:
3000
}
;
const
=
await
.
invokeTool
(
ToolName
.
ReadFile
,
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
const
=
await
toolResultToString
(
,
)
;
expect
(
)
.
toContain
(
'line 1'
)
;
expect
(
)
.
toContain
(
'line 2000'
)
;
expect
(
)
.
toContain
(
'[File content truncated at line 2000. Use read_file with offset/limit parameters to view more.]'
)
;
expect
(
)
.
not
.
toContain
(
'line 2001'
)
;
}
)
;
test
(
'long lines are truncated and a notice is appended'
,
async
(
)
=>
{
const
=
.
get
(
IToolsService
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/longlines.ts'
}
;
const
=
await
.
invokeTool
(
ToolName
.
ReadFile
,
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
const
=
await
toolResultToString
(
,
)
;
expect
(
)
.
toContain
(
'normal line'
)
;
expect
(
)
.
toContain
(
'[truncated]'
)
;
expect
(
)
.
toContain
(
'[One or more long lines were truncated at 2000 characters]'
)
;
const
=
.
split
(
'\n'
)
;
const
=
.
filter
(
=>
.
includes
(
'x'
.
repeat
(
100
)
)
)
;
for
(
const
of
)
{
expect
(
.
length
)
.
toBeLessThan
(
2500
)
;
}
}
)
;
test
(
'long line truncation does not split surrogate pairs'
,
async
(
)
=>
{
const
=
.
get
(
IToolsService
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/surrogate-boundary.ts'
}
;
const
=
await
.
invokeTool
(
ToolName
.
ReadFile
,
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
const
=
await
toolResultToString
(
,
)
;
const
=
.
split
(
'\n'
)
.
find
(
=>
.
endsWith
(
' [truncated]'
)
)
;
expect
(
)
.
toBe
(
'x'
.
repeat
(
1999
)
+
' [truncated]'
)
;
}
)
;
test
(
'read file with offset beyond file line count should throw error'
,
async
(
)
=>
{
const
=
.
get
(
IToolsService
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/file.ts'
,
:
535
}
;
await
expect
(
.
invokeTool
(
ToolName
.
ReadFile
,
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
)
.
rejects
.
toThrow
(
'Invalid offset 535: file only has 5 lines. Line numbers are 1-indexed.'
)
;
}
)
;
test
(
'read file with offset beyond single-line file should throw error'
,
async
(
)
=>
{
const
=
.
get
(
IToolsService
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/whitespace.ts'
,
:
10
}
;
await
expect
(
.
invokeTool
(
ToolName
.
ReadFile
,
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
)
.
rejects
.
toThrow
(
'Invalid offset 10: file only has 2 lines. Line numbers are 1-indexed.'
)
;
}
)
;
test
(
'read file with offset exactly at line count should succeed'
,
async
(
)
=>
{
const
=
.
get
(
IToolsService
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/file.ts'
,
:
5
,
:
1
}
;
const
=
await
.
invokeTool
(
ToolName
.
ReadFile
,
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
const
=
await
toolResultToString
(
,
)
;
expect
(
)
.
toContain
(
'line 5'
)
;
}
)
;
test
(
'read empty file with offset beyond bounds should throw error'
,
async
(
)
=>
{
const
=
.
get
(
IToolsService
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/empty.ts'
,
:
2
}
;
await
expect
(
.
invokeTool
(
ToolName
.
ReadFile
,
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
)
.
rejects
.
toThrow
(
'Invalid offset 2: file only has 1 line. Line numbers are 1-indexed.'
)
;
}
)
;
test
(
'read file with offset 0 should clamp to line 1'
,
async
(
)
=>
{
const
=
.
get
(
IToolsService
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/file.ts'
,
:
0
,
:
2
}
;
const
=
await
.
invokeTool
(
ToolName
.
ReadFile
,
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
const
=
await
toolResultToString
(
,
)
;
expect
(
)
.
toContain
(
'line 1'
)
;
expect
(
)
.
toContain
(
'line 2'
)
;
}
)
;
test
(
'read single-line file with offset beyond bounds should throw error with singular "line"'
,
async
(
)
=>
{
const
=
.
get
(
IToolsService
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/single.ts'
,
:
2
}
;
await
expect
(
.
invokeTool
(
ToolName
.
ReadFile
,
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
)
.
rejects
.
toThrow
(
'Invalid offset 2: file only has 1 line. Line numbers are 1-indexed.'
)
;
}
)
;
test
(
'read file with limit of 1'
,
async
(
)
=>
{
const
=
.
get
(
IToolsService
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/file.ts'
,
:
2
,
:
1
}
;
const
=
await
.
invokeTool
(
ToolName
.
ReadFile
,
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
const
=
await
toolResultToString
(
,
)
;
expect
(
)
.
toContain
(
'line 2'
)
;
expect
(
)
.
not
.
toContain
(
'line 3'
)
;
}
)
;
}
)
;
suite
(
'prepareInvocation'
,
(
)
=>
{
test
(
'should return "Reading/Read skill" message for skill files'
,
async
(
)
=>
{
const
=
createTextDocumentData
(
URI
.
file
(
'/workspace/test.skill.md'
)
,
'skill content'
,
'markdown'
)
.
document
;
const
=
createExtensionUnitTestingServices
(
)
;
.
define
(
IWorkspaceService
,
new
SyncDescriptor
(
TestWorkspaceService
,
[
[
URI
.
file
(
'/workspace'
)
]
,
[
]
,
]
)
)
;
const
=
new
MockCustomInstructionsService
(
)
;
.
setSkillFiles
(
[
URI
.
file
(
'/workspace/test.skill.md'
)
]
)
;
.
define
(
ICustomInstructionsService
,
)
;
const
=
.
createTestingAccessor
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
ReadFileTool
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/test.skill.md'
}
;
const
=
await
.
prepareInvocation
(
{
}
,
CancellationToken
.
None
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
(
!
.
invocationMessage
as
MarkdownString
)
.
value
)
.
toBe
(
'Reading skill [workspace](file:///workspace/test.skill.md?vscodeLinkType%3Dskill)'
)
;
expect
(
(
!
.
pastTenseMessage
as
MarkdownString
)
.
value
)
.
toBe
(
'Read skill [workspace](file:///workspace/test.skill.md?vscodeLinkType%3Dskill)'
)
;
.
dispose
(
)
;
}
)
;
test
(
'should return "Reading/Read" message for non-skill files'
,
async
(
)
=>
{
const
=
createTextDocumentData
(
URI
.
file
(
'/workspace/test.ts'
)
,
'code content'
,
'typescript'
)
.
document
;
const
=
createExtensionUnitTestingServices
(
)
;
.
define
(
IWorkspaceService
,
new
SyncDescriptor
(
TestWorkspaceService
,
[
[
URI
.
file
(
'/workspace'
)
]
,
[
]
,
]
)
)
;
const
=
new
MockCustomInstructionsService
(
)
;
.
define
(
ICustomInstructionsService
,
)
;
const
=
.
createTestingAccessor
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
ReadFileTool
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/test.ts'
}
;
const
=
await
.
prepareInvocation
(
{
}
,
CancellationToken
.
None
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
(
!
.
invocationMessage
as
MarkdownString
)
.
value
)
.
toBe
(
'Reading [](file:///workspace/test.ts)'
)
;
expect
(
(
!
.
pastTenseMessage
as
MarkdownString
)
.
value
)
.
toBe
(
'Read [](file:///workspace/test.ts)'
)
;
.
dispose
(
)
;
}
)
;
test
(
'should return "Reading skill/Read skill" message for skill files with line range'
,
async
(
)
=>
{
const
=
createTextDocumentData
(
URI
.
file
(
'/workspace/test.skill.md'
)
,
'line 1\nline 2\nline 3\nline 4\nline 5'
,
'markdown'
)
.
document
;
const
=
createExtensionUnitTestingServices
(
)
;
.
define
(
IWorkspaceService
,
new
SyncDescriptor
(
TestWorkspaceService
,
[
[
URI
.
file
(
'/workspace'
)
]
,
[
]
,
]
)
)
;
const
=
new
MockCustomInstructionsService
(
)
;
.
setSkillFiles
(
[
URI
.
file
(
'/workspace/test.skill.md'
)
]
)
;
.
define
(
ICustomInstructionsService
,
)
;
const
=
.
createTestingAccessor
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
ReadFileTool
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/test.skill.md'
,
:
2
,
:
2
}
;
const
=
await
.
prepareInvocation
(
{
}
,
CancellationToken
.
None
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
(
!
.
invocationMessage
as
MarkdownString
)
.
value
)
.
toBe
(
'Reading skill [workspace](file:///workspace/test.skill.md?vscodeLinkType%3Dskill#2-2), lines 2 to 4'
)
;
expect
(
(
!
.
pastTenseMessage
as
MarkdownString
)
.
value
)
.
toBe
(
'Read skill [workspace](file:///workspace/test.skill.md?vscodeLinkType%3Dskill#2-2), lines 2 to 4'
)
;
.
dispose
(
)
;
}
)
;
test
(
'should return "Reading/Read skill" message for non-.md skill files'
,
async
(
)
=>
{
const
=
createTextDocumentData
(
URI
.
file
(
'/workspace/test.skill'
)
,
'skill content'
,
'plaintext'
)
.
document
;
const
=
createExtensionUnitTestingServices
(
)
;
.
define
(
IWorkspaceService
,
new
SyncDescriptor
(
TestWorkspaceService
,
[
[
URI
.
file
(
'/workspace'
)
]
,
[
]
,
]
)
)
;
const
=
new
MockCustomInstructionsService
(
)
;
.
setSkillFiles
(
[
URI
.
file
(
'/workspace/test.skill'
)
]
)
;
.
define
(
ICustomInstructionsService
,
)
;
const
=
.
createTestingAccessor
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
ReadFileTool
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/test.skill'
}
;
const
=
await
.
prepareInvocation
(
{
}
,
CancellationToken
.
None
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
(
!
.
invocationMessage
as
MarkdownString
)
.
value
)
.
toContain
(
'Reading skill `workspace`: [](file:///workspace/test.skill)'
)
;
expect
(
(
!
.
pastTenseMessage
as
MarkdownString
)
.
value
)
.
toContain
(
'Read skill `workspace`: [](file:///workspace/test.skill)'
)
;
.
dispose
(
)
;
}
)
;
test
(
'should return "Reading/Read skill" message for non-.md skill files with line range'
,
async
(
)
=>
{
const
=
createTextDocumentData
(
URI
.
file
(
'/workspace/test.skill'
)
,
'line 1\nline 2\nline 3\nline 4\nline 5'
,
'plaintext'
)
.
document
;
const
=
createExtensionUnitTestingServices
(
)
;
.
define
(
IWorkspaceService
,
new
SyncDescriptor
(
TestWorkspaceService
,
[
[
URI
.
file
(
'/workspace'
)
]
,
[
]
,
]
)
)
;
const
=
new
MockCustomInstructionsService
(
)
;
.
setSkillFiles
(
[
URI
.
file
(
'/workspace/test.skill'
)
]
)
;
.
define
(
ICustomInstructionsService
,
)
;
const
=
.
createTestingAccessor
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
ReadFileTool
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/test.skill'
,
:
2
,
:
2
}
;
const
=
await
.
prepareInvocation
(
{
}
,
CancellationToken
.
None
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
(
!
.
invocationMessage
as
MarkdownString
)
.
value
)
.
toContain
(
'Reading skill `workspace`: [](file:///workspace/test.skill#2-2), lines 2 to 4'
)
;
expect
(
(
!
.
pastTenseMessage
as
MarkdownString
)
.
value
)
.
toContain
(
'Read skill `workspace`: [](file:///workspace/test.skill#2-2), lines 2 to 4'
)
;
.
dispose
(
)
;
}
)
;
test
(
'should return "Reading/Read" message for non-skill files with line range'
,
async
(
)
=>
{
const
=
createTextDocumentData
(
URI
.
file
(
'/workspace/test.ts'
)
,
'line 1\nline 2\nline 3\nline 4\nline 5'
,
'typescript'
)
.
document
;
const
=
createExtensionUnitTestingServices
(
)
;
.
define
(
IWorkspaceService
,
new
SyncDescriptor
(
TestWorkspaceService
,
[
[
URI
.
file
(
'/workspace'
)
]
,
[
]
,
]
)
)
;
const
=
new
MockCustomInstructionsService
(
)
;
.
define
(
ICustomInstructionsService
,
)
;
const
=
.
createTestingAccessor
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
ReadFileTool
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/test.ts'
,
:
2
,
:
2
}
;
const
=
await
.
prepareInvocation
(
{
}
,
CancellationToken
.
None
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
(
!
.
invocationMessage
as
MarkdownString
)
.
value
)
.
toBe
(
'Reading [](file:///workspace/test.ts#2-2), lines 2 to 4'
)
;
expect
(
(
!
.
pastTenseMessage
as
MarkdownString
)
.
value
)
.
toBe
(
'Read [](file:///workspace/test.ts#2-2), lines 2 to 4'
)
;
.
dispose
(
)
;
}
)
;
}
)
;
suite
(
'image files'
,
(
)
=>
{
test
(
'throws for image files and points to view_image'
,
async
(
)
=>
{
const
=
createExtensionUnitTestingServices
(
)
;
const
=
new
MockFileSystemService
(
)
;
.
mockFile
(
URI
.
file
(
'/workspace/photo.jpg'
)
,
'fake-image-bytes'
)
;
.
define
(
IFileSystemService
,
)
;
.
define
(
IWorkspaceService
,
new
SyncDescriptor
(
TestWorkspaceService
,
[
[
URI
.
file
(
'/workspace'
)
]
,
[
]
]
)
)
;
const
=
.
createTestingAccessor
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
ReadFileTool
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/photo.jpg'
}
;
await
expect
(
.
invoke
(
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
)
.
rejects
.
toThrow
(
'Use view_image instead'
)
;
.
dispose
(
)
;
}
)
;
test
(
'prepareInvocation throws for image files and points to view_image'
,
async
(
)
=>
{
const
=
createExtensionUnitTestingServices
(
)
;
const
=
new
MockFileSystemService
(
)
;
.
mockFile
(
URI
.
file
(
'/workspace/photo.png'
)
,
'fake-image-bytes'
)
;
.
define
(
IFileSystemService
,
)
;
.
define
(
IWorkspaceService
,
new
SyncDescriptor
(
TestWorkspaceService
,
[
[
URI
.
file
(
'/workspace'
)
]
,
[
]
]
)
)
;
const
=
.
createTestingAccessor
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
ReadFileTool
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/photo.png'
}
;
await
expect
(
.
prepareInvocation
(
{
}
,
CancellationToken
.
None
)
)
.
rejects
.
toThrow
(
'Use view_image instead'
)
;
.
dispose
(
)
;
}
)
;
}
)
;
suite
(
'binary files'
,
(
)
=>
{
function
createBinaryMockFs
(
:
URI
,
:
Uint8Array
)
:
MockFileSystemService
{
return
new
class
extends
MockFileSystemService
{
async
readFile
(
:
URI
)
:
Promise
<
Uint8Array
>
{
if
(
.
toString
(
)
===
.
toString
(
)
)
{
return
;
}
return
super
.
readFile
(
)
;
}
}
(
)
;
}
test
(
'returns hexdump for binary file'
,
async
(
)
=>
{
const
=
URI
.
file
(
'/workspace/binary.dat'
)
;
const
=
new
Uint8Array
(
[
0x4d
,
0x5a
,
0x00
,
0x03
,
0x00
,
0x00
,
0xff
,
0xfe
]
)
;
const
=
createBinaryMockFs
(
,
)
;
const
=
createExtensionUnitTestingServices
(
)
;
.
define
(
IFileSystemService
,
)
;
.
define
(
IWorkspaceService
,
new
SyncDescriptor
(
TestWorkspaceService
,
[
[
URI
.
file
(
'/workspace'
)
]
,
[
]
]
)
)
;
const
=
.
createTestingAccessor
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
ReadFileTool
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/binary.dat'
}
;
const
=
await
.
invoke
(
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
const
=
await
toolResultToString
(
,
)
;
expect
(
)
.
toContain
(
'4d 5a 00 03'
)
;
expect
(
)
.
toContain
(
'MZ'
)
;
.
dispose
(
)
;
}
)
;
test
(
'returns hexdump with v1 byte range params'
,
async
(
)
=>
{
const
=
URI
.
file
(
'/workspace/binary.dat'
)
;
const
=
new
Uint8Array
(
64
)
;
for
(
let
=
0
;
<
64
;
++
)
{
[
]
=
;
}
[
0
]
=
0x00
;
const
=
createBinaryMockFs
(
,
)
;
const
=
createExtensionUnitTestingServices
(
)
;
.
define
(
IFileSystemService
,
)
;
.
define
(
IWorkspaceService
,
new
SyncDescriptor
(
TestWorkspaceService
,
[
[
URI
.
file
(
'/workspace'
)
]
,
[
]
]
)
)
;
const
=
.
createTestingAccessor
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
ReadFileTool
)
;
const
:
IReadFileParamsV1
=
{
:
'/workspace/binary.dat'
,
:
16
,
:
32
}
;
const
=
await
.
invoke
(
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
const
=
await
toolResultToString
(
,
)
;
expect
(
)
.
toContain
(
'00000010'
)
;
.
dispose
(
)
;
}
)
;
test
(
'returns hexdump with v2 offset/limit byte params'
,
async
(
)
=>
{
const
=
URI
.
file
(
'/workspace/binary.dat'
)
;
const
=
new
Uint8Array
(
64
)
;
for
(
let
=
0
;
<
64
;
++
)
{
[
]
=
;
}
[
0
]
=
0x00
;
const
=
createBinaryMockFs
(
,
)
;
const
=
createExtensionUnitTestingServices
(
)
;
.
define
(
IFileSystemService
,
)
;
.
define
(
IWorkspaceService
,
new
SyncDescriptor
(
TestWorkspaceService
,
[
[
URI
.
file
(
'/workspace'
)
]
,
[
]
]
)
)
;
const
=
.
createTestingAccessor
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
ReadFileTool
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/binary.dat'
,
:
16
}
;
const
=
await
.
invoke
(
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
const
=
await
toolResultToString
(
,
)
;
expect
(
)
.
toContain
(
'00000010'
)
;
.
dispose
(
)
;
}
)
;
test
(
'returns hexdump with v2 offset and limit byte params'
,
async
(
)
=>
{
const
=
URI
.
file
(
'/workspace/binary.dat'
)
;
const
=
new
Uint8Array
(
128
)
;
for
(
let
=
0
;
<
128
;
++
)
{
[
]
=
;
}
[
0
]
=
0x00
;
const
=
createBinaryMockFs
(
,
)
;
const
=
createExtensionUnitTestingServices
(
)
;
.
define
(
IFileSystemService
,
)
;
.
define
(
IWorkspaceService
,
new
SyncDescriptor
(
TestWorkspaceService
,
[
[
URI
.
file
(
'/workspace'
)
]
,
[
]
]
)
)
;
const
=
.
createTestingAccessor
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
ReadFileTool
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/binary.dat'
,
:
16
,
:
16
}
;
const
=
await
.
invoke
(
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
const
=
await
toolResultToString
(
,
)
;
expect
(
)
.
toContain
(
'00000010'
)
;
expect
(
)
.
not
.
toContain
(
'00000020'
)
;
.
dispose
(
)
;
}
)
;
test
(
'does not treat text files as binary'
,
async
(
)
=>
{
const
=
URI
.
file
(
'/workspace/text.dat'
)
;
const
=
new
TextEncoder
(
)
.
encode
(
'Hello, world!\nThis is text.\n'
)
;
const
=
createBinaryMockFs
(
,
)
;
const
=
createTextDocumentData
(
,
'Hello, world!\nThis is text.\n'
,
'plaintext'
)
.
document
;
const
=
createExtensionUnitTestingServices
(
)
;
.
define
(
IFileSystemService
,
)
;
.
define
(
IWorkspaceService
,
new
SyncDescriptor
(
TestWorkspaceService
,
[
[
URI
.
file
(
'/workspace'
)
]
,
[
]
]
)
)
;
const
=
.
createTestingAccessor
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
ReadFileTool
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/text.dat'
}
;
const
=
await
.
invoke
(
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
const
=
await
toolResultToString
(
,
)
;
expect
(
)
.
toContain
(
'Hello, world!'
)
;
expect
(
)
.
not
.
toContain
(
'00000000'
)
;
.
dispose
(
)
;
}
)
;
}
)
;
suite
(
'skill provenance telemetry'
,
(
)
=>
{
class
CapturingTelemetryService
extends
NullTelemetryService
{
readonly
:
{
:
string
;
?
:
TelemetryEventProperties
;
?
:
TelemetryEventMeasurements
}
[
]
=
[
]
;
readonly
:
{
:
string
;
?
:
TelemetryEventProperties
}
[
]
=
[
]
;
readonly
:
{
:
string
;
?
:
TelemetryEventProperties
}
[
]
=
[
]
;
sendGHTelemetryEvent
(
:
string
,
?
:
TelemetryEventProperties
,
?
:
TelemetryEventMeasurements
)
:
void
{
this
.
events
.
push
(
{
,
,
}
)
;
}
sendEnhancedGHTelemetryEvent
(
:
string
,
?
:
TelemetryEventProperties
)
:
void
{
this
.
enhancedEvents
.
push
(
{
,
}
)
;
}
sendInternalMSFTTelemetryEvent
(
:
string
,
?
:
TelemetryEventProperties
)
:
void
{
this
.
internalEvents
.
push
(
{
,
}
)
;
}
sendMSFTTelemetryEvent
(
:
string
,
?
:
TelemetryEventProperties
,
?
:
TelemetryEventMeasurements
)
:
void
{
this
.
events
.
push
(
{
,
,
}
)
;
}
}
test
(
'should send separate skillContentRead event with skillStorage=local for workspace skill files'
,
async
(
)
=>
{
const
=
'# My Skill\nDo something useful.'
;
const
=
URI
.
file
(
'/workspace/.github/skills/my-skill/SKILL.md'
)
;
const
=
createTextDocumentData
(
,
,
'markdown'
)
.
document
;
const
=
createExtensionUnitTestingServices
(
)
;
.
define
(
IWorkspaceService
,
new
SyncDescriptor
(
TestWorkspaceService
,
[
[
URI
.
file
(
'/workspace'
)
]
,
[
]
]
)
)
;
const
=
new
MockCustomInstructionsService
(
)
;
.
setSkillFiles
(
[
]
)
;
.
define
(
ICustomInstructionsService
,
)
;
const
=
new
CapturingTelemetryService
(
)
;
.
define
(
ITelemetryService
,
)
;
const
=
.
createTestingAccessor
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
ReadFileTool
)
;
const
:
IReadFileParamsV2
=
{
:
.
fsPath
}
;
await
.
invoke
(
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
const
=
.
events
.
find
(
=>
.
eventName
===
'skillContentRead'
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
!
.
properties
!
.
skillStorage
)
.
toBe
(
SkillStorage
.
Workspace
)
;
expect
(
!
.
properties
!
.
skillNameHash
)
.
not
.
toBe
(
''
)
;
expect
(
!
.
properties
!
.
skillExtensionIdHash
)
.
toBe
(
''
)
;
expect
(
!
.
properties
!
.
skillExtensionVersion
)
.
toBe
(
''
)
;
expect
(
!
.
properties
!
.
skillContentHash
)
.
not
.
toBe
(
''
)
;
const
=
.
enhancedEvents
.
find
(
=>
.
eventName
===
'skillContentRead'
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
!
.
properties
!
.
skillName
)
.
toBe
(
'my-skill'
)
;
expect
(
!
.
properties
!
.
skillPath
)
.
toBe
(
.
toString
(
)
)
;
expect
(
!
.
properties
!
.
skillExtensionId
)
.
toBe
(
''
)
;
expect
(
!
.
properties
!
.
skillExtensionVersion
)
.
toBe
(
''
)
;
expect
(
!
.
properties
!
.
skillStorage
)
.
toBe
(
SkillStorage
.
Workspace
)
;
expect
(
!
.
properties
!
.
skillContentHash
)
.
not
.
toBe
(
''
)
;
const
=
.
internalEvents
.
find
(
=>
.
eventName
===
'skillContentRead'
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
!
.
properties
!
.
skillName
)
.
toBe
(
'my-skill'
)
;
expect
(
!
.
properties
!
.
skillPath
)
.
toBe
(
.
toString
(
)
)
;
expect
(
!
.
properties
!
.
skillExtensionId
)
.
toBe
(
''
)
;
expect
(
!
.
properties
!
.
skillStorage
)
.
toBe
(
SkillStorage
.
Workspace
)
;
expect
(
!
.
properties
!
.
skillContentHash
)
.
not
.
toBe
(
''
)
;
.
dispose
(
)
;
}
)
;
test
(
'should send skillStorage=user for personal skill files'
,
async
(
)
=>
{
const
=
'# Personal Skill'
;
const
=
URI
.
file
(
'/home/testuser/.copilot/skills/personal-skill/SKILL.md'
)
;
const
=
createTextDocumentData
(
,
,
'markdown'
)
.
document
;
const
=
createExtensionUnitTestingServices
(
)
;
.
define
(
IWorkspaceService
,
new
SyncDescriptor
(
TestWorkspaceService
,
[
[
URI
.
file
(
'/workspace'
)
]
,
[
]
]
)
)
;
const
=
new
MockCustomInstructionsService
(
)
;
.
setSkillFiles
(
[
]
,
SkillStorage
.
Personal
)
;
.
define
(
ICustomInstructionsService
,
)
;
const
=
new
CapturingTelemetryService
(
)
;
.
define
(
ITelemetryService
,
)
;
const
=
.
createTestingAccessor
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
ReadFileTool
)
;
const
:
IReadFileParamsV2
=
{
:
.
fsPath
}
;
await
.
invoke
(
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
const
=
.
events
.
find
(
=>
.
eventName
===
'skillContentRead'
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
!
.
properties
!
.
skillStorage
)
.
toBe
(
SkillStorage
.
Personal
)
;
.
dispose
(
)
;
}
)
;
test
(
'should send skillStorage=extension with skillExtensionIdHash and skillExtensionVersion'
,
async
(
)
=>
{
const
=
'# Extension Skill'
;
const
=
URI
.
file
(
'/extensions/publisher.my-ext/skills/ext-skill/SKILL.md'
)
;
const
=
createTextDocumentData
(
,
,
'markdown'
)
.
document
;
const
=
createExtensionUnitTestingServices
(
)
;
.
define
(
IWorkspaceService
,
new
SyncDescriptor
(
TestWorkspaceService
,
[
[
URI
.
file
(
'/workspace'
)
]
,
[
]
]
)
)
;
const
=
new
MockCustomInstructionsService
(
)
;
.
setSkillFiles
(
[
]
)
;
.
setExtensionSkillInfos
(
[
{
:
,
:
'ext-skill'
,
:
URI
.
file
(
'/extensions/publisher.my-ext/skills/ext-skill'
)
,
:
'publisher.my-ext'
,
}
]
)
;
.
define
(
ICustomInstructionsService
,
)
;
const
=
new
TestExtensionsService
(
)
;
.
addExtension
(
{
:
'publisher.my-ext'
,
:
{
:
'1.2.3'
}
,
}
as
any
)
;
.
define
(
IExtensionsService
,
)
;
const
=
new
CapturingTelemetryService
(
)
;
.
define
(
ITelemetryService
,
)
;
const
=
.
createTestingAccessor
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
ReadFileTool
)
;
const
:
IReadFileParamsV2
=
{
:
.
fsPath
}
;
await
.
invoke
(
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
const
=
.
events
.
find
(
=>
.
eventName
===
'skillContentRead'
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
!
.
properties
!
.
skillStorage
)
.
toBe
(
SkillStorage
.
Extension
)
;
expect
(
!
.
properties
!
.
skillExtensionIdHash
)
.
not
.
toBe
(
''
)
;
expect
(
!
.
properties
!
.
skillExtensionVersion
)
.
toBe
(
'1.2.3'
)
;
expect
(
!
.
properties
!
.
skillContentHash
)
.
not
.
toBe
(
''
)
;
const
=
.
enhancedEvents
.
find
(
=>
.
eventName
===
'skillContentRead'
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
!
.
properties
!
.
skillName
)
.
toBe
(
'ext-skill'
)
;
expect
(
!
.
properties
!
.
skillPath
)
.
toBe
(
.
toString
(
)
)
;
expect
(
!
.
properties
!
.
skillExtensionId
)
.
toBe
(
'publisher.my-ext'
)
;
expect
(
!
.
properties
!
.
skillExtensionVersion
)
.
toBe
(
'1.2.3'
)
;
expect
(
!
.
properties
!
.
skillStorage
)
.
toBe
(
SkillStorage
.
Extension
)
;
expect
(
!
.
properties
!
.
skillContentHash
)
.
not
.
toBe
(
''
)
;
const
=
.
internalEvents
.
find
(
=>
.
eventName
===
'skillContentRead'
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
!
.
properties
!
.
skillName
)
.
toBe
(
'ext-skill'
)
;
expect
(
!
.
properties
!
.
skillExtensionId
)
.
toBe
(
'publisher.my-ext'
)
;
expect
(
!
.
properties
!
.
skillExtensionVersion
)
.
toBe
(
'1.2.3'
)
;
expect
(
!
.
properties
!
.
skillStorage
)
.
toBe
(
SkillStorage
.
Extension
)
;
expect
(
!
.
properties
!
.
skillContentHash
)
.
not
.
toBe
(
''
)
;
.
dispose
(
)
;
}
)
;
test
(
'should not send skillContentRead for non-skill files'
,
async
(
)
=>
{
const
=
new
CapturingTelemetryService
(
)
;
const
=
createExtensionUnitTestingServices
(
)
;
.
define
(
ITelemetryService
,
)
;
const
=
createTextDocumentData
(
URI
.
file
(
'/workspace/file.ts'
)
,
'line 1\nline 2'
,
'ts'
)
.
document
;
.
define
(
IWorkspaceService
,
new
SyncDescriptor
(
TestWorkspaceService
,
[
[
URI
.
file
(
'/workspace'
)
]
,
[
]
]
)
)
;
const
=
.
createTestingAccessor
(
)
;
const
=
.
get
(
IInstantiationService
)
.
createInstance
(
ReadFileTool
)
;
const
:
IReadFileParamsV2
=
{
:
'/workspace/file.ts'
}
;
await
.
invoke
(
{
,
:
null
as
never
}
,
CancellationToken
.
None
)
;
const
=
.
events
.
find
(
=>
.
eventName
===
'skillContentRead'
)
;
expect
(
)
.
toBeUndefined
(
)
;
const
=
.
enhancedEvents
.
find
(
=>
.
eventName
===
'skillContentRead'
)
;
expect
(
)
.
toBeUndefined
(
)
;
const
=
.
internalEvents
.
find
(
=>
.
eventName
===
'skillContentRead'
)
;
expect
(
)
.
toBeUndefined
(
)
;
const
=
.
events
.
find
(
=>
.
eventName
===
'readFileToolInvoked'
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
!
.
properties
!
.
fileType
)
.
toBe
(
''
)
;
.
dispose
(
)
;
}
)
;
}
)
;
}
)
;