@ekkos/cli 0.2.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/dist/cache/LocalSessionStore.d.ts +129 -0
- package/dist/cache/LocalSessionStore.js +688 -0
- package/dist/cache/capture.d.ts +26 -0
- package/dist/cache/capture.js +461 -0
- package/dist/cache/index.d.ts +7 -0
- package/dist/cache/index.js +23 -0
- package/dist/cache/types.d.ts +147 -0
- package/dist/cache/types.js +40 -0
- package/dist/commands/init.d.ts +9 -0
- package/dist/commands/init.js +478 -0
- package/dist/commands/run.d.ts +12 -0
- package/dist/commands/run.js +829 -0
- package/dist/commands/setup.d.ts +6 -0
- package/dist/commands/setup.js +658 -0
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +109 -0
- package/dist/commands/test.d.ts +1 -0
- package/dist/commands/test.js +157 -0
- package/dist/deploy/agents.d.ts +15 -0
- package/dist/deploy/agents.js +72 -0
- package/dist/deploy/hooks.d.ts +16 -0
- package/dist/deploy/hooks.js +121 -0
- package/dist/deploy/index.d.ts +7 -0
- package/dist/deploy/index.js +24 -0
- package/dist/deploy/instructions.d.ts +12 -0
- package/dist/deploy/instructions.js +36 -0
- package/dist/deploy/mcp.d.ts +19 -0
- package/dist/deploy/mcp.js +109 -0
- package/dist/deploy/plugins.d.ts +19 -0
- package/dist/deploy/plugins.js +62 -0
- package/dist/deploy/settings.d.ts +8 -0
- package/dist/deploy/settings.js +84 -0
- package/dist/deploy/skills.d.ts +19 -0
- package/dist/deploy/skills.js +60 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +71 -0
- package/dist/restore/RestoreOrchestrator.d.ts +48 -0
- package/dist/restore/RestoreOrchestrator.js +481 -0
- package/dist/restore/index.d.ts +4 -0
- package/dist/restore/index.js +20 -0
- package/dist/utils/platform.d.ts +29 -0
- package/dist/utils/platform.js +65 -0
- package/dist/utils/session-words.json +119 -0
- package/dist/utils/state.d.ts +57 -0
- package/dist/utils/state.js +186 -0
- package/dist/utils/templates.d.ts +24 -0
- package/dist/utils/templates.js +118 -0
- package/package.json +48 -0
- package/templates/CLAUDE.md +287 -0
- package/templates/README.md +378 -0
- package/templates/agents/README.md +182 -0
- package/templates/agents/code-reviewer.md +166 -0
- package/templates/agents/debug-detective.md +169 -0
- package/templates/agents/ekkOS_Vercel.md +99 -0
- package/templates/agents/extension-manager.md +229 -0
- package/templates/agents/git-companion.md +185 -0
- package/templates/agents/github-test-agent.md +321 -0
- package/templates/agents/railway-manager.md +179 -0
- package/templates/claude-plugins/PHASE2_COMPLETION.md +346 -0
- package/templates/claude-plugins/PLUGIN_PROPOSALS.md +1776 -0
- package/templates/claude-plugins/README.md +587 -0
- package/templates/claude-plugins/agents/code-reviewer.json +14 -0
- package/templates/claude-plugins/agents/debug-detective.json +15 -0
- package/templates/claude-plugins/agents/git-companion.json +14 -0
- package/templates/claude-plugins/blog-manager/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins/blog-manager/commands/blog.md +691 -0
- package/templates/claude-plugins/golden-loop-monitor/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins/golden-loop-monitor/commands/loop-status.md +434 -0
- package/templates/claude-plugins/learning-tracker/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins/learning-tracker/commands/my-patterns.md +282 -0
- package/templates/claude-plugins/memory-lens/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins/memory-lens/commands/memory-search.md +181 -0
- package/templates/claude-plugins/pattern-coach/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins/pattern-coach/commands/forge.md +365 -0
- package/templates/claude-plugins/project-schema-validator/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins/project-schema-validator/commands/validate-schema.md +582 -0
- package/templates/claude-plugins-admin/AGENT_TEAM_PROPOSALS.md +819 -0
- package/templates/claude-plugins-admin/README.md +446 -0
- package/templates/claude-plugins-admin/autonomous-admin-agent/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins-admin/autonomous-admin-agent/commands/agent.md +595 -0
- package/templates/claude-plugins-admin/backend-agent/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins-admin/backend-agent/commands/backend.md +798 -0
- package/templates/claude-plugins-admin/deploy-guardian/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins-admin/deploy-guardian/commands/deploy.md +554 -0
- package/templates/claude-plugins-admin/frontend-agent/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins-admin/frontend-agent/commands/frontend.md +881 -0
- package/templates/claude-plugins-admin/mcp-server-manager/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins-admin/mcp-server-manager/commands/mcp.md +85 -0
- package/templates/claude-plugins-admin/memory-system-monitor/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins-admin/memory-system-monitor/commands/memory-health.md +569 -0
- package/templates/claude-plugins-admin/qa-agent/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins-admin/qa-agent/commands/qa.md +863 -0
- package/templates/claude-plugins-admin/tech-lead-agent/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins-admin/tech-lead-agent/commands/lead.md +732 -0
- package/templates/commands/continue.md +47 -0
- package/templates/cursor-hooks/after-agent-response.sh +117 -0
- package/templates/cursor-hooks/before-submit-prompt.sh +419 -0
- package/templates/cursor-hooks/hooks.json +20 -0
- package/templates/cursor-hooks/lib/contract.sh +320 -0
- package/templates/cursor-hooks/stop.sh +75 -0
- package/templates/cursor-rules/ekkos-memory.md +187 -0
- package/templates/hooks/assistant-response.sh +96 -0
- package/templates/hooks/hooks.json +28 -0
- package/templates/hooks/lib/contract.sh +320 -0
- package/templates/hooks/lib/state.sh +158 -0
- package/templates/hooks/session-start.ps1 +41 -0
- package/templates/hooks/session-start.sh +318 -0
- package/templates/hooks/stop.ps1 +16 -0
- package/templates/hooks/stop.sh +989 -0
- package/templates/hooks/user-prompt-submit.ps1 +174 -0
- package/templates/hooks/user-prompt-submit.sh +587 -0
- package/templates/hooks-node/lib/state.js +187 -0
- package/templates/hooks-node/stop.js +416 -0
- package/templates/hooks-node/user-prompt-submit.js +337 -0
- package/templates/plan-template.md +306 -0
- package/templates/rules/00-hooks-contract.mdc +89 -0
- package/templates/rules/30-ekkos-core.mdc +188 -0
- package/templates/rules/31-ekkos-messages.mdc +78 -0
- package/templates/skills/continue/SKILL.md +169 -0
- package/templates/skills/ekkOS_Deep_Recall/Skill.md +282 -0
- package/templates/skills/ekkOS_Learn/Skill.md +265 -0
- package/templates/skills/ekkOS_Memory_First/Skill.md +206 -0
- package/templates/skills/ekkOS_Plan_Assist/Skill.md +302 -0
- package/templates/skills/ekkOS_Preferences/Skill.md +247 -0
- package/templates/skills/ekkOS_Reflect/Skill.md +257 -0
- package/templates/skills/ekkOS_Safety/Skill.md +265 -0
- package/templates/skills/ekkOS_Schema/Skill.md +251 -0
- package/templates/skills/ekkOS_Summary/Skill.md +257 -0
- package/templates/skills/ekkOS_Vault/Skill.md +287 -0
- package/templates/skills/permissions/Skill.md +322 -0
- package/templates/spec-template.md +159 -0
- package/templates/windsurf-hooks/before-submit-prompt.sh +238 -0
- package/templates/windsurf-hooks/hooks.json +10 -0
- package/templates/windsurf-hooks/lib/contract.sh +320 -0
- package/templates/windsurf-rules/ekkos-memory.md +129 -0
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
# Validate Schema
|
|
2
|
+
|
|
3
|
+
Validate database schemas and type definitions in YOUR project. Catch field name mismatches, type errors, and schema drift before they cause runtime errors.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This plugin helps you validate schemas in YOUR codebase:
|
|
8
|
+
- TypeScript type definitions
|
|
9
|
+
- Prisma schema files
|
|
10
|
+
- GraphQL schemas
|
|
11
|
+
- Supabase database types
|
|
12
|
+
- JSON Schema definitions
|
|
13
|
+
- API response types
|
|
14
|
+
|
|
15
|
+
**This is NOT for validating ekkOS's internal database** - it's for YOUR projects!
|
|
16
|
+
|
|
17
|
+
## What it does
|
|
18
|
+
|
|
19
|
+
1. **Indexes your project schemas** - Finds all schema files (*.d.ts, schema.prisma, *.graphql)
|
|
20
|
+
2. **Validates field names** - Checks for mismatches across your code
|
|
21
|
+
3. **Detects schema drift** - Compares database schema to TypeScript types
|
|
22
|
+
4. **Catches type errors** - Finds common type mistakes before runtime
|
|
23
|
+
5. **Suggests fixes** - Provides actionable corrections
|
|
24
|
+
6. **Remembers schema** - Stores in ekkOS for future reference
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Index all schemas in current project
|
|
30
|
+
/validate-schema
|
|
31
|
+
|
|
32
|
+
# Index specific schema file
|
|
33
|
+
/validate-schema --file prisma/schema.prisma
|
|
34
|
+
|
|
35
|
+
# Check a specific table/type
|
|
36
|
+
/validate-schema users
|
|
37
|
+
|
|
38
|
+
# Compare database to TypeScript types
|
|
39
|
+
/validate-schema --compare
|
|
40
|
+
|
|
41
|
+
# Show indexed schemas
|
|
42
|
+
/validate-schema --show
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Example - First Time Setup
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
User: /validate-schema
|
|
49
|
+
|
|
50
|
+
🔍 Project Schema Validator
|
|
51
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
52
|
+
|
|
53
|
+
Scanning project for schema files...
|
|
54
|
+
|
|
55
|
+
✅ Found Schema Files:
|
|
56
|
+
|
|
57
|
+
1. TypeScript Types
|
|
58
|
+
• packages/database-types/index.ts (2,450 lines)
|
|
59
|
+
• src/types/api.d.ts (320 lines)
|
|
60
|
+
• src/models/user.ts (150 lines)
|
|
61
|
+
|
|
62
|
+
2. Prisma Schema
|
|
63
|
+
• prisma/schema.prisma (18 models, 150 fields)
|
|
64
|
+
|
|
65
|
+
3. GraphQL Schema
|
|
66
|
+
• schema.graphql (12 types, 85 fields)
|
|
67
|
+
|
|
68
|
+
4. Supabase Generated Types
|
|
69
|
+
• supabase/types.ts (auto-generated from database)
|
|
70
|
+
|
|
71
|
+
───────────────────────────────────────────────────────────────────
|
|
72
|
+
📊 Indexing Schemas...
|
|
73
|
+
|
|
74
|
+
Processing TypeScript types...
|
|
75
|
+
✅ Indexed 47 interfaces, 23 types, 12 enums
|
|
76
|
+
|
|
77
|
+
Processing Prisma schema...
|
|
78
|
+
✅ Indexed 18 models with 150 fields
|
|
79
|
+
|
|
80
|
+
Processing GraphQL schema...
|
|
81
|
+
✅ Indexed 12 types with 85 fields
|
|
82
|
+
|
|
83
|
+
───────────────────────────────────────────────────────────────────
|
|
84
|
+
🎯 Schema Index Complete!
|
|
85
|
+
|
|
86
|
+
Total schemas indexed: 4 files
|
|
87
|
+
Total types/models: 77
|
|
88
|
+
Total fields: 335
|
|
89
|
+
|
|
90
|
+
Stored in ekkOS Layer 8 (Codebase) for future queries.
|
|
91
|
+
|
|
92
|
+
───────────────────────────────────────────────────────────────────
|
|
93
|
+
✅ Validation Results: HEALTHY
|
|
94
|
+
|
|
95
|
+
No critical issues found!
|
|
96
|
+
|
|
97
|
+
⚠️ Minor Warnings (2):
|
|
98
|
+
|
|
99
|
+
1. Field name inconsistency
|
|
100
|
+
Location: src/api/users.ts:42
|
|
101
|
+
Issue: Using `user.username` but schema has `user.userName` (camelCase)
|
|
102
|
+
Fix: Change to `user.userName`
|
|
103
|
+
|
|
104
|
+
2. Optional field not checked
|
|
105
|
+
Location: src/components/UserCard.tsx:18
|
|
106
|
+
Issue: Accessing `user.bio` without null check
|
|
107
|
+
Schema: `bio` is optional (can be null)
|
|
108
|
+
Fix: Add null check: `user.bio ? ... : 'No bio'`
|
|
109
|
+
|
|
110
|
+
───────────────────────────────────────────────────────────────────
|
|
111
|
+
💡 Next Steps
|
|
112
|
+
|
|
113
|
+
Your schemas are now indexed in ekkOS!
|
|
114
|
+
|
|
115
|
+
• Check specific type: /validate-schema User
|
|
116
|
+
• Compare schemas: /validate-schema --compare
|
|
117
|
+
• Fix warnings above to prevent runtime errors
|
|
118
|
+
|
|
119
|
+
Whenever you change your schema, run /validate-schema again to update ekkOS.
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Example - Checking Specific Table
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
User: /validate-schema users
|
|
126
|
+
|
|
127
|
+
🔍 Schema: users
|
|
128
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
129
|
+
|
|
130
|
+
📋 Database Schema (Prisma):
|
|
131
|
+
|
|
132
|
+
model User {
|
|
133
|
+
id String @id @default(uuid())
|
|
134
|
+
email String @unique
|
|
135
|
+
userName String
|
|
136
|
+
firstName String?
|
|
137
|
+
lastName String?
|
|
138
|
+
bio String?
|
|
139
|
+
avatarUrl String?
|
|
140
|
+
createdAt DateTime @default(now())
|
|
141
|
+
updatedAt DateTime @updatedAt
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
───────────────────────────────────────────────────────────────────
|
|
145
|
+
📝 TypeScript Type:
|
|
146
|
+
|
|
147
|
+
interface User {
|
|
148
|
+
id: string;
|
|
149
|
+
email: string;
|
|
150
|
+
userName: string;
|
|
151
|
+
firstName: string | null;
|
|
152
|
+
lastName: string | null;
|
|
153
|
+
bio: string | null;
|
|
154
|
+
avatarUrl: string | null;
|
|
155
|
+
createdAt: Date;
|
|
156
|
+
updatedAt: Date;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
───────────────────────────────────────────────────────────────────
|
|
160
|
+
✅ Schema Match: PERFECT
|
|
161
|
+
|
|
162
|
+
TypeScript types match Prisma schema exactly!
|
|
163
|
+
|
|
164
|
+
All field names, types, and nullability are correct.
|
|
165
|
+
|
|
166
|
+
───────────────────────────────────────────────────────────────────
|
|
167
|
+
🔍 Usage Analysis (found in codebase):
|
|
168
|
+
|
|
169
|
+
✅ src/api/users.ts:15
|
|
170
|
+
Correct: user.userName
|
|
171
|
+
|
|
172
|
+
✅ src/components/UserProfile.tsx:42
|
|
173
|
+
Correct: user.bio ? ... : 'No bio' (null check present)
|
|
174
|
+
|
|
175
|
+
❌ src/pages/Profile.tsx:88
|
|
176
|
+
ERROR: Using user.username (should be userName)
|
|
177
|
+
Fix needed!
|
|
178
|
+
|
|
179
|
+
───────────────────────────────────────────────────────────────────
|
|
180
|
+
🔧 Suggested Fixes:
|
|
181
|
+
|
|
182
|
+
1. File: src/pages/Profile.tsx
|
|
183
|
+
Line: 88
|
|
184
|
+
|
|
185
|
+
Current:
|
|
186
|
+
```typescript
|
|
187
|
+
const name = user.username;
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Should be:
|
|
191
|
+
```typescript
|
|
192
|
+
const name = user.userName;
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
───────────────────────────────────────────────────────────────────
|
|
196
|
+
💡 Action Required
|
|
197
|
+
|
|
198
|
+
Run this fix to prevent runtime errors:
|
|
199
|
+
|
|
200
|
+
1. Open src/pages/Profile.tsx:88
|
|
201
|
+
2. Change `user.username` → `user.userName`
|
|
202
|
+
3. Test the page
|
|
203
|
+
|
|
204
|
+
This mismatch would cause: "Cannot read property 'username' of undefined"
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Example - Schema Drift Detected
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
User: /validate-schema --compare
|
|
211
|
+
|
|
212
|
+
🔍 Comparing Schemas
|
|
213
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
214
|
+
|
|
215
|
+
Comparing:
|
|
216
|
+
• Database (Prisma schema)
|
|
217
|
+
• TypeScript types
|
|
218
|
+
• GraphQL schema
|
|
219
|
+
|
|
220
|
+
───────────────────────────────────────────────────────────────────
|
|
221
|
+
⚠️ SCHEMA DRIFT DETECTED!
|
|
222
|
+
|
|
223
|
+
Your TypeScript types are out of sync with your database.
|
|
224
|
+
|
|
225
|
+
───────────────────────────────────────────────────────────────────
|
|
226
|
+
❌ Critical Issues (3):
|
|
227
|
+
|
|
228
|
+
1. Missing Field in TypeScript
|
|
229
|
+
|
|
230
|
+
Database has: User.phoneNumber (String?)
|
|
231
|
+
TypeScript: Missing!
|
|
232
|
+
|
|
233
|
+
Impact: TypeScript won't know about this field
|
|
234
|
+
Fix: Add to interface:
|
|
235
|
+
```typescript
|
|
236
|
+
interface User {
|
|
237
|
+
// ... existing fields
|
|
238
|
+
phoneNumber: string | null; // ADD THIS
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
2. Wrong Type
|
|
243
|
+
|
|
244
|
+
Database: Post.viewCount (Int)
|
|
245
|
+
TypeScript: Post.viewCount (string)
|
|
246
|
+
|
|
247
|
+
Impact: Type mismatch will cause runtime errors
|
|
248
|
+
Fix: Change to number:
|
|
249
|
+
```typescript
|
|
250
|
+
interface Post {
|
|
251
|
+
viewCount: number; // Was: string
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
3. Field Renamed in Database
|
|
256
|
+
|
|
257
|
+
Database: User.profileImageUrl
|
|
258
|
+
TypeScript: User.avatarUrl
|
|
259
|
+
|
|
260
|
+
Impact: Queries will fail (field doesn't exist)
|
|
261
|
+
Fix: Either:
|
|
262
|
+
- Update TypeScript to profileImageUrl, OR
|
|
263
|
+
- Rename database field back to avatarUrl
|
|
264
|
+
|
|
265
|
+
───────────────────────────────────────────────────────────────────
|
|
266
|
+
🔧 Quick Fix Command
|
|
267
|
+
|
|
268
|
+
To regenerate TypeScript types from database:
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
# If using Prisma:
|
|
272
|
+
npx prisma generate
|
|
273
|
+
|
|
274
|
+
# If using Supabase:
|
|
275
|
+
npx supabase gen types typescript > src/types/database.ts
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
───────────────────────────────────────────────────────────────────
|
|
279
|
+
💡 Prevention
|
|
280
|
+
|
|
281
|
+
To avoid schema drift:
|
|
282
|
+
|
|
283
|
+
1. Use generated types (don't hand-write them)
|
|
284
|
+
2. Run /validate-schema after schema changes
|
|
285
|
+
3. Add to pre-commit hook:
|
|
286
|
+
```bash
|
|
287
|
+
npx prisma generate && git add src/types/
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
After fixing, run /validate-schema again to verify!
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
## Example - Fresh Project Setup
|
|
294
|
+
|
|
295
|
+
```
|
|
296
|
+
User: /validate-schema
|
|
297
|
+
|
|
298
|
+
🔍 Project Schema Validator
|
|
299
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
300
|
+
|
|
301
|
+
Scanning project for schema files...
|
|
302
|
+
|
|
303
|
+
───────────────────────────────────────────────────────────────────
|
|
304
|
+
ℹ️ Fresh Project Detected
|
|
305
|
+
|
|
306
|
+
No schema files found yet. That's OK for a new project!
|
|
307
|
+
|
|
308
|
+
Here's how to get started:
|
|
309
|
+
|
|
310
|
+
───────────────────────────────────────────────────────────────────
|
|
311
|
+
🚀 Recommended Setup
|
|
312
|
+
|
|
313
|
+
For a TypeScript + Database project, we recommend:
|
|
314
|
+
|
|
315
|
+
1. **Choose a database approach:**
|
|
316
|
+
|
|
317
|
+
Option A: Prisma (recommended)
|
|
318
|
+
```bash
|
|
319
|
+
npm install prisma @prisma/client
|
|
320
|
+
npx prisma init
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Option B: Supabase
|
|
324
|
+
```bash
|
|
325
|
+
npm install @supabase/supabase-js
|
|
326
|
+
npx supabase init
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
2. **Define your schema:**
|
|
330
|
+
|
|
331
|
+
Prisma: Edit prisma/schema.prisma
|
|
332
|
+
Supabase: Use Supabase dashboard or migrations
|
|
333
|
+
|
|
334
|
+
3. **Generate TypeScript types:**
|
|
335
|
+
|
|
336
|
+
Prisma: `npx prisma generate`
|
|
337
|
+
Supabase: `npx supabase gen types typescript`
|
|
338
|
+
|
|
339
|
+
4. **Index with ekkOS:**
|
|
340
|
+
|
|
341
|
+
Run /validate-schema again after setup!
|
|
342
|
+
|
|
343
|
+
───────────────────────────────────────────────────────────────────
|
|
344
|
+
💡 Why This Matters
|
|
345
|
+
|
|
346
|
+
Schema validation prevents:
|
|
347
|
+
• Field name typos (user.username vs user.userName)
|
|
348
|
+
• Type mismatches (expecting string, got number)
|
|
349
|
+
• Null pointer errors (missing null checks)
|
|
350
|
+
• Schema drift (types out of sync with database)
|
|
351
|
+
|
|
352
|
+
Once you have schemas, ekkOS will remember them and help catch errors!
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
## Advanced Usage
|
|
356
|
+
|
|
357
|
+
### Index Specific Files
|
|
358
|
+
|
|
359
|
+
```bash
|
|
360
|
+
# Index TypeScript types
|
|
361
|
+
/validate-schema --file src/types/database.d.ts
|
|
362
|
+
|
|
363
|
+
# Index Prisma schema
|
|
364
|
+
/validate-schema --file prisma/schema.prisma
|
|
365
|
+
|
|
366
|
+
# Index multiple files
|
|
367
|
+
/validate-schema --files "src/types/*.d.ts"
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### Show Indexed Schemas
|
|
371
|
+
|
|
372
|
+
```bash
|
|
373
|
+
/validate-schema --show
|
|
374
|
+
|
|
375
|
+
# Shows:
|
|
376
|
+
# - All indexed schemas
|
|
377
|
+
# - When they were indexed
|
|
378
|
+
# - Field count per schema
|
|
379
|
+
# - Last validation results
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### Compare Across Schema Sources
|
|
383
|
+
|
|
384
|
+
```bash
|
|
385
|
+
# Compare database vs TypeScript
|
|
386
|
+
/validate-schema --compare database typescript
|
|
387
|
+
|
|
388
|
+
# Compare GraphQL vs database
|
|
389
|
+
/validate-schema --compare graphql database
|
|
390
|
+
|
|
391
|
+
# Compare all sources
|
|
392
|
+
/validate-schema --compare all
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### Watch for Changes
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
# Re-index when schema files change
|
|
399
|
+
/validate-schema --watch
|
|
400
|
+
|
|
401
|
+
# (Sets up file watcher - re-runs validation on save)
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
## Common Issues Detected
|
|
405
|
+
|
|
406
|
+
### 1. Field Name Mismatches
|
|
407
|
+
|
|
408
|
+
```
|
|
409
|
+
Database: user.firstName
|
|
410
|
+
Code: user.first_name
|
|
411
|
+
|
|
412
|
+
Error: Cannot read property 'first_name' of undefined
|
|
413
|
+
Fix: Use consistent naming (camelCase everywhere)
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
### 2. Missing Null Checks
|
|
417
|
+
|
|
418
|
+
```
|
|
419
|
+
Database: bio String? (optional)
|
|
420
|
+
Code: <p>{user.bio.substring(0, 100)}</p>
|
|
421
|
+
|
|
422
|
+
Error: Cannot read property 'substring' of null
|
|
423
|
+
Fix: Add null check: user.bio ? user.bio.substring(0, 100) : ''
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### 3. Wrong Types
|
|
427
|
+
|
|
428
|
+
```
|
|
429
|
+
Database: age Int
|
|
430
|
+
TypeScript: age: string
|
|
431
|
+
|
|
432
|
+
Error: Type 'number' is not assignable to type 'string'
|
|
433
|
+
Fix: Change to age: number
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### 4. Missing Fields
|
|
437
|
+
|
|
438
|
+
```
|
|
439
|
+
Database: phoneNumber String?
|
|
440
|
+
TypeScript: (missing)
|
|
441
|
+
|
|
442
|
+
Error: TypeScript doesn't know this field exists
|
|
443
|
+
Fix: Add phoneNumber: string | null to interface
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
### 5. Schema Drift
|
|
447
|
+
|
|
448
|
+
```
|
|
449
|
+
Database was updated but TypeScript types weren't regenerated
|
|
450
|
+
|
|
451
|
+
Fix: Run prisma generate or supabase gen types
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
## Requirements
|
|
455
|
+
|
|
456
|
+
- Project with schema files (TypeScript, Prisma, GraphQL, etc.)
|
|
457
|
+
- ekkOS MCP server configured
|
|
458
|
+
- Project directory accessible to Claude Code
|
|
459
|
+
|
|
460
|
+
## Implementation Details
|
|
461
|
+
|
|
462
|
+
When this command runs, Claude will:
|
|
463
|
+
|
|
464
|
+
1. **Scan Project Directory**:
|
|
465
|
+
- Find all schema-related files (*.d.ts, schema.prisma, *.graphql, etc.)
|
|
466
|
+
- Parse schema definitions
|
|
467
|
+
- Extract types, models, fields
|
|
468
|
+
|
|
469
|
+
2. **Call ekkOS_IndexSchema**:
|
|
470
|
+
```typescript
|
|
471
|
+
ekkOS_IndexSchema({
|
|
472
|
+
project_path: "/path/to/project",
|
|
473
|
+
files: [
|
|
474
|
+
{ name: "prisma/schema.prisma", content: "..." },
|
|
475
|
+
{ name: "src/types/database.d.ts", content: "..." }
|
|
476
|
+
]
|
|
477
|
+
})
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
3. **Analyze for Issues**:
|
|
481
|
+
- Field name inconsistencies (camelCase vs snake_case)
|
|
482
|
+
- Type mismatches (string vs number)
|
|
483
|
+
- Missing null checks
|
|
484
|
+
- Optional fields accessed without guards
|
|
485
|
+
|
|
486
|
+
4. **Compare Schemas**:
|
|
487
|
+
- Database schema (source of truth)
|
|
488
|
+
- TypeScript types (what code expects)
|
|
489
|
+
- GraphQL schema (API contract)
|
|
490
|
+
- Identify drift and mismatches
|
|
491
|
+
|
|
492
|
+
5. **Generate Fixes**:
|
|
493
|
+
- Show exact line numbers
|
|
494
|
+
- Provide corrected code
|
|
495
|
+
- Suggest commands to regenerate types
|
|
496
|
+
|
|
497
|
+
6. **Store in ekkOS**:
|
|
498
|
+
- Call `ekkOS_GetSchema` later for quick lookups
|
|
499
|
+
- Stored in Layer 8 (Codebase memory)
|
|
500
|
+
- Available across sessions
|
|
501
|
+
|
|
502
|
+
7. **Format Output**:
|
|
503
|
+
- Clear status indicators (✅⚠️❌)
|
|
504
|
+
- Actionable fix suggestions
|
|
505
|
+
- Command snippets to run
|
|
506
|
+
- Prevention tips
|
|
507
|
+
|
|
508
|
+
## Multi-Tool Workflow
|
|
509
|
+
|
|
510
|
+
This plugin combines:
|
|
511
|
+
- `ekkOS_IndexSchema` - Index user's schemas
|
|
512
|
+
- `ekkOS_GetSchema` - Retrieve specific table/type
|
|
513
|
+
- `ekkOS_Codebase` - Search for field usage in code
|
|
514
|
+
- `ekkOS_Search` - Check for past schema issues
|
|
515
|
+
- `ekkOS_Forge` - Remember schema issues as patterns
|
|
516
|
+
|
|
517
|
+
**Example workflow:**
|
|
518
|
+
1. User runs `/validate-schema`
|
|
519
|
+
2. Indexes schemas with `ekkOS_IndexSchema`
|
|
520
|
+
3. Searches codebase with `ekkOS_Codebase` for field usage
|
|
521
|
+
4. Checks past schema issues with `ekkOS_Search`
|
|
522
|
+
5. If issues found, forges pattern with `ekkOS_Forge`
|
|
523
|
+
6. Next time similar issue occurs, pattern is auto-retrieved!
|
|
524
|
+
|
|
525
|
+
## Fresh Project Support
|
|
526
|
+
|
|
527
|
+
For brand new projects:
|
|
528
|
+
- Detects no schemas exist yet
|
|
529
|
+
- Provides setup guide (Prisma vs Supabase)
|
|
530
|
+
- Shows recommended workflow
|
|
531
|
+
- Explains why schema validation matters
|
|
532
|
+
- Offers to help after setup
|
|
533
|
+
|
|
534
|
+
## Benefits
|
|
535
|
+
|
|
536
|
+
### Prevents Runtime Errors
|
|
537
|
+
```
|
|
538
|
+
Before: user.username → undefined (field doesn't exist)
|
|
539
|
+
After: Caught by /validate-schema before running code
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
### Keeps Types in Sync
|
|
543
|
+
```
|
|
544
|
+
Before: Database updated, TypeScript stale
|
|
545
|
+
After: /validate-schema detects drift, reminds you to regenerate
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
### Saves Debugging Time
|
|
549
|
+
```
|
|
550
|
+
Before: 30 minutes debugging "Cannot read property X"
|
|
551
|
+
After: 30 seconds to see issue and fix
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
### Builds Institutional Knowledge
|
|
555
|
+
```
|
|
556
|
+
All schema issues forged as patterns in ekkOS
|
|
557
|
+
Future projects benefit from past mistakes
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
## Tips
|
|
561
|
+
|
|
562
|
+
1. **Run after schema changes**: Always run `/validate-schema` after updating Prisma schema or database
|
|
563
|
+
2. **Add to CI/CD**: Run validation in pre-commit hooks
|
|
564
|
+
3. **Use generated types**: Don't hand-write types - generate from schema
|
|
565
|
+
4. **Check before deploy**: Run validation before pushing to production
|
|
566
|
+
5. **Forge issues as patterns**: When you find a schema bug, forge it so ekkOS remembers
|
|
567
|
+
|
|
568
|
+
## Comparison: This vs Admin Schema Sentinel
|
|
569
|
+
|
|
570
|
+
| Feature | Project Schema Validator (This) | Schema Sentinel (Admin) |
|
|
571
|
+
|---------|--------------------------------|-------------------------|
|
|
572
|
+
| Target | YOUR projects | ekkOS database |
|
|
573
|
+
| Portable | ✅ Works anywhere | ❌ ekkOS-specific |
|
|
574
|
+
| Schemas | TypeScript, Prisma, GraphQL | Supabase only |
|
|
575
|
+
| Purpose | Help users validate their code | Help ekkOS team validate migrations |
|
|
576
|
+
| Deployed to | All users | Admin only |
|
|
577
|
+
|
|
578
|
+
**This plugin is FOR YOU to use on YOUR codebases!**
|
|
579
|
+
|
|
580
|
+
---
|
|
581
|
+
|
|
582
|
+
**Your schemas, validated. Your errors, prevented. Your time, saved.** ⚡🛡️
|