Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
// tokens are accumulated into a file tree is seen (generally the first
// thing in the response) to avoid printing a generic "what framework are
// you using?" if the user gave a generic questioning prompt
.
markdown
(
.
accumulate
(
0
,
.
tokens
.
length
-
1
)
)
;
}
else
if
(
.
transitionTo
===
State
.
FoundTree
)
{
const
=
.
accumulate
(
undefined
,
undefined
,
State
.
FileTree
)
;
this
.
handleFileTree
(
,
,
)
;
}
else
if
(
.
transitionTo
===
undefined
&&
.
state
!==
State
.
FileTree
&&
.
visited
(
State
.
FileTree
)
)
{
.
markdown
(
.
token
)
;
}
}
}
;
const
=
new
StreamingGrammar
(
State
.
LookingForTree
,
{
[
State
.
LookingForTree
]
:
{
'```filetree'
:
State
.
FileTree
}
,
[
State
.
FileTree
]
:
{
'```'
:
State
.
FoundTree
}
,
}
)
;
for
await
(
const
{
}
of
)
{
pushTokens
(
.
append
(
.
text
)
)
;
}
pushTokens
(
.
flush
(
)
)
;
if
(
this
.
delegatedSetup
)
{
.
markdown
(
this
.
delegatedSetup
.
message
)
;
}
const
=
this
.
setupConfirmation
?.
||
this
.
delegatedSetup
?.
;
if
(
)
{
// prompt will already include the `message` at the end, just add the button as needed
.
button
(
)
;
}
else
if
(
.
visited
(
State
.
FileTree
)
)
{
await
this
.
recommendExtension
(
.
accumulate
(
undefined
,
undefined
,
State
.
LookingForTree
)
,
,
)
;
}
else
{
// if we never saw a file tree, automatically do the generic test setup
await
this
.
doFrameworkQuery
(
,
,
)
;
}
}
private
async
doFrameworkQuery
(
:
IResponseProcessorContext
,
:
.
ChatResponseStream
,
:
CancellationToken
)
{
const
=
this
.
instantiationService
.
createInstance
(
SetupTestsFrameworkQueryInvocationRaw
,
this
.
endpoint
,
undefined
)
;
const
=
await
.
buildPrompt
(
this
.
buildPromptContext
,
undefined
,
)
;
const
=
new
FetchStreamSource
(
)
;
const
=
.
processResponse
(
,
.
stream
,
,
)
;
await
this
.
endpoint
.
makeChatRequest2
(
{
:
'testSetupAutomaticFrameworkID'
,
:
.
messages
,
finishedCb
:
(
,
,
)
=>
{
.
update
(
,
)
;
return
Promise
.
resolve
(
undefined
)
;
}
,
location
:
this
.
location
,
}
,
)
;
.
resolve
(
)
;
await
;
}
private
async
getSetupConfirmation
(
)
{
const
=
this
.
recommendedExtension
.
value
;
const
=
?
this
.
extensionsService
.
getExtension
(
.
id
)
:
undefined
;
const
=
(
?.
as
IPackageJson
)
?.
?.
?.
;
if
(
!
)
{
return
;
}
let
:
SetupConfirmationResult
|
undefined
;
try
{
=
await
this
.
commandService
.
executeCommand
(
)
;
}
catch
{
// ignored
}
return
;
}
private
async
delegateHandling
(
)
{
const
=
this
.
recommendedExtension
.
value
;
const
=
?
this
.
extensionsService
.
getExtension
(
.
id
)
:
undefined
;
const
=
(
?.
as
IPackageJson
)
?.
?.
?.
;
return
?
await
this
.
commandService
.
executeCommand
(
)
:
undefined
;
}
private
=
new
Lazy
(
(
)
=>
getKnownExtensionInText
(
this
.
prompt
)
)
;
private
async
recommendExtension
(
:
string
,
:
.
ChatResponseStream
,
:
CancellationToken
)
{
let
:
string
;
let
:
ISetupTestExtension
|
undefined
;
if
(
this
.
recommendedExtension
.
value
)
{
=
this
.
prompt
;
=
this
.
recommendedExtension
.
value
;
}
else
{
=
await
this
.
deriveFrameworkFromResponse
(
,
)
;
=
getKnownExtensionInText
(
)
;
}
if
(
&&
this
.
extensionsService
.
getExtension
(
.
id
)
)
{
return
;
// extension already installed
}
.
markdown
(
'\n\n'
)
;
if
(
)
{
.
markdown
(
.
t
(
'I also recommend installing the {0} extension to make tests easy to run in VS Code:'
,
.
name
)
)
;
.
markdown
(
'\n\n'
)
;
.
push
(
new
ChatResponseExtensionsPart
(
[
.
id
]
)
)
;
}
else
{
.
markdown
(
.
t
(
'You can also search for an extension to make tests easy to run in VS Code:'
)
)
;
.
button
(
{
:
'workbench.extensions.search'
,
:
.
t
(
'Search Extensions'
)
,
:
[
`@category:testing ${this.prompt}`
]
}
)
;
}
}
private
async
deriveFrameworkFromResponse
(
:
string
,
:
CancellationToken
)
{
const
=
await
PromptRenderer
.
create
(
this
.
instantiationService
,
this
.
endpoint
,
TestFrameworkFromResponsePrompt
,
{
:
,
}
)
.
render
(
)
;
const
=
await
this
.
endpoint
.
makeChatRequest2
(
{
:
'setupTestDeriveName'
,
:
.
messages
,
:
undefined
,
location
:
ChatLocation
.
Panel
,
}
,
)
;
if
(
.
type
!==
ChatFetchResponseType
.
Success
)
{
return
''
;
}
return
.
value
.
replaceAll
(
'`'
,
''
)
;
}
private
handleFileTree
(
:
string
,
:
string
,
:
.
ChatResponseStream
)
{
const
=
this
.
workspaceService
.
getWorkspaceFolders
(
)
.
at
(
0
)
;
if
(
!
)
{
return
;
}
// todo: make the preview URI a diff for existing files
const
{
}
=
convertFileTreeToChatResponseFileTree
(
,
(
)
=>
makePreviewUri
(
)
)
;
// Handle a root '[project-name]' or similar fake root node
const
=
.
value
[
0
]
;
if
(
.
value
.
length
===
1
&&
/^\[.+\]$/
.
test
(
.
name
)
&&
.
children
)
{
.
value
=
.
children
!
;
}
this
.
workspaceMutationManager
.
create
(
,
{
:
,
:
listFilesInResponseFileTree
(
.
value
)
,
:
,
:
this
.
prompt
,
}
)
;
.
push
(
)
;
.
button
(
{
:
'github.copilot.tests.applyMutations'
,
:
.
t
(
'Apply Changes'
)
,
:
[
]
,
}
)
;
}
}
const
=
'[project-name]'
;
function
makePreviewUri
(
:
string
,
?
:
string
)
{
return
URI
.
from
(
{
:
SetupTestFileScheme
,
:
,
:
?
`/${filePath}`
:
'/'
}
)
;
}
interface
SetupTestsPromptProps
extends
BasePromptElementProps
{
:
IBuildPromptContext
;
:
string
;
:
IChatEndpoint
;
:
SetupConfirmationResult
|
undefined
;
}
class
SetupTestsPrompt
extends
PromptElement<SetupTestsPromptProps>
{
render
(
:
void
,
:
PromptSizing
)
:
PromptPiece
<
any
,
any
>
|
undefined
{
const
{
,
}
=
this
.
props
;
return
<>
<SystemMessagepriority={1000}>
You are a software engineer with expert knowledge around software testing frameworks.
<br/>
<br/>
<CopilotIdentityRules/>
<SafetyRules/>
<EditorIntegrationRules/>
<ResponseTranslationRules/>
# Additional Rules<br />
1. The user will tell you what testing framework they want to set up, and provide you their workspace structure.
<br/>
2. Determine how to test up the desired testing framework.
<br/>
3. Generate a markdown file tree structure listing files you want to create or edit in order to set up the testing framework. The tree MUST NOT include files that don't need to be modified.
<br/>
4. Make sure to include a basic "hello world" test to help the user get started. If you see existing test files in the workspace, make sure to try to match their naming convention.
<br/>
5. Do not attempt to modify the file content yourself and simply respond with the file tree structure.
<br/>
6. After listing the file tree structure, respond with any terminal commands the user should execute to finish installing the testing framework. Terminal commands should be wrapped in a code fence tagged with the "sh" language.
<br/>
7. Finally, provide a command line a user can execute to run their tests.
<br/>
{
&&
<>
8. At the end, include a phrase that conveys '{setupConfirmation.message}', but rephrase this to indicate that this is the last step the user needs to take to enable rich UI integration in VS Code.
{
.
command
&&
` This message will be followed by a button that says "${setupConfirmation.command.title}".`
}
<br/>
</>
}
<br/>
# Example<br />
## Question:
<br/>
I want to: set up mocha tests in the workspace<br />
I am working in a workspace that has the following structure:
Then, we'll need to install Mocha in your workspace:
<br/>
```sh<br />
npm install --save-dev mocha
```
<br/>
<br/>
Finally, you can run your tests with the following command:
<br/>
```sh<br />
npx mocha<br />
```
<br/>
</SystemMessage>
<UserMessageflexGrow={2}>
<SetupWorkspaceStructure/>
</UserMessage>
<ChatVariablesAndQueryflexGrow={2}priority={900}chatVariables={this.props.promptContext.chatVariables}query={`I want to: ${query}`}embeddedInsideUserMessage={false}/>
1. The user will give you instructions they were told regarding how to set up a testing framework.
<br/>
2. Your job is to print the name of the testing framework referred to in the response.
<br/>
3. Do not print any other information except for the name of the framework.
<br/>
<br/>
# Example<br />
## Question:
<br/>
Given the structure of your workspace, I recommend using Mocha for testing. To set up Mocha, you should create a `.mocharc.js` file to configure your test settings, as well as a "hello world" test.