create-theokit 1.0.11 → 1.0.12
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/package.json
CHANGED
|
@@ -12,6 +12,7 @@ This project includes TheoKit-aware skills that activate automatically when you
|
|
|
12
12
|
| theokit-agents | `**/*agent*`, `**/*tool*`, `**/*Agent*`, `**/*Tool*` | @Agent, @Tool, @Toolbox decorators, LLM integration |
|
|
13
13
|
| theokit-database | `**/*schema*`, `**/*db*`, `**/drizzle*`, `**/*migration*`, `**/*seed*` | Drizzle ORM, SQLite, schema patterns, migrations |
|
|
14
14
|
| theokit-frontend | `app/**` | File-based routing, layouts, theoFetch, useAgentStream |
|
|
15
|
+
| theokit-ui | `app/**`, `**/*Chat*`, `**/*Sidebar*`, `**/*Theme*` | @theokit/ui components: ChatThread, ChatMessage, CodeBlock, Sidebar, theming |
|
|
15
16
|
| theokit-config | `theo.config*`, `**/*config*` | defineConfig options, plugins, security, storage |
|
|
16
17
|
|
|
17
18
|
### Settings
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: theokit-ui
|
|
3
|
+
description: "@theokit/ui component library — chat UI (ChatThread, ChatMessage, ChatComposer, CodeBlock), theming, providers, sidebar"
|
|
4
|
+
user-invocable: false
|
|
5
|
+
paths:
|
|
6
|
+
- "app/**"
|
|
7
|
+
- "**/*Chat*"
|
|
8
|
+
- "**/*chat*"
|
|
9
|
+
- "**/*Sidebar*"
|
|
10
|
+
- "**/*sidebar*"
|
|
11
|
+
- "**/*theme*"
|
|
12
|
+
- "**/*Theme*"
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# @theokit/ui — AI Chat Component Library
|
|
16
|
+
|
|
17
|
+
`@theokit/ui` is an optional peer dependency. If installed, it provides ready-made components for chat UIs, theming, and layout. **Never build custom equivalents** of components `@theokit/ui` provides.
|
|
18
|
+
|
|
19
|
+
## Package Identity
|
|
20
|
+
|
|
21
|
+
The published package is `@theokit/ui` (NOT `@usetheo/ui` — that was the old name).
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Install from npm
|
|
25
|
+
npm install @theokit/ui
|
|
26
|
+
|
|
27
|
+
# Or link from source (development)
|
|
28
|
+
npm link ../theo-ui # if you have the source repo
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Provider Setup (required before using any component)
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
// app/layout.tsx
|
|
35
|
+
import '@theokit/ui/styles.css'
|
|
36
|
+
import { TheoUIProvider, ThemeProvider } from '@theokit/ui'
|
|
37
|
+
|
|
38
|
+
export default function Layout({ children }) {
|
|
39
|
+
return (
|
|
40
|
+
<TheoUIProvider>
|
|
41
|
+
<ThemeProvider>
|
|
42
|
+
{children}
|
|
43
|
+
</ThemeProvider>
|
|
44
|
+
</TheoUIProvider>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Chat Components
|
|
50
|
+
|
|
51
|
+
### Full Chat Page (typical assembly)
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import {
|
|
55
|
+
PageShell,
|
|
56
|
+
Sidebar,
|
|
57
|
+
SessionListItem,
|
|
58
|
+
ChatThread,
|
|
59
|
+
ChatMessage,
|
|
60
|
+
ChatMessageContent,
|
|
61
|
+
ChatComposer,
|
|
62
|
+
} from '@theokit/ui'
|
|
63
|
+
import { useAgentStream } from 'theokit/client'
|
|
64
|
+
|
|
65
|
+
function ChatPage() {
|
|
66
|
+
const { status, events, send } = useAgentStream('/api/agents/assistant')
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<PageShell sidebar={
|
|
70
|
+
<Sidebar>
|
|
71
|
+
{sessions.map(s => (
|
|
72
|
+
<SessionListItem key={s.id} title={s.title} onClick={() => select(s)} />
|
|
73
|
+
))}
|
|
74
|
+
</Sidebar>
|
|
75
|
+
}>
|
|
76
|
+
<ChatThread>
|
|
77
|
+
{messages.map(m => (
|
|
78
|
+
<ChatMessage key={m.id} role={m.role}>
|
|
79
|
+
<ChatMessageContent markdown={m.content} />
|
|
80
|
+
</ChatMessage>
|
|
81
|
+
))}
|
|
82
|
+
</ChatThread>
|
|
83
|
+
|
|
84
|
+
<ChatComposer
|
|
85
|
+
disabled={status === 'streaming'}
|
|
86
|
+
onSubmit={text => send({ message: text })}
|
|
87
|
+
/>
|
|
88
|
+
</PageShell>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Individual Components
|
|
94
|
+
|
|
95
|
+
| Component | Purpose | Key Props |
|
|
96
|
+
|-----------|---------|-----------|
|
|
97
|
+
| `ChatThread` | Scrollable message container | `children` (ChatMessage elements) |
|
|
98
|
+
| `ChatMessage` | Single message bubble | `role: 'user' \| 'assistant'`, `children` |
|
|
99
|
+
| `ChatMessageContent` | Markdown + code rendering | `markdown: string` (handles streaming partial) |
|
|
100
|
+
| `CodeBlock` | Syntax-highlighted code | `code: string`, `language?: string` (uses shiki, lazy-loaded) |
|
|
101
|
+
| `ChatComposer` | Message input + submit | `onSubmit: (text) => void`, `disabled?: boolean` |
|
|
102
|
+
| `PageShell` | App layout with sidebar slot | `sidebar?: ReactNode`, `children` |
|
|
103
|
+
| `Sidebar` | Collapsible side panel | `children` |
|
|
104
|
+
| `SessionListItem` | Session entry in sidebar | `title: string`, `onClick`, `active?: boolean` |
|
|
105
|
+
|
|
106
|
+
### Other Useful Components
|
|
107
|
+
|
|
108
|
+
| Component | Purpose |
|
|
109
|
+
|-----------|---------|
|
|
110
|
+
| `Button`, `Input`, `Textarea` | Form primitives (themed) |
|
|
111
|
+
| `ToolCallCard` | Display agent tool invocations |
|
|
112
|
+
| `AgentStream` | Lower-level stream renderer |
|
|
113
|
+
| `ThemeSwitcher` | Light/dark mode toggle |
|
|
114
|
+
| `Avatar` | User/agent avatar |
|
|
115
|
+
| `Alert` | Status messages |
|
|
116
|
+
|
|
117
|
+
## Peer Dependencies (install only what you use)
|
|
118
|
+
|
|
119
|
+
**Chat/markdown path** (most apps need these):
|
|
120
|
+
```bash
|
|
121
|
+
npm install mdast-util-from-markdown mdast-util-to-hast mdast-util-gfm \
|
|
122
|
+
hast-util-to-jsx-runtime hast-util-sanitize hast-util-from-html \
|
|
123
|
+
micromark-extension-gfm unist-util-visit unist-util-visit-parents shiki
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**DO NOT install** unless you use the specific components:
|
|
127
|
+
- `mermaid` — only for diagram rendering components
|
|
128
|
+
- `katex` — only for math/LaTeX rendering
|
|
129
|
+
- `roughjs` / `perfect-freehand` — only for whiteboard/drawing components
|
|
130
|
+
|
|
131
|
+
## Theming
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
import { defineTheme, ThemeProvider } from '@theokit/ui'
|
|
135
|
+
|
|
136
|
+
// Built-in themes
|
|
137
|
+
import { dracula, oneDark, githubDark, anthropicStyle } from '@theokit/ui'
|
|
138
|
+
|
|
139
|
+
// Custom theme
|
|
140
|
+
const myTheme = defineTheme({
|
|
141
|
+
name: 'my-theme',
|
|
142
|
+
colors: { primary: '#3b82f6', background: '#0a0a0a' },
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
<ThemeProvider theme={myTheme}>
|
|
146
|
+
{children}
|
|
147
|
+
</ThemeProvider>
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Anti-patterns
|
|
151
|
+
|
|
152
|
+
- NEVER build a custom chat message component — use `ChatMessage` + `ChatMessageContent`
|
|
153
|
+
- NEVER build a custom markdown renderer — `ChatMessageContent` handles it (including streaming partial fences)
|
|
154
|
+
- NEVER build a custom code highlighter — `CodeBlock` uses shiki (lazy-loaded)
|
|
155
|
+
- NEVER import from `@usetheo/ui` — that's the deprecated package name; use `@theokit/ui`
|
|
156
|
+
- NEVER install ALL peer deps — only install the peers for components you actually use
|
|
157
|
+
- NEVER use components without wrapping in `TheoUIProvider` + `ThemeProvider` first
|