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 / prompts / node / panel / editCodePrompt.tsx 570 строк · изменён 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
import * as l10n from '@vscode/l10n' ;
import { AssistantMessage , BasePromptElementProps , Chunk , PrioritizedList , PromptElement , PromptReference , PromptSizing , SystemMessage , TextChunk , UserMessage } from '@vscode/prompt-tsx' ;
import { ChatLocation } from '../../../../platform/chat/common/commonTypes' ;
import { ConfigKey , IConfigurationService
promptContext
endpoint
props
@ configurationService
@ promptPathRepresentationService
props
state sizing
tsExampleFilePath
instructionsAfterHistory
hasFilesInWorkingSet
instructions hasFilesInWorkingSet
tsExampleFilePath
instructionsAfterHistory instructions instructionsAfterHistory instructions
chatVariables
workingSet
props
@ promptPathRepresentationService
props
override
readonlyUris
readonlyUris
readonlyUris uri
readonlyUris
entry
entry
readonlyUris entry
variable
variable
variable
readonlyUris variable
variable
readonlyUris variable
readonlyUris
workingSet
promptInstructions
chatVariables
history
priority
props
@ _promptPathRepresentationService
props
override state sizing
includedFilesAtVersions
entry
includedFilesAtVersions entry entry
includedPromptInstructions
promptInstruction
includedPromptInstructions promptInstruction promptInstruction
history
turn
editCodeStep turn
editCodeStep
history editCodeStep includedFilesAtVersions includedPromptInstructions
history editCodeStep
history
message
message message
message
editCodeStep includedFilesAtVersion includedPromptInstructions
filesToRemove
entry editCodeStep
versions includedFilesAtVersion entry
isAlreadyIncluded versions version version entry
isAlreadyIncluded
filesToRemove entry
versions entry
includedFilesAtVersion entry versions
promptInstructionsToRemove
entry editCodeStep
versions includedPromptInstructions entry
isAlreadyIncluded versions version version entry
isAlreadyIncluded
promptInstructionsToRemove entry
userMessage editCodeStep promptInstructionsToRemove
userMessage userMessage filesToRemove
userMessage userMessage
userMessage
userMessage shouldRemove
interestingFilePaths shouldRemove uri uri
userMessage match
interestingFilePaths path match path
match
userMessage shouldRemove
interestingFilePaths shouldRemove uri
userMessage match
interestingFilePaths path match path
match
userMessage
userMessage match
props
@ experimentationService
@ _configurationService
props
state sizing
query chatVariables workingSet
useProjectLabels
useProjectLabels query chatVariables query
workingSet
override state sizing
workingSet
workingSet
workingSet entry index
entry
props
@ _workspaceService
@ _promptPathRepresentationService
props
override state sizing
workspaceFolders
workspaceFolders
workspaceFolders
workspaceFolders f
untitledRoot scheme authority
entry
props
@ _ignoreService
@ instantiationService
props
state sizing
range selection state workingSetEntryState
isIgnored
isIgnored
s
summarized s selection sizing
costFnOverride fileVariableCostFn
promptReferenceOptions summarized
status description l10n kind
userActionStateFragment
workingSetEntryState
userActionStateFragment
workingSetEntryState
userActionStateFragment
workingSetEntryState
userActionStateFragment
userActionStateFragment userActionStateFragment
selection
entry
props
@ _ignoreService
@ instantiationService
props
state sizing
range selection state workingSetEntryState
isIgnored
isIgnored
s
summarized s selection sizing
costFnOverride fileVariableCostFn
promptReferenceOptions summarized
status description l10n kind
userActionStateFragment
workingSetEntryState
userActionStateFragment
workingSetEntryState
userActionStateFragment
workingSetEntryState
userActionStateFragment
userActionStateFragment userActionStateFragment
selection
selection
props
@ _ignoreService
props
state sizing
selection
selection
isIgnored
isIgnored
selectionLines
selectionLines acc line acc line
selectionStartLine
selection
selectionEndLine selection
selectionEndLine selectionStartLine selection
selectionEndLine
selectionStartLine selectionEndLine selection selectionStartLine
selectionStartLine
i selectionStartLine i selectionEndLine i
line i
selectionLines line
above selectionStartLine
below selectionEndLine
selectionLines
above
selectionLines above
above
below
selectionLines below
below
}
from
'../../../../platform/configuration/common/configurationService'
;
import
{ NotebookDocumentSnapshot }
from
'../../../../platform/editing/common/notebookDocumentSnapshot'
;
import
{ TextDocumentSnapshot }
from
'../../../../platform/editing/common/textDocumentSnapshot'
;
import
{ modelPrefersInstructionsAfterHistory }
from
'../../../../platform/endpoint/common/chatModelCapabilities'
;
import
{ IIgnoreService }
from
'../../../../platform/ignore/common/ignoreService'
;
import
{ IChatEndpoint }
from
'../../../../platform/networking/common/networking'
;
import
{ IPromptPathRepresentationService }
from
'../../../../platform/prompts/common/promptPathRepresentationService'
;
import
{ IExperimentationService }
from
'../../../../platform/telemetry/common/nullExperimentationService'
;
import
{ IWorkspaceService }
from
'../../../../platform/workspace/common/workspaceService'
;
import
{ filepathCodeBlockMarker }
from
'../../../../util/common/markdown'
;
import
{ isLocation, isUri }
from
'../../../../util/common/types'
;
import
{ ResourceMap }
from
'../../../../util/vs/base/common/map'
;
import
{ Schemas }
from
'../../../../util/vs/base/common/network'
;
import
{ IInstantiationService }
from
'../../../../util/vs/platform/instantiation/common/instantiation'
;
import
{ Range , Uri }
from
'../../../../vscodeTypes'
;
import
{ GenericBasePromptElementProps }
from
'../../../context/node/resolvers/genericPanelIntentInvocation'
;
import
{ IEditStepBuildPromptContext , PreviousEditCodeStep }
from
'../../../intents/node/editCodeStep'
;
import
{ ChatVariablesCollection }
from
'../../../prompt/common/chatVariablesCollection'
;
import
{ Turn }
from
'../../../prompt/common/conversation'
;
import
{ INotebookWorkingSetEntry , isTextDocumentWorkingSetEntry, ITextDocumentWorkingSetEntry , IWorkingSet , WorkingSetEntryState }
from
'../../../prompt/common/intents'
;
import
{ CompositeElement }
from
'../base/common'
;
import
{ CopilotIdentityRules }
from
'../base/copilotIdentity'
;
import
{ InstructionMessage }
from
'../base/instructionMessage'
;
import
{ ResponseTranslationRules }
from
'../base/responseTranslationRules'
;
import
{ LegacySafetyRules }
from
'../base/safetyRules'
;
import
{ Tag }
from
'../base/tag'
;
import
{ DocumentSummarizer , NotebookDocumentSummarizer }
from
'../inline/summarizedDocument/summarizeDocumentHelpers'
;
import
{ ChatToolReferences , ChatVariables , UserQuery }
from
'./chatVariables'
;
import
{
EXISTING_CODE_MARKER
}
from
'./codeBlockFormattingRules'
;
import
{ CustomInstructions }
from
'./customInstructions'
;
import
{ fileVariableCostFn }
from
'./fileVariable'
;
import
{ NotebookFormat , NotebookReminderInstructions }
from
'./notebookEditCodePrompt'
;
import
{ ProjectLabels }
from
'./projectLabels'
;
import
{ CodeBlock , ExampleCodeBlock }
from
'./safeElements'
;
import
{ ChatToolCalls }
from
'./toolCalling'
;
export
interface
EditCodePromptProps
extends
GenericBasePromptElementProps
{
readonly
:
IEditStepBuildPromptContext
;
readonly
:
IChatEndpoint
;
readonly
location
:
ChatLocation
;
}
export
class
EditCodePrompt
extends
PromptElement< EditCodePromptProps>
{
constructor
(
:
EditCodePromptProps
,
IConfigurationService
private
readonly
:
IConfigurationService
,
IPromptPathRepresentationService
private
readonly
:
IPromptPathRepresentationService
,
)
{
super
(
)
;
}
async
render
(
:
void
,
:
PromptSizing
)
{
const
=
'/Users/someone/proj01/example.ts'
;
const
=
modelPrefersInstructionsAfterHistory
(
this
.
props
.
endpoint
.
family
)
;
const
=
this
.
props
.
promptContext
.
workingSet
.
length
>
0
;
const
=
< InstructionMessage priority = { 900 } >
{
?
< >
The user has a request for modifying one or more files.
< br />
</ >
:
< >
If the user asks a question, then answer it.
< br />
If you need to change existing files and it's not clear which files should be changed, then refuse and answer with "Please add the files to be modified to the working set{(this.configurationService.getConfig(ConfigKey.CodeSearchAgentEnabled) || this.configurationService.getConfig(ConfigKey.Advanced.CodeSearchAgentEnabled)) ? ', or use `#codebase` in your request to automatically discover working set files.' : ''}".
< br />
The only exception is if you need to create new files. In that case, follow the following instructions.
< br />
</ >
}
1. Please come up with a solution that you first describe step-by-step.
< br />
2. Group your changes by file. Use the file path as the header.
< br />
3. For each file, give a short summary of what needs to be changed followed by a code block that contains the code changes.
< br />
4. The code block should start with four backticks followed by the language.
< br />
5. On the first line of the code block add a comment containing the filepath. This includes Markdown code blocks.
< br />
6. Use a single code block per file that needs to be modified, even if there are multiple changes for a file.
< br />
7. The user is very smart and can understand how to merge your code blocks into their files, you just need to provide minimal hints.
< br />
8. Avoid repeating existing code, instead use comments to represent regions of unchanged code. The user prefers that you are as concise as possible. For example:
< br />
< ExampleCodeBlock languageId = ' languageId' examplePath = { '/path/to/file' } includeFilepath = { true } minNumberOfBackticks = { 4 }
code = {
[
` // ${ EXISTING_CODE_MARKER } ` ,
` { changed code } ` ,
` // ${ EXISTING_CODE_MARKER } ` ,
` { changed code } ` ,
` // ${ EXISTING_CODE_MARKER } `
] . join ( '\n' )
}
/>
<br />
< br />
< ResponseTranslationRules />
Here is an example of how you should format a code block belonging to the file example.ts in your response:
< br />
< Tag name = ' example' >
###
{
this
.
promptPathRepresentationService
.
getExampleFilePath
(
)
}
< br />
< br />
Add a new property 'age' and a new method 'getAge' to the class Person.
< br />
< br />
< ExampleCodeBlock languageId = ' typescript' examplePath = { tsExampleFilePath} includeFilepath = { true } minNumberOfBackticks = { 4 }
code = {
[
` class Person { ` ,
` // ${ EXISTING_CODE_MARKER } ` ,
` age: number; ` ,
` // ${ EXISTING_CODE_MARKER } ` ,
` getAge() { ` ,
` return this.age; ` ,
` } ` ,
` } ` ,
] . join ( '\n' )
}
/>
<br />
</ Tag >
</ InstructionMessage >
;
return
(
< >
< SystemMessage priority = { 1000 } >
You are an AI programming assistant.
< br />
< CopilotIdentityRules />
< LegacySafetyRules />
</ SystemMessage >
{
?
undefined
:
}
< EditCodeConversationHistory flexGrow = { 1 } priority = { 700 } workingSet = { this . props . promptContext . workingSet } history = { this . props . promptContext . history } promptInstructions = { this . props . promptContext . promptInstructions } chatVariables = { this . props . promptContext . chatVariables } />
{
?
:
undefined
}
< EditCodeUserMessage flexGrow = { 2 } priority = { 900 } { ... this . props } />
< ChatToolCalls priority = { 899 } flexGrow = { 3 } promptContext = { this . props . promptContext } toolCallRounds = { this . props . promptContext . toolCallRounds } toolCallResults = { this . props . promptContext . toolCallResults } />
</ >
)
;
}
}
interface
EditCodeReadonlyInstructionsProps
extends
BasePromptElementProps
{
readonly
:
ChatVariablesCollection
;
readonly
:
IWorkingSet
;
}
export
class
EditCodeReadonlyInstructions
extends
PromptElement< EditCodeReadonlyInstructionsProps>
{
constructor
(
:
EditCodeReadonlyInstructionsProps
,
IPromptPathRepresentationService
private
readonly
:
IPromptPathRepresentationService
,
)
{
super
(
)
;
}
render
(
)
{
const
{
}
=
this
;
if
(
!
.
length
)
{
return
< >
</ >
;
}
return
< TextChunk >
{
'<fileRestrictions>'
}
< br />
The following files are readonly. Making edits to any of these file paths is FORBIDDEN. If you cannot accomplish the task without editing the files, briefly explain why, but NEVER edit any of these files:
< br />
{
.
map
(
=>
` \t- ${ this . promptPathRepresentationService. getFilePath ( uri) } `
)
.
join
(
'\n'
)
}
< br />
{
'</fileRestrictions>'
}
</ TextChunk >
;
}
private
get
readonlyUris
(
)
:
Uri
[
]
{
const
=
[
]
;
for
(
const
of
this
.
props
.
workingSet
)
{
if
(
.
isMarkedReadonly
)
{
.
push
(
.
document
.
uri
)
;
}
}
for
(
const
of
this
.
props
.
chatVariables
)
{
if
(
.
isMarkedReadonly
)
{
if
(
isUri
(
.
value
)
)
{
.
push
(
.
value
)
;
}
else
if
(
isLocation
(
.
value
)
)
{
.
push
(
.
value
.
uri
)
;
}
}
}
return
;
}
}
interface
EditCodeConversationHistoryProps
extends
BasePromptElementProps
{
readonly
:
IWorkingSet
;
readonly
:
readonly
TextDocumentSnapshot
[
]
;
readonly
:
ChatVariablesCollection
;
readonly
:
readonly
Turn
[
]
;
readonly
:
number
;
}
class
EditCodeConversationHistory
extends
PromptElement< EditCodeConversationHistoryProps>
{
constructor
(
:
EditCodeConversationHistoryProps
,
IPromptPathRepresentationService
private
readonly
:
IPromptPathRepresentationService
)
{
super
(
)
;
}
async
render
(
:
void
,
:
PromptSizing
)
{
const
=
new
ResourceMap< number [ ] >
(
)
;
for
(
const
of
this
.
props
.
workingSet
)
{
.
set
(
.
document
.
uri
,
[
.
document
.
version
]
)
;
}
const
=
new
ResourceMap< number [ ] >
(
)
;
for
(
const
of
this
.
props
.
promptInstructions
)
{
.
set
(
.
uri
,
[
.
version
]
)
;
}
const
:
(
UserMessage
|
AssistantMessage
)
[
]
=
[
]
;
for
(
const
of
this
.
props
.
history
)
{
const
=
PreviousEditCodeStep
.
fromTurn
(
)
;
if
(
)
{
.
push
(
this
.
_renderUserMessageWithoutFiles
(
,
,
)
)
;
.
push
(
this
.
_renderAssistantMessageWithoutFileTags
(
.
response
)
)
;
}
}
return
(
< PrioritizedList priority = { this . props . priority } descending = { false } >
{
}
</ PrioritizedList >
)
;
}
private
_renderAssistantMessageWithoutFileTags
(
:
string
)
:
AssistantMessage
{
=
.
replace
(
/ <\/ ? file> / g
,
''
)
;
return
(
< AssistantMessage >
{
}
</ AssistantMessage >
)
;
}
private
_renderUserMessageWithoutFiles
(
:
PreviousEditCodeStep
,
:
ResourceMap
<
number
[
]
>
,
:
ResourceMap
<
number
[
]
>
)
:
UserMessage
{
const
:
Uri
[
]
=
[
]
;
for
(
const
of
.
workingSet
)
{
const
=
.
get
(
.
document
.
uri
)
??
[
]
;
const
=
.
some
(
=>
===
.
document
.
version
)
;
if
(
)
{
.
push
(
.
document
.
uri
)
;
}
else
{
.
push
(
.
document
.
version
)
;
.
set
(
.
document
.
uri
,
)
;
}
}
const
:
Uri
[
]
=
[
]
;
for
(
const
of
.
promptInstructions
)
{
const
=
.
get
(
.
document
.
uri
)
??
[
]
;
const
=
.
some
(
=>
===
.
document
.
version
)
;
if
(
)
{
.
push
(
.
document
.
uri
)
;
}
}
let
=
this
.
_removePromptInstructionsFromPastUserMessage
(
.
request
,
)
;
=
this
.
_removeFilesFromPastUserMessage
(
,
)
;
=
this
.
_removeReminders
(
)
;
return
(
< UserMessage >
{
}
</ UserMessage >
)
;
}
private
_removePromptInstructionsFromPastUserMessage
(
:
string
,
:
Uri
[
]
)
{
const
=
.
map
(
=>
this
.
_promptPathRepresentationService
.
getFilePath
(
)
)
;
return
.
replace
(
/ <instructions>[ \s \S ] *? <\/ instructions> / g
,
(
)
=>
{
if
(
.
some
(
=>
.
includes
(
)
)
)
{
return
''
;
}
return
;
}
)
;
}
private
_removeFilesFromPastUserMessage
(
:
string
,
:
Uri
[
]
)
{
const
=
.
map
(
=>
` ${ filepathCodeBlockMarker} ${ this . _promptPathRepresentationService. getFilePath ( uri) } `
)
;
return
.
replace
(
/ <file( -selection) ? >[ \s \S ] *? <\/ file( -selection) ? > / g
,
(
)
=>
{
if
(
.
some
(
=>
.
includes
(
)
)
)
{
return
''
;
}
return
;
}
)
;
}
private
_removeReminders
(
:
string
)
{
return
.
replace
(
/ ^ <reminder>[ \s \S ] *? ^ <\/ reminder>/ gm
,
(
)
=>
{
return
''
;
}
)
;
}
}
export
class
EditCodeUserMessage
extends
PromptElement< EditCodePromptProps>
{
constructor
(
:
EditCodePromptProps
,
IExperimentationService
private
readonly
:
IExperimentationService
,
IConfigurationService
private
readonly
:
IConfigurationService
,
)
{
super
(
)
;
}
async
render
(
:
void
,
:
PromptSizing
)
{
const
{
,
,
}
=
this
.
props
.
promptContext
;
const
=
this
.
_configurationService
.
getExperimentBasedConfig
(
ConfigKey
.
Advanced
.
ProjectLabelsChat
,
this
.
experimentationService
)
;
return
(
< >
< UserMessage >
{
&&
< ProjectLabels flexGrow = { 1 } priority = { 600 } />
}
< CustomInstructions flexGrow = { 6 } priority = { 750 } languageId = { undefined } chatVariables = { chatVariables} />
< NotebookFormat flexGrow = { 5 } priority = { 810 } chatVariables = { workingSet} query = { query} />
< ChatToolReferences flexGrow = { 4 } priority = { 898 } promptContext = { this . props . promptContext } documentContext = { this . props . documentContext } />
< ChatVariables flexGrow = { 3 } priority = { 898 } chatVariables = { chatVariables} />
< WorkingSet flexGrow = { 3 } flexReserve = { sizing. tokenBudget * 0.8 } priority = { 810 } workingSet = { workingSet} />
<br />
< Tag name = ' reminder' flexGrow = { 2 } priority = { 899 } >
Avoid repeating existing code, instead use a line comment with `{EXISTING_CODE_MARKER}` to represent regions of unchanged code.
< br />
The code block for each file being edited must start with a comment containing the filepath. This includes Markdown code blocks.
< br />
For existing files, make sure the filepath exactly matches the filepath of the original file.
< br />
< NotebookReminderInstructions chatVariables = { chatVariables} query = { query} />
< NewFilesLocationHint />
</ Tag >
{
&&
< Tag name = ' prompt' >
<UserQuery flexGrow=
{
7
}
priority=
{
900
}
chatVariables=
{
}
query=
{
}
/>
</ Tag >
}
< EditCodeReadonlyInstructions chatVariables = { chatVariables} workingSet = { workingSet} />
</ UserMessage >
</ >
)
;
}
}
interface
WorkingSetPromptProps
extends
BasePromptElementProps
{
readonly
:
IWorkingSet
;
}
export
class
WorkingSet
extends
PromptElement< WorkingSetPromptProps>
{
public
render
(
:
void
,
:
PromptSizing
)
{
const
{
}
=
this
.
props
;
return
(
.
length
?
< >
The user has provided the following files as input. Always make changes to these files unless the user asks to create a new file.
< br />
Untitled files are files that are not yet named. Make changes to them like regular files.
< br />
{
.
map
(
(
,
)
=>
(
isTextDocumentWorkingSetEntry
(
)
?
< TextDocumentWorkingSetEntry entry = { entry} flexGrow = { index} />
:
< NotebookWorkingSetEntry entry = { entry} flexGrow = { index} />
)
)
}
</ >
:
< >
</ >
)
;
}
}
export
class
NewFilesLocationHint
extends
PromptElement
{
constructor
(
:
BasePromptElementProps
,
IWorkspaceService
private
readonly
:
IWorkspaceService
,
IPromptPathRepresentationService
private
readonly
:
IPromptPathRepresentationService
,
)
{
super
(
)
;
}
public
render
(
:
void
,
:
PromptSizing
)
{
const
=
this
.
_workspaceService
.
getWorkspaceFolders
(
)
;
if
(
.
length
===
1
)
{
return
< >
When suggesting to create new files, pick a location inside `{this._promptPathRepresentationService.getFilePath(workspaceFolders[0])}`.
</ >
;
}
else
if
(
.
length
>
0
)
{
return
< >
When suggesting to create new files, pick a location inside one of these root folders:
{
.
map
(
=>
` ${ this . _promptPathRepresentationService. getFilePath ( f) } `
)
.
join
(
', '
)
}
.
</ >
;
}
else
{
const
=
Uri
.
from
(
{
:
Schemas
.
untitled
,
:
'untitled'
}
)
;
return
< >
When suggesting to create new files, pick a location inside `{this._promptPathRepresentationService.getFilePath(untitledRoot)}`.
</ >
;
}
}
}
interface
TextDocumentWorkingSetEntryPromptProps
extends
BasePromptElementProps
{
readonly
:
ITextDocumentWorkingSetEntry
;
}
class
TextDocumentWorkingSetEntry
extends
PromptElement< TextDocumentWorkingSetEntryPromptProps>
{
constructor
(
:
TextDocumentWorkingSetEntryPromptProps
,
IIgnoreService
private
readonly
:
IIgnoreService
,
IInstantiationService
private
readonly
:
IInstantiationService
,
)
{
super
(
)
;
}
async
render
(
:
void
,
:
PromptSizing
)
{
const
{
document
,
:
,
:
}
=
this
.
props
.
entry
;
const
=
await
this
.
_ignoreService
.
isCopilotIgnored
(
document
.
uri
)
;
if
(
)
{
return
< ignoredFiles value = { [ document . uri ] } />
;
}
const
=
this
.
instantiationService
.
createInstance
(
DocumentSummarizer
)
;
const
=
await
.
summarizeDocument
(
document
,
undefined
,
,
.
tokenBudget
,
{
:
,
}
)
;
const
=
!
.
isOriginal
?
{
:
{
:
.
t
(
'Part of this file was not sent to the model due to context window limitations. Try attaching specific selections from your file instead.'
)
,
:
2
}
}
:
undefined
;
let
=
''
;
if
(
===
WorkingSetEntryState
.
Accepted
)
{
=
'I applied your suggestions for this file and accepted them. Here is the updated file:'
;
}
else
if
(
===
WorkingSetEntryState
.
Rejected
)
{
=
'I considered your suggestions for this file but rejected them. Here is the file:'
;
}
else
if
(
===
WorkingSetEntryState
.
Undecided
)
{
=
'I applied your suggestions for this file but haven\'t decided yet if I accept or reject them. Here is the updated file:'
;
}
return
(
< CompositeElement priority = { this . props . priority } >
< Chunk priority = { 2 } >
< Tag name = ' file' >
{
&&
< >
< br />
<status>
{
}
</status>
< br />
</ >
}
< CodeBlock includeFilepath = { true } languageId = { document . languageId } uri = { document . uri } references = { [ new PromptReference ( document . uri , undefined , promptReferenceOptions) ] } code = { summarized. text } />
</ Tag >
</ Chunk >
{
!
!
&&
< FileSelection document = { document } selection = { selection} priority = { 1 } />
}
</ CompositeElement >
)
;
}
}
interface
NotebookWorkingSetEntryPromptProps
extends
BasePromptElementProps
{
readonly
:
INotebookWorkingSetEntry
;
}
class
NotebookWorkingSetEntry
extends
PromptElement< NotebookWorkingSetEntryPromptProps>
{
constructor
(
:
NotebookWorkingSetEntryPromptProps
,
IIgnoreService
private
readonly
:
IIgnoreService
,
IInstantiationService
private
readonly
:
IInstantiationService
,
)
{
super
(
)
;
}
async
render
(
:
void
,
:
PromptSizing
)
{
const
{
document
,
:
,
:
}
=
this
.
props
.
entry
;
const
=
await
this
.
_ignoreService
.
isCopilotIgnored
(
document
.
uri
)
;
if
(
)
{
return
< ignoredFiles value = { [ document . uri ] } />
;
}
const
=
this
.
instantiationService
.
createInstance
(
NotebookDocumentSummarizer
)
;
const
=
await
.
summarizeDocument
(
document
,
undefined
,
,
.
tokenBudget
,
{
:
,
}
)
;
const
=
!
.
isOriginal
?
{
:
{
:
.
t
(
'Part of this file was not sent to the model due to context window limitations. Try attaching specific selections from your file instead.'
)
,
:
2
}
}
:
undefined
;
let
=
''
;
if
(
===
WorkingSetEntryState
.
Accepted
)
{
=
'I applied your suggestions for this file and accepted them. Here is the updated file:'
;
}
else
if
(
===
WorkingSetEntryState
.
Rejected
)
{
=
'I considered your suggestions for this file but rejected them. Here is the file:'
;
}
else
if
(
===
WorkingSetEntryState
.
Undecided
)
{
=
'I applied your suggestions for this file but haven\'t decided yet if I accept or reject them. Here is the updated file:'
;
}
return
(
< CompositeElement priority = { this . props . priority } >
< Chunk priority = { 2 } >
This is a notebook file:
< br />
< Tag name = ' file' >
{
&&
< >
< br />
<status>
{
}
</status>
< br />
</ >
}
< CodeBlock includeFilepath = { true } languageId = { document . languageId } uri = { document . uri } references = { [ new PromptReference ( document . uri , undefined , promptReferenceOptions) ] } code = { summarized. text } />
</ Tag >
</ Chunk >
{
!
!
&&
< FileSelection document = { document } selection = { selection} priority = { 1 } />
}
</ CompositeElement >
)
;
}
}
interface
CurrentFileSelectionPromptProps
extends
BasePromptElementProps
{
document
:
TextDocumentSnapshot
|
NotebookDocumentSnapshot
|
undefined
;
:
Range
|
undefined
;
}
class
FileSelection
extends
PromptElement< CurrentFileSelectionPromptProps>
{
constructor
(
:
CurrentFileSelectionPromptProps
,
IIgnoreService
private
readonly
:
IIgnoreService
)
{
super
(
)
;
}
async
render
(
:
void
,
:
PromptSizing
)
{
const
{
document
,
}
=
this
.
props
;
if
(
!
document
||
!
)
{
return
undefined
;
}
const
=
await
this
.
_ignoreService
.
isCopilotIgnored
(
document
.
uri
)
;
if
(
)
{
return
< ignoredFiles value = { [ document . uri ] } />
;
}
if
(
document
.
lineCount
>=
4
)
{
const
:
string
[
]
=
[
]
;
const
charactersInSelectionLines
=
(
)
=>
.
reduce
(
(
,
)
=>
+
.
length
,
0
)
;
let
=
Math
.
min
(
document
.
lineCount
-
1
,
Math
.
max
(
0
,
.
start
.
line
)
)
;
let
=
Math
.
min
(
document
.
lineCount
-
1
,
.
end
.
line
)
;
if
(
>
&&
.
end
.
character
===
0
)
{
--
;
}
if
(
<
&&
.
start
.
character
===
document
.
lineAt
(
)
.
text
.
length
)
{
++
;
}
for
(
let
=
;
<=
;
++
)
{
const
=
document
.
lineAt
(
)
;
.
push
(
.
text
)
;
}
let
=
-
1
;
let
=
+
1
;
while
(
.
length
<
4
&&
charactersInSelectionLines
(
)
<
10
)
{
if
(
>=
0
)
{
.
unshift
(
document
.
lineAt
(
)
.
text
)
;
--
;
}
if
(
<
document
.
lineCount
)
{
.
push
(
document
.
lineAt
(
)
.
text
)
;
++
;
}
}
return
(
< Chunk >
<file-selection>
< CodeBlock includeFilepath = { true } languageId = { document . languageId } uri = { document . uri } references = { [ new PromptReference ( document . uri , undefined ) ] } code = { selectionLines. join ( '\n' ) } shouldTrim = { false } />
<br />
</file-selection>
</ Chunk >
)
;
}
else
{
return
undefined
;
}
}
}