@thecms/cli 0.0.0-stage → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,292 @@
1
+ # Method: a site on theCMS., from wherever you are to the standard {#method}
2
+
3
+ How you get to a site on theCMS. **whatever the starting point**: an old site, a template, the contents, only a logo, a prototype made on another system, an empty account.
4
+ The roads differ, the result is one: the **standard** ([`standard/app.md`](standard/app.md), [`standard/components.md`](standard/components.md), [`standard/brand.md`](standard/brand.md) and, for a site with an app for its users, [`standard/mobile.md`](standard/mobile.md)), checked by `thecms check`, `thecms brand` and `thecms verify`.
5
+
6
+ The method is not a fixed sequence:
7
+ 1. you **read the state** (account, workspace, site, brand);
8
+ 2. you understand **who the person is** and **where they start from**;
9
+ 3. you propose the **module** needed now; each module says what it needs and what it leaves, so the next one is always known.
10
+
11
+ A rule discovered on one site is written here, in its module, so that it holds for everyone.
12
+
13
+ ---
14
+
15
+ ## 1. How we work {#how-we-work}
16
+
17
+ These rules hold for every site; the CLI and the MCP apply them.
18
+
19
+ - **Proposal before code.** A change touching several files is presented first: file by file, what changes, what shows, the open choices. Then you wait for the ok. "Go ahead with X" says *what*, not *how*: the proposal stays. A small fix, in one file, already asked for, goes straight in.
20
+ - **Do what is asked.** A future goal changes *how* today's code is written, it does not add work today.
21
+ - **The site first, then the product.** A need that could become a feature of theCMS. is solved in the site or in the workspace. The product gets a report only for a bug or a real limit of the library or of the platform.
22
+ - **Languages before the workspace.** They are decided before the workspace exists: the default language never changes afterwards.
23
+ - **The workspace as the person, like the dashboard.** The MCP and the project's scripts work with the person's own sign-in (`thecms login`: the personal token, read from the computer's keychain at each run, never written in a file), with their role. Changes to the workspace are routine operations: no backup. Inside an approved proposal they are carried out; outside one, you ask.
24
+ - **Idempotent changes.** Every change to the workspace sits in a script that writes only what differs and can run again ("as designed").
25
+ - **Secrets.** An API key is only for what runs without a person — the CI and a site's server that writes —, each with a role made for its purpose. A secret the platform generates is written by the MCP into a file ignored by git (`.env.local`) and never shown in the conversation; a secret the person types (a provider's keys, a sign-in method's secret) is entered in the dashboard. Never written credentials.
26
+ - **No environment variable in the site, except secrets.** The address, the name, the languages, the globals and the messages come from `cms.site()`; the application's public key sits in `lib/cms.ts`. The exceptions are secrets, read on the server only (route handlers, server components, lib files no `"use client"` file imports), never `NEXT_PUBLIC_*`, never committed: `THECMS_SECRET_KEY` of a site that writes records (a contact form, a review), and the secret of a third party the site integrates, named `<PROVIDER>_SECRET_KEY` (reCAPTCHA's `RECAPTCHA_SECRET_KEY`). Analytics, Tag Manager, pixels, captcha and the cookie banner are the site's own code: their public ids live in the globals, their secret in that variable (`thecms check`).
27
+ - **Drafts show only inside the dashboard's editor**; a browser tab always shows the published site.
28
+ - **Git.** Everything on `main`, commits in English with the why; no branches left behind; no push without an ok.
29
+ - **One development server** per site.
30
+ - **Where and which.** Where a value is used is the component's choice, which value is the brand's.
31
+ - **Language.** With the client and in the documents, their language; code, commits and the workspace's structure in English — schema and field names, their labels, plural names, enum values, sets and shapes. The client's language lives in the contents and in the messages: the site translates (filters, buttons, labels from the messages).
32
+ - **Only verified facts.** What is stated has been measured: the old site, the documents, the API's answers.
33
+ - **Decisions when they are needed.** Each choice (the languages, the structure, the design's direction, the typefaces, the texts to approve, every plan to write) is asked at the moment it serves, as an interactive question: the options, the recommended first, the why in one line — the MCP asks through the agent's client when it can. A phase's document opens with the decisions taken (date, who): it is not where the choices are found.
34
+ - **Propose, from where the person is**: every answer ends with what to do next — read the role, the workspace's state and its features, offer one to three steps (the recommended first, the why in one line); ask where to work when it is not clear; say what is missing (a feature, a role, the product) when something cannot be done.
35
+ - **What the person sees is an artifact.** Everything made for the person to look at, choose, approve or pass on — the logo's directions, proposals, comparisons, tables, reports, previews, the checks' results — is published as an artifact, from the first one and without waiting to be asked: the **board** (Design type) for the identity, the model and the design, the client proposal (Slides type), an artifact of its own for the rest. Never an HTML or markdown file to open: the project keeps only the sources for the machines (`brand/tokens.json`, the logo's SVGs, the icons, `design/design.json`, the caches). An agent that cannot publish artifacts says so and writes no file in their place; one already kept as a file is published as its artifact and the file deleted (`realign` lists them).
36
+ - **The MCP does what the role allows.** Everything the person's role allows in the dashboard, the agent does through the MCP: it never sends the person to the dashboard for it. When no tool does it, the agent says "the MCP lacks <what>" — a gap of the product, to report — and stops there. The dashboard stays the person's only for what is never an agent's: the secrets they type (a sign-in method's secret, the keys of a payment, video or storage provider), money (refunds), legal acceptances, the platform's console, a visitor's own data.
37
+ - **Everything in the site's project.** Never a site's files in the product's repository.
38
+
39
+ ---
40
+
41
+ ## 2. Reading the state {#state}
42
+
43
+ Before proposing anything, look at what is there. Each level is read with one call; what is missing says which module is needed.
44
+ The workspace's routes sit under `/v1/{workspace}/…`.
45
+
46
+ ### Account {#level-account}
47
+ - **Read with**: the person's token: `GET /v1/_auth/account`, `GET /v1/_auth/my-workspaces`.
48
+ - **Look at**: how many workspaces, with which languages.
49
+ - **If missing or wrong**: no workspace → the languages are decided **first** (the default one never changes afterwards), then the person creates it (the dashboard's profile, or the MCP's `create_workspace`): they are its owner. A workspace for a client is created by the platform's administrator with the client as its owner.
50
+
51
+ ### Model {#level-model}
52
+ - **Read with**: the workspace's key: `/schemas`, `/widgets`.
53
+ - **Look at**: published schemas and fields; sets, shapes, the shapes' fields, the delivered fields (`settings.fields`).
54
+ - **If missing or wrong**: empty schemas, or schemas designed around the widgets → **Data model**.
55
+
56
+ ### Contents {#level-contents}
57
+ - **Read with**: `/records/{schema}`, `/assets`, `/globals`, `/messages`.
58
+ - **Look at**: published records per schema, languages covered, the images' alt, the organisation's data, the interface's texts.
59
+ - **If missing or wrong**: few records, languages not covered, missing alt → **Contents**.
60
+
61
+ ### Pages {#level-pages}
62
+ - **Read with**: `/views?app=…`, `/layouts`.
63
+ - **Look at**: pages, status, SEO, blocks with a title; menu and footer in the layout.
64
+ - **If missing or wrong**: pages without blocks or SEO → **Data model** (pages) and **Contents** (SEO).
65
+
66
+ ### Application {#level-application}
67
+ - **Read with**: `/applications`.
68
+ - **Look at**: Site URL, Site name, sitemap, public key, redirects; with an app for the users, the app's own application (no pages, the role of its users).
69
+ - **If missing or wrong**: a Site URL that does not lead to the site → **Application**; an app without its application or its users' role → **App**.
70
+
71
+ ### Site {#level-site}
72
+ - **Read with**: the repository.
73
+ - **Look at**: is there a Next.js app with `@thecms/next`? is the key in `lib/cms.ts` the app's? do `thecms check`, `thecms brand`, `thecms verify` pass?
74
+ - **If missing or wrong**: no app → **Application**; `thecms check` does not pass → **Components**.
75
+
76
+ ### Brand {#level-brand}
77
+ - **Read with**: the repository.
78
+ - **Look at**: `brand/tokens.json`, a vector logo, icons; the board's Logo, Manual, Motion and Voice pages and their approval (`design/design.json`).
79
+ - **If missing or wrong**: no tokens → **Brand** (from the logo, from the template or from scratch).
80
+
81
+ ### Quality signals {#quality-signals}
82
+
83
+ Even when everything is there: a field no component reads, two fields with the same data, an interface text written in the code, an image without alt, a page without a description, a block the site cannot draw. Each one is a proposed fix, with its reason.
84
+
85
+ ---
86
+
87
+ ## 3. Who the person is {#who}
88
+
89
+ It changes who decides, how much is explained, what is proposed. It does not change the result.
90
+
91
+ ### Agency or developer {#who-agency}
92
+ - **Decides**: structure, code, delivery; the client approves design, texts, price.
93
+ - **What is proposed**: every module, with the whole standard; the client proposal.
94
+
95
+ ### Professional or small business {#who-professional}
96
+ Making their own site.
97
+ - **Decides**: contents, brand, the visible choices.
98
+ - **What is proposed**: the modules in plain words, one decision at a time; the code follows the standard without asking.
99
+
100
+ ### Editorial team {#who-editorial}
101
+ On a site already made.
102
+ - **Decides**: only the contents.
103
+ - **What is proposed**: the Contents module and the quality signals; structure and code stay with whoever owns the site.
104
+
105
+ The standard is **Next.js with `@thecms/next`**; an app for the site's users is **native** — Swift / SwiftUI for iPhone, Kotlin / Jetpack Compose for Android — and talks to theCMS. through its HTTP API ([`standard/mobile.md`](standard/mobile.md)). A site made with another framework can use the CMS's data (with `@thecms/sdk`), but it is outside the standard: the checks do not cover it.
106
+
107
+ ---
108
+
109
+ ## 4. Starting points {#starting-points}
110
+
111
+ Each starting point is a sequence of modules (section 5). Modules already in place in the state are skipped — in a rebranding, a module of the identity is in place only once it changed.
112
+
113
+ **The starting point is the person's.** It is asked as an interactive question — the options, the recommended first (what the state suggests: a prototype in the folder, a site already made, a full workspace), the why in one line — and never chosen by the agent; until the person chose, no sequence opens. The choice is kept in the project (`design/design.json`) and changes only when the person asks.
114
+
115
+ ### An old site to remake {#from-old-site}
116
+ Contents (reading the old site) → Data model → Logo → Brand → Type and tone → Design → Application → Components → Verification.
117
+ - **Before reading, the scope** is the person's: a proof of concept (the main pages and a few of each model) or the whole archive, which languages, whether images and documents come too, how many pages at most.
118
+ - **The sources, in this order**: an export from the client (WordPress: Tools › Export, a dump of its database, its sitemap) or an access to the old CMS; else the public site read with `thecms capture <url>` (the MCP's `capture_site`); the agent's own browser only as the last way, when the person confirms there is neither an export nor an access.
119
+ - **The reading**: first a sample, 1–2 pages of each model, shown to the person as an artifact; then the rest, on its own, at a human pace — robots.txt kept, never faster than the site allows. A site that stops programs is never bypassed: ask the client for the export or the access.
120
+ - **The cache**, `content/old-site/` in the project — one markdown per page with its source, language, title, description, social image, alternates and model; the files the pages link; the menus — is the input of Contents and Data model. The site is read once: started again, the reading takes only what is missing.
121
+
122
+ ### A template {#from-template}
123
+ Brand *from the template* (colours, typefaces, spaces brought onto the scale) → Data model *from the template's sections* (each section is a candidate set · shape) → Contents → Application → Components *from the template's markup* → Verification. Design is skipped: it is the template.
124
+
125
+ ### The contents {#from-contents}
126
+ Texts, documents, a catalogue: Contents → Data model (the schemas come from the contents) → Logo → Brand → Type and tone → Design → Application → Components → Verification.
127
+
128
+ ### Only a logo or a brand {#from-logo}
129
+ Logo → Brand → Type and tone → Data model → Design → Contents → Application → Components → Verification. The identity needs no data; the pages' design does: the model comes before it.
130
+
131
+ ### A full workspace, without a site {#from-full-workspace}
132
+ Logo, Brand, Type and tone and Design if missing → Application → Components → Verification. The project exists before its app (`thecms create` without a public key: `brand/`, the MCP; `thecms brand` makes the icons in `brand/` and gives the data of the board's Manual and Motion pages); the app comes with the application.
133
+
134
+ ### A site on theCMS. already made {#from-existing-site}
135
+ Verification (`thecms check`, `thecms brand`, `thecms verify`) → the fixes it finds, module by module.
136
+
137
+ ### A rebranding {#from-rebrand}
138
+ A new identity for a site on theCMS. already made: Before → Logo → Brand → Type and tone → Design → Components → Verification (the after against the before); for those working for a client, the Client proposal with the before and the after.
139
+ - **The before first**, then the rebranding is opened (the MCP's `record_design` with `kind: rebrand`): the board, the proposal and the directions so far go to the history of `design/design.json` — kept, with their addresses, never lost.
140
+ - **Logo, Brand, Type and tone, Components** count done once each changed since the rebranding opened (measured on `brand/logo/`, `brand/tokens.json`, the components and `site.css`); **Design** once the new board is approved.
141
+ - **The data and the contents do not change**: a field the new design asks for goes through the Data model as a change of its own, with its ok.
142
+
143
+ ### A prototype on another system {#from-prototype}
144
+ A prototype the person made elsewhere — Supabase and a React Native app, say — to bring onto theCMS., done properly: Reading the prototype → Data model → Logo → Brand → Type and tone → Design → Contents → Application → Components → App → Verification.
145
+ - **Recognised by itself**: the first reading of the state in the folder sees the prototype (Supabase: `@supabase/supabase-js` among the dependencies, `supabase/migrations`; a React Native / Expo app) and says so; the question of the starting point recommends it first, the person confirms.
146
+ - **What it gives**: the model (tables, links, what never repeats, the rules of "only mine"), the app's screens and flows, its colours and typefaces, how its users sign in — all proposals, read once into `content/prototype/`; the person approves the model as always.
147
+ - **What comes across**: the model and the **shared** contents (rows that belong to nobody: a library of exercises); **never** the users nor their personal data — the identities change (the users sign in with the workspace's methods) and the prototype stays a prototype.
148
+ - The result is a site and its app (below): the site the showcase, the app native.
149
+
150
+ ### A site and its app {#with-app}
151
+ Not a starting point of its own: any road above, when the person also wants an **app where the site's users act** — they sign in, keep their own data, interact with others' (a gym's training log, a club's posts with likes and comments).
152
+ - **The app is native**: Swift / SwiftUI for iPhone (`ios/`), Kotlin / Jetpack Compose for Android (`android/`) — never a cross-platform framework. It is the client's code, written following [`standard/mobile.md`](standard/mobile.md), and talks to theCMS. through its HTTP API.
153
+ - **Two applications in the same workspace, one brand.** The **site** is the showcase: public contents, SEO, marketing — pages, sitemap, no role for its users (its readers do not write). The **app** belongs to the users: no pages, the role of its users, its Site URL the site's address followed by `/app` (`https://example.com/app`), so the return from the sign-in reopens the app and never the site.
154
+ - **The sequence** is the road's own with **App** after Components; Design draws the app's screens too (the board's App page); Verification covers the app.
155
+ - **Before the app**: the workspace has the readers' feature and a sign-in method on (its secret typed by the person in the dashboard).
156
+
157
+ ### Nothing: an empty account {#from-nothing}
158
+ Questions: who are you, what site, what do you already have (a site, a template, contents, a logo) → one of the starting points above.
159
+
160
+ With a template, its CSS does not go in as it is: colours, spaces and text styles become tokens and roles, the components are rewritten following the standard, and `thecms check` confirms it.
161
+
162
+ ---
163
+
164
+ ## 5. Modules {#modules}
165
+
166
+ Each module: **needs** (what must be there first) · **produces** (what is there afterwards) · **who decides** · **rules** · **how to check**.
167
+
168
+ ### Reading the prototype {#module-prototype}
169
+ - **Needs**: the prototype's project in the folder (its database's migrations, its app's code).
170
+ - **Produces**: `content/prototype/reading.json`, read once (`thecms prototype`, the MCP's `read_prototype`) — a cache for the machines, never a document to read: the tables as proposed schemas (their types translated), the foreign keys as relations, the unique constraints and composite keys as `unique`, the references to the users as `_reader` / `_createdBy`, the rules of "only mine" (`auth.uid()`) as the role of the app's users, the functions and triggers listed as rules for later; from the app, its screens and flows, its colours and typefaces (a proposal for the brand), how its users sign in.
171
+ - **Who decides**: nobody: it is a reading; every proposal goes to its module (the model to Data model, the colours to Brand, the screens to Design), where the person approves it. The person sees the proposed model on the board's **Model** page.
172
+ - **Rules**: the database's code read with a parser, never with patterns on its text; the users and their data stay behind; the server's functions are not carried — they are listed.
173
+ - **How to check**: the board's Model page says, table by table, what the reading proposes and what it leaves.
174
+
175
+ ### Before (a rebranding) {#module-before}
176
+ - **Needs**: the site online, as it is today.
177
+ - **Produces**: the HTML of every address (the sitemap plus a 404) and the screenshots of every page at a desktop and a phone width, in the project; the rebranding opened, the old board and proposal in the history.
178
+ - **Who decides**: nobody: it is a measurement, taken before any change of the identity.
179
+ - **Rules**: two shots in a row identical (scrolling, for lazy images); nothing of the identity changes before it is taken.
180
+ - **How to check**: `design/design.json` holds the rebranding with where the before is.
181
+
182
+ ### Logo {#module-logo}
183
+ - **Needs**: the existing logo (even a small PNG) or the request for a new one.
184
+ - **Produces**: the logo's sources in `brand/logo/` (a faithful vector, refined, negative — SVG files), the symbol for the icons; the board's **Logo** page: the directions, the refinement justified point by point, the sizes and the versions. The board is **published as an artifact of the Design type** before the first direction is shown, its address recorded (`record_design`): Logo is often its first page.
185
+ - **Who decides**: the person chooses the direction and approves the refinement, the clear space and the minimum size, on the Logo page.
186
+ - **Rules**: first the faithful vector (letters as paths), then the refinement justified point by point (one colour, exact proportions, equal margins, small text legible); a negative version; the symbol on a grid that falls on whole pixels; what is shown about the logo — the directions, the comparisons, the sizes — is its page in the board, never a README, an HTML sheet or another file beside the SVGs.
187
+ - **How to check**: original/refined comparison; icons at 16, 32, 48, 180, 192, 512 px — `thecms logo trace` (a first faithful vector from a raster), `thecms logo compare`, `thecms logo render`: nothing to install — shown on the Logo page.
188
+
189
+ ### Brand {#module-brand}
190
+ - **Needs**: the logo, or the template, or a graphic direction.
191
+ - **Produces**: `brand/tokens.json` and what `thecms brand` generates from it (the site's variables and roles, the icons): [`standard/brand.md`](standard/brand.md); the board's **Manual** page — colours with their use, the space scale, the layout, the text roles with an example each, the icons — its data generated from the tokens; the board's **Motion** page — how the blocks enter with the scroll (`motion`), with a live example — its CSS generated from the tokens.
192
+ - **Who decides**: the person approves the colours, the scale and the layout we propose, on the Manual page, and how the site moves, on the Motion page.
193
+ - **Rules**: one source (`tokens.json`); space belongs to the brand: a 9-step scale, below the first step it is optical correction; layout in the brand (maximum width, side margin, block space, first block, grid, phone breakpoint); colours with their use (CMYK and Pantone from the printer); motion in the brand, once for the whole site, as the default of a site without its own: every block's texts and pictures enter the same way, tied to the scroll, CSS only — nothing moves with reduced motion or in a browser without scroll-driven animations, a ground (anything that carries a background) never moves, a carousel scrolls only sideways; a site may animate as its template wants, with three obligations: reduced motion turns everything off, the page is complete without motion, motion never changes the layout; the CSS and the Manual and Motion pages' data generated from the tokens, never written by hand. **Where** a value is used is the component's choice, **which** value the brand's.
194
+ - **How to check**: `thecms brand` (spaces, text styles, breakpoints, colours of `site.css`); `thecms check` (the three obligations of motion: every animation, timeline and moving transition off with reduced motion, and a file that moves things by script says what reduced motion does; no text or picture invisible by default; no `@keyframes`, transition or `.style` write of a layout property from a scroll listener or frame; no ground on a text or picture while the brand's motion is on; no carousel scrolling up and down); `thecms verify --render --site-url …` in the site's pipeline, on the started build, proves the page is complete with JavaScript off and with reduced motion; the Manual and Motion pages approved.
195
+
196
+ ### Type and tone {#module-type-and-tone}
197
+ - **Needs**: the brand.
198
+ - **Produces**: the type roles in `tokens.json`; the rules of the tone in `tokens.json` (`voice`), shown on the board's **Voice** page — its data generated from the tokens.
199
+ - **Who decides**: the person chooses the typeface (on the Manual page) and the tone (on the Voice page).
200
+ - **Rules**: a free typeface, served by the site; each text style is a complete **role** (the phone's size in a `clamp()`, leading, weight, width, tracking, uppercase) used with the class `t-<role>`; no generic AI look (cream background, soft serif and terracotta, rounded cards): real references looked for first; clear, short texts, from the real documents.
201
+ - **How to check**: the Manual page with one example per role, the Voice page with one example per rule.
202
+
203
+ ### Design {#module-design}
204
+ - **Needs**: brand, typefaces, the planned sets and shapes (even only as a hypothesis).
205
+ - **Produces**: a **board** (the identity's pages — **Logo**, **Manual**, **Motion**, **Voice** —, the proposed **Model** — the structure, and from a prototype or an old site what their reading proposes —; system, one artboard per set · shape, desktop and mobile pages, the archive of the directions; with an app, the **App** page: each screen, iPhone and Android, with the workspace's real contents and the main flows — the sign-in, the main action, the interaction with others; from a prototype, its screens are the starting point) with the workspace's real contents, **published as an artifact of the Design type** — the same one the first module that showed something (Logo, the Model) started —, its address and its approval in the project (`design/design.json`): the module is done when the board is approved. A board already kept as a file (`design/board.html`, `docs/design.md`…) is drawn again as its artifact, the file deleted.
206
+ - **Who decides**: the person chooses the direction among three proposals with real references, then approves each set · shape; the identity's pages and the Model are approved one by one (Logo, Manual, Motion, Voice, Model).
207
+ - **Rules**: everything the person looks at or approves is a page of this ONE board — never an md or an html file to read; the project keeps only the sources for the machines (`brand/tokens.json` with the tone inside, the logo's SVGs, the icons, `design/design.json`, the JSON caches); the page is the stack of blocks the CMS delivers, each set · shape is a module of its own; the fields a shape asks for are noted as proposals for the Data model.
208
+ - **Example of a choice**: the colour comes from the photos, the interface stays sober.
209
+ - **Skipped**: when the design already exists (a template, a site to keep).
210
+
211
+ ### Data model {#module-data-model}
212
+ - **Needs**: the contents (or their list; from an old site, its cache `content/old-site/`: the models of its pages, the types that recur; from a prototype, its reading `content/prototype/`) and, if there is one, the design or the template; the pages and the blocks each one shows (from the design, the template or the old site).
213
+ - **Produces**: schemas, sets, shapes, pages, layouts, application on the workspace; the structure as the board's **Model** page (schemas, fields, relations, sets and shapes) and the idempotent script that writes it, a source in the site's project.
214
+ - **Who decides**: the person approves the structure on the board's Model page, then each change.
215
+ - **Rules**:
216
+ - **the model starts from how it is shown**: each page and block (view, set, shape) says which records it reads and how — a list, a filter on the open record (`{context.<field>}`), without the open record (`{context._id}`), a tree, an order by `position`; the schemas and fields are the ones those readings need. "See also" is a shared category read by a block filtered on the open record, never a relation; a relation of a schema with itself is a tree (a menu, nested pages);
217
+ - **schemas describe the domain**, not the widgets (`event` and `venue`; an event inside another is a relation of the schema with itself; "carousel" is a shape, not a schema);
218
+ - **every field serves**: it has someone who reads it and does not repeat a piece of data; otherwise it goes;
219
+ - **every field at its level**: *record* the content; *placement* what holds on that page (the block's title, "see all", a list's introduction); *shape* a variant of the drawing;
220
+ - **no layout in the CMS** (margins, colours, the side of a photo): the data does not depend on the frontend;
221
+ - **the words that introduce a list sit in the list**;
222
+ - order decided by the editor (`position`); languages: the main one without a prefix, the others `/xx/`; names in `snake_case`, schemas in the singular; a relation is named after the schema it points at — singular for one, plural for many, a second one to the same schema `<name>_<role>`;
223
+ - **the structure is in English**: schema and field names, their labels (`name`, `pluralName`, `label`), enum values, sets and shapes — a label left out is made from the name (`service_category` → "Service category", "Service categories"); the client's language lives in the contents and in the messages, the site translates; a label already in another language is a check of the plan and is listed by `realign` (a label changes at once, no record is touched);
224
+ - **everything the site shows comes from the workspace**: contents, menu, footer, the organisation's data (globals), the interface's texts (messages), SEO, redirects; the site's name is the application's *Site name*.
225
+ - **How to check**: `thecms verify`; running the script again changes nothing.
226
+
227
+ ### Contents {#module-contents}
228
+ - **Needs**: the model (or its draft); from an old site, its cache `content/old-site/` (`thecms capture`).
229
+ - **Produces**: published records in every language, images with alt, globals, messages, the pages' SEO; the approved texts in the site's project.
230
+ - **Who decides**: the person approves the texts.
231
+ - **Rules**: an old site is read **once** and kept in a cache, then the import is an idempotent script; from a prototype only the shared contents, never its users nor their data; the real data wins over the old site (a date from the document's heading); text proposals are shown to the person as an artifact and stay in the project, as the import's source, until they are approved; the alt says what the photo shows; a translation is corrected where it is safe, the rest is proofread.
232
+ - **How to check**: `thecms verify`; the approved texts against the site.
233
+
234
+ ### Application {#module-application}
235
+ - **Needs**: a workspace with an application and its public key.
236
+ - **Produces**: the standard's Next.js app ([`standard/app.md`](standard/app.md)): one route for every address, a layout with the language, error pages, robots, sitemap, manifest, icons, no environment variable but secrets; the application's Site URL on the site.
237
+ - **Rules**: the site draws, the CMS decides; configuration from the CMS; generic logic from the library (`/kit`), what belongs only to the site in `lib/site.ts`.
238
+ - **How to check**: build, `thecms verify`, "Open site" from the dashboard opens the site.
239
+
240
+ ### Components {#module-components}
241
+ - **Needs**: application, brand, design (or template), the workspace's shapes.
242
+ - **Produces**: one component for every shape, `site.css` with one section per shape ([`standard/components.md`](standard/components.md)).
243
+ - **Rules**: the component receives only `{ block }` and reads the rest from `cmsContext()`; root `blk()`, `.wrap`, the block's header, body; space inside the block, steps of the scale, choices by position with `orderOf`; texts only with `t-*` roles and from the messages; colours from the tokens; no `style={{}}`; images with `image()`, the first of the first block at once, the others lazy; filters and pages with the CMS's tokens (`?f=<token>`).
244
+ - **How to check**: `thecms check` (before every build), `thecms verify` (shapes ↔ components).
245
+
246
+ ### App {#module-app}
247
+ - **Needs**: the site's application and the app's (method §4, a site and its app); the data model with what the users write — their profile, their own records, their interactions with others' contents; a sign-in method on; the board's App page approved.
248
+ - **Produces**: the native app — `ios/` (Swift / SwiftUI) and `android/` (Kotlin / Jetpack Compose) — written following [`standard/mobile.md`](standard/mobile.md): the sign-in with PKCE in the system's window, the session in the phone's keychain, writes as the user through the HTTP API; `app.thecms.json` (the app's key, its identities, the schemas it writes and reads); the role of the app's users; the themes `thecms brand` generates from `brand/tokens.json` (`ios/Theme.swift`, Android's `Theme.kt`); the site's `/.well-known` files that reopen the app.
249
+ - **Who decides**: the person approves what the users can do (the role, said in words) and the app's screens (the board).
250
+ - **Rules**:
251
+ - native, never a cross-platform framework; no secret and no server in the app: the users write only through the role of their application — their own records and files, others' only read under a condition, never a publish;
252
+ - interacting with others' contents is a record of the user's own linked to theirs (a like, a comment, a follow), with its uniqueness (one like per user and post);
253
+ - people are a relation to `_reader` with their profile (`readerProfile`), never an email;
254
+ - colours, text roles and spaces only from the generated themes; the interface's texts from the messages.
255
+ - **How to check**: `thecms verify` (rule `app`), the app's build in Xcode and Gradle, a sign-in on a phone or a simulator that comes back to the app.
256
+
257
+ ### Verification {#module-verification}
258
+ - **HTML**: the same addresses (sitemap plus a 404) before and after; differences only where expected.
259
+ - **Screenshots** of every page at a desktop width and at a phone width, before and after, pixel by pixel (scrolling, for lazy images); two shots in a row must be identical.
260
+ - **Measurements** where a proposal promises a number.
261
+ - **Checks**: `thecms check`, `thecms brand`, `thecms verify`, typecheck, build.
262
+ - **The app**, when there is one: `thecms verify` (rule `app`) — the users' role, a sign-in method on, the site's `/.well-known` files answering, every schema `app.thecms.json` declares inside the role, the app without pages and the site without a role, the themes in line with the tokens.
263
+ - **Cache**: the site's answers stay 60 s; a change on the workspace is checked afterwards.
264
+ - **What the person sees**: the before and the after side by side, the differences, the checks' results — an artifact, never a report file.
265
+
266
+ ### Client proposal (for those working for a client) {#module-client-proposal}
267
+ - **Needs**: the design's board, the state of today's site.
268
+ - **Produces**: a presentation **published as an artifact of the Slides type** (one already kept as a file is drawn again as its artifact, the file deleted): how it is today and how it will be (identity, site — and the app, when there is one —, how it is found), with real measurements; a price on value, which pays back the infrastructure with a margin.
269
+
270
+ ---
271
+
272
+ ## 6. Site and product {#site-and-product}
273
+
274
+ - The standard uses `@thecms/next` and `@thecms/sdk` from npmjs.org (public, no key), all at the same pinned version; how they reach your computer and your site is section 7.
275
+ - The product gets a report only for a bug or a real limit, with the case reproduced and what is expected; the site adapts when the library changes.
276
+ - This text is the **one source** of the method and of the standard: the CLI includes it in every release and shows it with `thecms docs`; the starter (`@thecms/create-app`) and the **MCP** (`thecms mcp`) read it from there. The MCP does this method: section 2 is the reading of the state (`state`), sections 3 and 4 the advice (`next_steps`), the modules the actions (`apply_*`, `publish`), the standard's checks its verifications (`check`, `brand`, `verify`, `quality`).
277
+ - The method and the standard do not change without the ok of whoever is responsible for the product.
278
+
279
+ ---
280
+
281
+ ## 7. Your computer and your site {#computer-and-site}
282
+
283
+ Two places, each set up once.
284
+
285
+ ### Your computer {#your-computer}
286
+ - The `thecms` CLI (`@thecms/cli`) is installed **once, globally**: `npm install -g @thecms/cli` (the same line in Profile › Connected computers). The same CLI serves every site on the computer; `thecms mcp` runs from it.
287
+ - `thecms login` signs the computer in with your account (a personal token, kept in the system's keychain), `thecms logout` signs it out.
288
+ - Afterwards the CLI **updates itself**: `thecms upgrade` (signed in) from any folder brings it to the latest version, `thecms upgrade <version>` to the one named (a release candidate too) — no token to copy; inside a site the site's theCMS. packages follow at the same version.
289
+
290
+ ### Your site {#your-site}
291
+ - theCMS.'s packages need **no `.npmrc`**: they install from npmjs.org like any other. `thecms upgrade` takes theCMS.'s old lines (registry and token) out of a site's `.npmrc`; the site's own lines stay.
292
+ - `thecms doctor` checks it: the site no longer names the old packages (`@toninospiderman123/…`) nor their registry.
@@ -0,0 +1,127 @@
1
+ # Standard · The Next.js application {#standard-app}
2
+
3
+ How a site on theCMS. is made: one way only, the cleanest for how the product works.
4
+ Whoever starts from an old site, a template or the contents gets here ([method](../method.md)). How a component is written is in [`components.md`](components.md), the graphic values in [`brand.md`](brand.md).
5
+
6
+ > **Already there:** the `thecms` CLI (`@thecms/cli`): `thecms create` creates this application file by file (with `brand/` beside it), `thecms docs` shows these texts, `thecms doctor` / `thecms upgrade` keep the packages at the same version, `thecms brand` and `thecms check` check brand and code before every build, `thecms verify` compares the workspace with the site. The rest is already there: in `@thecms/next` `createNextCms`, `cms.page`, `cms.metadata`, `cms.site`, `cms.siteText` (the site's text without a page, with `CmsSiteTexts` / `useSiteTexts`), `CmsBlocks`, `cmsContext`, `cms.handler`, `cms.robots`, `cms.sitemap`; in `@thecms/next/kit` the components' generic functions.
7
+
8
+ ---
9
+
10
+ ## 1. Principle {#app-principle}
11
+
12
+ **The site draws, the CMS decides.** Addresses, languages, redirects, 404, contents, menu, footer, interface texts, SEO, sitemap come from the CMS with the application's public key. The site's code holds only **how** each block is drawn, with the brand's values.
13
+
14
+ It follows:
15
+ - no page written by hand: one route for every address;
16
+ - no environment variable but secrets (the secret key of a site that writes, a third party's `<PROVIDER>_SECRET_KEY`): the address, the name, the languages, the globals come from `cms.site()`;
17
+ - no text in the code (exception: the error page when the CMS does not answer);
18
+ - no graphic value written by hand: they come from `brand/tokens.json`.
19
+
20
+ ---
21
+
22
+ ## 2. The files {#app-files}
23
+
24
+ **One project, one or more sites**: `brand/` and one or more apps (`frontend/` by default; in a monorepo the apps the project lists). Each site is an application of the workspace: its public key in `lib/cms.ts`, its Site URL its own address; one key per host, the host chooses only among the declared ones, every address from the Site URL.
25
+
26
+ Key: **library** = given by `@thecms/next` · **generated** = by a command, never by hand · **site** = written for this site.
27
+
28
+ ```
29
+ brand/ the graphic values (outside the app: they hold for paper too)
30
+ tokens.json site one source: colours, typefaces and roles, space scale, layout, logo
31
+ logo/ site vector logo, refined, negative; symbol.svg (square): the icons' symbol
32
+
33
+ frontend/ the Next.js app
34
+ package.json site dev · prebuild · build · start · typecheck · brand · check
35
+ next.config.ts site the minimum (section 5)
36
+ tsconfig.json site alias @/* on the app's folder
37
+ app/
38
+ [[...path]]/
39
+ layout.tsx site the document: <html lang>, typeface, CSS, the error pages' texts
40
+ page.tsx site the page: metadata, structured data, <CmsBlocks page={page} main />
41
+ not-found.tsx site 404 in the address's language
42
+ error.tsx site page not drawn: "try again"
43
+ global-error.tsx site the CMS does not answer: the only text written in the code
44
+ api/cms/[...cms]/route.ts library cms.handler: editor, drafts, reads, sign-ins, purchases
45
+ robots.ts library cms.robots
46
+ sitemap.xml/route.ts library cms.sitemap
47
+ .well-known/ site apple-app-site-association, assetlinks.json: the app's links on /app/* only ([`mobile.md`](mobile.md))
48
+ manifest.ts site name from the Site name, colours from the tokens, icons
49
+ tokens.css generated variables and type roles (.t-*) (thecms brand)
50
+ font.ts generated the typeface with next/font, from where tokens.json says (thecms brand)
51
+ fonts/ generated the typeface's files when it sits in brand/ (thecms brand)
52
+ brand.ts generated name and colours for manifest.ts (thecms brand)
53
+ site.css site one sheet, one section for each set · shape
54
+ components/
55
+ blocks/
56
+ index.ts site the components map: set → shape → component
57
+ <set>.tsx site one file per set, one component per shape
58
+ head.tsx site BlockHead: the header of every block
59
+ client.tsx site only the interactive parts ("use client")
60
+ structured-data.tsx site the page's ld+json scripts
61
+ lib/
62
+ cms.ts site createNextCms({ publicKey, components })
63
+ site.ts site what holds only for this site (depends on its schemas)
64
+ jsonld.ts site the structured data, from the site's domain
65
+ app-links.json generated the app's identities for .well-known, from app.thecms.json (thecms brand)
66
+ public/ generated icons (favicon.ico, icon.svg, apple-icon.png, icon-192/512.png) (thecms brand)
67
+ ```
68
+
69
+ The generic logic, the same on every site (block, media, links, dates, markdown, filters, the texts of the pages without the CMS), does not sit in the site: `@thecms/next/kit` gives it. It holds no markup and no names of the domain. The components and `site.css` are the site's design.
70
+
71
+ ---
72
+
73
+ ## 3. A request, from the address to the drawing {#app-request}
74
+
75
+ 1. **`page.tsx`** calls `cms.page(props)`: the CMS resolves the address (language, redirect, 404, geographic block) and returns the page with its blocks already resolved (records, lists with filters and pages, links). An address with `?f=<token>` (a list's link: a page, a filter) gives the page with that list in that state, in the same answer.
76
+ 2. `cms.page()` fixes the request's **context**: from here on `cmsContext()` gives `page`, `locale`, `path`, `alternates`, `site` (the site's answer), `t()` (messages), `g()` (globals), `isFirst(block)`.
77
+ 3. **`layout.tsx`** reads `cms.site()` and the language from the address: `<html lang>`, the typeface, the error pages' texts.
78
+ 4. **`<CmsBlocks page={page} main />`** draws everything: the layout's blocks (menu, footer) and, inside `<main>`, the page's blocks; it mounts visits and the preview in the editor.
79
+ 5. For each block `CmsBlocks` picks the component from the map (`set` → `shape`); a container draws its slots with `<CmsBlocks blocks={slot} />`.
80
+ 6. **`generateMetadata`** uses `cms.metadata(props)`: title, description, absolute URLs, alternate languages, Open Graph, the record's dates. The site adds only what it knows of the domain (e.g. an article's official date).
81
+
82
+ Drafts show only inside the editor (the library guarantees it). The site's answers are cached for 60 s: a change on the workspace shows afterwards.
83
+
84
+ Readers and purchases go through the same library: `cms.signInUrl(key, returnTo)` for the sign-in buttons of `cms.site().signIn`, `cms.reader()`, `cms.unlock(keys)`, `cms.checkout(productId, returnTo)`, `cms.purchases()`, `cms.order(id)`; the route `api/cms/[...cms]` receives the return from the sign-in and the purchase form (`POST checkout`).
85
+
86
+ ---
87
+
88
+ ## 4. The document's pages {#app-pages}
89
+
90
+ | File | Does | Rules |
91
+ |---|---|---|
92
+ | `layout.tsx` | `<html lang>` from the address's language, `<body className="t-<role of the running text>">`, typeface, `tokens.css` + `site.css`, icons and manifest in the metadata | Reads only `cms.site()`; the error pages' texts from `siteText` |
93
+ | `page.tsx` | `cms.page` → `<StructuredData />` + `<CmsBlocks page={page} main />`; `generateMetadata` from `cms.metadata` | No markup of its own besides the `geoBlocked` case (text from `siteText`) |
94
+ | `not-found.tsx` | 404 in the address's language, links to the languages' homes, `<title>` | Texts from `siteText` (messages `notFound.*`) |
95
+ | `error.tsx` | Page not drawn, "try again" button | Texts from `siteText` (messages `error.*`) |
96
+ | `global-error.tsx` | The CMS does not answer | Has its own `<html>`; a fixed text in every language of the site: the only one in the code |
97
+ | `manifest.ts` | Name from the *Site name* (`cms.site().name`), colours from the tokens, icons | No value written by hand |
98
+
99
+ ---
100
+
101
+ ## 5. Configuration {#app-configuration}
102
+
103
+ - **Public key** of the application in `lib/cms.ts` (it is not a secret). The site reads no environment variable but secrets, on the server only (the server that writes, below). The project's scripts that change the workspace use the person's `thecms login` (`personalToken()` of the CLI with the SDK), never an API key in a file.
104
+ - **Application on the workspace**: Site URL = this site's address (in development `http://localhost:3000`), so "Open site" and the editor open the real site; Site name (the site's name, `cms.site().name`); sitemap on.
105
+ - **Languages**: the main one without a prefix, the others with `/xx/`; a page's language comes from its address.
106
+ - **Typeface**: `next/font` (served by the site, no request to third parties), exposed as the variable `--font-<name>`; family and weights from `tokens.json`.
107
+ - **Images**: `<img>` with the `srcSet` and `sizes` the CMS prepares (formats and sizes); no `next/image` (`images.unoptimized`).
108
+ - **Libraries**: `@thecms/next` and `@thecms/sdk` from npmjs.org, all at the same pinned version.
109
+ - **One development process** per site, on a fixed port (the same as the development Site URL).
110
+ - **A shape that writes** (its frontend lets a visitor create a record: a request, a booking, a review): the shape declares it on the set, the workspace gives a role that only creates and a key per environment; the site's own server writes with the SDK, the secret key and the visitor's address. The form, its route and its checks are the site's code; the platform limits the writes per visitor and per schema. The same for the secret of a third party the site integrates (reCAPTCHA, a pixel's API): an environment variable named `<PROVIDER>_SECRET_KEY` (`RECAPTCHA_SECRET_KEY`), read only on the server, never `NEXT_PUBLIC_*`, never committed; its public id lives in the globals.
111
+
112
+ ---
113
+
114
+ ## 6. Commands {#app-commands}
115
+
116
+ | Script | Does |
117
+ |---|---|
118
+ | `dev` | Next in development |
119
+ | `build` | Production build (must pass) |
120
+ | `typecheck` | `tsc --noEmit` |
121
+ | `brand` | `thecms brand`: validates `tokens.json`, generates `tokens.css`, `font.ts`, `brand.ts` and the icons (the Manual page's data for the board), checks spaces, text styles, breakpoints and colours in `site.css` |
122
+ | `check` | `thecms check`: checks components and pages against the standard ([`components.md`](components.md) section 15) |
123
+ | `prebuild` | `brand` and `check` before every build: outside the standard, the build does not start |
124
+
125
+ `thecms verify` compares the workspace with the site: with the public key alone, shapes ↔ components both ways, the homes of every language (SEO title, alternates), a made-up address is a 404, the sitemap; with `thecms login` or an API key (`--key`) every page in every language, the delivered blocks against the map, the blocks' links and images. `thecms docs` shows this text.
126
+
127
+ The build changes `next-env.d.ts`: it is not committed.