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 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":";;;AAoDA,MAAa,aAAa;IACxB;;;;OAIG;IACK,MAAM,CAAC,gBAAgB,CAAC,WAAmB;QACjD,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC;QACnC,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAExC,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;YACtB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC;QACzD,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,UAA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EAAE;SACZ,CAAC;IACJ,CAAC;CACF;AA3KD,sCA2KC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { RepositoryInfo } from '../models/repository';
|
|
2
|
+
import { PluginConfig } from '../models/config';
|
|
3
|
+
/**
|
|
4
|
+
* GitHub Trending Fetcher
|
|
5
|
+
* Fetches and parses GitHub trending repositories
|
|
6
|
+
*/
|
|
7
|
+
export declare class GitHubFetcher {
|
|
8
|
+
private readonly BASE_URL;
|
|
9
|
+
private readonly RAW_URL;
|
|
10
|
+
private readonly proxyConfig?;
|
|
11
|
+
constructor(config?: PluginConfig);
|
|
12
|
+
/**
|
|
13
|
+
* Create axios instance with proxy configuration
|
|
14
|
+
*/
|
|
15
|
+
private createAxiosInstance;
|
|
16
|
+
/**
|
|
17
|
+
* Parse star count from string (supports k suffix)
|
|
18
|
+
* @param countString Star count as string (e.g., "1.2k", "2345")
|
|
19
|
+
* @returns Number of stars
|
|
20
|
+
*/
|
|
21
|
+
parseStarCount(countString: string | null | undefined): number;
|
|
22
|
+
/**
|
|
23
|
+
* Parse trending page HTML and extract repository information
|
|
24
|
+
* @param html HTML content of trending page
|
|
25
|
+
* @returns Array of RepositoryInfo objects
|
|
26
|
+
*/
|
|
27
|
+
parseTrendingPage(html: string): RepositoryInfo[];
|
|
28
|
+
/**
|
|
29
|
+
* Fetch trending repositories
|
|
30
|
+
* @param since Time period: 'daily', 'weekly', 'monthly'
|
|
31
|
+
* @returns Array of RepositoryInfo objects
|
|
32
|
+
*/
|
|
33
|
+
fetchTrending(since?: 'daily' | 'weekly' | 'monthly'): Promise<RepositoryInfo[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Fetch README content from a repository
|
|
36
|
+
* Tries multiple file names (README.md, README.rst, README.txt, README) and branches (main, master)
|
|
37
|
+
* @param fullName Repository full name (owner/repo)
|
|
38
|
+
* @returns README content as string, or empty string if not found
|
|
39
|
+
*/
|
|
40
|
+
fetchReadme(fullName: string): Promise<string>;
|
|
41
|
+
}
|
|
42
|
+
export default GitHubFetcher;
|
|
43
|
+
//# sourceMappingURL=fetcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../../src/core/fetcher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIhD;;;GAGG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAwB;IACjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuC;IAC/D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAsC;gBAEvD,MAAM,CAAC,EAAE,YAAY;IASjC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAwC3B;;;;OAIG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM;IAuB9D;;;;OAIG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,EAAE;IA4EjD;;;;OAIG;IACG,aAAa,CAAC,KAAK,GAAE,OAAO,GAAG,QAAQ,GAAG,SAAmB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAqD/F;;;;;OAKG;IACG,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CA0DrD;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.GitHubFetcher = void 0;
|
|
40
|
+
const axios_1 = __importDefault(require("axios"));
|
|
41
|
+
const cheerio = __importStar(require("cheerio"));
|
|
42
|
+
const logger_1 = require("../utils/logger");
|
|
43
|
+
const logger = logger_1.Logger.get('Fetcher');
|
|
44
|
+
/**
|
|
45
|
+
* GitHub Trending Fetcher
|
|
46
|
+
* Fetches and parses GitHub trending repositories
|
|
47
|
+
*/
|
|
48
|
+
class GitHubFetcher {
|
|
49
|
+
constructor(config) {
|
|
50
|
+
this.BASE_URL = 'https://github.com';
|
|
51
|
+
this.RAW_URL = 'https://raw.githubusercontent.com';
|
|
52
|
+
this.proxyConfig = config?.proxy;
|
|
53
|
+
if (this.proxyConfig?.enabled && this.proxyConfig.url) {
|
|
54
|
+
logger.info('GitHub Fetcher] Proxy enabled', {
|
|
55
|
+
proxyUrl: this.proxyConfig.url
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Create axios instance with proxy configuration
|
|
61
|
+
*/
|
|
62
|
+
createAxiosInstance(proxyConfig) {
|
|
63
|
+
const axiosConfig = {
|
|
64
|
+
headers: {
|
|
65
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
// Apply proxy if enabled
|
|
69
|
+
if (proxyConfig?.enabled && proxyConfig.url) {
|
|
70
|
+
logger.info('GitHub Fetcher] Applying proxy to axios', {
|
|
71
|
+
proxyUrl: proxyConfig.url
|
|
72
|
+
});
|
|
73
|
+
const proxyUrl = proxyConfig.url;
|
|
74
|
+
const match = proxyUrl.match(/^(https?):\/\/(?:([^:]+):([^@]+)@)?([^:]+):(\d+)$/);
|
|
75
|
+
if (match) {
|
|
76
|
+
const [, protocol, username, password, host, port] = match;
|
|
77
|
+
axiosConfig.proxy = {
|
|
78
|
+
protocol: protocol || 'http',
|
|
79
|
+
host: host,
|
|
80
|
+
port: parseInt(port, 10),
|
|
81
|
+
...(username && password ? { auth: { username, password } } : {})
|
|
82
|
+
};
|
|
83
|
+
logger.info('GitHub Fetcher] Proxy configuration applied', {
|
|
84
|
+
protocol,
|
|
85
|
+
host,
|
|
86
|
+
port,
|
|
87
|
+
hasAuth: !!username
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
logger.warn('GitHub Fetcher] Invalid proxy URL format, using default axios instance', {
|
|
92
|
+
proxyUrl
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return axios_1.default.create(axiosConfig);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Parse star count from string (supports k suffix)
|
|
100
|
+
* @param countString Star count as string (e.g., "1.2k", "2345")
|
|
101
|
+
* @returns Number of stars
|
|
102
|
+
*/
|
|
103
|
+
parseStarCount(countString) {
|
|
104
|
+
if (!countString || typeof countString !== 'string') {
|
|
105
|
+
return 0;
|
|
106
|
+
}
|
|
107
|
+
const trimmed = countString.trim();
|
|
108
|
+
if (!trimmed) {
|
|
109
|
+
return 0;
|
|
110
|
+
}
|
|
111
|
+
// Check for k suffix (thousands)
|
|
112
|
+
const match = trimmed.match(/^([\d.]+)k$/i);
|
|
113
|
+
if (match) {
|
|
114
|
+
const num = parseFloat(match[1]);
|
|
115
|
+
return isNaN(num) ? 0 : Math.floor(num * 1000);
|
|
116
|
+
}
|
|
117
|
+
// Remove any non-numeric characters (commas, etc.)
|
|
118
|
+
const clean = trimmed.replace(/[^0-9]/g, '');
|
|
119
|
+
const num = parseInt(clean, 10);
|
|
120
|
+
return isNaN(num) ? 0 : num;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Parse trending page HTML and extract repository information
|
|
124
|
+
* @param html HTML content of trending page
|
|
125
|
+
* @returns Array of RepositoryInfo objects
|
|
126
|
+
*/
|
|
127
|
+
parseTrendingPage(html) {
|
|
128
|
+
const $ = cheerio.load(html);
|
|
129
|
+
const repositories = [];
|
|
130
|
+
// Find all trending repositories using simple, reliable selector
|
|
131
|
+
$('article.Box-row').each((_, element) => {
|
|
132
|
+
const $item = $(element);
|
|
133
|
+
// Extract repository link - support both h1 and h2 (GitHub changed this)
|
|
134
|
+
const $repoLink = $item.find('h2.h3 a, h1.h3 a').first();
|
|
135
|
+
const href = $repoLink.attr('href');
|
|
136
|
+
if (!href)
|
|
137
|
+
return;
|
|
138
|
+
// Clean up href to get full URL
|
|
139
|
+
let url = href.startsWith('http') ? href : `${this.BASE_URL}${href}`;
|
|
140
|
+
// Extract full name (owner/repo) - clean up whitespace and slashes
|
|
141
|
+
const rawName = $repoLink.text();
|
|
142
|
+
const fullName = rawName.replace(/\s+/g, '').replace('/', '/');
|
|
143
|
+
// Extract name (repo name only)
|
|
144
|
+
const name = href.split('/').pop() || '';
|
|
145
|
+
// Description
|
|
146
|
+
const description = $item.find('p.col-9').text().trim();
|
|
147
|
+
// Total Star count - try new format first, then fallback to old format
|
|
148
|
+
let starCount = 0;
|
|
149
|
+
const starLink = $item.find('a[href$="/stargazers"]');
|
|
150
|
+
if (starLink.length > 0) {
|
|
151
|
+
// New GitHub format: link to stargazers
|
|
152
|
+
const starText = starLink.text().trim();
|
|
153
|
+
starCount = this.parseStarCount(starText);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
// Old format: span with aria-label="Star"
|
|
157
|
+
const starText = $item.find('span[aria-label="Star"]').first().text() ||
|
|
158
|
+
$item.find('.d-inline-block.mr-3').first().find('span').first().text();
|
|
159
|
+
if (starText) {
|
|
160
|
+
starCount = this.parseStarCount(starText);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// Fork count - try new format first, then fallback to old format
|
|
164
|
+
let forkCount = 0;
|
|
165
|
+
const forkLink = $item.find('a[href$="/forks"]');
|
|
166
|
+
if (forkLink.length > 0) {
|
|
167
|
+
// New GitHub format: link to forks
|
|
168
|
+
const forkText = forkLink.text().trim();
|
|
169
|
+
forkCount = this.parseStarCount(forkText);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
// Old format: span with aria-label="Fork"
|
|
173
|
+
const forkText = $item.find('span[aria-label="Fork"]').first().text() ||
|
|
174
|
+
$item.find('.d-inline-block.mr-3').eq(1).find('span').first().text();
|
|
175
|
+
if (forkText) {
|
|
176
|
+
forkCount = this.parseStarCount(forkText);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// Language - try itemprop first (real GitHub), then fallback (test fixtures)
|
|
180
|
+
const language = $item.find('span[itemprop="programmingLanguage"]').text().trim() ||
|
|
181
|
+
$item.find('span.text-bold.mr-2').last().text().trim();
|
|
182
|
+
repositories.push({
|
|
183
|
+
name,
|
|
184
|
+
full_name: fullName,
|
|
185
|
+
url,
|
|
186
|
+
stars: starCount,
|
|
187
|
+
description,
|
|
188
|
+
language,
|
|
189
|
+
forks: forkCount
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
return repositories;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Fetch trending repositories
|
|
196
|
+
* @param since Time period: 'daily', 'weekly', 'monthly'
|
|
197
|
+
* @returns Array of RepositoryInfo objects
|
|
198
|
+
*/
|
|
199
|
+
async fetchTrending(since = 'daily') {
|
|
200
|
+
if (!['daily', 'weekly', 'monthly'].includes(since)) {
|
|
201
|
+
throw new Error('Invalid since parameter. Must be "daily", "weekly", or "monthly".');
|
|
202
|
+
}
|
|
203
|
+
const url = `${this.BASE_URL}/trending?since=${since}`;
|
|
204
|
+
logger.info('GitHub Fetcher] Fetching trending repositories', {
|
|
205
|
+
since,
|
|
206
|
+
url,
|
|
207
|
+
proxyConfig: this.proxyConfig,
|
|
208
|
+
});
|
|
209
|
+
try {
|
|
210
|
+
const axiosInstance = this.createAxiosInstance(this.proxyConfig);
|
|
211
|
+
const startTime = Date.now();
|
|
212
|
+
const response = await axiosInstance.get(url);
|
|
213
|
+
const duration = Date.now() - startTime;
|
|
214
|
+
logger.info('GitHub Fetcher] Got response from GitHub', {
|
|
215
|
+
status: response.status,
|
|
216
|
+
durationMs: duration,
|
|
217
|
+
dataLength: response.data?.length || 0
|
|
218
|
+
});
|
|
219
|
+
if (!response.data) {
|
|
220
|
+
throw new Error('Empty response from GitHub');
|
|
221
|
+
}
|
|
222
|
+
if (response.status !== 200) {
|
|
223
|
+
throw new Error(`Failed to fetch trending page: HTTP ${response.status}`);
|
|
224
|
+
}
|
|
225
|
+
logger.debug('GitHub Fetcher] Parsing HTML content...');
|
|
226
|
+
const repos = this.parseTrendingPage(response.data);
|
|
227
|
+
logger.info('GitHub Fetcher] ✅ Successfully parsed trending page', {
|
|
228
|
+
repoCount: repos.length
|
|
229
|
+
});
|
|
230
|
+
return repos;
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
logger.error('GitHub Fetcher] Failed to fetch trending repositories', {
|
|
234
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
235
|
+
stack: error instanceof Error ? error.stack : undefined
|
|
236
|
+
});
|
|
237
|
+
if (error instanceof Error) {
|
|
238
|
+
throw new Error(`Failed to fetch trending page: ${error.message}`);
|
|
239
|
+
}
|
|
240
|
+
throw error;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Fetch README content from a repository
|
|
245
|
+
* Tries multiple file names (README.md, README.rst, README.txt, README) and branches (main, master)
|
|
246
|
+
* @param fullName Repository full name (owner/repo)
|
|
247
|
+
* @returns README content as string, or empty string if not found
|
|
248
|
+
*/
|
|
249
|
+
async fetchReadme(fullName) {
|
|
250
|
+
const readmeFiles = ['README.md', 'README.rst', 'README.txt', 'README'];
|
|
251
|
+
const branches = ['main', 'master'];
|
|
252
|
+
logger.debug('GitHub Fetcher] Fetching README', {
|
|
253
|
+
fullName,
|
|
254
|
+
readmeFiles,
|
|
255
|
+
branches
|
|
256
|
+
});
|
|
257
|
+
for (const readmeName of readmeFiles) {
|
|
258
|
+
for (const branch of branches) {
|
|
259
|
+
const readmeUrl = `${this.RAW_URL}/${fullName}/${branch}/${readmeName}`;
|
|
260
|
+
try {
|
|
261
|
+
const axiosInstance = this.createAxiosInstance(this.proxyConfig);
|
|
262
|
+
const startTime = Date.now();
|
|
263
|
+
const response = await axiosInstance.get(readmeUrl, {
|
|
264
|
+
timeout: 10000 // 10 second timeout
|
|
265
|
+
});
|
|
266
|
+
const duration = Date.now() - startTime;
|
|
267
|
+
if (response.status === 200 && response.data) {
|
|
268
|
+
logger.info('GitHub Fetcher] ✅ README found', {
|
|
269
|
+
fullName,
|
|
270
|
+
readmeName,
|
|
271
|
+
branch,
|
|
272
|
+
contentLength: response.data.length,
|
|
273
|
+
durationMs: duration
|
|
274
|
+
});
|
|
275
|
+
return response.data;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
// Continue to next combination if this one fails
|
|
280
|
+
if (axios_1.default.isAxiosError(error) && error.response?.status === 404) {
|
|
281
|
+
logger.debug('GitHub Fetcher] README not found', {
|
|
282
|
+
fullName,
|
|
283
|
+
readmeName,
|
|
284
|
+
branch
|
|
285
|
+
});
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
// For other errors, log and continue
|
|
289
|
+
logger.warn('GitHub Fetcher] Error fetching README', {
|
|
290
|
+
fullName,
|
|
291
|
+
readmeName,
|
|
292
|
+
branch,
|
|
293
|
+
error: error instanceof Error ? error.message : 'Unknown error'
|
|
294
|
+
});
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
// No README found in any combination
|
|
300
|
+
logger.info('GitHub Fetcher] No README found in any combination', { fullName });
|
|
301
|
+
return '';
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
exports.GitHubFetcher = GitHubFetcher;
|
|
305
|
+
exports.default = GitHubFetcher;
|
|
306
|
+
//# sourceMappingURL=fetcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetcher.js","sourceRoot":"","sources":["../../src/core/fetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,iDAAmC;AAEnC,4CAAyC;AAGzC,MAAM,MAAM,GAAG,eAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAErC;;;GAGG;AACH,MAAa,aAAa;IAKxB,YAAY,MAAqB;QAJhB,aAAQ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EAAE,CAAC;wBAChE,MAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE;4BAC/C,QAAQ;4BACR,UAAU;4BACV,MAAM;yBACP,CAAC,CAAC;wBACH,SAAS;oBACX,CAAC;oBACD,qCAAqC;oBACrC,MAAM,CAAC,IAAI,CAAC,uCAAuC,EAAE;wBACnD,QAAQ;wBACR,UAAU;wBACV,MAAM;wBACN,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;qBAChE,CAAC,CAAC;oBACH,SAAS;gBACX,CAAC;YACH,CAAC;QACH,CAAC;QAED,qCAAqC;QACrC,MAAM,CAAC,IAAI,CAAC,oDAAoD,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;QAChF,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAhSD,sCAgSC;AAED,kBAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File-based storage manager
|
|
3
|
+
* Stores data in JSON files with monthly rotation
|
|
4
|
+
* Location: ~/.openclaw/plugins/openclaw-github-trending/data/YYYY-MM.json
|
|
5
|
+
*/
|
|
6
|
+
export declare class FileStorageManager {
|
|
7
|
+
private dataDir;
|
|
8
|
+
private pluginId;
|
|
9
|
+
constructor(pluginId?: string);
|
|
10
|
+
/**
|
|
11
|
+
* Get current month key (YYYY-MM)
|
|
12
|
+
*/
|
|
13
|
+
private getCurrentMonthKey;
|
|
14
|
+
/**
|
|
15
|
+
* Get file path for a specific month
|
|
16
|
+
*/
|
|
17
|
+
private getFilePath;
|
|
18
|
+
/**
|
|
19
|
+
* Load data from file (current month by default)
|
|
20
|
+
*/
|
|
21
|
+
get(key: string, monthKey?: string): Promise<any>;
|
|
22
|
+
/**
|
|
23
|
+
* Save data to file (current month by default)
|
|
24
|
+
*/
|
|
25
|
+
set(key: string, value: any, monthKey?: string): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Get all months with data
|
|
28
|
+
*/
|
|
29
|
+
getMonths(): Promise<string[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Get full data object for a specific month
|
|
32
|
+
*/
|
|
33
|
+
getMonthData(monthKey?: string): Promise<Record<string, any> | null>;
|
|
34
|
+
/**
|
|
35
|
+
* Merge data across all months (useful for migrations)
|
|
36
|
+
*/
|
|
37
|
+
getAllData(): Promise<Record<string, any>>;
|
|
38
|
+
/**
|
|
39
|
+
* Delete data for a specific key
|
|
40
|
+
*/
|
|
41
|
+
delete(key: string, monthKey?: string): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Clear all data for a specific month
|
|
44
|
+
*/
|
|
45
|
+
clear(monthKey?: string): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Get storage statistics
|
|
48
|
+
*/
|
|
49
|
+
getStats(): Promise<{
|
|
50
|
+
totalMonths: number;
|
|
51
|
+
currentMonth: string;
|
|
52
|
+
currentMonthSize: number;
|
|
53
|
+
totalSize: number;
|
|
54
|
+
files: {
|
|
55
|
+
month: string;
|
|
56
|
+
size: number;
|
|
57
|
+
}[];
|
|
58
|
+
}>;
|
|
59
|
+
}
|
|
60
|
+
export declare function getStorageManager(pluginId?: string): FileStorageManager;
|
|
61
|
+
export default FileStorageManager;
|
|
62
|
+
//# sourceMappingURL=file-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-storage.d.ts","sourceRoot":"","sources":["../../src/core/file-storage.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAS;gBAEb,QAAQ,GAAE,MAAmC;IAsBzD;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAK1B;;OAEG;IACH,OAAO,CAAC,WAAW;IAInB;;OAEG;IACG,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,G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