ai-props 2.0.2 → 2.1.3

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.
@@ -1,5 +1,4 @@
1
-
2
- 
3
- > ai-props@2.0.1 build /Users/nathanclevenger/projects/primitives.org.ai/packages/ai-props
4
- > tsc
5
-
1
+
2
+ > ai-props@2.1.3 build /Users/nathanclevenger/projects/primitives.org.ai/packages/ai-props
3
+ > tsc
4
+
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # ai-props
2
2
 
3
+ ## 2.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Documentation and testing improvements
8
+ - Add deterministic AI testing suite with self-validating patterns
9
+ - Apply StoryBrand narrative to all package READMEs
10
+ - Update TESTING.md with four principles of deterministic AI testing
11
+ - Fix duplicate examples package name conflict
12
+
13
+ - Updated dependencies
14
+ - ai-functions@2.1.3
15
+
16
+ ## 2.1.1
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [6beb531]
21
+ - ai-functions@2.1.1
22
+
23
+ ## 2.0.3
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies
28
+ - rpc.do@0.2.0
29
+ - ai-functions@2.0.3
30
+
3
31
  ## 2.0.2
4
32
 
5
33
  ### Patch Changes
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 .org.ai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,44 +1,43 @@
1
1
  # ai-props
2
2
 
3
- AI-powered props primitives for intelligent component properties.
3
+ **Stop manually writing placeholder props. Let AI fill in the blanks.**
4
4
 
5
- ## Overview
5
+ You've built a beautiful component library. But every time you use a component, you're stuck inventing placeholder text, mock data, and dummy content. Your `<UserCard />` needs a bio. Your `<ProductCard />` needs a description. Your `<SEOHead />` needs meta tags.
6
6
 
7
- `ai-props` provides utilities for automatically generating component props using AI based on schema definitions. It's designed to work seamlessly with React components, Next.js, and other frameworks.
7
+ What if your components could intelligently complete themselves?
8
8
 
9
- ## Installation
10
-
11
- ```bash
12
- npm install ai-props
13
- ```
14
-
15
- ## Quick Start
9
+ ## Before & After
16
10
 
17
11
  ```typescript
18
- import { AI, generateProps } from 'ai-props'
19
-
20
- // Define an AI-powered component schema
12
+ // BEFORE: Manual placeholder props (tedious, repetitive, inconsistent)
13
+ <UserCard
14
+ name="John Doe"
15
+ bio="Lorem ipsum dolor sit amet..." // You've typed this a thousand times
16
+ avatar="/placeholder.png"
17
+ />
18
+
19
+ // AFTER: AI-powered props (intelligent, contextual, automatic)
21
20
  const UserCard = AI({
22
21
  schema: {
23
22
  name: 'User name',
24
23
  bio: 'User biography',
25
24
  avatar: 'Avatar URL',
26
25
  },
27
- defaults: {
28
- avatar: '/default-avatar.png',
29
- },
30
26
  })
31
27
 
32
- // Generate props with AI
33
- const props = await UserCard({ name: 'John' })
34
- // { name: 'John', bio: 'AI-generated bio...', avatar: '/default-avatar.png' }
28
+ const props = await UserCard({ name: 'John Doe' })
29
+ // { name: 'John Doe', bio: 'Software engineer passionate about...', avatar: 'https://...' }
35
30
  ```
36
31
 
37
- ## Core Features
32
+ ## Quick Start
33
+
34
+ ### 1. Install
38
35
 
39
- ### AI() Wrapper
36
+ ```bash
37
+ npm install ai-props
38
+ ```
40
39
 
41
- Create AI-powered component wrappers that automatically fill in missing props:
40
+ ### 2. Define Your Schema
42
41
 
43
42
  ```typescript
44
43
  import { AI } from 'ai-props'
@@ -49,17 +48,48 @@ const ProductCard = AI({
49
48
  description: 'Product description',
50
49
  price: 'Price (number)',
51
50
  },
52
- required: ['price'], // Required props won't be generated
53
- exclude: ['internal'], // Exclude props from generation
51
+ required: ['price'], // AI won't generate required props
54
52
  })
53
+ ```
54
+
55
+ ### 3. Generate Props
55
56
 
56
- // Use the component
57
+ ```typescript
57
58
  const props = await ProductCard({ price: 99 })
59
+ // { title: 'Premium Widget Pro', description: 'A high-quality...', price: 99 }
58
60
  ```
59
61
 
60
- ### generateProps()
62
+ That's it. Your components now complete themselves intelligently.
63
+
64
+ ---
65
+
66
+ ## Core API
61
67
 
62
- Low-level function for direct prop generation:
68
+ ### `AI()` - The Smart Component Wrapper
69
+
70
+ Wrap any component schema to enable intelligent prop generation:
71
+
72
+ ```typescript
73
+ import { AI } from 'ai-props'
74
+
75
+ const UserCard = AI({
76
+ schema: {
77
+ name: 'Full name of the user',
78
+ bio: 'A short biography',
79
+ avatar: 'URL to avatar image',
80
+ },
81
+ defaults: {
82
+ avatar: '/default-avatar.png',
83
+ },
84
+ exclude: ['internal'], // Never generate these props
85
+ })
86
+
87
+ const props = await UserCard({ name: 'Jane' })
88
+ ```
89
+
90
+ ### `generateProps()` - Low-Level Generation
91
+
92
+ Direct access to prop generation with full metadata:
63
93
 
64
94
  ```typescript
65
95
  import { generateProps } from 'ai-props'
@@ -73,14 +103,14 @@ const result = await generateProps({
73
103
  context: { topic: 'AI-powered applications' },
74
104
  })
75
105
 
76
- console.log(result.props) // Generated props
77
- console.log(result.cached) // Whether result came from cache
78
- console.log(result.metadata) // Model info, duration, etc.
106
+ console.log(result.props) // Generated props
107
+ console.log(result.cached) // Cache hit?
108
+ console.log(result.metadata) // Model info, duration
79
109
  ```
80
110
 
81
- ### createAIComponent()
111
+ ### `createAIComponent()` - Full TypeScript Support
82
112
 
83
- Create typed AI components:
113
+ Get complete type inference for your generated props:
84
114
 
85
115
  ```typescript
86
116
  import { createAIComponent } from 'ai-props'
@@ -94,18 +124,19 @@ interface ProductProps {
94
124
  const ProductCard = createAIComponent<ProductProps>({
95
125
  schema: {
96
126
  title: 'Product title',
97
- price: 'Price (number)',
127
+ price: 'Price in USD (number)',
98
128
  description: 'Product description',
99
129
  },
100
130
  })
101
131
 
102
- const props = await ProductCard({})
103
- // props is typed as ProductProps
132
+ const props = await ProductCard({}) // Typed as ProductProps
104
133
  ```
105
134
 
106
- ### createComponentFactory()
135
+ ---
107
136
 
108
- Create a factory for generating multiple instances:
137
+ ## Batch & Factory Patterns
138
+
139
+ ### Generate Multiple Items
109
140
 
110
141
  ```typescript
111
142
  import { createComponentFactory } from 'ai-props'
@@ -117,25 +148,18 @@ const factory = createComponentFactory({
117
148
  },
118
149
  })
119
150
 
120
- // Generate a single instance
151
+ // Single item
121
152
  const product = await factory.generate({ category: 'electronics' })
122
153
 
123
- // Generate multiple instances
154
+ // Multiple items in parallel
124
155
  const products = await factory.generateMany([
125
156
  { category: 'electronics' },
126
157
  { category: 'clothing' },
158
+ { category: 'home' },
127
159
  ])
128
-
129
- // Generate with overrides
130
- const custom = await factory.generateWith(
131
- { category: 'tech' },
132
- { price: 99 }
133
- )
134
160
  ```
135
161
 
136
- ### composeAIComponents()
137
-
138
- Compose multiple schemas together:
162
+ ### Compose Multiple Schemas
139
163
 
140
164
  ```typescript
141
165
  import { composeAIComponents } from 'ai-props'
@@ -155,11 +179,11 @@ const profile = await FullProfile({
155
179
  })
156
180
  ```
157
181
 
158
- ## HOC Utilities
182
+ ---
159
183
 
160
- ### createPropsEnhancer()
184
+ ## SSR & Framework Integration
161
185
 
162
- Create a props enhancer for any component system:
186
+ ### Props Enhancer
163
187
 
164
188
  ```typescript
165
189
  import { createPropsEnhancer } from 'ai-props'
@@ -169,15 +193,13 @@ const enhancer = createPropsEnhancer({
169
193
  title: 'Page title',
170
194
  description: 'Page description',
171
195
  },
172
- defaults: { title: 'Default Title' },
196
+ defaults: { title: 'My App' },
173
197
  })
174
198
 
175
- const props = await enhancer({ description: 'My page' })
199
+ const props = await enhancer({ description: 'Welcome page' })
176
200
  ```
177
201
 
178
- ### createAsyncPropsProvider()
179
-
180
- Create an async props provider for SSR:
202
+ ### Async Props Provider (Next.js)
181
203
 
182
204
  ```typescript
183
205
  import { createAsyncPropsProvider } from 'ai-props'
@@ -196,9 +218,7 @@ export async function getStaticProps() {
196
218
  }
197
219
  ```
198
220
 
199
- ### createBatchGenerator()
200
-
201
- Generate props for multiple items efficiently:
221
+ ### Batch Generation
202
222
 
203
223
  ```typescript
204
224
  import { createBatchGenerator } from 'ai-props'
@@ -214,15 +234,16 @@ const items = await batch.generate([
214
234
  ])
215
235
  ```
216
236
 
217
- ## Validation
237
+ ---
218
238
 
219
- ### validateProps()
239
+ ## Validation
220
240
 
221
- Validate props against a schema:
241
+ Ensure your props match expectations:
222
242
 
223
243
  ```typescript
224
- import { validateProps } from 'ai-props'
244
+ import { validateProps, assertValidProps } from 'ai-props'
225
245
 
246
+ // Validate and get errors
226
247
  const result = validateProps(
227
248
  { name: 'John', age: '25' },
228
249
  { name: 'Name', age: 'Age (number)' }
@@ -232,78 +253,56 @@ if (!result.valid) {
232
253
  console.log(result.errors)
233
254
  // [{ path: 'age', message: 'Expected number, got string' }]
234
255
  }
235
- ```
236
-
237
- ### assertValidProps()
238
256
 
239
- Assert props are valid (throws on error):
240
-
241
- ```typescript
242
- import { assertValidProps } from 'ai-props'
243
-
244
- assertValidProps(
245
- { name: 'John', age: 25 },
246
- { name: 'Name', age: 'Age (number)' }
247
- )
257
+ // Or throw on invalid
258
+ assertValidProps(props, schema)
248
259
  ```
249
260
 
250
- ### Other Validation Utilities
261
+ ### Validation Utilities
251
262
 
252
263
  ```typescript
253
264
  import {
254
265
  hasRequiredProps,
255
266
  getMissingProps,
256
267
  isComplete,
257
- getMissingFromSchema,
258
268
  sanitizeProps,
259
269
  mergeWithDefaults,
260
270
  createValidator,
261
271
  } from 'ai-props'
262
272
 
263
- // Check required props
264
- hasRequiredProps({ name: 'John' }, ['name', 'email']) // false
265
-
266
- // Get missing props
267
- getMissingProps({ name: 'John' }, ['name', 'email']) // ['email']
268
-
269
- // Check schema completion
270
- isComplete({ name: 'John' }, { name: 'Name', age: 'Age' }) // false
271
-
272
- // Sanitize extra props
273
- sanitizeProps({ name: 'John', extra: 'value' }, { name: 'Name' })
274
- // { name: 'John' }
273
+ hasRequiredProps({ name: 'John' }, ['name', 'email']) // false
274
+ getMissingProps({ name: 'John' }, ['name', 'email']) // ['email']
275
+ isComplete({ name: 'John' }, { name: 'Name', age: 'Age' }) // false
276
+ sanitizeProps({ name: 'John', extra: 'x' }, { name: 'Name' }) // { name: 'John' }
275
277
 
276
- // Merge with defaults
277
- mergeWithDefaults({ name: 'John' }, { age: 0 }, { name: 'Name', age: 'Age' })
278
- // { name: 'John', age: 0 }
279
-
280
- // Create reusable validator
281
278
  const validate = createValidator({ name: 'Name', age: 'Age (number)' })
282
- validate({ name: 'John', age: 25 }) // { valid: true, errors: [] }
279
+ validate({ name: 'John', age: 25 }) // { valid: true, errors: [] }
283
280
  ```
284
281
 
282
+ ---
283
+
285
284
  ## Caching
286
285
 
287
- ### Cache Configuration
286
+ Avoid redundant AI calls with built-in caching:
288
287
 
289
288
  ```typescript
290
289
  import { configureAIProps, configureCache, clearCache } from 'ai-props'
291
290
 
292
- // Configure global settings
291
+ // Global configuration
293
292
  configureAIProps({
294
293
  model: 'gpt-4',
295
294
  cache: true,
296
- cacheTTL: 5 * 60 * 1000, // 5 minutes
295
+ cacheTTL: 5 * 60 * 1000, // 5 minutes
297
296
  })
298
297
 
299
- // Configure cache with custom TTL
300
- configureCache(10 * 60 * 1000) // 10 minutes
298
+ // Or configure cache directly
299
+ configureCache(10 * 60 * 1000)
301
300
 
302
- // Clear all cached props
301
+ // Clear when needed
303
302
  clearCache()
304
303
  ```
305
304
 
306
- ### Cache Classes
305
+ ### Cache Implementations
307
306
 
308
307
  ```typescript
309
308
  import { MemoryPropsCache, LRUPropsCache } from 'ai-props'
@@ -314,17 +313,15 @@ const memCache = new MemoryPropsCache(5 * 60 * 1000)
314
313
  // LRU cache with max entries
315
314
  const lruCache = new LRUPropsCache(100, 5 * 60 * 1000)
316
315
 
317
- // Cache operations
318
316
  lruCache.set('key', { name: 'John' })
319
317
  const entry = lruCache.get<{ name: string }>('key')
320
- lruCache.delete('key')
321
- lruCache.clear()
322
- console.log(lruCache.size)
323
318
  ```
324
319
 
320
+ ---
321
+
325
322
  ## Schema Type Hints
326
323
 
327
- Use type hints in schema strings:
324
+ Use type hints in your schema strings for precise generation:
328
325
 
329
326
  ```typescript
330
327
  const schema = {
@@ -341,33 +338,31 @@ const schema = {
341
338
  }
342
339
  ```
343
340
 
341
+ ---
342
+
344
343
  ## Configuration
345
344
 
346
345
  ```typescript
347
346
  import { configureAIProps, getConfig, resetConfig } from 'ai-props'
348
347
 
349
- // Configure globally
350
348
  configureAIProps({
351
- model: 'sonnet', // Default model
352
- cache: true, // Enable caching
353
- cacheTTL: 300000, // Cache TTL in ms
354
- system: 'Custom prompt', // System prompt
349
+ model: 'sonnet',
350
+ cache: true,
351
+ cacheTTL: 300000,
352
+ system: 'Generate realistic, contextual content',
355
353
  generate: async (schema, context) => {
356
- // Custom generator
357
- return { /* generated props */ }
354
+ // Custom generation logic
355
+ return { /* props */ }
358
356
  },
359
357
  })
360
358
 
361
- // Get current config
362
359
  const config = getConfig()
363
-
364
- // Reset to defaults
365
360
  resetConfig()
366
361
  ```
367
362
 
368
- ## API Reference
363
+ ---
369
364
 
370
- ### Types
365
+ ## TypeScript Reference
371
366
 
372
367
  ```typescript
373
368
  interface PropSchema {
@@ -412,6 +407,22 @@ interface ValidationError {
412
407
  }
413
408
  ```
414
409
 
410
+ ---
411
+
412
+ ## What You Achieve
413
+
414
+ With `ai-props`, you:
415
+
416
+ - **Ship faster** - No more inventing placeholder content
417
+ - **Stay consistent** - AI generates contextually appropriate props
418
+ - **Type safely** - Full TypeScript inference throughout
419
+ - **Cache intelligently** - Avoid redundant AI calls
420
+ - **Scale effortlessly** - Batch generation for multiple items
421
+
422
+ Your components become smarter. Your development becomes faster. Your content becomes consistent.
423
+
424
+ ---
425
+
415
426
  ## License
416
427
 
417
428
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-props",
3
- "version": "2.0.2",
3
+ "version": "2.1.3",
4
4
  "description": "AI-powered props primitives for intelligent component properties",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -11,17 +11,8 @@
11
11
  "types": "./dist/index.d.ts"
12
12
  }
13
13
  },
14
- "scripts": {
15
- "build": "tsc",
16
- "dev": "tsc --watch",
17
- "test": "vitest",
18
- "typecheck": "tsc --noEmit",
19
- "lint": "eslint .",
20
- "clean": "rm -rf dist"
21
- },
22
14
  "dependencies": {
23
- "ai-functions": "2.0.2",
24
- "rpc.do": "^0.1.0"
15
+ "ai-functions": "2.1.3"
25
16
  },
26
17
  "devDependencies": {
27
18
  "typescript": "^5.7.2",
@@ -33,5 +24,13 @@
33
24
  "react",
34
25
  "primitives"
35
26
  ],
36
- "license": "MIT"
37
- }
27
+ "license": "MIT",
28
+ "scripts": {
29
+ "build": "tsc",
30
+ "dev": "tsc --watch",
31
+ "test": "vitest",
32
+ "typecheck": "tsc --noEmit",
33
+ "lint": "eslint .",
34
+ "clean": "rm -rf dist"
35
+ }
36
+ }