# @iterate-com/ui
iterate's UI kit. This repository, `/repos/ui` of the iterate.com mind, is its source of truth
(since 27 Nov 2026; before, it was `packages/ui` of iterate/private). Anyone can clone it, every
branch and every pull: write nothing private here. The same files serve four uses:
- **Releases for no-build pages.** A builder releases each commit of `main` to the branch `dist`,
and `ui.iterate.com` serves it. Commit nothing to `dist` yourself.
- **A shadcn registry** for apps in other repos, at `ui.iterate.com/r`.
- **The source that iterate/private's apps bundle**, as a git dependency at one commit: the pin in
that repo's `pnpm-workspace.yaml`. An app change that needs a kit change is the kit's pull
first, then the pin.
- **An npm package** built for no-build pages, which iterate/private publishes from that pin.
[README.md](README.md) tells outside users which one to use.
## Work here
`pnpm install`, then `pnpm check` before a pull: typecheck, oxlint, oxfmt, the registry's
`update` with no diff, and the tests. `pnpm check:shadcn` asks shadcn's registry over the network:
run it after a change to a vendored file, an item's files or the `shadcn` pin. Nothing runs these
for you on a pull.
The repository builds alone. Versions that two or more of its packages share are in the catalog
of `pnpm-workspace.yaml`, and `pnpm-lock.yaml` is frozen for a release. `package.json` names what
the source imports as `dependencies`, with written versions, because an app that takes this
repository as a git dependency reads them; `iterate` (the kernel's SDK), `react` and `react-dom`
are peers, which the app gives. For the kit's own build and tests, `iterate` is the npm package
at the version in `devDependencies`: move it when the kit needs a newer kernel.
## Layout and imports
The package has the layout of an app after `shadcn add`, so the registry serves its files as they
are:
- `src/components/ui/`: shadcn's components, vendored byte for byte. Do not edit them
([src/components/ui/AGENTS.md](src/components/ui/AGENTS.md)).
- `src/components/` and `src/lib/`: our components and their plain helpers. Each file or folder is
one registry item.
- `src/apps/` (the shell that every app's `server.ts`, `router.tsx`, `document.tsx` and `head.ts`
call), `src/hooks/` and `src/agent-kind-view/`: not in the registry. iterate/private's apps import
them from the source, at the commit that they pin.
- Imports use the `#/*` subpath import, with extensions: `#/components/ui/button.tsx`. `shadcn add`
rewrites these to the installing app's aliases. The CLI identifies a shadcn component only by the
`ui/` in its path. Files of one item import each other relatively (`./filters.tsx`), because they
travel together.
## The registry
`registry.json` names each item, gives a one-line description and lists its files.
`node scripts/shadcn-registry.ts update` (`pnpm registry`) calculates the rest (dependencies, registry
dependencies, the `theme` item, `publishConfig.exports`) and writes `registry.json` and
`package.json`. Run it after you add or move a file, or change an import, and commit both files.
`pnpm check` fails when they are stale. The script's header explains the registry.
- `update` throws when an installing app would get an import it cannot resolve: a file in
`src/components/` or `src/lib/` that no item lists, a relative import of another item's file, a
`#/` import of a file outside the registry (`src/apps/`, `src/hooks/`), or an `@iterate-com/*`
import.
- Hooks and providers are not items. They belong in `iterate/react`. `use-context-explorer` stays
here until it moves. A hook that a registry item needs lives in its `src/lib/` file
(`lib/saved-context`, `lib/waiting-approvals`).
- The shadcn CLI drops a file's leading comment when it installs it (shadcn-ui/ui#9206). The copy
here keeps it.
## The npm package
`pnpm build` (tsdown, `tsdown.config.ts`) makes the files that a no-build page imports: a release
at `ui.iterate.com`, and the npm package, which iterate/private publishes under the `main`
dist-tag from the commit that it pins.
- The build bundles every dependency, React included, and the npm package names no dependency
(the publish takes them out of its manifest). For this reason, do not `npm install` the package
into an app: the app gets a second React, and our hooks fail with "Invalid hook call".
- `browser-entries.ts` names the entries: one for each item and each vendored component, plus
`page`, `live`, React's own modules (`src/browser/`) and `styles.css`. esm.sh needs each entry
named, not a wildcard, to keep shared chunks shared.
- The default config's apps (`core/configs/default/apps/*/index.html`) import one pinned build
through their import maps, so a change here reaches them only when that pin moves.
- How a page uses the package and signs in: [examples/README.md](examples/README.md).
## Quality bar
- Colours are tokens and text sizes are steps (`scripts/design-tokens.test.ts`). The tokens and the
look are in [src/styles/AGENTS.md](src/styles/AGENTS.md).
- The repo IDE, the virtual log, the context view and the agent chat score 100 on React Doctor.
Keep them there. The commands are in the folders' `AGENTS.md` files.
- The Dash and the context catalog score 100 on React Doctor too. Keep them there:
```sh
npx react-doctor@latest --yes src/components/dash/*.tsx src/components/dash/*.ts src/components/context-catalog/*.tsx src/components/context-catalog/*.ts
```
- The browser specs of this package (`test/playwright/ui/*.spec.ts`) left the repo with `core/os`.
`git show cbf560aa7:test/playwright/ui/<name>.spec.ts` shows what they held.
## Topic notes
- [src/components/virtual-log/AGENTS.md](src/components/virtual-log/AGENTS.md): the root of every
view of a log.
- [src/components/agent-chat/AGENTS.md](src/components/agent-chat/AGENTS.md): one agent's
conversation.
- [src/components/repo-ide/AGENTS.md](src/components/repo-ide/AGENTS.md): the IDE over one repo.
- `components/dash` is a mind's Dash, drawn from lists, for a no-build page: the shell takes
the pages and the groups of links, and each kit page (`DashRepo`, `DashSecrets`, …) takes the
member's `itx` and does its own reads. A page imports its larger part with `import()` of that
item's own entry file, never of a file that is no entry: on esm.sh only an entry stays one
module. Its URL is `lib/page-url`; the member's socket is `live`'s `memberItx`, whose `itx` is a
proxy that dials a new session when the socket closes. A stub or a subscription ends with its
session. The Dash keeps a page mounted over a new session only when its component says
`staysOverReconnect`; any other page is mounted anew, so a page on the SDK's hooks alone is
never stale. A page that stays opens again what it holds: the plain parts are `lib/itx-session`
(the session's epoch for a hook's deps, `kept`, `keptContext`), and the hooks over them
(`useHeldContext`, `useKeptContext`) are `src/hooks/use-itx-session.ts`, outside the registry
and exported by `live`. Only `ReconnectingMark`, once in the shell, says that the connection
is gone. THE FIRST PAINT IS THE PAGE'S HTML: the default config's Dash draws the shell's frame
from its `index.html` and `app.css` alone (the sidebar open or as a rail, an agent page's
header row, `DashPlaceholder`'s shapes), dials `/itx` in its head (`EARLY_ITX_SOCKET`, which
`memberItx` takes) and renders with no await: `Dash` asks `whoami()` itself, and a page gets
`principal` undefined until the answer. The frame's numbers are the shell's own (sidebar 16rem
or 3rem, header rows of 45, 53 and 42 px, the column of 48rem): when one changes here, change
`core/configs/default/apps/dash/public/app.css` with it. `data-frame` on `<html>` tells
`LogReading` that the wait began with the page. Two page ids mean
more: `agents` puts the agents in the sidebar and takes `/agents/<path>` (`/agents?contextPath=/`
for root), and `contexts` is the raw view. The Home and Agents pages (`DashHome`, `DashAgents`)
are in `agent-kind-view/dash-agents.tsx`, outside the registry, because they host a kind's frame.
THE DASH'S ADDRESSES ARE PATHS: `/`, `/secrets`, `/agents/agents/onboarding`,
`/contexts/repos/config` (`/contexts?contextPath=/` for root), `/repos/config/worker.ts`, and
`/<id>/<rest>` (the pure codec is `components/dash/dash-paths.ts`, registered by
`components/dash/dash-href.ts`). Every part reads `usePageParam` and builds `pageHref`,
`agentViewHref` or `rawViewHref`: never read `location` or write a `?page=` link by hand.
- `components/context-catalog` reads the mind's catalog of its contexts. The mind pushes it:
`catalog-collection.ts` is the catalog as TanStack DB collections over `itx.contexts.watch`, on
the page's one socket (an on-demand collection whose live queries become catalog queries, and
one collection for one named query, such as the awake list), and `context-catalog-live.ts` is
the hook that the Dash reads its rows with (`useWatchedContextCatalog`) and the one set of
collections for an `itx` (`catalogOf`). A page writes its own live query of
`catalogOf(itx).contexts` with TanStack DB from the `db` entry (`@iterate-com/ui/db`), never
from an import-map line of its own: the collections and the query must be of one copy. A mind
whose platform has no `contexts.watch` is asked for `contexts.list` every ten seconds, as before.
- `components/page-tools` lends the agent that a page shows tools that run in that page (a
banner, Playwright's locators). `lib/page-tools.ts` says how a call travels, who may call and
what each refusal is worth: read its header before you add a tool or loosen a rule. The Dash
turns it on with the Agents row's `pageTools`.
- The Agents app's parts (`components/agents-nav`, `components/agents-home`, `lib/agent-summary`)
serve the hosted app; the Dash takes `StatusDot` and `lib/agent-summary`. None imports a router. They take
`agentHref(path)` and `onOpen(path)`, so that a page with a client router can make a plain click
a route change.