@polymorphism-tech/morph-spec 4.16.0 → 4.17.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 (98) hide show
  1. package/README.md +2 -2
  2. package/bin/morph-spec.js +3 -0
  3. package/bin/task-manager.js +999 -962
  4. package/claude-plugin.json +1 -1
  5. package/docs/CHEATSHEET.md +1 -1
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/agents/ai-agents/vector-search-expert.md +247 -233
  8. package/framework/agents/backend/ms-agent-expert.md +1 -1
  9. package/framework/agents/backend/neon-expert.md +397 -0
  10. package/framework/agents/frontend/gsap-animator.md +131 -0
  11. package/framework/agents.json +1175 -1085
  12. package/framework/commands/morph-preflight.md +200 -192
  13. package/framework/hooks/claude-code/session-start/inject-morph-context.js +1 -1
  14. package/framework/rules/gsap-standards.md +13 -0
  15. package/framework/rules/neon-standards.md +25 -0
  16. package/framework/skills/level-0-meta/mcp-registry.json +1 -1
  17. package/framework/skills/level-0-meta/morph-agent-teams/SKILL.md +472 -472
  18. package/framework/skills/level-0-meta/morph-init/SKILL.md +11 -11
  19. package/framework/skills/level-0-meta/morph-post-implementation/SKILL.md +5 -5
  20. package/framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md +5 -5
  21. package/framework/skills/level-0-meta/morph-tool-usage-guide/references/tools-per-phase.md +7 -7
  22. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +24 -24
  23. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +12 -12
  24. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +9 -9
  25. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +1 -1
  26. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +1 -1
  27. package/framework/skills/level-1-workflows/morph-phase-tasks/references/task-planning-patterns.md +143 -143
  28. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +1 -1
  29. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +1 -1
  30. package/framework/standards/STANDARDS.json +184 -107
  31. package/framework/standards/ai-agents/production.md +1 -0
  32. package/framework/standards/ai-agents/setup.md +3 -2
  33. package/framework/standards/ai-agents/workflows.md +1 -0
  34. package/framework/standards/architecture/vertical-slice/vertical-slice.md +4 -4
  35. package/framework/standards/backend/database/postgresql/database.md +58 -78
  36. package/framework/standards/backend/dotnet/scalar-ui.md +172 -172
  37. package/framework/standards/backend/dotnet/vsa-handler-patterns.md +274 -274
  38. package/framework/standards/backend/integrations/asaas/asaas-api.md +1 -1
  39. package/framework/standards/backend/integrations/clerk/clerk-auth.md +23 -21
  40. package/framework/standards/frontend/design-system/animations.md +9 -0
  41. package/framework/standards/frontend/gsap/gsap-core.md +463 -0
  42. package/framework/standards/frontend/gsap/gsap-plugins.md +294 -0
  43. package/framework/standards/frontend/gsap/gsap-scrolltrigger.md +318 -0
  44. package/framework/standards/frontend/nextjs/motion-patterns.md +1 -0
  45. package/framework/standards/frontend/nextjs/nextjs-patterns.md +47 -37
  46. package/framework/standards/infrastructure/docker/easypanel-deploy.md +4 -8
  47. package/framework/standards/infrastructure/neon/neon-pgrag.md +239 -0
  48. package/framework/standards/infrastructure/neon/neon-pgvector.md +236 -0
  49. package/framework/standards/infrastructure/neon/neon-semantic-kernel.md +310 -0
  50. package/framework/standards/infrastructure/neon/neon-setup.md +186 -0
  51. package/framework/standards/integration/mcp/mcp-tools.md +32 -34
  52. package/framework/templates/README.md +18 -18
  53. package/framework/templates/REGISTRY.json +49 -96
  54. package/framework/templates/code/dotnet/abstractions/api-endpoint.cs +7 -7
  55. package/framework/templates/code/dotnet/backend/repository.cs +148 -148
  56. package/framework/templates/code/dotnet/contracts/contracts-vsa.cs +2 -2
  57. package/framework/templates/code/dotnet/database/vector-entity.cs +93 -0
  58. package/framework/templates/code/dotnet/feature/endpoint.cs.hbs +1 -1
  59. package/framework/templates/code/sql/{supabase-migration.sql → postgresql-migration.sql} +8 -17
  60. package/framework/templates/code/sql/{supabase-migration.template.sql → postgresql-migration.template.sql} +10 -13
  61. package/framework/templates/code/sql/{rls-policy.sql → postgresql-rls-policy.sql} +8 -8
  62. package/framework/templates/code/typescript/contracts.ts +167 -168
  63. package/framework/templates/context/CONTEXT.md +3 -3
  64. package/framework/templates/docs/proposal.md +6 -6
  65. package/framework/templates/docs/ui-components.md +1 -1
  66. package/framework/templates/feature/decisions.md +121 -121
  67. package/framework/templates/feature/recap.md +145 -145
  68. package/framework/templates/feature/tasks.md +199 -199
  69. package/framework/templates/frontend/nextjs/gsap-scroll-section.tsx.hbs +44 -0
  70. package/framework/templates/infrastructure/docker/docker-compose.template.yml +50 -67
  71. package/framework/templates/infrastructure/docker/dockerfile-api.dockerfile +38 -38
  72. package/framework/templates/infrastructure/docker/dockerfile-web.dockerfile +48 -48
  73. package/framework/templates/infrastructure/docker/easypanel.template.json +46 -54
  74. package/framework/templates/infrastructure/github/README.md +56 -56
  75. package/framework/templates/integrations/semantic-kernel-neon.cs +125 -0
  76. package/framework/workflows/README.md +1 -1
  77. package/framework/workflows/docs/full-morph.md +69 -69
  78. package/package.json +1 -1
  79. package/src/commands/agents/dispatch-agents.js +19 -15
  80. package/src/commands/state/advance-phase.js +5 -0
  81. package/src/commands/tasks/task.js +3 -0
  82. package/src/core/state/state-manager.js +45 -1
  83. package/src/core/templates/template-registry.js +1 -66
  84. package/src/lib/detectors/index.js +2 -2
  85. package/src/lib/generators/architecture-scanner.js +640 -640
  86. package/src/lib/installers/mcp-installer.js +1 -1
  87. package/src/lib/tasks/task-classifier.js +15 -1
  88. package/src/lib/tasks/test-runner.js +5 -1
  89. package/src/lib/validators/content/content-validator.js +9 -10
  90. package/src/lib/validators/validation-runner.js +7 -5
  91. package/framework/agents/backend/supabase-expert.md +0 -256
  92. package/framework/rules/supabase-standards.md +0 -29
  93. package/framework/standards/infrastructure/supabase/mcp-setup.md +0 -142
  94. package/framework/standards/infrastructure/supabase/supabase-auth.md +0 -176
  95. package/framework/standards/infrastructure/supabase/supabase-custom-jwt.md +0 -206
  96. package/framework/standards/infrastructure/supabase/supabase-pgvector.md +0 -169
  97. package/framework/standards/infrastructure/supabase/supabase-rls.md +0 -184
  98. package/framework/standards/infrastructure/supabase/supabase-storage.md +0 -153
@@ -1,184 +0,0 @@
1
- # Supabase Row Level Security Standard
2
-
3
- > **Scope:** nextjs-supabase
4
- > **Layer:** 2 (on keyword)
5
- > **Keywords:** supabase, rls, policy, security, row level security
6
- > **Load When:** supabase rls keywords detected
7
-
8
- Stack: Next.js 15 + Supabase + .NET Backend
9
-
10
- ## Core Rules
11
-
12
- - ALWAYS enable RLS on every table: `ALTER TABLE t ENABLE ROW LEVEL SECURITY`
13
- - NEVER rely solely on application-level filtering — RLS is the security boundary
14
- - `service_role` key bypasses ALL RLS — use only on trusted backend
15
- - ALWAYS create at least one policy after enabling RLS — otherwise no rows are accessible
16
- - ALWAYS add indexes on columns used in RLS policies
17
-
18
- ## Policy Syntax
19
-
20
- ### USING vs WITH CHECK
21
-
22
- | Clause | Applies To | Purpose |
23
- |--------|-----------|---------|
24
- | `USING (expr)` | SELECT, UPDATE, DELETE | Filter which existing rows are visible |
25
- | `WITH CHECK (expr)` | INSERT, UPDATE | Validate new/modified row data |
26
-
27
- ```sql
28
- -- SELECT: only see your own rows
29
- CREATE POLICY "users_select_own" ON documents
30
- FOR SELECT USING (user_id = auth.uid());
31
-
32
- -- INSERT: can only insert rows owned by you
33
- CREATE POLICY "users_insert_own" ON documents
34
- FOR INSERT WITH CHECK (user_id = auth.uid());
35
-
36
- -- UPDATE: can only see AND modify your own rows
37
- CREATE POLICY "users_update_own" ON documents
38
- FOR UPDATE
39
- USING (user_id = auth.uid())
40
- WITH CHECK (user_id = auth.uid());
41
-
42
- -- DELETE: can only delete your own rows
43
- CREATE POLICY "users_delete_own" ON documents
44
- FOR DELETE USING (user_id = auth.uid());
45
- ```
46
-
47
- ## Auth Functions
48
-
49
- | Function | Returns | Use Case |
50
- |----------|---------|----------|
51
- | `auth.uid()` | UUID of authenticated user | Ownership checks |
52
- | `auth.jwt()` | Full JWT claims as JSON | Custom claims, roles, tenant ID |
53
- | `auth.role()` | Current role string | Distinguish anon vs authenticated |
54
-
55
- ```sql
56
- -- Access custom JWT claims
57
- auth.jwt() ->> 'tenant_id'
58
- auth.jwt() -> 'app_metadata' ->> 'role'
59
- ```
60
-
61
- ## Common Patterns
62
-
63
- ### 1. Ownership
64
-
65
- ```sql
66
- ALTER TABLE documents ENABLE ROW LEVEL SECURITY;
67
-
68
- CREATE POLICY "owner_all" ON documents
69
- FOR ALL USING (user_id = auth.uid())
70
- WITH CHECK (user_id = auth.uid());
71
- ```
72
-
73
- ### 2. Tenant Isolation
74
-
75
- ```sql
76
- -- Requires tenant_id in JWT app_metadata
77
- CREATE POLICY "tenant_isolation" ON orders
78
- FOR ALL
79
- USING (tenant_id = (auth.jwt() -> 'app_metadata' ->> 'tenant_id')::uuid)
80
- WITH CHECK (tenant_id = (auth.jwt() -> 'app_metadata' ->> 'tenant_id')::uuid);
81
- ```
82
-
83
- ### 3. Role-Based Access
84
-
85
- ```sql
86
- -- Admins see everything, users see own
87
- CREATE POLICY "admin_full_access" ON documents
88
- FOR ALL USING (
89
- auth.jwt() -> 'app_metadata' ->> 'role' = 'admin'
90
- );
91
-
92
- CREATE POLICY "user_own_access" ON documents
93
- FOR ALL USING (user_id = auth.uid())
94
- WITH CHECK (user_id = auth.uid());
95
- ```
96
-
97
- ### 4. Public Read, Authenticated Write
98
-
99
- ```sql
100
- CREATE POLICY "public_read" ON posts
101
- FOR SELECT USING (published = true);
102
-
103
- CREATE POLICY "auth_write" ON posts
104
- FOR INSERT WITH CHECK (auth.role() = 'authenticated');
105
- ```
106
-
107
- ### 5. Team/Organization Access
108
-
109
- ```sql
110
- CREATE POLICY "team_access" ON projects
111
- FOR SELECT USING (
112
- EXISTS (
113
- SELECT 1 FROM team_members
114
- WHERE team_members.team_id = projects.team_id
115
- AND team_members.user_id = auth.uid()
116
- )
117
- );
118
- ```
119
-
120
- ## Index Recommendations
121
-
122
- Always index columns used in RLS policies for performance:
123
-
124
- ```sql
125
- CREATE INDEX idx_documents_user_id ON documents (user_id);
126
- CREATE INDEX idx_orders_tenant_id ON orders (tenant_id);
127
- CREATE INDEX idx_team_members_lookup ON team_members (team_id, user_id);
128
- ```
129
-
130
- ## Testing RLS Policies
131
-
132
- ### Via SQL (Supabase SQL Editor)
133
-
134
- ```sql
135
- -- Test as a specific user
136
- SET request.jwt.claims = '{"sub": "user-uuid-here", "role": "authenticated",
137
- "app_metadata": {"tenant_id": "tenant-uuid", "role": "admin"}}';
138
- SET role = 'authenticated';
139
-
140
- SELECT * FROM documents; -- should only return rows matching policy
141
-
142
- RESET role;
143
- RESET request.jwt.claims;
144
- ```
145
-
146
- ### Via Client (different auth contexts)
147
-
148
- ```ts
149
- // Test with anon key (unauthenticated)
150
- const anonClient = createClient(url, anonKey);
151
- const { data } = await anonClient.from("documents").select("*");
152
- // Should return empty if no public policy
153
-
154
- // Test with authenticated user
155
- const { data: userData } = await authClient.from("documents").select("*");
156
- // Should return only user's rows
157
- ```
158
-
159
- ## Migration Pattern
160
-
161
- ```sql
162
- -- migration: 001_enable_rls.sql
163
- ALTER TABLE documents ENABLE ROW LEVEL SECURITY;
164
- ALTER TABLE orders ENABLE ROW LEVEL SECURITY;
165
- ALTER TABLE team_members ENABLE ROW LEVEL SECURITY;
166
-
167
- -- Always pair with policies
168
- CREATE POLICY "documents_owner" ON documents
169
- FOR ALL USING (user_id = auth.uid())
170
- WITH CHECK (user_id = auth.uid());
171
- ```
172
-
173
- ## Common Mistakes
174
-
175
- | Wrong | Right | Why |
176
- |-------|-------|-----|
177
- | Enable RLS without policies | Enable RLS + create policies | No policies = no access at all |
178
- | `FOR ALL USING (true)` | Specific conditions per operation | Grants unrestricted access, defeats RLS |
179
- | UPDATE with only USING | UPDATE with USING + WITH CHECK | User could change user_id to another user |
180
- | Complex subqueries in policies | Simple conditions + indexed columns | Subqueries in policies cause N+1 perf issues |
181
- | Using `anon` key as service_role | Separate keys, service_role only on backend | anon key respects RLS (correct), don't confuse |
182
- | RLS on some tables but not others | RLS on ALL tables with user data | Attackers target unprotected tables |
183
- | `auth.uid()` without null check | `auth.uid() IS NOT NULL AND user_id = auth.uid()` | Prevents anon access when policy is permissive |
184
- | Forgetting junction table RLS | RLS on junction tables too | team_members without RLS leaks membership |
@@ -1,153 +0,0 @@
1
- # Supabase Storage Standard
2
-
3
- > **Scope:** nextjs-supabase
4
- > **Layer:** 2 (on keyword)
5
- > **Keywords:** supabase, storage, bucket, upload, file storage
6
- > **Load When:** supabase storage keywords detected
7
-
8
- Stack: Next.js 15 + Supabase + .NET Backend
9
-
10
- ## Core Rules
11
-
12
- - ALWAYS use RLS policies on storage.objects for access control
13
- - NEVER serve private files without signed URLs
14
- - ALWAYS validate file type and size before upload
15
- - Public buckets: anyone can read, still need auth for write
16
- - Private buckets: require signed URLs or authenticated access
17
-
18
- ## Bucket Configuration
19
-
20
- ```sql
21
- -- Public bucket (avatars, logos)
22
- INSERT INTO storage.buckets (id, name, public, file_size_limit, allowed_mime_types)
23
- VALUES ('avatars', 'avatars', true, 2097152, ARRAY['image/jpeg','image/png','image/webp']);
24
-
25
- -- Private bucket (documents, reports)
26
- INSERT INTO storage.buckets (id, name, public, file_size_limit, allowed_mime_types)
27
- VALUES ('documents', 'documents', false, 10485760, ARRAY['application/pdf','image/jpeg','image/png']);
28
- ```
29
-
30
- | Setting | Public Bucket | Private Bucket |
31
- |---------|--------------|----------------|
32
- | Read access | Anyone via URL | Signed URL or auth required |
33
- | Write access | RLS policy required | RLS policy required |
34
- | Use case | Avatars, public images | Documents, reports |
35
-
36
- ## Storage RLS Policies
37
-
38
- ```sql
39
- -- Users upload/view/delete in their own folder
40
- CREATE POLICY "user_upload" ON storage.objects FOR INSERT
41
- WITH CHECK (bucket_id = 'documents' AND (storage.foldername(name))[1] = auth.uid()::text);
42
-
43
- CREATE POLICY "user_select" ON storage.objects FOR SELECT
44
- USING (bucket_id = 'documents' AND (storage.foldername(name))[1] = auth.uid()::text);
45
-
46
- CREATE POLICY "user_delete" ON storage.objects FOR DELETE
47
- USING (bucket_id = 'documents' AND (storage.foldername(name))[1] = auth.uid()::text);
48
-
49
- -- Public bucket: anyone reads, auth users upload to own folder
50
- CREATE POLICY "public_read" ON storage.objects FOR SELECT
51
- USING (bucket_id = 'avatars');
52
-
53
- CREATE POLICY "auth_upload_avatar" ON storage.objects FOR INSERT
54
- WITH CHECK (bucket_id = 'avatars' AND (storage.foldername(name))[1] = auth.uid()::text);
55
- ```
56
-
57
- ## Path Naming Convention
58
-
59
- ```
60
- {bucket}/{user_id}/{category}/{filename}
61
- avatars/{user_id}/profile.webp
62
- documents/{user_id}/invoices/2026-01-invoice.pdf
63
- ```
64
-
65
- First folder segment = user_id (enables simple RLS). Use lowercase, hyphens, include extension.
66
-
67
- ## Upload Patterns
68
-
69
- ### Browser Upload (Next.js)
70
-
71
- ```ts
72
- async function uploadFile(file: File, userId: string) {
73
- if (file.size > 10 * 1024 * 1024) throw new Error("File too large");
74
- const allowedTypes = ["application/pdf", "image/jpeg", "image/png"];
75
- if (!allowedTypes.includes(file.type)) throw new Error("Invalid type");
76
-
77
- const path = `${userId}/uploads/${Date.now()}-${file.name}`;
78
- const { data, error } = await supabase.storage
79
- .from("documents")
80
- .upload(path, file, { cacheControl: "3600", upsert: false, contentType: file.type });
81
- if (error) throw error;
82
- return data.path;
83
- }
84
- ```
85
-
86
- ### Server Upload (.NET)
87
-
88
- ```csharp
89
- public sealed class StorageService(Supabase.Client client, ILogger<StorageService> logger)
90
- {
91
- private static readonly string[] AllowedTypes = ["application/pdf", "image/jpeg", "image/png"];
92
-
93
- public async Task<string> UploadAsync(
94
- string bucket, string path, Stream stream,
95
- string contentType, CancellationToken ct = default)
96
- {
97
- if (!AllowedTypes.Contains(contentType))
98
- throw new ValidationException($"Invalid content type: {contentType}");
99
- var response = await client.Storage.From(bucket)
100
- .Upload(stream, path, new FileOptions { ContentType = contentType, Upsert = false });
101
- return response;
102
- }
103
- }
104
- ```
105
-
106
- ## Download and Signed URLs
107
-
108
- ```ts
109
- // Public bucket: direct URL
110
- const { data } = supabase.storage.from("avatars").getPublicUrl("user-id/profile.webp");
111
-
112
- // Private bucket: signed URL (time-limited)
113
- const { data } = await supabase.storage
114
- .from("documents").createSignedUrl("user-id/report.pdf", 3600); // 1 hour
115
-
116
- // Download file content (returns Blob)
117
- const { data } = await supabase.storage.from("documents").download("user-id/report.pdf");
118
- ```
119
-
120
- ## Image Transformations
121
-
122
- ```ts
123
- const { data } = supabase.storage.from("avatars").getPublicUrl("user-id/photo.jpg", {
124
- transform: { width: 200, height: 200, resize: "cover", quality: 80 },
125
- });
126
- ```
127
-
128
- | Parameter | Options | Default |
129
- |-----------|---------|---------|
130
- | `width` / `height` | 1-2500 px | original |
131
- | `resize` | cover, contain, fill | cover |
132
- | `quality` | 20-100 | 80 |
133
- | `format` | origin, avif, webp | origin |
134
-
135
- ## File Validation
136
-
137
- | Check | Client-Side | Server-Side | Bucket Config |
138
- |-------|------------|-------------|---------------|
139
- | File size | `file.size` | Stream length | `file_size_limit` |
140
- | MIME type | `file.type` | Content-Type | `allowed_mime_types` |
141
- | Extension | File name | File name | -- |
142
-
143
- Always validate at all three levels. Client-side can be bypassed.
144
-
145
- ## Common Mistakes
146
-
147
- | Wrong | Right | Why |
148
- |-------|-------|-----|
149
- | No RLS on storage.objects | Policies for each bucket | Anyone can read/write without policies |
150
- | Private files via public URL | `createSignedUrl()` | Private bucket returns 403 without auth |
151
- | User-provided filename as-is | Sanitize + timestamp prefix | Path traversal attacks, collisions |
152
- | `upsert: true` by default | `upsert: false` | Prevents accidental file overwrites |
153
- | Files without user folder | `{user_id}/...` path pattern | Cannot write simple RLS policies |