ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / extensions / copilot / src / extension / tools / node / listDirTool.tsx 104 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import * as l10n from '@vscode/l10n' ;
import { BasePromptElementProps , PromptElement , PromptPiece , PromptSizing , TextChunk } from '@vscode/prompt-tsx' ;
import type * as vscode from 'vscode' ;
import { IFileSystemService } from '../../../platform/filesystem/common/fileSystemService' ;
import { FileType } from '../../../platform/filesystem/common/fileTypes' ;
import
path
toolName
nonDeferred
_promptContext
@ fsService
@ instantiationService
@ workspaceService
@ promptPathRepresentationService
options vscode token
uri options
token
contents uri
token
results contents options token
options vscode token vscode vscode
uri options
isExternal
accessor accessor uri readOnly workingDirectory options
isExternal
message
l10n
l10n
invocationMessage l10n
pastTenseMessage l10n
confirmationMessages
title l10n
message
invocationMessage l10n
pastTenseMessage l10n
input promptContext
promptContext
input
results
override state sizing
name type name type
{
IPromptPathRepresentationService
}
from
'../../../platform/prompts/common/promptPathRepresentationService'
;
import
{ IWorkspaceService }
from
'../../../platform/workspace/common/workspaceService'
;
import
{ CancellationToken }
from
'../../../util/vs/base/common/cancellation'
;
import
{ IInstantiationService , ServicesAccessor }
from
'../../../util/vs/platform/instantiation/common/instantiation'
;
import
{ LanguageModelPromptTsxPart , LanguageModelToolResult , MarkdownString }
from
'../../../vscodeTypes'
;
import
{ renderPromptElementJSON }
from
'../../prompts/node/base/promptRenderer'
;
import
{ ToolName }
from
'../common/toolNames'
;
import
{ ToolRegistry }
from
'../common/toolsRegistry'
;
import
{ formatUriForFileWidget }
from
'../common/toolUtils'
;
import
{ checkCancellation, isDirExternalAndNeedsConfirmation, resolveToolInputPath }
from
'./toolUtils'
;
import
{ IBuildPromptContext }
from
'../../prompt/common/intents'
;
interface
IListDirParams
{
:
string
;
}
class
ListDirTool
implements
vscode
.
LanguageModelTool
<
IListDirParams
>
{
public
static
readonly
=
ToolName
.
ListDirectory
;
public
static
readonly
=
true
;
private
:
IBuildPromptContext
|
undefined
;
constructor
(
IFileSystemService
private
readonly
:
IFileSystemService
,
IInstantiationService
private
readonly
:
IInstantiationService
,
IWorkspaceService
private
readonly
:
IWorkspaceService
,
IPromptPathRepresentationService
private
readonly
:
IPromptPathRepresentationService
,
)
{
}
async
invoke
(
:
.
LanguageModelToolInvocationOptions
<
IListDirParams
>
,
:
CancellationToken
)
{
const
=
resolveToolInputPath
(
.
input
.
path
,
this
.
promptPathRepresentationService
)
;
checkCancellation
(
)
;
const
=
await
this
.
fsService
.
readDirectory
(
)
;
checkCancellation
(
)
;
return
new
LanguageModelToolResult
(
[
new
LanguageModelPromptTsxPart
(
await
renderPromptElementJSON
(
this
.
instantiationService
,
ListDirResult
,
{
:
}
,
.
tokenizationOptions
,
)
)
]
)
;
}
async
prepareInvocation
(
:
.
LanguageModelToolInvocationPrepareOptions
<
IListDirParams
>
,
:
.
CancellationToken
)
:
Promise
<
.
PreparedToolInvocation
|
undefined
>
{
const
=
resolveToolInputPath
(
.
input
.
path
,
this
.
promptPathRepresentationService
)
;
const
=
this
.
instantiationService
.
invokeFunction
(
(
:
ServicesAccessor
)
=>
isDirExternalAndNeedsConfirmation
(
,
,
this
.
_promptContext
,
{
:
true
,
:
.
workingDirectory
}
)
)
;
if
(
)
{
const
=
this
.
workspaceService
.
getWorkspaceFolders
(
)
.
length
===
1
?
new
MarkdownString
(
.
t
` ${ formatUriForFileWidget ( uri) } is outside of the current folder. `
)
:
new
MarkdownString
(
.
t
` ${ formatUriForFileWidget ( uri) } is outside of the current workspace. `
)
;
return
{
:
new
MarkdownString
(
.
t
` Reading ${ formatUriForFileWidget ( uri) } `
)
,
:
new
MarkdownString
(
.
t
` Read ${ formatUriForFileWidget ( uri) } `
)
,
:
{
:
.
t
` Allow reading external directory? `
,
,
}
}
;
}
return
{
:
new
MarkdownString
(
.
t
` Reading ${ formatUriForFileWidget ( uri) } `
)
,
:
new
MarkdownString
(
.
t
` Read ${ formatUriForFileWidget ( uri) } `
)
,
}
;
}
async
resolveInput
(
:
IListDirParams
,
:
IBuildPromptContext
)
:
Promise
<
IListDirParams
>
{
this
.
_promptContext
=
;
return
;
}
}
ToolRegistry
.
registerTool
(
ListDirTool
)
;
interface
ListDirResultProps
extends
BasePromptElementProps
{
:
[
string
,
FileType
]
[
]
;
}
class
ListDirResult
extends
PromptElement< ListDirResultProps>
{
render
(
:
void
,
:
PromptSizing
)
:
PromptPiece
<
any
,
any
>
|
undefined
{
if
(
this
.
props
.
results
.
length
===
0
)
{
return
< >
Folder is empty
</ >
;
}
return
< >
{
this
.
props
.
results
.
map
(
(
[
,
]
)
=>
< TextChunk >
{
}
{
===
FileType
.
Directory
?
'/'
:
''
}
</ TextChunk >
)
}
</ >
;
}
}