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 / diagnosticsContext.tsx 235 строк · изменён 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
import { BasePromptElementProps , PromptElement , PromptReference , PromptSizing } from '@vscode/prompt-tsx' ;
import { TextDocumentSnapshot } from '../../../../platform/editing/common/textDocumentSnapshot' ;
import { IIgnoreService } from '../../../../platform/ignore/common/ignoreService' ;
import { ILogService } from '../../../../platform/log/common/logService' ;
import { IParserService , treeSitterOffsetRangeToVSCodeRange, treeSitterToVSCodeRange, vscodeToTreeSitterOffsetRange, vscodeToTreeSitterRange
documentContext
diagnostics
includeRelatedInfos
props
@ ignoreService
@ fixCookbookService
props
state sizing
diagnostics documentContext
isIgnored documentContext
isIgnored
diagnostics
diagnostics d idx
cookbook documentContext d
documentContext
diagnostic
cookbook
maxLength
state sizing
d
range d
content range range
code content
content
content
code
range
range d
diagnostic
cookbook
content
uri
range
infos
definitionRanges
ignoredFiles
props
@ workspaceService
@ parserService
@ ignoreService
@ logService
@ telemetryService
props
_state sizing
infos ignoredFiles definitionRanges
infos definitionRanges
infos info
definitionRanges range
infos
definitionRanges
ignoredFiles
diagnostic
diagnostic
relatedInformation diagnostic
relatedInformation
ignoredFiles
locationRange
treeSitterAST
relatedCodeText
treeSitterAST
treeSitterLocationRange locationRange
rangeOfInterest treeSitterAST treeSitterLocationRange
relatedCodeText rangeOfInterest
relatedCodeText relatedCodeText
relatedCodeText locationRange
relatedCodeText
infos content relatedCodeText uri range
e
definitionLocations
definitionLocations
treeSitterAST
treeSitterAST
diagnosticOffsetRange
expressionInfos treeSitterAST diagnosticOffsetRange
expressionInfo expressionInfos
expressionRange expressionInfo
definitionRanges expressionRange
definitionRanges
infos definitionRanges ignoredFiles
cookbook
state sizing
suggestedFixes
suggestedFixes
prompt suggestedFixes
prompt prompt
}
from
'../../../../platform/parser/node/parserService'
;
import
{ ITelemetryService }
from
'../../../../platform/telemetry/common/telemetry'
;
import
{ IWorkspaceService }
from
'../../../../platform/workspace/common/workspaceService'
;
import
{ Diagnostic , Location , Range , Uri }
from
'../../../../vscodeTypes'
;
import
{ asyncComputeWithTimeBudget }
from
'../../../context/node/resolvers/selectionContextHelpers'
;
import
{ IDocumentContext }
from
'../../../prompt/node/documentContext'
;
import
{ Tag }
from
'../base/tag'
;
import
{ ReferencesAtPosition }
from
'../panel/referencesAtPosition'
;
import
{ CodeBlock }
from
'../panel/safeElements'
;
import
{ ContextLocation , Cookbook , IFixCookbookService }
from
'./fixCookbookService'
;
export
type
DiagnosticContext
=
Pick
<
IDocumentContext
,
'document'
|
'language'
>
;
interface
DiagnosticsProps
extends
BasePromptElementProps
{
readonly
:
DiagnosticContext
;
readonly
:
Diagnostic
[
]
;
readonly
?
:
boolean
;
}
const
LINE_CONTEXT_MAX_SIZE
=
200
;
const
RELATED_INFO_MAX_SIZE
=
300
;
export
class
Diagnostics
extends
PromptElement< DiagnosticsProps>
{
constructor
(
:
DiagnosticsProps
,
IIgnoreService
private
readonly
:
IIgnoreService
,
IFixCookbookService
private
readonly
:
IFixCookbookService
,
)
{
super
(
)
;
}
async
render
(
:
void
,
:
PromptSizing
)
{
const
{
,
}
=
this
.
props
;
const
=
await
this
.
ignoreService
.
isCopilotIgnored
(
.
document
.
uri
)
;
if
(
)
{
return
< ignoredFiles value = { [ documentContext. document . uri ] } />
;
}
return
(
.
length
>
0
&&
< >
{
.
map
(
(
,
)
=>
{
const
=
this
.
fixCookbookService
.
getCookbook
(
.
language
.
languageId
,
)
;
return
< >
< DiagnosticDescription diagnostic = { d} cookbook = { cookbook} maxLength = { LINE_CONTEXT_MAX_SIZE } documentContext = { documentContext} />
{
this
.
props
.
includeRelatedInfos
!==
false
&&
< DiagnosticRelatedInfo diagnostic = { d} cookbook = { cookbook} document = { documentContext. document } />
}
< DiagnosticSuggestedFix cookbook = { cookbook} />
</ >
;
}
)
}
</ >
)
;
}
}
interface
DiagnosticDescriptionProps
extends
BasePromptElementProps
{
readonly
:
DiagnosticContext
;
readonly
:
Diagnostic
;
readonly
?
:
Cookbook
;
readonly
:
number
;
}
class
DiagnosticDescription
extends
PromptElement< DiagnosticDescriptionProps>
{
render
(
:
void
,
:
PromptSizing
)
{
const
=
this
.
props
.
diagnostic
;
const
document
=
this
.
props
.
documentContext
.
document
;
const
=
.
range
;
const
=
document
.
getText
(
new
Range
(
.
start
.
line
,
0
,
.
end
.
line
+
1
,
0
)
)
.
trimEnd
(
)
;
const
=
(
.
length
>
this
.
props
.
maxLength
)
?
.
slice
(
0
,
this
.
props
.
maxLength
)
+
' (truncated…)'
:
;
return
< >
{
?
< >
This code at line
{
.
start
.
line
+
1
}
< br />
< CodeBlock code = { code} uri = { document . uri } shouldTrim = { false } />
<br />
</ >
:
< >
At line
{
.
start
.
line
+
1
}
< br />
</ >
}
has the problem reported:
< br />
< Tag name = ' compileError' >
{
.
message
}
</ Tag >
</ >
;
}
}
interface
DiagnosticRelatedInfoProps
extends
BasePromptElementProps
{
readonly
:
Diagnostic
;
readonly
:
Cookbook
;
readonly
document
:
TextDocumentSnapshot
;
}
type
RelatedInfo
=
{
readonly
:
string
;
readonly
:
Uri
;
readonly
:
Range
;
}
;
interface
DiagnosticRelatedInfoState
{
readonly
:
RelatedInfo
[
]
;
readonly
:
Range
[
]
;
readonly
:
Uri
[
]
;
}
export
class
DiagnosticRelatedInfo
extends
PromptElement< DiagnosticRelatedInfoProps>
{
constructor
(
:
DiagnosticRelatedInfoProps
,
IWorkspaceService
private
readonly
:
IWorkspaceService
,
IParserService
private
readonly
:
IParserService
,
IIgnoreService
private
readonly
:
IIgnoreService
,
ILogService
private
readonly
:
ILogService
,
ITelemetryService
private
readonly
:
ITelemetryService
,
)
{
super
(
)
;
}
async
render
(
:
void
,
:
PromptSizing
)
{
const
{
,
,
}
=
await
this
.
getRelatedInfos
(
)
;
if
(
!
.
length
&&
!
.
length
)
{
return
< ignoredFiles value = { ignoredFiles} />
;
}
return
< >
This diagnostic has some related code:
< br />
{
.
map
(
=>
< CodeBlock code = { info. content } uri = { info. uri } references = { [ new PromptReference ( new Location ( info. uri , info. range ) ) ] } includeFilepath = { true } />
)
}
{
.
map
(
=>
< ReferencesAtPosition document = { this . props . document } position = { range. start } />
)
}
< ignoredFiles value = { ignoredFiles} />
</ >
;
}
private
async
getRelatedInfos
(
)
:
Promise
<
DiagnosticRelatedInfoState
>
{
const
:
RelatedInfo
[
]
=
[
]
;
const
:
Range
[
]
=
[
]
;
const
:
Uri
[
]
=
[
]
;
const
=
this
.
props
.
diagnostic
;
if
(
.
relatedInformation
)
{
for
(
const
of
.
relatedInformation
)
{
try
{
const
location
=
.
location
;
if
(
await
this
.
ignoreService
.
isCopilotIgnored
(
location
.
uri
)
)
{
.
push
(
location
.
uri
)
;
continue
;
}
const
document
=
await
this
.
workspaceService
.
openTextDocument
(
location
.
uri
)
;
const
=
location
.
range
;
const
=
this
.
parserService
.
getTreeSitterAST
(
document
)
;
let
:
string
|
undefined
;
if
(
)
{
const
=
vscodeToTreeSitterRange
(
)
;
const
=
await
.
getCoarseParentScope
(
)
;
=
document
.
getText
(
treeSitterToVSCodeRange
(
)
)
;
}
if
(
!
||
.
length
>
RELATED_INFO_MAX_SIZE
)
{
=
document
.
getText
(
)
;
}
if
(
.
length
<=
RELATED_INFO_MAX_SIZE
)
{
.
push
(
{
:
,
:
location
.
uri
,
:
location
.
range
}
)
;
}
}
catch
(
)
{
}
}
}
const
=
this
.
props
.
cookbook
.
additionalContext
(
)
;
for
(
const
location
of
)
{
switch
(
location
)
{
case
ContextLocation
.
ParentCallDefinition
:
{
const
=
this
.
parserService
.
getTreeSitterAST
(
this
.
props
.
document
)
;
if
(
)
{
const
=
vscodeToTreeSitterOffsetRange
(
this
.
props
.
diagnostic
.
range
,
this
.
props
.
document
)
;
const
=
await
asyncComputeWithTimeBudget
(
this
.
logService
,
this
.
telemetryService
,
this
.
props
.
document
,
500
,
(
)
=>
.
getCallExpressions
(
)
,
[
]
)
;
for
(
const
of
)
{
const
=
treeSitterOffsetRangeToVSCodeRange
(
this
.
props
.
document
,
)
;
.
push
(
)
;
}
}
break
;
}
case
ContextLocation
.
DefinitionAtLocation
:
{
.
push
(
this
.
props
.
diagnostic
.
range
)
;
break
;
}
}
}
return
{
,
,
}
;
}
}
export
interface
DiagnosticSuggestedFixProps
extends
BasePromptElementProps
{
readonly
:
Cookbook
;
}
export
class
DiagnosticSuggestedFix
extends
PromptElement< DiagnosticSuggestedFixProps>
{
render
(
:
void
,
:
PromptSizing
)
{
const
=
this
.
props
.
cookbook
.
fixes
;
if
(
.
length
)
{
const
=
[
0
]
;
return
< Tag name = ' suggestedFix' >
{
.
title
+
.
message
}
</ Tag >
;
}
return
null
;
}
}