@uibot/design-md 0.0.0-stage → 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.
@@ -0,0 +1,172 @@
1
+ ---
2
+ id: vercel-design
3
+ title: Vercel Design System
4
+ category: brand
5
+ tags: [high-contrast, monochrome, minimal, sharp, geist, developer, 极简, 黑白, 高对比, 开发者]
6
+ layer: auto
7
+ ---
8
+
9
+ ## 1. Visual Theme & Atmosphere
10
+
11
+ Vercel is uncompromising black-and-white minimalism. The system is built on pure
12
+ contrast: near-black ink on white (or the inverse in dark mode), with color used
13
+ only as a rare functional signal. Edges are crisp, geometry is exact, and the
14
+ Geist typeface gives everything a clean, slightly technical voice. There is no
15
+ ornament — clarity and speed are the brand. Build interfaces that feel like a
16
+ well-set terminal turned into product UI: sharp, fast, legible, and confident in
17
+ their restraint.
18
+
19
+ ## 2. Color Palette & Roles
20
+
21
+ | Role | Token | Value | Notes |
22
+ | --- | --- | --- | --- |
23
+ | Background | `--bg` | `#ffffff` | light canvas |
24
+ | Background dark | `--bg-dark` | `#000000` | dark canvas |
25
+ | Surface | `--surface` | `#ffffff` | cards (light) |
26
+ | Surface dark | `--surface-dark` | `#0a0a0a` | cards (dark) |
27
+ | Foreground | `--fg` | `#000000` | primary ink (light) |
28
+ | Foreground dark | `--fg-dark` | `#ededed` | primary ink (dark) |
29
+ | Muted foreground | `--fg-muted` | `#666666` | secondary text |
30
+ | Subtle foreground | `--fg-subtle` | `#8f8f8f` | meta, disabled |
31
+ | Accent | `--accent` | `#0070f3` | functional blue (links/focus) |
32
+ | Border | `--border` | `#eaeaea` | hairlines (light) |
33
+ | Border dark | `--border-dark` | `#333333` | hairlines (dark) |
34
+ | Success | `--success` | `#0070f3` | / use blue or green `#50e3c2` |
35
+ | Warning | `--warning` | `#f5a623` | caution |
36
+ | Danger | `--danger` | `#ee0000` | error, destructive |
37
+
38
+ ## 3. Typography Rules
39
+
40
+ - **Sans:** `"Geist", "Geist Sans", -apple-system, "Segoe UI", sans-serif`
41
+ - **Mono:** `"Geist Mono", "SF Mono", ui-monospace, monospace`
42
+
43
+ Geist is geometric and even; headings are bold and tight, body is plain and
44
+ highly legible. Mono is used liberally for code, metrics, and labels to signal
45
+ the developer audience.
46
+
47
+ | Role | Size | Weight | Line-height | Tracking |
48
+ | --- | --- | --- | --- | --- |
49
+ | Display | `3.75rem` | `700` | `1.0` | `-0.04em` |
50
+ | H1 | `2.25rem` | `600` | `1.1` | `-0.03em` |
51
+ | H2 | `1.5rem` | `600` | `1.2` | `-0.02em` |
52
+ | H3 | `1.125rem` | `600` | `1.3` | `-0.012em` |
53
+ | Body | `1rem` | `400` | `1.5` | `-0.005em` |
54
+ | Label | `0.875rem` | `500` | `1.4` | `0` |
55
+ | Caption | `0.8125rem` | `400` | `1.4` | `0` |
56
+ | Mono | `0.875rem` | `400` | `1.5` | `0` |
57
+
58
+ ## 4. Component Stylings
59
+
60
+ ### Buttons
61
+
62
+ - **Primary (light):** bg `#000000`, text `#ffffff`, radius `0.375rem`, padding
63
+ `0.5rem 0.875rem`, weight `500`, font-size `0.875rem`. Hover bg `#383838`.
64
+ Active bg `#000000`. Focus ring `0 0 0 2px #ffffff, 0 0 0 4px #000000`.
65
+ - **Primary (dark):** bg `#ffffff`, text `#000000`. Hover bg `#cccccc`.
66
+ - **Secondary:** bg `transparent`, text `#000000`, border `1px solid #eaeaea`.
67
+ Hover border `#000000`.
68
+ - **Disabled:** bg `#fafafa`, text `#8f8f8f`, border `#eaeaea`.
69
+
70
+ ### Cards
71
+
72
+ - bg `#ffffff`, border `1px solid #eaeaea`, radius `0.5rem`, padding `1.5rem`.
73
+ - No shadow at rest; rely on the hairline border. Optional level-1 on hover.
74
+
75
+ ### Inputs
76
+
77
+ - bg `#ffffff`, border `1px solid #eaeaea`, radius `0.375rem`, height `2.5rem`,
78
+ padding `0 0.75rem`, text `#000000`, placeholder `#8f8f8f`.
79
+ - Focus: border `#000000`, ring `0 0 0 1px #000000`.
80
+
81
+ ### Badges
82
+
83
+ - Pill, radius `9999px`, font-size `0.75rem`, weight `500`, padding
84
+ `0.125rem 0.5rem`, border `1px solid #eaeaea`, text `#000000`. Status
85
+ variants use a small `0.5rem` colored dot rather than a fill.
86
+
87
+ ### Navigation
88
+
89
+ - Top bar, bg `rgba(255,255,255,0.8)` + `backdrop-filter: blur(8px)`,
90
+ height `4rem`, border-bottom `1px solid #eaeaea`. Links `#666666`; active/hover
91
+ `#000000`. Avatar/CTA on the right.
92
+
93
+ ## 5. Layout Principles
94
+
95
+ - **Spacing scale:** `0.25rem · 0.5rem · 0.75rem · 1rem · 1.5rem · 2rem · 4rem · 6rem`.
96
+ - **Container max-width:** `75rem` (1200px), side padding `1.5rem`.
97
+ - **Grid:** 12-column, gutter `1.5rem`; precise, aligned to an `8px` baseline.
98
+ - **Whitespace:** ample but exact — alignment matters more than padding size.
99
+ - **Radius scale:** `sm 0.25rem · md 0.375rem · lg 0.5rem · xl 0.75rem · full 9999px`.
100
+
101
+ ## 6. Depth & Elevation
102
+
103
+ Elevation is mostly avoided; structure comes from borders and contrast.
104
+
105
+ | Level | Use | Shadow |
106
+ | --- | --- | --- |
107
+ | 0 | flat (default) | `none` |
108
+ | 1 | hovered card | `0 2px 4px rgba(0,0,0,0.06)` |
109
+ | 2 | dropdown, popover | `0 4px 12px rgba(0,0,0,0.1)` |
110
+ | 3 | modal | `0 12px 32px rgba(0,0,0,0.16)` |
111
+
112
+ ## 7. Do's and Don'ts
113
+
114
+ **Do**
115
+
116
+ - Lead with pure black and white; treat color as a rare functional signal.
117
+ - Use hairline `#eaeaea` borders to define structure instead of shadows.
118
+ - Use Geist Mono for code, metrics, and technical labels.
119
+ - Apply tight negative tracking to large headings.
120
+ - Keep edges sharp and alignment exact (snap to an `8px` grid).
121
+
122
+ **Don't**
123
+
124
+ - Don't introduce decorative gradients or multiple accent colors.
125
+ - Don't soften the look with heavy shadows or large radii.
126
+ - Don't reduce contrast below clearly legible black-on-white.
127
+ - Don't add ornament; if it isn't functional, remove it.
128
+ - Don't mix many font weights — bold for headings, regular for body.
129
+
130
+ ## 8. Responsive Behavior
131
+
132
+ | Breakpoint | Min width | Behavior |
133
+ | --- | --- | --- |
134
+ | `sm` | `640px` | single column, full-width |
135
+ | `md` | `768px` | 2-column grids |
136
+ | `lg` | `1024px` | full 12-column layout |
137
+ | `xl` | `1280px` | max container `75rem` |
138
+
139
+ - **Touch targets:** minimum `44px × 44px`; buttons keep `2.5rem` height.
140
+ - **Collapsing strategy:** nav collapses to a hamburger below `md`; multi-column
141
+ grids stack to one column; preserve hairline dividers when stacked.
142
+
143
+ ## 9. Agent Prompt Guide
144
+
145
+ ### Quick Color Reference
146
+
147
+ - Ink: `#000000` (dark mode `#ededed`)
148
+ - Canvas: `#ffffff` (dark mode `#000000`)
149
+ - Muted: `#666666` · Subtle: `#8f8f8f`
150
+ - Border: `#eaeaea` (dark `#333333`)
151
+ - Accent (functional): `#0070f3` · Danger `#ee0000` · Warning `#f5a623`
152
+
153
+ ### Example prompts (copy-paste)
154
+
155
+ 1. "Generate a dashboard stat card in the Vercel system: white surface, `1px
156
+ #eaeaea` border, radius `0.5rem`, no shadow; a metric in Geist Mono
157
+ `0.875rem`, a label in `#666666`, and a tiny `0.5rem` status dot instead of a
158
+ filled badge."
159
+ 2. "Build a top nav: `4rem` tall, `rgba(255,255,255,0.8)` with `blur(8px)`,
160
+ `1px #eaeaea` bottom border, links in `#666666` turning `#000000` on hover,
161
+ and a black primary button (`#000000`/white, radius `0.375rem`) on the right."
162
+ 3. "Create a deploy log panel: `#000000` canvas, `#ededed` text, Geist Mono
163
+ `0.875rem`/`1.5` line-height, `#333333` hairline rows, blue `#0070f3` for
164
+ active/link states only. Sharp corners, no shadow."
165
+
166
+ ### Iteration guide
167
+
168
+ 1. Strip color: render in pure black and white first.
169
+ 2. Define structure with `#eaeaea` hairlines, not shadows.
170
+ 3. Add Geist Mono wherever data or code appears.
171
+ 4. Tighten heading tracking and keep edges sharp (no large radii).
172
+ 5. Reintroduce one functional accent (`#0070f3`/`#ee0000`) only where it signals.
@@ -0,0 +1,15 @@
1
+ import type { DesignMd } from "@uibot/contracts";
2
+ import type { DesignMdRegistry } from "./registry.js";
3
+ /** Absolute path to the bundled `content/` directory (resolved from this module). */
4
+ export declare const DESIGN_MD_CONTENT_DIR: string;
5
+ /**
6
+ * Load the bundled `*.design.md` seed files. Non-seed files (README.md) and
7
+ * scaffolds (anything starting with `_`, e.g. `_TEMPLATE.design.md`) are
8
+ * skipped. Files that fail to parse are skipped with a warning, not thrown.
9
+ */
10
+ export declare function loadBundledDesignMdContent(dir?: string): DesignMd[];
11
+ /**
12
+ * Seed a registry with bundled design-md files, honouring each file's
13
+ * declared `layer` (default `"auto"`). Returns the entries that were added.
14
+ */
15
+ export declare function seedDesignMdRegistry(registry: DesignMdRegistry, dir?: string): DesignMd[];
@@ -0,0 +1,111 @@
1
+ /**
2
+ * `DesignMdEvolutionAdapter` —— 让 design-md 条目走和 SKILL.md 同样的"失败
3
+ * 信号 → 反思 → 改写提案 → 晋升 override"演化闭环,而不需要把 design-md
4
+ * 假装成 SKILL 喂给 `SkillEvolver`。
5
+ *
6
+ * 设计动机(v2.16 s3):
7
+ * - `frontend-principles.md` 等 design-md 条目本质上和 SKILL.md 同形态——
8
+ * 一段 LLM 看的 markdown body,可被用户反馈(thumb-down / render-fail)
9
+ * 驱动改写。
10
+ * - `@uibot/skills` 已经有完整的 ReflectionStore(JSONL 反思记忆)和
11
+ * SkillEvolver(poll → propose → AutoPromoter 晋升)基础设施,但它们
12
+ * 紧耦合在 `SkillRegistry`/`SkillUsageStore` 之上;要让 design-md 接入,
13
+ * 最干净的做法是**纯组合复用**:
14
+ *
15
+ * failure signal ─► recordFailure() ─► ReflectionStore.append()
16
+ * │ (reuse skills' JSONL store
17
+ * │ using designMdId as the
18
+ * │ storage key — schema-compatible
19
+ * │ with skillId field)
20
+ * ▼
21
+ * caller ─► proposeRewrite() ─► gather recent reflections ─►
22
+ * inject as failureContext ─► generateImprovedBody() ─►
23
+ * returns proposed body (NOT persisted yet)
24
+ * │
25
+ * caller ─► applyOverride(proposed) ─► DesignMdRegistry.add(...,
26
+ * { layer: "override" })
27
+ *
28
+ * 不引入新 capability、新 store、新 evolver;只用一个 ~80 行的适配层把已有
29
+ * 三个基础设施(DesignMdRegistry / ReflectionStore / 调用方注入的
30
+ * generateImprovedBody)串起来。
31
+ */
32
+ import type { DesignMd, SkillReflectionRecord } from "@uibot/contracts";
33
+ import type { DesignMdRegistry } from "./registry.js";
34
+ /**
35
+ * 调用方注入的"用 LLM 改写"函数。
36
+ *
37
+ * 设计 mirror `SkillEvolverOptions.generateImprovedBody` 的形态,方便复用
38
+ * 同一个 LLM client(control-plane 那边的实现会直接转交给 modelRegistry)。
39
+ *
40
+ * `failureContext` 由 adapter 拼装:最近 N 条反思 + 当前 design-md id,
41
+ * 实现侧只负责调 LLM。
42
+ */
43
+ export type GenerateImprovedDesignMdBody = (input: {
44
+ designMdId: string;
45
+ currentBody: string;
46
+ failureContext: string;
47
+ }) => Promise<string>;
48
+ /**
49
+ * 最小的 ReflectionStore 接口 —— 只用到 `append` 和 `recent`。声明在 adapter
50
+ * 这边而不直接 import `@uibot/skills`,避免 @uibot/design-md 反向依赖
51
+ * @uibot/skills。control-plane 接线时把 SkillReflectionStore 强制转型为这
52
+ * 个接口传进来即可。
53
+ */
54
+ export interface DesignMdReflectionStoreShape {
55
+ append(record: SkillReflectionRecord): void;
56
+ recent(id: string, limit?: number): SkillReflectionRecord[];
57
+ }
58
+ export interface DesignMdEvolutionAdapterOptions {
59
+ /** Design-md 条目 id(≡ ReflectionStore 中 skillId 字段的存储 key)。 */
60
+ designMdId: string;
61
+ /** 维护权威 design-md 条目集合的 registry。 */
62
+ registry: DesignMdRegistry;
63
+ /** 复用 @uibot/skills 的 JSONL 反思记忆。 */
64
+ reflectionStore: DesignMdReflectionStoreShape;
65
+ /** 实际调 LLM 的改写函数。 */
66
+ generateImprovedBody: GenerateImprovedDesignMdBody;
67
+ /** 注入 prompt 的最近反思条数。默认 10。 */
68
+ reflectionLimit?: number;
69
+ /** ISO 时间戳工厂;测试可注入确定值。 */
70
+ now?: () => string;
71
+ }
72
+ export interface DesignMdEvolutionProposal {
73
+ designMdId: string;
74
+ baseVersion: string;
75
+ proposedBody: string;
76
+ reflectionCount: number;
77
+ generatedAt: string;
78
+ }
79
+ export declare class DesignMdEvolutionAdapter {
80
+ private readonly options;
81
+ constructor(options: DesignMdEvolutionAdapterOptions);
82
+ /**
83
+ * 记录一次失败信号(render-fail / 用户 thumb-down)。仅写入 ReflectionStore,
84
+ * 不会立即触发 proposal —— 调用方按节奏(定时 / 达到阈值)再调
85
+ * `proposeRewrite()`。
86
+ */
87
+ recordFailure(input: {
88
+ trigger: SkillReflectionRecord["trigger"];
89
+ reflection: string;
90
+ context?: string;
91
+ }): void;
92
+ /**
93
+ * 拉最近 N 条反思 + 当前 body → 调 generateImprovedBody → 返回提案。
94
+ * **不写盘、不替换 registry** —— 让调用方先 review / regression check 再决
95
+ * 定是否 `applyOverride`。
96
+ *
97
+ * 找不到当前 design-md 时返回 null(防止幻觉一份不存在的 body)。
98
+ */
99
+ proposeRewrite(): Promise<DesignMdEvolutionProposal | null>;
100
+ /**
101
+ * 把已审 proposal 应用为 layer="override" 的新版本。后续
102
+ * `composeSystemPrompt` 命中该 id 时拿到的就是 override 版本(priority
103
+ * `override > user > auto`)。
104
+ *
105
+ * 原条目的 frontmatter(title / category / tags / extractedTokens 等)
106
+ * 全部保留,只替换 body。
107
+ */
108
+ applyOverride(proposal: DesignMdEvolutionProposal): DesignMd | null;
109
+ }
110
+ /** 公开工厂式入口,与 `@uibot/skills` 的 `createSkillRegistry` 命名风格对齐。 */
111
+ export declare function createDesignMdEvolutionAdapter(options: DesignMdEvolutionAdapterOptions): DesignMdEvolutionAdapter;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Serialize design-md registry entries to portable `.design.md` text (v2.28 SC-5).
3
+ * Pure: no network, no auth. Handler layer owns exposure.
4
+ */
5
+ import type { DesignMd } from "@uibot/contracts";
6
+ import type { DesignMdRegistry } from "./registry.js";
7
+ /**
8
+ * Serialize one DesignMd entry to a full markdown file (frontmatter + body).
9
+ * Round-trips through parseFrontmatter for core identity fields.
10
+ */
11
+ export declare function serializeDesignMdFile(entry: DesignMd): string;
12
+ /**
13
+ * Export the merged registry view as id → file content.
14
+ * `registry.list()` already applies layer priority (override > user > auto).
15
+ */
16
+ export declare function exportDesignMdRegistry(registry: Pick<DesignMdRegistry, "list">): Record<string, string>;
17
+ /** Assert serialize → parseFrontmatter preserves identity fields. */
18
+ export declare function assertSerializeRoundTrip(entry: DesignMd): void;
@@ -0,0 +1,7 @@
1
+ import type { DesignMd } from "@uibot/contracts";
2
+ /**
3
+ * Scan `dir` recursively for `*.md` files and parse each as a DesignMd entry.
4
+ * Files that fail to parse (missing frontmatter, missing required fields) are skipped
5
+ * with a console warning rather than throwing.
6
+ */
7
+ export declare function scanDesignMdDir(dir: string): DesignMd[];
@@ -0,0 +1,30 @@
1
+ import type { UIBotPlugin } from "@uibot/contracts";
2
+ import { DesignMdRegistry } from "./registry.js";
3
+ import { DesignMdSelectorImpl } from "./selector.js";
4
+ export { loadDesignMdFile } from "./loader.js";
5
+ export { PROJECT_DESIGN_MD_ID, defaultProjectDesignRoots, loadProjectDesignMd, loadProjectDesignMdFromRoots, projectDesignMdPath, projectDesignMdTemplate, readLinkedConsumerRoot, } from "./project-design.js";
6
+ export type { ProjectDesignLoad } from "./project-design.js";
7
+ export { scanDesignMdDir } from "./fs-source.js";
8
+ export { DESIGN_MD_CONTENT_DIR, loadBundledDesignMdContent, seedDesignMdRegistry, } from "./content.js";
9
+ export { DesignMdRegistry } from "./registry.js";
10
+ export { DesignMdSelectorImpl } from "./selector.js";
11
+ export { extractTokensFromBody } from "./tokens.js";
12
+ export type { DesignMdFrontmatter } from "./schema.js";
13
+ export { syncDesignMdFromRemote, resolveRemoteSource, injectAttribution, isDesignMdName, MAX_DESIGN_MD_BYTES, } from "./remote-source.js";
14
+ export { serializeDesignMdFile, exportDesignMdRegistry, assertSerializeRoundTrip, } from "./export.js";
15
+ export type { RemoteSyncOptions, RemoteSyncResult, RemoteSyncFileResult, FetchLike, ResolvedRemoteSource, } from "./remote-source.js";
16
+ export { DesignMdEvolutionAdapter, createDesignMdEvolutionAdapter, } from "./evolution-adapter.js";
17
+ export type { DesignMdEvolutionAdapterOptions, DesignMdEvolutionProposal, DesignMdReflectionStoreShape, GenerateImprovedDesignMdBody, } from "./evolution-adapter.js";
18
+ export interface UIBotDesignMdPluginOptions {
19
+ /** Directory to scan for `.md` files (default: `process.cwd()/.uibot/design-md`) */
20
+ dir?: string;
21
+ }
22
+ /**
23
+ * Create a UIBot plugin that loads all `.md` files from `dir` and registers
24
+ * each as a `designMd:source` capability. Also exposes a `DesignMdSelector`
25
+ * via the exported `createSelector()` method.
26
+ */
27
+ export declare function createUIBotDesignMdPlugin(options?: UIBotDesignMdPluginOptions): UIBotPlugin & {
28
+ registry: DesignMdRegistry;
29
+ createSelector(): DesignMdSelectorImpl;
30
+ };