Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
// try resolving the document context programmatically
if
(
!
)
{
const
=
await
this
.
resolveDocContextProgrammatically
(
)
;
if
(
)
{
=
.
documentContext
;
=
.
alreadyConsumedChatVariable
;
}
}
// try resolving the document context using LLM
if
(
!
)
{
const
=
await
this
.
resolveDocContextUsingLlm
(
)
;
if
(
)
{
=
.
documentContext
;
=
.
alreadyConsumedChatVariable
;
}
}
if
(
!
)
{
throw
new
Error
(
'To generate tests, open a file and select code to test.'
)
;
}
if
(
await
this
.
ignoreService
.
isCopilotIgnored
(
.
document
.
uri
)
)
{
throw
new
Error
(
'Copilot is disabled for this file.'
)
;
}
const
location
=
.
location
;
const
=
await
this
.
endpointProvider
.
getChatEndpoint
(
.
request
)
;
return
isTestFile
(
.
document
)
?
this
.
instantiationService
.
createInstance
(
TestFromTestInvocation
,
this
,
,
location
,
,
)
:
this
.
instantiationService
.
createInstance
(
TestFromSourceInvocation
,
this
,
,
location
,
,
)
;
}
private
async
resolveDocContextProgrammatically
(
:
IIntentInvocationContext
)
{
const
=
.
request
.
references
;
// find a #file to use for testing
// count #file's because we use LLM if there're more than 1 in the prompt
let
=
0
;
const
:
[
ChatPromptReference
,
URI
]
[
]
=
[
]
;
for
(
const
of
)
{
if
(
.
id
===
'copilot.file'
||
.
id
===
'vscode.file'
)
{
if
(
isUri
(
.
value
)
)
{
+=
1
;
.
push
(
[
,
.
value
]
)
;
}
}
else
{
if
(
!
isUri
(
.
id
)
)
{
continue
;
}
const
=
URI
.
parse
(
.
id
)
;
if
(
!==
undefined
)
{
.
push
(
[
,
]
)
;
}
}
}
if
(
>
1
// use LLM if there's more than 1 file reference
||
.
length
===
0
)
{
return
;
}
const
[
,
]
=
[
0
]
;
return
{
:
await
this
.
createDocumentContext
(
)
,
:
,
}
;
}
private
async
resolveDocContextUsingLlm
(
:
IIntentInvocationContext
)
{
const
=
this
.
instantiationService
.
createInstance
(
UserQueryParser
)
;
const
=
await
.
parse
(
.
request
.
prompt
)
;
if
(
===
null
)
{
return
;
}
// FIXME@ulugbekna: UserQueryParser also returns symbols that need testing; we should use that info
const
{
,
}
=
;
// if parser couldn't identify the file, if there's only one file referenced, use that
if
(
===
undefined
)
{
return
;
}
for
(
let
=
0
;
<
.
request
.
references
.
length
;
++
)
{
const
=
.
request
.
references
[
]
;
// FIXME@ulugbekna: I don't like how I fish for #file references
if
(
.
id
!==
'vscode.file'
&&
.
id
!==
'copilot.file'
)
{
continue
;
}
const
[
,
]
=
.
name
.
trim
(
)
.
split
(
':'
)
;
if
(
!==
'file'
||
===
undefined
||
!
(
URI
.
isUri
(
.
value
)
)
||
!==
)
{
continue
;
}
return
{
:
await
this
.
createDocumentContext
(
.
value
)
,
:
,
}
;
}
}
/**
*
* @param selection defaults to whole file
*/
private
async
createDocumentContext
(
:
URI
,
?
:
Range
)
{
let
:
TextDocumentSnapshot
|
undefined
;
try
{
=
await
this
.
workspaceService
.
openTextDocumentAndSnapshot
(
)
;
}
catch
(
)
{
this
.
log
(
`Tried opening file ${file.toString()} but got error: ${e}`
)
;
return
;
}
const
=
??
new
Range
(
new
Position
(
0
,
0
)
,
new
Position
(
.
lineCount
-
1
,
.
lineAt
(
.
lineCount
-
1
)
.
text
.
length
)
)
;
return
{
document
:
,
:
undefined
,
:
getLanguage
(
.
languageId
)
,
:
,
:
new
Selection
(
.
start
,
.
end
)
,
}
IDocumentContext
;
}
private
log
(
...
:
any
[
]
)
:
void
{
const
=
.
map
(
=>
typeof
===
'object'
?
JSON
.
stringify
(
,
null
,
'\t'
)
:
)
.
join
(
'\n'
)
;
this
.
logService
.
debug
(
`[TestsIntent] ${message}`
)
;
}
}
class
RequestHandler
extends
DefaultIntentRequestHandler
{
constructor
(
:
IIntent
,
:
Conversation
,
:
ChatRequest
,
:
ChatResponseStream
,
:
CancellationToken
,
:
IDocumentContext
|
undefined
,
location
:
ChatLocation
,
:
ChatTelemetryBuilder
,
IInstantiationService
:
IInstantiationService
,
IConversationOptions
:
IConversationOptions
,
ITelemetryService
:
ITelemetryService
,
ILogService
:
ILogService
,
ISurveyService
:
ISurveyService
,
ISetupTestsDetector
private
readonly
:
ISetupTestsDetector
,
IRequestLogger
:
IRequestLogger
,
IEditSurvivalTrackerService
:
IEditSurvivalTrackerService
,
IAuthenticationService
:
IAuthenticationService
,
IChatHookService
:
IChatHookService
,
IOctoKitService
:
IOctoKitService
,
IConfigurationService
:
IConfigurationService
,
IChatWebSocketManager
:
IChatWebSocketManager
,
)
{
super
(
,
,
,
,
,
,
location
,
,
undefined
,
undefined
,
,
,
,
,
,
,
,
,
,
,
,
)
;
}
/**
* - Delegates out to setting up tests if the user confirmed they wanted to do that
* - Otherwise try to detect if setup should be shown
* - If not, just delegate to the base class
* - If so, either return just that or append a reminder.
*/
public
async
getResult
(
)
:
Promise
<
ChatResult
>
{
// if the user is starting test setup, we need to finish this request