Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
`Rename a code symbol across the workspace using the language server's rename functionality. This performs a precise, semantics-aware rename that updates all references.
Input:
- "symbol": The exact current name of the symbol to rename.
- "newName": The new name for the symbol.
- "uri": A full URI (e.g. "file:///path/to/file.ts") of a file within the current workspace or working directory where the symbol appears. Provide either "uri" or "filePath".
- "filePath": A file path relative to the current working directory when one is set, otherwise the first workspace folder (e.g. "src/utils/helpers.ts"). Provide either "uri" or "filePath".
- "lineContent": A substring of the line of code where the symbol appears. This is used to locate the exact position in the file. Must be the actual text from the file - do NOT fabricate it.
IMPORTANT: The file and line do NOT need to be the definition of the symbol. Any occurrence works - a usage, an import, a call site, etc. You can pick whichever occurrence is most convenient.
If the tool returns an error, retry with corrected input - ensure the file path is correct, the line content matches the actual file content, and the symbol name appears in that line.`
;
/**
* Static description that does not depend on the set of registered rename
* providers, so it stays byte-stable across requests as language extensions
* activate during a turn.
*/
const
=
+
`
If the file's language has no rename provider registered, the tool returns an error.`
;
export
class
RenameTool
extends
Disposable
implements
IToolImpl
{
constructor
(
@ILanguageFeaturesService
private
readonly
:
,
@ITextModelService
private
readonly
:
,
@IWorkspaceContextService
private
readonly
:
,
@IUriIdentityService
private
readonly
:
,
@IChatService
private
readonly
:
,
@IBulkEditService
private
readonly
:
,
)
{
super
(
)
;
}
getToolData
(
)
:
{
return
this
.
_buildToolData
(
,
localize
(
'tool.rename.userDescription'
,
'Rename a symbol across the workspace'
)
,
)
;
}
private
_buildToolData
(
:
string
,
:
string
)
:
{
return
{
:
,
:
'rename'
,
:
false
,
:
.
fromId
(
.
.
)
,
:
localize
(
'tool.rename.displayName'
,
'Rename Symbol'
)
,
,
,
:
.
,
:
{
:
'object'
,
:
{
symbol
:
{
:
'string'
,
:
'The exact current name of the symbol to rename.'
}
,
:
{
:
'string'
,
:
'The new name for the symbol.'
}
,
:
{
:
'string'
,
:
'A full URI of a file within the current workspace or working directory where the symbol appears (e.g. "file:///path/to/file.ts"). Provide either "uri" or "filePath".'
}
,
:
{
:
'string'
,
:
'A file path relative to the current working directory when one is set, otherwise the first workspace folder, where the symbol appears (e.g. "src/utils/helpers.ts"). Provide either "uri" or "filePath".'
}
,
:
{
:
'string'
,
:
'A substring of the line of code where the symbol appears. Used to locate the exact position. Must be actual text from the file.'
}
}
,
:
[
'symbol'
,
'newName'
,
'lineContent'
]
}
}
;
}
async
prepareToolInvocation
(
:
,
:
)
:
Promise
<
|
undefined
>
{
const
=
.
as
;
return
{
:
localize
(
'tool.rename.invocationMessage'
,
'Renaming `{0}` to `{1}`'
,
.
symbol
,
.
)
,
}
;
}
async
invoke
(
:
,
:
,
:
,
:
)
:
Promise
<
>
{
const
=
.
as
;
// --- resolve URI ---
const
=
resolveSymbolToolFileUri
(
,
this
.
,
this
.
,
.
?.
)
;
if
(
!
)
{
return
errorResult
(
localize
(
'tool.rename.invalidFile'
,
'Provide either "uri" (a full URI) or "filePath" (a workspace-relative path) to identify a file within the current workspace or working directory.'
)
)
;
}
// --- open text model ---
const
=
await
this
.
.
createModelReference
(
)
;
try
{
const
=
.
.
;
if
(
!
this
.
.
.
has
(
)
)
{
return
errorResult
(
`No rename provider available for this file's language. The rename tool may not support this language.`
)
;
}
// --- find line containing lineContent ---
const
=
findLineNumber
(
,
.
)
;
if
(
===
undefined
)
{
return
errorResult
(
`Could not find line content "${input.lineContent}" in ${uri.toString()}. Provide the exact text from the line where the symbol appears.`
)
;
}
// --- find symbol in that line ---
const
=
.
getLineContent
(
)
;
const
=
findSymbolColumn
(
,
.
symbol
)
;
if
(
===
undefined
)
{
return
errorResult
(
`Could not find symbol "${input.symbol}" in the matched line. Ensure the symbol name is correct and appears in the provided line content.`
)
;
}
const
=
new
Position
(
,
)
;
// --- perform rename ---
const
=
await
rename
(
this
.
.
,
,
,
.
)
;
if
(
.
)
{
return
errorResult
(
`Rename rejected: ${renameResult.rejectReason}`
)
;
}
if
(
.
.
===
0
)
{
return
errorResult
(
`Rename produced no edits.`
)
;
}
if
(
this
.
_containsOutOfScopeEdit
(
.
,
.
?.
)
)
{
return
errorResult
(
localize
(
'tool.rename.outOfScopeEdit'
,
'Rename was not applied because it would modify files outside the current workspace or working directory.'
)
)
;
}
// --- apply edits via chat response stream ---
if
(
.
)
{
const
=
this
.
.
getSession
(
.
.
)
as
|
undefined
;
const
=
?.
getRequests
(
)
.
at
(
-
1
)
;
if
(
&&
)
{
if
(
.
.
some
(
=>
!
.
is
(
)
)
)
{
return
errorResult
(
localize
(
'tool.rename.unsupportedEdit'
,
'Rename was not applied because it produced edits that cannot be reviewed in chat.'
)
)
;
}
// Group text edits by URI
const
=
new
ResourceMap<TextEdit[]>
(
)
;
for
(
const
of
.
)
{
if
(
.
is
(
)
)
{
let
=
.
get
(
.
)
;
if
(
!
)
{
=
[
]
;
.
set
(
.
,
)
;
}
.
push
(
.
)
;
}
}
// Push edits through the chat response stream
for
(
const
[
,
]
of
)
{
.
acceptResponseProgress
(
,
{
:
'textEdit'
,
:
,
:
[
]
,
}
)
;
.
acceptResponseProgress
(
,
{
:
'textEdit'
,
:
,
,
}
)
;
.
acceptResponseProgress
(
,
{
:
'textEdit'
,
:
,
:
[
]
,
:
true
,
}
)
;
}
return
this
.
_successResult
(
,
.
,
.
.
)
;
}
}
// Fallback: apply via bulk edit service when no chat context is available
await
this
.
_bulkEditService
.
apply
(
)
;
const
=
new
ResourceSet
(
.
.
filter
(
.
is
)
.
map
(
=>
.
)
)
.
;
return
this
.
_successResult
(
,
,
.
.
)
;
}
finally
{
.
dispose
(
)
;
}
}
private
_successResult
(
:
,
:
number
,
:
number
)
:
{
const
=
===
1
?
localize
(
'tool.rename.oneEdit'
,
"Renamed `{0}` to `{1}` - 1 edit in {2} file."
,
.
symbol
,
.
,
)
:
localize
(
'tool.rename.edits'
,
"Renamed `{0}` to `{1}` - {2} edits across {3} files."