@cianfrani/ai-ui 0.1.0-alpha.0
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/LICENSE +21 -0
- package/README.md +144 -0
- package/dist/ai-ui.js +3218 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/lib/has-slot-controller.d.ts +21 -0
- package/dist/types/lib/tool-tone.d.ts +2 -0
- package/dist/types/native-styles.d.ts +5 -0
- package/dist/types/semantic/ai-conversation.d.ts +28 -0
- package/dist/types/semantic/ai-event.d.ts +91 -0
- package/dist/types/semantic/ai-message.d.ts +45 -0
- package/dist/types/semantic/ai-thinking.d.ts +41 -0
- package/dist/types/semantic/ai-tool-call.d.ts +59 -0
- package/dist/types/semantic/ai-tool-result.d.ts +44 -0
- package/dist/types/semantic/index.d.ts +6 -0
- package/dist/types/visual/avatar.d.ts +34 -0
- package/dist/types/visual/badge.d.ts +32 -0
- package/dist/types/visual/divider.d.ts +26 -0
- package/dist/types/visual/icon.d.ts +24 -0
- package/dist/types/visual/index.d.ts +9 -0
- package/dist/types/visual/markdown.d.ts +52 -0
- package/dist/types/visual/stack.d.ts +32 -0
- package/dist/types/visual/status.d.ts +33 -0
- package/dist/types/visual/surface.d.ts +34 -0
- package/dist/types/visual/text.d.ts +37 -0
- package/package.json +67 -0
- package/src/custom-elements.json +3741 -0
- package/src/index.ts +8 -0
- package/src/lib/has-slot-controller.ts +61 -0
- package/src/lib/tool-tone.ts +18 -0
- package/src/native-styles.ts +29 -0
- package/src/semantic/ai-conversation.ts +84 -0
- package/src/semantic/ai-event.ts +452 -0
- package/src/semantic/ai-message.ts +235 -0
- package/src/semantic/ai-thinking.ts +190 -0
- package/src/semantic/ai-tool-call.ts +513 -0
- package/src/semantic/ai-tool-result.ts +239 -0
- package/src/semantic/index.ts +6 -0
- package/src/visual/avatar.ts +163 -0
- package/src/visual/badge.ts +141 -0
- package/src/visual/divider.ts +97 -0
- package/src/visual/icon.ts +97 -0
- package/src/visual/index.ts +9 -0
- package/src/visual/markdown.ts +888 -0
- package/src/visual/stack.ts +115 -0
- package/src/visual/status.ts +170 -0
- package/src/visual/surface.ts +150 -0
- package/src/visual/text.ts +141 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mark Cianfrani
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# @cianfrani/ai-ui
|
|
2
|
+
|
|
3
|
+
AI conversation web components for rendering agent transcripts — messages, tool
|
|
4
|
+
calls, tool results, reasoning, and events — built with [Lit](https://lit.dev).
|
|
5
|
+
|
|
6
|
+
Framework-agnostic standard custom elements. Works in any frontend (Lit, React,
|
|
7
|
+
Vue, Svelte, plain HTML). Every component renders correctly with **zero host
|
|
8
|
+
CSS** thanks to built-in token fallbacks; skin it to match your product by
|
|
9
|
+
overriding the `--ai-*` design tokens.
|
|
10
|
+
|
|
11
|
+
> **Status: v0 alpha.** The component API and token names are still settling.
|
|
12
|
+
> Expect breaking changes before `0.1`. Not recommended for production use yet.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install @cianfrani/ai-ui
|
|
18
|
+
# peer: lit ^3
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick start
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import "@cianfrani/ai-ui";
|
|
25
|
+
import { html, render } from "lit";
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```html
|
|
29
|
+
<ai-conversation label="Chat transcript" live>
|
|
30
|
+
<ai-message role="user" timestamp="2026-06-19T09:00:00Z">
|
|
31
|
+
<ai-markdown tone="user" .content=${"Ship it."></ai-markdown>
|
|
32
|
+
</ai-message>
|
|
33
|
+
|
|
34
|
+
<ai-message role="assistant" timestamp="2026-06-19T09:00:02Z">
|
|
35
|
+
<ai-markdown .content=${"Running the tests…"></ai-markdown>
|
|
36
|
+
<ai-tool-call id="t1" name="bash" status="running" headline="bun test src/">
|
|
37
|
+
<pre slot="input">bun test src/</pre>
|
|
38
|
+
<ai-tool-result for="t1" name="bash" status="success" .content=${"12 pass"></ai-tool-result>
|
|
39
|
+
</ai-tool-call>
|
|
40
|
+
</ai-message>
|
|
41
|
+
</ai-conversation>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Components
|
|
45
|
+
|
|
46
|
+
**Semantic transcript primitives**
|
|
47
|
+
- `ai-conversation` — ordered root container; `density`, `live`, accessible label.
|
|
48
|
+
- `ai-message` — message with `role="user|assistant|system|tool"`, `status`, `timestamp`, `label`; `default` / `meta` / `avatar` slots.
|
|
49
|
+
- `ai-tool-call` — collapsible tool-call block with input / summary slots and `ai-show` / `ai-hide` events.
|
|
50
|
+
- `ai-tool-result` — tool output block with `for` association and channel / status metadata.
|
|
51
|
+
- `ai-thinking` — reasoning block with compact disclosure.
|
|
52
|
+
- `ai-event` — compact status / checkpoint / system / error event.
|
|
53
|
+
|
|
54
|
+
**Visual atoms** — `ai-markdown` (markdown renderer with `tone="assistant|user|system|tool"`), `ai-stack`, `ai-surface`, `ai-text`, `ai-badge`, `ai-status`, `ai-avatar`, `ai-icon`, `ai-divider`.
|
|
55
|
+
|
|
56
|
+
Full API docs are generated as a [custom elements manifest](./src/custom-elements.json)
|
|
57
|
+
(`customElements` field). Point your tooling (Storybook, IDE plugins) at it.
|
|
58
|
+
|
|
59
|
+
## Theming
|
|
60
|
+
|
|
61
|
+
Every style reads from `--ai-*` CSS custom properties, and each token falls back
|
|
62
|
+
to a built-in default so the components render reasonably with **zero host CSS**.
|
|
63
|
+
To skin the library, override these tokens on `:root` (or any ancestor). The
|
|
64
|
+
block below is a **starter palette** you can adapt — it is not a mirror of the
|
|
65
|
+
internal defaults (those vary per component and are documented via `@cssprop`
|
|
66
|
+
in source):
|
|
67
|
+
|
|
68
|
+
```css
|
|
69
|
+
:root {
|
|
70
|
+
/* Color */
|
|
71
|
+
--ai-color-text: #f5f5f4;
|
|
72
|
+
--ai-color-text-muted: #a8a29e;
|
|
73
|
+
--ai-color-accent: #f97316;
|
|
74
|
+
--ai-color-border: rgba(255, 255, 255, 0.1);
|
|
75
|
+
--ai-color-success: #22c55e;
|
|
76
|
+
--ai-color-warning: #f59e0b;
|
|
77
|
+
--ai-color-error: #ef4444;
|
|
78
|
+
--ai-color-info: #3b82f6;
|
|
79
|
+
|
|
80
|
+
/* Spacing & radius */
|
|
81
|
+
--ai-space-xs: 0.25rem;
|
|
82
|
+
--ai-space-sm: 0.5rem;
|
|
83
|
+
--ai-space-md: 0.75rem;
|
|
84
|
+
--ai-space-lg: 1rem;
|
|
85
|
+
--ai-radius: 8px;
|
|
86
|
+
|
|
87
|
+
/* Typography */
|
|
88
|
+
--ai-font-family-mono: ui-monospace, monospace;
|
|
89
|
+
--ai-font-size-caption: 0.75rem;
|
|
90
|
+
--ai-font-size-meta: 0.8125rem;
|
|
91
|
+
--ai-font-size-body: 0.875rem;
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Each component also exposes component-local tokens (e.g.
|
|
96
|
+
`--ai-message-user-background`, `--ai-tool-call-border-color`,
|
|
97
|
+
`--ai-markdown-link-color`) for fine-grained control. See each component's
|
|
98
|
+
`@cssprop` docs in source.
|
|
99
|
+
|
|
100
|
+
## Framework notes
|
|
101
|
+
|
|
102
|
+
These are standard custom elements, so they work everywhere, but note:
|
|
103
|
+
|
|
104
|
+
- **Properties with`.`prefix** (`.content`, `.for`) must be set from JS, not as
|
|
105
|
+
HTML attributes. In React this means `ref`-based assignment or a wrapper; Lit
|
|
106
|
+
and Vue handle them natively.
|
|
107
|
+
- **`sideEffects: true`** — importing the package registers the custom elements.
|
|
108
|
+
|
|
109
|
+
## Develop
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
bun install
|
|
113
|
+
bun test # unit tests
|
|
114
|
+
bun run analyze # regenerate custom-elements.json
|
|
115
|
+
bun run build # build dist/ai-ui.js bundle + dist/types/*.d.ts (shipped to npm)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Releasing
|
|
119
|
+
|
|
120
|
+
Releases are automated with [Changesets](https://github.com/changesets/changesets).
|
|
121
|
+
Add a changeset describing your change, then merge the auto-opened "Version
|
|
122
|
+
Packages" PR to cut a release to npm.
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
bun run changeset # describe a change (major/minor/patch)
|
|
126
|
+
bun run version # consume changesets, bump versions + changelog
|
|
127
|
+
bun run release # publish to npm (run by CI)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**First release.** The release workflow (`.github/workflows/release.yml`) only
|
|
131
|
+
publishes when a "Version Packages" PR is merged. The first push to the new
|
|
132
|
+
repo's `main` ships nothing until you add a changeset and merge its version PR,
|
|
133
|
+
or bootstrap the registry once:
|
|
134
|
+
|
|
135
|
+
```sh
|
|
136
|
+
npm publish --tag alpha # one-time, before relying on CI
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The alpha-line prerelease flow (`changeset pre enter/exit alpha`) is documented
|
|
140
|
+
in [`.changeset/README.md`](./.changeset/README.md).
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
[MIT](./LICENSE)
|