sparkdesign 0.4.9 → 0.4.10

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 (38) hide show
  1. package/AGENT_COMPONENT_LIBRARY_QUICKREF.md +117 -0
  2. package/AI_README.md +7 -2
  3. package/README.md +4 -1
  4. package/cli/registry/AGENTS.md +1 -1
  5. package/cli/registry/agent-manifest.json +137 -93
  6. package/cli/registry/basic/calendar.tsx +16 -16
  7. package/cli/registry/basic/combobox.tsx +11 -2
  8. package/cli/registry/basic/date-picker.tsx +3 -2
  9. package/cli/registry/basic/popover.tsx +19 -2
  10. package/cli/registry/basic/rating.tsx +161 -0
  11. package/cli/registry/basic/sidebar.tsx +1 -1
  12. package/cli/registry/basic/stepper.tsx +163 -0
  13. package/cli/registry/basic/timeline.tsx +129 -0
  14. package/cli/registry/chat/permission-card.tsx +1 -1
  15. package/cli/registry/meta.json +30 -25
  16. package/dist/registry/basic/calendar.d.ts +1 -1
  17. package/dist/registry/basic/combobox.d.ts +2 -1
  18. package/dist/registry/basic/date-picker.d.ts +2 -2
  19. package/dist/registry/basic/popover.d.ts +2 -0
  20. package/dist/registry/basic/rating.d.ts +31 -0
  21. package/dist/registry/basic/stepper.d.ts +36 -0
  22. package/dist/registry/basic/timeline.d.ts +34 -0
  23. package/dist/spark-design.cjs.js +23 -23
  24. package/dist/spark-design.es.js +3420 -3035
  25. package/dist/sparkdesign.css +1 -1
  26. package/dist/src/components/basic/Rating/index.d.ts +13 -0
  27. package/dist/src/components/basic/Stepper/index.d.ts +13 -0
  28. package/dist/src/components/basic/Timeline/index.d.ts +13 -0
  29. package/dist/src/components/index.d.ts +6 -2
  30. package/docs/agent/component-selection.md +1 -3
  31. package/docs/agent/prompt-recipes.md +167 -0
  32. package/docs/guides/agent-usage.md +213 -0
  33. package/docs/guides/system-operating-model.md +148 -0
  34. package/package.json +14 -2
  35. package/registry/agent-manifest.json +137 -93
  36. package/cli/registry/basic/sheet.tsx +0 -18
  37. package/dist/registry/basic/sheet.d.ts +0 -13
  38. package/dist/src/components/basic/Sheet/index.d.ts +0 -13
@@ -0,0 +1,13 @@
1
+ /**
2
+ * [WHO]: Public Rating re-export.
3
+ * [FROM]: registry/basic/rating.
4
+ * [TO]: sparkdesign package consumers; src/components/index.ts barrel.
5
+ * [HERE]: src/components/basic/Rating/index.tsx — package-facing Rating entrypoint.
6
+ *
7
+ * [PROTOCOL]:
8
+ * 1. Keep this P3 header in sync when the public contract changes.
9
+ * 2. Update module AGENTS.md (P2) and root AGENTS.md (P1) when boundaries change.
10
+ * 3. Follow design tokens and explicit type exports.
11
+ */
12
+ export { Rating, ratingVariants } from '../../../../registry/basic/rating';
13
+ export type { RatingProps, RatingPrecision } from '../../../../registry/basic/rating';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * [WHO]: Public Stepper re-export.
3
+ * [FROM]: registry/basic/stepper.
4
+ * [TO]: sparkdesign package consumers; src/components/index.ts barrel.
5
+ * [HERE]: src/components/basic/Stepper/index.tsx — package-facing Stepper entrypoint.
6
+ *
7
+ * [PROTOCOL]:
8
+ * 1. Keep this P3 header in sync when the public contract changes.
9
+ * 2. Update module AGENTS.md (P2) and root AGENTS.md (P1) when boundaries change.
10
+ * 3. Follow design tokens and explicit type exports.
11
+ */
12
+ export { Stepper, StepperItem, StepperIndicator, StepperContent, StepperTitle, StepperDescription, StepperSeparator, } from '../../../../registry/basic/stepper';
13
+ export type { StepperProps, StepperItemProps, StepperIndicatorProps, StepperContentProps, StepperTitleProps, StepperDescriptionProps, StepperSeparatorProps, StepStatus, } from '../../../../registry/basic/stepper';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * [WHO]: Public Timeline re-export.
3
+ * [FROM]: registry/basic/timeline.
4
+ * [TO]: sparkdesign package consumers; src/components/index.ts barrel.
5
+ * [HERE]: src/components/basic/Timeline/index.tsx — package-facing Timeline entrypoint.
6
+ *
7
+ * [PROTOCOL]:
8
+ * 1. Keep this P3 header in sync when the public contract changes.
9
+ * 2. Update module AGENTS.md (P2) and root AGENTS.md (P1) when boundaries change.
10
+ * 3. Follow design tokens and explicit type exports.
11
+ */
12
+ export { Timeline, TimelineItem, TimelineMarker, TimelineConnector, TimelineContent, TimelineTitle, TimelineDescription, TimelineTime, timelineMarkerVariants, } from '../../../../registry/basic/timeline';
13
+ export type { TimelineProps, TimelineItemProps, TimelineMarkerProps, TimelineConnectorProps, TimelineContentProps, TimelineTitleProps, TimelineDescriptionProps, TimelineTimeProps, } from '../../../../registry/basic/timeline';
@@ -70,6 +70,12 @@ export { Tag, tagVariants } from './basic/Tag';
70
70
  export type { TagProps } from './basic/Tag';
71
71
  export { Progress } from './basic/Progress';
72
72
  export type { ProgressProps } from './basic/Progress';
73
+ export { Rating, ratingVariants } from './basic/Rating';
74
+ export type { RatingProps, RatingPrecision } from './basic/Rating';
75
+ export { Stepper, StepperItem, StepperIndicator, StepperContent, StepperTitle, StepperDescription, StepperSeparator, } from './basic/Stepper';
76
+ export type { StepperProps, StepperItemProps, StepperIndicatorProps, StepperContentProps, StepperTitleProps, StepperDescriptionProps, StepperSeparatorProps, StepStatus, } from './basic/Stepper';
77
+ export { Timeline, TimelineItem, TimelineMarker, TimelineConnector, TimelineContent, TimelineTitle, TimelineDescription, TimelineTime, timelineMarkerVariants, } from './basic/Timeline';
78
+ export type { TimelineProps, TimelineItemProps, TimelineMarkerProps, TimelineConnectorProps, TimelineContentProps, TimelineTitleProps, TimelineDescriptionProps, TimelineTimeProps, } from './basic/Timeline';
73
79
  export { CollapsibleCard } from './basic/CollapsibleCard';
74
80
  export type { CollapsibleCardProps } from './basic/CollapsibleCard';
75
81
  export { SidebarMenu } from './basic/SidebarMenu';
@@ -102,8 +108,6 @@ export { Dialog, DialogTrigger, DialogPortal, DialogOverlay, DialogClose, Dialog
102
108
  export type { DialogContentProps, DialogHeaderProps, DialogFooterProps, } from './basic/Dialog';
103
109
  export { Drawer, DrawerTrigger, DrawerClose, DrawerPortal, DrawerOverlay, DrawerContent, DrawerHeader, DrawerFooter, DrawerTitle, DrawerDescription, } from './basic/Drawer';
104
110
  export type { DrawerContentProps, DrawerHeaderProps, DrawerFooterProps, } from './basic/Drawer';
105
- export { Sheet, SheetTrigger, SheetClose, SheetPortal, SheetOverlay, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription, sheetVariants, } from './basic/Sheet';
106
- export type { SheetContentProps, SheetHeaderProps, SheetFooterProps, } from './basic/Sheet';
107
111
  export { Popover, PopoverTrigger, PopoverAnchor, PopoverContent, } from './basic/Popover';
108
112
  export type { PopoverContentProps } from './basic/Popover';
109
113
  export { HoverCard, HoverCardTrigger, HoverCardContent } from './basic/HoverCard';
@@ -8,6 +8,7 @@ details are needed.
8
8
 
9
9
  - `sparkdesign/agent-manifest.json` — package export for agent-facing component semantics.
10
10
  - `registry/agent-manifest.json` — source of truth in this repository.
11
+ - Showcase route `#/agent-component-selection` — visible companion page for the same decision model.
11
12
  - `npm run check:agent-manifest` — validates required semantic fields and recipe references.
12
13
  - `npm run report:agent-coverage` — reports manifest coverage against `registry/meta.json`.
13
14
  - `npm run check:agent-coverage` — fails if manifest coverage drops below 100%.
@@ -25,7 +26,6 @@ details are needed.
25
26
  - `sidebar` is the full app-shell primitive set: provider state, trigger, responsive collapse, mobile sheet, and inset content. Package imports expose its menu list as `SidebarNavMenu` / `SidebarNavMenuItem`.
26
27
  - `sidebar-menu` is the lightweight data-driven list component exported as `SidebarMenu`; use it when a full app shell would be overkill.
27
28
  - `form` is for React Hook Form validation wiring; `field` is for layout-only form rows.
28
- - `toast` and `sonner` share the same runtime toaster API. Prefer `toast` for Spark semantic naming and `sonner` only when matching that install target.
29
29
 
30
30
  ## Current High-Confidence Coverage
31
31
 
@@ -84,14 +84,12 @@ snapshot.
84
84
  - `scrollbar`
85
85
  - `select`
86
86
  - `separator`
87
- - `sheet`
88
87
  - `sidebar`
89
88
  - `sidebar-menu`
90
89
  - `shimmering-text`
91
90
  - `slider`
92
91
  - `skeleton`
93
92
  - `spinner`
94
- - `sonner`
95
93
  - `switch`
96
94
  - `table`
97
95
  - `tag`
@@ -0,0 +1,167 @@
1
+ # Spark Design Prompt Recipes
2
+
3
+ These prompts are for AI coding agents that need to build with Spark Design
4
+ without flattening the system into generic UI. They assume the agent can inspect
5
+ files, run commands, and edit code.
6
+
7
+ Showcase companion: `#/agent-prompt-recipes`.
8
+
9
+ ## How To Use
10
+
11
+ 1. Pick the recipe closest to the task.
12
+ 2. Paste it into the agent with the product-specific requirements.
13
+ 3. Keep the hard rules intact.
14
+ 4. Ask the agent to report which Spark surfaces it verified.
15
+
16
+ ## Universal Spark Contract
17
+
18
+ Add this block to any prompt when quality matters:
19
+
20
+ ```text
21
+ Use Spark Design as a system, not as loose components.
22
+
23
+ Before implementation:
24
+ - Read registry/agent-manifest.json and choose components by intent, states,
25
+ accessibility, composition, and antiPatterns.
26
+ - Read registry/tokens/ontology.json before writing styles.
27
+ - Prefer npx sparkdesign@latest add <component> for business apps that should
28
+ own copied source.
29
+ - Use package imports only if the app already consumes sparkdesign as a runtime.
30
+
31
+ Hard rules:
32
+ - Do not invent duplicate components when Spark already covers the intent.
33
+ - Do not hard-code hex colors, raw rgba overlays, arbitrary radii, or one-off
34
+ spacing in published UI.
35
+ - Preserve data-theme for color and data-style for layout density/radius/rhythm.
36
+ - Keep portal UI consistent with the active theme/style.
37
+ - For AI workflows, prefer chat components such as ChatInput, Response,
38
+ ToolInvocationCard, PermissionCard, ReasoningStep, TaskPart, PlanPart,
39
+ FileReviewPart, and RelatedPrompts instead of plain cards and Markdown.
40
+
41
+ Before handoff:
42
+ - Run the narrow checks that prove the changed surfaces.
43
+ - Report changed files, validation commands, and any remaining risk.
44
+ ```
45
+
46
+ ## Recipe 1: Install Spark In A New App
47
+
48
+ ```text
49
+ Set up Spark Design in this React app.
50
+
51
+ Requirements:
52
+ - Determine whether this project should use CLI copied source or package imports.
53
+ - Prefer CLI copied source unless the project already uses sparkdesign as a
54
+ runtime dependency or I explicitly ask for package mode.
55
+ - If using CLI mode, run npx sparkdesign@latest init and add only the components
56
+ needed for the screen.
57
+ - Configure Tailwind CSS 4 correctly, including @tailwindcss/vite and @source
58
+ for copied Spark components.
59
+ - Set data-theme and data-style on the root or document element.
60
+ - Verify dark mode and at least one portal component if the screen uses overlays.
61
+
62
+ Do not mix CLI copied-source imports with package imports.
63
+ Do not leave Vite starter CSS fighting Spark tokens.
64
+ ```
65
+
66
+ ## Recipe 2: Select Components For A Product Screen
67
+
68
+ ```text
69
+ Design and implement this product screen using Spark Design.
70
+
71
+ Task:
72
+ [Describe the screen, users, data density, and primary workflow.]
73
+
74
+ Process:
75
+ 1. Read registry/agent-manifest.json.
76
+ 2. List the Spark components selected by intent and explain why each one fits.
77
+ 3. Check antiPatterns for every selected component before composing the screen.
78
+ 4. Read registry/tokens/ontology.json and choose token families before styling.
79
+ 5. Implement the screen with tokenized classes and existing Spark primitives.
80
+ 6. Keep workflows efficient: use icons for tools, segmented controls for modes,
81
+ toggles for binary settings, and menus for option sets.
82
+
83
+ Verification:
84
+ - No duplicate local component that Spark already provides.
85
+ - No hard-coded hex/rgb, arbitrary radii, or arbitrary spacing unless explained.
86
+ - Text fits on desktop and mobile.
87
+ - Keyboard/focus behavior remains intact for controls and overlays.
88
+ ```
89
+
90
+ ## Recipe 3: Build An AI Workflow
91
+
92
+ ```text
93
+ Build this AI workflow with Spark Design chat components.
94
+
95
+ Workflow:
96
+ [Describe prompt entry, tool calls, files, approvals, reasoning, generated
97
+ content, error handling, and follow-up prompts.]
98
+
99
+ Use Spark chat components where they match intent:
100
+ - ChatInput for prompt composition and attachments.
101
+ - Response or Markdown for generated answers.
102
+ - ToolInvocationCard for tool execution visibility.
103
+ - PermissionCard or AskUserPart for approval/confirmation.
104
+ - ReasoningStep, PlanPart, TaskPart, or BrowserActionPart for structured agent
105
+ progress.
106
+ - FileCard, FileAttachment, FileReviewPart, and GeneratedImagesGrid for files.
107
+ - RelatedPrompts for next actions.
108
+
109
+ Do not flatten tool calls, approvals, or reasoning into plain Markdown.
110
+ Expose state clearly: pending, streaming, success, blocked, skipped, failed.
111
+ ```
112
+
113
+ ## Recipe 4: Add Or Change A Component
114
+
115
+ ```text
116
+ Add or change this Spark component while keeping the system isomorphic.
117
+
118
+ Component intent:
119
+ [Describe what user problem the component solves and what it should not solve.]
120
+
121
+ Required sequence:
122
+ 1. Search existing registry/basic, registry/chat, and registry/agent-manifest.json
123
+ to confirm this component is not a duplicate.
124
+ 2. Implement source of truth in registry/.
125
+ 3. Keep dependencies public and copy-safe for CLI users.
126
+ 4. Export component and prop types through src/components/.
127
+ 5. Regenerate or validate registry/meta.json and sync cli/registry if needed.
128
+ 6. Add showcase demo blocks with production-like examples and matching snippets.
129
+ 7. Add props metadata and localized labels.
130
+ 8. Update registry/agent-manifest.json with intent, slots, states, a11y,
131
+ composition, antiPatterns, and agentHints.
132
+ 9. Update P3 headers and P2 AGENTS.md maps.
133
+ 10. Run component, registry, showcase, token, and manifest checks.
134
+
135
+ Do not call the component complete until registry, CLI, package exports,
136
+ showcase, docs, and agent manifest agree.
137
+ ```
138
+
139
+ ## Recipe 5: Audit A Spark Change
140
+
141
+ ```text
142
+ Review this Spark Design change as a maintainer.
143
+
144
+ Prioritize:
145
+ - Behavioral bugs and regressions.
146
+ - Drift between registry, CLI, package exports, showcase, docs, and manifest.
147
+ - Token misuse: hard-coded colors, raw rgba, arbitrary spacing/radius, theme
148
+ inheritance failures, and one-off visual language.
149
+ - Accessibility gaps: labels, roles, focus states, keyboard behavior, status
150
+ text, and color-only meaning.
151
+ - Showcase quality: examples should teach real usage and snippets should compile.
152
+ - AI friendliness: manifest intent and antiPatterns should prevent bad agent
153
+ choices.
154
+
155
+ Return findings first with file/line references, then open questions, then a
156
+ short verification summary.
157
+ ```
158
+
159
+ ## Maintainer Checklist
160
+
161
+ - Prompt picked the correct consumption path: CLI copied source or package import.
162
+ - Prompt forced manifest and ontology reads before implementation.
163
+ - Prompt preserved theme/style axes and portal inheritance.
164
+ - Prompt required showcase and docs updates when public behavior changed.
165
+ - Prompt required agent manifest updates for new or changed components.
166
+ - Prompt kept AI-facing docs package-visible when guidance changed.
167
+ - Prompt included concrete verification commands and evidence.
@@ -0,0 +1,213 @@
1
+ # Spark Design Agent Usage Guide
2
+
3
+ > 给 AI agent / coding agent 的执行指南。目标不是介绍组件库是什么,而是约束“在项目里该怎么正确使用它”。
4
+
5
+ ## 1. 默认决策
6
+
7
+ ### 1.1 优先级
8
+
9
+ 默认优先使用 **CLI 按需引入**:
10
+
11
+ ```bash
12
+ npx sparkdesign@latest add button
13
+ ```
14
+
15
+ 只有在以下场景才优先考虑整包安装:
16
+
17
+ - 用户明确要求 `npm install sparkdesign`
18
+ - 目标是快速原型,而不是复制源码后再改
19
+ - 运行环境不方便把组件源码拷入项目
20
+
21
+ ### 1.2 两条使用路径
22
+
23
+ | 路径 | 适用场景 | Agent 默认行为 |
24
+ |------|----------|----------------|
25
+ | **CLI 按需引入** | 业务项目、需要修改组件源码、希望长期维护本地副本 | **默认优先** |
26
+ | **整包安装** | Showcase、快速试用、低定制场景、只想直接 import | 仅在用户明确要求或项目已采用整包模式时使用 |
27
+
28
+ ## 2. CLI 路径怎么用
29
+
30
+ ### 2.1 常用命令
31
+
32
+ ```bash
33
+ npx sparkdesign@latest init
34
+ npx sparkdesign@latest add button
35
+ npx sparkdesign@latest add response
36
+ npx sparkdesign@latest list
37
+ npx sparkdesign@latest diff button
38
+ ```
39
+
40
+ ### 2.2 生成后的默认路径
41
+
42
+ 默认组件会写到:
43
+
44
+ ```text
45
+ src/components/ui/basic/<name>.tsx
46
+ src/components/ui/chat/<name>.tsx
47
+ src/components/ui/chat/<name>/index.tsx
48
+ ```
49
+
50
+ 如果项目里已有 `components.json`,以 `aliases.ui` 为准,不要硬猜路径。
51
+
52
+ ### 2.3 CLI 路径下的 import 规则
53
+
54
+ 默认按以下方式导入:
55
+
56
+ ```tsx
57
+ import { Button } from '@/components/ui/basic/button'
58
+ import { Response } from '@/components/ui/chat/response'
59
+ ```
60
+
61
+ 不要在 CLI 路径下再写:
62
+
63
+ ```tsx
64
+ import { Button } from 'sparkdesign'
65
+ ```
66
+
67
+ 这会把“复制到本地的源码”与“整包运行时”混在一起。
68
+
69
+ ## 3. 整包路径怎么用
70
+
71
+ ### 3.1 安装与导入
72
+
73
+ ```bash
74
+ npm install sparkdesign
75
+ ```
76
+
77
+ ```tsx
78
+ import 'sparkdesign/style'
79
+ import { Button, Response } from 'sparkdesign'
80
+ ```
81
+
82
+ ### 3.2 整包路径下的样式规则
83
+
84
+ 默认优先:
85
+
86
+ ```tsx
87
+ import 'sparkdesign/style'
88
+ ```
89
+
90
+ 只有在消费者自己维护 Tailwind 4 样式管线时,才改用:
91
+
92
+ ```tsx
93
+ import 'sparkdesign/theme.css'
94
+ import 'sparkdesign/scale.css'
95
+ ```
96
+
97
+ ## 4. 主题与 Token 硬规则
98
+
99
+ ### 4.1 一律使用 design tokens
100
+
101
+ 选择 token 前,agent 应优先读取:
102
+
103
+ ```tsx
104
+ import ontology from 'sparkdesign/token-ontology.json'
105
+ ```
106
+
107
+ 仓库内源文件为:
108
+
109
+ ```text
110
+ registry/tokens/ontology.json
111
+ ```
112
+
113
+ 允许:
114
+
115
+ ```tsx
116
+ className="bg-primary text-text rounded-md"
117
+ className="px-[var(--spacing-3)]"
118
+ ```
119
+
120
+ 不允许:
121
+
122
+ ```tsx
123
+ className="bg-[#1890FF] text-[#333] rounded-[10px]"
124
+ ```
125
+
126
+ ### 4.2 根节点主题
127
+
128
+ 优先在根节点或大容器设置:
129
+
130
+ ```tsx
131
+ <div data-theme="light" data-style="neutral" />
132
+ ```
133
+
134
+ 可选值:
135
+
136
+ - `data-theme`: `light` | `dark` | 自定义主题名
137
+ - `data-style`: `neutral` | `compact` | `soft` | `sharp` | `dense`
138
+
139
+ ### 4.3 Portal / 浮层组件
140
+
141
+ Tooltip、DropdownMenu、Toast 这类浮层要考虑 theme/style 继承。若项目已用整包并提供 `ThemeStyleProvider`,优先沿用;不要通过强制 remount 的方式“刷新主题”。
142
+
143
+ ## 5. 组件选择规则
144
+
145
+ ### 5.0 先读 Agent Manifest
146
+
147
+ 设计 / coding agent 在选择组件前,优先读取:
148
+
149
+ ```tsx
150
+ import manifest from 'sparkdesign/agent-manifest.json'
151
+ ```
152
+
153
+ 仓库内源文件为:
154
+
155
+ ```text
156
+ registry/agent-manifest.json
157
+ ```
158
+
159
+ 该 manifest 提供组件 `intent`、`slots`、`states`、`a11y`、`composition`、`antiPatterns` 和常见 `recipes`。选择组件时先按 `intent` 和 `recipes` 匹配,再读源码;不要仅凭组件名相似度决定。
160
+
161
+ ### 5.1 Basic vs Chat
162
+
163
+ - `basic/*`: 原子 UI,适合表单、控制、布局、通用信息展示
164
+ - `chat/*`: 对话流组件,适合消息、响应、任务、推理步骤、附件、代码块等
165
+
166
+ ### 5.2 不要重复造轮子
167
+
168
+ 若以下组件已存在,优先复用:
169
+
170
+ - 通用按钮:`button` / `icon-button`
171
+ - 浮层:`tooltip` / `dropdown-menu` / `alert-dialog`
172
+ - 对话输入:`chat-input`
173
+ - AI 响应:`response`
174
+ - 推理步骤:`reasoning-step`
175
+ - 代码卡片:`code-block-part` / `terminal-code-block-part`
176
+ - 任务与计划:`task-part` / `plan-part`
177
+
178
+ ## 6. 改组件时的约束
179
+
180
+ ### 6.1 Registry 是 CLI 模板真相
181
+
182
+ 若改动会影响 `npx sparkdesign add ...` 的结果,优先检查:
183
+
184
+ - `registry/`
185
+ - `registry/meta.json`
186
+ - `cli/registry/` 是否已由同步脚本刷新
187
+
188
+ ### 6.2 根包是唯一发布入口
189
+
190
+ 不要从 `cli/` 目录单独发布。
191
+
192
+ 正式发布只从仓库根目录执行:
193
+
194
+ ```bash
195
+ npm publish
196
+ ```
197
+
198
+ 根包会同时带上:
199
+
200
+ - 运行时导出(整包)
201
+ - `bin.sparkdesign -> ./cli/dist/index.js`(CLI)
202
+
203
+ ## 7. 给 Agent 的执行清单
204
+
205
+ 开始工作前,优先回答这 5 个问题:
206
+
207
+ 1. 当前项目是在用 **CLI 本地源码**,还是在用 **整包 import**?
208
+ 2. 目标组件属于 `basic` 还是 `chat`?
209
+ 3. 是否已经有可复用组件,而不是新建一个相似组件?
210
+ 4. 样式是否完全基于 token,而不是硬编码?
211
+ 5. 如果会影响 CLI,是否同步检查了 `registry/meta.json` 与发布链路?
212
+
213
+ 如果这 5 个问题里有任何一个答不上来,先不要写代码,先补上下文。
@@ -0,0 +1,148 @@
1
+ # Spark Design Operating Model
2
+
3
+ > The system is excellent only when the implementation, documentation, showcase, registry, and agent contract all describe the same product truth.
4
+
5
+ ## Purpose
6
+
7
+ Showcase companion: `#/system-operating-model`.
8
+
9
+ Spark Design should feel like a world-class product system, not a folder of UI parts. Every addition must improve four surfaces at once:
10
+
11
+ - **Product surface:** components are elegant, restrained, accessible, and token-driven.
12
+ - **System surface:** registry, package exports, CLI copies, and metadata stay isomorphic.
13
+ - **Documentation surface:** users can understand when to use a component, how to install it, and how to extend it without reading source first.
14
+ - **Agent surface:** AI tools can select, compose, and verify components from manifest intent instead of guessing from names.
15
+
16
+ ## Principles
17
+
18
+ ### 1. Quiet Excellence
19
+
20
+ Prefer durable hierarchy over decoration. Components should look precise at rest, clear in motion, and trustworthy under edge cases.
21
+
22
+ Required signals:
23
+
24
+ - Stable spacing, radius, typography, and focus states across all `data-style` values.
25
+ - Semantic color usage through tokens, never one-off palettes in component source.
26
+ - Interaction feedback that clarifies state without delaying work.
27
+ - Empty, loading, disabled, error, and dense-content states handled deliberately.
28
+
29
+ ### 2. Isomorphic Maintenance
30
+
31
+ The map must stay aligned with the terrain. A component is not complete until every public surface agrees.
32
+
33
+ Required surfaces:
34
+
35
+ - `registry/` implementation and dependencies.
36
+ - `registry/meta.json` and `cli/registry/meta.json`.
37
+ - `src/components/index.ts` public exports.
38
+ - Showcase config, demo, props table, and localized labels.
39
+ - `registry/agent-manifest.json` intent, slots, states, a11y, recipes, and anti-patterns.
40
+ - P3 headers and P2 module maps when membership changes.
41
+
42
+ ### 3. AI-Friendly Semantics
43
+
44
+ Spark should be easy for agents to use correctly under time pressure.
45
+
46
+ Agent-facing data must answer:
47
+
48
+ - What user intent does this component satisfy?
49
+ - When should an agent choose a different component?
50
+ - What slots and states are expected?
51
+ - What accessibility obligations are non-negotiable?
52
+ - Which components compose well together?
53
+ - Which anti-patterns produce generic or unsafe UI?
54
+
55
+ If the manifest cannot answer those questions, update the manifest before treating the component as complete.
56
+
57
+ ### 4. Showcase as Product
58
+
59
+ The showcase is the primary trust surface. It should teach by showing real, polished product usage instead of dumping prop variants.
60
+
61
+ Every component page should include:
62
+
63
+ - A strong Overview example that represents the common production use case.
64
+ - One focused block per major dimension: size, state, composition, or variant.
65
+ - Snippets that compile and match the preview.
66
+ - Installation instructions for CLI-first usage.
67
+ - Props that match the actual exported API.
68
+ - Copy that explains when to use the component, not just what props exist.
69
+
70
+ ## Component Addition Flow
71
+
72
+ Use this sequence for every new component or public API change:
73
+
74
+ 1. **Define intent:** Write the component purpose, non-goals, expected states, and likely compositions.
75
+ 2. **Check reuse:** Search existing `basic/*`, `chat/*`, and `agent-manifest.json` before creating anything new.
76
+ 3. **Implement in registry:** Keep registry source standalone, tokenized, typed, and free of package-private imports.
77
+ 4. **Export publicly:** Add package-facing re-exports under `src/components/` and `src/components/index.ts`.
78
+ 5. **Sync registry metadata:** Regenerate and validate `registry/meta.json`; sync CLI registry copies.
79
+ 6. **Teach the showcase:** Add demo blocks, config entry, props metadata, and localized page labels.
80
+ 7. **Teach agents:** Add or update `registry/agent-manifest.json` with intent, states, a11y, composition, anti-patterns, and hints.
81
+ 8. **Update DIP docs:** Refresh P3 headers, P2 maps, and root docs when topology or commands change.
82
+ 9. **Verify:** Run the narrow checks that prove the touched surfaces are aligned.
83
+
84
+ ## Quality Gates
85
+
86
+ Minimum gates for component work:
87
+
88
+ ```bash
89
+ npm run check:agent-manifest
90
+ npm run check:agent-coverage
91
+ npm run check:ai-docs
92
+ npm run check:registry-meta
93
+ npm run check:registry
94
+ npm run check:showcase
95
+ npm run check:showcase-quality
96
+ npm run check:token-antipatterns
97
+ ```
98
+
99
+ Before publishing or merging broad system work, also run:
100
+
101
+ ```bash
102
+ npm run lint
103
+ npm run test:run
104
+ npm run build
105
+ npm run size
106
+ ```
107
+
108
+ ## Review Rubric
109
+
110
+ Use this rubric before calling project-wide polish complete:
111
+
112
+ | Area | Passing standard |
113
+ | ---- | ---------------- |
114
+ | Structure | Source of truth is clear; registry, CLI, package exports, and docs agree. |
115
+ | Components | APIs are small, typed, tokenized, accessible, and composed from existing primitives. |
116
+ | Showcase | Pages feel product-grade, scannable, and useful for both beginners and advanced users. |
117
+ | Docs | Guides explain decisions, not only commands; SOPs prevent drift. |
118
+ | AI contract | Manifest and token ontology make correct component selection obvious. |
119
+ | Maintenance | Verification commands prove the actual changed surfaces, not only a narrow build path. |
120
+
121
+ `npm run check:ai-docs` guards the AI-facing semantic layer: package exports,
122
+ published files, relative links, and Showcase companion pages for the operating
123
+ model, prompt recipes, and component selection guide.
124
+
125
+ `npm run check:showcase-quality` guards the public documentation surface:
126
+ registry-to-showcase coverage, demo exports, props metadata, and locale coverage.
127
+ The default props metadata baseline is 70% and should only move upward. The
128
+ Showcase registry config must not keep parallel `legacy*` maps; `categories`,
129
+ `props`, `dependencies`, and `timeline` are the single source of truth. Duplicate
130
+ component keys inside `props` or `dependencies` are blocked because they silently
131
+ overwrite documentation data.
132
+
133
+ ## Anti-Patterns
134
+
135
+ - Adding a component because a demo needs one instead of validating reusable intent.
136
+ - Shipping source without CLI registry and metadata alignment.
137
+ - Updating showcase copy without updating agent semantics.
138
+ - Writing a component that looks good only in one theme or one `data-style`.
139
+ - Treating the homepage as marketing while component pages remain weak.
140
+ - Letting docs say "token-driven" while source uses raw colors or arbitrary geometry.
141
+
142
+ ## Coverage Ratchet
143
+
144
+ `npm run check:showcase-quality` currently enforces a baseline for component page structure, props metadata, and locale coverage. When props tables or localized copy improve, raise the script thresholds instead of letting quality gains remain informal.
145
+
146
+ ## North Star
147
+
148
+ Spark Design should help humans and agents build calm, coherent AI product interfaces. The strongest version of the project is clean enough for beginners, explicit enough for maintainers, and structured enough for AI systems to use without guesswork.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sparkdesign",
3
- "version": "0.4.9",
3
+ "version": "0.4.10",
4
4
  "type": "module",
5
5
  "description": "Modern React Design System with dual-dimension theme system",
6
6
  "keywords": [
@@ -32,16 +32,26 @@
32
32
  "./theme-base.css": "./dist/theme-base.css",
33
33
  "./agent-manifest.json": "./registry/agent-manifest.json",
34
34
  "./token-ontology.json": "./registry/tokens/ontology.json",
35
+ "./ai-readme.md": "./AI_README.md",
36
+ "./agent-quickref.md": "./AGENT_COMPONENT_LIBRARY_QUICKREF.md",
37
+ "./agent-prompt-recipes.md": "./docs/agent/prompt-recipes.md",
38
+ "./agent-component-selection.md": "./docs/agent/component-selection.md",
39
+ "./agent-token-ontology.md": "./docs/agent/token-ontology.md",
40
+ "./system-operating-model.md": "./docs/guides/system-operating-model.md",
41
+ "./agent-usage.md": "./docs/guides/agent-usage.md",
35
42
  "./tokens/*": "./dist/tokens/*",
36
43
  "./themes/*": "./dist/themes/*",
37
44
  "./scale/*": "./dist/scale/*"
38
45
  },
39
46
  "files": [
40
47
  "AI_README.md",
48
+ "AGENT_COMPONENT_LIBRARY_QUICKREF.md",
41
49
  "dist",
42
50
  "cli/dist",
43
51
  "cli/registry",
44
52
  "docs/agent",
53
+ "docs/guides/agent-usage.md",
54
+ "docs/guides/system-operating-model.md",
45
55
  "registry/agent-manifest.json",
46
56
  "registry/tokens/ontology.json"
47
57
  ],
@@ -56,10 +66,12 @@
56
66
  "gen:registry-meta": "node scripts/generate-registry-meta.mjs",
57
67
  "check:registry-meta": "node scripts/generate-registry-meta.mjs --check && node scripts/validate-registry-meta.mjs registry && node scripts/validate-registry-meta.mjs cli",
58
68
  "check:agent-manifest": "node scripts/validate-agent-manifest.mjs",
69
+ "check:ai-docs": "node scripts/check-ai-docs-package.mjs",
59
70
  "check:token-ontology": "node scripts/validate-token-ontology.mjs",
60
71
  "check:token-antipatterns": "node scripts/check-token-antipatterns.mjs",
61
72
  "check:registry": "node scripts/check-registry-sync.mjs",
62
73
  "check:showcase": "node scripts/check-showcase-sync.mjs",
74
+ "check:showcase-quality": "node scripts/check-showcase-quality.mjs",
63
75
  "report:agent-coverage": "node scripts/report-agent-manifest-coverage.mjs",
64
76
  "check:agent-coverage": "node scripts/report-agent-manifest-coverage.mjs --fail-under=100",
65
77
  "gen:demo": "node scripts/gen-demo.mjs",
@@ -81,7 +93,7 @@
81
93
  "test:smoke:vite": "node scripts/smoke-test-cli.mjs vite",
82
94
  "test:smoke:next": "node scripts/smoke-test-cli.mjs nextjs",
83
95
  "test:smoke:add": "node scripts/smoke-test-cli.mjs pure-add",
84
- "prepublishOnly": "node scripts/generate-registry-meta.mjs && npm run check:agent-manifest && npm run check:agent-coverage && npm run check:token-ontology && npm run check:token-antipatterns && npm run build && node scripts/sync-registry-to-cli.mjs && npm run check:registry-meta"
96
+ "prepublishOnly": "node scripts/generate-registry-meta.mjs && npm run check:agent-manifest && npm run check:agent-coverage && npm run check:ai-docs && npm run check:token-ontology && npm run check:token-antipatterns && npm run check:showcase-quality && npm run build && node scripts/sync-registry-to-cli.mjs && npm run check:registry-meta"
85
97
  },
86
98
  "peerDependencies": {
87
99
  "react": ">=18.0.0",