25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(docs): remove public GitHub API dependencies
t8y2ca11b166f8b8
diff --git a/.github/workflows/contributors.yml b/.github/workflows/contributors.ymlindex 0e73f4f970..a72b30ed06 100644--- a/.github/workflows/contributors.yml+++ b/.github/workflows/contributors.yml@@ -2,7 +2,7 @@ name: Update Contributorson:schedule:- - cron: "23 3 * * 1"+ - cron: "0 18 * * *"workflow_dispatch:permissions:diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.ymlindex 352bab3206..5922a45c64 100644--- a/.github/workflows/docs.yml+++ b/.github/workflows/docs.yml@@ -5,7 +5,8 @@ on:branches: [main]paths: ["docs/**"]workflow_run:- workflows: ["Publish Packages"]+ # Release and agent metadata are embedded during the static build, so wait for their R2 producers.+ workflows: ["Sync Changelog to R2", "Agents Release"]types: [completed]workflow_dispatch:diff --git a/docs/app/[lang]/drivers/DriversClient.tsx b/docs/app/[lang]/drivers/DriversClient.tsxindex 05f742c697..e1fe517391 100644--- a/docs/app/[lang]/drivers/DriversClient.tsx+++ b/docs/app/[lang]/drivers/DriversClient.tsx@@ -1,10 +1,10 @@"use client";-import { useCallback, useEffect, useMemo, useState } from "react";+import { useEffect, useMemo, useState } from "react";import { useParams } from "next/navigation";import { LandingNav } from "@/components/landing/LandingNav";-import { downloadLinksFor, fetchAgentDownloadCatalog, formatSize, type AgentDownloadCatalog, type DownloadSource, type JreDisplayEntry, type NativeAgentDisplayEntry, type OfflineBundleEntry } from "@/lib/agentRegistry";-import { AlertTriangle, Archive, Cpu, Database, Download, Loader2, Plug, Search, Terminal, X } from "lucide-react";+import { downloadLinksFor, formatSize, type AgentDownloadCatalog, type DownloadSource, type JreDisplayEntry, type NativeAgentDisplayEntry, type OfflineBundleEntry } from "@/lib/agentRegistry";+import { Archive, Cpu, Database, Download, Plug, Search, Terminal, X } from "lucide-react";const i18n = {en: {@@ -22,9 +22,6 @@ const i18n = {nativeAgentsDesc: "Platform-specific offline ZIPs for Oracle, KingBase, and XuguDB. Import the ZIP directly in Driver Manager.",jre: "Java Runtime (JRE)",jreDesc: "JRE packages used by agent-based database drivers. Required for Oracle, SQL Server, and other agent-managed connections.",- loading: "Loading driver catalog...",- error: "Unable to load driver catalog. Please check your network connection.",- retry: "Retry",download: "Download",installMethod: "Install",version: "Version",@@ -61,9 +58,6 @@ const i18n = {nativeAgentsDesc: "Oracle、人大金仓和虚谷的按平台单驱动离线包,可直接在驱动管理中导入 ZIP。",jre: "Java 运行时 (JRE)",jreDesc: "Agent 驱动所需的 JRE 环境,Oracle、SQL Server 等数据库通过 Agent 连接时需要。",- loading: "正在加载驱动列表...",- error: "加载驱动列表失败,请检查网络连接。",- retry: "重试",download: "下载",installMethod: "安装方式",version: "版本",@@ -134,40 +128,17 @@ function matchesSearch(values: Array<string | number | undefined>, query: stringreturn values.filter(Boolean).join(" ").toLowerCase().includes(query);}-export function DriversClient() {+export function DriversClient({ initialCatalog }: { initialCatalog: AgentDownloadCatalog }) {const params = useParams();const rawLang = params?.lang as string | undefined;const lang: "en" | "cn" = rawLang === "cn" ? "cn" : "en";const t = i18n[lang];- const [catalog, setCatalog] = useState<AgentDownloadCatalog | null>(null);- const [loading, setLoading] = useState(true);- const [error, setError] = useState<string | null>(null);+ const catalog = initialCatalog;const [activeTab, setActiveTab] = useState<ActiveTab>("bundles");const [searchQuery, setSearchQuery] = useState("");const [selectedNativePlatforms, setSelectedNativePlatforms] = useState<Record<string, string>>({});- const loadCatalog = useCallback(async () => {- setLoading(true);- setError(null);- try {- const data = await fetchAgentDownloadCatalog();- if (data) {- setCatalog(data);- } else {- setError("Unable to load driver catalog");- }- } catch {- setError("Unable to load driver catalog");- } finally {- setLoading(false);- }- }, []);-- useEffect(() => {- loadCatalog();- }, [loadCatalog]);-const bundles = catalog?.bundles ?? [];const drivers = catalog?.drivers ?? [];const nativeAgents = catalog?.nativeAgents ?? [];@@ -243,24 +214,7 @@ export function DriversClient() {</section><section className="max-w-[1180px] mx-auto px-7 pb-20 max-[760px]:px-[18px]">- {loading && (- <div className="flex items-center justify-center gap-3 py-20 text-landing-muted">- <Loader2 size={20} className="animate-spin" />- <span className="text-sm">{t.loading}</span>- </div>- )}-- {error && !loading && (- <div className="flex flex-col items-center gap-4 py-20">- <AlertTriangle size={28} className="text-yellow-500" />- <span className="text-landing-muted text-sm">{t.error}</span>- <button type="button" onClick={loadCatalog} className="landing-nav-link rounded-[7px] px-4 py-2 text-sm font-medium border border-landing-line">- {t.retry}- </button>- </div>- )}-- {catalog && !loading && (+ {catalog && (<><div className="mb-3 flex items-center gap-2 rounded-[7px] border border-landing-blue/30 bg-landing-blue/10 px-3 py-2 text-xs leading-[1.55] text-landing-sky"><Download size={14} className="shrink-0" />diff --git a/docs/app/[lang]/drivers/page.tsx b/docs/app/[lang]/drivers/page.tsxindex 5dc331d41d..49126be6ed 100644--- a/docs/app/[lang]/drivers/page.tsx+++ b/docs/app/[lang]/drivers/page.tsx@@ -1,4 +1,5 @@import { DriversClient } from "./DriversClient";+import { fetchAgentDownloadCatalog } from "@/lib/agentRegistrySource";import { buildMetadata } from "@/lib/metadata";import type { Metadata } from "next";@@ -27,6 +28,8 @@ export async function generateMetadata({ params }: { params: Promise<{ lang: str});}-export default function DriversPage() {- return <DriversClient />;+export default async function DriversPage() {+ const catalog = await fetchAgentDownloadCatalog();+ if (!catalog) throw new Error("Unable to generate the static driver catalog from R2 or CNB");+ return <DriversClient initialCatalog={catalog} />;}diff --git a/docs/app/[lang]/page.tsx b/docs/app/[lang]/page.tsxindex 72918af11e..dadbd7ccea 100644--- a/docs/app/[lang]/page.tsx+++ b/docs/app/[lang]/page.tsx@@ -10,14 +10,14 @@ import { InstallTabs } from "@/components/landing/InstallTabs";import { LandingLatestUpdates } from "@/components/landing/LandingLatestUpdates";import { RevealSection } from "@/components/landing/RevealSection";import { ContributorsWallContent } from "@/components/landing/ContributorsWall";-import { fetchContributors } from "@/lib/contributors";+import contributorSnapshot from "@/data/contributors.json";+import type { ContributorActivityData } from "@/lib/contributorActivity";+import { contributorsFromActivity } from "@/lib/contributors";import { getAppVersion } from "@/lib/appVersion";import { fetchChangelog } from "@/lib/changelog";import { fetchLatestReleaseInfo } from "@/lib/latestRelease";import { ArrowRight, Bot, Database, FileCode, GitCompare, Network, Search, Shield, Table, Terminal, Zap } from "lucide-react";-const fallbackStarLabel = "1.3k+";-function formatStars(count: number) {if (count >= 1000) {return `${(Math.floor(count / 100) / 10).toFixed(1)}k+`;@@ -26,22 +26,6 @@ function formatStars(count: number) {return `${count}+`;}-async function getGitHubStarLabel() {- try {- const response = await fetch("https://api.github.com/repos/t8y2/dbx", {- headers: { Accept: "application/vnd.github+json" },- next: { revalidate: 60 * 60 * 6 },- });-- if (!response.ok) return fallbackStarLabel;-- const data = (await response.json()) as { stargazers_count?: number };- return typeof data.stargazers_count === "number" ? formatStars(data.stargazers_count) : fallbackStarLabel;- } catch {- return fallbackStarLabel;- }-}-function metrics(starLabel: string) {return {en: [@@ -460,11 +444,12 @@ export default async function LandingPage({ params }: { params: Promise<{ lang:const t = i18nText[l];const workflowItems = workflows[l];const capabilityItems = capabilities[l];- const starLabel = await getGitHubStarLabel();+ const contributorData = contributorSnapshot as ContributorActivityData;+ const starLabel = formatStars(contributorData.stars);const metricItems = metrics(starLabel)[l];const appVersion = getAppVersion();const [initialChangelog, initialLatestRelease] = await Promise.all([fetchChangelog(l), fetchLatestReleaseInfo()]);- const contributors = await fetchContributors();+ const contributors = contributorsFromActivity(contributorData.contributors);const initialDownloadVersion = initialLatestRelease?.version ?? appVersion;const testimonialItems = testimonials[l];diff --git a/docs/components/landing/ChangelogRuntime.tsx b/docs/components/landing/ChangelogRuntime.tsxindex 355613d24d..6b045fda51 100644--- a/docs/components/landing/ChangelogRuntime.tsx+++ b/docs/components/landing/ChangelogRuntime.tsx@@ -1,8 +1,7 @@"use client";-import { useEffect, useState } from "react";import { ChangelogList } from "@/components/landing/ChangelogList";-import { fetchChangelog, type ChangelogRelease } from "@/lib/changelog";+import type { ChangelogRelease } from "@/lib/changelog";type ChangelogRuntimeProps = {lang: "en" | "cn";@@ -11,39 +10,17 @@ type ChangelogRuntimeProps = {const text = {en: {- loading: "Loading releases...",empty: "No releases found.",},cn: {- loading: "正在加载版本记录...",empty: "暂无版本记录。",},};export function ChangelogRuntime({ lang, initialReleases = [] }: ChangelogRuntimeProps) {- const [releases, setReleases] = useState<ChangelogRelease[] | null>(initialReleases);-- useEffect(() => {- let active = true;-- fetchChangelog(lang).then((data) => {- if (active && data.releases.length > 0) {- setReleases(data.releases);- }- });-- return () => {- active = false;- };- }, [lang]);-- if (releases === null) {- return <p className="text-landing-muted py-12">{text[lang].loading}</p>;- }-- if (releases.length === 0) {+ if (initialReleases.length === 0) {return <p className="text-landing-muted py-12">{text[lang].empty}</p>;}- return <ChangelogList releases={releases} lang={lang} />;+ return <ChangelogList releases={initialReleases} lang={lang} />;}diff --git a/docs/components/landing/InstallTabs.tsx b/docs/components/landing/InstallTabs.tsxindex 1f1c8514cc..bec0446f2b 100644--- a/docs/components/landing/InstallTabs.tsx+++ b/docs/components/landing/InstallTabs.tsx@@ -2,8 +2,7 @@import { ChevronDown, Download, Server } from "lucide-react";import { useEffect, useMemo, useState } from "react";-import { createInstallOptions, type InstallOption } from "@/lib/downloadLinks";-import { fetchLatestReleaseInfo } from "@/lib/latestRelease";+import { createInstallOptions } from "@/lib/downloadLinks";type InstallTabsProps = {lang: "en" | "cn";@@ -44,8 +43,7 @@ function PlatformIcon({ id, size, variant }: { id: string; size: number; variant}export function InstallTabs({ lang, version }: InstallTabsProps) {- const [downloadVersion, setDownloadVersion] = useState(version);- const options = useMemo(() => createInstallOptions(lang, downloadVersion), [lang, downloadVersion]);+ const options = useMemo(() => createInstallOptions(lang, version), [lang, version]);const [open, setOpen] = useState(false);const [platformId, setPlatformId] = useState("macos-arm");@@ -53,21 +51,6 @@ export function InstallTabs({ lang, version }: InstallTabsProps) {setPlatformId(detectPlatformId());}, []);- useEffect(() => {- let active = true;-- setDownloadVersion(version);- fetchLatestReleaseInfo().then((release) => {- if (active && release?.version) {- setDownloadVersion(release.version);- }- });-- return () => {- active = false;- };- }, [version]);-const primary = useMemo(() => options.find((o) => o.id === platformId) ?? options[0], [options, platformId]);const menuOptions = useMemo(() => options.filter((o) => o.id !== platformId), [options, platformId]);diff --git a/docs/components/landing/LandingLatestUpdates.tsx b/docs/components/landing/LandingLatestUpdates.tsxindex 369fe04a34..8a4300d337 100644--- a/docs/components/landing/LandingLatestUpdates.tsx+++ b/docs/components/landing/LandingLatestUpdates.tsx@@ -2,11 +2,10 @@import Link from "next/link";import { ArrowRight, CheckCircle2 } from "lucide-react";-import { useEffect, useState } from "react";import { RevealSection } from "@/components/landing/RevealSection";-import { fetchChangelog, type ChangelogRelease } from "@/lib/changelog";+import type { ChangelogRelease } from "@/lib/changelog";import { buildLandingLatestUpdates } from "@/lib/landingLatest";-import { fetchLatestReleaseInfo, type LatestReleaseInfo } from "@/lib/latestRelease";+import type { LatestReleaseInfo } from "@/lib/latestRelease";type LandingLatestUpdatesProps = {lang: "en" | "cn";@@ -16,22 +15,7 @@ type LandingLatestUpdatesProps = {};export function LandingLatestUpdates({ lang, fallbackVersion, initialRelease, initialLatestRelease }: LandingLatestUpdatesProps) {- const [latest, setLatest] = useState(() => buildLandingLatestUpdates(lang, initialRelease, fallbackVersion, initialLatestRelease));-- useEffect(() => {- let active = true;-- setLatest(buildLandingLatestUpdates(lang, initialRelease, fallbackVersion, initialLatestRelease));- Promise.all([fetchLatestReleaseInfo(), fetchChangelog(lang)]).then(([releaseInfo, data]) => {- if (!active) return;-- setLatest(buildLandingLatestUpdates(lang, data.releases[0] ?? initialRelease, fallbackVersion, releaseInfo ?? initialLatestRelease));- });-- return () => {- active = false;- };- }, [lang, fallbackVersion, initialRelease, initialLatestRelease]);+ const latest = buildLandingLatestUpdates(lang, initialRelease, fallbackVersion, initialLatestRelease);return (<RevealSection className="grid grid-cols-[minmax(86px,0.16fr)_minmax(210px,0.32fr)_minmax(0,0.38fr)_max-content] gap-[22px] items-center max-w-[1180px] mx-auto px-7 border-t border-b border-landing-line mt-[62px] py-6 max-[1040px]:grid-cols-[minmax(0,1fr)_max-content] max-[760px]:block max-[760px]:px-[18px]">diff --git a/docs/lib/agentRegistry.test.ts b/docs/lib/agentRegistry.test.tsindex 7f128955e5..b67fefdf6d 100644--- a/docs/lib/agentRegistry.test.ts+++ b/docs/lib/agentRegistry.test.ts@@ -1,7 +1,8 @@import assert from "node:assert/strict";import { afterEach, test, vi } from "vitest";import driverVersions from "../../agents/versions.json";-import { buildAgentDownloadCatalog, buildDriverEntries, buildNativeAgentEntries, downloadLinksFor, fetchAgentDownloadCatalog, formatSize } from "./agentRegistry";+import { buildAgentDownloadCatalog, buildDriverEntries, buildNativeAgentEntries, downloadLinksFor, formatSize } from "./agentRegistry";+import { fetchAgentDownloadCatalog } from "./agentRegistrySource";afterEach(() => {vi.restoreAllMocks();@@ -25,28 +26,18 @@ test("versioned release assets expose GitHub and CNB download links", () => {});test("non-release assets retain their official download link", () => {- assert.deepEqual(downloadLinksFor("https://dl.dbxio.com/releases/latest/dbx-jdbc-plugin-latest.zip"), [- { source: "official", url: "https://dl.dbxio.com/releases/latest/dbx-jdbc-plugin-latest.zip" },- ]);+ assert.deepEqual(downloadLinksFor("https://dl.dbxio.com/releases/latest/dbx-jdbc-plugin-latest.zip"), [{ source: "official", url: "https://dl.dbxio.com/releases/latest/dbx-jdbc-plugin-latest.zip" }]);});-test("catalog falls back from GitHub to CNB", async () => {+test("catalog falls back from R2 to CNB without using GitHub API", async () => {const requestedUrls: string[] = [];vi.stubGlobal("fetch",vi.fn(async (input: string | URL | Request) => {const url = String(input);requestedUrls.push(url);- if (url.includes("api.github.com")) {- return Response.json({- assets: [- {- name: "agent-registry.json",- size: 1,- browser_download_url: "https://github.com/t8y2/dbx/releases/download/agents-latest/agent-registry.json",- },- ],- });+ if (url === "https://dl.dbxio.com/agents/agent-registry.json") {+ return new Response("registry unavailable", { status: 503 });}return Response.json({drivers: {@@ -74,17 +65,11 @@ test("catalog falls back from GitHub to CNB", async () => {const catalog = await fetchAgentDownloadCatalog();- assert.deepEqual(requestedUrls, [- "https://api.github.com/repos/t8y2/dbx/releases/tags/agents-latest",- "https://cnb.cool/dbxio.com/dbx/-/releases/download/agents-latest/agent-registry.json",- ]);+ assert.deepEqual(requestedUrls, ["https://dl.dbxio.com/agents/agent-registry.json", "https://cnb.cool/dbxio.com/dbx/-/releases/download/agents-latest/agent-registry.json"]);assert.equal(catalog?.drivers[0]?.key, "access");assert.equal(catalog?.jres[0]?.platformKey, "macos-aarch64");assert.equal(catalog?.bundles[0]?.platformKey, "macos-aarch64");- assert.equal(- catalog?.bundles[0]?.url,- "https://github.com/t8y2/dbx/releases/download/agents-v0.2.64/dbx-agents-offline-macos-aarch64.zip",- );+ assert.equal(catalog?.bundles[0]?.url, "https://github.com/t8y2/dbx/releases/download/agents-v0.2.64/dbx-agents-offline-macos-aarch64.zip");});test("unknown fallback asset sizes render as unavailable", () => {diff --git a/docs/lib/agentRegistry.ts b/docs/lib/agentRegistry.tsindex 804ba1aa07..77094886dd 100644--- a/docs/lib/agentRegistry.ts+++ b/docs/lib/agentRegistry.ts@@ -18,10 +18,6 @@ export interface GitHubReleaseAsset {browser_download_url: string;}-interface GitHubRelease {- assets?: GitHubReleaseAsset[];-}-interface AgentRegistryArtifact {url: string;size: number;@@ -33,7 +29,7 @@ interface AgentRegistryDriver {native?: Record<string, AgentRegistryArtifact>;}-interface AgentRegistry {+export interface AgentRegistry {jres?: Record<string, { platforms?: Record<string, AgentRegistryArtifact> }>;drivers?: Record<string, AgentRegistryDriver>;}@@ -87,8 +83,6 @@ export interface AgentDownloadCatalog {nativeAgents: NativeAgentDisplayEntry[];}-const AGENTS_LATEST_RELEASE_API_URL = "https://api.github.com/repos/t8y2/dbx/releases/tags/agents-latest";-const CNB_AGENT_REGISTRY_URL = "https://cnb.cool/dbxio.com/dbx/-/releases/download/agents-latest/agent-registry.json";const JDBC_PLUGIN_DOWNLOAD_URL = "https://dl.dbxio.com/releases/latest/dbx-jdbc-plugin-latest.zip";const GITHUB_RELEASE_DOWNLOAD_PREFIX = "https://github.com/t8y2/dbx/releases/download/";const CNB_RELEASE_DOWNLOAD_PREFIX = "https://cnb.cool/dbxio.com/dbx/-/releases/download/";@@ -230,16 +224,6 @@ function registryReleaseAssets(registry: AgentRegistry): GitHubReleaseAsset[] {return Array.from(assets.values());}-function hasDownloadAssets(catalog: AgentDownloadCatalog): boolean {- return catalog.bundles.length > 0 || catalog.drivers.length > 0 || catalog.jres.length > 0 || catalog.nativeAgents.length > 0;-}--async function fetchJson<T>(url: string, headers?: HeadersInit): Promise<T> {- const response = await fetch(url, { cache: "no-store", headers });- if (!response.ok) throw new Error(`Download catalog request failed with ${response.status}`);- return response.json() as Promise<T>;-}-export function downloadLinksFor(url: string): DownloadLink[] {const releasePath = url.startsWith(GITHUB_RELEASE_DOWNLOAD_PREFIX) ? url.slice(GITHUB_RELEASE_DOWNLOAD_PREFIX.length) : null;if (!releasePath) return [{ source: "official", url }];@@ -254,22 +238,8 @@ function assetMap(assets: GitHubReleaseAsset[]): Map<string, GitHubReleaseAsset>return new Map(assets.map((asset) => [asset.name, asset]));}-export async function fetchAgentDownloadCatalog(): Promise<AgentDownloadCatalog | null> {- const loaders: Array<() => Promise<GitHubReleaseAsset[]>> = [- async () => (await fetchJson<GitHubRelease>(AGENTS_LATEST_RELEASE_API_URL, { Accept: "application/vnd.github+json" })).assets ?? [],- async () => registryReleaseAssets(await fetchJson<AgentRegistry>(CNB_AGENT_REGISTRY_URL)),- ];-- for (const loadAssets of loaders) {- try {- const catalog = buildAgentDownloadCatalog(await loadAssets());- if (hasDownloadAssets(catalog)) return catalog;- } catch {- // Try the next synchronized release source.- }- }-- return null;+export function buildAgentDownloadCatalogFromRegistry(registry: AgentRegistry): AgentDownloadCatalog {+ return buildAgentDownloadCatalog(registryReleaseAssets(registry));}export function buildAgentDownloadCatalog(assets: GitHubReleaseAsset[]): AgentDownloadCatalog {@@ -317,10 +287,7 @@ export function buildDriverEntries(assets: GitHubReleaseAsset[]): DriverDisplayEreturn currentJavaDriverKeys.map((key) => {const version = driverVersionMap[key] ?? "";- const asset =- byName.get(`dbx-agent-${key}-${version}.zip`) ??- byName.get(`dbx-agent-${key}-${version}.jar`) ??- byName.get(`dbx-agent-${key}.jar`);+ const asset = byName.get(`dbx-agent-${key}-${version}.zip`) ?? byName.get(`dbx-agent-${key}-${version}.jar`) ?? byName.get(`dbx-agent-${key}.jar`);if (!asset) return null;return {diff --git a/docs/lib/agentRegistrySource.ts b/docs/lib/agentRegistrySource.tsnew file mode 100644index 0000000000..de0222168c--- /dev/null+++ b/docs/lib/agentRegistrySource.ts@@ -0,0 +1,29 @@+import { buildAgentDownloadCatalogFromRegistry, type AgentDownloadCatalog, type AgentRegistry } from "./agentRegistry";++const AGENT_REGISTRY_URLS = ["https://dl.dbxio.com/agents/agent-registry.json", "https://cnb.cool/dbxio.com/dbx/-/releases/download/agents-latest/agent-registry.json"] as const;++function hasDownloadAssets(catalog: AgentDownloadCatalog): boolean {+ return catalog.bundles.length > 0 || catalog.drivers.length > 0 || catalog.jres.length > 0 || catalog.nativeAgents.length > 0;+}++async function fetchRegistry(url: string): Promise<AgentRegistry> {+ const response = await fetch(url, {+ cache: "force-cache",+ headers: { Accept: "application/json" },+ });+ if (!response.ok) throw new Error(`Download catalog request failed with ${response.status}`);+ return response.json() as Promise<AgentRegistry>;+}++export async function fetchAgentDownloadCatalog(): Promise<AgentDownloadCatalog | null> {+ for (const url of AGENT_REGISTRY_URLS) {+ try {+ const catalog = buildAgentDownloadCatalogFromRegistry(await fetchRegistry(url));+ if (hasDownloadAssets(catalog)) return catalog;+ } catch {+ // Both sources contain the same generated registry; try the synchronized mirror next.+ }+ }++ return null;+}diff --git a/docs/lib/changelog.test.ts b/docs/lib/changelog.test.tsindex 59c8bba532..206297303b 100644--- a/docs/lib/changelog.test.ts+++ b/docs/lib/changelog.test.ts@@ -1,8 +1,13 @@import assert from "node:assert/strict";-import { test } from "vitest";+import { afterEach, test, vi } from "vitest";+import { fetchChangelog } from "./changelog";import { isAppReleaseTag } from "./releaseTags";+afterEach(() => {+ vi.restoreAllMocks();+});+test("recognizes only DBX app release tags", () => {assert.equal(isAppReleaseTag("v0.5.66"), true);assert.equal(isAppReleaseTag("v1.2.3-hotfix.1"), true);@@ -10,3 +15,17 @@ test("recognizes only DBX app release tags", () => {assert.equal(isAppReleaseTag("agents-v0.2.64"), false);assert.equal(isAppReleaseTag("v0.5.x"), false);});++test("changelog build fails without falling back to GitHub API", async () => {+ const requestedUrls = [];+ vi.stubGlobal(+ "fetch",+ vi.fn(async (input) => {+ requestedUrls.push(String(input));+ return new Response("unavailable", { status: 503 });+ }),+ );++ await assert.rejects(fetchChangelog("cn"), /Request failed with status 503/);+ assert.deepEqual(requestedUrls, ["https://dl.dbxio.com/changelog/releases-cn.json"]);+});diff --git a/docs/lib/changelog.ts b/docs/lib/changelog.tsindex 316698858d..b7ebe5a504 100644--- a/docs/lib/changelog.ts+++ b/docs/lib/changelog.ts@@ -1,5 +1,4 @@-import { requestJson } from "@/lib/httpJson";-import { isAppReleaseTag } from "@/lib/releaseTags";+import { requestJson } from "./httpJson";export type ChangelogItem = {title: string;@@ -24,30 +23,7 @@ export type ChangelogData = {releases: ChangelogRelease[];};-type GitHubRelease = {- tag_name: string;- name: string | null;- published_at: string | null;- body: string | null;- draft: boolean;- prerelease: boolean;-};-const DEFAULT_BASE_URL = "https://dl.dbxio.com/changelog";-const GITHUB_RELEASES_URL = "https://api.github.com/repos/t8y2/dbx/releases?per_page=30";--const SECTION_MAP: Record<string, string> = {- 新功能: "added",- Added: "added",- 改进: "improved",- Improved: "improved",- 修复: "fixed",- Fixed: "fixed",- 变更: "changed",- Changed: "changed",- 移除: "removed",- Removed: "removed",-};export function changelogUrl(lang: "en" | "cn") {const baseUrl = (typeof process !== "undefined" && (process.env.NEXT_PUBLIC_CHANGELOG_BASE_URL || process.env.CHANGELOG_BASE_URL)) || DEFAULT_BASE_URL;@@ -56,80 +32,5 @@ export function changelogUrl(lang: "en" | "cn") {}export async function fetchChangelog(lang: "en" | "cn"): Promise<ChangelogData> {- // 浏览器端同样优先走 R2 的翻译版 JSON(英文版由 sync-changelog 翻译生成);- // 之前客户端直接 fallback 到 GitHub 原文(中文),会导致英文页面 hydrate 后被中文覆盖。- const url = changelogUrl(lang);-- try {- return await requestJson<ChangelogData>(url);- } catch {- return fetchGitHubChangelog();- }-}--function stripDownloadSection(body: string) {- const markers = ["### 下载安装", "### Download", "### 系统要求", "### System Requirements"];- let idx = body.length;-- for (const marker of markers) {- const markerIndex = body.indexOf(marker);- if (markerIndex !== -1 && markerIndex < idx) {- idx = markerIndex;- }- }-- return body.slice(0, idx).trim();-}--function parseReleaseBody(body: string) {- const sections: ChangelogSection[] = [];- let current: ChangelogSection | null = null;-- for (const line of stripDownloadSection(body).split("\n")) {- const headerMatch = line.match(/^###\s+(.+)/);- if (headerMatch) {- const title = headerMatch[1].trim();- current = { type: SECTION_MAP[title] || "other", title, items: [] };- sections.push(current);- continue;- }-- if (!current) continue;-- const itemMatch = line.match(/^-\s+\*\*(.+?)\*\*\s*[—–-]\s*(.+)/);- if (itemMatch) {- current.items.push({ title: itemMatch[1].trim(), desc: itemMatch[2].trim() });- continue;- }-- const plainMatch = line.match(/^-\s+(.+)/);- if (plainMatch) {- current.items.push({ title: plainMatch[1].trim(), desc: "" });- }- }-- return sections.filter((section) => section.items.length > 0);-}--export async function fetchGitHubChangelog(): Promise<ChangelogData> {- try {- const releases = await requestJson<GitHubRelease[]>(GITHUB_RELEASES_URL, {- headers: { Accept: "application/vnd.github+json" },- });-- return {- updatedAt: new Date().toISOString(),- releases: releases- // GitHub contains separate app, agent, and package release streams.- .filter((release) => !release.draft && !release.prerelease && isAppReleaseTag(release.tag_name))- .map((release) => ({- tag: release.tag_name,- name: release.name || release.tag_name,- date: (release.published_at || "").slice(0, 10),- sections: parseReleaseBody(release.body || ""),- })),- };- } catch {- return { updatedAt: "", releases: [] };- }+ return requestJson<ChangelogData>(changelogUrl(lang), { cache: "force-cache" });}diff --git a/docs/lib/contributors.test.ts b/docs/lib/contributors.test.tsindex aed916fd3b..5f01cc2cd9 100644--- a/docs/lib/contributors.test.ts+++ b/docs/lib/contributors.test.ts@@ -1,6 +1,6 @@import assert from "node:assert/strict";import { test } from "vitest";-import { dedupeContributors, type Contributor } from "./contributors";+import { contributorsFromActivity, dedupeContributors, type Contributor } from "./contributors";const contributor = (login: string): Contributor => ({login,@@ -20,3 +20,27 @@ test("dedupeContributors preserves the original contributor order", () => {assert.deepEqual(dedupeContributors(contributors), contributors);});++test("contributorsFromActivity strips snapshot-only fields from landing data", () => {+ assert.deepEqual(+ contributorsFromActivity([+ {+ login: "builder",+ avatarUrl: "https://avatars.githubusercontent.com/u/1",+ profileUrl: "https://github.com/builder",+ commits: 42,+ mergedPullRequests: 7,+ firstContributionAt: "2026-01-01T00:00:00Z",+ latestContributionAt: "2026-07-01T00:00:00Z",+ },+ ]),+ [+ {+ login: "builder",+ avatar_url: "https://avatars.githubusercontent.com/u/1",+ html_url: "https://github.com/builder",+ contributions: 42,+ },+ ],+ );+});diff --git a/docs/lib/contributors.ts b/docs/lib/contributors.tsindex 8ca86aaee5..b62e63a689 100644--- a/docs/lib/contributors.ts+++ b/docs/lib/contributors.ts@@ -1,3 +1,5 @@+import type { ContributorActivity } from "@/lib/contributorActivity";+export type Contributor = {login: string;avatar_url: string;@@ -6,65 +8,6 @@ export type Contributor = {type?: string;};-const GITHUB_CONTRIBUTORS_API = "https://api.github.com/repos/t8y2/dbx/contributors";--function parseNextLink(linkHeader: string): string | null {- const parts = linkHeader.split(",");- for (const part of parts) {- const [url, rel] = part.split(";").map((s) => s.trim());- if (rel === 'rel="next"') {- return url.slice(1, -1); // strip < >- }- }- return null;-}--async function fetchPage(url: string, token?: string): Promise<{ data: Contributor[]; next: string | null }> {- const headers: Record<string, string> = {- Accept: "application/vnd.github+json",- };- if (token) {- headers.Authorization = `Bearer ${token}`;- }-- const response = await fetch(url, {- headers,- next: { revalidate: 60 * 60 * 6 },- });-- if (!response.ok) return { data: [], next: null };-- const data = (await response.json()) as Contributor[];- if (!Array.isArray(data)) return { data: [], next: null };-- const linkHeader = response.headers.get("Link");- const next = linkHeader ? parseNextLink(linkHeader) : null;-- return { data, next };-}--function fallbackContributors(): Contributor[] {- return [- { login: "t8y2", avatar_url: "https://avatars.githubusercontent.com/u/77960507", html_url: "https://github.com/t8y2", contributions: 1601 },- { login: "Illuminated2020", avatar_url: "https://avatars.githubusercontent.com/u/53017147", html_url: "https://github.com/Illuminated2020", contributions: 40 },- { login: "rarnu", avatar_url: "https://avatars.githubusercontent.com/u/28835581", html_url: "https://github.com/rarnu", contributions: 23 },- { login: "SuLea-IT", avatar_url: "https://avatars.githubusercontent.com/u/105108570", html_url: "https://github.com/SuLea-IT", contributions: 22 },- { login: "serenez", avatar_url: "https://github.com/serenez.png", html_url: "https://github.com/serenez", contributions: 22 },- { login: "yavon007", avatar_url: "https://avatars.githubusercontent.com/u/61088461", html_url: "https://github.com/yavon007", contributions: 18 },- { login: "Bacon2994", avatar_url: "https://avatars.githubusercontent.com/u/108093786", html_url: "https://github.com/Bacon2994", contributions: 11 },- { login: "Abeautifulsnow", avatar_url: "https://avatars.githubusercontent.com/u/115250255", html_url: "https://github.com/Abeautifulsnow", contributions: 9 },- { login: "CN-Scars", avatar_url: "https://avatars.githubusercontent.com/u/100192060", html_url: "https://github.com/CN-Scars", contributions: 8 },- { login: "DengQingNian", avatar_url: "https://avatars.githubusercontent.com/u/117324885", html_url: "https://github.com/DengQingNian", contributions: 7 },- { login: "xKrah", avatar_url: "https://avatars.githubusercontent.com/u/120772591", html_url: "https://github.com/xKrah", contributions: 7 },- { login: "agent-43", avatar_url: "https://avatars.githubusercontent.com/u/188405022", html_url: "https://github.com/agent-43", contributions: 6 },- { login: "eryajf", avatar_url: "https://avatars.githubusercontent.com/u/33259379", html_url: "https://github.com/eryajf", contributions: 5 },- { login: "wu-clan", avatar_url: "https://avatars.githubusercontent.com/u/114193468", html_url: "https://github.com/wu-clan", contributions: 4 },- { login: "fraluc06", avatar_url: "https://avatars.githubusercontent.com/u/67560467", html_url: "https://github.com/fraluc06", contributions: 4 },- { login: "Caisin", avatar_url: "https://avatars.githubusercontent.com/u/62819122", html_url: "https://github.com/Caisin", contributions: 3 },- { login: "wds824", avatar_url: "https://avatars.githubusercontent.com/u/93659702", html_url: "https://github.com/wds824", contributions: 3 },- ];-}-export function dedupeContributors(contributors: Contributor[]): Contributor[] {const seenLogins = new Set<string>();@@ -76,24 +19,13 @@ export function dedupeContributors(contributors: Contributor[]): Contributor[] {});}-export async function fetchContributors(): Promise<Contributor[]> {- const token = process.env.GITHUB_TOKEN;- const firstPage = `${GITHUB_CONTRIBUTORS_API}?per_page=100`;-- try {- const allContributors: Contributor[] = [];- let url: string | null = firstPage;-- while (url) {- const { data, next } = await fetchPage(url, token);- allContributors.push(...data);- url = next;- }-- if (allContributors.length === 0) return fallbackContributors();-- return dedupeContributors(allContributors.filter((c) => c.login && c.avatar_url && c.type !== "Bot"));- } catch {- return fallbackContributors();- }+export function contributorsFromActivity(contributors: readonly ContributorActivity[]): Contributor[] {+ return dedupeContributors(+ contributors.map((contributor) => ({+ login: contributor.login,+ avatar_url: contributor.avatarUrl,+ html_url: contributor.profileUrl,+ contributions: contributor.commits,+ })),+ );}diff --git a/docs/lib/latestRelease.test.ts b/docs/lib/latestRelease.test.tsnew file mode 100644index 0000000000..a7c14963aa--- /dev/null+++ b/docs/lib/latestRelease.test.ts@@ -0,0 +1,36 @@+import assert from "node:assert/strict";+import { afterEach, test, vi } from "vitest";++import { fetchLatestReleaseInfo } from "./latestRelease";++afterEach(() => {+ vi.restoreAllMocks();+});++test("latest release metadata uses only the static R2 endpoint", async () => {+ const requestedUrls = [];+ vi.stubGlobal(+ "fetch",+ vi.fn(async (input) => {+ requestedUrls.push(String(input));+ return Response.json({ version: "v0.5.66", notes: "Static metadata" });+ }),+ );++ assert.deepEqual(await fetchLatestReleaseInfo(), { version: "0.5.66", notes: "Static metadata" });+ assert.deepEqual(requestedUrls, ["https://dl.dbxio.com/releases/latest/latest.json"]);+});++test("latest release metadata fails closed without a GitHub API fallback", async () => {+ const requestedUrls = [];+ vi.stubGlobal(+ "fetch",+ vi.fn(async (input) => {+ requestedUrls.push(String(input));+ return new Response("unavailable", { status: 503 });+ }),+ );++ assert.equal(await fetchLatestReleaseInfo(), null);+ assert.deepEqual(requestedUrls, ["https://dl.dbxio.com/releases/latest/latest.json"]);+});diff --git a/docs/lib/latestRelease.ts b/docs/lib/latestRelease.tsindex e0c1767bad..95e4c6ba70 100644--- a/docs/lib/latestRelease.ts+++ b/docs/lib/latestRelease.ts@@ -1,5 +1,4 @@-import { requestJson } from "@/lib/httpJson";-import { browserCacheBuster, createUncachedUrl, releaseMetadataRequestInit } from "@/lib/releaseMetadataRequest";+import { requestJson } from "./httpJson";export type LatestReleaseInfo = {version: string;@@ -7,41 +6,19 @@ export type LatestReleaseInfo = {pub_date?: string;};-type GitHubLatestRelease = {- tag_name: string;- body: string | null;- published_at: string | null;-};-const LATEST_RELEASE_URL = "https://dl.dbxio.com/releases/latest/latest.json";-const GITHUB_LATEST_RELEASE_URL = "https://api.github.com/repos/t8y2/dbx/releases/latest";function normalizeVersion(version: string) {return version.replace(/^v/, "");}export async function fetchLatestReleaseInfo(): Promise<LatestReleaseInfo | null> {- if (typeof window !== "undefined") {- return fetchGitHubLatestReleaseInfo();- }-try {- const release = await requestJson<LatestReleaseInfo>(createUncachedUrl(LATEST_RELEASE_URL, browserCacheBuster()), releaseMetadataRequestInit());+ const release = await requestJson<LatestReleaseInfo>(LATEST_RELEASE_URL, {+ cache: "force-cache",+ headers: { Accept: "application/json" },+ });return release.version ? { ...release, version: normalizeVersion(release.version) } : null;- } catch {- return fetchGitHubLatestReleaseInfo();- }-}--export async function fetchGitHubLatestReleaseInfo(): Promise<LatestReleaseInfo | null> {- try {- const release = await requestJson<GitHubLatestRelease>(createUncachedUrl(GITHUB_LATEST_RELEASE_URL, browserCacheBuster()), releaseMetadataRequestInit({ headers: { Accept: "application/vnd.github+json" } }));-- return {- version: normalizeVersion(release.tag_name),- notes: release.body || undefined,- pub_date: release.published_at || undefined,- };} catch {return null;}diff --git a/docs/lib/releaseMetadataRequest.test.ts b/docs/lib/releaseMetadataRequest.test.tsdeleted file mode 100644index 8af7f5113e..0000000000--- a/docs/lib/releaseMetadataRequest.test.ts+++ /dev/null@@ -1,21 +0,0 @@-import assert from "node:assert/strict";-import { test } from "vitest";-import { createUncachedUrl, releaseMetadataRequestInit } from "./releaseMetadataRequest";--test("createUncachedUrl appends cache buster without removing existing query params", () => {- assert.equal(createUncachedUrl("https://dl.dbxio.com/releases/latest/latest.json?lang=cn", 123), "https://dl.dbxio.com/releases/latest/latest.json?lang=cn&_ts=123");-});--test("createUncachedUrl leaves server-side build URLs stable without a cache buster", () => {- assert.equal(createUncachedUrl("https://dl.dbxio.com/releases/latest/latest.json"), "https://dl.dbxio.com/releases/latest/latest.json");-});--test("releaseMetadataRequestInit disables fetch cache and preserves custom headers", () => {- assert.deepEqual(releaseMetadataRequestInit({ headers: { Authorization: "token example" } }), {- cache: "no-store",- headers: {- Accept: "application/json",- Authorization: "token example",- },- });-});diff --git a/docs/lib/releaseMetadataRequest.ts b/docs/lib/releaseMetadataRequest.tsdeleted file mode 100644index ecc2741f37..0000000000--- a/docs/lib/releaseMetadataRequest.ts+++ /dev/null@@ -1,22 +0,0 @@-export function createUncachedUrl(url: string, cacheBuster?: string | number) {- if (cacheBuster === undefined) return url;-- const nextUrl = new URL(url);- nextUrl.searchParams.set("_ts", String(cacheBuster));- return nextUrl.toString();-}--export function browserCacheBuster() {- return typeof window === "undefined" ? undefined : Date.now();-}--export function releaseMetadataRequestInit(init: RequestInit = {}): RequestInit {- return {- ...init,- cache: "no-store",- headers: {- Accept: "application/json",- ...init.headers,- },- };-}diff --git a/docs/package.json b/docs/package.jsonindex aacc4541e5..588eb4c531 100644--- a/docs/package.json+++ b/docs/package.json@@ -5,7 +5,7 @@"scripts": {"dev": "next dev","build": "next build",- "postbuild": "node scripts/generate-sitemap.mjs",+ "postbuild": "node scripts/generate-sitemap.mjs && node scripts/verify-static-export.mjs","contributors:update": "node scripts/update-contributors.mjs","start": "next start","postinstall": "fumadocs-mdx"diff --git a/docs/scripts/verify-static-export.mjs b/docs/scripts/verify-static-export.mjsnew file mode 100644index 0000000000..0b8c93b02b--- /dev/null+++ b/docs/scripts/verify-static-export.mjs@@ -0,0 +1,38 @@+import { readdir, readFile } from "node:fs/promises";+import { extname, join, relative } from "node:path";+import { fileURLToPath } from "node:url";++const outputDirectory = fileURLToPath(new URL("../out/", import.meta.url));+const scannedExtensions = new Set([".html", ".js", ".txt"]);+const forbiddenEndpoint = "api.github.com";++async function collectFiles(directory) {+ const entries = await readdir(directory, { withFileTypes: true });+ const files = [];++ for (const entry of entries) {+ const path = join(directory, entry.name);+ if (entry.isDirectory()) {+ files.push(...(await collectFiles(path)));+ } else if (scannedExtensions.has(extname(entry.name))) {+ files.push(path);+ }+ }++ return files;+}++const files = await collectFiles(outputDirectory);+const violations = [];++for (const file of files) {+ if ((await readFile(file, "utf8")).includes(forbiddenEndpoint)) {+ violations.push(relative(outputDirectory, file));+ }+}++if (violations.length > 0) {+ throw new Error(`Static export contains browser-visible GitHub API endpoints:\n${violations.join("\n")}`);+}++console.log(`Static export verified: ${files.length} files contain no GitHub API endpoints.`);