copilot-chat-analyzer 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 copilot-chat-analyzer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,149 @@
1
+ # Copilot Chat Analyzer
2
+
3
+ [![Test](https://github.com/dealenx/copilot-chat-analyzer/actions/workflows/test.yml/badge.svg)](https://github.com/dealenx/copilot-chat-analyzer/actions/workflows/test.yml)
4
+ [![Code Quality](https://github.com/dealenx/copilot-chat-analyzer/actions/workflows/quality.yml/badge.svg)](https://github.com/dealenx/copilot-chat-analyzer/actions/workflows/quality.yml)
5
+ [![npm version](https://badge.fury.io/js/copilot-chat-analyzer.svg)](https://badge.fury.io/js/copilot-chat-analyzer)
6
+
7
+ Простая библиотека для анализа экспортированных чатов GitHub Copilot.
8
+
9
+ ## Особенности
10
+
11
+ - 📊 Подсчет количества запросов в диалоге
12
+ - 🔍 Определение статуса диалога (завершен, отменен, в процессе)
13
+ - 📝 Получение детальной информации о статусе
14
+ - 🚀 Простой и понятный API
15
+
16
+ ## Установка
17
+
18
+ ```bash
19
+ npm install copilot-chat-analyzer
20
+ ```
21
+
22
+ Или с yarn:
23
+
24
+ ```bash
25
+ yarn add copilot-chat-analyzer
26
+ ```
27
+
28
+ Или с pnpm:
29
+
30
+ ```bash
31
+ pnpm add copilot-chat-analyzer
32
+ ```
33
+
34
+ ## 🚀 Использование
35
+
36
+ ### Основной API
37
+
38
+ ```javascript
39
+ import CopilotChatAnalyzer from "copilot-chat-analyzer";
40
+ import { readFileSync } from "fs";
41
+
42
+ const chatData = JSON.parse(readFileSync("chat.json", "utf8"));
43
+ const analyzer = new CopilotChatAnalyzer();
44
+
45
+ // Подсчет запросов
46
+ const requestsCount = analyzer.getRequestsCount(chatData);
47
+ console.log(`Количество запросов: ${requestsCount}`);
48
+
49
+ // Определение статуса диалога
50
+ const status = analyzer.getDialogStatus(chatData);
51
+ console.log(`Статус: ${status}`); // 'completed', 'canceled', 'in_progress'
52
+
53
+ // Получение детальной информации о статусе
54
+ const details = analyzer.getDialogStatusDetails(chatData);
55
+ console.log({
56
+ status: details.status,
57
+ statusText: details.statusText,
58
+ hasResult: details.hasResult,
59
+ hasFollowups: details.hasFollowups,
60
+ isCanceled: details.isCanceled,
61
+ lastRequestId: details.lastRequestId,
62
+ });
63
+ ```
64
+
65
+ ## Статусы диалога
66
+
67
+ - **`DialogStatus.COMPLETED`** (`"completed"`) - Диалог завершен успешно
68
+
69
+ - Есть поле `followups: []` (пустой массив)
70
+ - Есть поле `result` с метаданными
71
+ - `isCanceled: false`
72
+
73
+ - **`DialogStatus.CANCELED`** (`"canceled"`) - Диалог был отменен
74
+
75
+ - `isCanceled: true`
76
+ - Может быть с `followups: []` или без него
77
+
78
+ - **`DialogStatus.IN_PROGRESS`** (`"in_progress"`) - Диалог в процессе
79
+ - Отсутствует поле `followups`
80
+ - `isCanceled: false`
81
+
82
+ ## Примеры использования
83
+
84
+ Смотрите файлы в папке `examples/parse-export-chat-json/`:
85
+
86
+ - `index.js` - основной пример использования всех функций
87
+
88
+ ## Запуск примера
89
+
90
+ ```bash
91
+ cd examples/parse-export-chat-json
92
+ node index.js
93
+ ```
94
+
95
+ ## Тестирование
96
+
97
+ Для запуска тестов используйте:
98
+
99
+ ```bash
100
+ # Запуск всех тестов
101
+ pnpm test
102
+
103
+ # Запуск тестов в watch режиме
104
+ pnpm test:watch
105
+
106
+ # Запуск тестов с анализом покрытия кода
107
+ pnpm test:coverage
108
+ ```
109
+
110
+ Проект использует **Jest** для тестирования с поддержкой TypeScript через **ts-jest**.
111
+
112
+ ## Структура экспорта чата
113
+
114
+ Библиотека работает с JSON файлами, экспортированными из GitHub Copilot Chat со следующей структурой:
115
+
116
+ ```json
117
+ {
118
+ "requests": [
119
+ {
120
+ "requestId": "...",
121
+ "message": {...},
122
+ "response": [...],
123
+ "followups": [], // только в завершенных диалогах
124
+ "result": {...}, // только в завершенных диалогах
125
+ "isCanceled": false
126
+ }
127
+ ]
128
+ }
129
+ ```
130
+
131
+ ## Типы
132
+
133
+ ```typescript
134
+ interface CopilotChatData {
135
+ requests?: any[];
136
+ [key: string]: any;
137
+ }
138
+
139
+ type DialogStatusType = "completed" | "canceled" | "in_progress";
140
+
141
+ interface DialogStatusDetails {
142
+ status: DialogStatusType;
143
+ statusText: string;
144
+ hasResult: boolean;
145
+ hasFollowups: boolean;
146
+ isCanceled: boolean;
147
+ lastRequestId?: string;
148
+ }
149
+ ```
@@ -0,0 +1,27 @@
1
+ interface CopilotChatData {
2
+ requests?: any[];
3
+ [key: string]: any;
4
+ }
5
+ interface DialogStatusDetails {
6
+ status: DialogStatusType;
7
+ statusText: string;
8
+ hasResult: boolean;
9
+ hasFollowups: boolean;
10
+ isCanceled: boolean;
11
+ lastRequestId?: string;
12
+ }
13
+ declare const DialogStatus: {
14
+ readonly COMPLETED: "completed";
15
+ readonly CANCELED: "canceled";
16
+ readonly IN_PROGRESS: "in_progress";
17
+ };
18
+ type DialogStatusType = (typeof DialogStatus)[keyof typeof DialogStatus];
19
+ declare class CopilotChatAnalyzer {
20
+ getRequestsCount(chatData: CopilotChatData): number;
21
+ private hasRequests;
22
+ private getLastRequest;
23
+ getDialogStatus(chatData: CopilotChatData): DialogStatusType;
24
+ getDialogStatusDetails(chatData: CopilotChatData): DialogStatusDetails;
25
+ }
26
+
27
+ export { CopilotChatAnalyzer, DialogStatus, type DialogStatusType, CopilotChatAnalyzer as default };
@@ -0,0 +1,27 @@
1
+ interface CopilotChatData {
2
+ requests?: any[];
3
+ [key: string]: any;
4
+ }
5
+ interface DialogStatusDetails {
6
+ status: DialogStatusType;
7
+ statusText: string;
8
+ hasResult: boolean;
9
+ hasFollowups: boolean;
10
+ isCanceled: boolean;
11
+ lastRequestId?: string;
12
+ }
13
+ declare const DialogStatus: {
14
+ readonly COMPLETED: "completed";
15
+ readonly CANCELED: "canceled";
16
+ readonly IN_PROGRESS: "in_progress";
17
+ };
18
+ type DialogStatusType = (typeof DialogStatus)[keyof typeof DialogStatus];
19
+ declare class CopilotChatAnalyzer {
20
+ getRequestsCount(chatData: CopilotChatData): number;
21
+ private hasRequests;
22
+ private getLastRequest;
23
+ getDialogStatus(chatData: CopilotChatData): DialogStatusType;
24
+ getDialogStatusDetails(chatData: CopilotChatData): DialogStatusDetails;
25
+ }
26
+
27
+ export { CopilotChatAnalyzer, DialogStatus, type DialogStatusType, CopilotChatAnalyzer as default };
package/dist/index.js ADDED
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ CopilotChatAnalyzer: () => CopilotChatAnalyzer,
24
+ DialogStatus: () => DialogStatus,
25
+ default: () => index_default
26
+ });
27
+ module.exports = __toCommonJS(index_exports);
28
+ var DialogStatus = {
29
+ COMPLETED: "completed",
30
+ CANCELED: "canceled",
31
+ IN_PROGRESS: "in_progress"
32
+ };
33
+ var CopilotChatAnalyzer = class {
34
+ getRequestsCount(chatData) {
35
+ if (!chatData || !Array.isArray(chatData.requests)) {
36
+ return 0;
37
+ }
38
+ return chatData.requests.length;
39
+ }
40
+ hasRequests(chatData) {
41
+ return Array.isArray(chatData.requests) && chatData.requests.length > 0;
42
+ }
43
+ getLastRequest(chatData) {
44
+ if (!this.hasRequests(chatData)) {
45
+ return null;
46
+ }
47
+ return chatData.requests[chatData.requests.length - 1];
48
+ }
49
+ getDialogStatus(chatData) {
50
+ if (!this.hasRequests(chatData)) {
51
+ return DialogStatus.IN_PROGRESS;
52
+ }
53
+ const lastRequest = this.getLastRequest(chatData);
54
+ if (!lastRequest) {
55
+ return DialogStatus.IN_PROGRESS;
56
+ }
57
+ if (lastRequest.isCanceled === true) {
58
+ return DialogStatus.CANCELED;
59
+ }
60
+ if ("followups" in lastRequest && Array.isArray(lastRequest.followups)) {
61
+ if (lastRequest.followups.length === 0) {
62
+ return DialogStatus.COMPLETED;
63
+ }
64
+ }
65
+ if (!("followups" in lastRequest)) {
66
+ return DialogStatus.IN_PROGRESS;
67
+ }
68
+ return DialogStatus.IN_PROGRESS;
69
+ }
70
+ getDialogStatusDetails(chatData) {
71
+ const status = this.getDialogStatus(chatData);
72
+ if (!this.hasRequests(chatData)) {
73
+ return {
74
+ status: DialogStatus.IN_PROGRESS,
75
+ statusText: "\u041D\u0435\u0442 \u0437\u0430\u043F\u0440\u043E\u0441\u043E\u0432",
76
+ hasResult: false,
77
+ hasFollowups: false,
78
+ isCanceled: false
79
+ };
80
+ }
81
+ const lastRequest = this.getLastRequest(chatData);
82
+ const statusTexts = {
83
+ [DialogStatus.COMPLETED]: "\u0414\u0438\u0430\u043B\u043E\u0433 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043D \u0443\u0441\u043F\u0435\u0448\u043D\u043E",
84
+ [DialogStatus.CANCELED]: "\u0414\u0438\u0430\u043B\u043E\u0433 \u0431\u044B\u043B \u043E\u0442\u043C\u0435\u043D\u0435\u043D",
85
+ [DialogStatus.IN_PROGRESS]: "\u0414\u0438\u0430\u043B\u043E\u0433 \u0432 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u0435 \u0432\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u044F"
86
+ };
87
+ return {
88
+ status,
89
+ statusText: statusTexts[status],
90
+ hasResult: lastRequest && "result" in lastRequest && lastRequest.result !== null,
91
+ hasFollowups: lastRequest && "followups" in lastRequest,
92
+ isCanceled: lastRequest && lastRequest.isCanceled === true,
93
+ lastRequestId: lastRequest?.requestId
94
+ };
95
+ }
96
+ };
97
+ var index_default = CopilotChatAnalyzer;
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ CopilotChatAnalyzer,
101
+ DialogStatus
102
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,76 @@
1
+ // src/index.ts
2
+ var DialogStatus = {
3
+ COMPLETED: "completed",
4
+ CANCELED: "canceled",
5
+ IN_PROGRESS: "in_progress"
6
+ };
7
+ var CopilotChatAnalyzer = class {
8
+ getRequestsCount(chatData) {
9
+ if (!chatData || !Array.isArray(chatData.requests)) {
10
+ return 0;
11
+ }
12
+ return chatData.requests.length;
13
+ }
14
+ hasRequests(chatData) {
15
+ return Array.isArray(chatData.requests) && chatData.requests.length > 0;
16
+ }
17
+ getLastRequest(chatData) {
18
+ if (!this.hasRequests(chatData)) {
19
+ return null;
20
+ }
21
+ return chatData.requests[chatData.requests.length - 1];
22
+ }
23
+ getDialogStatus(chatData) {
24
+ if (!this.hasRequests(chatData)) {
25
+ return DialogStatus.IN_PROGRESS;
26
+ }
27
+ const lastRequest = this.getLastRequest(chatData);
28
+ if (!lastRequest) {
29
+ return DialogStatus.IN_PROGRESS;
30
+ }
31
+ if (lastRequest.isCanceled === true) {
32
+ return DialogStatus.CANCELED;
33
+ }
34
+ if ("followups" in lastRequest && Array.isArray(lastRequest.followups)) {
35
+ if (lastRequest.followups.length === 0) {
36
+ return DialogStatus.COMPLETED;
37
+ }
38
+ }
39
+ if (!("followups" in lastRequest)) {
40
+ return DialogStatus.IN_PROGRESS;
41
+ }
42
+ return DialogStatus.IN_PROGRESS;
43
+ }
44
+ getDialogStatusDetails(chatData) {
45
+ const status = this.getDialogStatus(chatData);
46
+ if (!this.hasRequests(chatData)) {
47
+ return {
48
+ status: DialogStatus.IN_PROGRESS,
49
+ statusText: "\u041D\u0435\u0442 \u0437\u0430\u043F\u0440\u043E\u0441\u043E\u0432",
50
+ hasResult: false,
51
+ hasFollowups: false,
52
+ isCanceled: false
53
+ };
54
+ }
55
+ const lastRequest = this.getLastRequest(chatData);
56
+ const statusTexts = {
57
+ [DialogStatus.COMPLETED]: "\u0414\u0438\u0430\u043B\u043E\u0433 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043D \u0443\u0441\u043F\u0435\u0448\u043D\u043E",
58
+ [DialogStatus.CANCELED]: "\u0414\u0438\u0430\u043B\u043E\u0433 \u0431\u044B\u043B \u043E\u0442\u043C\u0435\u043D\u0435\u043D",
59
+ [DialogStatus.IN_PROGRESS]: "\u0414\u0438\u0430\u043B\u043E\u0433 \u0432 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u0435 \u0432\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u044F"
60
+ };
61
+ return {
62
+ status,
63
+ statusText: statusTexts[status],
64
+ hasResult: lastRequest && "result" in lastRequest && lastRequest.result !== null,
65
+ hasFollowups: lastRequest && "followups" in lastRequest,
66
+ isCanceled: lastRequest && lastRequest.isCanceled === true,
67
+ lastRequestId: lastRequest?.requestId
68
+ };
69
+ }
70
+ };
71
+ var index_default = CopilotChatAnalyzer;
72
+ export {
73
+ CopilotChatAnalyzer,
74
+ DialogStatus,
75
+ index_default as default
76
+ };
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "copilot-chat-analyzer",
3
+ "private": false,
4
+ "version": "0.0.1",
5
+ "description": "Simple library for analyzing exported GitHub Copilot chats",
6
+ "keywords": [
7
+ "copilot",
8
+ "chat",
9
+ "analyzer",
10
+ "github",
11
+ "typescript"
12
+ ],
13
+ "author": "dealenx",
14
+ "license": "MIT",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/dealenx/copilot-chat-analyzer.git"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/dealenx/copilot-chat-analyzer/issues"
21
+ },
22
+ "homepage": "https://github.com/dealenx/copilot-chat-analyzer#readme",
23
+ "type": "module",
24
+ "main": "dist/index.js",
25
+ "module": "dist/index.mjs",
26
+ "types": "dist/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.mjs",
31
+ "require": "./dist/index.js",
32
+ "default": "./dist/index.mjs"
33
+ }
34
+ },
35
+ "files": [
36
+ "dist"
37
+ ],
38
+ "devDependencies": {
39
+ "@types/jest": "^30.0.0",
40
+ "@types/node": "^24.6.1",
41
+ "jest": "^30.2.0",
42
+ "ts-jest": "^29.4.4",
43
+ "typescript": "~5.8.3",
44
+ "vite": "^7.1.7"
45
+ },
46
+ "dependencies": {
47
+ "tsup": "^8.5.0"
48
+ },
49
+ "scripts": {
50
+ "build": "tsup",
51
+ "test": "jest",
52
+ "test:watch": "jest --watch",
53
+ "test:coverage": "jest --coverage"
54
+ }
55
+ }