ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / extensions / copilot / src / platform / inlineEdits / common / inlineEditLogContext.ts 855 строк · изменён 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
import { Raw } from '@vscode/prompt-tsx' ;
import type { InlineCompletionContext } from 'vscode' ;
import * as yaml from 'yaml' ;
import { ErrorUtils } from '../../../util/common/errors' ;
import { isCancellationError } from '../../../util/vs/base/common/errors' ;
import { Emitter, Event } from '../../../util/vs/base/common/event' ;
import { ThemeIcon } from '../../../util/vs/base/common/themables' ;
import { SerializedLineEdit }
OffsetRange
SerializedEdit
FetchCancellationError
LanguageContextResponse SerializedContextResponse serializeLanguageContext
PromptSectionTokenCounts
RootedLineEdit
DebugRecorderBookmark
ISerializedNextEditRequest StatelessNextEditRequest
stringifyChatMessages
Icon now
HistoryContext
_id
requestId InlineEditRequestLogContext _id
time
_isVisible
_isVisible
_isCompleted
_isCompleted
_isCompleted
_onDidChange
onDidChange Event _onDidChange event
_onDidChange
filePath
version
_context InlineCompletionContext
recordingBookmark DebugRecorderBookmark
lines
lines
_isCompleted
lines
lines
lines
lines
lines
lines
lines
lines
lines
lines
lines
lines
lines
lines
lines
lines
fromCacheStatus _logContextOfCachedEdit
lines
headerRequestId
lines
lines
_nextEditRequest
lines
lines
lines _nextEditRequest
lines
_diagnosticsResultEdit
lines
lines
lines
lines _diagnosticsResultEdit
lines
lines
_resultEdit
lines
lines
lines
lines _resultEdit
lines
lines
prompt
lines
lines
e prompt
lines
lines e
lines
lines
error
lines
lines
lines ErrorUtils ErrorUtils error
lines
response
lines
lines
lines
lines response
lines
lines
_responseResults
lines
lines
lines
lines yaml _responseResults
lines
lines
_promptSectionTokens
t _promptSectionTokens
lines
lines
lines
lines
lines
lines
lines
lines
lines
lines
lines
lines
lines
lines
lines
lines
lines
lines
lines
lines
lines
_isAccepted
lines
_rebaseFailure
lines
lines
lines _rebaseFailure
lines
_logs length
lines
lines
lines _logs
lines
lines
_trace length
lines
lines
lines
lines _trace
lines
lines
lines
lines
_nesTypePicked _diagnosticsResultEdit
lines
lines
lines _diagnosticsResultEdit
lines
_nesTypePicked _resultEdit
lines
lines
_resultEdit
lines _resultEdit
lines _resultEdit
lines
lines
error
lines
lines
lines ErrorUtils ErrorUtils error
lines
lines
lines
_context
lines
lines
lines
_statelessNextEditProviderId
id
_statelessNextEditProviderId id
_nextEditRequest StatelessNextEditRequest
nextEditRequest StatelessNextEditRequest
_isVisible
_nextEditRequest nextEditRequest
_resultEdit RootedLineEdit
resultEditOrPatchString RootedLineEdit
_isVisible
_resultEdit resultEditOrPatchString
_diagnosticsResultEdit RootedLineEdit
resultEdit RootedLineEdit
_isVisible
_diagnosticsResultEdit resultEdit
_nesTypePicked
nesTypePicked
_nesTypePicked nesTypePicked
_logContextOfCachedEdit InlineEditRequestLogContext
logContextOfCachedEdit InlineEditRequestLogContext
_logContextOfCachedEdit logContextOfCachedEdit
recordingBookmark logContextOfCachedEdit recordingBookmark
_nextEditRequest logContextOfCachedEdit _nextEditRequest _nextEditRequest
_resultEdit logContextOfCachedEdit _resultEdit _resultEdit
_diagnosticsResultEdit logContextOfCachedEdit _diagnosticsResultEdit _diagnosticsResultEdit
_endpointInfo logContextOfCachedEdit _endpointInfo _endpointInfo
_headerRequestId logContextOfCachedEdit _headerRequestId _headerRequestId
logContextOfCachedEdit _prompt
_prompt logContextOfCachedEdit _prompt
_promptSectionTokens logContextOfCachedEdit _promptSectionTokens _promptSectionTokens
response logContextOfCachedEdit response response
_responseResults logContextOfCachedEdit _responseResults _responseResults
logContextOfCachedEdit fullResponsePromise
logContextOfCachedEdit fullResponsePromise
_error logContextOfCachedEdit _error _error
_isVisible
_outcome
logContextOfReusedRequest InlineEditRequestLogContext
_logContextOfCachedEdit logContextOfReusedRequest
recordingBookmark logContextOfReusedRequest recordingBookmark
_nextEditRequest logContextOfReusedRequest _nextEditRequest _nextEditRequest
_resultEdit logContextOfReusedRequest _resultEdit _resultEdit
_diagnosticsResultEdit logContextOfReusedRequest _diagnosticsResultEdit _diagnosticsResultEdit
_endpointInfo logContextOfReusedRequest _endpointInfo _endpointInfo
_headerRequestId logContextOfReusedRequest _headerRequestId _headerRequestId
logContextOfReusedRequest _prompt
_prompt logContextOfReusedRequest _prompt
_promptSectionTokens logContextOfReusedRequest _promptSectionTokens _promptSectionTokens
response logContextOfReusedRequest response response
_responseResults logContextOfReusedRequest _responseResults _responseResults
logContextOfReusedRequest fullResponsePromise
logContextOfReusedRequest fullResponsePromise
_error logContextOfReusedRequest _error _error
_isVisible
_outcome
_endpointInfo url modelName
url modelName
_endpointInfo url modelName
url modelName
_endpointInfo
_headerRequestId
headerRequestId
_headerRequestId headerRequestId
_headerRequestId
_prompt
_rawMessages Raw ChatMessage
_promptSectionTokens PromptSectionTokenCounts
_prompt
Raw ChatMessage
_rawMessages
prompt Raw ChatMessage
_isVisible
prompt
_prompt prompt
_rawMessages prompt
_prompt prompt
counts PromptSectionTokenCounts
_promptSectionTokens counts
rawMessages $ filePath v$ version $ icon svg '
parsedTraces _trace line
timeMatch line
timestamp timeMatch timeMatch
afterTime line
segments
remaining afterTime
bracketMatch
bracketMatch remaining
segments bracketMatch
remaining remaining bracketMatch length
message remaining
timestamp segments message
parsedTraces length
lines
lines
lines
lines
maxTime Math parsedTraces t t timestamp
timeWidth Math maxTime length
activeSegments
segmentLifetimes path startTime endTime depth name
parsedTraces trace idx
currentPath trace segments
path info activeSegments
currentPath path currentPath path
segmentLifetimes
path
startTime info startTime
endTime trace timestamp
depth info depth
name path
activeSegments path
pathSoFar
trace segments segment depth
pathSoFar pathSoFar segment
activeSegments pathSoFar
activeSegments pathSoFar startTime trace timestamp depth
lastTimestamp parsedTraces parsedTraces length timestamp
path info activeSegments
segmentLifetimes
path
startTime info startTime
endTime lastTimestamp
depth info depth
name path
lines
lines
lines
currentAtDepth
trace parsedTraces
timeStr
indentUnit
newBranchUnit
indent
displaySegment
hasNewSegment
d d trace segments length d
seg trace segments d
currentAtDepth d seg
hasNewSegment
currentAtDepth d seg
currentAtDepth length d
displaySegment seg
indent indentUnit d
indent indentUnit d
hasNewSegment
prefix indent newBranchUnit
lines
trace message
msgIndent indentUnit trace segments length
lines
trace message
msgIndent indentUnit trace segments length
lines
lines
lines
lines
lines
_logs
content
_logs content
_rebaseFailure MarkdownLoggable
failure MarkdownLoggable
_rebaseFailure failure
_isAccepted
isAccepted
_isAccepted isAccepted
list
list l
code language
_logs
_fileDiagnostics
fileDiagnostics
_fileDiagnostics fileDiagnostics
_terminalOutput
terminalOutput
_terminalOutput terminalOutput
_languageContext LanguageContextResponse
langCtx LanguageContextResponse
_languageContext langCtx
ISerializedInlineEditLogContext
requestId requestId
time time
filePath filePath
version version
statelessNextEditProviderId _statelessNextEditProviderId
nextEditRequest _nextEditRequest
diagnosticsResultEdit _diagnosticsResultEdit
resultEdit _resultEdit
isCachedResult _logContextOfCachedEdit
prompt prompt
error error
response fullResponse
responseResults yaml _responseResults
providerStartTime providerStartTime
providerEndTime providerEndTime
fetchStartTime fetchStartTime
fetchEndTime fetchEndTime
logs _logs
isAccepted _isAccepted
languageContext _languageContext _languageContext
diagnostics _fileDiagnostics
terminalOutput _terminalOutput
path
slash Math path path
slash path
path slash
recentWorkspaceEdits path initialText edit SerializedEdit
recentWorkspaceEditsActiveDocumentIdx
statelessDocuments initialText edit SerializedLineEdit
statelessActiveDocumentIdx
statelessLLMPrompt
statelessLLMResponse
statelessNextEdit SerializedLineEdit
nextEdit SerializedEdit
requestId
time
filePath
version
statelessNextEditProviderId
nextEditRequest ISerializedNextEditRequest
diagnosticsResultEdit
resultEdit
isCachedResult
prompt
error
response
responseResults
providerStartTime
providerEndTime
fetchStartTime
fetchEndTime
logs
isAccepted
languageContext SerializedContextResponse
diagnostics
terminalOutput
from
'../../../util/vs/editor/common/core/edits/lineEdit'
;
import
{
}
from
'../../../util/vs/editor/common/core/ranges/offsetRange'
;
import
{
}
from
'./dataTypes/editUtils'
;
import
{
}
from
'./dataTypes/fetchCancellationError'
;
import
{
,
,
}
from
'./dataTypes/languageContext'
;
import
{
}
from
'./dataTypes/promptSectionTokens'
;
import
{
}
from
'./dataTypes/rootedLineEdit'
;
import
{
}
from
'./debugRecorderBookmark'
;
import
{
,
}
from
'./statelessNextEditProvider'
;
import
{
}
from
'./utils/stringifyChatMessages'
;
import
{
,
}
from
'./utils/utils'
;
import
{
}
from
'./workspaceEditTracker/historyContextProvider'
;
export
interface
MarkdownLoggable
{
toMarkdown
(
)
:
string
;
}
type
LogContextOutcome
=
'pending'
|
'succeeded'
|
'noSuggestions'
|
'cached'
|
'cachedFromGhostText'
|
'reusedInFlight'
|
'skipped'
|
'cancelled'
|
'errored'
|
'previouslyRejected'
;
export
class
InlineEditRequestLogContext
{
private
static
=
0
;
public
readonly
=
.
++
;
public
readonly
=
now
(
)
;
protected
:
boolean
=
false
;
get
includeInLogTree
(
)
:
boolean
{
return
this
.
;
}
private
:
boolean
=
false
;
markCompleted
(
)
:
void
{
if
(
this
.
)
{
console
.
warn
(
` [InlineEditRequestLogContext] markCompleted called twice (request # ${ this . requestId} ) `
)
;
}
this
.
=
true
;
this
.
fireDidChange
(
)
;
}
private
readonly
=
new
Emitter< void >
(
)
;
public
readonly
:
<
void
>
=
this
.
.
;
protected
fireDidChange
(
)
:
void
{
this
.
.
fire
(
)
;
}
constructor
(
public
readonly
:
string
,
public
readonly
:
number
,
private
:
|
undefined
,
)
{
}
public
:
|
undefined
=
undefined
;
toLogDocument
(
)
:
string
{
const
:
string
[
]
=
[
]
;
.
push
(
'# '
+
this
.
getMarkdownTitle
(
)
+
` (Request # ${ this . requestId} ) `
)
;
if
(
!
this
.
)
{
.
push
(
'\n⏳ **In progress…**\n'
)
;
}
.
push
(
'💡 Tip: double-click anywhere to open this file as text to copy-paste content into an issue.\n'
)
;
.
push
(
'<details><summary>Explanation for icons</summary>\n'
)
;
.
push
(
` - ${ Icon. lightbulbFull. svg} - model had suggestions\n `
)
;
.
push
(
` - ${ Icon. circleSlash. svg} - model had NO suggestions\n `
)
;
.
push
(
` - ${ Icon. database. svg} - response is from cache\n `
)
;
.
push
(
` - ${ Icon. gitMerge. svg} - joined an in-flight request (async or speculative reuse)\n `
)
;
.
push
(
` - ${ Icon. error. svg} - error happened\n `
)
;
.
push
(
` - ${ Icon. skipped. svg} - fetching started but got cancelled\n `
)
;
.
push
(
'</details>\n'
)
;
.
push
(
` Inline Edit Provider: ${ this . _statelessNextEditProviderId ?? '<NOT-SET>' } \n `
)
;
.
push
(
` Chat Endpoint `
)
;
.
push
(
'```'
)
;
.
push
(
` Model name: ${ this . _endpointInfo?. modelName ?? '<NOT-SET>' } `
)
;
.
push
(
` URL: ${ this . _endpointInfo?. url ?? '<NOT-SET>' } `
)
;
.
push
(
'```'
)
;
const
=
this
.
?
` (cached # ${ this . _logContextOfCachedEdit. requestId} ) `
:
'(not cached)'
;
.
push
(
` Opportunity ID: ${ this . _context ? this . _context. requestUuid : '<NOT-SET>' } `
)
;
if
(
this
.
)
{
.
push
(
''
)
;
.
push
(
` Header Request ID: ${ this . headerRequestId} ${ fromCacheStatus} `
)
;
}
if
(
this
.
)
{
.
push
(
` ## Latest user edits ${ fromCacheStatus} `
)
;
.
push
(
'<details open><summary>Edit</summary>\n'
)
;
.
push
(
this
.
.
toMarkdown
(
)
)
;
.
push
(
'\n</details>\n'
)
;
}
if
(
this
.
)
{
.
push
(
` ## Proposed diagnostics suggestion ${ this . _nesTypePicked === 'diagnostics' ? '(Picked)' : '(Not Picked)' } `
)
;
.
push
(
'<details open><summary>Edit</summary>\n'
)
;
.
push
(
'``` patch'
)
;
.
push
(
this
.
.
toString
(
)
)
;
.
push
(
'```'
)
;
.
push
(
'\n</details>\n'
)
;
}
if
(
this
.
)
{
.
push
(
` ## Proposed inline suggestion ${ fromCacheStatus} `
)
;
.
push
(
'<details open><summary>Edit</summary>\n'
)
;
.
push
(
'``` patch'
)
;
.
push
(
this
.
.
toString
(
)
)
;
.
push
(
'```'
)
;
.
push
(
'\n</details>\n'
)
;
}
if
(
this
.
)
{
.
push
(
` ## Prompt ${ fromCacheStatus} `
)
;
.
push
(
'<details><summary>Click to view</summary>\n'
)
;
const
=
this
.
;
.
push
(
'````'
)
;
.
push
(
...
.
split
(
'\n'
)
)
;
.
push
(
'````'
)
;
.
push
(
'\n</details>\n'
)
;
}
if
(
this
.
)
{
.
push
(
` ## Error ${ fromCacheStatus} `
)
;
.
push
(
'```'
)
;
.
push
(
.
toString
(
.
fromUnknown
(
this
.
)
)
)
;
.
push
(
'```'
)
;
}
if
(
this
.
)
{
.
push
(
` ## Response ${ fromCacheStatus} `
)
;
.
push
(
'<details><summary>Click to view</summary>\n'
)
;
.
push
(
'````'
)
;
.
push
(
this
.
)
;
.
push
(
'````'
)
;
.
push
(
'\n</details>\n'
)
;
}
if
(
this
.
)
{
.
push
(
` ## Response Results ${ fromCacheStatus} `
)
;
.
push
(
'<details><summary>Click to view</summary>\n'
)
;
.
push
(
'```'
)
;
.
push
(
.
stringify
(
this
.
,
null
,
'\t'
)
)
;
.
push
(
'```'
)
;
.
push
(
'\n</details>\n'
)
;
}
if
(
this
.
)
{
const
=
this
.
;
.
push
(
` ## Prompt section tokens ${ fromCacheStatus} `
)
;
.
push
(
'<details><summary>Click to view</summary>\n'
)
;
.
push
(
'Approximate (char/4) token counts per prompt section.\n'
)
;
.
push
(
'Indented `↳` rows break down `recently_viewed_code_snippets` by source; they do not sum exactly to the section total (section tags and inter-snippet newline glue are excluded).\n'
)
;
.
push
(
'| Section | Tokens |'
)
;
.
push
(
'| --- | --- |'
)
;
.
push
(
` | system_prompt | ${ t. systemPrompt} | `
)
;
.
push
(
` | recently_viewed_code_snippets | ${ t. recentlyViewed} | `
)
;
.
push
(
` | ↳ recently viewed files (xtab history) | ${ t. recentlyViewedSubsections. recentlyViewedFiles} | `
)
;
.
push
(
` | ↳ language context | ${ t. recentlyViewedSubsections. languageContext} | `
)
;
.
push
(
` | ↳ neighbor files | ${ t. recentlyViewedSubsections. neighborFiles} | `
)
;
.
push
(
` | current_file_content | ${ t. currentFile} | `
)
;
.
push
(
` | lint_errors | ${ t. lintErrors} | `
)
;
.
push
(
` | edit_diff_history | ${ t. editHistory} | `
)
;
.
push
(
` | area_around_code_to_edit | ${ t. areaAroundCodeToEdit} | `
)
;
.
push
(
` | cursor_location | ${ t. cursorLocation} | `
)
;
.
push
(
` | related_information | ${ t. relatedInformation} | `
)
;
.
push
(
` | post_script | ${ t. postScript} | `
)
;
.
push
(
` | overhead (newlines / backticks / trim) | ${ t. overhead} | `
)
;
.
push
(
` | **user_prompt_total** | ** ${ t. userPromptTotal} ** | `
)
;
.
push
(
'\n</details>\n'
)
;
}
if
(
this
.
!==
undefined
)
{
.
push
(
` ## Accepted : ${ this . _isAccepted ? 'Yes' : 'No' } `
)
;
}
if
(
this
.
)
{
.
push
(
'## Rebase Failure'
)
;
.
push
(
'<details><summary>Click to view</summary>\n'
)
;
.
push
(
this
.
.
toMarkdown
(
)
)
;
.
push
(
'\n</details>\n'
)
;
}
if
(
this
.
.
>
0
)
{
.
push
(
'## Logs'
)
;
.
push
(
'<details open><summary>Logs</summary>\n'
)
;
.
push
(
...
this
.
)
;
.
push
(
'\n</details>\n'
)
;
}
.
push
(
...
this
.
_renderTraceDiagram
(
)
)
;
if
(
this
.
.
>
0
)
{
.
push
(
'## Trace'
)
;
.
push
(
'<details><summary>Trace</summary>\n'
)
;
.
push
(
'```'
)
;
.
push
(
...
this
.
)
;
.
push
(
'```'
)
;
.
push
(
'\n</details>\n'
)
;
}
return
.
join
(
'\n'
)
;
}
toMinimalLog
(
)
:
string
{
const
:
string
[
]
=
[
]
;
if
(
this
.
===
'diagnostics'
&&
this
.
)
{
.
push
(
` ## Result (Diagnostics): `
)
;
.
push
(
'``` patch'
)
;
.
push
(
this
.
.
toString
(
)
)
;
.
push
(
'```'
)
;
}
else
if
(
this
.
===
'llm'
&&
this
.
)
{
.
push
(
` ## Result: `
)
;
.
push
(
'``` patch'
)
;
if
(
typeof
this
.
===
'string'
)
{
.
push
(
this
.
)
;
}
else
{
.
push
(
this
.
.
toString
(
)
)
;
}
.
push
(
'```'
)
;
}
else
{
.
push
(
` ## Result: <NOT-SET> `
)
;
}
if
(
this
.
)
{
.
push
(
` ## Error: `
)
;
.
push
(
'```'
)
;
.
push
(
.
toString
(
.
fromUnknown
(
this
.
)
)
)
;
.
push
(
'```'
)
;
}
.
push
(
` ### Info: `
)
;
.
push
(
` **From cache:** ${ this . _logContextOfCachedEdit ? ` YES (Request: ${ this . _logContextOfCachedEdit. requestId} ) ` : 'NO' } `
)
;
if
(
this
.
)
{
.
push
(
` **Trigger Kind:** ${ this . _context. triggerKind === 0 ? 'Manual' : 'Automatic' } `
)
;
.
push
(
` **Request UUID:** ${ this . _context. requestUuid} `
)
;
}
return
.
join
(
'\n'
)
;
}
private
:
string
|
undefined
=
undefined
;
setStatelessNextEditProviderId
(
:
string
)
{
this
.
=
;
}
private
:
|
undefined
=
undefined
;
setRequestInput
(
:
)
:
void
{
this
.
=
true
;
this
.
=
;
this
.
fireDidChange
(
)
;
}
private
:
|
string
|
undefined
=
undefined
;
setResult
(
:
|
string
)
{
this
.
=
true
;
this
.
=
;
this
.
fireDidChange
(
)
;
}
protected
:
|
undefined
=
undefined
;
setDiagnosticsResult
(
:
)
{
this
.
=
true
;
this
.
=
;
this
.
fireDidChange
(
)
;
}
private
:
'llm'
|
'diagnostics'
|
undefined
;
public
setPickedNESType
(
:
'llm'
|
'diagnostics'
)
:
this
{
this
.
=
;
return
this
;
}
private
:
|
undefined
=
undefined
;
setIsCachedResult
(
:
)
:
void
{
this
.
=
;
this
.
=
.
;
this
.
=
.
??
this
.
;
this
.
=
.
??
this
.
;
this
.
=
.
??
this
.
;
this
.
=
.
??
this
.
;
this
.
=
.
??
this
.
;
if
(
.
)
{
this
.
=
.
;
}
this
.
=
.
??
this
.
;
this
.
=
.
??
this
.
;
this
.
=
.
??
this
.
;
if
(
.
)
{
this
.
setFullResponse
(
.
)
;
}
this
.
=
.
??
this
.
;
this
.
=
true
;
this
.
=
'cached'
;
this
.
fireDidChange
(
)
;
}
setIsReusedInFlightResult
(
:
)
:
void
{
this
.
=
;
this
.
=
.
;
this
.
=
.
??
this
.
;
this
.
=
.
??
this
.
;
this
.
=
.
??
this
.
;
this
.
=
.
??
this
.
;
this
.
=
.
??
this
.
;
if
(
.
)
{
this
.
=
.
;
}
this
.
=
.
??
this
.
;
this
.
=
.
??
this
.
;
this
.
=
.
??
this
.
;
if
(
.
)
{
this
.
setFullResponse
(
.
)
;
}
this
.
=
.
??
this
.
;
this
.
=
true
;
this
.
=
'reusedInFlight'
;
this
.
fireDidChange
(
)
;
}
private
:
{
:
string
;
:
string
}
|
undefined
;
public
setEndpointInfo
(
:
string
,
:
string
)
:
void
{
this
.
=
{
,
}
;
this
.
fireDidChange
(
)
;
}
public
get
endpointInfo
(
)
:
{
:
string
;
:
string
}
|
undefined
{
return
this
.
;
}
private
:
string
|
undefined
=
undefined
;
public
setHeaderRequestId
(
:
string
)
:
void
{
this
.
=
;
this
.
fireDidChange
(
)
;
}
get
headerRequestId
(
)
:
string
|
undefined
{
return
this
.
;
}
public
:
string
|
undefined
=
undefined
;
private
:
.
[
]
|
undefined
=
undefined
;
public
:
|
undefined
=
undefined
;
get
prompt
(
)
:
string
|
undefined
{
return
this
.
;
}
get
rawMessages
(
)
:
.
[
]
|
undefined
{
return
this
.
;
}
setPrompt
(
:
string
|
.
[
]
)
{
this
.
=
true
;
if
(
typeof
===
'string'
)
{
this
.
=
;
}
else
{
this
.
=
;
this
.
=
stringifyChatMessages
(
)
;
}
this
.
fireDidChange
(
)
;
}
setPromptSectionTokens
(
:
)
{
this
.
=
;
this
.
fireDidChange
(
)
;
}
` ). Never emitted to telemetry sinks — the
* `
` can contain full prompt content (source code).
*/
private _cursorJumpRawMessages: Raw.ChatMessage[] | undefined = undefined;
private _cursorJumpKeptRange: OffsetRange | undefined = undefined;
get cursorJumpRawMessages(): Raw.ChatMessage[] | undefined {
return this._cursorJumpRawMessages;
}
get cursorJumpKeptRange(): OffsetRange | undefined {
return this._cursorJumpKeptRange;
}
setCursorJumpPrompt(messages: Raw.ChatMessage[], keptRange: OffsetRange) {
this._cursorJumpRawMessages = messages;
this._cursorJumpKeptRange = keptRange;
this.fireDidChange();
}
private _outcome: LogContextOutcome = 'pending';
private _setOutcome(outcome: LogContextOutcome): void {
this._outcome = outcome;
}
private _resolveIcon(): Icon.t {
switch (this._outcome) {
case 'pending': return this._isCompleted ? Icon.check : Icon.loading;
case 'succeeded': return Icon.lightbulbFull;
case 'noSuggestions': return Icon.circleSlash;
case 'cached':
case 'cachedFromGhostText': return Icon.database;
case 'reusedInFlight': return Icon.gitMerge;
case 'skipped':
case 'cancelled': return Icon.skipped;
case 'errored': return Icon.error;
case 'previouslyRejected': return Icon.thumbsdown;
}
}
getIcon(): ThemeIcon {
return this._resolveIcon().themeIcon;
}
public setIsSkipped() {
this._setOutcome('skipped');
this._isVisible = false;
this.fireDidChange();
}
public markAsFromCache() {
this._setOutcome('cachedFromGhostText');
this._isVisible = true;
this.fireDidChange();
}
public markAsNoSuggestions() {
this._setOutcome('noSuggestions');
this._isVisible = true;
this.fireDidChange();
}
public markAsPreviouslyRejected() {
this._setOutcome('previouslyRejected');
this._isVisible = true;
this.fireDidChange();
}
private _error: unknown | undefined = undefined;
get error(): unknown | undefined {
return this._error;
}
setError(e: unknown): void {
this._isVisible = true;
this._error = e;
if (this._error instanceof FetchCancellationError) {
this._setOutcome('skipped');
} else if (isCancellationError(this._error)) {
this._setOutcome('cancelled');
this._isVisible = false;
} else {
this._setOutcome('errored');
}
this.fireDidChange();
}
/**
* Model Response
*/
private response: string | undefined = undefined;
setResponse(v: string): void {
this._isVisible = true;
this.response = v;
this.fireDidChange();
}
private fullResponsePromise: Promise<string | undefined> | undefined = undefined;
private fullResponse: string | undefined = undefined;
setFullResponse(promise: Promise<string | undefined>): void {
this.fullResponsePromise = promise;
promise.then(response => this.fullResponse = response);
}
async allPromisesResolved(): Promise<void> {
await this.fullResponsePromise;
}
private providerStartTime: number | undefined = undefined;
setProviderStartTime(): void {
this.providerStartTime = Date.now();
this.fireDidChange();
}
private providerEndTime: number | undefined = undefined;
setProviderEndTime(): void {
this.providerEndTime = Date.now();
this.fireDidChange();
}
private fetchStartTime: number | undefined = undefined;
setFetchStartTime(): void {
this.fetchStartTime = Date.now();
this.fireDidChange();
}
private fetchEndTime: number | undefined = undefined;
setFetchEndTime(): void {
this.fetchEndTime = Date.now();
this.fireDidChange();
}
/**
* Each of edit suggestions from model
*/
private _responseResults: readonly unknown[] | undefined = undefined;
get responseResults(): readonly unknown[] | undefined {
return this._responseResults;
}
setResponseResults(v: readonly unknown[]): void {
this._isVisible = true;
this._responseResults = v;
if (this._outcome === 'pending') {
this._outcome = 'succeeded';
}
this.fireDidChange();
}
getDebugName(): string {
return `
NES
|
{
basename
(
this
.
)
}
(
{
this
.
}
)
` ;
}
getMarkdownTitle(): string {
const icon = this._resolveIcon();
return `
{
.
}
` + this.getDebugName();
}
protected _recentEdit: HistoryContext | undefined = undefined;
setRecentEdit(edit: HistoryContext): void {
this._recentEdit = edit;
}
private _trace: string[] = [];
trace(msg: string): void {
this._trace.push(msg);
this.fireDidChange();
}
private _renderTraceDiagram(): string[] {
if (this._trace.length === 0) {
return [];
}
const lines: string[] = [];
lines.push('## Trace Diagram');
lines.push('<details open><summary>Trace Diagram</summary>\n');
lines.push(' `
` `
)
;
const
=
this
.
.
map
(
=>
{
const
=
.
match
(
/ ^ \[ \s * ( \d + ) ms\] /
)
;
const
=
?
parseInt
(
[
1
]
,
10
)
:
0
;
const
=
.
replace
(
/ ^ \[ \s * \d + ms\] \s * /
,
''
)
;
const
:
string
[
]
=
[
]
;
let
=
;
let
;
while
(
(
=
.
match
(
/ ^ \[ ( [ ^ \] ] + ) \] /
)
)
)
{
.
push
(
[
1
]
)
;
=
.
slice
(
[
0
]
.
)
;
}
const
=
.
trim
(
)
;
return
{
,
,
}
;
}
)
;
if
(
.
===
0
)
{
.
push
(
'(no trace data)'
)
;
.
push
(
'```'
)
;
.
push
(
'\n</details>\n'
)
;
return
;
}
const
=
.
max
(
...
.
map
(
=>
.
)
)
;
const
=
.
max
(
6
,
String
(
)
.
+
3
)
;
const
=
new
Map< string , { startTime: number ; depth: number } >
(
)
;
const
:
{
:
string
;
:
number
;
:
number
;
:
number
;
:
string
}
[
]
=
[
]
;
.
forEach
(
(
,
)
=>
{
const
=
.
.
join
(
'|'
)
;
for
(
const
[
,
]
of
)
{
if
(
!
.
startsWith
(
)
&&
!==
)
{
.
push
(
{
,
:
.
,
:
.
,
:
.
,
:
.
split
(
'|'
)
.
pop
(
)
||
''
}
)
;
.
delete
(
)
;
}
}
let
=
''
;
.
.
forEach
(
(
,
)
=>
{
=
?
` ${ pathSoFar} | ${ segment} `
:
;
if
(
!
.
has
(
)
)
{
.
set
(
,
{
:
.
,
}
)
;
}
}
)
;
}
)
;
const
=
[
.
-
1
]
?.
||
0
;
for
(
const
[
,
]
of
)
{
.
push
(
{
,
:
.
,
:
,
:
.
,
:
.
split
(
'|'
)
.
pop
(
)
||
''
}
)
;
}
.
push
(
''
)
;
.
push
(
'Timeline (nested call hierarchy):'
)
;
.
push
(
'─'
.
repeat
(
60
)
)
;
const
:
string
[
]
=
[
]
;
for
(
const
of
)
{
const
=
` [ ${ String ( trace. timestamp) . padStart ( timeWidth - 3 ) } ms] `
;
const
=
'│ '
;
const
=
'├── '
;
let
=
''
;
let
=
''
;
let
=
false
;
for
(
let
=
0
;
<
.
.
;
++
)
{
const
=
.
[
]
;
if
(
[
]
!==
)
{
=
true
;
[
]
=
;
.
=
+
1
;
=
;
=
.
repeat
(
)
;
break
;
}
=
.
repeat
(
+
1
)
;
}
if
(
)
{
const
=
+
;
.
push
(
` ${ timeStr} ${ prefix} [ ${ displaySegment} ] `
)
;
if
(
.
)
{
const
=
.
repeat
(
.
.
)
;
.
push
(
` ${ ' ' . repeat ( timeWidth + 1 ) } ${ msgIndent} ↳ ${ trace. message} `
)
;
}
}
else
if
(
.
)
{
const
=
.
repeat
(
.
.
)
;
.
push
(
` ${ timeStr} ${ msgIndent} ↳ ${ trace. message} `
)
;
}
}
.
push
(
'─'
.
repeat
(
60
)
)
;
.
push
(
'```'
)
;
.
push
(
'\n</details>\n'
)
;
return
;
}
private
:
string
[
]
=
[
]
;
addLog
(
:
string
)
:
void
{
this
.
.
push
(
.
replace
(
'\n'
,
'\\n'
)
.
replace
(
'\t'
,
'\\t'
)
.
replace
(
'`'
,
'\`'
)
+
'\n'
)
;
this
.
fireDidChange
(
)
;
}
private
:
|
undefined
;
setRebaseFailure
(
:
)
:
void
{
this
.
=
;
}
private
:
boolean
|
undefined
=
undefined
;
setAccepted
(
:
boolean
)
:
void
{
this
.
=
;
}
addListToLog
(
:
string
[
]
)
:
void
{
.
forEach
(
=>
this
.
addLog
(
` - ${ l} `
)
)
;
}
addCodeblockToLog
(
:
string
,
:
string
=
''
)
:
void
{
this
.
.
push
(
` \`\`\` ${ language} \n ${ code} \n\`\`\`\n `
)
;
}
private
:
string
|
undefined
;
setDiagnosticsData
(
:
string
)
:
void
{
this
.
=
;
}
private
:
string
|
undefined
;
setTerminalData
(
:
string
)
:
void
{
this
.
=
;
}
private
:
|
undefined
;
setLanguageContext
(
:
)
:
void
{
this
.
=
;
}
toJSON
(
)
:
{
return
{
:
this
.
,
:
this
.
,
:
this
.
,
:
this
.
,
:
this
.
,
:
this
.
?.
serialize
(
)
,
:
this
.
?.
toString
(
)
,
:
this
.
?.
toString
(
)
,
:
!
!
this
.
,
:
this
.
,
:
String
(
this
.
)
,
:
this
.
,
:
.
stringify
(
this
.
,
null
,
'\t'
)
,
:
this
.
,
:
this
.
,
:
this
.
,
:
this
.
,
:
this
.
,
:
this
.
,
:
this
.
?
serializeLanguageContext
(
this
.
)
:
undefined
,
:
this
.
,
:
this
.
,
}
;
}
}
function
basename
(
:
string
)
:
string
{
const
=
.
max
(
.
lastIndexOf
(
'/'
)
,
.
lastIndexOf
(
'\\'
)
)
;
if
(
===
-
1
)
{
return
;
}
return
.
slice
(
+
1
)
;
}
export
interface
INextEditProviderTest
{
:
{
:
string
;
:
string
;
:
}
[
]
;
?
:
number
;
?
:
{
:
string
;
:
}
[
]
;
?
:
number
;
?
:
string
;
?
:
string
;
?
:
;
?
:
;
}
export
interface
ISerializedInlineEditLogContext
{
:
number
;
:
number
;
:
string
;
:
number
;
:
string
|
undefined
;
:
|
undefined
;
:
string
|
undefined
;
:
string
|
undefined
;
:
boolean
;
:
string
|
undefined
;
:
string
;
:
string
|
undefined
;
:
string
;
:
number
|
undefined
;
:
number
|
undefined
;
:
number
|
undefined
;
:
number
|
undefined
;
:
string
[
]
;
:
boolean
|
undefined
;
:
|
undefined
;
:
string
|
undefined
;
:
string
|
undefined
;
}