File size: 28,608 Bytes
3f98f93 000e1d5 3f98f93 70181fd 3f98f93 70181fd 3f98f93 03dad1a 70181fd 79c068a 70181fd 03dad1a 3f98f93 5110fd8 3f98f93 5110fd8 3f98f93 7579239 3f98f93 000e1d5 3f98f93 b80e7b6 3f98f93 000e1d5 a0eab66 3f98f93 b37f0a1 2b4c297 b37f0a1 3f98f93 4b28c07 38c2fdf 4b28c07 3e50656 4b28c07 3e50656 4b28c07 3e50656 4b28c07 3e50656 4b28c07 475f352 38c2fdf 3f98f93 3e50656 3f98f93 3e50656 3f98f93 3e50656 3f98f93 3e50656 3f98f93 029b560 3f98f93 1506df4 e96f5f5 3f98f93 e96f5f5 3f98f93 a2e4ff7 3e50656 a2e4ff7 3e50656 a2e4ff7 3e50656 a2e4ff7 3e50656 a2e4ff7 3f98f93 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 |
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Awesome Self-Evolving Agents</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
:root {
--primary: #6366f1;
--primary-dark: #4f46e5;
--secondary: #10b981;
--dark: #0f172a;
--light: #f8fafc;
--gray: #94a3b8;
--card-bg: #1e293b;
--transition: all 0.3s ease;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
color: var(--light);
line-height: 1.6;
overflow-x: hidden;
}
.container {
width: 90%;
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
}
header {
background: rgba(15, 23, 42, 0.8);
backdrop-filter: blur(10px);
padding: 20px 0;
position: sticky;
top: 0;
z-index: 100;
border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
display: flex;
align-items: center;
gap: 12px;
font-size: 1.8rem;
font-weight: 700;
color: var(--light);
text-decoration: none;
}
.logo i {
color: var(--secondary);
}
.nav-links {
display: flex;
gap: 30px;
}
.nav-links a {
color: var(--gray);
text-decoration: none;
font-weight: 500;
transition: var(--transition);
position: relative;
}
.nav-links a:hover {
color: var(--light);
}
.nav-links a::after {
content: '';
position: absolute;
bottom: -5px;
left: 0;
width: 0;
height: 2px;
background: var(--primary);
transition: var(--transition);
}
.nav-links a:hover::after {
width: 100%;
}
.hero {
padding: 100px 0;
text-align: center;
position: relative;
}
.hero::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: radial-gradient(circle at center, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
z-index: -1;
}
.hero h1 {
font-size: clamp(2.5rem, 5vw, 4rem);
font-weight: 800;
margin-bottom: 20px;
background: linear-gradient(to right, #818cf8, #60a5fa);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
line-height: 1.2;
}
.hero p {
font-size: clamp(1.1rem, 2vw, 1.3rem);
max-width: 700px;
margin: 0 auto 40px;
color: var(--gray);
}
.btn {
display: inline-block;
padding: 15px 35px;
background: var(--primary);
color: white;
border-radius: 50px;
text-decoration: none;
font-weight: 600;
transition: var(--transition);
border: none;
cursor: pointer;
font-size: 1rem;
box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
}
.btn:hover {
background: var(--primary-dark);
transform: translateY(-3px);
box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}
.btn-secondary {
background: transparent;
border: 2px solid var(--primary);
color: var(--primary);
margin-left: 15px;
}
.btn-secondary:hover {
background: var(--primary);
color: white;
}
.section {
padding: 80px 0;
}
.section-title {
text-align: center;
font-size: 2.5rem;
margin-bottom: 40px; /* 缩短一点间距,更紧凑 */
position: relative;
}
.section-title::after {
content: '';
position: absolute;
bottom: -15px;
left: 50%;
transform: translateX(-50%);
width: 80px;
height: 4px;
background: var(--secondary);
border-radius: 2px;
}
.features {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 30px;
margin-top: 50px;
}
.feature-card {
background: var(--card-bg);
border-radius: 15px;
padding: 30px;
transition: var(--transition);
border: 1px solid rgba(148, 163, 184, 0.1);
}
.feature-card:hover {
transform: translateY(-10px);
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
border-color: rgba(99, 102, 241, 0.3);
}
.feature-card i {
font-size: 2.5rem;
color: var(--primary);
margin-bottom: 20px;
}
.feature-card h3 {
font-size: 1.5rem;
margin-bottom: 15px;
}
.feature-card p {
color: var(--gray);
}
.paper-section {
background: rgba(30, 41, 59, 0.5);
border-radius: 20px;
padding: 50px;
margin: 50px 0;
border: 1px solid rgba(148, 163, 184, 0.2);
}
.paper-content {
display: grid;
grid-template-columns: 1fr 300px;
gap: 40px;
align-items: center;
}
.paper-info h2 {
font-size: 2rem;
margin-bottom: 20px;
}
.paper-info p {
margin-bottom: 25px;
color: var(--gray);
}
.paper-actions {
display: flex;
gap: 15px;
flex-wrap: wrap;
}
.paper-image {
border-radius: 10px;
overflow: hidden;
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}
.paper-image img {
width: 100%;
height: auto;
display: block;
transition: var(--transition);
}
.paper-image img:hover {
transform: scale(1.03);
}
.github-stats {
display: flex;
justify-content: center;
gap: 30px;
margin-top: 40px;
flex-wrap: wrap;
}
.stat-card {
background: var(--card-bg);
border-radius: 15px;
padding: 25px;
text-align: center;
min-width: 150px;
border: 1px solid rgba(148, 163, 184, 0.1);
}
.stat-card i {
font-size: 2rem;
color: var(--secondary);
margin-bottom: 15px;
}
.stat-card .number {
font-size: 2rem;
font-weight: 700;
margin-bottom: 5px;
}
.stat-card .label {
color: var(--gray);
font-size: 0.9rem;
}
.team {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 30px;
margin-top: 50px;
}
.team-member {
background: var(--card-bg);
border-radius: 15px;
padding: 30px;
text-align: center;
transition: var(--transition);
}
.team-member:hover {
transform: translateY(-10px);
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.team-member img {
width: 120px;
height: 120px;
border-radius: 50%;
object-fit: cover;
margin-bottom: 20px;
border: 3px solid var(--primary);
}
.team-member h3 {
font-size: 1.5rem;
margin-bottom: 10px;
}
.team-member p {
color: var(--gray);
margin-bottom: 15px;
}
.abstract {
background: var(--card-bg);
border-radius: 15px;
padding: 30px;
margin: 0 auto; /* 真正居中 */
max-width: 1000px; /* 摘要区宽度 */
border-left: 4px solid var(--primary);
text-align: justify; /* 两端对齐 */
}
.abstract h3 {
text-align: center; /* 标题居中 */
font-weight: bold;
margin-bottom: 1rem;
}
.abstract p {
text-indent: 2em; /* 首行缩进2字符 */
margin-bottom: 1rem; /* 段落间距 */
}
.abstract em {
font-style: italic; /* 斜体保持论文风格 */
}
.social-links {
display: flex;
justify-content: center;
gap: 15px;
}
.social-links a {
display: inline-flex;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
border-radius: 50%;
background: rgba(148, 163, 184, 0.1);
color: var(--light);
transition: var(--transition);
}
.social-links a:hover {
background: var(--primary);
transform: translateY(-3px);
}
footer {
background: rgba(15, 23, 42, 0.9);
padding: 50px 0 20px;
text-align: center;
border-top: 1px solid rgba(148, 163, 184, 0.1);
}
.footer-content {
margin-bottom: 40px;
}
.footer-logo {
font-size: 2rem;
font-weight: 700;
margin-bottom: 20px;
display: inline-block;
}
.footer-links {
display: flex;
justify-content: center;
gap: 30px;
margin-bottom: 30px;
flex-wrap: wrap;
}
.footer-links a {
color: var(--gray);
text-decoration: none;
transition: var(--transition);
}
.footer-links a:hover {
color: var(--light);
}
.copyright {
color: var(--gray);
font-size: 0.9rem;
padding-top: 20px;
border-top: 1px solid rgba(148, 163, 184, 0.1);
}
@media (max-width: 768px) {
.navbar {
flex-direction: column;
gap: 20px;
}
.nav-links {
gap: 15px;
flex-wrap: wrap;
justify-content: center;
}
.hero {
padding: 60px 0;
}
.paper-content {
grid-template-columns: 1fr;
text-align: center;
}
.paper-actions {
justify-content: center;
}
.paper-section {
padding: 30px;
}
.section {
padding: 50px 0;
}
}
.highlight {
color: var(--secondary);
font-weight: 600;
}
.code-block {
background: rgba(30, 41, 59, 0.8);
border-radius: 10px;
padding: 20px;
margin: 20px 0;
font-family: monospace;
overflow-x: auto;
border: 1px solid rgba(148, 163, 184, 0.2);
}
/* .abstract {
background: var(--card-bg);
border-radius: 15px;
padding: 30px;
margin: 40px 0;
border-left: 4px solid var(--primary);
} */
.authors-list {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 10px;
margin: 20px 0;
}
.author-item {
background: rgba(99, 102, 241, 0.1);
padding: 8px 15px;
border-radius: 20px;
font-size: 0.9rem;
}
.institutions-list {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 15px;
margin-top: 15px;
font-size: 0.85rem;
color: var(--gray);
}
.survey-icon {
font-size: 3rem;
color: var(--primary);
text-align: center;
margin-bottom: 20px;
}
</style>
</head>
<body id="top">
<header>
<div class="container">
<nav class="navbar">
<a href="#" class="logo">
<i class="fa-solid fa-robot"></i>
Self-Evolving AI Agents Survey
</a>
<div class="nav-links">
<a href="#overview">Overview</a>
<a href="#framework">Framework</a>
<!-- <a href="#paper">Paper</a> -->
<a href="#authors">Authors</a>
<a href="#github">GitHub</a>
</div>
</nav>
</div>
</header>
<section class="hero">
<div class="container">
<div class="survey-icon">
<i class="fas fa-book-open"></i>
</div>
<h1>A Comprehensive Survey of Self-Evolving AI Agents</h1>
<p>A New Paradigm Bridging Foundation Models and Lifelong Agentic Systems</p>
<div class="hero-actions">
<a href="https://arxiv.org/abs/2508.07407" class="btn" target="_blank">Read Paper</a>
<a href="https://github.com/EvoAgentX/Awesome-Self-Evolving-Agents" class="btn btn-secondary" target="_blank">View on GitHub</a>
</div>
</div>
</section>
<section id="overview" class="section">
<div class="container">
<h2 class="section-title">Overview</h2>
<div class="abstract">
<h3>Abstract</h3>
<p>
Recent advances in large language models (LLMs) have sparked growing interest in AI agents capable of solving complex, real-world tasks. However, most existing agent systems rely on manually crafted configurations that remain static after deployment, limiting their ability to adapt to dynamic and evolving environments. To address this limitation, recent research has explored agent <em>evolution</em> techniques that aim to automatically enhance agent systems based on interaction data and environmental feedback. This emerging direction lays the foundation for <em>self-evolving AI agents</em>, which bridge the static capabilities of foundation models with the continuous adaptability required by <em>lifelong agentic systems</em>. In this survey, we provide a comprehensive review of existing techniques for self-evolving agentic systems.
Specifically, we first introduce a <em>unified conceptual framework</em> that abstracts the feedback loop underlying the design of self-evolving agentic systems. The framework highlights four key components: <em>System inputs</em>, <em>Agent System</em>, <em>Environment</em>, and <em>Optimisers</em>, serving as a foundation for understanding and comparing different strategies. Based on this framework, we systematically review a wide range of self-evolving techniques that target different components of the agent system, including foundation models, agent prompts, memory, tools, workflows, and communication mechanisms across agents.
We also investigate domain-specific evolution strategies developed for specialised fields such as biomedicine, programming, and finance, where agent behaviour and optimisation objectives are tightly coupled with domain constraints. In addition, we provide a dedicated discussion on the <em>evaluation, safety, and ethical considerations</em> for self-evolving agentic systems, which are critical to ensuring their effectiveness and reliability.
This survey aims to provide researchers and practitioners with a systematic understanding of self-evolving AI agents, laying the foundation for the development of more adaptive, autonomous, and lifelong agentic systems.
</p>
</div>
</div>
</section>
<section id="framework" class="section">
<div class="container">
<h2 class="section-title">Conceptual Framework</h2>
<div class="features">
<div class="feature-card">
<i class="fas fa-sign-in-alt"></i>
<h3>System Inputs</h3>
<p>Dynamic data sources that provide information to the agent system. Includes user queries, environmental observations, and interaction data.</p>
</div>
<div class="feature-card">
<i class="fas fa-robot"></i>
<h3>Agent System</h3>
<p>The core AI agent components including foundation models, planning modules, memory systems, tools, workflows, and communication mechanisms.</p>
</div>
<div class="feature-card">
<i class="fas fa-globe"></i>
<h3>Environment</h3>
<p>The external world or specialized domain where agents operate, providing feedback and constraints that drive evolution.</p>
</div>
<div class="feature-card">
<i class="fas fa-cogs"></i>
<h3>Optimisers</h3>
<p>Mechanisms that enable agents to self-evolve by analyzing performance, identifying deficiencies, and implementing improvements.</p>
</div>
</div>
</div>
</section>
<section id="authors" class="section">
<div class="container">
<h2 class="section-title">Research Team</h2>
<div class="authors-list">
<span class="author-item">Jinyuan Fang* (1)</span>
<span class="author-item">Yanwen Peng* (2)</span>
<span class="author-item">Xi Zhang* (1)</span>
<span class="author-item">Yingxu Wang* (3)</span>
<span class="author-item">Xinhao Yi (1)</span>
<span class="author-item">Guibin Zhang (4)</span>
<span class="author-item">Yi Xu (5)</span>
<span class="author-item">Bin Wu (6)</span>
<span class="author-item">Siwei Liu (7)</span>
<span class="author-item">Zihao Li (1)</span>
<span class="author-item">Zhaochun Ren (8)</span>
<span class="author-item">Nikos Aletras (2)</span>
<span class="author-item">Xi Wang (2)</span>
<span class="author-item">Han Zhou (5)</span>
<span class="author-item">Zaiqiao Meng✉ (1)</span>
</div>
<div class="institutions-list">
<span>(1) University of Glasgow</span>
<span>(2) University of Sheffield</span>
<span>(3) Mohamed bin Zayed University of Artificial Intelligence</span>
<span>(4) National University of Singapore</span>
<span>(5) University of Cambridge</span>
<span>(6) University College London</span>
<span>(7) University of Aberdeen</span>
<span>(8) Leiden University</span>
</div>
<p style="text-align: center; margin-top: 30px; color: var(--gray);">
* Equal Contributor | ✉ Corresponding Author
</p>
</div>
</section>
<section id="github" class="section">
<div class="container">
<h2 class="section-title">EvoAgentX GitHub Repository</h2>
<div class="github-stats" data-repo="EvoAgentX/EvoAgentX">
<div class="stat-card">
<i class="fas fa-star"></i>
<div class="number" data-metric="stars">--</div>
<div class="label">Stars</div>
</div>
<div class="stat-card">
<i class="fas fa-code-branch"></i>
<div class="number" data-metric="forks">--</div>
<div class="label">Forks</div>
</div>
<div class="stat-card">
<i class="fas fa-bug"></i>
<div class="number" data-metric="issues">--</div>
<div class="label">Issues</div>
</div>
<div class="stat-card">
<i class="fas fa-users"></i>
<div class="number" data-metric="contributors">--</div>
<div class="label">Contributors</div>
</div>
</div>
<h2 class="section-title">Awesome Self-Evolving Agents GitHub Repository</h2>
<div class="github-stats" data-repo="EvoAgentX/Awesome-Self-Evolving-Agents">
<div class="stat-card">
<i class="fas fa-star"></i>
<div class="number" data-metric="stars">--</div>
<div class="label">Stars</div>
</div>
<div class="stat-card">
<i class="fas fa-code-branch"></i>
<div class="number" data-metric="forks">--</div>
<div class="label">Forks</div>
</div>
<div class="stat-card">
<i class="fas fa-bug"></i>
<div class="number" data-metric="issues">--</div>
<div class="label">Issues</div>
</div>
<div class="stat-card">
<i class="fas fa-users"></i>
<div class="number" data-metric="contributors">--</div>
<div class="label">Contributors</div>
</div>
</div>
<div class="paper-section">
<h3 style="text-align: center; margin-bottom: 20px;">Awesome Self-Evolving Agents Repository</h3>
<p style="text-align: center;">This repository contains a comprehensive collection of resources related to self-evolving AI agents, including:</p>
<ul style="max-width: 600px; margin: 20px auto; padding-left: 20px;">
<li>Papers and research articles on agent evolution techniques</li>
<li>Frameworks and methodologies for self-evolving systems</li>
<li>Case studies in domain-specific applications</li>
<li>Evaluation metrics and benchmarks</li>
<li>Safety and ethical considerations resources</li>
</ul>
<div style="text-align: center;">
<a href="https://github.com/EvoAgentX/Awesome-Self-Evolving-Agents" class="btn" target="_blank">Explore Repository</a>
</div>
</div>
</div>
</section>
<footer>
<div class="container">
<div class="footer-content">
<!-- 点击 logo 回到顶部 -->
<a href="#top" class="footer-logo">
<i class="fas fa-book"></i>
Self-Evolving AI Agents Survey
</a>
<p>A comprehensive survey of techniques enabling AI agents to autonomously evolve their behaviors</p>
<div class="footer-links">
<a href="#overview">Overview</a>
<a href="#framework">Framework</a>
<a href="#paper">Paper</a>
<a href="#authors">Authors</a>
<a href="https://github.com/EvoAgentX/Awesome-Self-Evolving-Agents" target="_blank" >GitHub</a>
</div>
</div>
<div class="copyright">
<p>© 2025 Self-Evolving AI Agents Survey. All rights reserved.</p>
</div>
</div>
</footer>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Smooth scrolling for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Header scroll effect
window.addEventListener('scroll', function() {
const header = document.querySelector('header');
if (window.scrollY > 50) {
header.style.boxShadow = '0 4px 20px rgba(0, 0, 0, 0.3)';
} else {
header.style.boxShadow = 'none';
}
});
// Add animation to feature cards when they come into view
const featureCards = document.querySelectorAll('.feature-card');
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = 1;
entry.target.style.transform = 'translateY(0)';
}
});
}, { threshold: 0.1 });
featureCards.forEach(card => {
card.style.opacity = 0;
card.style.transform = 'translateY(20px)';
card.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
observer.observe(card);
});
// Add animation to stat cards when they come into view
const statCards = document.querySelectorAll('.stat-card');
statCards.forEach(card => {
card.style.opacity = 0;
card.style.transform = 'translateY(20px)';
card.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
observer.observe(card);
});
});
</script>
<script>
const fmt = n => Intl.NumberFormat('en', { notation: 'compact', maximumFractionDigits: 1 }).format(n);
async function updateOneStats(container) {
const repo = container.dataset.repo;
if (!repo) return;
try {
const [repoRes, contribRes] = await Promise.all([
fetch(`https://api.github.com/repos/${repo}`),
fetch(`https://api.github.com/repos/${repo}/contributors?per_page=1&anon=0`)
]);
const repoData = await repoRes.json();
// contributors:优先从 Link 头拿最后一页页码
let contributors = 0;
const link = contribRes.headers.get('link');
if (link && /&page=(\d+)>;\s*rel="last"/.test(link)) {
contributors = parseInt(RegExp.$1, 10);
} else {
const arr = await contribRes.json();
contributors = Array.isArray(arr) ? arr.length : 0;
}
const setNum = (metric, val) => {
const el = container.querySelector(`.number[data-metric="${metric}"]`);
if (el) el.textContent = fmt(val);
};
setNum('stars', repoData.stargazers_count);
setNum('forks', repoData.forks_count);
setNum('issues', repoData.open_issues_count);
setNum('contributors', contributors);
} catch (e) {
console.error('GitHub stats fetch error:', e);
}
}
// 更新页面上所有带 data-repo 的区块
document.querySelectorAll('.github-stats[data-repo]').forEach(updateOneStats);
</script>
</body>
</html> |