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.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +234 -0
  3. package/README.zh-CN.md +129 -0
  4. package/agents/AGENTS.snippet.md +13 -0
  5. package/artifact-docs/examples/commentable-feedback.mdx +126 -0
  6. package/artifact-docs/examples/decision-matrix.mdx +80 -0
  7. package/artifact-docs/examples/layout-composition.mdx +216 -0
  8. package/artifact-docs/examples/streamlit-style-mixed.mdx +183 -0
  9. package/dist/lib/cli/artifact-state.d.ts +27 -0
  10. package/dist/lib/cli/artifact-state.js +115 -0
  11. package/dist/lib/cli/build.d.ts +1 -0
  12. package/dist/lib/cli/build.js +25 -0
  13. package/dist/lib/cli/components.d.ts +3 -0
  14. package/dist/lib/cli/components.js +58 -0
  15. package/dist/lib/cli/config.d.ts +2 -0
  16. package/dist/lib/cli/config.js +36 -0
  17. package/dist/lib/cli/dev.d.ts +1 -0
  18. package/dist/lib/cli/dev.js +24 -0
  19. package/dist/lib/cli/index.d.ts +2 -0
  20. package/dist/lib/cli/index.js +69 -0
  21. package/dist/lib/cli/review.d.ts +33 -0
  22. package/dist/lib/cli/review.js +390 -0
  23. package/dist/lib/cli/scaffold.d.ts +1 -0
  24. package/dist/lib/cli/scaffold.js +56 -0
  25. package/dist/lib/cli/types.d.ts +7 -0
  26. package/dist/lib/cli/types.js +1 -0
  27. package/dist/lib/cli/validate.d.ts +6 -0
  28. package/dist/lib/cli/validate.js +79 -0
  29. package/dist/lib/cli/vite-artifact.d.ts +13 -0
  30. package/dist/lib/cli/vite-artifact.js +213 -0
  31. package/dist/lib/react/components/AnnotatedCode.d.ts +19 -0
  32. package/dist/lib/react/components/AnnotatedCode.js +30 -0
  33. package/dist/lib/react/components/ArtifactState.d.ts +68 -0
  34. package/dist/lib/react/components/ArtifactState.js +286 -0
  35. package/dist/lib/react/components/Callout.d.ts +9 -0
  36. package/dist/lib/react/components/Callout.js +21 -0
  37. package/dist/lib/react/components/CodeBlock.d.ts +10 -0
  38. package/dist/lib/react/components/CodeBlock.js +28 -0
  39. package/dist/lib/react/components/Comments.d.ts +53 -0
  40. package/dist/lib/react/components/Comments.js +613 -0
  41. package/dist/lib/react/components/ComparisonSet.d.ts +24 -0
  42. package/dist/lib/react/components/ComparisonSet.js +30 -0
  43. package/dist/lib/react/components/DecisionMatrix.d.ts +16 -0
  44. package/dist/lib/react/components/DecisionMatrix.js +27 -0
  45. package/dist/lib/react/components/DiffBlock.d.ts +15 -0
  46. package/dist/lib/react/components/DiffBlock.js +24 -0
  47. package/dist/lib/react/components/ExportPanel.d.ts +7 -0
  48. package/dist/lib/react/components/ExportPanel.js +84 -0
  49. package/dist/lib/react/components/InlineText.d.ts +9 -0
  50. package/dist/lib/react/components/InlineText.js +18 -0
  51. package/dist/lib/react/components/Layout.d.ts +44 -0
  52. package/dist/lib/react/components/Layout.js +28 -0
  53. package/dist/lib/react/components/MarkdownBody.d.ts +7 -0
  54. package/dist/lib/react/components/MarkdownBody.js +36 -0
  55. package/dist/lib/react/components/OptionGrid.d.ts +13 -0
  56. package/dist/lib/react/components/OptionGrid.js +21 -0
  57. package/dist/lib/react/components/Section.d.ts +7 -0
  58. package/dist/lib/react/components/Section.js +41 -0
  59. package/dist/lib/react/components/SeverityBadge.d.ts +7 -0
  60. package/dist/lib/react/components/SeverityBadge.js +14 -0
  61. package/dist/lib/react/index.d.ts +33 -0
  62. package/dist/lib/react/index.js +16 -0
  63. package/dist/lib/react/registry.d.ts +24 -0
  64. package/dist/lib/react/registry.js +1002 -0
  65. package/dist/lib/react/styles.css +1417 -0
  66. package/docs/component-protocol.md +273 -0
  67. package/docs/component-taxonomy.md +273 -0
  68. package/docs/design.md +239 -0
  69. package/docs/design.zh-CN.md +217 -0
  70. package/docs/naming.md +123 -0
  71. package/docs/testing.md +138 -0
  72. package/package.json +90 -0
@@ -0,0 +1,16 @@
1
+ export type DecisionMatrixOption = {
2
+ id?: string;
3
+ name: string;
4
+ summary?: string;
5
+ pros?: string[];
6
+ cons?: string[];
7
+ risks?: string[];
8
+ confidence?: "low" | "medium" | "high";
9
+ verdict?: string;
10
+ };
11
+ export type DecisionMatrixProps = {
12
+ id?: string;
13
+ question: string;
14
+ options: DecisionMatrixOption[];
15
+ };
16
+ export declare function DecisionMatrix({ id, question, options }: DecisionMatrixProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CommentTarget } from "./Comments.js";
3
+ import { InlineText } from "./InlineText.js";
4
+ export function DecisionMatrix({ id, question, options }) {
5
+ const targetId = id ?? `decision:${slugify(question)}`;
6
+ return (_jsx(CommentTarget, { className: "ak-comment-target-section", description: "DecisionMatrix component", targetId: targetId, title: question, children: _jsxs("section", { className: "ak-section ak-decision-matrix", children: [_jsxs("div", { className: "ak-section-header", children: [_jsx("p", { className: "ak-eyebrow", children: "Decision Matrix" }), _jsx(InlineText, { as: "h2", text: question, variant: "title" })] }), _jsx("div", { className: "ak-decision-grid", children: options.map((option, index) => {
7
+ const optionTargetId = id
8
+ ? `${id}.${option.id ?? `${index + 1}`}`
9
+ : `decision:${slugify(question)}:${index + 1}:${slugify(option.name)}`;
10
+ return (_jsx(CommentTarget, { className: "ak-comment-target-card", description: `DecisionMatrix option in ${question}`, targetId: optionTargetId, title: option.name, children: _jsxs("article", { className: "ak-card", children: [_jsxs("div", { className: "ak-card-header", children: [_jsx(InlineText, { as: "h3", text: option.name, variant: "subtitle" }), option.confidence ? (_jsx("span", { className: `ak-badge ak-badge-${option.confidence}`, children: option.confidence })) : null] }), option.summary ? _jsx(InlineText, { as: "p", className: "ak-muted", text: option.summary }) : null, _jsx(ListBlock, { title: "Pros", items: option.pros }), _jsx(ListBlock, { title: "Cons", items: option.cons }), _jsx(ListBlock, { title: "Risks", items: option.risks }), option.verdict ? _jsx(InlineText, { as: "p", className: "ak-verdict", text: option.verdict }) : null] }) }, option.name));
11
+ }) })] }) }));
12
+ }
13
+ function ListBlock({ title, items }) {
14
+ if (!items?.length) {
15
+ return null;
16
+ }
17
+ return (_jsxs("div", { className: "ak-list-block", children: [_jsx("h4", { children: title }), _jsx("ul", { children: items.map((item) => (_jsx("li", { children: _jsx(InlineText, { text: item }) }, item))) })] }));
18
+ }
19
+ function slugify(value) {
20
+ const slug = value
21
+ .toLowerCase()
22
+ .replace(/[`*_~[\]()]/g, "")
23
+ .replace(/[^a-z0-9]+/g, "-")
24
+ .replace(/^-+|-+$/g, "")
25
+ .slice(0, 64);
26
+ return slug || "item";
27
+ }
@@ -0,0 +1,15 @@
1
+ export type DiffLineType = "add" | "remove" | "context";
2
+ export type DiffLine = {
3
+ type: DiffLineType;
4
+ oldLine?: number;
5
+ newLine?: number;
6
+ content: string;
7
+ };
8
+ export type DiffBlockProps = {
9
+ id?: string;
10
+ lines: DiffLine[];
11
+ filename?: string;
12
+ language?: string;
13
+ className?: string;
14
+ };
15
+ export declare function DiffBlock({ id, lines, filename, language, className }: DiffBlockProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CommentTarget } from "./Comments.js";
3
+ const markers = {
4
+ add: "+",
5
+ remove: "-",
6
+ context: " "
7
+ };
8
+ export function DiffBlock({ id, lines, filename, language, className }) {
9
+ const title = filename ?? (language ? `${language} diff block` : "Diff block");
10
+ const targetId = id ?? `diff:${slugify(filename ?? language ?? lines.map((line) => line.content).join("-"))}`;
11
+ return (_jsx(CommentTarget, { className: classNames("ak-comment-target-section", className), description: "DiffBlock component", targetId: targetId, title: title, children: _jsxs("figure", { className: "ak-code-block ak-diff-block", children: [(filename || language) && (_jsxs("figcaption", { className: "ak-code-header", children: [filename && _jsx("span", { className: "ak-code-filename", children: filename }), language && _jsx("span", { className: "ak-code-language", children: language })] })), _jsx("pre", { className: "ak-code-pre", children: _jsx("code", { className: language ? `language-${language}` : undefined, children: lines.map((line, index) => (_jsxs("span", { className: classNames("ak-diff-line", `ak-diff-line-${line.type}`), children: [_jsx("span", { className: "ak-diff-line-number", children: line.newLine ?? line.oldLine ?? "" }), _jsx("span", { className: "ak-diff-marker", children: markers[line.type] }), _jsx("span", { className: "ak-diff-line-content", children: line.content || "\u00a0" })] }, `${line.type}-${index}`))) }) })] }) }));
12
+ }
13
+ function classNames(...values) {
14
+ return values.filter(Boolean).join(" ");
15
+ }
16
+ function slugify(value) {
17
+ const slug = value
18
+ .toLowerCase()
19
+ .replace(/[`*_~[\]()]/g, "")
20
+ .replace(/[^a-z0-9]+/g, "-")
21
+ .replace(/^-+|-+$/g, "")
22
+ .slice(0, 64);
23
+ return slug || "item";
24
+ }
@@ -0,0 +1,7 @@
1
+ export type ExportFormat = "markdown" | "json";
2
+ export type ExportPanelProps = {
3
+ title?: string;
4
+ formats?: ExportFormat[];
5
+ value: unknown;
6
+ };
7
+ export declare function ExportPanel({ title, formats, value }: ExportPanelProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,84 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as Tabs from "@radix-ui/react-tabs";
3
+ import { useMemo, useState } from "react";
4
+ import { serializeCommentsToMarkdown, useOptionalCommentExportValue } from "./Comments.js";
5
+ import { InlineText } from "./InlineText.js";
6
+ export function ExportPanel({ title = "Export Result", formats = ["markdown", "json"], value }) {
7
+ const [format, setFormat] = useState(formats[0] ?? "markdown");
8
+ const [source, setSource] = useState("result");
9
+ const [isOpen, setOpen] = useState(false);
10
+ const [copied, setCopied] = useState(false);
11
+ const comments = useOptionalCommentExportValue();
12
+ const hasCommentsSource = Boolean(comments);
13
+ const resolvedSource = source === "comments" && !hasCommentsSource ? "result" : source;
14
+ const output = useMemo(() => {
15
+ if (resolvedSource === "comments" && comments) {
16
+ return format === "json" ? JSON.stringify(comments, null, 2) : serializeCommentsToMarkdown(comments);
17
+ }
18
+ return serialize(value, format);
19
+ }, [comments, format, resolvedSource, value]);
20
+ async function copyOutput() {
21
+ if (navigator.clipboard?.writeText) {
22
+ await navigator.clipboard.writeText(output);
23
+ }
24
+ else {
25
+ fallbackCopy(output);
26
+ }
27
+ setCopied(true);
28
+ window.setTimeout(() => setCopied(false), 1200);
29
+ }
30
+ function updateSource(value) {
31
+ setSource(value);
32
+ setCopied(false);
33
+ }
34
+ function updateFormat(value) {
35
+ setFormat(value);
36
+ setCopied(false);
37
+ }
38
+ return (_jsxs("aside", { className: "ak-export-dock", "aria-label": title, children: [_jsx("button", { className: "ak-export-dock-trigger", onClick: () => setOpen((current) => !current), type: "button", children: "Export" }), isOpen ? (_jsxs("div", { className: "ak-export-drawer", role: "dialog", children: [_jsxs("div", { className: "ak-section-header ak-export-header", children: [_jsxs("div", { children: [_jsx("p", { className: "ak-eyebrow", children: "Export" }), _jsx(InlineText, { as: "h2", text: title, variant: "title" })] }), _jsx("button", { className: "ak-button", onClick: () => setOpen(false), type: "button", children: "Close" })] }), _jsxs("div", { className: "ak-export-toolbar", children: [_jsx(Tabs.Root, { className: "ak-format-tabs", onValueChange: updateSource, value: resolvedSource, children: _jsxs(Tabs.List, { "aria-label": "Export source", className: "ak-format-tabs-list", children: [_jsx(Tabs.Trigger, { className: "ak-format-trigger", value: "result", children: "Result" }), hasCommentsSource ? (_jsx(Tabs.Trigger, { className: "ak-format-trigger", value: "comments", children: "Comments" })) : null] }) }), _jsx(Tabs.Root, { className: "ak-format-tabs", onValueChange: updateFormat, value: format, children: _jsx(Tabs.List, { "aria-label": "Export format", className: "ak-format-tabs-list", children: formats.map((item) => (_jsx(Tabs.Trigger, { className: "ak-format-trigger", value: item, children: item }, item))) }) }), _jsx("button", { className: "ak-button ak-button-primary", onClick: copyOutput, type: "button", children: copied ? "Copied" : "Copy" })] }), _jsx("pre", { className: "ak-export-output", children: output })] })) : null] }));
39
+ }
40
+ function serialize(value, format) {
41
+ if (format === "json") {
42
+ return JSON.stringify(value, null, 2);
43
+ }
44
+ return toMarkdown(value);
45
+ }
46
+ function fallbackCopy(value) {
47
+ const textarea = document.createElement("textarea");
48
+ textarea.value = value;
49
+ textarea.setAttribute("readonly", "true");
50
+ textarea.style.position = "fixed";
51
+ textarea.style.left = "-9999px";
52
+ document.body.appendChild(textarea);
53
+ textarea.select();
54
+ document.execCommand("copy");
55
+ document.body.removeChild(textarea);
56
+ }
57
+ function toMarkdown(value, depth = 0) {
58
+ if (value == null) {
59
+ return "";
60
+ }
61
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
62
+ return String(value);
63
+ }
64
+ if (Array.isArray(value)) {
65
+ return value
66
+ .map((item) => {
67
+ const rendered = toMarkdown(item, depth + 1);
68
+ return `${" ".repeat(depth)}- ${rendered.replace(/\n/g, `\n${" ".repeat(depth + 1)}`)}`;
69
+ })
70
+ .join("\n");
71
+ }
72
+ if (typeof value === "object") {
73
+ return Object.entries(value)
74
+ .map(([key, item]) => {
75
+ const rendered = toMarkdown(item, depth + 1);
76
+ if (Array.isArray(item) || (item && typeof item === "object")) {
77
+ return `${" ".repeat(depth)}- **${key}**:\n${rendered}`;
78
+ }
79
+ return `${" ".repeat(depth)}- **${key}**: ${rendered}`;
80
+ })
81
+ .join("\n");
82
+ }
83
+ return String(value);
84
+ }
@@ -0,0 +1,9 @@
1
+ export type InlineTextAs = "span" | "p" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
2
+ export type InlineTextVariant = "default" | "title" | "subtitle" | "label" | "caption";
3
+ export type InlineTextProps = {
4
+ text: string;
5
+ as?: InlineTextAs;
6
+ variant?: InlineTextVariant;
7
+ className?: string;
8
+ };
9
+ export declare function InlineText({ text, as: Component, variant, className }: InlineTextProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import ReactMarkdown from "react-markdown";
3
+ import remarkGfm from "remark-gfm";
4
+ const inlineAllowedElements = ["p", "strong", "em", "del", "code", "a", "br"];
5
+ const inlineComponents = {
6
+ p({ children }) {
7
+ return _jsx(_Fragment, { children: children });
8
+ },
9
+ a({ children, href }) {
10
+ return (_jsx("a", { href: href, rel: "noreferrer", target: "_blank", children: children }));
11
+ }
12
+ };
13
+ export function InlineText({ text, as: Component = "span", variant = "default", className }) {
14
+ return (_jsx(Component, { className: classNames("ak-inline-text", `ak-inline-text--${variant}`, className), children: _jsx(ReactMarkdown, { allowedElements: inlineAllowedElements, components: inlineComponents, remarkPlugins: [remarkGfm], skipHtml: true, unwrapDisallowed: true, children: text }) }));
15
+ }
16
+ function classNames(...values) {
17
+ return values.filter(Boolean).join(" ");
18
+ }
@@ -0,0 +1,44 @@
1
+ import type { ReactNode } from "react";
2
+ export type AkGap = "sm" | "md" | "lg";
3
+ export type AkCollapseAt = "sm" | "md" | "lg";
4
+ export type AkSurface = "none" | "plain" | "subtle" | "outlined";
5
+ export type StackProps = {
6
+ children: ReactNode;
7
+ gap?: AkGap;
8
+ align?: "start" | "center" | "stretch";
9
+ className?: string;
10
+ };
11
+ export type ColumnsRatio = "1:1" | "1:1:1" | "1:1:1:1" | "2:1" | "3:1" | "3:1:1" | "1:3:1" | "1:1:3";
12
+ export type ColumnsProps = {
13
+ children: ReactNode;
14
+ ratio?: ColumnsRatio;
15
+ gap?: AkGap;
16
+ collapseAt?: AkCollapseAt;
17
+ className?: string;
18
+ };
19
+ export type GridProps = {
20
+ children: ReactNode;
21
+ columns?: 2 | 3 | 4;
22
+ gap?: AkGap;
23
+ collapseAt?: AkCollapseAt;
24
+ className?: string;
25
+ };
26
+ export type SplitPaneRatio = "1:1" | "2:1" | "3:1" | "1:2" | "1:3";
27
+ export type SplitPaneProps = {
28
+ children: ReactNode;
29
+ ratio?: SplitPaneRatio;
30
+ gap?: AkGap;
31
+ collapseAt?: AkCollapseAt;
32
+ className?: string;
33
+ };
34
+ export type FrameProps = {
35
+ children: ReactNode;
36
+ surface?: AkSurface;
37
+ padding?: "none" | AkGap;
38
+ className?: string;
39
+ };
40
+ export declare function Stack({ children, gap, align, className }: StackProps): import("react/jsx-runtime").JSX.Element;
41
+ export declare function Columns({ children, ratio, gap, collapseAt, className }: ColumnsProps): import("react/jsx-runtime").JSX.Element;
42
+ export declare function Grid({ children, columns, gap, collapseAt, className }: GridProps): import("react/jsx-runtime").JSX.Element;
43
+ export declare function SplitPane({ children, ratio, gap, collapseAt, className }: SplitPaneProps): import("react/jsx-runtime").JSX.Element;
44
+ export declare function Frame({ children, surface, padding, className }: FrameProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export function Stack({ children, gap = "md", align = "stretch", className }) {
3
+ return _jsx("div", { className: classNames("ak-stack", `ak-gap-${gap}`, `ak-stack-align-${align}`, className), children: children });
4
+ }
5
+ export function Columns({ children, ratio = "1:1", gap = "md", collapseAt = "md", className }) {
6
+ return (_jsx("div", { className: classNames("ak-columns", `ak-gap-${gap}`, `ak-collapse-${collapseAt}`, className), style: cssVars({ "--ak-layout-columns": ratioToTemplate(ratio) }), children: children }));
7
+ }
8
+ export function Grid({ children, columns = 2, gap = "md", collapseAt = "md", className }) {
9
+ return (_jsx("div", { className: classNames("ak-grid", `ak-gap-${gap}`, `ak-collapse-${collapseAt}`, className), style: cssVars({ "--ak-layout-columns": `repeat(${columns}, minmax(0, 1fr))` }), children: children }));
10
+ }
11
+ export function SplitPane({ children, ratio = "3:1", gap = "md", collapseAt = "md", className }) {
12
+ return (_jsx("div", { className: classNames("ak-split-pane", `ak-gap-${gap}`, `ak-collapse-${collapseAt}`, className), style: cssVars({ "--ak-layout-columns": ratioToTemplate(ratio) }), children: children }));
13
+ }
14
+ export function Frame({ children, surface = "outlined", padding = "md", className }) {
15
+ return (_jsx("div", { className: classNames("ak-frame", `ak-surface-${surface}`, `ak-padding-${padding}`, className), children: children }));
16
+ }
17
+ function ratioToTemplate(ratio) {
18
+ return ratio
19
+ .split(":")
20
+ .map((part) => `${part}fr`)
21
+ .join(" ");
22
+ }
23
+ function cssVars(values) {
24
+ return values;
25
+ }
26
+ function classNames(...values) {
27
+ return values.filter(Boolean).join(" ");
28
+ }
@@ -0,0 +1,7 @@
1
+ export type MarkdownBodyVariant = "default" | "compact";
2
+ export type MarkdownBodyProps = {
3
+ body: string;
4
+ variant?: MarkdownBodyVariant;
5
+ className?: string;
6
+ };
7
+ export declare function MarkdownBody({ body, variant, className }: MarkdownBodyProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import ReactMarkdown from "react-markdown";
3
+ import remarkGfm from "remark-gfm";
4
+ const blockAllowedElements = [
5
+ "p",
6
+ "h1",
7
+ "h2",
8
+ "h3",
9
+ "h4",
10
+ "h5",
11
+ "h6",
12
+ "strong",
13
+ "em",
14
+ "del",
15
+ "code",
16
+ "a",
17
+ "br",
18
+ "ul",
19
+ "ol",
20
+ "li",
21
+ "blockquote"
22
+ ];
23
+ const blockComponents = {
24
+ a({ children, href }) {
25
+ return (_jsx("a", { href: href, rel: "noreferrer", target: "_blank", children: children }));
26
+ }
27
+ };
28
+ export function MarkdownBody({ body, variant = "default", className }) {
29
+ if (!body.trim()) {
30
+ return null;
31
+ }
32
+ return (_jsx("div", { className: classNames("ak-markdown-body", `ak-markdown-body--${variant}`, className), children: _jsx(ReactMarkdown, { allowedElements: blockAllowedElements, components: blockComponents, remarkPlugins: [remarkGfm], skipHtml: true, unwrapDisallowed: true, children: body }) }));
33
+ }
34
+ function classNames(...values) {
35
+ return values.filter(Boolean).join(" ");
36
+ }
@@ -0,0 +1,13 @@
1
+ export type OptionGridItem = {
2
+ id?: string;
3
+ name: string;
4
+ intent?: string;
5
+ description?: string;
6
+ tradeoffs?: string[];
7
+ };
8
+ export type OptionGridProps = {
9
+ id?: string;
10
+ title: string;
11
+ options: OptionGridItem[];
12
+ };
13
+ export declare function OptionGrid({ id, title, options }: OptionGridProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CommentTarget } from "./Comments.js";
3
+ import { InlineText } from "./InlineText.js";
4
+ export function OptionGrid({ id, title, options }) {
5
+ const targetId = id ?? `option:${slugify(title)}`;
6
+ return (_jsx(CommentTarget, { className: "ak-comment-target-section", description: "OptionGrid component", targetId: targetId, title: title, children: _jsxs("section", { className: "ak-section", children: [_jsxs("div", { className: "ak-section-header", children: [_jsx("p", { className: "ak-eyebrow", children: "Option Grid" }), _jsx(InlineText, { as: "h2", text: title, variant: "title" })] }), _jsx("div", { className: "ak-option-grid", children: options.map((option, index) => {
7
+ const optionTargetId = id
8
+ ? `${id}.${option.id ?? `${index + 1}`}`
9
+ : `option:${slugify(title)}:${index + 1}:${slugify(option.name)}`;
10
+ return (_jsx(CommentTarget, { className: "ak-comment-target-card", description: `OptionGrid item in ${title}`, targetId: optionTargetId, title: option.name, children: _jsxs("article", { className: "ak-card", children: [_jsx(InlineText, { as: "h3", text: option.name, variant: "subtitle" }), option.intent ? _jsx(InlineText, { as: "p", className: "ak-intent", text: option.intent }) : null, option.description ? _jsx(InlineText, { as: "p", text: option.description }) : null, option.tradeoffs?.length ? (_jsx("ul", { children: option.tradeoffs.map((tradeoff) => (_jsx("li", { children: _jsx(InlineText, { text: tradeoff }) }, tradeoff))) })) : null] }) }, option.name));
11
+ }) })] }) }));
12
+ }
13
+ function slugify(value) {
14
+ const slug = value
15
+ .toLowerCase()
16
+ .replace(/[`*_~[\]()]/g, "")
17
+ .replace(/[^a-z0-9]+/g, "-")
18
+ .replace(/^-+|-+$/g, "")
19
+ .slice(0, 64);
20
+ return slug || "item";
21
+ }
@@ -0,0 +1,7 @@
1
+ import { type ReactNode } from "react";
2
+ export type SectionProps = {
3
+ id: string;
4
+ children: ReactNode;
5
+ className?: string;
6
+ };
7
+ export declare function Section({ id, children, className }: SectionProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Children, isValidElement } from "react";
3
+ import { CommentTarget } from "./Comments.js";
4
+ export function Section({ id, children, className }) {
5
+ const title = getFirstHeadingText(children) ?? id;
6
+ return (_jsx(CommentTarget, { className: classNames("ak-comment-target-section", className), targetId: id, title: title, children: _jsx("div", { className: "ak-section ak-content-section", children: children }) }));
7
+ }
8
+ function getFirstHeadingText(children) {
9
+ for (const child of Children.toArray(children)) {
10
+ const heading = getHeadingText(child);
11
+ if (heading) {
12
+ return heading;
13
+ }
14
+ }
15
+ return undefined;
16
+ }
17
+ function getHeadingText(node) {
18
+ if (!isValidElement(node)) {
19
+ return undefined;
20
+ }
21
+ if (typeof node.type === "string" && /^h[1-6]$/.test(node.type)) {
22
+ return getTextContent(node.props.children);
23
+ }
24
+ return undefined;
25
+ }
26
+ function getTextContent(node) {
27
+ if (typeof node === "string" || typeof node === "number") {
28
+ return String(node);
29
+ }
30
+ if (Array.isArray(node)) {
31
+ const text = node.map(getTextContent).filter(Boolean).join(" ").trim();
32
+ return text || undefined;
33
+ }
34
+ if (isValidElement(node)) {
35
+ return getTextContent(node.props.children);
36
+ }
37
+ return undefined;
38
+ }
39
+ function classNames(...values) {
40
+ return values.filter(Boolean).join(" ");
41
+ }
@@ -0,0 +1,7 @@
1
+ export type SeverityLevel = "info" | "low" | "medium" | "high" | "critical";
2
+ export type SeverityBadgeProps = {
3
+ level?: SeverityLevel;
4
+ label?: string;
5
+ className?: string;
6
+ };
7
+ export declare function SeverityBadge({ level, label, className }: SeverityBadgeProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ const defaultLabels = {
3
+ info: "Info",
4
+ low: "Low",
5
+ medium: "Medium",
6
+ high: "High",
7
+ critical: "Critical"
8
+ };
9
+ export function SeverityBadge({ level = "info", label = defaultLabels[level], className }) {
10
+ return _jsx("span", { className: classNames("ak-severity-badge", `ak-severity-badge-${level}`, className), children: label });
11
+ }
12
+ function classNames(...values) {
13
+ return values.filter(Boolean).join(" ");
14
+ }
@@ -0,0 +1,33 @@
1
+ export { AnnotatedCode } from "./components/AnnotatedCode";
2
+ export type { AnnotatedCodeProps, CodeAnnotation } from "./components/AnnotatedCode";
3
+ export { ArtifactStateProvider, createArtifactCommentsFromState, createArtifactStateFromComments, useOptionalArtifactState } from "./components/ArtifactState";
4
+ export type { ArtifactStateComment, ArtifactStateMessage, ArtifactStateMeta, ArtifactStateProviderProps, ArtifactStateStatus, ArtifactStateThread, ArtifactStateValue } from "./components/ArtifactState";
5
+ export { Callout } from "./components/Callout";
6
+ export type { CalloutProps, CalloutTone } from "./components/Callout";
7
+ export { ComparisonSet } from "./components/ComparisonSet";
8
+ export type { ComparisonSetItemProps, ComparisonSetProps } from "./components/ComparisonSet";
9
+ export { CodeBlock } from "./components/CodeBlock";
10
+ export type { CodeBlockProps } from "./components/CodeBlock";
11
+ export { CommentableBlock, CommentExport, CommentLayer, CommentTarget, serializeCommentsToMarkdown, useOptionalCommentExportValue } from "./components/Comments";
12
+ export type { ArtifactComment, CommentableBlockProps, CommentExportFormat, CommentExportProps, CommentExportValue, CommentLayerProps, CommentTargetProps } from "./components/Comments";
13
+ export { DecisionMatrix } from "./components/DecisionMatrix";
14
+ export type { DecisionMatrixOption, DecisionMatrixProps } from "./components/DecisionMatrix";
15
+ export { DiffBlock } from "./components/DiffBlock";
16
+ export type { DiffBlockProps, DiffLine, DiffLineType } from "./components/DiffBlock";
17
+ export { ExportPanel } from "./components/ExportPanel";
18
+ export type { ExportFormat, ExportPanelProps } from "./components/ExportPanel";
19
+ export { InlineText } from "./components/InlineText";
20
+ export type { InlineTextAs, InlineTextProps, InlineTextVariant } from "./components/InlineText";
21
+ export { Columns, Frame, Grid, SplitPane, Stack } from "./components/Layout";
22
+ export type { AkCollapseAt, AkGap, AkSurface, ColumnsProps, ColumnsRatio, FrameProps, GridProps, SplitPaneProps, SplitPaneRatio, StackProps } from "./components/Layout";
23
+ export { MarkdownBody } from "./components/MarkdownBody";
24
+ export type { MarkdownBodyProps, MarkdownBodyVariant } from "./components/MarkdownBody";
25
+ export { OptionGrid } from "./components/OptionGrid";
26
+ export type { OptionGridItem, OptionGridProps } from "./components/OptionGrid";
27
+ export { Section } from "./components/Section";
28
+ export type { SectionProps } from "./components/Section";
29
+ export { SeverityBadge } from "./components/SeverityBadge";
30
+ export type { SeverityBadgeProps, SeverityLevel } from "./components/SeverityBadge";
31
+ export { componentRegistry, findComponentMeta } from "./registry";
32
+ export type { ComponentMeta, ComponentPropMeta } from "./registry";
33
+ export type { ArtifactKitConfig } from "../cli/types";
@@ -0,0 +1,16 @@
1
+ export { AnnotatedCode } from "./components/AnnotatedCode.js";
2
+ export { ArtifactStateProvider, createArtifactCommentsFromState, createArtifactStateFromComments, useOptionalArtifactState } from "./components/ArtifactState.js";
3
+ export { Callout } from "./components/Callout.js";
4
+ export { ComparisonSet } from "./components/ComparisonSet.js";
5
+ export { CodeBlock } from "./components/CodeBlock.js";
6
+ export { CommentableBlock, CommentExport, CommentLayer, CommentTarget, serializeCommentsToMarkdown, useOptionalCommentExportValue } from "./components/Comments.js";
7
+ export { DecisionMatrix } from "./components/DecisionMatrix.js";
8
+ export { DiffBlock } from "./components/DiffBlock.js";
9
+ export { ExportPanel } from "./components/ExportPanel.js";
10
+ export { InlineText } from "./components/InlineText.js";
11
+ export { Columns, Frame, Grid, SplitPane, Stack } from "./components/Layout.js";
12
+ export { MarkdownBody } from "./components/MarkdownBody.js";
13
+ export { OptionGrid } from "./components/OptionGrid.js";
14
+ export { Section } from "./components/Section.js";
15
+ export { SeverityBadge } from "./components/SeverityBadge.js";
16
+ export { componentRegistry, findComponentMeta } from "./registry.js";
@@ -0,0 +1,24 @@
1
+ export type ComponentPropMeta = {
2
+ name: string;
3
+ type: string;
4
+ contentType?: "plainText" | "inlineMarkdown" | "blockMarkdown" | "json" | "code";
5
+ required?: boolean;
6
+ description: string;
7
+ };
8
+ export type ComponentTypeMeta = {
9
+ name: string;
10
+ description?: string;
11
+ fields: ComponentPropMeta[];
12
+ };
13
+ export type ComponentMeta = {
14
+ name: string;
15
+ category?: "artifact" | "content" | "layout" | "semantic";
16
+ stability?: "stable" | "advanced";
17
+ description: string;
18
+ useWhen: string[];
19
+ props: ComponentPropMeta[];
20
+ types?: ComponentTypeMeta[];
21
+ example: string;
22
+ };
23
+ export declare const componentRegistry: ComponentMeta[];
24
+ export declare function findComponentMeta(name: string): ComponentMeta | undefined;