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 / chronicle / common / test / sessionStoreTracking.spec.ts 260 строк · изменён 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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
import { describe, expect, it } from 'vitest' ;
import { extractAgentName, extractFilePath, extractPlainTextFromContent, extractRefsFromMcpTool, extractRefsFromTerminal, extractRepoFromMcpTool, isGitHubMcpTool } from '../sessionStoreTracking' ;
describe ( 'extractFilePath' , ( ) => {
it ( 'extracts filePath from replace_string_in_file' , ( ) => {
expect ( extractFilePath ( 'replace_string_in_file' , { filePath: '/src/foo.ts' , oldString newString
explanation
replacements
filePath oldString newString
filePath oldString newString
filePath code
filePath content
filePath editType cellId
filePath startLine endLine
path
dirPath
input
input
input
input
input
input
filePath input
path
path
command
query
filePath
refs pullNumber owner repo
refs ref_type ref_value
refs issue_number owner repo
refs ref_type ref_value
refs sha owner repo
refs ref_type ref_value
query
owner repo
owner
refs
command
refs ref_type ref_value
refs
command
refs ref_type ref_value
refs
command
refs ref_type ref_value
command
name attributes
name attributes
name attributes
name attributes
name attributes
name attributes
:
'a'
,
:
'b'
}
)
)
.
toBe
(
'/src/foo.ts'
)
;
}
)
;
it
(
'extracts filePath from multi_replace_string_in_file replacements array'
,
(
)
=>
{
expect
(
extractFilePath
(
'multi_replace_string_in_file'
,
{
:
'fix imports'
,
:
[
{
:
'/src/bar.ts'
,
:
'a'
,
:
'b'
}
,
{
:
'/src/baz.ts'
,
:
'c'
,
:
'd'
}
,
]
}
)
)
.
toBe
(
'/src/bar.ts'
)
;
}
)
;
it
(
'extracts filePath from insert_edit_into_file'
,
(
)
=>
{
expect
(
extractFilePath
(
'insert_edit_into_file'
,
{
:
'/src/edit.ts'
,
:
'// new'
}
)
)
.
toBe
(
'/src/edit.ts'
)
;
}
)
;
it
(
'extracts filePath from create_file'
,
(
)
=>
{
expect
(
extractFilePath
(
'create_file'
,
{
:
'/src/new.ts'
,
:
''
}
)
)
.
toBe
(
'/src/new.ts'
)
;
}
)
;
it
(
'extracts filePath from edit_notebook_file'
,
(
)
=>
{
expect
(
extractFilePath
(
'edit_notebook_file'
,
{
:
'/nb.ipynb'
,
:
'edit'
,
:
'c1'
}
)
)
.
toBe
(
'/nb.ipynb'
)
;
}
)
;
it
(
'extracts filePath from read_file'
,
(
)
=>
{
expect
(
extractFilePath
(
'read_file'
,
{
:
'/src/read.ts'
,
:
1
,
:
10
}
)
)
.
toBe
(
'/src/read.ts'
)
;
}
)
;
it
(
'extracts path from list_dir'
,
(
)
=>
{
expect
(
extractFilePath
(
'list_dir'
,
{
:
'/src'
}
)
)
.
toBe
(
'/src'
)
;
}
)
;
it
(
'extracts dirPath from create_directory'
,
(
)
=>
{
expect
(
extractFilePath
(
'create_directory'
,
{
:
'/src/new-dir'
}
)
)
.
toBe
(
'/src/new-dir'
)
;
}
)
;
it
(
'extracts file path from apply_patch input text'
,
(
)
=>
{
const
=
'*** Begin Patch\n*** Update File: /src/hello.ts\n@@class Foo\n- bar\n+ baz\n*** End Patch'
;
expect
(
extractFilePath
(
'apply_patch'
,
{
}
)
)
.
toBe
(
'/src/hello.ts'
)
;
}
)
;
it
(
'extracts file path from apply_patch Add File'
,
(
)
=>
{
const
=
'*** Begin Patch\n*** Add File: /src/new.ts\n+export const x = 1;\n*** End Patch'
;
expect
(
extractFilePath
(
'apply_patch'
,
{
}
)
)
.
toBe
(
'/src/new.ts'
)
;
}
)
;
it
(
'extracts file path from apply_patch Delete File'
,
(
)
=>
{
const
=
'*** Begin Patch\n*** Delete File: /src/old.ts\n*** End Patch'
;
expect
(
extractFilePath
(
'apply_patch'
,
{
}
)
)
.
toBe
(
'/src/old.ts'
)
;
}
)
;
it
(
'falls back to filePath arg for apply_patch when present'
,
(
)
=>
{
expect
(
extractFilePath
(
'apply_patch'
,
{
:
'/from/arg.ts'
,
:
'*** Update File: /from/input.ts'
}
)
)
.
toBe
(
'/from/arg.ts'
)
;
}
)
;
it
(
'extracts path from CLI str_replace_editor (backward compat)'
,
(
)
=>
{
expect
(
extractFilePath
(
'str_replace_editor'
,
{
:
'/cli/file.py'
}
)
)
.
toBe
(
'/cli/file.py'
)
;
}
)
;
it
(
'extracts path from CLI create tool (backward compat)'
,
(
)
=>
{
expect
(
extractFilePath
(
'create'
,
{
:
'/cli/new.py'
}
)
)
.
toBe
(
'/cli/new.py'
)
;
}
)
;
it
(
'returns undefined for unknown tools'
,
(
)
=>
{
expect
(
extractFilePath
(
'run_in_terminal'
,
{
:
'ls'
}
)
)
.
toBeUndefined
(
)
;
expect
(
extractFilePath
(
'file_search'
,
{
:
'**/*.ts'
}
)
)
.
toBeUndefined
(
)
;
}
)
;
it
(
'returns undefined for null args'
,
(
)
=>
{
expect
(
extractFilePath
(
'create_file'
,
null
)
)
.
toBeUndefined
(
)
;
}
)
;
it
(
'returns undefined when filePath is not a string'
,
(
)
=>
{
expect
(
extractFilePath
(
'create_file'
,
{
:
42
}
)
)
.
toBeUndefined
(
)
;
}
)
;
}
)
;
describe
(
'isGitHubMcpTool'
,
(
)
=>
{
it
(
'matches mcp_github_ prefix (VS Code)'
,
(
)
=>
{
expect
(
isGitHubMcpTool
(
'mcp_github_issue_write'
)
)
.
toBe
(
true
)
;
expect
(
isGitHubMcpTool
(
'mcp_github_create_pull_request'
)
)
.
toBe
(
true
)
;
expect
(
isGitHubMcpTool
(
'mcp_github_search_issues'
)
)
.
toBe
(
true
)
;
}
)
;
it
(
'matches github-mcp-server- prefix (CLI)'
,
(
)
=>
{
expect
(
isGitHubMcpTool
(
'github-mcp-server-create_issue'
)
)
.
toBe
(
true
)
;
}
)
;
it
(
'rejects non-GitHub MCP tools'
,
(
)
=>
{
expect
(
isGitHubMcpTool
(
'read_file'
)
)
.
toBe
(
false
)
;
expect
(
isGitHubMcpTool
(
'mcp_perplexity_ask'
)
)
.
toBe
(
false
)
;
expect
(
isGitHubMcpTool
(
'run_in_terminal'
)
)
.
toBe
(
false
)
;
}
)
;
}
)
;
describe
(
'extractRefsFromMcpTool'
,
(
)
=>
{
it
(
'extracts PR ref from mcp_github_pull_request_read'
,
(
)
=>
{
const
=
extractRefsFromMcpTool
(
'mcp_github_pull_request_read'
,
{
:
42
,
:
'ms'
,
:
'vscode'
}
)
;
expect
(
)
.
toEqual
(
[
{
:
'pr'
,
:
'42'
}
]
)
;
}
)
;
it
(
'extracts issue ref from mcp_github_issue_write'
,
(
)
=>
{
const
=
extractRefsFromMcpTool
(
'mcp_github_issue_write'
,
{
:
123
,
:
'ms'
,
:
'vscode'
}
)
;
expect
(
)
.
toEqual
(
[
{
:
'issue'
,
:
'123'
}
]
)
;
}
)
;
it
(
'extracts commit ref from mcp_github_get_commit'
,
(
)
=>
{
const
=
extractRefsFromMcpTool
(
'mcp_github_get_commit'
,
{
:
'abc123'
,
:
'ms'
,
:
'vscode'
}
)
;
expect
(
)
.
toEqual
(
[
{
:
'commit'
,
:
'abc123'
}
]
)
;
}
)
;
it
(
'returns empty for non-matching tool name'
,
(
)
=>
{
expect
(
extractRefsFromMcpTool
(
'mcp_github_search_code'
,
{
:
'foo'
}
)
)
.
toEqual
(
[
]
)
;
}
)
;
}
)
;
describe
(
'extractRepoFromMcpTool'
,
(
)
=>
{
it
(
'extracts owner/repo'
,
(
)
=>
{
expect
(
extractRepoFromMcpTool
(
{
:
'microsoft'
,
:
'vscode'
}
)
)
.
toBe
(
'microsoft/vscode'
)
;
}
)
;
it
(
'returns undefined when missing'
,
(
)
=>
{
expect
(
extractRepoFromMcpTool
(
{
:
'microsoft'
}
)
)
.
toBeUndefined
(
)
;
expect
(
extractRepoFromMcpTool
(
{
}
)
)
.
toBeUndefined
(
)
;
}
)
;
}
)
;
describe
(
'extractRefsFromTerminal'
,
(
)
=>
{
it
(
'extracts PR ref from gh pr create output'
,
(
)
=>
{
const
=
extractRefsFromTerminal
(
{
:
'gh pr create --title "fix"'
}
,
'https://github.com/microsoft/vscode/pull/999'
,
)
;
expect
(
)
.
toEqual
(
[
{
:
'pr'
,
:
'999'
}
]
)
;
}
)
;
it
(
'extracts issue ref from gh issue create output'
,
(
)
=>
{
const
=
extractRefsFromTerminal
(
{
:
'gh issue create --title "bug"'
}
,
'https://github.com/microsoft/vscode/issues/456'
,
)
;
expect
(
)
.
toEqual
(
[
{
:
'issue'
,
:
'456'
}
]
)
;
}
)
;
it
(
'extracts commit SHA from git commit output'
,
(
)
=>
{
const
=
extractRefsFromTerminal
(
{
:
'git commit -m "fix"'
}
,
'[main abc1234] fix\n 1 file changed'
,
)
;
expect
(
)
.
toEqual
(
[
{
:
'commit'
,
:
'abc1234'
}
]
)
;
}
)
;
it
(
'returns empty for unrelated commands'
,
(
)
=>
{
expect
(
extractRefsFromTerminal
(
{
:
'ls -la'
}
,
'output'
)
)
.
toEqual
(
[
]
)
;
}
)
;
}
)
;
describe
(
'extractAgentName'
,
(
)
=>
{
it
(
'returns trimmed attribute value when present'
,
(
)
=>
{
expect
(
extractAgentName
(
{
:
'invoke_agent'
,
:
{
'gen_ai.agent.name'
:
' copilot '
}
}
)
)
.
toBe
(
'copilot'
)
;
}
)
;
it
(
'parses agent name from span name when attribute is absent'
,
(
)
=>
{
expect
(
extractAgentName
(
{
:
'invoke_agent copilot'
,
:
{
}
}
)
)
.
toBe
(
'copilot'
)
;
}
)
;
it
(
'parses multi-word agent name from span name'
,
(
)
=>
{
expect
(
extractAgentName
(
{
:
'invoke_agent GitHub Copilot Chat'
,
:
{
}
}
)
)
.
toBe
(
'GitHub Copilot Chat'
)
;
}
)
;
it
(
'returns unknown when span name is invoke_agent with no suffix'
,
(
)
=>
{
expect
(
extractAgentName
(
{
:
'invoke_agent '
,
:
{
}
}
)
)
.
toBe
(
'unknown'
)
;
}
)
;
it
(
'falls back to span name when attribute is empty string'
,
(
)
=>
{
expect
(
extractAgentName
(
{
:
'invoke_agent copilot'
,
:
{
'gen_ai.agent.name'
:
''
}
}
)
)
.
toBe
(
'copilot'
)
;
}
)
;
it
(
'returns unknown when span name does not start with invoke_agent'
,
(
)
=>
{
expect
(
extractAgentName
(
{
:
'execute_tool read_file'
,
:
{
}
}
)
)
.
toBe
(
'unknown'
)
;
}
)
;
}
)
;
describe
(
'extractPlainTextFromContent'
,
(
)
=>
{
it
(
'returns plain text string unchanged'
,
(
)
=>
{
expect
(
extractPlainTextFromContent
(
'Fix the bug'
)
)
.
toBe
(
'Fix the bug'
)
;
}
)
;
it
(
'returns undefined for empty string'
,
(
)
=>
{
expect
(
extractPlainTextFromContent
(
''
)
)
.
toBeUndefined
(
)
;
}
)
;
it
(
'returns undefined for whitespace-only string'
,
(
)
=>
{
expect
(
extractPlainTextFromContent
(
' '
)
)
.
toBeUndefined
(
)
;
}
)
;
it
(
'extracts text from [{type:"text", text:"..."}] array'
,
(
)
=>
{
expect
(
extractPlainTextFromContent
(
'[{"type":"text","text":"Fix the bug"}]'
)
)
.
toBe
(
'Fix the bug'
)
;
}
)
;
it
(
'trims whitespace from text part'
,
(
)
=>
{
expect
(
extractPlainTextFromContent
(
'[{"type":"text","text":" padded "}]'
)
)
.
toBe
(
'padded'
)
;
}
)
;
it
(
'returns undefined for text part with empty text'
,
(
)
=>
{
expect
(
extractPlainTextFromContent
(
'[{"type":"text","text":""}]'
)
)
.
toBeUndefined
(
)
;
}
)
;
it
(
'returns undefined for array with no text parts (tool results)'
,
(
)
=>
{
expect
(
extractPlainTextFromContent
(
'[{"type":"tool_result","content":"some result"}]'
)
)
.
toBeUndefined
(
)
;
}
)
;
it
(
'extracts content from {role, content} object with string content'
,
(
)
=>
{
expect
(
extractPlainTextFromContent
(
'{"role":"user","content":"Fix the login bug"}'
)
)
.
toBe
(
'Fix the login bug'
)
;
}
)
;
it
(
'returns undefined for object with array content (multi-modal)'
,
(
)
=>
{
expect
(
extractPlainTextFromContent
(
'{"role":"user","content":[{"type":"text"}]}'
)
)
.
toBeUndefined
(
)
;
}
)
;
it
(
'returns undefined for invalid/truncated JSON'
,
(
)
=>
{
expect
(
extractPlainTextFromContent
(
'[{"type":"text","text":"Fix'
)
)
.
toBeUndefined
(
)
;
}
)
;
}
)
;