@@ -4,7 +4,7 @@ import path from "path";
44
55describe ( "parse_copilot_log.cjs" , ( ) => {
66 let mockCore , originalConsole , originalProcess ;
7- let main , parseCopilotLog , extractWireRequestToolResults ;
7+ let main , parseCopilotLog ;
88
99 beforeEach ( async ( ) => {
1010 originalConsole = global . console ;
@@ -45,7 +45,6 @@ describe("parse_copilot_log.cjs", () => {
4545 const module = await import ( "./parse_copilot_log.cjs?" + Date . now ( ) ) ;
4646 main = module . main ;
4747 parseCopilotLog = module . parseCopilotLog ;
48- extractWireRequestToolResults = module . extractWireRequestToolResults ;
4948 } ) ;
5049
5150 afterEach ( ( ) => {
@@ -125,6 +124,20 @@ describe("parse_copilot_log.cjs", () => {
125124 expect ( resultData ?. numTurns ) . toBe ( 1 ) ;
126125 } ) ;
127126
127+ it ( "renders tool output preview from result.content in Copilot CLI events.jsonl" , ( ) => {
128+ const eventsLog = [
129+ '{"type":"user.message","timestamp":"2026-06-05T00:44:01.367Z","data":{}}' ,
130+ '{"type":"tool.execution_start","timestamp":"2026-06-05T00:44:04.520Z","data":{"toolName":"bash","mcpServerName":""}}' ,
131+ '{"type":"tool.execution_complete","timestamp":"2026-06-05T00:44:04.700Z","data":{"toolName":"bash","mcpServerName":"","success":true,"result":{"content":"file1.txt\\nfile2.txt\\nfile3.txt"}}}' ,
132+ '{"type":"assistant.message","timestamp":"2026-06-05T00:44:59.769Z","data":{"content":"Done"}}' ,
133+ ] . join ( "\n" ) ;
134+
135+ const result = parseCopilotLog ( eventsLog ) ;
136+
137+ expect ( result . markdown ) . toContain ( "bash" ) ;
138+ expect ( result . markdown ) . toContain ( "file1.txt" ) ;
139+ } ) ;
140+
128141 it ( "should handle tool calls with details in HTML format" , ( ) => {
129142 const logWithHtmlDetails = JSON . stringify ( [
130143 { type : "system" , subtype : "init" , session_id : "html-test" , tools : [ "Bash" ] , model : "gpt-5" } ,
@@ -503,126 +516,4 @@ describe("parse_copilot_log.cjs", () => {
503516 expect ( result . markdown ) . toContain ( "safe_outputs::create_issue" ) ;
504517 } ) ;
505518 } ) ;
506-
507- describe ( "extractWireRequestToolResults function" , ( ) => {
508- it ( "should extract tool results from Wire request blocks" , ( ) => {
509- const lines = [
510- "2026-06-18T16:00:00.000Z [DEBUG] Wire request: {" ,
511- ' "messages": [' ,
512- ' { "role": "user", "content": "list files" },' ,
513- " {" ,
514- ' "role": "tool",' ,
515- ' "tool_call_id": "tooluse_abc123",' ,
516- ' "content": "file1.txt\\nfile2.txt\\nfile3.txt"' ,
517- " }" ,
518- " ]" ,
519- "}" ,
520- "2026-06-18T16:00:01.000Z [INFO] Done" ,
521- ] ;
522- const result = extractWireRequestToolResults ( lines ) ;
523- expect ( result . get ( "tooluse_abc123" ) ) . toBe ( "file1.txt\nfile2.txt\nfile3.txt" ) ;
524- } ) ;
525-
526- it ( "should skip non-string content values (e.g. null)" , ( ) => {
527- const lines = [
528- "2026-06-18T16:00:00.000Z [DEBUG] Wire request: {" ,
529- ' "messages": [' ,
530- " {" ,
531- ' "role": "tool",' ,
532- ' "tool_call_id": "tooluse_nullcontent",' ,
533- ' "content": null' ,
534- " }" ,
535- " ]" ,
536- "}" ,
537- "2026-06-18T16:00:01.000Z [INFO] Done" ,
538- ] ;
539- const result = extractWireRequestToolResults ( lines ) ;
540- expect ( result . has ( "tooluse_nullcontent" ) ) . toBe ( false ) ;
541- } ) ;
542-
543- it ( "should only store the first occurrence of a tool_call_id (from earlier Wire request)" , ( ) => {
544- const lines = [
545- // First Wire request: only tool A
546- "2026-06-18T16:00:00.000Z [DEBUG] Wire request: {" ,
547- ' "messages": [' ,
548- " {" ,
549- ' "role": "tool",' ,
550- ' "tool_call_id": "tooluse_A",' ,
551- ' "content": "result A"' ,
552- " }" ,
553- " ]" ,
554- "}" ,
555- // Second Wire request: tool A repeated plus tool B
556- "2026-06-18T16:00:01.000Z [DEBUG] Wire request: {" ,
557- ' "messages": [' ,
558- " {" ,
559- ' "role": "tool",' ,
560- ' "tool_call_id": "tooluse_A",' ,
561- ' "content": "result A again"' ,
562- " }," ,
563- " {" ,
564- ' "role": "tool",' ,
565- ' "tool_call_id": "tooluse_B",' ,
566- ' "content": "result B"' ,
567- " }" ,
568- " ]" ,
569- "}" ,
570- "2026-06-18T16:00:02.000Z [INFO] Done" ,
571- ] ;
572- const result = extractWireRequestToolResults ( lines ) ;
573- expect ( result . get ( "tooluse_A" ) ) . toBe ( "result A" ) ;
574- expect ( result . get ( "tooluse_B" ) ) . toBe ( "result B" ) ;
575- } ) ;
576-
577- it ( "should return an empty map when no Wire request blocks are present" , ( ) => {
578- const lines = [ "2026-06-18T16:00:00.000Z [DEBUG] data:" , "2026-06-18T16:00:00.001Z [DEBUG] {" , ' "choices": []' , "}" , "2026-06-18T16:00:01.000Z [INFO] Done" ] ;
579- const result = extractWireRequestToolResults ( lines ) ;
580- expect ( result . size ) . toBe ( 0 ) ;
581- } ) ;
582- } ) ;
583-
584- describe ( "debug log format tool result previews" , ( ) => {
585- it ( "should show tool output preview lines from Wire request blocks" , ( ) => {
586- const debugLog = [
587- "2026-06-18T16:00:00.000Z [INFO] Starting Copilot CLI: 0.0.412" ,
588- "2026-06-18T16:00:01.000Z [DEBUG] data:" ,
589- "2026-06-18T16:00:01.001Z [DEBUG] {" ,
590- ' "model": "claude-sonnet-4.6",' ,
591- ' "usage": { "prompt_tokens": 100, "completion_tokens": 50 },' ,
592- ' "choices": [' ,
593- " {" ,
594- ' "message": {' ,
595- ' "content": null,' ,
596- ' "tool_calls": [' ,
597- " {" ,
598- ' "id": "tooluse_abc123",' ,
599- ' "type": "function",' ,
600- ' "function": { "name": "bash", "arguments": "{\\"command\\": \\"ls /tmp\\"}" }' ,
601- " }" ,
602- " ]" ,
603- " }" ,
604- " }" ,
605- " ]" ,
606- "}" ,
607- "2026-06-18T16:00:02.000Z [DEBUG] Wire request: {" ,
608- ' "messages": [' ,
609- " {" ,
610- ' "role": "tool",' ,
611- ' "tool_call_id": "tooluse_abc123",' ,
612- ' "content": "file1.txt\\nfile2.txt\\nfile3.txt"' ,
613- " }" ,
614- " ]" ,
615- "}" ,
616- "2026-06-18T16:00:03.000Z [INFO] Done" ,
617- ] . join ( "\n" ) ;
618-
619- const result = parseCopilotLog ( debugLog ) ;
620-
621- // Tool call should be shown
622- expect ( result . markdown ) . toContain ( "ls /tmp" ) ;
623- // Preview lines from Wire request should be shown
624- expect ( result . markdown ) . toContain ( "file1.txt" ) ;
625- expect ( result . markdown ) . toContain ( "file2.txt" ) ;
626- } ) ;
627- } ) ;
628519} ) ;
0 commit comments