ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / src / vs / workbench / contrib / editTelemetry / test / browser / aiContributionFeature.test.ts 218 строк · изменён 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
import assert from 'assert' ;
import { DisposableStore } from '../../../../../base/common/lifecycle.js' ;
import { URI } from '../../../../../base/common/uri.js' ;
import { ServiceCollection } from '../../../../../platform/instantiation/common/serviceCollection.js' ;
import { TestInstantiationService } from '../../../../../platform/instantiation/test/common/instantiationServiceMock.js' ;
import { AnnotatedDocuments, UriVisibilityProvider } from '../../browser/helpers/annotatedDocuments.js' ;
import { StringEditWithReason } from '../../browser/helpers/observableWorkspace.js' ;
import AiContributionFeature
EditSources
DiffService
computeStringDiff
ensureNoDisposablesAreLeakedInTestSuite
ILogService NullLogService
MutableObservableWorkspace
CommandsRegistry
timeout
runWithFakedTimers
disposables DisposableStore
workspace MutableObservableWorkspace
fileA
fileB
chatEdit EditSources
languageId
modelId
codeBlockSuggestionId
extensionId
mode
requestId
sessionId
userEdit EditSources kind
inlineCompletionEdit EditSources
nes
requestUuid
languageId
correlationId
disposables
instantiationService disposables
instantiationService DiffService original modified original modified maxComputationTimeMs
instantiationService UriVisibilityProvider
instantiationService ILogService
workspace
annotatedDocuments disposables workspace instantiationService
disposables instantiationService AiContributionFeature annotatedDocuments
uris level
CommandsRegistry uris level
uris
CommandsRegistry uris
CommandsRegistry
d disposables workspace uri fileA initialValue
assert d uri
assert d uri
disposables
d disposables workspace uri fileA initialValue
d StringEditWithReason d chatEdit
assert d uri
assert d uri
disposables
d disposables workspace uri fileA initialValue
d StringEditWithReason d inlineCompletionEdit
assert d uri
assert d uri
disposables
d disposables workspace uri fileA initialValue
d StringEditWithReason d userEdit
assert d uri
assert d uri
disposables
dA disposables workspace uri fileA initialValue
dB disposables workspace uri fileB initialValue
dA StringEditWithReason dA chatEdit
dB StringEditWithReason dB chatEdit
assert dA uri
assert dB uri
dA uri
assert dA uri
assert dB uri
disposables
dA disposables workspace uri fileA initialValue
dB disposables workspace uri fileB initialValue
dA StringEditWithReason dA chatEdit
dB StringEditWithReason dB chatEdit
assert dA uri
assert dB uri
disposables
d disposables workspace uri fileA initialValue
d StringEditWithReason d chatEdit
d uri
assert d uri
d StringEditWithReason d chatEdit
assert d uri
disposables
d disposables workspace uri fileA initialValue
d StringEditWithReason d chatEdit
assert d uri
d
assert fileA
disposables
assert
disposables
dA disposables workspace uri fileA initialValue
disposables workspace uri fileB initialValue
dA StringEditWithReason dA chatEdit
assert fileA fileB
assert fileB fileA
assert fileB
disposables
{
}
from
'../../browser/aiContributionFeature.js'
;
import
{
}
from
'../../../../../editor/common/textModelEditSource.js'
;
import
{
}
from
'../../browser/helpers/documentWithAnnotatedEdits.js'
;
import
{
}
from
'../../../../../editor/common/services/editorWebWorker.js'
;
import
{
}
from
'../../../../../base/test/common/utils.js'
;
import
{
,
}
from
'../../../../../platform/log/common/log.js'
;
import
{
}
from
'./editTelemetry.test.js'
;
import
{
}
from
'../../../../../platform/commands/common/commands.js'
;
import
{
}
from
'../../../../../base/common/async.js'
;
import
{
}
from
'../../../../../base/test/common/timeTravelScheduler.js'
;
suite
(
'AiContributionFeature'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
let
:
;
let
:
;
const
=
URI
.
parse
(
'file:///a.ts'
)
;
const
=
URI
.
parse
(
'file:///b.ts'
)
;
const
=
.
chatApplyEdits
(
{
:
'plaintext'
,
:
undefined
,
:
undefined
,
:
undefined
,
:
undefined
,
:
undefined
,
:
undefined
,
}
)
;
const
=
.
cursor
(
{
:
'type'
}
)
;
const
=
.
inlineCompletionAccept
(
{
:
false
,
:
'test-uuid'
,
:
'plaintext'
,
:
undefined
,
}
)
;
function
setup
(
)
:
void
{
=
new
DisposableStore
(
)
;
const
=
.
add
(
new
TestInstantiationService
(
new
ServiceCollection
(
)
,
false
,
undefined
,
true
)
)
;
.
stubInstance
(
,
{
computeDiff
:
async
(
,
)
=>
computeStringDiff
(
,
,
{
:
500
}
,
'advanced'
)
}
)
;
.
stubInstance
(
,
{
isVisible
:
(
)
=>
true
}
)
;
.
stub
(
,
new
NullLogService
(
)
)
;
=
new
MutableObservableWorkspace
(
)
;
const
=
.
add
(
new
AnnotatedDocuments
(
,
)
)
;
.
add
(
.
createInstance
(
,
)
)
;
}
function
hasAiContributions
(
:
URI
[
]
,
:
'chatAndAgent'
|
'all'
)
:
boolean
{
return
.
getCommand
(
'_aiEdits.hasAiContributions'
)
!
.
handler
(
undefined
!
,
,
)
as
unknown
as
boolean
;
}
function
clearAiContributions
(
:
URI
[
]
)
:
void
{
.
getCommand
(
'_aiEdits.clearAiContributions'
)
!
.
handler
(
undefined
!
,
)
;
}
function
clearAllAiContributions
(
)
:
void
{
.
getCommand
(
'_aiEdits.clearAllAiContributions'
)
!
.
handler
(
undefined
!
)
;
}
test
(
'no contributions initially'
,
(
)
=>
runWithFakedTimers
(
{
}
,
async
(
)
=>
{
setup
(
)
;
const
=
.
add
(
.
createDocument
(
{
:
,
:
'hello'
}
,
undefined
)
)
;
await
timeout
(
1500
)
;
.
strictEqual
(
hasAiContributions
(
[
.
]
,
'all'
)
,
false
)
;
.
strictEqual
(
hasAiContributions
(
[
.
]
,
'chatAndAgent'
)
,
false
)
;
.
dispose
(
)
;
}
)
)
;
test
(
'detects chat AI edits'
,
(
)
=>
runWithFakedTimers
(
{
}
,
async
(
)
=>
{
setup
(
)
;
const
=
.
add
(
.
createDocument
(
{
:
,
:
'hello'
}
,
undefined
)
)
;
await
timeout
(
1500
)
;
.
applyEdit
(
.
replace
(
.
findRange
(
'hello'
)
,
'world'
,
)
)
;
await
timeout
(
1500
)
;
.
strictEqual
(
hasAiContributions
(
[
.
]
,
'all'
)
,
true
)
;
.
strictEqual
(
hasAiContributions
(
[
.
]
,
'chatAndAgent'
)
,
true
)
;
.
dispose
(
)
;
}
)
)
;
test
(
'detects inline completion AI edits at all level only'
,
(
)
=>
runWithFakedTimers
(
{
}
,
async
(
)
=>
{
setup
(
)
;
const
=
.
add
(
.
createDocument
(
{
:
,
:
'hello'
}
,
undefined
)
)
;
await
timeout
(
1500
)
;
.
applyEdit
(
.
replace
(
.
findRange
(
'hello'
)
,
'world'
,
)
)
;
await
timeout
(
1500
)
;
.
strictEqual
(
hasAiContributions
(
[
.
]
,
'all'
)
,
true
)
;
.
strictEqual
(
hasAiContributions
(
[
.
]
,
'chatAndAgent'
)
,
false
)
;
.
dispose
(
)
;
}
)
)
;
test
(
'does not detect user edits as AI'
,
(
)
=>
runWithFakedTimers
(
{
}
,
async
(
)
=>
{
setup
(
)
;
const
=
.
add
(
.
createDocument
(
{
:
,
:
'hello'
}
,
undefined
)
)
;
await
timeout
(
1500
)
;
.
applyEdit
(
.
replace
(
.
findRange
(
'hello'
)
,
'world'
,
)
)
;
await
timeout
(
1500
)
;
.
strictEqual
(
hasAiContributions
(
[
.
]
,
'all'
)
,
false
)
;
.
strictEqual
(
hasAiContributions
(
[
.
]
,
'chatAndAgent'
)
,
false
)
;
.
dispose
(
)
;
}
)
)
;
test
(
'clear resets contributions for specific resources'
,
(
)
=>
runWithFakedTimers
(
{
}
,
async
(
)
=>
{
setup
(
)
;
const
=
.
add
(
.
createDocument
(
{
:
,
:
'hello'
}
,
undefined
)
)
;
const
=
.
add
(
.
createDocument
(
{
:
,
:
'world'
}
,
undefined
)
)
;
await
timeout
(
1500
)
;
.
applyEdit
(
.
replace
(
.
findRange
(
'hello'
)
,
'foo'
,
)
)
;
.
applyEdit
(
.
replace
(
.
findRange
(
'world'
)
,
'bar'
,
)
)
;
await
timeout
(
1500
)
;
.
strictEqual
(
hasAiContributions
(
[
.
]
,
'all'
)
,
true
)
;
.
strictEqual
(
hasAiContributions
(
[
.
]
,
'all'
)
,
true
)
;
clearAiContributions
(
[
.
]
)
;
.
strictEqual
(
hasAiContributions
(
[
.
]
,
'all'
)
,
false
)
;
.
strictEqual
(
hasAiContributions
(
[
.
]
,
'all'
)
,
true
)
;
.
dispose
(
)
;
}
)
)
;
test
(
'clearAll resets all contributions'
,
(
)
=>
runWithFakedTimers
(
{
}
,
async
(
)
=>
{
setup
(
)
;
const
=
.
add
(
.
createDocument
(
{
:
,
:
'hello'
}
,
undefined
)
)
;
const
=
.
add
(
.
createDocument
(
{
:
,
:
'world'
}
,
undefined
)
)
;
await
timeout
(
1500
)
;
.
applyEdit
(
.
replace
(
.
findRange
(
'hello'
)
,
'foo'
,
)
)
;
.
applyEdit
(
.
replace
(
.
findRange
(
'world'
)
,
'bar'
,
)
)
;
await
timeout
(
1500
)
;
clearAllAiContributions
(
)
;
.
strictEqual
(
hasAiContributions
(
[
.
]
,
'all'
)
,
false
)
;
.
strictEqual
(
hasAiContributions
(
[
.
]
,
'all'
)
,
false
)
;
.
dispose
(
)
;
}
)
)
;
test
(
'tracks new edits after clear'
,
(
)
=>
runWithFakedTimers
(
{
}
,
async
(
)
=>
{
setup
(
)
;
const
=
.
add
(
.
createDocument
(
{
:
,
:
'hello'
}
,
undefined
)
)
;
await
timeout
(
1500
)
;
.
applyEdit
(
.
replace
(
.
findRange
(
'hello'
)
,
'world'
,
)
)
;
await
timeout
(
1500
)
;
clearAiContributions
(
[
.
]
)
;
.
strictEqual
(
hasAiContributions
(
[
.
]
,
'all'
)
,
false
)
;
.
applyEdit
(
.
replace
(
.
findRange
(
'world'
)
,
'again'
,
)
)
;
await
timeout
(
1500
)
;
.
strictEqual
(
hasAiContributions
(
[
.
]
,
'all'
)
,
true
)
;
.
dispose
(
)
;
}
)
)
;
test
(
'cleans up tracker when document is closed'
,
(
)
=>
runWithFakedTimers
(
{
}
,
async
(
)
=>
{
setup
(
)
;
const
=
.
add
(
.
createDocument
(
{
:
,
:
'hello'
}
,
undefined
)
)
;
await
timeout
(
1500
)
;
.
applyEdit
(
.
replace
(
.
findRange
(
'hello'
)
,
'world'
,
)
)
;
await
timeout
(
1500
)
;
.
strictEqual
(
hasAiContributions
(
[
.
]
,
'all'
)
,
true
)
;
.
dispose
(
)
;
await
timeout
(
1500
)
;
.
strictEqual
(
hasAiContributions
(
[
]
,
'all'
)
,
false
)
;
.
dispose
(
)
;
}
)
)
;
test
(
'returns false for unknown URIs'
,
(
)
=>
runWithFakedTimers
(
{
}
,
async
(
)
=>
{
setup
(
)
;
.
strictEqual
(
hasAiContributions
(
[
URI
.
parse
(
'file:///unknown.ts'
)
]
,
'all'
)
,
false
)
;
.
dispose
(
)
;
}
)
)
;
test
(
'checks multiple resources'
,
(
)
=>
runWithFakedTimers
(
{
}
,
async
(
)
=>
{
setup
(
)
;
const
=
.
add
(
.
createDocument
(
{
:
,
:
'hello'
}
,
undefined
)
)
;
.
add
(
.
createDocument
(
{
:
,
:
'world'
}
,
undefined
)
)
;
await
timeout
(
1500
)
;
.
applyEdit
(
.
replace
(
.
findRange
(
'hello'
)
,
'foo'
,
)
)
;
await
timeout
(
1500
)
;
.
strictEqual
(
hasAiContributions
(
[
,
]
,
'all'
)
,
true
)
;
.
strictEqual
(
hasAiContributions
(
[
,
]
,
'all'
)
,
true
)
;
.
strictEqual
(
hasAiContributions
(
[
]
,
'all'
)
,
false
)
;
.
dispose
(
)
;
}
)
)
;
}
)
;