* Formats initialization information from system init entry * @param {any} initEntry - The system init entry containing tools, mcp_servers, etc. * @param {Object} options - Configuration options * @param {Function} [options.mcpFailureCallback] - Optional callback for tracking MCP failures (server
(initEntry, options = {})
| 404 | * @returns {{markdown: string, mcpFailures?: string[]}} Result with formatted markdown string and optional MCP failure list |
| 405 | */ |
| 406 | function formatInitializationSummary(initEntry, options = {}) { |
| 407 | const { mcpFailureCallback, modelInfoCallback, includeSlashCommands = false } = options; |
| 408 | let markdown = ""; |
| 409 | const mcpFailures = []; |
| 410 | |
| 411 | // Display model and session info |
| 412 | if (initEntry.model) { |
| 413 | markdown += `**Model:** ${initEntry.model}\n\n`; |
| 414 | } |
| 415 | |
| 416 | // Call model info callback for engine-specific model information (e.g., Copilot premium info) |
| 417 | if (modelInfoCallback) { |
| 418 | const modelInfo = modelInfoCallback(initEntry); |
| 419 | if (modelInfo) { |
| 420 | markdown += modelInfo; |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | if (initEntry.session_id) { |
| 425 | markdown += `**Session ID:** ${initEntry.session_id}\n\n`; |
| 426 | } |
| 427 | |
| 428 | if (initEntry.cwd) { |
| 429 | // Show a cleaner path by removing common prefixes |
| 430 | const cleanCwd = initEntry.cwd.replace(/^\/home\/runner\/work\/[^\/]+\/[^\/]+/, "."); |
| 431 | markdown += `**Working Directory:** ${cleanCwd}\n\n`; |
| 432 | } |
| 433 | |
| 434 | // Display MCP servers status |
| 435 | if (initEntry.mcp_servers && Array.isArray(initEntry.mcp_servers)) { |
| 436 | markdown += "**MCP Servers:**\n"; |
| 437 | for (const server of initEntry.mcp_servers) { |
| 438 | const statusIcon = server.status === "connected" ? "✅" : server.status === "failed" ? "❌" : "❓"; |
| 439 | markdown += `- ${statusIcon} ${server.name} (${server.status})\n`; |
| 440 | |
| 441 | // Track failed MCP servers - call callback if provided (for Claude's detailed error tracking) |
| 442 | if (server.status === "failed") { |
| 443 | mcpFailures.push(server.name); |
| 444 | |
| 445 | // Call callback to allow engine-specific failure handling |
| 446 | if (mcpFailureCallback) { |
| 447 | const failureDetails = mcpFailureCallback(server); |
| 448 | if (failureDetails) { |
| 449 | markdown += failureDetails; |
| 450 | } |
| 451 | } |
| 452 | } |
| 453 | } |
| 454 | markdown += "\n"; |
| 455 | } |
| 456 | |
| 457 | // Display tools by category |
| 458 | if (initEntry.tools && Array.isArray(initEntry.tools)) { |
| 459 | markdown += "**Available Tools:**\n"; |
| 460 | |
| 461 | // Categorize tools with improved groupings |
| 462 | /** @type {{ [key: string]: string[] }} */ |
| 463 | const categories = { |
no test coverage detected