logicsrc/apps/logicsrc-web/src/lib/docs.ts
Anthony Ettinger 66ef39cda6 docs: OpenCPU, OpenMemory, OpenGPU and OpenBandwidth, the resources of a server purchase
Four resource specifications under OpenServer, one per thing that is
negotiable when a server is bought. Each is the block of an OpenServer
offer (compute, memory, gpu, network) written down on its own, with the
units OpenServer 0.1 already uses (vcpu, cores, ram_mb, vram_mb,
bandwidth_mbps, transfer_gb, ipv4, ipv6) and one new shape shared by all
four: `range`, the field a buyer can dial at checkout, its bounds, the
step and what a step costs on top of the base price.

- OpenCPU: threads against cores, the processor by its vendor name,
  dedicated, shared or burstable allocation.
- OpenMemory: mebibytes, DDR generation, ECC as three states, reserved,
  balloonable or shared; wins over compute.ram_mb when both are present.
- OpenGPU: the card by its vendor name, count and VRAM per device,
  interconnect, passthrough, MIG, vGPU or shared access.
- OpenBandwidth: port, four meters (transfer, unmetered, percentile,
  flat), overage, IPv4 and IPv6 addresses as a priced resource.

A provider that sells only one resource lists it as an OpenServer offer
and may serve the same document at /.well-known/<slug>.json. Landing
pages share one component (resource-spec-page.tsx). Registered in
DOC_SLUGS, NAV, STATIC_ROUTES and llms.txt. OpenServer, OpenFile and
OpenDisk arrive in sibling PRs.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014cmNRtR2vL1p89dbVQ7FZJ
2026-09-13 01:38:19 +00:00

79 lines
2 KiB
TypeScript

import { readFileSync } from "node:fs";
import { resolve } from "node:path";
// Repo-root docs/ (read at build time during static generation, so there is
// no runtime filesystem dependency in the deployed image).
const DOCS_DIR = resolve(process.cwd(), "../../docs");
// Curated, public-facing reference docs. Internal notes (roadmap, positioning,
// arcade) are intentionally excluded.
export const DOC_SLUGS = [
"asdlc",
"openswarm",
"opencreds",
"openprd",
"openontology",
"openontology-governance",
"openontology-interoperability",
"openjob",
"openresume",
"openprofile",
"openmcp",
"openaccess",
"openstream",
"opencpu",
"openmemory",
"opengpu",
"openbandwidth",
"openspec-comparison",
"data-model",
"cli",
"tui",
"config",
"permissions",
"plugins",
"credential-sharing",
"agent-screening",
] as const;
export type DocSlug = (typeof DOC_SLUGS)[number];
export function isDocSlug(slug: string): slug is DocSlug {
return (DOC_SLUGS as readonly string[]).includes(slug);
}
export function readDoc(slug: string): string | null {
if (!isDocSlug(slug)) return null;
try {
return readFileSync(resolve(DOCS_DIR, `${slug}.md`), "utf8");
} catch {
return null;
}
}
export function docTitle(markdown: string, slug: string): string {
const h1 = markdown.split("\n").find((line) => line.startsWith("# "));
return h1 ? h1.replace(/^#\s+/, "").trim() : slug;
}
export function docExcerpt(markdown: string): string {
for (const raw of markdown.split("\n")) {
const line = raw.trim();
if (line && !line.startsWith("#") && !line.startsWith("```") && !line.startsWith(">")) {
return line.replace(/[*_`#>[\]()]/g, "").trim().slice(0, 160);
}
}
return "";
}
export type DocSummary = { slug: DocSlug; title: string; excerpt: string };
export function listDocs(): DocSummary[] {
const out: DocSummary[] = [];
for (const slug of DOC_SLUGS) {
const md = readDoc(slug);
if (!md) continue;
out.push({ slug, title: docTitle(md, slug), excerpt: docExcerpt(md) });
}
return out;
}