agentaudit 3.9.29 โ 3.9.30
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/cli.mjs +39 -1
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -147,6 +147,29 @@ function saveCredentials(data) {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
const USER_CONFIG_FILE = path.join(USER_CRED_DIR, 'config.json');
|
|
150
|
+
const USER_STATS_FILE = path.join(USER_CRED_DIR, 'stats-cache.json');
|
|
151
|
+
|
|
152
|
+
function loadStatsCache() {
|
|
153
|
+
try { return fs.existsSync(USER_STATS_FILE) ? JSON.parse(fs.readFileSync(USER_STATS_FILE, 'utf8')) : null; } catch { return null; }
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function saveStatsCache(stats) {
|
|
157
|
+
try { fs.mkdirSync(USER_CRED_DIR, { recursive: true }); fs.writeFileSync(USER_STATS_FILE, JSON.stringify({ ...stats, _ts: Date.now() })); } catch {}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async function refreshStatsCache(agentName) {
|
|
161
|
+
try {
|
|
162
|
+
const lbRes = await fetch(`${REGISTRY_URL}/api/leaderboard`, { signal: AbortSignal.timeout(5000) });
|
|
163
|
+
if (!lbRes.ok) return null;
|
|
164
|
+
const agents = await lbRes.json();
|
|
165
|
+
const idx = Array.isArray(agents) ? agents.findIndex(a => (a.agent_name || '').toLowerCase() === agentName.toLowerCase()) : -1;
|
|
166
|
+
if (idx < 0) return null;
|
|
167
|
+
const me = agents[idx];
|
|
168
|
+
const stats = { rank: idx + 1, total: agents.length, pts: me.total_points || 0, reports: me.total_reports || 0, official: !!me.is_official };
|
|
169
|
+
saveStatsCache(stats);
|
|
170
|
+
return stats;
|
|
171
|
+
} catch { return null; }
|
|
172
|
+
}
|
|
150
173
|
|
|
151
174
|
function loadConfig() {
|
|
152
175
|
try {
|
|
@@ -330,6 +353,8 @@ async function setupCommand() {
|
|
|
330
353
|
console.log(` ${icons.safe} Registered as ${c.bold}${data.agent_name}${c.reset}`);
|
|
331
354
|
console.log(` ${c.dim}Key: ${data.api_key.slice(0, 12)}...${c.reset}`);
|
|
332
355
|
console.log(` ${c.dim}Saved to: ${USER_CRED_FILE}${c.reset}`);
|
|
356
|
+
// Initialize stats cache
|
|
357
|
+
refreshStatsCache(data.agent_name).catch(() => {});
|
|
333
358
|
} catch (err) {
|
|
334
359
|
console.log(` ${c.red}failed${c.reset}`);
|
|
335
360
|
console.log(` ${c.red}${err.message}${c.reset}`);
|
|
@@ -384,7 +409,16 @@ function banner() {
|
|
|
384
409
|
const agentInfo = creds?.agent_name ? ` ${c.dim}ยท${c.reset} ${c.green}${creds.agent_name}${c.reset}` : '';
|
|
385
410
|
console.log();
|
|
386
411
|
console.log(` ๐ก ${c.bold}${c.cyan}AgentAudit${c.reset} ${c.dim}v${getVersion()}${c.reset}${agentInfo}`);
|
|
387
|
-
|
|
412
|
+
// Show cached stats inline
|
|
413
|
+
if (creds?.agent_name) {
|
|
414
|
+
const cached = loadStatsCache();
|
|
415
|
+
if (cached && cached.pts !== undefined) {
|
|
416
|
+
const medal = cached.rank === 1 ? '๐ฅ' : cached.rank === 2 ? '๐ฅ' : cached.rank === 3 ? '๐ฅ' : `#${cached.rank}`;
|
|
417
|
+
console.log(` ${c.dim}${medal} ยท ${cached.pts} pts ยท ${cached.reports} reports${cached.official ? ` ยท ${c.green}Official${c.reset}${c.dim}` : ''}${c.reset}`);
|
|
418
|
+
}
|
|
419
|
+
} else {
|
|
420
|
+
console.log(` ${c.dim}Security scanner for AI tools${c.reset}`);
|
|
421
|
+
}
|
|
388
422
|
console.log();
|
|
389
423
|
}
|
|
390
424
|
|
|
@@ -1695,6 +1729,8 @@ async function auditRepo(url) {
|
|
|
1695
1729
|
const reportSlug = data?.skill_slug || data?.slug || slug;
|
|
1696
1730
|
console.log(` ${c.green}done${c.reset}`);
|
|
1697
1731
|
console.log(` ${c.dim}Report: ${REGISTRY_URL}/skills/${reportSlug}${c.reset}`);
|
|
1732
|
+
// Refresh stats cache in background
|
|
1733
|
+
if (creds.agent_name) refreshStatsCache(creds.agent_name).catch(() => {});
|
|
1698
1734
|
} else {
|
|
1699
1735
|
console.log(` ${c.yellow}failed (HTTP ${res.status})${c.reset}`);
|
|
1700
1736
|
}
|
|
@@ -1996,6 +2032,8 @@ async function main() {
|
|
|
1996
2032
|
console.log(` ${c.bold}Your Stats:${c.reset}`);
|
|
1997
2033
|
console.log(` ${medal} Rank #${rank} of ${agents.length} ${c.dim}โ${c.reset} ${c.cyan}${pts}${c.reset} points ${c.dim}โ${c.reset} ${reports} reports`);
|
|
1998
2034
|
if (me.is_official) console.log(` ${c.green}โ Official Auditor${c.reset}`);
|
|
2035
|
+
// Update stats cache
|
|
2036
|
+
saveStatsCache({ rank, total: agents.length, pts, reports, official: !!me.is_official });
|
|
1999
2037
|
}
|
|
2000
2038
|
}
|
|
2001
2039
|
} catch {}
|