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 / safeElements.tsx 178 строк · изменён 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
import { BasePromptElementProps , PromptElement , PromptElementProps , PromptReference , TextChunk } from '@vscode/prompt-tsx' ;
import type * as vscode from 'vscode' ;
import { isScenarioAutomation } from '../../../../platform/env/common/envService' ;
import { IVSCodeExtensionContext } from '../../../../platform/extContext/common/extensionContext' ;
import { IIgnoreService } from '../../../../platform/ignore/common/ignoreService' ;
import
props
@ _contextService
@ _telemetryService
@ _logService
@ _ignoreService
props
err
err
isScenarioAutomation
err
stack err
includeFilepath
uri vscode
code
languageId
references
lineBasedPriority
shouldTrim
fence
props
@ _contextService
@ _telemetryService
@ _logService
@ _ignoreService
@ _promptPathRepresentationService
props _contextService _telemetryService _logService _ignoreService
isIgnored
isIgnored
filePath
code filePath
reference
lines code
lines line i i reference line i lines
reference code
examplePath
isSummarized
includeFilepath
range vscode
code
languageId
shouldTrim
minNumberOfBackticks
props
@ _contextService
@ _telemetryService
@ _logService
@ _ignoreService
@ _promptPathRepresentationService
props _contextService _telemetryService _logService _ignoreService
filePath
code filePath
code
value vscode
mode
override
isIgnored
isIgnored
value
value
value
value
{ ILogService }
from
'../../../../platform/log/common/logService'
;
import
{ IPromptPathRepresentationService }
from
'../../../../platform/prompts/common/promptPathRepresentationService'
;
import
{ ITelemetryService }
from
'../../../../platform/telemetry/common/telemetry'
;
import
{ createFencedCodeBlock }
from
'../../../../util/common/markdown'
;
import
{ basename }
from
'../../../../util/vs/base/common/resources'
;
import
{ ExtensionMode }
from
'../../../../vscodeTypes'
;
export
abstract
class
SafePromptElement< P extends BasePromptElementProps, S = void >
extends
PromptElement< P , S >
{
constructor
(
:
P
,
IVSCodeExtensionContext
protected
readonly
:
IVSCodeExtensionContext
,
ITelemetryService
protected
readonly
:
ITelemetryService
,
ILogService
protected
readonly
:
ILogService
,
IIgnoreService
protected
readonly
:
IIgnoreService
,
)
{
super
(
)
;
}
protected
_handleFoulPrompt
(
)
:
undefined
{
const
=
new
Error
(
'BAD PROMPT'
)
;
this
.
_logService
.
error
(
)
;
if
(
this
.
_contextService
.
extensionMode
!==
ExtensionMode
.
Production
&&
!
)
{
throw
;
}
this
.
_telemetryService
.
sendMSFTTelemetryErrorEvent
(
'prompt.invalidreference'
,
{
:
.
stack
}
)
;
}
}
export
type
CodeBlockProps
=
PromptElementProps
<
{
readonly
?
:
boolean
;
readonly
:
.
Uri
;
readonly
:
string
;
readonly
?
:
string
;
readonly
?
:
PromptReference
[
]
;
readonly
?
:
boolean
;
readonly
?
:
boolean
;
readonly
?
:
string
;
}
>
;
export
class
CodeBlock
extends
SafePromptElement< CodeBlockProps>
{
constructor
(
:
CodeBlockProps
,
IVSCodeExtensionContext
:
IVSCodeExtensionContext
,
ITelemetryService
:
ITelemetryService
,
ILogService
:
ILogService
,
IIgnoreService
:
IIgnoreService
,
IPromptPathRepresentationService
private
readonly
:
IPromptPathRepresentationService
,
)
{
super
(
,
,
,
,
)
;
}
async
render
(
)
{
const
=
this
.
props
.
uri
?
await
this
.
_ignoreService
.
isCopilotIgnored
(
this
.
props
.
uri
)
:
false
;
if
(
)
{
return
this
.
_handleFoulPrompt
(
)
;
}
const
=
this
.
props
.
includeFilepath
?
this
.
_promptPathRepresentationService
.
getFilePath
(
this
.
props
.
uri
)
:
undefined
;
const
=
createFencedCodeBlock
(
this
.
props
.
languageId
??
''
,
this
.
props
.
code
,
this
.
props
.
shouldTrim
??
true
,
,
this
.
props
.
fence
)
;
const
=
this
.
props
.
references
&&
< references value = { this . props . references } />
;
if
(
this
.
props
.
lineBasedPriority
)
{
const
=
.
split
(
'\n'
)
;
return
< >
{
.
map
(
(
,
)
=>
< TextChunk priority = { i === lines. length - 1 ? lines. length : lines. length - i} >
{
===
0
&&
}
{
}
{
===
.
length
-
1
?
''
:
'\n'
}
</ TextChunk >
)
}
</ >
;
}
return
< TextChunk >
{
}
{
}
</ TextChunk >
;
}
}
export
type
ExampleCodeBlockProps
=
PromptElementProps
<
{
readonly
?
:
string
;
readonly
?
:
boolean
;
readonly
?
:
boolean
;
readonly
?
:
.
Range
;
readonly
:
string
;
readonly
?
:
string
;
readonly
?
:
boolean
;
readonly
?
:
number
;
}
>
;
export
class
ExampleCodeBlock
extends
SafePromptElement< ExampleCodeBlockProps>
{
constructor
(
:
ExampleCodeBlockProps
,
IVSCodeExtensionContext
:
IVSCodeExtensionContext
,
ITelemetryService
:
ITelemetryService
,
ILogService
:
ILogService
,
IIgnoreService
:
IIgnoreService
,
IPromptPathRepresentationService
private
readonly
:
IPromptPathRepresentationService
,
)
{
super
(
,
,
,
,
)
;
}
async
render
(
)
{
const
=
this
.
props
.
includeFilepath
?
this
.
_promptPathRepresentationService
.
getExampleFilePath
(
this
.
props
.
examplePath
??
'/path/to/file'
)
:
undefined
;
const
=
createFencedCodeBlock
(
this
.
props
.
languageId
??
''
,
this
.
props
.
code
,
this
.
props
.
shouldTrim
??
true
,
,
this
.
props
.
minNumberOfBackticks
)
;
return
< TextChunk >
{
}
</ TextChunk >
;
}
}
export
const
enum
UriMode
{
Basename
,
Path
}
export
type
UriProps
=
PromptElementProps
<
{
:
.
Uri
;
?
:
UriMode
;
}
>
;
export
class
Uri
extends
SafePromptElement< UriProps>
{
get
insertLineBreakBefore
(
)
:
boolean
{
return
false
;
}
async
render
(
)
{
const
=
await
this
.
_ignoreService
.
isCopilotIgnored
(
this
.
props
.
value
)
;
if
(
)
{
return
this
.
_handleFoulPrompt
(
)
;
}
let
:
string
;
if
(
this
.
props
.
mode
===
UriMode
.
Path
)
{
=
this
.
props
.
value
.
path
;
}
else
{
=
basename
(
this
.
props
.
value
)
;
}
return
< >
{
}
</ >
;
}
}