@polymorphism-tech/morph-spec 4.14.0 → 4.15.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.
- package/README.md +2 -2
- package/claude-plugin.json +1 -1
- package/docs/CHEATSHEET.md +1 -1
- package/docs/QUICKSTART.md +1 -1
- package/framework/agents/ai-agents/ai-system-architect.md +2 -0
- package/framework/agents/ai-agents/vector-search-expert.md +233 -0
- package/framework/agents/architecture/seo-growth-hacker.md +2 -0
- package/framework/agents/architecture/standards-architect.md +3 -0
- package/framework/agents/backend/dotnet-senior.md +3 -0
- package/framework/agents/backend/ef-modeler.md +2 -0
- package/framework/agents/backend/hangfire-orchestrator.md +2 -0
- package/framework/agents/backend/ms-agent-expert.md +2 -0
- package/framework/agents/backend/supabase-expert.md +256 -0
- package/framework/agents/frontend/css-specialist.md +2 -0
- package/framework/agents/frontend/nextjs-expert.md +3 -0
- package/framework/agents/frontend/ui-ux-designer.md +3 -1
- package/framework/agents/infrastructure/infra-architect.md +3 -0
- package/framework/agents/integrations/asaas-financial.md +2 -0
- package/framework/agents/integrations/clerk-auth.md +2 -0
- package/framework/agents/integrations/resend-email.md +2 -0
- package/framework/agents.json +23 -30
- package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +1 -1
- package/package.json +1 -1
- package/src/utils/agents-installer.js +18 -8
- package/framework/agents/integrations/hangfire-integration.md +0 -69
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> Spec-driven development framework for multi-stack projects. Turns feature requests into implementation-ready code through structured, AI-orchestrated phases.
|
|
4
4
|
|
|
5
5
|
**Package:** `@polymorphism-tech/morph-spec`
|
|
6
|
-
**Version:** 4.
|
|
6
|
+
**Version:** 4.15.0
|
|
7
7
|
**Requires:** Node.js 18+, Claude Code
|
|
8
8
|
|
|
9
9
|
---
|
|
@@ -364,4 +364,4 @@ Code generated by morph-spec (contracts, templates, implementation output) belon
|
|
|
364
364
|
|
|
365
365
|
---
|
|
366
366
|
|
|
367
|
-
*morph-spec v4.
|
|
367
|
+
*morph-spec v4.15.0 by [Polymorphism Tech](https://polymorphism.tech)*
|
package/claude-plugin.json
CHANGED
package/docs/CHEATSHEET.md
CHANGED
package/docs/QUICKSTART.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
name: ai-system-architect
|
|
3
3
|
description: AI System Architect specialist for designing multi-agent systems, LLM orchestration, RAG pipelines, and Semantic Kernel patterns. Use when designing AI agent architectures, implementing LLM-powered features, building RAG pipelines, or integrating Microsoft Agent Framework.
|
|
4
4
|
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
5
|
+
color: orange
|
|
6
|
+
effort: high
|
|
5
7
|
---
|
|
6
8
|
|
|
7
9
|
# AI System Architect
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vector-search-expert
|
|
3
|
+
description: Vector Search & RAG specialist for embedding pipelines, pgvector indexes, semantic search, hybrid search, and retrieval-augmented generation. Use when implementing embedding generation, vector similarity search, RAG pipelines, or hybrid full-text + vector search.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
5
|
+
color: yellow
|
|
6
|
+
effort: medium
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Vector Search & RAG Specialist
|
|
10
|
+
|
|
11
|
+
Expert in embedding pipelines, pgvector, semantic search, and retrieval-augmented generation.
|
|
12
|
+
|
|
13
|
+
> **Ref:** `framework/standards/backend/database/vector-search-rag.md` — Chunking, embedding, retrieval patterns
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Embedding Pipeline
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
Documents → Chunking → Embedding → pgvector Storage → Retrieval → LLM
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Chunking Strategies
|
|
24
|
+
|
|
25
|
+
| Strategy | Method | Best For | Chunk Size |
|
|
26
|
+
|----------|--------|----------|------------|
|
|
27
|
+
| **Paragraph** | Split by `\n\n` | General text | 200-500 tokens |
|
|
28
|
+
| **Markdown Headers** | Split by `#`, `##` | Documentation | Variable |
|
|
29
|
+
| **Token-based** | Fixed token windows | Uniform chunks | 256-512 tokens |
|
|
30
|
+
| **Semantic** | Cosine similarity threshold | Highest quality | Variable |
|
|
31
|
+
|
|
32
|
+
**Always overlap:** 10-20% overlap between chunks prevents context loss at boundaries.
|
|
33
|
+
|
|
34
|
+
```csharp
|
|
35
|
+
// Simple paragraph chunker
|
|
36
|
+
public static IEnumerable<string> ChunkByParagraph(string text, int maxTokens = 500)
|
|
37
|
+
{
|
|
38
|
+
var paragraphs = text.Split("\n\n", StringSplitOptions.RemoveEmptyEntries);
|
|
39
|
+
var current = new StringBuilder();
|
|
40
|
+
var currentTokens = 0;
|
|
41
|
+
|
|
42
|
+
foreach (var para in paragraphs)
|
|
43
|
+
{
|
|
44
|
+
var paraTokens = EstimateTokens(para);
|
|
45
|
+
if (currentTokens + paraTokens > maxTokens && current.Length > 0)
|
|
46
|
+
{
|
|
47
|
+
yield return current.ToString().Trim();
|
|
48
|
+
current.Clear();
|
|
49
|
+
currentTokens = 0;
|
|
50
|
+
}
|
|
51
|
+
current.AppendLine(para);
|
|
52
|
+
currentTokens += paraTokens;
|
|
53
|
+
}
|
|
54
|
+
if (current.Length > 0) yield return current.ToString().Trim();
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Embedding Generation
|
|
61
|
+
|
|
62
|
+
```csharp
|
|
63
|
+
// Using Microsoft.Extensions.AI
|
|
64
|
+
public class EmbeddingService(IEmbeddingGenerator<string, Embedding<float>> generator)
|
|
65
|
+
{
|
|
66
|
+
public async Task<float[]> GenerateAsync(string text, CancellationToken ct = default)
|
|
67
|
+
{
|
|
68
|
+
var result = await generator.GenerateAsync([text], cancellationToken: ct);
|
|
69
|
+
return result[0].Vector.ToArray();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public async Task<IReadOnlyList<float[]>> GenerateBatchAsync(
|
|
73
|
+
IEnumerable<string> texts, CancellationToken ct = default)
|
|
74
|
+
{
|
|
75
|
+
var result = await generator.GenerateAsync(texts.ToList(), cancellationToken: ct);
|
|
76
|
+
return result.Select(e => e.Vector.ToArray()).ToList();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Registration
|
|
81
|
+
builder.Services.AddEmbeddingGenerator(b => b
|
|
82
|
+
.UseOpenTelemetry()
|
|
83
|
+
.UseLogging()
|
|
84
|
+
.Use(new OpenAIEmbeddingGenerator(
|
|
85
|
+
new OpenAIClient(apiKey),
|
|
86
|
+
"text-embedding-3-small"))); // 1536 dimensions
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## pgvector Storage & Search
|
|
92
|
+
|
|
93
|
+
### Table schema
|
|
94
|
+
|
|
95
|
+
```sql
|
|
96
|
+
CREATE TABLE public.embeddings (
|
|
97
|
+
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
|
|
98
|
+
source_id UUID NOT NULL,
|
|
99
|
+
source_type TEXT NOT NULL, -- 'document', 'faq', 'article'
|
|
100
|
+
chunk_index INT NOT NULL,
|
|
101
|
+
content TEXT NOT NULL,
|
|
102
|
+
embedding vector(1536) NOT NULL,
|
|
103
|
+
metadata JSONB DEFAULT '{}'::jsonb,
|
|
104
|
+
created_at TIMESTAMPTZ DEFAULT now() NOT NULL,
|
|
105
|
+
UNIQUE(source_id, chunk_index)
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
-- HNSW index (fast, recommended for < 1M vectors)
|
|
109
|
+
CREATE INDEX idx_embeddings_hnsw ON public.embeddings
|
|
110
|
+
USING hnsw (embedding vector_cosine_ops)
|
|
111
|
+
WITH (m = 16, ef_construction = 64);
|
|
112
|
+
|
|
113
|
+
-- IVFFlat index (better for > 1M vectors)
|
|
114
|
+
-- CREATE INDEX idx_embeddings_ivf ON public.embeddings
|
|
115
|
+
-- USING ivfflat (embedding vector_cosine_ops) WITH (lists = 100);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Similarity search
|
|
119
|
+
|
|
120
|
+
```sql
|
|
121
|
+
-- Cosine similarity (1 = identical, 0 = unrelated)
|
|
122
|
+
SELECT id, content, metadata,
|
|
123
|
+
1 - (embedding <=> $1::vector) AS similarity
|
|
124
|
+
FROM public.embeddings
|
|
125
|
+
WHERE 1 - (embedding <=> $1::vector) > 0.78
|
|
126
|
+
ORDER BY embedding <=> $1::vector
|
|
127
|
+
LIMIT 5;
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Hybrid search (vector + full-text)
|
|
131
|
+
|
|
132
|
+
```sql
|
|
133
|
+
-- Combine vector similarity with PostgreSQL full-text search
|
|
134
|
+
CREATE OR REPLACE FUNCTION hybrid_search(
|
|
135
|
+
query_text TEXT,
|
|
136
|
+
query_embedding vector(1536),
|
|
137
|
+
match_count INT DEFAULT 5,
|
|
138
|
+
vector_weight FLOAT DEFAULT 0.7,
|
|
139
|
+
text_weight FLOAT DEFAULT 0.3
|
|
140
|
+
)
|
|
141
|
+
RETURNS TABLE (id UUID, content TEXT, score FLOAT)
|
|
142
|
+
LANGUAGE plpgsql AS $$
|
|
143
|
+
BEGIN
|
|
144
|
+
RETURN QUERY
|
|
145
|
+
WITH vector_results AS (
|
|
146
|
+
SELECT e.id, e.content,
|
|
147
|
+
1 - (e.embedding <=> query_embedding) AS vscore
|
|
148
|
+
FROM public.embeddings e
|
|
149
|
+
ORDER BY e.embedding <=> query_embedding
|
|
150
|
+
LIMIT match_count * 3
|
|
151
|
+
),
|
|
152
|
+
text_results AS (
|
|
153
|
+
SELECT e.id, e.content,
|
|
154
|
+
ts_rank(to_tsvector('english', e.content), plainto_tsquery('english', query_text)) AS tscore
|
|
155
|
+
FROM public.embeddings e
|
|
156
|
+
WHERE to_tsvector('english', e.content) @@ plainto_tsquery('english', query_text)
|
|
157
|
+
LIMIT match_count * 3
|
|
158
|
+
)
|
|
159
|
+
SELECT COALESCE(v.id, t.id),
|
|
160
|
+
COALESCE(v.content, t.content),
|
|
161
|
+
(COALESCE(v.vscore, 0) * vector_weight + COALESCE(t.tscore, 0) * text_weight) AS score
|
|
162
|
+
FROM vector_results v
|
|
163
|
+
FULL OUTER JOIN text_results t ON v.id = t.id
|
|
164
|
+
ORDER BY score DESC
|
|
165
|
+
LIMIT match_count;
|
|
166
|
+
END;
|
|
167
|
+
$$;
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## RAG Tool for Agent Framework
|
|
173
|
+
|
|
174
|
+
```csharp
|
|
175
|
+
public class KnowledgeBaseTool(
|
|
176
|
+
EmbeddingService embeddings,
|
|
177
|
+
ISupabaseClient supabase)
|
|
178
|
+
{
|
|
179
|
+
[Description("Search the knowledge base for relevant information")]
|
|
180
|
+
public async Task<string> SearchAsync(
|
|
181
|
+
[Description("Natural language search query")] string query,
|
|
182
|
+
[Description("Maximum results to return")] int topK = 5,
|
|
183
|
+
CancellationToken ct = default)
|
|
184
|
+
{
|
|
185
|
+
var embedding = await embeddings.GenerateAsync(query, ct);
|
|
186
|
+
|
|
187
|
+
var results = await supabase.Rpc("match_embeddings", new
|
|
188
|
+
{
|
|
189
|
+
query_embedding = embedding,
|
|
190
|
+
match_threshold = 0.78,
|
|
191
|
+
match_count = topK
|
|
192
|
+
}, ct);
|
|
193
|
+
|
|
194
|
+
return string.Join("\n\n---\n\n",
|
|
195
|
+
results.Select(r => $"[Score: {r.Similarity:F2}]\n{r.Content}"));
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Index Selection Guide
|
|
203
|
+
|
|
204
|
+
| Vectors | Recommended | Why |
|
|
205
|
+
|---------|-------------|-----|
|
|
206
|
+
| < 10K | No index (sequential scan) | Index overhead not worth it |
|
|
207
|
+
| 10K - 1M | HNSW (m=16, ef=64) | Fast, good recall |
|
|
208
|
+
| 1M+ | IVFFlat (lists=sqrt(n)) | Lower memory, acceptable recall |
|
|
209
|
+
|
|
210
|
+
### Tuning HNSW
|
|
211
|
+
|
|
212
|
+
- `m` (connections per node): higher = better recall, more memory. Default 16.
|
|
213
|
+
- `ef_construction` (build-time search depth): higher = better index, slower build. Default 64.
|
|
214
|
+
- `ef_search` (query-time): `SET hnsw.ef_search = 100;` for better recall at query time.
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Checklist
|
|
219
|
+
|
|
220
|
+
- [ ] Chunking strategy selected and tested with real data
|
|
221
|
+
- [ ] Chunk overlap configured (10-20%)
|
|
222
|
+
- [ ] Embedding model chosen (text-embedding-3-small for cost, text-embedding-3-large for quality)
|
|
223
|
+
- [ ] pgvector extension enabled
|
|
224
|
+
- [ ] HNSW or IVFFlat index created based on vector count
|
|
225
|
+
- [ ] Similarity threshold tuned (start at 0.78, adjust by domain)
|
|
226
|
+
- [ ] Hybrid search implemented if full-text relevance matters
|
|
227
|
+
- [ ] Batch embedding for initial ingestion (not one-by-one)
|
|
228
|
+
- [ ] RLS policies on embeddings table
|
|
229
|
+
- [ ] Source tracking (source_id + source_type) for updates/deletes
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
*MORPH-SPEC by Polymorphism Tech*
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
name: seo-growth-hacker
|
|
3
3
|
description: SEO and Growth specialist for technical SEO, Core Web Vitals optimization, content strategy, and organic growth for SaaS and landing pages. Use when optimizing for search engine ranking, improving Lighthouse scores, implementing SEO for Next.js pages, or planning content-driven growth.
|
|
4
4
|
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
5
|
+
color: pink
|
|
6
|
+
effort: medium
|
|
5
7
|
---
|
|
6
8
|
|
|
7
9
|
# SEO Growth Hacker
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
name: standards-architect
|
|
3
3
|
description: Standards Architect (Tier 1 Orchestrator) that enforces MORPH-SPEC naming conventions, coding standards, and cross-cutting compliance across all outputs. Always active in MORPH-SPEC workflows. Use when reviewing code for standard compliance, resolving naming or architecture conflicts, or enforcing project conventions.
|
|
4
4
|
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
5
|
+
color: red
|
|
6
|
+
effort: high
|
|
7
|
+
permissionMode: acceptEdits
|
|
5
8
|
---
|
|
6
9
|
|
|
7
10
|
# Standards Architect
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: supabase-expert
|
|
3
|
+
description: Supabase & PostgreSQL specialist for RLS policies, auth integration, pgvector, Realtime subscriptions, Edge Functions, and migration management. Use when designing database schemas, implementing Row Level Security, setting up auth flows, or working with pgvector embeddings.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
5
|
+
stacks:
|
|
6
|
+
- supabase
|
|
7
|
+
color: teal
|
|
8
|
+
effort: medium
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Supabase & PostgreSQL Specialist
|
|
12
|
+
|
|
13
|
+
Expert in Supabase auth, Row Level Security, Realtime, Edge Functions, and pgvector.
|
|
14
|
+
|
|
15
|
+
> **Ref:** `framework/standards/infrastructure/supabase/` — RLS, auth, storage, pgvector standards
|
|
16
|
+
|
|
17
|
+
## Connection Pooling
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
# Direct connection (migrations only)
|
|
21
|
+
postgresql://postgres:[password]@db.[project].supabase.co:5432/postgres
|
|
22
|
+
|
|
23
|
+
# PgBouncer (application — ALWAYS use this)
|
|
24
|
+
postgresql://postgres.[project]:[password]@aws-0-[region].pooler.supabase.com:6543/postgres
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Rule:** Application code ALWAYS connects via PgBouncer (port 6543). Direct connections (port 5432) only for migrations and schema changes.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Row Level Security (RLS)
|
|
32
|
+
|
|
33
|
+
### Enable RLS on every table
|
|
34
|
+
|
|
35
|
+
```sql
|
|
36
|
+
ALTER TABLE public.documents ENABLE ROW LEVEL SECURITY;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Common RLS Patterns
|
|
40
|
+
|
|
41
|
+
```sql
|
|
42
|
+
-- User owns the row
|
|
43
|
+
CREATE POLICY "Users can view own documents"
|
|
44
|
+
ON public.documents FOR SELECT
|
|
45
|
+
USING (auth.uid() = user_id);
|
|
46
|
+
|
|
47
|
+
-- User can insert own rows
|
|
48
|
+
CREATE POLICY "Users can insert own documents"
|
|
49
|
+
ON public.documents FOR INSERT
|
|
50
|
+
WITH CHECK (auth.uid() = user_id);
|
|
51
|
+
|
|
52
|
+
-- User can update own rows
|
|
53
|
+
CREATE POLICY "Users can update own documents"
|
|
54
|
+
ON public.documents FOR UPDATE
|
|
55
|
+
USING (auth.uid() = user_id)
|
|
56
|
+
WITH CHECK (auth.uid() = user_id);
|
|
57
|
+
|
|
58
|
+
-- User can delete own rows
|
|
59
|
+
CREATE POLICY "Users can delete own documents"
|
|
60
|
+
ON public.documents FOR DELETE
|
|
61
|
+
USING (auth.uid() = user_id);
|
|
62
|
+
|
|
63
|
+
-- Service role bypass (for backend API)
|
|
64
|
+
CREATE POLICY "Service role full access"
|
|
65
|
+
ON public.documents FOR ALL
|
|
66
|
+
USING (auth.role() = 'service_role');
|
|
67
|
+
|
|
68
|
+
-- Team-based access
|
|
69
|
+
CREATE POLICY "Team members can view"
|
|
70
|
+
ON public.documents FOR SELECT
|
|
71
|
+
USING (
|
|
72
|
+
team_id IN (
|
|
73
|
+
SELECT team_id FROM public.team_members
|
|
74
|
+
WHERE user_id = auth.uid()
|
|
75
|
+
)
|
|
76
|
+
);
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### RLS with Clerk JWT (custom claims)
|
|
80
|
+
|
|
81
|
+
```sql
|
|
82
|
+
-- Extract Clerk user ID from JWT
|
|
83
|
+
CREATE OR REPLACE FUNCTION auth.clerk_user_id()
|
|
84
|
+
RETURNS TEXT AS $$
|
|
85
|
+
SELECT coalesce(
|
|
86
|
+
current_setting('request.jwt.claims', true)::json->>'sub',
|
|
87
|
+
''
|
|
88
|
+
);
|
|
89
|
+
$$ LANGUAGE sql STABLE;
|
|
90
|
+
|
|
91
|
+
-- Use in RLS policies
|
|
92
|
+
CREATE POLICY "Clerk users own rows"
|
|
93
|
+
ON public.documents FOR ALL
|
|
94
|
+
USING (clerk_user_id = auth.clerk_user_id());
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Migrations
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Create new migration
|
|
103
|
+
npx supabase migration new create_documents_table
|
|
104
|
+
|
|
105
|
+
# Apply locally
|
|
106
|
+
npx supabase db reset
|
|
107
|
+
|
|
108
|
+
# Push to remote
|
|
109
|
+
npx supabase db push
|
|
110
|
+
|
|
111
|
+
# Diff local vs remote
|
|
112
|
+
npx supabase db diff --use-migra
|
|
113
|
+
|
|
114
|
+
# Lint for common issues
|
|
115
|
+
npx supabase db lint --level warning
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Migration file structure
|
|
119
|
+
|
|
120
|
+
```sql
|
|
121
|
+
-- supabase/migrations/20240101000000_create_documents_table.sql
|
|
122
|
+
|
|
123
|
+
CREATE TABLE public.documents (
|
|
124
|
+
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
|
|
125
|
+
user_id UUID NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
|
|
126
|
+
title TEXT NOT NULL,
|
|
127
|
+
content TEXT,
|
|
128
|
+
created_at TIMESTAMPTZ DEFAULT now() NOT NULL,
|
|
129
|
+
updated_at TIMESTAMPTZ DEFAULT now() NOT NULL
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
-- Always enable RLS
|
|
133
|
+
ALTER TABLE public.documents ENABLE ROW LEVEL SECURITY;
|
|
134
|
+
|
|
135
|
+
-- Always add indexes for filtered columns
|
|
136
|
+
CREATE INDEX idx_documents_user_id ON public.documents(user_id);
|
|
137
|
+
CREATE INDEX idx_documents_created_at ON public.documents(created_at DESC);
|
|
138
|
+
|
|
139
|
+
-- RLS policies
|
|
140
|
+
CREATE POLICY "Users manage own documents"
|
|
141
|
+
ON public.documents FOR ALL
|
|
142
|
+
USING (auth.uid() = user_id)
|
|
143
|
+
WITH CHECK (auth.uid() = user_id);
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## pgvector (Embeddings)
|
|
149
|
+
|
|
150
|
+
### Setup
|
|
151
|
+
|
|
152
|
+
```sql
|
|
153
|
+
CREATE EXTENSION IF NOT EXISTS vector;
|
|
154
|
+
|
|
155
|
+
CREATE TABLE public.embeddings (
|
|
156
|
+
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
|
|
157
|
+
document_id UUID REFERENCES public.documents(id) ON DELETE CASCADE,
|
|
158
|
+
content TEXT NOT NULL,
|
|
159
|
+
embedding vector(1536) NOT NULL, -- OpenAI text-embedding-3-small
|
|
160
|
+
metadata JSONB DEFAULT '{}'::jsonb,
|
|
161
|
+
created_at TIMESTAMPTZ DEFAULT now() NOT NULL
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
-- HNSW index for fast similarity search (cosine distance)
|
|
165
|
+
CREATE INDEX idx_embeddings_vector ON public.embeddings
|
|
166
|
+
USING hnsw (embedding vector_cosine_ops)
|
|
167
|
+
WITH (m = 16, ef_construction = 64);
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Similarity search function
|
|
171
|
+
|
|
172
|
+
```sql
|
|
173
|
+
CREATE OR REPLACE FUNCTION match_embeddings(
|
|
174
|
+
query_embedding vector(1536),
|
|
175
|
+
match_threshold FLOAT DEFAULT 0.78,
|
|
176
|
+
match_count INT DEFAULT 5
|
|
177
|
+
)
|
|
178
|
+
RETURNS TABLE (
|
|
179
|
+
id UUID,
|
|
180
|
+
content TEXT,
|
|
181
|
+
metadata JSONB,
|
|
182
|
+
similarity FLOAT
|
|
183
|
+
)
|
|
184
|
+
LANGUAGE plpgsql AS $$
|
|
185
|
+
BEGIN
|
|
186
|
+
RETURN QUERY
|
|
187
|
+
SELECT
|
|
188
|
+
e.id,
|
|
189
|
+
e.content,
|
|
190
|
+
e.metadata,
|
|
191
|
+
1 - (e.embedding <=> query_embedding) AS similarity
|
|
192
|
+
FROM public.embeddings e
|
|
193
|
+
WHERE 1 - (e.embedding <=> query_embedding) > match_threshold
|
|
194
|
+
ORDER BY e.embedding <=> query_embedding
|
|
195
|
+
LIMIT match_count;
|
|
196
|
+
END;
|
|
197
|
+
$$;
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Realtime Subscriptions
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
// Subscribe to changes on a table
|
|
206
|
+
const channel = supabase
|
|
207
|
+
.channel('documents-changes')
|
|
208
|
+
.on('postgres_changes',
|
|
209
|
+
{ event: '*', schema: 'public', table: 'documents', filter: `user_id=eq.${userId}` },
|
|
210
|
+
(payload) => {
|
|
211
|
+
console.log('Change:', payload.eventType, payload.new);
|
|
212
|
+
}
|
|
213
|
+
)
|
|
214
|
+
.subscribe();
|
|
215
|
+
|
|
216
|
+
// Cleanup
|
|
217
|
+
channel.unsubscribe();
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
**Rule:** Always filter subscriptions by user/team — never subscribe to full table changes.
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Storage (File Uploads)
|
|
225
|
+
|
|
226
|
+
```sql
|
|
227
|
+
-- Create bucket
|
|
228
|
+
INSERT INTO storage.buckets (id, name, public)
|
|
229
|
+
VALUES ('avatars', 'avatars', true);
|
|
230
|
+
|
|
231
|
+
-- RLS for storage
|
|
232
|
+
CREATE POLICY "Users upload own avatar"
|
|
233
|
+
ON storage.objects FOR INSERT
|
|
234
|
+
WITH CHECK (
|
|
235
|
+
bucket_id = 'avatars' AND
|
|
236
|
+
auth.uid()::text = (storage.foldername(name))[1]
|
|
237
|
+
);
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Checklist
|
|
243
|
+
|
|
244
|
+
- [ ] PgBouncer (port 6543) used for all application connections
|
|
245
|
+
- [ ] RLS enabled on ALL public tables
|
|
246
|
+
- [ ] RLS policies cover SELECT, INSERT, UPDATE, DELETE
|
|
247
|
+
- [ ] Service role policy exists for backend API access
|
|
248
|
+
- [ ] Migrations use `npx supabase migration new` (not manual SQL)
|
|
249
|
+
- [ ] Indexes on all frequently filtered columns
|
|
250
|
+
- [ ] pgvector: HNSW index with appropriate m/ef_construction values
|
|
251
|
+
- [ ] Realtime subscriptions filtered by user/team
|
|
252
|
+
- [ ] Storage buckets have RLS policies
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
*MORPH-SPEC by Polymorphism Tech*
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
name: css-specialist
|
|
3
3
|
description: CSS & Design System Specialist for design token enforcement, naming conventions (BEM), WCAG contrast validation, and CSS architecture. Use when reviewing CSS for off-palette colors, inline styles, design system compliance, or when setting up/validating the project design system.
|
|
4
4
|
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
5
|
+
color: pink
|
|
6
|
+
effort: medium
|
|
5
7
|
---
|
|
6
8
|
|
|
7
9
|
# CSS & Design System Specialist
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: ui-
|
|
2
|
+
name: ui-designer
|
|
3
3
|
description: UI/UX Designer specialist for wireframes, design systems, component specs, user flows, and design brief definition. Commits to a visual direction (aesthetic, palette, motion) BEFORE generating any output. Use for Phase 2 (UI/UX) and Phase 3 (spec) of features with frontend UI.
|
|
4
4
|
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
5
|
+
color: purple
|
|
6
|
+
effort: medium
|
|
5
7
|
---
|
|
6
8
|
|
|
7
9
|
# UI/UX Designer
|
package/framework/agents.json
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"role": "Team Lead (Delegate Mode)",
|
|
30
30
|
"icon": "🎯",
|
|
31
31
|
"triggers": "cross-domain conflicts, full spec synthesis, architecture decisions, team coordination",
|
|
32
|
-
"spawn_prompt": "You are the Chief Architect and Team Lead for MORPH-SPEC.
|
|
32
|
+
"spawn_prompt": "You are the Chief Architect and Team Lead for MORPH-SPEC. Coordinate Domain Leaders, resolve architectural conflicts, and synthesize results.\n\nWorkflow:\n1. Read `.morph/state.json` for active feature and phase\n2. Read `.morph/features/{feature}/spec.md` for scope\n3. Delegate to Domain Leaders — DO NOT implement code yourself\n4. Synthesize results and escalate unresolvable conflicts to the user\n\nRefer to the Domain Knowledge section below for naming rules, instant-fail checks, and VSA project structure."
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"ai-system-architect": {
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"role": "AI Architect",
|
|
76
76
|
"icon": "🤖",
|
|
77
77
|
"triggers": "AI system design, agent workflows, MCP integration, orchestration patterns",
|
|
78
|
-
"spawn_prompt": "You are the AI/Agent System Architect
|
|
78
|
+
"spawn_prompt": "You are the AI/Agent System Architect. Design agent workflows, tool integrations, and AI orchestration patterns.\n\nWorkflow:\n1. Read `.morph/state.json` and spec.md for AI requirements\n2. Design architecture using patterns from Domain Knowledge section below\n3. Delegate implementation to ms-agent-expert and vector-search-expert\n\nDO NOT implement code yourself. Refer to the Domain Knowledge section below for the 20 agentic patterns, MAF orchestration, and RAG pipeline architecture."
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
81
|
"dotnet-senior": {
|
|
@@ -114,13 +114,10 @@
|
|
|
114
114
|
"feature-slice",
|
|
115
115
|
"vsa-scaffold",
|
|
116
116
|
"rest",
|
|
117
|
-
"graphql",
|
|
118
|
-
"grpc",
|
|
119
117
|
"openapi",
|
|
120
118
|
"swagger",
|
|
121
119
|
"versioning",
|
|
122
120
|
"rate limiting",
|
|
123
|
-
"hot chocolate",
|
|
124
121
|
"endpoint"
|
|
125
122
|
],
|
|
126
123
|
"validators": [
|
|
@@ -166,7 +163,7 @@
|
|
|
166
163
|
"role": "Backend Squad Leader",
|
|
167
164
|
"icon": "⚙️",
|
|
168
165
|
"triggers": ".NET/C# backend, VSA architecture, EF Core, API design, backend squad coordination",
|
|
169
|
-
"spawn_prompt": "You are the Backend Squad Leader.
|
|
166
|
+
"spawn_prompt": "You are the Backend Squad Leader. Coordinate backend specialists and own VSA architecture, API design, and .NET/C# standards.\n\nWorkflow:\n1. Read `.morph/state.json` and spec.md for backend requirements\n2. Produce VSA Blueprint: entity fields, operations (slices), routes, error types, validation rules\n3. Delegate to squad: ef-modeler, hangfire-orchestrator, ms-agent-expert, supabase-expert, vector-search-expert, asaas-financial, clerk-auth, resend-email\n\nRefer to the Domain Knowledge section below for IHandler, Result<T>, Scrutor, IApiEndpoint patterns and code templates."
|
|
170
167
|
}
|
|
171
168
|
},
|
|
172
169
|
"infra-architect": {
|
|
@@ -193,11 +190,7 @@
|
|
|
193
190
|
"container",
|
|
194
191
|
"iac",
|
|
195
192
|
"pipeline",
|
|
196
|
-
"
|
|
197
|
-
"neon",
|
|
198
|
-
"planetscale",
|
|
199
|
-
"serverless database",
|
|
200
|
-
"serverless postgres",
|
|
193
|
+
"easypanel",
|
|
201
194
|
"docker",
|
|
202
195
|
"containerize",
|
|
203
196
|
"dockerfile",
|
|
@@ -214,8 +207,8 @@
|
|
|
214
207
|
"teammate": {
|
|
215
208
|
"role": "Infrastructure Squad Leader",
|
|
216
209
|
"icon": "🏗️",
|
|
217
|
-
"triggers": "Docker, CI/CD, GitHub Actions,
|
|
218
|
-
"spawn_prompt": "You are the Infrastructure Squad Leader.
|
|
210
|
+
"triggers": "Docker, CI/CD, GitHub Actions, EasyPanel deployment, containerization",
|
|
211
|
+
"spawn_prompt": "You are the Infrastructure Squad Leader. Coordinate Docker, CI/CD, and EasyPanel deployment.\n\nWorkflow:\n1. Read `.morph/state.json` and spec.md for infrastructure requirements\n2. Design containerization and deployment architecture\n3. Escalate to standards-architect on cross-domain conflicts\n\nRefer to the Domain Knowledge section below for Docker, GitHub Actions, and EasyPanel patterns."
|
|
219
212
|
}
|
|
220
213
|
},
|
|
221
214
|
"ui-designer": {
|
|
@@ -266,10 +259,10 @@
|
|
|
266
259
|
}
|
|
267
260
|
],
|
|
268
261
|
"teammate": {
|
|
269
|
-
"role": "UI/UX Squad Leader
|
|
262
|
+
"role": "UI/UX Squad Leader",
|
|
270
263
|
"icon": "🎨",
|
|
271
264
|
"triggers": "UI/UX design, wireframes, user flows, design system, shadcn/ui component selection",
|
|
272
|
-
"spawn_prompt": "You are the UI/UX Squad Leader.
|
|
265
|
+
"spawn_prompt": "You are the UI/UX Squad Leader. Create wireframes, design system, and user flows during the UI/UX phase.\n\nWorkflow:\n1. Read `.morph/context/design-system.md` FIRST — use only defined tokens\n2. Read spec.md for UI requirements\n3. Generate deliverables: design-system.md, mockups.md, components.md, flows.md\n4. Coordinate squad: nextjs-expert, css-specialist, seo-growth-hacker\n\nWork is UI/UX phase ONLY — no implementation code. Refer to the Domain Knowledge section below for design brief protocol, shadcn/ui reference, and accessibility rules."
|
|
273
266
|
}
|
|
274
267
|
},
|
|
275
268
|
"ef-modeler": {
|
|
@@ -302,7 +295,7 @@
|
|
|
302
295
|
"role": "Data Persistence Specialist",
|
|
303
296
|
"icon": "🗄️",
|
|
304
297
|
"triggers": "Entity Framework, database entities, migrations, DbContext, SQL schema design",
|
|
305
|
-
"spawn_prompt": "You are the Data Persistence Specialist (EF Core).
|
|
298
|
+
"spawn_prompt": "You are the Data Persistence Specialist (EF Core). Design and implement entities, migrations, and database schema.\n\nWorkflow:\n1. Read spec.md and VSA Blueprint from dotnet-senior for entity definitions\n2. Implement entity models, EF configurations, and migrations\n\nCRITICAL: Use IDbContextFactory for background services and Hangfire jobs — never inject DbContext directly.\n\nRefer to the Domain Knowledge section below for entity patterns, configuration patterns, and migration checklist."
|
|
306
299
|
}
|
|
307
300
|
},
|
|
308
301
|
"hangfire-orchestrator": {
|
|
@@ -335,7 +328,7 @@
|
|
|
335
328
|
"role": "Background Jobs Specialist",
|
|
336
329
|
"icon": "⏰",
|
|
337
330
|
"triggers": "background jobs, scheduled tasks, cron jobs, webhooks, async job pipelines",
|
|
338
|
-
"spawn_prompt": "You are the Background Jobs Specialist (Hangfire).
|
|
331
|
+
"spawn_prompt": "You are the Background Jobs Specialist (Hangfire). Implement fire-and-forget, delayed, recurring, and continuation jobs.\n\nWorkflow:\n1. Read spec.md for background processing requirements\n2. Implement jobs with proper scoped service patterns\n\nCRITICAL: Use IDbContextFactory or IRepositoryFactory for scoped DB operations — never inject DbContext directly.\n\nRefer to the Domain Knowledge section below for setup, job types, retry patterns, and dashboard configuration."
|
|
339
332
|
}
|
|
340
333
|
},
|
|
341
334
|
"ms-agent-expert": {
|
|
@@ -388,7 +381,7 @@
|
|
|
388
381
|
"role": "Microsoft Agent Framework Expert",
|
|
389
382
|
"icon": "🤖",
|
|
390
383
|
"triggers": "Microsoft Agent Framework, IChatClient, agent workflows, MCP tools, A2A protocol",
|
|
391
|
-
"spawn_prompt": "You are the Microsoft Agent Framework Expert.
|
|
384
|
+
"spawn_prompt": "You are the Microsoft Agent Framework Expert. Implement AI agent systems using IChatClient, AIFunctionFactory, and workflow patterns.\n\nWorkflow:\n1. Read spec.md for AI agent requirements\n2. Review architecture from ai-system-architect\n3. Implement using Microsoft.Extensions.AI patterns\n\nRefer to the Domain Knowledge section below for agent implementation, tool registration, MCP integration, and A2A protocol patterns."
|
|
392
385
|
}
|
|
393
386
|
},
|
|
394
387
|
"supabase-expert": {
|
|
@@ -419,7 +412,7 @@
|
|
|
419
412
|
"role": "Supabase & PostgreSQL Specialist",
|
|
420
413
|
"icon": "🐘",
|
|
421
414
|
"triggers": "Supabase, PostgreSQL, RLS policies, pgvector, Edge Functions, Realtime subscriptions",
|
|
422
|
-
"spawn_prompt": "You are the Supabase & PostgreSQL Specialist.
|
|
415
|
+
"spawn_prompt": "You are the Supabase & PostgreSQL Specialist. Implement auth, RLS, Realtime, Edge Functions, and pgvector.\n\nWorkflow:\n1. Read spec.md for database and auth requirements\n2. Design RLS policies and schema\n3. ALWAYS use PgBouncer (port 6543) for application connections\n\nRefer to the Domain Knowledge section below for RLS patterns, migration workflow, pgvector setup, and Clerk JWT integration."
|
|
423
416
|
}
|
|
424
417
|
},
|
|
425
418
|
"vector-search-expert": {
|
|
@@ -461,7 +454,7 @@
|
|
|
461
454
|
"role": "Vector Search & RAG Specialist",
|
|
462
455
|
"icon": "🔎",
|
|
463
456
|
"triggers": "vector embeddings, RAG pipelines, semantic search, pgvector, HNSW indexes",
|
|
464
|
-
"spawn_prompt": "You are the Vector Search & RAG Specialist.
|
|
457
|
+
"spawn_prompt": "You are the Vector Search & RAG Specialist. Implement embeddings, similarity search, and RAG pipelines.\n\nWorkflow:\n1. Read spec.md for search and retrieval requirements\n2. Review AI architecture from ai-system-architect\n3. Implement chunking, embedding, and retrieval components\n\nRefer to the Domain Knowledge section below for chunking strategies, pgvector setup, hybrid search, and RAG tool patterns."
|
|
465
458
|
}
|
|
466
459
|
},
|
|
467
460
|
"asaas-financial": {
|
|
@@ -495,7 +488,7 @@
|
|
|
495
488
|
"role": "Payment Integration Specialist",
|
|
496
489
|
"icon": "💳",
|
|
497
490
|
"triggers": "PIX payments, Boleto, Asaas SDK, subscription billing, Brazilian payments",
|
|
498
|
-
"spawn_prompt": "You are the Payment Integration Specialist (Asaas/Brazil).
|
|
491
|
+
"spawn_prompt": "You are the Payment Integration Specialist (Asaas/Brazil). Implement PIX, Boleto, Credit Card, and subscription billing.\n\nNever hardcode API keys. Follow contract-compliance patterns.\n\nRefer to the Domain Knowledge section below for Asaas SDK patterns, webhook handling, and payment flow examples."
|
|
499
492
|
}
|
|
500
493
|
},
|
|
501
494
|
"clerk-auth": {
|
|
@@ -526,7 +519,7 @@
|
|
|
526
519
|
"role": "Auth SaaS Integration Specialist",
|
|
527
520
|
"icon": "🔐",
|
|
528
521
|
"triggers": "Clerk authentication, login/signup flows, OAuth, session management",
|
|
529
|
-
"spawn_prompt": "You are the Auth SaaS Integration Specialist (Clerk).
|
|
522
|
+
"spawn_prompt": "You are the Auth SaaS Integration Specialist (Clerk). Implement authentication flows and session management with Next.js App Router.\n\nRefer to the Domain Knowledge section below for Clerk SDK patterns, middleware configuration, and webhook handling."
|
|
530
523
|
}
|
|
531
524
|
},
|
|
532
525
|
"resend-email": {
|
|
@@ -559,7 +552,7 @@
|
|
|
559
552
|
"role": "Email Integration Specialist",
|
|
560
553
|
"icon": "📧",
|
|
561
554
|
"triggers": "transactional email, Resend SDK, email templates, notifications",
|
|
562
|
-
"spawn_prompt": "You are the Email Integration Specialist (Resend).
|
|
555
|
+
"spawn_prompt": "You are the Email Integration Specialist (Resend). Implement transactional email delivery.\n\nNever hardcode API keys. Follow contract-compliance patterns.\n\nRefer to the Domain Knowledge section below for Resend SDK patterns, React Email templates, and error handling."
|
|
563
556
|
}
|
|
564
557
|
},
|
|
565
558
|
"nextjs-expert": {
|
|
@@ -675,7 +668,7 @@
|
|
|
675
668
|
"role": "Next.js Development Specialist",
|
|
676
669
|
"icon": "⚛️",
|
|
677
670
|
"triggers": "Next.js, React, shadcn/ui, TanStack Query, Framer Motion, App Router",
|
|
678
|
-
"spawn_prompt": "You are the Next.js Development Specialist.
|
|
671
|
+
"spawn_prompt": "You are the Next.js Development Specialist. Build Next.js 14+ apps with shadcn/ui, TanStack Query, and Framer Motion.\n\nWorkflow:\n1. Read `.morph/context/design-system.md` FIRST — use only defined tokens\n2. Read spec.md for frontend requirements\n3. Implement with App Router patterns (Server Components default, \"use client\" only when needed)\n\nALWAYS: useReducedMotion() for WCAG compliance. Never edit shadcn/ui primitives.\n\nRefer to the Domain Knowledge section below for App Router patterns, data fetching, animation, and component reference."
|
|
679
672
|
}
|
|
680
673
|
},
|
|
681
674
|
"css-specialist": {
|
|
@@ -719,7 +712,7 @@
|
|
|
719
712
|
"role": "CSS & Design System Specialist",
|
|
720
713
|
"icon": "🎨",
|
|
721
714
|
"triggers": "CSS design tokens, Tailwind, color palette, WCAG accessibility, design system compliance",
|
|
722
|
-
"spawn_prompt": "You are the CSS & Design System Specialist.
|
|
715
|
+
"spawn_prompt": "You are the CSS & Design System Specialist. Validate and enforce design token compliance across all styling.\n\nMANDATORY FIRST STEP: Read `.morph/context/design-system.md` — any missing tokens must be added there before making fixes.\n\nRefer to the Domain Knowledge section below for token categories, naming conventions, and WCAG accessibility rules."
|
|
723
716
|
}
|
|
724
717
|
},
|
|
725
718
|
"seo-growth-hacker": {
|
|
@@ -749,7 +742,7 @@
|
|
|
749
742
|
"role": "SEO & Growth Specialist",
|
|
750
743
|
"icon": "📈",
|
|
751
744
|
"triggers": "SEO, meta tags, schema markup, Core Web Vitals, Lighthouse, structured data",
|
|
752
|
-
"spawn_prompt": "You are the SEO & Growth Specialist.
|
|
745
|
+
"spawn_prompt": "You are the SEO & Growth Specialist. Implement technical SEO, structured data, and Core Web Vitals optimization for Next.js.\n\nWorkflow:\n1. Read spec.md for SEO requirements and target keywords\n2. Audit existing pages and implement optimizations\n3. Target: 90+ Performance, 100 Accessibility, 100 Best Practices, 100 SEO on Lighthouse\n\nRefer to the Domain Knowledge section below for meta tag patterns, JSON-LD schemas, and Next.js optimization."
|
|
753
746
|
}
|
|
754
747
|
},
|
|
755
748
|
"morph-spec-architect": {
|
|
@@ -761,7 +754,7 @@
|
|
|
761
754
|
"design",
|
|
762
755
|
"tasks"
|
|
763
756
|
],
|
|
764
|
-
"reports_to": "
|
|
757
|
+
"reports_to": "standards-architect",
|
|
765
758
|
"domains": [
|
|
766
759
|
"cli",
|
|
767
760
|
"framework-design",
|
|
@@ -853,15 +846,15 @@
|
|
|
853
846
|
"teammate": {
|
|
854
847
|
"icon": "🏗️",
|
|
855
848
|
"role": "Architecture Validator (read-only)",
|
|
856
|
-
"triggers": "architecture validation,
|
|
857
|
-
"spawn_prompt": "You are the Architecture Validator (READ-ONLY). Scan for architectural violations in .NET projects.\n\nWhen invoked:\n1. Use Grep and Glob to scan all .cs files and Program.cs\n2. Check for: DbContext injection, async anti-patterns, DI registration order,
|
|
849
|
+
"triggers": "architecture validation, VSA slice violations, async anti-patterns, DI registration order",
|
|
850
|
+
"spawn_prompt": "You are the Architecture Validator (READ-ONLY). Scan for architectural violations in .NET VSA projects.\n\nWhen invoked:\n1. Use Grep and Glob to scan all .cs files and Program.cs\n2. Check for: DbContext injection, async anti-patterns, DI registration order, VSA violations\n\nScan checklist:\n- DbContext injection: direct DbContext injection in background services (use IDbContextFactory)\n- Async anti-patterns: .Result, .Wait(), .GetAwaiter().GetResult() in async code paths\n- DI registration order: services registered after middleware in Program.cs (services before app.Use*/Map*)\n- VSA slice violations: cross-feature imports (Feature A referencing Feature B internals), shared code not in Shared project\n- Handler pattern: Handlers must return Result<T>, use CancellationToken, be sealed\n\nOutput JSON:\n{\n \"passed\": boolean,\n \"issues\": [{ \"file\": string, \"line\": number, \"message\": string, \"severity\": \"error\" }]\n}\n\nDo NOT modify any files."
|
|
858
851
|
},
|
|
859
852
|
"hook_behavior": {
|
|
860
853
|
"validates": [
|
|
861
854
|
"DbContext injection (IDbContextFactory required)",
|
|
862
855
|
"Async/await patterns (no .Result or .Wait)",
|
|
863
856
|
"DI registration order (services before middleware)",
|
|
864
|
-
"
|
|
857
|
+
"VSA slice isolation (no cross-feature imports)"
|
|
865
858
|
],
|
|
866
859
|
"severity": "error",
|
|
867
860
|
"blocks_on_fail": true
|
|
@@ -3,7 +3,7 @@ name: morph-phase-codebase-analysis
|
|
|
3
3
|
description: MORPH-SPEC Design sub-phase that analyzes existing codebase and database schema, producing schema-analysis.md with real column names, types, relationships, and field mismatches. Use at the start of Design phase before generating contracts.cs to prevent incorrect field names or types.
|
|
4
4
|
user-invocable: false
|
|
5
5
|
allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
|
|
6
|
-
cliVersion: "4.
|
|
6
|
+
cliVersion: "4.15.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# MORPH Codebase Analysis - Design Sub-phase
|
|
@@ -4,7 +4,7 @@ description: MORPH-SPEC Phase 2 (Design). Schema-first interactive design: reads
|
|
|
4
4
|
argument-hint: "[feature-name]"
|
|
5
5
|
user-invocable: false
|
|
6
6
|
allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion, Agent
|
|
7
|
-
cliVersion: "4.
|
|
7
|
+
cliVersion: "4.15.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# MORPH Design — Phase 2
|
|
@@ -4,7 +4,7 @@ description: MORPH-SPEC Phase 3 (Plan). Generates a detailed implementation plan
|
|
|
4
4
|
argument-hint: "[feature-name]"
|
|
5
5
|
user-invocable: false
|
|
6
6
|
allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
|
|
7
|
-
cliVersion: "4.
|
|
7
|
+
cliVersion: "4.15.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# MORPH Plan — Phase 3
|
|
@@ -4,7 +4,7 @@ description: MORPH-SPEC Phase 4 (Tasks). Breaks approved spec into bottom-up ord
|
|
|
4
4
|
argument-hint: "[feature-name]"
|
|
5
5
|
user-invocable: false
|
|
6
6
|
allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
|
|
7
|
-
cliVersion: "4.
|
|
7
|
+
cliVersion: "4.15.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# MORPH Tasks — Phase 4
|
|
@@ -4,7 +4,7 @@ description: MORPH-SPEC Phase 2 (UI/UX). Creates design-system.md, mockups.md, c
|
|
|
4
4
|
argument-hint: "[feature-name]"
|
|
5
5
|
user-invocable: false
|
|
6
6
|
allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
|
|
7
|
-
cliVersion: "4.
|
|
7
|
+
cliVersion: "4.15.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# MORPH UI/UX Design - Phase 2
|
|
@@ -4,7 +4,7 @@ description: Guided workflow for mid-implementation scope escalation — analyze
|
|
|
4
4
|
user-invocable: true
|
|
5
5
|
argument-hint: "[feature-name]"
|
|
6
6
|
allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
|
|
7
|
-
cliVersion: "4.
|
|
7
|
+
cliVersion: "4.15.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# Scope Escalation Workflow
|
package/package.json
CHANGED
|
@@ -262,19 +262,23 @@ function buildBody(agent) {
|
|
|
262
262
|
* Handles both inline values and YAML block scalars (>).
|
|
263
263
|
*
|
|
264
264
|
* @param {string} rawContent - Raw file content
|
|
265
|
-
* @returns {{ name: string|null, description: string|null, allowedTools: string, body: string }}
|
|
265
|
+
* @returns {{ name: string|null, description: string|null, allowedTools: string, color: string|null, effort: string|null, permissionMode: string|null, background: boolean, stacks: string[], body: string }}
|
|
266
266
|
*/
|
|
267
267
|
export function parseSkillFile(rawContent) {
|
|
268
268
|
// Normalize CRLF to LF for consistent parsing on Windows
|
|
269
269
|
const content = rawContent.replace(/\r\n/g, '\n');
|
|
270
270
|
const match = content.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
|
|
271
|
-
if (!match) return { name: null, description: null, allowedTools: 'Read, Write, Edit, Bash, Glob, Grep', body: rawContent };
|
|
271
|
+
if (!match) return { name: null, description: null, allowedTools: 'Read, Write, Edit, Bash, Glob, Grep', color: null, effort: null, permissionMode: null, background: false, body: rawContent };
|
|
272
272
|
|
|
273
273
|
const fm = match[1];
|
|
274
274
|
const body = match[2];
|
|
275
275
|
|
|
276
276
|
const name = (fm.match(/^name:\s*(.+)$/m) ?? [])[1]?.trim() ?? null;
|
|
277
277
|
const allowedTools = (fm.match(/^allowed-tools:\s*(.+)$/m) ?? [])[1]?.trim() ?? 'Read, Write, Edit, Bash, Glob, Grep';
|
|
278
|
+
const color = (fm.match(/^color:\s*(.+)$/m) ?? [])[1]?.trim() ?? null;
|
|
279
|
+
const effort = (fm.match(/^effort:\s*(.+)$/m) ?? [])[1]?.trim() ?? null;
|
|
280
|
+
const permissionMode = (fm.match(/^permissionMode:\s*(.+)$/m) ?? [])[1]?.trim() ?? null;
|
|
281
|
+
const background = (fm.match(/^background:\s*(.+)$/m) ?? [])[1]?.trim() === 'true';
|
|
278
282
|
|
|
279
283
|
let description = null;
|
|
280
284
|
const blockMatch = fm.match(/^description:\s*>\s*\n((?:[ \t]+.*\n?)*)/m);
|
|
@@ -286,7 +290,7 @@ export function parseSkillFile(rawContent) {
|
|
|
286
290
|
}
|
|
287
291
|
|
|
288
292
|
const stacks = parseStacks(rawContent);
|
|
289
|
-
return { name, description, allowedTools, stacks, body };
|
|
293
|
+
return { name, description, allowedTools, color, effort, permissionMode, background, stacks, body };
|
|
290
294
|
}
|
|
291
295
|
|
|
292
296
|
/**
|
|
@@ -311,6 +315,8 @@ export function collectSkillFiles(dir) {
|
|
|
311
315
|
/**
|
|
312
316
|
* Installs domain agent files as native Claude Code subagents
|
|
313
317
|
* in .claude/agents/ with memory:project, model:sonnet, maxTurns:20.
|
|
318
|
+
* Supports optional CC-native fields (color, effort, permissionMode, background)
|
|
319
|
+
* declared in each domain file's YAML frontmatter.
|
|
314
320
|
*
|
|
315
321
|
* @param {string} projectDir - Target project directory
|
|
316
322
|
* @param {string} frameworkDir - Path to morph-spec framework/ directory
|
|
@@ -326,20 +332,24 @@ export async function installDomainAgents(projectDir, frameworkDir = 'framework'
|
|
|
326
332
|
const installed = new Set();
|
|
327
333
|
for (const filePath of collectSkillFiles(domainsDir)) {
|
|
328
334
|
const raw = readFileSync(filePath, 'utf-8');
|
|
329
|
-
const { name, description, allowedTools, stacks, body } = parseSkillFile(raw);
|
|
335
|
+
const { name, description, allowedTools, color, effort, permissionMode, background, stacks, body } = parseSkillFile(raw);
|
|
330
336
|
if (!name) continue;
|
|
331
337
|
if (!shouldInstall(stacks, projectTags)) continue;
|
|
332
338
|
|
|
333
339
|
const desc = description ?? `MORPH-SPEC domain agent: ${name}`;
|
|
334
|
-
const
|
|
340
|
+
const lines = [
|
|
335
341
|
`name: ${name}`,
|
|
336
342
|
`description: ${desc}`,
|
|
337
343
|
`model: sonnet`,
|
|
338
344
|
`tools: ${allowedTools}`,
|
|
339
345
|
`maxTurns: 20`,
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
346
|
+
];
|
|
347
|
+
if (color) lines.push(`color: ${color}`);
|
|
348
|
+
if (effort) lines.push(`effort: ${effort}`);
|
|
349
|
+
if (permissionMode && permissionMode !== 'default') lines.push(`permissionMode: ${permissionMode}`);
|
|
350
|
+
if (background) lines.push(`background: true`);
|
|
351
|
+
lines.push(`memory: project`, '');
|
|
352
|
+
const frontmatter = lines.join('\n');
|
|
343
353
|
|
|
344
354
|
// If agents.json already generated morph-{name}.md, append domain content there
|
|
345
355
|
const agentsJsonFile = `morph-${name}.md`;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: hangfire-orchestrator-integration
|
|
3
|
-
description: Hangfire integration specialist for connecting background jobs with external services, implementing webhook handlers, and building event-driven workflows in .NET. Use when integrating Hangfire with third-party APIs, processing webhooks asynchronously, or designing event-driven job pipelines.
|
|
4
|
-
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
5
|
-
stacks:
|
|
6
|
-
- hangfire
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# Hangfire Orchestrator
|
|
10
|
-
|
|
11
|
-
**Tier:** 3 (Specialist)
|
|
12
|
-
**Always Active:** No
|
|
13
|
-
**Keywords:** scheduled, job, background, cron, recurring, batch, queue, hangfire
|
|
14
|
-
**Reports to:** dotnet-senior
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## Role
|
|
19
|
-
|
|
20
|
-
Hangfire specialist for background jobs, scheduled tasks, and asynchronous processing.
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## Standards Applied
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
framework/standards/backend/integrations/hangfire/setup.md
|
|
28
|
-
framework/standards/backend/integrations/hangfire/jobs.md
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## Responsibilities
|
|
34
|
-
|
|
35
|
-
- Configure Hangfire with SQL Server storage
|
|
36
|
-
- Create fire-and-forget jobs
|
|
37
|
-
- Schedule recurring jobs with cron expressions
|
|
38
|
-
- Implement delayed and continuation jobs
|
|
39
|
-
- Use IRepositoryFactory for DbContext in jobs (NOT direct injection)
|
|
40
|
-
- Configure Hangfire Dashboard with authentication
|
|
41
|
-
- Handle job failures and retries
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
## When to Use
|
|
46
|
-
|
|
47
|
-
- Background processing (emails, reports, cleanup)
|
|
48
|
-
- Scheduled tasks (daily/hourly jobs)
|
|
49
|
-
- Delayed operations (abandoned cart after 24h)
|
|
50
|
-
- Long-running operations outside HTTP request
|
|
51
|
-
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
## Critical Pattern
|
|
55
|
-
|
|
56
|
-
**ALWAYS use IRepositoryFactory in Hangfire jobs** - DbContext is scoped to HTTP request and won't exist in background jobs.
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
## Collaborates With
|
|
61
|
-
|
|
62
|
-
- **dotnet-senior** - Service layer triggering jobs
|
|
63
|
-
- **ef-modeler** - Repository factory implementation
|
|
64
|
-
- **infra-architect** - Hangfire dashboard security (Docker/EasyPanel)
|
|
65
|
-
- **resend-email** - Email jobs coordination
|
|
66
|
-
|
|
67
|
-
---
|
|
68
|
-
|
|
69
|
-
*MORPH-SPEC by Polymorphism Tech*
|