@auto-engineer/component-implementer 0.10.5

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 ADDED
@@ -0,0 +1,358 @@
1
+ # @auto-engineer/frontend-implementer
2
+
3
+ AI-powered frontend implementation plugin for the Auto Engineer CLI that implements client-side code with AI assistance. This plugin creates React components, hooks, and application logic from specifications and design requirements.
4
+
5
+ ## Installation
6
+
7
+ This is a plugin for the Auto Engineer CLI. Install both the CLI and this plugin:
8
+
9
+ ```bash
10
+ npm install -g @auto-engineer/cli
11
+ npm install @auto-engineer/frontend-implementer
12
+ ```
13
+
14
+ ## Configuration
15
+
16
+ Add this plugin to your `auto.config.ts`:
17
+
18
+ ```typescript
19
+ export default {
20
+ plugins: [
21
+ '@auto-engineer/frontend-implementer',
22
+ // ... other plugins
23
+ ],
24
+ };
25
+ ```
26
+
27
+ ## Commands
28
+
29
+ This plugin provides the following commands:
30
+
31
+ - `implement:client` - Implement client-side code with AI assistance
32
+
33
+ ## What does this plugin do?
34
+
35
+ The Frontend Implementer plugin uses AI capabilities to implement React applications, including components, pages, hooks, and business logic. It understands design systems, GraphQL schemas, and user experience requirements to create functional user interfaces.
36
+
37
+ ## Key Features
38
+
39
+ ### AI React Development
40
+
41
+ - Generates functional React components from specifications
42
+ - Implements custom hooks for state management and API interactions
43
+ - Creates responsive layouts and interactive user interfaces
44
+ - Integrates with design systems and component libraries
45
+
46
+ ### GraphQL Integration
47
+
48
+ - Generates Apollo Client queries and mutations
49
+ - Implements optimistic updates and error handling
50
+ - Creates type-safe GraphQL operations
51
+ - Handles loading states and data caching
52
+
53
+ ### Design System Awareness
54
+
55
+ - Uses imported design tokens and components consistently
56
+ - Follows established design patterns and UI conventions
57
+ - Implements accessibility standards and best practices
58
+ - Maintains visual consistency across the application
59
+
60
+ ### User Experience Focus
61
+
62
+ - Implements intuitive user workflows and navigation
63
+ - Handles edge cases and error scenarios gracefully
64
+ - Creates responsive designs for mobile and desktop
65
+ - Optimizes for performance and user experience
66
+
67
+ ## Implementation Patterns
68
+
69
+ ### Page Component Implementation
70
+
71
+ The plugin creates complete page implementations:
72
+
73
+ ```typescript
74
+ // Before (generated stub)
75
+ export function OrderHistoryPage() {
76
+ // TODO: Implement order history display
77
+ return <div>Order History - Not implemented</div>;
78
+ }
79
+
80
+ // After (AI implementation)
81
+ export function OrderHistoryPage() {
82
+ const { data, loading, error, refetch } = useOrderHistoryQuery({
83
+ variables: { customerId: useCurrentUser().id },
84
+ errorPolicy: 'partial'
85
+ });
86
+
87
+ const [selectedOrder, setSelectedOrder] = useState<Order | null>(null);
88
+
89
+ if (loading) return <LoadingSpinner message="Loading your orders..." />;
90
+ if (error) return <ErrorMessage error={error} onRetry={refetch} />;
91
+
92
+ return (
93
+ <PageLayout title="Order History" breadcrumbs={[{ label: 'Orders', href: '/orders' }]}>
94
+ <div className="space-y-6">
95
+ <OrderFilters onFilterChange={handleFilterChange} />
96
+
97
+ {data?.orders.length === 0 ? (
98
+ <EmptyState
99
+ title="No orders found"
100
+ description="You haven't placed any orders yet."
101
+ action={<Button href="/products">Start Shopping</Button>}
102
+ />
103
+ ) : (
104
+ <OrderList
105
+ orders={data?.orders || []}
106
+ onSelectOrder={setSelectedOrder}
107
+ />
108
+ )}
109
+
110
+ {selectedOrder && (
111
+ <OrderDetailModal
112
+ order={selectedOrder}
113
+ isOpen={!!selectedOrder}
114
+ onClose={() => setSelectedOrder(null)}
115
+ />
116
+ )}
117
+ </div>
118
+ </PageLayout>
119
+ );
120
+ }
121
+ ```
122
+
123
+ ### Custom Hook Implementation
124
+
125
+ Creates reusable hooks for complex logic:
126
+
127
+ ```typescript
128
+ // Implements data fetching and state management
129
+ export function useOrderManagement() {
130
+ const [placeOrderMutation] = usePlaceOrderMutation();
131
+ const [cancelOrderMutation] = useCancelOrderMutation();
132
+ const [orders, setOrders] = useState<Order[]>([]);
133
+
134
+ const placeOrder = useCallback(
135
+ async (orderData: PlaceOrderInput) => {
136
+ try {
137
+ const result = await placeOrderMutation({
138
+ variables: { input: orderData },
139
+ optimisticResponse: {
140
+ placeOrder: {
141
+ __typename: 'Order',
142
+ id: `temp-${Date.now()}`,
143
+ status: OrderStatus.Pending,
144
+ ...orderData,
145
+ },
146
+ },
147
+ update: (cache, { data }) => {
148
+ if (data?.placeOrder) {
149
+ cache.modify({
150
+ fields: {
151
+ orders: (existing = []) => [...existing, data.placeOrder],
152
+ },
153
+ });
154
+ }
155
+ },
156
+ });
157
+
158
+ return result.data?.placeOrder;
159
+ } catch (error) {
160
+ throw new OrderPlacementError('Failed to place order', error);
161
+ }
162
+ },
163
+ [placeOrderMutation],
164
+ );
165
+
166
+ const cancelOrder = useCallback(
167
+ async (orderId: string) => {
168
+ // Implementation with optimistic updates and error handling
169
+ },
170
+ [cancelOrderMutation],
171
+ );
172
+
173
+ return { placeOrder, cancelOrder, orders };
174
+ }
175
+ ```
176
+
177
+ ### Component Implementation
178
+
179
+ Creates feature-rich, accessible components:
180
+
181
+ ```typescript
182
+ // Implements interactive components with full functionality
183
+ export function ProductCard({ product, onAddToCart }: ProductCardProps) {
184
+ const [isAdding, setIsAdding] = useState(false);
185
+ const [imageError, setImageError] = useState(false);
186
+ const { addToast } = useToast();
187
+
188
+ const handleAddToCart = async () => {
189
+ setIsAdding(true);
190
+ try {
191
+ await onAddToCart(product.id);
192
+ addToast({
193
+ type: 'success',
194
+ message: `${product.name} added to cart`
195
+ });
196
+ } catch (error) {
197
+ addToast({
198
+ type: 'error',
199
+ message: 'Failed to add item to cart'
200
+ });
201
+ } finally {
202
+ setIsAdding(false);
203
+ }
204
+ };
205
+
206
+ return (
207
+ <Card className="group hover:shadow-lg transition-shadow">
208
+ <CardContent className="p-0">
209
+ {!imageError ? (
210
+ <img
211
+ src={product.imageUrl}
212
+ alt={product.name}
213
+ className="w-full h-48 object-cover rounded-t-lg"
214
+ onError={() => setImageError(true)}
215
+ />
216
+ ) : (
217
+ <div className="w-full h-48 bg-gray-100 flex items-center justify-center rounded-t-lg">
218
+ <ImageIcon className="text-gray-400" size={48} />
219
+ </div>
220
+ )}
221
+
222
+ <div className="p-4">
223
+ <h3 className="font-semibold text-lg mb-2">{product.name}</h3>
224
+ <p className="text-gray-600 text-sm mb-3 line-clamp-2">
225
+ {product.description}
226
+ </p>
227
+
228
+ <div className="flex justify-between items-center">
229
+ <span className="text-xl font-bold text-primary">
230
+ ${product.price.toFixed(2)}
231
+ </span>
232
+
233
+ <Button
234
+ onClick={handleAddToCart}
235
+ disabled={isAdding || !product.inStock}
236
+ className="min-w-24"
237
+ >
238
+ {isAdding ? (
239
+ <Spinner size="sm" />
240
+ ) : !product.inStock ? (
241
+ 'Out of Stock'
242
+ ) : (
243
+ 'Add to Cart'
244
+ )}
245
+ </Button>
246
+ </div>
247
+ </div>
248
+ </CardContent>
249
+ </Card>
250
+ );
251
+ }
252
+ ```
253
+
254
+ ## Configuration Options
255
+
256
+ Customize implementation behavior:
257
+
258
+ ```typescript
259
+ // auto.config.ts
260
+ export default {
261
+ plugins: [
262
+ [
263
+ '@auto-engineer/frontend-implementer',
264
+ {
265
+ // AI model configuration
266
+ model: 'claude-3-sonnet',
267
+
268
+ // Framework preferences
269
+ framework: 'react',
270
+ stateManagement: 'apollo-client',
271
+
272
+ // UI library integration
273
+ designSystem: 'shadcn/ui',
274
+ iconLibrary: 'lucide-react',
275
+
276
+ // Implementation preferences
277
+ includeAccessibility: true,
278
+ includeAnimations: true,
279
+ includeErrorBoundaries: true,
280
+
281
+ // Testing
282
+ generateTests: true,
283
+ testingLibrary: 'testing-library',
284
+ },
285
+ ],
286
+ ],
287
+ };
288
+ ```
289
+
290
+ ## Features
291
+
292
+ ### Responsive Design Implementation
293
+
294
+ - Mobile-first approach with responsive breakpoints
295
+ - Touch-friendly interactions for mobile devices
296
+ - Optimized layouts for different screen sizes
297
+ - Progressive enhancement patterns
298
+
299
+ ### Accessibility (a11y) Integration
300
+
301
+ - ARIA labels and roles for screen readers
302
+ - Keyboard navigation support
303
+ - Color contrast compliance
304
+ - Focus management and visual indicators
305
+
306
+ ### Performance Optimization
307
+
308
+ - Lazy loading for images and components
309
+ - Code splitting for optimal bundle sizes
310
+ - Memoization for expensive computations
311
+ - Efficient re-rendering patterns
312
+
313
+ ### Error Handling
314
+
315
+ - Comprehensive error boundaries
316
+ - User-friendly error messages
317
+ - Retry mechanisms for failed operations
318
+ - Graceful degradation patterns
319
+
320
+ ## Integration with Other Plugins
321
+
322
+ Works with the Auto Engineer ecosystem:
323
+
324
+ - **@auto-engineer/frontend-generator-react-graphql**: Implements generated component scaffolds
325
+ - **@auto-engineer/design-system-importer**: Uses imported design tokens and components
326
+ - **@auto-engineer/frontend-checks**: Validates implementations pass tests and type checking
327
+ - **@auto-engineer/information-architect**: Uses IA specifications for navigation and content structure
328
+
329
+ ## Quality Assurance
330
+
331
+ Ensures high-quality implementations through:
332
+
333
+ - **TypeScript Compliance**: Full type safety and IntelliSense support
334
+ - **Component Testing**: Comprehensive test coverage for user interactions
335
+ - **Accessibility Auditing**: WCAG compliance and screen reader compatibility
336
+ - **Performance Monitoring**: Identifies and resolves performance bottlenecks
337
+ - **Code Review**: AI-powered review for best practices and patterns
338
+
339
+ ## Advanced Features
340
+
341
+ ### Context-Aware Implementation
342
+
343
+ The AI understands:
344
+
345
+ - Existing design patterns and component structure
346
+ - GraphQL schema and available operations
347
+ - Design system tokens and component props
348
+ - User experience requirements and workflows
349
+ - Performance considerations and optimization opportunities
350
+
351
+ ### Progressive Implementation
352
+
353
+ - Implements core functionality first
354
+ - Adds advanced features incrementally
355
+ - Supports partial implementations and manual refinements
356
+ - Adapts to user feedback and requirements changes
357
+
358
+ The Frontend Implementer plugin transforms UI specifications and design requirements into functional React applications, accelerating frontend development while maintaining quality and consistency.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env tsx
2
+ export {};
3
+ //# sourceMappingURL=agent-cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-cli.d.ts","sourceRoot":"","sources":["../../src/agent-cli.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env tsx
2
+ import { runAIAgent } from './agent';
3
+ const [, , projectDir, iaSchemeDir, designSystemPath] = process.argv;
4
+ if (!projectDir) {
5
+ console.error('Usage: agent-cli <project-directory> <ia-scheme-directory>');
6
+ process.exit(1);
7
+ }
8
+ runAIAgent(projectDir, iaSchemeDir, designSystemPath, []).catch((err) => {
9
+ console.error('Error running AI agent:', err);
10
+ process.exit(1);
11
+ });
12
+ //# sourceMappingURL=agent-cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-cli.js","sourceRoot":"","sources":["../../src/agent-cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,CAAC,EAAE,AAAD,EAAG,UAAU,EAAE,WAAW,EAAE,gBAAgB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;AAErE,IAAI,CAAC,UAAU,EAAE,CAAC;IAChB,OAAO,CAAC,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAC5E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,UAAU,CAAC,UAAU,EAAE,WAAW,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACtE,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;IAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,54 @@
1
+ export declare function callAI(prompt: string, options?: {
2
+ temperature?: number;
3
+ maxTokens?: number;
4
+ }): Promise<any>;
5
+ interface Scheme {
6
+ generatedComponents?: {
7
+ type: string;
8
+ items?: Record<string, unknown>;
9
+ }[];
10
+ atoms?: {
11
+ description?: string;
12
+ items?: Record<string, unknown>;
13
+ };
14
+ molecules?: {
15
+ description?: string;
16
+ items?: Record<string, unknown>;
17
+ };
18
+ organisms?: {
19
+ description?: string;
20
+ items?: Record<string, unknown>;
21
+ };
22
+ pages?: {
23
+ description?: string;
24
+ items?: Record<string, {
25
+ route: string;
26
+ description: string;
27
+ layout?: unknown;
28
+ navigation?: unknown;
29
+ [key: string]: unknown;
30
+ }>;
31
+ };
32
+ }
33
+ interface ProjectContext {
34
+ scheme: Scheme | undefined;
35
+ files: string[];
36
+ atoms: {
37
+ name: string;
38
+ props: {
39
+ name: string;
40
+ type: string;
41
+ }[];
42
+ }[];
43
+ keyFileContents: Record<string, string>;
44
+ fileTreeSummary: string[];
45
+ graphqlOperations: Record<string, string>;
46
+ userPreferences: string;
47
+ theme: string;
48
+ failures: string[];
49
+ }
50
+ export declare function loadScheme(iaSchemeDir: string): Promise<Scheme | undefined>;
51
+ export declare function getProjectContext(projectDir: string, iaSchemeDir: string, userPreferences: string, designSystem: string, failures: string[]): Promise<ProjectContext>;
52
+ export declare function runAIAgent(projectDir: string, iaSchemeDir: string, designSystemPath: string, failures: string[]): Promise<void>;
53
+ export {};
54
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/agent.ts"],"names":[],"mappings":"AAqHA,wBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,gBAOlG;AAGD,UAAU,MAAM;IACd,mBAAmB,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,EAAE,CAAC;IAC1E,KAAK,CAAC,EAAE;QACN,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACjC,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