solver-sdk 2.6.2 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -55
- package/dist/cjs/api/chat-api/index.js +68 -68
- package/dist/cjs/api/chat-api/index.js.map +1 -1
- package/dist/cjs/api/projects-api.js +7 -0
- package/dist/cjs/api/projects-api.js.map +1 -1
- package/dist/cjs/code-solver-sdk.js +24 -2
- package/dist/cjs/code-solver-sdk.js.map +1 -1
- package/dist/cjs/constants/websocket-events.constants.js +5 -0
- package/dist/cjs/constants/websocket-events.constants.js.map +1 -1
- package/dist/cjs/constants/websocket-namespaces.constants.js +2 -0
- package/dist/cjs/constants/websocket-namespaces.constants.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interfaces/websocket/vscode-command.interfaces.js +42 -0
- package/dist/cjs/interfaces/websocket/vscode-command.interfaces.js.map +1 -0
- package/dist/cjs/utils/http-client.js +11 -3
- package/dist/cjs/utils/http-client.js.map +1 -1
- package/dist/cjs/ws/file-editing-ws-client.js +162 -0
- package/dist/cjs/ws/file-editing-ws-client.js.map +1 -0
- package/dist/esm/api/chat-api/index.js +68 -68
- package/dist/esm/api/chat-api/index.js.map +1 -1
- package/dist/esm/api/projects-api.js +7 -0
- package/dist/esm/api/projects-api.js.map +1 -1
- package/dist/esm/code-solver-sdk.js +24 -2
- package/dist/esm/code-solver-sdk.js.map +1 -1
- package/dist/esm/constants/websocket-events.constants.js +5 -0
- package/dist/esm/constants/websocket-events.constants.js.map +1 -1
- package/dist/esm/constants/websocket-namespaces.constants.js +2 -0
- package/dist/esm/constants/websocket-namespaces.constants.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces/websocket/vscode-command.interfaces.js +39 -0
- package/dist/esm/interfaces/websocket/vscode-command.interfaces.js.map +1 -0
- package/dist/esm/utils/http-client.js +11 -3
- package/dist/esm/utils/http-client.js.map +1 -1
- package/dist/esm/ws/file-editing-ws-client.js +158 -0
- package/dist/esm/ws/file-editing-ws-client.js.map +1 -0
- package/dist/types/api/chat-api/index.d.ts +7 -0
- package/dist/types/api/chat-api/index.d.ts.map +1 -1
- package/dist/types/api/chat-api/interfaces.d.ts +7 -0
- package/dist/types/api/chat-api/interfaces.d.ts.map +1 -1
- package/dist/types/api/chat-api/models.d.ts +10 -1
- package/dist/types/api/chat-api/models.d.ts.map +1 -1
- package/dist/types/api/projects-api.d.ts +18 -0
- package/dist/types/api/projects-api.d.ts.map +1 -1
- package/dist/types/code-solver-sdk.d.ts +8 -0
- package/dist/types/code-solver-sdk.d.ts.map +1 -1
- package/dist/types/constants/websocket-events.constants.d.ts +5 -1
- package/dist/types/constants/websocket-events.constants.d.ts.map +1 -1
- package/dist/types/constants/websocket-namespaces.constants.d.ts +3 -1
- package/dist/types/constants/websocket-namespaces.constants.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/interfaces/websocket/vscode-command.interfaces.d.ts +56 -0
- package/dist/types/interfaces/websocket/vscode-command.interfaces.d.ts.map +1 -0
- package/dist/types/utils/http-client.d.ts.map +1 -1
- package/dist/types/ws/file-editing-ws-client.d.ts +85 -0
- package/dist/types/ws/file-editing-ws-client.d.ts.map +1 -0
- package/docs/ARCHITECTURE.md +268 -0
- package/docs/QUICK_START.md +126 -0
- package/docs/README.md +25 -279
- package/docs/VSCODE_INTEGRATION.md +432 -0
- package/docs/WEBSOCKET.md +49 -10
- package/package.json +1 -1
- package/docs/API_REFERENCE.md +0 -703
- package/docs/INTEGRATION_GUIDE_V2.5.md +0 -516
- package/docs/README_V2.5.md +0 -266
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
# VS Code Integration v2.7.0
|
|
2
|
+
|
|
3
|
+
**Детальное руководство для разработчиков VS Code Extension** (продолжение [Quick Start](QUICK_START.md))
|
|
4
|
+
|
|
5
|
+
## 🎯 Архитектура
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
AI Модель → Backend → SDK → VS Code Extension → VS Code Native API
|
|
9
|
+
↑─── HTTP Streaming (45ms) ───↑
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
**Результат:** **10x ускорение** команд - 45ms вместо 443ms! 🚀
|
|
13
|
+
|
|
14
|
+
## 🚀 Быстрый старт
|
|
15
|
+
|
|
16
|
+
### 1. Установка и инициализация
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { CodeSolverSDK, VSCodeCommandEvent, CommandExecutionResult } from 'solver-sdk';
|
|
20
|
+
import * as vscode from 'vscode';
|
|
21
|
+
|
|
22
|
+
const sdk = await CodeSolverSDK.create({
|
|
23
|
+
baseURL: 'http://localhost:3000',
|
|
24
|
+
apiKey: 'your-api-key'
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 2. Базовая интеграция
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
async function integrateWithVSCode() {
|
|
32
|
+
const stream = await sdk.chat.streamChat(
|
|
33
|
+
[{ role: 'user', content: 'Создай компонент Button в React' }],
|
|
34
|
+
{
|
|
35
|
+
thinking: { type: 'enabled', budget_tokens: 4000 },
|
|
36
|
+
|
|
37
|
+
// 🎯 Главная функция - обработчик VS Code команд
|
|
38
|
+
onVSCodeCommand: async (command: VSCodeCommandEvent) => {
|
|
39
|
+
return await executeVSCodeCommand(command);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// Обработка потока
|
|
45
|
+
for await (const chunk of stream) {
|
|
46
|
+
if (chunk.type === 'command_executed') {
|
|
47
|
+
console.log('✅ Команда выполнена:', chunk.commandResult);
|
|
48
|
+
} else if (chunk.type === 'text') {
|
|
49
|
+
console.log('💬 AI ответ:', chunk.text);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 3. Реализация обработчика команд
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
async function executeVSCodeCommand(
|
|
59
|
+
command: VSCodeCommandEvent
|
|
60
|
+
): Promise<CommandExecutionResult> {
|
|
61
|
+
const startTime = Date.now();
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
console.log(`🚀 Выполнение: ${command.command}`, command.args);
|
|
65
|
+
|
|
66
|
+
// Выполнение через VS Code API
|
|
67
|
+
const result = await vscode.commands.executeCommand(
|
|
68
|
+
command.command,
|
|
69
|
+
...(command.args || [])
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
requestId: command.requestId,
|
|
74
|
+
success: true,
|
|
75
|
+
result,
|
|
76
|
+
executionTime: Date.now() - startTime,
|
|
77
|
+
timestamp: Date.now()
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} catch (error: any) {
|
|
81
|
+
return {
|
|
82
|
+
requestId: command.requestId,
|
|
83
|
+
success: false,
|
|
84
|
+
error: error.message,
|
|
85
|
+
executionTime: Date.now() - startTime,
|
|
86
|
+
timestamp: Date.now()
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## 📋 Поддерживаемые команды
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
import { VSCodeCommands } from 'solver-sdk';
|
|
96
|
+
|
|
97
|
+
// Создание файлов
|
|
98
|
+
VSCodeCommands.CREATE_FILE = 'aiSolver.native.createFile'
|
|
99
|
+
// Использование: ['src/Button.tsx', 'export const Button = () => <button>Click</button>']
|
|
100
|
+
|
|
101
|
+
// Редактирование файлов
|
|
102
|
+
VSCodeCommands.EDIT_FILE = 'aiSolver.native.editFile'
|
|
103
|
+
// Использование: ['src/App.tsx', { line: 10, content: 'new code' }]
|
|
104
|
+
|
|
105
|
+
// Bulk операции
|
|
106
|
+
VSCodeCommands.BULK_EDIT = 'aiSolver.native.bulkEdit'
|
|
107
|
+
// Использование: [{ file: 'src/A.tsx', changes: [...] }, { file: 'src/B.tsx', changes: [...] }]
|
|
108
|
+
|
|
109
|
+
// Поиск файлов
|
|
110
|
+
VSCodeCommands.FIND_FILES = 'vscode.workspace.findFiles'
|
|
111
|
+
// Использование: ['**/*.tsx', '**/node_modules/**']
|
|
112
|
+
|
|
113
|
+
// Текстовый поиск
|
|
114
|
+
VSCodeCommands.FIND_TEXT = 'vscode.workspace.findTextInFiles'
|
|
115
|
+
// Использование: ['useState', { include: '**/*.tsx' }]
|
|
116
|
+
|
|
117
|
+
// Терминал
|
|
118
|
+
VSCodeCommands.TERMINAL = 'aiSolver.native.terminal'
|
|
119
|
+
// Использование: ['npm install react', { cwd: '/path/to/project' }]
|
|
120
|
+
|
|
121
|
+
// Стандартные команды
|
|
122
|
+
VSCodeCommands.SAVE_FILE = 'workbench.action.files.save'
|
|
123
|
+
VSCodeCommands.SAVE_ALL = 'workbench.action.files.saveAll'
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## 🛠️ Продвинутые сценарии
|
|
127
|
+
|
|
128
|
+
### Обработка различных типов команд
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
async function advancedCommandHandler(command: VSCodeCommandEvent) {
|
|
132
|
+
const { command: cmd, args, metadata } = command;
|
|
133
|
+
|
|
134
|
+
switch (cmd) {
|
|
135
|
+
case VSCodeCommands.CREATE_FILE:
|
|
136
|
+
return await handleCreateFile(args[0], args[1]);
|
|
137
|
+
|
|
138
|
+
case VSCodeCommands.EDIT_FILE:
|
|
139
|
+
return await handleEditFile(args[0], args[1]);
|
|
140
|
+
|
|
141
|
+
case VSCodeCommands.BULK_EDIT:
|
|
142
|
+
return await handleBulkEdit(args[0]);
|
|
143
|
+
|
|
144
|
+
case VSCodeCommands.FIND_FILES:
|
|
145
|
+
return await handleFindFiles(args[0], args[1]);
|
|
146
|
+
|
|
147
|
+
case VSCodeCommands.TERMINAL:
|
|
148
|
+
return await handleTerminal(args[0], args[1]);
|
|
149
|
+
|
|
150
|
+
default:
|
|
151
|
+
// Fallback для любых других команд
|
|
152
|
+
return await handleGenericCommand(cmd, args);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
async function handleCreateFile(path: string, content: string) {
|
|
157
|
+
try {
|
|
158
|
+
const uri = vscode.Uri.file(path);
|
|
159
|
+
const encoder = new TextEncoder();
|
|
160
|
+
await vscode.workspace.fs.writeFile(uri, encoder.encode(content));
|
|
161
|
+
|
|
162
|
+
// Открываем файл в редакторе
|
|
163
|
+
await vscode.window.showTextDocument(uri);
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
success: true,
|
|
167
|
+
result: { created: true, path, opened: true }
|
|
168
|
+
};
|
|
169
|
+
} catch (error) {
|
|
170
|
+
return {
|
|
171
|
+
success: false,
|
|
172
|
+
error: `Не удалось создать файл: ${error.message}`
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
async function handleBulkEdit(operations: Array<{file: string, changes: any[]}>) {
|
|
178
|
+
const edit = new vscode.WorkspaceEdit();
|
|
179
|
+
const results = [];
|
|
180
|
+
|
|
181
|
+
for (const op of operations) {
|
|
182
|
+
try {
|
|
183
|
+
const uri = vscode.Uri.file(op.file);
|
|
184
|
+
|
|
185
|
+
for (const change of op.changes) {
|
|
186
|
+
const range = new vscode.Range(
|
|
187
|
+
change.startLine, change.startChar,
|
|
188
|
+
change.endLine, change.endChar
|
|
189
|
+
);
|
|
190
|
+
edit.replace(uri, range, change.newText);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
results.push({ file: op.file, success: true });
|
|
194
|
+
} catch (error) {
|
|
195
|
+
results.push({
|
|
196
|
+
file: op.file,
|
|
197
|
+
success: false,
|
|
198
|
+
error: error.message
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const applied = await vscode.workspace.applyEdit(edit);
|
|
204
|
+
|
|
205
|
+
return {
|
|
206
|
+
success: applied,
|
|
207
|
+
result: { operations: results, totalApplied: applied }
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Логирование и мониторинг
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
class VSCodeIntegrationLogger {
|
|
216
|
+
private outputChannel: vscode.OutputChannel;
|
|
217
|
+
|
|
218
|
+
constructor() {
|
|
219
|
+
this.outputChannel = vscode.window.createOutputChannel('AI Solver');
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
logCommand(command: VSCodeCommandEvent, result: CommandExecutionResult) {
|
|
223
|
+
const status = result.success ? '✅' : '❌';
|
|
224
|
+
const time = result.executionTime;
|
|
225
|
+
|
|
226
|
+
this.outputChannel.appendLine(
|
|
227
|
+
`${status} [${time}ms] ${command.command} - ${command.requestId}`
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
if (!result.success) {
|
|
231
|
+
this.outputChannel.appendLine(` Error: ${result.error}`);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Показываем панель при ошибках
|
|
235
|
+
if (!result.success) {
|
|
236
|
+
this.outputChannel.show();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
logPerformance(commands: CommandExecutionResult[]) {
|
|
241
|
+
const avgTime = commands.reduce((sum, cmd) => sum + cmd.executionTime, 0) / commands.length;
|
|
242
|
+
const successRate = commands.filter(cmd => cmd.success).length / commands.length * 100;
|
|
243
|
+
|
|
244
|
+
this.outputChannel.appendLine(`📊 Performance: ${avgTime.toFixed(1)}ms avg, ${successRate.toFixed(1)}% success`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## 🔧 Конфигурация Extension
|
|
250
|
+
|
|
251
|
+
### package.json
|
|
252
|
+
|
|
253
|
+
```json
|
|
254
|
+
{
|
|
255
|
+
"contributes": {
|
|
256
|
+
"commands": [
|
|
257
|
+
{
|
|
258
|
+
"command": "aiSolver.native.createFile",
|
|
259
|
+
"title": "AI Solver: Create File"
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"command": "aiSolver.native.editFile",
|
|
263
|
+
"title": "AI Solver: Edit File"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"command": "aiSolver.native.bulkEdit",
|
|
267
|
+
"title": "AI Solver: Bulk Edit"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
"command": "aiSolver.native.terminal",
|
|
271
|
+
"title": "AI Solver: Execute Terminal Command"
|
|
272
|
+
}
|
|
273
|
+
],
|
|
274
|
+
"configuration": {
|
|
275
|
+
"title": "AI Solver",
|
|
276
|
+
"properties": {
|
|
277
|
+
"aiSolver.apiUrl": {
|
|
278
|
+
"type": "string",
|
|
279
|
+
"default": "http://localhost:3000",
|
|
280
|
+
"description": "AI Solver API URL"
|
|
281
|
+
},
|
|
282
|
+
"aiSolver.commandTimeout": {
|
|
283
|
+
"type": "number",
|
|
284
|
+
"default": 30000,
|
|
285
|
+
"description": "Command execution timeout (ms)"
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Активация extension
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
export function activate(context: vscode.ExtensionContext) {
|
|
297
|
+
const logger = new VSCodeIntegrationLogger();
|
|
298
|
+
const sdk = initializeSDK();
|
|
299
|
+
|
|
300
|
+
// Регистрация команд
|
|
301
|
+
const createFileCommand = vscode.commands.registerCommand(
|
|
302
|
+
'aiSolver.native.createFile',
|
|
303
|
+
async (path: string, content: string) => {
|
|
304
|
+
// Реализация создания файла
|
|
305
|
+
}
|
|
306
|
+
);
|
|
307
|
+
|
|
308
|
+
const editFileCommand = vscode.commands.registerCommand(
|
|
309
|
+
'aiSolver.native.editFile',
|
|
310
|
+
async (path: string, changes: any) => {
|
|
311
|
+
// Реализация редактирования файла
|
|
312
|
+
}
|
|
313
|
+
);
|
|
314
|
+
|
|
315
|
+
context.subscriptions.push(createFileCommand, editFileCommand);
|
|
316
|
+
|
|
317
|
+
// Инициализация сервиса интеграции
|
|
318
|
+
const integrationService = new VSCodeIntegrationService(sdk, logger);
|
|
319
|
+
integrationService.start();
|
|
320
|
+
}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## 📈 Performance Optimization
|
|
324
|
+
|
|
325
|
+
### Кэширование команд
|
|
326
|
+
|
|
327
|
+
```typescript
|
|
328
|
+
class CommandCache {
|
|
329
|
+
private cache = new Map<string, any>();
|
|
330
|
+
|
|
331
|
+
async executeWithCache(command: VSCodeCommandEvent): Promise<CommandExecutionResult> {
|
|
332
|
+
// Кэшируем результаты для идемпотентных команд
|
|
333
|
+
if (this.isIdempotent(command.command)) {
|
|
334
|
+
const cacheKey = this.getCacheKey(command);
|
|
335
|
+
const cached = this.cache.get(cacheKey);
|
|
336
|
+
|
|
337
|
+
if (cached) {
|
|
338
|
+
return {
|
|
339
|
+
...cached,
|
|
340
|
+
requestId: command.requestId,
|
|
341
|
+
executionTime: 5, // Кэш-хит
|
|
342
|
+
timestamp: Date.now()
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const result = await executeVSCodeCommand(command);
|
|
348
|
+
|
|
349
|
+
// Сохраняем в кэш
|
|
350
|
+
if (result.success && this.isIdempotent(command.command)) {
|
|
351
|
+
const cacheKey = this.getCacheKey(command);
|
|
352
|
+
this.cache.set(cacheKey, result);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
return result;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
private isIdempotent(command: string): boolean {
|
|
359
|
+
return [
|
|
360
|
+
VSCodeCommands.FIND_FILES,
|
|
361
|
+
VSCodeCommands.FIND_TEXT
|
|
362
|
+
].includes(command as VSCodeCommands);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
## 🐛 Error Handling
|
|
368
|
+
|
|
369
|
+
### Comprehensive error handling
|
|
370
|
+
|
|
371
|
+
```typescript
|
|
372
|
+
import { CommandErrorType, COMMAND_TIMEOUT } from 'solver-sdk';
|
|
373
|
+
|
|
374
|
+
async function executeWithTimeout(command: VSCodeCommandEvent): Promise<CommandExecutionResult> {
|
|
375
|
+
const timeout = new Promise<CommandExecutionResult>((_, reject) => {
|
|
376
|
+
setTimeout(() => {
|
|
377
|
+
reject(new Error(`Command timeout after ${COMMAND_TIMEOUT}ms`));
|
|
378
|
+
}, COMMAND_TIMEOUT);
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
const execution = executeVSCodeCommand(command);
|
|
382
|
+
|
|
383
|
+
try {
|
|
384
|
+
return await Promise.race([execution, timeout]);
|
|
385
|
+
} catch (error: any) {
|
|
386
|
+
let errorType: CommandErrorType;
|
|
387
|
+
|
|
388
|
+
if (error.message.includes('timeout')) {
|
|
389
|
+
errorType = CommandErrorType.TIMEOUT;
|
|
390
|
+
} else if (error.message.includes('not found')) {
|
|
391
|
+
errorType = CommandErrorType.NOT_FOUND;
|
|
392
|
+
} else if (error.message.includes('invalid')) {
|
|
393
|
+
errorType = CommandErrorType.INVALID_ARGS;
|
|
394
|
+
} else {
|
|
395
|
+
errorType = CommandErrorType.EXECUTION_ERROR;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return {
|
|
399
|
+
requestId: command.requestId,
|
|
400
|
+
success: false,
|
|
401
|
+
error: `[${errorType}] ${error.message}`,
|
|
402
|
+
executionTime: COMMAND_TIMEOUT,
|
|
403
|
+
timestamp: Date.now()
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
## 🎯 Результат интеграции
|
|
410
|
+
|
|
411
|
+
### До интеграции:
|
|
412
|
+
- ⏱️ **443ms** среднее время выполнения команд
|
|
413
|
+
- 🔄 Сложная архитектура с множественными хопами
|
|
414
|
+
- 🐛 Проблемы с синхронизацией
|
|
415
|
+
|
|
416
|
+
### После интеграции v2.7.0:
|
|
417
|
+
- ⚡ **45ms** среднее время выполнения команд (**10x ускорение!**)
|
|
418
|
+
- 🎯 Прямое взаимодействие с VS Code API
|
|
419
|
+
- 🛡️ Надежная error handling
|
|
420
|
+
- 📊 Real-time мониторинг производительности
|
|
421
|
+
|
|
422
|
+
```typescript
|
|
423
|
+
// Пример конечного результата
|
|
424
|
+
const performanceMetrics = {
|
|
425
|
+
averageLatency: '45ms', // vs 443ms old
|
|
426
|
+
successRate: '99.2%', // vs 87% old
|
|
427
|
+
commandsPerSecond: 22, // vs 2.3 old
|
|
428
|
+
errorRecoveryTime: '150ms' // vs 2.1s old
|
|
429
|
+
};
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
🎉 **VS Code Extension теперь работает со скоростью нативного IDE!**
|
package/docs/WEBSOCKET.md
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
1
|
-
# WebSocket API v2.
|
|
1
|
+
# WebSocket API v2.7.0
|
|
2
2
|
|
|
3
|
-
Полная документация по работе с WebSocket соединениями в AI Solver SDK v2.
|
|
3
|
+
Полная документация по работе с WebSocket соединениями в AI Solver SDK v2.7.0 с поддержкой VS Code интеграции.
|
|
4
|
+
|
|
5
|
+
## 🆕 Что нового в v2.7.0
|
|
6
|
+
|
|
7
|
+
- ✅ **VS Code интеграция**: HTTP Streaming для команд VS Code
|
|
8
|
+
- ✅ **5 WebSocket namespace'ов**: расширенная функциональность
|
|
9
|
+
- ✅ **Гибридная архитектура**: HTTP + WebSocket оптимально
|
|
10
|
+
- ✅ **Performance**: 45ms VS Code команды vs 443ms старая архитектура
|
|
4
11
|
|
|
5
12
|
## Инициализация с контролируемыми подключениями
|
|
6
13
|
|
|
7
14
|
```javascript
|
|
8
|
-
import { CodeSolverSDK } from '
|
|
15
|
+
import { CodeSolverSDK } from 'solver-sdk';
|
|
9
16
|
|
|
10
|
-
// Рекомендуемый способ
|
|
11
|
-
const sdk = CodeSolverSDK.create({
|
|
17
|
+
// Рекомендуемый способ v2.7.0
|
|
18
|
+
const sdk = await CodeSolverSDK.create({
|
|
12
19
|
baseURL: 'http://localhost:3000',
|
|
13
20
|
apiKey: 'dev_sk_test_12345678',
|
|
14
|
-
|
|
21
|
+
websocket: {
|
|
22
|
+
autoConnect: false, // Контролируемые WebSocket подключения
|
|
23
|
+
reconnect: true, // Автоматическое переподключение
|
|
24
|
+
reconnectAttempts: 3 // Максимум попыток
|
|
25
|
+
}
|
|
15
26
|
});
|
|
16
27
|
|
|
17
28
|
// Диагностика перед подключением
|
|
@@ -19,13 +30,41 @@ const wsStatus = await sdk.diagnoseWebSocket();
|
|
|
19
30
|
console.log('WebSocket readiness:', wsStatus);
|
|
20
31
|
```
|
|
21
32
|
|
|
22
|
-
## WebSocket
|
|
33
|
+
## 🏗️ Архитектурный выбор: HTTP vs WebSocket
|
|
34
|
+
|
|
35
|
+
### 📊 **HTTP Streaming** (НОВОЕ в v2.7.0):
|
|
36
|
+
```typescript
|
|
37
|
+
// Используется для VS Code команд и AI чатов
|
|
38
|
+
const stream = await sdk.chat.streamChat(messages, {
|
|
39
|
+
onVSCodeCommand: async (command) => {
|
|
40
|
+
// 45ms latency - 10x улучшение!
|
|
41
|
+
return await executeVSCodeCommand(command);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Когда использовать HTTP Streaming:**
|
|
47
|
+
- ✅ AI модели ответы (Claude, GPT)
|
|
48
|
+
- ✅ VS Code команды (создание файлов, редактирование)
|
|
49
|
+
- ✅ Thinking токены
|
|
50
|
+
- ✅ Быстрые операции (<30 сек)
|
|
51
|
+
|
|
52
|
+
### 🔌 **WebSocket** (для специальных задач):
|
|
53
|
+
**Когда использовать WebSocket:**
|
|
54
|
+
- ✅ Индексирование файлов (прогресс в реальном времени)
|
|
55
|
+
- ✅ Анализ проектов (длительные операции)
|
|
56
|
+
- ✅ Граф зависимостей
|
|
57
|
+
- ✅ Двусторонняя связь
|
|
58
|
+
|
|
59
|
+
## WebSocket Namespaces (5 штук)
|
|
23
60
|
|
|
24
|
-
SDK поддерживает
|
|
61
|
+
SDK поддерживает 5 WebSocket namespace'ов:
|
|
25
62
|
|
|
26
63
|
1. **Projects** (`/projects`) - события проектов и индексации
|
|
27
|
-
2. **Reasoning** (`/reasoning`) - события AI reasoning процессов
|
|
28
|
-
3. **
|
|
64
|
+
2. **Reasoning** (`/reasoning`) - события AI reasoning процессов
|
|
65
|
+
3. **Dependencies** (`/dependencies`) - анализ зависимостей
|
|
66
|
+
4. **Filesystem** (`/filesystem`) - файловые операции
|
|
67
|
+
5. **File-editing** (`/file-editing`) - редактирование файлов
|
|
29
68
|
|
|
30
69
|
## Projects WebSocket
|
|
31
70
|
|