@polymorphism-tech/morph-spec 6.0.0 → 7.1.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 (114) hide show
  1. package/README.md +367 -366
  2. package/docs/CHEATSHEET.md +3 -3
  3. package/docs/QUICKSTART.md +4 -4
  4. package/framework/CLAUDE.md +13 -0
  5. package/framework/MORPH.md +57 -36
  6. package/framework/agents.json +132 -127
  7. package/framework/commands/morph-apply.md +4 -21
  8. package/framework/commands/morph-archive.md +1 -1
  9. package/framework/commands/morph-proposal.md +2 -0
  10. package/framework/hooks/claude-code/core/enforce-phase-writes.js +1 -1
  11. package/framework/hooks/claude-code/core/protect-spec-files.js +1 -1
  12. package/framework/hooks/claude-code/core/state-sync.js +212 -0
  13. package/framework/hooks/shared/phase-utils.js +5 -4
  14. package/framework/hooks/shared/state-reader.js +1 -1
  15. package/framework/phases.json +1 -1
  16. package/framework/rubrics/backend.json +41 -36
  17. package/framework/rules/ai-agents-standards.md +45 -15
  18. package/framework/rules/morph-workflow.md +15 -34
  19. package/framework/rules/neon-standards.md +25 -26
  20. package/framework/schemas/tasks.schema.json +35 -0
  21. package/framework/skills/core/morph-apply/SKILL.md +154 -0
  22. package/framework/skills/core/morph-brainstorming/SKILL.md +53 -30
  23. package/framework/skills/core/morph-implement/SKILL.md +25 -14
  24. package/framework/skills/core/morph-plan/SKILL.md +91 -23
  25. package/framework/skills/core/morph-proposal/SKILL.md +137 -0
  26. package/framework/skills/core/morph-review/SKILL.md +43 -7
  27. package/framework/skills/core/morph-stack-scan/SKILL.md +40 -1
  28. package/framework/standards/STANDARDS.json +1729 -1134
  29. package/framework/standards/ai-agents/agent-session.md +160 -0
  30. package/framework/standards/ai-agents/batching.md +193 -0
  31. package/framework/standards/ai-agents/context-providers.md +188 -0
  32. package/framework/standards/ai-agents/mcp-server.md +250 -0
  33. package/framework/standards/ai-agents/mcp-tools.md +197 -0
  34. package/framework/standards/ai-agents/middleware-patterns.md +207 -0
  35. package/framework/standards/ai-agents/modalities-image-gen.md +173 -0
  36. package/framework/standards/ai-agents/modalities-speech-to-text.md +171 -0
  37. package/framework/standards/ai-agents/modalities-text-to-speech.md +181 -0
  38. package/framework/standards/ai-agents/modalities-vision.md +201 -0
  39. package/framework/standards/ai-agents/multi-agent-patterns.md +155 -0
  40. package/framework/standards/ai-agents/production.md +114 -258
  41. package/framework/standards/ai-agents/prompts-in-db.md +214 -0
  42. package/framework/standards/ai-agents/providers/model-registry.md +158 -0
  43. package/framework/standards/ai-agents/rag-custom-pgvector.md +243 -0
  44. package/framework/standards/ai-agents/service-tier-flex.md +135 -0
  45. package/framework/standards/ai-agents/setup.md +142 -316
  46. package/framework/standards/ai-agents/structured-output.md +249 -0
  47. package/framework/standards/ai-agents/sweet-spot.md +109 -0
  48. package/framework/standards/ai-agents/workflows.md +114 -284
  49. package/framework/standards/architecture/vertical-slice/vertical-slice.md +433 -429
  50. package/framework/standards/backend/api/validation.md +92 -88
  51. package/framework/standards/backend/database/postgresql/database.md +336 -332
  52. package/framework/standards/backend/database/vector-search-rag.md +599 -541
  53. package/framework/standards/backend/dotnet/fluent-validation-vsa.md +4 -0
  54. package/framework/standards/backend/dotnet/result-pattern.md +4 -0
  55. package/framework/standards/backend/dotnet/scalar-ui.md +176 -172
  56. package/framework/standards/backend/dotnet/scrutor.md +4 -0
  57. package/framework/standards/backend/dotnet/vsa-handler-patterns.md +278 -274
  58. package/framework/standards/backend/integrations/asaas/asaas-api.md +260 -216
  59. package/framework/standards/backend/integrations/hangfire/hangfire-jobs.md +354 -350
  60. package/framework/standards/backend/integrations/neon-auth/neon-auth.md +30 -19
  61. package/framework/standards/backend/integrations/resend/resend-email.md +400 -385
  62. package/framework/standards/data/nosql/cache/redis.md +106 -97
  63. package/framework/standards/data/nosql/cosmos-db.md +127 -118
  64. package/framework/standards/data/vector-search/rag-chunking.md +113 -104
  65. package/framework/standards/frontend/design-system/ai-image-generation.md +4 -0
  66. package/framework/standards/frontend/design-system/animations.md +164 -160
  67. package/framework/standards/frontend/design-system/naming.md +68 -64
  68. package/framework/standards/frontend/gsap/gsap-core.md +14 -8
  69. package/framework/standards/frontend/gsap/gsap-plugins.md +26 -21
  70. package/framework/standards/frontend/gsap/gsap-scrolltrigger.md +9 -7
  71. package/framework/standards/frontend/nextjs/app-router.md +127 -123
  72. package/framework/standards/frontend/nextjs/components.md +136 -132
  73. package/framework/standards/frontend/nextjs/data-fetching.md +130 -126
  74. package/framework/standards/frontend/nextjs/forms.md +134 -128
  75. package/framework/standards/frontend/nextjs/motion-patterns.md +328 -322
  76. package/framework/standards/frontend/nextjs/naming-conventions.md +71 -67
  77. package/framework/standards/frontend/nextjs/nextjs-patterns.md +229 -225
  78. package/framework/standards/frontend/nextjs/project-structure.md +106 -102
  79. package/framework/standards/frontend/nextjs/state-management.md +76 -72
  80. package/framework/standards/frontend/nextjs/testing.md +115 -111
  81. package/framework/standards/infrastructure/docker/easypanel-deploy.md +196 -192
  82. package/framework/standards/infrastructure/neon/neon-pgrag.md +6 -2
  83. package/framework/standards/infrastructure/neon/neon-pgvector.md +4 -0
  84. package/framework/standards/infrastructure/neon/neon-setup.md +5 -1
  85. package/framework/standards/integration/mcp/mcp-tools.md +471 -462
  86. package/framework/templates/REGISTRY.json +1745 -1239
  87. package/framework/templates/code/dotnet/ai-agents/AgentBootstrap.cs.template +39 -0
  88. package/framework/templates/code/dotnet/ai-agents/EmbeddingService.cs.template +68 -0
  89. package/framework/templates/code/dotnet/ai-agents/ModelRegistry.cs.template +117 -0
  90. package/framework/templates/code/dotnet/ai-agents/PromptRepository.cs.template +95 -0
  91. package/framework/templates/code/dotnet/ai-agents/ResilientToolMiddleware.cs.template +61 -0
  92. package/framework/templates/code/dotnet/ai-agents/VectorSearchTool.cs.template +107 -0
  93. package/framework/templates/code/dotnet/ai-agents/model-registry.json.template +58 -0
  94. package/framework/templates/code/sql/ai-agents/agent-prompts-migration.sql.template +58 -0
  95. package/framework/templates/code/sql/ai-agents/pgvector-embeddings-migration.sql.template +91 -0
  96. package/framework/templates/docs/onboarding.md +4 -4
  97. package/framework/templates/tasks.template.json +17 -0
  98. package/package.json +89 -83
  99. package/src/commands/project/init.js +16 -0
  100. package/src/commands/validation/validate-feature.js +1 -1
  101. package/src/core/paths/output-schema.js +6 -6
  102. package/src/core/state/state-manager.js +1 -1
  103. package/src/core/templates/template-registry.js +289 -256
  104. package/src/lib/detectors/design-system-detector.js +1 -1
  105. package/src/lib/generators/context-generator.js +516 -518
  106. package/src/lib/generators/scaffold-generator.js +23 -26
  107. package/src/lib/installers/memory-installer.js +138 -0
  108. package/src/lib/phase-chain/phase-validator.js +4 -4
  109. package/src/lib/risk-detector.js +80 -0
  110. package/src/lib/tasks/tasks-json-parser.js +185 -0
  111. package/src/scripts/setup-infra.js +25 -0
  112. package/src/utils/hooks-installer.js +59 -10
  113. package/framework/standards/infrastructure/neon/neon-semantic-kernel.md +0 -310
  114. package/framework/templates/integrations/semantic-kernel-neon.cs +0 -125
@@ -1,88 +1,92 @@
1
- # Status Validation Pattern
2
-
3
- > **Scope:** universal
4
- > **Layer:** 0 (always load)
5
- > **Keywords:** validation, fluent, dto, modelstate, fluentvalidation
6
- > **Load When:** always
7
-
8
- **MORPH-SPEC Standard** — Validate what is INVALID, not what is valid.
9
-
10
- ## Problem
11
-
12
- Validations assuming a single flow break when new flows are added.
13
-
14
- ```
15
- Original: Created → PendingPayment → Processing → Completed → EmailSent
16
- Free: Created → Processing → Completed → EmailSent (skips payment)
17
- ```
18
-
19
- ```csharp
20
- // ❌ Assumes single flow — breaks free flow
21
- if (order.Status != OrderStatus.PendingPayment)
22
- throw new InvalidOperationException("Must be pending payment");
23
-
24
- // ✅ Validates invalid states — works for all flows
25
- if (order.Status >= OrderStatus.Completed || order.Status == OrderStatus.Failed)
26
- throw new InvalidOperationException("Order already completed or failed");
27
- ```
28
-
29
- ## Enum Design
30
-
31
- ```csharp
32
- public enum OrderStatus
33
- {
34
- Created = 0, PendingPayment = 1, Processing = 2, Completed = 3, EmailSent = 4,
35
- // Error states (separated range)
36
- Failed = 100, Cancelled = 101, Refunded = 102
37
- }
38
- ```
39
-
40
- ## Validation Patterns
41
-
42
- | Pattern | When | Example |
43
- |---------|------|---------|
44
- | Final state check | Block after completion | `if (status >= OrderStatus.Completed)` |
45
- | Error state list | Block specific errors | `if (new[] { Failed, Cancelled, Refunded }.Contains(status))` |
46
- | Range comparison | Block finalized + errors | `if (status >= Completed \|\| status >= Failed)` |
47
-
48
- ## Anti-Patterns
49
-
50
- | Anti-Pattern | Problem | Fix |
51
- |-------------|---------|-----|
52
- | `if (status != Expected)` | Assumes single flow | Validate invalid states instead |
53
- | Exhaustive switch on valid states | Must modify for each new status | Validate only invalid states |
54
- | Business logic in state validator | Mixed concerns | Separate state validation from business rules |
55
-
56
- ## Complete Example
57
-
58
- ```csharp
59
- public async Task<Result> ProcessOrderAsync(Guid orderId, CancellationToken ct)
60
- {
61
- var order = await _repository.GetByIdAsync(orderId, ct);
62
- if (order == null) return Result.Failure("Order not found");
63
-
64
- // State validation (invalid states)
65
- if (order.Status >= OrderStatus.Completed) return Result.Failure("Already completed");
66
- if (order.Status == OrderStatus.Failed) return Result.Failure("Cannot process failed order");
67
- if (order.Status == OrderStatus.Cancelled) return Result.Failure("Cannot process cancelled order");
68
-
69
- // Business validation (separate)
70
- if (order.RequiresPayment && !order.IsPaid) return Result.Failure("Payment required");
71
-
72
- order.MarkAsProcessing();
73
- await _repository.UpdateAsync(order, ct);
74
- return Result.Success();
75
- }
76
- ```
77
-
78
- ## Checklist
79
-
80
- - [ ] Validates INVALID states (not valid)?
81
- - [ ] Uses ordered enum comparison where possible?
82
- - [ ] Error states treated separately (100+ range)?
83
- - [ ] All flows documented in decisions.md?
84
- - [ ] Tested with all possible flows?
85
-
86
- ---
87
-
88
- *MORPH-SPEC by Polymorphism Tech*
1
+ # Status Validation Pattern
2
+
3
+ > **Scope:** universal
4
+ > **Layer:** 0 (always load)
5
+ > **Keywords:** validation, fluent, dto, modelstate, fluentvalidation
6
+ > **Load When:** always
7
+
8
+ **Verified against:** .NET 10 (pure state-validation pattern — no external package). Last-verified: 2026-05-20.
9
+
10
+ ---
11
+
12
+ **MORPH-SPEC Standard** — Validate what is INVALID, not what is valid.
13
+
14
+ ## Problem
15
+
16
+ Validations assuming a single flow break when new flows are added.
17
+
18
+ ```
19
+ Original: Created → PendingPayment → Processing → Completed → EmailSent
20
+ Free: Created → Processing → Completed → EmailSent (skips payment)
21
+ ```
22
+
23
+ ```csharp
24
+ // ❌ Assumes single flow — breaks free flow
25
+ if (order.Status != OrderStatus.PendingPayment)
26
+ throw new InvalidOperationException("Must be pending payment");
27
+
28
+ // ✅ Validates invalid states — works for all flows
29
+ if (order.Status >= OrderStatus.Completed || order.Status == OrderStatus.Failed)
30
+ throw new InvalidOperationException("Order already completed or failed");
31
+ ```
32
+
33
+ ## Enum Design
34
+
35
+ ```csharp
36
+ public enum OrderStatus
37
+ {
38
+ Created = 0, PendingPayment = 1, Processing = 2, Completed = 3, EmailSent = 4,
39
+ // Error states (separated range)
40
+ Failed = 100, Cancelled = 101, Refunded = 102
41
+ }
42
+ ```
43
+
44
+ ## Validation Patterns
45
+
46
+ | Pattern | When | Example |
47
+ |---------|------|---------|
48
+ | Final state check | Block after completion | `if (status >= OrderStatus.Completed)` |
49
+ | Error state list | Block specific errors | `if (new[] { Failed, Cancelled, Refunded }.Contains(status))` |
50
+ | Range comparison | Block finalized + errors | `if (status >= Completed \|\| status >= Failed)` |
51
+
52
+ ## Anti-Patterns
53
+
54
+ | Anti-Pattern | Problem | Fix |
55
+ |-------------|---------|-----|
56
+ | `if (status != Expected)` | Assumes single flow | Validate invalid states instead |
57
+ | Exhaustive switch on valid states | Must modify for each new status | Validate only invalid states |
58
+ | Business logic in state validator | Mixed concerns | Separate state validation from business rules |
59
+
60
+ ## Complete Example
61
+
62
+ ```csharp
63
+ public async Task<Result> ProcessOrderAsync(Guid orderId, CancellationToken ct)
64
+ {
65
+ var order = await _repository.GetByIdAsync(orderId, ct);
66
+ if (order == null) return Result.Failure("Order not found");
67
+
68
+ // State validation (invalid states)
69
+ if (order.Status >= OrderStatus.Completed) return Result.Failure("Already completed");
70
+ if (order.Status == OrderStatus.Failed) return Result.Failure("Cannot process failed order");
71
+ if (order.Status == OrderStatus.Cancelled) return Result.Failure("Cannot process cancelled order");
72
+
73
+ // Business validation (separate)
74
+ if (order.RequiresPayment && !order.IsPaid) return Result.Failure("Payment required");
75
+
76
+ order.MarkAsProcessing();
77
+ await _repository.UpdateAsync(order, ct);
78
+ return Result.Success();
79
+ }
80
+ ```
81
+
82
+ ## Checklist
83
+
84
+ - [ ] Validates INVALID states (not valid)?
85
+ - [ ] Uses ordered enum comparison where possible?
86
+ - [ ] Error states treated separately (100+ range)?
87
+ - [ ] All flows documented in decisions.md?
88
+ - [ ] Tested with all possible flows?
89
+
90
+ ---
91
+
92
+ *MORPH-SPEC by Polymorphism Tech*