MCPcopy Create free account
hub / github.com/github/gh-aw / parseClaudeLog

Function parseClaudeLog

actions/setup/js/parse_claude_log.cjs:17–103  ·  view source on GitHub ↗

* Parses Claude log content and converts it to markdown format * @param {string} logContent - The raw log content as a string * @returns {{markdown: string, mcpFailures: string[], maxTurnsHit: boolean, logEntries: Array}} Result with formatted markdown content, MCP failure list, max-turns status,

(logContent)

Source from the content-addressed store, hash-verified

15 * @returns {{markdown: string, mcpFailures: string[], maxTurnsHit: boolean, logEntries: Array}} Result with formatted markdown content, MCP failure list, max-turns status, and parsed log entries
16 */
17function parseClaudeLog(logContent) {
18 // Use shared parseLogEntries function
19 const logEntries = parseLogEntries(logContent);
20
21 if (!logEntries) {
22 return {
23 markdown: "## Agent Log Summary\n\nLog format not recognized as Claude JSON array or JSONL.\n",
24 mcpFailures: [],
25 maxTurnsHit: false,
26 logEntries: [],
27 };
28 }
29
30 const mcpFailures = [];
31
32 // Generate conversation markdown using shared function
33 const canonicalLogEntries = convertLegacyLogEntriesToCopilotEvents(logEntries, { sourceEngine: "claude" });
34 const conversationResult = generateConversationMarkdown(canonicalLogEntries, {
35 formatToolCallback: (toolUse, toolResult) => formatToolUse(toolUse, toolResult, { includeDetailedParameters: false }),
36 formatInitCallback: initEntry => {
37 const result = formatInitializationSummary(initEntry, {
38 includeSlashCommands: true,
39 mcpFailureCallback: server => {
40 // Display detailed error information for failed MCP servers (Claude-specific)
41 const errorDetails = [];
42
43 if (server.error) {
44 errorDetails.push(`**Error:** ${server.error}`);
45 }
46
47 if (server.stderr) {
48 // Truncate stderr if too long
49 const maxStderrLength = 500;
50 const stderr = server.stderr.length > maxStderrLength ? server.stderr.substring(0, maxStderrLength) + "..." : server.stderr;
51 errorDetails.push(`**Stderr:** \`${stderr}\``);
52 }
53
54 if (server.exitCode !== undefined && server.exitCode !== null) {
55 errorDetails.push(`**Exit Code:** ${server.exitCode}`);
56 }
57
58 if (server.command) {
59 errorDetails.push(`**Command:** \`${server.command}\``);
60 }
61
62 if (server.message) {
63 errorDetails.push(`**Message:** ${server.message}`);
64 }
65
66 if (server.reason) {
67 errorDetails.push(`**Reason:** ${server.reason}`);
68 }
69
70 // Return formatted error details with proper indentation
71 if (errorDetails.length > 0) {
72 return errorDetails.map(detail => ` - ${detail}\n`).join("");
73 }
74 return "";

Callers 1

Calls 6

parseLogEntriesFunction · 0.85
formatToolUseFunction · 0.85

Tested by

no test coverage detected