@polymorphism-tech/morph-spec 8.34.2 → 8.35.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 (325) hide show
  1. package/CLAUDE.md +20 -3
  2. package/README.md +2 -2
  3. package/bin/morph-spec.js +18 -4
  4. package/bin/validate.js +379 -379
  5. package/claude-plugin.json +1 -1
  6. package/docs/CHEATSHEET.md +5 -4
  7. package/docs/QUICKSTART.md +1 -1
  8. package/framework/MORPH.md +16 -17
  9. package/framework/agents.json +197 -44
  10. package/framework/ai-pin.json +22 -0
  11. package/framework/commands/morph-media.md +45 -0
  12. package/framework/docs/CLI.md +234 -9
  13. package/framework/evals/proof-rubrics/README.md +76 -0
  14. package/framework/evals/proof-rubrics/eval-de-modelo.md +64 -0
  15. package/framework/evals/proof-rubrics/fiacao.md +54 -0
  16. package/framework/evals/proof-rubrics/guard-cego.md +52 -0
  17. package/framework/evals/proof-rubrics/media-claims.md +109 -0
  18. package/framework/evals/proof-rubrics/mutation-proof.md +77 -0
  19. package/framework/evals/proof-rubrics/observabilidade-genai.md +119 -0
  20. package/framework/evals/proof-rubrics/verde-nao-e-coberto.md +48 -0
  21. package/framework/evals/rubrics/architecture.md +30 -0
  22. package/framework/evals/rubrics/code-quality.md +26 -0
  23. package/framework/evals/rubrics/test-coverage.md +20 -0
  24. package/framework/hooks/claude-code/core/protect-spec-files.js +41 -4
  25. package/framework/hooks/claude-code/statusline.sh +11 -11
  26. package/framework/hooks/git/commit-msg/conventional-commits.sh +33 -33
  27. package/framework/hooks/git/pre-commit/agents.sh +25 -25
  28. package/framework/hooks/git/pre-commit/orchestrator.sh +64 -64
  29. package/framework/hooks/git/pre-commit/specs.sh +50 -50
  30. package/framework/hooks/git/pre-push/run-tests.sh +44 -44
  31. package/framework/hooks/shared/e2e-check.js +135 -22
  32. package/framework/hooks/shared/stdin-reader.js +26 -26
  33. package/framework/rules/ai-agents-standards.md +14 -2
  34. package/framework/schemas/ai-pin.schema.json +97 -0
  35. package/framework/schemas/config.schema.json +107 -0
  36. package/framework/schemas/feature.schema.json +23 -4
  37. package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
  38. package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
  39. package/framework/skills/core/morph-apply/SKILL.md +26 -5
  40. package/framework/skills/core/morph-brainstorming/SKILL.md +1 -1
  41. package/framework/skills/core/morph-eval/SKILL.md +1 -1
  42. package/framework/skills/core/morph-hotfix/SKILL.md +2 -2
  43. package/framework/skills/core/morph-implement/SKILL.md +18 -2
  44. package/framework/skills/core/morph-media/SKILL.md +215 -0
  45. package/framework/skills/core/morph-plan/SKILL.md +33 -2
  46. package/framework/skills/core/morph-proposal/SKILL.md +1 -1
  47. package/framework/skills/core/morph-review/SKILL.md +166 -9
  48. package/framework/skills/core/morph-stack-scan/SKILL.md +1 -1
  49. package/framework/skills/core/morph-standards/SKILL.md +1 -1
  50. package/framework/skills/core/morph-uiux/SKILL.md +1 -1
  51. package/framework/standards/PROVENANCE.json +81 -3
  52. package/framework/standards/STANDARDS.json +1483 -839
  53. package/framework/standards/ai-agents/agent-archetypes.md +160 -0
  54. package/framework/standards/ai-agents/agent-session.md +164 -68
  55. package/framework/standards/ai-agents/agent-spec.md +196 -0
  56. package/framework/standards/ai-agents/batching.md +61 -37
  57. package/framework/standards/ai-agents/context-providers.md +97 -24
  58. package/framework/standards/ai-agents/conversational-agent-with-phases.md +239 -0
  59. package/framework/standards/ai-agents/cost-and-budget.md +256 -0
  60. package/framework/standards/ai-agents/durable-workflows-hitl.md +98 -5
  61. package/framework/standards/ai-agents/evals-with-cache.md +289 -0
  62. package/framework/standards/ai-agents/guardrails.md +222 -0
  63. package/framework/standards/ai-agents/llm-runtime-defaults.md +226 -0
  64. package/framework/standards/ai-agents/mcp-server.md +119 -18
  65. package/framework/standards/ai-agents/mcp-tools.md +85 -32
  66. package/framework/standards/ai-agents/media-pipeline.md +352 -0
  67. package/framework/standards/ai-agents/media-video.md +267 -0
  68. package/framework/standards/ai-agents/middleware-patterns.md +39 -5
  69. package/framework/standards/ai-agents/modalities-image-gen.md +354 -105
  70. package/framework/standards/ai-agents/modalities-speech-to-text.md +8 -2
  71. package/framework/standards/ai-agents/modalities-text-to-speech.md +10 -2
  72. package/framework/standards/ai-agents/modalities-vision.md +6 -2
  73. package/framework/standards/ai-agents/multi-agent-patterns.md +61 -5
  74. package/framework/standards/ai-agents/observability-patterns.md +227 -17
  75. package/framework/standards/ai-agents/production.md +38 -9
  76. package/framework/standards/ai-agents/prompt-sources.md +389 -0
  77. package/framework/standards/ai-agents/providers/model-registry.md +174 -39
  78. package/framework/standards/ai-agents/rag-custom-pgvector.md +69 -4
  79. package/framework/standards/ai-agents/service-tier-flex.md +27 -19
  80. package/framework/standards/ai-agents/setup.md +166 -50
  81. package/framework/standards/ai-agents/structured-output.md +34 -3
  82. package/framework/standards/ai-agents/sweet-spot.md +23 -3
  83. package/framework/standards/ai-agents/testing-ai.md +236 -0
  84. package/framework/standards/ai-agents/vector-data-extensions.md +50 -20
  85. package/framework/standards/ai-agents/workflows.md +27 -7
  86. package/framework/standards/frontend/design-system/ai-image-generation.md +12 -0
  87. package/framework/standards/frontend/design-system/ai-video-generation.md +13 -0
  88. package/framework/standards/infrastructure/docker/local-compose-isolation.md +3 -1
  89. package/framework/templates/.idea/morph-templates.xml +92 -0
  90. package/framework/templates/.vscode/morph-templates.code-snippets +186 -0
  91. package/framework/templates/IDE-SNIPPETS.md +262 -262
  92. package/framework/templates/REGISTRY.json +13 -0
  93. package/framework/templates/code/dotnet/abstractions/api-endpoint.cs +7 -7
  94. package/framework/templates/code/dotnet/ai-agents/AgentBootstrap.cs.template +39 -39
  95. package/framework/templates/code/dotnet/ai-agents/EmbeddingService.cs.template +68 -68
  96. package/framework/templates/code/dotnet/ai-agents/ModelRegistry.cs.template +117 -117
  97. package/framework/templates/code/dotnet/ai-agents/PromptRepository.cs.template +1 -1
  98. package/framework/templates/code/dotnet/ai-agents/ResilientToolMiddleware.cs.template +61 -61
  99. package/framework/templates/code/dotnet/ai-agents/VectorSearchTool.cs.template +107 -107
  100. package/framework/templates/code/dotnet/ai-agents/model-registry.json.template +58 -58
  101. package/framework/templates/code/dotnet/contracts/contracts-vsa.cs +281 -281
  102. package/framework/templates/code/dotnet/database/migration.cs +83 -83
  103. package/framework/templates/code/dotnet/feature/endpoint.cs.hbs +21 -21
  104. package/framework/templates/code/dotnet/feature/request.cs.hbs +4 -4
  105. package/framework/templates/code/dotnet/feature/response.cs.hbs +4 -4
  106. package/framework/templates/code/dotnet/feature/validator.cs.hbs +15 -15
  107. package/framework/templates/code/sql/ai-agents/agent-prompts-migration.sql.template +1 -1
  108. package/framework/templates/code/sql/ai-agents/pgvector-embeddings-migration.sql.template +91 -91
  109. package/framework/templates/code/typescript/contracts.ts +167 -167
  110. package/framework/templates/docs/clarifications.md +253 -253
  111. package/framework/templates/docs/schema-analysis.md +119 -119
  112. package/framework/templates/docs/ui-components.md +52 -52
  113. package/framework/templates/docs/ui-design-system.md +76 -76
  114. package/framework/templates/docs/ui-flows.md +167 -167
  115. package/framework/templates/docs/ui-mockups.md +98 -98
  116. package/framework/templates/dotnet/ai-kit/Directory.Build.props +25 -0
  117. package/framework/templates/dotnet/ai-kit/Directory.Packages.props +26 -0
  118. package/framework/templates/dotnet/ai-kit/Morph.AiKit.sln +56 -0
  119. package/framework/templates/dotnet/ai-kit/NuGet.config +12 -0
  120. package/framework/templates/dotnet/ai-kit/README.md +128 -0
  121. package/framework/templates/dotnet/ai-kit/global.json +9 -0
  122. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Agents/AgentApi.cs +65 -0
  123. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Agents/AgentFactory.cs +289 -0
  124. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Agents/AgentFactoryOptions.cs +91 -0
  125. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Agents/AgentSpec.cs +91 -0
  126. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Agents/AgentSpecOptions.cs +181 -0
  127. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/AiKitAssemblyMarker.cs +14 -0
  128. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Conversation/ConversationStore.cs +174 -0
  129. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Conversation/IConversationStore.cs +54 -0
  130. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Conversation/InMemoryConversationStore.cs +75 -0
  131. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/CountingChatClient.cs +71 -0
  132. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalAssertion.cs +246 -0
  133. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalCacheMissException.cs +57 -0
  134. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalCacheOptions.cs +78 -0
  135. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalCacheStamp.cs +225 -0
  136. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalFixture.cs +463 -0
  137. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalMode.cs +32 -0
  138. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalQualityEvaluators.cs +49 -0
  139. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalScenario.cs +214 -0
  140. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalSummary.cs +168 -0
  141. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/OfflineChatClient.cs +142 -0
  142. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/ShortPathResponseCache.cs +349 -0
  143. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/IMediaGenerator.cs +42 -0
  144. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/IMediaProvider.cs +77 -0
  145. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaArtifact.cs +28 -0
  146. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaDisclosure.cs +107 -0
  147. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaGenerator.cs +253 -0
  148. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaIdempotencyKey.cs +103 -0
  149. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaJob.cs +259 -0
  150. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaJobId.cs +21 -0
  151. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaJobState.cs +47 -0
  152. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaPricing.cs +102 -0
  153. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaProvenance.cs +44 -0
  154. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaRequest.cs +192 -0
  155. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaResult.cs +94 -0
  156. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaReview.cs +99 -0
  157. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaSeams.cs +97 -0
  158. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaStore.cs +133 -0
  159. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MorphMedia.cs +93 -0
  160. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/Providers/GoogleImageProvider.cs +112 -0
  161. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/Providers/OpenAIImageProvider.cs +288 -0
  162. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/Providers/VeoVideoProvider.cs +158 -0
  163. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Middleware/IUsageCostSink.cs +29 -0
  164. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Middleware/UsageCostMiddleware.cs +208 -0
  165. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Middleware/UsageCostRecord.cs +95 -0
  166. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Morph.AiKit.csproj +38 -0
  167. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Observability/MorphOpenTelemetryExtensions.cs +119 -0
  168. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Observability/MorphTelemetryOptions.cs +82 -0
  169. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/IProviderClientFactory.cs +33 -0
  170. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/ModelAlias.cs +267 -0
  171. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/ModelRegistry.cs +474 -0
  172. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/model-registry.v2.json +87 -0
  173. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Rag/DeltaIngest.cs +169 -0
  174. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Rag/DeltaPlan.cs +49 -0
  175. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/AgentFactoryTests.cs +495 -0
  176. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/AgentSpecTests.cs +260 -0
  177. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/ConversationStoreTests.cs +405 -0
  178. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/DeltaIngestTests.cs +379 -0
  179. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalAssertionTests.cs +197 -0
  180. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalCacheMissTests.cs +139 -0
  181. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalCacheStampTests.cs +157 -0
  182. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalFailuresTests.cs +178 -0
  183. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalFixtureTests.cs +153 -0
  184. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalRefreshTests.cs +194 -0
  185. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalWorkspace.cs +86 -0
  186. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/KitEvals.cs +213 -0
  187. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/OfflineChatClientTests.cs +95 -0
  188. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeChatClient.cs +225 -0
  189. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeChatClientTests.cs +215 -0
  190. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeClock.cs +33 -0
  191. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeMediaProvider.cs +89 -0
  192. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeProviderClientFactory.cs +55 -0
  193. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeUsageCostSink.cs +60 -0
  194. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/InMemoryMediaStore.cs +131 -0
  195. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaAccessibilityTests.cs +133 -0
  196. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaAliasIsNotAnAgentTests.cs +127 -0
  197. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaDisclosureTests.cs +216 -0
  198. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaGeneratorTests.cs +264 -0
  199. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaIdempotencyKeyTests.cs +148 -0
  200. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaJobStateTests.cs +184 -0
  201. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaReviewTests.cs +89 -0
  202. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaStoreTests.cs +98 -0
  203. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/ModelRegistryTests.cs +451 -0
  204. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Morph.AiKit.Tests.csproj +76 -0
  205. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/SkeletonSmokeTests.cs +33 -0
  206. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/TelemetryTests.cs +261 -0
  207. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/UsageCostMiddlewareTests.cs +374 -0
  208. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-cache/.morph-eval-cache.json +12 -0
  209. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-cache/cache/orcamento.acme.a-resposta-estruturada/1/CF70A7CE27BBD66A/contents.data +13 -0
  210. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-cache/cache/orcamento.acme.a-resposta-estruturada/1/CF70A7CE27BBD66A/entry.json +7 -0
  211. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-cache/cache/triagem.acme.a-saudacao/1/19F631228C6E00BA/contents.data +13 -0
  212. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-cache/cache/triagem.acme.a-saudacao/1/19F631228C6E00BA/entry.json +7 -0
  213. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-cache/cache/triagem.acme.b-escalonamento/1/A24A7C9BDD8239D8/contents.data +13 -0
  214. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-cache/cache/triagem.acme.b-escalonamento/1/A24A7C9BDD8239D8/entry.json +7 -0
  215. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-cache/cache/triagem.globex.a-saudacao/1/E38CD37DF003EDB7/contents.data +13 -0
  216. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-cache/cache/triagem.globex.a-saudacao/1/E38CD37DF003EDB7/entry.json +7 -0
  217. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-datasets/orcamento/acme/a-resposta-estruturada.json +24 -0
  218. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-datasets/triagem/acme/a-saudacao.json +23 -0
  219. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-datasets/triagem/acme/b-escalonamento.json +24 -0
  220. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-datasets/triagem/globex/a-saudacao.json +23 -0
  221. package/framework/templates/feature/decisions.md +122 -122
  222. package/framework/templates/frontend/nextjs/Dockerfile.nextjs.hbs +43 -43
  223. package/framework/templates/frontend/nextjs/client-component.tsx.hbs +26 -26
  224. package/framework/templates/frontend/nextjs/env.mjs.hbs +32 -32
  225. package/framework/templates/frontend/nextjs/feature-form.tsx.hbs +56 -56
  226. package/framework/templates/frontend/nextjs/page.tsx.hbs +22 -22
  227. package/framework/templates/frontend/nextjs/tsconfig.json.hbs +26 -26
  228. package/framework/templates/frontend/nextjs/use-feature.ts.hbs +54 -54
  229. package/framework/templates/infrastructure/docker/Dockerfile.template +58 -58
  230. package/framework/templates/infrastructure/docker/dockerfile-api.dockerfile +38 -38
  231. package/framework/templates/infrastructure/docker/dockerfile-web.dockerfile +48 -48
  232. package/framework/templates/infrastructure/github/README.md +56 -56
  233. package/framework/templates/infrastructure/github/actions/docker-build-push/action.yml.hbs +45 -45
  234. package/framework/templates/infrastructure/github/actions/health-check/action.yml.hbs +27 -27
  235. package/framework/templates/infrastructure/github/workflows/docker-build-push.yml.hbs +59 -59
  236. package/framework/templates/infrastructure/github/workflows/dotnet-build.yml.hbs +39 -39
  237. package/framework/templates/integrations/asaas-client.cs +387 -387
  238. package/framework/templates/integrations/asaas-webhook.cs +351 -351
  239. package/framework/templates/meta-prompts/fusion/fusion-agent.md +76 -76
  240. package/framework/templates/meta-prompts/fusion/fusion-aggregator.md +100 -100
  241. package/framework/templates/meta-prompts/validators/pre-commit-validator.md +95 -95
  242. package/framework/templates/project/validate.js +120 -120
  243. package/framework/templates/state.template.json +17 -17
  244. package/framework/templates/ui/design-system.css +226 -226
  245. package/package.json +3 -3
  246. package/src/commands/dashboard/dashboard.js +53 -53
  247. package/src/commands/e2e/e2e.js +15 -2
  248. package/src/commands/index.js +13 -13
  249. package/src/commands/project/checkpoint.js +209 -209
  250. package/src/commands/project/doctor.js +140 -5
  251. package/src/commands/project/update.js +469 -153
  252. package/src/commands/project/worktree.js +8 -1
  253. package/src/commands/state/advance.js +24 -2
  254. package/src/commands/state/approve.js +33 -1
  255. package/src/commands/state/create.js +72 -11
  256. package/src/commands/state/finish.js +333 -21
  257. package/src/commands/state/gate-check.js +190 -6
  258. package/src/commands/state/score.js +36 -1
  259. package/src/commands/validation/verify.js +134 -25
  260. package/src/core/state/phase-state-machine.js +197 -197
  261. package/src/core/state/state-manager.js +9 -1
  262. package/src/core/templates/template-renderer.js +477 -477
  263. package/src/dashboard/app/components/DetailPanel.jsx +11 -11
  264. package/src/dashboard/app/components/FlowGraph.jsx +17 -17
  265. package/src/dashboard/app/components/SearchFilter.jsx +22 -22
  266. package/src/dashboard/app/hooks/useDetailPanel.js +15 -15
  267. package/src/dashboard/app/main.jsx +13 -13
  268. package/src/dashboard/app/pages/AgentMap.jsx +370 -370
  269. package/src/dashboard/app/pages/PhasePipeline.jsx +408 -408
  270. package/src/dashboard/app/pages/RulesMap.jsx +273 -273
  271. package/src/dashboard/app/pages/SkillsLibrary.jsx +366 -366
  272. package/src/dashboard/app/pages/Standards.jsx +332 -332
  273. package/src/dashboard/app/styles/index.css +47 -47
  274. package/src/dashboard/index.html +12 -12
  275. package/src/dashboard/package.json +24 -24
  276. package/src/dashboard/scanner/phases-scanner.js +15 -15
  277. package/src/dashboard/scanner/rubrics-scanner.js +12 -12
  278. package/src/dashboard/scanner/rules-scanner.js +37 -37
  279. package/src/dashboard/scanner/skills-scanner.js +43 -43
  280. package/src/dashboard/scanner/squads-scanner.js +13 -13
  281. package/src/dashboard/vite-plugin-morph-data.js +17 -17
  282. package/src/dashboard/vite.config.js +24 -24
  283. package/src/lib/ai/ai-checks.js +182 -0
  284. package/src/lib/ai/ai-project-scan.js +347 -0
  285. package/src/lib/ai/code-audit.js +181 -0
  286. package/src/lib/ai/comment-stripper.js +184 -0
  287. package/src/lib/ai/pin-drift.js +138 -0
  288. package/src/lib/ai/registry-audit.js +285 -0
  289. package/src/lib/detectors/design-system-detector.js +188 -188
  290. package/src/lib/detectors/index.js +217 -217
  291. package/src/lib/e2e/compose-env.js +50 -4
  292. package/src/lib/evaluator-report.js +269 -15
  293. package/src/lib/generators/design-system-generator.js +508 -508
  294. package/src/lib/generators/settings-generator.js +209 -209
  295. package/src/lib/git/default-branch.js +92 -4
  296. package/src/lib/hooks/hook-executor.js +167 -167
  297. package/src/lib/installers/effects.js +193 -0
  298. package/src/lib/installers/mcp-installer.js +719 -719
  299. package/src/lib/installers/templates-reconcile.js +3 -3
  300. package/src/lib/risk-detector.js +284 -0
  301. package/src/lib/standards/verified-against.js +276 -0
  302. package/src/lib/tasks/eval-node.js +485 -0
  303. package/src/lib/tasks/linux-runner.js +297 -0
  304. package/src/lib/tasks/task-classifier.js +30 -30
  305. package/src/lib/tasks/task-parser.js +209 -209
  306. package/src/lib/tasks/test-nodes.js +486 -0
  307. package/src/lib/tasks/test-runner.js +410 -33
  308. package/src/lib/validators/checkpoint-persistence.js +39 -39
  309. package/src/lib/validators/css/css-validator.js +340 -340
  310. package/src/lib/validators/shared/emit-validator-dispatch.js +14 -14
  311. package/src/lib/validators/shared/issue-counter.js +14 -14
  312. package/src/lib/validators/verify-runner.js +583 -28
  313. package/src/lib/worktree/docker-audit.js +287 -0
  314. package/src/lib/worktree/env-allocator.js +24 -0
  315. package/src/lib/worktree/worktree-audit.js +30 -1
  316. package/src/scripts/setup-infra.js +24 -11
  317. package/src/utils/agent-id-mapper.js +11 -11
  318. package/src/utils/agents-installer.js +18 -8
  319. package/src/utils/claude-md-injector.js +10 -5
  320. package/src/utils/claude-settings-manager.js +300 -300
  321. package/src/utils/file-copier.js +11 -4
  322. package/src/utils/hooks-installer.js +29 -26
  323. package/src/utils/skills-installer.js +36 -29
  324. package/src/utils/version-checker.js +68 -3
  325. package/framework/standards/ai-agents/prompts-in-db.md +0 -214
@@ -1,33 +1,33 @@
1
- #!/usr/bin/env bash
2
- # Scope: universal | Validates commit message format (Conventional Commits)
3
- # MORPH-SPEC Commit Message Hook
4
- # Enforces Conventional Commits specification
5
-
6
- COMMIT_MSG_FILE="$1"
7
- COMMIT_MSG=$(cat "$COMMIT_MSG_FILE")
8
-
9
- # Conventional Commits pattern: type(scope): description
10
- # Types: feat, fix, docs, style, refactor, perf, test, chore, build, ci, revert
11
- PATTERN="^(feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert)(\(.+\))?: .{1,100}"
12
-
13
- if ! echo "$COMMIT_MSG" | grep -qE "$PATTERN"; then
14
- echo "❌ Invalid commit message format!"
15
- echo ""
16
- echo "Required format: <type>(<scope>): <description>"
17
- echo ""
18
- echo "Types: feat, fix, docs, style, refactor, perf, test, chore, build, ci, revert"
19
- echo ""
20
- echo "Examples:"
21
- echo " feat(auth): add JWT refresh token rotation"
22
- echo " fix(api): resolve null reference in UserService"
23
- echo " docs(readme): update installation instructions"
24
- echo ""
25
- echo "Your message:"
26
- echo " $COMMIT_MSG"
27
- echo ""
28
- echo "Override with: git commit --no-verify"
29
- exit 1
30
- fi
31
-
32
- echo "✅ Commit message format valid"
33
- exit 0
1
+ #!/usr/bin/env bash
2
+ # Scope: universal | Validates commit message format (Conventional Commits)
3
+ # MORPH-SPEC Commit Message Hook
4
+ # Enforces Conventional Commits specification
5
+
6
+ COMMIT_MSG_FILE="$1"
7
+ COMMIT_MSG=$(cat "$COMMIT_MSG_FILE")
8
+
9
+ # Conventional Commits pattern: type(scope): description
10
+ # Types: feat, fix, docs, style, refactor, perf, test, chore, build, ci, revert
11
+ PATTERN="^(feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert)(\(.+\))?: .{1,100}"
12
+
13
+ if ! echo "$COMMIT_MSG" | grep -qE "$PATTERN"; then
14
+ echo "❌ Invalid commit message format!"
15
+ echo ""
16
+ echo "Required format: <type>(<scope>): <description>"
17
+ echo ""
18
+ echo "Types: feat, fix, docs, style, refactor, perf, test, chore, build, ci, revert"
19
+ echo ""
20
+ echo "Examples:"
21
+ echo " feat(auth): add JWT refresh token rotation"
22
+ echo " fix(api): resolve null reference in UserService"
23
+ echo " docs(readme): update installation instructions"
24
+ echo ""
25
+ echo "Your message:"
26
+ echo " $COMMIT_MSG"
27
+ echo ""
28
+ echo "Override with: git commit --no-verify"
29
+ exit 1
30
+ fi
31
+
32
+ echo "✅ Commit message format valid"
33
+ exit 0
@@ -1,25 +1,25 @@
1
- #!/bin/bash
2
- # Scope: universal | Validates agents.json Schema
3
- # MORPH-SPEC Pre-Commit Hook: Agent Configuration Validation
4
- # Uses validate-agents.js to check agents.json
5
-
6
- echo "🤖 Validating agent configuration..."
7
-
8
- # Check if agents.json is being modified
9
- if git diff --cached --name-only | grep -q 'agents\.json$'; then
10
- echo "Detected changes to agents.json"
11
-
12
- # Run validator
13
- if ! morph-spec validate-agents-skills; then
14
- echo ""
15
- echo "❌ COMMIT BLOCKED: agents.json validation failed"
16
- echo " Fix errors above before committing"
17
- exit 1
18
- fi
19
-
20
- echo "✓ agents.json is valid"
21
- else
22
- echo "✓ No changes to agents.json"
23
- fi
24
-
25
- exit 0
1
+ #!/bin/bash
2
+ # Scope: universal | Validates agents.json Schema
3
+ # MORPH-SPEC Pre-Commit Hook: Agent Configuration Validation
4
+ # Uses validate-agents.js to check agents.json
5
+
6
+ echo "🤖 Validating agent configuration..."
7
+
8
+ # Check if agents.json is being modified
9
+ if git diff --cached --name-only | grep -q 'agents\.json$'; then
10
+ echo "Detected changes to agents.json"
11
+
12
+ # Run validator
13
+ if ! morph-spec validate-agents-skills; then
14
+ echo ""
15
+ echo "❌ COMMIT BLOCKED: agents.json validation failed"
16
+ echo " Fix errors above before committing"
17
+ exit 1
18
+ fi
19
+
20
+ echo "✓ agents.json is valid"
21
+ else
22
+ echo "✓ No changes to agents.json"
23
+ fi
24
+
25
+ exit 0
@@ -1,64 +1,64 @@
1
- #!/usr/bin/env bash
2
- # Scope: universal | Orchestrates framework + stack-specific pre-commit hooks
3
- # MORPH-SPEC Master Pre-Commit Hook
4
- # Runs universal framework hooks + stack-specific hooks in sequence
5
-
6
- echo "╔════════════════════════════════════════════════╗"
7
- echo "║ MORPH-SPEC PRE-COMMIT VALIDATION ║"
8
- echo "╚════════════════════════════════════════════════╝"
9
- echo ""
10
-
11
- FRAMEWORK_HOOKS_DIR="$(dirname "$0")"
12
- STACK_HOOKS_DIR=".morph/hooks/pre-commit"
13
-
14
- HAS_FAILURES=false
15
-
16
- # Run framework hooks (universal - all stacks)
17
- echo "📦 Running framework hooks (universal)..."
18
- for hook in "$FRAMEWORK_HOOKS_DIR"/*.sh; do
19
- # Skip orchestrator itself
20
- if [[ "$hook" == */orchestrator.sh ]]; then
21
- continue
22
- fi
23
-
24
- if [[ -f "$hook" ]]; then
25
- hook_name=$(basename "$hook")
26
- echo "─────────────────────────────────────────────────"
27
- if ! bash "$hook"; then
28
- HAS_FAILURES=true
29
- echo "❌ Framework hook failed: $hook_name"
30
- fi
31
- echo ""
32
- fi
33
- done
34
-
35
- # Run stack-specific hooks (if exist)
36
- if [[ -d "$STACK_HOOKS_DIR" ]]; then
37
- echo "🎯 Running stack-specific hooks..."
38
- for hook in "$STACK_HOOKS_DIR"/*.sh; do
39
- if [[ -f "$hook" ]]; then
40
- hook_name=$(basename "$hook")
41
- echo "─────────────────────────────────────────────────"
42
- if ! bash "$hook"; then
43
- HAS_FAILURES=true
44
- echo "❌ Stack hook failed: $hook_name"
45
- fi
46
- echo ""
47
- fi
48
- done
49
- else
50
- echo "ℹ️ No stack-specific hooks found (optional)"
51
- echo ""
52
- fi
53
-
54
- echo "═════════════════════════════════════════════════"
55
-
56
- if [[ "$HAS_FAILURES" == "true" ]]; then
57
- echo "❌ PRE-COMMIT VALIDATION FAILED"
58
- echo " Fix errors above before committing"
59
- echo " Or use: git commit --no-verify to skip"
60
- exit 1
61
- fi
62
-
63
- echo "✅ ALL PRE-COMMIT VALIDATIONS PASSED"
64
- exit 0
1
+ #!/usr/bin/env bash
2
+ # Scope: universal | Orchestrates framework + stack-specific pre-commit hooks
3
+ # MORPH-SPEC Master Pre-Commit Hook
4
+ # Runs universal framework hooks + stack-specific hooks in sequence
5
+
6
+ echo "╔════════════════════════════════════════════════╗"
7
+ echo "║ MORPH-SPEC PRE-COMMIT VALIDATION ║"
8
+ echo "╚════════════════════════════════════════════════╝"
9
+ echo ""
10
+
11
+ FRAMEWORK_HOOKS_DIR="$(dirname "$0")"
12
+ STACK_HOOKS_DIR=".morph/hooks/pre-commit"
13
+
14
+ HAS_FAILURES=false
15
+
16
+ # Run framework hooks (universal - all stacks)
17
+ echo "📦 Running framework hooks (universal)..."
18
+ for hook in "$FRAMEWORK_HOOKS_DIR"/*.sh; do
19
+ # Skip orchestrator itself
20
+ if [[ "$hook" == */orchestrator.sh ]]; then
21
+ continue
22
+ fi
23
+
24
+ if [[ -f "$hook" ]]; then
25
+ hook_name=$(basename "$hook")
26
+ echo "─────────────────────────────────────────────────"
27
+ if ! bash "$hook"; then
28
+ HAS_FAILURES=true
29
+ echo "❌ Framework hook failed: $hook_name"
30
+ fi
31
+ echo ""
32
+ fi
33
+ done
34
+
35
+ # Run stack-specific hooks (if exist)
36
+ if [[ -d "$STACK_HOOKS_DIR" ]]; then
37
+ echo "🎯 Running stack-specific hooks..."
38
+ for hook in "$STACK_HOOKS_DIR"/*.sh; do
39
+ if [[ -f "$hook" ]]; then
40
+ hook_name=$(basename "$hook")
41
+ echo "─────────────────────────────────────────────────"
42
+ if ! bash "$hook"; then
43
+ HAS_FAILURES=true
44
+ echo "❌ Stack hook failed: $hook_name"
45
+ fi
46
+ echo ""
47
+ fi
48
+ done
49
+ else
50
+ echo "ℹ️ No stack-specific hooks found (optional)"
51
+ echo ""
52
+ fi
53
+
54
+ echo "═════════════════════════════════════════════════"
55
+
56
+ if [[ "$HAS_FAILURES" == "true" ]]; then
57
+ echo "❌ PRE-COMMIT VALIDATION FAILED"
58
+ echo " Fix errors above before committing"
59
+ echo " Or use: git commit --no-verify to skip"
60
+ exit 1
61
+ fi
62
+
63
+ echo "✅ ALL PRE-COMMIT VALIDATIONS PASSED"
64
+ exit 0
@@ -1,50 +1,50 @@
1
- #!/bin/bash
2
- # Scope: universal | Validates spec.md required sections
3
- # MORPH-SPEC Pre-Commit Hook: Spec Validation
4
- # Validates that spec.md files have required sections
5
-
6
- echo "🔍 Validating spec files..."
7
-
8
- # Find modified spec.md files
9
- SPEC_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep 'spec\.md$')
10
-
11
- if [ -z "$SPEC_FILES" ]; then
12
- echo "✓ No spec files modified"
13
- exit 0
14
- fi
15
-
16
- HAS_ERRORS=false
17
-
18
- for spec_file in $SPEC_FILES; do
19
- echo "Checking: $spec_file"
20
-
21
- # Required sections
22
- REQUIRED_SECTIONS=(
23
- "## 📋 Metadata"
24
- "## 🎯 Overview"
25
- "## 🏗️ Technical Design"
26
- "## ✅ Acceptance Criteria"
27
- )
28
-
29
- for section in "${REQUIRED_SECTIONS[@]}"; do
30
- if ! grep -q "$section" "$spec_file"; then
31
- echo " ❌ Missing section: $section"
32
- HAS_ERRORS=true
33
- fi
34
- done
35
-
36
- # Check if has at least one user story or requirement
37
- if ! grep -qi "user story\|requirement\|acceptance criteria" "$spec_file"; then
38
- echo " ⚠️ Warning: No user stories or requirements found"
39
- fi
40
- done
41
-
42
- if [ "$HAS_ERRORS" = true ]; then
43
- echo ""
44
- echo "❌ COMMIT BLOCKED: spec.md files are incomplete"
45
- echo " Add missing sections before committing"
46
- exit 1
47
- fi
48
-
49
- echo "✓ All spec files are valid"
50
- exit 0
1
+ #!/bin/bash
2
+ # Scope: universal | Validates spec.md required sections
3
+ # MORPH-SPEC Pre-Commit Hook: Spec Validation
4
+ # Validates that spec.md files have required sections
5
+
6
+ echo "🔍 Validating spec files..."
7
+
8
+ # Find modified spec.md files
9
+ SPEC_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep 'spec\.md$')
10
+
11
+ if [ -z "$SPEC_FILES" ]; then
12
+ echo "✓ No spec files modified"
13
+ exit 0
14
+ fi
15
+
16
+ HAS_ERRORS=false
17
+
18
+ for spec_file in $SPEC_FILES; do
19
+ echo "Checking: $spec_file"
20
+
21
+ # Required sections
22
+ REQUIRED_SECTIONS=(
23
+ "## 📋 Metadata"
24
+ "## 🎯 Overview"
25
+ "## 🏗️ Technical Design"
26
+ "## ✅ Acceptance Criteria"
27
+ )
28
+
29
+ for section in "${REQUIRED_SECTIONS[@]}"; do
30
+ if ! grep -q "$section" "$spec_file"; then
31
+ echo " ❌ Missing section: $section"
32
+ HAS_ERRORS=true
33
+ fi
34
+ done
35
+
36
+ # Check if has at least one user story or requirement
37
+ if ! grep -qi "user story\|requirement\|acceptance criteria" "$spec_file"; then
38
+ echo " ⚠️ Warning: No user stories or requirements found"
39
+ fi
40
+ done
41
+
42
+ if [ "$HAS_ERRORS" = true ]; then
43
+ echo ""
44
+ echo "❌ COMMIT BLOCKED: spec.md files are incomplete"
45
+ echo " Add missing sections before committing"
46
+ exit 1
47
+ fi
48
+
49
+ echo "✓ All spec files are valid"
50
+ exit 0
@@ -1,44 +1,44 @@
1
- #!/usr/bin/env bash
2
- # Scope: universal | Runs test suite before push
3
- # MORPH-SPEC Pre-Push Hook
4
- # Ensures all tests pass before pushing to remote
5
-
6
- echo "🧪 Running test suite before push..."
7
- echo ""
8
-
9
- # Detect project type and run appropriate tests
10
- if [[ -f *.csproj ]] || find . -maxdepth 2 -name "*.csproj" 2>/dev/null | grep -q .; then
11
- # .NET project detected
12
- echo "📦 Detected .NET project"
13
-
14
- if ! dotnet test --verbosity minimal --no-build --no-restore 2>/dev/null; then
15
- echo ""
16
- echo "❌ .NET tests failed!"
17
- echo ""
18
- echo "Fix failing tests before pushing."
19
- echo "Override with: git push --no-verify"
20
- exit 1
21
- fi
22
-
23
- elif [[ -f package.json ]]; then
24
- # Node.js project detected
25
- echo "📦 Detected Node.js project"
26
-
27
- if ! npm test 2>/dev/null; then
28
- echo ""
29
- echo "❌ Node.js tests failed!"
30
- echo ""
31
- echo "Fix failing tests before pushing."
32
- echo "Override with: git push --no-verify"
33
- exit 1
34
- fi
35
-
36
- else
37
- echo "⚠️ No recognized test framework found"
38
- echo " Skipping test execution"
39
- exit 0
40
- fi
41
-
42
- echo ""
43
- echo "✅ All tests passed - safe to push"
44
- exit 0
1
+ #!/usr/bin/env bash
2
+ # Scope: universal | Runs test suite before push
3
+ # MORPH-SPEC Pre-Push Hook
4
+ # Ensures all tests pass before pushing to remote
5
+
6
+ echo "🧪 Running test suite before push..."
7
+ echo ""
8
+
9
+ # Detect project type and run appropriate tests
10
+ if [[ -f *.csproj ]] || find . -maxdepth 2 -name "*.csproj" 2>/dev/null | grep -q .; then
11
+ # .NET project detected
12
+ echo "📦 Detected .NET project"
13
+
14
+ if ! dotnet test --verbosity minimal --no-build --no-restore 2>/dev/null; then
15
+ echo ""
16
+ echo "❌ .NET tests failed!"
17
+ echo ""
18
+ echo "Fix failing tests before pushing."
19
+ echo "Override with: git push --no-verify"
20
+ exit 1
21
+ fi
22
+
23
+ elif [[ -f package.json ]]; then
24
+ # Node.js project detected
25
+ echo "📦 Detected Node.js project"
26
+
27
+ if ! npm test 2>/dev/null; then
28
+ echo ""
29
+ echo "❌ Node.js tests failed!"
30
+ echo ""
31
+ echo "Fix failing tests before pushing."
32
+ echo "Override with: git push --no-verify"
33
+ exit 1
34
+ fi
35
+
36
+ else
37
+ echo "⚠️ No recognized test framework found"
38
+ echo " Skipping test execution"
39
+ exit 0
40
+ fi
41
+
42
+ echo ""
43
+ echo "✅ All tests passed - safe to push"
44
+ exit 0
@@ -322,10 +322,29 @@ export function deleteStamp(gitCommonDir, projectName) {
322
322
  /**
323
323
  * Does this stack serve the working tree directly?
324
324
  *
325
- * A service that bind-mounts the project into the container reads source from
326
- * disk on every request, so a rebuild can never make it fresher — it is
327
- * already serving whatever is on disk. This is the ONE case where reuse is
328
- * unconditionally safe.
325
+ * The question is right; the answer used to be wrong. The predicate used to be
326
+ * "does ANY service mount ANYTHING under cwd" — which a Playwright sidecar
327
+ * mounting `./e2e` answers yes to. `decideReuse()` then short-circuited BEFORE
328
+ * the stamp comparison and printed "source is bind-mounted" about a stack whose
329
+ * application is a compiled image: a true statement about the sidecar, used as
330
+ * a false statement about the code under test, and the stamp — the only real
331
+ * proof of freshness — never got a say.
332
+ *
333
+ * The honest predicate looks only at services that are BUILT here, because only
334
+ * those carry code a rebuild could refresh:
335
+ *
336
+ * - no service declares `build:` → false. Nothing is compiled from this
337
+ * tree, so "a rebuild cannot make it fresher" says nothing about it, and
338
+ * the stamp decides.
339
+ * - EVERY built service mounts the project ROOT → true. Each reads source
340
+ * from disk on every request, so a running stack is current by
341
+ * construction — the ONE case where reuse is unconditionally safe.
342
+ * - anything else → false. One built service serving an image is one service
343
+ * that can be stale.
344
+ *
345
+ * A subdirectory mount is deliberately not enough: a service that mounts only
346
+ * `./e2e` still runs whatever was baked into its image. Uncertainty answers
347
+ * false, which costs one cheap layer-cached rebuild — see bringUpStack().
329
348
  *
330
349
  * @param {object} composeConfig - parsed `docker compose config --format json`
331
350
  * @param {string} cwd
@@ -335,18 +354,46 @@ export function usesBindMount(composeConfig, cwd) {
335
354
  const services = composeConfig?.services;
336
355
  if (!services || typeof services !== 'object') return false;
337
356
 
338
- const normalizedCwd = cwd.replace(/\\/g, '/').replace(/\/+$/, '');
339
-
340
- return Object.values(services).some((service) => {
341
- const volumes = Array.isArray(service?.volumes) ? service.volumes : [];
342
- return volumes.some((vol) => {
343
- // Long syntax: { type: 'bind', source: '...' }. Short syntax is a string
344
- // "src:dst" that compose has already expanded to an absolute path.
345
- const source = typeof vol === 'string' ? vol.split(':')[0] : vol?.source;
346
- if (!source) return false;
347
- const normalized = String(source).replace(/\\/g, '/').replace(/\/+$/, '');
348
- return normalized === normalizedCwd || normalized.startsWith(`${normalizedCwd}/`);
349
- });
357
+ const normalizedCwd = normalizeMountPath(cwd);
358
+ const built = Object.values(services).filter(
359
+ (service) => service && service.build !== undefined && service.build !== null,
360
+ );
361
+ if (built.length === 0) return false;
362
+
363
+ return built.every((service) => mountsProjectRoot(service, normalizedCwd));
364
+ }
365
+
366
+ /** One spelling per path, so two spellings of the same directory compare equal. */
367
+ function normalizeMountPath(path) {
368
+ return String(path ?? '')
369
+ .replace(/\\/g, '/')
370
+ .replace(/\/+$/, '');
371
+ }
372
+
373
+ /**
374
+ * Source half of a short-syntax volume ("src:dst[:mode]").
375
+ *
376
+ * Splitting on the FIRST ':' loses on Windows, where compose expands the source
377
+ * to `C:\path`. The target is always an absolute container path, so anchoring on
378
+ * the ':' that precedes it is the split that survives both platforms.
379
+ */
380
+ function shortVolumeSource(spec) {
381
+ const match = /^(.+):(\/[^:]*)(:[A-Za-z,]+)?$/.exec(spec);
382
+ return match ? match[1] : null;
383
+ }
384
+
385
+ /**
386
+ * Does this service bind-mount the project ROOT? A subdirectory does not count:
387
+ * only the root makes the whole service read its code from disk.
388
+ */
389
+ function mountsProjectRoot(service, normalizedCwd) {
390
+ const volumes = Array.isArray(service?.volumes) ? service.volumes : [];
391
+ return volumes.some((vol) => {
392
+ // Long syntax: { type: 'bind', source: '...' }; short syntax is a string.
393
+ if (typeof vol !== 'string' && vol?.type && vol.type !== 'bind') return false;
394
+ const source = typeof vol === 'string' ? shortVolumeSource(vol) : vol?.source;
395
+ if (!source) return false;
396
+ return normalizeMountPath(source) === normalizedCwd;
350
397
  });
351
398
  }
352
399
 
@@ -513,6 +560,19 @@ export function bringUpStack(
513
560
  return { status: 'pass', reused: true, output: '', reason: decision.reason };
514
561
  }
515
562
 
563
+ // "Fresh" is a promise about the DATA, not only about the image. Adding
564
+ // `--build` alone rebuilds the container and leaves the postgres volume
565
+ // standing, so the next suite talks to the previous run's database — the
566
+ // stale rows survive the very flag asked to get rid of them. The named
567
+ // volumes go first, and the stamp goes with them: a stamp that outlives the
568
+ // stack it described would let the next `up` reuse something that no longer
569
+ // exists. Teardown is best-effort by construction (tearDownStack never
570
+ // throws), so a stack that was not up costs nothing here.
571
+ if (forceFresh) {
572
+ tearDownStack(cwd, { composeFile, projectName, env, volumes: true }, exec);
573
+ deleteStamp(gitCommonDir, projectName);
574
+ }
575
+
516
576
  const upArgs = [...base, 'up', '-d', '--wait'];
517
577
  if (decision.rebuild) upArgs.push('--build');
518
578
 
@@ -555,7 +615,11 @@ function decideReuse({ cwd, base, env, stamp, status, gitCommonDir, projectName,
555
615
  if (!status.up || !status.healthy) return { reuse: false, rebuild: true };
556
616
 
557
617
  // Bind-mounted source is served from disk, so a running stack is current by
558
- // construction — the only unconditionally safe reuse.
618
+ // construction — the only unconditionally safe reuse. usesBindMount() answers
619
+ // this for the services that are BUILT here; when it says no, control falls
620
+ // through to the stamp, which is the real proof. The two reasons below stay
621
+ // distinct on purpose: whoever reads "reused warm stack" has to be able to
622
+ // tell which fact bought the reuse.
559
623
  const configJson = exec('docker', [...base, 'config', '--format', 'json'], { cwd, env });
560
624
  if (configJson.code === 0) {
561
625
  try {
@@ -666,13 +730,37 @@ export function loadEnvFile(path) {
666
730
  * screen would quietly end up with no e2e at all. Missing auth CONFIG is a
667
731
  * planning gap (Gate 2); broken auth at runtime is a real failure.
668
732
  *
669
- * @returns {{ status: 'pass'|'fail'|'skip', reason: string|null }}
733
+ * The same rule applied one level up is why `warning` exists: a config that
734
+ * declares `seedCommand` but leaves `mode` absent (or "none") used to return
735
+ * `skip` on the first line and run nothing at all. The seed was configured, the
736
+ * code knew how to execute it, and `mode` switched it off without a word — the
737
+ * silence is what made a working seedCommand look like dead configuration.
738
+ *
739
+ * @param {object} [options]
740
+ * @param {boolean} [options.forceSeed] - `--fresh-e2e`: the database was just
741
+ * dropped, so a storageState captured against it is a session for rows that
742
+ * no longer exist. Refuses the "file exists → reuse" shortcut.
743
+ * @returns {{ status: 'pass'|'fail'|'skip', reason: string|null, warning?: string }}
670
744
  */
671
- export function prepareAuth(cwd, { config, env, timeout = 60_000 } = {}, exec = defaultExec) {
745
+ export function prepareAuth(
746
+ cwd,
747
+ { config, env, timeout = 60_000, forceSeed = false } = {},
748
+ exec = defaultExec,
749
+ ) {
672
750
  const auth = config?.e2e?.auth;
673
751
  const mode = auth?.mode ?? 'none';
674
752
 
675
753
  if (mode === 'none') {
754
+ if (auth?.seedCommand) {
755
+ const declared = auth.mode == null ? 'absent' : `"${auth.mode}"`;
756
+ return {
757
+ status: 'skip',
758
+ reason: null,
759
+ warning:
760
+ `e2e.auth.seedCommand is configured but e2e.auth.mode is ${declared} — ` +
761
+ 'the seed never runs (set e2e.auth.mode to "seed" or "storageState")',
762
+ };
763
+ }
676
764
  return { status: 'skip', reason: null };
677
765
  }
678
766
 
@@ -685,10 +773,25 @@ export function prepareAuth(cwd, { config, env, timeout = 60_000 } = {}, exec =
685
773
  const statePath = auth.storageStatePath
686
774
  ? join(cwd, auth.storageStatePath)
687
775
  : null;
688
- if (statePath && existsSync(statePath)) {
776
+ const stateExists = Boolean(statePath && existsSync(statePath));
777
+
778
+ // The file's existence is not its freshness. After `--fresh-e2e` dropped
779
+ // the volumes, a storageState captured against the old database
780
+ // authenticates a user that is no longer there: every request comes back
781
+ // 403 and the failure looks like a broken app. forceSeed refuses the
782
+ // shortcut and re-establishes the session against the new database.
783
+ if (stateExists && !forceSeed) {
689
784
  return { status: 'pass', reason: 'reused stored auth session' };
690
785
  }
691
786
  if (!auth.seedCommand) {
787
+ if (stateExists) {
788
+ // Nothing to refresh it with — reusing is the only option left, and
789
+ // saying so is the difference between a reuse and a silent one.
790
+ return {
791
+ status: 'pass',
792
+ reason: 'reused stored auth session (no e2e.auth.seedCommand to refresh it)',
793
+ };
794
+ }
692
795
  return {
693
796
  status: 'fail',
694
797
  reason:
@@ -715,7 +818,12 @@ export function prepareAuth(cwd, { config, env, timeout = 60_000 } = {}, exec =
715
818
  reason: `e2e auth setup failed (${auth.seedCommand}): ${firstLine(result.output)}`,
716
819
  };
717
820
  }
718
- return { status: 'pass', reason: 'auth seeded for the e2e environment' };
821
+ return {
822
+ status: 'pass',
823
+ reason: forceSeed
824
+ ? 'auth re-seeded against the fresh stack'
825
+ : 'auth seeded for the e2e environment',
826
+ };
719
827
  }
720
828
 
721
829
  // ============================================================================
@@ -818,7 +926,12 @@ export function runE2eCheck(cwd, options = {}) {
818
926
  }
819
927
 
820
928
  try {
821
- const auth = prepareAuth(cwd, { config, env: composeEnv }, exec);
929
+ // forceSeed rides on forceFresh: the same flag that dropped the database is
930
+ // the one that invalidates any session captured against it.
931
+ const auth = prepareAuth(cwd, { config, env: composeEnv, forceSeed: forceFresh }, exec);
932
+ // A configured seed that never runs is a finding, not a detail — it travels
933
+ // to warnings[] so verify turns it into a "[e2e] warning: …" feedback line.
934
+ if (auth.warning) warnings.push(auth.warning);
822
935
  if (auth.status === 'fail') {
823
936
  return { status: 'fail', command: null, output: '', reason: auth.reason, warnings };
824
937
  }