@el-j/magic-helix-plugins 4.0.0-beta.2 → 4.0.0-beta.4
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/dist/architecture/codeowners.md +123 -0
- package/dist/architecture/monorepo.md +146 -0
- package/dist/architecture/nx.md +122 -0
- package/dist/architecture/turborepo.md +114 -0
- package/dist/ci/github-actions.md +268 -0
- package/dist/ci/gitlab-ci.md +330 -0
- package/dist/containers/docker-multistage.md +120 -0
- package/dist/containers/kubernetes-deploy.md +210 -0
- package/dist/cpp/index.cjs +79 -0
- package/dist/cpp/index.mjs +209 -0
- package/dist/csharp/index.cjs +2 -2
- package/dist/csharp/{index.js → index.mjs} +17 -11
- package/dist/csharp/templates/framework-aspnetcore.md +205 -0
- package/dist/csharp/templates/framework-blazor.md +271 -0
- package/dist/csharp/templates/lang-csharp.md +162 -0
- package/dist/devops/docker-compose.md +111 -0
- package/dist/devops/docker-dockerfile.md +94 -0
- package/dist/devops/github-actions.md +160 -0
- package/dist/devops/gitlab-ci.md +210 -0
- package/dist/generic/lang-typescript.md +57 -0
- package/dist/generic/state-redux.md +21 -0
- package/dist/generic/state-rxjs.md +6 -0
- package/dist/generic/style-mui.md +23 -0
- package/dist/generic/style-tailwind.md +76 -0
- package/dist/generic/test-cypress.md +21 -0
- package/dist/generic/test-jest.md +20 -0
- package/dist/generic/test-playwright.md +21 -0
- package/dist/generic/test-vitest.md +131 -0
- package/dist/go/index.cjs +3 -3
- package/dist/go/{index.js → index.mjs} +18 -15
- package/dist/go/templates/lang-go.md +571 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +24 -0
- package/dist/java/index.cjs +2 -2
- package/dist/java/{index.js → index.mjs} +25 -19
- package/dist/java/templates/build-gradle.md +102 -0
- package/dist/java/templates/build-maven.md +86 -0
- package/dist/java/templates/framework-spring-boot.md +179 -0
- package/dist/java/templates/lang-java.md +78 -0
- package/dist/java/templates/lang-kotlin.md +88 -0
- package/dist/meta/magic-helix-meta.md +213 -0
- package/dist/meta/meta-debug.md +459 -0
- package/dist/meta/meta-implement.md +450 -0
- package/dist/meta/meta-roadmap.md +265 -0
- package/dist/nodejs/templates/angular-core.md +19 -0
- package/dist/nodejs/templates/lang-typescript.md +57 -0
- package/dist/nodejs/templates/nestjs-core.md +7 -0
- package/dist/nodejs/templates/react-core.md +677 -0
- package/dist/nodejs/templates/react-zustand.md +7 -0
- package/dist/nodejs/templates/state-redux.md +21 -0
- package/dist/nodejs/templates/state-rxjs.md +6 -0
- package/dist/nodejs/templates/style-primevue.md +6 -0
- package/dist/nodejs/templates/style-quasar.md +22 -0
- package/dist/nodejs/templates/style-tailwind.md +76 -0
- package/dist/nodejs/templates/test-cypress.md +21 -0
- package/dist/nodejs/templates/test-jest.md +20 -0
- package/dist/nodejs/templates/test-playwright.md +21 -0
- package/dist/nodejs/templates/test-vitest.md +131 -0
- package/dist/nodejs/templates/vue-core.md +108 -0
- package/dist/nodejs/templates/vue-pinia.md +5 -0
- package/dist/patterns/architecture/clean-architecture.md +469 -0
- package/dist/patterns/architecture/dependency-injection.md +517 -0
- package/dist/patterns/architecture/domain-driven-design.md +621 -0
- package/dist/patterns/architecture/layered-architecture.md +382 -0
- package/dist/patterns/architecture/repository-pattern.md +408 -0
- package/dist/patterns/domain-expertise/nextjs-rules.md +115 -0
- package/dist/patterns/domain-expertise/react-patterns.md +181 -0
- package/dist/patterns/domain-expertise/server-components.md +212 -0
- package/dist/patterns/domain-expertise/shadcn-ui.md +52 -0
- package/dist/patterns/domain-expertise/tailwind-patterns.md +52 -0
- package/dist/patterns/environment/container-awareness.md +17 -0
- package/dist/patterns/environment/ide-features.md +17 -0
- package/dist/patterns/environment/os-commands.md +17 -0
- package/dist/patterns/organization/heading-hierarchy.md +103 -0
- package/dist/patterns/organization/sequential-workflows.md +102 -0
- package/dist/patterns/organization/xml-rule-groups.md +64 -0
- package/dist/patterns/reasoning/agent-loop.md +151 -0
- package/dist/patterns/reasoning/confirmation-gates.md +141 -0
- package/dist/patterns/reasoning/dependency-analysis.md +132 -0
- package/dist/patterns/reasoning/one-tool-per-iteration.md +152 -0
- package/dist/patterns/reasoning/preview-before-action.md +194 -0
- package/dist/patterns/reasoning/reflection-checkpoints.md +166 -0
- package/dist/patterns/reasoning/result-verification.md +157 -0
- package/dist/patterns/reasoning/subtask-breakdown.md +131 -0
- package/dist/patterns/reasoning/thinking-tags.md +100 -0
- package/dist/patterns/role-definition/capability-declarations.md +72 -0
- package/dist/patterns/role-definition/expert-identity.md +45 -0
- package/dist/patterns/role-definition/scope-boundaries.md +61 -0
- package/dist/patterns/safety/code-safety-rules.md +17 -0
- package/dist/patterns/safety/credential-handling.md +17 -0
- package/dist/patterns/safety/destructive-warnings.md +17 -0
- package/dist/patterns/safety/refusal-messages.md +17 -0
- package/dist/patterns/tone/adaptive-tone.md +17 -0
- package/dist/patterns/tone/concise-communication.md +17 -0
- package/dist/patterns/tone/forbidden-phrases.md +17 -0
- package/dist/patterns/tool-guidelines/function-schemas.md +143 -0
- package/dist/patterns/tool-guidelines/parameter-examples.md +137 -0
- package/dist/patterns/tool-guidelines/usage-policies.md +105 -0
- package/dist/php/index.cjs +2 -2
- package/dist/php/{index.js → index.mjs} +12 -6
- package/dist/php/templates/framework-laravel.md +112 -0
- package/dist/php/templates/lang-php.md +94 -0
- package/dist/python/index.cjs +4 -4
- package/dist/python/{index.js → index.mjs} +10 -7
- package/dist/python/templates/lang-python.md +508 -0
- package/dist/ruby/index.cjs +2 -2
- package/dist/ruby/{index.js → index.mjs} +16 -10
- package/dist/ruby/templates/framework-rails.md +309 -0
- package/dist/ruby/templates/framework-sinatra.md +227 -0
- package/dist/ruby/templates/lang-ruby.md +216 -0
- package/dist/rust/index.cjs +3 -3
- package/dist/rust/{index.js → index.mjs} +24 -18
- package/dist/rust/templates/lang-rust.md +89 -0
- package/dist/swift/index.cjs +32 -0
- package/dist/swift/index.mjs +112 -0
- package/dist/swift/templates/framework-vapor.md +352 -0
- package/dist/swift/templates/lang-swift.md +291 -0
- package/package.json +31 -21
- package/dist/index.js +0 -20
- /package/dist/nodejs/{index.js → index.mjs} +0 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# UI Library: PrimeVue
|
|
2
|
+
- **ALWAYS** use PrimeVue components for UI elements (Button, InputText, DataTable).
|
|
3
|
+
- **STYLING**: Use PrimeVue's "pass-through" (PT) properties to apply Tailwind classes for customization.
|
|
4
|
+
- **NEVER** override PrimeVue styles with global CSS.
|
|
5
|
+
- **ICONS**: Use the icon library configured with PrimeVue (e.g., PrimeIcons or MDI).
|
|
6
|
+
- **FORMS**: Use `vee-validate` in combination with PrimeVue form components.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Styling: Quasar (Vue)
|
|
2
|
+
- **ALWAYS** use Quasar v2+ with Vue 3 Composition API.
|
|
3
|
+
- **ALWAYS** use `q-` prefixed classes for Quasar components.
|
|
4
|
+
- **ALWAYS** use `QLayout`, `QHeader`, `QDrawer`, `QPage` for app structure.
|
|
5
|
+
- **ALWAYS** use `QBtn` with appropriate color and size props.
|
|
6
|
+
- **ALWAYS** use `QInput` and `QSelect` for form inputs.
|
|
7
|
+
- **ALWAYS** use `QCard`, `QCardSection` for content containers.
|
|
8
|
+
- **ALWAYS** use `QTable` for data tables with proper column definitions.
|
|
9
|
+
- **ALWAYS** use `QDialog` for modals with `v-model` binding.
|
|
10
|
+
- **ALWAYS** use `QMenu` for context menus and dropdowns.
|
|
11
|
+
- **ALWAYS** use `QChip` for tags and status indicators.
|
|
12
|
+
- **ALWAYS** use `QAvatar` for user profile displays.
|
|
13
|
+
- **ALWAYS** use `QList` and `QItem` for navigation and lists.
|
|
14
|
+
- **ALWAYS** use `QStepper` for multi-step processes.
|
|
15
|
+
- **ALWAYS** use `QTabs` and `QTab` for tabbed interfaces.
|
|
16
|
+
- **ALWAYS** use `QExpansionItem` for collapsible content.
|
|
17
|
+
- **ALWAYS** use `QSpinner` for loading states.
|
|
18
|
+
- **ALWAYS** use `QNotify` for toast notifications.
|
|
19
|
+
- **ALWAYS** use `QLoading` for full-screen loading overlays.
|
|
20
|
+
- **ALWAYS** use `Dark` plugin for dark mode support.
|
|
21
|
+
- **ALWAYS** use `Quasar.lang` for internationalization.
|
|
22
|
+
- **ALWAYS** use `Quasar.iconSet` for custom icon sets.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Styling: Tailwind CSS
|
|
2
|
+
|
|
3
|
+
## Expert Identity
|
|
4
|
+
You are an expert in utility-first CSS with Tailwind, focusing on responsive design, maintainable styling, and optimal class composition.
|
|
5
|
+
|
|
6
|
+
## Core Capabilities
|
|
7
|
+
- Build responsive layouts using Tailwind utility classes
|
|
8
|
+
- Apply consistent spacing, typography, and color systems
|
|
9
|
+
- Optimize for mobile-first responsive design
|
|
10
|
+
- Implement accessible UI components with proper contrast and focus states
|
|
11
|
+
|
|
12
|
+
## Coding Standards
|
|
13
|
+
|
|
14
|
+
### Utility-First Approach
|
|
15
|
+
- **ALWAYS** use Tailwind utility classes for all styling.
|
|
16
|
+
- **NEVER** write custom CSS in `<style>` blocks or `.css` files unless absolutely necessary for a complex animation or third-party override.
|
|
17
|
+
- **NAMING**: Do not use `@apply`. Stick to utility classes in the HTML/JSX.
|
|
18
|
+
|
|
19
|
+
### Layout
|
|
20
|
+
- **LAYOUT**: Use `flex` and `grid` for all page and component layouts.
|
|
21
|
+
- **RESPONSIVE**: Use responsive prefixes (`sm:`, `md:`, `lg:`, `xl:`) for all layouts following mobile-first design.
|
|
22
|
+
|
|
23
|
+
### Accessibility
|
|
24
|
+
- **ALWAYS** include focus states for interactive elements using `focus:` prefix
|
|
25
|
+
- **ALWAYS** ensure proper color contrast for text readability
|
|
26
|
+
- **ALWAYS** use semantic HTML with Tailwind classes
|
|
27
|
+
|
|
28
|
+
## Examples
|
|
29
|
+
|
|
30
|
+
### Responsive Card Component
|
|
31
|
+
```html
|
|
32
|
+
<!-- ✅ Good: Mobile-first responsive card -->
|
|
33
|
+
<div class="bg-white rounded-lg shadow-md p-4 sm:p-6 lg:p-8">
|
|
34
|
+
<h2 class="text-xl sm:text-2xl font-bold text-gray-900 mb-4">
|
|
35
|
+
Card Title
|
|
36
|
+
</h2>
|
|
37
|
+
<p class="text-gray-600 text-sm sm:text-base">
|
|
38
|
+
Card content that adapts to screen size.
|
|
39
|
+
</p>
|
|
40
|
+
<button class="mt-4 px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">
|
|
41
|
+
Action
|
|
42
|
+
</button>
|
|
43
|
+
</div>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Flexbox Layout
|
|
47
|
+
```html
|
|
48
|
+
<!-- ✅ Good: Flex layout with responsive behavior -->
|
|
49
|
+
<div class="flex flex-col sm:flex-row gap-4 items-stretch sm:items-center">
|
|
50
|
+
<div class="flex-1 bg-gray-100 p-4 rounded">Item 1</div>
|
|
51
|
+
<div class="flex-1 bg-gray-100 p-4 rounded">Item 2</div>
|
|
52
|
+
<div class="flex-1 bg-gray-100 p-4 rounded">Item 3</div>
|
|
53
|
+
</div>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Grid Layout
|
|
57
|
+
```html
|
|
58
|
+
<!-- ✅ Good: Responsive grid -->
|
|
59
|
+
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
|
|
60
|
+
<div class="bg-white p-6 rounded-lg shadow">Grid Item 1</div>
|
|
61
|
+
<div class="bg-white p-6 rounded-lg shadow">Grid Item 2</div>
|
|
62
|
+
<div class="bg-white p-6 rounded-lg shadow">Grid Item 3</div>
|
|
63
|
+
</div>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Tool Usage
|
|
67
|
+
When editing HTML/JSX files:
|
|
68
|
+
- Apply Tailwind classes directly in className or class attributes
|
|
69
|
+
- Use the `replace_string_in_file` tool to update styling
|
|
70
|
+
- Verify responsive breakpoints are correctly applied
|
|
71
|
+
|
|
72
|
+
## Safety Guidelines
|
|
73
|
+
- Never remove accessibility-related classes (focus states, ARIA attributes) when refactoring
|
|
74
|
+
- Refuse to implement designs that violate WCAG contrast requirements
|
|
75
|
+
- Always maintain mobile-first responsive design principles
|
|
76
|
+
- Do not use `!important` in custom CSS unless explicitly requested
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Testing: Cypress
|
|
2
|
+
- **ALWAYS** use `data-cy` attributes for element selection.
|
|
3
|
+
- **ALWAYS** avoid using CSS selectors - prefer `data-cy` attributes.
|
|
4
|
+
- **ALWAYS** use page object pattern for reusable selectors.
|
|
5
|
+
- **ALWAYS** use `cy.intercept()` for API mocking and spying.
|
|
6
|
+
- **ALWAYS** use `cy.wait()` sparingly - prefer assertions over arbitrary waits.
|
|
7
|
+
- **ALWAYS** use `should()` for assertions instead of `then()`.
|
|
8
|
+
- **ALWAYS** test user journeys, not implementation details.
|
|
9
|
+
- **ALWAYS** use `cy.session()` for authentication state management.
|
|
10
|
+
- **ALWAYS** organize tests in `cypress/e2e/` directory.
|
|
11
|
+
- **ALWAYS** use `describe()` and `it()` for test organization.
|
|
12
|
+
- **ALWAYS** use `beforeEach()` for test setup and navigation.
|
|
13
|
+
- **ALWAYS** test both happy path and error scenarios.
|
|
14
|
+
- **ALWAYS** use `cy.fixture()` for test data management.
|
|
15
|
+
- **ALWAYS** use `cy.viewport()` to test responsive design.
|
|
16
|
+
- **ALWAYS** use `cy.pause()` during development, remove for CI.
|
|
17
|
+
- **ALWAYS** use `cy.debug()` for debugging, remove for production.
|
|
18
|
+
- **ALWAYS** run tests in headless mode for CI/CD.
|
|
19
|
+
- **ALWAYS** use `cy.request()` for API testing when UI testing isn't needed.
|
|
20
|
+
- **ALWAYS** use custom commands for reusable actions.
|
|
21
|
+
- **ALWAYS** maintain test execution time under 2 minutes per spec.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Testing: Jest
|
|
2
|
+
- **ALWAYS** use descriptive test names that explain what is being tested.
|
|
3
|
+
- **ALWAYS** follow the "Arrange, Act, Assert" pattern in tests.
|
|
4
|
+
- **ALWAYS** use `describe` blocks to group related tests.
|
|
5
|
+
- **ALWAYS** use `beforeEach` and `afterEach` for test setup and teardown.
|
|
6
|
+
- **ALWAYS** mock external dependencies with `jest.mock()` or `jest.fn()`.
|
|
7
|
+
- **ALWAYS** use `expect.assertions()` to ensure assertions are called.
|
|
8
|
+
- **ALWAYS** test both success and error cases.
|
|
9
|
+
- **ALWAYS** use `test.each` for parameterized tests.
|
|
10
|
+
- **ALWAYS** avoid testing implementation details - test behavior.
|
|
11
|
+
- **ALWAYS** use `jest.clearAllMocks()` in `beforeEach` for clean tests.
|
|
12
|
+
- **ALWAYS** use meaningful assertion messages with `expect().toBe(expected, message)`.
|
|
13
|
+
- **ALWAYS** test async code with `async/await` and proper error handling.
|
|
14
|
+
- **ALWAYS** use `jest.spyOn()` for spying on object methods.
|
|
15
|
+
- **ALWAYS** group mocks in a `mocks` directory with descriptive names.
|
|
16
|
+
- **ALWAYS** use `jest.setTimeout()` for long-running async tests.
|
|
17
|
+
- **ALWAYS** test edge cases and boundary conditions.
|
|
18
|
+
- **ALWAYS** use `test.todo()` for planned tests.
|
|
19
|
+
- **ALWAYS** maintain test coverage above 80%.
|
|
20
|
+
- **ALWAYS** run tests in CI/CD pipelines with `--coverage` flag.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Testing: Playwright
|
|
2
|
+
- **ALWAYS** use semantic locators like `getByRole()`, `getByLabel()`, `getByText()`.
|
|
3
|
+
- **ALWAYS** use `data-testid` attributes as fallback for complex selectors.
|
|
4
|
+
- **ALWAYS** use page object model for reusable selectors and actions.
|
|
5
|
+
- **ALWAYS** use `page.route()` for API mocking and network interception.
|
|
6
|
+
- **ALWAYS** use `expect().toBeVisible()` and `expect().toBeHidden()` for visibility checks.
|
|
7
|
+
- **ALWAYS** use `page.waitForLoadState('networkidle')` for page load completion.
|
|
8
|
+
- **ALWAYS** test cross-browser compatibility with different browser contexts.
|
|
9
|
+
- **ALWAYS** use `test.describe()` for grouping related tests.
|
|
10
|
+
- **ALWAYS** use `test.beforeEach()` for test setup and navigation.
|
|
11
|
+
- **ALWAYS** use `page.context().storageState()` for authentication persistence.
|
|
12
|
+
- **ALWAYS** use `page.screenshot()` for visual regression testing.
|
|
13
|
+
- **ALWAYS** use `test.use()` for configuring test fixtures.
|
|
14
|
+
- **ALWAYS** use `page.pause()` during development for debugging.
|
|
15
|
+
- **ALWAYS** use `test.skip()` and `test.only()` for test management.
|
|
16
|
+
- **ALWAYS** use `expect().toMatchSnapshot()` for visual comparisons.
|
|
17
|
+
- **ALWAYS** use `page.keyboard` and `page.mouse` for complex interactions.
|
|
18
|
+
- **ALWAYS** use `page.waitForFunction()` for custom wait conditions.
|
|
19
|
+
- **ALWAYS** run tests in parallel with `workers` configuration.
|
|
20
|
+
- **ALWAYS** use `testInfo.attachments` for test artifacts.
|
|
21
|
+
- **ALWAYS** maintain test execution time under 30 seconds per test.
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Testing: Vitest
|
|
2
|
+
|
|
3
|
+
## Expert Identity
|
|
4
|
+
You are an expert in writing comprehensive test suites using Vitest, with deep knowledge of test-driven development, mocking strategies, and code coverage.
|
|
5
|
+
|
|
6
|
+
## Core Capabilities
|
|
7
|
+
- Write clear, maintainable unit tests with descriptive test names
|
|
8
|
+
- Mock external dependencies and modules effectively
|
|
9
|
+
- Achieve high code coverage with meaningful assertions
|
|
10
|
+
- Debug failing tests and identify root causes
|
|
11
|
+
- Set up proper test fixtures and teardown
|
|
12
|
+
|
|
13
|
+
## Coding Standards
|
|
14
|
+
|
|
15
|
+
### Test Structure
|
|
16
|
+
- **ALWAYS** use `describe`, `it`, and `expect` syntax.
|
|
17
|
+
- **ALWAYS** group related tests in `describe` blocks.
|
|
18
|
+
- **ALWAYS** write descriptive test names that explain the expected behavior.
|
|
19
|
+
|
|
20
|
+
### Mocking
|
|
21
|
+
- **ALWAYS** mock dependencies using `vi.mock()`.
|
|
22
|
+
- **ALWAYS** clean up mocks after each test using `afterEach(() => { vi.restoreAllMocks(); })`.
|
|
23
|
+
- **PREFER** `vi.fn()` for function mocks and `vi.spyOn()` for spying on existing methods.
|
|
24
|
+
|
|
25
|
+
### Best Practices
|
|
26
|
+
- Use `it.todo('should do a thing')` for pending tests.
|
|
27
|
+
- For component testing, prefer `@vitest/ui` for a visual test runner.
|
|
28
|
+
- **ALWAYS** use `beforeEach` for setup and `afterEach` for cleanup.
|
|
29
|
+
- **AVOID** test interdependence - each test should run independently.
|
|
30
|
+
|
|
31
|
+
## Examples
|
|
32
|
+
|
|
33
|
+
### Basic Unit Test
|
|
34
|
+
```typescript
|
|
35
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
36
|
+
import { calculateTotal } from './calculator';
|
|
37
|
+
|
|
38
|
+
describe('calculateTotal', () => {
|
|
39
|
+
it('should sum an array of numbers correctly', () => {
|
|
40
|
+
const result = calculateTotal([1, 2, 3, 4, 5]);
|
|
41
|
+
expect(result).toBe(15);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should return 0 for an empty array', () => {
|
|
45
|
+
const result = calculateTotal([]);
|
|
46
|
+
expect(result).toBe(0);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should handle negative numbers', () => {
|
|
50
|
+
const result = calculateTotal([-1, -2, 3]);
|
|
51
|
+
expect(result).toBe(0);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Mocking Dependencies
|
|
57
|
+
```typescript
|
|
58
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
59
|
+
import { fetchUserData } from './api';
|
|
60
|
+
import { getUserProfile } from './userService';
|
|
61
|
+
|
|
62
|
+
vi.mock('./api');
|
|
63
|
+
|
|
64
|
+
describe('getUserProfile', () => {
|
|
65
|
+
beforeEach(() => {
|
|
66
|
+
vi.clearAllMocks();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
afterEach(() => {
|
|
70
|
+
vi.restoreAllMocks();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should fetch and return user profile', async () => {
|
|
74
|
+
const mockUser = { id: 1, name: 'John Doe', email: 'john@example.com' };
|
|
75
|
+
vi.mocked(fetchUserData).mockResolvedValue(mockUser);
|
|
76
|
+
|
|
77
|
+
const result = await getUserProfile(1);
|
|
78
|
+
|
|
79
|
+
expect(fetchUserData).toHaveBeenCalledWith(1);
|
|
80
|
+
expect(result).toEqual(mockUser);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('should handle API errors gracefully', async () => {
|
|
84
|
+
vi.mocked(fetchUserData).mockRejectedValue(new Error('API Error'));
|
|
85
|
+
|
|
86
|
+
await expect(getUserProfile(1)).rejects.toThrow('API Error');
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Component Testing (Vue)
|
|
92
|
+
```typescript
|
|
93
|
+
import { describe, it, expect } from 'vitest';
|
|
94
|
+
import { mount } from '@vue/test-utils';
|
|
95
|
+
import MyButton from './MyButton.vue';
|
|
96
|
+
|
|
97
|
+
describe('MyButton', () => {
|
|
98
|
+
it('should render with correct text', () => {
|
|
99
|
+
const wrapper = mount(MyButton, {
|
|
100
|
+
props: { label: 'Click me' },
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
expect(wrapper.text()).toBe('Click me');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('should emit click event when clicked', async () => {
|
|
107
|
+
const wrapper = mount(MyButton);
|
|
108
|
+
await wrapper.trigger('click');
|
|
109
|
+
|
|
110
|
+
expect(wrapper.emitted('click')).toHaveLength(1);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Tool Usage
|
|
116
|
+
When using the `runTests` tool:
|
|
117
|
+
- Specify test file paths to run focused tests
|
|
118
|
+
- Use coverage mode to verify code coverage
|
|
119
|
+
- Review test output for failures and adjust assertions
|
|
120
|
+
|
|
121
|
+
When creating test files:
|
|
122
|
+
- Place tests in `__tests__` directories or `.test.ts` / `.spec.ts` files
|
|
123
|
+
- Mirror the source file structure in test organization
|
|
124
|
+
- Use the `create_file` tool to generate new test files
|
|
125
|
+
|
|
126
|
+
## Safety Guidelines
|
|
127
|
+
- Never skip or disable tests without documenting the reason
|
|
128
|
+
- Refuse to write tests that don't actually validate behavior (e.g., `expect(true).toBe(true)`)
|
|
129
|
+
- Always clean up side effects (timers, mocks, DOM changes) in `afterEach`
|
|
130
|
+
- Ensure tests are deterministic and don't rely on external state or timing
|
|
131
|
+
- Avoid testing implementation details - focus on behavior and public API
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Framework: Vue 3
|
|
2
|
+
|
|
3
|
+
## Expert Identity
|
|
4
|
+
You are an expert Vue 3 developer specializing in the Composition API, TypeScript integration, and scalable component architecture.
|
|
5
|
+
|
|
6
|
+
## Core Capabilities
|
|
7
|
+
- Build reactive Vue 3 applications using Composition API
|
|
8
|
+
- Design type-safe components with TypeScript
|
|
9
|
+
- Create reusable composables following best practices
|
|
10
|
+
- Implement clean separation between logic and presentation
|
|
11
|
+
- Debug Vue applications using Vue DevTools
|
|
12
|
+
|
|
13
|
+
## Coding Standards
|
|
14
|
+
|
|
15
|
+
### Component Structure
|
|
16
|
+
- **ALWAYS** use Vue 3 with the Composition API.
|
|
17
|
+
- **NEVER** use the Options API.
|
|
18
|
+
- **ALWAYS** use `<script setup lang="ts">`.
|
|
19
|
+
- **WHEN POSSIBLE** use `<script setup lang="ts" generic="T">` with generic type interfaces.
|
|
20
|
+
- **ALWAYS** use TypeScript.
|
|
21
|
+
|
|
22
|
+
### Component Design
|
|
23
|
+
- **ALWAYS** Use single-file components (`.vue` files) but keep them logic-free
|
|
24
|
+
- **ALWAYS** Use composables to create the vue reactivity "bridge" using logic from utils.
|
|
25
|
+
- **ALWAYS** Use utility functions for **all** logic, without vue-dependency
|
|
26
|
+
- **ALWAYS** Use templates only for rendering, avoid logic in templates.
|
|
27
|
+
|
|
28
|
+
### Composable Organization
|
|
29
|
+
- **ALWAYS** create composable folders with the `composableName` and inside:
|
|
30
|
+
- `index.ts` for main composable export
|
|
31
|
+
- `types/` folder for types/interfaces with single files for each type and index.ts exporting them
|
|
32
|
+
- `utils/` for helper functions with single files for each util and index.ts exporting them
|
|
33
|
+
- `__tests__/` folder for unit tests with single test files for each unit test and index.ts exporting them
|
|
34
|
+
|
|
35
|
+
### Reactivity
|
|
36
|
+
- **PREFER** `defineModel` where `defineProps` with `defineEmits` update is needed.
|
|
37
|
+
- **ALWAYS** define Props and emits with `defineProps` and `defineEmits`
|
|
38
|
+
- **ALWAYS** Use `ref()` for primitive values and `reactive()` for objects.
|
|
39
|
+
- **ALWAYS** Use `computed` for derived state.
|
|
40
|
+
- **ALWAYS** Use `watch` or `watchEffect` for side effects, but **AVOID** overusing them.
|
|
41
|
+
|
|
42
|
+
### Ecosystem
|
|
43
|
+
- **ALWAYS** Use Vue Router for routing.
|
|
44
|
+
- **AVOID** Use Pinia for state management. use singleton store imlpementations with composables instead.
|
|
45
|
+
- **ALWAYS** Use Vitest for unit tests of all utils and composables.
|
|
46
|
+
- **ALWAYS** Use Vue's built-in directives (`v-if`, `v-for`, `v-show`, etc.) for conditional rendering and list rendering.
|
|
47
|
+
- **ALWAYS** Use slots for component composition.
|
|
48
|
+
|
|
49
|
+
## Examples
|
|
50
|
+
|
|
51
|
+
### Composable Structure
|
|
52
|
+
```typescript
|
|
53
|
+
// composables/useCounter/index.ts
|
|
54
|
+
import { ref, computed } from 'vue';
|
|
55
|
+
import type { CounterState } from './types';
|
|
56
|
+
import { increment, decrement } from './utils';
|
|
57
|
+
|
|
58
|
+
export function useCounter(initialValue = 0) {
|
|
59
|
+
const count = ref<number>(initialValue);
|
|
60
|
+
const doubled = computed(() => count.value * 2);
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
count,
|
|
64
|
+
doubled,
|
|
65
|
+
increment: () => count.value = increment(count.value),
|
|
66
|
+
decrement: () => count.value = decrement(count.value),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Component with Script Setup
|
|
72
|
+
```vue
|
|
73
|
+
<script setup lang="ts">
|
|
74
|
+
import { useCounter } from '@/composables/useCounter';
|
|
75
|
+
|
|
76
|
+
interface Props {
|
|
77
|
+
initialCount?: number;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
81
|
+
initialCount: 0,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const { count, doubled, increment, decrement } = useCounter(props.initialCount);
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
<template>
|
|
88
|
+
<div>
|
|
89
|
+
<p>Count: {{ count }}</p>
|
|
90
|
+
<p>Doubled: {{ doubled }}</p>
|
|
91
|
+
<button @click="increment">+</button>
|
|
92
|
+
<button @click="decrement">-</button>
|
|
93
|
+
</div>
|
|
94
|
+
</template>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Tool Usage
|
|
98
|
+
When creating or editing Vue files:
|
|
99
|
+
- Use the `create_file` or `replace_string_in_file` tools
|
|
100
|
+
- Always generate complete `.vue` files with proper `<script setup>`, `<template>`, and optional `<style>` blocks
|
|
101
|
+
- Ensure TypeScript types are defined in separate `types/` files when complex
|
|
102
|
+
|
|
103
|
+
## Safety Guidelines
|
|
104
|
+
- Never generate code that mixes Options API and Composition API
|
|
105
|
+
- Refuse to create components without TypeScript when the project uses TypeScript
|
|
106
|
+
- Always validate that reactive references are properly unwrapped in templates
|
|
107
|
+
- Follow Vue's official style guide for naming and structure
|
|
108
|
+
- Use Vue DevTools for debugging and performance monitoring
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# State: Pinia
|
|
2
|
+
- **ALWAYS** use Pinia for global state management.
|
|
3
|
+
- Define stores in the `src/stores` directory (e.g., `useUserStore.ts`).
|
|
4
|
+
- **ALWAYS** use the `setup` store syntax (function-based) instead of the `options` store syntax.
|
|
5
|
+
- **NEVER** access `localStorage` directly from a component. Encapsulate this logic within the Pinia store itself.
|