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 / tools / node / vscodeCmdTool.tsx 208 строк · изменён 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
import * as l10n from '@vscode/l10n' ;
import type * as vscode from 'vscode' ;
import { IRunCommandExecutionService } from '../../../platform/commands/common/runCommandExecutionService' ;
import { ILogService } from '../../../platform/log/common/logService' ;
import { IWorkbenchService } from '../../../platform/workbench/common/workbenchService' ;
import { CancellationToken } from '../../../util/vs/base/common/cancellation' ;
import
commandId
name
args
skipCheck
noConfirmationCommandsWithoutArgs
noConfirmationCommandsWithArgs
toolName
@ _commandService
@ _workbenchService
@ _logService
options vscode token vscode
command options
args options
options
allCommands
commandItem allCommands commandItem commandItem command
commandItem
allCommandsNoFilter
commandItemNoFilter allCommandsNoFilter commandItem commandItem command
commandItemNoFilter
result command args
textPart
result result
textPart
result
textPart
serializedResult
serializedResult result
serializedResult result
textPart
textPart
error
options vscode token vscode vscode
commandId options
commandId
invocationMessage l10n
noConfirmationCommandsWithoutArgs commandId noConfirmationCommandsWithArgs commandId options options
invocationMessage
noConfirmationCommandsWithArgs commandId options options
invocationMessage
quickOpenCommand
commandStr quickOpenCommand commandId
hasArguments options length
markdownString
markdownString l10n options commandStr options
hasArguments
markdownString
markdownString options
markdownString enabledCommands quickOpenCommand
invocationMessage
confirmationMessages
title l10n
message markdownString
approveCombination
message hasArguments
l10n
l10n
arguments hasArguments options
{ LanguageModelTextPart , LanguageModelToolResult , MarkdownString }
from
'../../../vscodeTypes'
;
import
{ commandUri }
from
'../../linkify/common/commands'
;
import
{ ToolName }
from
'../common/toolNames'
;
import
{ ToolRegistry }
from
'../common/toolsRegistry'
;
interface
IVSCodeCmdToolToolInput
{
:
string
;
:
string
;
:
any
[
]
;
?
:
boolean
;
}
const
=
new
Set
(
[
'github.copilot.debug.collectDiagnostics'
,
'breadcrumbs.toggle'
,
'diffEditor.toggleCollapseUnchangedRegions'
,
'diffEditor.toggleShowMovedCodeBlocks'
,
'editor.action.announceCursorPosition'
,
'editor.action.defineKeybinding'
,
'editor.action.showOrFocusStandaloneColorPicker'
,
'editor.action.toggleOvertypeInsertMode'
,
'editor.action.toggleScreenReaderAccessibilityMode'
,
'editor.action.toggleStickyScroll'
,
'extension.bisect.start'
,
'extension.bisect.stop'
,
'git.blame.toggleEditorDecoration'
,
'git.branch'
,
'git.closeAllDiffEditors'
,
'git.closeAllUnmodifiedEditors'
,
'git.openAllChanges'
,
'git.rebaseAbort'
,
'git.showOutput'
,
'git.stageAll'
,
'git.stash'
,
'git.stashPop'
,
'git.stashPopLatest'
,
'git.stashStaged'
,
'git.stashView'
,
'github.copilot.chat.completions.disable'
,
'github.copilot.chat.completions.enable'
,
'github.copilot.chat.completions.toggle'
,
'github.copilot.chat.tools.memory.showMemories'
,
'github.copilot.open.walkthrough'
,
'github.copilot.report'
,
'markdown.showPreview'
,
'markdown.showSource'
,
'search.action.getSearchResults'
,
'update.checkForUpdate'
,
'update.downloadUpdate'
,
'update.installUpdate'
,
'update.restartToUpdate'
,
'workbench.action.activityBarLocation.bottom'
,
'workbench.action.activityBarLocation.default'
,
'workbench.action.activityBarLocation.hide'
,
'workbench.action.activityBarLocation.top'
,
'workbench.action.chat.export'
,
'workbench.action.chat.openFeatureSettings'
,
'workbench.action.chat.openInEditor'
,
'workbench.action.chat.openInNewWindow'
,
'workbench.action.chat.openInSidebar'
,
'workbench.action.chat.readChatResponseAloud'
,
'workbench.action.chat.upgradePlan'
,
'workbench.action.chatEditor.newChat'
,
'workbench.action.closeAuxiliaryBar'
,
'workbench.action.closePanel'
,
'workbench.action.closeSidebar'
,
'workbench.action.configureRuntimeArguments'
,
'workbench.action.newWindow'
,
'workbench.action.openFolderSettings'
,
'workbench.action.openGlobalSettings'
,
'workbench.action.openLogFile'
,
'workbench.action.openSnippets'
,
'workbench.action.openWorkspaceSettings'
,
'workbench.action.showAboutDialog'
,
'workbench.action.showRuntimeExtensions'
,
'workbench.action.toggleFullScreen'
,
'workbench.action.toggleZenMode'
,
'workbench.action.zoomIn'
,
'workbench.action.zoomOut'
,
'workbench.action.zoomReset'
]
)
;
const
=
new
Set
(
[
'editor.action.goToReferences'
,
'editor.action.peekDeclaration'
,
'editor.action.referenceSearch.trigger'
,
'editor.showCallHierarchy'
,
'editor.showIncomingCalls'
,
'editor.showOutgoingCalls'
,
'editor.showSubtypes'
,
'editor.showSupertypes'
,
'editor.showTypeHierarchy'
,
'extension.bisect.next'
,
'git.openChange'
,
'git.openMergeEditor'
,
'git.stage'
]
)
;
class
VSCodeCmdTool
implements
vscode
.
LanguageModelTool
<
IVSCodeCmdToolToolInput
>
{
public
static
readonly
=
ToolName
.
RunVscodeCmd
;
constructor
(
IRunCommandExecutionService
private
readonly
:
IRunCommandExecutionService
,
IWorkbenchService
private
readonly
:
IWorkbenchService
,
ILogService
private
readonly
:
ILogService
)
{
}
async
invoke
(
:
.
LanguageModelToolInvocationOptions
<
IVSCodeCmdToolToolInput
>
,
:
CancellationToken
)
:
Promise
<
.
LanguageModelToolResult
>
{
const
=
.
input
.
commandId
;
const
=
.
input
.
args
??
[
]
;
if
(
!
.
input
.
skipCheck
)
{
const
=
(
await
this
.
_workbenchService
.
getAllCommands
(
true
)
)
;
const
=
.
find
(
=>
.
command
===
)
;
if
(
!
)
{
const
=
(
await
this
.
_workbenchService
.
getAllCommands
(
false
)
)
;
const
=
.
find
(
=>
.
command
===
)
;
if
(
)
{
return
new
LanguageModelToolResult
(
[
new
LanguageModelTextPart
(
` Command \` ${ options. input. name} \` exists, but its preconditions are not currently met. Ask the user to try running it manually via the command palette. `
)
]
)
;
}
else
{
return
new
LanguageModelToolResult
(
[
new
LanguageModelTextPart
(
` Failed to find command \` ${ options. input. name} \`. `
)
]
)
;
}
}
}
try
{
const
=
await
this
.
_commandService
.
executeCommand
(
,
...
)
;
let
:
LanguageModelTextPart
;
if
(
===
undefined
||
===
null
)
{
=
new
LanguageModelTextPart
(
` Finished running command \` ${ options. input. name} \`. `
)
;
}
else
if
(
typeof
===
'string'
)
{
=
new
LanguageModelTextPart
(
` Finished running command \` ${ options. input. name} \` with result:\n\n ${ result} `
)
;
}
else
{
let
:
string
;
try
{
=
JSON
.
stringify
(
)
;
}
catch
{
=
String
(
)
;
}
=
new
LanguageModelTextPart
(
` Finished running command \` ${ options. input. name} \` with result:\n\n ${ serializedResult} `
)
;
}
return
new
LanguageModelToolResult
(
[
]
)
;
}
catch
(
)
{
this
.
_logService
.
error
(
` [VSCodeCmdTool] ${ error} `
)
;
return
new
LanguageModelToolResult
(
[
new
LanguageModelTextPart
(
` Failed to run command \` ${ options. input. name} \`. `
)
]
)
;
}
}
async
prepareInvocation
(
:
.
LanguageModelToolInvocationPrepareOptions
<
IVSCodeCmdToolToolInput
>
,
:
.
CancellationToken
)
:
Promise
<
.
PreparedToolInvocation
>
{
const
=
.
input
.
commandId
;
if
(
!
)
{
throw
new
Error
(
'Command ID undefined'
)
;
}
const
=
.
t
` Running command \` ${ options. input. name} \` `
;
if
(
(
.
has
(
)
||
.
has
(
)
)
&&
(
!
.
input
.
args
||
.
input
.
args
.
length
===
0
)
)
{
return
{
}
;
}
if
(
.
has
(
)
&&
.
input
.
args
&&
.
input
.
args
.
length
>
0
)
{
return
{
}
;
}
const
=
'workbench.action.quickOpen'
;
const
=
commandUri
(
,
[
'>'
+
]
)
;
const
=
!
!
.
input
.
args
?.
;
const
=
new
MarkdownString
(
)
;
.
appendMarkdown
(
.
t
(
` Copilot will execute the [{0}]({1}) (\`{2}\`) command. `
,
.
input
.
name
,
,
.
input
.
commandId
)
)
;
if
(
)
{
.
appendMarkdown
(
` \n\n ${ l10n. t ( 'Arguments' ) } :\n\n `
)
;
.
appendCodeblock
(
JSON
.
stringify
(
.
input
.
args
,
undefined
,
2
)
,
'json'
)
;
}
.
isTrusted
=
{
:
[
]
}
;
return
{
,
:
{
:
.
t
` Run Command \` ${ options. input. name} \` (\` ${ options. input. commandId} \`)? `
,
:
,
:
{
:
?
.
t
` Allow running command \` ${ options. input. commandId} \` with specific arguments `
:
.
t
` Allow running command \` ${ options. input. commandId} \` without arguments `
,
:
?
JSON
.
stringify
(
.
input
.
args
)
:
undefined
,
}
,
}
,
}
;
}
}
ToolRegistry
.
registerTool
(
VSCodeCmdTool
)
;