Reorganize tool definitions into granular domain modules

**New structure:**
src/tools/definitions/
├── mod.rs         # Aggregates all 43 tools
├── system.rs      # 3 tools: healthcheck, verify_setup, list_symbols
├── experts.rs     # 4 tools: compile_ea, list_experts, list_indicators, list_scripts
├── backtest.rs    # 4 tools: run_backtest, get_backtest_status, cache_status, clean_cache
├── optimization.rs # 4 tools: run_optimization, get_optimization_status, get_optimization_results, list_jobs
├── analytics.rs   # 9 tools: analyze_report + 8 granular analytics
├── reports.rs     # 11 tools: list_reports, search_reports, get_latest_report, etc.
├── setfiles.rs    # 8 tools: read/write/patch/clone/diff set files
└── baseline.rs    # 1 tool: compare_baseline

**Benefits:**
- Domain-based organization (21KB monolith -> 9 focused files)
- Each domain can evolve independently
- Easier to find and modify tool definitions
- Clear separation between system, experts, backtest, optimization, analytics, reports, setfiles
This commit is contained in:
Devid HW
2026-04-19 02:25:25 +07:00
parent 1f63505cb9
commit bc5d0d7022
10 changed files with 703 additions and 693 deletions
+150
View File
@@ -0,0 +1,150 @@
use serde_json::{json, Value};
pub fn tool_get_latest_report() -> Value {
json!({
"name": "get_latest_report",
"description": "Get the latest backtest report with full details and equity chart image",
"inputSchema": {
"type": "object",
"properties": {
"include_chart": { "type": "boolean", "description": "Include equity chart as base64 PNG (default: true)", "default": true }
}
}
})
}
pub fn tool_list_reports() -> Value {
json!({
"name": "list_reports",
"description": "List most recent backtest reports from the central registry (SQLite). Returns id, metrics, set file, chart paths.",
"inputSchema": {
"type": "object",
"properties": {
"limit": { "type": "integer", "description": "Max results (default 30)" }
}
}
})
}
pub fn tool_search_reports() -> Value {
json!({
"name": "search_reports",
"description": "Search backtest history with filters. All filters are optional and combinable.",
"inputSchema": {
"type": "object",
"properties": {
"expert": { "type": "string", "description": "EA name substring match" },
"symbol": { "type": "string", "description": "Exact symbol, e.g. XAUUSD" },
"timeframe": { "type": "string", "description": "Exact timeframe, e.g. M5" },
"after": { "type": "string", "description": "ISO8601 date — only reports created after this" },
"min_profit": { "type": "number", "description": "Minimum net profit" },
"max_dd": { "type": "number", "description": "Maximum drawdown %" },
"verdict": { "type": "string", "description": "Only reports with this verdict (pass, fail, marginal)" },
"limit": { "type": "integer", "default": 50 }
}
}
})
}
pub fn tool_tail_log() -> Value {
json!({
"name": "tail_log",
"description": "Stream the last N lines of a job log",
"inputSchema": {
"type": "object",
"properties": {
"job_id": { "type": "string" },
"file": { "type": "string" },
"lines": { "type": "integer", "default": 50 }
}
}
})
}
pub fn tool_archive_report() -> Value {
json!({
"name": "archive_report",
"description": "Compress a backtest report directory to tar.gz",
"inputSchema": {
"type": "object",
"required": ["report_dir"],
"properties": {
"report_dir": { "type": "string" },
"delete_after": { "type": "boolean" }
}
}
})
}
pub fn tool_archive_all_reports() -> Value {
json!({
"name": "archive_all_reports",
"description": "Archive all old reports except the N most recent",
"inputSchema": {
"type": "object",
"properties": {
"keep_last": { "type": "integer" }
}
}
})
}
pub fn tool_get_history() -> Value {
json!({
"name": "get_history",
"description": "Retrieve backtest history for an EA or symbol",
"inputSchema": {
"type": "object",
"properties": {
"ea": { "type": "string" },
"symbol": { "type": "string" },
"verdict": { "type": "string" },
"limit": { "type": "integer" }
}
}
})
}
pub fn tool_promote_to_baseline() -> Value {
json!({
"name": "promote_to_baseline",
"description": "Copy report metrics to config/baseline.json for future comparisons",
"inputSchema": {
"type": "object",
"required": ["report_dir"],
"properties": {
"report_dir": { "type": "string" }
}
}
})
}
pub fn tool_annotate_history() -> Value {
json!({
"name": "annotate_history",
"description": "Add notes, tags or verdict to a history entry",
"inputSchema": {
"type": "object",
"required": ["history_id"],
"properties": {
"history_id": { "type": "string" },
"notes": { "type": "string" },
"tags": { "type": "array", "items": { "type": "string" } },
"verdict": { "type": "string", "enum": ["pass", "fail", "marginal"] }
}
}
})
}
pub fn tool_prune_reports() -> Value {
json!({
"name": "prune_reports",
"description": "Delete old backtest report directories",
"inputSchema": {
"type": "object",
"properties": {
"keep_last": { "type": "integer" }
}
}
})
}