agentic-flow 1.2.7 → 1.3.1

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.
Files changed (31) hide show
  1. package/README.md +53 -3
  2. package/dist/agents/claudeAgent.js +19 -1
  3. package/dist/agents/directApiAgent.js +1 -1
  4. package/dist/cli/claude-code-wrapper.js +11 -2
  5. package/dist/cli-proxy.js +111 -12
  6. package/dist/cli-standalone-proxy.js +1 -1
  7. package/dist/proxy/anthropic-to-openrouter.js +184 -94
  8. package/dist/proxy/anthropic-to-requesty.js +627 -0
  9. package/dist/proxy/tool-emulation.js +365 -0
  10. package/dist/utils/modelCapabilities.js +276 -0
  11. package/docs/plans/agent-booster/00-INDEX.md +230 -0
  12. package/docs/plans/agent-booster/00-OVERVIEW.md +454 -0
  13. package/docs/plans/agent-booster/01-ARCHITECTURE.md +699 -0
  14. package/docs/plans/agent-booster/02-INTEGRATION.md +771 -0
  15. package/docs/plans/agent-booster/03-BENCHMARKS.md +616 -0
  16. package/docs/plans/agent-booster/04-NPM-SDK.md +673 -0
  17. package/docs/plans/agent-booster/GITHUB-ISSUE.md +523 -0
  18. package/docs/plans/agent-booster/README.md +576 -0
  19. package/docs/plans/requesty/00-overview.md +176 -0
  20. package/docs/plans/requesty/01-api-research.md +573 -0
  21. package/docs/plans/requesty/02-architecture.md +1076 -0
  22. package/docs/plans/requesty/03-implementation-phases.md +1129 -0
  23. package/docs/plans/requesty/04-testing-strategy.md +905 -0
  24. package/docs/plans/requesty/05-migration-guide.md +576 -0
  25. package/docs/plans/requesty/README.md +290 -0
  26. package/package.json +1 -1
  27. package/dist/agents/sdkAgent.js +0 -151
  28. package/dist/examples/parallel-swarm-deployment.js +0 -171
  29. package/dist/utils/.claude-flow/metrics/agent-metrics.json +0 -1
  30. package/dist/utils/.claude-flow/metrics/performance.json +0 -9
  31. package/dist/utils/.claude-flow/metrics/task-metrics.json +0 -10
@@ -0,0 +1,771 @@
1
+ # Agent Booster: Integration Guide
2
+
3
+ ## 🔌 Agentic-Flow Integration
4
+
5
+ ### Overview
6
+
7
+ Agent Booster integrates seamlessly with agentic-flow as an **optional performance accelerator** for code editing operations. When enabled, it replaces slow LLM-based code application with ultra-fast vector-based semantic merging.
8
+
9
+ ### Integration Strategy
10
+
11
+ ```
12
+ ┌─────────────────────────────────────────────────────────────┐
13
+ │ Agentic-Flow Agent │
14
+ │ │
15
+ │ Agent receives task: "Add error handling to parseConfig" │
16
+ └────────────────────┬────────────────────────────────────────┘
17
+
18
+
19
+ ┌─────────────────────────────────────────────────────────────┐
20
+ │ Tool: edit_file (Enhanced) │
21
+ │ │
22
+ │ Check: AGENT_BOOSTER_ENABLED? │
23
+ └────────┬───────────────────────────────────┬────────────────┘
24
+ │ YES │ NO
25
+ ▼ ▼
26
+ ┌────────────────────────┐ ┌──────────────────────────────┐
27
+ │ Agent Booster │ │ Original Behavior │
28
+ │ (30ms, $0) │ │ (LLM rewrite or API) │
29
+ │ │ │ (6000ms, $0.01) │
30
+ │ ├─ Parse AST │ │ │
31
+ │ ├─ Vector search │ │ ├─ Full file rewrite │
32
+ │ ├─ Smart merge │ │ │ or │
33
+ │ └─ Validate │ │ └─ Morph LLM API call │
34
+ │ │ │ │
35
+ │ Confidence >= 65%? │ │ │
36
+ │ ├─ YES: Return result │ │ │
37
+ │ └─ NO: Fallback to → │────┘ │
38
+ └────────────────────────┘ │
39
+ │ │
40
+ └─────────────────────────────────────────────────────┘
41
+
42
+
43
+ ┌────────────────┐
44
+ │ Final Result │
45
+ └────────────────┘
46
+ ```
47
+
48
+ ### Environment Variables
49
+
50
+ ```bash
51
+ # .env
52
+
53
+ # ═══════════════════════════════════════════════════════════
54
+ # Agent Booster Configuration
55
+ # ═══════════════════════════════════════════════════════════
56
+
57
+ # Enable Agent Booster for code edits (default: false)
58
+ AGENT_BOOSTER_ENABLED=true
59
+
60
+ # Embedding model to use
61
+ # Options: jina-code-v2 (best), all-MiniLM-L6-v2 (fast)
62
+ # Default: jina-code-v2
63
+ AGENT_BOOSTER_MODEL=jina-code-v2
64
+
65
+ # Confidence threshold (0.0 - 1.0)
66
+ # If confidence < threshold, fallback to LLM
67
+ # Default: 0.65
68
+ AGENT_BOOSTER_CONFIDENCE_THRESHOLD=0.65
69
+
70
+ # Enable fallback to Morph LLM when confidence is low
71
+ # Default: true
72
+ AGENT_BOOSTER_FALLBACK_TO_MORPH=true
73
+
74
+ # Morph API key for fallback (optional)
75
+ MORPH_API_KEY=sk-morph-xxx
76
+
77
+ # Model cache directory (optional)
78
+ # Default: ~/.cache/agent-booster
79
+ AGENT_BOOSTER_CACHE_DIR=/path/to/cache
80
+
81
+ # Enable debug logging (default: false)
82
+ AGENT_BOOSTER_DEBUG=false
83
+
84
+ # Maximum number of chunks to extract per file (default: 100)
85
+ AGENT_BOOSTER_MAX_CHUNKS=100
86
+
87
+ # Enable embedding caching (default: true)
88
+ AGENT_BOOSTER_CACHE_EMBEDDINGS=true
89
+ ```
90
+
91
+ ### Tool Implementation
92
+
93
+ #### Enhanced `edit_file` Tool
94
+
95
+ ```typescript
96
+ // src/tools/edit-file.ts
97
+
98
+ import { AgentBooster } from 'agent-booster';
99
+ import { readFileSync, writeFileSync } from 'fs';
100
+
101
+ let booster: AgentBooster | null = null;
102
+
103
+ // Initialize on first use
104
+ function getBooster(): AgentBooster | null {
105
+ if (process.env.AGENT_BOOSTER_ENABLED !== 'true') {
106
+ return null;
107
+ }
108
+
109
+ if (!booster) {
110
+ booster = new AgentBooster({
111
+ model: process.env.AGENT_BOOSTER_MODEL || 'jina-code-v2',
112
+ confidenceThreshold: parseFloat(
113
+ process.env.AGENT_BOOSTER_CONFIDENCE_THRESHOLD || '0.65'
114
+ ),
115
+ fallbackToMorph: process.env.AGENT_BOOSTER_FALLBACK_TO_MORPH === 'true',
116
+ morphApiKey: process.env.MORPH_API_KEY,
117
+ debug: process.env.AGENT_BOOSTER_DEBUG === 'true',
118
+ });
119
+ }
120
+
121
+ return booster;
122
+ }
123
+
124
+ export const editFileTool = {
125
+ name: 'edit_file',
126
+ description: 'Apply semantic code edits to files',
127
+ parameters: {
128
+ type: 'object',
129
+ properties: {
130
+ file_path: {
131
+ type: 'string',
132
+ description: 'Path to the file to edit',
133
+ },
134
+ edit_description: {
135
+ type: 'string',
136
+ description: 'Description of the edit to apply',
137
+ },
138
+ language: {
139
+ type: 'string',
140
+ enum: ['javascript', 'typescript', 'python', 'rust'],
141
+ description: 'Programming language',
142
+ },
143
+ },
144
+ required: ['file_path', 'edit_description'],
145
+ },
146
+
147
+ async execute(params: {
148
+ file_path: string;
149
+ edit_description: string;
150
+ language?: string;
151
+ }) {
152
+ const { file_path, edit_description, language } = params;
153
+
154
+ // Read original file
155
+ const originalCode = readFileSync(file_path, 'utf-8');
156
+
157
+ // Try Agent Booster first if enabled
158
+ const booster = getBooster();
159
+ if (booster) {
160
+ try {
161
+ const result = await booster.applyEdit({
162
+ originalCode,
163
+ editSnippet: edit_description,
164
+ language: language || detectLanguage(file_path),
165
+ });
166
+
167
+ // Check confidence
168
+ if (result.confidence >= booster.config.confidenceThreshold) {
169
+ // High confidence - use Agent Booster result
170
+ writeFileSync(file_path, result.mergedCode, 'utf-8');
171
+
172
+ return {
173
+ success: true,
174
+ method: 'agent-booster',
175
+ confidence: result.confidence,
176
+ strategy: result.strategy,
177
+ latency_ms: result.metadata.latency_ms,
178
+ cost: 0,
179
+ message: `Applied edit using Agent Booster (${result.strategy}, confidence: ${(result.confidence * 100).toFixed(1)}%)`,
180
+ };
181
+ } else {
182
+ // Low confidence - fallback
183
+ console.log(
184
+ `Agent Booster confidence too low (${(result.confidence * 100).toFixed(1)}%), falling back to LLM`
185
+ );
186
+ }
187
+ } catch (error) {
188
+ console.error('Agent Booster failed, falling back to LLM:', error);
189
+ }
190
+ }
191
+
192
+ // Fallback to original behavior (LLM-based)
193
+ return fallbackToLLM(originalCode, edit_description, file_path);
194
+ },
195
+ };
196
+
197
+ // Fallback to LLM-based editing
198
+ async function fallbackToLLM(
199
+ originalCode: string,
200
+ editDescription: string,
201
+ filePath: string
202
+ ) {
203
+ // Option 1: Use Morph LLM API
204
+ if (process.env.MORPH_API_KEY) {
205
+ const startTime = Date.now();
206
+ const response = await fetch('https://api.morphllm.com/v1/chat/completions', {
207
+ method: 'POST',
208
+ headers: {
209
+ 'Authorization': `Bearer ${process.env.MORPH_API_KEY}`,
210
+ 'Content-Type': 'application/json',
211
+ },
212
+ body: JSON.stringify({
213
+ model: 'morph-v3-large',
214
+ messages: [{
215
+ role: 'user',
216
+ content: `<instruction>${editDescription}</instruction>\n<code>${originalCode}</code>\n<update>Apply the edit</update>`,
217
+ }],
218
+ }),
219
+ });
220
+
221
+ const data = await response.json();
222
+ const mergedCode = data.choices[0].message.content;
223
+ const latency = Date.now() - startTime;
224
+
225
+ writeFileSync(filePath, mergedCode, 'utf-8');
226
+
227
+ return {
228
+ success: true,
229
+ method: 'morph-llm',
230
+ latency_ms: latency,
231
+ cost: estimateCost(originalCode, mergedCode),
232
+ message: `Applied edit using Morph LLM API`,
233
+ };
234
+ }
235
+
236
+ // Option 2: Use main LLM to rewrite file
237
+ // (existing implementation)
238
+ return existingEditFileImplementation(originalCode, editDescription, filePath);
239
+ }
240
+
241
+ function detectLanguage(filePath: string): string {
242
+ const ext = filePath.split('.').pop();
243
+ const langMap: Record<string, string> = {
244
+ 'js': 'javascript',
245
+ 'jsx': 'javascript',
246
+ 'ts': 'typescript',
247
+ 'tsx': 'typescript',
248
+ 'py': 'python',
249
+ 'rs': 'rust',
250
+ 'go': 'go',
251
+ 'java': 'java',
252
+ };
253
+ return langMap[ext || ''] || 'javascript';
254
+ }
255
+
256
+ function estimateCost(original: string, merged: string): number {
257
+ const tokens = (original.length + merged.length) / 4;
258
+ return (tokens / 1000) * 0.003; // Rough estimate
259
+ }
260
+ ```
261
+
262
+ ### CLI Integration
263
+
264
+ ```typescript
265
+ // src/cli/commands/edit.ts
266
+
267
+ import { Command } from 'commander';
268
+ import { AgentBooster } from 'agent-booster';
269
+ import { readFileSync, writeFileSync } from 'fs';
270
+
271
+ export const editCommand = new Command('edit')
272
+ .description('Apply code edits using Agent Booster')
273
+ .argument('<file>', 'File to edit')
274
+ .argument('<description>', 'Edit description')
275
+ .option('--model <model>', 'Embedding model', 'jina-code-v2')
276
+ .option('--threshold <threshold>', 'Confidence threshold', '0.65')
277
+ .option('--fallback', 'Fallback to Morph LLM if confidence low', false)
278
+ .option('--dry-run', 'Show result without writing', false)
279
+ .action(async (file: string, description: string, options) => {
280
+ console.log(`📝 Editing ${file}...`);
281
+ console.log(`📋 Edit: ${description}\n`);
282
+
283
+ const booster = new AgentBooster({
284
+ model: options.model,
285
+ confidenceThreshold: parseFloat(options.threshold),
286
+ fallbackToMorph: options.fallback,
287
+ });
288
+
289
+ const originalCode = readFileSync(file, 'utf-8');
290
+ const startTime = Date.now();
291
+
292
+ try {
293
+ const result = await booster.applyEdit({
294
+ originalCode,
295
+ editSnippet: description,
296
+ language: detectLanguage(file),
297
+ });
298
+
299
+ const latency = Date.now() - startTime;
300
+
301
+ // Display results
302
+ console.log(`✅ Success!`);
303
+ console.log(` Strategy: ${result.strategy}`);
304
+ console.log(` Confidence: ${(result.confidence * 100).toFixed(1)}%`);
305
+ console.log(` Latency: ${latency}ms`);
306
+ console.log(` Cost: $0.00\n`);
307
+
308
+ if (result.confidence < parseFloat(options.threshold)) {
309
+ console.log(`⚠️ Warning: Low confidence (${(result.confidence * 100).toFixed(1)}%)`);
310
+ console.log(` Consider using --fallback for better accuracy\n`);
311
+ }
312
+
313
+ if (options.dryRun) {
314
+ console.log('Dry run - no changes written\n');
315
+ console.log('Preview:');
316
+ console.log('─'.repeat(80));
317
+ console.log(result.mergedCode);
318
+ console.log('─'.repeat(80));
319
+ } else {
320
+ writeFileSync(file, result.mergedCode, 'utf-8');
321
+ console.log(`💾 Saved to ${file}`);
322
+ }
323
+ } catch (error) {
324
+ console.error(`❌ Error: ${error.message}`);
325
+ process.exit(1);
326
+ }
327
+ });
328
+ ```
329
+
330
+ ### Configuration Presets
331
+
332
+ ```typescript
333
+ // src/config/agent-booster-presets.ts
334
+
335
+ export const presets = {
336
+ // Maximum speed, acceptable accuracy
337
+ fast: {
338
+ model: 'all-MiniLM-L6-v2',
339
+ confidenceThreshold: 0.60,
340
+ fallbackToMorph: false,
341
+ cacheEmbeddings: true,
342
+ },
343
+
344
+ // Balanced speed and accuracy (recommended)
345
+ balanced: {
346
+ model: 'jina-code-v2',
347
+ confidenceThreshold: 0.65,
348
+ fallbackToMorph: true,
349
+ cacheEmbeddings: true,
350
+ },
351
+
352
+ // Maximum accuracy
353
+ accurate: {
354
+ model: 'jina-code-v2',
355
+ confidenceThreshold: 0.75,
356
+ fallbackToMorph: true,
357
+ cacheEmbeddings: false, // Always fresh
358
+ },
359
+
360
+ // Offline mode (no fallback)
361
+ offline: {
362
+ model: 'jina-code-v2',
363
+ confidenceThreshold: 0.50, // More lenient
364
+ fallbackToMorph: false,
365
+ cacheEmbeddings: true,
366
+ },
367
+ };
368
+
369
+ // Usage in .env
370
+ // AGENT_BOOSTER_PRESET=balanced
371
+ ```
372
+
373
+ ### Metrics & Monitoring
374
+
375
+ ```typescript
376
+ // src/utils/agent-booster-metrics.ts
377
+
378
+ interface EditMetrics {
379
+ method: 'agent-booster' | 'morph-llm' | 'llm-rewrite';
380
+ latency_ms: number;
381
+ confidence?: number;
382
+ strategy?: string;
383
+ cost: number;
384
+ success: boolean;
385
+ timestamp: Date;
386
+ }
387
+
388
+ class MetricsCollector {
389
+ private metrics: EditMetrics[] = [];
390
+
391
+ record(metric: EditMetrics) {
392
+ this.metrics.push(metric);
393
+
394
+ // Optionally log to file
395
+ if (process.env.AGENT_BOOSTER_METRICS_FILE) {
396
+ appendFileSync(
397
+ process.env.AGENT_BOOSTER_METRICS_FILE,
398
+ JSON.stringify(metric) + '\n'
399
+ );
400
+ }
401
+ }
402
+
403
+ getSummary() {
404
+ const total = this.metrics.length;
405
+ const boosterEdits = this.metrics.filter(m => m.method === 'agent-booster');
406
+ const morphEdits = this.metrics.filter(m => m.method === 'morph-llm');
407
+
408
+ return {
409
+ total_edits: total,
410
+ agent_booster_usage: `${((boosterEdits.length / total) * 100).toFixed(1)}%`,
411
+ avg_latency_booster: average(boosterEdits.map(m => m.latency_ms)),
412
+ avg_latency_morph: average(morphEdits.map(m => m.latency_ms)),
413
+ total_cost_saved: morphEdits.length * 0.01, // Estimated
414
+ avg_confidence: average(boosterEdits.map(m => m.confidence || 0)),
415
+ };
416
+ }
417
+ }
418
+
419
+ export const metricsCollector = new MetricsCollector();
420
+ ```
421
+
422
+ ### Usage Example
423
+
424
+ ```typescript
425
+ // examples/agentic-flow-with-agent-booster.ts
426
+
427
+ import { AgenticFlow } from 'agentic-flow';
428
+ import { editFileTool } from './tools/edit-file';
429
+
430
+ // Configure via .env
431
+ // AGENT_BOOSTER_ENABLED=true
432
+ // AGENT_BOOSTER_MODEL=jina-code-v2
433
+ // AGENT_BOOSTER_CONFIDENCE_THRESHOLD=0.65
434
+ // AGENT_BOOSTER_FALLBACK_TO_MORPH=true
435
+
436
+ const agent = new AgenticFlow({
437
+ model: 'claude-sonnet-4',
438
+ tools: [editFileTool],
439
+ systemPrompt: `You are a code refactoring assistant.
440
+ Use the edit_file tool to apply code changes.`,
441
+ });
442
+
443
+ // Agent will automatically use Agent Booster for fast edits
444
+ const result = await agent.run({
445
+ task: 'Add error handling to all functions in src/utils/parser.ts',
446
+ });
447
+
448
+ console.log(result);
449
+
450
+ // Check metrics
451
+ import { metricsCollector } from './utils/agent-booster-metrics';
452
+ console.log('\nPerformance Summary:');
453
+ console.log(metricsCollector.getSummary());
454
+ ```
455
+
456
+ ---
457
+
458
+ ## 🖥️ Model Context Protocol (MCP) Server
459
+
460
+ ### Overview
461
+
462
+ Agent Booster provides a full-featured MCP server that enables seamless integration with MCP clients like Claude Desktop, Cursor, VS Code, and other AI assistants with workspace detection.
463
+
464
+ ### MCP Server Architecture
465
+
466
+ ```
467
+ ┌─────────────────────────────────────────────────────────────┐
468
+ │ MCP Client │
469
+ │ (Claude Desktop / Cursor / VS Code) │
470
+ └────────────────────┬────────────────────────────────────────┘
471
+ │ MCP Protocol (stdio/HTTP)
472
+
473
+ ┌─────────────────────────────────────────────────────────────┐
474
+ │ Agent Booster MCP Server │
475
+ │ │
476
+ │ Tools Exposed: │
477
+ │ ├─ agent_booster_apply (Apply single edit) │
478
+ │ ├─ agent_booster_batch (Batch edits) │
479
+ │ ├─ agent_booster_analyze (Analyze workspace) │
480
+ │ └─ agent_booster_status (Server status) │
481
+ │ │
482
+ │ Resources: │
483
+ │ └─ agent_booster://metrics (Usage metrics) │
484
+ └────────────────────┬────────────────────────────────────────┘
485
+
486
+
487
+ ┌─────────────────────────────────────────────────────────────┐
488
+ │ Agent Booster Core │
489
+ │ (Rust library via native addon) │
490
+ └─────────────────────────────────────────────────────────────┘
491
+ ```
492
+
493
+ ### Starting the MCP Server
494
+
495
+ ```bash
496
+ # Start stdio server (for Claude Desktop, etc.)
497
+ npx agent-booster mcp
498
+
499
+ # Start HTTP server
500
+ npx agent-booster mcp --http --port 3000
501
+
502
+ # With custom config
503
+ npx agent-booster mcp --config ./agent-booster.json
504
+ ```
505
+
506
+ ### MCP Client Configuration
507
+
508
+ #### Claude Desktop
509
+
510
+ ```json
511
+ // ~/Library/Application Support/Claude/claude_desktop_config.json
512
+ {
513
+ "mcpServers": {
514
+ "agent-booster": {
515
+ "command": "npx",
516
+ "args": ["agent-booster", "mcp"],
517
+ "env": {
518
+ "AGENT_BOOSTER_MODEL": "jina-code-v2",
519
+ "AGENT_BOOSTER_CONFIDENCE_THRESHOLD": "0.65"
520
+ }
521
+ }
522
+ }
523
+ }
524
+ ```
525
+
526
+ #### Cursor
527
+
528
+ ```json
529
+ // .cursor/mcp.json
530
+ {
531
+ "mcpServers": {
532
+ "agent-booster": {
533
+ "command": "npx",
534
+ "args": ["agent-booster", "mcp"],
535
+ "cwd": "${workspaceFolder}"
536
+ }
537
+ }
538
+ }
539
+ ```
540
+
541
+ #### VS Code (via MCP Extension)
542
+
543
+ ```json
544
+ // .vscode/mcp.json
545
+ {
546
+ "servers": {
547
+ "agent-booster": {
548
+ "command": "npx agent-booster mcp",
549
+ "workspaceDetection": true
550
+ }
551
+ }
552
+ }
553
+ ```
554
+
555
+ ### MCP Tools
556
+
557
+ #### 1. `agent_booster_apply`
558
+
559
+ Apply a single code edit to a file.
560
+
561
+ ```json
562
+ {
563
+ "name": "agent_booster_apply",
564
+ "description": "Apply semantic code edit using vector similarity (200x faster than LLM)",
565
+ "inputSchema": {
566
+ "type": "object",
567
+ "properties": {
568
+ "file_path": {
569
+ "type": "string",
570
+ "description": "Relative path to file from workspace root"
571
+ },
572
+ "edit_description": {
573
+ "type": "string",
574
+ "description": "Description of the edit to apply"
575
+ },
576
+ "language": {
577
+ "type": "string",
578
+ "enum": ["javascript", "typescript", "python", "rust", "go"],
579
+ "description": "Programming language (auto-detected if omitted)"
580
+ }
581
+ },
582
+ "required": ["file_path", "edit_description"]
583
+ }
584
+ }
585
+ ```
586
+
587
+ **Example Usage (Claude Desktop):**
588
+
589
+ ```
590
+ User: Add error handling to the parseConfig function in src/utils/config.ts
591
+
592
+ Claude: I'll use agent_booster_apply to add error handling.
593
+
594
+ [Calls agent_booster_apply with:
595
+ file_path: "src/utils/config.ts"
596
+ edit_description: "add try-catch error handling to parseConfig function"]
597
+
598
+ Response: {
599
+ "success": true,
600
+ "confidence": 0.92,
601
+ "strategy": "exact_replace",
602
+ "latency_ms": 35,
603
+ "cost": 0
604
+ }
605
+
606
+ Claude: I've successfully added error handling to the parseConfig function
607
+ with 92% confidence in 35ms at zero cost!
608
+ ```
609
+
610
+ #### 2. `agent_booster_batch`
611
+
612
+ Apply multiple edits in parallel.
613
+
614
+ ```json
615
+ {
616
+ "name": "agent_booster_batch",
617
+ "description": "Apply multiple code edits in parallel (up to 10x faster)",
618
+ "inputSchema": {
619
+ "type": "object",
620
+ "properties": {
621
+ "edits": {
622
+ "type": "array",
623
+ "items": {
624
+ "type": "object",
625
+ "properties": {
626
+ "file_path": { "type": "string" },
627
+ "edit_description": { "type": "string" }
628
+ }
629
+ },
630
+ "maxItems": 100
631
+ }
632
+ },
633
+ "required": ["edits"]
634
+ }
635
+ }
636
+ ```
637
+
638
+ #### 3. `agent_booster_analyze`
639
+
640
+ Analyze workspace for optimization opportunities.
641
+
642
+ ```json
643
+ {
644
+ "name": "agent_booster_analyze",
645
+ "description": "Analyze workspace to identify files suitable for Agent Booster",
646
+ "inputSchema": {
647
+ "type": "object",
648
+ "properties": {
649
+ "path": {
650
+ "type": "string",
651
+ "description": "Path to analyze (default: workspace root)"
652
+ },
653
+ "include_metrics": {
654
+ "type": "boolean",
655
+ "description": "Include detailed metrics",
656
+ "default": true
657
+ }
658
+ }
659
+ }
660
+ }
661
+ ```
662
+
663
+ #### 4. `agent_booster_status`
664
+
665
+ Get server status and configuration.
666
+
667
+ ```json
668
+ {
669
+ "name": "agent_booster_status",
670
+ "description": "Get Agent Booster server status and metrics",
671
+ "inputSchema": {
672
+ "type": "object",
673
+ "properties": {}
674
+ }
675
+ }
676
+ ```
677
+
678
+ ### MCP Resources
679
+
680
+ #### Metrics Resource
681
+
682
+ ```
683
+ agent_booster://metrics
684
+ ```
685
+
686
+ Returns JSON with usage statistics:
687
+
688
+ ```json
689
+ {
690
+ "total_edits": 1247,
691
+ "agent_booster_usage": "82.3%",
692
+ "morph_fallback_usage": "17.7%",
693
+ "avg_latency_booster_ms": 38,
694
+ "avg_latency_morph_ms": 5420,
695
+ "total_cost_saved_usd": 22.14,
696
+ "avg_confidence": 0.87,
697
+ "uptime_hours": 12.4
698
+ }
699
+ ```
700
+
701
+ ### Workspace Detection
702
+
703
+ Agent Booster MCP server automatically detects workspace roots by looking for:
704
+
705
+ - `.git/` directory
706
+ - `package.json`
707
+ - `Cargo.toml`
708
+ - `.agent-booster.json` config file
709
+
710
+ Files are resolved relative to the detected workspace root.
711
+
712
+ ### Performance Comparison (MCP Context)
713
+
714
+ ```
715
+ Traditional MCP Flow (without Agent Booster):
716
+
717
+ User request: "Add logging to 10 functions"
718
+
719
+ Claude analyzes workspace (5s)
720
+
721
+ For each function:
722
+ ├─ Read file (100ms)
723
+ ├─ Generate edit via LLM (6000ms)
724
+ ├─ Apply edit (100ms)
725
+ └─ Write file (50ms)
726
+ Total per file: ~6250ms
727
+
728
+ Total time: 10 files × 6250ms = 62.5 seconds
729
+ Total cost: 10 × $0.01 = $0.10
730
+
731
+ ═════════════════════════════════════════════════════
732
+
733
+ Agent Booster MCP Flow:
734
+
735
+ User request: "Add logging to 10 functions"
736
+
737
+ Claude analyzes workspace (5s)
738
+
739
+ Calls agent_booster_batch with 10 edits:
740
+ ├─ Parse all files in parallel (200ms)
741
+ ├─ Generate embeddings in parallel (400ms)
742
+ ├─ Apply all merges in parallel (300ms)
743
+ └─ Validate all files in parallel (100ms)
744
+ Total: ~1000ms = 1 second
745
+
746
+ Total time: 6 seconds (5s analysis + 1s edits)
747
+ Total cost: $0.00
748
+
749
+ Speedup: 10x faster
750
+ Savings: $0.10 (100%)
751
+ ```
752
+
753
+ ---
754
+
755
+ ## 📊 Metrics Dashboard
756
+
757
+ Optional web dashboard for monitoring Agent Booster usage:
758
+
759
+ ```bash
760
+ # Start metrics dashboard
761
+ npx agent-booster dashboard --port 8080
762
+ ```
763
+
764
+ View at `http://localhost:8080`:
765
+
766
+ - Real-time edit metrics
767
+ - Cost savings calculator
768
+ - Performance graphs
769
+ - Confidence distribution
770
+ - Language breakdown
771
+ - Failure analysis