metacoding 1.0.0 → 1.1.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +68 -43
  2. package/LICENSE +1 -1
  3. package/lib/services/template-manager.d.ts +3 -0
  4. package/lib/services/template-manager.d.ts.map +1 -1
  5. package/lib/services/template-manager.js +126 -9
  6. package/lib/services/template-manager.js.map +1 -1
  7. package/lib/services/vscode.js +1 -1
  8. package/lib/services/vscode.js.map +1 -1
  9. package/package.json +4 -4
  10. package/templates/general/code-review.instructions.md +265 -0
  11. package/templates/general/{files/copilot-instructions.md.template → copilot-instructions.md} +97 -140
  12. package/templates/{python/files → general}/docs-update.instructions.md +45 -32
  13. package/templates/general/release.instructions.md +242 -0
  14. package/templates/general/test-runner.instructions.md +188 -0
  15. package/templates/node/nodejs.coding.instructions.md +249 -0
  16. package/templates/node/nodejs.docs.instructions.md +234 -0
  17. package/templates/node/nodejs.testing.instructions.md +373 -0
  18. package/templates/python/python.coding.instructions.md +339 -0
  19. package/templates/python/python.docs.instructions.md +1147 -0
  20. package/templates/python/python.testing.instructions.md +1074 -0
  21. package/templates/react/react.coding.instructions.md +695 -0
  22. package/templates/react/react.docs.instructions.md +427 -0
  23. package/templates/react/react.testing.instructions.md +193 -0
  24. package/templates/react/test-runner.instructions.md +135 -0
  25. package/templates/typescript/template.json +16 -0
  26. package/templates/typescript/typescript.coding.instructions.md +368 -0
  27. package/templates/typescript/typescript.docs.instructions.md +734 -0
  28. package/templates/typescript/typescript.testing.instructions.md +740 -0
  29. package/templates/general/files/code-review.instructions.md +0 -111
  30. package/templates/general/files/docs-update.instructions.md +0 -203
  31. package/templates/general/files/release.instructions.md +0 -72
  32. package/templates/general/files/test-runner.instructions.md +0 -107
  33. package/templates/node/files/code-review.instructions.md +0 -222
  34. package/templates/node/files/copilot-instructions.md.template +0 -391
  35. package/templates/node/files/docs-update.instructions.md +0 -203
  36. package/templates/node/files/release.instructions.md +0 -72
  37. package/templates/node/files/test-runner.instructions.md +0 -108
  38. package/templates/python/files/code-review.instructions.md +0 -215
  39. package/templates/python/files/copilot-instructions.md.template +0 -418
  40. package/templates/python/files/release.instructions.md +0 -72
  41. package/templates/python/files/test-runner.instructions.md +0 -108
  42. package/templates/react/files/code-review.instructions.md +0 -160
  43. package/templates/react/files/copilot-instructions.md.template +0 -472
  44. package/templates/react/files/docs-update.instructions.md +0 -203
  45. package/templates/react/files/release.instructions.md +0 -72
  46. package/templates/react/files/test-runner.instructions.md +0 -108
@@ -0,0 +1,427 @@
1
+ ---
2
+ description: 'React-specific documentation standards and guidelines'
3
+ language: 'react'
4
+ category: 'documentation'
5
+ ---
6
+
7
+ # React Documentation Standards
8
+
9
+ ## Component Documentation Guidelines
10
+
11
+ ### JSDoc for React Components
12
+
13
+ ````typescript
14
+ /**
15
+ * A reusable button component with multiple variants and sizes.
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * <Button variant="primary" size="large" onClick={handleClick}>
20
+ * Click me
21
+ * </Button>
22
+ * ```
23
+ *
24
+ * @param props - The component props
25
+ * @param props.variant - The visual style variant
26
+ * @param props.size - The size of the button
27
+ * @param props.disabled - Whether the button is disabled
28
+ * @param props.children - The button content
29
+ * @param props.onClick - Click event handler
30
+ */
31
+ export function Button({
32
+ variant = 'primary',
33
+ size = 'medium',
34
+ disabled = false,
35
+ children,
36
+ onClick,
37
+ }: ButtonProps) {
38
+ // Component implementation
39
+ }
40
+ ````
41
+
42
+ ### PropTypes and TypeScript Interfaces
43
+
44
+ ```typescript
45
+ /**
46
+ * Props for the Button component.
47
+ */
48
+ export interface ButtonProps {
49
+ /** The visual style variant of the button */
50
+ variant?: 'primary' | 'secondary' | 'danger';
51
+ /** The size of the button */
52
+ size?: 'small' | 'medium' | 'large';
53
+ /** Whether the button is disabled */
54
+ disabled?: boolean;
55
+ /** The content to display inside the button */
56
+ children: React.ReactNode;
57
+ /** Click event handler */
58
+ onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
59
+ }
60
+ ```
61
+
62
+ ## Component API Documentation
63
+
64
+ ### Required Documentation Elements
65
+
66
+ 1. **Purpose and Use Cases:** Clear description of what the component does
67
+ 2. **Props Interface:** Complete TypeScript interface with descriptions
68
+ 3. **Usage Examples:** Common usage patterns with code examples
69
+ 4. **Accessibility Notes:** ARIA requirements and keyboard interactions
70
+ 5. **Styling Information:** CSS classes, design tokens, theming support
71
+ 6. **Dependencies:** Required peer dependencies or context providers
72
+
73
+ ### Component README Template
74
+
75
+ ````markdown
76
+ # ComponentName
77
+
78
+ Brief description of the component's purpose and primary use case.
79
+
80
+ ## Usage
81
+
82
+ ```tsx
83
+ import { ComponentName } from './ComponentName';
84
+
85
+ function Example() {
86
+ return (
87
+ <ComponentName prop1="value" prop2={variable} onAction={handleAction}>
88
+ Content
89
+ </ComponentName>
90
+ );
91
+ }
92
+ ```
93
+ ````
94
+
95
+ ## Props
96
+
97
+ | Prop | Type | Default | Description |
98
+ | ----- | ------- | --------- | -------------------- |
99
+ | prop1 | string | 'default' | Description of prop1 |
100
+ | prop2 | boolean | false | Description of prop2 |
101
+
102
+ ## Examples
103
+
104
+ ### Basic Usage
105
+
106
+ [Code example]
107
+
108
+ ### Advanced Usage
109
+
110
+ [Code example with complex props]
111
+
112
+ ## Accessibility
113
+
114
+ - Keyboard navigation support
115
+ - Screen reader compatibility
116
+ - ARIA attributes used
117
+
118
+ ## Styling
119
+
120
+ - CSS classes available
121
+ - Design tokens used
122
+ - Theming support
123
+
124
+ ## Related Components
125
+
126
+ - List of related components
127
+ - When to use alternatives
128
+
129
+ ````
130
+
131
+ ## Hook Documentation
132
+
133
+ ### Custom Hook Documentation
134
+
135
+ ```typescript
136
+ /**
137
+ * A hook for managing form state with validation.
138
+ *
139
+ * @example
140
+ * ```tsx
141
+ * function ContactForm() {
142
+ * const { values, errors, handleChange, handleSubmit } = useForm({
143
+ * initialValues: { email: '', message: '' },
144
+ * validation: {
145
+ * email: (value) => value.includes('@') ? null : 'Invalid email'
146
+ * }
147
+ * });
148
+ *
149
+ * return (
150
+ * <form onSubmit={handleSubmit}>
151
+ * <input
152
+ * value={values.email}
153
+ * onChange={handleChange('email')}
154
+ * aria-invalid={!!errors.email}
155
+ * />
156
+ * {errors.email && <span>{errors.email}</span>}
157
+ * </form>
158
+ * );
159
+ * }
160
+ * ```
161
+ *
162
+ * @param config - Hook configuration options
163
+ * @returns Form state and handlers
164
+ */
165
+ export function useForm<T extends Record<string, any>>(
166
+ config: FormConfig<T>
167
+ ): FormReturn<T> {
168
+ // Hook implementation
169
+ }
170
+ ````
171
+
172
+ ## Storybook Documentation
173
+
174
+ ### Story Documentation Standards
175
+
176
+ ```typescript
177
+ import type { Meta, StoryObj } from '@storybook/react';
178
+ import { Button } from './Button';
179
+
180
+ const meta: Meta<typeof Button> = {
181
+ title: 'Components/Button',
182
+ component: Button,
183
+ parameters: {
184
+ docs: {
185
+ description: {
186
+ component:
187
+ 'A versatile button component with multiple variants and sizes.',
188
+ },
189
+ },
190
+ },
191
+ argTypes: {
192
+ variant: {
193
+ control: 'select',
194
+ options: ['primary', 'secondary', 'danger'],
195
+ description: 'The visual style variant of the button',
196
+ },
197
+ size: {
198
+ control: 'select',
199
+ options: ['small', 'medium', 'large'],
200
+ description: 'The size of the button',
201
+ },
202
+ },
203
+ };
204
+
205
+ export default meta;
206
+ type Story = StoryObj<typeof meta>;
207
+
208
+ /**
209
+ * The default button style used for primary actions.
210
+ */
211
+ export const Primary: Story = {
212
+ args: {
213
+ variant: 'primary',
214
+ children: 'Button',
215
+ },
216
+ };
217
+
218
+ /**
219
+ * Secondary buttons for less prominent actions.
220
+ */
221
+ export const Secondary: Story = {
222
+ args: {
223
+ variant: 'secondary',
224
+ children: 'Button',
225
+ },
226
+ };
227
+ ```
228
+
229
+ ## Architecture Documentation
230
+
231
+ ### Component Architecture Docs
232
+
233
+ Document component relationships and data flow:
234
+
235
+ ```markdown
236
+ # Component Architecture
237
+
238
+ ## Component Hierarchy
239
+ ```
240
+
241
+ App
242
+ ├── Header
243
+ │ ├── Navigation
244
+ │ └── UserMenu
245
+ ├── Main
246
+ │ ├── Sidebar
247
+ │ └── ContentArea
248
+ │ ├── FeatureComponent
249
+ │ └── DataDisplay
250
+ └── Footer
251
+
252
+ ```
253
+
254
+ ## Data Flow
255
+
256
+ 1. **State Management:** Describe state management approach (Context, Redux, Zustand)
257
+ 2. **Props Flow:** How data flows down through component tree
258
+ 3. **Event Handling:** How events bubble up and are handled
259
+ 4. **Side Effects:** API calls, external integrations
260
+
261
+ ## Performance Considerations
262
+
263
+ - Component memoization strategies
264
+ - Bundle splitting points
265
+ - Lazy loading implementation
266
+ - Re-render optimization
267
+ ```
268
+
269
+ ## Design System Documentation
270
+
271
+ ### Component Design Specs
272
+
273
+ ```markdown
274
+ # Design System - Button Component
275
+
276
+ ## Design Tokens
277
+
278
+ ### Colors
279
+
280
+ - Primary: `--color-primary-500`
281
+ - Secondary: `--color-neutral-200`
282
+ - Danger: `--color-error-500`
283
+
284
+ ### Typography
285
+
286
+ - Font: `--font-family-base`
287
+ - Size: `--font-size-md`
288
+ - Weight: `--font-weight-medium`
289
+
290
+ ### Spacing
291
+
292
+ - Padding: `--space-3` `--space-4`
293
+ - Margin: `--space-2`
294
+
295
+ ## Variants
296
+
297
+ ### Primary Button
298
+
299
+ - Background: Primary color
300
+ - Text: White
301
+ - Border: None
302
+ - Shadow: `--shadow-sm`
303
+
304
+ ### Secondary Button
305
+
306
+ - Background: Transparent
307
+ - Text: Primary color
308
+ - Border: 1px solid primary
309
+ - Shadow: None
310
+
311
+ ## States
312
+
313
+ - **Default:** Base styling
314
+ - **Hover:** Darker background, `--shadow-md`
315
+ - **Active:** Pressed state with inset shadow
316
+ - **Disabled:** 50% opacity, no interactions
317
+ - **Focus:** Visible focus ring for accessibility
318
+ ```
319
+
320
+ ## API Integration Documentation
321
+
322
+ ### Component API Integration
323
+
324
+ ````typescript
325
+ /**
326
+ * A component that fetches and displays user data.
327
+ *
328
+ * @example
329
+ * ```tsx
330
+ * <UserProfile userId="123" />
331
+ * ```
332
+ *
333
+ * ## API Dependencies
334
+ *
335
+ * - **GET /api/users/:id** - Fetches user profile data
336
+ * - **PUT /api/users/:id** - Updates user profile
337
+ *
338
+ * ## Error Handling
339
+ *
340
+ * - Network errors: Shows retry button
341
+ * - 404 errors: Shows "User not found" message
342
+ * - 403 errors: Shows permission denied message
343
+ *
344
+ * ## Loading States
345
+ *
346
+ * - Initial load: Skeleton placeholder
347
+ * - Update: Spinner overlay
348
+ * - Background refresh: Subtle loading indicator
349
+ */
350
+ export function UserProfile({ userId }: UserProfileProps) {
351
+ // Component implementation
352
+ }
353
+ ````
354
+
355
+ ## Testing Documentation Integration
356
+
357
+ ### Component Test Documentation
358
+
359
+ ```typescript
360
+ /**
361
+ * Tests for the Button component.
362
+ *
363
+ * @testcases
364
+ * - Renders with correct text content
365
+ * - Applies variant classes correctly
366
+ * - Handles click events properly
367
+ * - Shows disabled state appropriately
368
+ * - Meets accessibility requirements
369
+ * - Supports keyboard navigation
370
+ */
371
+ describe('Button Component', () => {
372
+ // Test implementations
373
+ });
374
+ ```
375
+
376
+ ## Migration and Deprecation Docs
377
+
378
+ ### Breaking Changes Documentation
379
+
380
+ ````markdown
381
+ # Migration Guide: Button v2.0
382
+
383
+ ## Breaking Changes
384
+
385
+ ### Removed Props
386
+
387
+ - `type` prop removed - use `variant` instead
388
+ - `large` prop removed - use `size="large"` instead
389
+
390
+ ### API Changes
391
+
392
+ - `onClick` now receives event object as first parameter
393
+ - `disabled` prop now affects aria-disabled attribute
394
+
395
+ ## Migration Steps
396
+
397
+ 1. Replace `type="primary"` with `variant="primary"`
398
+ 2. Replace `large={true}` with `size="large"`
399
+ 3. Update click handlers to accept event parameter
400
+
401
+ ### Before
402
+
403
+ ```tsx
404
+ <Button type="primary" large onClick={handleClick}>
405
+ Click me
406
+ </Button>
407
+ ```
408
+ ````
409
+
410
+ ### After
411
+
412
+ ```tsx
413
+ <Button variant="primary" size="large" onClick={(e) => handleClick(e)}>
414
+ Click me
415
+ </Button>
416
+ ```
417
+
418
+ ```
419
+
420
+ ## Documentation Maintenance
421
+
422
+ - **Component Updates:** Update docs when component API changes
423
+ - **Example Accuracy:** Ensure all code examples are tested and working
424
+ - **Version Alignment:** Keep documentation in sync with component versions
425
+ - **Accessibility Updates:** Update accessibility docs when ARIA patterns change
426
+ - **Performance Notes:** Document performance implications of component usage
427
+ ```
@@ -0,0 +1,193 @@
1
+ ---
2
+ description: 'React-specific testing guidelines and standards'
3
+ language: 'react'
4
+ category: 'testing'
5
+ ---
6
+
7
+ # React Testing Standards
8
+
9
+ ## Test Case Naming Conventions
10
+
11
+ ### Test Case ID Format: `[AREA]-[TYPE]-[NUMBER]`
12
+
13
+ **React/Frontend Area Prefixes:**
14
+
15
+ - `COMP` - React component tests
16
+ - `HOOK` - Custom hooks tests
17
+ - `PAGE` - Page/Route component tests
18
+ - `FORM` - Form validation and submission tests
19
+ - `UI` - UI interaction and behavior tests
20
+ - `STORE` - State management tests (Redux/Zustand/Context)
21
+ - `API` - Frontend API client tests
22
+ - `A11Y` - Accessibility compliance tests
23
+ - `PERF` - Performance and optimization tests
24
+ - `UTIL` - Frontend utility function tests
25
+
26
+ **Type Suffixes:**
27
+
28
+ - `UNIT` - Unit tests (isolated component testing)
29
+ - `INT` - Integration tests (component interaction testing)
30
+ - `E2E` - End-to-end tests (full user workflow testing)
31
+
32
+ **Examples:**
33
+
34
+ - `COMP-UNIT-001` - First unit test for React Component
35
+ - `HOOK-UNIT-001` - First unit test for Custom Hook
36
+ - `PAGE-E2E-001` - First end-to-end test for Page Component
37
+ - `FORM-INT-001` - First integration test for Form Component
38
+
39
+ ## Testing Framework Stack
40
+
41
+ - **Primary Framework:** Jest with React Testing Library
42
+ - **Component Testing:** @testing-library/react for component behavior testing
43
+ - **User Interaction:** @testing-library/user-event for realistic user interactions
44
+ - **Mocking:** Jest built-in mocking for modules and dependencies
45
+ - **Snapshot Testing:** Use sparingly, prefer behavioral tests
46
+
47
+ ## Component Testing Guidelines
48
+
49
+ ### Test Structure
50
+
51
+ - **Arrange-Act-Assert:** Clear test structure with setup, action, and verification
52
+ - **Test Behavior, Not Implementation:** Focus on what the component does, not how
53
+ - **User-Centric Tests:** Test from the user's perspective using accessible queries
54
+ - **Isolation:** Each test should be independent and not rely on other tests
55
+
56
+ ### Testing Patterns
57
+
58
+ ```typescript
59
+ // Good: Testing behavior
60
+ test('displays error message when form submission fails', async () => {
61
+ render(<ContactForm onSubmit={jest.fn().mockRejectedValue(new Error())} />);
62
+
63
+ await user.click(screen.getByRole('button', { name: /submit/i }));
64
+
65
+ expect(screen.getByText(/error occurred/i)).toBeInTheDocument();
66
+ });
67
+
68
+ // Bad: Testing implementation details
69
+ test('calls setState when button is clicked', () => {
70
+ const component = shallow(<MyComponent />);
71
+ component.find('button').simulate('click');
72
+ expect(component.state('clicked')).toBe(true);
73
+ });
74
+ ```
75
+
76
+ ## Query Priorities
77
+
78
+ 1. **Accessible Queries (Preferred):**
79
+
80
+ - `getByRole()` - Primary choice for interactive elements
81
+ - `getByLabelText()` - Form inputs with labels
82
+ - `getByPlaceholderText()` - Form inputs with placeholders
83
+ - `getByText()` - Non-interactive text content
84
+
85
+ 2. **Semantic Queries:**
86
+
87
+ - `getByAltText()` - Images with alt text
88
+ - `getByTitle()` - Elements with title attributes
89
+
90
+ 3. **Test ID Queries (Last Resort):**
91
+ - `getByTestId()` - Only when semantic queries aren't sufficient
92
+
93
+ ## React-Specific Testing Scenarios
94
+
95
+ ### Component Lifecycle and State
96
+
97
+ - **State Changes:** Test state transitions triggered by user interactions
98
+ - **Effect Testing:** Verify useEffect behavior with proper cleanup
99
+ - **Context Testing:** Test components that consume React Context
100
+ - **Custom Hooks:** Test custom hooks in isolation using renderHook
101
+
102
+ ### Async Operations
103
+
104
+ - **API Calls:** Mock API responses and test loading/success/error states
105
+ - **User Interactions:** Use waitFor() for async state updates
106
+ - **Suspense:** Test Suspense boundaries and fallback components
107
+ - **Error Boundaries:** Test error boundary behavior with error states
108
+
109
+ ### Form Testing
110
+
111
+ - **Form Validation:** Test client-side validation messages
112
+ - **Form Submission:** Test successful and failed form submissions
113
+ - **Field Interactions:** Test input changes, selections, and clearing
114
+ - **Accessibility:** Ensure form labels and error associations work correctly
115
+
116
+ ## Mock Strategies
117
+
118
+ ### Component Mocking
119
+
120
+ ```typescript
121
+ // Mock child components that aren't relevant to the test
122
+ jest.mock('./ComplexChild', () => {
123
+ return function MockedComplexChild({ title }: { title: string }) {
124
+ return <div data-testid="mocked-complex-child">{title}</div>;
125
+ };
126
+ });
127
+ ```
128
+
129
+ ### API Mocking
130
+
131
+ ```typescript
132
+ // Use MSW (Mock Service Worker) for API mocking
133
+ import { rest } from 'msw';
134
+ import { setupServer } from 'msw/node';
135
+
136
+ const server = setupServer(
137
+ rest.get('/api/users', (req, res, ctx) => {
138
+ return res(ctx.json([{ id: 1, name: 'John Doe' }]));
139
+ })
140
+ );
141
+ ```
142
+
143
+ ## Performance Testing
144
+
145
+ - **Render Performance:** Use React DevTools Profiler for performance testing
146
+ - **Memory Leaks:** Test component cleanup and event listener removal
147
+ - **Large Lists:** Test virtualization and pagination performance
148
+ - **Bundle Size:** Monitor component bundle impact with bundler analysis
149
+
150
+ ## Testing File Organization
151
+
152
+ ```
153
+ /test
154
+ /components
155
+ /common # Reusable component tests
156
+ /pages # Page component tests
157
+ /forms # Form component tests
158
+ /hooks # Custom hook tests
159
+ /utils # Utility function tests
160
+ /fixtures
161
+ /api-responses # Mock API response data
162
+ /component-props # Common component prop fixtures
163
+ ```
164
+
165
+ ## React Testing Anti-Patterns
166
+
167
+ - **Avoid Shallow Rendering:** Use full rendering with React Testing Library
168
+ - **Don't Test Implementation Details:** Focus on user-observable behavior
169
+ - **Avoid Snapshot Testing Everything:** Use snapshots sparingly for stable UI
170
+ - **Don't Mock React Itself:** Mock external dependencies, not React features
171
+ - **Avoid Testing Library Internals:** Don't test useState, useEffect directly
172
+
173
+ ## Accessibility Testing
174
+
175
+ - **Screen Reader Testing:** Ensure components work with assistive technology
176
+ - **Keyboard Navigation:** Test keyboard-only navigation patterns
177
+ - **ARIA Attributes:** Verify proper ARIA labels and roles
178
+ - **Color Contrast:** Test component readability across different themes
179
+ - **Focus Management:** Test focus trapping and restoration in modals/dialogs
180
+
181
+ ## Test Data Management
182
+
183
+ - **Factory Functions:** Create reusable test data generators
184
+ - **Realistic Data:** Use realistic data that matches production scenarios
185
+ - **Edge Cases:** Test with empty states, long text, special characters
186
+ - **Internationalization:** Test with different locales and text lengths
187
+
188
+ ## CI/CD Integration
189
+
190
+ - **Visual Regression:** Use tools like Chromatic for visual testing
191
+ - **Cross-Browser Testing:** Test across different browsers and devices
192
+ - **Performance Budgets:** Set performance thresholds for components
193
+ - **Bundle Analysis:** Monitor bundle size impact of new components