From 03704df0a5cc86da75de7d24c201886c0d91f39e Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Wed, 13 May 2026 14:43:35 +0700 Subject: [PATCH] feat: initial scaffold of awesome-coding-agents tracker Go updater that fetches AI agent coding tool repo stats via GitHub GraphQL (batched, one query), sorts by star count, appends a daily snapshot to data/history.jsonl, and regenerates README.md from templates/readme.tmpl. Daily workflow at .github/workflows/update.yml refreshes rankings and commits changes. Seed list in data/agents.yml covers 19 tracked repos. --- .github/workflows/update.yml | 49 +++++++++ .gitignore | 10 ++ LICENSE | 202 +++++++++++++++++++++++++++++++++++ README.md | 55 ++++++++++ agents.go | 37 +++++++ data/agents.yml | 62 +++++++++++ data/history.jsonl | 1 + github.go | 131 +++++++++++++++++++++++ go.mod | 5 + go.sum | 4 + history.go | 105 ++++++++++++++++++ main.go | 47 ++++++++ readme.go | 96 +++++++++++++++++ templates/readme.tmpl | 39 +++++++ 14 files changed, 843 insertions(+) create mode 100644 .github/workflows/update.yml create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 agents.go create mode 100644 data/agents.yml create mode 100644 data/history.jsonl create mode 100644 github.go create mode 100644 go.mod create mode 100644 go.sum create mode 100644 history.go create mode 100644 main.go create mode 100644 readme.go create mode 100644 templates/readme.tmpl diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml new file mode 100644 index 0000000..c2426cd --- /dev/null +++ b/.github/workflows/update.yml @@ -0,0 +1,49 @@ +name: Update rankings + +on: + schedule: + - cron: '0 0 * * *' + workflow_dispatch: + push: + branches: [main] + paths: + - 'data/agents.yml' + - 'templates/**' + - '**.go' + - 'go.mod' + - '.github/workflows/update.yml' + +permissions: + contents: write + +concurrency: + group: update-rankings + cancel-in-progress: false + +jobs: + update: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: 'stable' + cache: true + + - name: Run updater + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: go run . + + - name: Commit changes + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add README.md data/history.jsonl + if git diff --staged --quiet; then + echo "no changes" + exit 0 + fi + git commit -m "chore: daily ranking refresh" + git push diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..33f1524 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +# Go build artifacts +/awesome-coding-agents +*.exe +*.test +*.out + +# Editor / OS noise +.DS_Store +.idea/ +.vscode/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..aea7003 --- /dev/null +++ b/README.md @@ -0,0 +1,55 @@ +# Awesome Coding Agents + +> Curated ranking of AI agent coding tools, sorted by GitHub stars. +> Updated daily by GitHub Actions. + +**Last updated:** 2026-05-13 07:43 UTC · **Tracked:** 19 repos + +| # | Repo | Stars | Δ7d | Language | Last push | Description | +|---|------|------:|----:|----------|-----------|-------------| +| 1 | [anomalyco/opencode](https://github.com/anomalyco/opencode) | 159.4k | — | TypeScript | 2026-05-13 | The open source coding agent. | +| 2 | [anthropics/claude-code](https://github.com/anthropics/claude-code) | 123.1k | — | Shell | 2026-05-12 | Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands. | +| 3 | [google-gemini/gemini-cli](https://github.com/google-gemini/gemini-cli) | 103.8k | — | TypeScript | 2026-05-13 | An open-source AI agent that brings the power of Gemini directly into your terminal. | +| 4 | [zed-industries/zed](https://github.com/zed-industries/zed) | 82.6k | — | Rust | 2026-05-13 | Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter. | +| 5 | [openai/codex](https://github.com/openai/codex) | 82.2k | — | Rust | 2026-05-13 | Lightweight coding agent that runs in your terminal | +| 6 | [cline/cline](https://github.com/cline/cline) | 61.7k | — | TypeScript | 2026-05-13 | Autonomous coding agent as an SDK, IDE extension, or CLI assistant. | +| 7 | [AntonOsika/gpt-engineer](https://github.com/AntonOsika/gpt-engineer) | 55.2k | — | Python | 2025-05-14 | CLI platform to experiment with codegen. Precursor to: https://lovable.dev | +| 8 | [aaif-goose/goose](https://github.com/aaif-goose/goose) | 45.1k | — | Rust | 2026-05-13 | an open source, extensible AI agent that goes beyond code suggestions - install, execute, edit, and test with any LLM | +| 9 | [Aider-AI/aider](https://github.com/Aider-AI/aider) | 44.7k | — | Python | 2026-04-25 | aider is AI pair programming in your terminal | +| 10 | [TabbyML/tabby](https://github.com/TabbyML/tabby) | 33.5k | — | Rust | 2026-03-02 | Self-hosted AI coding assistant | +| 11 | [continuedev/continue](https://github.com/continuedev/continue) | 33.2k | — | TypeScript | 2026-05-13 | ⏩ Source-controlled AI checks, enforceable in CI. Powered by the open-source Continue CLI | +| 12 | [voideditor/void](https://github.com/voideditor/void) | 28.7k | — | TypeScript | 2026-01-12 | | +| 13 | [charmbracelet/crush](https://github.com/charmbracelet/crush) | 24.2k | — | Go | 2026-05-13 | Glamourous agentic coding for all 💘 | +| 14 | [RooCodeInc/Roo-Code](https://github.com/RooCodeInc/Roo-Code) | 24.0k | — | TypeScript | 2026-05-13 | Roo Code gives you a whole dev team of AI agents in your code editor. | +| 15 | [kortix-ai/suna](https://github.com/kortix-ai/suna) | 19.8k | — | TypeScript | 2026-05-10 | The Autonomous Company Operating System | +| 16 | [SWE-agent/SWE-agent](https://github.com/SWE-agent/SWE-agent) | 19.2k | — | Python | 2026-04-27 | SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024] | +| 17 | [yetone/avante.nvim](https://github.com/yetone/avante.nvim) | 17.9k | — | Lua | 2026-05-12 | Use your Neovim like using Cursor AI IDE! | +| 18 | [stackblitz/bolt.new](https://github.com/stackblitz/bolt.new) | 16.4k | — | TypeScript | 2024-12-17 | Prompt, run, edit, and deploy full-stack web applications. -- bolt.new -- Help Center: https://support.bolt.new/ -- Community Support: https://discord.com/invite/stackblitz | +| 19 | [plandex-ai/plandex](https://github.com/plandex-ai/plandex) | 15.4k | — | Go | 2025-10-03 | Open source AI coding agent. Designed for large projects and real world tasks. | + +--- + +## How it works + +1. `data/agents.yml` is the curated source list. +2. A daily GitHub Actions workflow (`.github/workflows/update.yml`) runs the Go updater. +3. The updater fetches live repo metadata via the GitHub GraphQL API in one batched query. +4. Star counts are appended to `data/history.jsonl` for 7-day delta computation. +5. This `README.md` is regenerated from `templates/readme.tmpl` and committed back to the repo. + +## Contributing + +Add an agent to [`data/agents.yml`](data/agents.yml): + +```yaml +agents: + - owner: github-username-or-org + repo: repository-name + category: cli # cli | ide | extension | library | research | web +``` + +Open a PR. The next daily run picks it up automatically. + +## License + +Apache-2.0 diff --git a/agents.go b/agents.go new file mode 100644 index 0000000..09cf390 --- /dev/null +++ b/agents.go @@ -0,0 +1,37 @@ +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"` +} + +type Config struct { + Agents []Agent `yaml:"agents"` +} + +func loadAgents(path string) ([]Agent, error) { + data, err := os.ReadFile(path) + if err != nil { + return nil, err + } + var cfg Config + if err := yaml.Unmarshal(data, &cfg); err != nil { + return nil, err + } + // validate each entry has owner + repo + 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 +} diff --git a/data/agents.yml b/data/agents.yml new file mode 100644 index 0000000..c76e364 --- /dev/null +++ b/data/agents.yml @@ -0,0 +1,62 @@ +# Curated list of AI agent coding tools. +# Edit this file to add, remove, or recategorize entries. +# The daily GitHub Actions run will refresh stars and regenerate README.md. + +agents: + - owner: Aider-AI + repo: aider + category: cli + - owner: cline + repo: cline + category: extension + - owner: continuedev + repo: continue + category: extension + - owner: sst + repo: opencode + category: cli + - owner: charmbracelet + repo: crush + category: cli + - owner: google-gemini + repo: gemini-cli + category: cli + - owner: openai + repo: codex + category: cli + - owner: block + repo: goose + category: cli + - owner: plandex-ai + repo: plandex + category: cli + - owner: gpt-engineer-org + repo: gpt-engineer + category: cli + - owner: SWE-agent + repo: SWE-agent + category: research + - owner: RooCodeInc + repo: Roo-Code + category: extension + - owner: TabbyML + repo: tabby + category: ide + - owner: zed-industries + repo: zed + category: ide + - owner: voideditor + repo: void + category: ide + - owner: anthropics + repo: claude-code + category: cli + - owner: yetone + repo: avante.nvim + category: extension + - owner: stackblitz + repo: bolt.new + category: web + - owner: kortix-ai + repo: suna + category: web diff --git a/data/history.jsonl b/data/history.jsonl new file mode 100644 index 0000000..5b85601 --- /dev/null +++ b/data/history.jsonl @@ -0,0 +1 @@ +{"date":"2026-05-13","stars":{"Aider-AI/aider":44740,"AntonOsika/gpt-engineer":55219,"RooCodeInc/Roo-Code":24034,"SWE-agent/SWE-agent":19205,"TabbyML/tabby":33507,"aaif-goose/goose":45115,"anomalyco/opencode":159409,"anthropics/claude-code":123059,"charmbracelet/crush":24226,"cline/cline":61705,"continuedev/continue":33158,"google-gemini/gemini-cli":103832,"kortix-ai/suna":19752,"openai/codex":82234,"plandex-ai/plandex":15358,"stackblitz/bolt.new":16370,"voideditor/void":28747,"yetone/avante.nvim":17887,"zed-industries/zed":82628}} diff --git a/github.go b/github.go new file mode 100644 index 0000000..896aff5 --- /dev/null +++ b/github.go @@ -0,0 +1,131 @@ +package main + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "net/http" + "os" + "sort" + "strings" + "time" +) + +type Stat struct { + Owner string + Repo string + Category string + Notes string + Description string + Stars int + Language string + PushedAt time.Time + URL string + NameWithOwner string +} + +type repoNode struct { + StargazerCount int `json:"stargazerCount"` + Description string `json:"description"` + PrimaryLanguage *struct { + Name string `json:"name"` + } `json:"primaryLanguage"` + PushedAt time.Time `json:"pushedAt"` + URL string `json:"url"` + NameWithOwner string `json:"nameWithOwner"` +} + +type graphQLResponse struct { + Data map[string]*repoNode `json:"data"` + Errors []struct { + Message string `json:"message"` + Path []any `json:"path"` + } `json:"errors"` +} + +const repoFields = ` + stargazerCount + description + primaryLanguage { name } + pushedAt + url + nameWithOwner + ` + +func fetchStats(token string, agents []Agent) ([]Stat, error) { + var b strings.Builder + b.WriteString("query {\n") + for i, a := range agents { + fmt.Fprintf(&b, " r%d: repository(owner: %q, name: %q) {%s}\n", i, a.Owner, a.Repo, repoFields) + } + b.WriteString("}\n") + + body, err := json.Marshal(map[string]string{"query": b.String()}) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", "https://api.github.com/graphql", bytes.NewReader(body)) + if err != nil { + return nil, err + } + req.Header.Set("Authorization", "Bearer "+token) + req.Header.Set("Content-Type", "application/json") + req.Header.Set("User-Agent", "awesome-coding-agents-updater") + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + raw, err := io.ReadAll(resp.Body) + if err != nil { + return nil, err + } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("graphql HTTP %d: %s", resp.StatusCode, raw) + } + + var out graphQLResponse + if err := json.Unmarshal(raw, &out); err != nil { + return nil, fmt.Errorf("decode response: %w (body=%s)", err, raw) + } + for _, e := range out.Errors { + // repos that 404 or are renamed land here; continue with partial data + fmt.Fprintf(os.Stderr, "graphql warn: %s (path=%v)\n", e.Message, e.Path) + } + + stats := make([]Stat, 0, len(agents)) + for i, a := range agents { + node := out.Data[fmt.Sprintf("r%d", i)] + if node == nil { + fmt.Fprintf(os.Stderr, "skip %s/%s — no data\n", a.Owner, a.Repo) + continue + } + lang := "" + if node.PrimaryLanguage != nil { + lang = node.PrimaryLanguage.Name + } + stats = append(stats, Stat{ + Owner: a.Owner, + Repo: a.Repo, + Category: a.Category, + Notes: a.Notes, + Description: node.Description, + Stars: node.StargazerCount, + Language: lang, + PushedAt: node.PushedAt, + URL: node.URL, + NameWithOwner: node.NameWithOwner, + }) + } + return stats, nil +} + +func sortByStars(stats []Stat) { + sort.SliceStable(stats, func(i, j int) bool { + return stats[i].Stars > stats[j].Stars + }) +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..3a69af3 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module github.com/tiennm99/awesome-coding-agents + +go 1.23 + +require gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..a62c313 --- /dev/null +++ b/go.sum @@ -0,0 +1,4 @@ +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/history.go b/history.go new file mode 100644 index 0000000..a813b5a --- /dev/null +++ b/history.go @@ -0,0 +1,105 @@ +package main + +import ( + "bufio" + "encoding/json" + "os" + "time" +) + +type Snapshot struct { + Date string `json:"date"` + Stars map[string]int `json:"stars"` +} + +func appendHistory(path string, stats []Stat) (map[string]int, error) { + today := time.Now().UTC().Format("2006-01-02") + current := Snapshot{Date: today, Stars: map[string]int{}} + for _, s := range stats { + current.Stars[s.NameWithOwner] = s.Stars + } + + snapshots, err := readSnapshots(path) + if err != nil { + return nil, err + } + + deltas := computeDeltas(snapshots, current) + + // drop any pre-existing snapshot for today, then append current + kept := snapshots[:0] + for _, s := range snapshots { + if s.Date != today { + kept = append(kept, s) + } + } + kept = append(kept, current) + + return deltas, writeSnapshots(path, kept) +} + +func readSnapshots(path string) ([]Snapshot, error) { + f, err := os.Open(path) + if err != nil { + if os.IsNotExist(err) { + return nil, nil + } + return nil, err + } + defer f.Close() + + var out []Snapshot + scanner := bufio.NewScanner(f) + scanner.Buffer(make([]byte, 1024*1024), 16*1024*1024) + for scanner.Scan() { + line := scanner.Bytes() + if len(line) == 0 { + continue + } + var s Snapshot + if err := json.Unmarshal(line, &s); err != nil { + // skip malformed lines rather than fail the whole run + continue + } + out = append(out, s) + } + return out, scanner.Err() +} + +func writeSnapshots(path string, snapshots []Snapshot) error { + f, err := os.Create(path) + if err != nil { + return err + } + defer f.Close() + enc := json.NewEncoder(f) + for _, s := range snapshots { + if err := enc.Encode(s); err != nil { + return err + } + } + return nil +} + +// computeDeltas returns stars-now minus stars-at-or-before-cutoff for each repo. +// Cutoff = 7 days ago UTC. If no snapshot is old enough, delta is omitted. +func computeDeltas(history []Snapshot, current Snapshot) map[string]int { + deltas := map[string]int{} + cutoff := time.Now().UTC().AddDate(0, 0, -7).Format("2006-01-02") + + var base *Snapshot + for i := range history { + if history[i].Date <= cutoff { + base = &history[i] + } + } + if base == nil { + return deltas + } + for repo, cur := range current.Stars { + if prev, ok := base.Stars[repo]; ok { + deltas[repo] = cur - prev + } + } + return deltas +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..ee88d1e --- /dev/null +++ b/main.go @@ -0,0 +1,47 @@ +package main + +import ( + "fmt" + "log" + "os" +) + +func main() { + if err := run(); err != nil { + log.Fatalf("update failed: %v", err) + } +} + +func run() error { + agents, err := loadAgents("data/agents.yml") + if err != nil { + return fmt.Errorf("load agents: %w", err) + } + if len(agents) == 0 { + return fmt.Errorf("no agents in data/agents.yml") + } + + token := os.Getenv("GITHUB_TOKEN") + if token == "" { + return fmt.Errorf("GITHUB_TOKEN env var required") + } + + stats, err := fetchStats(token, agents) + if err != nil { + return fmt.Errorf("fetch stats: %w", err) + } + + sortByStars(stats) + + deltas, err := appendHistory("data/history.jsonl", stats) + if err != nil { + return fmt.Errorf("append history: %w", err) + } + + if err := renderReadme("templates/readme.tmpl", "README.md", stats, deltas); err != nil { + return fmt.Errorf("render readme: %w", err) + } + + fmt.Printf("updated %d agents\n", len(stats)) + return nil +} diff --git a/readme.go b/readme.go new file mode 100644 index 0000000..71502bf --- /dev/null +++ b/readme.go @@ -0,0 +1,96 @@ +package main + +import ( + "fmt" + "os" + "strings" + "text/template" + "time" +) + +type Row struct { + Rank int + NameWithOwner string + URL string + Stars int + Delta7d int + HasDelta bool + Language string + PushedAt string + Description string + Category string +} + +func renderReadme(tmplPath, outPath string, stats []Stat, deltas map[string]int) error { + rows := make([]Row, len(stats)) + for i, s := range stats { + delta, has := deltas[s.NameWithOwner] + rows[i] = Row{ + Rank: i + 1, + NameWithOwner: s.NameWithOwner, + URL: s.URL, + Stars: s.Stars, + Delta7d: delta, + HasDelta: has, + Language: s.Language, + PushedAt: s.PushedAt.Format("2006-01-02"), + Description: sanitizeCell(s.Description), + Category: s.Category, + } + } + + funcs := template.FuncMap{ + "formatDelta": func(d int, has bool) string { + if !has { + return "—" + } + if d > 0 { + return fmt.Sprintf("+%d", d) + } + if d < 0 { + return fmt.Sprintf("%d", d) + } + return "0" + }, + "formatStars": func(n int) string { + switch { + case n < 1000: + return fmt.Sprintf("%d", n) + case n < 1_000_000: + return fmt.Sprintf("%.1fk", float64(n)/1000) + default: + return fmt.Sprintf("%.1fM", float64(n)/1_000_000) + } + }, + } + + tmpl, err := template.New("").Funcs(funcs).ParseFiles(tmplPath) + if err != nil { + return err + } + + f, err := os.Create(outPath) + if err != nil { + return err + } + defer f.Close() + + name := tmplPath + if i := strings.LastIndex(tmplPath, "/"); i >= 0 { + name = tmplPath[i+1:] + } + + return tmpl.ExecuteTemplate(f, name, map[string]any{ + "Rows": rows, + "UpdatedAt": time.Now().UTC().Format("2006-01-02 15:04 UTC"), + "Total": len(rows), + }) +} + +// sanitizeCell escapes pipe and newline characters so descriptions stay in one table cell. +func sanitizeCell(s string) string { + s = strings.ReplaceAll(s, "|", "\\|") + s = strings.ReplaceAll(s, "\n", " ") + s = strings.ReplaceAll(s, "\r", " ") + return strings.TrimSpace(s) +} diff --git a/templates/readme.tmpl b/templates/readme.tmpl new file mode 100644 index 0000000..1f1c2d3 --- /dev/null +++ b/templates/readme.tmpl @@ -0,0 +1,39 @@ +# Awesome Coding Agents + +> Curated ranking of AI agent coding tools, sorted by GitHub stars. +> Updated daily by GitHub Actions. + +**Last updated:** {{.UpdatedAt}} · **Tracked:** {{.Total}} repos + +| # | Repo | Stars | Δ7d | Language | Last push | Description | +|---|------|------:|----:|----------|-----------|-------------| +{{- range .Rows }} +| {{ .Rank }} | [{{ .NameWithOwner }}]({{ .URL }}) | {{ formatStars .Stars }} | {{ formatDelta .Delta7d .HasDelta }} | {{ .Language }} | {{ .PushedAt }} | {{ .Description }} | +{{- end }} + +--- + +## How it works + +1. `data/agents.yml` is the curated source list. +2. A daily GitHub Actions workflow (`.github/workflows/update.yml`) runs the Go updater. +3. The updater fetches live repo metadata via the GitHub GraphQL API in one batched query. +4. Star counts are appended to `data/history.jsonl` for 7-day delta computation. +5. This `README.md` is regenerated from `templates/readme.tmpl` and committed back to the repo. + +## Contributing + +Add an agent to [`data/agents.yml`](data/agents.yml): + +```yaml +agents: + - owner: github-username-or-org + repo: repository-name + category: cli # cli | ide | extension | library | research | web +``` + +Open a PR. The next daily run picks it up automatically. + +## License + +Apache-2.0