@veloxts/mcp 0.6.23

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 (58) hide show
  1. package/LICENSE +21 -0
  2. package/dist/bin.d.ts +17 -0
  3. package/dist/bin.d.ts.map +1 -0
  4. package/dist/bin.js +25 -0
  5. package/dist/bin.js.map +1 -0
  6. package/dist/index.d.ts +34 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +29 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/prompts/index.d.ts +8 -0
  11. package/dist/prompts/index.d.ts.map +1 -0
  12. package/dist/prompts/index.js +7 -0
  13. package/dist/prompts/index.js.map +1 -0
  14. package/dist/prompts/templates.d.ts +75 -0
  15. package/dist/prompts/templates.d.ts.map +1 -0
  16. package/dist/prompts/templates.js +442 -0
  17. package/dist/prompts/templates.js.map +1 -0
  18. package/dist/resources/errors.d.ts +45 -0
  19. package/dist/resources/errors.d.ts.map +1 -0
  20. package/dist/resources/errors.js +117 -0
  21. package/dist/resources/errors.js.map +1 -0
  22. package/dist/resources/index.d.ts +14 -0
  23. package/dist/resources/index.d.ts.map +1 -0
  24. package/dist/resources/index.js +10 -0
  25. package/dist/resources/index.js.map +1 -0
  26. package/dist/resources/procedures.d.ts +61 -0
  27. package/dist/resources/procedures.d.ts.map +1 -0
  28. package/dist/resources/procedures.js +147 -0
  29. package/dist/resources/procedures.js.map +1 -0
  30. package/dist/resources/routes.d.ts +44 -0
  31. package/dist/resources/routes.d.ts.map +1 -0
  32. package/dist/resources/routes.js +115 -0
  33. package/dist/resources/routes.js.map +1 -0
  34. package/dist/resources/schemas.d.ts +41 -0
  35. package/dist/resources/schemas.d.ts.map +1 -0
  36. package/dist/resources/schemas.js +143 -0
  37. package/dist/resources/schemas.js.map +1 -0
  38. package/dist/server.d.ts +28 -0
  39. package/dist/server.d.ts.map +1 -0
  40. package/dist/server.js +371 -0
  41. package/dist/server.js.map +1 -0
  42. package/dist/tools/generate.d.ts +64 -0
  43. package/dist/tools/generate.d.ts.map +1 -0
  44. package/dist/tools/generate.js +155 -0
  45. package/dist/tools/generate.js.map +1 -0
  46. package/dist/tools/index.d.ts +10 -0
  47. package/dist/tools/index.d.ts.map +1 -0
  48. package/dist/tools/index.js +8 -0
  49. package/dist/tools/index.js.map +1 -0
  50. package/dist/tools/migrate.d.ts +72 -0
  51. package/dist/tools/migrate.d.ts.map +1 -0
  52. package/dist/tools/migrate.js +163 -0
  53. package/dist/tools/migrate.js.map +1 -0
  54. package/dist/utils/project.d.ts +49 -0
  55. package/dist/utils/project.d.ts.map +1 -0
  56. package/dist/utils/project.js +133 -0
  57. package/dist/utils/project.js.map +1 -0
  58. package/package.json +63 -0
@@ -0,0 +1,442 @@
1
+ /**
2
+ * Prompt Templates
3
+ *
4
+ * Reusable prompt templates for common VeloxTS tasks.
5
+ */
6
+ // ============================================================================
7
+ // Templates
8
+ // ============================================================================
9
+ /**
10
+ * Create procedure template
11
+ */
12
+ export const CREATE_PROCEDURE = {
13
+ name: 'create-procedure',
14
+ description: 'Guide for creating a new VeloxTS procedure',
15
+ arguments: [
16
+ { name: 'entity', description: 'Entity name (e.g., User, Post)', required: true },
17
+ {
18
+ name: 'operations',
19
+ description: 'Operations to include (get, list, create, update, delete)',
20
+ },
21
+ ],
22
+ content: `# Creating a VeloxTS Procedure
23
+
24
+ ## Steps
25
+
26
+ 1. **Define the Zod schema** in \`src/schemas/{entity}.ts\`:
27
+ \`\`\`typescript
28
+ import { z } from '@veloxts/velox';
29
+
30
+ export const {Entity}Schema = z.object({
31
+ id: z.string().uuid(),
32
+ // Add your fields here
33
+ createdAt: z.date(),
34
+ updatedAt: z.date(),
35
+ });
36
+
37
+ export type {Entity} = z.infer<typeof {Entity}Schema>;
38
+
39
+ export const Create{Entity}Schema = {Entity}Schema.omit({
40
+ id: true,
41
+ createdAt: true,
42
+ updatedAt: true,
43
+ });
44
+
45
+ export type Create{Entity} = z.infer<typeof Create{Entity}Schema>;
46
+ \`\`\`
47
+
48
+ 2. **Create the procedure** in \`src/procedures/{entities}.ts\`:
49
+ \`\`\`typescript
50
+ import { defineProcedures, procedure, z } from '@veloxts/velox';
51
+ import { {Entity}Schema, Create{Entity}Schema } from '../schemas/{entity}.js';
52
+
53
+ export const {entity}Procedures = defineProcedures('{entities}', {
54
+ get{Entity}: procedure()
55
+ .input(z.object({ id: z.string().uuid() }))
56
+ .output({Entity}Schema)
57
+ .query(async ({ input, ctx }) => {
58
+ return ctx.db.{entity}.findUnique({ where: { id: input.id } });
59
+ }),
60
+
61
+ list{Entities}: procedure()
62
+ .output(z.array({Entity}Schema))
63
+ .query(async ({ ctx }) => {
64
+ return ctx.db.{entity}.findMany();
65
+ }),
66
+
67
+ create{Entity}: procedure()
68
+ .input(Create{Entity}Schema)
69
+ .output({Entity}Schema)
70
+ .mutation(async ({ input, ctx }) => {
71
+ return ctx.db.{entity}.create({ data: input });
72
+ }),
73
+ });
74
+ \`\`\`
75
+
76
+ 3. **Register in index** at \`src/procedures/index.ts\`:
77
+ \`\`\`typescript
78
+ export { {entity}Procedures } from './{entities}.js';
79
+ \`\`\`
80
+
81
+ ## Naming Conventions
82
+
83
+ | Procedure Name | HTTP Method | Route |
84
+ |----------------|-------------|-------|
85
+ | get{Entity} | GET | /{entities}/:id |
86
+ | list{Entities} | GET | /{entities} |
87
+ | create{Entity} | POST | /{entities} |
88
+ | update{Entity} | PUT | /{entities}/:id |
89
+ | delete{Entity} | DELETE | /{entities}/:id |
90
+ `,
91
+ };
92
+ /**
93
+ * Add validation template
94
+ */
95
+ export const ADD_VALIDATION = {
96
+ name: 'add-validation',
97
+ description: 'Guide for adding Zod validation to procedures',
98
+ content: `# Adding Validation with Zod
99
+
100
+ ## Common Validation Patterns
101
+
102
+ ### String Validation
103
+ \`\`\`typescript
104
+ z.string()
105
+ .min(1, 'Required')
106
+ .max(255, 'Too long')
107
+ .email('Invalid email')
108
+ .url('Invalid URL')
109
+ .uuid('Invalid UUID')
110
+ .regex(/pattern/, 'Invalid format')
111
+ \`\`\`
112
+
113
+ ### Number Validation
114
+ \`\`\`typescript
115
+ z.number()
116
+ .int('Must be integer')
117
+ .positive('Must be positive')
118
+ .min(0, 'Must be >= 0')
119
+ .max(100, 'Must be <= 100')
120
+ \`\`\`
121
+
122
+ ### Object Validation
123
+ \`\`\`typescript
124
+ z.object({
125
+ required: z.string(),
126
+ optional: z.string().optional(),
127
+ nullable: z.string().nullable(),
128
+ defaulted: z.string().default('value'),
129
+ })
130
+ \`\`\`
131
+
132
+ ### Array Validation
133
+ \`\`\`typescript
134
+ z.array(z.string())
135
+ .min(1, 'At least one item')
136
+ .max(10, 'Too many items')
137
+ .nonempty('Cannot be empty')
138
+ \`\`\`
139
+
140
+ ### Enum Validation
141
+ \`\`\`typescript
142
+ z.enum(['active', 'inactive', 'pending'])
143
+ z.nativeEnum(StatusEnum)
144
+ \`\`\`
145
+
146
+ ### Union & Intersection
147
+ \`\`\`typescript
148
+ // Union: one of multiple types
149
+ z.union([z.string(), z.number()])
150
+
151
+ // Discriminated union
152
+ z.discriminatedUnion('type', [
153
+ z.object({ type: z.literal('a'), value: z.string() }),
154
+ z.object({ type: z.literal('b'), count: z.number() }),
155
+ ])
156
+ \`\`\`
157
+
158
+ ### Transform & Refine
159
+ \`\`\`typescript
160
+ // Transform input
161
+ z.string().transform(s => s.toLowerCase())
162
+
163
+ // Custom validation
164
+ z.string().refine(
165
+ (val) => isValidSlug(val),
166
+ { message: 'Invalid slug format' }
167
+ )
168
+ \`\`\`
169
+
170
+ ## Best Practices
171
+
172
+ 1. **Reuse schemas** - Create base schemas and derive others
173
+ 2. **Use .omit()/.pick()** - Create partial schemas from complete ones
174
+ 3. **Add error messages** - Always provide clear validation messages
175
+ 4. **Export types** - Use \`z.infer<typeof Schema>\` for type exports
176
+ `,
177
+ };
178
+ /**
179
+ * Setup authentication template
180
+ */
181
+ export const SETUP_AUTH = {
182
+ name: 'setup-auth',
183
+ description: 'Guide for setting up authentication in VeloxTS',
184
+ content: `# Setting Up Authentication
185
+
186
+ ## JWT Authentication
187
+
188
+ ### 1. Environment Variables
189
+ \`\`\`bash
190
+ # .env
191
+ JWT_SECRET=<64+ character secret>
192
+ JWT_REFRESH_SECRET=<64+ character secret>
193
+ \`\`\`
194
+
195
+ Generate secrets:
196
+ \`\`\`bash
197
+ openssl rand -base64 64
198
+ \`\`\`
199
+
200
+ ### 2. Configure Auth Plugin
201
+ \`\`\`typescript
202
+ import { authPlugin, jwtManager } from '@veloxts/auth';
203
+
204
+ const jwt = jwtManager({
205
+ secret: process.env.JWT_SECRET!,
206
+ refreshSecret: process.env.JWT_REFRESH_SECRET!,
207
+ accessTokenExpiry: '15m',
208
+ refreshTokenExpiry: '7d',
209
+ });
210
+
211
+ await app.register(authPlugin(jwt));
212
+ \`\`\`
213
+
214
+ ### 3. Protect Procedures with Guards
215
+ \`\`\`typescript
216
+ import { authenticated, hasRole, hasPermission } from '@veloxts/auth';
217
+
218
+ // Require authentication
219
+ const getProfile = procedure()
220
+ .guard(authenticated)
221
+ .query(({ ctx }) => ctx.user);
222
+
223
+ // Require specific role
224
+ const adminDashboard = procedure()
225
+ .guard(hasRole('admin'))
226
+ .query(({ ctx }) => { /* ... */ });
227
+
228
+ // Require permission
229
+ const deletePost = procedure()
230
+ .guard(hasPermission('posts.delete'))
231
+ .mutation(({ ctx, input }) => { /* ... */ });
232
+ \`\`\`
233
+
234
+ ### 4. Auth Endpoints
235
+ \`\`\`typescript
236
+ export const authProcedures = defineProcedures('auth', {
237
+ register: procedure()
238
+ .input(RegisterSchema)
239
+ .output(UserSchema)
240
+ .mutation(async ({ input, ctx }) => {
241
+ const hashedPassword = await hash(input.password);
242
+ return ctx.db.user.create({
243
+ data: { ...input, password: hashedPassword },
244
+ });
245
+ }),
246
+
247
+ login: procedure()
248
+ .input(LoginSchema)
249
+ .output(TokensSchema)
250
+ .mutation(async ({ input, ctx }) => {
251
+ const user = await ctx.db.user.findUnique({
252
+ where: { email: input.email },
253
+ });
254
+ if (!user || !await verify(input.password, user.password)) {
255
+ throw VeloxError.unauthorized('Invalid credentials');
256
+ }
257
+ return jwt.generateTokens(user);
258
+ }),
259
+ });
260
+ \`\`\`
261
+
262
+ ## Available Guards
263
+
264
+ | Guard | Description |
265
+ |-------|-------------|
266
+ | \`authenticated\` | Requires logged-in user |
267
+ | \`emailVerified\` | Requires verified email |
268
+ | \`hasRole(role)\` | Checks user role |
269
+ | \`hasPermission(perm)\` | Checks user permission |
270
+ | \`allOf(guards)\` | All guards must pass |
271
+ | \`anyOf(guards)\` | Any guard must pass |
272
+ | \`not(guard)\` | Inverts guard result |
273
+ `,
274
+ };
275
+ /**
276
+ * Error handling template
277
+ */
278
+ export const ERROR_HANDLING = {
279
+ name: 'error-handling',
280
+ description: 'Guide for error handling in VeloxTS',
281
+ content: `# Error Handling in VeloxTS
282
+
283
+ ## Using VeloxError
284
+
285
+ VeloxTS provides structured errors with codes, messages, and fix suggestions.
286
+
287
+ ### Factory Methods
288
+ \`\`\`typescript
289
+ import { VeloxError } from '@veloxts/core';
290
+
291
+ // Not found (404)
292
+ throw VeloxError.notFound('User', userId);
293
+
294
+ // Validation error (400)
295
+ throw VeloxError.validation('Invalid email format');
296
+
297
+ // Unauthorized (401)
298
+ throw VeloxError.unauthorized('Login required');
299
+
300
+ // Forbidden (403)
301
+ throw VeloxError.forbidden('Cannot access this resource');
302
+
303
+ // Conflict (409)
304
+ throw VeloxError.conflict('Email already registered');
305
+ \`\`\`
306
+
307
+ ### Custom Errors
308
+ \`\`\`typescript
309
+ throw new VeloxError({
310
+ code: 'E1006',
311
+ message: 'Custom error message',
312
+ fix: 'Suggested fix for the user',
313
+ details: { additionalContext: 'value' },
314
+ });
315
+ \`\`\`
316
+
317
+ ## Error Code Categories
318
+
319
+ | Range | Category |
320
+ |-------|----------|
321
+ | E1xxx | Core/Runtime |
322
+ | E2xxx | Generator |
323
+ | E3xxx | Seeding |
324
+ | E4xxx | Migration |
325
+ | E5xxx | Dev Server |
326
+ | E6xxx | Validation |
327
+ | E7xxx | Authentication |
328
+ | E8xxx | Database |
329
+ | E9xxx | Configuration |
330
+
331
+ ## Error Handling Patterns
332
+
333
+ ### In Procedures
334
+ \`\`\`typescript
335
+ const getUser = procedure()
336
+ .input(z.object({ id: z.string().uuid() }))
337
+ .query(async ({ ctx, input }) => {
338
+ const user = await ctx.db.user.findUnique({
339
+ where: { id: input.id },
340
+ });
341
+
342
+ if (!user) {
343
+ throw VeloxError.notFound('User', input.id);
344
+ }
345
+
346
+ return user;
347
+ });
348
+ \`\`\`
349
+
350
+ ### Global Error Handler
351
+ Fastify automatically catches errors and formats them based on the error type.
352
+
353
+ ### JSON Error Response
354
+ \`\`\`json
355
+ {
356
+ "success": false,
357
+ "error": {
358
+ "code": "E1001",
359
+ "message": "User not found",
360
+ "fix": "Check that the user ID is correct",
361
+ "docsUrl": "https://veloxts.dev/errors/E1001"
362
+ }
363
+ }
364
+ \`\`\`
365
+ `,
366
+ };
367
+ // ============================================================================
368
+ // Registry
369
+ // ============================================================================
370
+ /**
371
+ * All available prompt templates
372
+ */
373
+ export const PROMPT_TEMPLATES = [
374
+ CREATE_PROCEDURE,
375
+ ADD_VALIDATION,
376
+ SETUP_AUTH,
377
+ ERROR_HANDLING,
378
+ ];
379
+ /**
380
+ * Get a prompt template by name
381
+ */
382
+ export function getPromptTemplate(name) {
383
+ return PROMPT_TEMPLATES.find((t) => t.name === name);
384
+ }
385
+ /**
386
+ * Render a prompt template with argument substitution
387
+ *
388
+ * Supports the following placeholder transformations:
389
+ * - {arg} - lowercase (e.g., "user")
390
+ * - {Arg} - PascalCase (e.g., "User")
391
+ * - {args} - lowercase plural (e.g., "users")
392
+ * - {Args} - PascalCase plural (e.g., "Users")
393
+ *
394
+ * @param name - Template name
395
+ * @param args - Argument values as key-value pairs
396
+ * @returns Rendered content or undefined if template not found
397
+ */
398
+ export function renderPromptTemplate(name, args) {
399
+ const template = getPromptTemplate(name);
400
+ if (!template)
401
+ return undefined;
402
+ let content = template.content;
403
+ for (const [key, value] of Object.entries(args)) {
404
+ // Skip empty values
405
+ if (!value)
406
+ continue;
407
+ const lower = value.toLowerCase();
408
+ const pascal = value.charAt(0).toUpperCase() + value.slice(1).toLowerCase();
409
+ // Simple pluralization (add 's' or 'es')
410
+ const pluralize = (s) => {
411
+ if (s.endsWith('s') ||
412
+ s.endsWith('x') ||
413
+ s.endsWith('z') ||
414
+ s.endsWith('ch') ||
415
+ s.endsWith('sh')) {
416
+ return `${s}es`;
417
+ }
418
+ return `${s}s`;
419
+ };
420
+ // Replace all variations of the placeholder
421
+ // {key} - lowercase
422
+ content = content.replace(new RegExp(`\\{${key}\\}`, 'g'), lower);
423
+ // {Key} - PascalCase
424
+ const pascalKey = key.charAt(0).toUpperCase() + key.slice(1);
425
+ content = content.replace(new RegExp(`\\{${pascalKey}\\}`, 'g'), pascal);
426
+ // {keys} - lowercase plural (when key ends without 's')
427
+ content = content.replace(new RegExp(`\\{${key}s\\}`, 'g'), pluralize(lower));
428
+ // {Keys} - PascalCase plural
429
+ content = content.replace(new RegExp(`\\{${pascalKey}s\\}`, 'g'), pluralize(pascal));
430
+ }
431
+ return content;
432
+ }
433
+ /**
434
+ * List all available prompts
435
+ */
436
+ export function listPromptTemplates() {
437
+ return PROMPT_TEMPLATES.map((t) => ({
438
+ name: t.name,
439
+ description: t.description,
440
+ }));
441
+ }
442
+ //# sourceMappingURL=templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/prompts/templates.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgCH,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAmB;IAC9C,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,4CAA4C;IACzD,SAAS,EAAE;QACT,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gCAAgC,EAAE,QAAQ,EAAE,IA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GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7D,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,MAAM,SAAS,KAAK,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;QACzE,wDAAwD;QACxD,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9E,6BAA6B;QAC7B,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,MAAM,SAAS,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IACvF,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAClC,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,WAAW,EAAE,CAAC,CAAC,WAAW;KAC3B,CAAC,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Errors Resource
3
+ *
4
+ * Exposes the VeloxTS error catalog to AI tools.
5
+ */
6
+ /**
7
+ * Error information for MCP response
8
+ */
9
+ export interface ErrorInfo {
10
+ code: string;
11
+ name: string;
12
+ message: string;
13
+ fix?: string;
14
+ docsUrl?: string;
15
+ category: string;
16
+ }
17
+ /**
18
+ * Errors resource response
19
+ */
20
+ export interface ErrorsResourceResponse {
21
+ errors: ErrorInfo[];
22
+ categories: {
23
+ prefix: string;
24
+ name: string;
25
+ count: number;
26
+ }[];
27
+ totalCount: number;
28
+ }
29
+ /**
30
+ * Get all errors from the catalog
31
+ */
32
+ export declare function getErrors(): ErrorsResourceResponse;
33
+ /**
34
+ * Get errors for a specific category
35
+ */
36
+ export declare function getErrorsByPrefix(prefix: string): ErrorInfo[];
37
+ /**
38
+ * Search errors by keyword
39
+ */
40
+ export declare function searchErrors(query: string): ErrorInfo[];
41
+ /**
42
+ * Format errors response as text
43
+ */
44
+ export declare function formatErrorsAsText(response: ErrorsResourceResponse): string;
45
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/resources/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,UAAU,EAAE;QACV,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,UAAU,EAAE,MAAM,CAAC;CACpB;AA+BD;;GAEG;AACH,wBAAgB,SAAS,IAAI,sBAAsB,CAqBlD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,CAU7D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,CAmBvD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,sBAAsB,GAAG,MAAM,CA6B3E"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Errors Resource
3
+ *
4
+ * Exposes the VeloxTS error catalog to AI tools.
5
+ */
6
+ import { ERROR_CATALOG, getErrorsByCategory } from '@veloxts/cli';
7
+ // ============================================================================
8
+ // Error Categories
9
+ // ============================================================================
10
+ const ERROR_CATEGORIES = [
11
+ { prefix: 'E1', name: 'Core/Runtime' },
12
+ { prefix: 'E2', name: 'Generator' },
13
+ { prefix: 'E3', name: 'Seeding' },
14
+ { prefix: 'E4', name: 'Migration' },
15
+ { prefix: 'E5', name: 'Dev Server' },
16
+ { prefix: 'E6', name: 'Validation' },
17
+ { prefix: 'E7', name: 'Authentication' },
18
+ { prefix: 'E8', name: 'Database' },
19
+ { prefix: 'E9', name: 'Configuration' },
20
+ ];
21
+ // ============================================================================
22
+ // Resource Handler
23
+ // ============================================================================
24
+ /**
25
+ * Get the category name for an error code
26
+ */
27
+ function getErrorCategory(code) {
28
+ const prefix = code.substring(0, 2);
29
+ const category = ERROR_CATEGORIES.find((c) => c.prefix === prefix);
30
+ return category?.name ?? 'Unknown';
31
+ }
32
+ /**
33
+ * Get all errors from the catalog
34
+ */
35
+ export function getErrors() {
36
+ const errors = Object.values(ERROR_CATALOG).map((def) => ({
37
+ code: def.code,
38
+ name: def.name,
39
+ message: def.message,
40
+ fix: def.fix,
41
+ docsUrl: def.docsUrl,
42
+ category: getErrorCategory(def.code),
43
+ }));
44
+ const categories = ERROR_CATEGORIES.map((cat) => ({
45
+ prefix: cat.prefix,
46
+ name: cat.name,
47
+ count: getErrorsByCategory(cat.prefix).length,
48
+ })).filter((cat) => cat.count > 0);
49
+ return {
50
+ errors,
51
+ categories,
52
+ totalCount: errors.length,
53
+ };
54
+ }
55
+ /**
56
+ * Get errors for a specific category
57
+ */
58
+ export function getErrorsByPrefix(prefix) {
59
+ const defs = getErrorsByCategory(prefix);
60
+ return defs.map((def) => ({
61
+ code: def.code,
62
+ name: def.name,
63
+ message: def.message,
64
+ fix: def.fix,
65
+ docsUrl: def.docsUrl,
66
+ category: getErrorCategory(def.code),
67
+ }));
68
+ }
69
+ /**
70
+ * Search errors by keyword
71
+ */
72
+ export function searchErrors(query) {
73
+ const lowerQuery = query.toLowerCase();
74
+ return Object.values(ERROR_CATALOG)
75
+ .filter((def) => def.code.toLowerCase().includes(lowerQuery) ||
76
+ def.name.toLowerCase().includes(lowerQuery) ||
77
+ def.message.toLowerCase().includes(lowerQuery) ||
78
+ def.fix?.toLowerCase().includes(lowerQuery))
79
+ .map((def) => ({
80
+ code: def.code,
81
+ name: def.name,
82
+ message: def.message,
83
+ fix: def.fix,
84
+ docsUrl: def.docsUrl,
85
+ category: getErrorCategory(def.code),
86
+ }));
87
+ }
88
+ /**
89
+ * Format errors response as text
90
+ */
91
+ export function formatErrorsAsText(response) {
92
+ const lines = [
93
+ '# VeloxTS Error Catalog',
94
+ '',
95
+ `Total errors: ${response.totalCount}`,
96
+ '',
97
+ '## Categories',
98
+ '',
99
+ ];
100
+ for (const cat of response.categories) {
101
+ lines.push(`- ${cat.prefix}xxx: ${cat.name} (${cat.count} errors)`);
102
+ }
103
+ lines.push('', '## All Errors', '');
104
+ for (const error of response.errors) {
105
+ lines.push(`### ${error.code}: ${error.name}`);
106
+ lines.push(`**Message:** ${error.message}`);
107
+ if (error.fix) {
108
+ lines.push(`**Fix:** ${error.fix}`);
109
+ }
110
+ if (error.docsUrl) {
111
+ lines.push(`**Docs:** ${error.docsUrl}`);
112
+ }
113
+ lines.push('');
114
+ }
115
+ return lines.join('\n');
116
+ }
117
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/resources/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AA+BlE,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E,MAAM,gBAAgB,GAAG;IACvB,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE;IACtC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE;IACnC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE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B,KAAK,CAAC,IAAI,CAAC,aAAa,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC3C,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * MCP Resources
3
+ *
4
+ * Resources expose read-only project context to AI tools.
5
+ */
6
+ export type { ErrorInfo, ErrorsResourceResponse } from './errors.js';
7
+ export { formatErrorsAsText, getErrors, getErrorsByPrefix, searchErrors, } from './errors.js';
8
+ export type { ProcedureInfo, ProceduresResourceResponse } from './procedures.js';
9
+ export { formatProceduresAsText, getProcedures, getProceduresByNamespace, getProceduresByType, } from './procedures.js';
10
+ export type { RouteInfo, RoutesResourceResponse } from './routes.js';
11
+ export { formatRoutesAsText, getRoutes, getRoutesByMethod, getRoutesByNamespace, } from './routes.js';
12
+ export type { SchemaInfo, SchemasResourceResponse } from './schemas.js';
13
+ export { formatSchemasAsText, getSchemas, searchSchemas, } from './schemas.js';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EACjB,YAAY,GACb,MAAM,aAAa,CAAC;AAErB,YAAY,EAAE,aAAa,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AACjF,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAErB,YAAY,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,aAAa,GACd,MAAM,cAAc,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * MCP Resources
3
+ *
4
+ * Resources expose read-only project context to AI tools.
5
+ */
6
+ export { formatErrorsAsText, getErrors, getErrorsByPrefix, searchErrors, } from './errors.js';
7
+ export { formatProceduresAsText, getProcedures, getProceduresByNamespace, getProceduresByType, } from './procedures.js';
8
+ export { formatRoutesAsText, getRoutes, getRoutesByMethod, getRoutesByNamespace, } from './routes.js';
9
+ export { formatSchemasAsText, getSchemas, searchSchemas, } from './schemas.js';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EACjB,YAAY,GACb,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,aAAa,GACd,MAAM,cAAc,CAAC"}