chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
export function formatCompact(n: number): string {
|
||||
if (n >= 10_000) return `${(n / 1000).toFixed(1).replace(/\.0$/, "")}K`;
|
||||
if (n >= 1_000) return `${(n / 1000).toFixed(1)}K`;
|
||||
return n.toString();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"version": "0.9.26",
|
||||
"mcpTools": 53,
|
||||
"hooks": 12,
|
||||
"restEndpoints": 126,
|
||||
"testsPassing": 1394,
|
||||
"generatedAt": "2026-06-03T10:14:01.074Z"
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import "server-only";
|
||||
|
||||
export interface RepoStats {
|
||||
stars: number;
|
||||
forks: number;
|
||||
issues: number;
|
||||
}
|
||||
|
||||
const REPO = "rohitg00/agentmemory";
|
||||
|
||||
export async function fetchRepoStats(): Promise<RepoStats> {
|
||||
const fallback: RepoStats = { stars: 0, forks: 0, issues: 0 };
|
||||
try {
|
||||
const headers: Record<string, string> = {
|
||||
accept: "application/vnd.github+json",
|
||||
"user-agent": "agentmemory-website",
|
||||
};
|
||||
if (process.env.GITHUB_TOKEN) {
|
||||
headers.authorization = `Bearer ${process.env.GITHUB_TOKEN}`;
|
||||
}
|
||||
const res = await fetch(`https://api.github.com/repos/${REPO}`, {
|
||||
headers,
|
||||
next: { revalidate: 3600 },
|
||||
});
|
||||
if (!res.ok) return fallback;
|
||||
const data = (await res.json()) as {
|
||||
stargazers_count?: number;
|
||||
forks_count?: number;
|
||||
open_issues_count?: number;
|
||||
};
|
||||
return {
|
||||
stars: data.stargazers_count ?? 0,
|
||||
forks: data.forks_count ?? 0,
|
||||
issues: data.open_issues_count ?? 0,
|
||||
};
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import "server-only";
|
||||
import generated from "./generated-meta.json" with { type: "json" };
|
||||
|
||||
export interface ProjectMeta {
|
||||
version: string;
|
||||
mcpTools: number;
|
||||
hooks: number;
|
||||
restEndpoints: number;
|
||||
testsPassing: number;
|
||||
}
|
||||
|
||||
// Values are baked at build time by scripts/gen-meta.mjs (see package.json
|
||||
// prebuild). Runtime file lookups via import.meta.url break after Next.js
|
||||
// moves server components into .next/server/ — `../..` from there stays
|
||||
// inside the build cache, not at the repo root, and version silently falls
|
||||
// back to "0.0.0". Static JSON import sidesteps that entirely.
|
||||
export function getProjectMeta(): ProjectMeta {
|
||||
return {
|
||||
version: generated.version,
|
||||
mcpTools: generated.mcpTools,
|
||||
hooks: generated.hooks,
|
||||
restEndpoints: generated.restEndpoints,
|
||||
testsPassing: generated.testsPassing,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user