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 / copilotToolDisplay.test.ts 1028 строк · изменён 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
import assert from 'assert' ;
import type { PermissionRequest } from '@github/copilot-sdk' ;
import { URI } from '../../../../base/common/uri.js' ;
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../base/test/common/utils.js' ;
import { getEditFilePath, getEditFilePaths, getInvocationMessage, getPastTenseMessage, getPermissionDisplay, getShellIntention, getShellLanguage, getStreamingInvocationMessage, getTaskCompleteMarkdown, getToolDisplayName, getToolInputString, getToolKind, getToolMarkdownContent, isEditTool, isHiddenTool, isMarkdownRenderedTool, synthesizeSkillToolCall
Extract PermissionRequest kind
Extract PermissionRequest kind
fullCommandText requestSandboxBypass CopilotShellPermissionRequest
kind
canOfferSessionApproval
commands
fullCommandText
hasWriteFileRedirection
intention
possiblePaths
possibleUrls
requestSandboxBypass
toolName args CopilotCustomToolPermissionRequest CopilotCustomToolPermissionRequest
kind
toolName
toolDescription
args
cases toolName displayName
toolName displayName cases
assert toolName displayName toolName
assert
toolName
assert toolName toolName
command
assert command command
assert
assert
assert
assert
assert
assert
assert summary
truncatedOutput
assert
withSummary summary truncatedOutput
withoutSummary
withSummary
withoutSummary
assert summary
assert
assert
assert summary
assert summary
wd
path requestSandboxBypass PermissionRequest
kind intention path requestSandboxBypass requestSandboxBypass PermissionRequest
paths PermissionRequest
kind intention paths PermissionRequest
assert
inside wd confirmationTitle
insideDirectory wd confirmationTitle
outside wd confirmationTitle
secondRoot wd confirmationTitle
outsideEveryRoot wd confirmationTitle
pathGate wd confirmationTitle
relative wd confirmationTitle
unknownWorkspace confirmationTitle
sandboxBypass wd confirmationTitle
inside
insideDirectory
outside
secondRoot
outsideEveryRoot
pathGate
relative
unknownWorkspace
sandboxBypass
wd
request
display request wd
assert display toolInput
assert display permissionKind
request
display request wd
assert display toolInput
request
display request
assert display toolInput
request command
display request wd
assert display toolInput
assert display permissionKind
request command
display request wd
assert display toolInput
assert display permissionKind
request command
display request wd
assert display toolInput
sandboxed wd
bypass wd
assert bypass confirmationTitle sandboxed confirmationTitle
assert bypass confirmationTitle
display
kind
path
intention
assert
invocationMessage display invocationMessage
toolInput display toolInput
permissionKind display permissionKind
permissionPath display permissionPath
invocationMessage markdown
toolInput
permissionKind
permissionPath
request
kind
canOfferSessionApproval
diff
fileName
intention
satisfies PermissionRequest
assert
create request
edit request
create
confirmationTitle
invocationMessage markdown
toolInput
permissionKind
permissionPath
edit
confirmationTitle
invocationMessage markdown
toolInput
permissionKind
permissionPath
parameters Record
result parameters
result result result markdown
parameters Record
result parameters
result result result markdown
assert path
assert path
paths
assert
paths path
invocation path view_range
pastTense path view_range
invocation pastTense
invocation pastTense
invocation pastTense
invocation pastTense
assert path view_range
assert path view_range
assert path view_range
assert path view_range
assert path view_range
assert path view_range
assert path view_range
assert path view_range
assert path view_range
assert path view_range
assert path view_range
assert path view_range
toolName parameters Record
result toolName toolName parameters
result result result markdown
toolName parameters Record
result toolName toolName parameters
result result result markdown
assert agent_id
assert agent_id
assert agent_id message
assert agent_id message
assert
assert
assert agent_id
assert agent_id
assert
assert
assert
assert
assert
assert
assert
assert
toolName parameters resolvePath path
result toolName toolName parameters resolvePath
result result result markdown
toolName parameters Record
result toolName toolName parameters
result result result markdown
toolName parameters Record
result toolName toolName parameters
result result result markdown
assert
path
path old_str
path old_str new_str
assert
path file_text
path new_str
assert
command path file_text
command path old_str new_str
command path
cases toolName parameters Record ready complete
path
path
command path
command path
assert cases toolName parameters
ready toolName parameters
complete toolName parameters
cases ready complete ready complete
patch
assert
patch path
assert
path old_str
assert
command
assert
assert
assert
assert
assert
assert
assert
assert
command
command
assert
assert
assert
assert
assert
assert
assert
msg ReturnType getInvocationMessage
msg msg msg markdown
msg command
assert msg
msg
assert msg length
assert msg
msg command
assert msg
msg
assert msg
msg
assert msg
writeBashMsg command
bashMsg command
assert writeBashMsg bashMsg
msg ReturnType getPastTenseMessage
msg msg msg markdown
msg command
assert msg
msg
assert msg length
msg command
assert msg
msg
assert msg
msg command
assert msg length
msg ReturnType getInvocationMessage ReturnType getPastTenseMessage
msg msg msg markdown
listResult comments id id
assert
displayName
invoke
past listResult
displayName
invoke
past
assert
assert command
assert command
assert
assert
assert
withPath
name path content
withoutEventId
name path content
assert
skillIsHidden
withPathToolCallId withPath toolCallId
withPathToolName withPath toolName
withPathDisplayName withPath displayName
withPathInvocation withPath invocationMessage
withPathPastTense withPath pastTenseMessage
withoutEventIdToolCallId withoutEventId toolCallId
withoutEventIdInvocation withoutEventId invocationMessage
withoutEventIdPastTense withoutEventId pastTenseMessage
skillIsHidden
withPathToolCallId
withPathToolName
withPathDisplayName
withPathInvocation markdown
withPathPastTense markdown
withoutEventIdToolCallId
withoutEventIdInvocation markdown
withoutEventIdPastTense markdown
msg ReturnType getInvocationMessage
msg msg msg markdown
inv pattern
past pattern
assert inv past
inv
past
inv
assert inv
inv pattern
past pattern
assert inv past
inv
past
assert pattern
assert pattern
msg ReturnType getInvocationMessage ReturnType getPastTenseMessage
msg msg msg markdown
parameters url
assert
invocation parameters
pastTense parameters
input parameters
invocation
pastTense
input
assert
invocation
pastTense
failure url
invocation
pastTense
failure
msg ReturnType getInvocationMessage ReturnType getPastTenseMessage
msg msg msg markdown
assert
webInvocation query
webComplete query
codeInvocation query
codeComplete query
webInvocation
webComplete
codeInvocation
codeComplete
msg ReturnType getInvocationMessage ReturnType getPastTenseMessage
msg msg msg markdown
parameters description query
assert parameters
assert parameters
assert query
assert query
msg ReturnType getInvocationMessage
msg msg msg markdown
singleFilePatch
multiFilePatch
inv input singleFilePatch
past input singleFilePatch
assert inv past
inv
past
inv input multiFilePatch
past input multiFilePatch
assert inv past
inv
past
assert
assert input
assert
inv patch singleFilePatch
assert inv
inv input singleFilePatch
past input singleFilePatch
assert inv past
inv
past
assert input singleFilePatch
assert input singleFilePatch
assert input multiFilePatch
assert patch singleFilePatch
assert input singleFilePatch
assert input
assert input singleFilePatch
assert input multiFilePatch
assert patch multiFilePatch
assert input multiFilePatch
assert path
assert input
assert
assert multiFilePatch
assert singleFilePatch
assert
bash command description
powershell command description
shellNoDescription command
shellEmptyDescription command description
taskTool description
viewTool path description
noArgs
bash
powershell
shellNoDescription
shellEmptyDescription
taskTool
viewTool
noArgs
}
from
'../../node/copilot/copilotToolDisplay.js'
;
type
CopilotShellPermissionRequest
=
<
,
{
:
'shell'
}
>
;
type
CopilotCustomToolPermissionRequest
=
<
,
{
:
'custom-tool'
}
>
;
function
shellPermissionRequest
(
:
string
,
?
:
boolean
)
:
{
return
{
:
'shell'
,
:
false
,
:
[
]
,
,
:
false
,
:
''
,
:
[
]
,
:
[
]
,
,
}
;
}
function
customToolPermissionRequest
(
:
string
,
:
[
'args'
]
)
:
{
return
{
:
'custom-tool'
,
,
:
''
,
,
}
;
}
suite
(
'copilotToolDisplay — friendly tool names'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
test
(
'mirrors internal Copilot CLI friendly labels for representative tools'
,
(
)
=>
{
const
:
Array
<
[
:
string
,
:
string
]
>
=
[
[
'bash'
,
'Run Shell Command'
]
,
[
'powershell'
,
'Run Shell Command'
]
,
[
'read_bash'
,
'Read Terminal'
]
,
[
'read_powershell'
,
'Read Terminal'
]
,
[
'write_bash'
,
'Write to Bash'
]
,
[
'write_powershell'
,
'Write to PowerShell'
]
,
[
'stop_bash'
,
'Stop Terminal Session'
]
,
[
'stop_powershell'
,
'Stop Terminal Session'
]
,
[
'bash_shutdown'
,
'Stop Terminal Session'
]
,
[
'powershell_shutdown'
,
'Stop Terminal Session'
]
,
[
'list_bash'
,
'List Shell Sessions'
]
,
[
'list_powershell'
,
'List Shell Sessions'
]
,
[
'view'
,
'Read'
]
,
[
'edit'
,
'Edit File'
]
,
[
'str_replace_editor'
,
'Edit File'
]
,
[
'str_replace'
,
'Edit File'
]
,
[
'insert'
,
'Edit File'
]
,
[
'create'
,
'Create File'
]
,
[
'grep'
,
'Search'
]
,
[
'rg'
,
'Search'
]
,
[
'glob'
,
'Search'
]
,
[
'search_code_subagent'
,
'Search Code'
]
,
[
'reply_to_comment'
,
'Reply to Comment'
]
,
[
'code_review'
,
'Code Review'
]
,
[
'think'
,
'Thinking'
]
,
[
'report_intent'
,
'Report Intent'
]
,
[
'report_progress'
,
'Progress update'
]
,
[
'web_fetch'
,
'Fetch Web Content'
]
,
[
'web_search'
,
'Web Search'
]
,
[
'update_todo'
,
'Update Todo'
]
,
[
'show_file'
,
'Show File'
]
,
[
'fetch_copilot_cli_documentation'
,
'Fetch Documentation'
]
,
[
'propose_work'
,
'Propose Work'
]
,
[
'task_complete'
,
'Task Complete'
]
,
[
'ask_user'
,
'Ask User'
]
,
[
'skill'
,
'Invoke Skill'
]
,
[
'task'
,
'Delegate Task'
]
,
[
'list_agents'
,
'List Agents'
]
,
[
'read_agent'
,
'Read Agent'
]
,
[
'exit_plan_mode'
,
'Exit Plan Mode'
]
,
[
'sql'
,
'Execute SQL'
]
,
[
'lsp'
,
'Language Server'
]
,
[
'create_pull_request'
,
'Create Pull Request'
]
,
[
'gh-advisory-database'
,
'Check Dependencies'
]
,
[
'store_memory'
,
'Store Memory'
]
,
[
'apply_patch'
,
'Apply Patch'
]
,
[
'write_agent'
,
'Write to Agent'
]
,
[
'mcp_reload'
,
'Reload MCP Config'
]
,
[
'mcp_validate'
,
'Validate MCP Config'
]
,
[
'tool_search_tool_regex'
,
'Search Tools'
]
,
[
'parallel_validation'
,
'Validate Changes'
]
,
[
'codeql_checker'
,
'CodeQL Security Scan'
]
,
[
'addComment'
,
'Add Comment'
]
,
[
'listComments'
,
'List Comments'
]
,
[
'replyToComment'
,
'Reply to Comment'
]
,
[
'deleteComments'
,
'Delete Comments'
]
,
[
'resolveComments'
,
'Resolve Comments'
]
,
[
'viewUnreviewedComments'
,
'View Comments'
]
,
]
;
for
(
const
[
,
]
of
)
{
.
strictEqual
(
getToolDisplayName
(
)
,
,
)
;
}
}
)
;
test
(
'falls back to the raw tool name for unknown tools'
,
(
)
=>
{
.
strictEqual
(
getToolDisplayName
(
'some_new_tool'
)
,
'some_new_tool'
)
;
}
)
;
}
)
;
suite
(
'copilotToolDisplay — edit tool classification'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
test
(
'classifies direct file edit tools'
,
(
)
=>
{
for
(
const
of
[
'edit'
,
'str_replace'
,
'insert'
,
'create'
,
'apply_patch'
,
'git_apply_patch'
]
)
{
.
strictEqual
(
isEditTool
(
)
,
true
,
)
;
}
}
)
;
test
(
'classifies str_replace_editor by command'
,
(
)
=>
{
for
(
const
of
[
'edit'
,
'str_replace'
,
'insert'
,
'create'
]
)
{
.
strictEqual
(
isEditTool
(
'str_replace_editor'
,
)
,
true
,
)
;
}
.
strictEqual
(
isEditTool
(
'str_replace_editor'
,
'view'
)
,
false
)
;
.
strictEqual
(
isEditTool
(
'str_replace_editor'
,
'unknown'
)
,
false
)
;
.
strictEqual
(
isEditTool
(
'str_replace_editor'
)
,
false
)
;
}
)
;
}
)
;
suite
(
'copilotToolDisplay — markdown-rendered tools'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
test
(
'task_complete renders as markdown, other tools do not'
,
(
)
=>
{
.
strictEqual
(
isMarkdownRenderedTool
(
'task_complete'
)
,
true
)
;
.
strictEqual
(
isMarkdownRenderedTool
(
'bash'
)
,
false
)
;
.
strictEqual
(
isMarkdownRenderedTool
(
'report_intent'
)
,
false
)
;
}
)
;
test
(
'getToolMarkdownContent returns the task_complete summary when present'
,
(
)
=>
{
.
strictEqual
(
getToolMarkdownContent
(
'task_complete'
,
{
:
'All tests pass.'
}
)
,
'\n\n**Task completed:** All tests pass.'
)
;
}
)
;
test
(
'getTaskCompleteMarkdown prefers the input summary over truncated tool output'
,
(
)
=>
{
const
=
'Output too large to read at once (11.3 KB). Saved to: /tmp/task-complete.txt'
;
.
deepStrictEqual
(
{
:
getTaskCompleteMarkdown
(
{
:
'Completed the requested work.'
}
,
)
,
:
getTaskCompleteMarkdown
(
{
}
,
'Fallback summary.'
)
,
}
,
{
:
'\n\n**Task completed:** Completed the requested work.'
,
:
'\n\n**Task completed:** Fallback summary.'
,
}
)
;
}
)
;
test
(
'getToolMarkdownContent returns undefined for empty, missing, or non-string summaries'
,
(
)
=>
{
.
strictEqual
(
getToolMarkdownContent
(
'task_complete'
,
{
:
''
}
)
,
undefined
)
;
.
strictEqual
(
getToolMarkdownContent
(
'task_complete'
,
{
}
)
,
undefined
)
;
.
strictEqual
(
getToolMarkdownContent
(
'task_complete'
,
undefined
)
,
undefined
)
;
.
strictEqual
(
getToolMarkdownContent
(
'task_complete'
,
{
:
42
}
)
,
undefined
)
;
}
)
;
test
(
'getToolMarkdownContent returns undefined for non-markdown tools'
,
(
)
=>
{
.
strictEqual
(
getToolMarkdownContent
(
'bash'
,
{
:
'ignored'
}
)
,
undefined
)
;
}
)
;
}
)
;
suite
(
'getPermissionDisplay — read confirmation title'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
const
=
URI
.
file
(
'/repo/project'
)
;
function
readRequest
(
:
string
,
?
:
boolean
)
:
{
return
{
:
'read'
,
:
` Read file: ${ path} `
,
,
...
(
?
{
}
:
{
}
)
}
as
;
}
function
unauthorizedPathGateRequest
(
...
:
string
[
]
)
:
{
return
{
:
'read'
,
:
'Read files'
,
}
as
unknown
as
;
}
test
(
'claims "outside of workspace" only when the path really is outside'
,
(
)
=>
{
.
deepStrictEqual
(
{
:
getPermissionDisplay
(
readRequest
(
'/repo/project/src/app.ts'
)
,
)
.
,
:
getPermissionDisplay
(
readRequest
(
'/repo/project/src'
)
,
)
.
,
:
getPermissionDisplay
(
readRequest
(
'/etc/hosts'
)
,
)
.
,
:
getPermissionDisplay
(
readRequest
(
'/repo/other/lib.ts'
)
,
,
undefined
,
[
URI
.
file
(
'/repo/other'
)
]
)
.
,
:
getPermissionDisplay
(
readRequest
(
'/etc/hosts'
)
,
,
undefined
,
[
URI
.
file
(
'/repo/other'
)
]
)
.
,
:
getPermissionDisplay
(
unauthorizedPathGateRequest
(
'/etc/hosts'
)
,
)
.
,
:
getPermissionDisplay
(
readRequest
(
'README.md'
)
,
)
.
,
:
getPermissionDisplay
(
readRequest
(
'/repo/project/src/app.ts'
)
,
undefined
)
.
,
:
getPermissionDisplay
(
readRequest
(
'/repo/project/src/app.ts'
,
true
)
,
)
.
,
}
,
{
:
'Allow reading file?'
,
:
'Allow reading file?'
,
:
'Allow reading file outside of workspace?'
,
:
'Allow reading file?'
,
:
'Allow reading file outside of workspace?'
,
:
'Allow reading file outside of workspace?'
,
:
'Allow reading file?'
,
:
'Allow reading file?'
,
:
'Read file outside the sandbox?'
,
}
)
;
}
)
;
}
)
;
suite
(
'getPermissionDisplay — cd-prefix stripping'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
const
=
URI
.
file
(
'/repo/project'
)
;
test
(
'strips redundant cd from shell permission request fullCommandText'
,
(
)
=>
{
const
=
shellPermissionRequest
(
'cd /repo/project && npm test'
)
;
const
=
getPermissionDisplay
(
,
)
;
.
strictEqual
(
.
,
'npm test'
)
;
.
strictEqual
(
.
,
'shell'
)
;
}
)
;
test
(
'leaves shell command alone when cd target differs from working directory'
,
(
)
=>
{
const
=
shellPermissionRequest
(
'cd /tmp && ls'
)
;
const
=
getPermissionDisplay
(
,
)
;
.
strictEqual
(
.
,
'cd /tmp && ls'
)
;
}
)
;
test
(
'leaves shell command alone when no working directory provided'
,
(
)
=>
{
const
=
shellPermissionRequest
(
'cd /repo/project && npm test'
)
;
const
=
getPermissionDisplay
(
,
undefined
)
;
.
strictEqual
(
.
,
'cd /repo/project && npm test'
)
;
}
)
;
test
(
'strips redundant cd from custom-tool shell permission request'
,
(
)
=>
{
const
=
customToolPermissionRequest
(
'bash'
,
{
:
'cd /repo/project && echo hi'
}
)
;
const
=
getPermissionDisplay
(
,
)
;
.
strictEqual
(
.
,
'echo hi'
)
;
.
strictEqual
(
.
,
'shell'
)
;
}
)
;
test
(
'does not affect non-shell custom-tool requests'
,
(
)
=>
{
const
=
customToolPermissionRequest
(
'some_other_tool'
,
{
:
'cd /repo/project && echo hi'
}
)
;
const
=
getPermissionDisplay
(
,
)
;
.
ok
(
.
?.
includes
(
'cd /repo/project'
)
,
` expected unrewritten args, got: ${ display. toolInput} `
)
;
.
strictEqual
(
.
,
'custom-tool'
)
;
}
)
;
test
(
'handles powershell custom-tool with semicolon separator'
,
(
)
=>
{
const
=
customToolPermissionRequest
(
'powershell'
,
{
:
'cd /repo/project; dir'
}
)
;
const
=
getPermissionDisplay
(
,
)
;
.
strictEqual
(
.
,
'dir'
)
;
}
)
;
test
(
'confirmation title reflects sandbox bypass for shell requests'
,
(
)
=>
{
const
=
getPermissionDisplay
(
shellPermissionRequest
(
'npm test'
)
,
)
;
const
=
getPermissionDisplay
(
shellPermissionRequest
(
'npm test'
,
true
)
,
)
;
.
notStrictEqual
(
.
,
.
)
;
.
ok
(
/ sandbox / i
.
test
(
.
)
,
` expected title to mention the sandbox, got: ${ bypass. confirmationTitle} `
)
;
}
)
;
}
)
;
suite
(
'getPermissionDisplay — read permission display'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
test
(
'uses the view-tool invocation message for read permissions'
,
(
)
=>
{
const
=
getPermissionDisplay
(
{
:
'read'
,
:
'/Users/connor/Downloads/context7-copilot-debug-main.json'
,
:
'Read file: /Users/connor/Downloads/context7-copilot-debug-main.json'
,
}
,
URI
.
file
(
'/repo/project'
)
)
;
.
deepStrictEqual
(
{
:
.
,
:
.
,
:
.
,
:
.
,
}
,
{
:
{
:
'Read [context7-copilot-debug-main.json](file:///Users/connor/Downloads/context7-copilot-debug-main.json)'
}
,
:
undefined
,
:
'read'
,
:
'/Users/connor/Downloads/context7-copilot-debug-main.json'
,
}
)
;
}
)
;
}
)
;
suite
(
'getPermissionDisplay — write permission display'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
test
(
'distinguishes creating a file from editing one'
,
(
)
=>
{
const
=
{
:
'write'
,
:
false
,
:
''
,
:
'/repo/project/package.json'
,
:
''
,
}
;
.
deepStrictEqual
(
{
:
getPermissionDisplay
(
,
URI
.
file
(
'/repo/project'
)
,
true
)
,
:
getPermissionDisplay
(
,
URI
.
file
(
'/repo/project'
)
,
false
)
,
}
,
{
:
{
:
'Create file?'
,
:
{
:
'Create [package.json](file:///repo/project/package.json)'
}
,
:
'{"path":"/repo/project/package.json"}'
,
:
'write'
,
:
'/repo/project/package.json'
,
}
,
:
{
:
'Write file?'
,
:
{
:
'Edit [package.json](file:///repo/project/package.json)'
}
,
:
'{"path":"/repo/project/package.json"}'
,
:
'write'
,
:
'/repo/project/package.json'
,
}
,
}
)
;
}
)
;
}
)
;
suite
(
'view tool — view_range display'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
function
invocation
(
:
<
string
,
unknown
>
|
undefined
)
:
string
{
const
=
getInvocationMessage
(
'view'
,
'View File'
,
)
;
return
typeof
===
'string'
?
:
.
;
}
function
pastTense
(
:
<
string
,
unknown
>
|
undefined
)
:
string
{
const
=
getPastTenseMessage
(
'view'
,
'View File'
,
,
true
)
;
return
typeof
===
'string'
?
:
.
;
}
test
(
'renders path-only when view_range is absent'
,
(
)
=>
{
.
ok
(
invocation
(
{
:
'/repo/file.ts'
}
)
.
startsWith
(
'Read ['
)
)
;
.
ok
(
pastTense
(
{
:
'/repo/file.ts'
}
)
.
startsWith
(
'Read ['
)
)
;
}
)
;
test
(
'renders Copilot SDK tool-output reads without exposing the temp path'
,
(
)
=>
{
const
=
[
'/tmp/1786468439523-copilot-tool-output-d115e2.txt'
,
'/tmp/1786499016779-copilot-tool-output-44600-1a0a63b8-4548-4fb8-a507-da72473e0556.txt'
,
'C:\\Temp\\copilot-tool-output-1786468439523-d115e2.txt'
,
'C:\\Temp\\copilot-tool-output-1786499172415-297.txt'
,
]
;
.
deepStrictEqual
(
.
map
(
=>
(
{
:
invocation
(
{
,
:
[
107
,
119
]
}
)
,
:
pastTense
(
{
,
:
[
107
,
119
]
}
)
,
}
)
)
,
[
{
:
'Read tool output'
,
:
'Read tool output'
}
,
{
:
'Read tool output'
,
:
'Read tool output'
}
,
{
:
'Read tool output'
,
:
'Read tool output'
}
,
{
:
'Read tool output'
,
:
'Read tool output'
}
,
]
,
)
;
}
)
;
test
(
'renders "lines X to Y" for a valid two-element range'
,
(
)
=>
{
.
ok
(
invocation
(
{
:
'/repo/file.ts'
,
:
[
10
,
20
]
}
)
.
endsWith
(
', lines 10 to 20'
)
)
;
.
ok
(
pastTense
(
{
:
'/repo/file.ts'
,
:
[
10
,
20
]
}
)
.
endsWith
(
', lines 10 to 20'
)
)
;
}
)
;
test
(
'renders "line X" when start === end'
,
(
)
=>
{
.
ok
(
invocation
(
{
:
'/repo/file.ts'
,
:
[
10
,
10
]
}
)
.
endsWith
(
', line 10'
)
)
;
.
ok
(
pastTense
(
{
:
'/repo/file.ts'
,
:
[
10
,
10
]
}
)
.
endsWith
(
', line 10'
)
)
;
}
)
;
test
(
'renders "line X to the end" for the -1 EOF sentinel'
,
(
)
=>
{
.
ok
(
invocation
(
{
:
'/repo/file.ts'
,
:
[
10
,
-
1
]
}
)
.
endsWith
(
', line 10 to the end'
)
)
;
.
ok
(
pastTense
(
{
:
'/repo/file.ts'
,
:
[
10
,
-
1
]
}
)
.
endsWith
(
', line 10 to the end'
)
)
;
}
)
;
test
(
'falls back to path-only for invalid ranges'
,
(
)
=>
{
.
ok
(
!
invocation
(
{
:
'/repo/file.ts'
,
:
[
20
,
10
]
}
)
.
includes
(
','
)
)
;
.
ok
(
!
invocation
(
{
:
'/repo/file.ts'
,
:
[
-
5
,
10
]
}
)
.
includes
(
','
)
)
;
.
ok
(
!
invocation
(
{
:
'/repo/file.ts'
,
:
[
1.5
,
10
]
}
)
.
includes
(
','
)
)
;
.
ok
(
!
invocation
(
{
:
'/repo/file.ts'
,
:
[
10
]
}
)
.
includes
(
','
)
)
;
.
ok
(
!
invocation
(
{
:
'/repo/file.ts'
,
:
[
10
,
20
,
30
]
}
)
.
includes
(
','
)
)
;
.
ok
(
!
invocation
(
{
:
'/repo/file.ts'
,
:
'whatever'
}
)
.
includes
(
','
)
)
;
}
)
;
}
)
;
suite
(
'copilotToolDisplay — built-in tool invocation/past-tense messages'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
function
invocation
(
:
string
,
:
<
string
,
unknown
>
|
undefined
)
:
string
{
const
=
getInvocationMessage
(
,
getToolDisplayName
(
)
,
)
;
return
typeof
===
'string'
?
:
.
;
}
function
pastTense
(
:
string
,
:
<
string
,
unknown
>
|
undefined
)
:
string
{
const
=
getPastTenseMessage
(
,
getToolDisplayName
(
)
,
,
true
)
;
return
typeof
===
'string'
?
:
.
;
}
test
(
'agent-coordination tools use a single message for both invocation and completion'
,
(
)
=>
{
.
strictEqual
(
invocation
(
'read_agent'
,
{
:
'math-helper'
}
)
,
'Read agent `math-helper`'
)
;
.
strictEqual
(
pastTense
(
'read_agent'
,
{
:
'math-helper'
}
)
,
'Read agent `math-helper`'
)
;
.
strictEqual
(
invocation
(
'write_agent'
,
{
:
'math-helper'
,
:
'hi'
}
)
,
'Write to agent `math-helper`'
)
;
.
strictEqual
(
pastTense
(
'write_agent'
,
{
:
'math-helper'
,
:
'hi'
}
)
,
'Write to agent `math-helper`'
)
;
}
)
;
test
(
'agent tools fall back to a generic phrase without an agent id'
,
(
)
=>
{
.
strictEqual
(
invocation
(
'read_agent'
,
{
}
)
,
'Read agent'
)
;
.
strictEqual
(
pastTense
(
'write_agent'
,
undefined
)
,
'Write to agent'
)
;
}
)
;
test
(
'agent tools ignore a malformed (non-string) agent id instead of throwing'
,
(
)
=>
{
.
strictEqual
(
invocation
(
'read_agent'
,
{
:
123
}
)
,
'Read agent'
)
;
.
strictEqual
(
pastTense
(
'write_agent'
,
{
:
''
}
)
,
'Write to agent'
)
;
}
)
;
test
(
'list_agents shares one message; task keeps distinct present/past phrases'
,
(
)
=>
{
.
strictEqual
(
invocation
(
'list_agents'
,
{
}
)
,
'List agents'
)
;
.
strictEqual
(
pastTense
(
'list_agents'
,
{
}
)
,
'List agents'
)
;
.
strictEqual
(
invocation
(
'task'
,
{
}
)
,
'Delegating task'
)
;
.
strictEqual
(
pastTense
(
'task'
,
{
}
)
,
'Delegated task'
)
;
}
)
;
test
(
'unhandled tools fall back to just the display name'
,
(
)
=>
{
.
strictEqual
(
invocation
(
'store_memory'
,
{
}
)
,
'Store Memory'
)
;
.
strictEqual
(
pastTense
(
'store_memory'
,
{
}
)
,
'Store Memory'
)
;
.
strictEqual
(
invocation
(
'some_new_tool'
,
{
}
)
,
'some_new_tool'
)
;
.
strictEqual
(
pastTense
(
'some_new_tool'
,
{
}
)
,
'some_new_tool'
)
;
}
)
;
}
)
;
suite
(
'copilotToolDisplay — streaming edit messages'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
function
streaming
(
:
string
,
:
unknown
,
?
:
(
:
string
)
=>
string
)
:
string
{
const
=
getStreamingInvocationMessage
(
,
getToolDisplayName
(
)
,
,
)
;
return
typeof
===
'string'
?
:
.
;
}
function
invocation
(
:
string
,
:
<
string
,
unknown
>
)
:
string
{
const
=
getInvocationMessage
(
,
getToolDisplayName
(
)
,
)
;
return
typeof
===
'string'
?
:
.
;
}
function
completed
(
:
string
,
:
<
string
,
unknown
>
)
:
string
{
const
=
getPastTenseMessage
(
,
getToolDisplayName
(
)
,
,
true
)
;
return
typeof
===
'string'
?
:
.
;
}
test
(
'streams replacement line counts and the target file'
,
(
)
=>
{
.
deepStrictEqual
(
[
streaming
(
'edit'
,
{
:
'/repo/file.ts'
}
)
,
streaming
(
'edit'
,
{
:
'/repo/file.ts'
,
:
'one\ntwo'
}
)
,
streaming
(
'edit'
,
{
:
'/repo/file.ts'
,
:
'one\ntwo'
,
:
'one\nupdated\nthree'
}
)
,
]
,
[
'Editing [file.ts](file:///repo/file.ts)'
,
'Replacing 2 lines in [file.ts](file:///repo/file.ts)'
,
'Replacing 2 lines with 3 lines in [file.ts](file:///repo/file.ts)'
,
]
)
;
}
)
;
test
(
'streams create and insert line counts'
,
(
)
=>
{
.
deepStrictEqual
(
[
streaming
(
'create'
,
{
:
'/repo/new.ts'
,
:
'one\r\ntwo\r\nthree'
}
)
,
streaming
(
'insert'
,
{
:
'/repo/file.ts'
,
:
'one\rtwo'
}
)
,
]
,
[
'Creating [new.ts](file:///repo/new.ts) (3 lines)'
,
'Inserting 2 lines in [file.ts](file:///repo/file.ts)'
,
]
)
;
}
)
;
test
(
'uses the str_replace_editor command shape'
,
(
)
=>
{
.
deepStrictEqual
(
[
streaming
(
'str_replace_editor'
,
{
:
'create'
,
:
'/repo/new.ts'
,
:
'one\ntwo'
}
)
,
streaming
(
'str_replace_editor'
,
{
:
'str_replace'
,
:
'/repo/file.ts'
,
:
'old'
,
:
'new\nvalue'
}
)
,
streaming
(
'str_replace_editor'
,
{
:
'view'
,
:
'/repo/file.ts'
}
)
,
]
,
[
'Creating [new.ts](file:///repo/new.ts) (2 lines)'
,
'Replacing 1 line with 2 lines in [file.ts](file:///repo/file.ts)'
,
'Read [file.ts](file:///repo/file.ts)'
,
]
)
;
}
)
;
test
(
'preserves file context after streaming aliases become ready and complete'
,
(
)
=>
{
const
:
Array
<
[
:
string
,
:
<
string
,
unknown
>
,
:
string
,
:
string
]
>
=
[
[
'str_replace'
,
{
:
'/repo/file.ts'
}
,
'Edit [file.ts](file:///repo/file.ts)'
,
'Edit [file.ts](file:///repo/file.ts)'
]
,
[
'insert'
,
{
:
'/repo/file.ts'
}
,
'Insert text in [file.ts](file:///repo/file.ts)'
,
'Insert text in [file.ts](file:///repo/file.ts)'
]
,
[
'str_replace_editor'
,
{
:
'create'
,
:
'/repo/new.ts'
}
,
'Create [new.ts](file:///repo/new.ts)'
,
'Create [new.ts](file:///repo/new.ts)'
]
,
[
'str_replace_editor'
,
{
:
'str_replace'
,
:
'/repo/file.ts'
}
,
'Edit [file.ts](file:///repo/file.ts)'
,
'Edit [file.ts](file:///repo/file.ts)'
]
,
]
;
.
deepStrictEqual
(
.
map
(
(
[
,
]
)
=>
(
{
:
invocation
(
,
)
,
:
completed
(
,
)
,
}
)
)
,
.
map
(
(
[
,
,
,
]
)
=>
(
{
,
}
)
)
)
;
}
)
;
test
(
'streams raw patch line counts and resolves discovered file paths'
,
(
)
=>
{
const
=
[
'*** Begin Patch'
,
'*** Update File: src/file.ts'
,
'@@'
,
'-old'
,
'+new'
,
'*** End Patch'
,
]
.
join
(
'\n'
)
;
.
strictEqual
(
streaming
(
'apply_patch'
,
,
=>
` /workspace/ ${ path} `
)
,
'Generating patch (6 lines) in [file.ts](file:///workspace/src/file.ts)'
,
)
;
}
)
;
test
(
'ignores malformed partial paths'
,
(
)
=>
{
.
strictEqual
(
streaming
(
'edit'
,
{
:
42
,
:
'one'
}
)
,
'Replacing 1 line'
,
)
;
}
)
;
test
(
'falls back to the normal invocation formatter for non-edit tools'
,
(
)
=>
{
.
strictEqual
(
streaming
(
'bash'
,
{
:
'npm test'
}
)
,
'Running `npm test`'
,
)
;
}
)
;
}
)
;
suite
(
'copilotToolDisplay — write_/read_ shell tools'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
suite
(
'getToolKind'
,
(
)
=>
{
test
(
'returns terminal for bash'
,
(
)
=>
{
.
strictEqual
(
getToolKind
(
'bash'
)
,
'terminal'
)
;
}
)
;
test
(
'returns terminal for powershell'
,
(
)
=>
{
.
strictEqual
(
getToolKind
(
'powershell'
)
,
'terminal'
)
;
}
)
;
test
(
'returns undefined for write_bash (sending input to a running program, not launching a terminal)'
,
(
)
=>
{
.
strictEqual
(
getToolKind
(
'write_bash'
)
,
undefined
)
;
}
)
;
test
(
'returns undefined for write_powershell'
,
(
)
=>
{
.
strictEqual
(
getToolKind
(
'write_powershell'
)
,
undefined
)
;
}
)
;
test
(
'returns undefined for read_bash (reading output, not launching a terminal)'
,
(
)
=>
{
.
strictEqual
(
getToolKind
(
'read_bash'
)
,
undefined
)
;
}
)
;
test
(
'returns undefined for read_powershell'
,
(
)
=>
{
.
strictEqual
(
getToolKind
(
'read_powershell'
)
,
undefined
)
;
}
)
;
test
(
'returns subagent for task'
,
(
)
=>
{
.
strictEqual
(
getToolKind
(
'task'
)
,
'subagent'
)
;
}
)
;
test
(
'returns read for file reads'
,
(
)
=>
{
.
deepStrictEqual
(
[
getToolKind
(
'view'
)
,
getToolKind
(
'str_replace_editor'
,
{
:
'view'
}
)
,
getToolKind
(
'str_replace_editor'
,
{
:
'str_replace'
}
)
,
]
,
[
'read'
,
'read'
,
undefined
,
]
)
;
}
)
;
test
(
'returns search for glob'
,
(
)
=>
{
.
strictEqual
(
getToolKind
(
'glob'
)
,
'search'
)
;
}
)
;
}
)
;
suite
(
'getShellLanguage'
,
(
)
=>
{
test
(
'bash returns shellscript'
,
(
)
=>
{
.
strictEqual
(
getShellLanguage
(
'bash'
)
,
'shellscript'
)
;
}
)
;
test
(
'powershell returns powershell'
,
(
)
=>
{
.
strictEqual
(
getShellLanguage
(
'powershell'
)
,
'powershell'
)
;
}
)
;
test
(
'write_bash returns shellscript'
,
(
)
=>
{
.
strictEqual
(
getShellLanguage
(
'write_bash'
)
,
'shellscript'
)
;
}
)
;
test
(
'write_powershell returns powershell'
,
(
)
=>
{
.
strictEqual
(
getShellLanguage
(
'write_powershell'
)
,
'powershell'
)
;
}
)
;
test
(
'read_bash returns shellscript'
,
(
)
=>
{
.
strictEqual
(
getShellLanguage
(
'read_bash'
)
,
'shellscript'
)
;
}
)
;
test
(
'read_powershell returns powershell'
,
(
)
=>
{
.
strictEqual
(
getShellLanguage
(
'read_powershell'
)
,
'powershell'
)
;
}
)
;
}
)
;
suite
(
'getInvocationMessage'
,
(
)
=>
{
function
getText
(
:
<
typeof
>
)
:
string
{
return
typeof
===
'string'
?
:
.
;
}
test
(
'write_bash with command includes the command text'
,
(
)
=>
{
const
=
getInvocationMessage
(
'write_bash'
,
'Write Shell Input'
,
{
:
'echo hello'
}
)
;
.
ok
(
getText
(
)
.
includes
(
'echo hello'
)
,
` expected 'echo hello' in: ${ getText ( msg) } `
)
;
}
)
;
test
(
'write_bash without command returns a non-empty fallback message'
,
(
)
=>
{
const
=
getInvocationMessage
(
'write_bash'
,
'Write Shell Input'
,
undefined
)
;
.
ok
(
getText
(
)
.
>
0
)
;
.
ok
(
!
getText
(
)
.
includes
(
'undefined'
)
)
;
}
)
;
test
(
'write_powershell with command includes the command text'
,
(
)
=>
{
const
=
getInvocationMessage
(
'write_powershell'
,
'Write Shell Input'
,
{
:
'Get-Date'
}
)
;
.
ok
(
getText
(
)
.
includes
(
'Get-Date'
)
,
` expected 'Get-Date' in: ${ getText ( msg) } `
)
;
}
)
;
test
(
'read_bash returns a non-empty message'
,
(
)
=>
{
const
=
getInvocationMessage
(
'read_bash'
,
'Read Shell Output'
,
undefined
)
;
.
strictEqual
(
getText
(
)
,
'Reading Terminal'
)
;
}
)
;
test
(
'read_powershell returns a non-empty message'
,
(
)
=>
{
const
=
getInvocationMessage
(
'read_powershell'
,
'Read Shell Output'
,
undefined
)
;
.
strictEqual
(
getText
(
)
,
'Reading Terminal'
)
;
}
)
;
test
(
'write_bash message differs from bash message (distinct wording)'
,
(
)
=>
{
const
=
getText
(
getInvocationMessage
(
'write_bash'
,
'Write Shell Input'
,
{
:
'echo hi'
}
)
)
;
const
=
getText
(
getInvocationMessage
(
'bash'
,
'Bash'
,
{
:
'echo hi'
}
)
)
;
.
notStrictEqual
(
,
)
;
}
)
;
}
)
;
suite
(
'getPastTenseMessage'
,
(
)
=>
{
function
getText
(
:
<
typeof
>
)
:
string
{
return
typeof
===
'string'
?
:
.
;
}
test
(
'write_bash with command includes the command text'
,
(
)
=>
{
const
=
getPastTenseMessage
(
'write_bash'
,
'Write Shell Input'
,
{
:
'echo hello'
}
,
true
)
;
.
ok
(
getText
(
)
.
includes
(
'echo hello'
)
,
` expected 'echo hello' in: ${ getText ( msg) } `
)
;
}
)
;
test
(
'write_bash without command returns a non-empty fallback message'
,
(
)
=>
{
const
=
getPastTenseMessage
(
'write_bash'
,
'Write Shell Input'
,
undefined
,
true
)
;
.
ok
(
getText
(
)
.
>
0
)
;
}
)
;
test
(
'write_powershell with command includes the command text'
,
(
)
=>
{
const
=
getPastTenseMessage
(
'write_powershell'
,
'Write Shell Input'
,
{
:
'Get-Date'
}
,
true
)
;
.
ok
(
getText
(
)
.
includes
(
'Get-Date'
)
,
` expected 'Get-Date' in: ${ getText ( msg) } `
)
;
}
)
;
test
(
'read_bash success returns a non-empty message'
,
(
)
=>
{
const
=
getPastTenseMessage
(
'read_bash'
,
'Read Shell Output'
,
undefined
,
true
)
;
.
strictEqual
(
getText
(
)
,
'Read Terminal'
)
;
}
)
;
test
(
'write_bash failure returns a non-empty error message'
,
(
)
=>
{
const
=
getPastTenseMessage
(
'write_bash'
,
'Write Shell Input'
,
{
:
'echo hello'
}
,
false
)
;
.
ok
(
getText
(
)
.
>
0
)
;
}
)
;
}
)
;
suite
(
'feedback comment tools (delegated to the shared server-tool group)'
,
(
)
=>
{
function
text
(
:
<
typeof
>
|
<
typeof
>
)
:
string
{
return
typeof
===
'string'
?
:
.
;
}
test
(
'Copilot display delegates to the shared group'
,
(
)
=>
{
const
=
JSON
.
stringify
(
{
:
[
{
:
'a'
}
,
{
:
'b'
}
]
}
)
;
.
deepStrictEqual
(
{
:
getToolDisplayName
(
'listComments'
)
,
:
text
(
getInvocationMessage
(
'listComments'
,
'List Comments'
,
undefined
)
)
,
:
text
(
getPastTenseMessage
(
'listComments'
,
'List Comments'
,
undefined
,
true
,
)
)
,
}
,
{
:
'List Comments'
,
:
'List comments'
,
:
'List comments'
,
}
)
;
}
)
;
test
(
'failed feedback tool still uses the generic failure message'
,
(
)
=>
{
.
strictEqual
(
text
(
getPastTenseMessage
(
'listComments'
,
'List Comments'
,
undefined
,
false
)
)
,
'"List Comments" failed'
)
;
}
)
;
}
)
;
suite
(
'getToolInputString'
,
(
)
=>
{
test
(
'write_bash extracts command field'
,
(
)
=>
{
.
strictEqual
(
getToolInputString
(
'write_bash'
,
{
:
'echo hello'
}
,
undefined
)
,
'echo hello'
)
;
}
)
;
test
(
'write_powershell extracts command field'
,
(
)
=>
{
.
strictEqual
(
getToolInputString
(
'write_powershell'
,
{
:
'Get-Date'
}
,
undefined
)
,
'Get-Date'
)
;
}
)
;
test
(
'write_bash falls back to rawArguments when no command field'
,
(
)
=>
{
.
strictEqual
(
getToolInputString
(
'write_bash'
,
{
}
,
'{"command":"echo hello"}'
)
,
'{"command":"echo hello"}'
)
;
}
)
;
test
(
'write_bash returns undefined when both parameters and rawArguments are absent'
,
(
)
=>
{
.
strictEqual
(
getToolInputString
(
'write_bash'
,
undefined
,
undefined
)
,
undefined
)
;
}
)
;
test
(
'read_bash with no parameters returns undefined'
,
(
)
=>
{
.
strictEqual
(
getToolInputString
(
'read_bash'
,
undefined
,
undefined
)
,
undefined
)
;
}
)
;
}
)
;
}
)
;
suite
(
'skill events'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
test
(
'hides the raw `skill` tool call and synthesizes a tool-start/complete pair from `skill.invoked`'
,
(
)
=>
{
const
=
synthesizeSkillToolCall
(
{
:
'plan'
,
:
'/abs/repo/skills/plan/SKILL.md'
,
:
''
}
,
'evt-123'
,
)
;
const
=
synthesizeSkillToolCall
(
{
:
'plan'
,
:
'/abs/repo/skills/plan/SKILL.md'
,
:
''
}
,
undefined
,
)
;
.
deepStrictEqual
(
{
:
isHiddenTool
(
'skill'
)
,
:
.
,
:
.
,
:
.
,
:
.
,
:
.
,
:
.
,
:
.
,
:
.
,
}
,
{
:
true
,
:
'synth-skill-evt-123'
,
:
'skill'
,
:
'Read Skill'
,
:
{
:
'Read skill [plan](file:///abs/repo/skills/plan/SKILL.md)'
}
,
:
{
:
'Read skill [plan](file:///abs/repo/skills/plan/SKILL.md)'
}
,
:
'synth-skill--15753539'
,
:
{
:
'Read skill [plan](file:///abs/repo/skills/plan/SKILL.md)'
}
,
:
{
:
'Read skill [plan](file:///abs/repo/skills/plan/SKILL.md)'
}
,
}
)
;
}
)
;
}
)
;
suite
(
'rg / grep search tool display'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
function
text
(
:
<
typeof
>
)
:
string
{
return
typeof
===
'string'
?
:
.
;
}
test
(
'rg uses one stable search message'
,
(
)
=>
{
const
=
text
(
getInvocationMessage
(
'rg'
,
'Search'
,
{
:
'foo'
}
)
)
;
const
=
text
(
getPastTenseMessage
(
'rg'
,
'Search'
,
{
:
'foo'
}
,
true
)
)
;
.
deepStrictEqual
(
{
,
}
,
{
:
'Search for `foo`'
,
:
'Search for `foo`'
,
}
)
;
}
)
;
test
(
'rg without a pattern falls back to a generic search message (not the raw tool name)'
,
(
)
=>
{
const
=
text
(
getInvocationMessage
(
'rg'
,
'Search'
,
undefined
)
)
;
.
strictEqual
(
,
'Search files'
)
;
}
)
;
test
(
'grep uses one stable search message'
,
(
)
=>
{
const
=
text
(
getInvocationMessage
(
'grep'
,
'Search'
,
{
:
'bar'
}
)
)
;
const
=
text
(
getPastTenseMessage
(
'grep'
,
'Search'
,
{
:
'bar'
}
,
true
)
)
;
.
deepStrictEqual
(
{
,
}
,
{
:
'Search for `bar`'
,
:
'Search for `bar`'
,
}
)
;
}
)
;
test
(
'getToolInputString returns pattern for both grep and rg'
,
(
)
=>
{
.
strictEqual
(
getToolInputString
(
'grep'
,
{
:
'abc'
}
,
undefined
)
,
'abc'
)
;
.
strictEqual
(
getToolInputString
(
'rg'
,
{
:
'abc'
}
,
undefined
)
,
'abc'
)
;
}
)
;
}
)
;
suite
(
'web_fetch tool display'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
function
text
(
:
<
typeof
>
|
<
typeof
>
)
:
string
{
return
typeof
===
'string'
?
:
.
;
}
test
(
'uses the fetched URL for invocation and completion messages'
,
(
)
=>
{
const
=
{
:
'https://example.com/docs'
}
;
.
deepStrictEqual
(
{
:
text
(
getInvocationMessage
(
'web_fetch'
,
'Fetch Web Content'
,
)
)
,
:
text
(
getPastTenseMessage
(
'web_fetch'
,
'Fetch Web Content'
,
,
true
)
)
,
:
getToolInputString
(
'web_fetch'
,
,
undefined
)
,
}
,
{
:
'Fetching [https://example.com/docs](https://example.com/docs)'
,
:
'Fetched [https://example.com/docs](https://example.com/docs)'
,
:
'https://example.com/docs'
,
}
)
;
}
)
;
test
(
'falls back to generic URL wording when the URL is absent'
,
(
)
=>
{
.
deepStrictEqual
(
{
:
text
(
getInvocationMessage
(
'web_fetch'
,
'Fetch Web Content'
,
undefined
)
)
,
:
text
(
getPastTenseMessage
(
'web_fetch'
,
'Fetch Web Content'
,
undefined
,
true
)
)
,
:
text
(
getPastTenseMessage
(
'web_fetch'
,
'Fetch Web Content'
,
{
:
'https://example.com/docs'
}
,
false
)
)
,
}
,
{
:
'Fetching URL'
,
:
'Fetched URL'
,
:
'"Fetch Web Content" failed'
,
}
)
;
}
)
;
}
)
;
suite
(
'search tool display'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
function
text
(
:
<
typeof
>
|
<
typeof
>
)
:
string
{
return
typeof
===
'string'
?
:
.
;
}
test
(
'web search has progress wording while code search stays stable'
,
(
)
=>
{
.
deepStrictEqual
(
{
:
text
(
getInvocationMessage
(
'web_search'
,
'Web Search'
,
{
:
'VS Code tests'
}
)
)
,
:
text
(
getPastTenseMessage
(
'web_search'
,
'Web Search'
,
{
:
'VS Code tests'
}
,
true
)
)
,
:
text
(
getInvocationMessage
(
'search_code_subagent'
,
'Search Code'
,
{
:
'tool display mapping'
}
)
)
,
:
text
(
getPastTenseMessage
(
'search_code_subagent'
,
'Search Code'
,
{
:
'tool display mapping'
}
,
true
)
)
,
}
,
{
:
'Searching the web for `VS Code tests`'
,
:
'Searched the web for `VS Code tests`'
,
:
'Search code for `tool display mapping`'
,
:
'Search code for `tool display mapping`'
,
}
)
;
}
)
;
}
)
;
suite
(
'sql tool display'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
function
text
(
:
<
typeof
>
|
<
typeof
>
)
:
string
{
return
typeof
===
'string'
?
:
.
;
}
test
(
'uses the SQL description for invocation and completion messages'
,
(
)
=>
{
const
=
{
:
'Insert agent host study todos'
,
:
'INSERT INTO todos (title) VALUES (\'Read terminal activation docs\')'
}
;
.
strictEqual
(
text
(
getInvocationMessage
(
'sql'
,
'Execute SQL'
,
)
)
,
'Insert agent host study todos'
)
;
.
strictEqual
(
text
(
getPastTenseMessage
(
'sql'
,
'Execute SQL'
,
,
true
)
)
,
'Insert agent host study todos'
)
;
}
)
;
test
(
'falls back to generic SQL wording when description is absent'
,
(
)
=>
{
.
strictEqual
(
text
(
getInvocationMessage
(
'sql'
,
'Execute SQL'
,
{
:
'SELECT 1'
}
)
)
,
'Execute SQL query'
)
;
.
strictEqual
(
text
(
getPastTenseMessage
(
'sql'
,
'Execute SQL'
,
{
:
'SELECT 1'
}
,
true
)
)
,
'Execute SQL query'
)
;
}
)
;
}
)
;
suite
(
'apply_patch tool display'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
function
text
(
:
<
typeof
>
)
:
string
{
return
typeof
===
'string'
?
:
.
;
}
const
=
[
'*** Begin Patch'
,
'*** Update File: /repo/src/foo.ts'
,
'@@'
,
'-old'
,
'+new'
,
'*** End Patch'
,
]
.
join
(
'\n'
)
;
const
=
[
'*** Begin Patch'
,
'*** Update File: /repo/src/foo.ts'
,
'@@'
,
'-old'
,
'+new'
,
'*** Add File: /repo/src/bar.ts'
,
'+hello'
,
'*** Delete File: /repo/src/baz.ts'
,
'*** End Patch'
,
]
.
join
(
'\n'
)
;
test
(
'renders a clickable file link for a single-file patch'
,
(
)
=>
{
const
=
text
(
getInvocationMessage
(
'apply_patch'
,
'Patch'
,
{
:
}
)
)
;
const
=
text
(
getPastTenseMessage
(
'apply_patch'
,
'Patch'
,
{
:
}
,
true
)
)
;
.
deepStrictEqual
(
{
,
}
,
{
:
'Edit [foo.ts](file:///repo/src/foo.ts)'
,
:
'Edit [foo.ts](file:///repo/src/foo.ts)'
,
}
)
;
}
)
;
test
(
'lists every affected file for a multi-file patch'
,
(
)
=>
{
const
=
text
(
getInvocationMessage
(
'apply_patch'
,
'Patch'
,
{
:
}
)
)
;
const
=
text
(
getPastTenseMessage
(
'apply_patch'
,
'Patch'
,
{
:
}
,
true
)
)
;
.
deepStrictEqual
(
{
,
}
,
{
:
'Edit [foo.ts](file:///repo/src/foo.ts), [bar.ts](file:///repo/src/bar.ts), [baz.ts](file:///repo/src/baz.ts)'
,
:
'Edit [foo.ts](file:///repo/src/foo.ts), [bar.ts](file:///repo/src/bar.ts), [baz.ts](file:///repo/src/baz.ts)'
,
}
)
;
}
)
;
test
(
'falls back to a generic message when the patch body is missing or unparseable'
,
(
)
=>
{
.
strictEqual
(
getInvocationMessage
(
'apply_patch'
,
'Patch'
,
undefined
)
,
'Edit files'
)
;
.
strictEqual
(
getInvocationMessage
(
'apply_patch'
,
'Patch'
,
{
:
'not a patch'
}
)
,
'Edit files'
)
;
.
strictEqual
(
getPastTenseMessage
(
'apply_patch'
,
'Patch'
,
undefined
,
true
)
,
'Edit files'
)
;
}
)
;
test
(
'also accepts the patch text under the `patch` parameter (CLI shape)'
,
(
)
=>
{
const
=
text
(
getInvocationMessage
(
'apply_patch'
,
'Patch'
,
{
:
}
)
)
;
.
strictEqual
(
,
'Edit [foo.ts](file:///repo/src/foo.ts)'
)
;
}
)
;
test
(
'git_apply_patch shares the same display path'
,
(
)
=>
{
const
=
text
(
getInvocationMessage
(
'git_apply_patch'
,
'Patch'
,
{
:
}
)
)
;
const
=
text
(
getPastTenseMessage
(
'git_apply_patch'
,
'Patch'
,
{
:
}
,
true
)
)
;
.
deepStrictEqual
(
{
,
}
,
{
:
'Edit [foo.ts](file:///repo/src/foo.ts)'
,
:
'Edit [foo.ts](file:///repo/src/foo.ts)'
,
}
)
;
}
)
;
test
(
'failure still routes through the generic failed message'
,
(
)
=>
{
.
strictEqual
(
getPastTenseMessage
(
'apply_patch'
,
'Patch'
,
{
:
}
,
false
)
,
'"Patch" failed'
)
;
}
)
;
test
(
'getEditFilePath returns the first affected file from a patch body'
,
(
)
=>
{
.
strictEqual
(
getEditFilePath
(
{
:
}
)
,
'/repo/src/foo.ts'
)
;
.
strictEqual
(
getEditFilePath
(
{
:
}
)
,
'/repo/src/foo.ts'
)
;
.
strictEqual
(
getEditFilePath
(
{
:
}
)
,
'/repo/src/foo.ts'
)
;
.
strictEqual
(
getEditFilePath
(
JSON
.
stringify
(
{
:
}
)
)
,
'/repo/src/foo.ts'
)
;
.
strictEqual
(
getEditFilePath
(
{
:
'not a patch'
}
)
,
undefined
)
;
}
)
;
test
(
'getEditFilePaths returns every affected file from a patch body'
,
(
)
=>
{
.
deepStrictEqual
(
getEditFilePaths
(
{
:
}
)
,
[
'/repo/src/foo.ts'
]
)
;
.
deepStrictEqual
(
getEditFilePaths
(
{
:
}
)
,
[
'/repo/src/foo.ts'
,
'/repo/src/bar.ts'
,
'/repo/src/baz.ts'
]
)
;
.
deepStrictEqual
(
getEditFilePaths
(
{
:
}
)
,
[
'/repo/src/foo.ts'
,
'/repo/src/bar.ts'
,
'/repo/src/baz.ts'
]
)
;
.
deepStrictEqual
(
getEditFilePaths
(
JSON
.
stringify
(
{
:
}
)
)
,
[
'/repo/src/foo.ts'
,
'/repo/src/bar.ts'
,
'/repo/src/baz.ts'
]
)
;
.
deepStrictEqual
(
getEditFilePaths
(
{
:
'/repo/src/edit.ts'
}
)
,
[
'/repo/src/edit.ts'
]
)
;
.
deepStrictEqual
(
getEditFilePaths
(
{
:
'not a patch'
}
)
,
[
]
)
;
.
deepStrictEqual
(
getEditFilePaths
(
undefined
)
,
[
]
)
;
.
deepStrictEqual
(
getEditFilePaths
(
)
,
[
'/repo/src/foo.ts'
,
'/repo/src/bar.ts'
,
'/repo/src/baz.ts'
]
)
;
.
deepStrictEqual
(
getEditFilePaths
(
)
,
[
'/repo/src/foo.ts'
]
)
;
}
)
;
}
)
;
suite
(
'getShellIntention'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
test
(
'reads the description argument of shell tools, and ignores non-shell tools'
,
(
)
=>
{
.
deepStrictEqual
(
{
:
getShellIntention
(
'bash'
,
{
:
'ls'
,
:
'List files'
}
)
,
:
getShellIntention
(
'powershell'
,
{
:
'Get-ChildItem'
,
:
'List files'
}
)
,
:
getShellIntention
(
'bash'
,
{
:
'ls'
}
)
,
:
getShellIntention
(
'bash'
,
{
:
'ls'
,
:
''
}
)
,
:
getShellIntention
(
'task'
,
{
:
'Explore the codebase'
}
)
,
:
getShellIntention
(
'view'
,
{
:
'/repo/file.ts'
,
:
'why'
}
)
,
:
getShellIntention
(
'bash'
,
undefined
)
,
}
,
{
:
'List files'
,
:
'List files'
,
:
undefined
,
:
undefined
,
:
undefined
,
:
undefined
,
:
undefined
,
}
)
;
}
)
;
}
)
;