@guren/server 1.0.0-rc.9 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/{Application-DtWDHXr1.d.ts → Application-BnsyCKXY.d.ts} +79 -8
  2. package/dist/AuthManager-SfhCNkAU.d.ts +79 -0
  3. package/dist/{BroadcastManager-AkIWUGJo.d.ts → BroadcastManager-CGWl9rUO.d.ts} +5 -0
  4. package/dist/{ConsoleKernel-CqCVrdZs.d.ts → ConsoleKernel-BDtBETjm.d.ts} +1 -1
  5. package/dist/{Gate-CNkBYf8m.d.ts → Gate-CynjZCtS.d.ts} +5 -0
  6. package/dist/{I18nManager-Dtgzsf5n.d.ts → I18nManager-BiSoczfV.d.ts} +6 -1
  7. package/dist/McpServiceProvider-JW6PDVMD.js +7 -0
  8. package/dist/api-token-BSSCLlFW.d.ts +541 -0
  9. package/dist/auth/index.d.ts +9 -327
  10. package/dist/auth/index.js +59 -6684
  11. package/dist/authorization/index.d.ts +2 -2
  12. package/dist/authorization/index.js +19 -604
  13. package/dist/broadcasting/index.d.ts +2 -2
  14. package/dist/broadcasting/index.js +12 -895
  15. package/dist/cache/index.js +8 -809
  16. package/dist/chunk-2T6JN4VR.js +1563 -0
  17. package/dist/chunk-44F7JQ7I.js +950 -0
  18. package/dist/chunk-74HTZG3V.js +331 -0
  19. package/dist/chunk-A3ISJVEV.js +598 -0
  20. package/dist/chunk-CSDKWLFD.js +652 -0
  21. package/dist/chunk-CSRQTEQA.js +839 -0
  22. package/dist/chunk-DAQKYKLH.js +182 -0
  23. package/dist/chunk-EDRGAM6G.js +647 -0
  24. package/dist/chunk-EGU5KB7V.js +818 -0
  25. package/dist/chunk-H32L2NE3.js +372 -0
  26. package/dist/chunk-HKQSAFSN.js +837 -0
  27. package/dist/chunk-IOTWFHZU.js +558 -0
  28. package/dist/chunk-ONSDE37A.js +125 -0
  29. package/dist/chunk-QQKTH5KX.js +114 -0
  30. package/dist/chunk-R2TCP7D7.js +409 -0
  31. package/dist/chunk-SIP34GBE.js +380 -0
  32. package/dist/chunk-THSX7OOR.js +454 -0
  33. package/dist/chunk-UY3AZSYL.js +14 -0
  34. package/dist/chunk-VT5KRDPH.js +134 -0
  35. package/dist/chunk-VXXZIXAP.js +255 -0
  36. package/dist/chunk-WJJ5CTNI.js +907 -0
  37. package/dist/chunk-WVY45EIW.js +359 -0
  38. package/dist/chunk-ZRBLZY3M.js +462 -0
  39. package/dist/client-CKXJLsTe.d.ts +232 -0
  40. package/dist/email-verification-CAeArjui.d.ts +327 -0
  41. package/dist/encryption/index.js +48 -556
  42. package/dist/errors-JOOPDDQ6.js +34 -0
  43. package/dist/events/index.js +14 -316
  44. package/dist/health/index.js +12 -367
  45. package/dist/i18n/index.d.ts +2 -2
  46. package/dist/i18n/index.js +14 -583
  47. package/dist/index.d.ts +37 -239
  48. package/dist/index.js +2873 -19166
  49. package/dist/lambda/index.d.ts +9 -7
  50. package/dist/lambda/index.js +4 -9
  51. package/dist/logging/index.js +12 -545
  52. package/dist/mail/index.d.ts +29 -1
  53. package/dist/mail/index.js +15 -684
  54. package/dist/mcp/index.d.ts +7 -5
  55. package/dist/mcp/index.js +5 -378
  56. package/dist/notifications/index.d.ts +8 -6
  57. package/dist/notifications/index.js +13 -730
  58. package/dist/queue/index.d.ts +37 -7
  59. package/dist/queue/index.js +22 -940
  60. package/dist/redis/index.d.ts +366 -0
  61. package/dist/redis/index.js +597 -0
  62. package/dist/runtime/index.d.ts +8 -6
  63. package/dist/runtime/index.js +26 -244
  64. package/dist/scheduling/index.js +14 -822
  65. package/dist/storage/index.d.ts +1 -0
  66. package/dist/storage/index.js +6 -824
  67. package/package.json +15 -7
  68. package/dist/api-token-JOif2CtG.d.ts +0 -1792
@@ -0,0 +1,359 @@
1
+ import {
2
+ ServiceProvider
3
+ } from "./chunk-VT5KRDPH.js";
4
+
5
+ // src/mcp/create-mcp-server.ts
6
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
7
+ import { z } from "zod";
8
+ function createMcpServer(options) {
9
+ const { cwd, cli, version = "0.2.0" } = options;
10
+ const server = new McpServer({
11
+ name: "guren",
12
+ version
13
+ });
14
+ server.tool(
15
+ "guren_get_context",
16
+ "Get a complete project context map including models, routes, pages, controllers, resources, events, jobs, middleware, listeners, and validators.",
17
+ {
18
+ format: z.enum(["json", "markdown"]).default("json").describe("Output format")
19
+ },
20
+ async ({ format }) => {
21
+ const ctx = await cli.generateContext({ cwd });
22
+ const text = format === "markdown" ? cli.renderContextMarkdown(ctx) : JSON.stringify(ctx, null, 2);
23
+ return { content: [{ type: "text", text }] };
24
+ }
25
+ );
26
+ server.tool(
27
+ "guren_check",
28
+ "Validate route-to-controller-to-page consistency, check for empty controller methods, missing test files, and missing generated manifests.",
29
+ {},
30
+ async () => {
31
+ const report = await cli.runCheck({ cwd });
32
+ return { content: [{ type: "text", text: JSON.stringify(report, null, 2) }] };
33
+ }
34
+ );
35
+ server.tool(
36
+ "guren_list_models",
37
+ "List all models with their table names, relationships, authentication trait, and soft deletes status.",
38
+ {},
39
+ async () => {
40
+ const models = await cli.listModels({ appRoot: cwd });
41
+ return { content: [{ type: "text", text: JSON.stringify(models, null, 2) }] };
42
+ }
43
+ );
44
+ server.tool(
45
+ "guren_generate_guidelines",
46
+ "Generate project-specific coding guidelines based on the current project structure, naming conventions, auth setup, models, validation patterns, and middleware.",
47
+ {},
48
+ async () => {
49
+ const guidelines = await cli.generateGuidelines({ cwd });
50
+ return { content: [{ type: "text", text: guidelines }] };
51
+ }
52
+ );
53
+ server.tool(
54
+ "guren_doctor",
55
+ "Run a comprehensive health check on the Guren project and optionally suggest actionable next steps.",
56
+ {
57
+ next: z.boolean().default(false).describe("Include actionable next steps")
58
+ },
59
+ async ({ next }) => {
60
+ const report = await cli.runDoctor({ cwd });
61
+ let text = JSON.stringify(report, null, 2);
62
+ if (next) {
63
+ const steps = await cli.suggestNextSteps({ cwd });
64
+ text = JSON.stringify({ ...report, nextSteps: steps }, null, 2);
65
+ }
66
+ return { content: [{ type: "text", text }] };
67
+ }
68
+ );
69
+ server.tool(
70
+ "guren_make_feature",
71
+ "Generate a complete CRUD feature: controller, model, views (Index, Show, New, Edit), validator, and resource. Optionally include test file.",
72
+ {
73
+ name: z.string().describe('Resource name in PascalCase (e.g., "Post", "BlogComment")'),
74
+ fields: z.string().optional().describe(
75
+ 'Comma-separated field definitions (e.g., "title:string,body:text,published:boolean")'
76
+ ),
77
+ withTest: z.boolean().default(false).describe("Generate test file"),
78
+ force: z.boolean().default(false).describe("Overwrite existing files")
79
+ },
80
+ async ({ name, fields, withTest, force }) => {
81
+ const originalCwd = process.cwd();
82
+ try {
83
+ process.chdir(cwd);
84
+ const createdFiles = await cli.makeFeature(name, { fields, withTest, force });
85
+ return {
86
+ content: [{ type: "text", text: JSON.stringify({ created: createdFiles }, null, 2) }]
87
+ };
88
+ } finally {
89
+ process.chdir(originalCwd);
90
+ }
91
+ }
92
+ );
93
+ server.tool(
94
+ "guren_make_component",
95
+ "Generate a single component: controller, model, middleware, event, job, listener, resource, view, test, mail, notification, seeder, factory, or migration.",
96
+ {
97
+ type: z.enum([
98
+ "controller",
99
+ "model",
100
+ "middleware",
101
+ "event",
102
+ "job",
103
+ "listener",
104
+ "resource",
105
+ "view",
106
+ "test",
107
+ "mail",
108
+ "notification",
109
+ "seeder",
110
+ "factory",
111
+ "provider",
112
+ "exception",
113
+ "command",
114
+ "channel"
115
+ ]).describe("Component type to generate"),
116
+ name: z.string().describe("Component name in PascalCase"),
117
+ force: z.boolean().default(false).describe("Overwrite existing files")
118
+ },
119
+ async ({ type, name, force }) => {
120
+ const originalCwd = process.cwd();
121
+ try {
122
+ process.chdir(cwd);
123
+ const makers = {
124
+ controller: cli.makeController,
125
+ model: cli.makeModel,
126
+ view: cli.makeView,
127
+ test: cli.makeTest,
128
+ route: cli.makeRoute
129
+ };
130
+ const maker = makers[type];
131
+ if (!maker) {
132
+ return {
133
+ content: [
134
+ {
135
+ type: "text",
136
+ text: `Component type "${type}" is not yet supported via MCP. Use the CLI: bunx guren make:${type} ${name}`
137
+ }
138
+ ],
139
+ isError: true
140
+ };
141
+ }
142
+ const result = await maker(name, { force });
143
+ const created = Array.isArray(result) ? result : [result];
144
+ return {
145
+ content: [{ type: "text", text: JSON.stringify({ created }, null, 2) }]
146
+ };
147
+ } finally {
148
+ process.chdir(originalCwd);
149
+ }
150
+ }
151
+ );
152
+ server.tool(
153
+ "guren_codegen",
154
+ "Generate type-safe route, page, data, and channel type manifests (.guren/*.gen.ts files).",
155
+ {},
156
+ async () => {
157
+ const originalCwd = process.cwd();
158
+ try {
159
+ process.chdir(cwd);
160
+ const generated = [];
161
+ try {
162
+ await cli.generateRouteTypes({ cwd });
163
+ generated.push(".guren/routes.gen.ts");
164
+ } catch {
165
+ }
166
+ try {
167
+ await cli.generatePageTypes({ cwd });
168
+ generated.push(".guren/pages.gen.ts");
169
+ } catch {
170
+ }
171
+ try {
172
+ await cli.generateDataTypes({ cwd });
173
+ generated.push(".guren/data.gen.ts");
174
+ } catch {
175
+ }
176
+ try {
177
+ await cli.generateChannelTypes({ cwd });
178
+ generated.push(".guren/channels.gen.ts");
179
+ } catch {
180
+ }
181
+ return {
182
+ content: [{ type: "text", text: JSON.stringify({ generated }, null, 2) }]
183
+ };
184
+ } finally {
185
+ process.chdir(originalCwd);
186
+ }
187
+ }
188
+ );
189
+ server.resource(
190
+ "context",
191
+ "guren://context",
192
+ {
193
+ description: "Current project structure map (models, routes, pages, controllers, etc.)",
194
+ mimeType: "application/json"
195
+ },
196
+ async (uri) => {
197
+ const ctx = await cli.generateContext({ cwd });
198
+ return {
199
+ contents: [
200
+ {
201
+ uri: uri.href,
202
+ mimeType: "application/json",
203
+ text: JSON.stringify(ctx, null, 2)
204
+ }
205
+ ]
206
+ };
207
+ }
208
+ );
209
+ server.resource(
210
+ "guidelines",
211
+ "guren://guidelines",
212
+ {
213
+ description: "Auto-generated project-specific coding guidelines",
214
+ mimeType: "text/markdown"
215
+ },
216
+ async (uri) => {
217
+ const guidelines = await cli.generateGuidelines({ cwd });
218
+ return {
219
+ contents: [
220
+ {
221
+ uri: uri.href,
222
+ mimeType: "text/markdown",
223
+ text: guidelines
224
+ }
225
+ ]
226
+ };
227
+ }
228
+ );
229
+ server.prompt(
230
+ "guren_review",
231
+ "Review code changes against project conventions and patterns. Automatically fetches project context and runs integrity checks first.",
232
+ async () => {
233
+ let contextSummary;
234
+ try {
235
+ const ctx = await cli.generateContext({ cwd });
236
+ const check = await cli.runCheck({ cwd });
237
+ contextSummary = [
238
+ "## Project Context",
239
+ `Framework: ${ctx.framework.name} v${ctx.framework.version}`,
240
+ `Models: ${ctx.models.map((m) => m.className).join(", ") || "none"}`,
241
+ `Controllers: ${ctx.controllers.join(", ") || "none"}`,
242
+ `Pages: ${ctx.pages.join(", ") || "none"}`,
243
+ "",
244
+ "## Integrity Check",
245
+ `Pass: ${check.passCount}, Warn: ${check.warnCount}, Fail: ${check.failCount}`,
246
+ ...check.checks.filter((c) => c.status !== "pass").map((c) => `- [${c.status}] ${c.title}: ${c.message}`)
247
+ ].join("\n");
248
+ } catch {
249
+ contextSummary = "Could not load project context.";
250
+ }
251
+ return {
252
+ messages: [
253
+ {
254
+ role: "user",
255
+ content: {
256
+ type: "text",
257
+ text: [
258
+ "Review the recent code changes in this Guren project.",
259
+ "Check for:",
260
+ "1. Adherence to project naming conventions and patterns",
261
+ "2. Route-controller-page consistency",
262
+ "3. Missing validation schemas",
263
+ "4. Missing tests for new controllers",
264
+ "5. Proper use of Model API (findOrFail, relationships)",
265
+ "",
266
+ contextSummary
267
+ ].join("\n")
268
+ }
269
+ }
270
+ ]
271
+ };
272
+ }
273
+ );
274
+ server.prompt(
275
+ "guren_plan_feature",
276
+ "Plan a new feature given the current project structure. Provide the feature description as an argument.",
277
+ { feature: z.string().describe("Description of the feature to plan") },
278
+ async ({ feature }) => {
279
+ let contextSummary;
280
+ try {
281
+ const ctx = await cli.generateContext({ cwd });
282
+ const models = await cli.listModels({ appRoot: cwd });
283
+ contextSummary = [
284
+ "## Current Project State",
285
+ `Models: ${models.map((m) => `${m.className}${m.tableName ? ` (${m.tableName})` : ""}`).join(", ") || "none"}`,
286
+ `Controllers: ${ctx.controllers.join(", ") || "none"}`,
287
+ `Routes: ${ctx.routes.length} defined`,
288
+ `Pages: ${ctx.pages.join(", ") || "none"}`,
289
+ "",
290
+ "## Model Relationships",
291
+ ...models.flatMap(
292
+ (m) => m.relationships.length > 0 ? [
293
+ `${m.className}: ${m.relationships.map((r) => `${r.type}(${r.name})`).join(", ")}`
294
+ ] : []
295
+ )
296
+ ].join("\n");
297
+ } catch {
298
+ contextSummary = "Could not load project context.";
299
+ }
300
+ return {
301
+ messages: [
302
+ {
303
+ role: "user",
304
+ content: {
305
+ type: "text",
306
+ text: [
307
+ `Plan the implementation of: ${feature}`,
308
+ "",
309
+ "Provide:",
310
+ "1. Which files to create/modify",
311
+ "2. Database schema changes (migration)",
312
+ "3. Model definition with relationships",
313
+ "4. Controller actions and validation schemas",
314
+ "5. Inertia page components",
315
+ "6. Route definitions",
316
+ "7. Test plan",
317
+ "",
318
+ contextSummary
319
+ ].join("\n")
320
+ }
321
+ }
322
+ ]
323
+ };
324
+ }
325
+ );
326
+ return server;
327
+ }
328
+
329
+ // src/mcp/McpServiceProvider.ts
330
+ var McpServiceProvider = class extends ServiceProvider {
331
+ register() {
332
+ }
333
+ async boot() {
334
+ if (process.env.NODE_ENV === "production") {
335
+ return;
336
+ }
337
+ const app = this.container.make("app");
338
+ const hono = app.hono;
339
+ const cwd = process.cwd();
340
+ const [{ WebStandardStreamableHTTPServerTransport }, cli] = await Promise.all([
341
+ import("@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js"),
342
+ // @ts-ignore — @guren/cli is available at runtime via the app's dependencies
343
+ import("@guren/cli")
344
+ ]);
345
+ hono.all("/_guren/mcp", async (c) => {
346
+ const mcpServer = createMcpServer({ cwd, cli });
347
+ const transport = new WebStandardStreamableHTTPServerTransport({
348
+ sessionIdGenerator: void 0
349
+ });
350
+ await mcpServer.connect(transport);
351
+ return transport.handleRequest(c.req.raw);
352
+ });
353
+ }
354
+ };
355
+
356
+ export {
357
+ createMcpServer,
358
+ McpServiceProvider
359
+ };