@polymorphism-tech/morph-spec 4.5.0 → 4.7.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 (292) hide show
  1. package/CLAUDE.md +77 -56
  2. package/README.md +394 -700
  3. package/docs/ARCHITECTURE.md +331 -0
  4. package/docs/CHEATSHEET.md +221 -0
  5. package/docs/COMMAND-FLOWS.md +368 -0
  6. package/docs/QUICKSTART.md +212 -0
  7. package/docs/examples/order-management/contracts.cs +84 -0
  8. package/docs/examples/order-management/proposal.md +24 -0
  9. package/docs/examples/order-management/spec.md +162 -0
  10. package/docs/plans/2026-02-23-ddd-architecture-refactor.md +1153 -0
  11. package/docs/plans/2026-02-23-ddd-nextsteps.md +682 -0
  12. package/docs/plans/2026-02-23-infra-architect-refactor.md +437 -0
  13. package/docs/plans/2026-02-23-nextjs-code-review-design.md +156 -0
  14. package/docs/plans/2026-02-23-nextjs-code-review-impl.md +1254 -0
  15. package/docs/plans/2026-02-23-nextjs-standards-design.md +149 -0
  16. package/docs/plans/2026-02-23-nextjs-standards-impl.md +1846 -0
  17. package/framework/{skills/level-2-domains → agents}/README.md +14 -14
  18. package/framework/{skills/level-2-domains → agents}/ai-agents/ai-system-architect.md +1 -4
  19. package/framework/{skills/level-2-domains → agents}/architecture/po-pm-advisor.md +1 -2
  20. package/framework/{skills/level-2-domains → agents}/architecture/prompt-engineer.md +1 -2
  21. package/framework/{skills/level-2-domains → agents}/architecture/seo-growth-hacker.md +1 -2
  22. package/framework/{skills/level-2-domains → agents}/architecture/standards-architect.md +159 -162
  23. package/framework/agents/backend/api-designer.md +103 -0
  24. package/framework/{skills/level-2-domains → agents}/backend/dotnet-senior.md +1 -2
  25. package/framework/agents/backend/ef-modeler.md +119 -0
  26. package/framework/{skills/level-2-domains → agents}/backend/hangfire-orchestrator.md +1 -4
  27. package/framework/{skills/level-2-domains → agents}/backend/ms-agent-expert.md +1 -4
  28. package/framework/{skills/level-2-domains → agents}/frontend/blazor-builder.md +1 -4
  29. package/framework/agents/frontend/nextjs-expert.md +118 -0
  30. package/framework/{skills/level-2-domains → agents}/frontend/ui-ux-designer.md +1 -2
  31. package/framework/{skills/level-2-domains → agents}/infrastructure/azure-architect.md +147 -148
  32. package/framework/{skills/level-2-domains → agents}/infrastructure/azure-deploy-specialist.md +1 -2
  33. package/framework/{skills/level-2-domains → agents}/infrastructure/bicep-architect.md +1 -4
  34. package/framework/{skills/level-2-domains → agents}/infrastructure/container-specialist.md +1 -4
  35. package/framework/{skills/level-2-domains → agents}/infrastructure/devops-engineer.md +1 -4
  36. package/framework/agents/infrastructure/infra-architect.md +45 -0
  37. package/framework/{skills/level-2-domains → agents}/integrations/asaas-financial.md +1 -4
  38. package/framework/{skills/level-2-domains → agents}/integrations/azure-identity.md +1 -4
  39. package/framework/{skills/level-2-domains → agents}/integrations/clerk-auth.md +1 -4
  40. package/framework/{skills/level-2-domains → agents}/integrations/hangfire-integration.md +1 -2
  41. package/framework/{skills/level-2-domains → agents}/integrations/resend-email.md +1 -4
  42. package/framework/{skills/level-2-domains → agents}/quality/code-analyzer.md +1 -4
  43. package/framework/{skills/level-2-domains → agents}/quality/testing-specialist.md +1 -4
  44. package/framework/agents.json +1145 -278
  45. package/framework/hooks/claude-code/statusline.py +384 -85
  46. package/framework/hooks/shared/phase-utils.js +129 -129
  47. package/framework/rules/frontend-standards.md +0 -3
  48. package/framework/rules/nextjs-standards.md +17 -0
  49. package/framework/skills/README.md +66 -0
  50. package/framework/skills/level-0-meta/{brainstorming.md → brainstorming/SKILL.md} +3 -1
  51. package/framework/skills/level-0-meta/brainstorming/references/proposal-example.md +138 -0
  52. package/framework/skills/level-0-meta/{code-review.md → code-review/SKILL.md} +3 -2
  53. package/framework/skills/level-0-meta/code-review/references/review-example.md +164 -0
  54. package/framework/skills/level-0-meta/code-review/scripts/scan-csharp.mjs +121 -0
  55. package/framework/skills/level-0-meta/code-review-nextjs/SKILL.md +147 -0
  56. package/framework/skills/level-0-meta/code-review-nextjs/references/review-example-nextjs.md +254 -0
  57. package/framework/skills/level-0-meta/{morph-checklist.md → morph-checklist/SKILL.md} +2 -5
  58. package/framework/skills/{level-1-workflows/morph-replicate.md → level-0-meta/morph-replicate/SKILL.md} +6 -7
  59. package/framework/skills/level-0-meta/{simulation-checklist.md → simulation-checklist/SKILL.md} +3 -6
  60. package/framework/skills/level-0-meta/{tool-usage-guide.md → tool-usage-guide/SKILL.md} +4 -5
  61. package/framework/skills/level-0-meta/{verification-before-completion.md → verification-before-completion/SKILL.md} +3 -1
  62. package/framework/skills/level-0-meta/verification-before-completion/scripts/check-phase-outputs.mjs +110 -0
  63. package/framework/skills/level-1-workflows/{phase-clarify.md → phase-clarify/SKILL.md} +3 -3
  64. package/framework/skills/level-1-workflows/phase-clarify/references/clarifications-example.md +117 -0
  65. package/framework/skills/level-1-workflows/{phase-codebase-analysis.md → phase-codebase-analysis/SKILL.md} +2 -3
  66. package/framework/skills/level-1-workflows/{phase-design.md → phase-design/SKILL.md} +46 -182
  67. package/framework/skills/level-1-workflows/phase-design/references/spec-example.md +253 -0
  68. package/framework/skills/level-1-workflows/{phase-implement.md → phase-implement/SKILL.md} +3 -3
  69. package/framework/skills/level-1-workflows/phase-implement/references/recap-example.md +132 -0
  70. package/framework/skills/level-1-workflows/{phase-setup.md → phase-setup/SKILL.md} +2 -3
  71. package/framework/skills/level-1-workflows/{phase-tasks.md → phase-tasks/SKILL.md} +42 -3
  72. package/framework/skills/level-1-workflows/phase-tasks/references/tasks-example.md +231 -0
  73. package/framework/skills/level-1-workflows/phase-tasks/scripts/validate-tasks.mjs +112 -0
  74. package/framework/skills/level-1-workflows/{phase-uiux.md → phase-uiux/SKILL.md} +2 -3
  75. package/framework/standards/STANDARDS.json +121 -0
  76. package/framework/standards/architecture/ddd/bounded-contexts.md +105 -0
  77. package/framework/standards/architecture/ddd/complexity-levels.md +108 -0
  78. package/framework/standards/architecture/ddd/ubiquitous-language.md +58 -0
  79. package/framework/standards/frontend/nextjs/app-router.md +123 -0
  80. package/framework/standards/frontend/nextjs/components.md +132 -0
  81. package/framework/standards/frontend/nextjs/data-fetching.md +126 -0
  82. package/framework/standards/frontend/nextjs/forms.md +128 -0
  83. package/framework/standards/frontend/nextjs/naming-conventions.md +67 -0
  84. package/framework/standards/frontend/nextjs/project-structure.md +102 -0
  85. package/framework/standards/frontend/nextjs/state-management.md +72 -0
  86. package/framework/standards/frontend/nextjs/testing.md +111 -0
  87. package/framework/templates/REGISTRY.json +538 -142
  88. package/framework/templates/code/dotnet/contracts/contracts-level1.cs +69 -0
  89. package/framework/templates/code/dotnet/contracts/contracts-level2.cs +86 -0
  90. package/framework/templates/code/dotnet/contracts/contracts-level3.cs +41 -0
  91. package/framework/templates/docs/spec.md +49 -0
  92. package/framework/templates/frontend/nextjs/Dockerfile.nextjs.hbs +43 -0
  93. package/framework/templates/frontend/nextjs/client-component.tsx.hbs +26 -0
  94. package/framework/templates/frontend/nextjs/env.mjs.hbs +32 -0
  95. package/framework/templates/frontend/nextjs/feature-form.tsx.hbs +56 -0
  96. package/framework/templates/frontend/nextjs/page.tsx.hbs +22 -0
  97. package/framework/templates/frontend/nextjs/tsconfig.json.hbs +26 -0
  98. package/framework/templates/frontend/nextjs/use-feature.ts.hbs +54 -0
  99. package/framework/templates/project-structure/dotnet-ddd.md +70 -0
  100. package/framework/workflows/docs/enforcement-pipeline.md +2 -1
  101. package/package.json +1 -1
  102. package/scripts/scan-nextjs.mjs +169 -0
  103. package/src/commands/project/doctor.js +52 -1
  104. package/src/commands/project/init.js +19 -65
  105. package/src/commands/project/update.js +7 -63
  106. package/src/lib/detectors/claude-config-detector.js +1 -3
  107. package/src/lib/standards/standards-context-injector.js +5 -0
  108. package/src/lib/validators/nextjs/index.js +6 -0
  109. package/src/lib/validators/nextjs/next-component-validator.js +181 -0
  110. package/src/lib/validators/validation-runner.js +5 -0
  111. package/src/utils/agents-installer.js +16 -4
  112. package/src/utils/skills-installer.js +59 -15
  113. package/.morph/.morphversion +0 -5
  114. package/.morph/analytics/threads-log.jsonl +0 -44
  115. package/.morph/config/config.json +0 -8
  116. package/.morph/context/README.md +0 -17
  117. package/.morph/framework/agents.json +0 -948
  118. package/.morph/framework/standards/STANDARDS.json +0 -812
  119. package/.morph/framework/standards/ai-agents/blazor-ui.md +0 -364
  120. package/.morph/framework/standards/ai-agents/production.md +0 -415
  121. package/.morph/framework/standards/ai-agents/setup.md +0 -418
  122. package/.morph/framework/standards/ai-agents/team-orchestration.md +0 -479
  123. package/.morph/framework/standards/ai-agents/workflows.md +0 -354
  124. package/.morph/framework/standards/architecture/ddd/aggregates.md +0 -120
  125. package/.morph/framework/standards/architecture/ddd/entities.md +0 -99
  126. package/.morph/framework/standards/architecture/ddd/value-objects.md +0 -124
  127. package/.morph/framework/standards/backend/api/minimal-api.md +0 -494
  128. package/.morph/framework/standards/backend/api/rest.md +0 -492
  129. package/.morph/framework/standards/backend/api/validation.md +0 -88
  130. package/.morph/framework/standards/backend/authentication/passkeys.md +0 -428
  131. package/.morph/framework/standards/backend/database/ef-core.md +0 -199
  132. package/.morph/framework/standards/backend/database/migrations.md +0 -393
  133. package/.morph/framework/standards/backend/database/postgresql/database.md +0 -352
  134. package/.morph/framework/standards/backend/database/repository-patterns.md +0 -528
  135. package/.morph/framework/standards/backend/database/vector-search-rag.md +0 -541
  136. package/.morph/framework/standards/backend/dotnet/async.md +0 -366
  137. package/.morph/framework/standards/backend/dotnet/core.md +0 -117
  138. package/.morph/framework/standards/backend/dotnet/di.md +0 -439
  139. package/.morph/framework/standards/backend/dotnet/program-cs-checklist.md +0 -92
  140. package/.morph/framework/standards/backend/integrations/asaas/asaas-api.md +0 -216
  141. package/.morph/framework/standards/backend/integrations/clerk/clerk-auth.md +0 -290
  142. package/.morph/framework/standards/backend/integrations/hangfire/hangfire-jobs.md +0 -350
  143. package/.morph/framework/standards/backend/integrations/resend/resend-email.md +0 -385
  144. package/.morph/framework/standards/context/analytics.md +0 -96
  145. package/.morph/framework/standards/context/bundles.md +0 -110
  146. package/.morph/framework/standards/context/priming.md +0 -78
  147. package/.morph/framework/standards/core/architecture.md +0 -185
  148. package/.morph/framework/standards/core/coding.md +0 -214
  149. package/.morph/framework/standards/core/git-branching-strategy.md +0 -403
  150. package/.morph/framework/standards/core/git.md +0 -185
  151. package/.morph/framework/standards/core/testing.md +0 -295
  152. package/.morph/framework/standards/data/nosql/blob-storage.md +0 -102
  153. package/.morph/framework/standards/data/nosql/cache/redis.md +0 -97
  154. package/.morph/framework/standards/data/nosql/cosmos-db.md +0 -118
  155. package/.morph/framework/standards/data/vector-search/azure-ai-search.md +0 -121
  156. package/.morph/framework/standards/data/vector-search/rag-chunking.md +0 -104
  157. package/.morph/framework/standards/frontend/blazor/design-checklist.md +0 -222
  158. package/.morph/framework/standards/frontend/blazor/fluent-ui-setup.md +0 -595
  159. package/.morph/framework/standards/frontend/blazor/fluent-ui.md +0 -137
  160. package/.morph/framework/standards/frontend/blazor/html-conversion.md +0 -184
  161. package/.morph/framework/standards/frontend/blazor/lifecycle.md +0 -195
  162. package/.morph/framework/standards/frontend/blazor/pitfalls.md +0 -198
  163. package/.morph/framework/standards/frontend/blazor/state.md +0 -191
  164. package/.morph/framework/standards/frontend/design-system/animations.md +0 -151
  165. package/.morph/framework/standards/frontend/design-system/naming.md +0 -64
  166. package/.morph/framework/standards/frontend/nextjs/nextjs-patterns.md +0 -198
  167. package/.morph/framework/standards/infrastructure/azure/azure.md +0 -624
  168. package/.morph/framework/standards/infrastructure/azure/bicep/bicep-patterns.md +0 -422
  169. package/.morph/framework/standards/infrastructure/azure/devops/azure-devops-setup.md +0 -516
  170. package/.morph/framework/standards/infrastructure/azure/devops/local-development.md +0 -520
  171. package/.morph/framework/standards/infrastructure/azure/services/functions.md +0 -486
  172. package/.morph/framework/standards/infrastructure/azure/services/service-bus.md +0 -459
  173. package/.morph/framework/standards/infrastructure/azure/services/storage.md +0 -407
  174. package/.morph/framework/standards/infrastructure/docker/easypanel-deploy.md +0 -196
  175. package/.morph/framework/standards/infrastructure/supabase/mcp-setup.md +0 -252
  176. package/.morph/framework/standards/infrastructure/supabase/supabase-auth.md +0 -176
  177. package/.morph/framework/standards/infrastructure/supabase/supabase-pgvector.md +0 -169
  178. package/.morph/framework/standards/infrastructure/supabase/supabase-rls.md +0 -184
  179. package/.morph/framework/standards/infrastructure/supabase/supabase-storage.md +0 -153
  180. package/.morph/framework/standards/integration/api/graphql.md +0 -91
  181. package/.morph/framework/standards/integration/api/grpc.md +0 -114
  182. package/.morph/framework/standards/integration/api/rest-design.md +0 -95
  183. package/.morph/framework/standards/integration/event-driven/cqrs.md +0 -101
  184. package/.morph/framework/standards/integration/event-driven/event-sourcing.md +0 -124
  185. package/.morph/framework/standards/integration/event-driven/service-bus.md +0 -95
  186. package/.morph/framework/standards/integration/mcp/mcp-tools.md +0 -384
  187. package/.morph/framework/standards/observability/logging.md +0 -131
  188. package/.morph/framework/standards/observability/metrics.md +0 -121
  189. package/.morph/framework/standards/observability/monitoring.md +0 -114
  190. package/.morph/framework/standards/observability/tracing.md +0 -132
  191. package/.morph/framework/standards/workflows/parallel-execution.md +0 -112
  192. package/.morph/framework/standards/workflows/thread-management.md +0 -113
  193. package/.morph/framework/templates/.idea/morph-templates.xml +0 -92
  194. package/.morph/framework/templates/.vscode/morph-templates.code-snippets +0 -186
  195. package/.morph/framework/templates/IDE-SNIPPETS.md +0 -266
  196. package/.morph/framework/templates/README.md +0 -814
  197. package/.morph/framework/templates/REGISTRY.json +0 -1492
  198. package/.morph/framework/templates/code/dotnet/backend/repository.cs +0 -141
  199. package/.morph/framework/templates/code/dotnet/backend/service.cs +0 -139
  200. package/.morph/framework/templates/code/dotnet/contracts/Commands.cs +0 -74
  201. package/.morph/framework/templates/code/dotnet/contracts/Entities.cs +0 -25
  202. package/.morph/framework/templates/code/dotnet/contracts/Queries.cs +0 -74
  203. package/.morph/framework/templates/code/dotnet/contracts/README.md +0 -74
  204. package/.morph/framework/templates/code/dotnet/contracts/api-contracts.cs +0 -173
  205. package/.morph/framework/templates/code/dotnet/contracts/contracts.cs +0 -217
  206. package/.morph/framework/templates/code/dotnet/contracts/contracts.cs.hbs +0 -172
  207. package/.morph/framework/templates/code/dotnet/database/migration.cs +0 -83
  208. package/.morph/framework/templates/code/dotnet/frontend/component.razor +0 -239
  209. package/.morph/framework/templates/code/dotnet/jobs/agent.cs +0 -163
  210. package/.morph/framework/templates/code/dotnet/jobs/job.cs +0 -171
  211. package/.morph/framework/templates/code/dotnet/test.cs +0 -239
  212. package/.morph/framework/templates/code/sql/rls-policy.sql +0 -57
  213. package/.morph/framework/templates/code/sql/supabase-migration.sql +0 -100
  214. package/.morph/framework/templates/code/sql/supabase-migration.template.sql +0 -113
  215. package/.morph/framework/templates/code/typescript/contracts.ts +0 -168
  216. package/.morph/framework/templates/context/CONTEXT-FEATURE.md +0 -276
  217. package/.morph/framework/templates/context/CONTEXT.md +0 -181
  218. package/.morph/framework/templates/docs/clarifications.md +0 -253
  219. package/.morph/framework/templates/docs/onboarding.md +0 -123
  220. package/.morph/framework/templates/docs/proposal.md +0 -182
  221. package/.morph/framework/templates/docs/schema-analysis.md +0 -119
  222. package/.morph/framework/templates/docs/spec.md +0 -149
  223. package/.morph/framework/templates/docs/ui-components.md +0 -124
  224. package/.morph/framework/templates/docs/ui-design-system.md +0 -76
  225. package/.morph/framework/templates/docs/ui-flows.md +0 -167
  226. package/.morph/framework/templates/docs/ui-mockups.md +0 -98
  227. package/.morph/framework/templates/examples/design-system-examples.md +0 -357
  228. package/.morph/framework/templates/examples/spec-examples.md +0 -90
  229. package/.morph/framework/templates/feature/decisions.md +0 -187
  230. package/.morph/framework/templates/feature/recap.md +0 -146
  231. package/.morph/framework/templates/feature/tasks.md +0 -199
  232. package/.morph/framework/templates/infrastructure/azure/Dockerfile.example +0 -82
  233. package/.morph/framework/templates/infrastructure/azure/README.md +0 -286
  234. package/.morph/framework/templates/infrastructure/azure/app-insights.bicep +0 -63
  235. package/.morph/framework/templates/infrastructure/azure/app-service.bicep +0 -164
  236. package/.morph/framework/templates/infrastructure/azure/container-app-env.bicep +0 -49
  237. package/.morph/framework/templates/infrastructure/azure/container-app.bicep +0 -156
  238. package/.morph/framework/templates/infrastructure/azure/deploy-checklist.md +0 -426
  239. package/.morph/framework/templates/infrastructure/azure/deploy.ps1 +0 -229
  240. package/.morph/framework/templates/infrastructure/azure/deploy.sh +0 -208
  241. package/.morph/framework/templates/infrastructure/azure/key-vault.bicep +0 -91
  242. package/.morph/framework/templates/infrastructure/azure/main.bicep +0 -189
  243. package/.morph/framework/templates/infrastructure/azure/parameters.dev.json +0 -29
  244. package/.morph/framework/templates/infrastructure/azure/parameters.prod.json +0 -29
  245. package/.morph/framework/templates/infrastructure/azure/parameters.staging.json +0 -29
  246. package/.morph/framework/templates/infrastructure/azure/sql-database.bicep +0 -103
  247. package/.morph/framework/templates/infrastructure/azure/storage.bicep +0 -106
  248. package/.morph/framework/templates/infrastructure/docker/Dockerfile.template +0 -58
  249. package/.morph/framework/templates/infrastructure/docker/docker-compose.template.yml +0 -67
  250. package/.morph/framework/templates/infrastructure/docker/dockerfile-api.dockerfile +0 -38
  251. package/.morph/framework/templates/infrastructure/docker/dockerfile-web.dockerfile +0 -48
  252. package/.morph/framework/templates/infrastructure/docker/easypanel.template.json +0 -54
  253. package/.morph/framework/templates/infrastructure/github/README.md +0 -593
  254. package/.morph/framework/templates/infrastructure/github/actions/azure-auth/action.yml.hbs +0 -22
  255. package/.morph/framework/templates/infrastructure/github/actions/docker-build-push/action.yml.hbs +0 -45
  256. package/.morph/framework/templates/infrastructure/github/actions/health-check/action.yml.hbs +0 -27
  257. package/.morph/framework/templates/infrastructure/github/workflows/deploy-azure-app-service.yml.hbs +0 -61
  258. package/.morph/framework/templates/infrastructure/github/workflows/deploy-easypanel.yml.hbs +0 -31
  259. package/.morph/framework/templates/infrastructure/github/workflows/docker-build-push.yml.hbs +0 -59
  260. package/.morph/framework/templates/infrastructure/github/workflows/dotnet-build.yml.hbs +0 -39
  261. package/.morph/framework/templates/integrations/asaas-client.cs +0 -387
  262. package/.morph/framework/templates/integrations/asaas-webhook.cs +0 -351
  263. package/.morph/framework/templates/integrations/azure-identity-config.cs +0 -288
  264. package/.morph/framework/templates/integrations/clerk-config.cs +0 -258
  265. package/.morph/framework/templates/meta-prompts/fusion/fusion-agent.md +0 -76
  266. package/.morph/framework/templates/meta-prompts/fusion/fusion-aggregator.md +0 -100
  267. package/.morph/framework/templates/meta-prompts/hops/hop-retry.md +0 -78
  268. package/.morph/framework/templates/meta-prompts/hops/hop-validation.md +0 -97
  269. package/.morph/framework/templates/meta-prompts/hops/hop-wrapper.md +0 -36
  270. package/.morph/framework/templates/meta-prompts/parallel-workers/parallel-coordinator.md +0 -113
  271. package/.morph/framework/templates/meta-prompts/parallel-workers/parallel-worker.md +0 -80
  272. package/.morph/framework/templates/meta-prompts/squad-leaders/backend-squad.md +0 -90
  273. package/.morph/framework/templates/meta-prompts/squad-leaders/frontend-squad.md +0 -126
  274. package/.morph/framework/templates/meta-prompts/squad-leaders/squad-leader.md +0 -43
  275. package/.morph/framework/templates/meta-prompts/validators/checkpoint-validator.md +0 -107
  276. package/.morph/framework/templates/meta-prompts/validators/pre-commit-validator.md +0 -95
  277. package/.morph/framework/templates/saas/subscription.cs +0 -347
  278. package/.morph/framework/templates/saas/tenant.cs +0 -338
  279. package/.morph/framework/templates/state.template.json +0 -17
  280. package/.morph/framework/templates/ui/FluentDesignTheme.cs +0 -149
  281. package/.morph/framework/templates/ui/MudTheme.cs +0 -281
  282. package/.morph/framework/templates/ui/design-system.css +0 -226
  283. package/.morph/logs/tool-failures.log +0 -51
  284. package/.morph/memory/pre-compact-2026-02-22T17-01-01-658Z.json +0 -16
  285. package/.morph/state.json +0 -48
  286. package/framework/skills/level-2-domains/backend/api-designer.md +0 -66
  287. package/framework/skills/level-2-domains/backend/ef-modeler.md +0 -65
  288. package/framework/skills/level-2-domains/frontend/nextjs-expert.md +0 -161
  289. package/framework/skills/level-3-technologies/README.md +0 -7
  290. package/framework/skills/level-4-patterns/README.md +0 -7
  291. package/framework/templates/code/dotnet/contracts/contracts.cs +0 -217
  292. package/framework/templates/code/dotnet/contracts/contracts.cs.hbs +0 -172
@@ -1,624 +0,0 @@
1
- # Padrões Azure - MORPH Framework
2
-
3
- > **Scope:** blazor-azure
4
- > **Layer:** 2 (on keyword)
5
- > **Keywords:** azure, identity, keyvault, credential, managed identity
6
- > **Load When:** azure keywords detected
7
-
8
- ## 💰 Filosofia de Custos
9
-
10
- **Free tier primeiro. Aprovação explícita para upgrade.**
11
-
12
- | Nível | Limite | Requer |
13
- |-------|--------|--------|
14
- | Sem aprovação | Free tier apenas | Nada |
15
- | Com aprovação | Até $10/mês | Confirmação |
16
- | Acima de $10 | Justificativa detalhada | ADR |
17
-
18
- ---
19
-
20
- ## 🌐 Hosting: App Service vs Container Apps
21
-
22
- ### Matriz de Decisão
23
-
24
- | Critério | App Service (Free F1) | Container Apps (Consumption) |
25
- |----------|----------------------|------------------------------|
26
- | **Custo** | ✅ $0/mês | ⚠️ ~$5/mês |
27
- | **RAM** | 1GB | Configurável (0.5Gi min) |
28
- | **Storage** | 1GB | Ephemeral |
29
- | **CPU** | ⚠️ 60 min/dia | ✅ Ilimitado |
30
- | **Disponibilidade** | ⚠️ Sleep após 20min | ✅ Scale-to-zero sem sleep |
31
- | **SSL Customizado** | ❌ Não (apenas *.azurewebsites.net) | ✅ Sim, gratuito |
32
- | **Scale Out** | ❌ Não | ✅ Auto-scaling |
33
- | **Blazor Server** | ✅ Suporte nativo | ✅ Via Docker |
34
- | **Deploy** | ✅ Direto (ZIP, Git) | ⚠️ Requer container |
35
-
36
- ### Quando Usar App Service Free
37
-
38
- **✅ Cenários Ideais:**
39
- - Protótipos e MVPs de baixo tráfego
40
- - Aplicações de uso interno (horário comercial)
41
- - Demos e POCs
42
- - Apps que toleram cold start (20 min sleep)
43
- - Orçamento zero absoluto
44
-
45
- **❌ Não Usar Quando:**
46
- - Necessita estar sempre disponível (24/7)
47
- - Tráfego imprevisível ou spikes
48
- - Mais de 60 min de CPU/dia
49
- - Precisa de SSL customizado
50
- - Requer auto-scaling
51
-
52
- ### Quando Usar Container Apps
53
-
54
- **✅ Cenários Ideais:**
55
- - Produção com disponibilidade 24/7
56
- - Auto-scaling baseado em demanda
57
- - SSL customizado necessário
58
- - Arquitetura microserviços
59
- - Background jobs com Hangfire (minReplicas: 1)
60
- - Apps que precisam estar sempre "quentes"
61
-
62
- **❌ Não Usar Quando:**
63
- - Orçamento zero obrigatório
64
- - Tráfego extremamente baixo (< 100 req/dia)
65
- - MVP simples sem requisitos de SLA
66
-
67
- ### Estratégia Híbrida
68
-
69
- ```
70
- Dev/Staging: App Service Free F1
71
- Production: Container Apps Consumption
72
- ```
73
-
74
- **Benefícios:**
75
- - 💰 Economia em ambientes não críticos
76
- - 🚀 Performance garantida em produção
77
- - 🔄 Fácil migração (mesma stack .NET)
78
-
79
- ---
80
-
81
- ## 📋 Stack Padrão Aprovado
82
-
83
- | Recurso | Tier | Custo | Quando Usar |
84
- |---------|------|-------|-------------|
85
- | **App Service** | Free F1 | $0 | MVP, protótipos, dev/staging |
86
- | **Container Apps** | Consumption | ~$0-5/mês | Produção, auto-scaling |
87
- | **Azure SQL** | Free 32GB | $0 | Database |
88
- | **ACR** | Basic | ~$5/mês | Container registry (apenas com CA) |
89
- | **App Insights** | Free 5GB | $0 | Logs e métricas |
90
- | **Azure OpenAI** | gpt-4o-mini | ~$2-10/mês | Análises AI |
91
-
92
- **Custo total típico:**
93
- - **App Service Stack:** $0-2/mês (sem ACR)
94
- - **Container Apps Stack:** $7-20/mês (com ACR)
95
-
96
- ### ⚠️ Requer Aprovação
97
-
98
- | Recurso | Custo | Alternativa Free |
99
- |---------|-------|------------------|
100
- | Azure Functions | ~$0-5/mês | Hangfire |
101
- | Service Bus | ~$10/mês | Queue em SQL |
102
- | Cosmos DB | ~$25/mês | Azure SQL JSON |
103
- | Redis Cache | ~$15/mês | In-memory |
104
-
105
- ---
106
-
107
- ## 🌐 App Service Free Tier
108
-
109
- ### Configuração Obrigatória
110
- ```bicep
111
- resource appService 'Microsoft.Web/sites@2022-03-01' = {
112
- name: 'app-${projectName}-${environment}'
113
- location: location
114
- properties: {
115
- serverFarmId: appServicePlan.id
116
- httpsOnly: true
117
- siteConfig: {
118
- netFrameworkVersion: 'v8.0'
119
- alwaysOn: false # ⚠️ OBRIGATÓRIO no Free tier
120
- minTlsVersion: '1.2'
121
- }
122
- }
123
- }
124
-
125
- resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = {
126
- name: 'plan-${projectName}-${environment}'
127
- location: location
128
- sku: {
129
- name: 'F1' # Free tier
130
- tier: 'Free'
131
- }
132
- }
133
- ```
134
-
135
- ### Limitações Importantes
136
- - ⚠️ **CPU**: Apenas 60 minutos/dia (não contínuos)
137
- - ⚠️ **Sleep**: App dorme após 20 minutos de inatividade
138
- - ⚠️ **SSL**: Apenas `*.azurewebsites.net` (sem domínio customizado)
139
- - ⚠️ **Escala**: Sem scale-out (apenas 1 instância)
140
- - ✅ **Memória**: 1GB RAM
141
- - ✅ **Storage**: 1GB disco
142
-
143
- ### Deploy
144
- ```bash
145
- # Via Azure CLI
146
- az webapp up --name app-myproject-dev --runtime "DOTNET:8.0"
147
-
148
- # Via GitHub Actions
149
- - task: AzureWebApp@1
150
- inputs:
151
- azureSubscription: 'Azure-Connection'
152
- appName: 'app-myproject-dev'
153
- package: '$(Build.ArtifactStagingDirectory)/**/*.zip'
154
- ```
155
-
156
- ### Quando Migrar para Container Apps
157
- Se você observar:
158
- - 🔴 CPU quota esgotada frequentemente
159
- - 🔴 Cold starts afetando UX
160
- - 🔴 Necessidade de SSL customizado
161
- - 🔴 Tráfego crescendo (>1000 req/dia)
162
-
163
- **→ Considere migrar para Container Apps Consumption**
164
-
165
- ---
166
-
167
- ## 🐳 Container Apps
168
-
169
- ### Configuração Obrigatória
170
- ```yaml
171
- properties:
172
- template:
173
- scale:
174
- minReplicas: 0 # ⚠️ OBRIGATÓRIO: scale-to-zero
175
- maxReplicas: 2
176
- containers:
177
- - name: app
178
- resources:
179
- cpu: 0.25 # Mínimo
180
- memory: 0.5Gi # Mínimo
181
- ```
182
-
183
- ### Scale-to-Zero
184
- - ✅ **OBRIGATÓRIO** para dev/staging
185
- - ⚠️ Em prod com Hangfire: `minReplicas: 1`
186
- - 💰 Economia: ~80% vs always-on
187
-
188
- ---
189
-
190
- ## 🗄️ Azure SQL Free Tier
191
-
192
- ```
193
- - 32 GB storage
194
- - 100,000 vCore seconds/month
195
- - Serverless compute
196
- - Auto-pause after 1 hour idle
197
- ```
198
-
199
- ### Práticas
200
- - ✅ Usar Managed Identity
201
- - ✅ TDE habilitado (default)
202
- - ❌ Não criar índices em excesso
203
-
204
- ---
205
-
206
- ## 🤖 Azure OpenAI
207
-
208
- ### Modelo Padrão: gpt-4o-mini
209
-
210
- | Modelo | Custo Input | Custo Output | Usar |
211
- |--------|-------------|--------------|------|
212
- | **gpt-4o-mini** | $0.15/1M | $0.60/1M | ✅ PADRÃO |
213
- | gpt-4o | $2.50/1M | $10/1M | Com aprovação |
214
- | gpt-4 | $30/1M | $60/1M | ❌ NUNCA |
215
-
216
- ### Otimização
217
- ```csharp
218
- var settings = new OpenAIPromptExecutionSettings
219
- {
220
- MaxTokens = 500, // Limitar resposta
221
- Temperature = 0.3 // Mais determinístico
222
- };
223
- ```
224
-
225
- ---
226
-
227
- ## 🔐 Segurança
228
-
229
- ### Managed Identity (Preferido)
230
- ```csharp
231
- // Para Azure SQL
232
- "Authentication=Active Directory Managed Identity;"
233
-
234
- // Para Azure OpenAI
235
- var credential = new DefaultAzureCredential();
236
- ```
237
-
238
- ### Key Vault
239
- Usar apenas para:
240
- - Secrets de serviços externos
241
- - API keys de terceiros
242
-
243
- ---
244
-
245
- ## 📛 Naming Conventions
246
-
247
- ```
248
- {tipo}-{projeto}-{ambiente}
249
-
250
- Exemplos:
251
- - rg-myproject-dev # Resource Group
252
- - app-myproject-dev # App Service
253
- - plan-myproject-dev # App Service Plan
254
- - ca-myproject-dev # Container App
255
- - sql-myproject-dev # SQL Server
256
- - sqldb-myproject-dev # SQL Database
257
- - acr-myproject # Container Registry
258
- - appi-myproject-dev # App Insights
259
- - kv-myproject-dev # Key Vault
260
- ```
261
-
262
- | Ambiente | Sufixo | Características |
263
- |----------|--------|-----------------|
264
- | Development | -dev | Scale-to-zero, free tier |
265
- | Staging | -stg | Scale-to-zero, free tier |
266
- | Production | -prod | Min 1 replica |
267
-
268
- ---
269
-
270
- ## 🚀 Azure DevOps Pipelines
271
-
272
- ### Estratégia de Ambientes
273
-
274
- **2 ambientes:**
275
- - **Staging**: Desenvolvimento + QA (branch: `staging`)
276
- - Developers rodam projeto LOCAL
277
- - Acessam recursos REMOTOS staging
278
- - Deploy automático via pipeline
279
-
280
- - **Produção**: Ambiente crítico (branch: `main`/`master`)
281
- - Deploy via pipeline com aprovação manual
282
- - Always-on, monitoramento 24/7
283
-
284
- ### Estrutura de Pipelines
285
-
286
- **Stack Configuration** (`.azure/pipelines/`):
287
- ```
288
- stacks/blazor-azure/.azure/pipelines/
289
- ├── staging-pipeline.yml # Branch: staging
290
- ├── prod-pipeline.yml # Branch: main/master
291
- └── pipeline-variables.yml # Variáveis compartilhadas
292
- ```
293
-
294
- **Framework Templates** (`framework/templates/infrastructure/azure/pipelines/`):
295
- ```
296
- framework/templates/infrastructure/azure/pipelines/templates/
297
- ├── build-dotnet.yml # Build .NET projects
298
- ├── deploy-container-app.yml # Deploy to Azure Container Apps
299
- ├── deploy-app-service.yml # Deploy to Azure App Service
300
- └── infra-deploy.yml # Deploy Bicep infrastructure
301
- ```
302
-
303
- **Usage in Pipelines:**
304
- ```yaml
305
- # Reference framework templates with relative path
306
- - template: ../../../../framework/templates/infrastructure/azure/pipelines/templates/build-dotnet.yml
307
- parameters:
308
- dotnetVersion: '8.x'
309
- ```
310
-
311
- ### Pipeline Staging
312
-
313
- ```yaml
314
- # staging-pipeline.yml
315
- trigger:
316
- branches:
317
- include: [staging]
318
-
319
- variables:
320
- - template: pipeline-variables.yml
321
- - name: environment
322
- value: 'staging'
323
- - name: hostingType
324
- value: 'containerapp'
325
-
326
- stages:
327
- - stage: Build
328
- - stage: DeployInfra
329
- - stage: BuildContainer
330
- - stage: DeployApp
331
- jobs:
332
- - deployment: DeployAppJob
333
- environment: 'staging' # No approval
334
- ```
335
-
336
- ### Pipeline Production
337
-
338
- ```yaml
339
- # prod-pipeline.yml
340
- trigger:
341
- branches:
342
- include: [main, master]
343
-
344
- variables:
345
- - template: pipeline-variables.yml
346
- - name: environment
347
- value: 'prod'
348
- - name: hostingType
349
- value: 'containerapp'
350
-
351
- stages:
352
- - stage: Build
353
- - stage: SecurityScan
354
- - stage: DeployInfra
355
- - stage: BuildContainer
356
- - stage: DeployApp
357
- jobs:
358
- - deployment: DeployAppJob
359
- environment: 'production' # Approval required
360
- ```
361
-
362
- ### Workload Identity (Sem Secrets)
363
-
364
- Ao invés de Service Principals com secrets, use Workload Identity Federation:
365
-
366
- ```bash
367
- # Criar App Registration com Federated Credential
368
- az ad app create --display-name "myapp-prod-pipeline"
369
-
370
- # Configurar federated credential
371
- az ad app federated-credential create \
372
- --id <APP_ID> \
373
- --parameters @federated-credential.json
374
- ```
375
-
376
- **Vantagens:**
377
- - ✅ Sem secrets para gerenciar
378
- - ✅ Rotação automática de tokens
379
- - ✅ Mais seguro
380
- - ✅ Auditoria melhorada
381
-
382
- **Documentação completa:** `.azure/docs/azure-devops-setup.md`
383
-
384
- ---
385
-
386
- ## ✅ Checklist de Deploy
387
-
388
- ### Antes
389
- - [ ] Testes passando
390
- - [ ] Migrations aplicadas
391
- - [ ] Secrets no Key Vault
392
- - [ ] Managed Identity configurada
393
-
394
- ### Após
395
- - [ ] Health check OK
396
- - [ ] Logs no App Insights
397
- - [ ] Funcionalidade testada
398
- - [ ] Custos verificados
399
-
400
- ---
401
-
402
- ## ⚠️ Package Version Conflicts
403
-
404
- ### Azure.Identity Downgrade Error
405
-
406
- **Error:**
407
- ```
408
- NU1605: Detected package downgrade: Azure.Identity from 1.14.2 to 1.13.2
409
- ```
410
-
411
- **Cause:** `Microsoft.Data.SqlClient` or other packages require a newer version.
412
-
413
- **Solution:** Always specify `Azure.Identity` explicitly in your `.csproj`:
414
-
415
- ```xml
416
- <!-- Prevent version conflicts -->
417
- <PackageReference Include="Azure.Identity" Version="1.14.2" />
418
- ```
419
-
420
- **Why this happens:**
421
- - Transitive dependencies pull different versions
422
- - NuGet picks the lowest common version
423
- - This causes runtime failures with newer APIs
424
-
425
- ---
426
-
427
- ## 🔑 Key Vault Configuration
428
-
429
- ### Critical Rule
430
-
431
- **NEVER condition Key Vault loading on environment. Load whenever URI is configured.**
432
-
433
- **❌ WRONG:**
434
- ```csharp
435
- // This breaks DI in development!
436
- if (!string.IsNullOrEmpty(keyVaultUri) && !builder.Environment.IsDevelopment())
437
- {
438
- builder.Configuration.AddAzureKeyVault(...);
439
- }
440
- ```
441
-
442
- **✅ CORRECT:**
443
- ```csharp
444
- // Load Key Vault in ALL environments where URI exists
445
- if (!string.IsNullOrEmpty(keyVaultUri))
446
- {
447
- builder.Configuration.AddAzureKeyVault(
448
- new Uri(keyVaultUri),
449
- new DefaultAzureCredential());
450
- }
451
- ```
452
-
453
- **Why:**
454
- - Services registered via DI may depend on Key Vault secrets
455
- - `IBlobStorageService`, `IPaymentService`, etc. fail if secrets not loaded
456
- - Development can use Azure Key Vault with developer credentials
457
- - Or use `appsettings.Development.json` to override secrets locally
458
-
459
- ---
460
-
461
- ## 🚀 DefaultAzureCredential Optimization
462
-
463
- ### Problem
464
-
465
- `DefaultAzureCredential` is **slow in containers** because it tries multiple authentication methods sequentially (environment, workload identity, managed identity, Visual Studio, CLI, etc.).
466
-
467
- **Symptom:** Startup takes 30+ seconds, or times out.
468
-
469
- ### Solution: Disable Unused Credential Types
470
-
471
- ```csharp
472
- // For Container Apps / AKS with Managed Identity ONLY
473
- var credential = new DefaultAzureCredential(new DefaultAzureCredentialOptions
474
- {
475
- // Disable all except Managed Identity
476
- ExcludeEnvironmentCredential = true,
477
- ExcludeWorkloadIdentityCredential = true,
478
- ExcludeSharedTokenCacheCredential = true,
479
- ExcludeVisualStudioCredential = true,
480
- ExcludeVisualStudioCodeCredential = true,
481
- ExcludeAzureCliCredential = true,
482
- ExcludeAzurePowerShellCredential = true,
483
- ExcludeAzureDeveloperCliCredential = true,
484
- ExcludeInteractiveBrowserCredential = true,
485
- ExcludeManagedIdentityCredential = false // Keep this one!
486
- });
487
- ```
488
-
489
- ### Environment-Specific Configuration
490
-
491
- ```csharp
492
- // Program.cs - Smart credential selection
493
- DefaultAzureCredential CreateCredential(IHostEnvironment env)
494
- {
495
- if (env.IsDevelopment())
496
- {
497
- // Development: Allow CLI, VS, VS Code
498
- return new DefaultAzureCredential();
499
- }
500
-
501
- // Production: Only Managed Identity (fast!)
502
- return new DefaultAzureCredential(new DefaultAzureCredentialOptions
503
- {
504
- ExcludeEnvironmentCredential = true,
505
- ExcludeWorkloadIdentityCredential = true,
506
- ExcludeSharedTokenCacheCredential = true,
507
- ExcludeVisualStudioCredential = true,
508
- ExcludeVisualStudioCodeCredential = true,
509
- ExcludeAzureCliCredential = true,
510
- ExcludeAzurePowerShellCredential = true,
511
- ExcludeAzureDeveloperCliCredential = true,
512
- ExcludeInteractiveBrowserCredential = true,
513
- ExcludeManagedIdentityCredential = false
514
- });
515
- }
516
- ```
517
-
518
- ---
519
-
520
- ## 🐳 Container App Deployment Issues
521
-
522
- ### Problem: Container App Not Updating
523
-
524
- After pushing a new image, Container App continues running the old version.
525
-
526
- **Cause:** Same image digest doesn't trigger a new revision.
527
-
528
- **Solution:** Force a new revision with a timestamp:
529
-
530
- ```bash
531
- # Force new revision with environment variable
532
- az containerapp update \
533
- --name ca-myapp-prod \
534
- --resource-group rg-myapp-prod \
535
- --set-env-vars "DEPLOY_TIMESTAMP=$(date +%s)"
536
- ```
537
-
538
- ### Complete Deploy Script
539
-
540
- ```bash
541
- #!/bin/bash
542
- # deploy-container-app.sh
543
-
544
- APP_NAME="ca-myapp-prod"
545
- RG_NAME="rg-myapp-prod"
546
- ACR_NAME="acrmyapp"
547
- IMAGE_TAG="latest"
548
-
549
- # 1. Build and push
550
- docker build --no-cache -t $ACR_NAME.azurecr.io/myapp:$IMAGE_TAG .
551
- docker push $ACR_NAME.azurecr.io/myapp:$IMAGE_TAG
552
-
553
- # 2. Update with timestamp (forces new revision)
554
- az containerapp update \
555
- --name $APP_NAME \
556
- --resource-group $RG_NAME \
557
- --set-env-vars "DEPLOY_TIMESTAMP=$(date +%s)"
558
-
559
- # 3. Verify
560
- az containerapp show \
561
- --name $APP_NAME \
562
- --resource-group $RG_NAME \
563
- --query "properties.runningStatus"
564
-
565
- # 4. Check logs
566
- az containerapp logs show \
567
- --name $APP_NAME \
568
- --resource-group $RG_NAME \
569
- --follow
570
- ```
571
-
572
- ---
573
-
574
- ## 🔧 Troubleshooting Azure
575
-
576
- Quick reference for common Azure issues:
577
-
578
- ### Key Vault access denied
579
- → Verify RBAC role assignment (Key Vault Secrets User)
580
- → Check Managed Identity is enabled on the resource
581
- → Verify Key Vault firewall allows the resource's IP/VNet
582
-
583
- ### Container App 404
584
- → Check ingress configuration (external/internal)
585
- → Verify health probe endpoint exists and returns 200
586
- → Check container is actually running (logs)
587
-
588
- ### Managed Identity not working
589
- → Verify identity is assigned to the resource
590
- → Check RBAC scope (subscription vs resource group vs resource)
591
- → Allow 5-10 minutes for propagation after assignment
592
-
593
- ### blazor.web.js 404 (.NET 10)
594
- → Add to `.csproj`:
595
- ```xml
596
- <RequiresAspNetWebAssets>true</RequiresAspNetWebAssets>
597
- ```
598
-
599
- ### DefaultAzureCredential slow/timeout
600
- → Disable unused credential types (see section above)
601
- → Check network connectivity to Azure AD
602
-
603
- ### Container App not updating
604
- → Use `DEPLOY_TIMESTAMP` to force new revision (see section above)
605
- → Verify image was actually pushed to ACR
606
- → Check ACR webhook/event subscription
607
-
608
- ### EF Core migrations not applied
609
- → Add auto-migration to startup (dev/staging only)
610
- → Or run migration in pipeline before deploy
611
-
612
- ---
613
-
614
- ## 📚 Lessons Learned - Deploy
615
-
616
- Key insights from production deployments:
617
-
618
- 1. **`docker build --no-cache`** is essential when debugging image issues
619
- 2. **`DEPLOY_TIMESTAMP`** forces new revision in Container Apps
620
- 3. **.NET 10 Preview** has undocumented breaking changes - check GitHub Issues
621
- 4. **GitHub Issues** are more effective than official docs for edge cases
622
- 5. **Auto-migration** simplifies deploy but has risks in production
623
- 6. **Key Vault in dev** needs developer credentials, not just prod Managed Identity
624
- 7. **Document while solving** - saves time later (hence this document!)