stats: update model, recurse

Amolith created

Change summary

skill-stats.go | 64 ++++++++++++++++++++++++++-------------------------
1 file changed, 33 insertions(+), 31 deletions(-)

Detailed changes

skill-stats.go 🔗

@@ -1,4 +1,4 @@
-//usr/bin/env go run "$0" "$@"; exit
+// usr/bin/env go run "$0" "$@"; exit
 package main
 
 import (
@@ -20,7 +20,7 @@ import (
 
 const (
 	syntheticAPI = "https://api.synthetic.new/anthropic/v1/messages/count_tokens"
-	model        = "hf:moonshotai/Kimi-K2.5"
+	model        = "hf:moonshotai/Kimi-K2.6"
 	workerCount  = 5 // Number of parallel API workers
 )
 
@@ -61,14 +61,14 @@ type TokenResult struct {
 }
 
 type SkillComparison struct {
-	PrevTotal      int
-	PrevMetadata   int
-	PrevBody       int
-	Delta          int
-	MetadataDelta  int
-	BodyDelta      int
-	Percent        float64
-	IsNew          bool
+	PrevTotal     int
+	PrevMetadata  int
+	PrevBody      int
+	Delta         int
+	MetadataDelta int
+	BodyDelta     int
+	Percent       float64
+	IsNew         bool
 }
 
 func main() {
@@ -239,30 +239,32 @@ func analyzeSkill(path string, counter *TokenCounter) (SkillInfo, error) {
 	jobs = append(jobs, TokenJob{ID: fmt.Sprintf("%s:description", skill.Dir), Text: fm.Description})
 	jobs = append(jobs, TokenJob{ID: fmt.Sprintf("%s:body", skill.Dir), Text: body})
 
-	// Collect reference file jobs
+	// Collect reference file jobs (recursively walk subdirectories)
 	refsPath := filepath.Join(path, "references")
-	entries, err := os.ReadDir(refsPath)
-	if err != nil {
-		if !os.IsNotExist(err) {
-			skill.Errors = append(skill.Errors, fmt.Sprintf("Cannot read references directory: %v", err))
-		}
-	} else {
-		for _, entry := range entries {
-			if entry.IsDir() {
-				continue
-			}
-			refPath := filepath.Join(refsPath, entry.Name())
-			refContent, err := os.ReadFile(refPath)
-			if err != nil {
-				skill.Errors = append(skill.Errors, fmt.Sprintf("Cannot read reference %s: %v", entry.Name(), err))
-				continue
+	filepath.WalkDir(refsPath, func(refPath string, d os.DirEntry, err error) error {
+		if err != nil {
+			if os.IsNotExist(err) {
+				return nil
 			}
-			jobs = append(jobs, TokenJob{
-				ID:   fmt.Sprintf("%s:ref:%s", skill.Dir, entry.Name()),
-				Text: string(refContent),
-			})
+			skill.Errors = append(skill.Errors, fmt.Sprintf("Cannot access references path %s: %v", refPath, err))
+			return nil
 		}
-	}
+		if d.IsDir() {
+			return nil
+		}
+		refContent, err := os.ReadFile(refPath)
+		if err != nil {
+			skill.Errors = append(skill.Errors, fmt.Sprintf("Cannot read reference %s: %v", refPath, err))
+			return nil
+		}
+		// Use path relative to references/ dir as the key
+		relPath, _ := filepath.Rel(refsPath, refPath)
+		jobs = append(jobs, TokenJob{
+			ID:   fmt.Sprintf("%s:ref:%s", skill.Dir, relPath),
+			Text: string(refContent),
+		})
+		return nil
+	})
 
 	// Interleave enqueue and drain to prevent deadlock
 	processResult := func(result TokenResult) {