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.
Files changed (142) hide show
  1. package/README.md +224 -60
  2. package/README.zh-CN.md +299 -42
  3. package/agents/AGENTS.snippet.md +21 -10
  4. package/artifact-docs/examples/commentable-feedback.mdx +76 -70
  5. package/artifact-docs/examples/decision-matrix.mdx +122 -50
  6. package/artifact-docs/examples/layout-composition.mdx +106 -128
  7. package/artifact-docs/examples/streamlit-style-mixed.mdx +100 -85
  8. package/dist/lib/cli/{build.js → commands/build.js} +2 -2
  9. package/dist/lib/cli/{components.js → commands/components.js} +19 -3
  10. package/dist/lib/cli/{dev.js → commands/dev.js} +2 -2
  11. package/dist/lib/cli/commands/interactions.d.ts +2 -0
  12. package/dist/lib/cli/commands/interactions.js +280 -0
  13. package/dist/lib/cli/commands/review.d.ts +1 -0
  14. package/dist/lib/cli/commands/review.js +171 -0
  15. package/dist/lib/cli/commands/scaffold.d.ts +16 -0
  16. package/dist/lib/cli/commands/scaffold.js +440 -0
  17. package/dist/lib/cli/commands/validate.d.ts +18 -0
  18. package/dist/lib/cli/commands/validate.js +311 -0
  19. package/dist/lib/cli/config/config.d.ts +2 -0
  20. package/dist/lib/cli/{config.js → config/config.js} +3 -2
  21. package/dist/lib/cli/{types.d.ts → config/types.d.ts} +2 -1
  22. package/dist/lib/cli/{vite-artifact.d.ts → dev-server/vite-artifact.d.ts} +3 -3
  23. package/dist/lib/cli/dev-server/vite-artifact.js +415 -0
  24. package/dist/lib/cli/diagnostics/diagnostics.d.ts +11 -0
  25. package/dist/lib/cli/diagnostics/diagnostics.js +1 -0
  26. package/dist/lib/cli/index.js +39 -18
  27. package/dist/lib/cli/mdx/sortable-list.d.ts +14 -0
  28. package/dist/lib/cli/mdx/sortable-list.js +520 -0
  29. package/dist/lib/cli/resources/resource-policy.d.ts +15 -0
  30. package/dist/lib/cli/resources/resource-policy.js +46 -0
  31. package/dist/lib/cli/resources/safe-path.d.ts +13 -0
  32. package/dist/lib/cli/resources/safe-path.js +55 -0
  33. package/dist/lib/cli/services/interaction-service.d.ts +40 -0
  34. package/dist/lib/cli/services/interaction-service.js +226 -0
  35. package/dist/lib/cli/services/review.d.ts +43 -0
  36. package/dist/lib/cli/{review.js → services/review.js} +34 -172
  37. package/dist/lib/react/{components → composites/comparison-set}/ComparisonSet.d.ts +1 -1
  38. package/dist/lib/react/{components → composites/comparison-set}/ComparisonSet.js +3 -3
  39. package/dist/lib/react/composites/comparison-set/index.d.ts +2 -0
  40. package/dist/lib/react/composites/comparison-set/index.js +1 -0
  41. package/dist/lib/react/composites/content-set/ContentItem.d.ts +37 -0
  42. package/dist/lib/react/composites/content-set/ContentItem.js +49 -0
  43. package/dist/lib/react/composites/content-set/index.d.ts +2 -0
  44. package/dist/lib/react/composites/content-set/index.js +1 -0
  45. package/dist/lib/react/{components → composites/export-panel}/ExportPanel.js +2 -2
  46. package/dist/lib/react/composites/export-panel/index.d.ts +2 -0
  47. package/dist/lib/react/composites/export-panel/index.js +1 -0
  48. package/dist/lib/react/{components → composites/section}/Section.js +1 -1
  49. package/dist/lib/react/composites/section/index.d.ts +2 -0
  50. package/dist/lib/react/composites/section/index.js +1 -0
  51. package/dist/lib/react/index.d.ts +36 -31
  52. package/dist/lib/react/index.js +18 -15
  53. package/dist/lib/react/interactions/artifact-state/index.d.ts +1 -0
  54. package/dist/lib/react/interactions/artifact-state/index.js +1 -0
  55. package/dist/lib/react/{components → interactions/comments}/Comments.d.ts +2 -2
  56. package/dist/lib/react/{components → interactions/comments}/Comments.js +3 -3
  57. package/dist/lib/react/interactions/comments/index.d.ts +1 -0
  58. package/dist/lib/react/interactions/comments/index.js +1 -0
  59. package/dist/lib/react/interactions/sortable-list/SortableList.d.ts +29 -0
  60. package/dist/lib/react/interactions/sortable-list/SortableList.js +282 -0
  61. package/dist/lib/react/interactions/sortable-list/index.d.ts +1 -0
  62. package/dist/lib/react/interactions/sortable-list/index.js +1 -0
  63. package/dist/lib/react/layout/layout-primitives/index.d.ts +2 -0
  64. package/dist/lib/react/layout/layout-primitives/index.js +1 -0
  65. package/dist/lib/react/legacy/LegacyContentComponents.d.ts +65 -0
  66. package/dist/lib/react/legacy/LegacyContentComponents.js +26 -0
  67. package/dist/lib/react/mdx-components.d.ts +5 -0
  68. package/dist/lib/react/mdx-components.js +38 -0
  69. package/dist/lib/react/{components → primitives/annotated-code}/AnnotatedCode.d.ts +1 -1
  70. package/dist/lib/react/{components → primitives/annotated-code}/AnnotatedCode.js +5 -5
  71. package/dist/lib/react/primitives/annotated-code/index.d.ts +2 -0
  72. package/dist/lib/react/primitives/annotated-code/index.js +1 -0
  73. package/dist/lib/react/primitives/callout/Callout.d.ts +11 -0
  74. package/dist/lib/react/{components → primitives/callout}/Callout.js +9 -6
  75. package/dist/lib/react/primitives/callout/index.d.ts +2 -0
  76. package/dist/lib/react/primitives/callout/index.js +1 -0
  77. package/dist/lib/react/primitives/code-block/CodeBlock.d.ts +20 -0
  78. package/dist/lib/react/primitives/code-block/CodeBlock.js +32 -0
  79. package/dist/lib/react/primitives/code-block/index.d.ts +2 -0
  80. package/dist/lib/react/primitives/code-block/index.js +1 -0
  81. package/dist/lib/react/primitives/code-surface/CodeSurface.d.ts +11 -0
  82. package/dist/lib/react/primitives/code-surface/CodeSurface.js +34 -0
  83. package/dist/lib/react/primitives/code-surface/index.d.ts +2 -0
  84. package/dist/lib/react/primitives/code-surface/index.js +1 -0
  85. package/dist/lib/react/primitives/diff-block/DiffBlock.js +25 -0
  86. package/dist/lib/react/primitives/diff-block/index.d.ts +2 -0
  87. package/dist/lib/react/primitives/diff-block/index.js +1 -0
  88. package/dist/lib/react/{components → primitives/inline-text}/InlineText.d.ts +4 -2
  89. package/dist/lib/react/primitives/inline-text/InlineText.js +28 -0
  90. package/dist/lib/react/primitives/inline-text/index.d.ts +2 -0
  91. package/dist/lib/react/primitives/inline-text/index.js +1 -0
  92. package/dist/lib/react/primitives/markdown-body/MarkdownBody.d.ts +9 -0
  93. package/dist/lib/react/primitives/markdown-body/MarkdownBody.js +49 -0
  94. package/dist/lib/react/primitives/markdown-body/index.d.ts +2 -0
  95. package/dist/lib/react/primitives/markdown-body/index.js +1 -0
  96. package/dist/lib/react/primitives/severity-badge/index.d.ts +2 -0
  97. package/dist/lib/react/primitives/severity-badge/index.js +1 -0
  98. package/dist/lib/react/registry.d.ts +10 -0
  99. package/dist/lib/react/registry.js +505 -210
  100. package/dist/lib/react/styles.css +490 -38
  101. package/docs/cli-structure.md +141 -0
  102. package/docs/component-protocol.md +199 -33
  103. package/docs/component-taxonomy.md +40 -4
  104. package/docs/design.md +42 -21
  105. package/docs/design.zh-CN.md +41 -21
  106. package/docs/naming.md +17 -7
  107. package/docs/releasing.md +132 -0
  108. package/docs/testing.md +35 -10
  109. package/package.json +9 -7
  110. package/dist/lib/cli/config.d.ts +0 -2
  111. package/dist/lib/cli/review.d.ts +0 -33
  112. package/dist/lib/cli/scaffold.d.ts +0 -1
  113. package/dist/lib/cli/scaffold.js +0 -56
  114. package/dist/lib/cli/validate.d.ts +0 -6
  115. package/dist/lib/cli/validate.js +0 -79
  116. package/dist/lib/cli/vite-artifact.js +0 -237
  117. package/dist/lib/react/components/Callout.d.ts +0 -9
  118. package/dist/lib/react/components/CodeBlock.d.ts +0 -10
  119. package/dist/lib/react/components/CodeBlock.js +0 -28
  120. package/dist/lib/react/components/DecisionMatrix.d.ts +0 -16
  121. package/dist/lib/react/components/DecisionMatrix.js +0 -27
  122. package/dist/lib/react/components/DiffBlock.js +0 -24
  123. package/dist/lib/react/components/InlineText.js +0 -18
  124. package/dist/lib/react/components/MarkdownBody.d.ts +0 -7
  125. package/dist/lib/react/components/MarkdownBody.js +0 -36
  126. package/dist/lib/react/components/OptionGrid.d.ts +0 -13
  127. package/dist/lib/react/components/OptionGrid.js +0 -21
  128. /package/dist/lib/cli/{build.d.ts → commands/build.d.ts} +0 -0
  129. /package/dist/lib/cli/{components.d.ts → commands/components.d.ts} +0 -0
  130. /package/dist/lib/cli/{dev.d.ts → commands/dev.d.ts} +0 -0
  131. /package/dist/lib/cli/{types.js → config/types.js} +0 -0
  132. /package/dist/lib/cli/{artifact-state.d.ts → state/artifact-state.d.ts} +0 -0
  133. /package/dist/lib/cli/{artifact-state.js → state/artifact-state.js} +0 -0
  134. /package/dist/lib/react/{components → composites/export-panel}/ExportPanel.d.ts +0 -0
  135. /package/dist/lib/react/{components → composites/section}/Section.d.ts +0 -0
  136. /package/dist/lib/react/{components → interactions/artifact-state}/ArtifactState.d.ts +0 -0
  137. /package/dist/lib/react/{components → interactions/artifact-state}/ArtifactState.js +0 -0
  138. /package/dist/lib/react/{components → layout/layout-primitives}/Layout.d.ts +0 -0
  139. /package/dist/lib/react/{components → layout/layout-primitives}/Layout.js +0 -0
  140. /package/dist/lib/react/{components → primitives/diff-block}/DiffBlock.d.ts +0 -0
  141. /package/dist/lib/react/{components → primitives/severity-badge}/SeverityBadge.d.ts +0 -0
  142. /package/dist/lib/react/{components → primitives/severity-badge}/SeverityBadge.js +0 -0
@@ -0,0 +1,141 @@
1
+ # CLI Structure
2
+
3
+ This document describes how the CLI source tree is organized and where new code should go.
4
+
5
+ The CLI entry remains `src/cli/index.ts`. It wires the command parser and delegates to command modules. Most implementation code should live below one of the focused subdirectories instead of growing inside the entry file.
6
+
7
+ ## Maintenance Summary
8
+
9
+ The current CLI structure is the result of two stabilization passes:
10
+
11
+ 1. The source tree was moved from a flat `src/cli` directory into command, service, MDX, state, dev-server, config, diagnostics, and resources boundaries.
12
+ 2. The interaction and review commands were split so command modules stay focused on argument parsing, terminal output, and exit-code behavior, while service modules own stateful workflow operations.
13
+ 3. Validation now emits structured diagnostics and resource checks share a project-root safety policy.
14
+
15
+ This means future CLI changes should start by identifying the real owner of the behavior:
16
+
17
+ - command shape and terminal output belong in `commands/`
18
+ - artifact state mutation belongs in `services/`
19
+ - persisted MDX source changes belong in `mdx/`
20
+ - browser-local endpoint handling belongs in `dev-server/`
21
+ - state file format and route helpers belong in `state/`
22
+ - config loading and config types belong in `config/`
23
+ - structured diagnostic types belong in `diagnostics/`
24
+ - local resource path safety and resource policy checks belong in `resources/`
25
+
26
+ Do not put reusable workflow logic into a command module just because the first caller is a CLI command. If the same behavior could be triggered by the dev server, an agent, or a future automation entry point, place it below `services/` and keep the command as a thin wrapper.
27
+
28
+ ## Directory Map
29
+
30
+ ```text
31
+ src/cli/
32
+ index.ts
33
+ commands/
34
+ config/
35
+ dev-server/
36
+ diagnostics/
37
+ mdx/
38
+ resources/
39
+ services/
40
+ state/
41
+ ```
42
+
43
+ | Directory | Responsibility | Examples |
44
+ |---|---|---|
45
+ | `commands/` | Command-level orchestration for each public CLI command. | `build`, `components`, `dev`, `interactions`, `review`, `scaffold`, `validate` |
46
+ | `config/` | Shared CLI config loading and public config types. | `loadMdxArtifactsConfig`, `MdxArtifactsConfig` |
47
+ | `dev-server/` | Vite dev server integration and browser-facing dev endpoints. | artifact dev server middleware |
48
+ | `diagnostics/` | Shared structured diagnostic types used by validation and resource checks. | `ArtifactDiagnostic` |
49
+ | `mdx/` | MDX source updates, parsing helpers, and document mutation helpers. | `sortable-list` source patching |
50
+ | `resources/` | Project-root resource safety and resource policy diagnostics. | safe path checks, resource policy checks |
51
+ | `services/` | Reusable CLI workflows that sit below commands but above low-level helpers. | interaction and review operation handling |
52
+ | `state/` | Artifact state file IO and state-shape helpers. | artifact state snapshots |
53
+
54
+ ## Boundaries
55
+
56
+ Command modules should stay thin. They may parse arguments, call shared services, print concise CLI output, and return an exit code. They should not accumulate reusable state, MDX mutation, or dev server internals.
57
+
58
+ Service modules can own workflow behavior that is shared by commands, the dev server, or future automation entry points. A service should not print CLI output directly unless the output is part of its public contract.
59
+
60
+ MDX modules should keep document-level mutations close to the syntax they operate on. When a behavior changes persisted artifact source, prefer placing that logic under `mdx/` and calling it from a command or service.
61
+
62
+ Current examples:
63
+
64
+ - `commands/interactions.ts` parses interaction CLI arguments and formats CLI output.
65
+ - `services/interaction-service.ts` owns SortableList runtime overlay writes and source promotion.
66
+ - `mdx/sortable-list.ts` owns SortableList-specific MDX source inspection and patching.
67
+ - `commands/review.ts` parses review CLI arguments, formats review output, and owns validate exit-code behavior.
68
+ - `services/review.ts` owns review thread add, reply, validation, state writes, and anchor discovery.
69
+
70
+ State modules should own local state file formats and persistence helpers. They should not know about command names, terminal output, or Vite middleware.
71
+
72
+ Dev server modules should own runtime endpoints, Vite configuration, and browser integration. They may call services or state helpers, but should not become the source of truth for persisted document changes.
73
+
74
+ Config modules should remain small and stable. Runtime UI components may import config types, but should not import command or service modules.
75
+
76
+ Diagnostics modules should stay data-focused. They define result shapes that commands, validation, resource checks, and future agent repair loops can consume without depending on terminal formatting.
77
+
78
+ Resources modules should own path safety and resource policy decisions. They may return diagnostics, but they should not read arbitrary MDX import graphs or turn artifacts into a data-loading framework.
79
+
80
+ ## Import Direction
81
+
82
+ Prefer this dependency direction:
83
+
84
+ ```text
85
+ index.ts
86
+ -> commands/
87
+ -> services/
88
+ -> config/
89
+ -> diagnostics/
90
+ -> resources/
91
+ -> state/
92
+ -> mdx/
93
+ -> dev-server/
94
+
95
+ dev-server/
96
+ -> services/
97
+ -> state/
98
+ -> config/
99
+
100
+ services/
101
+ -> state/
102
+ -> mdx/
103
+ -> config/
104
+
105
+ resources/
106
+ -> diagnostics/
107
+ ```
108
+
109
+ Avoid importing from `commands/` into lower-level modules. If logic is needed outside a command, move it into `services/`, `mdx/`, `state/`, or `config/` first.
110
+
111
+ ## Tests
112
+
113
+ Keep tests next to the module they cover. For example:
114
+
115
+ ```text
116
+ src/cli/commands/components.test.ts
117
+ src/cli/state/artifact-state.test.ts
118
+ src/cli/dev-server/vite-artifact.test.ts
119
+ ```
120
+
121
+ Use focused CLI tests for command behavior and lower-level tests for state, MDX, and server helpers. Avoid testing the same behavior only through the CLI entry point when a narrower module test can cover it directly.
122
+
123
+ For commands backed by services, prefer this test split:
124
+
125
+ - Test the service directly for state mutations, MDX mutations, validation, and result shapes.
126
+ - Test the command for argument parsing, output formatting, and exit-code behavior.
127
+ - Test dev-server endpoints only for request validation, response shape, and whether they call the same service path as the CLI.
128
+
129
+ This keeps behavior coverage close to the owner while still protecting the public command shape.
130
+
131
+ ## Future Split Points
132
+
133
+ The current structure is only a directory boundary. It does not require every large module to be split immediately.
134
+
135
+ Good next split candidates:
136
+
137
+ - Keep interaction ordering and item mutation logic inside `services/` or `mdx/`, with commands and dev server endpoints calling that shared layer.
138
+ - Keep dev server HTTP endpoint code inside `dev-server/`, but move reusable artifact operations out when they become useful from CLI commands.
139
+ - Consider a dedicated interaction domain directory only after another interaction type, such as a board component, proves that `services/` plus focused `mdx/` modules are no longer enough.
140
+
141
+ The goal is to keep the CLI queryable and agent-friendly without turning it into a framework. Add a new directory only when an existing boundary is no longer enough.
@@ -9,19 +9,27 @@ Agents should write MDX that calls high-level components. They should not genera
9
9
  Typical source:
10
10
 
11
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
- />
12
+ import { ContentSet, ExportPanel } from "mdx-artifacts/react";
13
+
14
+ <ContentSet
15
+ id="set.stage-one"
16
+ title="Should stage one focus on a **single HTML artifact**?"
17
+ columns={3}
18
+ >
19
+ <ContentSet.Item
20
+ id="vite"
21
+ title="Vite artifact"
22
+ badge="Recommended"
23
+ tone="positive"
24
+ emphasis="primary"
25
+ summary="Validate the shortest artifact loop first."
26
+ >
27
+ ### Tradeoffs
28
+
29
+ - Short feedback loop
30
+ - No docs-site navigation yet
31
+ </ContentSet.Item>
32
+ </ContentSet>
25
33
 
26
34
  <ExportPanel
27
35
  value={{ recommendation: "Start with the single artifact loop." }}
@@ -42,14 +50,170 @@ import { DecisionMatrix, ExportPanel } from "mdx-artifacts/react";
42
50
  The CLI reads the same registry:
43
51
 
44
52
  ```bash
45
- artifact-kit components
46
- artifact-kit components DecisionMatrix
47
- artifact-kit components --json
53
+ mdx-artifacts components
54
+ mdx-artifacts components ContentSet
55
+ mdx-artifacts components --json
48
56
  ```
49
57
 
50
58
  When adding or changing a component, update the registry in the same change.
51
59
 
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:
60
+ ## Content Slots
61
+
62
+ Content components should use a small display-oriented slot model. Prefer these slots before inventing component-specific text props:
63
+
64
+ - `title`: required visible heading or item label.
65
+ - `badge`: optional short display label shown beside the title.
66
+ - `summary`: optional one-line explanation below the title.
67
+ - `children`: Markdown-rich body content for paragraphs, local headings, lists, quotes, and rationale.
68
+
69
+ Use props for short display structure. Use `children` for long explanations, pros and cons, tradeoff lists, risks, and any content that should remain readable in MDX diffs.
70
+
71
+ Do not parse headings inside `children` as a component protocol. Headings and lists in children are human-readable body structure, not machine-readable slot names.
72
+
73
+ Content components may add decorative icon slots when the component owns the icon placement and the semantic meaning remains in text, tone, and body content. See [Content Icon Slots](./content-icon-slots/README.md) for the phased policy.
74
+
75
+ ## Content Items
76
+
77
+ Use `ContentItem` when one reusable content block needs display slots, tone color, emphasis weight, a stable comment anchor, and Markdown-rich body content.
78
+
79
+ Use `ContentSet` when multiple same-kind content items should be displayed together:
80
+
81
+ ```mdx
82
+ <ContentSet id="set.authoring-paths" title="Authoring paths" layout="grid" columns={3} surface="subtle">
83
+ <ContentSet.Item
84
+ id="component-first"
85
+ title="Component-first"
86
+ badge="Recommended"
87
+ tone="positive"
88
+ emphasis="primary"
89
+ summary="Best for stable interaction and visual structure."
90
+ >
91
+ ### Tradeoffs
92
+
93
+ - Clear component boundaries
94
+ - Easy to debug
95
+ - Less natural for long prose
96
+ </ContentSet.Item>
97
+ </ContentSet>
98
+ ```
99
+
100
+ `tone` and `emphasis` are separate:
101
+
102
+ - `surface` controls the `ContentSet` container treatment: `plain`, `subtle`, or `outlined`.
103
+ - `surface` is not semantic color. Use it to decide whether the group should read as document flow, a soft section, or a bounded section.
104
+ - `tone` controls semantic color: `neutral`, `info`, `positive`, `warning`, `danger`, or `accent`.
105
+ - `emphasis` controls structural weight: `default`, `primary`, or `subtle`.
106
+ - `badge` is visible text only. It does not choose color by itself.
107
+ - `emphasis="subtle"` may mute the badge and summary, but body children should remain readable.
108
+
109
+ `ContentSet` is not a workspace or large layout container. Use it for one group of same-kind items. Use layout primitives such as `SplitPane` or `Columns` for multi-region artifacts.
110
+
111
+ ## Interactive Data Components
112
+
113
+ Use props-first APIs when a component owns user-controlled state such as sorting, board columns, selected values, or exportable edits.
114
+
115
+ `SortableList` is the current baseline:
116
+
117
+ ```mdx
118
+ <SortableList
119
+ id="list.launch-priority"
120
+ title="Launch priority"
121
+ summary="Drag items or use the controls to change the handoff order."
122
+ items={[
123
+ {
124
+ id: "contentset-api",
125
+ title: "Stabilize ContentSet API",
126
+ summary: "Must land before public examples.",
127
+ badge: "P0",
128
+ tags: ["api", "docs"]
129
+ }
130
+ ]}
131
+ />
132
+ ```
133
+
134
+ For interactive data components:
135
+
136
+ - Use structured props for stable ids, item labels, tags, and initial state.
137
+ - Keep item records short. Do not put long prose, Markdown lists, or narrative rationale into item data.
138
+ - Persist user-controlled state into artifact interactions when available.
139
+ - Treat MDX props as the authored truth and artifact interactions as the runtime overlay.
140
+ - Use `mdx-artifacts interactions inspect <file.mdx> <id>` to read the current truth from MDX plus the state overlay.
141
+ - Use `Section` beside the component for long explanation, criteria, or rationale.
142
+
143
+ `interactions inspect` is read-only. It reports the resolved order, ignores stale state ids that no longer exist in MDX, and appends new MDX item ids that are not yet present in the state overlay.
144
+
145
+ Use narrow CLI writes for runtime interaction state:
146
+
147
+ ```bash
148
+ mdx-artifacts interactions set-order artifact-docs/examples/decision-matrix.mdx \
149
+ list.next-priorities \
150
+ --ordered-ids example-output validate-build adapter-design
151
+
152
+ mdx-artifacts interactions reset artifact-docs/examples/decision-matrix.mdx \
153
+ list.next-priorities
154
+
155
+ mdx-artifacts interactions promote artifact-docs/examples/decision-matrix.mdx \
156
+ list.next-priorities
157
+
158
+ mdx-artifacts interactions add-item artifact-docs/examples/decision-matrix.mdx \
159
+ list.next-priorities \
160
+ --item-id docs --title "Update docs" --tags docs,protocol
161
+
162
+ mdx-artifacts interactions update-item artifact-docs/examples/decision-matrix.mdx \
163
+ list.next-priorities \
164
+ --item-id docs --summary "Document the workflow."
165
+
166
+ mdx-artifacts interactions remove-item artifact-docs/examples/decision-matrix.mdx \
167
+ list.next-priorities \
168
+ --item-id docs
169
+ ```
170
+
171
+ `set-order` writes only the runtime overlay and requires the ordered ids to match the current MDX item ids exactly. `reset` removes the runtime overlay for that component and falls back to the MDX default order. Neither command edits MDX.
172
+
173
+ `promote` is the explicit authored-truth write. It reorders the static MDX `items` array to match the current runtime overlay, then clears that component's overlay. It rejects stale or incomplete runtime ids instead of guessing.
174
+
175
+ The local dev server exposes the same interaction writes through narrow JSON endpoints:
176
+
177
+ - `POST /__artifact/interactions/set-order`
178
+ - `POST /__artifact/interactions/reset`
179
+ - `POST /__artifact/interactions/promote`
180
+ - `POST /__artifact/interactions/add-item`
181
+ - `POST /__artifact/interactions/update-item`
182
+ - `POST /__artifact/interactions/remove-item`
183
+
184
+ These endpoints are for local artifact tooling and reuse the same state and source write rules as the CLI.
185
+
186
+ Item editing commands and endpoints are authored-truth writes. They patch the static MDX `items` array and keep any existing runtime order overlay synchronized. They only support short structured fields: `title`, `summary`, `badge`, `tags`, and `disabled`.
187
+
188
+ When a local writable dev server is available, `SortableList` may expose a small item editor that calls these endpoints. Static artifacts remain read-only.
189
+
190
+ ## Authoring Kinds
191
+
192
+ Every public component should declare an authoring kind in `src/react/registry.ts`. This keeps the component API aligned with the product philosophy and gives `mdx-artifacts components <ComponentName>` enough guidance for agents.
193
+
194
+ Use these kinds:
195
+
196
+ | Kind | Use For | API Shape |
197
+ |---|---|---|
198
+ | `content-block` | Readable cards, options, findings, risks, callouts, and repeated items. | `title`, optional `badge`, optional `summary`, and Markdown-rich `children`. |
199
+ | `structured-renderer` | Code, diffs, line annotations, and other domain-shaped renderers. | Explicit structured props such as `code`, `lines`, or `annotations`. |
200
+ | `layout-primitive` | Arrangement-only helpers such as `Stack`, `Columns`, `Grid`, `SplitPane`, and `Frame`. | Layout props plus `children`; no workflow semantics. |
201
+ | `interactive-data` | User-controlled structured state such as sortable lists and future boards. | Structured props for initial state plus artifact interactions for user edits. |
202
+ | `export-editor` | Export docks, editors, and state handoff controls. | Structured `value`, state, format, or handoff props. |
203
+ | `review-boundary` | Comment layers, stable review sections, and fine-grained comment targets. | Stable ids or target ids plus the visible reviewed `children`. |
204
+
205
+ The kind is not a styling category. It tells an author where meaning belongs:
206
+
207
+ - `content-block`: keep long human-readable text in MDX children.
208
+ - `structured-renderer`: keep machine-shaped data in props.
209
+ - `layout-primitive`: do not encode domain meaning.
210
+ - `interactive-data`: keep stateful records structured and exportable.
211
+ - `export-editor`: keep handoff data structured.
212
+ - `review-boundary`: keep anchors durable and review targets meaningful.
213
+
214
+ Low-level shared rendering primitives, such as `CodeSurface`, may be exported for composition but should not be the primary authoring contract for agents. Native fenced code, `CodeBlock`, and `DiffBlock` can share one surface while keeping distinct semantics.
215
+
216
+ 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 `DiffLine[]` or `CodeAnnotation[]`, add a matching entry to the component's `types` metadata:
53
217
 
54
218
  ```ts
55
219
  {
@@ -80,7 +244,7 @@ Complex props must be self-describing through the registry. Do not rely on TypeS
80
244
  }
81
245
  ```
82
246
 
83
- The CLI must show these nested fields in `artifact-kit components <ComponentName>` and return them in `artifact-kit components <ComponentName> --json`.
247
+ The CLI must show these nested fields in `mdx-artifacts components <ComponentName>` and return them in `mdx-artifacts components <ComponentName> --json`.
84
248
 
85
249
  ## Extension Lifecycle
86
250
 
@@ -124,11 +288,11 @@ Preferred public code components:
124
288
 
125
289
  Examples:
126
290
 
127
- - `DecisionMatrix`
128
- - `DiffExplainer`
129
- - `PriorityBoard`
130
- - `PromptWorkbench`
131
- - `FeatureFlagEditor`
291
+ - `ContentSet`
292
+ - `ContentItem`
293
+ - `AnnotatedCode`
294
+ - `ExportPanel`
295
+ - future workflow recipes such as `DiffExplainer`, `PriorityBoard`, `PromptWorkbench`, and `FeatureFlagEditor`
132
296
 
133
297
  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
298
 
@@ -174,15 +338,17 @@ Content rendering primitives may grow beyond text and Markdown. Future candidate
174
338
  - Does not support tables, HTML, math, or code blocks.
175
339
  - Prefer component title props for main artifact structure.
176
340
 
177
- `DecisionMatrix`
341
+ `ContentItem`
178
342
 
179
- - Use for tradeoff comparison.
180
- - Text fields should remain short and scannable.
343
+ - Use for standalone readable content cards.
344
+ - Use `title`, optional `badge`, optional `summary`, `tone`, `emphasis`, and Markdown-rich children.
181
345
 
182
- `OptionGrid`
346
+ `ContentSet`
183
347
 
184
- - Use for side-by-side alternatives.
185
- - Each option should focus on intent and tradeoffs.
348
+ - Use for a group of same-kind content items.
349
+ - Use `ContentSet.Item` children.
350
+ - Use `layout="grid" | "stack"` and `columns={2 | 3 | 4 | 5}` for arrangement.
351
+ - Use `tone` for semantic color and `emphasis` for structural weight.
186
352
 
187
353
  `ExportPanel`
188
354
 
@@ -195,7 +361,7 @@ Reviewable content should use stable anchors:
195
361
 
196
362
  - Native MDX prose uses `Section id="..."`.
197
363
  - 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`.
364
+ - Component sub-items may derive child anchors from the parent id and item id, such as `set.stage-one.vite`.
199
365
 
200
366
  The source MDX remains the content truth. Review state lives in a sibling `.state.json` file and references anchors through `anchorId`.
201
367
 
@@ -241,16 +407,16 @@ Example state:
241
407
  Use narrow CLI writes for review state:
242
408
 
243
409
  ```bash
244
- artifact-kit review add artifact-docs/examples/decision-matrix.mdx \
410
+ mdx-artifacts review add artifact-docs/examples/decision-matrix.mdx \
245
411
  --anchor decision.stage-one \
246
412
  --body "Clarify why native MDX remains the default."
247
413
 
248
- artifact-kit review reply artifact-docs/examples/decision-matrix.mdx \
414
+ mdx-artifacts review reply artifact-docs/examples/decision-matrix.mdx \
249
415
  --thread thr_decision_stage_one \
250
416
  --body "Updated the decision copy." \
251
417
  --status resolved
252
418
 
253
- artifact-kit review validate artifact-docs/examples/decision-matrix.mdx
419
+ mdx-artifacts review validate artifact-docs/examples/decision-matrix.mdx
254
420
  ```
255
421
 
256
422
  `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.
@@ -48,6 +48,41 @@ The common risk is exposing too many `Card`, `Panel`, or ad hoc `Grid` shapes. T
48
48
 
49
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
50
 
51
+ ## Content Component Slot Model
52
+
53
+ Use the shared display slot model for readable content components that render repeated cards, items, options, findings, risks, or sections.
54
+
55
+ Default slots:
56
+
57
+ - `title`: the primary visible label.
58
+ - `badge`: an optional short status or category label beside the title.
59
+ - `summary`: an optional one-line explanation below the title.
60
+ - `children`: Markdown-rich body content for paragraphs, local headings, lists, quotes, risks, pros, cons, and rationale.
61
+
62
+ This slot model applies to `ContentItem` and `ContentSet.Item`. It should also be the default for future components such as `FindingCard`, `RiskList.Item`, `StatusReport.Section`, or `ImplementationPlan.Step`.
63
+
64
+ Do not apply the slot model blindly to every complex component:
65
+
66
+ - Structured renderers such as `CodeBlock`, `DiffBlock`, and `AnnotatedCode` should keep their domain schemas.
67
+ - Layout primitives such as `Stack`, `Columns`, `Grid`, `SplitPane`, and `Frame` should keep layout props and children.
68
+ - Export or editor components such as `ExportPanel` should keep state and handoff props.
69
+ - Document boundaries such as `Section` should stay focused on stable review anchors and native MDX children.
70
+
71
+ The test is whether the component is primarily a readable content block. If yes, use `title`, `badge`, `summary`, and `children`. If the component primarily renders structured data, controls layout, or exports state, keep its domain-specific schema.
72
+
73
+ ## Authoring Metadata
74
+
75
+ The registry records the same distinction through `authoring.kind`. This makes the taxonomy queryable from the CLI instead of leaving it only in prose docs.
76
+
77
+ | Authoring Kind | Current Components | Guidance |
78
+ |---|---|---|
79
+ | `content-block` | `InlineText`, `MarkdownBody`, `ContentItem`, `ContentSet`, `SeverityBadge`, `Callout`, `ComparisonSet` | Use short display props plus Markdown-rich children for readable body content. |
80
+ | `structured-renderer` | `CodeBlock`, `DiffBlock`, `AnnotatedCode` | Keep code, diff rows, and annotations in structured props. |
81
+ | `layout-primitive` | `Stack`, `Columns`, `Grid`, `SplitPane`, `Frame` | Arrange content without owning workflow meaning. |
82
+ | `interactive-data` | `SortableList` | Keep user-controlled state structured, short, and exportable through artifact interactions. |
83
+ | `export-editor` | `ExportPanel`, `CommentExport` | Keep handoff data structured and copy/export behavior explicit. |
84
+ | `review-boundary` | `CommentLayer`, `Section`, `CommentableBlock`, `CommentTarget` | Provide stable anchors around meaningful review targets. |
85
+
51
86
  ## Extension Lifecycle
52
87
 
53
88
  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.
@@ -102,6 +137,7 @@ Already available:
102
137
  - `MarkdownBody`: controlled block Markdown for component-local body copy.
103
138
  - `CodeBlock`: controlled code rendering with filename, language label, line numbers, and highlighted lines.
104
139
  - `DiffBlock`: structured diff rendering with add, remove, context rows, and compact effective line numbers.
140
+ - `CodeSurface`: low-level shared code frame used by native fenced code, `CodeBlock`, and `DiffBlock`; prefer author-facing components or native Markdown in artifact source.
105
141
  - `Callout`: semantic note, warning, recommendation, or risk block with controlled Markdown body copy.
106
142
  - `SeverityBadge`: compact severity, confidence, status, or risk label.
107
143
  - `AnnotatedCode`: code block with line-level annotations and severity labels.
@@ -114,7 +150,7 @@ Candidate foundation components:
114
150
  | `Callout` | Highlight warnings, assumptions, gotchas, or decisions. | Shipped | Useful across reports, code review, research, and plans. |
115
151
  | `SeverityBadge` | Show severity, confidence, status, or risk. | Shipped | Small but widely reused by review/report components. |
116
152
  | `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. |
153
+ | `CodeBlock` | Render code with language, filename, line numbers, copy affordance, and highlighted lines. | Shipped | Syntax highlighting can be added later without changing the authoring contract. |
118
154
  | `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
155
  | `Timeline` | Show ordered events, milestones, incidents, or plans. | P2 | Reusable for status reports, incidents, and implementation plans. |
120
156
  | `MetricCard` | Show compact numeric status with label and trend. | P2 | Useful for status reports and dashboards. |
@@ -130,8 +166,8 @@ Workflow recipes represent artifact-level jobs. They are usually better expresse
130
166
 
131
167
  Already available:
132
168
 
133
- - `DecisionMatrix`: compare options.
134
- - `OptionGrid`: show alternative directions side by side.
169
+ - `ContentSet`: group same-kind content items in a grid or stack, with optional container surface treatment.
170
+ - `ContentItem`: render a standalone readable content card.
135
171
 
136
172
  Candidate workflow recipes:
137
173
 
@@ -140,7 +176,7 @@ Candidate workflow recipes:
140
176
  | `DiffExplainer` | PR review with files, diff hunks, annotations, and findings. | P1 | `AnnotatedCode`, `SeverityBadge`, `Callout` |
141
177
  | `PRWriteup` | Reviewer-facing PR explanation with motivation, file tour, and review focus. | P2 | `Callout`, `AnnotatedCode` |
142
178
  | `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` |
179
+ | `ImplementationPlan` | Show milestones, risks, data flow, and handoff tasks. | P2 | `Timeline`, `Callout`, `ContentSet` |
144
180
  | `FeatureExplainer` | Explain how a repo feature works with TL;DR, files read, steps, code tabs, gotchas, and FAQ. | P2 | `DisclosureSteps`, `TabsPanel`, `AnnotatedCode`, `Callout` |
145
181
  | `StatusReport` | Weekly or project status summary with shipped/slipped/risks. | P3 | `MetricCard`, `Timeline`, `Callout` |
146
182
  | `IncidentReport` | Post-mortem with TL;DR, severity, timeline, root cause, impact, and action items. | P3 | `Timeline`, `AnnotatedCode`, `DataTable`, `ActionItemList`, `Callout` |
package/docs/design.md CHANGED
@@ -35,13 +35,14 @@ First-stage components:
35
35
 
36
36
  - `InlineText`: short text with controlled inline Markdown.
37
37
  - `MarkdownBody`: controlled component-local body Markdown.
38
- - `DecisionMatrix`: compare options.
39
- - `OptionGrid`: show alternatives side by side.
38
+ - `ContentItem`: standalone readable content card.
39
+ - `ContentSet`: grouped readable content cards with tone and emphasis.
40
+ - `SortableList`: draggable structured priority list with persisted order.
40
41
  - `ExportPanel`: export Markdown or JSON.
41
42
 
42
43
  Planned components:
43
44
 
44
- - `PriorityBoard`: drag-and-drop priority sorting.
45
+ - `KanbanBoard`: column-based card sorting.
45
46
  - `PromptWorkbench`: prompt variables and sample previews.
46
47
  - `DiffExplainer`: PR and diff explanation.
47
48
  - `ParameterTuner`: parameter tuning UI.
@@ -101,26 +102,29 @@ Second target: Astro docs site
101
102
 
102
103
  ## Styling Protocol
103
104
 
104
- Artifact Kit provides default CSS, but the default theme is not part of the core artifact contract.
105
+ MDX Artifacts provides default CSS, but the default theme is not part of the core artifact contract.
105
106
 
106
- Users can inject brand styles through `artifact-kit.config.mjs`:
107
+ Users can inject brand styles through `mdx-artifacts.config.mjs`:
107
108
 
108
109
  ```js
109
- /** @type {import("mdx-artifacts").ArtifactKitConfig} */
110
+ /** @type {import("mdx-artifacts").MdxArtifactsConfig} */
110
111
  const config = {
111
112
  docsDir: "artifact-docs",
112
113
  outDir: "dist/artifacts",
113
114
  includeDefaultStyles: true,
114
- styles: ["artifact-theme.css"]
115
+ styles: ["artifact-theme.css"],
116
+ tailwindSources: ["artifact-components/**/*.{ts,tsx}"]
115
117
  };
116
118
  ```
117
119
 
118
120
  Rules:
119
121
 
120
- - `includeDefaultStyles: true` imports Artifact Kit default styles first.
122
+ - `includeDefaultStyles: true` imports MDX Artifacts default styles first.
121
123
  - `styles` are imported in array order after the default styles.
122
124
  - Users can override CSS variables or `ak-*` classes.
123
- - `includeDefaultStyles: false` means the user owns all styling.
125
+ - `includeDefaultStyles: false` disables MDX Artifacts default styles.
126
+ - The current MDX file is always registered as a Tailwind source for local MDX components.
127
+ - `tailwindSources` registers additional project-local component files that use Tailwind classes.
124
128
  - The final CSS is still inlined into the standalone HTML artifact.
125
129
 
126
130
  ## UI Dependencies
@@ -153,8 +157,9 @@ Current workflow:
153
157
 
154
158
  ```text
155
159
  Component development: pnpm storybook
156
- Protocol verification: pnpm typecheck / pnpm test / pnpm artifact:validate
157
- Artifact verification: pnpm artifact:build
160
+ Protocol verification: pnpm typecheck / pnpm test / pnpm mdx-artifacts:validate
161
+ Artifact verification: pnpm mdx-artifacts:build
162
+ Release readiness: pnpm release:check / pnpm pack:smoke / npm pack --dry-run
158
163
  ```
159
164
 
160
165
  ## Testing Protocol
@@ -175,7 +180,9 @@ Out of scope for the first baseline:
175
180
  - browser E2E
176
181
  - visual regression
177
182
  - Astro adapter tests
178
- - package tarball smoke tests
183
+ - package tarball smoke tests as part of the default `pnpm check` baseline
184
+
185
+ Package readiness is covered separately by `pnpm release:check`, `pnpm pack:smoke`, and manual `npm pack --dry-run` before publishing.
179
186
 
180
187
  ## Agent Contract
181
188
 
@@ -185,31 +192,44 @@ When generating an artifact, agents should:
185
192
  2. Prefer existing high-level components.
186
193
  3. Provide an export path for interactive artifacts.
187
194
  4. Move bulky data into adjacent `.json` files.
188
- 5. Run `artifact-kit components <ComponentName>` when props are unclear.
189
- 6. Run `artifact-kit components --json` for machine-readable metadata.
190
- 7. Run `artifact-kit validate <file.mdx>` before build.
191
- 8. Run `artifact-kit build <file.mdx>` to produce standalone HTML.
195
+ 5. Run `mdx-artifacts components <ComponentName>` when props are unclear.
196
+ 6. Run `mdx-artifacts components --json` for machine-readable metadata.
197
+ 7. Run `mdx-artifacts validate <file.mdx>` before build.
198
+ 8. Run `mdx-artifacts build <file.mdx>` to produce standalone HTML.
192
199
 
193
200
  ## CLI Component Query
194
201
 
195
202
  To keep skills and agent instructions short, the CLI exposes component metadata:
196
203
 
197
204
  ```bash
198
- artifact-kit components
199
- artifact-kit components ExportPanel
200
- artifact-kit components --json
201
- artifact-kit components ExportPanel --json
205
+ mdx-artifacts components
206
+ mdx-artifacts components ExportPanel
207
+ mdx-artifacts components --json
208
+ mdx-artifacts components ExportPanel --json
202
209
  ```
203
210
 
204
211
  The data comes from `componentRegistry`. Future docs, Storybook docs, validation rules, and agent skills should derive from the same source.
205
212
 
206
213
  Component naming rules:
207
214
 
208
- - Names must be self-describing, such as `DecisionMatrix` and `ExportPanel`.
215
+ - Names must be self-describing, such as `ContentSet` and `ExportPanel`.
209
216
  - Avoid generic names such as `Panel` or `CardList`.
210
217
  - A component should represent an artifact workflow, not a primitive UI element.
211
218
  - Text rendering is intentionally split into `InlineText`, `MarkdownBody`, and future long-form prose components.
212
219
 
220
+ ## Package Boundary
221
+
222
+ MDX Artifacts remains a single npm package for now.
223
+
224
+ The package exposes separate entry points for the current public surfaces:
225
+
226
+ - `mdx-artifacts` for the CLI
227
+ - `mdx-artifacts/react` for React components
228
+ - `mdx-artifacts/registry` for registry metadata
229
+ - `mdx-artifacts/styles.css` for default styles
230
+
231
+ Do not split into packages such as `@mdx-artifacts/react`, `@mdx-artifacts/cli`, or `@mdx-artifacts/schema` until there is real maintenance pressure from independent versioning, dependency isolation, or adapter-specific release needs. The current priority is keeping installation, initialization, and agent guidance simple.
232
+
213
233
  ## Public Roadmap and Local Execution Notes
214
234
 
215
235
  Public project direction lives in:
@@ -219,6 +239,7 @@ Public project direction lives in:
219
239
  - `docs/naming.md`
220
240
  - `docs/component-protocol.md`
221
241
  - `docs/component-taxonomy.md`
242
+ - `docs/cli-structure.md`
222
243
  - `docs/testing.md`
223
244
 
224
245
  Local phase execution notes belong in `docs/local/*.local.md` and are not committed. They can track temporary decisions, verification notes, and agent working state without adding process noise to the public repository.