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 / prompts / node / panel / test / chatVariablesHelpers.spec.ts 205 строк · изменён 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
import { describe, expect, test } from 'vitest' ;
import { URI } from '../../../../../util/vs/base/common/uri' ;
import { ChatVariablesCollection, getPromptFileSlashCommandId, parseSlashCommand, PromptFileIdPrefix, type PromptVariable } from '../../../../prompt/common/chatVariablesCollection' ;
import { buildSlashCommandUserMessage } from '../chatVariables' ;
function makePromptVariable ( name: string , value: PromptVariable[ 'value' ] ) : PromptVariable {
reference id name name value
originalName name
uniqueName name
value
isMarkedReadonly
name id
name id
name id
name id
name id
name id
entries name uri ReturnType file ChatVariablesCollection
entries e
id
name e name
value e uri
chatVariables
name uri
name uri
chatVariables
chatVariables
chatVariables
chatVariables
chatVariables
chatVariables
chatVariables
chatVariables
chatVariables
entries name uri ReturnType file ChatVariablesCollection
entries e
id
name e name
value e uri
chatVariables
name uri
name uri
chatVariables
chatVariables
chatVariables
result chatVariables
result
result command
result args
result promptFile name id
result chatVariables
result
result command
result args
result chatVariables
result
result command
result promptFile name id
result args
result chatVariables
result
result variable value
result variable reference name
result chatVariables
result
result command
result chatVariables
result args
mixed
id name value
id name value
result mixed
result
result command
return
{
:
{
:
,
,
}
,
:
,
:
,
,
:
undefined
,
}
;
}
describe
(
'getPromptFileSlashCommandId'
,
(
)
=>
{
test
(
'prompt file uses filename without .prompt.md extension'
,
(
)
=>
{
expect
(
getPromptFileSlashCommandId
(
makePromptVariable
(
'prompt:yell-foo.prompt.md'
,
URI
.
file
(
'/workspace/.github/prompts/yell-foo.prompt.md'
)
)
)
)
.
toEqual
(
{
:
'prompt:yell-foo.prompt.md'
,
:
'yell-foo'
}
)
;
}
)
;
test
(
'skill file uses parent folder name'
,
(
)
=>
{
expect
(
getPromptFileSlashCommandId
(
makePromptVariable
(
'code-review'
,
URI
.
file
(
'/workspace/.github/skills/code-review/SKILL.md'
)
)
)
)
.
toEqual
(
{
:
'code-review'
,
:
'code-review'
}
)
;
}
)
;
test
(
'skill file is case-insensitive for SKILL.md'
,
(
)
=>
{
expect
(
getPromptFileSlashCommandId
(
makePromptVariable
(
'my-skill'
,
URI
.
file
(
'/workspace/.github/skills/my-skill/skill.md'
)
)
)
)
.
toEqual
(
{
:
'my-skill'
,
:
'my-skill'
}
)
;
}
)
;
test
(
'non-prompt, non-skill file falls back to reference name'
,
(
)
=>
{
expect
(
getPromptFileSlashCommandId
(
makePromptVariable
(
'some-instructions.instructions.md'
,
URI
.
file
(
'/workspace/.github/instructions/some-instructions.instructions.md'
)
)
)
)
.
toEqual
(
{
:
'some-instructions.instructions.md'
,
:
'some-instructions.instructions.md'
}
)
;
}
)
;
test
(
'non-URI value falls back to reference name'
,
(
)
=>
{
expect
(
getPromptFileSlashCommandId
(
makePromptVariable
(
'inline-ref'
,
'some string value'
)
)
)
.
toEqual
(
{
:
'inline-ref'
,
:
'inline-ref'
}
)
;
}
)
;
test
(
'prompt file with nested path'
,
(
)
=>
{
expect
(
getPromptFileSlashCommandId
(
makePromptVariable
(
'prompt:deeply-nested.prompt.md'
,
URI
.
file
(
'/a/b/c/d/deeply-nested.prompt.md'
)
)
)
)
.
toEqual
(
{
:
'prompt:deeply-nested.prompt.md'
,
:
'deeply-nested'
}
)
;
}
)
;
}
)
;
describe
(
'buildSlashCommandUserMessage'
,
(
)
=>
{
function
makeCollection
(
:
{
:
string
;
:
<
typeof
URI
.
>
}
[
]
)
:
{
return
new
ChatVariablesCollection
(
.
map
(
=>
(
{
:
` ${ PromptFileIdPrefix} : ${ e. name} `
,
:
.
,
:
.
,
}
)
)
)
;
}
const
=
makeCollection
(
[
{
:
'prompt:code-review.prompt.md'
,
:
URI
.
file
(
'/workspace/.github/prompts/code-review.prompt.md'
)
}
,
{
:
'my-skill'
,
:
URI
.
file
(
'/workspace/.github/skills/my-skill/SKILL.md'
)
}
,
]
)
;
test
(
'returns follow instruction for matching slash command without args'
,
(
)
=>
{
expect
(
buildSlashCommandUserMessage
(
'/code-review'
,
)
)
.
toBe
(
'Follow instructions in #prompt:code-review.prompt.md'
)
;
}
)
;
test
(
'returns follow instruction with arguments when provided'
,
(
)
=>
{
expect
(
buildSlashCommandUserMessage
(
'/code-review some-file.ts'
,
)
)
.
toBe
(
'Follow instructions in #prompt:code-review.prompt.md with these arguments: some-file.ts'
)
;
}
)
;
test
(
'passes multi-word arguments'
,
(
)
=>
{
expect
(
buildSlashCommandUserMessage
(
'/code-review file1.ts file2.ts --strict'
,
)
)
.
toBe
(
'Follow instructions in #prompt:code-review.prompt.md with these arguments: file1.ts file2.ts --strict'
)
;
}
)
;
test
(
'matches skill slash commands'
,
(
)
=>
{
expect
(
buildSlashCommandUserMessage
(
'/my-skill do something'
,
)
)
.
toBe
(
'Follow instructions in #my-skill with these arguments: do something'
)
;
}
)
;
test
(
'returns original query when no slash command'
,
(
)
=>
{
expect
(
buildSlashCommandUserMessage
(
'just a normal question'
,
)
)
.
toBe
(
'just a normal question'
)
;
}
)
;
test
(
'returns original query when slash command does not match any prompt file'
,
(
)
=>
{
expect
(
buildSlashCommandUserMessage
(
'/unknown-command arg1'
,
)
)
.
toBe
(
'/unknown-command arg1'
)
;
}
)
;
test
(
'handles leading whitespace in query'
,
(
)
=>
{
expect
(
buildSlashCommandUserMessage
(
' /code-review'
,
)
)
.
toBe
(
'Follow instructions in #prompt:code-review.prompt.md'
)
;
}
)
;
test
(
'trims trailing whitespace from arguments'
,
(
)
=>
{
expect
(
buildSlashCommandUserMessage
(
'/code-review some-file.ts '
,
)
)
.
toBe
(
'Follow instructions in #prompt:code-review.prompt.md with these arguments: some-file.ts'
)
;
}
)
;
test
(
'handles empty prompt file list'
,
(
)
=>
{
expect
(
buildSlashCommandUserMessage
(
'/code-review'
,
new
ChatVariablesCollection
(
[
]
)
)
)
.
toBe
(
'/code-review'
)
;
}
)
;
test
(
'handles multiline arguments'
,
(
)
=>
{
expect
(
buildSlashCommandUserMessage
(
'/code-review line1\nline2'
,
)
)
.
toBe
(
'Follow instructions in #prompt:code-review.prompt.md with these arguments: line1\nline2'
)
;
}
)
;
}
)
;
describe
(
'parseSlashCommand'
,
(
)
=>
{
function
makeCollection
(
:
{
:
string
;
:
<
typeof
URI
.
>
}
[
]
)
:
{
return
new
ChatVariablesCollection
(
.
map
(
=>
(
{
:
` ${ PromptFileIdPrefix} : ${ e. name} `
,
:
.
,
:
.
,
}
)
)
)
;
}
const
=
makeCollection
(
[
{
:
'prompt:code-review.prompt.md'
,
:
URI
.
file
(
'/workspace/.github/prompts/code-review.prompt.md'
)
}
,
{
:
'my-skill'
,
:
URI
.
file
(
'/workspace/.github/skills/my-skill/SKILL.md'
)
}
,
]
)
;
test
(
'returns undefined for plain text query'
,
(
)
=>
{
expect
(
parseSlashCommand
(
'just a question'
,
)
)
.
toBeUndefined
(
)
;
}
)
;
test
(
'returns undefined when slash command does not match any prompt file'
,
(
)
=>
{
expect
(
parseSlashCommand
(
'/unknown arg'
,
)
)
.
toBeUndefined
(
)
;
}
)
;
test
(
'returns undefined for empty query'
,
(
)
=>
{
expect
(
parseSlashCommand
(
''
,
)
)
.
toBeUndefined
(
)
;
}
)
;
test
(
'matches prompt file and returns command and empty args'
,
(
)
=>
{
const
=
parseSlashCommand
(
'/code-review'
,
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
!
.
)
.
toBe
(
'code-review'
)
;
expect
(
!
.
)
.
toBe
(
''
)
;
expect
(
!
.
)
.
toEqual
(
{
:
'prompt:code-review.prompt.md'
,
:
'code-review'
}
)
;
}
)
;
test
(
'matches prompt file and returns parsed args'
,
(
)
=>
{
const
=
parseSlashCommand
(
'/code-review src/foo.ts --strict'
,
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
!
.
)
.
toBe
(
'code-review'
)
;
expect
(
!
.
)
.
toBe
(
'src/foo.ts --strict'
)
;
}
)
;
test
(
'matches skill file'
,
(
)
=>
{
const
=
parseSlashCommand
(
'/my-skill do something'
,
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
!
.
)
.
toBe
(
'my-skill'
)
;
expect
(
!
.
)
.
toEqual
(
{
:
'my-skill'
,
:
'my-skill'
}
)
;
expect
(
!
.
)
.
toBe
(
'do something'
)
;
}
)
;
test
(
'returns the matched variable'
,
(
)
=>
{
const
=
parseSlashCommand
(
'/code-review'
,
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
URI
.
isUri
(
!
.
.
)
)
.
toBe
(
true
)
;
expect
(
!
.
.
.
)
.
toBe
(
'prompt:code-review.prompt.md'
)
;
}
)
;
test
(
'handles leading whitespace'
,
(
)
=>
{
const
=
parseSlashCommand
(
' /code-review'
,
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
!
.
)
.
toBe
(
'code-review'
)
;
}
)
;
test
(
'trims trailing whitespace from args'
,
(
)
=>
{
const
=
parseSlashCommand
(
'/code-review arg '
,
)
;
expect
(
!
.
)
.
toBe
(
'arg'
)
;
}
)
;
test
(
'skips non-prompt-file references'
,
(
)
=>
{
const
=
new
ChatVariablesCollection
(
[
{
:
'vscode.instructions.file:inst'
,
:
'inst'
,
:
URI
.
file
(
'/workspace/inst.md'
)
}
,
{
:
` ${ PromptFileIdPrefix} :prompt:review.prompt.md `
,
:
'prompt:review.prompt.md'
,
:
URI
.
file
(
'/workspace/review.prompt.md'
)
}
,
]
)
;
const
=
parseSlashCommand
(
'/review'
,
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
!
.
)
.
toBe
(
'review'
)
;
}
)
;
test
(
'returns undefined with empty collection'
,
(
)
=>
{
expect
(
parseSlashCommand
(
'/code-review'
,
new
ChatVariablesCollection
(
[
]
)
)
)
.
toBeUndefined
(
)
;
}
)
;
}
)
;