mdx-artifacts 0.1.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 +234 -0
- package/README.zh-CN.md +129 -0
- package/agents/AGENTS.snippet.md +13 -0
- package/artifact-docs/examples/commentable-feedback.mdx +126 -0
- package/artifact-docs/examples/decision-matrix.mdx +80 -0
- package/artifact-docs/examples/layout-composition.mdx +216 -0
- package/artifact-docs/examples/streamlit-style-mixed.mdx +183 -0
- package/dist/lib/cli/artifact-state.d.ts +27 -0
- package/dist/lib/cli/artifact-state.js +115 -0
- package/dist/lib/cli/build.d.ts +1 -0
- package/dist/lib/cli/build.js +25 -0
- package/dist/lib/cli/components.d.ts +3 -0
- package/dist/lib/cli/components.js +58 -0
- package/dist/lib/cli/config.d.ts +2 -0
- package/dist/lib/cli/config.js +36 -0
- package/dist/lib/cli/dev.d.ts +1 -0
- package/dist/lib/cli/dev.js +24 -0
- package/dist/lib/cli/index.d.ts +2 -0
- package/dist/lib/cli/index.js +69 -0
- package/dist/lib/cli/review.d.ts +33 -0
- package/dist/lib/cli/review.js +390 -0
- package/dist/lib/cli/scaffold.d.ts +1 -0
- package/dist/lib/cli/scaffold.js +56 -0
- package/dist/lib/cli/types.d.ts +7 -0
- package/dist/lib/cli/types.js +1 -0
- package/dist/lib/cli/validate.d.ts +6 -0
- package/dist/lib/cli/validate.js +79 -0
- package/dist/lib/cli/vite-artifact.d.ts +13 -0
- package/dist/lib/cli/vite-artifact.js +213 -0
- package/dist/lib/react/components/AnnotatedCode.d.ts +19 -0
- package/dist/lib/react/components/AnnotatedCode.js +30 -0
- package/dist/lib/react/components/ArtifactState.d.ts +68 -0
- package/dist/lib/react/components/ArtifactState.js +286 -0
- package/dist/lib/react/components/Callout.d.ts +9 -0
- package/dist/lib/react/components/Callout.js +21 -0
- package/dist/lib/react/components/CodeBlock.d.ts +10 -0
- package/dist/lib/react/components/CodeBlock.js +28 -0
- package/dist/lib/react/components/Comments.d.ts +53 -0
- package/dist/lib/react/components/Comments.js +613 -0
- package/dist/lib/react/components/ComparisonSet.d.ts +24 -0
- package/dist/lib/react/components/ComparisonSet.js +30 -0
- package/dist/lib/react/components/DecisionMatrix.d.ts +16 -0
- package/dist/lib/react/components/DecisionMatrix.js +27 -0
- package/dist/lib/react/components/DiffBlock.d.ts +15 -0
- package/dist/lib/react/components/DiffBlock.js +24 -0
- package/dist/lib/react/components/ExportPanel.d.ts +7 -0
- package/dist/lib/react/components/ExportPanel.js +84 -0
- package/dist/lib/react/components/InlineText.d.ts +9 -0
- package/dist/lib/react/components/InlineText.js +18 -0
- package/dist/lib/react/components/Layout.d.ts +44 -0
- package/dist/lib/react/components/Layout.js +28 -0
- package/dist/lib/react/components/MarkdownBody.d.ts +7 -0
- package/dist/lib/react/components/MarkdownBody.js +36 -0
- package/dist/lib/react/components/OptionGrid.d.ts +13 -0
- package/dist/lib/react/components/OptionGrid.js +21 -0
- package/dist/lib/react/components/Section.d.ts +7 -0
- package/dist/lib/react/components/Section.js +41 -0
- package/dist/lib/react/components/SeverityBadge.d.ts +7 -0
- package/dist/lib/react/components/SeverityBadge.js +14 -0
- package/dist/lib/react/index.d.ts +33 -0
- package/dist/lib/react/index.js +16 -0
- package/dist/lib/react/registry.d.ts +24 -0
- package/dist/lib/react/registry.js +1002 -0
- package/dist/lib/react/styles.css +1417 -0
- package/docs/component-protocol.md +273 -0
- package/docs/component-taxonomy.md +273 -0
- package/docs/design.md +239 -0
- package/docs/design.zh-CN.md +217 -0
- package/docs/naming.md +123 -0
- package/docs/testing.md +138 -0
- package/package.json +90 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# Component Protocol
|
|
2
|
+
|
|
3
|
+
The component protocol is the stable layer between agent-written MDX and generated HTML artifacts.
|
|
4
|
+
|
|
5
|
+
Agents should write MDX that calls high-level components. They should not generate raw HTML for common artifact workflows.
|
|
6
|
+
|
|
7
|
+
## Source Shape
|
|
8
|
+
|
|
9
|
+
Typical source:
|
|
10
|
+
|
|
11
|
+
```mdx
|
|
12
|
+
import { DecisionMatrix, ExportPanel } from "mdx-artifacts/react";
|
|
13
|
+
|
|
14
|
+
<DecisionMatrix
|
|
15
|
+
question="Should stage one focus on a **single HTML artifact**?"
|
|
16
|
+
options={[
|
|
17
|
+
{
|
|
18
|
+
name: "Vite artifact",
|
|
19
|
+
pros: ["Short feedback loop"],
|
|
20
|
+
cons: ["No docs-site navigation yet"],
|
|
21
|
+
verdict: "Recommended"
|
|
22
|
+
}
|
|
23
|
+
]}
|
|
24
|
+
/>
|
|
25
|
+
|
|
26
|
+
<ExportPanel
|
|
27
|
+
value={{ recommendation: "Start with the single artifact loop." }}
|
|
28
|
+
/>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Registry
|
|
32
|
+
|
|
33
|
+
`src/react/registry.ts` is the source of truth for:
|
|
34
|
+
|
|
35
|
+
- component descriptions
|
|
36
|
+
- use cases
|
|
37
|
+
- prop names
|
|
38
|
+
- content types
|
|
39
|
+
- nested object type fields
|
|
40
|
+
- examples
|
|
41
|
+
|
|
42
|
+
The CLI reads the same registry:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
artifact-kit components
|
|
46
|
+
artifact-kit components DecisionMatrix
|
|
47
|
+
artifact-kit components --json
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
When adding or changing a component, update the registry in the same change.
|
|
51
|
+
|
|
52
|
+
Complex props must be self-describing through the registry. Do not rely on TypeScript LSP alone for agent usage. If a prop type references a named object or object array, such as `DecisionMatrixOption[]`, `DiffLine[]`, or `CodeAnnotation[]`, add a matching entry to the component's `types` metadata:
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
{
|
|
56
|
+
name: "DiffBlock",
|
|
57
|
+
props: [
|
|
58
|
+
{
|
|
59
|
+
name: "lines",
|
|
60
|
+
type: "DiffLine[]",
|
|
61
|
+
contentType: "json",
|
|
62
|
+
required: true,
|
|
63
|
+
description: "Structured diff rows."
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
types: [
|
|
67
|
+
{
|
|
68
|
+
name: "DiffLine",
|
|
69
|
+
description: "One structured row in a rendered diff.",
|
|
70
|
+
fields: [
|
|
71
|
+
{
|
|
72
|
+
name: "type",
|
|
73
|
+
type: "'add' | 'remove' | 'context'",
|
|
74
|
+
required: true,
|
|
75
|
+
description: "Diff row kind."
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The CLI must show these nested fields in `artifact-kit components <ComponentName>` and return them in `artifact-kit components <ComponentName> --json`.
|
|
84
|
+
|
|
85
|
+
## Extension Lifecycle
|
|
86
|
+
|
|
87
|
+
The protocol should allow agents and users to go beyond the built-in component set, but that freedom needs a lifecycle. Otherwise MDX Artifacts would collapse back into agents hand-writing one-off React or HTML for every artifact.
|
|
88
|
+
|
|
89
|
+
Use these extension levels:
|
|
90
|
+
|
|
91
|
+
| Level | Location | Purpose | Registry Status |
|
|
92
|
+
|---|---|---|---|
|
|
93
|
+
| Built-in component | `mdx-artifacts/react` | Stable protocol components maintained by this package. | Required |
|
|
94
|
+
| Project local component | User project component folder, such as `artifact-components/` | Reusable project-specific extension. | Configured in the user project |
|
|
95
|
+
| Inline MDX component | Inside a single `.mdx` file | Tiny one-off expression for the current artifact. | Detected, not registered |
|
|
96
|
+
| NPM plugin | External package | Future reusable ecosystem extension. | Future plugin registry |
|
|
97
|
+
|
|
98
|
+
Inline MDX components are allowed as an escape hatch for small, single-use presentation details. They should not contain complex state, effects, drag-and-drop behavior, export logic, or large UI implementations. A strict validation mode may forbid inline components.
|
|
99
|
+
|
|
100
|
+
Project local components are the preferred path when a user needs a reusable extension that is not general enough for the core package. They should live outside the MDX file and be registered in project configuration with a name, import path, description, prop metadata, and examples. The CLI should be able to query these components alongside built-in components.
|
|
101
|
+
|
|
102
|
+
Project local components are build-time extensions, not runtime plugins. The artifact renderer can bundle them into the final HTML through the same MDX/Vite pipeline. This keeps the model simple and avoids a dynamic plugin runtime.
|
|
103
|
+
|
|
104
|
+
Promotion path:
|
|
105
|
+
|
|
106
|
+
1. Start with an inline MDX component for a tiny one-off need.
|
|
107
|
+
2. Move repeated project-specific behavior into a project local component.
|
|
108
|
+
3. Publish reusable cross-project behavior as a plugin package later.
|
|
109
|
+
4. Promote broadly useful, stable, tested behavior into the built-in registry.
|
|
110
|
+
|
|
111
|
+
Promotion into the built-in registry requires a stable name, schema, examples, tests, registry metadata, and a clear validation path.
|
|
112
|
+
|
|
113
|
+
## Abstraction Boundary
|
|
114
|
+
|
|
115
|
+
The public protocol should favor semantic components over layout containers.
|
|
116
|
+
|
|
117
|
+
Preferred public code components:
|
|
118
|
+
|
|
119
|
+
- encode a recognizable artifact task
|
|
120
|
+
- have stable props
|
|
121
|
+
- reduce repeated HTML or interaction code
|
|
122
|
+
- can be explained by their name
|
|
123
|
+
- can export decisions, state, or configuration when interactive
|
|
124
|
+
|
|
125
|
+
Examples:
|
|
126
|
+
|
|
127
|
+
- `DecisionMatrix`
|
|
128
|
+
- `DiffExplainer`
|
|
129
|
+
- `PriorityBoard`
|
|
130
|
+
- `PromptWorkbench`
|
|
131
|
+
- `FeatureFlagEditor`
|
|
132
|
+
|
|
133
|
+
Workflow-level names such as `DiffExplainer`, `FeatureExplainer`, `StatusReport`, and `IncidentReport` do not need to start as large React components. They can first exist as agent recipes or MDX templates that explain which semantic primitives to combine.
|
|
134
|
+
|
|
135
|
+
Promote a workflow recipe to a code component only when:
|
|
136
|
+
|
|
137
|
+
- the section structure is stable
|
|
138
|
+
- the schema is stable
|
|
139
|
+
- repeated MDX composition creates noise or errors
|
|
140
|
+
- the component still lets users hide, add, or replace sections
|
|
141
|
+
|
|
142
|
+
Layout primitives should usually remain internal:
|
|
143
|
+
|
|
144
|
+
- `Stack`
|
|
145
|
+
- `Columns`
|
|
146
|
+
- `Grid`
|
|
147
|
+
- `MosaicGrid`
|
|
148
|
+
- `SplitPane`
|
|
149
|
+
- `Frame`
|
|
150
|
+
|
|
151
|
+
These are useful arrangement strategies, but exposing too many of them pushes agents back toward hand-building UI. Only expose a layout primitive if users genuinely need to compose that structure directly in MDX.
|
|
152
|
+
|
|
153
|
+
If layout primitives are exposed, they should allow content rendering primitives and semantic primitives as children. For example, a `Columns` layout can hold `MarkdownBody`, `Callout`, `AnnotatedCode`, or `Timeline`. The layout controls placement; the child component owns meaning.
|
|
154
|
+
|
|
155
|
+
Avoid exposing domain-shaped layout names such as `ReportHeader`, `MetricBand`, `EditorSplitLayout`, or `TablePanel` as public protocol components. Those are better treated as internal sections inside recipes, templates, or higher-level components.
|
|
156
|
+
|
|
157
|
+
Semantic primitives are different from containers. For example, `AnnotatedCode` owns file paths, line ranges, annotations, and severity. A future `DiffExplainer` owns changed files, diff hunks, findings, and review handoff. Those concepts should not be reduced to arbitrary children inside a generic card.
|
|
158
|
+
|
|
159
|
+
Content rendering primitives may grow beyond text and Markdown. Future candidates include controlled `CodeBlock`, `MathBlock`, and `MermaidBlock` renderers. These should remain narrow format renderers with explicit safety boundaries; they should not become arbitrary HTML or script injection points.
|
|
160
|
+
|
|
161
|
+
## First-stage Components
|
|
162
|
+
|
|
163
|
+
`InlineText`
|
|
164
|
+
|
|
165
|
+
- Use for short labels, titles, captions, and notes.
|
|
166
|
+
- Accepts `inlineMarkdown`.
|
|
167
|
+
- Heading semantics are controlled by the `as` prop.
|
|
168
|
+
|
|
169
|
+
`MarkdownBody`
|
|
170
|
+
|
|
171
|
+
- Use for component-local body copy.
|
|
172
|
+
- Accepts controlled `blockMarkdown`.
|
|
173
|
+
- Supports local headings, paragraphs, lists, blockquotes, bold, emphasis, strikethrough, inline code, and links.
|
|
174
|
+
- Does not support tables, HTML, math, or code blocks.
|
|
175
|
+
- Prefer component title props for main artifact structure.
|
|
176
|
+
|
|
177
|
+
`DecisionMatrix`
|
|
178
|
+
|
|
179
|
+
- Use for tradeoff comparison.
|
|
180
|
+
- Text fields should remain short and scannable.
|
|
181
|
+
|
|
182
|
+
`OptionGrid`
|
|
183
|
+
|
|
184
|
+
- Use for side-by-side alternatives.
|
|
185
|
+
- Each option should focus on intent and tradeoffs.
|
|
186
|
+
|
|
187
|
+
`ExportPanel`
|
|
188
|
+
|
|
189
|
+
- Use when the artifact needs to return decisions, state, or configuration to the user or agent.
|
|
190
|
+
- Interactive artifacts should include `ExportPanel` or an equivalent export path.
|
|
191
|
+
|
|
192
|
+
## Review State Protocol
|
|
193
|
+
|
|
194
|
+
Reviewable content should use stable anchors:
|
|
195
|
+
|
|
196
|
+
- Native MDX prose uses `Section id="..."`.
|
|
197
|
+
- Structured components use their own `id` prop.
|
|
198
|
+
- Component sub-items may derive child anchors from the parent id and item id, such as `decision.stage-one.vite`.
|
|
199
|
+
|
|
200
|
+
The source MDX remains the content truth. Review state lives in a sibling `.state.json` file and references anchors through `anchorId`.
|
|
201
|
+
|
|
202
|
+
The first review model is:
|
|
203
|
+
|
|
204
|
+
- one primary thread per `anchorId`
|
|
205
|
+
- multiple messages per thread
|
|
206
|
+
- `role: "user"` for reviewer comments
|
|
207
|
+
- `role: "assistant"` for agent replies after the MDX has been updated
|
|
208
|
+
|
|
209
|
+
Example state:
|
|
210
|
+
|
|
211
|
+
```json
|
|
212
|
+
{
|
|
213
|
+
"version": 1,
|
|
214
|
+
"source": "artifact-docs/examples/decision-matrix.mdx",
|
|
215
|
+
"threads": [
|
|
216
|
+
{
|
|
217
|
+
"id": "thr_decision_stage_one",
|
|
218
|
+
"anchorId": "decision.stage-one",
|
|
219
|
+
"status": "open",
|
|
220
|
+
"title": "Text model decision",
|
|
221
|
+
"messages": [
|
|
222
|
+
{
|
|
223
|
+
"id": "msg_user_001",
|
|
224
|
+
"role": "user",
|
|
225
|
+
"body": "Clarify why native MDX remains the default.",
|
|
226
|
+
"createdAt": "2026-05-14T08:00:00.000Z"
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"id": "msg_assistant_001",
|
|
230
|
+
"role": "assistant",
|
|
231
|
+
"body": "Updated the decision copy and kept native MDX as the default path.",
|
|
232
|
+
"createdAt": "2026-05-14T08:10:00.000Z"
|
|
233
|
+
}
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
],
|
|
237
|
+
"interactions": {}
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Use narrow CLI writes for review state:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
artifact-kit review add artifact-docs/examples/decision-matrix.mdx \
|
|
245
|
+
--anchor decision.stage-one \
|
|
246
|
+
--body "Clarify why native MDX remains the default."
|
|
247
|
+
|
|
248
|
+
artifact-kit review reply artifact-docs/examples/decision-matrix.mdx \
|
|
249
|
+
--thread thr_decision_stage_one \
|
|
250
|
+
--body "Updated the decision copy." \
|
|
251
|
+
--status resolved
|
|
252
|
+
|
|
253
|
+
artifact-kit review validate artifact-docs/examples/decision-matrix.mdx
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
`review add` creates one open thread for an existing anchor. `review reply` appends assistant messages to existing threads and may update status. `review validate` reports state threads whose `anchorId` no longer exists in the current MDX. None of these commands edits MDX.
|
|
257
|
+
|
|
258
|
+
Do not introduce multi-thread-per-anchor UI until the single-thread message model is stable. Multiple independent threads for one anchor are a later review-system feature, not the first artifact review protocol.
|
|
259
|
+
|
|
260
|
+
## Styling
|
|
261
|
+
|
|
262
|
+
Default CSS uses the `ak-*` prefix.
|
|
263
|
+
|
|
264
|
+
Users can override styles through injected CSS. Component behavior should not depend on a particular brand theme.
|
|
265
|
+
|
|
266
|
+
## Non-goals
|
|
267
|
+
|
|
268
|
+
The component protocol is not:
|
|
269
|
+
|
|
270
|
+
- a raw HTML generator
|
|
271
|
+
- a general Markdown renderer
|
|
272
|
+
- an Astro-only docs framework
|
|
273
|
+
- a replacement for shadcn/ui or daisyUI
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# Component Taxonomy
|
|
2
|
+
|
|
3
|
+
This document maps recurring HTML artifact use cases into reusable component candidates.
|
|
4
|
+
|
|
5
|
+
The source inspiration is the public `html-effectiveness` example set. The goal is not to copy those HTML files. The goal is to extract repeatable structures, interaction patterns, and export loops that can become stable MDX component APIs.
|
|
6
|
+
|
|
7
|
+
## Source Use Case Groups
|
|
8
|
+
|
|
9
|
+
The example set groups twenty HTML artifacts into:
|
|
10
|
+
|
|
11
|
+
- Exploration and planning
|
|
12
|
+
- Code review and understanding
|
|
13
|
+
- Design
|
|
14
|
+
- Prototyping
|
|
15
|
+
- Diagrams
|
|
16
|
+
- Decks
|
|
17
|
+
- Research and learning
|
|
18
|
+
- Reports
|
|
19
|
+
- Custom editing interfaces
|
|
20
|
+
|
|
21
|
+
These groups suggest three broad layers for MDX Artifacts:
|
|
22
|
+
|
|
23
|
+
1. Foundation components
|
|
24
|
+
2. Workflow components
|
|
25
|
+
3. Templates or future adapters
|
|
26
|
+
|
|
27
|
+
## Abstraction Layers
|
|
28
|
+
|
|
29
|
+
The original HTML examples are free-form LLM output. They can produce endless visual variants. MDX Artifacts should not copy those variants one by one. It should extract stable abstractions from the information structure, user task, and export loop.
|
|
30
|
+
|
|
31
|
+
Use these layers when deciding whether a candidate belongs in the public registry.
|
|
32
|
+
|
|
33
|
+
| Layer | Public by Default | Purpose | Examples |
|
|
34
|
+
|---|---:|---|---|
|
|
35
|
+
| Layout primitives | No | Arrange content without owning meaning. These may include default spacing/border styles, but they should not own workflow semantics. | `Stack`, `Columns`, `Grid`, `MosaicGrid`, `SplitPane`, `Frame` |
|
|
36
|
+
| Content rendering primitives | Sometimes | Render controlled content formats. | `InlineText`, `MarkdownBody`, future `CodeBlock`, `MathBlock`, `MermaidBlock` |
|
|
37
|
+
| Semantic primitives | Yes | Express a reusable concept with a stable schema. | `Callout`, `SeverityBadge`, `AnnotatedCode`, `Timeline` |
|
|
38
|
+
| Workflow recipes | Not by default | Guide an agent to assemble an artifact-level job from semantic primitives. Promote to code only when the structure is stable. | `DiffExplainer`, `FeatureExplainer`, `StatusReport` |
|
|
39
|
+
| Editor components | Yes | Let users manipulate local state and export the result. | `PriorityBoard`, `PromptWorkbench`, `FeatureFlagEditor` |
|
|
40
|
+
| Output capabilities | Not always UI | Convert artifact state into handoff formats. | `FlagDiffExport`, `PromptTemplateExport`, `ActionItemsExport` |
|
|
41
|
+
| Templates or adapters | No | Package domain-specific or visually heavy artifact formats. | `DesignSystemSheet`, `ConceptExplainer`, `SlideDeck` |
|
|
42
|
+
|
|
43
|
+
Layout primitives should stay internal first. They should describe arrangement patterns, not domain-specific panels. Prefer names such as `Stack`, `Columns`, `Grid`, `MosaicGrid`, `SplitPane`, and `Frame` over names such as `ReportHeader`, `MetricBand`, or `EditorSplitLayout`.
|
|
44
|
+
|
|
45
|
+
If layout primitives are exposed later, they may accept content rendering primitives and semantic primitives as children. For example, a `Columns` layout could contain `MarkdownBody`, `Callout`, `AnnotatedCode`, or `Timeline`. This should remain an advanced composition path, not the default way for agents to build common artifacts.
|
|
46
|
+
|
|
47
|
+
The common risk is exposing too many `Card`, `Panel`, or ad hoc `Grid` shapes. That pushes agents toward assembling UI instead of calling semantic components or following workflow recipes.
|
|
48
|
+
|
|
49
|
+
Semantic examples matter. A code diff is not just a container with monospace text. It has files, hunks, line ranges, annotations, severity, findings, and review handoff. That is why `AnnotatedCode` belongs in the semantic layer, and why `DiffExplainer` should start as a workflow recipe before becoming a large code component.
|
|
50
|
+
|
|
51
|
+
## Extension Lifecycle
|
|
52
|
+
|
|
53
|
+
Component candidates do not all need to enter the core package. Use the lifecycle below to keep the core package small while still giving agents room to handle new artifact shapes.
|
|
54
|
+
|
|
55
|
+
| Level | Best For | Default Treatment |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| Inline MDX component | Tiny one-off display helpers used by one artifact. | Allow as an escape hatch; validate and report them. |
|
|
58
|
+
| Project local component | Reusable project-specific extensions, such as repo risk maps or internal release widgets. | Register in project config; make them queryable through the CLI. |
|
|
59
|
+
| Workflow recipe | Artifact-level jobs that still need flexible section composition. | Document as agent guidance or MDX templates first. |
|
|
60
|
+
| Built-in component | General, stable, reusable protocol primitives. | Add schema, registry metadata, examples, and tests. |
|
|
61
|
+
| NPM plugin | Cross-project extensions that should not live in the core package. | Future ecosystem layer. |
|
|
62
|
+
|
|
63
|
+
This lifecycle is meant to prevent two failure modes:
|
|
64
|
+
|
|
65
|
+
- overloading the core package with every visual variant found in LLM-generated HTML
|
|
66
|
+
- forcing users back to raw HTML or ad hoc React when they need a small extension
|
|
67
|
+
|
|
68
|
+
Inline MDX components should stay small. If an inline component needs browser state, effects, complex interaction, export logic, or repeated use, it should move into a project local component.
|
|
69
|
+
|
|
70
|
+
Project local components should be treated as build-time extensions. The CLI can bundle them into standalone HTML, validate their registration metadata, and list them together with built-in components. They should not require a runtime plugin system in the first implementation.
|
|
71
|
+
|
|
72
|
+
## Extraction Outputs
|
|
73
|
+
|
|
74
|
+
When reviewing an HTML artifact, extract three kinds of reusable assets.
|
|
75
|
+
|
|
76
|
+
Layout:
|
|
77
|
+
|
|
78
|
+
- Non-functional arrangement such as single column, equal columns, ratio columns, grids, preview frames, and split panes.
|
|
79
|
+
- Layout assets are usually internal primitives first.
|
|
80
|
+
- They should not become agent-facing registry components unless users need to compose layouts directly in MDX.
|
|
81
|
+
|
|
82
|
+
Component:
|
|
83
|
+
|
|
84
|
+
- Semantic or workflow-level pieces such as callouts, badges, annotated code, timelines, decision matrices, and diff explainers.
|
|
85
|
+
- Components can become agent-facing when their name, props, and use case are clear.
|
|
86
|
+
|
|
87
|
+
Output capability:
|
|
88
|
+
|
|
89
|
+
- Interaction or export behavior that returns user choices, annotations, sort order, prompt edits, config changes, or decisions back to the workflow.
|
|
90
|
+
- Output capability can be part of a component, or it can reuse `ExportPanel`.
|
|
91
|
+
- Early output capabilities should prefer copy/export over persistence or backend sync.
|
|
92
|
+
|
|
93
|
+
Early implementation should favor assets that are general, simple, and easy to test.
|
|
94
|
+
|
|
95
|
+
## Foundation Components
|
|
96
|
+
|
|
97
|
+
Foundation components are small protocol primitives. They are not a general UI kit, but they are reused by workflow components.
|
|
98
|
+
|
|
99
|
+
Already available:
|
|
100
|
+
|
|
101
|
+
- `InlineText`: controlled inline Markdown for short text.
|
|
102
|
+
- `MarkdownBody`: controlled block Markdown for component-local body copy.
|
|
103
|
+
- `CodeBlock`: controlled code rendering with filename, language label, line numbers, and highlighted lines.
|
|
104
|
+
- `DiffBlock`: structured diff rendering with add, remove, context rows, and compact effective line numbers.
|
|
105
|
+
- `Callout`: semantic note, warning, recommendation, or risk block with controlled Markdown body copy.
|
|
106
|
+
- `SeverityBadge`: compact severity, confidence, status, or risk label.
|
|
107
|
+
- `AnnotatedCode`: code block with line-level annotations and severity labels.
|
|
108
|
+
- `ExportPanel`: structured Markdown or JSON handoff.
|
|
109
|
+
|
|
110
|
+
Candidate foundation components:
|
|
111
|
+
|
|
112
|
+
| Component | Purpose | Priority | Notes |
|
|
113
|
+
|---|---|---:|---|
|
|
114
|
+
| `Callout` | Highlight warnings, assumptions, gotchas, or decisions. | Shipped | Useful across reports, code review, research, and plans. |
|
|
115
|
+
| `SeverityBadge` | Show severity, confidence, status, or risk. | Shipped | Small but widely reused by review/report components. |
|
|
116
|
+
| `AnnotatedCode` | Render code with line notes and severity markers. | Shipped | First version uses a code block plus annotation list. |
|
|
117
|
+
| `CodeBlock` | Render code with language, filename, line numbers, and highlighted lines. | Shipped | Syntax highlighting and copy affordance remain future enhancements. |
|
|
118
|
+
| `DiffBlock` | Render structured diff rows with compact effective line numbers. | Shipped | Accepts structured lines first; raw unified diff parsing can be a later helper. |
|
|
119
|
+
| `Timeline` | Show ordered events, milestones, incidents, or plans. | P2 | Reusable for status reports, incidents, and implementation plans. |
|
|
120
|
+
| `MetricCard` | Show compact numeric status with label and trend. | P2 | Useful for status reports and dashboards. |
|
|
121
|
+
| `DataTable` | Show simple structured rows such as shipped PRs, impact metrics, or comparisons. | P2/P3 | Keep narrow; do not turn the core package into a table framework. |
|
|
122
|
+
| `ActionItemList` | Show follow-up items with owner, due date, and status. | P2 | Useful for reports, incidents, implementation plans, and handoffs. |
|
|
123
|
+
| `DisclosureSteps` | Show expandable step-by-step explanations. | P2 | Useful for feature explainers and process walkthroughs. |
|
|
124
|
+
| `TabsPanel` | Switch between related examples, snippets, or outputs. | P2 | Useful, but should be added only when repeated. |
|
|
125
|
+
| `GlossaryPanel` | Show terminology with optional term highlighting from body copy. | P2/P3 | Useful for research, learning, and terminology-heavy reports. |
|
|
126
|
+
|
|
127
|
+
## Workflow Recipes
|
|
128
|
+
|
|
129
|
+
Workflow recipes represent artifact-level jobs. They are usually better expressed first as prompt guidance, CLI recipes, or MDX templates that tell an agent which semantic primitives to combine.
|
|
130
|
+
|
|
131
|
+
Already available:
|
|
132
|
+
|
|
133
|
+
- `DecisionMatrix`: compare options.
|
|
134
|
+
- `OptionGrid`: show alternative directions side by side.
|
|
135
|
+
|
|
136
|
+
Candidate workflow recipes:
|
|
137
|
+
|
|
138
|
+
| Recipe | Use Case | Priority | Depends On |
|
|
139
|
+
|---|---|---:|---|
|
|
140
|
+
| `DiffExplainer` | PR review with files, diff hunks, annotations, and findings. | P1 | `AnnotatedCode`, `SeverityBadge`, `Callout` |
|
|
141
|
+
| `PRWriteup` | Reviewer-facing PR explanation with motivation, file tour, and review focus. | P2 | `Callout`, `AnnotatedCode` |
|
|
142
|
+
| `ModuleMap` | Explain a package or module through nodes, edges, entry points, and hot paths. | P2 | Future diagram primitives |
|
|
143
|
+
| `ImplementationPlan` | Show milestones, risks, data flow, and handoff tasks. | P2 | `Timeline`, `Callout`, `DecisionMatrix` |
|
|
144
|
+
| `FeatureExplainer` | Explain how a repo feature works with TL;DR, files read, steps, code tabs, gotchas, and FAQ. | P2 | `DisclosureSteps`, `TabsPanel`, `AnnotatedCode`, `Callout` |
|
|
145
|
+
| `StatusReport` | Weekly or project status summary with shipped/slipped/risks. | P3 | `MetricCard`, `Timeline`, `Callout` |
|
|
146
|
+
| `IncidentReport` | Post-mortem with TL;DR, severity, timeline, root cause, impact, and action items. | P3 | `Timeline`, `AnnotatedCode`, `DataTable`, `ActionItemList`, `Callout` |
|
|
147
|
+
|
|
148
|
+
A workflow recipe should become a code component only when:
|
|
149
|
+
|
|
150
|
+
- its section structure is stable
|
|
151
|
+
- its schema is stable
|
|
152
|
+
- direct composition creates repeated MDX noise
|
|
153
|
+
- code encapsulation reduces agent errors
|
|
154
|
+
- users can still hide, add, or replace sections when needed
|
|
155
|
+
|
|
156
|
+
## Custom Editing Components
|
|
157
|
+
|
|
158
|
+
Custom editors are where HTML artifacts become directly operable. They should run locally, keep state in the browser, show validation feedback, and always include a clear export path back to an agent, issue, PR, config file, or prompt.
|
|
159
|
+
|
|
160
|
+
| Component | Use Case | Priority | Export Shape |
|
|
161
|
+
|---|---|---:|---|
|
|
162
|
+
| `PriorityBoard` | Drag tasks across Now / Next / Later / Cut and export the final plan. | P1 | Markdown and JSON |
|
|
163
|
+
| `PromptWorkbench` | Edit a prompt template, validate slots, and preview sample inputs live. | P1 | Prompt text and JSON |
|
|
164
|
+
| `FeatureFlagEditor` | Toggle grouped flags, show dependency warnings, and copy changed keys. | P1/P2 | JSON diff and full JSON |
|
|
165
|
+
| `ParameterTuner` | Tune values such as duration, easing, color, threshold, or model settings. | P2 | JSON or CSS variables |
|
|
166
|
+
|
|
167
|
+
Common editor requirements:
|
|
168
|
+
|
|
169
|
+
- Keep first versions backend-free and resettable.
|
|
170
|
+
- Prefer copy/export over persistence.
|
|
171
|
+
- Show pending changes or validation warnings before export.
|
|
172
|
+
- Export stable Markdown, JSON, diff, prompt text, or CSS variables.
|
|
173
|
+
|
|
174
|
+
## Design and Prototype Components
|
|
175
|
+
|
|
176
|
+
These are useful, but they should not dominate the core package too early. Design examples show that HTML is strong for token references, component contact sheets, and variant matrices. Those assets are valuable as templates because they help agents reuse a project's visual language without making MDX Artifacts a general-purpose UI kit.
|
|
177
|
+
|
|
178
|
+
| Component | Use Case | Priority | Notes |
|
|
179
|
+
|---|---|---:|---|
|
|
180
|
+
| `DesignSystemSheet` | Show tokens, swatches, type scale, spacing, radius, elevation, and component states. | P3 | Better as an adapter or template that exports prompt context. |
|
|
181
|
+
| `ComponentVariantSheet` | Show component variants, live token controls, usage notes, and copyable props. | P3 | Useful after the component library grows. Reuse `ParameterTuner` for controls. |
|
|
182
|
+
| `AnimationTuner` | Tune easing, duration, and visual motion. | P3 | Browser interaction heavy. |
|
|
183
|
+
| `ClickableFlow` | Link several screens into a prototype. | Later | Better as a template than core protocol. |
|
|
184
|
+
|
|
185
|
+
## Deferred Template Candidates
|
|
186
|
+
|
|
187
|
+
These are valuable artifact formats, but they should stay outside the core component protocol for now:
|
|
188
|
+
|
|
189
|
+
- `SlideDeck`
|
|
190
|
+
- `SVGIllustrationSheet`
|
|
191
|
+
- complex `ConceptExplainer`
|
|
192
|
+
- `InteractiveConceptDemo`
|
|
193
|
+
- generic charting beyond small report-specific charts
|
|
194
|
+
- full diagram authoring tools
|
|
195
|
+
- visual design generators
|
|
196
|
+
|
|
197
|
+
They are better treated as templates, examples, or future adapters after the core workflow components stabilize.
|
|
198
|
+
|
|
199
|
+
## Suggested Implementation Order
|
|
200
|
+
|
|
201
|
+
Phase 2.1: Theme and advanced layout primitives
|
|
202
|
+
|
|
203
|
+
1. `Stack`
|
|
204
|
+
2. `Columns`
|
|
205
|
+
3. `Grid`
|
|
206
|
+
4. `SplitPane`
|
|
207
|
+
5. `Frame`
|
|
208
|
+
|
|
209
|
+
Phase 2.2: Code and explanation foundation
|
|
210
|
+
|
|
211
|
+
1. `CodeBlock`
|
|
212
|
+
2. `DiffBlock`
|
|
213
|
+
3. `Callout`
|
|
214
|
+
4. `SeverityBadge`
|
|
215
|
+
5. `AnnotatedCode`
|
|
216
|
+
6. `DiffExplainer`
|
|
217
|
+
|
|
218
|
+
Phase 2.3: Operable custom editors
|
|
219
|
+
|
|
220
|
+
1. `PriorityBoard`
|
|
221
|
+
2. `PromptWorkbench`
|
|
222
|
+
3. `FeatureFlagEditor`
|
|
223
|
+
4. `ParameterTuner`
|
|
224
|
+
|
|
225
|
+
Phase 2.4: Reports and plans
|
|
226
|
+
|
|
227
|
+
1. `Timeline`
|
|
228
|
+
2. `ImplementationPlan`
|
|
229
|
+
3. `MetricCard`
|
|
230
|
+
4. `ActionItemList`
|
|
231
|
+
5. `StatusReport`
|
|
232
|
+
6. `IncidentReport`
|
|
233
|
+
|
|
234
|
+
## Selection Criteria
|
|
235
|
+
|
|
236
|
+
Prioritize a component when:
|
|
237
|
+
|
|
238
|
+
- it appears across multiple artifact categories
|
|
239
|
+
- it has a clear data schema
|
|
240
|
+
- an agent can choose it from its name and registry metadata
|
|
241
|
+
- it reduces repeated HTML or interaction code
|
|
242
|
+
- it produces a useful export or handoff
|
|
243
|
+
- it does not require the agent to hand-write layout-heavy JSX
|
|
244
|
+
|
|
245
|
+
Defer a component when:
|
|
246
|
+
|
|
247
|
+
- it needs complex browser-only behavior
|
|
248
|
+
- it is mostly visual polish
|
|
249
|
+
- it is better represented as a template
|
|
250
|
+
- it would force the core package to become a general UI kit
|
|
251
|
+
- it is just a container around arbitrary children
|
|
252
|
+
- it has no stable semantics beyond placement or styling
|
|
253
|
+
|
|
254
|
+
## Promotion Rules
|
|
255
|
+
|
|
256
|
+
A candidate can move from local analysis into the public registry when:
|
|
257
|
+
|
|
258
|
+
- the name is self-describing
|
|
259
|
+
- the schema is stable enough to document
|
|
260
|
+
- the component can be queried through the CLI
|
|
261
|
+
- examples can show normal use without raw HTML
|
|
262
|
+
- there is a focused test path
|
|
263
|
+
- interactive state has a clear export path
|
|
264
|
+
|
|
265
|
+
Workflow recipes have a higher bar before becoming code components. They can remain documented agent guidance for a long time. That keeps artifacts flexible while the semantic primitives mature.
|
|
266
|
+
|
|
267
|
+
Keep a candidate internal or template-only when:
|
|
268
|
+
|
|
269
|
+
- it only arranges content
|
|
270
|
+
- it exists only inside one workflow
|
|
271
|
+
- it needs complex children to be useful
|
|
272
|
+
- it is tightly coupled to a project's brand or domain model
|
|
273
|
+
- it would make the package behave like a UI kit, chart library, diagram editor, or docs framework
|