Skip to content

Commit ad88660

Browse files
committed
Adding github stars components to intro and fixing token trains
1 parent b27e560 commit ad88660

6 files changed

Lines changed: 351 additions & 89 deletions

File tree

website/docs/intro.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ hide_table_of_contents: false
77

88
import AgentWorkStabilityDiagram from '@site/src/components/VisualElements/AgentWorkStabilityDiagram';
99
import DiagramFrame from '@site/src/components/VisualElements/DiagramFrame';
10+
import GitHubSocialProof from '@site/src/components/GitHubSocialProof';
1011
import OperatorTransformationDiagram from '@site/src/components/VisualElements/OperatorTransformationDiagram';
1112

1213
AI agents make execution cheap. They also make production judgment more valuable.
@@ -74,8 +75,8 @@ The dangerous runs are not the obviously broken ones. They look finished early
7475

7576
This book, the tools it references, and everything built around them are **100% open source, community-backed projects with no commercial agenda.**
7677

77-
- **Book source:** [github.com/agenticoding/agenticoding.github.io](https://github.com/agenticoding/agenticoding.github.io)
78-
- **ChunkHound:** [github.com/chunkhound/chunkhound](https://github.com/chunkhound/chunkhound)
79-
- **Pi agenticoding extension:** [github.com/agenticoding/pi-agenticoding](https://github.com/agenticoding/pi-agenticoding)
78+
- **Book source:** [github.com/agenticoding/agenticoding.github.io](https://github.com/agenticoding/agenticoding.github.io) <GitHubSocialProof repo="agenticoding/agenticoding.github.io" fallbackStars={102} variant="project" />
79+
- **ChunkHound:** [github.com/chunkhound/chunkhound](https://github.com/chunkhound/chunkhound) <GitHubSocialProof repo="chunkhound/chunkhound" fallbackStars={1400} variant="project" />
80+
- **Pi agenticoding extension:** [github.com/agenticoding/pi-agenticoding](https://github.com/agenticoding/pi-agenticoding) <GitHubSocialProof repo="agenticoding/pi-agenticoding" fallbackStars={18} variant="project" />
8081

8182
No paid tiers. No enterprise licenses. Nothing to buy. Everything here exists because the problems are real and the solutions should be shared.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
.hero,
2+
.project {
3+
display: inline-flex;
4+
gap: var(--space-0h);
5+
align-items: center;
6+
color: var(--text-body);
7+
font-family: var(--font-body);
8+
font-size: var(--text-sm);
9+
line-height: var(--lh-sm);
10+
}
11+
12+
.hero {
13+
color: var(--text-body);
14+
font-family: var(--font-body);
15+
font-size: var(--text-lg);
16+
font-weight: 400;
17+
line-height: var(--lh-lg);
18+
vertical-align: baseline;
19+
/* Overrides Docusaurus's generic content-link underline. */
20+
text-decoration: none !important;
21+
}
22+
23+
.hero:focus-visible {
24+
outline: 2px solid var(--text-heading);
25+
outline-offset: var(--space-0h);
26+
}
27+
28+
.hero svg,
29+
.project svg {
30+
flex: 0 0 auto;
31+
width: var(--icon-sm);
32+
height: var(--icon-sm);
33+
fill: none;
34+
stroke: currentColor;
35+
stroke-linejoin: miter;
36+
stroke-width: 2;
37+
}
38+
39+
.starCount {
40+
display: inline-flex;
41+
gap: var(--space-0h);
42+
align-items: baseline;
43+
}
44+
45+
.hero svg {
46+
width: var(--icon-md);
47+
height: var(--icon-md);
48+
}
49+
50+
.hero .label {
51+
font-size: var(--text-sm);
52+
}
53+
54+
.count {
55+
color: var(--text-heading);
56+
font-weight: 700;
57+
}
58+
59+
.label {
60+
color: var(--text-muted);
61+
font-size: var(--text-xs);
62+
font-weight: 500;
63+
white-space: nowrap;
64+
}
65+
66+
.project {
67+
margin-inline-start: var(--space-1);
68+
vertical-align: baseline;
69+
}
70+
71+
.starCount {
72+
transform: translateY(var(--space-px));
73+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import { useEffect, useState, type ReactNode } from 'react';
2+
3+
import styles from './index.module.css';
4+
5+
type GitHubSocialProofVariant = 'hero' | 'project';
6+
7+
interface GitHubSocialProofProps {
8+
repo: string;
9+
fallbackStars: number;
10+
variant: GitHubSocialProofVariant;
11+
}
12+
13+
interface GitHubRepository {
14+
stargazers_count: number;
15+
}
16+
17+
const starCountRequests = new Map<string, Promise<number | null>>();
18+
19+
function fetchStarCount(repo: string): Promise<number | null> {
20+
const cachedRequest = starCountRequests.get(repo);
21+
if (cachedRequest) return cachedRequest;
22+
23+
const request = fetch(`https://api.github.com/repos/${repo}`)
24+
.then(async (response) => {
25+
if (!response.ok) return null;
26+
const repository = (await response.json()) as GitHubRepository;
27+
return Number.isSafeInteger(repository.stargazers_count)
28+
? repository.stargazers_count
29+
: null;
30+
})
31+
.catch(() => null);
32+
starCountRequests.set(repo, request);
33+
return request;
34+
}
35+
36+
function useGitHubStars(repo: string, fallbackStars: number): number {
37+
const [stars, setStars] = useState(fallbackStars);
38+
39+
useEffect(() => {
40+
let active = true;
41+
fetchStarCount(repo).then((count) => {
42+
if (active && count !== null) setStars(count);
43+
});
44+
return () => {
45+
active = false;
46+
};
47+
}, [repo]);
48+
49+
return stars;
50+
}
51+
52+
function formatStars(stars: number): string {
53+
if (stars < 1_000) return String(stars);
54+
return `${(stars / 1_000).toFixed(stars < 10_000 ? 1 : 0).replace('.0', '')}k`;
55+
}
56+
57+
function StarIcon(): ReactNode {
58+
return (
59+
<svg viewBox="0 0 24 24" aria-hidden="true">
60+
<path d="m12 3 2.8 5.7 6.2.9-4.5 4.4 1.1 6.2-5.6-3-5.6 3 1.1-6.2L3 9.6l6.2-.9L12 3Z" />
61+
</svg>
62+
);
63+
}
64+
65+
function StarCount({
66+
stars,
67+
label = 'stars',
68+
}: {
69+
stars: number;
70+
label?: string;
71+
}): ReactNode {
72+
return (
73+
<span className={styles.starCount} aria-live="polite">
74+
<span className={styles.count}>{formatStars(stars)}</span>
75+
<span className={styles.label}>{label}</span>
76+
</span>
77+
);
78+
}
79+
80+
export default function GitHubSocialProof({
81+
repo,
82+
fallbackStars,
83+
variant,
84+
}: GitHubSocialProofProps): ReactNode {
85+
const stars = useGitHubStars(repo, fallbackStars);
86+
const starCount = <StarCount stars={stars} />;
87+
88+
if (variant === 'project') {
89+
return (
90+
<span className={styles.project}>
91+
<StarIcon />
92+
{starCount}
93+
</span>
94+
);
95+
}
96+
97+
return (
98+
<a
99+
className={styles.hero}
100+
href={`https://github.com/${repo}`}
101+
target="_blank"
102+
rel="noopener noreferrer"
103+
aria-label={`GitHub repository: ${formatStars(stars)} stars`}
104+
>
105+
<StarIcon />
106+
<StarCount stars={stars} label="GitHub stars" />
107+
</a>
108+
);
109+
}

website/src/components/SiteHero/index.module.css

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,12 @@
3838

3939
.actions {
4040
display: flex;
41-
flex-wrap: wrap;
42-
gap: var(--space-2);
43-
align-items: center;
44-
margin-top: var(--space-1);
41+
flex-direction: column;
42+
gap: var(--space-1);
43+
align-items: flex-start;
4544
}
4645

47-
.primaryAction,
48-
.secondaryAction {
46+
.primaryAction {
4947
min-height: var(--target-lg);
5048
display: inline-flex;
5149
align-items: center;
@@ -71,20 +69,7 @@
7169
text-decoration: none;
7270
}
7371

74-
.secondaryAction {
75-
color: var(--text-heading);
76-
text-decoration-line: underline;
77-
text-decoration-thickness: 1px;
78-
text-underline-offset: 3px;
79-
}
80-
81-
.secondaryAction:hover {
82-
color: var(--text-heading);
83-
text-decoration-thickness: 2px;
84-
}
85-
86-
.primaryAction:focus-visible,
87-
.secondaryAction:focus-visible {
72+
.primaryAction:focus-visible {
8873
outline: 2px solid var(--text-heading);
8974
outline-offset: var(--space-0h);
9075
}
@@ -95,13 +80,7 @@
9580
line-height: var(--lh-2xl);
9681
}
9782

98-
.actions {
99-
display: grid;
100-
width: 100%;
101-
}
102-
103-
.primaryAction,
104-
.secondaryAction {
83+
.primaryAction {
10584
width: 100%;
10685
}
10786
}

website/src/components/SiteHero/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Link from '@docusaurus/Link';
22
import Heading from '@theme/Heading';
33
import { type ReactNode } from 'react';
44

5+
import GitHubSocialProof from '../GitHubSocialProof';
56
import InlineEmojiImage from '../VisualElements/InlineEmojiImage';
67
import { EMOJI, type EmojiAsset } from '../VisualElements/emojiAssets';
78
import styles from './index.module.css';
@@ -29,7 +30,12 @@ function HeroCopy() {
2930
An advanced reference for production work
3031
</p>
3132
<Heading as="h1" className={styles.title}>
32-
AI agents write code. You still ship software.
33+
AI agents write code. You still ship software.{' '}
34+
<GitHubSocialProof
35+
repo="agenticoding/agenticoding.github.io"
36+
fallbackStars={102}
37+
variant="hero"
38+
/>
3339
</Heading>
3440
<p className={styles.lead}>
3541
An advanced reference book for operating coding agents in production –
@@ -48,12 +54,6 @@ function HeroActions() {
4854
label="Read Chapter 1: LLMs Demystified"
4955
icon={EMOJI.rightArrow}
5056
/>
51-
<HeroAction
52-
className={styles.secondaryAction}
53-
href="#where-is-the-work-stuck"
54-
label="Find your starting point"
55-
icon={EMOJI.downArrow}
56-
/>
5757
</div>
5858
);
5959
}

0 commit comments

Comments
 (0)