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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mdx-artifacts contributors
|
|
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,234 @@
|
|
|
1
|
+
# MDX Artifacts
|
|
2
|
+
|
|
3
|
+
Interactive MDX artifacts for agents.
|
|
4
|
+
|
|
5
|
+
MDX Artifacts lets an agent write structured MDX with reusable React components, then compile it into a standalone HTML artifact that can be opened locally in a browser.
|
|
6
|
+
|
|
7
|
+
The goal is not to make agents generate raw HTML from scratch. The goal is to make agents call stable, high-level components:
|
|
8
|
+
|
|
9
|
+
```mdx
|
|
10
|
+
import { DecisionMatrix, ExportPanel } from "mdx-artifacts/react";
|
|
11
|
+
|
|
12
|
+
<DecisionMatrix
|
|
13
|
+
question="Should stage one focus on a Vite single HTML artifact?"
|
|
14
|
+
options={[
|
|
15
|
+
{
|
|
16
|
+
name: "Vite single HTML artifact",
|
|
17
|
+
pros: ["Short feedback loop", "Fits one-off tool artifacts"],
|
|
18
|
+
cons: ["No docs-site navigation yet"],
|
|
19
|
+
verdict: "Recommended for stage one"
|
|
20
|
+
}
|
|
21
|
+
]}
|
|
22
|
+
/>
|
|
23
|
+
|
|
24
|
+
<ExportPanel
|
|
25
|
+
title="Export decision"
|
|
26
|
+
formats={["markdown", "json"]}
|
|
27
|
+
value={{ recommendation: "Start with a single HTML artifact." }}
|
|
28
|
+
/>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The CLI turns that MDX file into a self-contained HTML file.
|
|
32
|
+
|
|
33
|
+
## Current Scope
|
|
34
|
+
|
|
35
|
+
The first stage focuses on the smallest useful loop:
|
|
36
|
+
|
|
37
|
+
1. `artifact-docs/**/*.mdx` is the source format.
|
|
38
|
+
2. `src/react` provides high-level artifact components.
|
|
39
|
+
3. `src/cli` provides `init`, `components`, `validate`, `dev`, `build`, and narrow review-state commands.
|
|
40
|
+
4. `components` exposes component props and examples for agents.
|
|
41
|
+
5. `build` outputs a standalone HTML artifact.
|
|
42
|
+
|
|
43
|
+
Astro is intentionally not part of the core yet. It can become a later adapter for long-lived docs sites.
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
|
|
47
|
+
Install in a project that should build local artifacts:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pnpm add mdx-artifacts react react-dom
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Initialize a workspace:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pnpm exec artifact-kit init
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
This creates:
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
artifact-kit.config.mjs
|
|
63
|
+
artifact-docs/examples/hello.mdx
|
|
64
|
+
agents/AGENTS.snippet.md
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Build the initialized example:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pnpm exec artifact-kit validate artifact-docs/examples/hello.mdx
|
|
71
|
+
pnpm exec artifact-kit build artifact-docs/examples/hello.mdx
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Default output:
|
|
75
|
+
|
|
76
|
+
```text
|
|
77
|
+
dist/artifacts/examples/hello.html
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## CLI
|
|
81
|
+
|
|
82
|
+
Inspect available components:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pnpm exec artifact-kit components
|
|
86
|
+
pnpm exec artifact-kit components ExportPanel
|
|
87
|
+
pnpm exec artifact-kit components --json
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Build one MDX file:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
pnpm exec artifact-kit build artifact-docs/examples/hello.mdx
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Review State
|
|
97
|
+
|
|
98
|
+
Artifact Kit can keep local review threads beside an MDX file while the dev server is running. Review state is stored in a sibling `.state.json` file:
|
|
99
|
+
|
|
100
|
+
```text
|
|
101
|
+
artifact-docs/examples/hello.mdx
|
|
102
|
+
artifact-docs/examples/hello.state.json
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Use stable anchors in MDX so review threads can survive edits:
|
|
106
|
+
|
|
107
|
+
```mdx
|
|
108
|
+
import { DecisionMatrix, Section } from "mdx-artifacts/react";
|
|
109
|
+
|
|
110
|
+
<Section id="section.context">
|
|
111
|
+
|
|
112
|
+
## Context
|
|
113
|
+
|
|
114
|
+
Native MDX prose can be reviewed through the section anchor.
|
|
115
|
+
|
|
116
|
+
</Section>
|
|
117
|
+
|
|
118
|
+
<DecisionMatrix
|
|
119
|
+
id="decision.stage-one"
|
|
120
|
+
question="Should this artifact use stable anchors?"
|
|
121
|
+
options={[
|
|
122
|
+
{
|
|
123
|
+
id: "yes",
|
|
124
|
+
name: "Use stable anchors",
|
|
125
|
+
verdict: "Recommended"
|
|
126
|
+
}
|
|
127
|
+
]}
|
|
128
|
+
/>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Agents can add a user thread, append an assistant reply, and validate that saved threads still point at anchors in the current MDX:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
pnpm exec artifact-kit review add artifact-docs/examples/hello.mdx \
|
|
135
|
+
--anchor decision.stage-one \
|
|
136
|
+
--body "Clarify this decision."
|
|
137
|
+
|
|
138
|
+
pnpm exec artifact-kit review reply artifact-docs/examples/hello.mdx \
|
|
139
|
+
--thread thr_decision_stage_one \
|
|
140
|
+
--body "Updated the decision copy." \
|
|
141
|
+
--status resolved
|
|
142
|
+
|
|
143
|
+
pnpm exec artifact-kit review validate artifact-docs/examples/hello.mdx
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Review commands read and write the sibling `.state.json` file for the source MDX. They do not edit the MDX source. `review validate` checks whether saved review threads still point at anchors that exist in the current MDX.
|
|
147
|
+
|
|
148
|
+
When an anchor is removed from MDX, the browser review layer keeps the thread visible as an unplaced comment instead of deleting it. The CLI reports the same problem:
|
|
149
|
+
|
|
150
|
+
```text
|
|
151
|
+
review validate failed
|
|
152
|
+
missing: 1
|
|
153
|
+
- thread: thr_removed anchorId: comparison.removed status: open title: Removed comparison
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Resolve missing anchors by restoring the old id, migrating the thread to a new anchor, or marking the thread resolved with an assistant reply that explains the structural change.
|
|
157
|
+
|
|
158
|
+
## Repository Development
|
|
159
|
+
|
|
160
|
+
Install dependencies:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
pnpm install
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Validate and build the repository example artifact:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
pnpm check
|
|
170
|
+
pnpm artifact:validate
|
|
171
|
+
pnpm artifact:build
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Develop components in Storybook:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
pnpm storybook
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Storybook is only for component development. The artifact workflow is still verified through `artifact-kit validate/build`.
|
|
181
|
+
|
|
182
|
+
Run the test baseline:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
pnpm test
|
|
186
|
+
pnpm typecheck
|
|
187
|
+
pnpm artifact:validate
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Run the package smoke test before publishing:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
pnpm pack:smoke
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Style Injection
|
|
197
|
+
|
|
198
|
+
Artifact Kit injects default styles by default. Users can add brand styles through `artifact-kit.config.mjs`:
|
|
199
|
+
|
|
200
|
+
```js
|
|
201
|
+
/** @type {import("mdx-artifacts").ArtifactKitConfig} */
|
|
202
|
+
const config = {
|
|
203
|
+
docsDir: "artifact-docs",
|
|
204
|
+
outDir: "dist/artifacts",
|
|
205
|
+
includeDefaultStyles: true,
|
|
206
|
+
styles: ["artifact-theme.css"]
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export default config;
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Custom styles are imported after the default styles, so they can override CSS variables or `ak-*` classes. Set `includeDefaultStyles: false` to fully own the styling.
|
|
213
|
+
|
|
214
|
+
## Design Principles
|
|
215
|
+
|
|
216
|
+
- Source files are MDX, not raw HTML.
|
|
217
|
+
- Component APIs should be semantic and self-describing.
|
|
218
|
+
- Interactive artifacts must provide an export path.
|
|
219
|
+
- Bulky data should live in adjacent JSON files instead of JSX props.
|
|
220
|
+
- Core components stay React/TypeScript and should be reusable from Vite, Astro, or artifact builders.
|
|
221
|
+
- Tailwind is an internal styling build tool; the final artifact still inlines CSS.
|
|
222
|
+
- Radix primitives are introduced only when complex interactions need them.
|
|
223
|
+
- shadcn/ui and daisyUI are not core dependencies; they may become optional templates or registries later.
|
|
224
|
+
- Basic tests protect registry metadata, controlled text rendering, CLI component lookup, and MDX validation.
|
|
225
|
+
|
|
226
|
+
## Documentation
|
|
227
|
+
|
|
228
|
+
- [Roadmap](ROADMAP.md)
|
|
229
|
+
- [Design notes](docs/design.md)
|
|
230
|
+
- [Naming conventions](docs/naming.md)
|
|
231
|
+
- [Component protocol](docs/component-protocol.md)
|
|
232
|
+
- [Component taxonomy](docs/component-taxonomy.md)
|
|
233
|
+
- [Testing](docs/testing.md)
|
|
234
|
+
- [Chinese README](README.zh-CN.md)
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# MDX Artifacts
|
|
2
|
+
|
|
3
|
+
一个面向 Agent 的交互式 MDX artifact 工具原型。
|
|
4
|
+
|
|
5
|
+
目标不是让模型每次生成一整份裸 HTML,而是让模型写较稳定的 MDX:
|
|
6
|
+
|
|
7
|
+
```mdx
|
|
8
|
+
import { DecisionMatrix, ExportPanel } from "../../src/react";
|
|
9
|
+
|
|
10
|
+
<DecisionMatrix
|
|
11
|
+
question="是否先用 Vite 跑通单 HTML artifact?"
|
|
12
|
+
options={[
|
|
13
|
+
{
|
|
14
|
+
name: "先做 Vite 单页",
|
|
15
|
+
pros: ["闭环短", "更贴近交互工具"],
|
|
16
|
+
cons: ["暂时没有文档站导航"],
|
|
17
|
+
verdict: "第一阶段推荐"
|
|
18
|
+
}
|
|
19
|
+
]}
|
|
20
|
+
/>
|
|
21
|
+
|
|
22
|
+
<ExportPanel
|
|
23
|
+
title="导出决策"
|
|
24
|
+
formats={["markdown", "json"]}
|
|
25
|
+
value={{ recommendation: "先做单 HTML artifact" }}
|
|
26
|
+
/>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
再由 CLI 输出一个可在浏览器中直接打开的 HTML artifact。
|
|
30
|
+
|
|
31
|
+
## 当前阶段
|
|
32
|
+
|
|
33
|
+
第一阶段只做最小闭环:
|
|
34
|
+
|
|
35
|
+
1. `artifact-docs/**/*.mdx` 作为源文件。
|
|
36
|
+
2. `src/react` 提供高阶组件。
|
|
37
|
+
3. `src/cli` 提供 `dev`、`build`、`validate`、`init`。
|
|
38
|
+
4. CLI 提供 `components` 查询组件参数和示例。
|
|
39
|
+
5. `build` 输出单个 self-contained HTML 文件。
|
|
40
|
+
6. `InlineText` / `MarkdownBody` 提供受控的文本渲染边界。
|
|
41
|
+
|
|
42
|
+
暂不把核心绑定到 Astro。Astro 后续只作为“结构化文档站 adapter”加入。
|
|
43
|
+
|
|
44
|
+
## 命令
|
|
45
|
+
|
|
46
|
+
安装依赖后:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pnpm check
|
|
50
|
+
pnpm artifact:validate
|
|
51
|
+
pnpm artifact:dev
|
|
52
|
+
pnpm artifact:build
|
|
53
|
+
pnpm storybook
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
查询组件:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pnpm artifact components
|
|
60
|
+
pnpm artifact components ExportPanel
|
|
61
|
+
pnpm artifact components --json
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
单文件构建:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pnpm artifact build artifact-docs/examples/decision-matrix.mdx
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
默认输出:
|
|
71
|
+
|
|
72
|
+
```text
|
|
73
|
+
dist/artifacts/examples/decision-matrix.html
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
组件开发:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pnpm storybook
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Storybook 只用于隔离调试 React 组件;最终 artifact 闭环仍以 `artifact-kit validate/build` 为准。
|
|
83
|
+
|
|
84
|
+
基础测试:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pnpm test
|
|
88
|
+
pnpm typecheck
|
|
89
|
+
pnpm artifact:validate
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## 样式注入
|
|
93
|
+
|
|
94
|
+
默认情况下,Artifact Kit 会注入内置样式。使用者可以在 `artifact-kit.config.ts` 里追加自己的品牌 CSS:
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
import type { ArtifactKitConfig } from "./src/cli/types";
|
|
98
|
+
|
|
99
|
+
const config: ArtifactKitConfig = {
|
|
100
|
+
docsDir: "artifact-docs",
|
|
101
|
+
outDir: "dist/artifacts",
|
|
102
|
+
includeDefaultStyles: true,
|
|
103
|
+
styles: ["artifact-theme.css"]
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export default config;
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`styles` 会在默认样式之后导入,因此可以覆盖 CSS variables 或 `ak-*` class。若要完全接管样式,可以设置 `includeDefaultStyles: false`。
|
|
110
|
+
|
|
111
|
+
## 设计原则
|
|
112
|
+
|
|
113
|
+
- 源文件是 MDX,不是裸 HTML。
|
|
114
|
+
- 组件 API 要语义化,避免让 Agent 手写布局。
|
|
115
|
+
- 交互工具必须提供导出能力。
|
|
116
|
+
- 大数据后续应放到相邻 JSON 文件,不要塞进 MDX props。
|
|
117
|
+
- 核心组件保持 React/TypeScript,可被 Vite、Astro、Claude artifact builder 复用。
|
|
118
|
+
- Tailwind 作为内部样式构建能力,最终仍输出内联 CSS 的单 HTML。
|
|
119
|
+
- Radix 只按需用于复杂交互 primitives,不把 shadcn/ui 或 daisyUI 作为核心依赖。
|
|
120
|
+
- 基础测试覆盖 registry 元数据、受控文本渲染、CLI 组件查询和 MDX validate。
|
|
121
|
+
|
|
122
|
+
## 后续阶段
|
|
123
|
+
|
|
124
|
+
- [公开路线图](ROADMAP.md)
|
|
125
|
+
- [设计说明](docs/design.zh-CN.md)
|
|
126
|
+
- [英文命名规范](docs/naming.md)
|
|
127
|
+
- [英文组件协议](docs/component-protocol.md)
|
|
128
|
+
- [英文组件分类](docs/component-taxonomy.md)
|
|
129
|
+
- [英文测试协议](docs/testing.md)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Artifact Kit Agent Instructions
|
|
2
|
+
|
|
3
|
+
When creating an interactive report, option comparison, temporary tool, or visual explanation page:
|
|
4
|
+
|
|
5
|
+
1. Do not generate raw HTML unless explicitly requested.
|
|
6
|
+
2. Create `.mdx` files under `artifact-docs/`.
|
|
7
|
+
3. Prefer high-level components from `mdx-artifacts/react`.
|
|
8
|
+
4. Interactive artifacts must include `ExportPanel` or an equivalent export path.
|
|
9
|
+
5. Do not inline bulky data in JSX props. Prefer adjacent `.json` files.
|
|
10
|
+
6. Run `artifact-kit components <ComponentName>` when component props are unclear.
|
|
11
|
+
7. Run `artifact-kit components --json` when machine-readable component metadata is needed.
|
|
12
|
+
8. Run `artifact-kit validate <file.mdx>` before build.
|
|
13
|
+
9. Run `artifact-kit build <file.mdx>` to produce standalone HTML.
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Callout,
|
|
3
|
+
CommentTarget,
|
|
4
|
+
DecisionMatrix,
|
|
5
|
+
ExportPanel,
|
|
6
|
+
OptionGrid,
|
|
7
|
+
Section,
|
|
8
|
+
} from "mdx-artifacts/react";
|
|
9
|
+
|
|
10
|
+
# Commentable Artifact Feedback
|
|
11
|
+
|
|
12
|
+
This example shows a local block-level comment loop. The author marks stable review targets with `Section` or component ids, the reader adds comments in the browser, and artifact state is saved beside the MDX file during local dev.
|
|
13
|
+
|
|
14
|
+
<DecisionMatrix
|
|
15
|
+
id="decision.comment-targets"
|
|
16
|
+
question="Should comment targets be explicit blocks in v1?"
|
|
17
|
+
options={[
|
|
18
|
+
{
|
|
19
|
+
id: "explicit",
|
|
20
|
+
name: "Explicit comment blocks",
|
|
21
|
+
summary:
|
|
22
|
+
"Authors wrap reviewable sections with a stable block id and title.",
|
|
23
|
+
pros: [
|
|
24
|
+
"Stable export target",
|
|
25
|
+
"Works for prose and components",
|
|
26
|
+
"Does not change existing component props",
|
|
27
|
+
],
|
|
28
|
+
cons: ["Adds one wrapper around reviewable regions"],
|
|
29
|
+
confidence: "high",
|
|
30
|
+
verdict: "Recommended for v1",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "implicit",
|
|
34
|
+
name: "Implicit component comments",
|
|
35
|
+
summary: "Every artifact component becomes commentable by default.",
|
|
36
|
+
pros: ["Less explicit authoring syntax"],
|
|
37
|
+
cons: [
|
|
38
|
+
"Cannot naturally target prose",
|
|
39
|
+
"Requires changing many component APIs",
|
|
40
|
+
],
|
|
41
|
+
confidence: "medium",
|
|
42
|
+
verdict: "Defer until block comments prove useful",
|
|
43
|
+
},
|
|
44
|
+
]}
|
|
45
|
+
/>
|
|
46
|
+
|
|
47
|
+
<Section id="section.prose-guidance">
|
|
48
|
+
|
|
49
|
+
## Prose guidance
|
|
50
|
+
|
|
51
|
+
A section target gives the exported state enough context for the next agent turn without requiring text selection or component internals.
|
|
52
|
+
|
|
53
|
+
Use section comments when feedback should attach to a visible native MDX region:
|
|
54
|
+
|
|
55
|
+
- a short prose explanation
|
|
56
|
+
- a nested supporting point
|
|
57
|
+
- a deeper supporting point
|
|
58
|
+
- a paragraph plus a list
|
|
59
|
+
- a decision summary before a component
|
|
60
|
+
- a custom composed section boundary
|
|
61
|
+
|
|
62
|
+
1. First ordered list item
|
|
63
|
+
1. Nested ordered list item
|
|
64
|
+
2. Another nested ordered item
|
|
65
|
+
2. Second ordered list item
|
|
66
|
+
|
|
67
|
+
</Section>
|
|
68
|
+
|
|
69
|
+
<OptionGrid
|
|
70
|
+
id="option.comment-flow"
|
|
71
|
+
title="Comment workflow pieces"
|
|
72
|
+
options={[
|
|
73
|
+
{
|
|
74
|
+
id: "layer",
|
|
75
|
+
name: "CommentLayer",
|
|
76
|
+
intent:
|
|
77
|
+
"The artifact shell now provides this review context automatically.",
|
|
78
|
+
tradeoffs: [
|
|
79
|
+
"No production backend",
|
|
80
|
+
"Local dev persists to sidecar state",
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: "section",
|
|
85
|
+
name: "Section",
|
|
86
|
+
intent:
|
|
87
|
+
"Marks native MDX prose with a stable anchor id while keeping native headings in the section body.",
|
|
88
|
+
tradeoffs: [
|
|
89
|
+
"Clear review context",
|
|
90
|
+
"Authors choose the section boundary",
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: "export",
|
|
95
|
+
name: "ExportPanel",
|
|
96
|
+
intent: "Exports the artifact result when a static handoff is needed.",
|
|
97
|
+
tradeoffs: [
|
|
98
|
+
"Agent-friendly handoff",
|
|
99
|
+
"State is handled by the local dev shell",
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
]}
|
|
103
|
+
/>
|
|
104
|
+
|
|
105
|
+
<CommentTarget
|
|
106
|
+
targetId="custom-comment-target"
|
|
107
|
+
title="Custom comment target"
|
|
108
|
+
description="A hand-authored target for content that is not inside a built-in component."
|
|
109
|
+
>
|
|
110
|
+
<Callout
|
|
111
|
+
id="callout.custom-target"
|
|
112
|
+
tone="warning"
|
|
113
|
+
title="Custom targets still work"
|
|
114
|
+
body="Use CommentTarget when an artifact has a smaller local region that should be commentable without turning the whole section into a target."
|
|
115
|
+
/>
|
|
116
|
+
</CommentTarget>
|
|
117
|
+
|
|
118
|
+
<ExportPanel
|
|
119
|
+
title="Export artifact feedback"
|
|
120
|
+
value={{
|
|
121
|
+
recommendation:
|
|
122
|
+
"Use explicit comment targets first, then evaluate implicit Markdown comments.",
|
|
123
|
+
reviewModel: "One comment per target",
|
|
124
|
+
nextStep: "Validate Section around native MDX prose blocks and unplaced comments",
|
|
125
|
+
}}
|
|
126
|
+
/>
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { DecisionMatrix, ExportPanel, OptionGrid } from "mdx-artifacts/react";
|
|
2
|
+
|
|
3
|
+
# Artifact Kit Stage One Decision
|
|
4
|
+
|
|
5
|
+
<DecisionMatrix
|
|
6
|
+
id="decision.stage-one"
|
|
7
|
+
question="Should stage one focus on a **Vite single HTML artifact** instead of starting with an Astro docs site?"
|
|
8
|
+
options={[
|
|
9
|
+
{
|
|
10
|
+
id: "vite",
|
|
11
|
+
name: "**Vite** single HTML artifact",
|
|
12
|
+
summary: "Validate the shortest `MDX -> HTML` loop first.",
|
|
13
|
+
pros: ["Shortest loop", "Direct interactive component debugging", "Fits one-off tool artifacts"],
|
|
14
|
+
cons: ["No docs-site navigation yet", "Weaker long-term archive experience"],
|
|
15
|
+
confidence: "high",
|
|
16
|
+
verdict: "Recommended for stage one"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: "astro",
|
|
20
|
+
name: "Astro docs site",
|
|
21
|
+
summary: "Turn the artifact-docs tree into a structured static docs site.",
|
|
22
|
+
pros: ["Better long-term reading experience", "File-based pages", "Good for archives"],
|
|
23
|
+
cons: ["Too heavy for stage one", "Mixes component protocol work with docs-site engineering"],
|
|
24
|
+
confidence: "medium",
|
|
25
|
+
verdict: "Add in stage two"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: "raw-html",
|
|
29
|
+
name: "Raw HTML",
|
|
30
|
+
summary: "Let agents generate complete HTML directly.",
|
|
31
|
+
pros: ["No toolchain", "Fast for very small throwaway pages"],
|
|
32
|
+
cons: ["Duplicated code", "Style drift", "~~Reusable~~ export behavior is hard to reuse"],
|
|
33
|
+
confidence: "low",
|
|
34
|
+
verdict: "Keep only as fallback"
|
|
35
|
+
}
|
|
36
|
+
]}
|
|
37
|
+
/>
|
|
38
|
+
|
|
39
|
+
<OptionGrid
|
|
40
|
+
id="option.first-components"
|
|
41
|
+
title="First component scope"
|
|
42
|
+
options={[
|
|
43
|
+
{
|
|
44
|
+
id: "decision-matrix",
|
|
45
|
+
name: "DecisionMatrix",
|
|
46
|
+
intent: "Compare options",
|
|
47
|
+
tradeoffs: ["Stable **decision** structure", "Does not own complex interaction"]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: "option-grid",
|
|
51
|
+
name: "OptionGrid",
|
|
52
|
+
intent: "Show alternatives side by side",
|
|
53
|
+
tradeoffs: ["Easy to scan", "Can add selection later"]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: "export-panel",
|
|
57
|
+
name: "ExportPanel",
|
|
58
|
+
intent: "Return conclusions or edits to the workflow",
|
|
59
|
+
tradeoffs: ["Copy-only in v1", "Can add file download later"]
|
|
60
|
+
}
|
|
61
|
+
]}
|
|
62
|
+
/>
|
|
63
|
+
|
|
64
|
+
<ExportPanel
|
|
65
|
+
title="Export recommendation"
|
|
66
|
+
formats={["markdown", "json"]}
|
|
67
|
+
value={{
|
|
68
|
+
recommendation: "Start with Vite + React + MDX to single HTML artifact.",
|
|
69
|
+
reasons: [
|
|
70
|
+
"Validate the high-level component protocol and exporter first.",
|
|
71
|
+
"Avoid binding the core to Astro docs-site structure too early.",
|
|
72
|
+
"The same MDX tree can still feed an Astro template later."
|
|
73
|
+
],
|
|
74
|
+
nextSteps: [
|
|
75
|
+
"Keep CLI validate/build/dev reliable.",
|
|
76
|
+
"Ensure the example MDX outputs standalone HTML.",
|
|
77
|
+
"Design the Astro adapter after the component protocol stabilizes."
|
|
78
|
+
]
|
|
79
|
+
}}
|
|
80
|
+
/>
|