@polymorphism-tech/morph-spec 8.28.0 → 8.31.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 (185) hide show
  1. package/CLAUDE.md +6 -1
  2. package/README.md +13 -2
  3. package/bin/morph-spec.js +48 -0
  4. package/bin/validate.js +379 -379
  5. package/claude-plugin.json +1 -1
  6. package/docs/CHEATSHEET.md +1 -1
  7. package/docs/QUICKSTART.md +1 -1
  8. package/framework/CLAUDE.md +2 -0
  9. package/framework/MORPH.md +2 -1
  10. package/framework/agents.json +20 -9
  11. package/framework/commands/create-umbraco-lp.md +1 -1
  12. package/framework/commands/morph-status.md +1 -1
  13. package/framework/docs/CLI.md +18 -0
  14. package/framework/evals/rubrics/code-quality.md +17 -0
  15. package/framework/evals/rubrics/condensed.md +3 -1
  16. package/framework/hooks/claude-code/statusline.sh +11 -11
  17. package/framework/hooks/git/commit-msg/conventional-commits.sh +33 -33
  18. package/framework/hooks/git/pre-commit/agents.sh +25 -25
  19. package/framework/hooks/git/pre-commit/orchestrator.sh +64 -64
  20. package/framework/hooks/git/pre-commit/specs.sh +50 -50
  21. package/framework/hooks/git/pre-push/run-tests.sh +44 -44
  22. package/framework/hooks/shared/phase-utils.js +2 -0
  23. package/framework/hooks/shared/stdin-reader.js +26 -26
  24. package/framework/mcp/registry.json +97 -11
  25. package/framework/rubrics/backend.json +2 -2
  26. package/framework/rubrics/default.json +2 -2
  27. package/framework/rubrics/frontend.json +2 -2
  28. package/framework/schemas/tasks.schema.json +25 -0
  29. package/framework/skills/core/create-umbraco-lp/SKILL.md +13 -2
  30. package/framework/skills/core/create-umbraco-lp/references/umbraco-lp-patterns.md +598 -0
  31. package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +92 -7
  32. package/framework/skills/core/morph-apply/SKILL.md +12 -3
  33. package/framework/skills/core/morph-brainstorming/SKILL.md +1 -1
  34. package/framework/skills/core/morph-eval/SKILL.md +1 -1
  35. package/framework/skills/core/morph-hotfix/SKILL.md +1 -1
  36. package/framework/skills/core/morph-implement/SKILL.md +12 -2
  37. package/framework/skills/core/morph-plan/SKILL.md +45 -3
  38. package/framework/skills/core/morph-proposal/SKILL.md +1 -1
  39. package/framework/skills/core/morph-review/SKILL.md +11 -3
  40. package/framework/skills/core/morph-stack-scan/SKILL.md +13 -1
  41. package/framework/skills/core/morph-standards/SKILL.md +1 -1
  42. package/framework/skills/core/morph-uiux/SKILL.md +1 -1
  43. package/framework/standards/PROVENANCE.json +41 -0
  44. package/framework/standards/STANDARDS.json +218 -7
  45. package/framework/standards/ai-agents/agent-session.md +160 -160
  46. package/framework/standards/ai-agents/batching.md +193 -193
  47. package/framework/standards/ai-agents/context-providers.md +188 -188
  48. package/framework/standards/ai-agents/mcp-server.md +250 -250
  49. package/framework/standards/ai-agents/mcp-tools.md +197 -197
  50. package/framework/standards/ai-agents/middleware-patterns.md +207 -207
  51. package/framework/standards/ai-agents/modalities-image-gen.md +173 -173
  52. package/framework/standards/ai-agents/modalities-speech-to-text.md +171 -171
  53. package/framework/standards/ai-agents/modalities-text-to-speech.md +181 -181
  54. package/framework/standards/ai-agents/modalities-vision.md +201 -201
  55. package/framework/standards/ai-agents/multi-agent-patterns.md +155 -155
  56. package/framework/standards/ai-agents/production.md +231 -231
  57. package/framework/standards/ai-agents/prompts-in-db.md +214 -214
  58. package/framework/standards/ai-agents/providers/model-registry.md +158 -158
  59. package/framework/standards/ai-agents/service-tier-flex.md +135 -135
  60. package/framework/standards/ai-agents/structured-output.md +249 -249
  61. package/framework/standards/ai-agents/sweet-spot.md +109 -109
  62. package/framework/standards/frontend/design-system/ai-image-generation.md +43 -0
  63. package/framework/standards/frontend/design-system/ai-video-generation.md +113 -0
  64. package/framework/standards/frontend/design-system/premium-finish.md +160 -0
  65. package/framework/standards/frontend/gsap/gsap-core.md +1 -1
  66. package/framework/standards/frontend/gsap/gsap-plugins.md +1 -1
  67. package/framework/standards/frontend/gsap/gsap-scrolltrigger.md +3 -1
  68. package/framework/standards/frontend/nextjs/motion-patterns.md +3 -1
  69. package/framework/standards/frontend/scroll-driven/frame-scrub.md +287 -0
  70. package/framework/standards/frontend/scroll-driven/scroll-components.md +256 -0
  71. package/framework/standards/frontend/scroll-driven/smooth-scroll.md +148 -0
  72. package/framework/standards/frontend/seo/meta-schema-audit.md +134 -0
  73. package/framework/templates/.idea/morph-templates.xml +92 -0
  74. package/framework/templates/.vscode/morph-templates.code-snippets +186 -0
  75. package/framework/templates/IDE-SNIPPETS.md +262 -262
  76. package/framework/templates/code/dotnet/abstractions/api-endpoint.cs +7 -7
  77. package/framework/templates/code/dotnet/ai-agents/AgentBootstrap.cs.template +39 -39
  78. package/framework/templates/code/dotnet/ai-agents/EmbeddingService.cs.template +68 -68
  79. package/framework/templates/code/dotnet/ai-agents/ModelRegistry.cs.template +117 -117
  80. package/framework/templates/code/dotnet/ai-agents/PromptRepository.cs.template +95 -95
  81. package/framework/templates/code/dotnet/ai-agents/ResilientToolMiddleware.cs.template +61 -61
  82. package/framework/templates/code/dotnet/ai-agents/VectorSearchTool.cs.template +107 -107
  83. package/framework/templates/code/dotnet/ai-agents/model-registry.json.template +58 -58
  84. package/framework/templates/code/dotnet/contracts/contracts-vsa.cs +281 -281
  85. package/framework/templates/code/dotnet/database/migration.cs +83 -83
  86. package/framework/templates/code/dotnet/feature/endpoint.cs.hbs +21 -21
  87. package/framework/templates/code/dotnet/feature/request.cs.hbs +4 -4
  88. package/framework/templates/code/dotnet/feature/response.cs.hbs +4 -4
  89. package/framework/templates/code/dotnet/feature/validator.cs.hbs +15 -15
  90. package/framework/templates/code/sql/ai-agents/agent-prompts-migration.sql.template +58 -58
  91. package/framework/templates/code/sql/ai-agents/pgvector-embeddings-migration.sql.template +91 -91
  92. package/framework/templates/code/typescript/contracts.ts +167 -167
  93. package/framework/templates/context/ARCHITECTURE.md +20 -0
  94. package/framework/templates/docs/clarifications.md +253 -253
  95. package/framework/templates/docs/schema-analysis.md +119 -119
  96. package/framework/templates/docs/ui-components.md +52 -52
  97. package/framework/templates/docs/ui-design-system.md +76 -76
  98. package/framework/templates/docs/ui-flows.md +167 -167
  99. package/framework/templates/docs/ui-mockups.md +98 -98
  100. package/framework/templates/feature/decisions.md +122 -122
  101. package/framework/templates/frontend/nextjs/Dockerfile.nextjs.hbs +43 -43
  102. package/framework/templates/frontend/nextjs/client-component.tsx.hbs +26 -26
  103. package/framework/templates/frontend/nextjs/env.mjs.hbs +32 -32
  104. package/framework/templates/frontend/nextjs/feature-form.tsx.hbs +56 -56
  105. package/framework/templates/frontend/nextjs/page.tsx.hbs +22 -22
  106. package/framework/templates/frontend/nextjs/tsconfig.json.hbs +26 -26
  107. package/framework/templates/frontend/nextjs/use-feature.ts.hbs +54 -54
  108. package/framework/templates/infrastructure/docker/Dockerfile.template +58 -58
  109. package/framework/templates/infrastructure/docker/dockerfile-api.dockerfile +38 -38
  110. package/framework/templates/infrastructure/docker/dockerfile-web.dockerfile +48 -48
  111. package/framework/templates/infrastructure/github/README.md +56 -56
  112. package/framework/templates/infrastructure/github/actions/docker-build-push/action.yml.hbs +45 -45
  113. package/framework/templates/infrastructure/github/actions/health-check/action.yml.hbs +27 -27
  114. package/framework/templates/infrastructure/github/workflows/docker-build-push.yml.hbs +59 -59
  115. package/framework/templates/infrastructure/github/workflows/dotnet-build.yml.hbs +39 -39
  116. package/framework/templates/integrations/asaas-client.cs +387 -387
  117. package/framework/templates/integrations/asaas-webhook.cs +351 -351
  118. package/framework/templates/meta-prompts/fusion/fusion-agent.md +76 -76
  119. package/framework/templates/meta-prompts/fusion/fusion-aggregator.md +100 -100
  120. package/framework/templates/meta-prompts/validators/pre-commit-validator.md +95 -95
  121. package/framework/templates/project/validate.js +120 -120
  122. package/framework/templates/state.template.json +17 -17
  123. package/framework/templates/ui/design-system.css +226 -226
  124. package/package.json +1 -1
  125. package/src/commands/dashboard/dashboard.js +53 -53
  126. package/src/commands/graph/affected.js +89 -0
  127. package/src/commands/graph/build.js +94 -0
  128. package/src/commands/graph/explain.js +96 -0
  129. package/src/commands/graph/status.js +93 -0
  130. package/src/commands/index.js +13 -13
  131. package/src/commands/project/checkpoint.js +209 -209
  132. package/src/commands/project/doctor.js +11 -0
  133. package/src/core/paths/output-schema.js +7 -0
  134. package/src/core/state/phase-state-machine.js +197 -197
  135. package/src/core/templates/template-renderer.js +477 -477
  136. package/src/dashboard/app/components/DetailPanel.jsx +11 -11
  137. package/src/dashboard/app/components/FlowGraph.jsx +17 -17
  138. package/src/dashboard/app/components/SearchFilter.jsx +22 -22
  139. package/src/dashboard/app/hooks/useDetailPanel.js +15 -15
  140. package/src/dashboard/app/main.jsx +13 -13
  141. package/src/dashboard/app/pages/AgentMap.jsx +370 -370
  142. package/src/dashboard/app/pages/HookInspector.jsx +418 -418
  143. package/src/dashboard/app/pages/PhasePipeline.jsx +408 -408
  144. package/src/dashboard/app/pages/RulesMap.jsx +273 -273
  145. package/src/dashboard/app/pages/SkillsLibrary.jsx +366 -366
  146. package/src/dashboard/app/pages/Standards.jsx +332 -332
  147. package/src/dashboard/app/styles/index.css +47 -47
  148. package/src/dashboard/index.html +12 -12
  149. package/src/dashboard/package.json +24 -24
  150. package/src/dashboard/scanner/phases-scanner.js +15 -15
  151. package/src/dashboard/scanner/rubrics-scanner.js +12 -12
  152. package/src/dashboard/scanner/rules-scanner.js +37 -37
  153. package/src/dashboard/scanner/skills-scanner.js +43 -43
  154. package/src/dashboard/scanner/squads-scanner.js +13 -13
  155. package/src/dashboard/vite-plugin-morph-data.js +17 -17
  156. package/src/dashboard/vite.config.js +24 -24
  157. package/src/lib/detectors/design-system-detector.js +188 -188
  158. package/src/lib/detectors/index.js +217 -217
  159. package/src/lib/generators/architecture-scanner.js +45 -4
  160. package/src/lib/generators/design-system-generator.js +508 -508
  161. package/src/lib/generators/settings-generator.js +209 -209
  162. package/src/lib/graph/god-nodes.js +75 -0
  163. package/src/lib/graph/graph-health.js +61 -0
  164. package/src/lib/graph/graph-loader.js +86 -0
  165. package/src/lib/graph/graphify-runtime.js +100 -0
  166. package/src/lib/graph/graphifyignore.js +86 -0
  167. package/src/lib/graph/sanitize.js +280 -0
  168. package/src/lib/hooks/hook-executor.js +167 -167
  169. package/src/lib/installers/mcp-installer.js +719 -719
  170. package/src/lib/tasks/task-classifier.js +30 -30
  171. package/src/lib/tasks/task-parser.js +209 -209
  172. package/src/lib/tasks/tasks-json-parser.js +26 -0
  173. package/src/lib/validators/checkpoint-persistence.js +39 -39
  174. package/src/lib/validators/css/css-validator.js +340 -340
  175. package/src/lib/validators/reuse/index.js +10 -0
  176. package/src/lib/validators/reuse/reuse-validator.js +324 -0
  177. package/src/lib/validators/reuse/symbol-scanner.js +144 -0
  178. package/src/lib/validators/shared/emit-validator-dispatch.js +14 -14
  179. package/src/lib/validators/shared/issue-counter.js +14 -14
  180. package/src/lib/validators/validation-runner.js +40 -1
  181. package/src/scripts/setup-infra.js +60 -1
  182. package/src/utils/agent-id-mapper.js +11 -11
  183. package/src/utils/claude-settings-manager.js +300 -300
  184. package/src/utils/file-copier.js +40 -0
  185. package/src/utils/skills-installer.js +187 -187
@@ -1,109 +1,109 @@
1
- # Sweet Spot — When to use what in MAF
2
-
3
- > **Scope:** stacks=["dotnet"]
4
- > **Layer:** 0 (always-load via persona maf-expert)
5
- > **Keywords:** sweet spot, when to use agent, agent vs workflow, when not to use workflow, MAF decision, simple agent
6
- > **Read by Claude in:** plan (decide arquitetura da feature antes de quebrar em tasks) + implement (validar que a arquitetura ainda é a mais simples possível)
7
-
8
- **Verified against:** MAF Tier List research (2026-05-18) + Microsoft Learn docs. Last-verified: 2026-05-19.
9
-
10
- ---
11
-
12
- ## The 4-feature rule
13
-
14
- ```
15
- 95% of production AI agents need ONLY:
16
-
17
- 1. Chat (the LLM call)
18
- 2. Structured Output (typed records, not free text)
19
- 3. Tools (typed functions the agent can call)
20
- 4. RAG Custom (pgvector tool, not hosted RAG)
21
-
22
- If your feature needs ONLY these 4 → use a single agent. Don't reach for workflows.
23
- ```
24
-
25
- Apply this rule before deciding multi-agent or workflow. Most of the time the answer is "single agent".
26
-
27
- ---
28
-
29
- ## Decision tree (Claude reads this in plan phase)
30
-
31
- ```
32
- Step 1 — Does the task even need an LLM?
33
- ├─ "Can a deterministic function solve this?" → YES → write the function, no agent
34
- └─ NO → continue
35
-
36
- Step 2 — Single agent vs multi-agent?
37
- ├─ One topic + one decision → single agent (DEFAULT)
38
- ├─ Multiple specialized topics with clear handoff → multi-agent
39
- │ └─ Prefer Agent-as-Tool pattern (one agent uses another as a tool)
40
- │ └─ See ai-agents-multi-agent-patterns
41
- └─ "I'm not sure" → start with single agent, escalate if needed
42
-
43
- Step 3 — Need a Workflow?
44
- ├─ The feature has fan-in/out (many inputs aggregated) → maybe workflow
45
- │ └─ Confirm: can you write it as a foreach + LINQ aggregate?
46
- │ └─ YES → write the foreach, NO workflow
47
- │ └─ NO → workflow may help
48
- ├─ Long-running with human-in-the-loop checkpoints → maybe workflow
49
- │ └─ See ai-agents-workflows (Onda 2)
50
- └─ Otherwise → NO workflow
51
-
52
- Step 4 — Which provider?
53
- ├─ ALWAYS direct models — never a hosted agent service
54
- ├─ Provider choice (OpenAI / Google / Anthropic / Ollama) lives in the
55
- │ project's Model Registry, not hardcoded → see ai-agents-providers-model-registry
56
- └─ Hosted services (Foundry Agent Service, Vertex AI hosted) → NOT used
57
-
58
- Step 5 — RAG approach?
59
- ├─ Need control over chunking/embedding/storage? → RAG custom (pgvector)
60
- │ └─ See ai-agents-rag-custom-pgvector (Onda 2)
61
- └─ Don't reach for hosted RAG — loses control
62
- ```
63
-
64
- ---
65
-
66
- ## Anti-patterns (what Claude should NOT do)
67
-
68
- | Anti-pattern | Why it's wrong | What to do instead |
69
- |--------------|----------------|---------------------|
70
- | Reach for Workflow when a function does the job | "Tudo que Workflows fazem, código C# normal faz com menos complexidade" — pesquisa | Write the function. Wrap in a tool if an agent needs to call it. |
71
- | Use a hosted agent service | Hosted is "always 6-9 months behind" on models + removes control | Direct models always (OpenAI / Google / Anthropic / Ollama) |
72
- | Upload PDFs to a hosted RAG | Loses control of chunking + embedding + storage | Custom RAG with pgvector. See ai-agents-rag-custom-pgvector |
73
- | Add Memory/Session because "agents need state" | If not building a chatbot, don't add chat state | Skip. Add when a real chat UI exists. |
74
- | Use Semantic Kernel for new features | SK is superseded by MAF | Use Microsoft.Agents.AI. See ai-agents-setup |
75
- | Return free text and parse it downstream | LLM output is non-deterministic | Structured Output. See ai-agents-structured-output (Onda 2) |
76
-
77
- ---
78
-
79
- ## When the 4-feature rule does NOT apply
80
-
81
- You may need to step outside the sweet spot when:
82
- - The feature genuinely fans-out (e.g., monthly report aggregating N items) → workflow with fan-in
83
- - The feature needs vision/audio/image-gen → modality-specific standards (see ai-agents-modalities-* — Onda 3)
84
-
85
- **Even in these cases:** the core of the agent still follows the 4-feature rule. Only the orchestration layer changes.
86
-
87
- ---
88
-
89
- ## Checklist (verifiable by morph-eval)
90
-
91
- - [ ] Was each agent designed as single-agent BEFORE reaching for multi-agent? (Check `decisions.md`.)
92
- - [ ] If a Workflow is used, is fan-in/out or HITL checkpointing genuinely present? Or could `foreach + LINQ` replace it?
93
- - [ ] Are the 4 features (Chat, Structured Output, Tools, RAG Custom) all present where applicable?
94
- - [ ] Are hosted agent services avoided?
95
-
96
- ---
97
-
98
- ## References
99
-
100
- - `ai-agents-setup` — packages and DI
101
- - `ai-agents-providers-model-registry` — provider-agnostic config
102
- - `ai-agents-structured-output` (Onda 2)
103
- - `ai-agents-multi-agent-patterns` (Onda 2)
104
- - `ai-agents-workflows` (Onda 2, reframed)
105
- - `ai-agents-rag-custom-pgvector` (Onda 2)
106
-
107
- ---
108
-
109
- *MORPH-SPEC by Polymorphism Tech — ai-agents/sweet-spot.md v1.0 (2026-05-19)*
1
+ # Sweet Spot — When to use what in MAF
2
+
3
+ > **Scope:** stacks=["dotnet"]
4
+ > **Layer:** 0 (always-load via persona maf-expert)
5
+ > **Keywords:** sweet spot, when to use agent, agent vs workflow, when not to use workflow, MAF decision, simple agent
6
+ > **Read by Claude in:** plan (decide arquitetura da feature antes de quebrar em tasks) + implement (validar que a arquitetura ainda é a mais simples possível)
7
+
8
+ **Verified against:** MAF Tier List research (2026-05-18) + Microsoft Learn docs. Last-verified: 2026-05-19.
9
+
10
+ ---
11
+
12
+ ## The 4-feature rule
13
+
14
+ ```
15
+ 95% of production AI agents need ONLY:
16
+
17
+ 1. Chat (the LLM call)
18
+ 2. Structured Output (typed records, not free text)
19
+ 3. Tools (typed functions the agent can call)
20
+ 4. RAG Custom (pgvector tool, not hosted RAG)
21
+
22
+ If your feature needs ONLY these 4 → use a single agent. Don't reach for workflows.
23
+ ```
24
+
25
+ Apply this rule before deciding multi-agent or workflow. Most of the time the answer is "single agent".
26
+
27
+ ---
28
+
29
+ ## Decision tree (Claude reads this in plan phase)
30
+
31
+ ```
32
+ Step 1 — Does the task even need an LLM?
33
+ ├─ "Can a deterministic function solve this?" → YES → write the function, no agent
34
+ └─ NO → continue
35
+
36
+ Step 2 — Single agent vs multi-agent?
37
+ ├─ One topic + one decision → single agent (DEFAULT)
38
+ ├─ Multiple specialized topics with clear handoff → multi-agent
39
+ │ └─ Prefer Agent-as-Tool pattern (one agent uses another as a tool)
40
+ │ └─ See ai-agents-multi-agent-patterns
41
+ └─ "I'm not sure" → start with single agent, escalate if needed
42
+
43
+ Step 3 — Need a Workflow?
44
+ ├─ The feature has fan-in/out (many inputs aggregated) → maybe workflow
45
+ │ └─ Confirm: can you write it as a foreach + LINQ aggregate?
46
+ │ └─ YES → write the foreach, NO workflow
47
+ │ └─ NO → workflow may help
48
+ ├─ Long-running with human-in-the-loop checkpoints → maybe workflow
49
+ │ └─ See ai-agents-workflows (Onda 2)
50
+ └─ Otherwise → NO workflow
51
+
52
+ Step 4 — Which provider?
53
+ ├─ ALWAYS direct models — never a hosted agent service
54
+ ├─ Provider choice (OpenAI / Google / Anthropic / Ollama) lives in the
55
+ │ project's Model Registry, not hardcoded → see ai-agents-providers-model-registry
56
+ └─ Hosted services (Foundry Agent Service, Vertex AI hosted) → NOT used
57
+
58
+ Step 5 — RAG approach?
59
+ ├─ Need control over chunking/embedding/storage? → RAG custom (pgvector)
60
+ │ └─ See ai-agents-rag-custom-pgvector (Onda 2)
61
+ └─ Don't reach for hosted RAG — loses control
62
+ ```
63
+
64
+ ---
65
+
66
+ ## Anti-patterns (what Claude should NOT do)
67
+
68
+ | Anti-pattern | Why it's wrong | What to do instead |
69
+ |--------------|----------------|---------------------|
70
+ | Reach for Workflow when a function does the job | "Tudo que Workflows fazem, código C# normal faz com menos complexidade" — pesquisa | Write the function. Wrap in a tool if an agent needs to call it. |
71
+ | Use a hosted agent service | Hosted is "always 6-9 months behind" on models + removes control | Direct models always (OpenAI / Google / Anthropic / Ollama) |
72
+ | Upload PDFs to a hosted RAG | Loses control of chunking + embedding + storage | Custom RAG with pgvector. See ai-agents-rag-custom-pgvector |
73
+ | Add Memory/Session because "agents need state" | If not building a chatbot, don't add chat state | Skip. Add when a real chat UI exists. |
74
+ | Use Semantic Kernel for new features | SK is superseded by MAF | Use Microsoft.Agents.AI. See ai-agents-setup |
75
+ | Return free text and parse it downstream | LLM output is non-deterministic | Structured Output. See ai-agents-structured-output (Onda 2) |
76
+
77
+ ---
78
+
79
+ ## When the 4-feature rule does NOT apply
80
+
81
+ You may need to step outside the sweet spot when:
82
+ - The feature genuinely fans-out (e.g., monthly report aggregating N items) → workflow with fan-in
83
+ - The feature needs vision/audio/image-gen → modality-specific standards (see ai-agents-modalities-* — Onda 3)
84
+
85
+ **Even in these cases:** the core of the agent still follows the 4-feature rule. Only the orchestration layer changes.
86
+
87
+ ---
88
+
89
+ ## Checklist (verifiable by morph-eval)
90
+
91
+ - [ ] Was each agent designed as single-agent BEFORE reaching for multi-agent? (Check `decisions.md`.)
92
+ - [ ] If a Workflow is used, is fan-in/out or HITL checkpointing genuinely present? Or could `foreach + LINQ` replace it?
93
+ - [ ] Are the 4 features (Chat, Structured Output, Tools, RAG Custom) all present where applicable?
94
+ - [ ] Are hosted agent services avoided?
95
+
96
+ ---
97
+
98
+ ## References
99
+
100
+ - `ai-agents-setup` — packages and DI
101
+ - `ai-agents-providers-model-registry` — provider-agnostic config
102
+ - `ai-agents-structured-output` (Onda 2)
103
+ - `ai-agents-multi-agent-patterns` (Onda 2)
104
+ - `ai-agents-workflows` (Onda 2, reframed)
105
+ - `ai-agents-rag-custom-pgvector` (Onda 2)
106
+
107
+ ---
108
+
109
+ *MORPH-SPEC by Polymorphism Tech — ai-agents/sweet-spot.md v1.0 (2026-05-19)*
@@ -20,6 +20,25 @@
20
20
 
21
21
  **Decision rule:** If the image is unique to the project's brand/aesthetic and doesn't exist as stock, use AI generation. If it's generic and widely available, use stock. If it's geometric or icon-based, use SVG/CSS.
22
22
 
23
+ ## Brand Fidelity: Reference, Don't Invent
24
+
25
+ The advantage of an image MCP over generating from scratch is staying consistent with the client's **real** assets. Pass them as reference (`edit_image` with `referenceImages`) rather than generating in a vacuum. A generated look-alike is a different product, and the client sees it immediately.
26
+
27
+ Two cases where this is a hard rule:
28
+
29
+ - **Property developers and architecture:** the building is the client's **real architectural render**. Never AI-recreate it. AI only animates it (see `frontend/design-system/ai-video-generation.md`) or composes a scene around the real render.
30
+ - **Physical products:** pass the real product photo as reference and generate angle or setting variations of the **same** product.
31
+
32
+ ### Chain from an approved hero
33
+
34
+ Generate the **hero first**. Once approved, use it as the reference for every derived image (detail shots, cards, scene variants), so the whole set shares light, palette and identity instead of looking like separate photo shoots.
35
+
36
+ ```
37
+ hero -> [approved] -> derivatives with the approved hero as referenceImages -> [approved per image]
38
+ ```
39
+
40
+ Skipping this chain is the most common cause of a page whose images do not feel like one set.
41
+
23
42
  ## Gemini Image MCP API
24
43
 
25
44
  ```javascript
@@ -233,6 +252,25 @@ The `assets.md` file is created during the UI/UX phase (Step 4.5) and consumed b
233
252
  - **Priority:** high
234
253
  ```
235
254
 
255
+ ## Downstream: Images That Become Video
256
+
257
+ Static images with faces usually pass image moderation. **Video generation is stricter**: face-bearing img2vid trips moderation (error E005).
258
+
259
+ So if an image is destined to become video footage, frame it without a face from the start (neck down, hands, the product). For tailoring, craft and manufacturing subjects this usually improves the shot anyway, because the product becomes the subject. See `frontend/design-system/ai-video-generation.md`.
260
+
261
+ For a frame that will drive a scroll scrub, also generate at the exact ratio the video will output, and place the subject on the side **opposite** the copy. See `frontend/design-system/premium-finish.md`.
262
+
263
+ ## The Two Assets Everyone Forgets
264
+
265
+ - **Favicon / monogram.** Derive a simple mark (one or two letters, or the existing symbol) that reads at 32x32. Use `edit_image` from the real logo so it stays on-brand. Export PNG at 512x512 and let the browser downscale. **Never invent a new logo**, simplify the existing one.
266
+ - **OG / share image (1200x630).** The image that appears when the link is pasted into a chat or a feed. Use the strongest shot on the page, with breathing room for a possible brand overlay. Generate or crop at that exact ratio. See `frontend/seo/meta-schema-audit.md`.
267
+
268
+ ## Variations and Cost
269
+
270
+ Generate **two or three variations per image**, varying angle, light or composition, **not just the seed**. Seed-only variation produces near-identical options and wastes the review.
271
+
272
+ If none are good, regenerate at the same step with the prompt adjusted by the feedback. **Do not advance with a weak image**: every derivative, any footage built from it, and the final page all inherit its quality.
273
+
236
274
  ## Quality Checklist
237
275
 
238
276
  - [ ] Colors match design system tokens (no random colors in prompts)
@@ -244,5 +282,10 @@ The `assets.md` file is created during the UI/UX phase (Step 4.5) and consumed b
244
282
  - [ ] `priority` prop set for above-the-fold images
245
283
  - [ ] Build compiles after integration (`npm run build`)
246
284
  - [ ] Image visible in dev server at correct route
285
+ - [ ] Client assets passed as `referenceImages`; nothing generated in a vacuum
286
+ - [ ] Real renders and real product photos used as-is, never AI-recreated
287
+ - [ ] Hero approved first, then used as reference for derivatives
288
+ - [ ] Images headed for video framed without faces
289
+ - [ ] Favicon and 1200x630 OG image produced
247
290
 
248
291
  *MORPH-SPEC by Polymorphism Tech*
@@ -0,0 +1,113 @@
1
+ # AI Video Generation — Directional Footage for Scroll Scrub
2
+
3
+ > **Scope:** frontend-design-system
4
+ > **Layer:** 3
5
+ > **Keywords:** video generation, seedance, img2vid, endImage, directional footage, loop video, E005 moderation, cost ladder
6
+ > **Load When:** producing footage for a scroll-driven page or animating a client render
7
+
8
+ **Verified against:** seedance MCP (generate_video, generate_loop_video, get_video, list_videos) over Replicate. Last-verified: 2026-08-21.
9
+
10
+ ---
11
+
12
+ How to generate footage that actually works under scroll control. The single most expensive mistake here is generating a perfect loop for a scrub section, which produces a page that feels frozen while the user scrolls. Covers the loop-versus-directional distinction, how to build directional footage, the face moderation workaround, and the cost ladder.
13
+
14
+ This is the knowledge layer. The approval gates that stop generation from burning credit belong to the calling workflow, not to this standard.
15
+
16
+ ---
17
+
18
+ ## Section 1: The Distinction That Decides Everything
19
+
20
+ A **perfect loop** has a last frame identical to its first: the camera and everything in it return to the start. That is exactly right for a video that plays itself on repeat, and exactly wrong for scrubbing. With start and end nearly identical, dragging the scroll appears to change nothing, and the page reads as static while the user scrolls.
21
+
22
+ Scrubbing needs the opposite: **directional movement**, with the end clearly different from the start. The scroll becomes the control for a camera traveling from one point to another.
23
+
24
+ | Use | Tool | Start vs end | Why |
25
+ |---|---|---|---|
26
+ | Hero or section driven by scroll | `generate_video` + `endImage` | **different** (push-in, dolly, reveal) | scroll must feel progression |
27
+ | Ambient background that plays itself | `generate_loop_video` | **identical** (loop seal) | seamless repeat |
28
+ | Animating a real client render | `generate_video` (img2vid) | per the desired movement | the building comes from the client, AI only animates |
29
+
30
+ **Directional is the default.** A seamless loop is the special case, reserved for a secondary ambient plane.
31
+
32
+ ---
33
+
34
+ ## Section 2: Building Directional Footage
35
+
36
+ Give a start image and an end image, and let the model interpolate a camera traveling between them.
37
+
38
+ 1. Pick or generate the **start frame**: the wide shot, the resting state.
39
+ 2. Pick or generate the **end frame** (`endImage`): the destination of the movement (a detail in close-up, a revealed facade).
40
+ 3. Call `generate_video { prompt, image: start, endImage: end }`. The prompt describes the camera movement between the two.
41
+
42
+ **Movements that scrub well:**
43
+
44
+ - **Push-in / dolly-in**: wide to detail. The most reliable by a wide margin.
45
+ - **Reveal**: camera rises or translates, uncovering more of the subject.
46
+ - **Pull-back**: detail to context, the inverse of push-in.
47
+ - **Slow tilt or pan** anchored on a subject.
48
+
49
+ **Avoid for scrub:** full orbits and any movement that returns to its origin. They become loops and kill the sense of progress.
50
+
51
+ ---
52
+
53
+ ## Section 3: Faces Trip Moderation
54
+
55
+ Img2vid with a **human face** repeatedly fails moderation (error E005). The workaround that works is to **crop the face out of frame** before generating.
56
+
57
+ - Frame from the neck down (garment, hands, fabric) rather than the whole person. For tailoring, craft and manufacturing this usually improves the shot, because the product becomes the subject.
58
+ - Hands working (at a cuff, a button, the material) pass reliably and carry the craft story.
59
+ - If the client insists on a face, generate the **static image** with it (image generation is more permissive) and reserve video for the face-free shots.
60
+
61
+ ---
62
+
63
+ ## Section 4: The Cost Ladder
64
+
65
+ Every generation costs money and you rarely nail the movement on the first attempt.
66
+
67
+ 1. **Draft:** fast model, 480p, 4s. Enough to judge framing and movement.
68
+ 2. **Final:** only after the draft is approved, regenerate at 1080p. Then re-extract frames and swap them into the build **with a cache-bust** (`?v=N`), or the browser serves the old ones. See `frontend/scroll-driven/frame-scrub.md`.
69
+
70
+ Never open at 1080p.
71
+
72
+ ---
73
+
74
+ ## Section 5: Prompt Skeleton
75
+
76
+ A directional prompt does not need a loop seal. It needs to be specific about camera, start, end and legibility:
77
+
78
+ ```
79
+ SCENE: [subject without a face: material, color, detail]. [environment]. Mood reference: [1-2 real refs]. Palette: [tones].
80
+ CAMERA: [directional movement] from the start frame to the end frame. Speed [slow, cinematic].
81
+ Start = [start image], end = [endImage]. Does NOT return to the start.
82
+ ACTION ARC: opens on [initial state], camera [pushes / reveals] until [final state or detail].
83
+ No elements that return to their starting position.
84
+ LIGHTING: [source, temperature]. Stable from start to finish, no flicker or color shift.
85
+ LEGIBILITY: leave a calm, dark region on one side of the frame for the page copy to sit over.
86
+ The subject stays on the side OPPOSITE the copy; if it comes out on the wrong side,
87
+ mirror it at extraction time (hflip).
88
+ TECHNICAL: img2vid with image (start) + endImage (end). No audio. No watermark.
89
+ Draft 480p/4s; 1080p only after approval.
90
+ ```
91
+
92
+ **Tone:** direct and technical, like director's notes. No hype words ("stunning", "breathtaking"). Describe what happens on screen, not editing software.
93
+
94
+ ---
95
+
96
+ ## Section 6: Async Contract
97
+
98
+ `generate_video` and `generate_loop_video` return a `request_id` rather than a file. Poll with `get_video { requestId, outputPath? }`, which downloads the `.mp4` once the job reports COMPLETED. `list_videos { limit? }` reads local job history and spends no credits, which also makes it the safe health check for the MCP.
99
+
100
+ ---
101
+
102
+ ## Checklist
103
+
104
+ - [ ] Directional footage (start differs from end) for anything scroll-driven
105
+ - [ ] Seamless loop used only for a self-playing ambient plane
106
+ - [ ] Client renders animated, never AI-recreated
107
+ - [ ] Faces cropped out of frame before img2vid
108
+ - [ ] Movement chosen from the scrub-friendly list, no orbits or returns
109
+ - [ ] Prompt reserves a calm region for copy, subject opposite the text
110
+ - [ ] Draft at 480p/4s approved before any 1080p render
111
+ - [ ] Frames re-extracted with a bumped cache-bust after the final render
112
+
113
+ *MORPH-SPEC by Polymorphism Tech*
@@ -0,0 +1,160 @@
1
+ # Premium Finish — The Layer That Separates Good From Expensive
2
+
3
+ > **Scope:** frontend-design-system
4
+ > **Layer:** 3
5
+ > **Keywords:** premium, polish, typography, film grain, atmosphere, load-in, scrim, legibility over video, accent
6
+ > **Load When:** ui-designer active, or the brief asks for a premium or high-end feel
7
+
8
+ **Verified against:** Production landing pages, CSS-only techniques, no runtime dependency. Last-verified: 2026-08-21.
9
+
10
+ ---
11
+
12
+ A build that runs, is responsive and has scroll animation can still look like a template. The gap between that and something a client reads as expensive is a finish layer applied on purpose. This is that checklist and the reasoning behind each item.
13
+
14
+ **Read these as principles, not as a recipe.** The goal is to hit the quality *level* for any brand, not to reproduce one project's aesthetic choices. Each item states the principle, which always holds, and then an illustrative answer in italics, which is one option among many.
15
+
16
+ **Never converge on the same choices across projects.** Same font, same palette, same gradient across clients is the failure mode. Each page should look designed for that business.
17
+
18
+ ---
19
+
20
+ ## Section 1: Typography With Character
21
+
22
+ Stack default fonts (Inter, Roboto, Arial, system) and the fonts that have become AI-generation tells (Space Grotesk, Playfair) announce "made by a machine". Commit to a display face with real personality, chosen from the brand: what it sells, to whom, at what temperature. Pair a distinctive display with a sober, legible body.
23
+
24
+ - Enable `font-optical-sizing: auto`.
25
+ - Tighten `letter-spacing` slightly on large headings (`-0.012em` to `-0.015em`) for an editorial set.
26
+
27
+ *One project (menswear tailoring) used Cormorant for headings and Jost for body. For a property developer or a SaaS the answer is different. Cormorant is not the rule, it was one answer.*
28
+
29
+ ---
30
+
31
+ ## Section 2: Atmosphere, Never Flat Color
32
+
33
+ Solid backgrounds flatten. Depth and texture make the eye read material. All of these generalize: film grain, subtle radial gradients (a brand glow), vignette, gradient meshes, dramatic shadows, layered transparency.
34
+
35
+ Film grain is cheap and universal, via an inline SVG `feTurbulence`:
36
+
37
+ ```css
38
+ body::after {
39
+ content: ''; position: fixed; inset: 0; z-index: 200; pointer-events: none;
40
+ opacity: 0.055; mix-blend-mode: overlay;
41
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
42
+ }
43
+ ```
44
+
45
+ The correct opacity is low: texture you feel, not texture you see. Calibrate per brand and per how dark the theme is.
46
+
47
+ ---
48
+
49
+ ## Section 3: One Orchestrated Load-In Beats Ten Micro-Interactions
50
+
51
+ A single well-choreographed page load (hero elements rising in stagger) delivers more impact than effects scattered across the page. Concentrate the effort on first contact.
52
+
53
+ Animate the children of the first hero block with one keyframe and increasing `animation-delay`: kicker, then H1, then subtitle, then CTA.
54
+
55
+ ```css
56
+ @keyframes heroRise {
57
+ from { opacity: 0; transform: translateY(28px); }
58
+ to { opacity: 1; transform: none; }
59
+ }
60
+ .hero-beat--1 .kicker,
61
+ .hero-beat--1 h1,
62
+ .hero-beat--1 .sub,
63
+ .hero-beat--1 .actions {
64
+ opacity: 0; animation: heroRise 1.1s cubic-bezier(.2,.7,.2,1) forwards;
65
+ }
66
+ .hero-beat--1 .kicker { animation-delay: .30s }
67
+ .hero-beat--1 h1 { animation-delay: .46s }
68
+ .hero-beat--1 .sub { animation-delay: .68s }
69
+ .hero-beat--1 .actions { animation-delay: .84s }
70
+ ```
71
+
72
+ The exact delays are an example rhythm. The principle is stagger on first impact.
73
+
74
+ ---
75
+
76
+ ## Section 4: Legibility Over Video (Close To a Hard Rule)
77
+
78
+ Text over video or photography is where a premium hero most often breaks. Solve it with a **directional scrim plus text-shadow**, every time.
79
+
80
+ The scrim darkens exactly the side where the copy lives and stays clear over the subject. A uniform veil is the wrong tool: it dims the whole image and kills the footage.
81
+
82
+ ```css
83
+ .scrub__scrim {
84
+ position: absolute; inset: 0;
85
+ background: linear-gradient(90deg,
86
+ rgba(14,11,12,.86) 0%, rgba(14,11,12,.5) 38%, rgba(14,11,12,0) 70%);
87
+ }
88
+ .scrub__copy {
89
+ text-shadow: 0 1px 3px rgba(0,0,0,.5), 0 4px 34px rgba(0,0,0,.5);
90
+ }
91
+ ```
92
+
93
+ The text-shadow is the insurance policy: it keeps the copy readable if a bright frame passes behind it.
94
+
95
+ If the subject collides with the copy, mirror the footage at extraction time (`hflip`) to throw the subject to the opposite side. See `frontend/scroll-driven/frame-scrub.md`.
96
+
97
+ ---
98
+
99
+ ## Section 5: One Precious Accent, Used Sparingly
100
+
101
+ A jewel-like detail in very few places (primary CTA, a proof number, one heading highlight) raises perceived value. Sparing and precise: if everything shines, nothing does.
102
+
103
+ ```css
104
+ /* light sweep on the CTA */
105
+ .btn-accent { position: relative; overflow: hidden; }
106
+ .btn-accent::before {
107
+ content: ''; position: absolute; top: 0; left: -130%; width: 55%; height: 100%;
108
+ transform: skewX(-22deg); pointer-events: none;
109
+ background: linear-gradient(90deg, transparent, rgba(255,255,255,.6), transparent);
110
+ transition: left .6s cubic-bezier(.2,.7,.2,1);
111
+ }
112
+ .btn-accent:hover::before { left: 150%; }
113
+
114
+ /* metallic gradient text */
115
+ .metallic {
116
+ background: linear-gradient(180deg, #fff3cf 0%, #ffecb4 28%, #c9a24b 62%, #9a7b35 100%);
117
+ -webkit-background-clip: text; background-clip: text;
118
+ -webkit-text-fill-color: transparent;
119
+ filter: drop-shadow(0 2px 16px rgba(201,162,75,.25));
120
+ }
121
+ ```
122
+
123
+ *The gold above is one answer. For another brand the accent could be chrome, copper, a brand neon, or a single stroke of color. The principle is "one precious accent, used sparingly", not "use gold".*
124
+
125
+ ---
126
+
127
+ ## Section 6: The Details That Add Up
128
+
129
+ - Scrollbar styled in brand color, not browser gray.
130
+ - `::selection` in the accent color.
131
+ - Hairlines (1px) as gradients that fade at the ends, instead of solid borders.
132
+ - Hover states with a micro-transition (a gap that grows, an arrow that advances), never binary on/off.
133
+ - Consistent radii and a spacing system, not loose numbers.
134
+
135
+ ---
136
+
137
+ ## Section 7: Order of Application
138
+
139
+ Apply this from the start of the build, not as a final polish pass. The client judges in two seconds.
140
+
141
+ 1. Define brand tokens first (colors, fonts, radii, shadows) as CSS variables. Everything inherits from there.
142
+ 2. Apply atmosphere globally (grain plus glow).
143
+ 3. Work the hero until the load-in and legibility are flawless.
144
+ 4. Place the accent in two or three spots, maximum.
145
+ 5. Sweep the details (scrollbar, selection, hovers, hairlines).
146
+
147
+ Finish with fresh eyes: open the page as if you were the client. Whatever looks like a template is the next thing to raise.
148
+
149
+ ---
150
+
151
+ ## Checklist
152
+
153
+ - [ ] Display font chosen from the brand, not from stack defaults or the AI-tell list
154
+ - [ ] Brand tokens defined as CSS variables before any component styling
155
+ - [ ] Atmosphere layer applied (grain, glow, or equivalent) at low opacity
156
+ - [ ] Hero load-in staggered with a single keyframe and increasing delays
157
+ - [ ] Directional scrim plus text-shadow on every text-over-media block
158
+ - [ ] Accent used in three places or fewer
159
+ - [ ] Details swept: scrollbar, selection, hairlines, hover micro-transitions
160
+ - [ ] Fresh-eyes pass done, and it does not read as a template
@@ -3,7 +3,7 @@
3
3
  > **Scope:** frontend-nextjs-ui
4
4
  > **Layer:** 3
5
5
  > **Keywords:** gsap, animation, timeline, tween, useGSAP, greensock, transform
6
- > **Load When:** gsap-animator active
6
+ > **Load When:** ui-designer active, or the project animates with GSAP
7
7
 
8
8
  **Verified against:** GSAP 3.13 + @gsap/react. Last-verified: 2026-05-20.
9
9
 
@@ -3,7 +3,7 @@
3
3
  > **Scope:** frontend-nextjs-gsap
4
4
  > **Layer:** 3
5
5
  > **Keywords:** flip, splittext, morphsvg, drawsvg, motionpath, draggable, observer, scrollto, gsap-plugins
6
- > **Load When:** gsap-animator active
6
+ > **Load When:** ui-designer active, or the project animates with GSAP
7
7
 
8
8
  **Verified against:** GSAP 3.13 + @gsap/react. Last-verified: 2026-05-20.
9
9
 
@@ -3,7 +3,7 @@
3
3
  > **Scope:** frontend-nextjs-gsap
4
4
  > **Layer:** 3
5
5
  > **Keywords:** scrolltrigger, scroll-animation, pinning, scrubbing, parallax, scroll-driven, gsap
6
- > **Load When:** gsap-animator active
6
+ > **Load When:** ui-designer active, or the project animates with GSAP
7
7
 
8
8
  **Verified against:** GSAP 3.13 ScrollTrigger + @gsap/react. Last-verified: 2026-05-20.
9
9
 
@@ -11,6 +11,8 @@
11
11
 
12
12
  Reference guide for implementing scroll-driven animations in Next.js projects using GSAP ScrollTrigger. Covers plugin setup, scrubbing, pinning, batch processing, responsive breakpoints, SSR considerations, and mandatory cleanup patterns.
13
13
 
14
+ **Pair this with a smooth scroller before shipping a cinematic page.** ScrollTrigger reads native scroll on its own, which is correct for app UI. A landing page whose scroll drives a scene wants Lenis handing scroll to ScrollTrigger through the GSAP ticker, plus the instance exposed on `window` so overlays and automated verification can drive it. That wiring, and the traps that come with it, live in `frontend/scroll-driven/smooth-scroll.md`.
15
+
14
16
  ---
15
17
 
16
18
  ## Section 1: Plugin Registration
@@ -9,7 +9,9 @@
9
9
 
10
10
  ---
11
11
 
12
- Reference guide for implementing animations and transitions in Next.js projects using **Motion for React** — the library formerly published as `framer-motion`. The package is now `motion` and components import from `motion/react`; the `framer-motion` name only survives inside the Framer design tool. Covers the canonical variants library, design token bridge, scroll and gesture patterns, loading states, and mandatory WCAG accessibility compliance.
12
+ Reference guide for implementing animations and transitions in Next.js projects using **Motion for React**, the library formerly published as `framer-motion`. The package is now `motion` and components import from `motion/react`; the `framer-motion` name only survives inside the Framer design tool. Covers the canonical variants library, design token bridge, scroll and gesture patterns, loading states, and mandatory WCAG accessibility compliance.
13
+
14
+ **Scope, and where the other motion stack starts.** This standard governs component-level motion: enter and exit, gestures, mount and unmount transitions, short scroll reveals in an app or product UI. When the scroll position itself drives the scene (frame scrubs, pinned sequences, parallax, a cinematic landing page), that is GSAP plus ScrollTrigger plus Lenis: see `frontend/scroll-driven/smooth-scroll.md` and `frontend/gsap/gsap-core.md`. The two stacks may share a page but never the same element, because both write inline styles and will fight for control. On a page that runs Lenis, use the `useReveal` recipe in `frontend/scroll-driven/scroll-components.md` rather than `whileInView`, so a single library owns the answer to when an element is visible.
13
15
 
14
16
  ---
15
17