@el-j/magic-helix-core 4.0.0-beta.1 → 4.0.0-beta.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.
Files changed (160) hide show
  1. package/dist/index-B88j4AyE.js +13 -0
  2. package/dist/index-B88j4AyE.js.map +1 -0
  3. package/dist/index-CY-pQbuu.cjs +2 -0
  4. package/dist/index-CY-pQbuu.cjs.map +1 -0
  5. package/dist/index.cjs +75 -1
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.ts +0 -1
  8. package/dist/index.mjs +2234 -51
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/pattern-combiner.d.ts +1 -1
  11. package/dist/plugin-loader.d.ts +7 -1
  12. package/package.json +4 -4
  13. package/dist/BasePlugin-6wv0hYJ9.js +0 -98
  14. package/dist/BasePlugin-6wv0hYJ9.js.map +0 -1
  15. package/dist/BasePlugin-odQJAKA-.cjs +0 -2
  16. package/dist/BasePlugin-odQJAKA-.cjs.map +0 -1
  17. package/dist/builtin-plugins/base/BasePlugin.d.ts +0 -69
  18. package/dist/builtin-plugins/csharp/index.d.ts +0 -20
  19. package/dist/builtin-plugins/go/index.d.ts +0 -23
  20. package/dist/builtin-plugins/index.d.ts +0 -15
  21. package/dist/builtin-plugins/java/index.d.ts +0 -22
  22. package/dist/builtin-plugins/nodejs/index.d.ts +0 -44
  23. package/dist/builtin-plugins/php/index.d.ts +0 -20
  24. package/dist/builtin-plugins/python/index.d.ts +0 -27
  25. package/dist/builtin-plugins/ruby/index.d.ts +0 -20
  26. package/dist/builtin-plugins/rust/index.d.ts +0 -53
  27. package/dist/builtin-plugins/swift/index.d.ts +0 -22
  28. package/dist/default_templates/angular/angular-core.md +0 -19
  29. package/dist/default_templates/architecture/codeowners.md +0 -123
  30. package/dist/default_templates/architecture/monorepo.md +0 -146
  31. package/dist/default_templates/architecture/nx.md +0 -122
  32. package/dist/default_templates/architecture/turborepo.md +0 -114
  33. package/dist/default_templates/ci/github-actions.md +0 -268
  34. package/dist/default_templates/ci/gitlab-ci.md +0 -330
  35. package/dist/default_templates/containers/docker-multistage.md +0 -120
  36. package/dist/default_templates/containers/kubernetes-deploy.md +0 -210
  37. package/dist/default_templates/devops/docker-compose.md +0 -111
  38. package/dist/default_templates/devops/docker-dockerfile.md +0 -94
  39. package/dist/default_templates/devops/github-actions.md +0 -160
  40. package/dist/default_templates/devops/gitlab-ci.md +0 -210
  41. package/dist/default_templates/dotnet/framework-aspnetcore.md +0 -205
  42. package/dist/default_templates/dotnet/framework-blazor.md +0 -271
  43. package/dist/default_templates/dotnet/lang-csharp.md +0 -162
  44. package/dist/default_templates/generic/lang-typescript.md +0 -11
  45. package/dist/default_templates/generic/state-redux.md +0 -21
  46. package/dist/default_templates/generic/state-rxjs.md +0 -6
  47. package/dist/default_templates/generic/style-mui.md +0 -23
  48. package/dist/default_templates/generic/style-tailwind.md +0 -6
  49. package/dist/default_templates/generic/test-cypress.md +0 -21
  50. package/dist/default_templates/generic/test-jest.md +0 -20
  51. package/dist/default_templates/generic/test-playwright.md +0 -21
  52. package/dist/default_templates/generic/test-vitest.md +0 -6
  53. package/dist/default_templates/go/lang-go.md +0 -571
  54. package/dist/default_templates/java/build-gradle.md +0 -102
  55. package/dist/default_templates/java/build-maven.md +0 -86
  56. package/dist/default_templates/java/framework-spring-boot.md +0 -179
  57. package/dist/default_templates/java/lang-java.md +0 -78
  58. package/dist/default_templates/java/lang-kotlin.md +0 -88
  59. package/dist/default_templates/meta/magic-helix-meta.md +0 -213
  60. package/dist/default_templates/meta/meta-debug.md +0 -459
  61. package/dist/default_templates/meta/meta-implement.md +0 -450
  62. package/dist/default_templates/meta/meta-roadmap.md +0 -265
  63. package/dist/default_templates/nestjs/nestjs-core.md +0 -7
  64. package/dist/default_templates/patterns/architecture/clean-architecture.md +0 -469
  65. package/dist/default_templates/patterns/architecture/dependency-injection.md +0 -517
  66. package/dist/default_templates/patterns/architecture/domain-driven-design.md +0 -621
  67. package/dist/default_templates/patterns/architecture/layered-architecture.md +0 -382
  68. package/dist/default_templates/patterns/architecture/repository-pattern.md +0 -408
  69. package/dist/default_templates/patterns/domain-expertise/nextjs-rules.md +0 -115
  70. package/dist/default_templates/patterns/domain-expertise/react-patterns.md +0 -181
  71. package/dist/default_templates/patterns/domain-expertise/server-components.md +0 -212
  72. package/dist/default_templates/patterns/domain-expertise/shadcn-ui.md +0 -52
  73. package/dist/default_templates/patterns/domain-expertise/tailwind-patterns.md +0 -52
  74. package/dist/default_templates/patterns/environment/container-awareness.md +0 -17
  75. package/dist/default_templates/patterns/environment/ide-features.md +0 -17
  76. package/dist/default_templates/patterns/environment/os-commands.md +0 -17
  77. package/dist/default_templates/patterns/organization/heading-hierarchy.md +0 -103
  78. package/dist/default_templates/patterns/organization/sequential-workflows.md +0 -102
  79. package/dist/default_templates/patterns/organization/xml-rule-groups.md +0 -64
  80. package/dist/default_templates/patterns/reasoning/agent-loop.md +0 -151
  81. package/dist/default_templates/patterns/reasoning/confirmation-gates.md +0 -141
  82. package/dist/default_templates/patterns/reasoning/dependency-analysis.md +0 -132
  83. package/dist/default_templates/patterns/reasoning/one-tool-per-iteration.md +0 -152
  84. package/dist/default_templates/patterns/reasoning/preview-before-action.md +0 -194
  85. package/dist/default_templates/patterns/reasoning/reflection-checkpoints.md +0 -166
  86. package/dist/default_templates/patterns/reasoning/result-verification.md +0 -157
  87. package/dist/default_templates/patterns/reasoning/subtask-breakdown.md +0 -131
  88. package/dist/default_templates/patterns/reasoning/thinking-tags.md +0 -100
  89. package/dist/default_templates/patterns/role-definition/capability-declarations.md +0 -72
  90. package/dist/default_templates/patterns/role-definition/expert-identity.md +0 -45
  91. package/dist/default_templates/patterns/role-definition/scope-boundaries.md +0 -61
  92. package/dist/default_templates/patterns/safety/code-safety-rules.md +0 -17
  93. package/dist/default_templates/patterns/safety/credential-handling.md +0 -17
  94. package/dist/default_templates/patterns/safety/destructive-warnings.md +0 -17
  95. package/dist/default_templates/patterns/safety/refusal-messages.md +0 -17
  96. package/dist/default_templates/patterns/tone/adaptive-tone.md +0 -17
  97. package/dist/default_templates/patterns/tone/concise-communication.md +0 -17
  98. package/dist/default_templates/patterns/tone/forbidden-phrases.md +0 -17
  99. package/dist/default_templates/patterns/tool-guidelines/function-schemas.md +0 -143
  100. package/dist/default_templates/patterns/tool-guidelines/parameter-examples.md +0 -137
  101. package/dist/default_templates/patterns/tool-guidelines/usage-policies.md +0 -105
  102. package/dist/default_templates/php/framework-laravel.md +0 -112
  103. package/dist/default_templates/php/lang-php.md +0 -94
  104. package/dist/default_templates/python/lang-python.md +0 -508
  105. package/dist/default_templates/react/react-core.md +0 -677
  106. package/dist/default_templates/react/react-zustand.md +0 -7
  107. package/dist/default_templates/ruby/framework-rails.md +0 -309
  108. package/dist/default_templates/ruby/framework-sinatra.md +0 -227
  109. package/dist/default_templates/ruby/lang-ruby.md +0 -216
  110. package/dist/default_templates/rust/lang-rust.md +0 -89
  111. package/dist/default_templates/swift/framework-vapor.md +0 -352
  112. package/dist/default_templates/swift/lang-swift.md +0 -291
  113. package/dist/default_templates/vue/style-primevue.md +0 -6
  114. package/dist/default_templates/vue/style-quasar.md +0 -22
  115. package/dist/default_templates/vue/vue-core.md +0 -28
  116. package/dist/default_templates/vue/vue-pinia.md +0 -5
  117. package/dist/index-AkVwRl-r.js +0 -92
  118. package/dist/index-AkVwRl-r.js.map +0 -1
  119. package/dist/index-B6BeG1yT.cjs +0 -68
  120. package/dist/index-B6BeG1yT.cjs.map +0 -1
  121. package/dist/index-B8pyjKdF.js +0 -94
  122. package/dist/index-B8pyjKdF.js.map +0 -1
  123. package/dist/index-B_6W_RnJ.cjs +0 -76
  124. package/dist/index-B_6W_RnJ.cjs.map +0 -1
  125. package/dist/index-Bg8DD8ku.js +0 -216
  126. package/dist/index-Bg8DD8ku.js.map +0 -1
  127. package/dist/index-BkJhe5Af.js +0 -1748
  128. package/dist/index-BkJhe5Af.js.map +0 -1
  129. package/dist/index-Bv4Q1Pr7.cjs +0 -33
  130. package/dist/index-Bv4Q1Pr7.cjs.map +0 -1
  131. package/dist/index-CN8J45Nc.cjs +0 -24
  132. package/dist/index-CN8J45Nc.cjs.map +0 -1
  133. package/dist/index-CPbv2Od1.js +0 -62
  134. package/dist/index-CPbv2Od1.js.map +0 -1
  135. package/dist/index-Cf-MC6Al.js +0 -63
  136. package/dist/index-Cf-MC6Al.js.map +0 -1
  137. package/dist/index-DDPXXXDy.cjs +0 -19
  138. package/dist/index-DDPXXXDy.cjs.map +0 -1
  139. package/dist/index-DO30AzDe.cjs +0 -19
  140. package/dist/index-DO30AzDe.cjs.map +0 -1
  141. package/dist/index-Dm37u5ut.js +0 -2128
  142. package/dist/index-Dm37u5ut.js.map +0 -1
  143. package/dist/index-DqHvgoXJ.cjs +0 -19
  144. package/dist/index-DqHvgoXJ.cjs.map +0 -1
  145. package/dist/index-J1qAfsnO.cjs +0 -2
  146. package/dist/index-J1qAfsnO.cjs.map +0 -1
  147. package/dist/index-Jz0HYZ7B.js +0 -13
  148. package/dist/index-Jz0HYZ7B.js.map +0 -1
  149. package/dist/index-K39pdw94.cjs +0 -31
  150. package/dist/index-K39pdw94.cjs.map +0 -1
  151. package/dist/index-L3IVvhd1.cjs +0 -89
  152. package/dist/index-L3IVvhd1.cjs.map +0 -1
  153. package/dist/index-OT2XAJkc.js +0 -117
  154. package/dist/index-OT2XAJkc.js.map +0 -1
  155. package/dist/index-TPAX4XKg.cjs +0 -30
  156. package/dist/index-TPAX4XKg.cjs.map +0 -1
  157. package/dist/index-WmVSB57y.js +0 -107
  158. package/dist/index-WmVSB57y.js.map +0 -1
  159. package/dist/index-mYXvc3Fs.js +0 -68
  160. package/dist/index-mYXvc3Fs.js.map +0 -1
@@ -1,382 +0,0 @@
1
- # Layered Architecture Pattern
2
-
3
- ## Purpose
4
- Organize code into horizontal layers with clear responsibilities. Common in MVC and enterprise applications.
5
-
6
- ## Layer Structure
7
-
8
- ```
9
- ┌─────────────────────────────────┐
10
- │ Presentation Layer (UI/API) │ ← User interaction, HTTP/GraphQL
11
- ├─────────────────────────────────┤
12
- │ Application/Service Layer │ ← Business logic orchestration
13
- ├─────────────────────────────────┤
14
- │ Domain/Business Layer │ ← Core business rules
15
- ├─────────────────────────────────┤
16
- │ Data Access Layer (DAL) │ ← Database, external APIs
17
- └─────────────────────────────────┘
18
- ```
19
-
20
- ## Layer Responsibilities
21
-
22
- ### 1. Presentation Layer (Controllers, Views, Components)
23
- **Handle user input, render UI, expose APIs.**
24
-
25
- ```typescript
26
- // ✅ Controller handles HTTP, delegates to service
27
- @Controller('/api/products')
28
- export class ProductController {
29
- constructor(private productService: ProductService) {}
30
-
31
- @Get()
32
- async getAll(@Query() filters: ProductFilters): Promise<ProductDTO[]> {
33
- const products = await this.productService.findAll(filters);
34
- return products.map(p => this.toDTO(p));
35
- }
36
-
37
- @Post()
38
- async create(@Body() dto: CreateProductDTO): Promise<ProductDTO> {
39
- const product = await this.productService.create(dto);
40
- return this.toDTO(product);
41
- }
42
-
43
- private toDTO(product: Product): ProductDTO {
44
- return {
45
- id: product.id,
46
- name: product.name,
47
- price: product.price.amount,
48
- currency: product.price.currency,
49
- };
50
- }
51
- }
52
- ```
53
-
54
- ### 2. Service Layer (Business Logic)
55
- **Orchestrate business operations, coordinate between domain and data layers.**
56
-
57
- ```typescript
58
- // ✅ Service contains business logic, uses repositories
59
- export class ProductService {
60
- constructor(
61
- private productRepository: ProductRepository,
62
- private inventoryService: InventoryService,
63
- private eventBus: EventBus
64
- ) {}
65
-
66
- async create(dto: CreateProductDTO): Promise<Product> {
67
- // Business validation
68
- if (dto.price <= 0) {
69
- throw new BusinessError('Price must be positive');
70
- }
71
-
72
- // Create domain object
73
- const product = new Product(
74
- generateId(),
75
- dto.name,
76
- new Money(dto.price, dto.currency)
77
- );
78
-
79
- // Persist
80
- await this.productRepository.save(product);
81
-
82
- // Business side effects
83
- await this.inventoryService.initializeStock(product.id, dto.initialStock);
84
- await this.eventBus.publish(new ProductCreatedEvent(product));
85
-
86
- return product;
87
- }
88
-
89
- async findAll(filters: ProductFilters): Promise<Product[]> {
90
- // Business logic for filtering
91
- const products = await this.productRepository.findMany(filters);
92
-
93
- // Business rule: filter out discontinued products unless explicitly requested
94
- if (!filters.includeDiscontinued) {
95
- return products.filter(p => !p.isDiscontinued);
96
- }
97
-
98
- return products;
99
- }
100
-
101
- async updatePrice(id: string, newPrice: Money): Promise<Product> {
102
- const product = await this.productRepository.findById(id);
103
- if (!product) {
104
- throw new NotFoundError('Product not found');
105
- }
106
-
107
- // Business rule: price change audit
108
- if (product.price.amount !== newPrice.amount) {
109
- await this.auditLog.recordPriceChange(id, product.price, newPrice);
110
- }
111
-
112
- product.updatePrice(newPrice);
113
- await this.productRepository.save(product);
114
-
115
- return product;
116
- }
117
- }
118
- ```
119
-
120
- ### 3. Domain Layer (Business Models)
121
- **Core business entities and rules. Framework-independent.**
122
-
123
- ```typescript
124
- // ✅ Domain model with business rules
125
- export class Product {
126
- constructor(
127
- public readonly id: string,
128
- private _name: string,
129
- private _price: Money,
130
- private _isDiscontinued: boolean = false
131
- ) {}
132
-
133
- get name(): string {
134
- return this._name;
135
- }
136
-
137
- get price(): Money {
138
- return this._price;
139
- }
140
-
141
- get isDiscontinued(): boolean {
142
- return this._isDiscontinued;
143
- }
144
-
145
- updatePrice(newPrice: Money): void {
146
- // Business rule: validate price
147
- if (newPrice.amount <= 0) {
148
- throw new Error('Price must be positive');
149
- }
150
-
151
- // Business rule: prevent large price changes
152
- const changePercent = Math.abs(
153
- (newPrice.amount - this._price.amount) / this._price.amount
154
- );
155
- if (changePercent > 0.5) {
156
- throw new Error('Price change exceeds 50% threshold');
157
- }
158
-
159
- this._price = newPrice;
160
- }
161
-
162
- discontinue(): void {
163
- // Business rule: cannot discontinue if already discontinued
164
- if (this._isDiscontinued) {
165
- throw new Error('Product already discontinued');
166
- }
167
- this._isDiscontinued = true;
168
- }
169
-
170
- rename(newName: string): void {
171
- // Business rule: validate name
172
- if (newName.trim().length < 3) {
173
- throw new Error('Name must be at least 3 characters');
174
- }
175
- this._name = newName;
176
- }
177
- }
178
-
179
- // ✅ Value object
180
- export class Money {
181
- constructor(
182
- public readonly amount: number,
183
- public readonly currency: string
184
- ) {
185
- if (amount < 0) {
186
- throw new Error('Amount cannot be negative');
187
- }
188
- }
189
-
190
- add(other: Money): Money {
191
- if (this.currency !== other.currency) {
192
- throw new Error('Cannot add different currencies');
193
- }
194
- return new Money(this.amount + other.amount, this.currency);
195
- }
196
- }
197
- ```
198
-
199
- ### 4. Data Access Layer (Repositories)
200
- **Database operations, external API calls, caching.**
201
-
202
- ```typescript
203
- // ✅ Repository handles data persistence
204
- export class ProductRepository {
205
- constructor(private db: Database) {}
206
-
207
- async save(product: Product): Promise<void> {
208
- await this.db.query(
209
- `INSERT INTO products (id, name, price_amount, price_currency, is_discontinued)
210
- VALUES ($1, $2, $3, $4, $5)
211
- ON CONFLICT (id) DO UPDATE SET
212
- name = $2,
213
- price_amount = $3,
214
- price_currency = $4,
215
- is_discontinued = $5`,
216
- [product.id, product.name, product.price.amount, product.price.currency, product.isDiscontinued]
217
- );
218
- }
219
-
220
- async findById(id: string): Promise<Product | null> {
221
- const row = await this.db.queryOne(
222
- 'SELECT * FROM products WHERE id = $1',
223
- [id]
224
- );
225
-
226
- if (!row) return null;
227
-
228
- return this.toDomain(row);
229
- }
230
-
231
- async findMany(filters: ProductFilters): Promise<Product[]> {
232
- const query = this.buildFilterQuery(filters);
233
- const rows = await this.db.query(query.sql, query.params);
234
- return rows.map(row => this.toDomain(row));
235
- }
236
-
237
- private toDomain(row: any): Product {
238
- return new Product(
239
- row.id,
240
- row.name,
241
- new Money(row.price_amount, row.price_currency),
242
- row.is_discontinued
243
- );
244
- }
245
-
246
- private buildFilterQuery(filters: ProductFilters): { sql: string; params: any[] } {
247
- // Build dynamic SQL based on filters
248
- // ...
249
- }
250
- }
251
- ```
252
-
253
- ## File Organization
254
-
255
- ### Backend (Node.js/Express/NestJS)
256
- ```
257
- src/
258
- ├── presentation/ # Controllers, DTOs, validators
259
- │ ├── controllers/
260
- │ │ ├── ProductController.ts
261
- │ │ └── OrderController.ts
262
- │ ├── dto/
263
- │ │ ├── CreateProductDTO.ts
264
- │ │ └── ProductDTO.ts
265
- │ └── validators/
266
- │ └── ProductValidator.ts
267
-
268
- ├── application/ # Services, use cases
269
- │ ├── services/
270
- │ │ ├── ProductService.ts
271
- │ │ └── OrderService.ts
272
- │ └── interfaces/
273
- │ └── IProductRepository.ts
274
-
275
- ├── domain/ # Business models, value objects
276
- │ ├── models/
277
- │ │ ├── Product.ts
278
- │ │ └── Order.ts
279
- │ └── value-objects/
280
- │ └── Money.ts
281
-
282
- └── infrastructure/ # Repositories, database, external APIs
283
- ├── repositories/
284
- │ ├── ProductRepository.ts
285
- │ └── OrderRepository.ts
286
- ├── database/
287
- │ └── connection.ts
288
- └── external/
289
- └── PaymentGateway.ts
290
- ```
291
-
292
- ### Frontend (React/Vue)
293
- ```
294
- src/
295
- ├── presentation/ # Components (UI only)
296
- │ ├── components/
297
- │ │ ├── ProductCard.tsx
298
- │ │ └── ProductList.tsx
299
- │ └── pages/
300
- │ └── ProductsPage.tsx
301
-
302
- ├── application/ # Hooks/Composables (business logic)
303
- │ ├── hooks/ # React
304
- │ │ ├── useProducts.ts
305
- │ │ └── useCart.ts
306
- │ └── composables/ # Vue
307
- │ ├── useProducts.ts
308
- │ └── useCart.ts
309
-
310
- ├── domain/ # Business models (client-side)
311
- │ ├── models/
312
- │ │ ├── Product.ts
313
- │ │ └── Cart.ts
314
- │ └── value-objects/
315
- │ └── CartItem.ts
316
-
317
- └── infrastructure/ # API clients, storage
318
- ├── api/
319
- │ └── ProductApiClient.ts
320
- └── storage/
321
- └── LocalStorageCart.ts
322
- ```
323
-
324
- ## Testing Strategy
325
-
326
- ```typescript
327
- // ✅ Test presentation layer (mock service)
328
- describe('ProductController', () => {
329
- it('returns all products', async () => {
330
- const mockService = { findAll: jest.fn().mockResolvedValue([]) };
331
- const controller = new ProductController(mockService);
332
- const result = await controller.getAll({});
333
- expect(result).toEqual([]);
334
- });
335
- });
336
-
337
- // ✅ Test service layer (mock repository)
338
- describe('ProductService', () => {
339
- it('creates product and triggers events', async () => {
340
- const mockRepo = { save: jest.fn() };
341
- const mockEvents = { publish: jest.fn() };
342
- const service = new ProductService(mockRepo, mockEvents);
343
-
344
- await service.create({ name: 'Test', price: 100 });
345
-
346
- expect(mockRepo.save).toHaveBeenCalled();
347
- expect(mockEvents.publish).toHaveBeenCalled();
348
- });
349
- });
350
-
351
- // ✅ Test domain layer (no mocks - pure logic)
352
- describe('Product', () => {
353
- it('prevents negative prices', () => {
354
- const product = new Product('1', 'Test', new Money(100, 'USD'));
355
- expect(() => product.updatePrice(new Money(-10, 'USD'))).toThrow();
356
- });
357
- });
358
-
359
- // ✅ Test data layer (integration test with real DB)
360
- describe('ProductRepository', () => {
361
- it('persists and retrieves product', async () => {
362
- const repo = new ProductRepository(testDb);
363
- const product = new Product('1', 'Test', new Money(100, 'USD'));
364
-
365
- await repo.save(product);
366
- const retrieved = await repo.findById('1');
367
-
368
- expect(retrieved?.name).toBe('Test');
369
- });
370
- });
371
- ```
372
-
373
- ## Rules Summary
374
-
375
- - **ALWAYS** keep presentation logic separate from business logic
376
- - **ALWAYS** put business rules in service or domain layer, not controllers
377
- - **ALWAYS** make repositories responsible for data access only
378
- - **ALWAYS** use DTOs to decouple API contracts from domain models
379
- - **NEVER** access database directly from controllers
380
- - **NEVER** put business logic in repositories
381
- - **PREFER** thin controllers, fat services
382
- - **PREFER** dependency injection for testability