@vinkius-core/mcp-fusion 2.8.0 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/cli/fusion.d.ts +29 -0
  2. package/dist/cli/fusion.d.ts.map +1 -1
  3. package/dist/cli/fusion.js +202 -17
  4. package/dist/cli/fusion.js.map +1 -1
  5. package/dist/cli/scaffold.d.ts +10 -0
  6. package/dist/cli/scaffold.d.ts.map +1 -0
  7. package/dist/cli/scaffold.js +92 -0
  8. package/dist/cli/scaffold.js.map +1 -0
  9. package/dist/cli/templates/config.d.ts +14 -0
  10. package/dist/cli/templates/config.d.ts.map +1 -0
  11. package/dist/cli/templates/config.js +133 -0
  12. package/dist/cli/templates/config.js.map +1 -0
  13. package/dist/cli/templates/constants.d.ts +9 -0
  14. package/dist/cli/templates/constants.d.ts.map +1 -0
  15. package/dist/cli/templates/constants.js +9 -0
  16. package/dist/cli/templates/constants.js.map +1 -0
  17. package/dist/cli/templates/core.d.ts +14 -0
  18. package/dist/cli/templates/core.d.ts.map +1 -0
  19. package/dist/cli/templates/core.js +130 -0
  20. package/dist/cli/templates/core.js.map +1 -0
  21. package/dist/cli/templates/cursor.d.ts +8 -0
  22. package/dist/cli/templates/cursor.d.ts.map +1 -0
  23. package/dist/cli/templates/cursor.js +13 -0
  24. package/dist/cli/templates/cursor.js.map +1 -0
  25. package/dist/cli/templates/index.d.ts +17 -0
  26. package/dist/cli/templates/index.d.ts.map +1 -0
  27. package/dist/cli/templates/index.js +27 -0
  28. package/dist/cli/templates/index.js.map +1 -0
  29. package/dist/cli/templates/middleware.d.ts +7 -0
  30. package/dist/cli/templates/middleware.d.ts.map +1 -0
  31. package/dist/cli/templates/middleware.js +31 -0
  32. package/dist/cli/templates/middleware.js.map +1 -0
  33. package/dist/cli/templates/presenter.d.ts +7 -0
  34. package/dist/cli/templates/presenter.d.ts.map +1 -0
  35. package/dist/cli/templates/presenter.js +46 -0
  36. package/dist/cli/templates/presenter.js.map +1 -0
  37. package/dist/cli/templates/prompt.d.ts +7 -0
  38. package/dist/cli/templates/prompt.d.ts.map +1 -0
  39. package/dist/cli/templates/prompt.js +42 -0
  40. package/dist/cli/templates/prompt.js.map +1 -0
  41. package/dist/cli/templates/readme.d.ts +8 -0
  42. package/dist/cli/templates/readme.d.ts.map +1 -0
  43. package/dist/cli/templates/readme.js +177 -0
  44. package/dist/cli/templates/readme.js.map +1 -0
  45. package/dist/cli/templates/testing.d.ts +11 -0
  46. package/dist/cli/templates/testing.d.ts.map +1 -0
  47. package/dist/cli/templates/testing.js +100 -0
  48. package/dist/cli/templates/testing.js.map +1 -0
  49. package/dist/cli/templates/tools.d.ts +9 -0
  50. package/dist/cli/templates/tools.d.ts.map +1 -0
  51. package/dist/cli/templates/tools.js +66 -0
  52. package/dist/cli/templates/tools.js.map +1 -0
  53. package/dist/cli/templates/vectors/database.d.ts +9 -0
  54. package/dist/cli/templates/vectors/database.d.ts.map +1 -0
  55. package/dist/cli/templates/vectors/database.js +87 -0
  56. package/dist/cli/templates/vectors/database.js.map +1 -0
  57. package/dist/cli/templates/vectors/index.d.ts +9 -0
  58. package/dist/cli/templates/vectors/index.d.ts.map +1 -0
  59. package/dist/cli/templates/vectors/index.js +9 -0
  60. package/dist/cli/templates/vectors/index.js.map +1 -0
  61. package/dist/cli/templates/vectors/oauth.d.ts +10 -0
  62. package/dist/cli/templates/vectors/oauth.d.ts.map +1 -0
  63. package/dist/cli/templates/vectors/oauth.js +77 -0
  64. package/dist/cli/templates/vectors/oauth.js.map +1 -0
  65. package/dist/cli/templates/vectors/openapi.d.ts +10 -0
  66. package/dist/cli/templates/vectors/openapi.d.ts.map +1 -0
  67. package/dist/cli/templates/vectors/openapi.js +106 -0
  68. package/dist/cli/templates/vectors/openapi.js.map +1 -0
  69. package/dist/cli/templates/vectors/workflow.d.ts +7 -0
  70. package/dist/cli/templates/vectors/workflow.d.ts.map +1 -0
  71. package/dist/cli/templates/vectors/workflow.js +49 -0
  72. package/dist/cli/templates/vectors/workflow.js.map +1 -0
  73. package/dist/cli/types.d.ts +29 -0
  74. package/dist/cli/types.d.ts.map +1 -0
  75. package/dist/cli/types.js +10 -0
  76. package/dist/cli/types.js.map +1 -0
  77. package/dist/introspection/BehaviorDigest.d.ts.map +1 -1
  78. package/dist/introspection/BehaviorDigest.js +1 -0
  79. package/dist/introspection/BehaviorDigest.js.map +1 -1
  80. package/dist/introspection/CapabilityLockfile.d.ts +2 -0
  81. package/dist/introspection/CapabilityLockfile.d.ts.map +1 -1
  82. package/dist/introspection/CapabilityLockfile.js +1 -0
  83. package/dist/introspection/CapabilityLockfile.js.map +1 -1
  84. package/dist/introspection/ContractDiff.js +1 -1
  85. package/dist/introspection/ContractDiff.js.map +1 -1
  86. package/dist/introspection/EntitlementScanner.d.ts +63 -10
  87. package/dist/introspection/EntitlementScanner.d.ts.map +1 -1
  88. package/dist/introspection/EntitlementScanner.js +224 -9
  89. package/dist/introspection/EntitlementScanner.js.map +1 -1
  90. package/dist/introspection/ToolContract.d.ts +2 -0
  91. package/dist/introspection/ToolContract.d.ts.map +1 -1
  92. package/dist/introspection/ToolContract.js +1 -0
  93. package/dist/introspection/ToolContract.js.map +1 -1
  94. package/dist/introspection/index.d.ts +2 -2
  95. package/dist/introspection/index.d.ts.map +1 -1
  96. package/dist/introspection/index.js +1 -1
  97. package/dist/introspection/index.js.map +1 -1
  98. package/package.json +1 -1
@@ -0,0 +1,133 @@
1
+ import { CORE_VERSION, TESTING_VERSION, MCP_SDK_VERSION, ZOD_VERSION } from './constants.js';
2
+ /** Generate `package.json` with vector-specific deps */
3
+ export function packageJson(config) {
4
+ const deps = {
5
+ '@modelcontextprotocol/sdk': MCP_SDK_VERSION,
6
+ '@vinkius-core/mcp-fusion': CORE_VERSION,
7
+ 'zod': ZOD_VERSION,
8
+ };
9
+ if (config.vector === 'prisma') {
10
+ deps['@prisma/client'] = '^6.0.0';
11
+ deps['mcp-fusion-prisma-gen'] = '^1.0.0';
12
+ }
13
+ if (config.vector === 'n8n') {
14
+ deps['mcp-fusion-n8n'] = '^1.0.0';
15
+ }
16
+ if (config.vector === 'openapi') {
17
+ deps['mcp-fusion-openapi-gen'] = '^1.0.0';
18
+ }
19
+ if (config.vector === 'oauth') {
20
+ deps['@vinkius-core/mcp-fusion-oauth'] = '^1.0.0';
21
+ }
22
+ const devDeps = {
23
+ 'tsx': '^4.19.0',
24
+ 'typescript': '^5.7.3',
25
+ '@types/node': '^22.0.0',
26
+ };
27
+ if (config.vector === 'prisma') {
28
+ devDeps['prisma'] = '^6.0.0';
29
+ }
30
+ if (config.testing) {
31
+ devDeps['vitest'] = '^3.0.5';
32
+ devDeps['@vinkius-core/mcp-fusion-testing'] = TESTING_VERSION;
33
+ }
34
+ const scripts = {
35
+ 'dev': 'tsx watch src/server.ts',
36
+ 'start': 'tsx src/server.ts',
37
+ 'build': 'tsc',
38
+ 'typecheck': 'tsc --noEmit',
39
+ };
40
+ if (config.testing) {
41
+ scripts['test'] = 'vitest run';
42
+ scripts['test:watch'] = 'vitest';
43
+ }
44
+ if (config.vector === 'prisma') {
45
+ scripts['db:generate'] = 'prisma generate';
46
+ scripts['db:push'] = 'prisma db push';
47
+ }
48
+ const pkg = {
49
+ name: config.name,
50
+ version: '0.1.0',
51
+ private: true,
52
+ type: 'module',
53
+ scripts,
54
+ dependencies: deps,
55
+ devDependencies: devDeps,
56
+ engines: { node: '>=18.0.0' },
57
+ };
58
+ return JSON.stringify(pkg, null, 4) + '\n';
59
+ }
60
+ /** Generate `tsconfig.json` */
61
+ export function tsconfig() {
62
+ return JSON.stringify({
63
+ compilerOptions: {
64
+ target: 'es2022',
65
+ module: 'Node16',
66
+ moduleResolution: 'Node16',
67
+ declaration: true,
68
+ sourceMap: true,
69
+ strict: true,
70
+ noUncheckedIndexedAccess: true,
71
+ noFallthroughCasesInSwitch: true,
72
+ exactOptionalPropertyTypes: true,
73
+ noImplicitOverride: true,
74
+ noPropertyAccessFromIndexSignature: true,
75
+ verbatimModuleSyntax: true,
76
+ forceConsistentCasingInFileNames: true,
77
+ resolveJsonModule: true,
78
+ skipLibCheck: true,
79
+ rootDir: './src',
80
+ outDir: './dist',
81
+ },
82
+ include: ['src/**/*'],
83
+ exclude: ['node_modules', 'dist', 'tests'],
84
+ }, null, 4) + '\n';
85
+ }
86
+ /** Generate `.gitignore` */
87
+ export function gitignore() {
88
+ return `node_modules/
89
+ dist/
90
+ *.tsbuildinfo
91
+ .env
92
+ .env.local
93
+ coverage/
94
+ `;
95
+ }
96
+ /** Generate `.env.example` with vector-specific vars */
97
+ export function envExample(config) {
98
+ let env = `# ── MCP Fusion Server Environment ─────────────────────
99
+ # Copy this to .env and fill in your values.
100
+
101
+ # Server
102
+ NODE_ENV=development
103
+ `;
104
+ if (config.vector === 'prisma') {
105
+ env += `
106
+ # Database (Prisma)
107
+ DATABASE_URL="postgresql://user:password@localhost:5432/mydb?schema=public"
108
+ `;
109
+ }
110
+ if (config.vector === 'n8n') {
111
+ env += `
112
+ # n8n Workflow Automation
113
+ N8N_BASE_URL=http://localhost:5678
114
+ N8N_API_KEY=your-api-key-here
115
+ `;
116
+ }
117
+ if (config.vector === 'oauth') {
118
+ env += `
119
+ # OAuth Device Flow (RFC 8628)
120
+ OAUTH_CLIENT_ID=your-client-id
121
+ OAUTH_AUTH_ENDPOINT=https://api.example.com/oauth/device/code
122
+ OAUTH_TOKEN_ENDPOINT=https://api.example.com/oauth/device/token
123
+ `;
124
+ }
125
+ if (config.transport === 'sse') {
126
+ env += `
127
+ # SSE Transport
128
+ PORT=3001
129
+ `;
130
+ }
131
+ return env;
132
+ }
133
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/cli/templates/config.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7F,wDAAwD;A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AAE,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC;KAC7C,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;AACvB,CAAC;AAED,4BAA4B;AAC5B,MAAM,UAAU,SAAS;IACrB,OAAO;;;;;;CAMV,CAAC;AACF,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,UAAU,CAAC,MAAqB;IAC5C,IAAI,GAAG,GAAG;;;;;CAKb,CAAC;IAEE,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC7B,GAAG,IAAI;;;CAGd,CAAC;IACE,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;QAC1B,GAAG,IAAI;;;;CAId,CAAC;IACE,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;QAC5B,GAAG,IAAI;;;;;CAKd,CAAC;IACE,CAAC;IACD,IAAI,MAAM,CAAC,SAAS,KAAK,KAAK,EAAE,CAAC;QAC7B,GAAG,IAAI;;;CAGd,CAAC;IACE,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Template Constants — Version pins for generated package.json
3
+ * @module
4
+ */
5
+ export declare const CORE_VERSION = "^2.8.0";
6
+ export declare const TESTING_VERSION = "^1.0.0";
7
+ export declare const MCP_SDK_VERSION = "^1.12.1";
8
+ export declare const ZOD_VERSION = "^3.25.1";
9
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/cli/templates/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,YAAY,WAAW,CAAC;AACrC,eAAO,MAAM,eAAe,WAAW,CAAC;AACxC,eAAO,MAAM,eAAe,YAAY,CAAC;AACzC,eAAO,MAAM,WAAW,YAAY,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Template Constants — Version pins for generated package.json
3
+ * @module
4
+ */
5
+ export const CORE_VERSION = '^2.8.0';
6
+ export const TESTING_VERSION = '^1.0.0';
7
+ export const MCP_SDK_VERSION = '^1.12.1';
8
+ export const ZOD_VERSION = '^3.25.1';
9
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/cli/templates/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC;AACrC,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC;AACxC,MAAM,CAAC,MAAM,eAAe,GAAG,SAAS,CAAC;AACzC,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Core Templates — fusion.ts, context.ts, server.ts
3
+ *
4
+ * The architectural spine of every scaffolded project.
5
+ * @module
6
+ */
7
+ import type { ProjectConfig } from '../types.js';
8
+ /** Generate `src/fusion.ts` — The one-file context center */
9
+ export declare function fusionTs(): string;
10
+ /** Generate `src/context.ts` — Application context type + factory */
11
+ export declare function contextTs(): string;
12
+ /** Generate `src/server.ts` — Bootstrap with autoDiscover + transport */
13
+ export declare function serverTs(config: ProjectConfig): string;
14
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../src/cli/templates/core.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,6DAA6D;AAC7D,wBAAgB,QAAQ,IAAI,MAAM,CAajC;AAED,qEAAqE;AACrE,wBAAgB,SAAS,IAAI,MAAM,CA8BlC;AAED,yEAAyE;AACzE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAkFtD"}
@@ -0,0 +1,130 @@
1
+ /** Generate `src/fusion.ts` — The one-file context center */
2
+ export function fusionTs() {
3
+ return `/**
4
+ * Fusion Instance — Context Initialization
5
+ *
6
+ * Define your context type ONCE. Every f.tool(), f.presenter(),
7
+ * f.prompt(), and f.middleware() call inherits AppContext —
8
+ * zero generic repetition anywhere in the codebase.
9
+ */
10
+ import { initFusion } from '@vinkius-core/mcp-fusion';
11
+ import type { AppContext } from './context.js';
12
+
13
+ export const f = initFusion<AppContext>();
14
+ `;
15
+ }
16
+ /** Generate `src/context.ts` — Application context type + factory */
17
+ export function contextTs() {
18
+ return `/**
19
+ * Application Context — Shared State for Every Tool Handler
20
+ *
21
+ * Every f.tool() handler receives { input, ctx } where ctx
22
+ * is this AppContext. Extend it with your own services
23
+ * (DB client, auth, external APIs, etc.)
24
+ */
25
+
26
+ export interface AppContext {
27
+ /** Current user role for RBAC checks */
28
+ role: 'ADMIN' | 'USER' | 'GUEST';
29
+
30
+ /** Tenant identifier (multi-tenancy) */
31
+ tenantId: string;
32
+ }
33
+
34
+ /**
35
+ * Create the application context for each tool invocation.
36
+ *
37
+ * In production, hydrate this from the MCP session metadata,
38
+ * JWT tokens, or environment variables.
39
+ */
40
+ export function createContext(): AppContext {
41
+ return {
42
+ role: 'ADMIN',
43
+ tenantId: 'default',
44
+ };
45
+ }
46
+ `;
47
+ }
48
+ /** Generate `src/server.ts` — Bootstrap with autoDiscover + transport */
49
+ export function serverTs(config) {
50
+ const transportImport = config.transport === 'stdio'
51
+ ? `import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';`
52
+ : `import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
53
+ import { createServer } from 'node:http';`;
54
+ const transportSetup = config.transport === 'stdio'
55
+ ? `
56
+ // ── Transport ────────────────────────────────────────────
57
+ const transport = new StdioServerTransport();
58
+ await server.connect(transport);
59
+ console.error('⚡ MCP Fusion server running on stdio');`
60
+ : `
61
+ // ── Transport ────────────────────────────────────────────
62
+ const PORT = Number(process.env['PORT'] ?? 3001);
63
+ const transports = new Map<string, SSEServerTransport>();
64
+
65
+ const httpServer = createServer(async (req, res) => {
66
+ if (req.method === 'GET' && req.url === '/sse') {
67
+ const sseTransport = new SSEServerTransport('/mcp/messages', res);
68
+ transports.set(sseTransport.sessionId, sseTransport);
69
+ res.on('close', () => transports.delete(sseTransport.sessionId));
70
+ await server.connect(sseTransport);
71
+ } else if (req.method === 'POST' && req.url?.startsWith('/mcp/messages')) {
72
+ const url = new URL(req.url, \`http://localhost:\${PORT}\`);
73
+ const sessionId = url.searchParams.get('sessionId') ?? '';
74
+ const transport = transports.get(sessionId);
75
+ if (transport) {
76
+ await transport.handlePostMessage(req, res);
77
+ } else {
78
+ res.writeHead(400).end('Unknown session');
79
+ }
80
+ } else {
81
+ res.writeHead(404).end();
82
+ }
83
+ });
84
+
85
+ httpServer.listen(PORT, () => {
86
+ console.error(\`⚡ MCP Fusion SSE server on http://localhost:\${PORT}/sse\`);
87
+ });`;
88
+ return `/**
89
+ * Server Bootstrap — MCP Fusion with autoDiscover
90
+ *
91
+ * Tools are auto-discovered from src/tools/ — drop a file,
92
+ * it becomes a tool. No manual imports or registration needed.
93
+ */
94
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
95
+ ${transportImport}
96
+ import { ToolRegistry, autoDiscover, PromptRegistry } from '@vinkius-core/mcp-fusion';
97
+ import type { AppContext } from './context.js';
98
+ import { createContext } from './context.js';
99
+ import { f } from './fusion.js';
100
+ import { GreetPrompt } from './prompts/greet.js';
101
+
102
+ // ── Registries ───────────────────────────────────────────
103
+ const registry = f.registry();
104
+ const prompts = new PromptRegistry<AppContext>();
105
+
106
+ // ── Auto-Discover Tools ──────────────────────────────────
107
+ const discovered = await autoDiscover(registry, new URL('./tools', import.meta.url).pathname);
108
+ console.error(\`📦 Discovered \${discovered.length} tool file(s)\`);
109
+
110
+ // ── Register Prompts ─────────────────────────────────────
111
+ prompts.register(GreetPrompt);
112
+ console.error(\`💬 Registered \${prompts.size} prompt(s)\`);
113
+
114
+ // ── Server ───────────────────────────────────────────────
115
+ const server = new Server(
116
+ { name: '${config.name}', version: '0.1.0' },
117
+ { capabilities: { tools: {}, prompts: {} } },
118
+ );
119
+
120
+ registry.attachToServer(server, {
121
+ contextFactory: () => createContext(),
122
+ });
123
+
124
+ prompts.attachToServer(server, {
125
+ contextFactory: () => createContext(),
126
+ });
127
+ ${transportSetup}
128
+ `;
129
+ }
130
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/cli/templates/core.ts"],"names":[],"mappings":"AAQA,6DAA6D;AAC7D,MAAM,UAAU,QAAQ;IACpB,OAAO;;;;;;;;;;;CAWV,CAAC;AACF,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,SAAS;IACrB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BV,CAAC;AACF,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,QAAQ,CAAC,MAAqB;IAC1C,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,KAAK,OAAO;QAChD,CAAC,CAAC,mFAAmF;QACrF,CAAC,CAAC;0CACgC,CAAC;IAEvC,MAAM,cAAc,GAAG,MAAM,CAAC,SAAS,KAAK,OAAO;QAC/C,CAAC,CAAC;;;;uDAI6C;QAC/C,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2BN,CAAC;IAED,OAAO;;;;;;;EAOT,eAAe;;;;;;;;;;;;;;;;;;;;;eAqBF,MAAM,CAAC,IAAI;;;;;;;;;;;EAWxB,cAAc;CACf,CAAC;AACF,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Cursor Template — Zero-click `.cursor/mcp.json` generation
3
+ * @module
4
+ */
5
+ import type { ProjectConfig } from '../types.js';
6
+ /** Generate `.cursor/mcp.json` — Auto-detected by Cursor Editor */
7
+ export declare function cursorMcpJson(config: ProjectConfig): string;
8
+ //# sourceMappingURL=cursor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../../src/cli/templates/cursor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,mEAAmE;AACnE,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAY3D"}
@@ -0,0 +1,13 @@
1
+ /** Generate `.cursor/mcp.json` — Auto-detected by Cursor Editor */
2
+ export function cursorMcpJson(config) {
3
+ const serverEntry = config.transport === 'sse'
4
+ ? { url: 'http://localhost:3001/sse' }
5
+ : { command: 'npx', args: ['tsx', 'src/server.ts'] };
6
+ const serverConfig = {
7
+ mcpServers: {
8
+ [config.name]: serverEntry,
9
+ },
10
+ };
11
+ return JSON.stringify(serverConfig, null, 2) + '\n';
12
+ }
13
+ //# sourceMappingURL=cursor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursor.js","sourceRoot":"","sources":["../../../src/cli/templates/cursor.ts"],"names":[],"mappings":"AAMA,mEAAmE;AACnE,MAAM,UAAU,aAAa,CAAC,MAAqB;IAC/C,MAAM,WAAW,GAAG,MAAM,CAAC,SAAS,KAAK,KAAK;QAC1C,CAAC,CAAC,EAAE,GAAG,EAAE,2BAA2B,EAAE;QACtC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,EAAE,CAAC;IAEzD,MAAM,YAAY,GAAG;QACjB,UAAU,EAAE;YACR,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,WAAW;SAC7B;KACJ,CAAC;IAEF,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;AACxD,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Templates — Barrel Export
3
+ *
4
+ * Re-exports all template generators from their focused modules.
5
+ * @module
6
+ */
7
+ export { packageJson, tsconfig, gitignore, envExample } from './config.js';
8
+ export { fusionTs, contextTs, serverTs } from './core.js';
9
+ export { healthToolTs, echoToolTs } from './tools.js';
10
+ export { systemPresenterTs } from './presenter.js';
11
+ export { greetPromptTs } from './prompt.js';
12
+ export { authMiddlewareTs } from './middleware.js';
13
+ export { vitestConfig, testSetupTs, systemTestTs } from './testing.js';
14
+ export { readme } from './readme.js';
15
+ export { cursorMcpJson } from './cursor.js';
16
+ export { prismaSchema, dbUsersToolTs, n8nConnectorTs, openapiYaml, openapiSetupMd, oauthSetupTs, oauthMiddlewareTs } from './vectors/index.js';
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/templates/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG3E,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAG1D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGnD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGvE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Templates — Barrel Export
3
+ *
4
+ * Re-exports all template generators from their focused modules.
5
+ * @module
6
+ */
7
+ // Config (package.json, tsconfig, etc.)
8
+ export { packageJson, tsconfig, gitignore, envExample } from './config.js';
9
+ // Core source (fusion.ts, context.ts, server.ts)
10
+ export { fusionTs, contextTs, serverTs } from './core.js';
11
+ // Tools
12
+ export { healthToolTs, echoToolTs } from './tools.js';
13
+ // Presenter
14
+ export { systemPresenterTs } from './presenter.js';
15
+ // Prompt
16
+ export { greetPromptTs } from './prompt.js';
17
+ // Middleware
18
+ export { authMiddlewareTs } from './middleware.js';
19
+ // Testing
20
+ export { vitestConfig, testSetupTs, systemTestTs } from './testing.js';
21
+ // README
22
+ export { readme } from './readme.js';
23
+ // Cursor integration
24
+ export { cursorMcpJson } from './cursor.js';
25
+ // Vector-specific
26
+ export { prismaSchema, dbUsersToolTs, n8nConnectorTs, openapiYaml, openapiSetupMd, oauthSetupTs, oauthMiddlewareTs } from './vectors/index.js';
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/templates/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wCAAwC;AACxC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE3E,iDAAiD;AACjD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1D,QAAQ;AACR,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEtD,YAAY;AACZ,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,SAAS;AACT,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,aAAa;AACb,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,UAAU;AACV,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEvE,SAAS;AACT,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,qBAAqB;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,kBAAkB;AAClB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Middleware Template — RBAC guard example
3
+ * @module
4
+ */
5
+ /** Generate `src/middleware/auth.ts` — RBAC middleware */
6
+ export declare function authMiddlewareTs(): string;
7
+ //# sourceMappingURL=middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/cli/templates/middleware.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0DAA0D;AAC1D,wBAAgB,gBAAgB,IAAI,MAAM,CAwBzC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Middleware Template — RBAC guard example
3
+ * @module
4
+ */
5
+ /** Generate `src/middleware/auth.ts` — RBAC middleware */
6
+ export function authMiddlewareTs() {
7
+ return `/**
8
+ * Auth Middleware — RBAC Guard
9
+ *
10
+ * Demonstrates middleware with tRPC-style context derivation.
11
+ * Rejects GUEST requests with a structured error.
12
+ *
13
+ * In production, replace this with JWT validation,
14
+ * API key checks, or OAuth token verification.
15
+ */
16
+ import { error } from '@vinkius-core/mcp-fusion';
17
+ import type { AppContext } from '../context.js';
18
+
19
+ export async function authGuard<TArgs>(
20
+ ctx: AppContext,
21
+ _args: TArgs,
22
+ next: () => Promise<unknown>,
23
+ ): Promise<unknown> {
24
+ if (ctx.role === 'GUEST') {
25
+ return error('Access denied. Authentication required.');
26
+ }
27
+ return next();
28
+ }
29
+ `;
30
+ }
31
+ //# sourceMappingURL=middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/cli/templates/middleware.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0DAA0D;AAC1D,MAAM,UAAU,gBAAgB;IAC5B,OAAO;;;;;;;;;;;;;;;;;;;;;;CAsBV,CAAC;AACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Presenter Template — MVA View Layer (Egress Firewall)
3
+ * @module
4
+ */
5
+ /** Generate `src/presenters/SystemPresenter.ts` */
6
+ export declare function systemPresenterTs(): string;
7
+ //# sourceMappingURL=presenter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presenter.d.ts","sourceRoot":"","sources":["../../../src/cli/templates/presenter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,mDAAmD;AACnD,wBAAgB,iBAAiB,IAAI,MAAM,CAuC1C"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Presenter Template — MVA View Layer (Egress Firewall)
3
+ * @module
4
+ */
5
+ /** Generate `src/presenters/SystemPresenter.ts` */
6
+ export function systemPresenterTs() {
7
+ return [
8
+ '/**',
9
+ ' * System Presenter — MVA View Layer (Egress Firewall)',
10
+ ' *',
11
+ ' * Defines how the Agent perceives system health data.',
12
+ ' * The Zod schema acts as a field whitelist — undeclared',
13
+ ' * fields are physically stripped in RAM before they',
14
+ ' * reach the LLM context window.',
15
+ ' *',
16
+ ' * Features demonstrated:',
17
+ ' * - definePresenter() with Zod schema',
18
+ ' * - .describe() auto-rules (JIT — travel with data, not in global prompt)',
19
+ ' * - ui.markdown() server-rendered UI blocks',
20
+ ' * - suggestActions() for HATEOAS-style affordances',
21
+ ' */',
22
+ "import { definePresenter, ui } from '@vinkius-core/mcp-fusion';",
23
+ "import { z } from 'zod';",
24
+ '',
25
+ 'export const SystemPresenter = definePresenter({',
26
+ " name: 'SystemHealth',",
27
+ ' schema: z.object({',
28
+ " status: z.string().describe('Server operational status'),",
29
+ " uptime: z.number().describe('Uptime in seconds since process start'),",
30
+ " version: z.string().describe('Server version string'),",
31
+ " timestamp: z.string().describe('ISO 8601 timestamp of this check'),",
32
+ ' }),',
33
+ ' // autoRules: true (default) — .describe() annotations become system rules',
34
+ ' ui: (data) => [',
35
+ ' ui.markdown(',
36
+ ' `\uD83D\uDFE2 **${data.status}** | \u23F1 ${Math.floor(data.uptime)}s | v${data.version}`',
37
+ ' ),',
38
+ ' ],',
39
+ " suggestActions: (data) => data.status !== 'healthy'",
40
+ " ? [{ tool: 'system.health', reason: 'Re-check after issue resolution' }]",
41
+ ' : [],',
42
+ '});',
43
+ '',
44
+ ].join('\n');
45
+ }
46
+ //# sourceMappingURL=presenter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presenter.js","sourceRoot":"","sources":["../../../src/cli/templates/presenter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,mDAAmD;AACnD,MAAM,UAAU,iBAAiB;IAC7B,OAAO;QACH,KAAK;QACL,wDAAwD;QACxD,IAAI;QACJ,wDAAwD;QACxD,0DAA0D;QAC1D,sDAAsD;QACtD,kCAAkC;QAClC,IAAI;QACJ,2BAA2B;QAC3B,wCAAwC;QACxC,4EAA4E;QAC5E,8CAA8C;QAC9C,qDAAqD;QACrD,KAAK;QACL,iEAAiE;QACjE,0BAA0B;QAC1B,EAAE;QACF,kDAAkD;QAClD,2BAA2B;QAC3B,wBAAwB;QACxB,mEAAmE;QACnE,+EAA+E;QAC/E,gEAAgE;QAChE,6EAA6E;QAC7E,SAAS;QACT,gFAAgF;QAChF,qBAAqB;QACrB,sBAAsB;QACtB,uGAAuG;QACvG,YAAY;QACZ,QAAQ;QACR,yDAAyD;QACzD,kFAAkF;QAClF,eAAe;QACf,KAAK;QACL,EAAE;KACL,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Prompt Template — MCP Prompt Engine example
3
+ * @module
4
+ */
5
+ /** Generate `src/prompts/greet.ts` — Prompt Engine example */
6
+ export declare function greetPromptTs(): string;
7
+ //# sourceMappingURL=prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/cli/templates/prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,8DAA8D;AAC9D,wBAAgB,aAAa,IAAI,MAAM,CAmCtC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Prompt Template — MCP Prompt Engine example
3
+ * @module
4
+ */
5
+ /** Generate `src/prompts/greet.ts` — Prompt Engine example */
6
+ export function greetPromptTs() {
7
+ return [
8
+ '/**',
9
+ ' * Greet Prompt — Prompt Engine Example',
10
+ ' *',
11
+ ' * Demonstrates:',
12
+ ' * - f.prompt() with automatic context typing',
13
+ ' * - JSON descriptors for args (no Zod needed)',
14
+ ' * - PromptMessage.system() + PromptMessage.user()',
15
+ ' * - MCP prompts/list + prompts/get',
16
+ ' */',
17
+ "import { f } from '../fusion.js';",
18
+ "import { PromptMessage } from '@vinkius-core/mcp-fusion';",
19
+ '',
20
+ "export const GreetPrompt = f.prompt('greet', {",
21
+ " description: 'Generate a personalized greeting for a user',",
22
+ ' args: {',
23
+ " name: { type: 'string', description: 'Name of the person to greet' },",
24
+ ' style: {',
25
+ " enum: ['formal', 'casual', 'pirate'] as const,",
26
+ " description: 'Greeting style',",
27
+ ' },',
28
+ ' } as const,',
29
+ ' handler: async (_ctx, { name, style }) => ({',
30
+ ' messages: [',
31
+ ' PromptMessage.system(',
32
+ ' `You are a friendly assistant. Greet the user in a ${style} style. ` +',
33
+ ' `Be creative and enthusiastic.`',
34
+ ' ),',
35
+ ' PromptMessage.user(`Please greet ${name}.`),',
36
+ ' ],',
37
+ ' }),',
38
+ '});',
39
+ '',
40
+ ].join('\n');
41
+ }
42
+ //# sourceMappingURL=prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../src/cli/templates/prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,8DAA8D;AAC9D,MAAM,UAAU,aAAa;IACzB,OAAO;QACH,KAAK;QACL,yCAAyC;QACzC,IAAI;QACJ,kBAAkB;QAClB,+CAA+C;QAC/C,gDAAgD;QAChD,oDAAoD;QACpD,qCAAqC;QACrC,KAAK;QACL,mCAAmC;QACnC,2DAA2D;QAC3D,EAAE;QACF,gDAAgD;QAChD,iEAAiE;QACjE,aAAa;QACb,+EAA+E;QAC/E,kBAAkB;QAClB,4DAA4D;QAC5D,4CAA4C;QAC5C,YAAY;QACZ,iBAAiB;QACjB,kDAAkD;QAClD,qBAAqB;QACrB,mCAAmC;QACnC,wFAAwF;QACxF,iDAAiD;QACjD,gBAAgB;QAChB,0DAA0D;QAC1D,YAAY;QACZ,SAAS;QACT,KAAK;QACL,EAAE;KACL,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * README Template — Quick-start guide with client config snippets
3
+ * @module
4
+ */
5
+ import type { ProjectConfig } from '../types.js';
6
+ /** Generate `README.md` with Claude/Cursor config snippets */
7
+ export declare function readme(config: ProjectConfig): string;
8
+ //# sourceMappingURL=readme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readme.d.ts","sourceRoot":"","sources":["../../../src/cli/templates/readme.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,8DAA8D;AAC9D,wBAAgB,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAiGpD"}