@crafter/skillkit 0.2.2 → 0.2.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crafter/skillkit",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Local-first analytics for AI agent skills. Track usage, measure context budget, and prune what you don't use.",
5
5
  "type": "module",
6
6
  "bin": {
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
  `);
@@ -56,7 +56,8 @@ export async function runStats(): Promise<void> {
56
56
  return;
57
57
  }
58
58
 
59
- const topSkills = getTopSkills(db, days);
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,17 +67,18 @@ 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;
73
+ const maxNameLen = Math.max(16, ...topSkills.map((s) => s.skill_name.length));
72
74
  const barWidth = 20;
73
75
 
74
- for (const skill of topSkills.slice(0, 10)) {
76
+ for (const skill of topSkills) {
75
77
  const daily = getDailyUsage(db, skill.skill_name, days);
76
78
  const filled = Math.round((skill.total / maxCount) * barWidth);
77
79
  const bar = "█".repeat(filled);
78
80
  const spark = sparkline(daily.map((d) => d.count));
79
- const name = cyan(skill.skill_name.padEnd(16));
81
+ const name = cyan(skill.skill_name.padEnd(maxNameLen));
80
82
  console.log(
81
83
  ` ${name} ${bar.padEnd(barWidth)} ${String(skill.total).padStart(4)} ${spark}`,
82
84
  );
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(db: Database, days = 30): TopSkillRow[] {
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
- return db
32
- .query<TopSkillRow, [string]>(
33
- "SELECT skill_name, COUNT(*) as total FROM skill_invocations WHERE timestamp >= ? GROUP BY skill_name ORDER BY total DESC LIMIT 20",
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 {