Returns a high-level project overview as a text resource.
(&self, id: Value)
| 2244 | |
| 2245 | /// Returns a high-level project overview as a text resource. |
| 2246 | async fn read_resource_overview(&self, id: Value) -> JsonRpcResponse { |
| 2247 | let cg = self.cg_snapshot().await; |
| 2248 | let stats = match cg.get_stats().await { |
| 2249 | Ok(s) => s, |
| 2250 | Err(e) => { |
| 2251 | return JsonRpcResponse::error( |
| 2252 | id, |
| 2253 | ErrorCode::InternalError, |
| 2254 | format!("failed to read graph stats: {e}"), |
| 2255 | ); |
| 2256 | } |
| 2257 | }; |
| 2258 | |
| 2259 | let mut lines = Vec::new(); |
| 2260 | lines.push(format!("Project: {}", cg.project_root().display())); |
| 2261 | lines.push(format!( |
| 2262 | "Graph: {} nodes, {} edges, {} files", |
| 2263 | stats.node_count, stats.edge_count, stats.file_count |
| 2264 | )); |
| 2265 | |
| 2266 | // Language distribution |
| 2267 | if !stats.files_by_language.is_empty() { |
| 2268 | lines.push("\nLanguages:".to_string()); |
| 2269 | let mut langs: Vec<_> = stats.files_by_language.iter().collect(); |
| 2270 | langs.sort_by(|a, b| b.1.cmp(a.1)); |
| 2271 | for (lang, count) in &langs { |
| 2272 | lines.push(format!(" {lang} ({count} files)")); |
| 2273 | } |
| 2274 | } |
| 2275 | |
| 2276 | // Node kind distribution (top 10) |
| 2277 | if !stats.nodes_by_kind.is_empty() { |
| 2278 | lines.push("\nSymbol kinds:".to_string()); |
| 2279 | let mut kinds: Vec<_> = stats.nodes_by_kind.iter().collect(); |
| 2280 | kinds.sort_by(|a, b| b.1.cmp(a.1)); |
| 2281 | for (kind, count) in kinds.iter().take(10) { |
| 2282 | lines.push(format!(" {kind} ({count})")); |
| 2283 | } |
| 2284 | } |
| 2285 | |
| 2286 | let text = lines.join("\n"); |
| 2287 | JsonRpcResponse::success( |
| 2288 | id, |
| 2289 | json!({ |
| 2290 | "contents": [{ |
| 2291 | "uri": "tracedecay://overview", |
| 2292 | "mimeType": "text/plain", |
| 2293 | "text": text |
| 2294 | }] |
| 2295 | }), |
| 2296 | ) |
| 2297 | } |
| 2298 | |
| 2299 | async fn read_resource_branches(&self, id: Value) -> JsonRpcResponse { |
| 2300 | let cg = self.cg_snapshot().await; |
no test coverage detected