Custom portal
When theming and YAML options are not enough, fork the reference portal into your repository.
The runtime then serves your build at /, from the active revision.
-
Scaffold it inside your Cicord repository (the directory with
cicord.yaml):Terminal window cicord portal init # → portal/ (or: cicord portal init <dir>) -
Build it:
Terminal window cd portal && pnpm install && pnpm build -
Point the runtime at the build in
cicord.yaml:cicord.yaml spec:portal:path: ./portal/dist # the build output, relative to cicord.yaml -
Commit everything, the build included:
Terminal window git add portal cicord.yaml # sources, pnpm-lock.yaml, vendor/ AND dist/ -
From then on,
cicord portal build(from the repository root) runs the install when needed, regenerates the route types and builds intospec.portal.path.
What cicord portal init writes
Section titled “What cicord portal init writes”The reference portal is React 19 with Vite+.
Directoryportal/
Directorysrc/
Directorypages/ Home, Onboarding, Profile, Leaderboard, Tickets, Developers
- …
- portal.tsx server selection, theme, navigation, sign-in
Directoryi18n/ en, fr
- …
Directorymock/ an in-browser fake runtime for
pnpm dev- …
- cicord-routes.d.ts the types of the repository’s plugin routes
Directoryvendor/
@cicord/client,@cicord/react,@cicord/uitarballs, from the cicord binary- …
- package.json
file:dependencies on vendor/
Directory.github/
Directoryworkflows/
- cicord-portal.yml rebuilds and checks the committed build
The @cicord/* packages are not on npm yet, so they are vendored as file: dependencies (plus
pnpm.overrides, because @cicord/react depends on @cicord/client by version). Once they are
published, cicord portal init --from-npm (or CICORD_FROM_NPM=true) writes
"@cicord/client": "^<version of cicord>" instead, with no vendor/. --force writes into a
non-empty directory.
The Developers page is a live map of the SDK: the session (cookie or token), every portal
endpoint with the SDK call that uses it, every plugin route of the server, and the raw
PortalServer. Its link is shown to moderators and admins and in development; delete it in
your fork if you do not want it.
Why the build is committed
Section titled “Why the build is committed”The runtime has no Node.js and only sees what is in the git revision it applies, so the build
output must be in that revision. Committing dist/ keeps the served portal exactly what was
reviewed, works with every source provider (GitHub, git, embedded, local) and needs no
artifact storage. Vite builds are deterministic for the same lockfile.
The generated .github/workflows/cicord-portal.yml rebuilds the portal on every pull request
and push, runs its tests, and fails when the committed dist/ differs from a fresh build,
so reviewers only need to read src/. Locally, cicord portal build --check does the same.
The runtime serves <active revision>/<path> at / with an SPA fallback, swaps it with every
new revision (no restart), and never lets it shadow /api, /auth, /hooks, /admin,
/healthz or /readyz. Files are read through a root confined to the portal directory: ..
and symbolic links leading outside are refused.
cicord validate checks spec.portal.path: outside the repository, through a symbolic link or
not a directory is an error; missing, or without index.html, is a warning (the
runtime serves the default portal until the build is committed).
Typed plugin routes
Section titled “Typed plugin routes”cicord portal init and cicord portal build write src/cicord-routes.d.ts; cicord portal typegen
regenerates it on its own. It describes the routes of every plugin installed in the
repository (every instance of every bot, local or from a registry), keyed by plugin name
then route key, with their access level, path parameters and the query, body and response
types of each plugin’s route contract. Routes of plugins
without a contract are typed as untyped JSON. Commit the file.
import { useRouteQuery, useRouteMutation } from "@cicord/react";
// The instance is found by plugin name in PortalServer.plugins; no instance → idle query.const board = useRouteQuery("levels", "GET /leaderboard", { query: { limit: 50 } });board.data?.items[0]?.displayName; // typed from the levels contractconst poll = useRouteQuery("polls", "GET /polls/:id", { params: { id } });An unknown route, a missing or extra path parameter, a wrong query or body and a wrong use of
the response are type errors, so a portal build fails when a plugin changes its contract.
cicord portal typegen --check (also a step of cicord-portal.yml, which runs when plugins/,
bots/ or cicord.lock change) and cicord portal build --check fail when the file is out of
date.
Dev loop
Section titled “Dev loop”Two terminals:
cicord dev --sim # runtime + Discord simulator on http://127.0.0.1:7420cd portal && pnpm dev:runtime # Vite dev server on http://localhost:5174, hot reloadpnpm dev:runtime proxies /api and /auth to CICORD_RUNTIME_URL (default
http://127.0.0.1:7420), so the page and the API are same-origin and cookie sessions work.
The proxy keeps a loopback Host and rewrites Origin to the runtime’s, which dev mode
requires.
cicord dev --sim has no Discord OAuth: the portal’s sign-in block lists the simulated users and
signs in with the dev login.
Other loops:
pnpm dev(mock mode) needs no runtime at all:src/mockfakes the API in the browser (?role=moderatorpreviews the moderator pages,?mode=lightthe light palette);cicord devalso serves the committed build: runcicord portal buildand the next revision serves it athttp://127.0.0.1:7420/;pnpm testruns the portal’s tests (Vitest and Testing Library, against the mock).