@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.
- package/README.md +368 -368
- package/claude-plugin.json +14 -14
- package/docs/CHEATSHEET.md +199 -199
- package/docs/QUICKSTART.md +200 -200
- package/framework/CLAUDE.md +1 -1
- package/framework/MORPH.md +4 -1
- package/framework/agents.json +132 -127
- package/framework/rubrics/backend.json +41 -36
- package/framework/rules/ai-agents-standards.md +45 -15
- package/framework/rules/neon-standards.md +25 -26
- package/framework/skills/core/morph-brainstorming/SKILL.md +1 -1
- package/framework/skills/core/morph-plan/SKILL.md +3 -1
- package/framework/skills/core/morph-stack-scan/SKILL.md +3 -3
- package/framework/standards/STANDARDS.json +1729 -1133
- package/framework/standards/ai-agents/agent-session.md +160 -0
- package/framework/standards/ai-agents/batching.md +193 -0
- package/framework/standards/ai-agents/context-providers.md +188 -0
- package/framework/standards/ai-agents/mcp-server.md +250 -0
- package/framework/standards/ai-agents/mcp-tools.md +197 -0
- package/framework/standards/ai-agents/middleware-patterns.md +207 -0
- package/framework/standards/ai-agents/modalities-image-gen.md +173 -0
- package/framework/standards/ai-agents/modalities-speech-to-text.md +171 -0
- package/framework/standards/ai-agents/modalities-text-to-speech.md +181 -0
- package/framework/standards/ai-agents/modalities-vision.md +201 -0
- package/framework/standards/ai-agents/multi-agent-patterns.md +155 -0
- package/framework/standards/ai-agents/production.md +114 -258
- package/framework/standards/ai-agents/prompts-in-db.md +214 -0
- package/framework/standards/ai-agents/providers/model-registry.md +158 -0
- package/framework/standards/ai-agents/rag-custom-pgvector.md +243 -0
- package/framework/standards/ai-agents/service-tier-flex.md +135 -0
- package/framework/standards/ai-agents/setup.md +142 -316
- package/framework/standards/ai-agents/structured-output.md +249 -0
- package/framework/standards/ai-agents/sweet-spot.md +109 -0
- package/framework/standards/ai-agents/workflows.md +114 -284
- package/framework/standards/architecture/vertical-slice/vertical-slice.md +439 -429
- package/framework/standards/backend/api/validation.md +92 -88
- package/framework/standards/backend/database/postgresql/database.md +336 -332
- package/framework/standards/backend/database/vector-search-rag.md +599 -541
- package/framework/standards/backend/dotnet/fluent-validation-vsa.md +4 -0
- package/framework/standards/backend/dotnet/result-pattern.md +4 -0
- package/framework/standards/backend/dotnet/scalar-ui.md +176 -172
- package/framework/standards/backend/dotnet/scrutor.md +4 -0
- package/framework/standards/backend/dotnet/vsa-handler-patterns.md +310 -274
- package/framework/standards/backend/integrations/asaas/asaas-api.md +260 -216
- package/framework/standards/backend/integrations/hangfire/hangfire-jobs.md +354 -350
- package/framework/standards/backend/integrations/neon-auth/neon-auth.md +30 -19
- package/framework/standards/backend/integrations/resend/resend-email.md +400 -385
- package/framework/standards/data/nosql/cache/redis.md +106 -97
- package/framework/standards/data/nosql/cosmos-db.md +127 -118
- package/framework/standards/data/vector-search/rag-chunking.md +113 -104
- package/framework/standards/frontend/design-system/ai-image-generation.md +4 -0
- package/framework/standards/frontend/design-system/animations.md +164 -160
- package/framework/standards/frontend/design-system/naming.md +68 -64
- package/framework/standards/frontend/gsap/gsap-core.md +14 -8
- package/framework/standards/frontend/gsap/gsap-plugins.md +26 -21
- package/framework/standards/frontend/gsap/gsap-scrolltrigger.md +9 -7
- package/framework/standards/frontend/nextjs/app-router.md +127 -123
- package/framework/standards/frontend/nextjs/components.md +136 -132
- package/framework/standards/frontend/nextjs/data-fetching.md +130 -126
- package/framework/standards/frontend/nextjs/forms.md +134 -128
- package/framework/standards/frontend/nextjs/motion-patterns.md +328 -322
- package/framework/standards/frontend/nextjs/naming-conventions.md +71 -67
- package/framework/standards/frontend/nextjs/nextjs-patterns.md +229 -225
- package/framework/standards/frontend/nextjs/project-structure.md +106 -102
- package/framework/standards/frontend/nextjs/state-management.md +76 -72
- package/framework/standards/frontend/nextjs/testing.md +115 -111
- package/framework/standards/infrastructure/docker/easypanel-deploy.md +196 -192
- package/framework/standards/infrastructure/neon/neon-pgrag.md +6 -2
- package/framework/standards/infrastructure/neon/neon-pgvector.md +4 -0
- package/framework/standards/infrastructure/neon/neon-setup.md +5 -1
- package/framework/standards/integration/mcp/mcp-tools.md +471 -462
- package/framework/templates/CLAUDE.md.core.template +1 -1
- package/framework/templates/REGISTRY.json +1745 -1239
- package/framework/templates/code/dotnet/ai-agents/AgentBootstrap.cs.template +39 -0
- package/framework/templates/code/dotnet/ai-agents/EmbeddingService.cs.template +68 -0
- package/framework/templates/code/dotnet/ai-agents/ModelRegistry.cs.template +117 -0
- package/framework/templates/code/dotnet/ai-agents/PromptRepository.cs.template +95 -0
- package/framework/templates/code/dotnet/ai-agents/ResilientToolMiddleware.cs.template +61 -0
- package/framework/templates/code/dotnet/ai-agents/VectorSearchTool.cs.template +107 -0
- package/framework/templates/code/dotnet/ai-agents/model-registry.json.template +58 -0
- package/framework/templates/code/dotnet/backend/repository.cs +3 -10
- package/framework/templates/code/sql/ai-agents/agent-prompts-migration.sql.template +58 -0
- package/framework/templates/code/sql/ai-agents/pgvector-embeddings-migration.sql.template +91 -0
- package/package.json +89 -83
- package/src/core/templates/template-registry.js +289 -256
- package/src/lib/generators/context-generator.js +516 -518
- package/src/lib/generators/scaffold-generator.js +23 -26
- package/framework/standards/infrastructure/neon/neon-semantic-kernel.md +0 -310
- 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 +
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
- ALWAYS
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} from '
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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*
|