Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
'Invalid input: filePath and content are required'
)
;
}
const
=
await
this
.
fileExists
(
)
;
const
=
this
.
notebookService
.
hasSupportedNotebooks
(
)
;
let
:
undefined
|
NotebookDocumentSnapshot
|
TextDocumentSnapshot
=
undefined
;
try
{
if
(
)
{
=
await
this
.
workspaceService
.
openNotebookDocumentAndSnapshot
(
,
this
.
alternativeNotebookContent
.
getFormat
(
this
.
_promptContext
?.
?.
)
)
;
}
else
{
=
await
this
.
workspaceService
.
openTextDocumentAndSnapshot
(
)
;
}
}
catch
(
)
{
// ignored
}
// note: fileExists could be `false` but we might still get a `doc` if it's held in memory
if
(
&&
!
!
?.
getText
(
)
)
{
if
(
)
{
throw
new
Error
(
`File already exists. You must use the ${ToolName.EditNotebook} tool to modify it.`
)
;
}
else
{
throw
new
Error
(
`File already exists. You must use an edit tool to modify it.`
)
;
}
}
const
=
?.
??
getLanguageForResource
(
)
.
languageId
;
const
=
extname
(
)
;
const
=
.
model
&&
(
await
this
.
endpointProvider
.
getChatEndpoint
(
.
model
)
)
.
model
;
if
(
)
{
// Its possible we have a code block with a language id
// Also possible we have file paths in the content.
let
=
.
input
.
content
;
const
=
new
CodeBlockProcessor
(
(
)
=>
undefined
,
(
)
=>
undefined
,
(
)
=>
=
.
code
)
;
.
processMarkdown
(
.
input
.
content
)
;
.
flush
(
)
;
=
removeLeadingFilepathComment
(
.
input
.
content
,
,
.
input
.
filePath
)
;
await
processFullRewriteNewNotebook
(
,
,
this
.
_promptContext
.
stream
,
this
.
alternativeNotebookEditGenerator
,
{
:
NotebookEditGenrationSource
.
createFile
,
:
.
chatRequestId
,
:
.
model
?
this
.
endpointProvider
.
getChatEndpoint
(
.
model
)
.
then
(
=>
.
model
)
:
undefined
}
,
)
;
this
.
_promptContext
.
stream
.
notebookEdit
(
,
true
)
;
this
.
sendTelemetry
(
.
chatRequestId
,
,
)
;
}
else
{
const
=
removeLeadingFilepathComment
(
.
input
.
content
,
,
.
input
.
filePath
)
;
// When the file has been deleted from disk but VS Code still holds a stale
// in-memory doc with content, use a full-document replace so the old buffer
// is overwritten rather than prepended to (https://github.com/microsoft/vscode/issues/311043).
if
(
!
&&
&&
.
getText
(
)
.
length
>
0
)
{
const
=
.
lineCount
-
1
;
this
.
_promptContext
.
stream
.
textEdit
(
,
TextEdit
.
replace
(
new
ExtRange
(
0
,
0
,
,
.
lineAt
(
)
.
text
.
length
)
,
)
)
;
}
else
{
this
.
_promptContext
.
stream
.
textEdit
(
,
TextEdit
.
insert
(
new
ExtPosition
(
0
,
0
)
,
)
)
;
}
this
.
_promptContext
.
stream
.
textEdit
(
,
true
)
;
this
.
sendTelemetry
(
.
chatRequestId
,
,
)
;
return
new
LanguageModelToolResult
(
[
new
LanguageModelPromptTsxPart
(
await
renderPromptElementJSON
(
this
.
instantiationService
,
EditFileResult
,
{
:
[
{
:
ActionType
.
ADD
,
,
:
false
}
]
,
:
2000
,
:
ToolName
.
CreateFile
,
:
.
chatRequestId
,
:
.
model
}
,
.
tokenizationOptions
??
{
:
1000
,
countTokens
:
(
)
=>
Promise
.
resolve
(
.
length
*
3
/
4
)
}
,
,
)
,
)
]
)
;
}
return
new
LanguageModelToolResult
(
[
new
LanguageModelTextPart
(
`File created at ${this.promptPathRepresentationService.getFilePath(uri)}`
,
)
]
)
;
}
/**
* Don't copy this helper, this is generally not a good pattern because it's vulnerable to race conditions. But the fileSystemService doesn't give us a proper atomic method for this.
*/
private
async
fileExists
(
:
URI
)
:
Promise
<
boolean
>
{
try
{
await
this
.
fileSystemService
.
stat
(
)
;
return
true
;
}
catch
(
)
{
return
false
;
}
}
async
resolveInput
(
:
ICreateFileParams
,
:
IBuildPromptContext
)
:
Promise
<
ICreateFileParams
>
{
this
.
_promptContext
=
;
return
;
}
async
prepareInvocation
(
:
.
LanguageModelToolInvocationPrepareOptions
<
ICreateFileParams
>
,
:
.
CancellationToken
)
:
Promise
<
.
PreparedToolInvocation
>
{
const
=
resolveToolInputPath
(
.
input
.
filePath
,
this
.
promptPathRepresentationService
)
;
const
=
.
input
.
content
||
''
;
const
=
await
this
.
instantiationService
.
invokeFunction
(
,
[
]
,
this
.
_promptContext
?.
,
async
(
)
=>
this
.
instantiationService
.
invokeFunction
(
,
,
''
,
// Empty initial content
)
,
.
forceConfirmationReason
,
undefined
,
.
workingDirectory
,
)
;
return
{
...
,
:
undefined
,
:
new
MarkdownString
(
.
t
`Creating ${formatUriForFileWidget(uri)}`
)
,
:
new
MarkdownString
(
.
t
`Created ${formatUriForFileWidget(uri)}`
)
}
;
}
async
handleToolStream
(
:
.
LanguageModelToolInvocationStreamOptions
<
ICreateFileParams
>
,
:
.
CancellationToken
)
:
Promise
<
.
LanguageModelToolStreamResult
>
{
let
:
MarkdownString
;
// rawInput is now a partial object (parsed via tryParsePartialToolInput)
/* __GDPR__
"createFileToolInvoked" : {
"owner": "bhavyaus",
"requestId": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The id of the current request turn." },
"model": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The model that invoked the tool" },
"fileExtension": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The file extension of the created file" }
}
*/