ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / src / vs / sessions / contrib / providers / agentHost / test / browser / agentHostSkillButtons.test.ts 233 строк · изменён 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
import assert from 'assert' ;
import { Codicon } from '../../../../../../base/common/codicons.js' ;
import { constObservable, observableValue } from '../../../../../../base/common/observable.js' ;
import { URI } from '../../../../../../base/common/uri.js' ;
import { mock } from '../../../../../../base/test/common/mock.js' ;
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../../base/test/common/utils.js' ;
import { isIMenuItem, isISubmenuItem, MenuId, MenuRegistry } from '../../../../../../platform/actions/common/actions.js'
CommandsRegistry
ContextKeyExpression IContextKeyService
TestInstantiationService
MockContextKeyService
ChatInteractivity IChat
ISessionsProvidersService
ISessionsProvider
IActiveSession
ISessionsService
IsAgentHostSession IsAgentHostSessionContextContribution isAgentHostSkillButtonId
BaseAgentHostSessionsProvider
providerId IActiveSession
chat
resource
createdAt
title
updatedAt
status
changes
modelId
modelSource
mode
isArchived
isRead
interactivity ChatInteractivity Full
checkpoints
lastTurnEnd
description
satisfies IChat
sessionId
resource chat resource
providerId
sessionType
icon Codicon copilot
createdAt chat createdAt
workspace
title chat title
updatedAt chat updatedAt
status chat status
changesets
changes chat changes
modelId chat modelId
mode chat mode
loading
isArchived chat isArchived
isRead chat isRead
lastTurnEnd chat lastTurnEnd
description chat description
chats chat
activeChat chat
mainChat chat
capabilities supportsMultipleChats
isCreated
sticky
openChats chat
closedChats
lastClosedChat
visibleChatTabs chat
shouldShowChatTabs
satisfies IActiveSession
id
Object FakeAgentHostProvider prototype BaseAgentHostSessionsProvider prototype
id
_serviceBrand
override activeSession
s IActiveSession
activeSession s
_serviceBrand
_providers
p id
_providers p id p ISessionsProvider
override id
_providers id
override ISessionsProvider
_providers
store
contextKeyService store
sessions
providers
instantiationService store
instantiationService IContextKeyService contextKeyService
instantiationService ISessionsService sessions
instantiationService ISessionsProvidersService providers
store instantiationService IsAgentHostSessionContextContribution
contextKeyService sessions providers
contextKeyService
assert contextKeyService IsAgentHostSession key
contextKeyService sessions providers
providers
sessions
assert contextKeyService IsAgentHostSession key
contextKeyService sessions providers
providers
sessions
assert contextKeyService IsAgentHostSession key
contextKeyService sessions
sessions
assert contextKeyService IsAgentHostSession key
contextKeyService sessions providers
providers
providers
sessions
assert contextKeyService IsAgentHostSession key
sessions
assert contextKeyService IsAgentHostSession key
sessions
assert contextKeyService IsAgentHostSession key
suite
all MenuRegistry MenuId AgentsChangesPrimaryActionSubMenu
menuItems command id when ContextKeyExpression
item all
item
item command id
menuItems item
menuItems
ids item item command id
assert ids
item
whenStr item when
assert
whenStr IsAgentHostSession key
assert
whenStr
assert
assert CommandsRegistry
toolbarItems MenuRegistry MenuId AgentsChangesToolbar
submenuEntry toolbarItems item item item submenu MenuId AgentsChangesPrimaryActionSubMenu
assert submenuEntry
assert submenuEntry group group
assert
assert
assert
;
import
{
}
from
'../../../../../../platform/commands/common/commands.js'
;
import
{
,
}
from
'../../../../../../platform/contextkey/common/contextkey.js'
;
import
{
}
from
'../../../../../../platform/instantiation/test/common/instantiationServiceMock.js'
;
import
{
}
from
'../../../../../../platform/keybinding/test/common/mockKeybindingService.js'
;
import
{
,
}
from
'../../../../../services/sessions/common/session.js'
;
import
{
}
from
'../../../../../services/sessions/browser/sessionsProvidersService.js'
;
import
{
}
from
'../../../../../services/sessions/common/sessionsProvider.js'
;
import
{
}
from
'../../../../../services/sessions/common/sessionsManagement.js'
;
import
{
}
from
'../../../../../services/sessions/browser/sessionsService.js'
;
import
{
AGENT_HOST_SKILL_BUTTON_UPDATE_PR_ID
,
,
,
}
from
'../../browser/agentHostSkillButtons.js'
;
import
{
}
from
'../../browser/baseAgentHostSessionsProvider.js'
;
import
'../../../../applyCommitsToParentRepo/browser/applyChangesToParentRepo.js'
;
function
makeActiveSession
(
:
string
)
:
{
const
=
{
:
URI
.
parse
(
'file:///session'
)
,
:
new
Date
(
)
,
:
observableValue
(
't'
,
'Test'
)
,
:
observableValue
(
'u'
,
new
Date
(
)
)
,
:
observableValue
(
's'
,
0
)
,
:
observableValue
(
'c'
,
[
]
)
,
:
observableValue
(
'm'
,
undefined
)
,
:
observableValue
(
'ms'
,
undefined
)
,
:
observableValue
(
'mo'
,
undefined
)
,
:
observableValue
(
'ia'
,
false
)
,
:
observableValue
(
'ir'
,
true
)
,
:
observableValue
(
'ii'
,
.
)
,
:
observableValue
(
'cp'
,
undefined
)
,
:
observableValue
(
'lte'
,
undefined
)
,
:
observableValue
(
'd'
,
undefined
)
,
}
;
return
{
:
` ${ providerId} :x `
,
:
.
,
,
:
'copilotcli'
,
:
.
,
:
.
,
:
observableValue
(
'w'
,
undefined
)
,
:
.
,
:
.
,
:
.
,
:
constObservable
(
[
]
)
,
:
.
,
:
.
,
:
.
,
:
observableValue
(
'l'
,
false
)
,
:
.
,
:
.
,
:
.
,
:
.
,
:
observableValue
(
'chats'
,
[
]
)
,
:
observableValue
(
'ac'
,
)
,
:
constObservable
(
)
,
:
constObservable
(
{
:
false
}
)
,
:
observableValue
(
'isCreated'
,
true
)
,
:
observableValue
(
'sticky'
,
false
)
,
:
observableValue
(
'openChats'
,
[
]
)
,
:
constObservable
(
[
]
)
,
:
undefined
,
:
constObservable
(
[
]
)
,
:
constObservable
(
false
)
,
}
;
}
class
FakeAgentHostProvider
{
constructor
(
public
readonly
:
string
)
{
}
}
.
setPrototypeOf
(
.
,
.
)
;
class
FakeNonAgentHostProvider
{
constructor
(
public
readonly
:
string
)
{
}
}
class
FakeSessionsService
extends
mock< ISessionsService>
(
)
{
declare
readonly
:
undefined
;
readonly
=
observableValue < IActiveSession | undefined >
(
'activeSession'
,
undefined
)
;
setActiveSession
(
:
|
undefined
)
:
void
{
this
.
.
set
(
,
undefined
)
;
}
}
class
FakeSessionsProvidersService
extends
mock< ISessionsProvidersService>
(
)
{
declare
readonly
:
undefined
;
private
readonly
=
new
Map< string , ISessionsProvider>
(
)
;
register
(
:
{
:
string
}
)
:
void
{
this
.
.
set
(
.
,
as
unknown
as
)
;
}
getProvider < T extends ISessionsProvider>
(
:
string
)
:
T
|
undefined
{
return
this
.
.
get
(
)
as
T
|
undefined
;
}
getProviders
(
)
:
[
]
{
return
[
...
this
.
.
values
(
)
]
;
}
}
suite
(
'agentHostSkillButtons - IsAgentHostSession context key'
,
(
)
=>
{
const
=
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
function
setup
(
)
{
const
=
.
add
(
new
MockContextKeyService
(
)
)
;
const
=
new
FakeSessionsService
(
)
;
const
=
new
FakeSessionsProvidersService
(
)
;
const
=
.
add
(
new
TestInstantiationService
(
)
)
;
.
stub
(
,
)
;
.
stub
(
,
)
;
.
stub
(
,
)
;
.
add
(
.
createInstance
(
)
)
;
return
{
,
,
}
;
}
test
(
'is false when no active session'
,
(
)
=>
{
const
{
}
=
setup
(
)
;
.
strictEqual
(
.
getContextKeyValue
(
.
)
,
false
)
;
}
)
;
test
(
'is true when active session comes from an agent-host provider'
,
(
)
=>
{
const
{
,
,
}
=
setup
(
)
;
.
register
(
new
FakeAgentHostProvider
(
'local-agent-host'
)
)
;
.
setActiveSession
(
makeActiveSession
(
'local-agent-host'
)
)
;
.
strictEqual
(
.
getContextKeyValue
(
.
)
,
true
)
;
}
)
;
test
(
'is false when active session comes from a non agent-host provider'
,
(
)
=>
{
const
{
,
,
}
=
setup
(
)
;
.
register
(
new
FakeNonAgentHostProvider
(
'copilot-cloud-agent'
)
)
;
.
setActiveSession
(
makeActiveSession
(
'copilot-cloud-agent'
)
)
;
.
strictEqual
(
.
getContextKeyValue
(
.
)
,
false
)
;
}
)
;
test
(
'is false when active session references an unknown provider'
,
(
)
=>
{
const
{
,
}
=
setup
(
)
;
.
setActiveSession
(
makeActiveSession
(
'no-such-provider'
)
)
;
.
strictEqual
(
.
getContextKeyValue
(
.
)
,
false
)
;
}
)
;
test
(
'updates reactively when active session changes'
,
(
)
=>
{
const
{
,
,
}
=
setup
(
)
;
.
register
(
new
FakeAgentHostProvider
(
'local-agent-host'
)
)
;
.
register
(
new
FakeNonAgentHostProvider
(
'copilot-cloud-agent'
)
)
;
.
setActiveSession
(
makeActiveSession
(
'local-agent-host'
)
)
;
.
strictEqual
(
.
getContextKeyValue
(
.
)
,
true
)
;
.
setActiveSession
(
makeActiveSession
(
'copilot-cloud-agent'
)
)
;
.
strictEqual
(
.
getContextKeyValue
(
.
)
,
false
)
;
.
setActiveSession
(
undefined
)
;
.
strictEqual
(
.
getContextKeyValue
(
.
)
,
false
)
;
}
)
;
}
)
;
.
skip
(
'agentHostSkillButtons - menu registration'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
function
skillButtonItems
(
)
{
const
=
.
getMenuItems
(
.
)
;
const
:
{
:
{
:
string
}
;
?
:
}
[
]
=
[
]
;
for
(
const
of
)
{
if
(
!
isIMenuItem
(
)
)
{
continue
;
}
if
(
isAgentHostSkillButtonId
(
.
.
)
)
{
.
push
(
)
;
}
}
return
;
}
test
(
'registers four skill button menu items on the apply submenu'
,
(
)
=>
{
const
=
skillButtonItems
(
)
.
map
(
=>
.
.
)
.
sort
(
)
;
.
deepStrictEqual
(
,
[
'workbench.action.agentSessions.runSkill.createDraftPR'
,
'workbench.action.agentSessions.runSkill.createPR'
,
'workbench.action.agentSessions.runSkill.merge'
,
'workbench.action.agentSessions.runSkill.updatePR'
,
]
)
;
}
)
;
test
(
'every skill button `when` clause includes sessions.isAgentHostSession and isSessionsWindow'
,
(
)
=>
{
for
(
const
of
skillButtonItems
(
)
)
{
const
=
.
?.
serialize
(
)
??
''
;
.
ok
(
.
includes
(
.
)
,
` expected ${ item. command. id} to gate on ${ IsAgentHostSession. key} , got: ${ whenStr} `
,
)
;
.
ok
(
.
includes
(
'isSessionsWindow'
)
,
` expected ${ item. command. id} to gate on isSessionsWindow, got: ${ whenStr} `
,
)
;
}
}
)
;
test
(
'exported updatePR id matches the registered command'
,
(
)
=>
{
.
ok
(
isAgentHostSkillButtonId
(
AGENT_HOST_SKILL_BUTTON_UPDATE_PR_ID
)
)
;
.
ok
(
.
getCommand
(
AGENT_HOST_SKILL_BUTTON_UPDATE_PR_ID
)
,
` expected command ${ AGENT_HOST_SKILL_BUTTON_UPDATE_PR_ID } to be registered `
)
;
}
)
;
test
(
'the apply submenu is contributed to the changes toolbar in the navigation group'
,
(
)
=>
{
const
=
.
getMenuItems
(
.
)
;
const
=
.
find
(
=>
isISubmenuItem
(
)
&&
.
===
.
)
;
.
ok
(
,
'expected AgentsChangesPrimaryActionSubMenu to be registered on AgentsChangesToolbar'
)
;
.
strictEqual
(
(
as
{
?
:
string
}
)
.
,
'navigation'
)
;
}
)
;
test
(
'isAgentHostSkillButtonId only matches our prefix'
,
(
)
=>
{
.
strictEqual
(
isAgentHostSkillButtonId
(
'workbench.action.agentSessions.runSkill.merge'
)
,
true
)
;
.
strictEqual
(
isAgentHostSkillButtonId
(
'github.copilot.sessions.commit'
)
,
false
)
;
.
strictEqual
(
isAgentHostSkillButtonId
(
''
)
,
false
)
;
}
)
;
}
)
;