specialist-agent 2.9.0 → 2.11.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 (111) hide show
  1. package/.claude-plugin/marketplace.json +5 -5
  2. package/.claude-plugin/plugin.json +2 -2
  3. package/.cursor-plugin/marketplace.json +1 -1
  4. package/.cursor-plugin/plugin.json +2 -2
  5. package/.opencode/INSTALL.md +74 -79
  6. package/.opencode/opencode.json +141 -0
  7. package/README.md +128 -250
  8. package/agents/analyst.md +1 -0
  9. package/agents/api.md +4 -4
  10. package/agents/architect-lite.md +2 -2
  11. package/agents/architect.md +29 -20
  12. package/agents/cloud-lite.md +1 -1
  13. package/agents/cloud.md +4 -4
  14. package/agents/data-lite.md +1 -1
  15. package/agents/data.md +4 -4
  16. package/agents/debugger.md +1 -0
  17. package/agents/deps.md +4 -4
  18. package/agents/designer-lite.md +1 -1
  19. package/agents/designer.md +4 -4
  20. package/agents/devops-lite.md +1 -1
  21. package/agents/devops.md +4 -4
  22. package/agents/docs.md +4 -4
  23. package/agents/executor.md +95 -0
  24. package/agents/explorer-lite.md +1 -1
  25. package/agents/explorer.md +4 -4
  26. package/agents/finance-lite.md +1 -1
  27. package/agents/finance.md +4 -4
  28. package/agents/i18n.md +4 -4
  29. package/agents/legal-lite.md +1 -1
  30. package/agents/legal.md +4 -4
  31. package/agents/marketing-lite.md +25 -0
  32. package/agents/marketing.md +179 -0
  33. package/agents/memory.md +13 -12
  34. package/agents/orchestrator.md +102 -0
  35. package/agents/pair.md +1 -0
  36. package/agents/perf.md +4 -4
  37. package/agents/planner.md +1 -0
  38. package/agents/product-lite.md +25 -0
  39. package/agents/product.md +186 -0
  40. package/agents/refactor.md +4 -4
  41. package/agents/ripple.md +1 -0
  42. package/agents/scout.md +1 -0
  43. package/agents/security-lite.md +1 -1
  44. package/agents/security.md +4 -4
  45. package/agents/sentry-triage-lite.md +54 -0
  46. package/agents/sentry-triage.md +214 -0
  47. package/agents/starter-lite.md +4 -4
  48. package/agents/starter.md +8 -8
  49. package/agents/support-lite.md +24 -0
  50. package/agents/support.md +190 -0
  51. package/agents/tdd.md +1 -0
  52. package/agents/tester-lite.md +1 -1
  53. package/agents/tester.md +43 -10
  54. package/cli/architectures.mjs +713 -0
  55. package/cli/detect-architecture.mjs +752 -0
  56. package/cli/generate-architecture.mjs +1096 -0
  57. package/cli/index.mjs +681 -179
  58. package/cli/recommend-architecture.mjs +870 -0
  59. package/hooks/native/auto-dispatch.mjs +22 -23
  60. package/hooks/native/auto-format.mjs +5 -25
  61. package/hooks/native/mcp-discovery.mjs +168 -0
  62. package/hooks/native/security-config.json +7 -0
  63. package/hooks/native/security-guard.mjs +77 -27
  64. package/hooks/native/session-context.mjs +61 -18
  65. package/hooks/native/settings-template.json +9 -0
  66. package/package.json +1 -1
  67. package/packs/angular/agents/builder.md +10 -54
  68. package/packs/angular/agents/doctor.md +7 -61
  69. package/packs/angular/agents/migrator.md +7 -101
  70. package/packs/angular/agents/reviewer.md +22 -33
  71. package/packs/angular/skills/review-check-architecture/SKILL.md +7 -7
  72. package/packs/angular/skills/review-review/SKILL.md +1 -0
  73. package/packs/astro/agents/builder.md +10 -79
  74. package/packs/astro/agents/doctor.md +7 -61
  75. package/packs/astro/agents/migrator.md +7 -111
  76. package/packs/astro/agents/reviewer.md +22 -32
  77. package/packs/astro/skills/review-check-architecture/SKILL.md +9 -9
  78. package/packs/astro/skills/review-review/SKILL.md +1 -0
  79. package/packs/nextjs/agents/builder.md +11 -108
  80. package/packs/nextjs/agents/doctor.md +7 -62
  81. package/packs/nextjs/agents/migrator.md +6 -194
  82. package/packs/nextjs/agents/reviewer.md +22 -76
  83. package/packs/nextjs/skills/review-check-architecture/SKILL.md +15 -15
  84. package/packs/nextjs/skills/review-review/SKILL.md +1 -0
  85. package/packs/nuxt/agents/builder.md +10 -55
  86. package/packs/nuxt/agents/doctor.md +7 -61
  87. package/packs/nuxt/agents/migrator.md +7 -109
  88. package/packs/nuxt/agents/reviewer.md +22 -42
  89. package/packs/nuxt/skills/review-check-architecture/SKILL.md +11 -11
  90. package/packs/nuxt/skills/review-review/SKILL.md +1 -0
  91. package/packs/react/agents/builder.md +10 -55
  92. package/packs/react/agents/doctor.md +7 -61
  93. package/packs/react/agents/migrator.md +7 -106
  94. package/packs/react/agents/reviewer.md +22 -55
  95. package/packs/react/skills/review-check-architecture/SKILL.md +10 -10
  96. package/packs/react/skills/review-review/SKILL.md +1 -0
  97. package/packs/svelte/agents/builder.md +10 -58
  98. package/packs/svelte/agents/doctor.md +7 -60
  99. package/packs/svelte/agents/migrator.md +7 -118
  100. package/packs/svelte/agents/reviewer.md +22 -42
  101. package/packs/svelte/skills/review-check-architecture/SKILL.md +12 -12
  102. package/packs/svelte/skills/review-review/SKILL.md +1 -0
  103. package/packs/vue/agents/builder.md +10 -55
  104. package/packs/vue/agents/doctor.md +7 -61
  105. package/packs/vue/agents/migrator.md +7 -93
  106. package/packs/vue/agents/reviewer.md +20 -32
  107. package/packs/vue/skills/review-check-architecture/SKILL.md +10 -10
  108. package/packs/vue/skills/review-review/SKILL.md +1 -0
  109. package/skills/autofix/SKILL.md +166 -0
  110. package/skills/discovery/SKILL.md +218 -0
  111. package/skills/migrate-architecture/SKILL.md +242 -0
@@ -0,0 +1,1096 @@
1
+ /**
2
+ * Architecture Guide Generator
3
+ *
4
+ * Generates framework-specific ARCHITECTURE.md files for any
5
+ * architecture pattern + framework + variant combination.
6
+ *
7
+ * Uses the existing pack ARCHITECTURE.md files as the base for 'modular'
8
+ * pattern, and generates new ones for other patterns by adapting the
9
+ * structure to the target architecture while preserving framework-specific
10
+ * conventions (Server Components, composables, etc.)
11
+ */
12
+
13
+ import { existsSync, readFileSync } from 'fs'
14
+ import { join, resolve, dirname } from 'path'
15
+ import { fileURLToPath } from 'url'
16
+ import { ARCHITECTURE_PATTERNS, FRAMEWORK_ADAPTATIONS } from './architectures.mjs'
17
+
18
+ const __filename = fileURLToPath(import.meta.url)
19
+ const __dirname = dirname(__filename)
20
+ const ROOT = resolve(__dirname, '..')
21
+
22
+ // ── Main Generator ────────────────────────────────────
23
+
24
+ export function generateArchitectureGuide(options) {
25
+ const {
26
+ architecture, // 'modular', 'clean', 'hexagonal', 'fsd', 'ddd', etc.
27
+ framework, // 'nextjs', 'react', 'vue', 'nuxt', 'svelte', 'angular', 'astro'
28
+ variant = 'full', // 'full' | 'lite'
29
+ nextjsRouter = null, // 'app-router' | 'pages-router' | null
30
+ } = options
31
+
32
+ // For modular architecture, use the existing pack ARCHITECTURE.md if available
33
+ if (architecture === 'modular' && variant === 'full') {
34
+ const packArchPath = join(ROOT, 'packs', framework, 'ARCHITECTURE.md')
35
+ if (existsSync(packArchPath)) {
36
+ return readFileSync(packArchPath, 'utf-8')
37
+ }
38
+ }
39
+
40
+ // Generate from template
41
+ const generator = GENERATORS[architecture]
42
+ if (!generator) {
43
+ return generateGenericGuide(architecture, framework, variant)
44
+ }
45
+
46
+ return generator(framework, variant, { nextjsRouter })
47
+ }
48
+
49
+ // ── Framework Helpers ─────────────────────────────────
50
+
51
+ function fw(framework) {
52
+ const configs = {
53
+ nextjs: {
54
+ name: 'Next.js',
55
+ lang: 'TypeScript',
56
+ componentExt: 'tsx',
57
+ hookDir: 'hooks',
58
+ hookPrefix: 'use',
59
+ stateClient: 'Zustand',
60
+ stateServer: 'TanStack React Query',
61
+ testLib: 'Vitest + React Testing Library',
62
+ validation: 'Zod',
63
+ styling: 'Tailwind CSS / CSS Modules',
64
+ router: 'App Router (file-system)',
65
+ componentPattern: 'React Server Components + Client Components',
66
+ },
67
+ react: {
68
+ name: 'React',
69
+ lang: 'TypeScript',
70
+ componentExt: 'tsx',
71
+ hookDir: 'hooks',
72
+ hookPrefix: 'use',
73
+ stateClient: 'Zustand',
74
+ stateServer: 'TanStack React Query',
75
+ testLib: 'Vitest + React Testing Library',
76
+ validation: 'Zod',
77
+ styling: 'Tailwind CSS / CSS Modules',
78
+ router: 'React Router 6',
79
+ componentPattern: 'Functional Components',
80
+ },
81
+ vue: {
82
+ name: 'Vue 3',
83
+ lang: 'TypeScript',
84
+ componentExt: 'vue',
85
+ hookDir: 'composables',
86
+ hookPrefix: 'use',
87
+ stateClient: 'Pinia',
88
+ stateServer: 'TanStack Vue Query',
89
+ testLib: 'Vitest + @vue/test-utils',
90
+ validation: 'Zod',
91
+ styling: 'Scoped CSS / Tailwind',
92
+ router: 'Vue Router 4',
93
+ componentPattern: '<script setup lang="ts">',
94
+ },
95
+ nuxt: {
96
+ name: 'Nuxt 3',
97
+ lang: 'TypeScript',
98
+ componentExt: 'vue',
99
+ hookDir: 'composables',
100
+ hookPrefix: 'use',
101
+ stateClient: 'Pinia',
102
+ stateServer: 'TanStack Vue Query',
103
+ testLib: 'Vitest + @vue/test-utils',
104
+ validation: 'Zod',
105
+ styling: 'Scoped CSS / Tailwind',
106
+ router: 'File-based routing (pages/)',
107
+ componentPattern: '<script setup lang="ts"> + auto-imports',
108
+ },
109
+ svelte: {
110
+ name: 'SvelteKit',
111
+ lang: 'TypeScript',
112
+ componentExt: 'svelte',
113
+ hookDir: 'stores',
114
+ hookPrefix: '',
115
+ stateClient: 'Svelte stores',
116
+ stateServer: 'TanStack Svelte Query',
117
+ testLib: 'Vitest + @testing-library/svelte',
118
+ validation: 'Zod',
119
+ styling: 'Scoped CSS / Tailwind',
120
+ router: 'File-based routing (+page.svelte)',
121
+ componentPattern: 'Svelte Components + Load Functions',
122
+ },
123
+ angular: {
124
+ name: 'Angular',
125
+ lang: 'TypeScript',
126
+ componentExt: 'ts',
127
+ hookDir: 'services',
128
+ hookPrefix: '',
129
+ stateClient: 'NgRx Signals',
130
+ stateServer: 'TanStack Angular Query',
131
+ testLib: 'Vitest + Angular Testing Library',
132
+ validation: 'Zod',
133
+ styling: 'Component styles / Tailwind',
134
+ router: 'Angular Router (lazy-loaded)',
135
+ componentPattern: 'Standalone Components + Signals',
136
+ },
137
+ astro: {
138
+ name: 'Astro',
139
+ lang: 'TypeScript',
140
+ componentExt: 'astro',
141
+ hookDir: 'utils',
142
+ hookPrefix: '',
143
+ stateClient: 'Nanostores',
144
+ stateServer: 'Astro data fetching',
145
+ testLib: 'Vitest',
146
+ validation: 'Zod',
147
+ styling: 'Scoped CSS / Tailwind',
148
+ router: 'File-based routing (pages/)',
149
+ componentPattern: 'Astro Components + Framework Islands',
150
+ },
151
+ }
152
+ return configs[framework] || configs.react
153
+ }
154
+
155
+ // ── Architecture Generators ───────────────────────────
156
+
157
+ const GENERATORS = {
158
+ modular: generateModularGuide,
159
+ 'modular-lite': generateModularLiteGuide,
160
+ clean: generateCleanGuide,
161
+ hexagonal: generateHexagonalGuide,
162
+ fsd: generateFSDGuide,
163
+ ddd: generateDDDGuide,
164
+ 'modular-monolith': generateModularMonolithGuide,
165
+ cqrs: generateCQRSGuide,
166
+ atomic: generateAtomicGuide,
167
+ mvc: generateMVCGuide,
168
+ }
169
+
170
+ function generateModularGuide(framework, variant, options) {
171
+ if (variant === 'lite') return generateModularLiteGuide(framework, variant, options)
172
+ const f = fw(framework)
173
+ const srcPrefix = framework === 'nuxt' ? '' : 'src/'
174
+
175
+ return `# ARCHITECTURE.md -- Architecture & Patterns Guide (${f.name})
176
+
177
+ > This document is the **source of truth** for all subagents.
178
+ > Every architectural decision must be documented here.
179
+
180
+ ---
181
+
182
+ ## 1. Overview
183
+
184
+ | Concept | Implementation |
185
+ |---------|---------------|
186
+ | Framework | ${f.name} |
187
+ | Language | ${f.lang} (strict) |
188
+ | Architecture | Modular (Feature-Based) -- Full |
189
+ | Components | ${f.componentPattern} |
190
+ | Client state | ${f.stateClient} |
191
+ | Server state | ${f.stateServer} |
192
+ | Routing | ${f.router} |
193
+ | Testing | ${f.testLib} |
194
+ | Validation | ${f.validation} |
195
+
196
+ ### Architecture Flow
197
+
198
+ \`\`\`
199
+ Service (HTTP only) --> Adapter (parse) --> ${f.hookDir === 'composables' ? 'Composable' : 'Hook'} (orchestrate) --> Component
200
+ \`\`\`
201
+
202
+ ---
203
+
204
+ ## 2. Directory Structure
205
+
206
+ \`\`\`
207
+ ${srcPrefix}
208
+ ├── modules/ # Feature modules (bounded contexts)
209
+ │ ├── [feature]/
210
+ │ │ ├── components/
211
+ │ │ ├── ${f.hookDir}/
212
+ │ │ ├── services/
213
+ │ │ ├── adapters/
214
+ │ │ ├── stores/
215
+ │ │ ├── types/
216
+ │ │ ├── __tests__/
217
+ │ │ └── index.ts # Barrel export (public API)
218
+ │
219
+ ├── shared/ # Shared across modules
220
+ │ ├── components/
221
+ │ ├── ${f.hookDir}/
222
+ │ ├── services/
223
+ │ ├── types/
224
+ │ ├── utils/ # Pure functions
225
+ │ └── helpers/ # Functions with side effects
226
+ \`\`\`
227
+
228
+ ### Import Rules
229
+
230
+ \`\`\`
231
+ modules/auth <-> shared/ OK
232
+ modules/auth --> modules/market NO (modules don't import from each other)
233
+ shared/ --> modules/auth NO (shared doesn't import from modules)
234
+ \`\`\`
235
+
236
+ ---
237
+
238
+ ## 3. Responsibility Layers
239
+
240
+ ### Services -- Pure HTTP Calls
241
+ - NO try/catch, NO transformation, NO business logic
242
+ - One file per domain/resource
243
+ - Export as object with methods
244
+
245
+ ### Adapters -- Contract Parsers
246
+ - Pure functions: API response <-> App contract
247
+ - Rename fields (snake_case -> camelCase)
248
+ - Convert types (string -> Date, cents -> decimal)
249
+
250
+ ### ${f.hookDir === 'composables' ? 'Composables' : 'Hooks'} -- Orchestration
251
+ - Connect service -> adapter -> ${f.stateServer}
252
+ - Manage loading, error, empty states
253
+ - Prefix with \`${f.hookPrefix}\`
254
+
255
+ ### Stores -- Client State Only
256
+ - ${f.stateClient} for UI state, filters, preferences
257
+ - NO server state (use ${f.stateServer} instead)
258
+ - NO HTTP calls inside stores
259
+
260
+ ### Types
261
+ - \`.types.ts\` for API types (raw response, snake_case)
262
+ - \`.contracts.ts\` for app contracts (camelCase, correct types)
263
+ - NO \`any\`
264
+
265
+ ---
266
+
267
+ ## 4. Rules
268
+
269
+ - Components < 200 lines, typed props
270
+ - Barrel exports (index.ts) per module
271
+ - Utils = pure functions | Helpers = side effects
272
+ - Error handling: centralized in ${f.hookDir} layer
273
+ `
274
+ }
275
+
276
+ function generateModularLiteGuide(framework, variant, options) {
277
+ const f = fw(framework)
278
+ const srcPrefix = framework === 'nuxt' ? '' : 'src/'
279
+
280
+ return `# ARCHITECTURE.md -- Architecture & Patterns Guide (${f.name})
281
+
282
+ > Simplified Modular Architecture -- fewer layers, same principles.
283
+
284
+ ---
285
+
286
+ ## 1. Overview
287
+
288
+ | Concept | Implementation |
289
+ |---------|---------------|
290
+ | Framework | ${f.name} |
291
+ | Language | ${f.lang} (strict) |
292
+ | Architecture | Modular (Feature-Based) -- Simplified |
293
+ | Client state | ${f.stateClient} |
294
+ | Server state | ${f.stateServer} |
295
+
296
+ ### Architecture Flow
297
+
298
+ \`\`\`
299
+ Service (HTTP + transform) --> ${f.hookDir === 'composables' ? 'Composable' : 'Hook'} (orchestrate) --> Component
300
+ \`\`\`
301
+
302
+ ---
303
+
304
+ ## 2. Directory Structure
305
+
306
+ \`\`\`
307
+ ${srcPrefix}
308
+ ├── modules/
309
+ │ ├── [feature]/
310
+ │ │ ├── components/
311
+ │ │ ├── ${f.hookDir}/
312
+ │ │ ├── services/ # HTTP + data transformation (no separate adapters)
313
+ │ │ ├── types/
314
+ │ │ └── index.ts
315
+ │
316
+ ├── shared/
317
+ │ ├── components/
318
+ │ ├── utils/
319
+ │ └── types/
320
+ \`\`\`
321
+
322
+ ### Key Differences from Full
323
+
324
+ - **No adapters/**: data transformation done in services directly
325
+ - **No stores/**: co-locate state with ${f.hookDir}
326
+ - **No helpers/**: merge into utils or ${f.hookDir}
327
+ - Same import rules: modules don't import from each other
328
+
329
+ ---
330
+
331
+ ## 3. Rules
332
+
333
+ - Services: HTTP calls + response transformation (combined)
334
+ - ${f.hookDir === 'composables' ? 'Composables' : 'Hooks'}: orchestrate service calls + manage state
335
+ - Types: \`.types.ts\` for API + app contracts (single file per domain)
336
+ - Components < 200 lines, typed props
337
+ - Barrel exports (index.ts) per module
338
+ `
339
+ }
340
+
341
+ function generateCleanGuide(framework, variant, options) {
342
+ const f = fw(framework)
343
+ const srcPrefix = framework === 'nuxt' ? '' : 'src/'
344
+ const isLite = variant === 'lite'
345
+
346
+ if (isLite) {
347
+ return `# ARCHITECTURE.md -- Clean Architecture Simplified (${f.name})
348
+
349
+ > Two-layer Clean Architecture: Core + Infrastructure.
350
+
351
+ ---
352
+
353
+ ## 1. Overview
354
+
355
+ | Concept | Implementation |
356
+ |---------|---------------|
357
+ | Framework | ${f.name} |
358
+ | Architecture | Clean Architecture -- Simplified |
359
+ | Dependency Rule | core/ has ZERO framework imports |
360
+
361
+ ---
362
+
363
+ ## 2. Directory Structure
364
+
365
+ \`\`\`
366
+ ${srcPrefix}
367
+ ├── core/ # Domain + Application (merged)
368
+ │ ├── entities/ # Business objects (pure TS)
369
+ │ ├── use-cases/ # Application logic
370
+ │ └── ports/ # Interfaces for external deps
371
+ │
372
+ ├── infra/ # Infrastructure + Presentation (merged)
373
+ │ ├── database/ # Repository implementations
374
+ │ ├── http/ # API clients, REST controllers
375
+ │ ├── components/ # UI components
376
+ │ └── ${f.hookDir}/
377
+ \`\`\`
378
+
379
+ ### Dependency Rule
380
+
381
+ \`\`\`
382
+ infra/ --> core/ OK (infra implements core interfaces)
383
+ core/ --> infra/ NEVER (core has no external dependencies)
384
+ \`\`\`
385
+
386
+ ---
387
+
388
+ ## 3. Key Rules
389
+
390
+ - **core/** has ZERO imports from framework (${f.name}), database, or HTTP libraries
391
+ - **ports/** define interfaces that **infra/** implements
392
+ - Use cases contain business logic, not components or services
393
+ - Entities are pure TypeScript objects with behavior
394
+ `
395
+ }
396
+
397
+ return `# ARCHITECTURE.md -- Clean Architecture (${f.name})
398
+
399
+ > Four-layer Clean Architecture with strict dependency rule.
400
+ > Dependencies point INWARD only: Frameworks -> Adapters -> Use Cases -> Entities.
401
+
402
+ ---
403
+
404
+ ## 1. Overview
405
+
406
+ | Concept | Implementation |
407
+ |---------|---------------|
408
+ | Framework | ${f.name} |
409
+ | Architecture | Clean Architecture -- Full |
410
+ | Client state | ${f.stateClient} |
411
+ | Server state | ${f.stateServer} |
412
+ | Dependency Rule | All dependencies point INWARD |
413
+
414
+ ---
415
+
416
+ ## 2. Directory Structure
417
+
418
+ \`\`\`
419
+ ${srcPrefix}
420
+ ├── domain/ # Innermost: Enterprise Business Rules
421
+ │ ├── entities/ # Business objects with behavior
422
+ │ ├── value-objects/ # Immutable, equality by value
423
+ │ ├── repositories/ # Interfaces ONLY (no implementations)
424
+ │ └── errors/ # Domain-specific errors
425
+ │
426
+ ├── application/ # Use Cases: Application Business Rules
427
+ │ ├── use-cases/ # One class per use case
428
+ │ ├── dtos/ # Data Transfer Objects
429
+ │ └── ports/ # Input/Output interfaces
430
+ │
431
+ ├── infrastructure/ # Outer: Frameworks & Drivers
432
+ │ ├── database/ # Repository implementations
433
+ │ ├── http/ # API clients, external services
434
+ │ ├── messaging/ # Message queue adapters
435
+ │ └── repositories/ # Concrete repository implementations
436
+ │
437
+ ├── presentation/ # Outer: UI Layer
438
+ │ ├── components/ # ${f.componentPattern}
439
+ │ ├── ${f.hookDir}/
440
+ │ ├── stores/ # ${f.stateClient}
441
+ │ └── pages/
442
+ \`\`\`
443
+
444
+ ### Dependency Rule (Iron Law)
445
+
446
+ \`\`\`
447
+ presentation/ --> application/ OK (uses use cases)
448
+ presentation/ --> domain/ OK (uses entities/types)
449
+ presentation/ --> infrastructure/ NEVER
450
+ infrastructure/ --> application/ OK (implements ports)
451
+ infrastructure/ --> domain/ OK (implements repositories)
452
+ application/ --> domain/ OK (uses entities)
453
+ application/ --> infrastructure/ NEVER
454
+ domain/ --> anything NEVER (zero external deps)
455
+ \`\`\`
456
+
457
+ ---
458
+
459
+ ## 3. Key Layers
460
+
461
+ ### Domain (entities/, value-objects/)
462
+ - Pure TypeScript, no framework imports
463
+ - Business rules live here
464
+ - Repository interfaces (not implementations)
465
+
466
+ ### Application (use-cases/)
467
+ - One class/function per use case: \`CreateOrder\`, \`GetUserById\`
468
+ - Depends only on domain
469
+ - DTOs for input/output
470
+
471
+ ### Infrastructure (database/, http/)
472
+ - Implements domain interfaces
473
+ - Database, HTTP clients, message queues
474
+ - Framework-specific code lives here
475
+
476
+ ### Presentation (components/, ${f.hookDir}/)
477
+ - ${f.componentPattern}
478
+ - ${f.hookDir} orchestrate use cases
479
+ - ${f.stateClient} for UI state only
480
+
481
+ ---
482
+
483
+ ## 4. Rules
484
+
485
+ - domain/ has ZERO imports from any other layer
486
+ - application/ only imports from domain/
487
+ - Use case per file (Single Responsibility)
488
+ - Repository pattern: interface in domain/, implementation in infrastructure/
489
+ - DTOs at layer boundaries (never pass entities to presentation)
490
+ `
491
+ }
492
+
493
+ function generateHexagonalGuide(framework, variant, options) {
494
+ const f = fw(framework)
495
+ const srcPrefix = framework === 'nuxt' ? '' : 'src/'
496
+ const isLite = variant === 'lite'
497
+
498
+ if (isLite) {
499
+ return `# ARCHITECTURE.md -- Hexagonal Architecture Simplified (${f.name})
500
+
501
+ > Ports & Adapters with flat structure.
502
+
503
+ ---
504
+
505
+ ## 1. Directory Structure
506
+
507
+ \`\`\`
508
+ ${srcPrefix}
509
+ ├── core/ # Domain + Use Cases
510
+ │ ├── domain/ # Entities, value objects
511
+ │ ├── ports/ # All interfaces (no in/out split)
512
+ │ └── use-cases/ # Application logic
513
+ │
514
+ ├── adapters/ # All implementations (no in/out split)
515
+ │ ├── web/ # ${f.componentPattern}
516
+ │ ├── database/ # Repository implementations
517
+ │ └── http-client/ # External API clients
518
+ \`\`\`
519
+
520
+ ### Rule
521
+
522
+ \`\`\`
523
+ core/ has ZERO external dependencies
524
+ adapters/ implement core/ports/ interfaces
525
+ \`\`\`
526
+ `
527
+ }
528
+
529
+ return `# ARCHITECTURE.md -- Hexagonal Architecture (${f.name})
530
+
531
+ > Ports & Adapters: Core domain isolated by explicit interfaces.
532
+
533
+ ---
534
+
535
+ ## 1. Overview
536
+
537
+ | Concept | Implementation |
538
+ |---------|---------------|
539
+ | Framework | ${f.name} |
540
+ | Architecture | Hexagonal (Ports & Adapters) -- Full |
541
+ | Core | Domain model with zero external dependencies |
542
+ | Ports | Interfaces that define how the core communicates |
543
+ | Adapters | Implementations that connect the core to the outside world |
544
+
545
+ ---
546
+
547
+ ## 2. Directory Structure
548
+
549
+ \`\`\`
550
+ ${srcPrefix}
551
+ ├── core/
552
+ │ ├── domain/
553
+ │ │ ├── entities/
554
+ │ │ ├── value-objects/
555
+ │ │ └── services/ # Domain services
556
+ │ ├── ports/
557
+ │ │ ├── in/ # Driving ports (use case interfaces)
558
+ │ │ └── out/ # Driven ports (repository/external interfaces)
559
+ │ └── use-cases/ # Implements driving ports
560
+ │
561
+ ├── adapters/
562
+ │ ├── in/ # Driving adapters (trigger the app)
563
+ │ │ ├── web/ # ${f.componentPattern}, controllers
564
+ │ │ └── cli/ # CLI commands (if applicable)
565
+ │ └── out/ # Driven adapters (called by the app)
566
+ │ ├── database/ # Repository implementations
567
+ │ ├── http-client/ # External API clients
568
+ │ └── messaging/ # Message broker adapters
569
+ \`\`\`
570
+
571
+ ### Port & Adapter Flow
572
+
573
+ \`\`\`
574
+ [User/External] -> Driving Adapter -> Driving Port -> Use Case -> Driven Port -> Driven Adapter -> [DB/API/Queue]
575
+ \`\`\`
576
+
577
+ ---
578
+
579
+ ## 3. Key Rules
580
+
581
+ - **core/** has ZERO imports from adapters/ or any framework
582
+ - **Ports** are interfaces defined in core/
583
+ - **Adapters** implement port interfaces
584
+ - Driving adapters (in/) trigger application logic
585
+ - Driven adapters (out/) are called by application logic
586
+ - Use cases implement driving ports and consume driven ports
587
+ - To swap infrastructure (e.g., PostgreSQL -> MongoDB), only change the adapter
588
+ `
589
+ }
590
+
591
+ function generateFSDGuide(framework, variant, options) {
592
+ const f = fw(framework)
593
+ const srcPrefix = framework === 'nuxt' ? '' : 'src/'
594
+ const isLite = variant === 'lite'
595
+
596
+ const layers = isLite
597
+ ? `\`\`\`
598
+ ${srcPrefix}
599
+ ├── app/ # App init, providers, routing
600
+ ├── pages/ # Full page compositions
601
+ ├── features/ # User interaction units
602
+ │ └── [feature]/
603
+ │ ├── ui/
604
+ │ └── model/
605
+ ├── entities/ # Business entities
606
+ │ └── [entity]/
607
+ │ ├── ui/
608
+ │ └── model/
609
+ └── shared/ # Reusable infrastructure
610
+ ├── ui/
611
+ └── lib/
612
+ \`\`\``
613
+ : `\`\`\`
614
+ ${srcPrefix}
615
+ ├── app/ # App init, providers, global styles
616
+ ├── processes/ # Cross-page business flows (optional)
617
+ ├── pages/ # Full page compositions
618
+ ├── widgets/ # Composite UI blocks
619
+ ├── features/ # User interaction units
620
+ │ └── [feature]/
621
+ │ ├── ui/ # Components
622
+ │ ├── model/ # State, types, logic
623
+ │ ├── api/ # API calls
624
+ │ └── lib/ # Utils
625
+ ├── entities/ # Business entities
626
+ │ └── [entity]/
627
+ │ ├── ui/
628
+ │ ├── model/
629
+ │ └── api/
630
+ └── shared/ # Reusable infrastructure
631
+ ├── ui/ # Design system components
632
+ ├── lib/ # Utilities
633
+ ├── api/ # API client
634
+ └── config/ # App config
635
+ \`\`\``
636
+
637
+ return `# ARCHITECTURE.md -- Feature-Sliced Design (${f.name})
638
+
639
+ > Strict layered architecture with import rules.
640
+ > Import direction: app -> pages -> widgets -> features -> entities -> shared
641
+
642
+ ---
643
+
644
+ ## 1. Overview
645
+
646
+ | Concept | Implementation |
647
+ |---------|---------------|
648
+ | Framework | ${f.name} |
649
+ | Architecture | Feature-Sliced Design -- ${isLite ? 'Simplified' : 'Full'} |
650
+ | Layers | ${isLite ? '5 (no processes/widgets)' : '7'} |
651
+ | Import rule | Top-down only, never upward |
652
+
653
+ ---
654
+
655
+ ## 2. Directory Structure
656
+
657
+ ${layers}
658
+
659
+ ### Import Rules (strict)
660
+
661
+ \`\`\`
662
+ app -> pages -> ${isLite ? '' : 'widgets -> '}features -> entities -> shared
663
+ \`\`\`
664
+
665
+ A layer can ONLY import from layers BELOW it. Never upward, never sideways at the same level.
666
+
667
+ ---
668
+
669
+ ## 3. Slice Structure
670
+
671
+ Each feature/entity is a "slice" with segments:
672
+
673
+ - **ui/**: Components specific to this slice
674
+ - **model/**: State management, types, business logic
675
+ - **api/**: Data fetching for this slice
676
+ - **lib/**: Utilities specific to this slice
677
+
678
+ Each slice has a public API via \`index.ts\`.
679
+
680
+ ---
681
+
682
+ ## 4. Key Rules
683
+
684
+ - NEVER import upward (features cannot import from pages)
685
+ - NEVER import sideways (feature A cannot import from feature B)
686
+ - Cross-slice communication goes through shared/ or via events
687
+ - Each slice is self-contained with its own segments
688
+ `
689
+ }
690
+
691
+ function generateDDDGuide(framework, variant, options) {
692
+ const f = fw(framework)
693
+ const srcPrefix = framework === 'nuxt' ? '' : 'src/'
694
+ const isLite = variant === 'lite'
695
+
696
+ if (isLite) {
697
+ return `# ARCHITECTURE.md -- Domain-Driven Design Simplified (${f.name})
698
+
699
+ > DDD with simplified tactical patterns.
700
+
701
+ ---
702
+
703
+ ## 1. Directory Structure
704
+
705
+ \`\`\`
706
+ ${srcPrefix}
707
+ ├── modules/ # One per bounded context
708
+ │ └── [context]/
709
+ │ ├── domain/
710
+ │ │ ├── entities/ # Business objects
711
+ │ │ ├── value-objects/ # Immutable types
712
+ │ │ └── events/ # Domain events
713
+ │ ├── application/
714
+ │ │ └── handlers/ # Command/query handlers
715
+ │ ├── infrastructure/ # DB, HTTP, messaging
716
+ │ └── index.ts # Public API
717
+ │
718
+ └── shared/ # Shared kernel
719
+ ├── types/
720
+ └── events/
721
+ \`\`\`
722
+
723
+ ---
724
+
725
+ ## 2. Key Rules
726
+
727
+ - Each module = one bounded context
728
+ - Domain layer has ZERO external dependencies
729
+ - Communicate between contexts via events or shared kernel
730
+ - Entities encapsulate business rules (not anemic models)
731
+ `
732
+ }
733
+
734
+ return `# ARCHITECTURE.md -- Domain-Driven Design (${f.name})
735
+
736
+ > Full DDD with bounded contexts and tactical patterns.
737
+
738
+ ---
739
+
740
+ ## 1. Overview
741
+
742
+ | Concept | Implementation |
743
+ |---------|---------------|
744
+ | Framework | ${f.name} |
745
+ | Architecture | Domain-Driven Design -- Full |
746
+ | Strategic | Bounded Contexts, Context Mapping |
747
+ | Tactical | Aggregates, Value Objects, Domain Events |
748
+
749
+ ---
750
+
751
+ ## 2. Directory Structure
752
+
753
+ \`\`\`
754
+ ${srcPrefix}
755
+ ├── bounded-contexts/
756
+ │ └── [context]/
757
+ │ ├── domain/
758
+ │ │ ├── aggregates/
759
+ │ │ │ └── [aggregate]/
760
+ │ │ │ ├── AggregateRoot.ts
761
+ │ │ │ ├── Entity.ts
762
+ │ │ │ └── ValueObject.ts
763
+ │ │ ├── events/
764
+ │ │ │ └── [DomainEvent].ts
765
+ │ │ ├── repositories/ # Interfaces only
766
+ │ │ └── services/ # Domain services
767
+ │ ├── application/
768
+ │ │ ├── commands/
769
+ │ │ ├── queries/
770
+ │ │ └── handlers/
771
+ │ └── infrastructure/
772
+ │ ├── persistence/
773
+ │ └── messaging/
774
+ │
775
+ └── shared-kernel/
776
+ ├── types/
777
+ └── events/
778
+ \`\`\`
779
+
780
+ ---
781
+
782
+ ## 3. Tactical Patterns
783
+
784
+ ### Aggregate Root
785
+ - Entry point for modifications to an aggregate
786
+ - Ensures consistency within the aggregate boundary
787
+ - Only aggregate roots are referenced by ID from outside
788
+
789
+ ### Value Object
790
+ - Immutable, equality by value (not identity)
791
+ - Examples: Money, Email, Address, DateRange
792
+
793
+ ### Domain Event
794
+ - Past tense: \`OrderPlaced\`, \`PaymentReceived\`
795
+ - Published when something important happens in the domain
796
+ - Consumed by other bounded contexts
797
+
798
+ ---
799
+
800
+ ## 4. Key Rules
801
+
802
+ - Domain layer has ZERO framework dependencies
803
+ - Aggregate Root is the only way to modify an aggregate
804
+ - Value Objects are immutable
805
+ - Bounded contexts communicate via events or ACL
806
+ - Ubiquitous language: use business terms, not technical ones
807
+ `
808
+ }
809
+
810
+ function generateModularMonolithGuide(framework, variant, options) {
811
+ const f = fw(framework)
812
+ const srcPrefix = framework === 'nuxt' ? '' : 'src/'
813
+ const isLite = variant === 'lite'
814
+
815
+ if (isLite) {
816
+ return `# ARCHITECTURE.md -- Modular Monolith Simplified (${f.name})
817
+
818
+ > Single deployment with module boundaries enforced by barrel exports.
819
+
820
+ ---
821
+
822
+ ## 1. Directory Structure
823
+
824
+ \`\`\`
825
+ ${srcPrefix}
826
+ ├── modules/
827
+ │ └── [module]/
828
+ │ ├── services/ # Business logic + data access
829
+ │ ├── types/ # Module types
830
+ │ └── index.ts # Public API (barrel export)
831
+ │
832
+ └── shared/
833
+ ├── database/
834
+ └── utils/
835
+ \`\`\`
836
+
837
+ ---
838
+
839
+ ## 2. Key Rules
840
+
841
+ - Single package.json, single deployment
842
+ - Modules communicate ONLY through barrel exports (index.ts)
843
+ - No direct imports between module internals
844
+ - When two modules need to share: move to shared/
845
+ `
846
+ }
847
+
848
+ return `# ARCHITECTURE.md -- Modular Monolith (${f.name})
849
+
850
+ > Single deployment with strict module boundaries and internal layering.
851
+
852
+ ---
853
+
854
+ ## 1. Overview
855
+
856
+ | Concept | Implementation |
857
+ |---------|---------------|
858
+ | Framework | ${f.name} |
859
+ | Architecture | Modular Monolith -- Full |
860
+ | Deployment | Single unit |
861
+ | Boundaries | Enforced via barrel exports + internal layers |
862
+
863
+ ---
864
+
865
+ ## 2. Directory Structure
866
+
867
+ \`\`\`
868
+ ${srcPrefix}
869
+ ├── modules/
870
+ │ └── [module]/
871
+ │ ├── domain/
872
+ │ │ ├── entities/
873
+ │ │ ├── value-objects/
874
+ │ │ └── repositories/ # Interfaces
875
+ │ ├── application/
876
+ │ │ ├── use-cases/
877
+ │ │ └── dtos/
878
+ │ ├── infrastructure/
879
+ │ │ ├── persistence/
880
+ │ │ └── http/
881
+ │ └── index.ts # Public API
882
+ │
883
+ └── shared/
884
+ ├── database/
885
+ ├── config/
886
+ └── utils/
887
+ \`\`\`
888
+
889
+ ---
890
+
891
+ ## 3. Key Rules
892
+
893
+ - **Single deployment** but **strict module boundaries**
894
+ - Modules communicate ONLY through their public API (index.ts)
895
+ - Each module has domain/application/infrastructure layers
896
+ - domain/ has ZERO external dependencies (same as Clean Architecture)
897
+ - This IS the stepping stone to microservices: extract modules when needed
898
+ - To extract a module to a microservice: move its folder, add network boundary
899
+ `
900
+ }
901
+
902
+ function generateCQRSGuide(framework, variant, options) {
903
+ const f = fw(framework)
904
+ const srcPrefix = framework === 'nuxt' ? '' : 'src/'
905
+ const isLite = variant === 'lite'
906
+
907
+ return `# ARCHITECTURE.md -- CQRS (${f.name})
908
+
909
+ > Command Query Responsibility Segregation${isLite ? ' -- without Event Sourcing' : ''}.
910
+
911
+ ---
912
+
913
+ ## 1. Directory Structure
914
+
915
+ ${isLite ? `\`\`\`
916
+ ${srcPrefix}
917
+ ├── commands/ # Write operations
918
+ │ └── CreateOrder.ts
919
+ ├── queries/ # Read operations
920
+ │ └── GetOrderById.ts
921
+ ├── handlers/ # Both command + query handlers
922
+ │ ├── CreateOrderHandler.ts
923
+ │ └── GetOrderByIdHandler.ts
924
+ ├── models/ # Shared model (single DB)
925
+ └── events/ # Domain events (optional)
926
+ \`\`\`` : `\`\`\`
927
+ ${srcPrefix}
928
+ ├── commands/
929
+ │ └── CreateOrder.ts
930
+ ├── command-handlers/
931
+ │ └── CreateOrderHandler.ts
932
+ ├── queries/
933
+ │ └── GetOrderById.ts
934
+ ├── query-handlers/
935
+ │ └── GetOrderByIdHandler.ts
936
+ ├── write-models/ # Write-optimized models
937
+ ├── read-models/ # Read-optimized projections
938
+ ├── events/ # Domain events
939
+ ├── projections/ # Event -> Read Model updaters
940
+ └── event-store/ # Event persistence
941
+ \`\`\``}
942
+
943
+ ---
944
+
945
+ ## 2. Key Rules
946
+
947
+ - Commands change state, Queries read state (never both)
948
+ - Command handlers validate and execute writes
949
+ - Query handlers optimize for reads (denormalized if needed)
950
+ ${isLite ? '- Same database for reads and writes (simplified)' : '- Separate read/write databases for optimal performance'}
951
+ ${isLite ? '' : '- Event Store records all state changes as events\n- Projections build read models from events'}
952
+ `
953
+ }
954
+
955
+ function generateAtomicGuide(framework, variant, options) {
956
+ const f = fw(framework)
957
+ const srcPrefix = framework === 'nuxt' ? '' : 'src/'
958
+ const isLite = variant === 'lite'
959
+
960
+ return `# ARCHITECTURE.md -- Atomic Design (${f.name})
961
+
962
+ > Components organized by granularity: ${isLite ? 'primitives, organisms, pages' : 'atoms, molecules, organisms, templates, pages'}.
963
+
964
+ ---
965
+
966
+ ## 1. Directory Structure
967
+
968
+ ${isLite ? `\`\`\`
969
+ ${srcPrefix}
970
+ ├── components/
971
+ │ ├── primitives/ # Atoms + Molecules (merged)
972
+ │ │ ├── Button.${f.componentExt}
973
+ │ │ ├── Input.${f.componentExt}
974
+ │ │ └── SearchBar.${f.componentExt}
975
+ │ └── organisms/
976
+ │ ├── Header.${f.componentExt}
977
+ │ └── ProductCard.${f.componentExt}
978
+ ├── pages/
979
+ ├── services/
980
+ └── types/
981
+ \`\`\`` : `\`\`\`
982
+ ${srcPrefix}
983
+ ├── components/
984
+ │ ├── atoms/ # Smallest units (Button, Input, Icon)
985
+ │ ├── molecules/ # Combinations (SearchBar, FormField)
986
+ │ ├── organisms/ # Complex blocks (Header, ProductCard)
987
+ │ └── templates/ # Page layouts (DashboardTemplate)
988
+ ├── pages/
989
+ ├── ${f.hookDir}/
990
+ ├── services/
991
+ └── types/
992
+ \`\`\``}
993
+
994
+ ---
995
+
996
+ ## 2. Component Hierarchy
997
+
998
+ \`\`\`
999
+ ${isLite ? 'Pages -> Organisms -> Primitives' : 'Pages -> Templates -> Organisms -> Molecules -> Atoms'}
1000
+ \`\`\`
1001
+
1002
+ Each level can only use components from levels below it.
1003
+
1004
+ ---
1005
+
1006
+ ## 3. Key Rules
1007
+
1008
+ - ${isLite ? 'Primitives' : 'Atoms/Molecules'}: no business logic, pure presentation
1009
+ - Organisms: can contain business logic, composed from smaller components
1010
+ - ${isLite ? '' : 'Templates: define page structure without data\n- '}Pages: compose ${isLite ? 'organisms' : 'templates'} with data
1011
+ `
1012
+ }
1013
+
1014
+ function generateMVCGuide(framework, variant, options) {
1015
+ const f = fw(framework)
1016
+ const srcPrefix = framework === 'nuxt' ? '' : 'src/'
1017
+ const isLite = variant === 'lite'
1018
+
1019
+ return `# ARCHITECTURE.md -- MVC / Layered Architecture (${f.name})
1020
+
1021
+ > Horizontal slicing by technical layer${isLite ? ' (simplified)' : ''}.
1022
+
1023
+ ---
1024
+
1025
+ ## 1. Directory Structure
1026
+
1027
+ ${isLite ? `\`\`\`
1028
+ ${srcPrefix}
1029
+ ├── services/ # Business logic + data access (merged)
1030
+ ├── models/ # Data models
1031
+ ├── routes/ # Route definitions
1032
+ └── utils/
1033
+ \`\`\`` : `\`\`\`
1034
+ ${srcPrefix}
1035
+ ├── controllers/ # Request handling
1036
+ ├── services/ # Business logic
1037
+ ├── repositories/ # Data access
1038
+ ├── models/ # Data models / entities
1039
+ ├── middlewares/ # Cross-cutting concerns
1040
+ ├── routes/ # Route definitions
1041
+ ├── config/
1042
+ └── utils/
1043
+ \`\`\``}
1044
+
1045
+ ---
1046
+
1047
+ ## 2. Layer Responsibilities
1048
+
1049
+ ${isLite ? `- **services/**: Business logic + data access combined
1050
+ - **models/**: Data structures and validation
1051
+ - **routes/**: HTTP route definitions` : `- **controllers/**: Handle HTTP requests, delegate to services
1052
+ - **services/**: Business logic, orchestration
1053
+ - **repositories/**: Data access, database queries
1054
+ - **models/**: Data structures, ORM entities
1055
+ - **middlewares/**: Auth, logging, validation
1056
+ - **routes/**: HTTP route mapping`}
1057
+
1058
+ ---
1059
+
1060
+ ## 3. Key Rules
1061
+
1062
+ - ${isLite ? 'Services handle both logic and data access' : 'Controllers don\'t contain business logic'}
1063
+ - ${isLite ? '' : 'Services don\'t access the database directly (use repositories)\n- '}Models define data structure and validation
1064
+ - Each layer only calls the layer below it
1065
+ `
1066
+ }
1067
+
1068
+ // ── Generic Fallback ──────────────────────────────────
1069
+
1070
+ function generateGenericGuide(architecture, framework, variant) {
1071
+ const f = fw(framework)
1072
+ const pattern = ARCHITECTURE_PATTERNS[architecture]
1073
+ const name = pattern?.name || architecture
1074
+
1075
+ return `# ARCHITECTURE.md -- ${name} (${f.name})
1076
+
1077
+ > Architecture guide for ${name} pattern with ${f.name}.
1078
+ > See docs/ for detailed patterns.
1079
+
1080
+ ## Overview
1081
+
1082
+ | Concept | Implementation |
1083
+ |---------|---------------|
1084
+ | Framework | ${f.name} |
1085
+ | Architecture | ${name} -- ${variant === 'full' ? 'Full' : 'Simplified'} |
1086
+ | Language | ${f.lang} (strict) |
1087
+
1088
+ ## Key Principles
1089
+
1090
+ ${pattern?.description || 'Follow the architecture patterns defined in this document.'}
1091
+
1092
+ ## Best For
1093
+
1094
+ ${pattern?.bestFor?.description || 'See architecture documentation for guidelines.'}
1095
+ `
1096
+ }