### Install Copilot Chat Analyzer Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Install the library using npm. This command is used to add the copilot-chat-analyzer package to your project dependencies. ```bash npm install copilot-chat-analyzer ``` -------------------------------- ### Copilot Chat Analyzer - Quick Start Source: https://github.com/dealenx/copilot-chat-analyzer/blob/main/AI_USAGE.md Demonstrates how to load chat data and perform basic analysis using the CopilotChatAnalyzer library. ```APIDOC ## Quick Start for AI Assistants This section provides a quick start guide for using the `copilot-chat-analyzer` library. ### Usage ```typescript import CopilotChatAnalyzer, { DialogStatus } from "copilot-chat-analyzer"; import { readFileSync } from "fs"; // Load chat data from JSON export const chatData = JSON.parse(readFileSync("chat.json", "utf8")); const analyzer = new CopilotChatAnalyzer(); // Basic analysis const status = analyzer.getDialogStatus(chatData); const requestCount = analyzer.getRequestsCount(chatData); ``` ### Parameters - `chatData` (object) - The parsed JSON data from a GitHub Copilot chat export. ### Returns - `status` (string) - The overall status of the dialog (e.g., 'pending', 'in_progress', 'completed', 'canceled'). - `requestCount` (number) - The total number of requests made in the chat. ``` -------------------------------- ### Copilot Chat Data Structure Example Source: https://github.com/dealenx/copilot-chat-analyzer/blob/main/AI_USAGE.md Illustrates the expected JSON structure for GitHub Copilot chat exports, including requester/responder information and an array of requests. ```typescript { requesterUsername: string, responderUsername: string, requests: Array<{ requestId: string, isCanceled?: boolean, followups?: any[], result?: any, response?: any[] }> } ``` -------------------------------- ### Quick Start: Load and Analyze Copilot Chat Data Source: https://github.com/dealenx/copilot-chat-analyzer/blob/main/AI_USAGE.md Load chat data from a JSON export file and perform basic analysis using CopilotChatAnalyzer. Requires 'copilot-chat-analyzer' and 'fs' modules. ```typescript import CopilotChatAnalyzer, { DialogStatus } from "copilot-chat-analyzer"; import { readFileSync } from "fs"; // Load chat data from JSON export const chatData = JSON.parse(readFileSync("chat.json", "utf8")); const analyzer = new CopilotChatAnalyzer(); // Basic analysis const status = analyzer.getDialogStatus(chatData); const requestCount = analyzer.getRequestsCount(chatData); ``` -------------------------------- ### Extract Session ID and Info Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Use getSessionId to retrieve only the unique session identifier. Use getSessionInfo to get the session ID along with agent and model details. Both functions require chat data as input. ```typescript import CopilotChatAnalyzer from "copilot-chat-analyzer"; const analyzer = new CopilotChatAnalyzer(); const chatData = { requests: [{ requestId: "req-1", result: { metadata: { sessionId: "ff72bca6-0dec-4953-b130-a103a97e5380", agentId: "github.copilot.editsAgent", modelId: "copilot/gemini-2.5-pro" } } }] }; // Get just the session ID const sessionId = analyzer.getSessionId(chatData); console.log(`Session ID: ${sessionId}`); // Output: Session ID: ff72bca6-0dec-4953-b130-a103a97e5380 // Get full session info including agent and model const sessionInfo = analyzer.getSessionInfo(chatData); console.log(sessionInfo); // Output: // { // sessionId: "ff72bca6-0dec-4953-b130-a103a97e5380", // agentId: "github.copilot.editsAgent", // modelId: "copilot/gemini-2.5-pro" // } ``` -------------------------------- ### Get Full Conversation History Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Retrieve the complete conversation history, pairing user requests with their corresponding AI responses. This method is useful for reconstructing and analyzing the flow of a chat. ```typescript import CopilotChatAnalyzer from "copilot-chat-analyzer"; const analyzer = new CopilotChatAnalyzer(); const chatData = { requests: [ { requestId: "req-1", message: { text: "Hello" }, response: [{ value: "Hi there! How can I help?" }] }, { requestId: "req-2", message: { text: "Explain async/await" }, response: [{ value: "Async/await is a syntax for handling promises..." }] } ] }; const history = analyzer.getConversationHistory(chatData); history.forEach(turn => { console.log(`Turn ${turn.index}:`); console.log(` User: ${turn.request.message}`); console.log(` AI: ${turn.response?.message || "(no response yet)"}`); }); ``` -------------------------------- ### Get Dialog Status Details Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Retrieve detailed dialog status information, including flags for results, followups, cancellation, and error details. This method provides a comprehensive overview of the dialog's state and outcome. ```typescript import CopilotChatAnalyzer from "copilot-chat-analyzer"; const analyzer = new CopilotChatAnalyzer(); const chatData = { requests: [{ requestId: "request_962e76d4-743c-490e-9609-c8f65ef52f56", followups: [], result: { timings: { totalElapsed: 59981 } }, isCanceled: false }] }; const details = analyzer.getDialogStatusDetails(chatData); console.log(details); // Output: // { // status: "completed", // statusText: "Dialog completed successfully", // hasResult: true, // hasFollowups: true, // isCanceled: false, // isFailed: false, // lastRequestId: "request_962e76d4-743c-490e-9609-c8f65ef52f56" // } // Example with failed dialog const failedData = { requests: [{ requestId: "req-456", result: { errorDetails: { code: "failed", message: "Sorry, your request failed. Authentication Error." } }, followups: [] }] }; const failedDetails = analyzer.getDialogStatusDetails(failedData); console.log(failedDetails); // Output: // { // status: "failed", // statusText: "Dialog failed with error", // hasResult: true, // hasFollowups: true, // isCanceled: false, // isFailed: true, // lastRequestId: "req-456", // errorCode: "failed", // errorMessage: "Sorry, your request failed. Authentication Error." // } ``` -------------------------------- ### Determine Dialog Status Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Use the getDialogStatus method to determine the current status of a dialog. The status is derived from the last request in the chat data. Examples cover pending, completed, in_progress, canceled, and failed states. ```typescript import CopilotChatAnalyzer, { DialogStatus } from "copilot-chat-analyzer"; const analyzer = new CopilotChatAnalyzer(); // Example: Pending chat (no requests made yet) const pendingChat = { requests: [] }; console.log(analyzer.getDialogStatus(pendingChat)); // Output: "pending" // Example: Completed chat (has empty followups array) const completedChat = { requests: [ { requestId: "req-1", followups: [], result: { data: "..." } } ] }; console.log(analyzer.getDialogStatus(completedChat)); // Output: "completed" // Example: In-progress chat (no followups property) const inProgressChat = { requests: [{ requestId: "req-1", isCanceled: false }] }; console.log(analyzer.getDialogStatus(inProgressChat)); // Output: "in_progress" // Example: Canceled chat const canceledChat = { requests: [{ requestId: "req-1", isCanceled: true }] }; console.log(analyzer.getDialogStatus(canceledChat)); // Output: "canceled" // Example: Failed chat (has errorDetails) const failedChat = { requests: [{ requestId: "req-1", result: { errorDetails: { code: "failed", message: "API error" } }, followups: [] }] }; console.log(analyzer.getDialogStatus(failedChat)); // Output: "failed" // Using DialogStatus constants if (analyzer.getDialogStatus(chatData) === DialogStatus.COMPLETED) { console.log("Dialog finished successfully!"); } ``` -------------------------------- ### CopilotChatAnalyzer Class Initialization and Basic Usage Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Demonstrates how to import and instantiate the CopilotChatAnalyzer class and perform a basic operation like counting requests. ```APIDOC ## CopilotChatAnalyzer Class ### Description The main class for analyzing GitHub Copilot chat exports. Instantiate it once and use its methods to analyze chat data loaded from JSON files. ### Method Instantiation ### Endpoint N/A (Class) ### Parameters None ### Request Example ```typescript import CopilotChatAnalyzer, { DialogStatus } from "copilot-chat-analyzer"; import { readFileSync } from "fs"; // Load exported chat JSON const chatData = JSON.parse(readFileSync("chat.json", "utf8")); // Create analyzer instance const analyzer = new CopilotChatAnalyzer(); // Count total requests in dialog const count = analyzer.getRequestsCount(chatData); console.log(`Total requests: ${count}`); ``` ### Response #### Success Response (Example Output) ``` Total requests: 5 ``` ``` -------------------------------- ### Initialize CopilotChatAnalyzer and Count Requests Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Instantiate the CopilotChatAnalyzer and use its getRequestsCount method to count total requests in a chat data object. Ensure chat data is loaded and parsed from a JSON file. ```typescript import CopilotChatAnalyzer, { DialogStatus } from "copilot-chat-analyzer"; import { readFileSync } from "fs"; // Load exported chat JSON const chatData = JSON.parse(readFileSync("chat.json", "utf8")); // Create analyzer instance const analyzer = new CopilotChatAnalyzer(); // Count total requests in dialog const count = analyzer.getRequestsCount(chatData); console.log(`Total requests: ${count}`); // Output: Total requests: 5 ``` -------------------------------- ### Monitor MCP Tool Usage Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Use getMcpToolMonitoring to track Model Context Protocol (MCP) tool usage. Provide no tool name for an overall summary, or specify a toolName for detailed statistics on that tool. Requires chat data, optionally with a tool name. ```typescript import CopilotChatAnalyzer from "copilot-chat-analyzer"; import { readFileSync } from "fs"; const analyzer = new CopilotChatAnalyzer(); const chatData = JSON.parse(readFileSync("chat_with_mcp.json", "utf8")); // Get summary of all MCP tools used const summary = analyzer.getMcpToolMonitoring(chatData); console.log(summary); // Output: // { // totalTools: 3, // totalCalls: 15, // overallSuccessRate: 86.67, // tools: [ // { toolName: "read_file", totalCalls: 5, successfulCalls: 5, errorCalls: 0, successRate: 100, calls: [...] }, // { toolName: "update_entry_fields", totalCalls: 8, successfulCalls: 6, errorCalls: 2, successRate: 75, calls: [...] }, // { toolName: "search", totalCalls: 2, totalCalls: 2, successfulCalls: 2, errorCalls: 0, successRate: 100, calls: [...] } // ] // } // Get detailed monitoring for a specific tool const toolStats = analyzer.getMcpToolMonitoring(chatData, "update_entry_fields"); console.log(toolStats); // Output: // { // toolName: "update_entry_fields", // totalCalls: 8, // successfulCalls: 6, // errorCalls: 2, // successRate: 75, // calls: [ // { toolId: "...", toolName: "update_entry_fields", requestId: "req-1", input: {...}, output: {...}, isError: false }, // { toolId: "...", toolName: "update_entry_fields", requestId: "req-2", input: {...}, output: null, isError: true }, // ... // ] // } ``` -------------------------------- ### List Unique MCP Tool Names Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Use getMcpToolNames to obtain a list of all distinct Model Context Protocol (MCP) tool names present in the chat data. Requires chat data as input. ```typescript import CopilotChatAnalyzer from "copilot-chat-analyzer"; const analyzer = new CopilotChatAnalyzer(); const toolNames = analyzer.getMcpToolNames(chatData); console.log("MCP Tools used:", toolNames); // Output: MCP Tools used: ["read_file", "update_entry_fields", "search", "write_file"] ``` -------------------------------- ### Copilot Chat Analyzer - Core Methods Source: https://github.com/dealenx/copilot-chat-analyzer/blob/main/AI_USAGE.md Details on the core methods available in the CopilotChatAnalyzer library for analyzing chat data. ```APIDOC ## Core Methods ### getDialogStatus(chatData) #### Description Returns one of four status strings indicating the state of the chat dialog. #### Method `getDialogStatus` #### Parameters - **chatData** (object) - The parsed JSON data from a GitHub Copilot chat export. #### Returns - **status** (string) - One of the following: - `"pending"`: Chat created but no requests made. - `"in_progress"`: Chat has requests but is not completed. - `"completed"`: Chat finished successfully. - `"canceled"`: Chat was canceled. ### getRequestsCount(chatData) #### Description Returns the total number of requests made within the chat. #### Method `getRequestsCount` #### Parameters - **chatData** (object) - The parsed JSON data from a GitHub Copilot chat export. #### Returns - **count** (number) - The number of requests in the chat. ### getDialogStatusDetails(chatData) #### Description Returns a detailed object containing various aspects of the dialog's status. #### Method `getDialogStatusDetails` #### Parameters - **chatData** (object) - The parsed JSON data from a GitHub Copilot chat export. #### Returns - **details** (object) - An object with the following properties: - `status` (string) - The overall dialog status. - `statusText` (string) - A human-readable description of the status. - `hasResult` (boolean) - Indicates if the dialog has a result. - `hasFollowups` (boolean) - Indicates if the dialog has followups. - `isCanceled` (boolean) - Indicates if the dialog was canceled. - `lastRequestId` (string, optional) - The ID of the last request. ### getMcpToolMonitoring(chatData, toolName?) #### Description Monitors Model Context Protocol (MCP) tool usage within the chat. #### Method `getMcpToolMonitoring` #### Parameters - **chatData** (object) - The parsed JSON data from a GitHub Copilot chat export. - **toolName** (string, optional) - The name of a specific tool to monitor. If not provided, a summary of all tools is returned. #### Returns - **monitoringData** (object | object[]) - Summary of all tools or detailed stats for a specific tool. ``` -------------------------------- ### Copilot Chat Analyzer - MCP Tool Analysis Source: https://github.com/dealenx/copilot-chat-analyzer/blob/main/AI_USAGE.md Details on how the library analyzes Model Context Protocol (MCP) tool calls. ```APIDOC ## MCP Tool Analysis The `copilot-chat-analyzer` library can extract and analyze Model Context Protocol (MCP) tool calls made from chat responses. This analysis provides insights into: - **Tool Success Rates**: Percentage of successful tool executions. - **Call Counts**: Number of times each tool was invoked. - **Input/Output Data**: Examination of data passed to and returned from tools. - **Error Tracking**: Identification and tracking of errors during tool execution. ``` -------------------------------- ### Import TypeScript Types Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Import necessary TypeScript types for working with the Copilot Chat Analyzer library. These types help ensure type safety in your project. ```typescript import type { DialogStatusDetails, DialogSession, McpToolCall, McpToolMonitoring, McpMonitoringSummary, UserRequest, AIResponse, ConversationTurn } from "copilot-chat-analyzer"; // DialogStatusType = "pending" | "completed" | "canceled" | "in_progress" | "failed" ``` -------------------------------- ### Copilot Chat Analyzer - Data Structure and Logic Source: https://github.com/dealenx/copilot-chat-analyzer/blob/main/AI_USAGE.md Explains the expected structure of the chat data and the logic used for status detection. ```APIDOC ## Chat Data Structure and Status Detection ### Chat Data Structure Expected JSON structure from GitHub Copilot export: ```typescript { requesterUsername: string, responderUsername: string, requests: Array<{ requestId: string, isCanceled?: boolean, followups?: any[], result?: any, response?: any[] }> } ``` ### Status Detection Logic The library uses the following logic to determine the dialog status: 1. If `requests` is empty or `null`, the status is `"pending"`. 2. If the last request has `isCanceled: true`, the status is `"canceled"`. 3. If the last request has an empty `followups` array (`followups: []`), the status is `"completed"`. 4. Otherwise, the status is `"in_progress"`. ``` -------------------------------- ### MCP Tool Monitoring Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Monitors the usage and performance of Model Context Protocol (MCP) tools within the chat data. ```APIDOC ## getMcpToolMonitoring(chatData, toolName?) ### Description Monitor MCP (Model Context Protocol) tool usage in the chat. Without a tool name, returns a summary of all tools. With a tool name, returns detailed statistics for that specific tool. ### Method - `getMcpToolMonitoring(chatData)`: Returns a summary of all MCP tools used. - `getMcpToolMonitoring(chatData, toolName)`: Returns detailed statistics for a specific tool. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **chatData** (object) - Required - The chat data object containing conversation history and metadata. - **toolName** (string) - Optional - The name of the specific MCP tool to monitor. ### Request Example ```typescript import CopilotChatAnalyzer from "copilot-chat-analyzer"; import { readFileSync } from "fs"; const analyzer = new CopilotChatAnalyzer(); const chatData = JSON.parse(readFileSync("chat_with_mcp.json", "utf8")); // Get summary of all MCP tools used const summary = analyzer.getMcpToolMonitoring(chatData); console.log(summary); // Get detailed monitoring for a specific tool const toolStats = analyzer.getMcpToolMonitoring(chatData, "update_entry_fields"); console.log(toolStats); ``` ### Response #### Success Response (200) - **totalTools** (number) - Total number of unique tools used. - **totalCalls** (number) - Total number of tool invocations. - **overallSuccessRate** (number) - The overall success rate of all tool calls (percentage). - **tools** (array) - An array of tool statistics objects (when no `toolName` is provided). - **toolName** (string) - The name of the tool. - **totalCalls** (number) - Total calls for this tool. - **successfulCalls** (number) - Number of successful calls for this tool. - **errorCalls** (number) - Number of failed calls for this tool. - **successRate** (number) - Success rate for this tool (percentage). - **calls** (array) - Array of individual call details (may be truncated in summary). - **toolName** (string) - The name of the specific tool (when `toolName` is provided). - **totalCalls** (number) - Total calls for this specific tool. - **successfulCalls** (number) - Number of successful calls for this specific tool. - **errorCalls** (number) - Number of failed calls for this specific tool. - **successRate** (number) - Success rate for this specific tool (percentage). - **calls** (array) - Array of individual call details for the specified tool. - **toolId** (string) - Unique ID for the tool invocation. - **toolName** (string) - The name of the tool. - **requestId** (string) - The ID of the request associated with this tool call. - **input** (object) - The input parameters for the tool call. - **output** (object | null) - The output of the tool call, or null if it resulted in an error. - **isError** (boolean) - True if the tool call resulted in an error, false otherwise. #### Response Example ```json { "toolName": "update_entry_fields", "totalCalls": 8, "successfulCalls": 6, "errorCalls": 2, "successRate": 75, "calls": [ { "toolId": "...", "toolName": "update_entry_fields", "requestId": "req-1", "input": {...}, "output": {...}, "isError": false }, { "toolId": "...", "toolName": "update_entry_fields", "requestId": "req-2", "input": {...}, "output": null, "isError": true }, ... ] } ``` ``` -------------------------------- ### Extract AI Responses with Tool Calls Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Use this method to extract all AI responses from chat data, including details about any tool calls made. Ensure the CopilotChatAnalyzer is imported and instantiated. ```typescript import CopilotChatAnalyzer from "copilot-chat-analyzer"; const analyzer = new CopilotChatAnalyzer(); const chatData = { requests: [{ requestId: "req-1", responseId: "resp-1", timestamp: 1234567890, response: [{ value: "Here's how to sort an array in JavaScript:" }], result: { metadata: { toolCallRounds: [{ response: "Let me check the docs.", toolCalls: [{}, {}] }] } } }] }; const responses = analyzer.getAIResponses(chatData); console.log(responses); ``` -------------------------------- ### getAIResponses Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Extracts all AI responses from the conversation, including information about tool calls. ```APIDOC ## getAIResponses(chatData) ### Description Extract all AI responses from the conversation, including information about tool calls. ### Method ```typescript getAIResponses ``` ### Parameters #### Request Body - **chatData** (object) - Required - The chat data object containing conversation requests. - **requests** (array) - Required - An array of request objects. - **requestId** (string) - Required - The ID of the request. - **responseId** (string) - Required - The ID of the response. - **timestamp** (number) - Required - The timestamp of the response. - **response** (array) - Required - An array of response parts. - **value** (string) - Required - The content of the response part. - **result** (object) - Optional - The result object containing metadata. - **metadata** (object) - Optional - Metadata about the response. - **toolCallRounds** (array) - Optional - An array of tool call rounds. - **response** (string) - Optional - The response from the tool call. - **toolCalls** (array) - Optional - An array of tool calls. ### Response #### Success Response (200) - **requestId** (string) - The ID of the request. - **responseId** (string) - The ID of the response. - **message** (string) - The combined AI message, including tool call responses. - **timestamp** (number) - The timestamp of the response. - **index** (number) - The index of the turn in the conversation. - **hasToolCalls** (boolean) - Indicates if the response included tool calls. - **toolCallCount** (number) - The number of tool calls made. ### Request Example ```json { "requests": [ { "requestId": "req-1", "responseId": "resp-1", "timestamp": 1234567890, "response": [{"value": "Here's how to sort an array in JavaScript:"}], "result": { "metadata": { "toolCallRounds": [{"response": "Let me check the docs.", "toolCalls": [{}, {}]}] } } } ] } ``` ### Response Example ```json [ { "requestId": "req-1", "responseId": "resp-1", "message": "Here's how to sort an array in JavaScript:\n\nLet me check the docs.", "timestamp": 1234567890, "index": 0, "hasToolCalls": true, "toolCallCount": 2 } ] ``` ``` -------------------------------- ### getDialogStatusDetails(chatData) Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Provides detailed information about the dialog status, including flags for results, followups, cancellation, and error specifics. ```APIDOC ## GET /api/chat/status/details ### Description Returns detailed information about the dialog status including flags for result presence, followups, cancellation state, and error details. ### Method GET ### Endpoint N/A (Method within CopilotChatAnalyzer class) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **chatData** (object) - Required - The chat data object loaded from a JSON export. ### Request Example ```typescript import CopilotChatAnalyzer from "copilot-chat-analyzer"; const analyzer = new CopilotChatAnalyzer(); const chatData = { requests: [{ requestId: "request_962e76d4-743c-490e-9609-c8f65ef52f56", followups: [], result: { timings: { totalElapsed: 59981 } }, isCanceled: false }] }; const details = analyzer.getDialogStatusDetails(chatData); console.log(details); ``` ### Response #### Success Response (200) - **status** (string) - The overall dialog status. - **statusText** (string) - A human-readable description of the status. - **hasResult** (boolean) - Indicates if the dialog has a result. - **hasFollowups** (boolean) - Indicates if the dialog has followups. - **isCanceled** (boolean) - Indicates if the dialog was canceled. - **isFailed** (boolean) - Indicates if the dialog failed. - **lastRequestId** (string) - The ID of the last request. - **errorCode** (string, optional) - The error code if the dialog failed. - **errorMessage** (string, optional) - The error message if the dialog failed. #### Response Example ```json { "status": "completed", "statusText": "Dialog completed successfully", "hasResult": true, "hasFollowups": true, "isCanceled": false, "isFailed": false, "lastRequestId": "request_962e76d4-743c-490e-9609-c8f65ef52f56" } ``` #### Response Example (Failed Dialog) ```json { "status": "failed", "statusText": "Dialog failed with error", "hasResult": true, "hasFollowups": true, "isCanceled": false, "isFailed": true, "lastRequestId": "req-456", "errorCode": "failed", "errorMessage": "Sorry, your request failed. Authentication Error." } ``` ``` -------------------------------- ### MCP Tool Call Retrieval Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Retrieves specific invocations of MCP tools, including details about their input, output, and success status. ```APIDOC ## getMcpToolCalls(chatData, toolName) ## getMcpToolSuccessfulCalls(chatData, toolName) ## getMcpToolErrorCalls(chatData, toolName) ### Description Get all invocations of a specific MCP tool. Returns an array of McpToolCall objects with input, output, and error status. Helper functions are available to filter for successful or error calls. ### Method - `getMcpToolCalls(chatData, toolName)`: Retrieves all calls for a given tool. - `getMcpToolSuccessfulCalls(chatData, toolName)`: Retrieves only successful calls for a given tool. - `getMcpToolErrorCalls(chatData, toolName)`: Retrieves only error calls for a given tool. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **chatData** (object) - Required - The chat data object containing conversation history and metadata. - **toolName** (string) - Required - The name of the specific MCP tool to retrieve calls for. ### Request Example ```typescript import CopilotChatAnalyzer from "copilot-chat-analyzer"; const analyzer = new CopilotChatAnalyzer(); // Get all calls to a specific tool const calls = analyzer.getMcpToolCalls(chatData, "update_entry_fields"); calls.forEach((call, index) => { console.log(`${index + 1}. ${call.isError ? "❌ Error" : "✅ Success"}`); console.log(` Input: ${JSON.stringify(call.input)}`); if (call.output) { console.log(` Output: ${JSON.stringify(call.output)}`); } }); // Get only successful calls const successCalls = analyzer.getMcpToolSuccessfulCalls(chatData, "update_entry_fields"); console.log(`Successful calls: ${successCalls.length}`); // Get only error calls const errorCalls = analyzer.getMcpToolErrorCalls(chatData, "update_entry_fields"); console.log(`Failed calls: ${errorCalls.length}`); ``` ### Response #### Success Response (200) - **calls** (array) - An array of McpToolCall objects. - **toolId** (string) - Unique ID for the tool invocation. - **toolName** (string) - The name of the tool. - **requestId** (string) - The ID of the request associated with this tool call. - **input** (object) - The input parameters for the tool call. - **output** (object | null) - The output of the tool call, or null if it resulted in an error. - **isError** (boolean) - True if the tool call resulted in an error, false otherwise. #### Response Example ```json [ { "toolId": "...", "toolName": "update_entry_fields", "requestId": "req-1", "input": {"field":"title","value":"New Title"}, "output": {"updated":true}, "isError": false }, { "toolId": "...", "toolName": "update_entry_fields", "requestId": "req-2", "input": {"field":"invalid","value":"..."}, "output": null, "isError": true } ] ``` ``` -------------------------------- ### Retrieve Specific MCP Tool Calls Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Use getMcpToolCalls to retrieve all invocations for a specified tool, including successful and error calls. getMcpToolSuccessfulCalls and getMcpToolErrorCalls filter these results. Requires chat data and a tool name. ```typescript import CopilotChatAnalyzer from "copilot-chat-analyzer"; const analyzer = new CopilotChatAnalyzer(); // Get all calls to a specific tool const calls = analyzer.getMcpToolCalls(chatData, "update_entry_fields"); calls.forEach((call, index) => { console.log(`${index + 1}. ${call.isError ? "❌ Error" : "✅ Success"}`); console.log(` Input: ${JSON.stringify(call.input)}`); if (call.output) { console.log(` Output: ${JSON.stringify(call.output)}`); } }); // Output: // 1. ✅ Success // Input: {"field":"title","value":"New Title"} // Output: {"updated":true} // 2. ❌ Error // Input: {"field":"invalid","value":"..."} // Get only successful calls const successCalls = analyzer.getMcpToolSuccessfulCalls(chatData, "update_entry_fields"); console.log(`Successful calls: ${successCalls.length}`); // Get only error calls const errorCalls = analyzer.getMcpToolErrorCalls(chatData, "update_entry_fields"); console.log(`Failed calls: ${errorCalls.length}`); ``` -------------------------------- ### getDialogStatus(chatData) Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Retrieves the current status of a dialog based on the last request. Supports states like pending, in_progress, completed, canceled, and failed. ```APIDOC ## GET /api/chat/status ### Description Returns the current status of a dialog as a string. The method analyzes the last request in the chat to determine the overall dialog state. ### Method GET ### Endpoint N/A (Method within CopilotChatAnalyzer class) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **chatData** (object) - Required - The chat data object loaded from a JSON export. ### Request Example ```typescript import CopilotChatAnalyzer, { DialogStatus } from "copilot-chat-analyzer"; const analyzer = new CopilotChatAnalyzer(); // Example: Pending chat (no requests made yet) const pendingChat = { requests: [] }; console.log(analyzer.getDialogStatus(pendingChat)); // Output: "pending" // Example: Completed chat (has empty followups array) const completedChat = { requests: [ { requestId: "req-1", followups: [], result: { data: "..." } } ] }; console.log(analyzer.getDialogStatus(completedChat)); // Output: "completed" // Example: In-progress chat (no followups property) const inProgressChat = { requests: [{ requestId: "req-1", isCanceled: false }] }; console.log(analyzer.getDialogStatus(inProgressChat)); // Output: "in_progress" // Example: Canceled chat const canceledChat = { requests: [{ requestId: "req-1", isCanceled: true }] }; console.log(analyzer.getDialogStatus(canceledChat)); // Output: "canceled" // Example: Failed chat (has errorDetails) const failedChat = { requests: [{ requestId: "req-1", result: { errorDetails: { code: "failed", message: "API error" } }, followups: [] }] }; console.log(analyzer.getDialogStatus(failedChat)); // Output: "failed" // Using DialogStatus constants // if (analyzer.getDialogStatus(chatData) === DialogStatus.COMPLETED) { // console.log("Dialog finished successfully!"); // } ``` ### Response #### Success Response (200) - **status** (string) - The dialog status (e.g., "pending", "completed", "failed"). #### Response Example ```json "completed" ``` ``` -------------------------------- ### Detailed Dialog Status Object Structure Source: https://github.com/dealenx/copilot-chat-analyzer/blob/main/AI_USAGE.md Provides a detailed breakdown of the chat dialog status, including status type, human-readable text, and cancellation information. Useful for comprehensive analysis. ```typescript { status: DialogStatusType, statusText: string, // Human readable status hasResult: boolean, // Has result data hasFollowups: boolean, // Has followups property isCanceled: boolean, // Was canceled lastRequestId?: string // ID of last request } ``` -------------------------------- ### Unique MCP Tool Names Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Retrieves a list of all distinct MCP tool names that have been invoked within the chat data. ```APIDOC ## getMcpToolNames(chatData) ### Description Get a list of all unique MCP tool names used in the chat. ### Method - `getMcpToolNames(chatData)`: Returns an array of unique tool names. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **chatData** (object) - Required - The chat data object containing conversation history and metadata. ### Request Example ```typescript import CopilotChatAnalyzer from "copilot-chat-analyzer"; const analyzer = new CopilotChatAnalyzer(); const toolNames = analyzer.getMcpToolNames(chatData); console.log("MCP Tools used:", toolNames); ``` ### Response #### Success Response (200) - **toolNames** (array) - An array of strings, where each string is a unique MCP tool name used in the chat. #### Response Example ```json ["read_file", "update_entry_fields", "search", "write_file"] ``` ``` -------------------------------- ### Extract User Requests Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Use getUserRequests to extract all messages or prompts submitted by the user from the chat data. The function returns an array of objects, each containing the request ID, message text, timestamp, and its index in the conversation. ```typescript import CopilotChatAnalyzer from "copilot-chat-analyzer"; const analyzer = new CopilotChatAnalyzer(); const chatData = { requests: [ { requestId: "req-1", message: { text: "How do I sort an array?" }, timestamp: 1234567890 }, { requestId: "req-2", message: { text: "Can you show me an example?" }, timestamp: 1234567900 } ] }; const userRequests = analyzer.getUserRequests(chatData); console.log(userRequests); // Output: // [ // { id: "req-1", message: "How do I sort an array?", timestamp: 1234567890, index: 0 }, // { id: "req-2", message: "Can you show me an example?", timestamp: 1234567900, index: 1 } // ] ``` -------------------------------- ### Session Information Extraction Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Extracts unique session identifiers and related metadata such as agent and model IDs from chat data. ```APIDOC ## getSessionId(chatData) and getSessionInfo(chatData) ### Description Extract session information from the chat data. The session ID is unique to each dialog and stored in the result metadata. ### Method - `getSessionId(chatData)`: Extracts only the session ID. - `getSessionInfo(chatData)`: Extracts session ID, agent ID, and model ID. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **chatData** (object) - Required - The chat data object containing conversation history and metadata. - **requests** (array) - Required - An array of request objects. - **requestId** (string) - Required - Unique identifier for the request. - **result** (object) - Required - The result of the request. - **metadata** (object) - Required - Metadata associated with the result. - **sessionId** (string) - Required - The unique session identifier. - **agentId** (string) - Optional - The ID of the agent used. - **modelId** (string) - Optional - The ID of the model used. ### Request Example ```typescript import CopilotChatAnalyzer from "copilot-chat-analyzer"; const analyzer = new CopilotChatAnalyzer(); const chatData = { requests: [{ requestId: "req-1", result: { metadata: { sessionId: "ff72bca6-0dec-4953-b130-a103a97e5380", agentId: "github.copilot.editsAgent", modelId: "copilot/gemini-2.5-pro" } } }] }; // Get just the session ID const sessionId = analyzer.getSessionId(chatData); console.log(`Session ID: ${sessionId}`); // Get full session info including agent and model const sessionInfo = analyzer.getSessionInfo(chatData); console.log(sessionInfo); ``` ### Response #### Success Response (200) - **sessionId** (string) - The unique session identifier. - **agentId** (string) - The ID of the agent used (returned by `getSessionInfo`). - **modelId** (string) - The ID of the model used (returned by `getSessionInfo`). #### Response Example ```json { "sessionId": "ff72bca6-0dec-4953-b130-a103a97e5380", "agentId": "github.copilot.editsAgent", "modelId": "copilot/gemini-2.5-pro" } ``` ``` -------------------------------- ### getConversationHistory Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Retrieves the full conversation history with paired user requests and AI responses. ```APIDOC ## getConversationHistory(chatData) ### Description Get the full conversation history with paired user requests and AI responses. ### Method ```typescript getConversationHistory ``` ### Parameters #### Request Body - **chatData** (object) - Required - The chat data object containing conversation requests. - **requests** (array) - Required - An array of request objects. - **requestId** (string) - Required - The ID of the request. - **message** (object) - Required - The user's message. - **text** (string) - Required - The text content of the user's message. - **response** (array) - Optional - An array of response parts from the AI. - **value** (string) - Required - The content of the response part. ### Response #### Success Response (200) - **index** (number) - The index of the conversation turn. - **request** (object) - The user's request object. - **message** (string) - The text of the user's message. - **response** (object) - The AI's response object. - **message** (string) - The text of the AI's response. ### Request Example ```json { "requests": [ { "requestId": "req-1", "message": {"text": "Hello"}, "response": [{"value": "Hi there! How can I help?"}] }, { "requestId": "req-2", "message": {"text": "Explain async/await"}, "response": [{"value": "Async/await is a syntax for handling promises..."}] } ] } ``` ### Response Example ```json [ { "index": 0, "request": {"message": "Hello"}, "response": {"message": "Hi there! How can I help?"} }, { "index": 1, "request": {"message": "Explain async/await"}, "response": {"message": "Async/await is a syntax for handling promises..."} } ] ``` ``` -------------------------------- ### User Request Extraction Source: https://context7.com/dealenx/copilot-chat-analyzer/llms.txt Extracts all messages or requests made by the user from the conversation history. ```APIDOC ## getUserRequests(chatData) ### Description Extract all user requests/messages from the conversation. ### Method - `getUserRequests(chatData)`: Returns an array of user request objects. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **chatData** (object) - Required - The chat data object containing conversation history and metadata. - **requests** (array) - Required - An array of request objects. - **requestId** (string) - Required - Unique identifier for the request. - **message** (object) - Required - The message content. - **text** (string) - Required - The text of the user's message. - **timestamp** (number) - Required - The timestamp of the message. ### Request Example ```typescript import CopilotChatAnalyzer from "copilot-chat-analyzer"; const analyzer = new CopilotChatAnalyzer(); const chatData = { requests: [ { requestId: "req-1", message: { text: "How do I sort an array?" }, timestamp: 1234567890 }, { requestId: "req-2", message: { text: "Can you show me an example?" }, timestamp: 1234567900 } ] }; const userRequests = analyzer.getUserRequests(chatData); console.log(userRequests); ``` ### Response #### Success Response (200) - **userRequests** (array) - An array of user request objects. - **id** (string) - The ID of the request (`requestId` from input). - **message** (string) - The text content of the user's message. - **timestamp** (number) - The timestamp of the message. - **index** (number) - The original index of the request in the `chatData.requests` array. #### Response Example ```json [ { "id": "req-1", "message": "How do I sort an array?", "timestamp": 1234567890, "index": 0 }, { "id": "req-2", "message": "Can you show me an example?", "timestamp": 1234567900, "index": 1 } ] ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.