rafters 0.0.54 → 0.0.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # rafters
2
2
 
3
- Design Intelligence CLI. Scaffold tokens, add components, and serve an MCP server so AI agents build UIs with designer-level judgment instead of guessing.
3
+ Design Intelligence CLI. Encodes a designer's judgment into queryable data so AI agents read decisions instead of guessing at colors, spacing, hierarchy.
4
+
5
+ → [rafters.studio](https://rafters.studio)
4
6
 
5
7
  ## Quick Start
6
8
 
@@ -8,24 +10,31 @@ Design Intelligence CLI. Scaffold tokens, add components, and serve an MCP serve
8
10
  pnpm dlx rafters init
9
11
  ```
10
12
 
11
- This detects your framework, scaffolds `.rafters/` with a complete token system, and generates output files.
13
+ `init` detects your framework, reads your existing CSS (shadcn or Tailwind v4 `@theme` blocks), and produces a complete token system that imports your brand decisions and derives the rest mathematically.
14
+
15
+ ## What `init` does
12
16
 
13
- ## Commands
17
+ On the first run against an existing project, `init` runs an import flow that lifts brand decisions out of your CSS into the token system. Every step emits a discrete event you can read with `--agent`:
14
18
 
15
- ### `rafters init`
19
+ - **Pre-generation base detection** — reads `--spacing` / `--spacing-base`, `--radius` / `--radius-base`, `--text-base` / `--font-size-base`, `--ring-width` / `--focus-ring-width` and threads them into the token generator BEFORE construction. The cascade flows correctly from the first generation; derived namespaces (spacing scale, shadow numerics, radius scale, focus tokens) all match the imported base.
20
+ - **Color import** — walks `:root` semantic declarations (`--primary`, `--background`, etc.) AND `@theme { ... }` multi-palette blocks (Tailwind v4 brand palette convention). Detects ramps (palette-0 through palette-950), runs a designer-driven role-walk in interactive mode or auto-assigns in `--agent` mode.
21
+ - **Font role-walk** — detects every font family loaded by the source (`@import url(google fonts)`, `@font-face`, named `--font-*` declarations) and assigns each to a typography role (`font-heading`, `font-body`, `font-code`). Custom fonts that don't fit a canonical role become their own tokens (`font-aurabesh`, `font-mydisplay`, etc.) so consumers can reference them via Tailwind utilities.
22
+ - **Motion is intentionally untouched** — rafters' motion system is research-backed (perceptual response curves, cognitive thresholds, reduced-motion accommodations); arbitrary `--duration-base` declarations in source are NOT auto-applied. Use `rafters set motion-duration-base ...` if you specifically need to override.
16
23
 
17
- Initialize a project with design tokens.
24
+ ### Modes
18
25
 
19
26
  ```bash
20
- pnpm dlx rafters init # Interactive setup
21
- pnpm dlx rafters init --rebuild # Regenerate output files from existing tokens
22
- pnpm dlx rafters init --reset # Re-run generators fresh, replacing persisted tokens
23
- pnpm dlx rafters init --agent # JSON output for CI/machine consumption
27
+ pnpm dlx rafters init # Interactive prompts for role assignments
28
+ pnpm dlx rafters init --agent # Non-interactive; auto-assigns; emits JSON events
29
+ pnpm dlx rafters init --rebuild # Regenerate output files from existing .rafters/tokens
30
+ pnpm dlx rafters init --reset # Re-run generators from defaults, replacing tokens
24
31
  ```
25
32
 
26
- **Detected frameworks:** Next.js, Vite, Remix, React Router, Astro
33
+ ### Detected frameworks
34
+
35
+ Next.js, Vite, Remix, React Router, Astro, Web Components, vanilla.
27
36
 
28
- **Export formats** (configured during init):
37
+ ### Export formats
29
38
 
30
39
  | Format | File | Default | Description |
31
40
  |--------|------|---------|-------------|
@@ -34,19 +43,29 @@ pnpm dlx rafters init --agent # JSON output for CI/machine consumption
34
43
  | DTCG JSON | `rafters.json` | No | W3C Design Tokens standard format |
35
44
  | Standalone CSS | `rafters.standalone.css` | No | Pre-built, no Tailwind required |
36
45
 
37
- Automatically detects and migrates existing shadcn/ui color values. Requires Tailwind v4.
46
+ Requires Tailwind v4. Tailwind v3 projects are rejected.
47
+
48
+ ## Other commands
38
49
 
39
50
  ### `rafters add [components...]`
40
51
 
41
- Add components from the Rafters registry to your project.
52
+ Add components from the rafters registry to your project.
42
53
 
43
54
  ```bash
44
55
  pnpm dlx rafters add button dialog # Add specific components
45
- pnpm dlx rafters add --list # List all available components
56
+ pnpm dlx rafters add --list # List available components
46
57
  pnpm dlx rafters add --overwrite # Replace existing files
47
58
  ```
48
59
 
49
- Components include embedded design intelligence: cognitive load ratings (1-7), accessibility requirements, do/never guidance, and trust-building patterns. Dependencies are resolved automatically.
60
+ Each component carries embedded design intelligence (cognitive load, accessibility, do/never guidance, variant patterns). Dependencies resolve automatically.
61
+
62
+ ### `rafters set <name> <value>`
63
+
64
+ Override a token value with a recorded reason. The previous value and the why-gate land as `userOverride` metadata so future agents can read your intent.
65
+
66
+ ```bash
67
+ pnpm dlx rafters set spacing-base 0.5rem --reason "denser layout for data-heavy UI"
68
+ ```
50
69
 
51
70
  ### `rafters mcp`
52
71
 
@@ -58,89 +77,98 @@ pnpm dlx rafters mcp
58
77
 
59
78
  ### `rafters studio`
60
79
 
61
- Launch Studio for visual token editing. Spawns a local Vite dev server from the `@rafters/studio` package.
80
+ Launch Studio for visual token editing.
62
81
 
63
82
  ```bash
64
83
  pnpm dlx rafters studio
65
84
  ```
66
85
 
67
- ## MCP Tools
86
+ ## MCP tools
68
87
 
69
- Four tools give AI agents complete design system access:
88
+ Four tools for agent ASSEMBLY (not design). Token design lives in Studio; import lives in `rafters init`. Agents read pre-made decisions; they do not author them.
70
89
 
71
90
  ### `rafters_composite`
72
91
 
73
- Query composites by ID, search term, or category. Returns designer intent (solves, appliesWhen, do/never), I/O rules for chaining, and block structure.
92
+ Query composites by ID, search term, or category. Returns designer intent (solves, appliesWhen, do/never), I/O rules, and block structure.
74
93
 
75
94
  ```json
76
- { "id": "heading" } // Get specific composite
77
- { "query": "form" } // Fuzzy search
78
- { "category": "typography" } // Filter by category
95
+ { "id": "login-form" } // Get a specific composite
96
+ { "query": "form" } // Fuzzy search across composites
97
+ { "category": "typography" } // Filter
79
98
  ```
80
99
 
81
100
  ### `rafters_pattern`
82
101
 
83
- Design pattern guidance by querying composites. Search by what the pattern solves or use fuzzy search.
102
+ Design pattern guidance by querying composites. Search by what the page or section SOLVES.
84
103
 
85
104
  ```json
86
- { "solves": "hierarchy" } // Find patterns for document hierarchy
87
- { "solves": "authentication" } // Find patterns for auth flows
88
- { "query": "form" } // Fuzzy search across composites
105
+ { "solves": "authentication" }
106
+ { "solves": "data entry" }
107
+ { "query": "navigation" }
89
108
  ```
90
109
 
91
- Returns composites with usagePatterns (do/never rules), cognitive load, and designer intent.
110
+ Returns composites with usagePatterns (do/never), cognitive load, and intent.
92
111
 
93
112
  ### `rafters_rule`
94
113
 
95
- Query validation rules or create new ones. Rules are named validation patterns that composites can apply.
114
+ Query validation rules or create new ones. Rules are named patterns composites apply to inputs.
96
115
 
97
116
  ```json
98
117
  {} // List all rules
99
- { "name": "email" } // Get specific rule
100
- { "query": "pass" } // Search rules
118
+ { "name": "email" } // Get a specific rule
101
119
  ```
102
120
 
103
- **Built-in rules:** `required`, `email`, `password`, `url`, `credentials`
121
+ Built-in: `required`, `email`, `password`, `url`, `credentials`.
104
122
 
105
123
  ### `rafters_component`
106
124
 
107
- Full intelligence for a specific component. Cognitive load rating, attention economics, accessibility requirements, trust-building patterns, variants, sizes, and primitives.
125
+ Full intelligence for a specific component: cognitive load, accessibility level, variants, sizes, do/never.
108
126
 
109
127
  ```json
110
128
  { "name": "button" }
111
129
  ```
112
130
 
113
- ## How It Works
114
-
115
- Rafters is a Design Intelligence Protocol. AI agents don't have taste -- they guess at colors, spacing, hierarchy. Rafters encodes a designer's judgment into queryable data so AI reads decisions instead of guessing.
131
+ ## Architecture
116
132
 
117
133
  Three layers:
118
134
 
119
- - **What** (Components) -- 55 React components with embedded intelligence metadata
120
- - **Where** (Tokens) -- 240+ tokens with dependency graph and human override tracking
121
- - **Why** (Decisions) -- Do/never patterns, cognitive load scores, trust patterns, accessibility requirements
135
+ - **What (Components)** React components with embedded intelligence metadata
136
+ - **Where (Tokens)** token dependency graph with human override tracking
137
+ - **Why (Decisions)** composite manifests, do/never patterns, cognitive load scores, trust-building patterns
138
+
139
+ The token system uses OKLCH color space, modular scales based on musical ratios, and a dependency engine that derives related values from primitive bases. Override a base — `spacing-base`, `radius-base`, `font-size-base` — and dependents recompute. Override a leaf (`primary` color, `spacing-4`) and the override anchors the subtree against future upstream changes.
122
140
 
123
- The token system uses OKLCH color space, modular scales based on musical ratios, and a dependency engine that automatically derives related values. When a designer overrides a computed value, the system records the reason so AI agents respect the intent.
141
+ When a designer overrides a computed value, the system records the reason. Agents read the why before they read the what.
124
142
 
125
- ## Project Structure
143
+ ## Project structure
126
144
 
127
145
  ```
128
146
  .rafters/
129
147
  config.rafters.json # Framework paths and export settings
130
148
  tokens/
131
- color.rafters.json # Color tokens with OKLCH values
132
- spacing.rafters.json # Spacing scale
133
- typography.rafters.json # Type scale
149
+ color.rafters.json
150
+ spacing.rafters.json
151
+ typography.rafters.json
152
+ radius.rafters.json
153
+ shadow.rafters.json
154
+ focus.rafters.json
155
+ motion.rafters.json
156
+ depth.rafters.json
157
+ elevation.rafters.json
158
+ breakpoint.rafters.json
159
+ semantic.rafters.json
160
+ fill.rafters.json
161
+ typography-composite.rafters.json
134
162
  output/
135
- rafters.css # Tailwind CSS export
163
+ rafters.css # Tailwind v4 CSS variables
136
164
  rafters.ts # TypeScript constants
137
165
  ```
138
166
 
139
167
  ## Requirements
140
168
 
141
- - Node.js >= 24.12.0
169
+ - Node.js 24.12.0
142
170
  - Tailwind CSS v4
143
- - React >= 19.0.0
171
+ - React 19.0.0 (when using React components)
144
172
 
145
173
  ## License
146
174