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 / inline / inlineChatNotebookEditPrompt.tsx 264 строк · изменён 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
import { PromptElement , PromptSizing , SystemMessage , TextChunk , UserMessage } from '@vscode/prompt-tsx' ;
import type { NotebookDocument } from 'vscode' ;
import { IIgnoreService } from '../../../../platform/ignore/common/ignoreService' ;
import { IParserService } from '../../../../platform/parser/node/parserService' ;
import { ITabsAndEditorsService } from '../../../../platform/tabs/common/tabsAndEditorsService'
hasCodeWithoutSelection
codeWithoutSelection
codeSelected
tagBasedDocumentSummary
props
@ tabsAndEditorsService
@ workspaceService
props
override
wholeRange
wholeRange wholeRange
state sizing
wholeRange state
contextInfo
sizing
wholeRange
doc
jupyterNotebook
hasCodeWithoutSelection codeWithoutSelection codeSelected
aboveCells belowCells contextInfo
aboveCellsInfo aboveCells
belowCellsInfo belowCells
lang
isMarkdown lang
isEditing hasCodeWithoutSelection codeSelected
tagBasedDocumentSummary
jupyterNotebook
aboveCellsInfo belowCellsInfo tagBasedDocumentSummary
aboveCellsInfo belowCellsInfo tagBasedDocumentSummary
isMarkdown
isEditing aboveCellsInfo isEditing aboveCellsInfo hasCodeWithoutSelection doc lang codeWithoutSelection hasCodeWithoutSelection
isEditing aboveCellsInfo isEditing aboveCellsInfo hasCodeWithoutSelection doc lang codeWithoutSelection codeSelected
isMarkdown
hasCodeWithoutSelection aboveCellsInfo hasCodeWithoutSelection aboveCellsInfo hasCodeWithoutSelection doc lang codeWithoutSelection hasCodeWithoutSelection
hasCodeWithoutSelection aboveCellsInfo hasCodeWithoutSelection aboveCellsInfo hasCodeWithoutSelection doc lang codeWithoutSelection hasCodeWithoutSelection
notebook
activeDocumentContext
isJupyterNotebook
props
@ ignoreService
@ parserService
@ experimentationService
@ _parserService
@ workspaceService
props
override sizing
currentDocumentContext
activeDocumentContext currentDocumentContext
notebook currentDocumentContext
isIgnored activeDocumentContext
wholeRange activeDocumentContext activeDocumentContext
summarizedDocument
activeDocumentContext
activeDocumentContext
wholeRange
sizing
isTagBasedDocumentSummary
notebook
isJupyterNotebook currentDocumentContext
summarizedDocument
isIgnored
priorities promptPriorities
tagBasedDocumentSummary isTagBasedDocumentSummary
activeDocumentContext activeDocumentContext
state sizing
state
context state
promptContext
context
state
tagBasedDocumentSummary state
query history chatVariables promptContext
jupyterNotebook state
context
lang context
isMarkdown lang
splitDoc state
codeAbove codeSelected codeBelow hasCodeWithoutSelection splitDoc
data context context
codeWithoutSelection
replyInterpreter splitDoc
splitDoc
line line data
priorities state
lang hasCodeWithoutSelection isMarkdown data;
import
{ IExperimentationService }
from
'../../../../platform/telemetry/common/nullExperimentationService'
;
import
{ IWorkspaceService }
from
'../../../../platform/workspace/common/workspaceService'
;
import
{ findNotebook, isJupyterNotebookUri }
from
'../../../../util/common/notebooks'
;
import
{ illegalArgument }
from
'../../../../util/vs/base/common/errors'
;
import
{ Schemas }
from
'../../../../util/vs/base/common/network'
;
import
{ SelectionSplitKind , SummarizedDocumentData }
from
'../../../intents/node/testIntent/summarizedDocumentWithSelection'
;
import
{ IDocumentContext }
from
'../../../prompt/node/documentContext'
;
import
{ EarlyStopping , LeadingMarkdownStreaming , ReplyInterpreterMetaData }
from
'../../../prompt/node/intents'
;
import
{ TextPieceClassifiers }
from
'../../../prompt/node/streamingEdits'
;
import
{ InstructionMessage }
from
'../base/instructionMessage'
;
import
{ LegacySafetyRules }
from
'../base/safetyRules'
;
import
{ JupyterNotebookRules }
from
'../notebook/commonPrompts'
;
import
{ ChatToolReferences , ChatVariables , UserQuery }
from
'../panel/chatVariables'
;
import
{ HistoryWithInstructions }
from
'../panel/conversationHistory'
;
import
{ CustomInstructions }
from
'../panel/customInstructions'
;
import
{ CodeBlock }
from
'../panel/safeElements'
;
import
{ InlineChatEditCodePromptProps }
from
'./inlineChatEditCodePrompt'
;
import
{ promptPriorities }
from
'./inlineChatNotebookCommon'
;
import
{ generateSelectionContextInNotebook, InlineChatCustomNotebookCellsContextRenderer , InlineChatCustomNotebookInfoRenderer , InlineChatJupyterNotebookCellsContextRenderer , InlineChatNotebookBasePromptState , InlineChatNotebookSelectionCommonProps , InlineChatNotebookSelectionState , InlineChatNotebookVariables }
from
'./inlineChatNotebookCommonPromptElements'
;
import
{ createPromptingSummarizedDocument }
from
'./promptingSummarizedDocument'
;
interface
InlineChatNotebookEditSelectionProps
extends
InlineChatNotebookSelectionCommonProps
{
:
boolean
;
:
string
;
:
string
;
:
boolean
;
}
class
InlineChatNotebookEditSelection
extends
PromptElement< InlineChatNotebookEditSelectionProps, InlineChatNotebookSelectionState>
{
constructor
(
:
InlineChatNotebookEditSelectionProps
,
ITabsAndEditorsService
private
readonly
:
ITabsAndEditorsService
,
IWorkspaceService
private
readonly
:
IWorkspaceService
)
{
super
(
)
;
}
async
prepare
(
)
:
Promise
<
InlineChatNotebookSelectionState
>
{
const
{
document
,
}
=
this
.
props
.
documentContext
;
return
{
:
document
.
validateRange
(
)
}
;
}
render
(
:
InlineChatNotebookSelectionState
,
:
PromptSizing
)
{
if
(
this
.
props
.
documentContext
.
document
.
uri
.
scheme
!==
Schemas
.
vscodeNotebookCell
)
{
throw
illegalArgument
(
'InlineChatNotebookSelection should be used only with a notebook!'
)
;
}
const
{
}
=
;
const
=
generateSelectionContextInNotebook
(
.
endpoint
.
modelMaxPromptTokens
/
3
,
this
.
props
.
documentContext
,
,
this
.
tabsAndEditorsService
,
this
.
workspaceService
)
;
const
=
this
.
props
.
documentContext
.
document
;
const
=
isJupyterNotebookUri
(
this
.
props
.
documentContext
.
document
.
uri
)
;
const
{
,
,
}
=
this
.
props
;
const
{
,
}
=
;
const
=
||
[
]
;
const
=
||
[
]
;
const
=
this
.
props
.
documentContext
.
language
;
const
=
.
languageId
===
'markdown'
;
const
=
||
.
length
>
0
;
const
=
this
.
props
.
tagBasedDocumentSummary
;
return
< >
{
?
< >
{
(
(
.
length
>
0
||
.
length
>
0
)
&&
!
)
&&
< InlineChatJupyterNotebookCellsContextRenderer documentContext = { this . props . documentContext } aboveCells = { aboveCellsInfo} belowCells = { belowCellsInfo} />
}
{
(
(
.
length
>
0
||
.
length
>
0
)
&&
)
&&
< InlineChatJupyterNotebookCellsContextRenderer documentContext = { this . props . documentContext } aboveCells = { aboveCellsInfo} belowCells = { belowCellsInfo} />
}
< UserMessage >
{
?
< >
{
&&
< >
Now I edit a markdown cell in this Jupyter Notebook document at index
{
.
length
}
.
< br />
</ >
}
{
!
&&
< >
Now I create a new markdown cell in this Jupyter Notebook document at index
{
.
length
}
.
< br />
</ >
}
This is a markdown cell. Markdown cell is used to describe and document your workflow.
< br />
{
&&
< >
<CodeBlock uri=
{
.
uri
}
languageId=
{
.
languageId
}
code=
{
}
shouldTrim=
{
false
}
/>
< br />
</ >
}
{
&&
< >
The $SELECTION_PLACEHOLDER$ code is:
< br />
</ >
}
< CodeBlock uri = { doc. uri } languageId = { lang. languageId } code = { codeSelected} shouldTrim = { false } />
</ >
:
< >
{
&&
< >
Now I edit a cell in this Jupyter Notebook document at index
{
.
length
}
.
< br />
</ >
}
{
!
&&
< >
Now I create a new cell in this Jupyter Notebook document at index
{
.
length
}
.
< br />
</ >
}
{
&&
< >
<CodeBlock uri=
{
.
uri
}
languageId=
{
.
languageId
}
code=
{
}
shouldTrim=
{
false
}
/>
< br />
</ >
}
{
(
.
length
>
0
)
&&
< >
The $SELECTION_PLACEHOLDER$ code is:
< br />
</ >
}
< CodeBlock uri = { doc. uri } languageId = { lang. languageId } code = { codeSelected} shouldTrim = { false } />
</ >
}
</ UserMessage >
</ >
:
< >
< InlineChatCustomNotebookInfoRenderer documentContext = { this . props . documentContext } />
< InlineChatCustomNotebookCellsContextRenderer documentContext = { this . props . documentContext } aboveCells = { aboveCellsInfo} belowCells = { belowCellsInfo} />
< UserMessage >
{
?
< >
{
&&
< >
Now I edit a markdown cell in this custom Notebook document at index
{
.
length
}
.
< br />
</ >
}
{
!
&&
< >
Now I create a new markdown cell in this custom Notebook document at index
{
.
length
}
.
< br />
</ >
}
This is a markdown cell. Markdown cell is used to describe and document your workflow.
< br />
{
&&
< >
<CodeBlock uri=
{
.
uri
}
languageId=
{
.
languageId
}
code=
{
}
shouldTrim=
{
false
}
/>
< br />
</ >
}
{
&&
< >
The $SELECTION_PLACEHOLDER$ code is:
< br />
</ >
}
< CodeBlock uri = { doc. uri } languageId = { lang. languageId } code = { codeSelected} shouldTrim = { false } />
</ >
:
< >
{
&&
< >
Now I edit a cell in this custom Notebook document at index
{
.
length
}
.
< br />
</ >
}
{
!
&&
< >
Now I create a new cell in this custom Notebook document at index
{
.
length
}
.
< br />
</ >
}
{
&&
< >
<CodeBlock uri=
{
.
uri
}
languageId=
{
.
languageId
}
code=
{
}
shouldTrim=
{
false
}
/>
< br />
</ >
}
{
&&
< >
The $SELECTION_PLACEHOLDER$ code is:
< br />
</ >
}
< CodeBlock uri = { doc. uri } languageId = { lang. languageId } code = { codeSelected} shouldTrim = { false } />
</ >
}
</ UserMessage >
</ >
}
</ >
;
}
}
interface
InlineChatNotebookAlternativeEditPromptState
extends
InlineChatNotebookBasePromptState
{
?
:
NotebookDocument
;
:
IDocumentContext
;
:
boolean
;
}
export
class
InlineChatNotebookEditPrompt
extends
PromptElement< InlineChatEditCodePromptProps, InlineChatNotebookAlternativeEditPromptState>
{
constructor
(
:
InlineChatEditCodePromptProps
,
IIgnoreService
private
readonly
:
IIgnoreService
,
IParserService
private
readonly
:
IParserService
,
IExperimentationService
private
readonly
:
IExperimentationService
,
IParserService
private
readonly
:
IParserService
,
IWorkspaceService
private
readonly
:
IWorkspaceService
)
{
super
(
)
;
}
async
prepare
(
:
PromptSizing
)
:
Promise
<
InlineChatNotebookAlternativeEditPromptState
>
{
const
=
this
.
props
.
documentContext
;
const
=
;
const
=
findNotebook
(
.
document
.
uri
,
this
.
workspaceService
.
notebookDocuments
)
;
const
=
await
this
.
ignoreService
.
isCopilotIgnored
(
.
document
.
uri
)
;
const
=
.
document
.
validateRange
(
.
wholeRange
)
;
const
=
await
createPromptingSummarizedDocument
(
this
.
parserService
,
.
document
,
.
fileIndentInfo
,
,
.
endpoint
.
modelMaxPromptTokens
/
3
)
;
const
=
this
.
experimentationService
.
getTreatmentVariable
<
boolean
>
(
'copilotchat.tagBasedDocumentSummary'
)
??
false
;
return
{
,
:
isJupyterNotebookUri
(
.
document
.
uri
)
,
,
,
:
,
:
,
:
,
}
;
}
async
render
(
:
InlineChatNotebookAlternativeEditPromptState
,
:
PromptSizing
)
{
if
(
!
.
notebook
)
{
throw
illegalArgument
(
'InlineChatNotebookEditPrompt should be used only with a notebook!'
)
;
}
const
=
.
activeDocumentContext
;
const
=
this
.
props
.
promptContext
;
if
(
.
document
.
uri
.
scheme
!==
Schemas
.
vscodeNotebookCell
)
{
throw
illegalArgument
(
'InlineChatNotebookEditPrompt should be used only with a notebook!'
)
;
}
if
(
.
isIgnored
)
{
return
< ignoredFiles value = { [ context. document . uri ] } />
;
}
const
=
.
tagBasedDocumentSummary
;
const
{
,
,
}
=
;
const
=
.
isJupyterNotebook
;
const
document
=
.
document
;
const
=
.
language
;
const
=
.
languageId
===
'markdown'
;
const
=
.
summarizedDocument
.
splitAroundAdjustedSelection
(
)
;
const
{
,
,
,
}
=
;
const
=
await
SummarizedDocumentData
.
create
(
this
.
_parserService
,
document
,
.
fileIndentInfo
,
.
wholeRange
,
SelectionSplitKind
.
Adjusted
)
;
const
=
` ${ codeAbove} ${ data. placeholderText} ${ codeBelow} `
;
const
=
.
createReplyInterpreter
(
LeadingMarkdownStreaming
.
Mute
,
EarlyStopping
.
StopAfterFirstCodeBlock
,
.
replaceSelectionStreaming
,
TextPieceClassifiers
.
createCodeBlockClassifier
(
)
,
=>
.
value
.
trim
(
)
!==
.
placeholderText
)
;
const
=
.
priorities
;
return
(
< >
< meta value = { new ReplyInterpreterMetaData ( replyInterpreter) } />
< SystemMessage priority = { priorities. core } >
You are an AI programming assistant.
< br />
When asked for your name, you must respond with "GitHub Copilot".
< br />
You are a world class expert in programming, and especially good at
{
.
languageId
}
.
< br />
Source code is always contained in ``` blocks.<br />
The user needs help to modify some code.<br />
{hasCodeWithoutSelection && <>The user includes existing code and marks with {data.placeholderText} where the selected code should go.<br /></>}
<LegacySafetyRules />
</SystemMessage>
<HistoryWithInstructions inline={true} passPriority historyPriority={priorities.history ?? 700} history={history}>
<InstructionMessage priority={priorities.core}>
{jupyterNotebook &&
<>
<JupyterNotebookRules />
{!tagBasedDocumentSummary && <>When dealing with Jupyter Notebook, do not generate CELL INDEX in the code blocks in your answer, it is only used to help you understand the context.<br /></>}
</>
}
{isMarkdown && <>When generating content for markdown cell, provide the answer directly without any additional introductory text. Ensure that the response is structured in Markdown format to seamlessly integrate into the markdown file.</>}
{hasCodeWithoutSelection && <>The user includes existing code and marks with {data.placeholderText} where the selected code should go.<br /></>}
</InstructionMessage>
</HistoryWithInstructions>
<ChatToolReferences priority={priorities.context} promptContext={promptContext} flexGrow={1} embeddedInsideUserMessage={false} />
<ChatVariables priority={priorities.context} chatVariables={chatVariables} embeddedInsideUserMessage={false} />
<InlineChatNotebookEditSelection documentContext={context} hasCodeWithoutSelection={hasCodeWithoutSelection} codeWithoutSelection={codeWithoutSelection} codeSelected={codeSelected} priority={priorities.core} tagBasedDocumentSummary={tagBasedDocumentSummary} />
<InlineChatNotebookVariables notebookURI={context.document.uri} priority={priorities.runtimeCore} priorities={priorities} query={query} />
<UserMessage>
<CustomInstructions priority={priorities.context} languageId={lang.languageId} chatVariables={chatVariables} />
<UserQuery priority={priorities.core} chatVariables={chatVariables} query={query} /><br />
{(hasCodeWithoutSelection && isMarkdown) && <TextChunk priority={priorities.core} >The modified {data.placeholderText} code without ``` is:
</ TextChunk >
}
{
(
&&
!
)
&&
< TextChunk priority = { priorities. core } >
The modified
{
.
placeholderText
}
code with ``` is:
</ TextChunk >
}
</ UserMessage >
</ >
);
}
}