Add get_latest_report tool with equity chart support

**New Tool: get_latest_report**
- Returns the most recent backtest report from the database
- Includes full report details: metrics, paths, tags, notes, verdict
- Optional include_chart parameter (default: true)
- Returns equity chart as base64 PNG when available

**Implementation:**
- ReportDb.get_latest(): Query for most recent report by created_at DESC
- handle_get_latest_report(): Fetches report and reads equity.png from charts_dir
- Base64 encoding using base64 crate v0.22
- Graceful handling when chart not found (equity_chart_error field)

**Files Changed:**
- storage/database.rs: Added get_latest() method
- tools/definitions.rs: Added tool_get_latest_report() definition
- tools/handlers/mod.rs: Added dispatch for get_latest_report
- tools/handlers/reports.rs: Implemented handler with base64 chart encoding
- Cargo.toml: Added base64 = 0.22 dependency
This commit is contained in:
Devid HW
2026-04-19 01:56:41 +07:00
parent 13e821bc5d
commit e94ec8153d
6 changed files with 159 additions and 0 deletions
+1
View File
@@ -62,6 +62,7 @@ impl ToolHandler {
"list_set_files" => setfiles::handle_list_set_files(&self.config).await,
// Report handlers
"get_latest_report" => reports::handle_get_latest_report(&self.config, args).await,
"list_reports" => reports::handle_list_reports(args).await,
"search_reports" => reports::handle_search_reports(args).await,
"prune_reports" => reports::handle_prune_reports(&self.config, args).await,