Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Get it running first, so you know the environment is sound:

```bash
npm install
npm test # 125 of them, ~4s, no network
npm test # 199 of them, ~1.5s, no network
npm run dev # demo mode; no keys needed
```

Expand Down Expand Up @@ -51,6 +51,14 @@ The `description` field is **the rubric Jev chooses from**. Write what kind of b

`LANGUAGES` in `lib/plan.ts` (the rubric Jev judges from) and `LANGUAGE_RULE` / `LENGTH_RULE` in `lib/content-parallel.ts` (the instructions the LLM writes under). Length hints are written for Chinese, so a new language needs a conversion note.

## Adding a component source

`lib/sources.ts` only. A source is one row: name, url, role, a factual one-line summary, licence, the exact install command an agent should run (or `null` when the browser is the only way in), the machine-readable endpoints that answered, the slots it can improve, and the caveat that bites whoever pastes it in without reading.

Fetch before you write. Every url, endpoint and command in that table was checked rather than recalled, and checking is what produced most of the caveats — `/r/index.json` is a 404 on beui.dev, `/registry.json` is a 404 on ui.shadcn.com, and Beautiful UI publishes no machine-readable surface at all. `npm run sources` re-runs those checks and exits non-zero if a declared endpoint stops answering; it needs the network, so it stays a script and never becomes a test.

`role` carries more weight than `blocks`. None of the five sources ships a marketing page section, so a source improves a block loom already renders rather than replacing one, and a `summary` written like a block catalogue sends an agent looking for a hero that does not exist. Check the licence in the same pass: one of the five forbids redistributing a substantial part of its collection, which is fine for a site built with it and not fine for anything vendored here.

## On what to ask a model

This is the one place the project has an opinion. Please follow it when changing things:
Expand Down
49 changes: 46 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,15 @@ The editor UI is a separate matter: eight languages, picked from `navigator.lang

## Export

Three formats, all derived from **the same rendered result**. There is no second copy of the layout code.
Five formats, all derived from **the same rendered result**. There is no second copy of the layout code.

| Export | Size | For |
|---|---|---|
| `site.html` | 36 KB | Put it online, or just double-click it |
| `Site.tsx` | 34 KB | Keep developing; compiles under `tsc --strict` |
| `spec.json` | a few KB | Archive it, or feed another renderer |
| `site.registry.json` | `Site.tsx`, wrapped | Install the page into a project that already uses shadcn/ui |
| `AGENTS.md` | a page | Hand the page to a coding agent: tokens, blocks, and where components come from |

### Site.tsx

Expand All @@ -209,6 +211,44 @@ Filtering tests each selector with `root.matches()` / `root.querySelector()`, st

Size-wise it only saves 16% (Tailwind was never the problem). The real gain is that the exported site no longer carries the editor's own styling. See `lib/export.ts`; there is **no second renderer**, block layout exists only in `app/registry.tsx`.

### site.registry.json

A [shadcn registry](https://ui.shadcn.com/docs/registry) item, so the page installs the way any shadcn component does:

```bash
npx shadcn@latest add ./site.registry.json
```

One command writes the component into whatever directory the project's `components.json` calls components, and merges the theme's 17 tokens into its stylesheet. The dependency list is empty on purpose: `Site.tsx` imports one type from React and nothing else, and padding the list would make the CLI install packages the file never uses. The CLI accepts a local path, so nothing has to be hosted first — the file the browser just downloaded works where it landed.

The item carries the same `Site.tsx` source; it is not a second rendering of the page. The tokens travel with it as `cssVars` because a component dropped into a project that defines its own variables renders in that project's colours, which is not the page anyone exported. They are keyed without the leading `--`, since the CLI adds that itself: written `--accent`, the token reaches the Tailwind bridge as `var(----accent)`, resolves to nothing, and the install still reports success.

### AGENTS.md

A short brief for the coding agent that picks the export up: `spec.json` is the authoritative description of the page, here are the 17 theme tokens with their values, here are the blocks this page actually has, and here are the component sources relevant to those blocks. It is written to be read once before work starts, not as documentation for a person.

## Components worth stealing

The workflow is the lazy one — point a coding agent at a good library and let it pick, adapt and paste. `lib/sources.ts` is the table it reads: five libraries, each with its role, licence, install command, the machine-readable endpoints that answered when they were checked, the slots it can improve, and the caveat that bites.

| Source | What it is | Way in |
|---|---|---|
| [shadcn/ui](https://ui.shadcn.com) | 63 accessible React primitives over Radix, plus the registry spec the other four target | `npx shadcn@latest add <name>` |
| [beUI](https://beui.dev) | 85 animated components as a shadcn-compatible registry, with an MCP endpoint | `npx shadcn@latest add https://beui.dev/r/<name>.json` |
| [Rare UI](https://rareui.com) | About 20 single-file animated widgets — gooey nav, proximity sidebar, odometer counter | `npx shadcn@latest add swamimalode07/rare-ui/<name>` |
| [Transitions](https://transitions.dev) | About 44 named motion snippets as plain CSS, namespaced `.t-*` | `npx transitions-dev add <slug>` |
| [Beautiful UI](https://beautifului.dev) | 21 primitives for AI application interfaces | Copy-paste from the browser; no CLI, no registry |

**None of the five ships a marketing page section.** No hero, no testimonials, no team grid and no footer anywhere in the set — they are primitives, motion and app-shaped widgets. So a source improves a block loom already renders; it never replaces one, and `role` is the field that says which kind of improvement to expect. An agent that reads the table as a block catalogue goes looking for a hero in shadcn/ui and finds `/blocks/login`.

The licences are not uniform either. Four are MIT; Transitions is a custom licence that forbids redistributing a substantial part of the collection, so its snippets can be used on a site but must not be vendored into this repo.

Every url and endpoint in that table was fetched and checked rather than recalled, and all of them will rot eventually:

```bash
npm run sources # re-checks each endpoint and reports how many components it still lists
```

## Themes are data

<p align="center">
Expand Down Expand Up @@ -261,7 +301,7 @@ The audit needs a running server and `npx playwright install chromium`, so it st


```bash
npm test # 125 of them, ~4s, no network
npm test # 199 of them, ~1.5s, no network
```

They cover **the three rules taken back from the model** — selling-point count decides grid vs list, tier count decides single vs comparison, whether there is a UI screenshot decides the hero layout. If any of these drift, the decision quietly goes back to a model that cannot make it, so they are the ones that must not move.
Expand Down Expand Up @@ -295,7 +335,10 @@ lib/
edit.ts edit intent recognition (speculative fan-out)
export.ts self-contained HTML, only the CSS in use
export-tsx.ts React source export, DOM → JSX
export-registry.ts the same source as a shadcn registry item, tokens included
export-agents.ts AGENTS.md: spec, tokens, blocks, and where components come from
i18n.ts UI language, reads locales/*.json
sources.ts five component libraries an agent can pull from, with roles and caveats
*.test.ts pure-logic tests, no network
locales/
en|zh|ja|ko|es|fr|de|pt.json UI translations, zh is the reference
Expand All @@ -316,7 +359,7 @@ app/

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md). Adding a block, a theme or a UI language each has a short, established path.
See [CONTRIBUTING.md](CONTRIBUTING.md). Adding a block, a theme, a UI language or a component source each has a short, established path.

## Star History

Expand Down
60 changes: 60 additions & 0 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { THEMES } from "@/lib/themes";
import { elementsFor, type SiteContent } from "@/lib/content";
import { buildStandaloneHtml } from "@/lib/export";
import { buildReactSource } from "@/lib/export-tsx";
import { buildRegistryItem } from "@/lib/export-registry";
import { buildAgentsMd } from "@/lib/export-agents";
import {
detectLocale,
dict,
Expand Down Expand Up @@ -278,6 +280,50 @@ export default function Page() {
URL.revokeObjectURL(url);
}, [spec, theme]);

/**
* Export the page as a shadcn registry item.
*
* This is the only interchange format the libraries in lib/sources.ts agree on: four of the five publish one, and `npx shadcn add <url>` is how a component gets pulled into a project in the first place. Emitting the same shape sends the generated page back down that pipe, so an agent handles it with the machinery it already has rather than being handed a novel file it has to be taught about.
*/
const exportRegistry = useCallback(() => {
const node = previewRef.current?.firstElementChild;
if (!node) return;
const item = buildRegistryItem(node, prompt, theme);
const blob = new Blob([item], { type: "application/json" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "site.registry.json";
a.click();
URL.revokeObjectURL(url);
setEditLog((log) => [
...log,
`${t.exportRegistry} · ${(item.length / 1024).toFixed(0)} KB`,
]);
}, [prompt, theme, t]);

/**
* Export a brief for a coding agent rather than an artefact for a build.
*
* The other four exports assume whoever receives them already knows what loom rendered. An agent asked to improve the result does not: it needs the slots that are actually on the page and the honest account of what each source can and cannot do for them — none of the five ships a marketing section, so the instruction is always to improve a block that exists, never to go find a replacement for it. Left to guess, an agent looks for a hero in shadcn/ui, finds a login block, and invents something.
*/
const exportAgents = useCallback(() => {
const node = previewRef.current?.firstElementChild;
if (!node) return;
const brief = buildAgentsMd(node, prompt, theme, slots);
const blob = new Blob([brief], { type: "text/markdown;charset=utf-8" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "AGENTS.md";
a.click();
URL.revokeObjectURL(url);
setEditLog((log) => [
...log,
`${t.exportAgents} · ${(brief.length / 1024).toFixed(0)} KB · ${slots.join(" ")}`,
]);
}, [prompt, theme, slots, t]);

const totalTokens = steps.reduce((sum, step) => sum + (step.inputTokens ?? 0), 0);

// Appearance lives entirely in one prop, so re-theming costs nothing: no
Expand Down Expand Up @@ -445,6 +491,20 @@ export default function Page() {
>
{t.exportSpec}
</button>
<button
type="button"
onClick={exportRegistry}
className="rounded-full border border-neutral-300 px-2.5 py-1 text-[12px] text-neutral-600 hover:border-neutral-600 dark:border-neutral-700 dark:text-neutral-300"
>
{t.exportRegistry}
</button>
<button
type="button"
onClick={exportAgents}
className="rounded-full border border-neutral-300 px-2.5 py-1 text-[12px] text-neutral-600 hover:border-neutral-600 dark:border-neutral-700 dark:text-neutral-300"
>
{t.exportAgents}
</button>
</div>
)}

Expand Down
49 changes: 46 additions & 3 deletions docs/README.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,15 @@ Die Editor-Oberfläche ist eine andere Sache: acht Sprachen, gewählt anhand von

## Export

Drei Formate, alle aus **demselben gerenderten Ergebnis**. Es gibt keine zweite Kopie des Layout-Codes.
Fünf Formate, alle aus **demselben gerenderten Ergebnis**. Es gibt keine zweite Kopie des Layout-Codes.

| Export | Größe | Für |
|---|---|---|
| `site.html` | 36 KB | Online stellen oder einfach doppelklicken |
| `Site.tsx` | 34 KB | Weiterentwickeln; kompiliert unter `tsc --strict` |
| `spec.json` | ein paar KB | Archivieren oder einem anderen Renderer geben |
| `site.registry.json` | `Site.tsx`, verpackt | Die Seite in ein Projekt installieren, das schon shadcn/ui nutzt |
| `AGENTS.md` | eine Seite | Die Seite einem Coding-Agent übergeben: Tokens, Blöcke, Herkunft der Komponenten |

### Site.tsx

Expand All @@ -207,6 +209,44 @@ Gefiltert wird, indem jeder Selektor mit `root.matches()` / `root.querySelector(

An Größe spart das nur 16 % (Tailwind war nie das Problem). Der eigentliche Gewinn ist, dass die exportierte Seite nicht mehr das Styling des Editors mitschleppt. Siehe `lib/export.ts`; es gibt **keinen zweiten Renderer**, das Blocklayout existiert nur in `app/registry.tsx`.

### site.registry.json

Ein [shadcn-Registry](https://ui.shadcn.com/docs/registry)-Item, die Seite installiert sich also wie jede andere shadcn-Komponente:

```bash
npx shadcn@latest add ./site.registry.json
```

Ein Befehl schreibt die Komponente in das Verzeichnis, das die `components.json` des Projekts als Komponentenordner ausweist, und führt die 17 Tokens des Themes mit dessen Stylesheet zusammen. Die Abhängigkeitsliste ist mit Absicht leer: `Site.tsx` importiert einen Typ aus React und sonst nichts, und sie zu füllen hieße, die CLI Pakete installieren zu lassen, die die Datei nie benutzt. Die CLI nimmt einen lokalen Pfad an, es muss also vorher nichts gehostet werden — die Datei, die der Browser gerade heruntergeladen hat, funktioniert dort, wo sie gelandet ist.

Das Item trägt denselben `Site.tsx`-Quelltext; es ist kein zweites Rendern der Seite. Die Tokens reisen als `cssVars` mit, denn eine Komponente, die in einem Projekt mit eigenen Variablen landet, wird in dessen Farben gezeichnet — und das ist nicht die Seite, die jemand exportiert hat. Ihre Schlüssel stehen ohne führendes `--`, weil die CLI das selbst ergänzt: als `--accent` geschrieben, kommt der Token in der Tailwind-Brücke als `var(----accent)` an, löst sich zu nichts auf, und die Installation meldet trotzdem Erfolg.

### AGENTS.md

Eine kurze Einweisung für den Coding-Agent, der den Export aufnimmt: `spec.json` ist die maßgebliche Beschreibung der Seite, hier sind die 17 Theme-Tokens mit ihren Werten, hier sind die Blöcke, die diese Seite tatsächlich hat, und hier sind die Komponentenquellen, die zu diesen Blöcken passen. Geschrieben, um vor der Arbeit einmal gelesen zu werden, nicht als Dokumentation für einen Menschen.

## Komponenten, die das Stehlen wert sind

Der Weg ist der bequeme: einem Coding-Agent eine gute Bibliothek zeigen und ihn auswählen, anpassen und einfügen lassen. `lib/sources.ts` ist die Tabelle, die er dabei liest: fünf Bibliotheken, jede mit ihrer Rolle, ihrer Lizenz, ihrem Installationsbefehl, den maschinenlesbaren Endpunkten, die bei der Prüfung geantwortet haben, den Slots, die sie verbessern kann, und dem Haken, der beißt.

| Quelle | Was es ist | Weg hinein |
|---|---|---|
| [shadcn/ui](https://ui.shadcn.com) | 63 zugängliche React-Primitive auf Radix, dazu die Registry-Spezifikation, auf die die anderen vier zielen | `npx shadcn@latest add <name>` |
| [beUI](https://beui.dev) | 85 animierte Komponenten als shadcn-kompatible Registry, mit MCP-Endpunkt | `npx shadcn@latest add https://beui.dev/r/<name>.json` |
| [Rare UI](https://rareui.com) | Rund 20 animierte Einzeldatei-Widgets — zähflüssige Navigation, Näherungs-Sidebar, Kilometerzähler | `npx shadcn@latest add swamimalode07/rare-ui/<name>` |
| [Transitions](https://transitions.dev) | Rund 44 benannte Bewegungsschnipsel in reinem CSS, im Namensraum `.t-*` | `npx transitions-dev add <slug>` |
| [Beautiful UI](https://beautifului.dev) | 21 Primitive für Oberflächen von KI-Anwendungen | Nur Kopieren und Einfügen im Browser; keine CLI, keine Registry |

**Keine der fünf liefert einen Abschnitt einer Marketingseite.** Kein Kopfbereich, keine Kundenstimmen, kein Teamraster, keine Fußzeile in der ganzen Auswahl — es sind Primitive, Bewegung und Widgets in App-Form. Eine Quelle verbessert also einen Block, den loom ohnehin rendert; sie ersetzt ihn nie, und `role` ist das Feld, das sagt, welche Art von Verbesserung zu erwarten ist. Ein Agent, der die Tabelle als Blockkatalog liest, sucht in shadcn/ui nach einem Kopfbereich und findet `/blocks/login`.

Auch die Lizenzen sind nicht einheitlich. Vier sind MIT; Transitions hat eine eigene Lizenz, die das Weiterverbreiten eines wesentlichen Teils der Sammlung untersagt, seine Schnipsel dürfen also auf einer Seite verwendet, aber nicht in dieses Repository übernommen werden.

Jede url und jeder Endpunkt in dieser Tabelle wurde abgerufen und geprüft statt aus dem Gedächtnis notiert, und verrotten werden sie trotzdem:

```bash
npm run sources # ruft jeden Endpunkt erneut ab und meldet, wie viele Komponenten er noch listet
```

## Themes sind Daten

<p align="center">
Expand Down Expand Up @@ -258,7 +298,7 @@ Die Prüfung braucht einen laufenden Server und `npx playwright install chromium


```bash
npm test # 125 Stück, rund 4 s, ohne Netz
npm test # 199 Stück, rund 1,5 s, ohne Netz
```

Sie decken **die drei dem Modell abgenommenen Regeln** ab: Die Anzahl der Verkaufsargumente entscheidet Raster oder Liste, die Anzahl der Preisstufen entscheidet Einzelkarte oder Vergleich, und ob es einen Oberflächen-Screenshot gibt, entscheidet das Layout des Kopfbereichs. Driftet eine davon, geht die Entscheidung still an ein Modell zurück, das sie nicht treffen kann — sie dürfen sich also nicht bewegen.
Expand Down Expand Up @@ -292,8 +332,11 @@ lib/
edit.ts Erkennung der Änderungsabsicht (spekulatives Fan-out)
export.ts eigenständiges HTML, nur das genutzte CSS
export-tsx.ts React-Quellexport, DOM → JSX
export-registry.ts derselbe Quelltext als shadcn-Registry-Item, Tokens inklusive
export-agents.ts AGENTS.md: Spec, Tokens, Blöcke und Herkunft der Komponenten
i18n.ts Oberflächensprache, liest locales/*.json
demo.ts spielt fixtures/ ab, wenn keine Schlüssel gesetzt sind
sources.ts fünf Komponentenquellen, aus denen ein Agent schöpfen kann, mit Rollen und Haken
*.test.ts Tests reiner Logik, ohne Netz
locales/
en|zh|ja|ko|es|fr|de|pt.json Oberflächenübersetzungen, zh ist die Referenz
Expand All @@ -316,7 +359,7 @@ app/

## Mitmachen

Siehe [CONTRIBUTING.md](../CONTRIBUTING.md). Für einen neuen Block, ein Theme oder eine Oberflächensprache gibt es jeweils einen kurzen, festgelegten Weg.
Siehe [CONTRIBUTING.md](../CONTRIBUTING.md). Für einen neuen Block, ein Theme, eine Oberflächensprache oder eine Komponentenquelle gibt es jeweils einen kurzen, festgelegten Weg.

## Star History

Expand Down
Loading
Loading