Skip to content

Shared Packages

The packages/ directory holds libraries that more than one app depends on. Some are pure logic, others are infra adapters, others are build-time config shared across deployables.

The in-house Go rules library. Pure TypeScript, no I/O.

  • Exports: Game, StoneColor, GameMessages.
  • Consumers: weiqi-server (lightweight move validation), MCP tools that validate moves client-side.
  • Docs: weiqi-engine.

Thin wrapper around the goban-engine UMD bundle. Adds strict typing and a stable serializePosition.

  • Exports: GoGame, StoneColor (string-enum form), serializePosition, Position, Player, ScoreResult, GameState.
  • Consumers: weiqi-server analysis and replay paths.
  • Docs: go-engine.

The bot-level catalog and KataGo request builders.

  • Exports: BOT_LEVELS, KataGoAnalyzeRequest, BOT_LEVEL_CODES.
  • Consumers: weiqi-server bot module, game-web level selector.

Glicko-2 rating math.

  • Exports: applyUpdate, applyRatingPeriod, defaultGlickoRating, constants (GLICKO_DEFAULT_RATING, GLICKO_DEFAULT_RD, GLICKO_TAU, GLICKO_VOLATILITY), types (GlickoRating, GlickoUpdateResult).
  • Consumers: rating-system modules where classical Elo is not appropriate (note: the bot ladder itself uses Elo via BotRankService, not Glicko).

Distinct from the Glicko package; this one defines the bot-level catalog. See Bot Ladder for the level table.

Roles, tiers, and bot entitlements.

  • Exports: APP_ROLES, SUBSCRIPTION_TIERS, BOT_ENTITLEMENTS (BOTS_HINT_TOP3, BOTS_LIVE_EVAL, BOTS_REVIEW_FULL, …), CHALLENGE_CAPABILITIES, helpers tierAtLeast, hasBotEntitlement, dailyGameCap, plus server-side env helpers.
  • Consumers: weiqi-server, auth-app, mcp-bridge, game-web.

Better-Auth client wrapper.

  • Exports: AuthService class wrapping better-auth/client with adminClient, anonymousClient, magicLinkClient.
  • Consumers: game-web, auth-app.

Shared types and helpers for the billing pipeline.

  • Exports: chains.registry (SupportedChain), webhook-canonical (canonical-bytes helper), webhook-signature (signWebhook, verifyWebhookSignature, decodePrivateKey) — Ed25519 over SHA-512, 32-byte hex keys.
  • Consumers: billing-indexer (signs), auth-app (verifies).

A typed HTTP client with composable interceptors.

  • Exports: HttpClient, createAuthInterceptor, createApiKeyInterceptor, createRetryInterceptor, presets createAuthenticatedClient, createApiKeyClient, createSSRClient, createClientSideClient.
  • Consumers: weiqi-server (calls auth-app), auth-app (calls weiqi-server), billing-indexer (delivers webhooks).

Client SDK for the accounts service.

  • Exports: typed wrappers over auth-app’s public REST surface.
  • Consumers: weiqi-server, internal scripts.

Env loader split into client/ and server/ halves.

  • Consumers: every app at boot time.

Radix-based, shadcn-style component library used by game-web, auth-app, and the marketing site.

  • Exports: ./components/*, ./lib/*, ./hooks/*, ./globals.css, ./theme.css. Tailwind + class-variance-authority + tailwind-merge
    • clsx.
  • Consumers: game-web, auth-app, main-app (selective).

Shared tsconfig extends.

  • Exports: base.json, vite.json, nextjs.json, react-library.json.
  • Consumers: every app and library.

Shared ESLint flat-config presets.

  • Exports: ./base, ./next, ./react-internal.
  • Consumers: every app and library.

Tailwind preset used by apps that share the design tokens.

  • Consumers: game-web, main-app, admin-app.
  1. Create packages/<name>/package.json with name: "@workspace/<name>".
  2. Run pnpm install from the repo root — the workspace symlink is automatic.
  3. Import from any app via import { ... } from "@workspace/<name>".
  4. Add a section to this page in the same PR.