Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/import*as l10nfrom'@vscode/l10n';import{BasePromptElementProps,PromptElement,PromptElementProps,PromptReference}from'@vscode/prompt-tsx';importtype*as vscode from'vscode';import{ConfigKey,IConfigurationService}from'../../../platform/configuration/common/configurationService';import{ObjectJsonSchema}from'../../../platform/configuration/common/jsonSchema';import
getReadFileV2Description orig vscode vscode
name
description
tags
source
inputSchema
type
required
properties
filePath
description
type
offset
description
type
limit
description
type
satisfies
fullReferenceName orig
filePath
startLine
endLine
filePath
offset
limit
isParamsV2 params params
params
start
end
truncated
getParamRanges params snapshot
start
end
truncated
params
params params snapshot
limit params
start params snapshot
end start limit snapshot
truncated limit params end snapshot
start params snapshot
end params snapshot
start end
end start start end
start end truncated
toolName
nonDeferred
_promptContext
@ workspaceService
@ notebookService
@ alternativeNotebookContent
@ promptPathRepresentationService
@ instantiationService
@ endpointProvider
@ telemetryService
@ configurationService
@ experimentationService
@ customInstructionsService
@ fileSystemService
@ extensionsService
options vscode token vscode
ranges
uri
uri options
uri
binary uri
binary
input options
startByte
endByte
input
startByte input
startByte input
endByte startByte input
startByte input
endByte input
options start end truncated uri
uri data binary startByte endByte
options
tokenBudget
t t
token
documentSnapshot uri
ranges options documentSnapshot
options ranges uri documentSnapshot
useCodeFences
uri startLine ranges endLine ranges truncated ranges snapshot documentSnapshot languageModel requestmodel useCodeFences
options
tokenBudget
t t
token
err
options ranges start end truncated uri
err
options vscode token vscode vscode
input options
input
uri
documentSnapshot
uri input
uri
accessor accessor uri
needsConfirmation realPath
accessor accessor uri readOnly workingDirectory options
realPath
accessor accessor realPath
needsConfirmation
folderUri uri
message realPath
l10n
l10n
l10n
l10n
invocationMessage l10n
pastTenseMessage l10n
confirmationMessages
title l10n
message
documentSnapshot uri
e
e
invocationMessage l10n
pastTenseMessage l10n
e
err
options start end truncated uri
err
start end input documentSnapshot
extUriBiasedIgnorePathCaseuri
skillInfo uri
start end documentSnapshot
skillInfo
skillName skillInfo
uri
invocationMessage l10n
pastTenseMessage l10n
invocationMessage l10n
pastTenseMessage l10n
invocationMessage l10n
pastTenseMessage l10n
readLocation uri start start
uri
skillInfo
skillName skillInfo
uri
invocationMessage l10n
pastTenseMessage l10n
invocationMessage l10n
pastTenseMessage l10n
invocationMessage l10n
pastTenseMessage l10n
originTool vscode vscode
originTool
originTool
uri
uri
uri requestmodel
uri
outcome options vscode start end truncated uri documentSnapshot
model options options
extensionSkillInfo uri uri
skillInfo extensionSkillInfo uri uri
fileType skillInfo
nameField extensionSkillInfo extensionSkillInfo skillInfo skillInfo
requestId options
interactionId options
toolOutcome outcome
isV2 options
isEntireFile options options options
fileType
nameField
model
linesRead end start
truncated truncated
skillInfo documentSnapshot uri uri
content documentSnapshot documentSnapshot
uri skillInfo content
input promptContext
promptContext
input
uri
startLine
endLine
truncated
snapshot
languageModel vscode
useCodeFences
props
@ instantiationService
@ promptPathRepresentationService
props
override
accessor accessor
documentSnapshot
documentText documentSnapshot
documentText
documentText
range
rawContents documentSnapshotrange
hadLongLines
contents rawContentsline
line
hadLongLines
end
lineend lineend
end
line end
line
hadLongLines
contents
contents
range documentSnapshot range range documentSnapshot
'Read the contents of a file. Line numbers are 1-indexed. This tool will truncate its output at 2000 lines and may be called repeatedly with offset and limit parameters to read larger files in chunks. Binary files use offset/limit as byte offsets.'
,
:
[
'vscode_codesearch'
]
,
:
undefined
,
:
{
:
'object'
,
:
[
'filePath'
]
,
:
{
:
{
:
'The absolute path of the file to read.'
,
:
'string'
}
,
:
{
:
'Optional: the 1-based line number to start reading from. Only use this if the file is too large to read at once. If not specified, the file will be read from the beginning.'
,
:
'number'
}
,
:
{
:
'Optional: the maximum number of lines to read. Only use this together with `offset` if the file is too large to read at once.'
,
:
'number'
}
,
}
}
ObjectJsonSchema
,
:
.
fullReferenceName
}
)
;
export
interface
IReadFileParamsV1
{
:
string
;
:
number
;
:
number
;
}
export
interface
IReadFileParamsV2
{
:
string
;
?
:
number
;
?
:
number
;
}
const
MAX_LINES_PER_READ
=
2000
;
const
MAX_LINE_LENGTH
=
2000
;
export
type
ReadFileParams
=
IReadFileParamsV1
|
IReadFileParamsV2
;
const
=
(
:
ReadFileParams
)
:
is
IReadFileParamsV2
=>
(
as
IReadFileParamsV1
)
.
startLine
===
undefined
;
interface
IParamRanges
{
:
number
;
:
number
;
:
boolean
;
}
const
=
(
:
ReadFileParams
,
:
NotebookDocumentSnapshot
|
TextDocumentSnapshot
)
:
IParamRanges
=>
{
let
:
number
;
let
:
number
;
let
=
false
;
if
(
isParamsV2
(
)
)
{
// Check if offset is out of bounds before clamping
if
(
.
offset
!==
undefined
&&
.
offset
>
.
lineCount
)
{
throw
new
Error
(
`Invalid offset ${params.offset}: file only has ${snapshot.lineCount} line${snapshot.lineCount ===1?'':'s'}. Line numbers are 1-indexed.`
)
;
}
const
=
clamp
(
.
limit
||
Infinity
,
1
,
MAX_LINES_PER_READ
-
1
)
;
=
clamp
(
.
offset
??
1
,
1
,
.
lineCount
)
;
=
clamp
(
+
,
1
,
.
lineCount
)
;
// signal truncation if we applied a limit to the lines other than what the model requested
=
!==
.
limit
&&
<
.
lineCount
;
}
else
{
=
clamp
(
.
startLine
,
1
,
.
lineCount
)
;
=
clamp
(
.
endLine
,
1
,
.
lineCount
)
;
}
if
(
>
)
{
[
,
]
=
[
,
]
;
}
return
{
,
,
}
;
}
;
export
class
ReadFileTool
implements
ICopilotTool<ReadFileParams>
{
public
static
=
ToolName
.
ReadFile
;
public
static
readonly
=
true
;
private
:
IBuildPromptContext
|
undefined
;
constructor
(
IWorkspaceService
private
readonly
:
IWorkspaceService
,
INotebookService
private
readonly
:
INotebookService
,
IAlternativeNotebookContentService
private
readonly
:
IAlternativeNotebookContentService
,
IPromptPathRepresentationService
private
readonly
:
IPromptPathRepresentationService
,
IInstantiationService
private
readonly
:
IInstantiationService
,
IEndpointProvider
private
readonly
:
IEndpointProvider
,
ITelemetryService
private
readonly
:
ITelemetryService
,
IConfigurationService
private
readonly
:
IConfigurationService
,
IExperimentationService
private
readonly
:
IExperimentationService
,
ICustomInstructionsService
private
readonly
:
ICustomInstructionsService
,
IFileSystemService
private
readonly
:
IFileSystemService
,
IExtensionsService
private
readonly
:
IExtensionsService
,
)
{
}
async
invoke
(
:
.
LanguageModelToolInvocationOptions
<
ReadFileParams
>
,
:
.
CancellationToken
)
{
let
:
IParamRanges
|
undefined
;
let
:
URI
|
undefined
;
try
{
=
resolveToolInputPath
(
.
input
.
filePath
,
this
.
promptPathRepresentationService
)
;
if
(
getImageMimeType
(
)
)
{
throw
new
Error
(
`Cannot read image files with ${ToolName.ReadFile}. Use ${ToolName.ViewImage} instead.`
)
;
}
// Handle binary files — read raw bytes and check for null bytes
const
=
await
hexdumpIfBinary
(
this
.
fileSystemService
,
)
;
if
(
)
{
const
=
.
input
;
let
:
number
|
undefined
;
let
:
number
|
undefined
;
if
(
isParamsV2
(
)
)
{
=
.
offset
;
if
(
!==
undefined
&&
typeof
.
limit
===
'number'
)
{
=
+
.
limit
;
}
}
else
{
=
.
startLine
;
=
.
endLine
;
}
void
this
.
sendReadFileTelemetry
(
'success'
,
,
{
:
0
,
:
0
,
:
false
}
,
)
;
return
new
LanguageModelToolResult
(
[
new
LanguageModelPromptTsxPart
(
await
renderPromptElementJSON
(
this
.
instantiationService
,
BinaryFileHexdump
,
{
,
:
.
data
,
,
}
,
.
tokenizationOptions
??
{
:
600
,
countTokens
:
=>
Promise
.
resolve
(
.
length
*
3
/
4
)
}
,
,
)
,
)
]
)
;
}
const
=
await
this
.
getSnapshot
(
)
;
=
getParamRanges
(
.
input
,
)
;
void
this
.
sendReadFileTelemetry
(
'success'
,
,
,
,
)
;
const
=
this
.
configurationService
.
getExperimentBasedConfig
<
boolean
>
(
ConfigKey
.
TeamInternal
.
ReadFileCodeFences
,
this
.
experimentationService
)
;
return
new
LanguageModelToolResult
(
[
new
LanguageModelPromptTsxPart
(
await
renderPromptElementJSON
(
this
.
instantiationService
,
ReadFileResult
,
{
,
:
.
start
,
:
.
end
,
:
.
truncated
,
:
,
:
this
.
_promptContext
?.
?.
,
}
,
// If we are not called with tokenization options, have _some_ fake tokenizer
// otherwise we end up returning the entire document on every readFile.
.
tokenizationOptions
??
{
:
600
,
countTokens
:
(
)
=>
Promise
.
resolve
(
.
length
*
3
/
4
)
}
,
,
)
,
)
]
)
;
}
catch
(
)
{
void
this
.
sendReadFileTelemetry
(
'error'
,
,
||
{
:
0
,
:
0
,
:
false
}
,
)
;
throw
;
}
}
async
prepareInvocation
(
:
.
LanguageModelToolInvocationPrepareOptions
<
ReadFileParams
>
,
:
.
CancellationToken
)
:
Promise
<
.
PreparedToolInvocation
|
undefined
>
{
const
{
}
=
;
if
(
!
.
filePath
.
length
)
{
return
;
}
let
:
URI
|
undefined
;
let
:
NotebookDocumentSnapshot
|
TextDocumentSnapshot
;
try
{
=
resolveToolInputPath
(
.
filePath
,
this
.
promptPathRepresentationService
)
;
if
(
getImageMimeType
(
)
)
{
throw
new
Error
(
`Cannot read image files with ${ToolName.ReadFile}. Use ${ToolName.ViewImage} instead.`
)
;
}
await
this
.
instantiationService
.
invokeFunction
(
=>
assertFileNotContentExcluded
(
,
!
)
)
;
// Check if file is external (outside workspace, not open in editor, etc.)
const
{
,
}
=
await
this
.
instantiationService
.
invokeFunction
(
=>
isFileExternalAndNeedsConfirmation
(
,
!
,
this
.
_promptContext
,
{
:
true
,
:
.
workingDirectory
}
)
)
;
if
(
)
{
await
this
.
instantiationService
.
invokeFunction
(
=>
assertFileNotContentExcluded
(
,
)
)
;
}
if
(
)
{
const
=
dirname
(
)
;
const
=
?
this
.
workspaceService
.
getWorkspaceFolders
(
)
.
length
===
1
?
new
MarkdownString
(
.
t
`${formatUriForFileWidget(uri)} links to ${formatUriForFileWidget(realPath)}, which is outside the current folder.`
)
:
new
MarkdownString
(
.
t
`${formatUriForFileWidget(uri)} links to ${formatUriForFileWidget(realPath)}, which is outside the current workspace.`
)
:
this
.
workspaceService
.
getWorkspaceFolders
(
)
.
length
===
1
?
new
MarkdownString
(
.
t
`${formatUriForFileWidget(uri)} is outside of the current folder in ${formatUriForFileWidget(folderUri)}.`
)
:
new
MarkdownString
(
.
t
`${formatUriForFileWidget(uri)} is outside of the current workspace in ${formatUriForFileWidget(folderUri)}.`
)
;
// Return confirmation request for external file
// The folder-based "allow this session" option is provided by the core confirmation contribution
`Reading skill \`${skillName}\`: ${formatUriForFileWidget(readLocation)}, lines ${start} to ${end}`
)
,
:
new
MarkdownString
(
.
t
`Read skill \`${skillName}\`: ${formatUriForFileWidget(readLocation)}, lines ${start} to ${end}`
)
,
}
;
}
}
}
return
{
:
new
MarkdownString
(
.
t
`Reading ${formatUriForFileWidget(readLocation)}, lines ${start} to ${end}`
)
,
:
new
MarkdownString
(
.
t
`Read ${formatUriForFileWidget(readLocation)}, lines ${start} to ${end}`
)
,
}
;
}
public
alternativeDefinition
(
:
.
LanguageModelToolInformation
)
:
.
LanguageModelToolInformation
{
if
(
this
.
configurationService
.
getExperimentBasedConfig
<
boolean
>
(
ConfigKey
.
TeamInternal
.
EnableReadFileV2
,
this
.
experimentationService
)
)
{
return
getReadFileV2Description
(
)
;
}
return
;
}
private
async
getSnapshot
(
:
URI
)
{
if
(
this
.
notebookService
.
hasSupportedNotebooks
(
)
)
{
return
this
.
workspaceService
.
openNotebookDocumentAndSnapshot
(
,
this
.
alternativeNotebookContent
.
getFormat
(
this
.
_promptContext
?.
?.
)
)
;
}
return
TextDocumentSnapshot
.
create
(
await
this
.
workspaceService
.
openTextDocument
(
)
)
;
}
private
async
sendReadFileTelemetry
(
:
string
,
:
Pick
<
.
LanguageModelToolInvocationOptions
<
ReadFileParams
>
,
'model'
|
'chatRequestId'
|
'input'
>
,
{
,
,
}
:
IParamRanges
,
:
URI
|
undefined
,
?
:
TextDocumentSnapshot
|
NotebookDocumentSnapshot
)
{
const
=
.
model
&&
(
await
this
.
endpointProvider
.
getChatEndpoint
(
.
model
)
)
.
model
;
const
=
&&
this
.
customInstructionsService
.
getExtensionSkillInfo
(
)
;
const
=
||
(
&&
this
.
customInstructionsService
.
getSkillInfo
(
)
)
;
const
=
?
'skill'
:
''
;
const
=
?
.
skillName
:
?
getCachedSha256Hash
(
.
skillName
)
:
''
;
/* __GDPR__
"readFileToolInvoked" : {
"owner": "roblourens",
"comment": "The read_file tool was invoked",
"requestId": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The id of the current request turn." },
"interactionId": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The id of the current interaction." },
"toolOutcome": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether the invocation was successful, or a failure reason" },
"model": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The model that invoked the tool" },
"linesRead": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "comment": "The number of lines that were read" },
"truncated": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "comment": "The file length was truncated" },
"isV2": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether the tool is a v2 version" },
"isEntireFile": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether the entire file was read with v2 params" },
"fileType": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The type of file being read" },
"nameField": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The name of the agent customization. Plain text for extension sources, otherwise hashed." }
}
*/
this
.
telemetryService
.
sendMSFTTelemetryEvent
(
'readFileToolInvoked'
,
{
:
.
chatRequestId
,
:
.
chatRequestId
,
:
,
// Props named "outcome" often get stuck in the kusto pipeline
:
isParamsV2
(
.
input
)
?
'true'
:
'false'
,
:
isParamsV2
(
.
input
)
&&
.
input
.
offset
===
undefined
&&
.
input
.
limit
===
undefined
?
'true'
:
'false'
,
,
,
,
}
,
{
:
-
,
:
?
1
:
0
,
}
)
;
// Send separate skillContentRead event only for successful skill file reads.