openclaw-github-trending 1.0.0
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 +21 -0
- package/README.md +480 -0
- package/dist/channels/email.d.ts +61 -0
- package/dist/channels/email.d.ts.map +1 -0
- package/dist/channels/email.js +599 -0
- package/dist/channels/email.js.map +1 -0
- package/dist/channels/feishu.d.ts +50 -0
- package/dist/channels/feishu.d.ts.map +1 -0
- package/dist/channels/feishu.js +322 -0
- package/dist/channels/feishu.js.map +1 -0
- package/dist/channels/types.d.ts +66 -0
- package/dist/channels/types.d.ts.map +1 -0
- package/dist/channels/types.js +12 -0
- package/dist/channels/types.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/config.d.ts +83 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +145 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/fetcher.d.ts +43 -0
- package/dist/core/fetcher.d.ts.map +1 -0
- package/dist/core/fetcher.js +306 -0
- package/dist/core/fetcher.js.map +1 -0
- package/dist/core/file-storage.d.ts +62 -0
- package/dist/core/file-storage.d.ts.map +1 -0
- package/dist/core/file-storage.js +253 -0
- package/dist/core/file-storage.js.map +1 -0
- package/dist/core/history.d.ts +71 -0
- package/dist/core/history.d.ts.map +1 -0
- package/dist/core/history.js +133 -0
- package/dist/core/history.js.map +1 -0
- package/dist/core/summarizer.d.ts +64 -0
- package/dist/core/summarizer.d.ts.map +1 -0
- package/dist/core/summarizer.js +324 -0
- package/dist/core/summarizer.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +668 -0
- package/dist/index.js.map +1 -0
- package/dist/models/config.d.ts +93 -0
- package/dist/models/config.d.ts.map +1 -0
- package/dist/models/config.js +3 -0
- package/dist/models/config.js.map +1 -0
- package/dist/models/history.d.ts +6 -0
- package/dist/models/history.d.ts.map +1 -0
- package/dist/models/history.js +7 -0
- package/dist/models/history.js.map +1 -0
- package/dist/models/repository.d.ts +28 -0
- package/dist/models/repository.d.ts.map +1 -0
- package/dist/models/repository.js +3 -0
- package/dist/models/repository.js.map +1 -0
- package/dist/models/service.types.d.ts +87 -0
- package/dist/models/service.types.d.ts.map +1 -0
- package/dist/models/service.types.js +3 -0
- package/dist/models/service.types.js.map +1 -0
- package/dist/services/trending.service.d.ts +29 -0
- package/dist/services/trending.service.d.ts.map +1 -0
- package/dist/services/trending.service.js +306 -0
- package/dist/services/trending.service.js.map +1 -0
- package/dist/tool.d.ts +47 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +314 -0
- package/dist/tool.js.map +1 -0
- package/dist/utils/logger.d.ts +77 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +214 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/markdown.d.ts +9 -0
- package/dist/utils/markdown.d.ts.map +1 -0
- package/dist/utils/markdown.js +40 -0
- package/dist/utils/markdown.js.map +1 -0
- package/openclaw.plugin.json +152 -0
- package/package.json +78 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FileStorageManager = void 0;
|
|
7
|
+
exports.getStorageManager = getStorageManager;
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const logger_1 = require("../utils/logger");
|
|
11
|
+
const logger = logger_1.Logger.get('FileStorage');
|
|
12
|
+
/**
|
|
13
|
+
* File-based storage manager
|
|
14
|
+
* Stores data in JSON files with monthly rotation
|
|
15
|
+
* Location: ~/.openclaw/plugins/openclaw-github-trending/data/YYYY-MM.json
|
|
16
|
+
*/
|
|
17
|
+
class FileStorageManager {
|
|
18
|
+
constructor(pluginId = 'openclaw-github-trending') {
|
|
19
|
+
this.pluginId = pluginId;
|
|
20
|
+
// Get OpenClaw home directory (~/.openclaw)
|
|
21
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE;
|
|
22
|
+
if (!homeDir) {
|
|
23
|
+
throw new Error('Could not determine home directory');
|
|
24
|
+
}
|
|
25
|
+
// Create data directory path
|
|
26
|
+
this.dataDir = path_1.default.join(homeDir, '.openclaw', 'plugins', pluginId, 'data');
|
|
27
|
+
// Ensure directory exists
|
|
28
|
+
try {
|
|
29
|
+
fs_1.default.mkdirSync(this.dataDir, { recursive: true });
|
|
30
|
+
logger.info('Storage directory created/verified', { dataDir: this.dataDir });
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
logger.error('Failed to create storage directory', { error, dataDir: this.dataDir });
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get current month key (YYYY-MM)
|
|
39
|
+
*/
|
|
40
|
+
getCurrentMonthKey() {
|
|
41
|
+
const now = new Date();
|
|
42
|
+
return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}`;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get file path for a specific month
|
|
46
|
+
*/
|
|
47
|
+
getFilePath(monthKey) {
|
|
48
|
+
return path_1.default.join(this.dataDir, `${monthKey}.json`);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Load data from file (current month by default)
|
|
52
|
+
*/
|
|
53
|
+
async get(key, monthKey) {
|
|
54
|
+
const targetMonth = monthKey || this.getCurrentMonthKey();
|
|
55
|
+
const filePath = this.getFilePath(targetMonth);
|
|
56
|
+
try {
|
|
57
|
+
if (!fs_1.default.existsSync(filePath)) {
|
|
58
|
+
logger.info('Storage file not found, returning null', { filePath, key });
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
const fileContent = fs_1.default.readFileSync(filePath, 'utf-8');
|
|
62
|
+
const data = JSON.parse(fileContent);
|
|
63
|
+
logger.info('Data loaded successfully', {
|
|
64
|
+
filePath,
|
|
65
|
+
key,
|
|
66
|
+
hasData: !!data[key],
|
|
67
|
+
dataSize: data[key] ? JSON.stringify(data[key]).length : 0
|
|
68
|
+
});
|
|
69
|
+
return data[key];
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
logger.error('Failed to load data', { error, filePath, key });
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Save data to file (current month by default)
|
|
78
|
+
*/
|
|
79
|
+
async set(key, value, monthKey) {
|
|
80
|
+
const targetMonth = monthKey || this.getCurrentMonthKey();
|
|
81
|
+
const filePath = this.getFilePath(targetMonth);
|
|
82
|
+
try {
|
|
83
|
+
let data = {};
|
|
84
|
+
// Load existing data if file exists
|
|
85
|
+
if (fs_1.default.existsSync(filePath)) {
|
|
86
|
+
const fileContent = fs_1.default.readFileSync(filePath, 'utf-8');
|
|
87
|
+
data = JSON.parse(fileContent);
|
|
88
|
+
logger.info('Loaded existing data', { filePath, existingKeys: Object.keys(data) });
|
|
89
|
+
}
|
|
90
|
+
// Update data
|
|
91
|
+
data[key] = value;
|
|
92
|
+
// Write back to file
|
|
93
|
+
fs_1.default.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf-8');
|
|
94
|
+
logger.info('Data saved successfully', {
|
|
95
|
+
filePath,
|
|
96
|
+
key,
|
|
97
|
+
dataSize: JSON.stringify(value).length,
|
|
98
|
+
totalSize: fs_1.default.statSync(filePath).size
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
logger.error('Failed to save data', { error, filePath, key });
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get all months with data
|
|
108
|
+
*/
|
|
109
|
+
async getMonths() {
|
|
110
|
+
try {
|
|
111
|
+
const files = fs_1.default.readdirSync(this.dataDir);
|
|
112
|
+
const months = files
|
|
113
|
+
.filter(file => file.endsWith('.json'))
|
|
114
|
+
.map(file => file.replace('.json', ''))
|
|
115
|
+
.sort((a, b) => b.localeCompare(a)); // Sort descending
|
|
116
|
+
logger.info('Retrieved months with data', { months });
|
|
117
|
+
return months;
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
logger.error('Failed to get months', { error });
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get full data object for a specific month
|
|
126
|
+
*/
|
|
127
|
+
async getMonthData(monthKey) {
|
|
128
|
+
const targetMonth = monthKey || this.getCurrentMonthKey();
|
|
129
|
+
const filePath = this.getFilePath(targetMonth);
|
|
130
|
+
try {
|
|
131
|
+
if (!fs_1.default.existsSync(filePath)) {
|
|
132
|
+
logger.info('Month data file not found', { filePath });
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
const fileContent = fs_1.default.readFileSync(filePath, 'utf-8');
|
|
136
|
+
const data = JSON.parse(fileContent);
|
|
137
|
+
logger.info('Month data loaded successfully', {
|
|
138
|
+
filePath,
|
|
139
|
+
keys: Object.keys(data),
|
|
140
|
+
size: fs_1.default.statSync(filePath).size
|
|
141
|
+
});
|
|
142
|
+
return data;
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
logger.error('Failed to load month data', { error, filePath });
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Merge data across all months (useful for migrations)
|
|
151
|
+
*/
|
|
152
|
+
async getAllData() {
|
|
153
|
+
const months = await this.getMonths();
|
|
154
|
+
const allData = {};
|
|
155
|
+
for (const month of months) {
|
|
156
|
+
const monthData = await this.getMonthData(month);
|
|
157
|
+
if (monthData) {
|
|
158
|
+
Object.assign(allData, monthData);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
logger.info('Retrieved all data across months', {
|
|
162
|
+
monthsCount: months.length,
|
|
163
|
+
keys: Object.keys(allData)
|
|
164
|
+
});
|
|
165
|
+
return allData;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Delete data for a specific key
|
|
169
|
+
*/
|
|
170
|
+
async delete(key, monthKey) {
|
|
171
|
+
const targetMonth = monthKey || this.getCurrentMonthKey();
|
|
172
|
+
const filePath = this.getFilePath(targetMonth);
|
|
173
|
+
try {
|
|
174
|
+
if (!fs_1.default.existsSync(filePath)) {
|
|
175
|
+
logger.warn('File not found for deletion', { filePath });
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const fileContent = fs_1.default.readFileSync(filePath, 'utf-8');
|
|
179
|
+
const data = JSON.parse(fileContent);
|
|
180
|
+
if (data[key]) {
|
|
181
|
+
delete data[key];
|
|
182
|
+
fs_1.default.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf-8');
|
|
183
|
+
logger.info('Data deleted successfully', { filePath, key });
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
logger.warn('Key not found for deletion', { filePath, key });
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
logger.error('Failed to delete data', { error, filePath, key });
|
|
191
|
+
throw error;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Clear all data for a specific month
|
|
196
|
+
*/
|
|
197
|
+
async clear(monthKey) {
|
|
198
|
+
const targetMonth = monthKey || this.getCurrentMonthKey();
|
|
199
|
+
const filePath = this.getFilePath(targetMonth);
|
|
200
|
+
try {
|
|
201
|
+
if (fs_1.default.existsSync(filePath)) {
|
|
202
|
+
fs_1.default.unlinkSync(filePath);
|
|
203
|
+
logger.info('Cleared storage file', { filePath });
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
logger.warn('File not found for clearing', { filePath });
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
logger.error('Failed to clear storage', { error, filePath });
|
|
211
|
+
throw error;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Get storage statistics
|
|
216
|
+
*/
|
|
217
|
+
async getStats() {
|
|
218
|
+
const months = await this.getMonths();
|
|
219
|
+
const files = [];
|
|
220
|
+
let totalSize = 0;
|
|
221
|
+
for (const month of months) {
|
|
222
|
+
const filePath = this.getFilePath(month);
|
|
223
|
+
if (fs_1.default.existsSync(filePath)) {
|
|
224
|
+
const size = fs_1.default.statSync(filePath).size;
|
|
225
|
+
totalSize += size;
|
|
226
|
+
files.push({ month, size });
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const currentMonth = this.getCurrentMonthKey();
|
|
230
|
+
const currentMonthFile = this.getFilePath(currentMonth);
|
|
231
|
+
const currentMonthSize = fs_1.default.existsSync(currentMonthFile)
|
|
232
|
+
? fs_1.default.statSync(currentMonthFile).size
|
|
233
|
+
: 0;
|
|
234
|
+
return {
|
|
235
|
+
totalMonths: months.length,
|
|
236
|
+
currentMonth,
|
|
237
|
+
currentMonthSize,
|
|
238
|
+
totalSize,
|
|
239
|
+
files
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
exports.FileStorageManager = FileStorageManager;
|
|
244
|
+
// Singleton instance
|
|
245
|
+
let storageManagerInstance = null;
|
|
246
|
+
function getStorageManager(pluginId = 'openclaw-github-trending') {
|
|
247
|
+
if (!storageManagerInstance) {
|
|
248
|
+
storageManagerInstance = new FileStorageManager(pluginId);
|
|
249
|
+
}
|
|
250
|
+
return storageManagerInstance;
|
|
251
|
+
}
|
|
252
|
+
exports.default = FileStorageManager;
|
|
253
|
+
//# sourceMappingURL=file-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-storage.js","sourceRoot":"","sources":["../../src/core/file-storage.ts"],"names":[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CAAC,CAAC,CAAC;QAEN,OAAO;YACL,WAAW,EAAE,MAAM,CAAC,MAAM;YAC1B,YAAY;YACZ,gBAAgB;YAChB,SAAS;YACT,KAAK;SACN,CAAC;IACJ,CAAC;CACF;AAtQD,gDAsQC;AAED,qBAAqB;AACrB,IAAI,sBAAsB,GAA8B,IAAI,CAAC;AAE7D,SAAgB,iBAAiB,CAAC,WAAmB,0BAA0B;IAC7E,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAC5B,sBAAsB,GAAG,IAAI,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,sBAAsB,CAAC;AAChC,CAAC;AAED,kBAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { RepositoryInfo } from '../models/repository';
|
|
2
|
+
export interface RepositoryHistory {
|
|
3
|
+
full_name: string;
|
|
4
|
+
url: string;
|
|
5
|
+
stars: number;
|
|
6
|
+
ai_summary: string;
|
|
7
|
+
first_seen: string;
|
|
8
|
+
last_seen: string;
|
|
9
|
+
last_stars: number;
|
|
10
|
+
push_count: number;
|
|
11
|
+
last_pushed?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface HistoryData {
|
|
14
|
+
repositories: Record<string, RepositoryHistory>;
|
|
15
|
+
last_updated: string;
|
|
16
|
+
}
|
|
17
|
+
export interface HistoryConfig {
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
star_threshold: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* History Manager for tracking processed repositories
|
|
23
|
+
* Provides smart deduplication based on star growth
|
|
24
|
+
*/
|
|
25
|
+
export declare class HistoryManager {
|
|
26
|
+
private data;
|
|
27
|
+
constructor();
|
|
28
|
+
/**
|
|
29
|
+
* Import existing history data
|
|
30
|
+
*/
|
|
31
|
+
importData(data: HistoryData): void;
|
|
32
|
+
/**
|
|
33
|
+
* Export history data for persistence
|
|
34
|
+
*/
|
|
35
|
+
exportData(): HistoryData;
|
|
36
|
+
/**
|
|
37
|
+
* Get a repository's history by full name
|
|
38
|
+
*/
|
|
39
|
+
getProject(fullName: string): RepositoryHistory | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Determine if a repository should be pushed again
|
|
42
|
+
*/
|
|
43
|
+
shouldPushAgain(repo: RepositoryInfo, history: RepositoryHistory, config: HistoryConfig): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Categorize repositories into new, should push, and already seen
|
|
46
|
+
*/
|
|
47
|
+
categorizeRepositories(repositories: RepositoryInfo[], config: HistoryConfig): {
|
|
48
|
+
newlySeen: RepositoryInfo[];
|
|
49
|
+
shouldPush: RepositoryInfo[];
|
|
50
|
+
alreadySeen: RepositoryInfo[];
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Mark repositories as pushed and update history
|
|
54
|
+
*/
|
|
55
|
+
markPushed(repositories: RepositoryInfo[]): void;
|
|
56
|
+
/**
|
|
57
|
+
* Update AI summary for a repository
|
|
58
|
+
*/
|
|
59
|
+
updateAiSummary(fullName: string, summary: string): void;
|
|
60
|
+
/**
|
|
61
|
+
* Get statistics about history
|
|
62
|
+
*/
|
|
63
|
+
getStats(): {
|
|
64
|
+
total_repositories: number;
|
|
65
|
+
total_pushes: number;
|
|
66
|
+
oldest_entry?: string;
|
|
67
|
+
newest_entry?: string;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export default HistoryManager;
|
|
71
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/core/history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE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C;KACvB;CAaF;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HistoryManager = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* History Manager for tracking processed repositories
|
|
6
|
+
* Provides smart deduplication based on star growth
|
|
7
|
+
*/
|
|
8
|
+
class HistoryManager {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.data = {
|
|
11
|
+
repositories: {},
|
|
12
|
+
last_updated: new Date().toISOString()
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Import existing history data
|
|
17
|
+
*/
|
|
18
|
+
importData(data) {
|
|
19
|
+
this.data = data;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Export history data for persistence
|
|
23
|
+
*/
|
|
24
|
+
exportData() {
|
|
25
|
+
this.data.last_updated = new Date().toISOString();
|
|
26
|
+
return this.data;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get a repository's history by full name
|
|
30
|
+
*/
|
|
31
|
+
getProject(fullName) {
|
|
32
|
+
return this.data.repositories[fullName];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Determine if a repository should be pushed again
|
|
36
|
+
*/
|
|
37
|
+
shouldPushAgain(repo, history, config) {
|
|
38
|
+
// Never pushed before
|
|
39
|
+
if (!history.last_pushed) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
// Stars increased significantly
|
|
43
|
+
const starGrowth = repo.stars - history.last_stars;
|
|
44
|
+
if (starGrowth >= config.star_threshold) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Categorize repositories into new, should push, and already seen
|
|
51
|
+
*/
|
|
52
|
+
categorizeRepositories(repositories, config) {
|
|
53
|
+
const newlySeen = [];
|
|
54
|
+
const shouldPush = [];
|
|
55
|
+
const alreadySeen = [];
|
|
56
|
+
for (const repo of repositories) {
|
|
57
|
+
const history = this.data.repositories[repo.full_name];
|
|
58
|
+
if (!history) {
|
|
59
|
+
// First time seeing this repository
|
|
60
|
+
newlySeen.push(repo);
|
|
61
|
+
shouldPush.push(repo);
|
|
62
|
+
}
|
|
63
|
+
else if (config.enabled && this.shouldPushAgain(repo, history, config)) {
|
|
64
|
+
// Seen before, but should push again (star growth)
|
|
65
|
+
shouldPush.push(repo);
|
|
66
|
+
alreadySeen.push(repo);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
// Seen before, don't push again
|
|
70
|
+
alreadySeen.push(repo);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return { newlySeen, shouldPush, alreadySeen };
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Mark repositories as pushed and update history
|
|
77
|
+
*/
|
|
78
|
+
markPushed(repositories) {
|
|
79
|
+
const now = new Date().toISOString();
|
|
80
|
+
for (const repo of repositories) {
|
|
81
|
+
const existing = this.data.repositories[repo.full_name];
|
|
82
|
+
if (existing) {
|
|
83
|
+
// Update existing record
|
|
84
|
+
existing.last_seen = now;
|
|
85
|
+
existing.last_stars = repo.stars;
|
|
86
|
+
existing.stars = repo.stars;
|
|
87
|
+
existing.ai_summary = repo.ai_summary || existing.ai_summary;
|
|
88
|
+
existing.push_count += 1;
|
|
89
|
+
existing.last_pushed = now;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
// Create new record
|
|
93
|
+
this.data.repositories[repo.full_name] = {
|
|
94
|
+
full_name: repo.full_name,
|
|
95
|
+
url: repo.url,
|
|
96
|
+
stars: repo.stars,
|
|
97
|
+
ai_summary: repo.ai_summary || '',
|
|
98
|
+
first_seen: now,
|
|
99
|
+
last_seen: now,
|
|
100
|
+
last_stars: repo.stars,
|
|
101
|
+
push_count: 1,
|
|
102
|
+
last_pushed: now
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Update AI summary for a repository
|
|
109
|
+
*/
|
|
110
|
+
updateAiSummary(fullName, summary) {
|
|
111
|
+
const history = this.data.repositories[fullName];
|
|
112
|
+
if (history) {
|
|
113
|
+
history.ai_summary = summary;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get statistics about history
|
|
118
|
+
*/
|
|
119
|
+
getStats() {
|
|
120
|
+
const repos = Object.values(this.data.repositories);
|
|
121
|
+
const total_pushes = repos.reduce((sum, r) => sum + r.push_count, 0);
|
|
122
|
+
const timestamps = repos.map(r => r.first_seen).sort();
|
|
123
|
+
return {
|
|
124
|
+
total_repositories: repos.length,
|
|
125
|
+
total_pushes,
|
|
126
|
+
oldest_entry: timestamps[0],
|
|
127
|
+
newest_entry: timestamps[timestamps.length - 1]
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.HistoryManager = HistoryManager;
|
|
132
|
+
exports.default = HistoryManager;
|
|
133
|
+
//# sourceMappingURL=history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/core/history.ts"],"names":[],"mappings":";;;AAwBA;;;GAGG;AACH,MAAa,cAAc;IAGzB;QACE,IAAI,CAAC,IAAI,GAAG;YACV,YAAY,EAAE,EAAE;YAChB,YAAY,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACvC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,IAAiB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,IAAI,CAAC,YAAY,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAClD,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED;;OAEG;IACH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e;QAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QACjD,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC;QAC/B,CAAC;IACH,CAAC;IAED;;OAEG;IACH,QAAQ;QAMN,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACpD,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QAErE,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC;QAEvD,OAAO;YACL,kBAAkB,EAAE,KAAK,CAAC,MAAM;YAChC,YAAY;YACZ,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC;YAC3B,YAAY,EAAE,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;SAChD,CAAC;IACJ,CAAC;CACF;AAtJD,wCAsJC;AAED,kBAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ResolvedAIConfig } from '../models/config';
|
|
2
|
+
import { RepositoryInfo } from '../models/repository';
|
|
3
|
+
/**
|
|
4
|
+
* AI Summarizer class
|
|
5
|
+
* Generates Chinese summaries for GitHub repositories using OpenAI or Anthropic API
|
|
6
|
+
*/
|
|
7
|
+
export declare class AISummarizer {
|
|
8
|
+
private readonly provider;
|
|
9
|
+
private readonly openaiClient?;
|
|
10
|
+
private readonly anthropicClient?;
|
|
11
|
+
private readonly model;
|
|
12
|
+
/**
|
|
13
|
+
* Create a new AISummarizer instance
|
|
14
|
+
* @param config AI configuration
|
|
15
|
+
*/
|
|
16
|
+
constructor(config: ResolvedAIConfig);
|
|
17
|
+
/**
|
|
18
|
+
* Build the prompt for AI summary generation
|
|
19
|
+
* @param repo Repository information
|
|
20
|
+
* @returns Prompt string
|
|
21
|
+
*/
|
|
22
|
+
buildPrompt(repo: RepositoryInfo): string;
|
|
23
|
+
/**
|
|
24
|
+
* Generate AI summary for a repository using OpenAI
|
|
25
|
+
* @param repo Repository information
|
|
26
|
+
* @returns AI-generated summary in Chinese, or empty string if failed
|
|
27
|
+
*/
|
|
28
|
+
private generateSummaryOpenAI;
|
|
29
|
+
/**
|
|
30
|
+
* Generate AI summary for a repository using Anthropic
|
|
31
|
+
* @param repo Repository information
|
|
32
|
+
* @returns AI-generated summary in Chinese, or empty string if failed
|
|
33
|
+
*/
|
|
34
|
+
private generateSummaryAnthropic;
|
|
35
|
+
/**
|
|
36
|
+
* Generate AI summary for a repository
|
|
37
|
+
* @param repo Repository information
|
|
38
|
+
* @returns AI-generated summary in Chinese, or empty string if failed
|
|
39
|
+
*/
|
|
40
|
+
generateSummary(repo: RepositoryInfo): Promise<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Generate AI summary from README content using OpenAI
|
|
43
|
+
* @param fullName Repository full name (owner/repo)
|
|
44
|
+
* @param readmeContent README.md content
|
|
45
|
+
* @returns AI-generated summary in Chinese, or empty string if failed
|
|
46
|
+
*/
|
|
47
|
+
private summarizeReadmeOpenAI;
|
|
48
|
+
/**
|
|
49
|
+
* Generate AI summary from README content using Anthropic
|
|
50
|
+
* @param fullName Repository full name (owner/repo)
|
|
51
|
+
* @param readmeContent README.md content
|
|
52
|
+
* @returns AI-generated summary in Chinese, or empty string if failed
|
|
53
|
+
*/
|
|
54
|
+
private summarizeReadmeAnthropic;
|
|
55
|
+
/**
|
|
56
|
+
* Generate AI summary from README content
|
|
57
|
+
* @param fullName Repository full name (owner/repo)
|
|
58
|
+
* @param readmeContent README.md content
|
|
59
|
+
* @returns AI-generated summary in Chinese, or empty string if failed
|
|
60
|
+
*/
|
|
61
|
+
summarizeReadme(fullName: string, readmeContent: string): Promise<string>;
|
|
62
|
+
}
|
|
63
|
+
export default AISummarizer;
|
|
64
|
+
//# sourceMappingURL=summarizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summarizer.d.ts","sourceRoot":"","sources":["../../src/core/summarizer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAKtD;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;IAClD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAY;IAC7C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAE/B;;;OAGG;gBACS,MAAM,EAAE,gBAAgB;IAiBpC;;;;OAIG;IACH,WAAW,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM;IAoDzC;;;;OAIG;YACW,qBAAqB;IAgDnC;;;;OAIG;YACW,wBAAwB;IA8CtC;;;;OAIG;IACG,eAAe,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ5D;;;;;OAKG;YACW,qBAAqB;IA6DnC;;;;;OAKG;YACW,wBAAwB;IA2DtC;;;;;OAKG;IACG,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAOhF;AAED,eAAe,YAAY,CAAC"}
|