@crafter/skillkit 0.2.2 → 0.2.3
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/package.json +1 -1
- package/src/bin.ts +1 -0
- package/src/commands/stats.ts +4 -3
- package/src/db/queries.ts +9 -6
package/package.json
CHANGED
package/src/bin.ts
CHANGED
|
@@ -27,6 +27,7 @@ function printHelp(): void {
|
|
|
27
27
|
${bold("FLAGS")}
|
|
28
28
|
${dim("scan")} ${cyan("--include-commands")} Also track slash commands (not just skills)
|
|
29
29
|
${dim("stats")} ${cyan("--days N")} Time range in days (default: 30)
|
|
30
|
+
${dim("stats")} ${cyan("--all")} Show all skills, not just top 10
|
|
30
31
|
|
|
31
32
|
${dim("Install skills via skills.sh: npx skills add <owner/repo>")}
|
|
32
33
|
`);
|
package/src/commands/stats.ts
CHANGED
|
@@ -56,7 +56,8 @@ export async function runStats(): Promise<void> {
|
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
const
|
|
59
|
+
const showAll = process.argv.includes("--all");
|
|
60
|
+
const topSkills = getTopSkills(db, days, showAll ? undefined : 10);
|
|
60
61
|
const activeDay = getMostActiveDay(db);
|
|
61
62
|
|
|
62
63
|
const label =
|
|
@@ -66,12 +67,12 @@ export async function runStats(): Promise<void> {
|
|
|
66
67
|
console.log(` Total invocations: ${bold(String(stats.total))}`);
|
|
67
68
|
console.log(` Unique skills: ${bold(String(stats.unique_skills))}`);
|
|
68
69
|
console.log(` Most active day: ${bold(activeDay)}\n`);
|
|
69
|
-
console.log(` ${bold("TOP SKILLS")}\n`);
|
|
70
|
+
console.log(` ${bold(showAll ? "ALL SKILLS" : "TOP SKILLS")}\n`);
|
|
70
71
|
|
|
71
72
|
const maxCount = topSkills.length > 0 ? (topSkills[0]?.total ?? 1) : 1;
|
|
72
73
|
const barWidth = 20;
|
|
73
74
|
|
|
74
|
-
for (const skill of topSkills
|
|
75
|
+
for (const skill of topSkills) {
|
|
75
76
|
const daily = getDailyUsage(db, skill.skill_name, days);
|
|
76
77
|
const filled = Math.round((skill.total / maxCount) * barWidth);
|
|
77
78
|
const bar = "█".repeat(filled);
|
package/src/db/queries.ts
CHANGED
|
@@ -24,15 +24,18 @@ interface InstalledSkillRow {
|
|
|
24
24
|
size_bytes: number | null;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export function getTopSkills(
|
|
27
|
+
export function getTopSkills(
|
|
28
|
+
db: Database,
|
|
29
|
+
days = 30,
|
|
30
|
+
limit?: number,
|
|
31
|
+
): TopSkillRow[] {
|
|
28
32
|
const cutoff = new Date(
|
|
29
33
|
Date.now() - days * 24 * 60 * 60 * 1000,
|
|
30
34
|
).toISOString();
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
.all(cutoff);
|
|
35
|
+
const sql = limit
|
|
36
|
+
? `SELECT skill_name, COUNT(*) as total FROM skill_invocations WHERE timestamp >= ? GROUP BY skill_name ORDER BY total DESC LIMIT ${limit}`
|
|
37
|
+
: "SELECT skill_name, COUNT(*) as total FROM skill_invocations WHERE timestamp >= ? GROUP BY skill_name ORDER BY total DESC";
|
|
38
|
+
return db.query<TopSkillRow, [string]>(sql).all(cutoff);
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
export function getSkillStats(db: Database, days = 30): StatsRow {
|