feat: 新增 Skills Usage 监控统计与图表 (#668)

* feat: add skills usage monitoring

* fix: localize Skills Usage page copy

* fix: keep Skills Usage labels compact
This commit is contained in:
Zhicheng Han
2026-05-13 01:43:25 +02:00
committed by GitHub
parent c2068302c3
commit ce08d2b05a
19 changed files with 1662 additions and 3 deletions
@@ -6,6 +6,7 @@ import {
safeReadFile, extractDescription, listFilesRecursive, getHermesDir,
} from '../../services/config-helpers'
import { pinSkill } from '../../services/hermes/hermes-cli'
import { getSkillUsageStatsFromDb } from '../../db/hermes/sessions-db'
/** Read bundled manifest as a name→hash map from ~/.hermes/skills/.bundled_manifest */
function readBundledManifest(manifestContent: string | null): Map<string, string> {
@@ -239,6 +240,18 @@ export async function list(ctx: any) {
}
}
export async function usageStats(ctx: any) {
const rawDays = parseInt(String(ctx.query?.days ?? '7'), 10)
const days = Number.isFinite(rawDays) && rawDays > 0 ? Math.min(rawDays, 365) : 7
try {
ctx.body = await getSkillUsageStatsFromDb(days)
} catch (err: any) {
ctx.status = 500
ctx.body = { error: `Failed to read skill usage stats: ${err.message}` }
}
}
export async function toggle(ctx: any) {
const { name, enabled } = ctx.request.body as { name?: string; enabled?: boolean }
if (!name || typeof enabled !== 'boolean') {