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
12 changes: 5 additions & 7 deletions .github/workflows/tokens.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
- main

jobs:
staleness:
name: Generated artifacts are current
valid:
name: tokens.json is valid and the app builds
runs-on: ubuntu-latest

steps:
Expand All @@ -29,8 +29,6 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Regenerate token artifacts
run: node build

- name: Check generated artifacts are committed
run: git diff --exit-code -- src/tokens.css
# The build validates tokens.json (both modes, aliases) and typechecks the app.
- name: Build the app
run: pnpm --dir north-star build
39 changes: 12 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Kilo's canonical design source for product UI. Agent guidance will be written fr

This repo keeps Kilo's UI decisions in one place so Desktop, Cloud, Mobile, VS Code and the other Kilo surfaces do not each invent their own design system.

It is intentionally small: one token source, one generated stylesheet, and one app that shows the language.
It is intentionally small: one token file and one app that shows the language.

> 🚧 This project is still in progress. The language is being defined from Kilo Desktop first; no product consumes these tokens yet.

Expand All @@ -14,7 +14,6 @@ It is intentionally small: one token source, one generated stylesheet, and one a
| --- | --- | --- |
| Colour tokens | Done | `tokens.json` is the only place values are written. Dark and light. Role names may still change. |
| Type, radius, spacing tokens | Drafted | Defined in `tokens.json`, but the screens in `north-star/` still hard-code these values. |
| Generated stylesheet | Done | `node build` writes `src/tokens.css`. |
| Language app | Done | `north-star/` shows foundations, components and product screens from the tokens. |
| VS Code surface | Next | Not in the app yet. The host editor owns its colours, so it needs its own study. |
| Desktop adoption | Next | Desktop is the first product to take its theme from this repo. |
Expand Down Expand Up @@ -51,33 +50,20 @@ It is intentionally small: one token source, one generated stylesheet, and one a
| Surface | What it is | Authority |
| --- | --- | --- |
| `tokens.json` | Hand-authored design token source, dark and light | Canonical values |
| `src/tokens.css` | Generated CSS variables | Committed output from `node build` |
| `north-star/` | Local Vite + React app: Foundations, Components, and target screens for Desktop, Cloud and Mobile | Reference for people and agents; reads only the tokens |
| `skill-arena/` | Repeatable prompt-pass workflow | Skill evaluation harness; its Kilo condition is off until a new skill exists |

Product code does not live here. Product repos consume this repo's artifacts from their own codebases.

## 🔁 How The Pieces Connect

```text
tokens.json
-> node build
-> src/tokens.css
-> north-star/ (every screen and the component page)
-> north-star/ Foundations page (reads the JSON directly)
```

`north-star/` holds no token values of its own. To change a colour, edit `tokens.json` and run `node build`.

## 📦 Tokens

Colour roles live under `color.dark` and `color.light`, and every role must exist in both. A value written as `{other-role}` is an alias. Each role becomes a CSS variable of the same name, for example `color.dark.act-bg` becomes `--act-bg`.
`tokens.json` is the only file that holds values, and there is no build step. People and agents read it directly.

```bash
node build
```
Colour roles live under `color.dark` and `color.light`, and every role must exist in both. A value written as `{other-role}` is an alias.

The app in `north-star/` turns the file into CSS variables when it starts: each role becomes a variable of the same name, so `color.dark.act-bg` becomes `--act-bg`. Dark is the default, and `data-mode="light"` or `data-mode="dark"` on any element switches. Save `tokens.json` while the app is running and it reloads.

This regenerates `src/tokens.css`. Dark is the default; set `data-mode="light"` or `data-mode="dark"` on any element to switch. The generated file is committed and never edited by hand. CI fails if it drifts from `tokens.json`.
The app refuses to start or build if a role is missing in one mode or an alias points nowhere. CI runs that build on every pull request.

## 🧭 Language App

Expand Down Expand Up @@ -117,21 +103,20 @@ It shows stacked rounds of no-skill and frontend-design outputs, with a fixed pr
Use this order when sources disagree:

1. `tokens.json`
2. `src/tokens.css`
3. the Components page in `north-star/`
4. nearby shipped product UI
2. the Components page in `north-star/`
3. nearby shipped product UI

## Decisions

These decisions still hold. Earlier decision records are in git history.

- **Tokens and the Components page are the target.** Token values and the target column of the Components page define where products are going, and shipped code that disagrees is drift to migrate. Each target records which shipped product it was taken from, so it is never an invented ideal.
- **Standalone repo, pulled by pinned hash.** The system lives in its own repo so that no product monorepo owns it, and consumers pull a pinned commit. No npm package, because registry and publish auth across three toolchains is too much upkeep, and no git submodule, because one was tried in `kilo-cloud` (PR #3507) and reverted days later (#3535).
- **One hand-authored source, generated artifacts.** Values are edited in one source, `tokens.json`, and every product format is generated from it by `node build`. Today that is one CSS file; Mobile and VS Code will need their own generated formats. Generated files are never edited by hand.
- **One hand-authored source, nothing generated yet.** Values are edited in one file, `tokens.json`, and nothing derived from it is committed. When a product needs its own format, such as a CSS file for Desktop, it is generated from `tokens.json` and never edited by hand. That format is decided with the product's developer at adoption.
- **Products are grouped by who owns the colours.** A product family is set by its theming contract, not by the code library it imports: surfaces that adapt to one host's theme are hosts within a family, and sharing a component library does not merge two families.
- **No `DESIGN.md` in product repos.** Design rules live only in this repo's agent guidance, and a product repo gets one path-scoped line in its existing `AGENTS.md` that points to it when UI files are edited. The trigger is never the word "design", because the old keyword-triggered `DESIGN.md` loaded design rules into unrelated backend tasks.
- **Governance starts manual, then graduates.** The design owner reviews design-touching PRs by hand until that becomes a bottleneck, then automated visual and drift checks become the first reviewer, and per-team champions follow once teams have stable ownership. Staying manual forever is a failure mode, not the plan.
- **Manual version bumps, CI staleness check.** Consumers pick up changes through small manual bump PRs until that becomes a chore, then a Renovate-style bot opens them. CI fails if the generated artifacts are stale against `tokens.json`.
- **Manual version bumps.** Consumers pick up changes through small manual bump PRs until that becomes a chore, then a Renovate-style bot opens them. CI fails if `tokens.json` is invalid.
- **Primary actions are neutral.** The primary button uses the foreground colour (`act-bg`). The yellow `#FFDD00` appears only in the logo. Yellow on white is about 1.35:1, so it cannot carry text or small marks in light mode.
- **Dark and light.** Every colour role has a value in both modes, and the build fails if one is missing. Desktop already ships both.
- **Desktop first.** The language is defined from Kilo Desktop, and Desktop adopts it before the other products.
Expand All @@ -149,7 +134,7 @@ These decisions still hold. Earlier decision records are in git history.

When editing this repo:

1. If token values change, edit `tokens.json`, then run `node build` and commit `src/tokens.css`.
1. If token values change, edit `tokens.json`. Nothing else needs to be run or committed.
2. Never write a colour, radius or shadow value into `north-star/`. Add a role to `tokens.json` instead.
3. If the artifact name or location changes, update `build/`, CI, this README, `north-star/src/main.tsx` and `skill-arena/server.mjs`.
3. If the shape of `tokens.json` changes, update `north-star/tokens-css.ts`, the Foundations page and `skill-arena/server.mjs`.
4. If the change is planning or status only, update Linear instead of adding a repo plan.
116 changes: 0 additions & 116 deletions build/index.js

This file was deleted.

9 changes: 0 additions & 9 deletions build/package.json

This file was deleted.

4 changes: 2 additions & 2 deletions north-star/AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# North star app: agent rules

The Kilo design language in one app: Foundations, Components, and target screens for every Kilo surface. This is a design reference, not product code. Every value comes from the repo root `tokens.json` through the generated `src/tokens.css`. How to run it and add screens: `README.md`.
The Kilo design language in one app: Foundations, Components, and target screens for every Kilo surface. This is a design reference, not product code. Every value comes from the repo root `tokens.json`, which the app turns into CSS variables when it starts. How to run it and add screens: `README.md`.

## Rules

- **Colour by role, never by hex.** This app defines no token values. If a role is missing, add it to the root `tokens.json` in both modes and run `node build`. Use the roles: `--act-bg/fg/bd/hover` (primary action), `--ink`, `--soft-bg/fg`, `--bubble-bg/fg`, `--send-bg/fg`, `--live`, `--check-bg/fg`, `--ring`, plus the neutrals and status colours. `#FFDD00` (`--brand-logo`) appears only in the logo tile.
- **Colour by role, never by hex.** This app defines no token values. If a role is missing, add it to the root `tokens.json` in both modes. Use the roles: `--act-bg/fg/bd/hover` (primary action), `--ink`, `--soft-bg/fg`, `--bubble-bg/fg`, `--send-bg/fg`, `--live`, `--check-bg/fg`, `--ring`, plus the neutrals and status colours. `#FFDD00` (`--brand-logo`) appears only in the logo tile.
- **One screen per file.** Add screens under `src/surfaces/<surface>/screens/`. A `.tsx` screen exports `meta: ScreenMeta` and a default component. A `.html` drop-in must be self-contained and must not load assets from other repos. Do not edit `src/registry.ts` to register anything; discovery is automatic.
- **Reuse the frames.** Build on `DesktopWindow`, `ComposerRow`, `SessionCanvas`, `CloudWindow`, `Phone` and `TabBar`. Do not copy a window or phone frame.
- **Prefix every class.** All surface CSS loads globally. Use the surface prefix (`d-` desktop, `c-` cloud, `m-` mobile, or a new one for a new surface), and put the styles in that surface's own `.css`.
Expand Down
6 changes: 3 additions & 3 deletions north-star/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The Kilo design language in one app: **Foundations** (the tokens), **Components** (one target per component), and target screens for every Kilo product. Primary actions use the foreground color; `#FFDD00` appears only in the logo.

Every value comes from the repo's `tokens.json` through the generated `src/tokens.css`. This app defines no token values.
Every value comes from the repo's `tokens.json`, which the app turns into CSS variables when it starts (`tokens-css.ts`, wired in `vite.config.ts`). This app defines no token values.

```sh
pnpm --dir north-star dev # http://localhost:8732
Expand Down Expand Up @@ -40,7 +40,7 @@ export default function SettingsPanel() {
}
```

Use the roles from `tokens.json` (`--act-bg`, `--ink`, `--soft-bg`, `--bubble-bg`, `--send-bg`, `--live`, …), never a raw value. If a role is missing, add it to `tokens.json` and run `node build`.
Use the roles from `tokens.json` (`--act-bg`, `--ink`, `--soft-bg`, `--bubble-bg`, `--send-bg`, `--live`, …), never a raw value. If a role is missing, add it to `tokens.json` in both modes.

**HTML drop-in** (a self-contained mock exported from another repo or tool). It renders in an iframe at the surface frame size. Optional head tags:

Expand All @@ -52,7 +52,7 @@ Use the roles from `tokens.json` (`--act-bg`, `--ink`, `--soft-bg`, `--bubble-bg
<meta name="north-star:source" content="kilo-cloud apps/web usage">
```

The app injects `src/tokens.css` into the iframe and sets `<html data-mode="dark|light">`, so a drop-in uses the same `var(--role)` names as the React screens and needs no colors of its own.
The app injects the token variables into the iframe and sets `<html data-mode="dark|light">`, so a drop-in uses the same `var(--role)` names as the React screens and needs no colors of its own.

## Add a surface

Expand Down
5 changes: 4 additions & 1 deletion north-star/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { createRoot } from "react-dom/client";
import "../../src/tokens.css";
import tokensCss from "virtual:kilo-tokens";
import "./shell/theme.css";
import "./shell/shell.css";
import { App } from "./App";

// Tokens first, so the app's own styles can override nothing by accident.
document.head.insertAdjacentHTML("afterbegin", `<style>${tokensCss}</style>`);

createRoot(document.getElementById("app")!).render(<App />);
4 changes: 2 additions & 2 deletions north-star/src/shell/ScreenView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useRef } from "react";
import type { Screen } from "../registry";
import tokensCss from "../../../src/tokens.css?inline";
import tokensCss from "virtual:kilo-tokens";

export type Mode = "dark" | "light";

Expand Down Expand Up @@ -30,7 +30,7 @@ function HtmlScreen({ screen, mode }: { screen: Extract<Screen, { kind: "html" }
ref={ref}
className="dropin"
title={screen.title}
// Drop-ins get the same generated tokens as the React screens.
// Drop-ins get the same tokens as the React screens.
srcDoc={screen.html.replace(/<head[^>]*>/i, (head) => `${head}<style>${tokensCss}</style>`)}
onLoad={onLoad}
style={{ inset: 0, width: "100%", height: "100%" }}
Expand Down
4 changes: 2 additions & 2 deletions north-star/src/shell/theme.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ==========================================================================
North-star shell. Every design value comes from ../../../src/tokens.css,
generated from the repo's tokens.json. Do not define token values here.
North-star shell. Every design value comes from the repo's tokens.json
(see ../../vite.config.ts). Do not define token values here.
========================================================================== */
*{box-sizing:border-box;margin:0;padding:0}
html{-webkit-font-smoothing:antialiased}
Expand Down
2 changes: 1 addition & 1 deletion north-star/src/surfaces/components/screens/Parity.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;600&display=swap" rel="stylesheet">
<script src="https://unpkg.com/lucide@0.469.0/dist/umd/lucide.min.js"></script>
<style>
/* Colors, radii and shadows come from the repo's tokens.css, which the north-star app injects into this document. */
/* Colors, radii and shadows come from the repo's tokens.json, which the north-star app injects into this document. */
:root{
--font:"Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
--mono:"JetBrains Mono",ui-monospace,Menlo,monospace;
Expand Down
5 changes: 5 additions & 0 deletions north-star/src/tokens.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** The repo's tokens.json as CSS variables. Built by the kilo-tokens plugin in vite.config.ts. */
declare module "virtual:kilo-tokens" {
const css: string;
export default css;
}
Loading
Loading