mirror of
https://github.com/tiennm99/awesome-coding-agents.git
synced 2026-05-25 17:56:50 +00:00
62cbdd7a4a
GitHub fetcher (github.go): - add 30s HTTP client timeout (was http.DefaultClient with no bound) - chunk GraphQL alias requests at 50 repos to stay clear of abuse detection - abort the run on any partial GraphQL error or missing repo rather than silently shrinking the README and poisoning the next delta - retry transient failures (network, 5xx, 429) with 2s/4s/8s backoff History layer (history.go): - key snapshots by canonical owner/repo from agents.yml instead of the rename-resolved NameWithOwner returned by the API; carry a lazy migration map so existing aaif-goose/goose entries fold into block/goose on next read with no manual data edit - tighten the 7d delta window to (cutoff-3d, cutoff] so a missed cron week no longer mislabels a 90d-old comparison as Delta7d - replace the snapshots[:0] aliased filter loop with slices.DeleteFunc - log malformed JSONL lines to stderr with line numbers instead of silently skipping them - write history.jsonl atomically via tmp file + rename so a crash mid-write can no longer truncate accumulated history Plus collapse a few redundant fmt.Errorf wraps, drop a named Config type that was used once, inline the single-call sortByStars helper with a deterministic tiebreaker on canonical key, and use filepath.Base instead of hand-rolling a basename. Includes unit tests covering the 7d window edges, canonical-key migration, atomic write path, malformed-line tolerance, YAML validation, and markdown cell escaping.
35 lines
643 B
Go
35 lines
643 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
type Agent struct {
|
|
Owner string `yaml:"owner"`
|
|
Repo string `yaml:"repo"`
|
|
Category string `yaml:"category,omitempty"`
|
|
Notes string `yaml:"notes,omitempty"`
|
|
}
|
|
|
|
func loadAgents(path string) ([]Agent, error) {
|
|
data, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var cfg struct {
|
|
Agents []Agent `yaml:"agents"`
|
|
}
|
|
if err := yaml.Unmarshal(data, &cfg); err != nil {
|
|
return nil, err
|
|
}
|
|
for i, a := range cfg.Agents {
|
|
if a.Owner == "" || a.Repo == "" {
|
|
return nil, fmt.Errorf("entry %d missing owner or repo", i)
|
|
}
|
|
}
|
|
return cfg.Agents, nil
|
|
}
|