ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / test / smoke / src / areas / chat / copilotCli.test.ts 232 строк · изменён 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
import * as assert from 'assert' ;
import * as fs from 'fs' ;
import * as os from 'os' ;
import * as path from 'path' ;
import { Application, Logger } from '../../../../automation' ;
import { getCopilotSmokeTestEnv, getMockLlmServerPath, installAllHandlers, MockLlmServer } from '../../utils' ;
const COPILOT_CLI_SCENARIO_ID = 'smoke-editor-copilot-cli' ;
const COPILOT_CLI_REPLY =
failureMarkers
logger Logger
mockServer MockLlmServer
startServer ScenarioBuilder registerScenario
mockServer
logger
logger opts
opts
extraEnv
opts extraEnv
mockServer userDataDir opts userDataDir
app app Application
app workbench settingsEditor
mockServer url
mockServer url
mockServer
it
app app Application
requestsBefore mockServer
app workbench quickaccess
app workbench chat
app workbench chat
app workbench chat
error
diagnostics app mockServer
responseText app workbench chat
diagnostics responseText length app mockServer
assert responseText length
assert responseText
assert mockServer requestsBefore
normalizedResponse responseText
matchedFailureMarker failureMarkers marker normalizedResponse marker
matchedFailureMarker
diagnostics app mockServer
assert
summary
details
app Application mockServer MockLlmServer CopilotCliDiagnostics
logs app code driver
copilotChatLog logs
extensionHostLog logs
copilotChatTail copilotChatLog contents
extensionHostTail extensionHostLog contents
sessionEventsTail copilotChatTail
combinedDiagnostics copilotChatTail extensionHostTail sessionEventsTail
summary combinedDiagnostics
relevantLogTail combinedDiagnostics summary
summary
details
sessionEventsTail sessionEventsTail
line line line
error
error
timeout error message
timeout
error message
error
diagnostics
nativeAddon diagnostics
nativeAddon
queryFailure diagnostics isQueryFailure
queryFailure
authFailure diagnostics isAuthFailure
authFailure
diagnostics
contents line
contents
line line
line line line
message
message
message
message
diagnostics summary
nativeFailure summary summary
diagnostics
line line
line line line
line nativeFailure line line
line
line
line
line line line
line
line
logs relativePath contents fileName relativePath contents
logs log log relativePath fileName
contents maxLength
contents Math contents length maxLength
log
sessionId
match log
sessionId match
sessionId
sessionId
sessionId
stateRoot process env os
eventsPath path stateRoot sessionId
fs eventsPath
fs eventsPath
'MOCKED_EDITOR_COPILOT_CLI_RESPONSE'
;
const
=
[
'Authorization failed'
,
'sign in to GitHub'
,
'Failed to load @github/copilot/sdk'
,
'pty.node'
,
'runtime.node'
,
'Cannot find module'
,
]
;
export
function
setup
(
:
)
{
describe
(
'Copilot CLI'
,
function
(
)
{
this
.
timeout
(
3
*
60
*
1000
)
;
this
.
retries
(
0
)
;
let
:
;
before
(
async
function
(
)
{
const
{
,
,
}
=
require
(
getMockLlmServerPath
(
)
)
;
registerScenario
(
'text-only'
,
new
ScenarioBuilder
(
)
.
emit
(
'OK'
)
.
build
(
)
)
;
registerScenario
(
COPILOT_CLI_SCENARIO_ID
,
new
ScenarioBuilder
(
)
.
emit
(
COPILOT_CLI_REPLY
)
.
build
(
)
)
;
=
await
startServer
(
0
)
;
.
log
(
` Copilot CLI mock LLM server started at ${ mockServer. url} `
)
;
}
)
;
installAllHandlers
(
,
=>
(
{
...
,
:
{
...
(
.
??
{
}
)
,
...
getCopilotSmokeTestEnv
(
,
{
:
.
}
)
,
}
,
}
)
)
;
before
(
async
function
(
)
{
const
=
this
.
as
;
await
.
.
.
addUserSettings
(
[
[
'github.copilot.advanced.debug.overrideProxyUrl'
,
JSON
.
stringify
(
.
)
]
,
[
'github.copilot.advanced.debug.overrideCapiUrl'
,
JSON
.
stringify
(
.
)
]
,
[
'github.copilot.advanced.debug.overrideAuthType'
,
'"token"'
]
,
[
'chat.allowAnonymousAccess'
,
'true'
]
,
[
'github.copilot.chat.githubMcpServer.enabled'
,
'false'
]
,
[
'chat.mcp.discovery.enabled'
,
'false'
]
,
[
'chat.mcp.enabled'
,
'false'
]
,
]
)
;
}
)
;
after
(
async
function
(
)
{
await
?.
close
(
)
;
}
)
;
.
skip
(
'opens a Copilot CLI session and receives a response'
,
async
function
(
)
{
const
=
this
.
as
;
const
=
.
requestCount
(
)
;
try
{
await
.
.
.
runCommand
(
'smoketest.openCopilotCliChat'
)
;
await
.
.
.
waitForChatEditor
(
600
)
;
await
.
.
.
sendEditorMessage
(
` Reply with one short sentence. Do not run tools or edit files. [scenario: ${ COPILOT_CLI_SCENARIO_ID } ] `
)
;
await
.
.
.
waitForEditorResponse
(
1500
)
;
}
catch
(
)
{
const
=
await
getCopilotCliDiagnostics
(
,
)
;
throw
new
Error
(
` Copilot CLI smoke test failed: ${ diagnostics. summary} \n\nUI symptom: ${ summarizeUiFailure ( error) } \n\n ${ diagnostics. details} `
)
;
}
const
=
(
await
.
.
.
getLatestEditorResponseText
(
)
)
.
trim
(
)
;
const
=
.
>
0
?
undefined
:
await
getCopilotCliDiagnostics
(
,
)
;
.
ok
(
.
>
0
,
` Expected Copilot CLI to produce a non-empty response. ${ diagnostics ? ` \nLikely cause: ${ diagnostics. summary} \n\n ${ diagnostics. details} ` : '' } `
)
;
.
ok
(
.
includes
(
COPILOT_CLI_REPLY
)
,
` Expected Copilot CLI response to include mocked scenario response " ${ COPILOT_CLI_REPLY } ".\n\nResponse:\n ${ responseText} `
)
;
.
ok
(
.
requestCount
(
)
>
,
'Expected the mock LLM server to receive a request from the Copilot CLI editor session'
)
;
const
=
.
toLowerCase
(
)
;
const
=
.
find
(
=>
.
includes
(
.
toLowerCase
(
)
)
)
;
if
(
)
{
const
=
await
getCopilotCliDiagnostics
(
,
)
;
.
fail
(
` Copilot CLI response contained failure marker " ${ matchedFailureMarker} ". Likely cause: ${ diagnostics. summary} \n\nResponse:\n ${ responseText} \n\n ${ diagnostics. details} `
)
;
}
}
)
;
}
)
;
}
interface
CopilotCliDiagnostics
{
readonly
:
string
;
readonly
:
string
;
}
async
function
getCopilotCliDiagnostics
(
:
,
?
:
)
:
Promise
<
>
{
const
=
await
.
.
.
getLogs
(
)
;
const
=
findNewestLog
(
,
'GitHub Copilot Chat.log'
)
;
const
=
findNewestLog
(
,
'exthost.log'
)
;
const
=
tail
(
?.
??
''
,
12000
)
;
const
=
tail
(
?.
??
''
,
16000
)
;
const
=
readSessionEventsTail
(
extractLatestSessionId
(
)
)
;
const
=
[
,
,
]
.
join
(
'\n'
)
;
const
=
summarizeCopilotCliFailure
(
)
;
const
=
getRelevantLogTail
(
,
)
;
return
{
,
:
[
'Copilot CLI diagnostics:'
,
` mockServer= ${ mockServer?. url ?? '(not started)' } requestCount= ${ mockServer?. requestCount ( ) ?? '(unknown)' } `
,
'appExtraEnv=GITHUB_PAT:true IS_SCENARIO_AUTOMATION:true VSCODE_COPILOT_CHAT_TOKEN:true'
,
` copilotChatLog= ${ copilotChatLog?. relativePath ?? '(not found)' } `
,
` extensionHostLog= ${ extensionHostLog?. relativePath ?? '(not found)' } `
,
` relevantLogTail:\n ${ relevantLogTail || '(empty; see attached smoke test logs for full output)' } `
,
&&
!
.
startsWith
(
'Session events file not found:'
)
?
` copilotCliSessionEventsTail:\n ${ sessionEventsTail} `
:
undefined
,
]
.
filter
(
(
)
:
is
string
=>
!
!
)
.
join
(
'\n\n'
)
}
;
}
function
summarizeUiFailure
(
:
unknown
)
:
string
{
if
(
instanceof
Error
)
{
const
=
.
.
match
(
/ Timeout: get element '( [ ^ '] + ) ' after ( [ ^ .] + ) \. /
)
;
if
(
)
{
return
` no completed response rendered; timed out waiting for ${ timeout[ 1 ] } after ${ timeout[ 2 ] } `
;
}
return
.
;
}
return
String
(
)
;
}
function
summarizeCopilotCliFailure
(
:
string
)
:
string
{
const
=
.
match
(
/ Native addon "( [ ^ "] + ) " not found for ( [ ^ \s .] + ) /
)
;
if
(
)
{
return
` native SDK module missing: Native addon " ${ nativeAddon[ 1 ] } " not found for ${ nativeAddon[ 2 ] } `
;
}
const
=
firstMatchingLine
(
,
)
;
if
(
)
{
return
` native module / SDK boot failure: ${ queryFailure} `
;
}
const
=
firstMatchingLine
(
,
)
;
if
(
)
{
return
` authentication failure: ${ authFailure} `
;
}
if
(
/ Using Copilot CLI session: /
.
test
(
)
)
{
return
'Copilot CLI session started, but no completed response appeared in the UI'
;
}
return
'Copilot CLI session did not produce a completed UI response'
;
}
function
firstMatchingLine
(
:
string
,
predicate
:
(
:
string
)
=>
boolean
)
:
string
|
undefined
{
return
.
split
(
/ \r ? \n /
)
.
map
(
=>
.
trim
(
)
)
.
find
(
=>
&&
predicate
(
)
)
;
}
function
isQueryFailure
(
:
string
)
:
boolean
{
return
/ \[ CopilotCLISession\] CopilotCLI error: \( query\) | \( query\) Execution failed| Native addon ". * " not found| Failed to load @github\/ copilot\/ sdk| Unable to find node-pty binaries| Failed to create (?: node-pty| ripgrep) shim| Cannot find module| MODULE_NOT_FOUND| runtime\. node| pty\. node/
.
test
(
)
;
}
function
isAuthFailure
(
:
string
)
:
boolean
{
return
/ Authorization failed| Unauthorized| \b 401\b | No model available| policy enablement| sign in to GitHub| getGitHubSession. * undefined| Authentication (?: failed| required) | Timed out waiting for authentication provider| authentication provider [ '"] github[ '"] / i
.
test
(
)
;
}
function
getRelevantLogTail
(
:
string
,
:
string
)
:
string
{
const
=
.
startsWith
(
'native SDK module missing'
)
||
.
startsWith
(
'native module / SDK boot failure'
)
;
return
.
split
(
/ \r ? \n /
)
.
map
(
=>
.
trim
(
)
)
.
filter
(
=>
&&
!
isKnownScenarioAutomationNoise
(
)
)
.
filter
(
=>
?
isNativeFailureLine
(
)
:
isRelevantFailureLine
(
)
)
.
slice
(
-
40
)
.
join
(
'\n'
)
;
}
function
isNativeFailureLine
(
:
string
)
:
boolean
{
return
/ Native addon ". * " not found| runtime\. node| pty\. node| MODULE_NOT_FOUND| Cannot find module| Failed to load @github\/ copilot\/ sdk| Failed to initialize| CopilotCLI error: \( query\) | Using Copilot CLI session| Invoking session / i
.
test
(
)
;
}
function
isRelevantFailureLine
(
:
string
)
:
boolean
{
return
isNativeFailureLine
(
)
||
isAuthFailure
(
)
||
/ \[ CopilotCLI\] | \[ CopilotCLISession\] | No model available/ i
.
test
(
)
;
}
function
isKnownScenarioAutomationNoise
(
:
string
)
:
boolean
{
return
/ GitHubOrgCustomAgentProvider| GitHubOrgInstructionsProvider| getCurrentAuthedUser is not a function| Invalid response format /
.
test
(
)
;
}
function
findNewestLog
(
:
readonly
{
:
string
;
:
string
}
[
]
,
:
string
)
:
{
:
string
;
:
string
}
|
undefined
{
return
.
find
(
=>
.
.
endsWith
(
)
)
;
}
function
tail
(
:
string
,
:
number
)
:
string
{
return
.
slice
(
.
max
(
0
,
.
-
)
)
;
}
function
extractLatestSessionId
(
:
string
)
:
string
|
undefined
{
let
:
string
|
undefined
;
for
(
const
of
.
matchAll
(
/ Using Copilot CLI session: ( [ 0- 9 a- f -] + ) / g
)
)
{
=
[
1
]
;
}
return
;
}
function
readSessionEventsTail
(
:
string
|
undefined
)
:
string
{
if
(
!
)
{
return
''
;
}
const
=
.
.
XDG_STATE_HOME
??
.
homedir
(
)
;
const
=
.
join
(
,
'.copilot'
,
'session-state'
,
,
'events.jsonl'
)
;
if
(
!
.
existsSync
(
)
)
{
return
` Session events file not found: ${ eventsPath} `
;
}
return
tail
(
.
readFileSync
(
,
'utf8'
)
,
12000
)
;
}