@close-by/clay 0.2.7 → 0.2.8
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.
- package/README.md +1 -1
- package/docs/README.md +80 -0
- package/docs/ai.md +65 -0
- package/docs/api.md +2136 -0
- package/docs/architecture.md +103 -0
- package/docs/boot.md +103 -0
- package/docs/browser-apis.md +65 -0
- package/docs/clickhouse.md +59 -0
- package/docs/concepts.md +269 -0
- package/docs/duckdb.md +68 -0
- package/docs/elements.md +194 -0
- package/docs/examples.md +314 -0
- package/docs/getting-started.md +278 -0
- package/docs/jsx-investigation.md +167 -0
- package/docs/kibana.md +138 -0
- package/docs/llms.txt +44 -0
- package/docs/ops-patterns.md +176 -0
- package/docs/production.md +71 -0
- package/docs/protocol.md +238 -0
- package/docs/reactive-let.md +217 -0
- package/docs/tailwind.md +73 -0
- package/docs/tutorial.md +234 -0
- package/package.json +13 -6
- package/src/docs-dir.ts +44 -0
- package/src/index.ts +0 -3
package/README.md
CHANGED
|
@@ -18,4 +18,4 @@ export default function () {
|
|
|
18
18
|
bunx clay hello.ts
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
Docs:
|
|
21
|
+
Docs: shipped with the package at `node_modules/@close-by/clay/docs/`. See [getting-started.md](docs/getting-started.md) after install.
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Clay Documentation
|
|
2
|
+
|
|
3
|
+
Server-driven UI for TypeScript, inspired by [NiceGUI](https://nicegui.io/).
|
|
4
|
+
|
|
5
|
+
You write imperative `ui.*` code on the server. Clay owns a per-client element tree and syncs it to a thin React + ShadCN client over WebSocket.
|
|
6
|
+
|
|
7
|
+
For coding agents: the repo-root [llms.txt](../llms.txt) is a short map of these guides.
|
|
8
|
+
|
|
9
|
+
## Guides
|
|
10
|
+
|
|
11
|
+
| Doc | Description |
|
|
12
|
+
|-----|-------------|
|
|
13
|
+
| [Getting started](./getting-started.md) | Install, `clay` CLI, create a page |
|
|
14
|
+
| [Boot: CLI vs library](./boot.md) | Production `ui.run` path, `clientDir`, `_run.ts`, reload stubs |
|
|
15
|
+
| [Tailwind](./tailwind.md) | Zero-config utilities from page modules; optional tokens |
|
|
16
|
+
| [Sample app](./tutorial.md) | Step-by-step tasks list, then two pages + shell |
|
|
17
|
+
| [Concepts](./concepts.md) | Mental model: sessions, elements, patches; **canonical `state`/`auto`/`timer` recipe**; reactive `let` alternative |
|
|
18
|
+
| [Browser APIs](./browser-apis.md) | Prefer `ui.clipboard` / hash / `openExternal` — never `window` in page code |
|
|
19
|
+
| [Production & security](./production.md) | Auth, server exposure, rate limits, boot parity |
|
|
20
|
+
| [Ops patterns](./ops-patterns.md) | Dense consoles: chips, master–detail, feeds, sensitive logs, auth nav |
|
|
21
|
+
| [API reference](./api.md) | `ui.*`, `Element` methods, `reactive`, helpers |
|
|
22
|
+
| [Elements](./elements.md) | All element types and props |
|
|
23
|
+
| [WebSocket protocol](./protocol.md) | Client ↔ server message formats |
|
|
24
|
+
| [Architecture](./architecture.md) | Packages, data flow, and ownership |
|
|
25
|
+
| [Examples](./examples.md) | Demo apps and patterns |
|
|
26
|
+
| [Reactive `let`](./reactive-let.md) | NiceGUI-style `let` transform (opt-in `--reactive-let`) |
|
|
27
|
+
| [AI UI](./ai.md) | `ui.ai.*` visual AI primitives (no model runtime) |
|
|
28
|
+
| [DuckDB](./duckdb.md) | Multi-DB DuckDB wrapper (`@close-by/clay-duckdb`) |
|
|
29
|
+
| [Kibana](./kibana.md) | Kibana REST + ES search (`@close-by/clay-kibana`) |
|
|
30
|
+
| [ClickHouse](./clickhouse.md) | Multi-connection ClickHouse wrapper (`@close-by/clay-clickhouse`) |
|
|
31
|
+
|
|
32
|
+
## Quick start
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
bun install
|
|
36
|
+
bun run build:client # monorepo: build + copy client into @close-by/clay-cli
|
|
37
|
+
bun run clay hello.ts
|
|
38
|
+
# → http://localhost:3000
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Outside the monorepo: `bun run pack:publishable` then install the `dist-pack/*.tgz` set (see [Getting started](./getting-started.md)), or `bun add @close-by/clay-cli @close-by/clay` once published. Maintainers: `bun run publish:dry` / `publish:npm` (order core → … → cli). Shipped CLI includes prebuilt client assets — no separate `build:client` after install.
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
// hello.ts
|
|
45
|
+
import { ui } from '@close-by/clay';
|
|
46
|
+
|
|
47
|
+
ui.run(() => {
|
|
48
|
+
let count = 0;
|
|
49
|
+
const label = ui.label(`Count: ${count}`);
|
|
50
|
+
|
|
51
|
+
ui.row(() => {
|
|
52
|
+
ui.button('-', {
|
|
53
|
+
onClick: () => {
|
|
54
|
+
count--;
|
|
55
|
+
label.setText(`Count: ${count}`);
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
ui.button('+', {
|
|
59
|
+
onClick: () => {
|
|
60
|
+
count++;
|
|
61
|
+
label.setText(`Count: ${count}`);
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Multi-page with shell:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
bun run clay ./pages --app --title "My App"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Or library-style entry (`loadPages` + `ui.run({ app })`) — see [Getting started](./getting-started.md).
|
|
75
|
+
|
|
76
|
+
## Naming
|
|
77
|
+
|
|
78
|
+
Public Clay APIs and the wire protocol use **camelCase** (`onClick`, `bindValue`, `setText`, element `type: "button"`).
|
|
79
|
+
|
|
80
|
+
React/ShadCN components inside `@close-by/clay-client` stay PascalCase because React requires it — that layer is an implementation detail.
|
package/docs/ai.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# AI UI (`ui.ai.*`)
|
|
2
|
+
|
|
3
|
+
Visual, data-driven primitives for AI-native interfaces. Callers pass props (messages, tools, status, text) and handle events (`onSubmit`, `onApprove`, …). **No AI SDK / model runtime** lives inside clay.
|
|
4
|
+
|
|
5
|
+
Inspired by [Beautiful UI](https://www.beautifului.dev/) patterns; reimplemented with clay factories + ShadCN/Tailwind on the client.
|
|
6
|
+
|
|
7
|
+
## Quick start
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { ui } from '@close-by/clay';
|
|
11
|
+
|
|
12
|
+
ui.ai.chat({
|
|
13
|
+
tabs: [{ id: 'flavors', label: 'Flavors' }],
|
|
14
|
+
activeTab: 'flavors',
|
|
15
|
+
messages: [
|
|
16
|
+
{ id: '1', role: 'user', text: 'Compare mint chip…' },
|
|
17
|
+
{
|
|
18
|
+
id: '2',
|
|
19
|
+
role: 'assistant',
|
|
20
|
+
text: 'Mint chip is up 12%.',
|
|
21
|
+
thinking: [{ kind: 'reasoning', title: 'Comparison', durationMs: 2000 }],
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
onSubmit: (text) => {
|
|
25
|
+
// App owns state; patch via chat.setMessages(...) or refreshable
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
ui.ai.promptBar({
|
|
30
|
+
placeholder: 'Ask…',
|
|
31
|
+
sources: [{ id: 'v1', label: 'Vanilla 1' }],
|
|
32
|
+
models: [{ id: 'gpt', label: 'GPT' }],
|
|
33
|
+
onSubmit: (value) => {},
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Demo gallery: `/examples/ai` (`AiDemo.ts`).
|
|
38
|
+
|
|
39
|
+
**State note:** `ui.ai.chat` is intentionally imperative (`var messages` + `chat.setMessages`). Surrounding controls can use `ui.state`; do not wrap the whole chat in `ui.auto` (remounts the composer). See [Ops patterns — ai.chat](./ops-patterns.md#uiaichat-and-state).
|
|
40
|
+
|
|
41
|
+
## Wire types
|
|
42
|
+
|
|
43
|
+
| `ui.ai.*` | Wire `type` | Notes |
|
|
44
|
+
|-----------|-------------|--------|
|
|
45
|
+
| `loader` | `aiLoader` | Variants: `drive` / `dots` / `orbit` / `pixel`; optional `startedAt` elapsed |
|
|
46
|
+
| `thinking` | `aiThinking` | Expandable step traces (`steps` / `reasoning` / `search` / `coding`) |
|
|
47
|
+
| `message` | `aiMessage` | Role, markdown/text, sources, actions, follow-ups, `streaming?` |
|
|
48
|
+
| `chat` | `aiChat` | Tabs + messages + composer; `AiChatElement` owns `setMessages` / `setActiveTab` |
|
|
49
|
+
| `promptBar` | `aiPromptBar` | Textarea, @sources, /commands, model picker, dictate stub |
|
|
50
|
+
| `codeBlock` | `aiCodeBlock` | Filename + optional streaming cue (Shiki) |
|
|
51
|
+
| `approval` | `aiApproval` | HITL option cards |
|
|
52
|
+
| `toolChips` | `aiToolChips` | Compact tool / edit chips |
|
|
53
|
+
| `tasks` | `aiTasks` | Nested running / failed / completed rows |
|
|
54
|
+
| `recommendation` | `aiRecommendation` | Confidence + alternatives |
|
|
55
|
+
| `context` | `aiContext` | Retrieved chunks + sources |
|
|
56
|
+
| `diffTable` | `aiDiffTable` | Compact proposed-edit table (not DataTable) |
|
|
57
|
+
| `insights` | `aiInsights` | Paged insight cards |
|
|
58
|
+
| `selectionActions` | `aiSelectionActions` | Selection text + action strip |
|
|
59
|
+
| `fineTune` | `aiFineTune` | Inspector-style field editors → `onChange` |
|
|
60
|
+
|
|
61
|
+
**Skipped overlaps:** use `ui.dataTable` for records/filter tables, `ui.app` for sidebar nav, `ui.command` for search.
|
|
62
|
+
|
|
63
|
+
## Events (common)
|
|
64
|
+
|
|
65
|
+
`submit`, `followUp`, `action`, `tabChange`, `sourceRemove`, `modelChange`, `command`, `dictate`, `approve`, `reject`, `chipClick`, `taskClick`, `accept`, `alternative`, `chunkClick`, `rowClick`, `indexChange`, `prompt`, `change`, `toggle`.
|