@polymorphism-tech/morph-spec 8.37.1 → 8.40.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 (317) hide show
  1. package/CLAUDE.md +37 -13
  2. package/README.md +2 -2
  3. package/bin/morph-spec.js +75 -49
  4. package/claude-plugin.json +1 -1
  5. package/docs/CHEATSHEET.md +1 -1
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/CLAUDE.md +6 -5
  8. package/framework/MORPH.md +25 -22
  9. package/framework/agents.json +96 -36
  10. package/framework/docs/CLI.md +54 -17
  11. package/framework/evals/rubrics/code-quality.md +5 -0
  12. package/framework/evals/rubrics/condensed.md +6 -2
  13. package/framework/evals/rubrics/contracts.md +20 -0
  14. package/framework/evals/rubrics/test-coverage.md +17 -6
  15. package/framework/hooks/README.md +9 -3
  16. package/framework/hooks/claude-code/core/graph-refresh-kick.js +52 -0
  17. package/framework/hooks/claude-code/core/telemetry-log.js +172 -87
  18. package/framework/hooks/claude-code/core/validate-completion.js +16 -90
  19. package/framework/hooks/claude-code/core/worktree-context.js +10 -0
  20. package/framework/hooks/shared/command-tokens.js +96 -0
  21. package/framework/hooks/shared/git-exclude.js +44 -0
  22. package/framework/hooks/shared/git-paths.js +52 -0
  23. package/framework/hooks/shared/graph-freshness.js +380 -0
  24. package/framework/hooks/shared/graph-refresh.js +416 -0
  25. package/framework/hooks/shared/morph-cli.js +17 -5
  26. package/framework/hooks/shared/redact-secrets.js +55 -0
  27. package/framework/hooks/shared/telemetry-logger.js +25 -2
  28. package/framework/hooks/shared/transcript-usage.js +80 -0
  29. package/framework/mcp/registry.json +33 -2
  30. package/framework/rubrics/backend.json +2 -2
  31. package/framework/rubrics/default.json +2 -2
  32. package/framework/rubrics/frontend.json +2 -2
  33. package/framework/rules/csharp-standards.md +1 -0
  34. package/framework/rules/infrastructure-standards.md +0 -1
  35. package/framework/rules/morph-workflow.md +10 -4
  36. package/framework/rules/nextjs-standards.md +1 -0
  37. package/framework/schemas/config.schema.json +41 -1
  38. package/framework/schemas/feature.schema.json +5 -1
  39. package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
  40. package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
  41. package/framework/skills/core/morph-apply/SKILL.md +40 -11
  42. package/framework/skills/core/morph-brainstorming/SKILL.md +16 -7
  43. package/framework/skills/core/morph-eval/SKILL.md +1 -1
  44. package/framework/skills/core/morph-hotfix/SKILL.md +1 -1
  45. package/framework/skills/core/morph-implement/SKILL.md +44 -10
  46. package/framework/skills/core/morph-media/SKILL.md +1 -1
  47. package/framework/skills/core/morph-plan/SKILL.md +73 -15
  48. package/framework/skills/core/morph-proposal/SKILL.md +1 -1
  49. package/framework/skills/core/morph-review/SKILL.md +51 -13
  50. package/framework/skills/core/morph-stack-scan/SKILL.md +1 -1
  51. package/framework/skills/core/morph-standards/SKILL.md +1 -1
  52. package/framework/skills/core/morph-uiux/SKILL.md +39 -13
  53. package/framework/standards/STANDARDS.json +189 -14
  54. package/framework/standards/ai-agents/context-providers.md +16 -26
  55. package/framework/standards/ai-agents/durable-workflows-hitl.md +15 -21
  56. package/framework/standards/ai-agents/modalities-image-gen.md +21 -25
  57. package/framework/standards/ai-agents/modalities-speech-to-text.md +4 -15
  58. package/framework/standards/ai-agents/modalities-text-to-speech.md +2 -11
  59. package/framework/standards/ai-agents/modalities-vision.md +1 -18
  60. package/framework/standards/ai-agents/prompt-sources.md +0 -4
  61. package/framework/standards/ai-agents/testing-ai.md +2 -1
  62. package/framework/standards/architecture/code-comments.md +100 -0
  63. package/framework/standards/backend/dotnet/testing.md +22 -0
  64. package/framework/standards/backend/integrations/neon-auth/neon-auth.md +63 -50
  65. package/framework/standards/frontend/admin-app/data-table.md +562 -0
  66. package/framework/standards/frontend/admin-app/feedback.md +236 -0
  67. package/framework/standards/frontend/admin-app/forms.md +232 -0
  68. package/framework/standards/frontend/admin-app/page-structure.md +203 -0
  69. package/framework/standards/frontend/design-system/ai-image-generation.md +5 -5
  70. package/framework/standards/frontend/nextjs/components.md +37 -58
  71. package/framework/standards/frontend/nextjs/data-fetching.md +1 -0
  72. package/framework/standards/frontend/nextjs/forms.md +31 -30
  73. package/framework/standards/frontend/nextjs/state-management.md +2 -1
  74. package/framework/standards/frontend/nextjs/testing.md +18 -0
  75. package/framework/standards/integration/mcp/mcp-tools.md +48 -117
  76. package/framework/templates/code/dotnet/abstractions/result.cs +0 -2
  77. package/framework/templates/code/dotnet/ai-agents/AgentBootstrap.cs.template +26 -39
  78. package/framework/templates/code/dotnet/ai-agents/EmbeddingService.cs.template +28 -68
  79. package/framework/templates/code/dotnet/ai-agents/ModelRegistry.cs.template +99 -117
  80. package/framework/templates/code/dotnet/ai-agents/PromptRepository.cs.template +2 -44
  81. package/framework/templates/code/dotnet/ai-agents/ResilientToolMiddleware.cs.template +40 -61
  82. package/framework/templates/code/dotnet/ai-agents/VectorSearchTool.cs.template +54 -107
  83. package/framework/templates/code/dotnet/ai-agents/model-registry.json.template +53 -58
  84. package/framework/templates/code/dotnet/contracts/contracts-vsa.cs +192 -281
  85. package/framework/templates/code/dotnet/database/migration.cs +49 -83
  86. package/framework/templates/code/dotnet/database/vector-entity.cs +2 -46
  87. package/framework/templates/code/dotnet/extensions/result-extensions.cs +0 -2
  88. package/framework/templates/code/dotnet/feature/validator.cs.hbs +11 -15
  89. package/framework/templates/code/dotnet/jobs/agent.cs +3 -51
  90. package/framework/templates/code/dotnet/jobs/job.cs +2 -97
  91. package/framework/templates/code/dotnet/test.cs +2 -87
  92. package/framework/templates/code/typescript/contracts.ts +140 -167
  93. package/framework/templates/context/design-system.md +3 -3
  94. package/framework/templates/docs/proposal.md +11 -0
  95. package/framework/templates/docs/spec.md +15 -0
  96. package/framework/templates/docs/ui-mockups.md +115 -98
  97. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Agents/AgentApi.cs +1 -48
  98. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Agents/AgentFactory.cs +3 -79
  99. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Agents/AgentFactoryOptions.cs +1 -70
  100. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Agents/AgentSpec.cs +1 -47
  101. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Agents/AgentSpecOptions.cs +2 -99
  102. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/AiKitAssemblyMarker.cs +0 -6
  103. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Conversation/ConversationStore.cs +3 -88
  104. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Conversation/IConversationStore.cs +1 -41
  105. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Conversation/InMemoryConversationStore.cs +0 -21
  106. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/CountingChatClient.cs +1 -25
  107. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalAssertion.cs +2 -63
  108. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalCacheMissException.cs +0 -30
  109. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalCacheOptions.cs +1 -52
  110. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalCacheStamp.cs +3 -78
  111. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalFixture.cs +4 -109
  112. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalMode.cs +0 -22
  113. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalQualityEvaluators.cs +1 -36
  114. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalScenario.cs +2 -57
  115. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalSummary.cs +0 -75
  116. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/OfflineChatClient.cs +2 -59
  117. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/ShortPathResponseCache.cs +4 -111
  118. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/IMediaGenerator.cs +0 -34
  119. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/IMediaProvider.cs +1 -57
  120. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaArtifact.cs +0 -19
  121. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaDisclosure.cs +2 -74
  122. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaGenerator.cs +2 -33
  123. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaIdempotencyKey.cs +1 -43
  124. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaJob.cs +1 -96
  125. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaJobId.cs +0 -13
  126. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaJobState.cs +0 -27
  127. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaPricing.cs +0 -33
  128. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaProvenance.cs +0 -31
  129. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaRequest.cs +3 -75
  130. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaResult.cs +0 -42
  131. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaReview.cs +0 -39
  132. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaSeams.cs +1 -55
  133. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaStore.cs +3 -59
  134. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MorphMedia.cs +0 -46
  135. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/Providers/GoogleImageProvider.cs +3 -28
  136. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/Providers/OpenAIImageProvider.cs +7 -61
  137. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/Providers/VeoVideoProvider.cs +2 -37
  138. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Middleware/IUsageCostSink.cs +1 -23
  139. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Middleware/UsageCostMiddleware.cs +2 -82
  140. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Middleware/UsageCostRecord.cs +1 -68
  141. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Observability/MorphOpenTelemetryExtensions.cs +1 -62
  142. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Observability/MorphTelemetryOptions.cs +2 -62
  143. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/IProviderClientFactory.cs +1 -25
  144. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/ModelAlias.cs +0 -124
  145. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/ModelRegistry.cs +1 -73
  146. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Rag/DeltaIngest.cs +1 -66
  147. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Rag/DeltaPlan.cs +0 -41
  148. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/AgentFactoryTests.cs +2 -112
  149. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/AgentSpecTests.cs +2 -43
  150. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/ConversationStoreTests.cs +5 -110
  151. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/DeltaIngestTests.cs +7 -103
  152. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalAssertionTests.cs +1 -42
  153. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalCacheMissTests.cs +1 -30
  154. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalCacheStampTests.cs +1 -19
  155. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalFailuresTests.cs +0 -48
  156. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalFixtureTests.cs +1 -29
  157. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalRefreshTests.cs +2 -38
  158. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalWorkspace.cs +1 -14
  159. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/KitEvals.cs +4 -69
  160. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/OfflineChatClientTests.cs +1 -10
  161. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeChatClient.cs +1 -57
  162. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeChatClientTests.cs +0 -26
  163. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeClock.cs +1 -19
  164. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeMediaProvider.cs +0 -32
  165. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeProviderClientFactory.cs +0 -14
  166. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeUsageCostSink.cs +0 -24
  167. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/InMemoryMediaStore.cs +0 -32
  168. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaAccessibilityTests.cs +0 -37
  169. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaAliasIsNotAnAgentTests.cs +0 -24
  170. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaDisclosureTests.cs +0 -78
  171. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaGeneratorTests.cs +0 -53
  172. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaIdempotencyKeyTests.cs +0 -44
  173. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaJobStateTests.cs +0 -44
  174. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaReviewTests.cs +0 -19
  175. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaStoreTests.cs +0 -24
  176. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/ModelRegistryTests.cs +6 -48
  177. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/SkeletonSmokeTests.cs +1 -13
  178. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/TelemetryTests.cs +2 -71
  179. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/UsageCostMiddlewareTests.cs +5 -100
  180. package/framework/templates/feature/decisions.md +124 -122
  181. package/framework/templates/frontend/nextjs/Dockerfile.nextjs.hbs +39 -43
  182. package/framework/templates/frontend/nextjs/env.mjs.hbs +29 -32
  183. package/framework/templates/frontend/nextjs/page.tsx.hbs +21 -22
  184. package/framework/templates/frontend/nextjs/use-feature.ts.hbs +42 -54
  185. package/framework/templates/integrations/asaas-client.cs +332 -387
  186. package/framework/templates/integrations/asaas-webhook.cs +290 -351
  187. package/framework/templates/integrations/neon-auth-config.cs +9 -105
  188. package/framework/templates/project/validate.js +97 -120
  189. package/package.json +2 -2
  190. package/src/commands/dashboard/dashboard.js +80 -53
  191. package/src/commands/graph/affected.js +4 -3
  192. package/src/commands/graph/build.js +109 -18
  193. package/src/commands/graph/explain.js +8 -5
  194. package/src/commands/graph/status.js +14 -8
  195. package/src/commands/mcp/mcp-setup.js +37 -9
  196. package/src/commands/observability/cost.js +148 -18
  197. package/src/commands/project/doctor.js +85 -15
  198. package/src/commands/project/init.js +6 -3
  199. package/src/commands/project/install-plugin-cmd.js +1 -1
  200. package/src/commands/project/update.js +30 -0
  201. package/src/commands/project/worktree.js +73 -90
  202. package/src/commands/state/advance.js +18 -0
  203. package/src/commands/state/approve.js +15 -0
  204. package/src/commands/state/archive.js +62 -9
  205. package/src/commands/state/finish.js +62 -14
  206. package/src/commands/state/gate-check.js +8 -1
  207. package/src/commands/state/gate-decision.js +8 -4
  208. package/src/commands/state/report-check.js +90 -9
  209. package/src/commands/state/usecase.js +66 -0
  210. package/src/commands/tasks/dag.js +17 -2
  211. package/src/commands/validation/validate-feature.js +6 -1
  212. package/src/commands/validation/verify.js +20 -1
  213. package/src/dashboard/app/App.jsx +80 -16
  214. package/src/dashboard/app/components/ActivityFeed.jsx +172 -0
  215. package/src/dashboard/app/components/CommandPalette.jsx +155 -0
  216. package/src/dashboard/app/components/DetailPanel.jsx +47 -11
  217. package/src/dashboard/app/components/EntityLink.jsx +55 -0
  218. package/src/dashboard/app/components/ErrorBoundary.jsx +54 -0
  219. package/src/dashboard/app/components/FlowGraph.jsx +19 -17
  220. package/src/dashboard/app/components/KnowledgeMarkdown.jsx +53 -0
  221. package/src/dashboard/app/components/Markdown.jsx +47 -0
  222. package/src/dashboard/app/components/PhaseRail.jsx +111 -0
  223. package/src/dashboard/app/components/SearchFilter.jsx +40 -22
  224. package/src/dashboard/app/components/Sidebar.jsx +146 -37
  225. package/src/dashboard/app/hooks/useMorphQuery.js +54 -0
  226. package/src/dashboard/app/hooks/usePref.js +38 -0
  227. package/src/dashboard/app/lib/format.js +69 -0
  228. package/src/dashboard/app/lib/phases.js +56 -0
  229. package/src/dashboard/app/lib/project.js +50 -0
  230. package/src/dashboard/app/pages/Activity.jsx +24 -0
  231. package/src/dashboard/app/pages/AgentMap.jsx +371 -370
  232. package/src/dashboard/app/pages/FeatureDetail.jsx +604 -0
  233. package/src/dashboard/app/pages/Features.jsx +400 -0
  234. package/src/dashboard/app/pages/Guide.jsx +146 -0
  235. package/src/dashboard/app/pages/HookInspector.jsx +357 -322
  236. package/src/dashboard/app/pages/PhasePipeline.jsx +277 -408
  237. package/src/dashboard/app/pages/Portfolio.jsx +156 -0
  238. package/src/dashboard/app/pages/Rubrics.jsx +101 -0
  239. package/src/dashboard/app/pages/RulesMap.jsx +300 -273
  240. package/src/dashboard/app/pages/SkillsLibrary.jsx +483 -366
  241. package/src/dashboard/app/pages/Standards.jsx +407 -332
  242. package/src/dashboard/app/styles/index.css +187 -47
  243. package/src/dashboard/index.html +14 -12
  244. package/src/dashboard/package.json +32 -24
  245. package/src/dashboard/scanner/activity-scanner.js +351 -0
  246. package/src/dashboard/scanner/agents-scanner.js +63 -1
  247. package/src/dashboard/scanner/docs-scanner.js +59 -0
  248. package/src/dashboard/scanner/feature-status.js +10 -0
  249. package/src/dashboard/scanner/features-scanner.js +360 -0
  250. package/src/dashboard/scanner/hooks-scanner.js +8 -1
  251. package/src/dashboard/scanner/index.js +14 -7
  252. package/src/dashboard/scanner/phases-scanner.js +14 -15
  253. package/src/dashboard/scanner/portfolio.js +153 -0
  254. package/src/dashboard/scanner/project-api.js +195 -0
  255. package/src/dashboard/scanner/rules-scanner.js +42 -37
  256. package/src/dashboard/scanner/skills-scanner.js +105 -43
  257. package/src/dashboard/scanner/standards-scanner.js +4 -1
  258. package/src/dashboard/vite-plugin-morph-data.js +134 -17
  259. package/src/lib/ai/comment-stripper.js +101 -4
  260. package/src/lib/detectors/claude-config-detector.js +2 -7
  261. package/src/lib/detectors/index.js +5 -1
  262. package/src/lib/evaluator-report.js +47 -0
  263. package/src/lib/generators/handoff-generator.js +4 -18
  264. package/src/lib/generators/settings-generator.js +208 -209
  265. package/src/lib/git/default-branch.js +52 -0
  266. package/src/lib/git/tree-fingerprint.js +58 -0
  267. package/src/lib/git/tree-state.js +167 -0
  268. package/src/lib/graph/god-nodes.js +12 -3
  269. package/src/lib/graph/graph-health.js +48 -2
  270. package/src/lib/graph/graph-loader.js +99 -25
  271. package/src/lib/graph/graphifyignore.js +145 -28
  272. package/src/lib/graph/sanitize.js +117 -11
  273. package/src/lib/installers/mcp-installer.js +724 -719
  274. package/src/lib/installers/memory-installer.js +1 -2
  275. package/src/lib/projects/registry.js +154 -0
  276. package/src/lib/risk-detector.js +90 -0
  277. package/src/lib/specs/acervo-format.js +70 -0
  278. package/src/lib/specs/acervo-lifecycle.js +264 -0
  279. package/src/lib/specs/adr-index.js +169 -0
  280. package/src/lib/specs/revocations.js +156 -0
  281. package/src/lib/specs/screen-checklist.js +357 -0
  282. package/src/lib/specs/usecase-check.js +20 -16
  283. package/src/lib/specs/usecase-promoter.js +103 -38
  284. package/src/lib/specs/usecase-registry.js +7 -7
  285. package/src/lib/tasks/tasks-json-parser.js +2 -3
  286. package/src/lib/telemetry/metrics.js +386 -0
  287. package/src/lib/telemetry/telemetry-reader.js +161 -51
  288. package/src/lib/telemetry/verify-event.js +79 -0
  289. package/src/lib/validators/code-budget/code-budget-validator.js +200 -0
  290. package/src/lib/validators/code-budget/comment-scanner.js +75 -0
  291. package/src/lib/validators/code-budget/index.js +9 -0
  292. package/src/lib/validators/reuse/reuse-validator.js +4 -2
  293. package/src/lib/validators/reuse/symbol-scanner.js +27 -22
  294. package/src/lib/validators/validation-runner.js +21 -5
  295. package/src/lib/validators/verify-runner.js +11 -0
  296. package/src/lib/worktree/finish-backup.js +739 -0
  297. package/src/lib/worktree/ignored-triage.js +15 -8
  298. package/src/lib/worktree/worktree-audit.js +5 -0
  299. package/src/scripts/install-plugin.js +1 -1
  300. package/src/scripts/setup-infra.js +31 -22
  301. package/src/utils/agents-installer.js +338 -24
  302. package/src/utils/banner.js +1 -1
  303. package/src/utils/hooks-installer.js +75 -15
  304. package/src/commands/index.js +0 -13
  305. package/src/commands/project/checkpoint.js +0 -209
  306. package/src/core/state/phase-state-machine.js +0 -197
  307. package/src/dashboard/app/hooks/useDetailPanel.js +0 -15
  308. package/src/dashboard/app/pages/LiveState.jsx +0 -206
  309. package/src/dashboard/scanner/squads-scanner.js +0 -13
  310. package/src/dashboard/scanner/state-scanner.js +0 -85
  311. package/src/lib/generators/index.js +0 -10
  312. package/src/lib/hooks/hook-executor.js +0 -167
  313. package/src/lib/validators/checkpoint-persistence.js +0 -39
  314. package/src/lib/validators/shared/emit-validator-dispatch.js +0 -14
  315. package/src/lib/validators/shared/index.js +0 -12
  316. package/src/lib/validators/shared/issue-counter.js +0 -14
  317. package/src/lib/validators/shared/result-formatter.js +0 -124
@@ -1,58 +1,53 @@
1
- // TEMPLATE: model-registry.json (place in project at config/model-registry.json)
2
- // PURPOSE: Single source of truth for model selection. Agents reference aliases, not models.
3
- // READS STANDARD: ai-agents-providers-model-registry
4
- // PROVIDERS: openai + ollama work out-of-the-box with the ModelRegistry template.
5
- // For google / anthropic, add a provider branch first (see the standard).
6
- // PLACEHOLDERS:
7
- // {{PROJECT_DEFAULT_ALIAS}} — alias used when none specified (default: "text-default")
8
- // LAST-VERIFIED: 2026-05-19
9
- {
10
- "$schema": "./model-registry.schema.json",
11
- "version": "1.0",
12
- "defaultAlias": "{{PROJECT_DEFAULT_ALIAS}}",
13
- "aliases": {
14
- "text-default": {
15
- "provider": "openai",
16
- "model": "gpt-4o-mini",
17
- "options": { "temperature": 0.7 }
18
- },
19
- "text-heavy": {
20
- "provider": "openai",
21
- "model": "gpt-4o",
22
- "options": { "temperature": 0.5 }
23
- },
24
- "reasoning": {
25
- "provider": "openai",
26
- "model": "o3-mini",
27
- "options": { "reasoningEffort": "medium" }
28
- },
29
- "long-form": {
30
- "provider": "anthropic",
31
- "model": "claude-sonnet-4-6",
32
- "options": {}
33
- },
34
- "vision": {
35
- "provider": "google",
36
- "model": "gemini-2.5-flash",
37
- "options": {}
38
- },
39
- "embeddings": {
40
- "provider": "openai",
41
- "model": "text-embedding-3-small",
42
- "options": { "dimensions": 1536 }
43
- },
44
- "local-dev": {
45
- "provider": "ollama",
46
- "model": "llama3.2:3b",
47
- "options": { "endpoint": "http://localhost:11434/v1" }
48
- },
49
- "transcription": {
50
- "provider": "openai",
51
- "model": "whisper-1",
52
- "options": {}
53
- }
54
- },
55
- "fallback": {
56
- "text-default": "ollama/llama3.2:3b"
57
- }
58
- }
1
+ // READS STANDARD: ai-agents-providers-model-registry
2
+ // Goes in config/model-registry.json. ModelRegistry only builds openai and ollama:
3
+ // the anthropic and google aliases throw until a provider branch is added there.
4
+ {
5
+ "$schema": "./model-registry.schema.json",
6
+ "version": "1.0",
7
+ "defaultAlias": "{{PROJECT_DEFAULT_ALIAS}}",
8
+ "aliases": {
9
+ "text-default": {
10
+ "provider": "openai",
11
+ "model": "gpt-4o-mini",
12
+ "options": { "temperature": 0.7 }
13
+ },
14
+ "text-heavy": {
15
+ "provider": "openai",
16
+ "model": "gpt-4o",
17
+ "options": { "temperature": 0.5 }
18
+ },
19
+ "reasoning": {
20
+ "provider": "openai",
21
+ "model": "o3-mini",
22
+ "options": { "reasoningEffort": "medium" }
23
+ },
24
+ "long-form": {
25
+ "provider": "anthropic",
26
+ "model": "claude-sonnet-4-6",
27
+ "options": {}
28
+ },
29
+ "vision": {
30
+ "provider": "google",
31
+ "model": "gemini-2.5-flash",
32
+ "options": {}
33
+ },
34
+ "embeddings": {
35
+ "provider": "openai",
36
+ "model": "text-embedding-3-small",
37
+ "options": { "dimensions": 1536 }
38
+ },
39
+ "local-dev": {
40
+ "provider": "ollama",
41
+ "model": "llama3.2:3b",
42
+ "options": { "endpoint": "http://localhost:11434/v1" }
43
+ },
44
+ "transcription": {
45
+ "provider": "openai",
46
+ "model": "whisper-1",
47
+ "options": {}
48
+ }
49
+ },
50
+ "fallback": {
51
+ "text-default": "ollama/llama3.2:3b"
52
+ }
53
+ }
@@ -1,281 +1,192 @@
1
- // ============================================================
2
- // CONTRACTS: {{pascalCase FEATURE_NAME}} — Vertical Slice Architecture
3
- // Generated by MORPH Framework | Date: {{DATE}}
4
- // Pattern: KanaiyaKatarmal/VerticalSliceArchitectureTemplate
5
- // Ref: framework/standards/architecture/vertical-slice/vertical-slice.md
6
- // ============================================================
7
- //
8
- // INSTRUÇÕES DE USO:
9
- // 1. Copie cada seção para o arquivo correspondente no projeto
10
- // 2. Substitua {{pascalCase FEATURE_NAME}} pelo nome da entidade (ex: Product)
11
- // 3. Substitua {{NAMESPACE}} pelo namespace raiz do projeto (ex: MyApp)
12
- // 4. Substitua {{ROUTE}} pela rota base (ex: /api/products)
13
- // 5. Adicione os campos reais da entidade (marcados com TODO)
14
- // ============================================================
15
-
16
- // ============================================================
17
- // ABSTRACTIONS (apenas se ainda não existir no projeto)
18
- // Caminho: Abstractions/IHandler.cs
19
- // ============================================================
20
-
21
- namespace {{NAMESPACE}}.Abstractions
22
- {
23
- public interface IHandler<in TRequest, TResponse>
24
- {
25
- Task<TResponse> HandleAsync(TRequest command, CancellationToken cancellationToken);
26
- }
27
- }
28
-
29
- // ============================================================
30
- // Caminho: Abstractions/IApiEndpoint.cs
31
- // ============================================================
32
-
33
- namespace {{NAMESPACE}}.Abstractions
34
- {
35
- public interface IApiEndpoint
36
- {
37
- void MapEndpoint(IEndpointRouteBuilder app);
38
- }
39
- }
40
-
41
- // ============================================================
42
- // Caminho: Abstractions/Errors/Error.cs
43
- // ============================================================
44
-
45
- namespace {{NAMESPACE}}.Abstractions.Errors;
46
-
47
- public record Error(string Code, string? Description = default, ErrorType Type = ErrorType.Failure)
48
- {
49
- public static readonly Error None = new(string.Empty);
50
- public static readonly Error Null = new("Error.NullValue", "The specified result value is null.");
51
-
52
- public static implicit operator Result(Error error) => Result.Failure(error);
53
-
54
- public static Error Failure(string code, string description) =>
55
- new(code, description, ErrorType.Failure);
56
- public static Error Unexpected(string code, string description) =>
57
- new(code, description, ErrorType.Unexpected);
58
- public static Error Validation(string code, string description) =>
59
- new(code, description, ErrorType.Validation);
60
- public static Error Conflict(string code, string description) =>
61
- new(code, description, ErrorType.Conflict);
62
- public static Error NotFound(string code, string description) =>
63
- new(code, description, ErrorType.NotFound);
64
- public static Error Unauthorized(string code, string description) =>
65
- new(code, description, ErrorType.Unauthorized);
66
- public static Error Forbidden(string code, string description) =>
67
- new(code, description, ErrorType.Forbidden);
68
- }
69
-
70
- public enum ErrorType
71
- {
72
- Failure, Unexpected, Validation, Conflict, NotFound, Unauthorized, Forbidden, Custom
73
- }
74
-
75
- // ============================================================
76
- // Caminho: Abstractions/Errors/ValidationError.cs
77
- // ============================================================
78
-
79
- namespace {{NAMESPACE}}.Abstractions.Errors;
80
-
81
- public sealed record ValidationError : Error
82
- {
83
- public ValidationError(Error[] errors)
84
- : base("Validation.General", "One or more validation errors occurred", ErrorType.Validation)
85
- {
86
- Errors = errors;
87
- }
88
- public Error[] Errors { get; }
89
- public static ValidationError FromResults(IEnumerable<Result> results) =>
90
- new(results.Where(r => r.IsFailure).Select(r => r.Error).ToArray());
91
- }
92
-
93
- // ============================================================
94
- // Caminho: Abstractions/Result.cs
95
- // ============================================================
96
-
97
- using {{NAMESPACE}}.Abstractions.Errors;
98
- namespace {{NAMESPACE}}.Abstractions;
99
-
100
- public class Result
101
- {
102
- protected internal Result(bool isSuccess, Error error)
103
- {
104
- if (isSuccess && error != Error.None || !isSuccess && error == Error.None)
105
- throw new ArgumentException("Invalid error", nameof(error));
106
- IsSuccess = isSuccess;
107
- Error = error;
108
- }
109
- public bool IsSuccess { get; }
110
- public bool IsFailure => !IsSuccess;
111
- public Error Error { get; }
112
-
113
- public static Result Success() => new(true, Error.None);
114
- public static Result<TValue> Success<TValue>(TValue value) => new(value, true, Error.None);
115
- public static Result Failure(Error error) => new(false, error);
116
- public static Result<TValue> Failure<TValue>(Error error) => new(default, false, error);
117
- public static Result<TValue> Create<TValue>(TValue? value) =>
118
- value is not null ? Success(value) : Failure<TValue>(Error.Null);
119
- }
120
-
121
- public class Result<TValue> : Result
122
- {
123
- private readonly TValue? _value;
124
- protected internal Result(TValue? value, bool isSuccess, Error error) : base(isSuccess, error)
125
- => _value = value;
126
- public TValue Value => IsSuccess
127
- ? _value!
128
- : throw new InvalidOperationException("The value of a failure result can not be accessed.");
129
- public static implicit operator Result<TValue>(TValue? value) => Create(value);
130
- public static implicit operator Result<TValue>(Error error) => Failure<TValue>(error);
131
- }
132
-
133
- // ============================================================
134
- // ENTITY
135
- // Caminho: Entities/{{pascalCase FEATURE_NAME}}.cs
136
- // ============================================================
137
-
138
- namespace {{NAMESPACE}}.Entities;
139
-
140
- public sealed class {{pascalCase FEATURE_NAME}}
141
- {
142
- public Guid Id { get; set; }
143
-
144
- // TODO: adicionar campos da entidade com tipos C# corretos
145
- // Exemplo:
146
- // public required string Name { get; set; }
147
- // public decimal Price { get; set; }
148
- // public int Quantity { get; set; }
149
- // public DateTime CreatedAt { get; set; }
150
- }
151
-
152
- // ============================================================
153
- // FEATURE ERRORS (compartilhado por todos os slices da feature)
154
- // Caminho: Features/{{pascalCase FEATURE_NAME}}Feature/{{pascalCase FEATURE_NAME}}Errors.cs
155
- // ============================================================
156
-
157
- using {{NAMESPACE}}.Abstractions.Errors;
158
- namespace {{NAMESPACE}}.Features.{{pascalCase FEATURE_NAME}}Feature;
159
-
160
- public static class {{pascalCase FEATURE_NAME}}Errors
161
- {
162
- public static Error NotFound(Guid id) =>
163
- Error.NotFound("{{pascalCase FEATURE_NAME}}s.NotFound",
164
- $"The {{pascalCase FEATURE_NAME}} with Id '{id}' was not found");
165
-
166
- // TODO: adicionar outros tipos de erro específicos da feature
167
- // public static Error AlreadyExists(string name) =>
168
- // Error.Conflict("{{pascalCase FEATURE_NAME}}s.AlreadyExists",
169
- // $"A {{pascalCase FEATURE_NAME}} with name '{name}' already exists");
170
- }
171
-
172
- // ============================================================
173
- // SLICE: Create{{pascalCase FEATURE_NAME}}
174
- // Caminho: Features/{{pascalCase FEATURE_NAME}}Feature/Create{{pascalCase FEATURE_NAME}}/
175
- // ============================================================
176
-
177
- // --- Create{{pascalCase FEATURE_NAME}}Handler.cs ---
178
- namespace {{NAMESPACE}}.Features.{{pascalCase FEATURE_NAME}}Feature.Create{{pascalCase FEATURE_NAME}};
179
-
180
- using {{NAMESPACE}}.Abstractions;
181
- using {{NAMESPACE}}.Database;
182
- using {{NAMESPACE}}.Entities;
183
-
184
- // TODO: adicionar todos os campos do request (campos obrigatórios para criação)
185
- public sealed record Create{{pascalCase FEATURE_NAME}}Request(/* string Name, decimal Price, ... */);
186
-
187
- // TODO: adicionar todos os campos do response (campos retornados após criação)
188
- public sealed record Create{{pascalCase FEATURE_NAME}}Response(Guid Id /* , string Name, ... */);
189
-
190
- public sealed class Create{{pascalCase FEATURE_NAME}}Handler(
191
- ApplicationDbContext _db) : IHandler<Create{{pascalCase FEATURE_NAME}}Request, Result<Create{{pascalCase FEATURE_NAME}}Response>>
192
- {
193
- public async Task<Result<Create{{pascalCase FEATURE_NAME}}Response>> HandleAsync(
194
- Create{{pascalCase FEATURE_NAME}}Request command, CancellationToken cancellationToken)
195
- {
196
- var entity = new {{pascalCase FEATURE_NAME}}
197
- {
198
- Id = Guid.CreateVersion7(),
199
- // TODO: mapear campos do command para a entidade
200
- // Name = command.Name,
201
- // Price = command.Price,
202
- };
203
-
204
- _db.Set<{{pascalCase FEATURE_NAME}}>().Add(entity);
205
- await _db.SaveChangesAsync(cancellationToken);
206
-
207
- return Result.Success(new Create{{pascalCase FEATURE_NAME}}Response(entity.Id /* , entity.Name, ... */));
208
- }
209
- }
210
-
211
- // --- Create{{pascalCase FEATURE_NAME}}Validator.cs ---
212
- namespace {{NAMESPACE}}.Features.{{pascalCase FEATURE_NAME}}Feature.Create{{pascalCase FEATURE_NAME}};
213
-
214
- using FluentValidation;
215
-
216
- public class Create{{pascalCase FEATURE_NAME}}Validator : AbstractValidator<Create{{pascalCase FEATURE_NAME}}Request>
217
- {
218
- public Create{{pascalCase FEATURE_NAME}}Validator()
219
- {
220
- // TODO: adicionar regras de validação para cada campo
221
- // RuleFor(c => c.Name)
222
- // .NotEmpty().WithMessage("Name is required")
223
- // .MaximumLength(200).WithMessage("Name must not exceed 200 characters");
224
- // RuleFor(c => c.Price)
225
- // .GreaterThan(0).WithMessage("Price must be greater than 0");
226
- }
227
- }
228
-
229
- // --- Create{{pascalCase FEATURE_NAME}}Endpoint.cs ---
230
- namespace {{NAMESPACE}}.Features.{{pascalCase FEATURE_NAME}}Feature.Create{{pascalCase FEATURE_NAME}};
231
-
232
- using {{NAMESPACE}}.Abstractions;
233
- using {{NAMESPACE}}.Extensions;
234
-
235
- internal sealed class Create{{pascalCase FEATURE_NAME}}Endpoint : IApiEndpoint
236
- {
237
- public void MapEndpoint(IEndpointRouteBuilder app)
238
- {
239
- app.MapPost("{{ROUTE}}", async (
240
- IHandler<Create{{pascalCase FEATURE_NAME}}Request, Result<Create{{pascalCase FEATURE_NAME}}Response>> handler,
241
- Create{{pascalCase FEATURE_NAME}}Request command,
242
- CancellationToken cancellationToken) =>
243
- {
244
- var result = await handler.HandleAsync(command, cancellationToken);
245
- return result.Match(
246
- onSuccess: () => Results.Ok(result.Value),
247
- onFailure: error => Results.BadRequest(error));
248
- })
249
- // TODO: substituir "{{pascalCase FEATURE_NAME}}s" pelo tag correto em ApiTags
250
- .WithTags("{{pascalCase FEATURE_NAME}}s")
251
- .Produces<Create{{pascalCase FEATURE_NAME}}Response>(StatusCodes.Status200OK)
252
- .Produces(StatusCodes.Status400BadRequest);
253
- }
254
- }
255
-
256
- // ============================================================
257
- // TODO: adicionar slices restantes (copiar padrão do Create acima)
258
- // ============================================================
259
- // GetAll{{pascalCase FEATURE_NAME}}s — sem validator (sem parâmetros)
260
- // Request: sealed record GetAll{{pascalCase FEATURE_NAME}}sRequest;
261
- // Response: sealed record GetAll{{pascalCase FEATURE_NAME}}sResponse(IEnumerable<{{pascalCase FEATURE_NAME}}Dto> Items);
262
- // DTO: sealed record {{pascalCase FEATURE_NAME}}Dto(Guid Id, /* campos */);
263
- // Endpoint: app.MapGet("{{ROUTE}}", ...)
264
- //
265
- // Get{{pascalCase FEATURE_NAME}}ById — com validator (Id obrigatório)
266
- // Request: sealed record Get{{pascalCase FEATURE_NAME}}ByIdRequest(Guid Id);
267
- // Response: sealed record Get{{pascalCase FEATURE_NAME}}ByIdResponse(Guid Id, /* campos */);
268
- // Endpoint: app.MapGet("{{ROUTE}}/{id:guid}", ...)
269
- // OnFailure: Results.NotFound(error)
270
- //
271
- // Update{{pascalCase FEATURE_NAME}} — com validator
272
- // Request: sealed record Update{{pascalCase FEATURE_NAME}}Request(Guid Id, /* campos nullable */);
273
- // Response: sealed record Update{{pascalCase FEATURE_NAME}}Response(Guid Id, /* campos */);
274
- // Endpoint: app.MapPut("{{ROUTE}}/{id:guid}", ...)
275
- // Checar NotFound antes de atualizar
276
- //
277
- // Delete{{pascalCase FEATURE_NAME}} — com validator
278
- // Request: sealed record Delete{{pascalCase FEATURE_NAME}}Request(Guid Id);
279
- // Response: sealed record Delete{{pascalCase FEATURE_NAME}}Response(Guid Id);
280
- // Endpoint: app.MapDelete("{{ROUTE}}/{id:guid}", ...)
281
- // Checar NotFound antes de deletar
1
+ // {{pascalCase FEATURE_NAME}} ({{DATE}}): cada seção vai para o arquivo do caminho que a encabeça.
2
+
3
+ // Abstractions/IHandler.cs
4
+ namespace {{NAMESPACE}}.Abstractions
5
+ {
6
+ public interface IHandler<in TRequest, TResponse>
7
+ {
8
+ Task<TResponse> HandleAsync(TRequest command, CancellationToken cancellationToken);
9
+ }
10
+ }
11
+
12
+ // Abstractions/IApiEndpoint.cs
13
+ namespace {{NAMESPACE}}.Abstractions
14
+ {
15
+ public interface IApiEndpoint
16
+ {
17
+ void MapEndpoint(IEndpointRouteBuilder app);
18
+ }
19
+ }
20
+
21
+ // Abstractions/Errors/Error.cs
22
+ namespace {{NAMESPACE}}.Abstractions.Errors;
23
+
24
+ public record Error(string Code, string? Description = default, ErrorType Type = ErrorType.Failure)
25
+ {
26
+ public static readonly Error None = new(string.Empty);
27
+ public static readonly Error Null = new("Error.NullValue", "The specified result value is null.");
28
+
29
+ public static implicit operator Result(Error error) => Result.Failure(error);
30
+
31
+ public static Error Failure(string code, string description) =>
32
+ new(code, description, ErrorType.Failure);
33
+ public static Error Unexpected(string code, string description) =>
34
+ new(code, description, ErrorType.Unexpected);
35
+ public static Error Validation(string code, string description) =>
36
+ new(code, description, ErrorType.Validation);
37
+ public static Error Conflict(string code, string description) =>
38
+ new(code, description, ErrorType.Conflict);
39
+ public static Error NotFound(string code, string description) =>
40
+ new(code, description, ErrorType.NotFound);
41
+ public static Error Unauthorized(string code, string description) =>
42
+ new(code, description, ErrorType.Unauthorized);
43
+ public static Error Forbidden(string code, string description) =>
44
+ new(code, description, ErrorType.Forbidden);
45
+ }
46
+
47
+ public enum ErrorType
48
+ {
49
+ Failure, Unexpected, Validation, Conflict, NotFound, Unauthorized, Forbidden, Custom
50
+ }
51
+
52
+ // Abstractions/Errors/ValidationError.cs
53
+ namespace {{NAMESPACE}}.Abstractions.Errors;
54
+
55
+ public sealed record ValidationError : Error
56
+ {
57
+ public ValidationError(Error[] errors)
58
+ : base("Validation.General", "One or more validation errors occurred", ErrorType.Validation)
59
+ {
60
+ Errors = errors;
61
+ }
62
+ public Error[] Errors { get; }
63
+ public static ValidationError FromResults(IEnumerable<Result> results) =>
64
+ new(results.Where(r => r.IsFailure).Select(r => r.Error).ToArray());
65
+ }
66
+
67
+ // Abstractions/Result.cs
68
+ using {{NAMESPACE}}.Abstractions.Errors;
69
+ namespace {{NAMESPACE}}.Abstractions;
70
+
71
+ public class Result
72
+ {
73
+ protected internal Result(bool isSuccess, Error error)
74
+ {
75
+ if (isSuccess && error != Error.None || !isSuccess && error == Error.None)
76
+ throw new ArgumentException("Invalid error", nameof(error));
77
+ IsSuccess = isSuccess;
78
+ Error = error;
79
+ }
80
+ public bool IsSuccess { get; }
81
+ public bool IsFailure => !IsSuccess;
82
+ public Error Error { get; }
83
+
84
+ public static Result Success() => new(true, Error.None);
85
+ public static Result<TValue> Success<TValue>(TValue value) => new(value, true, Error.None);
86
+ public static Result Failure(Error error) => new(false, error);
87
+ public static Result<TValue> Failure<TValue>(Error error) => new(default, false, error);
88
+ public static Result<TValue> Create<TValue>(TValue? value) =>
89
+ value is not null ? Success(value) : Failure<TValue>(Error.Null);
90
+ }
91
+
92
+ public class Result<TValue> : Result
93
+ {
94
+ private readonly TValue? _value;
95
+ protected internal Result(TValue? value, bool isSuccess, Error error) : base(isSuccess, error)
96
+ => _value = value;
97
+ public TValue Value => IsSuccess
98
+ ? _value!
99
+ : throw new InvalidOperationException("The value of a failure result can not be accessed.");
100
+ public static implicit operator Result<TValue>(TValue? value) => Create(value);
101
+ public static implicit operator Result<TValue>(Error error) => Failure<TValue>(error);
102
+ }
103
+
104
+ // Entities/{{pascalCase FEATURE_NAME}}.cs
105
+ namespace {{NAMESPACE}}.Entities;
106
+
107
+ public sealed class {{pascalCase FEATURE_NAME}}
108
+ {
109
+ public Guid Id { get; set; }
110
+
111
+ // TODO: campos da entidade
112
+ }
113
+
114
+ // Features/{{pascalCase FEATURE_NAME}}Feature/{{pascalCase FEATURE_NAME}}Errors.cs (compartilhado pelos slices)
115
+ using {{NAMESPACE}}.Abstractions.Errors;
116
+ namespace {{NAMESPACE}}.Features.{{pascalCase FEATURE_NAME}}Feature;
117
+
118
+ public static class {{pascalCase FEATURE_NAME}}Errors
119
+ {
120
+ public static Error NotFound(Guid id) =>
121
+ Error.NotFound("{{pascalCase FEATURE_NAME}}s.NotFound",
122
+ $"The {{pascalCase FEATURE_NAME}} with Id '{id}' was not found");
123
+ }
124
+
125
+ // Features/{{pascalCase FEATURE_NAME}}Feature/Create{{pascalCase FEATURE_NAME}}/Create{{pascalCase FEATURE_NAME}}Handler.cs
126
+ namespace {{NAMESPACE}}.Features.{{pascalCase FEATURE_NAME}}Feature.Create{{pascalCase FEATURE_NAME}};
127
+
128
+ using {{NAMESPACE}}.Abstractions;
129
+ using {{NAMESPACE}}.Database;
130
+ using {{NAMESPACE}}.Entities;
131
+
132
+ // TODO: campos do request e do response
133
+ public sealed record Create{{pascalCase FEATURE_NAME}}Request();
134
+
135
+ public sealed record Create{{pascalCase FEATURE_NAME}}Response(Guid Id);
136
+
137
+ public sealed class Create{{pascalCase FEATURE_NAME}}Handler(
138
+ ApplicationDbContext _db) : IHandler<Create{{pascalCase FEATURE_NAME}}Request, Result<Create{{pascalCase FEATURE_NAME}}Response>>
139
+ {
140
+ public async Task<Result<Create{{pascalCase FEATURE_NAME}}Response>> HandleAsync(
141
+ Create{{pascalCase FEATURE_NAME}}Request command, CancellationToken cancellationToken)
142
+ {
143
+ var entity = new {{pascalCase FEATURE_NAME}}
144
+ {
145
+ Id = Guid.CreateVersion7(),
146
+ // TODO: mapear os campos do command
147
+ };
148
+
149
+ _db.Set<{{pascalCase FEATURE_NAME}}>().Add(entity);
150
+ await _db.SaveChangesAsync(cancellationToken);
151
+
152
+ return Result.Success(new Create{{pascalCase FEATURE_NAME}}Response(entity.Id));
153
+ }
154
+ }
155
+
156
+ // Create{{pascalCase FEATURE_NAME}}/Create{{pascalCase FEATURE_NAME}}Validator.cs
157
+ namespace {{NAMESPACE}}.Features.{{pascalCase FEATURE_NAME}}Feature.Create{{pascalCase FEATURE_NAME}};
158
+
159
+ using FluentValidation;
160
+
161
+ public class Create{{pascalCase FEATURE_NAME}}Validator : AbstractValidator<Create{{pascalCase FEATURE_NAME}}Request>
162
+ {
163
+ public Create{{pascalCase FEATURE_NAME}}Validator()
164
+ {
165
+ }
166
+ }
167
+
168
+ // Create{{pascalCase FEATURE_NAME}}/Create{{pascalCase FEATURE_NAME}}Endpoint.cs
169
+ namespace {{NAMESPACE}}.Features.{{pascalCase FEATURE_NAME}}Feature.Create{{pascalCase FEATURE_NAME}};
170
+
171
+ using {{NAMESPACE}}.Abstractions;
172
+ using {{NAMESPACE}}.Extensions;
173
+
174
+ internal sealed class Create{{pascalCase FEATURE_NAME}}Endpoint : IApiEndpoint
175
+ {
176
+ public void MapEndpoint(IEndpointRouteBuilder app)
177
+ {
178
+ app.MapPost("{{ROUTE}}", async (
179
+ IHandler<Create{{pascalCase FEATURE_NAME}}Request, Result<Create{{pascalCase FEATURE_NAME}}Response>> handler,
180
+ Create{{pascalCase FEATURE_NAME}}Request command,
181
+ CancellationToken cancellationToken) =>
182
+ {
183
+ var result = await handler.HandleAsync(command, cancellationToken);
184
+ return result.Match(
185
+ onSuccess: () => Results.Ok(result.Value),
186
+ onFailure: error => Results.BadRequest(error));
187
+ })
188
+ .WithTags("{{pascalCase FEATURE_NAME}}s")
189
+ .Produces<Create{{pascalCase FEATURE_NAME}}Response>(StatusCodes.Status200OK)
190
+ .Produces(StatusCodes.Status400BadRequest);
191
+ }
192
+ }