-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.cursorrules
More file actions
250 lines (208 loc) · 6.81 KB
/
Copy path.cursorrules
File metadata and controls
250 lines (208 loc) · 6.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# Cursor AI Rules for @nexcraft/forge
## Package Information
- Package: @nexcraft/forge
- Description: AI-native web component library with React/Vue/Angular integrations
- Repository: https://github.com/dev-ignis/forge
- Documentation: ./docs/ai-methods.md
## Import Preferences
### React Projects (Recommended)
```javascript
// Prefer React integrations for better TypeScript support and SSR
import { ForgeButton, ForgeInput, ForgeCard } from '@nexcraft/forge/integrations/react'
// For forms with validation
import { RHFForgeInput, RHFForgeSelect } from '@nexcraft/forge/integrations/rhf'
```
### Tree-shaking / Bundle Optimization
```javascript
// Use selective imports for smaller bundles
import { ForgeButton } from '@nexcraft/forge/button'
import { ForgeInput } from '@nexcraft/forge/input'
import { ForgeCard } from '@nexcraft/forge/card'
```
### Tailwind CSS Projects
```javascript
// Add Tailwind plugin for semantic utilities
import forgePlugin from '@nexcraft/forge/plugin'
// tailwind.config.js
export default {
plugins: [forgePlugin]
}
```
## Component Guidelines
### Available Components
- **Atoms**: ForgeButton, ForgeInput, ForgeCard, ForgeAlert, ForgeCheckbox, ForgeBadge, ForgeIcon, ForgeSwitch, ForgeProgress, ForgeSkeleton
- **Molecules**: ForgeModal, ForgeSelect, ForgeTooltip, ForgeDropdown, ForgeFormField, ForgeMultiSelect, ForgeToast
- **Organisms**: ForgeDataTable, ForgeTabs, ForgePagination, ForgeNavigationBar, ForgeAccordion, ForgeTreeView
### Component Patterns
```javascript
// Login form pattern
<ForgeCard>
<ForgeInput type="email" label="Email" required />
<ForgeInput type="password" label="Password" required />
<ForgeButton variant="primary" type="submit">Sign In</ForgeButton>
</ForgeCard>
// Dashboard metrics card
<ForgeCard>
<div className="p-6">
<h3 className="text-lg font-semibold">Total Users</h3>
<p className="text-3xl font-bold">{metrics.users}</p>
<ForgeBadge variant="success">+12%</ForgeBadge>
</div>
</ForgeCard>
// Data table with actions
<ForgeDataTable
data={users}
columns={[
{ key: 'name', title: 'Name' },
{ key: 'email', title: 'Email' },
{
key: 'actions',
title: 'Actions',
render: (_, row) => (
<ForgeButton size="sm" variant="ghost">Edit</ForgeButton>
)
}
]}
/>
```
## Styling Guidelines
### CSS Custom Properties (Theming)
```css
/* Override design tokens */
forge-button {
--forge-color-primary-500: #3b82f6;
--forge-border-radius-md: 8px;
}
```
### Tailwind Integration
```javascript
// Use built-in variants (preferred)
<ForgeButton variant="primary" size="lg">Primary Button</ForgeButton>
// Combine with Tailwind classes
<ForgeButton className="w-full mt-4" variant="primary">Full Width</ForgeButton>
// Use plugin utilities
<forge-button className="btn-forge btn-forge-primary">Semantic Button</forge-button>
```
## Framework Integration
### React + TypeScript
```typescript
import { ForgeButton } from '@nexcraft/forge/integrations/react'
interface Props {
onSubmit: () => void
loading?: boolean
}
function SubmitButton({ onSubmit, loading }: Props) {
return (
<ForgeButton
variant="primary"
loading={loading}
onClick={onSubmit}
>
Submit
</ForgeButton>
)
}
```
### React Hook Form
```javascript
import { useForm } from 'react-hook-form'
import { RHFForgeInput, RHFForgeSelect } from '@nexcraft/forge/integrations/rhf'
function UserForm() {
const { control, handleSubmit } = useForm()
return (
<form onSubmit={handleSubmit(onSubmit)}>
<RHFForgeInput
name="email"
label="Email"
control={control}
rules={{ required: 'Email is required' }}
/>
<RHFForgeSelect
name="role"
label="Role"
control={control}
options={roleOptions}
/>
</form>
)
}
```
### Next.js SSR
```javascript
// Components work with SSR out of the box
import { ForgeCard, ForgeButton } from '@nexcraft/forge/integrations/react'
export default function Page() {
return (
<ForgeCard>
<div className="p-6">
<h1>SSR Compatible</h1>
<ForgeButton variant="primary">Click me</ForgeButton>
</div>
</ForgeCard>
)
}
```
## Common Use Cases
### Authentication Forms
- Use ForgeInput with type="email" and type="password"
- Wrap in ForgeCard for container
- Use ForgeButton with variant="primary" for submit
- Add ForgeAlert for error messages
### Dashboards
- Use ForgeCard for metric containers
- Use ForgeBadge for status indicators
- Use ForgeProgress for progress bars
- Use ForgeDataTable for data display
### Modal Dialogs
- Use ForgeModal with open/onClose props
- Use ForgeButton with variant="secondary" for cancel
- Use ForgeButton with variant="primary" for confirm
### Data Tables
- Use ForgeDataTable with data and columns props
- Add pagination={true} for large datasets
- Use custom render functions for actions
- Use selectable={true} for bulk operations
## Performance Tips
- Use selective imports for better tree-shaking
- Components include built-in performance monitoring
- All styles are embedded (no external CSS needed)
- SSR-compatible out of the box
## AI Discovery & Integration
### Component Discovery
```javascript
// Quick component overview (fast discovery)
import aiIndex from '@nexcraft/forge/ai-index.json'
console.log(`Available: ${aiIndex.summary.totalComponents} components`)
// Detailed component specifications
import aiManifest from '@nexcraft/forge/ai-manifest.json'
console.log(aiManifest.components[0]) // Full component details
// Framework-specific schemas
import buttonSpec from '@nexcraft/forge/ai-tools/react/button.json'
import vanillaSpec from '@nexcraft/forge/ai-tools/vanilla/button.json'
```
### AI Method Usage
```javascript
// All components have AI methods for intelligent interactions
const button = document.querySelector('forge-button')
// Get available actions
const actions = button.getPossibleActions()
// Returns: [{ name: 'click', description: 'Click the button', available: true }]
// Explain current state
const state = button.explainState()
// Returns: { currentState: 'enabled', possibleStates: ['enabled', 'disabled', 'loading'] }
// Get comprehensive AI state
const aiState = button.aiState
// Returns: Complete component metadata and current state
```
## Documentation Links
- **AI Index**: ./ai-index.json (quick component discovery)
- **AI Manifest**: ./ai-manifest.json (detailed specifications)
- **AI Tools**: ./ai-tools/ (framework-specific schemas)
- AI Methods Guide: ./docs/ai-methods.md
- Common Patterns: ./docs/patterns/AI_COMMON_PATTERNS.md
- Import Guide: ./docs/guides/AI_IMPORT_GUIDE.md
## Avoid These Patterns
- Don't import from internal paths like '@nexcraft/forge/src/components'
- Don't mix full bundle import with selective imports
- Don't use CSS frameworks that conflict with Shadow DOM
- Don't use React wrappers with non-React frameworks