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 / intents / node / testIntent / testFromTestInvocation.tsx 177 строк · изменён 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
import { PromptElement , PromptElementProps , PromptSizing , SystemMessage , UserMessage } from '@vscode/prompt-tsx' ;
import type * as vscode from 'vscode' ;
import { IResponsePart } from '../../../../platform/chat/common/chatMLFetcher' ;
import { ChatLocation } from '../../../../platform/chat/common/commonTypes' ;
import { IChatEndpoint } from '../../../../platform/networking/common/networking' ;
replyInterpreter
intent
endpoint
context
alreadyConsumedChatVariable vscode
@ instantiationService
promptContext
progress vscode
vscode vscode
token vscode
renderer
context
promptContext
alreadyConsumedChatVariable
result renderer progress token
result replyInterpreter
result
context
inputStream
outputStream vscode
token
vscode
responseProcessor
responseProcessor context inputStream outputStream token
context
inputStream
outputStream
token
context
promptContext
alreadyConsumedChatVariable vscode
props
@ parserService
props
override _state sizing
history query chatVariables
context alreadyConsumedChatVariable
context
requestAndUserQuery
data
context
context
context
filteredChatVariables alreadyConsumedChatVariable chatVariables chatVariables v v alreadyConsumedChatVariable
context context
import
{ IParserService }
from
'../../../../platform/parser/node/parserService'
;
import
{ isNotebookCellOrNotebookChatInput }
from
'../../../../util/common/notebooks'
;
import
{ CancellationToken }
from
'../../../../util/vs/base/common/cancellation'
;
import
{ illegalArgument }
from
'../../../../util/vs/base/common/errors'
;
import
{ assertType }
from
'../../../../util/vs/base/common/types'
;
import
{ IInstantiationService }
from
'../../../../util/vs/platform/instantiation/common/instantiation'
;
import
{ IBuildPromptContext }
from
'../../../prompt/common/intents'
;
import
{ IDocumentContext }
from
'../../../prompt/node/documentContext'
;
import
{ IIntentInvocation , IResponseProcessorContext , ReplyInterpreter , ReplyInterpreterMetaData }
from
'../../../prompt/node/intents'
;
import
{ Test2Impl }
from
'../../../prompt/node/test2Impl'
;
import
{ CopilotIdentityRules }
from
'../../../prompts/node/base/copilotIdentity'
;
import
{ InstructionMessage }
from
'../../../prompts/node/base/instructionMessage'
;
import
{ PromptRenderer }
from
'../../../prompts/node/base/promptRenderer'
;
import
{ SafetyRules }
from
'../../../prompts/node/base/safetyRules'
;
import
{ Tag }
from
'../../../prompts/node/base/tag'
;
import
{ ChatToolReferences , ChatVariables , UserQuery }
from
'../../../prompts/node/panel/chatVariables'
;
import
{ HistoryWithInstructions }
from
'../../../prompts/node/panel/conversationHistory'
;
import
{ CustomInstructions }
from
'../../../prompts/node/panel/customInstructions'
;
import
{ SelectionSplitKind , SummarizedDocumentData , SummarizedDocumentWithSelection }
from
'./summarizedDocumentWithSelection'
;
import
{ TestDeps }
from
'./testDeps'
;
import
{ TestsIntent }
from
'./testIntent'
;
import
{ PseudoStopStartResponseProcessor }
from
'../../../prompt/node/pseudoStartStopConversationCallback'
;
export
class
TestFromTestInvocation
implements
IIntentInvocation
{
private
:
ReplyInterpreter
|
null
=
null
;
constructor
(
readonly
:
TestsIntent
,
readonly
:
IChatEndpoint
,
readonly
location
:
ChatLocation
,
private
readonly
:
IDocumentContext
,
private
readonly
:
.
ChatPromptReference
|
undefined
,
IInstantiationService
private
readonly
:
IInstantiationService
,
)
{
}
async
buildPrompt
(
:
IBuildPromptContext
,
:
.
Progress
<
.
ChatResponseProgressPart
|
.
ChatResponseReferencePart
>
,
:
.
CancellationToken
)
{
const
=
PromptRenderer
.
create
(
this
.
instantiationService
,
this
.
endpoint
,
TestFromTestPrompt
,
{
:
this
.
context
,
,
:
this
.
alreadyConsumedChatVariable
,
}
)
;
const
=
await
.
render
(
,
)
;
this
.
replyInterpreter
=
.
metadata
.
get
(
ReplyInterpreterMetaData
)
?.
??
null
;
return
;
}
async
processResponse
(
:
IResponseProcessorContext
,
:
AsyncIterable
<
IResponsePart
>
,
:
.
ChatResponseStream
,
:
CancellationToken
)
:
Promise
<
.
ChatResult
|
void
>
{
if
(
this
.
location
===
ChatLocation
.
Panel
)
{
const
=
this
.
instantiationService
.
createInstance
(
PseudoStopStartResponseProcessor
,
[
]
,
undefined
)
;
await
.
processResponse
(
,
,
,
)
;
return
;
}
assertType
(
this
.
replyInterpreter
!==
null
,
'TestFromTestInvocation should have received replyInterpreter from its prompt element'
)
;
return
this
.
replyInterpreter
.
processResponse
(
,
,
,
)
;
}
}
type
Props
=
PromptElementProps
<
{
:
IDocumentContext
;
:
IBuildPromptContext
;
:
.
ChatPromptReference
|
undefined
;
}
>
;
class
TestFromTestPrompt
extends
PromptElement< Props>
{
constructor
(
:
Props
,
IParserService
private
readonly
:
IParserService
)
{
super
(
)
;
}
async
render
(
:
void
,
:
PromptSizing
)
{
const
{
,
,
,
}
=
this
.
props
.
promptContext
;
const
{
,
,
}
=
this
.
props
;
if
(
isNotebookCellOrNotebookChatInput
(
.
document
.
uri
)
)
{
throw
illegalArgument
(
'TestFromTestPrompt should not be used for notebooks'
)
;
}
const
=
` Please, generate more tests, taking into account existing tests. ${ query} `
.
trim
(
)
;
const
=
await
SummarizedDocumentData
.
create
(
this
.
parserService
,
.
document
,
.
fileIndentInfo
,
.
wholeRange
,
SelectionSplitKind
.
Adjusted
,
)
;
const
=
===
undefined
?
:
.
filter
(
=>
.
reference
!==
)
;
return
(
< >
< SystemMessage priority = { 1000 } >
You are an AI programming assistant.
< br />
< CopilotIdentityRules />
<br />
< SafetyRules />
</ SystemMessage >
< HistoryWithInstructions passPriority history = { history} historyPriority = { 700 } >
< InstructionMessage priority = { 1000 } >
The user has a
{
.
language
.
languageId
}
file opened in a code editor.
< br />
The user includes some code snippets from the file.
< br />
Answer with a single
{
.
language
.
languageId
}
code block.
< br />
Your expertise is strictly limited to software development topics.
< br />
</ InstructionMessage >
</ HistoryWithInstructions >
< UserMessage >
< TestDeps priority = { 750 } languageId = { context. language . languageId } />
< CustomInstructions chatVariables = { filteredChatVariables} priority = { 725 } languageId = { context. language . languageId } includeTestGenerationInstructions = { true } />
< ChatToolReferences priority = { 750 } promptContext = { this . props . promptContext } flexGrow = { 1 } />
< ChatVariables priority = { 750 } chatVariables = { filteredChatVariables} />
{
}
< Test2Impl priority = { 800 } documentContext = { context} />
{
}
< Tag name = ' testsFile' priority = { 900 } >
< SummarizedDocumentWithSelection
documentData = { data}
tokenBudget = { sizing. tokenBudget / 3 }
_allowEmptySelection = { true }
/>
{
}
</ Tag >
< Tag name = ' userPrompt' priority = { 900 } >
< UserQuery chatVariables = { filteredChatVariables} query = { requestAndUserQuery} />
</ Tag >
</ UserMessage >
</ >
)
;
}
}