mdx-artifacts 0.1.1 → 0.2.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/README.md +224 -60
- package/README.zh-CN.md +299 -42
- package/agents/AGENTS.snippet.md +21 -10
- package/artifact-docs/examples/commentable-feedback.mdx +76 -70
- package/artifact-docs/examples/decision-matrix.mdx +122 -50
- package/artifact-docs/examples/layout-composition.mdx +106 -128
- package/artifact-docs/examples/streamlit-style-mixed.mdx +100 -85
- package/dist/lib/cli/{build.js → commands/build.js} +2 -2
- package/dist/lib/cli/{components.js → commands/components.js} +19 -3
- package/dist/lib/cli/{dev.js → commands/dev.js} +2 -2
- package/dist/lib/cli/commands/interactions.d.ts +2 -0
- package/dist/lib/cli/commands/interactions.js +280 -0
- package/dist/lib/cli/commands/review.d.ts +1 -0
- package/dist/lib/cli/commands/review.js +171 -0
- package/dist/lib/cli/commands/scaffold.d.ts +16 -0
- package/dist/lib/cli/commands/scaffold.js +440 -0
- package/dist/lib/cli/commands/validate.d.ts +18 -0
- package/dist/lib/cli/commands/validate.js +311 -0
- package/dist/lib/cli/config/config.d.ts +2 -0
- package/dist/lib/cli/{config.js → config/config.js} +3 -2
- package/dist/lib/cli/{types.d.ts → config/types.d.ts} +2 -1
- package/dist/lib/cli/{vite-artifact.d.ts → dev-server/vite-artifact.d.ts} +3 -3
- package/dist/lib/cli/dev-server/vite-artifact.js +415 -0
- package/dist/lib/cli/diagnostics/diagnostics.d.ts +11 -0
- package/dist/lib/cli/diagnostics/diagnostics.js +1 -0
- package/dist/lib/cli/index.js +39 -18
- package/dist/lib/cli/mdx/sortable-list.d.ts +14 -0
- package/dist/lib/cli/mdx/sortable-list.js +520 -0
- package/dist/lib/cli/resources/resource-policy.d.ts +15 -0
- package/dist/lib/cli/resources/resource-policy.js +46 -0
- package/dist/lib/cli/resources/safe-path.d.ts +13 -0
- package/dist/lib/cli/resources/safe-path.js +55 -0
- package/dist/lib/cli/services/interaction-service.d.ts +40 -0
- package/dist/lib/cli/services/interaction-service.js +226 -0
- package/dist/lib/cli/services/review.d.ts +43 -0
- package/dist/lib/cli/{review.js → services/review.js} +34 -172
- package/dist/lib/react/{components → composites/comparison-set}/ComparisonSet.d.ts +1 -1
- package/dist/lib/react/{components → composites/comparison-set}/ComparisonSet.js +3 -3
- package/dist/lib/react/composites/comparison-set/index.d.ts +2 -0
- package/dist/lib/react/composites/comparison-set/index.js +1 -0
- package/dist/lib/react/composites/content-set/ContentItem.d.ts +37 -0
- package/dist/lib/react/composites/content-set/ContentItem.js +49 -0
- package/dist/lib/react/composites/content-set/index.d.ts +2 -0
- package/dist/lib/react/composites/content-set/index.js +1 -0
- package/dist/lib/react/{components → composites/export-panel}/ExportPanel.js +2 -2
- package/dist/lib/react/composites/export-panel/index.d.ts +2 -0
- package/dist/lib/react/composites/export-panel/index.js +1 -0
- package/dist/lib/react/{components → composites/section}/Section.js +1 -1
- package/dist/lib/react/composites/section/index.d.ts +2 -0
- package/dist/lib/react/composites/section/index.js +1 -0
- package/dist/lib/react/index.d.ts +36 -31
- package/dist/lib/react/index.js +18 -15
- package/dist/lib/react/interactions/artifact-state/index.d.ts +1 -0
- package/dist/lib/react/interactions/artifact-state/index.js +1 -0
- package/dist/lib/react/{components → interactions/comments}/Comments.d.ts +2 -2
- package/dist/lib/react/{components → interactions/comments}/Comments.js +3 -3
- package/dist/lib/react/interactions/comments/index.d.ts +1 -0
- package/dist/lib/react/interactions/comments/index.js +1 -0
- package/dist/lib/react/interactions/sortable-list/SortableList.d.ts +29 -0
- package/dist/lib/react/interactions/sortable-list/SortableList.js +282 -0
- package/dist/lib/react/interactions/sortable-list/index.d.ts +1 -0
- package/dist/lib/react/interactions/sortable-list/index.js +1 -0
- package/dist/lib/react/layout/layout-primitives/index.d.ts +2 -0
- package/dist/lib/react/layout/layout-primitives/index.js +1 -0
- package/dist/lib/react/legacy/LegacyContentComponents.d.ts +65 -0
- package/dist/lib/react/legacy/LegacyContentComponents.js +26 -0
- package/dist/lib/react/mdx-components.d.ts +5 -0
- package/dist/lib/react/mdx-components.js +38 -0
- package/dist/lib/react/{components → primitives/annotated-code}/AnnotatedCode.d.ts +1 -1
- package/dist/lib/react/{components → primitives/annotated-code}/AnnotatedCode.js +5 -5
- package/dist/lib/react/primitives/annotated-code/index.d.ts +2 -0
- package/dist/lib/react/primitives/annotated-code/index.js +1 -0
- package/dist/lib/react/primitives/callout/Callout.d.ts +11 -0
- package/dist/lib/react/{components → primitives/callout}/Callout.js +9 -6
- package/dist/lib/react/primitives/callout/index.d.ts +2 -0
- package/dist/lib/react/primitives/callout/index.js +1 -0
- package/dist/lib/react/primitives/code-block/CodeBlock.d.ts +20 -0
- package/dist/lib/react/primitives/code-block/CodeBlock.js +32 -0
- package/dist/lib/react/primitives/code-block/index.d.ts +2 -0
- package/dist/lib/react/primitives/code-block/index.js +1 -0
- package/dist/lib/react/primitives/code-surface/CodeSurface.d.ts +11 -0
- package/dist/lib/react/primitives/code-surface/CodeSurface.js +34 -0
- package/dist/lib/react/primitives/code-surface/index.d.ts +2 -0
- package/dist/lib/react/primitives/code-surface/index.js +1 -0
- package/dist/lib/react/primitives/diff-block/DiffBlock.js +25 -0
- package/dist/lib/react/primitives/diff-block/index.d.ts +2 -0
- package/dist/lib/react/primitives/diff-block/index.js +1 -0
- package/dist/lib/react/{components → primitives/inline-text}/InlineText.d.ts +4 -2
- package/dist/lib/react/primitives/inline-text/InlineText.js +28 -0
- package/dist/lib/react/primitives/inline-text/index.d.ts +2 -0
- package/dist/lib/react/primitives/inline-text/index.js +1 -0
- package/dist/lib/react/primitives/markdown-body/MarkdownBody.d.ts +9 -0
- package/dist/lib/react/primitives/markdown-body/MarkdownBody.js +49 -0
- package/dist/lib/react/primitives/markdown-body/index.d.ts +2 -0
- package/dist/lib/react/primitives/markdown-body/index.js +1 -0
- package/dist/lib/react/primitives/severity-badge/index.d.ts +2 -0
- package/dist/lib/react/primitives/severity-badge/index.js +1 -0
- package/dist/lib/react/registry.d.ts +10 -0
- package/dist/lib/react/registry.js +505 -210
- package/dist/lib/react/styles.css +490 -38
- package/docs/cli-structure.md +141 -0
- package/docs/component-protocol.md +199 -33
- package/docs/component-taxonomy.md +40 -4
- package/docs/design.md +42 -21
- package/docs/design.zh-CN.md +41 -21
- package/docs/naming.md +17 -7
- package/docs/releasing.md +132 -0
- package/docs/testing.md +35 -10
- package/package.json +9 -7
- package/dist/lib/cli/config.d.ts +0 -2
- package/dist/lib/cli/review.d.ts +0 -33
- package/dist/lib/cli/scaffold.d.ts +0 -1
- package/dist/lib/cli/scaffold.js +0 -56
- package/dist/lib/cli/validate.d.ts +0 -6
- package/dist/lib/cli/validate.js +0 -79
- package/dist/lib/cli/vite-artifact.js +0 -237
- package/dist/lib/react/components/Callout.d.ts +0 -9
- package/dist/lib/react/components/CodeBlock.d.ts +0 -10
- package/dist/lib/react/components/CodeBlock.js +0 -28
- package/dist/lib/react/components/DecisionMatrix.d.ts +0 -16
- package/dist/lib/react/components/DecisionMatrix.js +0 -27
- package/dist/lib/react/components/DiffBlock.js +0 -24
- package/dist/lib/react/components/InlineText.js +0 -18
- package/dist/lib/react/components/MarkdownBody.d.ts +0 -7
- package/dist/lib/react/components/MarkdownBody.js +0 -36
- package/dist/lib/react/components/OptionGrid.d.ts +0 -13
- package/dist/lib/react/components/OptionGrid.js +0 -21
- /package/dist/lib/cli/{build.d.ts → commands/build.d.ts} +0 -0
- /package/dist/lib/cli/{components.d.ts → commands/components.d.ts} +0 -0
- /package/dist/lib/cli/{dev.d.ts → commands/dev.d.ts} +0 -0
- /package/dist/lib/cli/{types.js → config/types.js} +0 -0
- /package/dist/lib/cli/{artifact-state.d.ts → state/artifact-state.d.ts} +0 -0
- /package/dist/lib/cli/{artifact-state.js → state/artifact-state.js} +0 -0
- /package/dist/lib/react/{components → composites/export-panel}/ExportPanel.d.ts +0 -0
- /package/dist/lib/react/{components → composites/section}/Section.d.ts +0 -0
- /package/dist/lib/react/{components → interactions/artifact-state}/ArtifactState.d.ts +0 -0
- /package/dist/lib/react/{components → interactions/artifact-state}/ArtifactState.js +0 -0
- /package/dist/lib/react/{components → layout/layout-primitives}/Layout.d.ts +0 -0
- /package/dist/lib/react/{components → layout/layout-primitives}/Layout.js +0 -0
- /package/dist/lib/react/{components → primitives/diff-block}/DiffBlock.d.ts +0 -0
- /package/dist/lib/react/{components → primitives/severity-badge}/SeverityBadge.d.ts +0 -0
- /package/dist/lib/react/{components → primitives/severity-badge}/SeverityBadge.js +0 -0
package/README.md
CHANGED
|
@@ -4,22 +4,31 @@ Interactive MDX artifacts for agents.
|
|
|
4
4
|
|
|
5
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
6
|
|
|
7
|
-
The goal is not to make agents generate raw HTML from scratch. The goal is to
|
|
7
|
+
The goal is not to make agents generate raw HTML from scratch or write a React app DSL inside MDX. The goal is to keep the source Markdown-native while using stable, high-level components as semantic islands:
|
|
8
8
|
|
|
9
9
|
```mdx
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
import { ContentSet, ExportPanel } from "mdx-artifacts/react";
|
|
11
|
+
|
|
12
|
+
<ContentSet
|
|
13
|
+
id="set.stage-one"
|
|
14
|
+
title="Should stage one focus on a Vite single HTML artifact?"
|
|
15
|
+
columns={3}
|
|
16
|
+
>
|
|
17
|
+
<ContentSet.Item
|
|
18
|
+
id="vite"
|
|
19
|
+
title="Vite single HTML artifact"
|
|
20
|
+
badge="Recommended"
|
|
21
|
+
tone="positive"
|
|
22
|
+
emphasis="primary"
|
|
23
|
+
summary="Validate the shortest Markdown-native source to interactive HTML loop first."
|
|
24
|
+
>
|
|
25
|
+
### Tradeoffs
|
|
26
|
+
|
|
27
|
+
- Short feedback loop
|
|
28
|
+
- Fits one-off tool artifacts
|
|
29
|
+
- No docs-site navigation yet
|
|
30
|
+
</ContentSet.Item>
|
|
31
|
+
</ContentSet>
|
|
23
32
|
|
|
24
33
|
<ExportPanel
|
|
25
34
|
title="Export decision"
|
|
@@ -30,47 +39,171 @@ import { DecisionMatrix, ExportPanel } from "mdx-artifacts/react";
|
|
|
30
39
|
|
|
31
40
|
The CLI turns that MDX file into a self-contained HTML file.
|
|
32
41
|
|
|
42
|
+
## Authoring Philosophy
|
|
43
|
+
|
|
44
|
+
MDX Artifacts is a Markdown-native artifact system.
|
|
45
|
+
|
|
46
|
+
Source files should read like documents. Output files should behave like interactive HTML artifacts. Components should mark semantic islands inside the document, not replace the document with a large JSX configuration object.
|
|
47
|
+
|
|
48
|
+
Use this product boundary when making component and authoring decisions:
|
|
49
|
+
|
|
50
|
+
- Prefer native Markdown or MDX children for narrative content, explanations, long descriptions, lists, and reviewable prose.
|
|
51
|
+
- Prefer semantic components for structured workflow regions such as decisions, comparisons, code review, export handoff, and interactive state.
|
|
52
|
+
- Prefer props for stable ids, short labels, enum-like settings, layout controls, machine-readable values, and genuinely structured data.
|
|
53
|
+
- Do not move all semantics into an implicit Markdown parser. Headings, lists, and tables should not secretly become component data unless a component explicitly owns that slot.
|
|
54
|
+
- Do not turn artifact sources into React application code. If an artifact needs arbitrary stateful UI, project-specific CSS, or app-level interaction, use a dedicated web artifact builder or a project local component.
|
|
55
|
+
|
|
56
|
+
This means new component APIs should usually be children-first for human-readable content and props-first for machine-readable configuration.
|
|
57
|
+
|
|
58
|
+
## When To Use It
|
|
59
|
+
|
|
60
|
+
Use MDX Artifacts when an agent should create a local, reviewable MDX artifact with semantic React components, structured validation, and a standalone HTML output.
|
|
61
|
+
|
|
62
|
+
It is a good fit for:
|
|
63
|
+
|
|
64
|
+
- decision reports, option comparisons, code review handoffs, and implementation plans
|
|
65
|
+
- artifacts that should remain readable as MDX source
|
|
66
|
+
- workflows where agents should query component metadata and validate before build
|
|
67
|
+
- project-local React components that supplement, but do not replace, the MDX document
|
|
68
|
+
|
|
69
|
+
Do not use it for ordinary README files, simple notes, raw HTML pages, full web apps, or artifacts that require arbitrary application state and custom runtime code.
|
|
70
|
+
|
|
71
|
+
## 0.2.0 Migration Notes
|
|
72
|
+
|
|
73
|
+
`DecisionMatrix` and `OptionGrid` are deprecated compatibility components. Existing MDX can still render, but new artifacts should use `ContentSet` for grouped content cards and `ContentItem` for standalone content cards.
|
|
74
|
+
|
|
75
|
+
This release makes the content authoring model more consistent: readable explanation, rationale, pros, cons, risks, and tradeoffs should live in MDX children instead of object-array props.
|
|
76
|
+
|
|
77
|
+
Use:
|
|
78
|
+
|
|
79
|
+
```mdx
|
|
80
|
+
<ContentSet id="set.path" title="Choose the implementation path" columns={3}>
|
|
81
|
+
<ContentSet.Item
|
|
82
|
+
id="path-a"
|
|
83
|
+
title="Path A"
|
|
84
|
+
badge="Recommended"
|
|
85
|
+
tone="positive"
|
|
86
|
+
emphasis="primary"
|
|
87
|
+
summary="Best first step."
|
|
88
|
+
>
|
|
89
|
+
### Tradeoffs
|
|
90
|
+
|
|
91
|
+
- Keeps the MDX source readable
|
|
92
|
+
- Lets long rationale stay in Markdown
|
|
93
|
+
</ContentSet.Item>
|
|
94
|
+
</ContentSet>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Do not use `DecisionMatrix`, `DecisionMatrix.Option`, `OptionGrid`, `OptionGrid.Item`, or `options={[...]}` for new artifacts. The `validate` command warns when deprecated compatibility components or older props such as `question`, `name`, `intent`, `pros`, `cons`, `risks`, `confidence`, `verdict`, or `tradeoffs` are found.
|
|
98
|
+
|
|
33
99
|
## Current Scope
|
|
34
100
|
|
|
35
101
|
The first stage focuses on the smallest useful loop:
|
|
36
102
|
|
|
37
|
-
1. `
|
|
38
|
-
2. `
|
|
39
|
-
3. `
|
|
40
|
-
4. `components` exposes component props and examples for agents.
|
|
103
|
+
1. The configured `docsDir` is the MDX source root. The default is `artifact-docs/`.
|
|
104
|
+
2. `mdx-artifacts/react` exports high-level artifact components.
|
|
105
|
+
3. The `mdx-artifacts` CLI provides `init`, `components`, `validate`, `dev`, `build`, and narrow review-state commands.
|
|
106
|
+
4. `mdx-artifacts components` exposes component props and examples for agents.
|
|
41
107
|
5. `build` outputs a standalone HTML artifact.
|
|
42
108
|
|
|
43
109
|
Astro is intentionally not part of the core yet. It can become a later adapter for long-lived docs sites.
|
|
44
110
|
|
|
45
|
-
## Install
|
|
111
|
+
## Install From npm
|
|
46
112
|
|
|
47
|
-
|
|
113
|
+
For npm users, the shortest first run is:
|
|
48
114
|
|
|
49
115
|
```bash
|
|
50
|
-
|
|
116
|
+
npm install --save-dev mdx-artifacts
|
|
117
|
+
npx mdx-artifacts init
|
|
118
|
+
npx mdx-artifacts validate artifact-docs/examples/hello.mdx
|
|
119
|
+
npx mdx-artifacts build artifact-docs/examples/hello.mdx
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The final command writes:
|
|
123
|
+
|
|
124
|
+
```text
|
|
125
|
+
dist/artifacts/examples/hello.html
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Install with pnpm in a project that should build local artifacts:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
pnpm add -D mdx-artifacts
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
In a pnpm workspace root, make the workspace-root install explicit:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
pnpm add -Dw mdx-artifacts
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
React and React DOM are peer dependencies. Modern package managers usually install them automatically for this dev-tool workflow. If peer dependency auto-install is disabled in your project, install them explicitly:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
npm install --save-dev mdx-artifacts react react-dom
|
|
144
|
+
pnpm add -D mdx-artifacts react react-dom
|
|
51
145
|
```
|
|
52
146
|
|
|
53
147
|
Initialize a workspace:
|
|
54
148
|
|
|
55
149
|
```bash
|
|
56
|
-
|
|
150
|
+
npx mdx-artifacts init
|
|
151
|
+
pnpm exec mdx-artifacts init
|
|
57
152
|
```
|
|
58
153
|
|
|
59
|
-
|
|
154
|
+
Interactive init uses numbered choices. Press Enter to accept defaults:
|
|
60
155
|
|
|
61
156
|
```text
|
|
62
|
-
artifact
|
|
63
|
-
artifact-docs/
|
|
157
|
+
Where should MDX artifact source files live?
|
|
158
|
+
1. ./artifact-docs/ (default)
|
|
159
|
+
2. Enter a custom directory
|
|
160
|
+
Select an option (1)
|
|
161
|
+
|
|
162
|
+
Use project-local React components?
|
|
163
|
+
Adds a Tailwind source directory; it does not auto-register components.
|
|
164
|
+
1. No (default)
|
|
165
|
+
2. Yes, choose a project-local component source directory
|
|
166
|
+
Select an option (1)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
For non-interactive setup, pass the project structure explicitly:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
pnpm exec mdx-artifacts init --yes --docs-dir docs/artifacts --components-dir artifact-components --agent codex
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
After init, the CLI prints a summary of the selected directories, generated guidance files, and next validation/build commands. The scaffold includes:
|
|
176
|
+
|
|
177
|
+
```text
|
|
178
|
+
mdx-artifacts.config.mjs
|
|
179
|
+
<docsDir>/examples/hello.mdx
|
|
64
180
|
agents/AGENTS.snippet.md
|
|
65
181
|
```
|
|
66
182
|
|
|
67
|
-
|
|
183
|
+
`components-dir` is a project-local component source directory. It is added to `tailwindSources` for Tailwind class discovery, but it does not automatically register components or make components available through `mdx-artifacts components`.
|
|
184
|
+
|
|
185
|
+
### Agent Guidance
|
|
186
|
+
|
|
187
|
+
`mdx-artifacts init --agent <agent>` can install project-local writing guidance for coding agents:
|
|
188
|
+
|
|
189
|
+
```text
|
|
190
|
+
--agent codex .agents/skills/mdx-artifacts/SKILL.md
|
|
191
|
+
--agent claude-code .claude/skills/mdx-artifacts/SKILL.md
|
|
192
|
+
--agent cursor .cursor/rules/mdx-artifacts.mdc
|
|
193
|
+
--agent all all supported project-local guidance files
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
The generated guidance tells agents when to use MDX Artifacts, where to place `.mdx` files, how to query component metadata, how to handle local resources, and to run `mdx-artifacts validate` before build. Keep the CLI registry as the source of truth for component props instead of copying long component metadata into agent instructions.
|
|
197
|
+
|
|
198
|
+
Build the initialized example. For the default init choices, the example lives under `artifact-docs/`:
|
|
68
199
|
|
|
69
200
|
```bash
|
|
70
|
-
pnpm exec
|
|
71
|
-
pnpm exec
|
|
201
|
+
pnpm exec mdx-artifacts validate artifact-docs/examples/hello.mdx
|
|
202
|
+
pnpm exec mdx-artifacts build artifact-docs/examples/hello.mdx
|
|
72
203
|
```
|
|
73
204
|
|
|
205
|
+
If you initialized with a custom `--docs-dir`, use `<docsDir>/examples/hello.mdx` instead.
|
|
206
|
+
|
|
74
207
|
Default output:
|
|
75
208
|
|
|
76
209
|
```text
|
|
@@ -82,20 +215,20 @@ dist/artifacts/examples/hello.html
|
|
|
82
215
|
Inspect available components:
|
|
83
216
|
|
|
84
217
|
```bash
|
|
85
|
-
pnpm exec
|
|
86
|
-
pnpm exec
|
|
87
|
-
pnpm exec
|
|
218
|
+
pnpm exec mdx-artifacts components
|
|
219
|
+
pnpm exec mdx-artifacts components ExportPanel
|
|
220
|
+
pnpm exec mdx-artifacts components --json
|
|
88
221
|
```
|
|
89
222
|
|
|
90
223
|
Build one MDX file:
|
|
91
224
|
|
|
92
225
|
```bash
|
|
93
|
-
pnpm exec
|
|
226
|
+
pnpm exec mdx-artifacts build artifact-docs/examples/hello.mdx
|
|
94
227
|
```
|
|
95
228
|
|
|
96
229
|
## Review State
|
|
97
230
|
|
|
98
|
-
|
|
231
|
+
MDX Artifacts 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
232
|
|
|
100
233
|
```text
|
|
101
234
|
artifact-docs/examples/hello.mdx
|
|
@@ -105,7 +238,7 @@ artifact-docs/examples/hello.state.json
|
|
|
105
238
|
Use stable anchors in MDX so review threads can survive edits:
|
|
106
239
|
|
|
107
240
|
```mdx
|
|
108
|
-
import {
|
|
241
|
+
import { ContentSet, Section } from "mdx-artifacts/react";
|
|
109
242
|
|
|
110
243
|
<Section id="section.context">
|
|
111
244
|
|
|
@@ -115,32 +248,30 @@ Native MDX prose can be reviewed through the section anchor.
|
|
|
115
248
|
|
|
116
249
|
</Section>
|
|
117
250
|
|
|
118
|
-
<
|
|
119
|
-
id="
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
]}
|
|
128
|
-
/>
|
|
251
|
+
<ContentSet
|
|
252
|
+
id="set.stage-one"
|
|
253
|
+
title="Should this artifact use stable anchors?"
|
|
254
|
+
columns={2}
|
|
255
|
+
>
|
|
256
|
+
<ContentSet.Item id="yes" title="Use stable anchors" badge="Recommended" tone="positive" emphasis="primary">
|
|
257
|
+
Stable child anchors keep review threads attached across edits.
|
|
258
|
+
</ContentSet.Item>
|
|
259
|
+
</ContentSet>
|
|
129
260
|
```
|
|
130
261
|
|
|
131
262
|
Agents can add a user thread, append an assistant reply, and validate that saved threads still point at anchors in the current MDX:
|
|
132
263
|
|
|
133
264
|
```bash
|
|
134
|
-
pnpm exec
|
|
135
|
-
--anchor
|
|
265
|
+
pnpm exec mdx-artifacts review add artifact-docs/examples/hello.mdx \
|
|
266
|
+
--anchor set.stage-one \
|
|
136
267
|
--body "Clarify this decision."
|
|
137
268
|
|
|
138
|
-
pnpm exec
|
|
139
|
-
--thread
|
|
269
|
+
pnpm exec mdx-artifacts review reply artifact-docs/examples/hello.mdx \
|
|
270
|
+
--thread thr_set_stage_one \
|
|
140
271
|
--body "Updated the decision copy." \
|
|
141
272
|
--status resolved
|
|
142
273
|
|
|
143
|
-
pnpm exec
|
|
274
|
+
pnpm exec mdx-artifacts review validate artifact-docs/examples/hello.mdx
|
|
144
275
|
```
|
|
145
276
|
|
|
146
277
|
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.
|
|
@@ -155,6 +286,18 @@ missing: 1
|
|
|
155
286
|
|
|
156
287
|
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
288
|
|
|
289
|
+
## Local Resource And Security Model
|
|
290
|
+
|
|
291
|
+
MDX Artifacts is intended for local, reviewable artifacts generated inside a project workspace.
|
|
292
|
+
|
|
293
|
+
- Local resources that go through the resource policy must stay inside the project root.
|
|
294
|
+
- Remote URLs, `~` paths, and project-root escapes are rejected for resources that go through the resource policy.
|
|
295
|
+
- Today, `validate` checks configured `styles` resources; data, artifact, and component-module references can use the same policy as those features become first-class inputs.
|
|
296
|
+
- `tailwindSources` is for Tailwind class discovery and should point only at project-local source files. It is a config convention, not component registration.
|
|
297
|
+
- `componentsDir` is a source location for user-owned React components, not a component registry.
|
|
298
|
+
- Raw React imports are still normal MDX imports, so use project-local components only when a semantic built-in component is not enough.
|
|
299
|
+
- Run `mdx-artifacts validate <file.mdx>` before build to catch supported path, component, and diagnostic issues before producing HTML.
|
|
300
|
+
|
|
158
301
|
## Repository Development
|
|
159
302
|
|
|
160
303
|
Install dependencies:
|
|
@@ -167,8 +310,8 @@ Validate and build the repository example artifact:
|
|
|
167
310
|
|
|
168
311
|
```bash
|
|
169
312
|
pnpm check
|
|
170
|
-
pnpm
|
|
171
|
-
pnpm
|
|
313
|
+
pnpm mdx-artifacts:validate
|
|
314
|
+
pnpm mdx-artifacts:build
|
|
172
315
|
```
|
|
173
316
|
|
|
174
317
|
Develop components in Storybook:
|
|
@@ -177,45 +320,64 @@ Develop components in Storybook:
|
|
|
177
320
|
pnpm storybook
|
|
178
321
|
```
|
|
179
322
|
|
|
180
|
-
Storybook is only for component development. The artifact workflow is still verified through `
|
|
323
|
+
Storybook is only for component development. The artifact workflow is still verified through `mdx-artifacts validate/build`.
|
|
181
324
|
|
|
182
325
|
Run the test baseline:
|
|
183
326
|
|
|
184
327
|
```bash
|
|
185
328
|
pnpm test
|
|
186
329
|
pnpm typecheck
|
|
187
|
-
pnpm
|
|
330
|
+
pnpm mdx-artifacts:validate
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
Run the lightweight release check before publishing or after package metadata, public docs, examples, or agent guidance changes:
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
pnpm release:check
|
|
188
337
|
```
|
|
189
338
|
|
|
190
|
-
Run the package smoke test before publishing:
|
|
339
|
+
Run the package smoke test before publishing or after package boundary, CLI output, config loading, scaffold, dependency, or build output changes:
|
|
191
340
|
|
|
192
341
|
```bash
|
|
193
342
|
pnpm pack:smoke
|
|
194
343
|
```
|
|
195
344
|
|
|
345
|
+
For a final manual pre-publish check, run:
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
npm pack --dry-run --cache /private/tmp/mdx-artifacts-npm-cache
|
|
349
|
+
```
|
|
350
|
+
|
|
196
351
|
## Style Injection
|
|
197
352
|
|
|
198
|
-
|
|
353
|
+
MDX Artifacts injects default styles by default. Users can add brand styles through `mdx-artifacts.config.mjs`:
|
|
199
354
|
|
|
200
355
|
```js
|
|
201
|
-
/** @type {import("mdx-artifacts").
|
|
356
|
+
/** @type {import("mdx-artifacts").MdxArtifactsConfig} */
|
|
202
357
|
const config = {
|
|
203
358
|
docsDir: "artifact-docs",
|
|
204
359
|
outDir: "dist/artifacts",
|
|
205
360
|
includeDefaultStyles: true,
|
|
206
|
-
styles: ["artifact-theme.css"]
|
|
361
|
+
styles: ["artifact-theme.css"],
|
|
362
|
+
tailwindSources: ["artifact-components/**/*.{ts,tsx}"]
|
|
207
363
|
};
|
|
208
364
|
|
|
209
365
|
export default config;
|
|
210
366
|
```
|
|
211
367
|
|
|
212
|
-
Custom styles are imported after the default styles, so they can override CSS variables or `ak-*` classes. Set `includeDefaultStyles: false` to
|
|
368
|
+
Custom styles are imported after the default styles, so they can override CSS variables or `ak-*` classes. Set `includeDefaultStyles: false` to disable MDX Artifacts default styles.
|
|
369
|
+
|
|
370
|
+
The CLI automatically registers the current MDX file as a Tailwind source, so Tailwind utility classes inside local MDX components are generated during artifact builds. Use `tailwindSources` for project-local component files that are imported by MDX and also contain Tailwind classes.
|
|
213
371
|
|
|
214
372
|
## Design Principles
|
|
215
373
|
|
|
216
374
|
- Source files are MDX, not raw HTML.
|
|
375
|
+
- Source should stay Markdown-native; output can be richer, interactive HTML.
|
|
376
|
+
- Components are semantic islands in the document, not the whole authoring model.
|
|
217
377
|
- Component APIs should be semantic and self-describing.
|
|
218
|
-
-
|
|
378
|
+
- Human-readable body content should prefer MDX children or explicit slots over long string props.
|
|
379
|
+
- Props should carry ids, short labels, variants, layout controls, and structured data.
|
|
380
|
+
- Interactive artifacts should provide an export path; `validate` warns when one is missing.
|
|
219
381
|
- Bulky data should live in adjacent JSON files instead of JSX props.
|
|
220
382
|
- Core components stay React/TypeScript and should be reusable from Vite, Astro, or artifact builders.
|
|
221
383
|
- Tailwind is an internal styling build tool; the final artifact still inlines CSS.
|
|
@@ -230,5 +392,7 @@ Custom styles are imported after the default styles, so they can override CSS va
|
|
|
230
392
|
- [Naming conventions](docs/naming.md)
|
|
231
393
|
- [Component protocol](docs/component-protocol.md)
|
|
232
394
|
- [Component taxonomy](docs/component-taxonomy.md)
|
|
395
|
+
- [CLI structure](docs/cli-structure.md)
|
|
233
396
|
- [Testing](docs/testing.md)
|
|
397
|
+
- [Releasing](docs/releasing.md)
|
|
234
398
|
- [Chinese README](README.zh-CN.md)
|