Byline is an open-source TypeScript CMS with versioned content, editorial workflow and content translation. This file holds shared instructions for working in the repository.
- Use root/package manifests,
turbo.json, and.github/workflows/ci.ymlfor commands; prose that conflicts with executable config is stale. - Start with the architecture overview and the topic references below. Use dated plans in
specs/for decision history. Verify shipped behavior against the implementation and tests. .github/copilot-instructions.mddescribes an older repository shape and is not authoritative.- Use the pnpm version pinned in package.json (currently 12.11.2). Turborepo covers
packages/*,apps/*andbenchmarks/storage. Node >=22.22.2 is required and CI uses Node 22.
- Root commands fan out through Turbo:
pnpm build,pnpm typecheck,pnpm test, andpnpm test:integration. pnpm lintruns Biome with--write --unsafe; it modifies files. Do not introduce ESLint or Prettier.- CI runs
pnpm byline:generate:check,pnpm docs:check,pnpm lint,pnpm typecheck,pnpm knip,pnpm knip:exportsandpnpm test:scriptsin that order. See the workflow for artifact, transport and integration gates. - Use the root Biome config for formatting and import order. It specifies two-space indentation, LF line endings, a 100-column width and single-quoted JavaScript strings.
- Use package filters while iterating, e.g.
pnpm --filter @byline/core testorpnpm --filter @byline/webapp typecheck. - Run one DB test from its package:
pnpm vitest run --mode=integration <test-file>. pnpm buildmay print RolldownINVALID_ANNOTATIONwarnings from Lexical dependencies; check the exit status rather than treating those warnings as failures.
- Developer documents under
docs/use YAML front matter withtitle,path, and a one-sentencesummary, followed by one H1 and aCompanions:list immediately below it. - The front matter
titleand first H1 text must match exactly. Document import and processing removes the first H1 and uses the front matter title in its place. - Write for developers evaluating or learning Byline. Introduce the main concept and vocabulary first, then move into APIs, limits, compatibility boundaries, implementation references, and tests.
- Address the reader as “you” and open each document with what it covers and when to use it. Use clear, direct, complete sentences and concrete subjects such as “Byline’s admin user interface.” Avoid vague shorthand, metaphors, slogans, compressed fragments, repeated explanations, and unstated assumptions.
- Preserve technical qualifications and verify claims against current code, manifests, and tests. Link to companion documents instead of duplicating their full explanations.
- Run
pnpm docs:checkandgit diff --checkafter creating or revising documentation. The/documentcommand in.claude/commandsand.opencode/commandscontains the full workflow.
packages/coreowns framework-independent types, lifecycle/auth/query/patch logic, configuration, and the pure@byline/core/codegenemitter.packages/clientis the in-process SDK;packages/db-postgresandpackages/db-mysqlimplement storage primitives;packages/host-tanstack-startowns TanStack server-function transport.- Keep generic React primitives in
packages/uiand CMS editor concepts inpackages/admin. The admin form context accumulates patches from field widgets. Usepackages/core/src/patches/for patch semantics. The Lexical editor adapter lives inpackages/richtext-lexical. - There is no stable public document HTTP API. Admin document operations currently use host-adapter server functions.
- App-owned schema/config lives in
apps/webapp/byline;apps/webapp/srcowns the host/public application.
- Composition and configuration.
initBylineCore()composes config, collections and providers. Keep schema declarations server-safe. Pair collection and block schemas with separate admin configuration. Core composition · Blocks - Authorization and reads.
@byline/authdefines actors, sessions and abilities. Core enforces collection access, and admin commands enforce admin-management abilities. PreservebeforeReadrow scoping and the request's read context through relationship population and hooks. Public reads must use published content, including when a newer draft exists. Authentication and authorization · Client SDK · Relationships - Field paths. Use
packages/core/src/paths/for declaration and instance paths. Persisted storage paths and patch paths are compatibility contracts. Admin field overrides inside a block belong to that block type's admin config. Path grammar - Delivery and search. The host serves published Markdown and
llms.txt. The client orchestrates indexing of published documents by locale and applies read restrictions to search hits. Providers index projections supplied by core. The SQL drivers share@byline/search-analysisand behavior tests in@byline/search-conformance. Check provider capabilities before using optional query features. Markdown export · Search API · Indexing - Files and extraction. Local and S3 storage providers implement the file-storage contract. Extraction types and pure helpers are browser-safe. Verified reads use the server-only
@byline/core/stored-filesentry. Build core before running its extraction root-graph test, which inspectsdist. Hosts currently own extraction workers, artifact storage and the search join. Uploads · Extraction contract - Editor and localization. Forms, fields, layout and editor widgets live under
packages/admin/src/. Keep content locales separate from admin interface locales. Add new admin keys to every bundled locale. Core validation emits stable codes and the UI translates them. Admin UI · Admin translations · Content locales - Other subsystems. Scheduled publication operates on a reviewed version. Analytics owns its ingest, storage and rollups. Keep AI execution behind
@byline/ai/server. The CLI installs Byline into a TanStack Start host. Scheduling · Analytics · AI package · CLI
apps/webapp/byline/collections/index.tsis the single server-safe collection tuple. Import schema modules only; keep React/admin presentation imports out.apps/webapp/byline/public.tsis the blessed client-safe configuration facade for public code. Do not expose admin/server config through it.- Server client getters (
getAdminBylineClient,getPublicBylineClient,getSystemBylineClient,getViewerBylineClient,isPreviewActive) come from@byline/client/server— typed via the generatedRegistermerge, server-only (browser export condition throws). Never import it into browser code. - Server bootstrap is a side effect of
apps/webapp/src/server.tsimportingbyline/server.config.ts. - Keep both
byline/admin.config.tsregistrations:_byline/route.tsxbeforeLoadprotects child loaders, while_byline/route.lazy.tsxprotects initial hydration. An eager import leaks the admin/editor graph into public bundles. Admin config registration
- After changing a collection, field, or block schema, run
pnpm byline:generateand commitapps/webapp/byline/generated/collection-types.ts. - App code imports collection types from
@byline/generated-types(the generated file declaration-merges into that stub package and into@byline/client'sRegister); never import the generated file by path. pnpm byline:generate:checkis read-only and fails on missing/stale output;byline/collection-types.contract.tschecks generated types exactly against inference.- Never hand-edit generated collection types or
apps/webapp/src/routeTree.gen.ts; both are excluded from Biome intentionally. - Generated collection types are canonical unpopulated read shapes. Keep operation-specific populate overlays near the query.
@byline/core/codegenis Node-only; do not re-export it from the browser-safe@byline/coreroot.
- Document storage is typed EAV. Use
packages/core/src/storage/field-store-map.tsfor field mapping,store-manifest.tsalongside it for shared store columns, andstorage-flatten.ts/storage-restore.tsfor write/read conversion. Each adapter owns its SQL. Document storage - Array/block
_idvalues are synthetic identity metadata. Do not persist or render them as schema data. - Ordinary reads/writes should use
@byline/clientor core lifecycle services. Directdb.commands.*/db.queries.*bypass auth, hooks, normalization, and lifecycle behavior and are only for seeds, migrations, tests, and internal tooling. - Content updates create immutable versions. Status, document paths, and advertised locales use dedicated non-versioned commands.
- Canonical numeric values are integer/float =
number, decimal = precision-preservingstring; stored file sizes restore asnumber. Core lifecycle normalization enforces this before hooks/storage. - Relation
hasMany,minItems, andmaxItemsaffect both inferred/generated types and collection fingerprints.
- Start the local database with the helper in postgres/ or mysql/. The full integration suite needs both engines, package-local
.env.testfiles and one-time initialization withpnpm db:init:testandpnpm db:init:test:mysql. Integration safety requires database names ending in_test. Local bootstrap scripts accept the designated_devor_testtargets. Development environment · Testing - Keep database integration runs serial. Packages share databases, migrate in global setup and truncate between files. Root integration concurrency is 1. Preserve the single-worker and isolation settings in the package Vitest configs.
- Each SQL adapter owns its Drizzle schema under
src/database/schema/. Usepnpm drizzle:generateand leavemigrations/metato Drizzle. Both core installers use their adapter's immutablemigrations/SQL and journal. The legacy hand-applied streams end at PostgreSQL 0015 and MySQL 0010. Inspect existing installations withbyline storage status, adopt the verified checkpoint with writers fenced, and upgrade journaled installations withbyline storage migrate. PostgreSQL upgrades · MySQL upgrades - Search and analytics drivers own independent numbered migration streams. Keep those migrations in their respective packages.
- Package node tests conventionally use
*.test.node.ts; client integration tests use*.integration.test.ts; db-postgres integration mode includessrc/**/tests/**/*.test.tsandtests/**/*.test.ts. - Both SQL adapters run node-mode unit suites via
pnpm test. Live storage conformance runs in integration mode. CI also runs the S3 conformance suite against an object store during the unit-test step. - Check each package's
vitest.config.tsbefore adding browser tests: plain*.test.tsxis not discovered by every package's defaultpnpm test. - There is no automated browser suite. Playwright was removed; do not add it back or treat a browser command as a gate. Verify browser behaviour by hand against a running dev server and record what you observed.
- When asked to commit, use conventional messages matching history (
feat(scope): ...,fix(scope): ...,docs: ...) and keep independently verifiable phases separate. Usegit commit -sfor the required DCO sign-off. It is the only permitted commit trailer.