@polymorphism-tech/morph-spec 7.0.0 → 7.1.1

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 (89) hide show
  1. package/README.md +368 -368
  2. package/claude-plugin.json +14 -14
  3. package/docs/CHEATSHEET.md +199 -199
  4. package/docs/QUICKSTART.md +200 -200
  5. package/framework/CLAUDE.md +1 -1
  6. package/framework/MORPH.md +4 -1
  7. package/framework/agents.json +132 -127
  8. package/framework/rubrics/backend.json +41 -36
  9. package/framework/rules/ai-agents-standards.md +45 -15
  10. package/framework/rules/neon-standards.md +25 -26
  11. package/framework/skills/core/morph-brainstorming/SKILL.md +1 -1
  12. package/framework/skills/core/morph-plan/SKILL.md +3 -1
  13. package/framework/skills/core/morph-stack-scan/SKILL.md +3 -3
  14. package/framework/standards/STANDARDS.json +1729 -1133
  15. package/framework/standards/ai-agents/agent-session.md +160 -0
  16. package/framework/standards/ai-agents/batching.md +193 -0
  17. package/framework/standards/ai-agents/context-providers.md +188 -0
  18. package/framework/standards/ai-agents/mcp-server.md +250 -0
  19. package/framework/standards/ai-agents/mcp-tools.md +197 -0
  20. package/framework/standards/ai-agents/middleware-patterns.md +207 -0
  21. package/framework/standards/ai-agents/modalities-image-gen.md +173 -0
  22. package/framework/standards/ai-agents/modalities-speech-to-text.md +171 -0
  23. package/framework/standards/ai-agents/modalities-text-to-speech.md +181 -0
  24. package/framework/standards/ai-agents/modalities-vision.md +201 -0
  25. package/framework/standards/ai-agents/multi-agent-patterns.md +155 -0
  26. package/framework/standards/ai-agents/production.md +114 -258
  27. package/framework/standards/ai-agents/prompts-in-db.md +214 -0
  28. package/framework/standards/ai-agents/providers/model-registry.md +158 -0
  29. package/framework/standards/ai-agents/rag-custom-pgvector.md +243 -0
  30. package/framework/standards/ai-agents/service-tier-flex.md +135 -0
  31. package/framework/standards/ai-agents/setup.md +142 -316
  32. package/framework/standards/ai-agents/structured-output.md +249 -0
  33. package/framework/standards/ai-agents/sweet-spot.md +109 -0
  34. package/framework/standards/ai-agents/workflows.md +114 -284
  35. package/framework/standards/architecture/vertical-slice/vertical-slice.md +439 -429
  36. package/framework/standards/backend/api/validation.md +92 -88
  37. package/framework/standards/backend/database/postgresql/database.md +336 -332
  38. package/framework/standards/backend/database/vector-search-rag.md +599 -541
  39. package/framework/standards/backend/dotnet/fluent-validation-vsa.md +4 -0
  40. package/framework/standards/backend/dotnet/result-pattern.md +4 -0
  41. package/framework/standards/backend/dotnet/scalar-ui.md +176 -172
  42. package/framework/standards/backend/dotnet/scrutor.md +4 -0
  43. package/framework/standards/backend/dotnet/vsa-handler-patterns.md +310 -274
  44. package/framework/standards/backend/integrations/asaas/asaas-api.md +260 -216
  45. package/framework/standards/backend/integrations/hangfire/hangfire-jobs.md +354 -350
  46. package/framework/standards/backend/integrations/neon-auth/neon-auth.md +30 -19
  47. package/framework/standards/backend/integrations/resend/resend-email.md +400 -385
  48. package/framework/standards/data/nosql/cache/redis.md +106 -97
  49. package/framework/standards/data/nosql/cosmos-db.md +127 -118
  50. package/framework/standards/data/vector-search/rag-chunking.md +113 -104
  51. package/framework/standards/frontend/design-system/ai-image-generation.md +4 -0
  52. package/framework/standards/frontend/design-system/animations.md +164 -160
  53. package/framework/standards/frontend/design-system/naming.md +68 -64
  54. package/framework/standards/frontend/gsap/gsap-core.md +14 -8
  55. package/framework/standards/frontend/gsap/gsap-plugins.md +26 -21
  56. package/framework/standards/frontend/gsap/gsap-scrolltrigger.md +9 -7
  57. package/framework/standards/frontend/nextjs/app-router.md +127 -123
  58. package/framework/standards/frontend/nextjs/components.md +136 -132
  59. package/framework/standards/frontend/nextjs/data-fetching.md +130 -126
  60. package/framework/standards/frontend/nextjs/forms.md +134 -128
  61. package/framework/standards/frontend/nextjs/motion-patterns.md +328 -322
  62. package/framework/standards/frontend/nextjs/naming-conventions.md +71 -67
  63. package/framework/standards/frontend/nextjs/nextjs-patterns.md +229 -225
  64. package/framework/standards/frontend/nextjs/project-structure.md +106 -102
  65. package/framework/standards/frontend/nextjs/state-management.md +76 -72
  66. package/framework/standards/frontend/nextjs/testing.md +115 -111
  67. package/framework/standards/infrastructure/docker/easypanel-deploy.md +196 -192
  68. package/framework/standards/infrastructure/neon/neon-pgrag.md +6 -2
  69. package/framework/standards/infrastructure/neon/neon-pgvector.md +4 -0
  70. package/framework/standards/infrastructure/neon/neon-setup.md +5 -1
  71. package/framework/standards/integration/mcp/mcp-tools.md +471 -462
  72. package/framework/templates/CLAUDE.md.core.template +1 -1
  73. package/framework/templates/REGISTRY.json +1745 -1239
  74. package/framework/templates/code/dotnet/ai-agents/AgentBootstrap.cs.template +39 -0
  75. package/framework/templates/code/dotnet/ai-agents/EmbeddingService.cs.template +68 -0
  76. package/framework/templates/code/dotnet/ai-agents/ModelRegistry.cs.template +117 -0
  77. package/framework/templates/code/dotnet/ai-agents/PromptRepository.cs.template +95 -0
  78. package/framework/templates/code/dotnet/ai-agents/ResilientToolMiddleware.cs.template +61 -0
  79. package/framework/templates/code/dotnet/ai-agents/VectorSearchTool.cs.template +107 -0
  80. package/framework/templates/code/dotnet/ai-agents/model-registry.json.template +58 -0
  81. package/framework/templates/code/dotnet/backend/repository.cs +3 -10
  82. package/framework/templates/code/sql/ai-agents/agent-prompts-migration.sql.template +58 -0
  83. package/framework/templates/code/sql/ai-agents/pgvector-embeddings-migration.sql.template +91 -0
  84. package/package.json +89 -83
  85. package/src/core/templates/template-registry.js +289 -256
  86. package/src/lib/generators/context-generator.js +516 -518
  87. package/src/lib/generators/scaffold-generator.js +23 -26
  88. package/framework/standards/infrastructure/neon/neon-semantic-kernel.md +0 -310
  89. package/framework/templates/integrations/semantic-kernel-neon.cs +0 -125
@@ -1,128 +1,134 @@
1
- # Next.js Forms Standard
2
-
3
- > **Scope:** frontend/nextjs/forms
4
- > **Layer:** 2 (on keyword)
5
- > **Keywords:** form, react-hook-form, zod, validation, input, submit, zodResolver
6
- > **Load When:** implementing any form in Next.js
7
-
8
- react-hook-form + Zod + shadcn Form components. Schema defines both validation rules and TypeScript types.
9
-
10
- ## Core Rules
11
-
12
- - ALWAYS define the Zod schema first — derive the TypeScript type from it with `z.infer<>`
13
- - ALWAYS use `zodResolver` to connect schema to react-hook-form
14
- - ALWAYS use shadcn `<Form>`, `<FormField>`, `<FormItem>`, `<FormMessage>` for consistent UI
15
- - NEVER use `useState` for form field values — react-hook-form handles this
16
- - ALWAYS use `useMutation` from TanStack Query for form submission
17
-
18
- ## Complete Form Pattern
19
-
20
- ```tsx
21
- // features/users/types/user.schemas.ts
22
- import { z } from 'zod';
23
-
24
- export const createUserSchema = z.object({
25
- name: z.string().min(2, 'Name must be at least 2 characters'),
26
- email: z.string().email('Invalid email address'),
27
- role: z.enum(['admin', 'user'], { required_error: 'Role is required' }),
28
- });
29
-
30
- export type CreateUserInput = z.infer<typeof createUserSchema>;
31
- ```
32
-
33
- ```tsx
34
- // features/users/components/create-user-form.tsx
35
- 'use client';
36
-
37
- import { useForm } from 'react-hook-form';
38
- import { zodResolver } from '@hookform/resolvers/zod';
39
- import {
40
- Form, FormControl, FormField, FormItem, FormLabel, FormMessage
41
- } from '@/components/ui/form';
42
- import { Input } from '@/components/ui/input';
43
- import { Button } from '@/components/ui/button';
44
- import { useCreateUser } from '@/features/users/hooks/use-create-user';
45
- import { createUserSchema, type CreateUserInput } from '@/features/users/types/user.schemas';
46
-
47
- export function CreateUserForm({ onSuccess }: { onSuccess?: () => void }) {
48
- const form = useForm<CreateUserInput>({
49
- resolver: zodResolver(createUserSchema),
50
- defaultValues: { name: '', email: '', role: 'user' },
51
- });
52
-
53
- const { mutate: createUser, isPending } = useCreateUser();
54
-
55
- function onSubmit(values: CreateUserInput) {
56
- createUser(values, {
57
- onSuccess: () => { form.reset(); onSuccess?.(); },
58
- onError: (error) => form.setError('root', { message: error.message }),
59
- });
60
- }
61
-
62
- return (
63
- <Form {...form}>
64
- <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
65
- <FormField
66
- control={form.control}
67
- name="name"
68
- render={({ field }) => (
69
- <FormItem>
70
- <FormLabel>Name</FormLabel>
71
- <FormControl><Input placeholder="John Doe" {...field} /></FormControl>
72
- <FormMessage />
73
- </FormItem>
74
- )}
75
- />
76
- <FormField
77
- control={form.control}
78
- name="email"
79
- render={({ field }) => (
80
- <FormItem>
81
- <FormLabel>Email</FormLabel>
82
- <FormControl><Input type="email" {...field} /></FormControl>
83
- <FormMessage />
84
- </FormItem>
85
- )}
86
- />
87
- {form.formState.errors.root && (
88
- <p className="text-sm text-destructive">{form.formState.errors.root.message}</p>
89
- )}
90
- <Button type="submit" disabled={isPending}>
91
- {isPending ? 'Creating...' : 'Create User'}
92
- </Button>
93
- </form>
94
- </Form>
95
- );
96
- }
97
- ```
98
-
99
- ## Edit Form Pattern
100
-
101
- ```tsx
102
- // Edit forms reuse the same schema with partial()
103
- const form = useForm<UpdateUserInput>({
104
- resolver: zodResolver(updateUserSchema),
105
- defaultValues: { name: user.name, email: user.email },
106
- });
107
- ```
108
-
109
- ## Schema Composition
110
-
111
- ```ts
112
- export const userSchema = z.object({ id: z.string(), name: z.string(), email: z.string() });
113
- export const createUserSchema = userSchema.omit({ id: true });
114
- export const updateUserSchema = createUserSchema.partial();
115
- ```
116
-
117
- ## Common Mistakes
118
-
119
- | Wrong | Right | Why |
120
- |-------|-------|-----|
121
- | `useState` for each field | `useForm` | Unnecessary re-renders on every keystroke |
122
- | Manual error display | `<FormMessage />` | Consistent UI, auto-connects to field errors |
123
- | `fetch` in submit handler | `useMutation` | Loading state, error handling, cache invalidation |
124
- | Type written manually | `z.infer<typeof schema>` | Single source of truth |
125
-
126
- ---
127
-
128
- *MORPH-SPEC by Polymorphism Tech*
1
+ # Next.js Forms Standard
2
+
3
+ > **Scope:** frontend/nextjs/forms
4
+ > **Layer:** 2 (on keyword)
5
+ > **Keywords:** form, react-hook-form, zod, validation, input, submit, zodResolver
6
+ > **Load When:** implementing any form in Next.js
7
+
8
+ **Verified against:** Next.js 15 + react-hook-form 7 + Zod 4 + @hookform/resolvers 3. Last-verified: 2026-05-20.
9
+
10
+ ---
11
+
12
+ react-hook-form + Zod + shadcn Form components. Schema defines both validation rules and TypeScript types.
13
+
14
+ ## Core Rules
15
+
16
+ - ALWAYS define the Zod schema first — derive the TypeScript type from it with `z.infer<>`
17
+ - ALWAYS use `zodResolver` to connect schema to react-hook-form
18
+ - ALWAYS use shadcn `<Form>`, `<FormField>`, `<FormItem>`, `<FormMessage>` for consistent UI
19
+ - NEVER use `useState` for form field values — react-hook-form handles this
20
+ - ALWAYS use `useMutation` from TanStack Query for form submission
21
+
22
+ ## Complete Form Pattern
23
+
24
+ ```tsx
25
+ // features/users/types/user.schemas.ts
26
+ import { z } from 'zod';
27
+
28
+ export const createUserSchema = z.object({
29
+ name: z.string().min(2, 'Name must be at least 2 characters'),
30
+ email: z.email('Invalid email address'),
31
+ role: z.enum(['admin', 'user'], { error: 'Role is required' }),
32
+ });
33
+
34
+ export type CreateUserInput = z.infer<typeof createUserSchema>;
35
+ ```
36
+
37
+ ```tsx
38
+ // features/users/components/create-user-form.tsx
39
+ 'use client';
40
+
41
+ import { useForm } from 'react-hook-form';
42
+ import { zodResolver } from '@hookform/resolvers/zod';
43
+ import {
44
+ Form, FormControl, FormField, FormItem, FormLabel, FormMessage
45
+ } from '@/components/ui/form';
46
+ import { Input } from '@/components/ui/input';
47
+ import { Button } from '@/components/ui/button';
48
+ import { useCreateUser } from '@/features/users/hooks/use-create-user';
49
+ import { createUserSchema, type CreateUserInput } from '@/features/users/types/user.schemas';
50
+
51
+ export function CreateUserForm({ onSuccess }: { onSuccess?: () => void }) {
52
+ const form = useForm<CreateUserInput>({
53
+ resolver: zodResolver(createUserSchema),
54
+ defaultValues: { name: '', email: '', role: 'user' },
55
+ });
56
+
57
+ const { mutate: createUser, isPending } = useCreateUser();
58
+
59
+ function onSubmit(values: CreateUserInput) {
60
+ createUser(values, {
61
+ onSuccess: () => { form.reset(); onSuccess?.(); },
62
+ onError: (error) => form.setError('root', { message: error.message }),
63
+ });
64
+ }
65
+
66
+ return (
67
+ <Form {...form}>
68
+ <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
69
+ <FormField
70
+ control={form.control}
71
+ name="name"
72
+ render={({ field }) => (
73
+ <FormItem>
74
+ <FormLabel>Name</FormLabel>
75
+ <FormControl><Input placeholder="John Doe" {...field} /></FormControl>
76
+ <FormMessage />
77
+ </FormItem>
78
+ )}
79
+ />
80
+ <FormField
81
+ control={form.control}
82
+ name="email"
83
+ render={({ field }) => (
84
+ <FormItem>
85
+ <FormLabel>Email</FormLabel>
86
+ <FormControl><Input type="email" {...field} /></FormControl>
87
+ <FormMessage />
88
+ </FormItem>
89
+ )}
90
+ />
91
+ {form.formState.errors.root && (
92
+ <p className="text-sm text-destructive">{form.formState.errors.root.message}</p>
93
+ )}
94
+ <Button type="submit" disabled={isPending}>
95
+ {isPending ? 'Creating...' : 'Create User'}
96
+ </Button>
97
+ </form>
98
+ </Form>
99
+ );
100
+ }
101
+ ```
102
+
103
+ ## Edit Form Pattern
104
+
105
+ ```tsx
106
+ // Edit forms reuse the same schema with partial()
107
+ const form = useForm<UpdateUserInput>({
108
+ resolver: zodResolver(updateUserSchema),
109
+ defaultValues: { name: user.name, email: user.email },
110
+ });
111
+ ```
112
+
113
+ ## Schema Composition
114
+
115
+ ```ts
116
+ export const userSchema = z.object({ id: z.string(), name: z.string(), email: z.string() });
117
+ export const createUserSchema = userSchema.omit({ id: true });
118
+ export const updateUserSchema = createUserSchema.partial();
119
+ ```
120
+
121
+ ## Common Mistakes
122
+
123
+ | Wrong | Right | Why |
124
+ |-------|-------|-----|
125
+ | `useState` for each field | `useForm` | Unnecessary re-renders on every keystroke |
126
+ | Manual error display | `<FormMessage />` | Consistent UI, auto-connects to field errors |
127
+ | `fetch` in submit handler | `useMutation` | Loading state, error handling, cache invalidation |
128
+ | Type written manually | `z.infer<typeof schema>` | Single source of truth |
129
+ | `z.string().email()` | `z.email()` | Zod 4 moved format checks to top-level functions |
130
+ | `{ required_error: '...' }` | `{ error: '...' }` | Zod 4 unified error customization on one `error` param |
131
+
132
+ ---
133
+
134
+ *MORPH-SPEC by Polymorphism Tech*