(skillName: string)
| 42 | * meaning usage from 7 days ago is worth half as much as usage today. |
| 43 | */ |
| 44 | export function getSkillUsageScore(skillName: string): number { |
| 45 | const config = getGlobalConfig() |
| 46 | const usage = config.skillUsage?.[skillName] |
| 47 | if (!usage) return 0 |
| 48 | |
| 49 | // Recency decay: halve score every 7 days |
| 50 | const daysSinceUse = (Date.now() - usage.lastUsedAt) / (1000 * 60 * 60 * 24) |
| 51 | const recencyFactor = Math.pow(0.5, daysSinceUse / 7) |
| 52 | |
| 53 | // Minimum recency factor of 0.1 to avoid completely dropping old but heavily used skills |
| 54 | return usage.usageCount * Math.max(recencyFactor, 0.1) |
| 55 | } |
| 56 |
no test coverage detected