agentic-flow 1.3.0 → 1.4.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 +87 -12
- package/dist/agents/claudeAgent.js +96 -67
- package/dist/cli/claude-code-wrapper.js +23 -1
- package/dist/cli-proxy.js +71 -5
- package/dist/mcp/standalone-stdio.js +251 -2
- package/dist/proxy/anthropic-to-requesty.js +707 -0
- package/dist/utils/cli.js +6 -0
- package/dist/utils/modelCapabilities.js +22 -0
- package/docs/plans/agent-booster/00-INDEX.md +230 -0
- package/docs/plans/agent-booster/00-OVERVIEW.md +454 -0
- package/docs/plans/agent-booster/01-ARCHITECTURE.md +699 -0
- package/docs/plans/agent-booster/02-INTEGRATION.md +771 -0
- package/docs/plans/agent-booster/03-BENCHMARKS.md +616 -0
- package/docs/plans/agent-booster/04-NPM-SDK.md +673 -0
- package/docs/plans/agent-booster/GITHUB-ISSUE.md +523 -0
- package/docs/plans/agent-booster/README.md +576 -0
- package/docs/plans/requesty/00-overview.md +176 -0
- package/docs/plans/requesty/01-api-research.md +573 -0
- package/docs/plans/requesty/02-architecture.md +1076 -0
- package/docs/plans/requesty/03-implementation-phases.md +1129 -0
- package/docs/plans/requesty/04-testing-strategy.md +905 -0
- package/docs/plans/requesty/05-migration-guide.md +576 -0
- package/docs/plans/requesty/README.md +290 -0
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { FastMCP } from 'fastmcp';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { execSync } from 'child_process';
|
|
6
|
+
import { resolve } from 'path';
|
|
6
7
|
// Suppress FastMCP internal warnings for cleaner output
|
|
7
8
|
const originalConsoleWarn = console.warn;
|
|
8
9
|
console.warn = (...args) => {
|
|
@@ -290,14 +291,262 @@ server.addTool({
|
|
|
290
291
|
}
|
|
291
292
|
}
|
|
292
293
|
});
|
|
293
|
-
|
|
294
|
+
// ========================================
|
|
295
|
+
// Agent Booster Tools (352x faster code editing)
|
|
296
|
+
// ========================================
|
|
297
|
+
// Tool: Apply code edit with Agent Booster
|
|
298
|
+
server.addTool({
|
|
299
|
+
name: 'agent_booster_edit_file',
|
|
300
|
+
description: 'Ultra-fast code editing (352x faster than cloud APIs, $0 cost). Apply precise code edits using Agent Booster\'s local WASM engine. Use "// ... existing code ..." markers for unchanged sections.',
|
|
301
|
+
parameters: z.object({
|
|
302
|
+
target_filepath: z.string().describe('Path of the file to modify'),
|
|
303
|
+
instructions: z.string().describe('First-person instruction (e.g., "I will add error handling")'),
|
|
304
|
+
code_edit: z.string().describe('Precise code lines to edit, using "// ... existing code ..." for unchanged sections'),
|
|
305
|
+
language: z.string().optional().describe('Programming language (auto-detected from file extension if not provided)')
|
|
306
|
+
}),
|
|
307
|
+
execute: async ({ target_filepath, instructions, code_edit, language }) => {
|
|
308
|
+
try {
|
|
309
|
+
const fs = await import('fs');
|
|
310
|
+
const path = await import('path');
|
|
311
|
+
// Read current file
|
|
312
|
+
if (!fs.existsSync(target_filepath)) {
|
|
313
|
+
throw new Error(`File not found: ${target_filepath}`);
|
|
314
|
+
}
|
|
315
|
+
const originalCode = fs.readFileSync(target_filepath, 'utf-8');
|
|
316
|
+
// Detect language if not provided
|
|
317
|
+
if (!language) {
|
|
318
|
+
const ext = path.extname(target_filepath).slice(1);
|
|
319
|
+
const langMap = {
|
|
320
|
+
'ts': 'typescript', 'js': 'javascript', 'py': 'python',
|
|
321
|
+
'rs': 'rust', 'go': 'go', 'java': 'java',
|
|
322
|
+
'c': 'c', 'cpp': 'cpp', 'h': 'c', 'hpp': 'cpp'
|
|
323
|
+
};
|
|
324
|
+
language = langMap[ext] || 'javascript';
|
|
325
|
+
}
|
|
326
|
+
// Apply edit using agent-booster CLI directly (local WASM, 0-1ms)
|
|
327
|
+
const agentBoosterCli = resolve(__dirname, '../../../agent-booster/dist/cli.js');
|
|
328
|
+
const cmd = `node ${agentBoosterCli} apply --language ${language}`;
|
|
329
|
+
const result = execSync(cmd, {
|
|
330
|
+
encoding: 'utf-8',
|
|
331
|
+
input: JSON.stringify({ code: originalCode, edit: code_edit }),
|
|
332
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
333
|
+
timeout: 5000,
|
|
334
|
+
cwd: resolve(__dirname, '../../../agent-booster')
|
|
335
|
+
});
|
|
336
|
+
const parsed = JSON.parse(result);
|
|
337
|
+
if (parsed.success && parsed.confidence >= 0.7) {
|
|
338
|
+
// High confidence - use Agent Booster result
|
|
339
|
+
fs.writeFileSync(target_filepath, parsed.output);
|
|
340
|
+
return JSON.stringify({
|
|
341
|
+
success: true,
|
|
342
|
+
method: 'agent_booster',
|
|
343
|
+
filepath: target_filepath,
|
|
344
|
+
instruction: instructions,
|
|
345
|
+
latency_ms: parsed.latency,
|
|
346
|
+
confidence: (parsed.confidence * 100).toFixed(1) + '%',
|
|
347
|
+
strategy: parsed.strategy,
|
|
348
|
+
message: `✅ Successfully edited ${target_filepath} (${parsed.latency}ms, ${(parsed.confidence * 100).toFixed(1)}% confidence)`
|
|
349
|
+
}, null, 2);
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
// Low confidence - fall back to LLM for complex edits
|
|
353
|
+
const confidencePercent = (parsed.confidence * 100).toFixed(1);
|
|
354
|
+
return JSON.stringify({
|
|
355
|
+
success: false,
|
|
356
|
+
method: 'agent_booster_failed',
|
|
357
|
+
filepath: target_filepath,
|
|
358
|
+
confidence: confidencePercent + '%',
|
|
359
|
+
fallback_required: true,
|
|
360
|
+
message: `⚠️ Agent Booster confidence too low (${confidencePercent}%). Falling back to LLM for complex edit.`,
|
|
361
|
+
suggestion: `Use agentic_flow_agent with task: "Apply this edit to ${target_filepath}: ${instructions}. Original code: ${originalCode.substring(0, 500)}... Target edit: ${code_edit.substring(0, 500)}..."`,
|
|
362
|
+
llm_fallback: {
|
|
363
|
+
tool: 'agentic_flow_agent',
|
|
364
|
+
agent: 'coder',
|
|
365
|
+
task: `Apply code edit to ${target_filepath}:\n\nInstructions: ${instructions}\n\nOriginal code:\n${originalCode}\n\nTarget edit:\n${code_edit}`,
|
|
366
|
+
reason: `Agent Booster pattern matching failed (${confidencePercent}% confidence). This edit requires LLM reasoning for: structural changes, complex logic, or vague instructions.`
|
|
367
|
+
}
|
|
368
|
+
}, null, 2);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
catch (error) {
|
|
372
|
+
throw new Error(`Failed to edit file: ${error.message}`);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
// Tool: Batch apply multiple edits
|
|
377
|
+
server.addTool({
|
|
378
|
+
name: 'agent_booster_batch_edit',
|
|
379
|
+
description: 'Apply multiple code edits in a single operation (ultra-fast batch processing). Perfect for multi-file refactoring.',
|
|
380
|
+
parameters: z.object({
|
|
381
|
+
edits: z.array(z.object({
|
|
382
|
+
target_filepath: z.string().describe('File path'),
|
|
383
|
+
instructions: z.string().describe('First-person instruction'),
|
|
384
|
+
code_edit: z.string().describe('Code edit with markers'),
|
|
385
|
+
language: z.string().optional().describe('Programming language')
|
|
386
|
+
})).describe('Array of edit requests')
|
|
387
|
+
}),
|
|
388
|
+
execute: async ({ edits }) => {
|
|
389
|
+
try {
|
|
390
|
+
const fs = await import('fs');
|
|
391
|
+
const path = await import('path');
|
|
392
|
+
const results = [];
|
|
393
|
+
let totalLatency = 0;
|
|
394
|
+
for (const edit of edits) {
|
|
395
|
+
const originalCode = fs.existsSync(edit.target_filepath)
|
|
396
|
+
? fs.readFileSync(edit.target_filepath, 'utf-8')
|
|
397
|
+
: '';
|
|
398
|
+
// Detect language
|
|
399
|
+
let language = edit.language;
|
|
400
|
+
if (!language) {
|
|
401
|
+
const ext = path.extname(edit.target_filepath).slice(1);
|
|
402
|
+
const langMap = {
|
|
403
|
+
'ts': 'typescript', 'js': 'javascript', 'py': 'python',
|
|
404
|
+
'rs': 'rust', 'go': 'go', 'java': 'java',
|
|
405
|
+
'c': 'c', 'cpp': 'cpp', 'h': 'c', 'hpp': 'cpp'
|
|
406
|
+
};
|
|
407
|
+
language = langMap[ext] || 'javascript';
|
|
408
|
+
}
|
|
409
|
+
// Apply edit
|
|
410
|
+
const cmd = `npx --yes agent-booster apply --language ${language}`;
|
|
411
|
+
const result = execSync(cmd, {
|
|
412
|
+
encoding: 'utf-8',
|
|
413
|
+
input: JSON.stringify({ code: originalCode, edit: edit.code_edit }),
|
|
414
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
415
|
+
timeout: 5000
|
|
416
|
+
});
|
|
417
|
+
const parsed = JSON.parse(result);
|
|
418
|
+
totalLatency += parsed.latency;
|
|
419
|
+
if (parsed.success && parsed.confidence >= 0.7) {
|
|
420
|
+
fs.writeFileSync(edit.target_filepath, parsed.output);
|
|
421
|
+
results.push({
|
|
422
|
+
file: edit.target_filepath,
|
|
423
|
+
success: true,
|
|
424
|
+
latency_ms: parsed.latency,
|
|
425
|
+
confidence: (parsed.confidence * 100).toFixed(1) + '%'
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
results.push({
|
|
430
|
+
file: edit.target_filepath,
|
|
431
|
+
success: false,
|
|
432
|
+
confidence: (parsed.confidence * 100).toFixed(1) + '%',
|
|
433
|
+
reason: 'Low confidence'
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
const successful = results.filter(r => r.success).length;
|
|
438
|
+
return JSON.stringify({
|
|
439
|
+
success: true,
|
|
440
|
+
total: edits.length,
|
|
441
|
+
successful,
|
|
442
|
+
failed: edits.length - successful,
|
|
443
|
+
total_latency_ms: totalLatency,
|
|
444
|
+
avg_latency_ms: (totalLatency / edits.length).toFixed(1),
|
|
445
|
+
results,
|
|
446
|
+
performance_note: `Agent Booster: ${totalLatency}ms total vs Morph LLM: ~${edits.length * 352}ms (${((edits.length * 352) / totalLatency).toFixed(1)}x faster)`
|
|
447
|
+
}, null, 2);
|
|
448
|
+
}
|
|
449
|
+
catch (error) {
|
|
450
|
+
throw new Error(`Batch edit failed: ${error.message}`);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
// Tool: Parse markdown code blocks and apply edits
|
|
455
|
+
server.addTool({
|
|
456
|
+
name: 'agent_booster_parse_markdown',
|
|
457
|
+
description: 'Parse markdown code blocks with filepath= and instruction= metadata, then apply all edits. Compatible with LLM-generated multi-file refactoring outputs.',
|
|
458
|
+
parameters: z.object({
|
|
459
|
+
markdown: z.string().describe('Markdown text containing code blocks with filepath= and instruction= metadata')
|
|
460
|
+
}),
|
|
461
|
+
execute: async ({ markdown }) => {
|
|
462
|
+
try {
|
|
463
|
+
const fs = await import('fs');
|
|
464
|
+
const path = await import('path');
|
|
465
|
+
// Parse markdown code blocks
|
|
466
|
+
const regex = /```(?:(\w+))?\s*filepath=([^\s]+)\s+instruction=([^\n]+)\n([\s\S]*?)```/g;
|
|
467
|
+
const edits = [];
|
|
468
|
+
let match;
|
|
469
|
+
while ((match = regex.exec(markdown)) !== null) {
|
|
470
|
+
const [_, language, filepath, instruction, code_edit] = match;
|
|
471
|
+
edits.push({
|
|
472
|
+
target_filepath: filepath.trim(),
|
|
473
|
+
instructions: instruction.trim(),
|
|
474
|
+
code_edit: code_edit.trim(),
|
|
475
|
+
language: language || undefined
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
if (edits.length === 0) {
|
|
479
|
+
throw new Error('No code blocks found in markdown. Expected format: ```language filepath=path instruction=description\\ncode\\n```');
|
|
480
|
+
}
|
|
481
|
+
// Apply all edits using batch tool
|
|
482
|
+
const results = [];
|
|
483
|
+
let totalLatency = 0;
|
|
484
|
+
for (const edit of edits) {
|
|
485
|
+
const originalCode = fs.existsSync(edit.target_filepath)
|
|
486
|
+
? fs.readFileSync(edit.target_filepath, 'utf-8')
|
|
487
|
+
: '';
|
|
488
|
+
let language = edit.language;
|
|
489
|
+
if (!language) {
|
|
490
|
+
const ext = path.extname(edit.target_filepath).slice(1);
|
|
491
|
+
const langMap = {
|
|
492
|
+
'ts': 'typescript', 'js': 'javascript', 'py': 'python',
|
|
493
|
+
'rs': 'rust', 'go': 'go', 'java': 'java',
|
|
494
|
+
'c': 'c', 'cpp': 'cpp', 'h': 'c', 'hpp': 'cpp'
|
|
495
|
+
};
|
|
496
|
+
language = langMap[ext] || 'javascript';
|
|
497
|
+
}
|
|
498
|
+
const cmd = `npx --yes agent-booster apply --language ${language}`;
|
|
499
|
+
const result = execSync(cmd, {
|
|
500
|
+
encoding: 'utf-8',
|
|
501
|
+
input: JSON.stringify({ code: originalCode, edit: edit.code_edit }),
|
|
502
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
503
|
+
timeout: 5000
|
|
504
|
+
});
|
|
505
|
+
const parsed = JSON.parse(result);
|
|
506
|
+
totalLatency += parsed.latency;
|
|
507
|
+
if (parsed.success && parsed.confidence >= 0.7) {
|
|
508
|
+
fs.writeFileSync(edit.target_filepath, parsed.output);
|
|
509
|
+
results.push({
|
|
510
|
+
file: edit.target_filepath,
|
|
511
|
+
instruction: edit.instructions,
|
|
512
|
+
success: true,
|
|
513
|
+
latency_ms: parsed.latency
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
else {
|
|
517
|
+
results.push({
|
|
518
|
+
file: edit.target_filepath,
|
|
519
|
+
success: false,
|
|
520
|
+
confidence: (parsed.confidence * 100).toFixed(1) + '%'
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
const successful = results.filter(r => r.success).length;
|
|
525
|
+
return JSON.stringify({
|
|
526
|
+
success: true,
|
|
527
|
+
parsed_edits: edits.length,
|
|
528
|
+
successful,
|
|
529
|
+
failed: edits.length - successful,
|
|
530
|
+
total_latency_ms: totalLatency,
|
|
531
|
+
results
|
|
532
|
+
}, null, 2);
|
|
533
|
+
}
|
|
534
|
+
catch (error) {
|
|
535
|
+
throw new Error(`Failed to parse and apply markdown edits: ${error.message}`);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
});
|
|
539
|
+
console.error('✅ Registered 10 tools (7 agentic-flow + 3 agent-booster):');
|
|
294
540
|
console.error(' • agentic_flow_agent (execute agent with 13 parameters)');
|
|
295
541
|
console.error(' • agentic_flow_list_agents (list 66+ agents)');
|
|
296
542
|
console.error(' • agentic_flow_create_agent (create custom agent)');
|
|
297
543
|
console.error(' • agentic_flow_list_all_agents (list with sources)');
|
|
298
544
|
console.error(' • agentic_flow_agent_info (get agent details)');
|
|
299
545
|
console.error(' • agentic_flow_check_conflicts (conflict detection)');
|
|
300
|
-
console.error(' • agentic_flow_optimize_model (auto-select best model)
|
|
546
|
+
console.error(' • agentic_flow_optimize_model (auto-select best model)');
|
|
547
|
+
console.error(' • agent_booster_edit_file (352x faster code editing) ⚡ NEW');
|
|
548
|
+
console.error(' • agent_booster_batch_edit (multi-file refactoring) ⚡ NEW');
|
|
549
|
+
console.error(' • agent_booster_parse_markdown (LLM output parsing) ⚡ NEW');
|
|
301
550
|
console.error('🔌 Starting stdio transport...');
|
|
302
551
|
server.start({ transportType: 'stdio' }).then(() => {
|
|
303
552
|
console.error('✅ Agentic-Flow MCP server running on stdio');
|