@juspay/neurolink 1.6.0 → 1.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 (176) hide show
  1. package/CHANGELOG.md +193 -7
  2. package/README.md +100 -17
  3. package/dist/agent/direct-tools.d.ts +1203 -0
  4. package/dist/agent/direct-tools.js +387 -0
  5. package/dist/cli/commands/agent-generate.d.ts +2 -0
  6. package/dist/cli/commands/agent-generate.js +70 -0
  7. package/dist/cli/commands/config.d.ts +6 -6
  8. package/dist/cli/commands/config.js +326 -273
  9. package/dist/cli/commands/mcp.d.ts +2 -1
  10. package/dist/cli/commands/mcp.js +874 -146
  11. package/dist/cli/commands/ollama.d.ts +1 -1
  12. package/dist/cli/commands/ollama.js +153 -143
  13. package/dist/cli/index.js +589 -323
  14. package/dist/cli/utils/complete-setup.d.ts +19 -0
  15. package/dist/cli/utils/complete-setup.js +81 -0
  16. package/dist/cli/utils/env-manager.d.ts +44 -0
  17. package/dist/cli/utils/env-manager.js +226 -0
  18. package/dist/cli/utils/interactive-setup.d.ts +48 -0
  19. package/dist/cli/utils/interactive-setup.js +302 -0
  20. package/dist/core/dynamic-models.d.ts +208 -0
  21. package/dist/core/dynamic-models.js +250 -0
  22. package/dist/core/factory.d.ts +13 -6
  23. package/dist/core/factory.js +176 -61
  24. package/dist/core/types.d.ts +4 -2
  25. package/dist/core/types.js +4 -4
  26. package/dist/index.d.ts +16 -16
  27. package/dist/index.js +16 -16
  28. package/dist/lib/agent/direct-tools.d.ts +1203 -0
  29. package/dist/lib/agent/direct-tools.js +387 -0
  30. package/dist/lib/core/dynamic-models.d.ts +208 -0
  31. package/dist/lib/core/dynamic-models.js +250 -0
  32. package/dist/lib/core/factory.d.ts +13 -6
  33. package/dist/lib/core/factory.js +176 -61
  34. package/dist/lib/core/types.d.ts +4 -2
  35. package/dist/lib/core/types.js +4 -4
  36. package/dist/lib/index.d.ts +16 -16
  37. package/dist/lib/index.js +16 -16
  38. package/dist/lib/mcp/auto-discovery.d.ts +120 -0
  39. package/dist/lib/mcp/auto-discovery.js +793 -0
  40. package/dist/lib/mcp/client.d.ts +66 -0
  41. package/dist/lib/mcp/client.js +245 -0
  42. package/dist/lib/mcp/config.d.ts +31 -0
  43. package/dist/lib/mcp/config.js +74 -0
  44. package/dist/lib/mcp/context-manager.d.ts +4 -4
  45. package/dist/lib/mcp/context-manager.js +24 -18
  46. package/dist/lib/mcp/factory.d.ts +28 -11
  47. package/dist/lib/mcp/factory.js +36 -29
  48. package/dist/lib/mcp/function-calling.d.ts +51 -0
  49. package/dist/lib/mcp/function-calling.js +510 -0
  50. package/dist/lib/mcp/index.d.ts +190 -0
  51. package/dist/lib/mcp/index.js +156 -0
  52. package/dist/lib/mcp/initialize-tools.d.ts +28 -0
  53. package/dist/lib/mcp/initialize-tools.js +209 -0
  54. package/dist/lib/mcp/initialize.d.ts +17 -0
  55. package/dist/lib/mcp/initialize.js +51 -0
  56. package/dist/lib/mcp/logging.d.ts +71 -0
  57. package/dist/lib/mcp/logging.js +183 -0
  58. package/dist/lib/mcp/manager.d.ts +67 -0
  59. package/dist/lib/mcp/manager.js +176 -0
  60. package/dist/lib/mcp/neurolink-mcp-client.d.ts +96 -0
  61. package/dist/lib/mcp/neurolink-mcp-client.js +417 -0
  62. package/dist/lib/mcp/orchestrator.d.ts +3 -3
  63. package/dist/lib/mcp/orchestrator.js +46 -43
  64. package/dist/lib/mcp/registry.d.ts +2 -2
  65. package/dist/lib/mcp/registry.js +42 -33
  66. package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.d.ts +1 -1
  67. package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.js +204 -65
  68. package/dist/lib/mcp/servers/ai-providers/ai-core-server.js +142 -102
  69. package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.d.ts +6 -6
  70. package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.js +197 -142
  71. package/dist/lib/mcp/servers/utilities/utility-server.d.ts +8 -0
  72. package/dist/lib/mcp/servers/utilities/utility-server.js +326 -0
  73. package/dist/lib/mcp/tool-integration.d.ts +67 -0
  74. package/dist/lib/mcp/tool-integration.js +179 -0
  75. package/dist/lib/mcp/unified-registry.d.ts +269 -0
  76. package/dist/lib/mcp/unified-registry.js +1411 -0
  77. package/dist/lib/neurolink.d.ts +68 -6
  78. package/dist/lib/neurolink.js +304 -42
  79. package/dist/lib/providers/agent-enhanced-provider.d.ts +59 -0
  80. package/dist/lib/providers/agent-enhanced-provider.js +242 -0
  81. package/dist/lib/providers/amazonBedrock.d.ts +3 -3
  82. package/dist/lib/providers/amazonBedrock.js +54 -50
  83. package/dist/lib/providers/anthropic.d.ts +2 -2
  84. package/dist/lib/providers/anthropic.js +92 -84
  85. package/dist/lib/providers/azureOpenAI.d.ts +2 -2
  86. package/dist/lib/providers/azureOpenAI.js +97 -86
  87. package/dist/lib/providers/function-calling-provider.d.ts +70 -0
  88. package/dist/lib/providers/function-calling-provider.js +359 -0
  89. package/dist/lib/providers/googleAIStudio.d.ts +10 -5
  90. package/dist/lib/providers/googleAIStudio.js +60 -38
  91. package/dist/lib/providers/googleVertexAI.d.ts +3 -3
  92. package/dist/lib/providers/googleVertexAI.js +96 -86
  93. package/dist/lib/providers/huggingFace.d.ts +3 -3
  94. package/dist/lib/providers/huggingFace.js +70 -63
  95. package/dist/lib/providers/index.d.ts +11 -11
  96. package/dist/lib/providers/index.js +18 -18
  97. package/dist/lib/providers/mcp-provider.d.ts +62 -0
  98. package/dist/lib/providers/mcp-provider.js +183 -0
  99. package/dist/lib/providers/mistralAI.d.ts +3 -3
  100. package/dist/lib/providers/mistralAI.js +42 -36
  101. package/dist/lib/providers/ollama.d.ts +4 -4
  102. package/dist/lib/providers/ollama.js +113 -98
  103. package/dist/lib/providers/openAI.d.ts +7 -3
  104. package/dist/lib/providers/openAI.js +45 -33
  105. package/dist/lib/utils/logger.js +2 -2
  106. package/dist/lib/utils/providerUtils.js +53 -31
  107. package/dist/mcp/auto-discovery.d.ts +120 -0
  108. package/dist/mcp/auto-discovery.js +794 -0
  109. package/dist/mcp/client.d.ts +66 -0
  110. package/dist/mcp/client.js +245 -0
  111. package/dist/mcp/config.d.ts +31 -0
  112. package/dist/mcp/config.js +74 -0
  113. package/dist/mcp/context-manager.d.ts +4 -4
  114. package/dist/mcp/context-manager.js +24 -18
  115. package/dist/mcp/factory.d.ts +28 -11
  116. package/dist/mcp/factory.js +36 -29
  117. package/dist/mcp/function-calling.d.ts +51 -0
  118. package/dist/mcp/function-calling.js +510 -0
  119. package/dist/mcp/index.d.ts +190 -0
  120. package/dist/mcp/index.js +156 -0
  121. package/dist/mcp/initialize-tools.d.ts +28 -0
  122. package/dist/mcp/initialize-tools.js +210 -0
  123. package/dist/mcp/initialize.d.ts +17 -0
  124. package/dist/mcp/initialize.js +51 -0
  125. package/dist/mcp/logging.d.ts +71 -0
  126. package/dist/mcp/logging.js +183 -0
  127. package/dist/mcp/manager.d.ts +67 -0
  128. package/dist/mcp/manager.js +176 -0
  129. package/dist/mcp/neurolink-mcp-client.d.ts +96 -0
  130. package/dist/mcp/neurolink-mcp-client.js +417 -0
  131. package/dist/mcp/orchestrator.d.ts +3 -3
  132. package/dist/mcp/orchestrator.js +46 -43
  133. package/dist/mcp/registry.d.ts +2 -2
  134. package/dist/mcp/registry.js +42 -33
  135. package/dist/mcp/servers/ai-providers/ai-analysis-tools.d.ts +1 -1
  136. package/dist/mcp/servers/ai-providers/ai-analysis-tools.js +204 -65
  137. package/dist/mcp/servers/ai-providers/ai-core-server.js +142 -102
  138. package/dist/mcp/servers/ai-providers/ai-workflow-tools.d.ts +6 -6
  139. package/dist/mcp/servers/ai-providers/ai-workflow-tools.js +197 -142
  140. package/dist/mcp/servers/utilities/utility-server.d.ts +8 -0
  141. package/dist/mcp/servers/utilities/utility-server.js +326 -0
  142. package/dist/mcp/tool-integration.d.ts +67 -0
  143. package/dist/mcp/tool-integration.js +179 -0
  144. package/dist/mcp/unified-registry.d.ts +269 -0
  145. package/dist/mcp/unified-registry.js +1411 -0
  146. package/dist/neurolink.d.ts +68 -6
  147. package/dist/neurolink.js +304 -42
  148. package/dist/providers/agent-enhanced-provider.d.ts +59 -0
  149. package/dist/providers/agent-enhanced-provider.js +242 -0
  150. package/dist/providers/amazonBedrock.d.ts +3 -3
  151. package/dist/providers/amazonBedrock.js +54 -50
  152. package/dist/providers/anthropic.d.ts +2 -2
  153. package/dist/providers/anthropic.js +92 -84
  154. package/dist/providers/azureOpenAI.d.ts +2 -2
  155. package/dist/providers/azureOpenAI.js +97 -86
  156. package/dist/providers/function-calling-provider.d.ts +70 -0
  157. package/dist/providers/function-calling-provider.js +359 -0
  158. package/dist/providers/googleAIStudio.d.ts +10 -5
  159. package/dist/providers/googleAIStudio.js +60 -38
  160. package/dist/providers/googleVertexAI.d.ts +3 -3
  161. package/dist/providers/googleVertexAI.js +96 -86
  162. package/dist/providers/huggingFace.d.ts +3 -3
  163. package/dist/providers/huggingFace.js +70 -63
  164. package/dist/providers/index.d.ts +11 -11
  165. package/dist/providers/index.js +18 -18
  166. package/dist/providers/mcp-provider.d.ts +62 -0
  167. package/dist/providers/mcp-provider.js +183 -0
  168. package/dist/providers/mistralAI.d.ts +3 -3
  169. package/dist/providers/mistralAI.js +42 -36
  170. package/dist/providers/ollama.d.ts +4 -4
  171. package/dist/providers/ollama.js +113 -98
  172. package/dist/providers/openAI.d.ts +7 -3
  173. package/dist/providers/openAI.js +45 -33
  174. package/dist/utils/logger.js +2 -2
  175. package/dist/utils/providerUtils.js +53 -31
  176. package/package.json +175 -161
@@ -2,72 +2,115 @@
2
2
  * AI Development Workflow Tools
3
3
  * Phase 1.2 Implementation - 4 specialized tools for AI development lifecycle
4
4
  */
5
- import { z } from 'zod';
6
- import { AIProviderFactory } from '../../../core/factory.js';
7
- import { getBestProvider } from '../../../utils/providerUtils.js';
5
+ import { z } from "zod";
6
+ import { AIProviderFactory } from "../../../core/factory.js";
7
+ import { getBestProvider } from "../../../utils/providerUtils.js";
8
8
  // Tool-specific schemas with comprehensive validation
9
9
  const generateTestCasesSchema = z.object({
10
- codeFunction: z.string().min(1).describe('The function or code to generate test cases for'),
11
- testTypes: z.array(z.enum(['unit', 'integration', 'edge-cases', 'performance', 'security']))
10
+ codeFunction: z
11
+ .string()
12
12
  .min(1)
13
- .default(['unit', 'edge-cases'])
14
- .describe('Types of test cases to generate'),
15
- framework: z.enum(['jest', 'mocha', 'vitest', 'pytest', 'unittest', 'rspec'])
16
- .default('jest')
17
- .describe('Testing framework to target'),
18
- coverageTarget: z.number().min(0).max(100).default(80).describe('Target test coverage percentage'),
19
- includeAsyncTests: z.boolean().default(true).describe('Whether to include async test cases')
13
+ .describe("The function or code to generate test cases for"),
14
+ testTypes: z
15
+ .array(z.enum(["unit", "integration", "edge-cases", "performance", "security"]))
16
+ .min(1)
17
+ .default(["unit", "edge-cases"])
18
+ .describe("Types of test cases to generate"),
19
+ framework: z
20
+ .enum(["jest", "mocha", "vitest", "pytest", "unittest", "rspec"])
21
+ .default("jest")
22
+ .describe("Testing framework to target"),
23
+ coverageTarget: z
24
+ .number()
25
+ .min(0)
26
+ .max(100)
27
+ .default(80)
28
+ .describe("Target test coverage percentage"),
29
+ includeAsyncTests: z
30
+ .boolean()
31
+ .default(true)
32
+ .describe("Whether to include async test cases"),
20
33
  });
21
34
  const refactorCodeSchema = z.object({
22
- code: z.string().min(1).describe('The code to refactor'),
23
- language: z.string().default('javascript').describe('Programming language of the code'),
24
- objectives: z.array(z.enum([
25
- 'readability',
26
- 'performance',
27
- 'maintainability',
28
- 'testability',
29
- 'modularity',
30
- 'dry-principle',
31
- 'solid-principles'
32
- ])).default(['readability', 'maintainability']).describe('Refactoring objectives'),
33
- preserveFunctionality: z.boolean().default(true).describe('Ensure functionality remains identical'),
34
- styleGuide: z.string().optional().describe('Optional style guide to follow (e.g., airbnb, google)')
35
+ code: z.string().min(1).describe("The code to refactor"),
36
+ language: z
37
+ .string()
38
+ .default("javascript")
39
+ .describe("Programming language of the code"),
40
+ objectives: z
41
+ .array(z.enum([
42
+ "readability",
43
+ "performance",
44
+ "maintainability",
45
+ "testability",
46
+ "modularity",
47
+ "dry-principle",
48
+ "solid-principles",
49
+ ]))
50
+ .default(["readability", "maintainability"])
51
+ .describe("Refactoring objectives"),
52
+ preserveFunctionality: z
53
+ .boolean()
54
+ .default(true)
55
+ .describe("Ensure functionality remains identical"),
56
+ styleGuide: z
57
+ .string()
58
+ .optional()
59
+ .describe("Optional style guide to follow (e.g., airbnb, google)"),
35
60
  });
36
61
  const generateDocumentationSchema = z.object({
37
- code: z.string().min(1).describe('The code to document'),
38
- language: z.string().default('javascript').describe('Programming language of the code'),
39
- documentationType: z.enum(['jsdoc', 'markdown', 'sphinx', 'doxygen', 'readme'])
40
- .default('jsdoc')
41
- .describe('Type of documentation to generate'),
42
- includeExamples: z.boolean().default(true).describe('Whether to include usage examples'),
43
- detailLevel: z.enum(['minimal', 'standard', 'comprehensive']).default('standard')
44
- .describe('Level of documentation detail')
62
+ code: z.string().min(1).describe("The code to document"),
63
+ language: z
64
+ .string()
65
+ .default("javascript")
66
+ .describe("Programming language of the code"),
67
+ documentationType: z
68
+ .enum(["jsdoc", "markdown", "sphinx", "doxygen", "readme"])
69
+ .default("jsdoc")
70
+ .describe("Type of documentation to generate"),
71
+ includeExamples: z
72
+ .boolean()
73
+ .default(true)
74
+ .describe("Whether to include usage examples"),
75
+ detailLevel: z
76
+ .enum(["minimal", "standard", "comprehensive"])
77
+ .default("standard")
78
+ .describe("Level of documentation detail"),
45
79
  });
46
80
  const debugAIOutputSchema = z.object({
47
- aiOutput: z.string().min(1).describe('The AI-generated output to debug'),
48
- expectedBehavior: z.string().describe('Description of expected behavior or output'),
49
- context: z.string().optional().describe('Additional context about the AI generation'),
50
- outputType: z.enum(['code', 'text', 'structured-data', 'conversation'])
51
- .default('text')
52
- .describe('Type of AI output being debugged'),
53
- includeFixSuggestions: z.boolean().default(true).describe('Whether to include fix suggestions')
81
+ aiOutput: z.string().min(1).describe("The AI-generated output to debug"),
82
+ expectedBehavior: z
83
+ .string()
84
+ .describe("Description of expected behavior or output"),
85
+ context: z
86
+ .string()
87
+ .optional()
88
+ .describe("Additional context about the AI generation"),
89
+ outputType: z
90
+ .enum(["code", "text", "structured-data", "conversation"])
91
+ .default("text")
92
+ .describe("Type of AI output being debugged"),
93
+ includeFixSuggestions: z
94
+ .boolean()
95
+ .default(true)
96
+ .describe("Whether to include fix suggestions"),
54
97
  });
55
98
  /**
56
99
  * Generate test cases for code functions
57
100
  */
58
101
  export const generateTestCasesTool = {
59
- name: 'generate-test-cases',
60
- description: 'Generate comprehensive test cases for code functions with various test types and frameworks',
61
- category: 'ai-workflow',
102
+ name: "generate-test-cases",
103
+ description: "Generate comprehensive test cases for code functions with various test types and frameworks",
104
+ category: "ai-workflow",
62
105
  inputSchema: generateTestCasesSchema,
63
106
  isImplemented: true,
64
- permissions: ['write'],
65
- version: '2.0.0', // Updated version with real AI
107
+ permissions: ["write"],
108
+ version: "2.0.0", // Updated version with real AI
66
109
  execute: async (params, context) => {
67
110
  const startTime = Date.now();
68
111
  try {
69
112
  const validatedParams = generateTestCasesSchema.parse(params);
70
- const { codeFunction, testTypes, framework, coverageTarget, includeAsyncTests } = validatedParams;
113
+ const { codeFunction, testTypes, framework, coverageTarget, includeAsyncTests, } = validatedParams;
71
114
  // Get AI provider for real test case generation
72
115
  const providerName = await getBestProvider();
73
116
  const provider = await AIProviderFactory.createProvider(providerName);
@@ -75,12 +118,12 @@ export const generateTestCasesTool = {
75
118
  throw new Error(`Failed to create AI provider: ${providerName}`);
76
119
  }
77
120
  // Create structured prompt for test case generation
78
- const prompt = `Generate ${testTypes.join(', ')} test cases for this ${framework} function:
121
+ const prompt = `Generate ${testTypes.join(", ")} test cases for this ${framework} function:
79
122
 
80
123
  ${codeFunction}
81
124
 
82
125
  Requirements:
83
- - Test types: ${testTypes.join(', ')}
126
+ - Test types: ${testTypes.join(", ")}
84
127
  - Framework: ${framework}
85
128
  - Coverage target: ${coverageTarget}%
86
129
  - Include async tests: ${includeAsyncTests}
@@ -103,10 +146,10 @@ Generate 3-5 comprehensive test cases covering the requested types.`;
103
146
  const result = await provider.generateText({
104
147
  prompt,
105
148
  maxTokens: 1200,
106
- temperature: 0.3 // Lower temperature for more consistent structured output
149
+ temperature: 0.3, // Lower temperature for more consistent structured output
107
150
  });
108
151
  if (!result || !result.text) {
109
- throw new Error('AI provider returned no result for test case generation.');
152
+ throw new Error("AI provider returned no result for test case generation.");
110
153
  }
111
154
  // Parse AI response
112
155
  const aiResponse = JSON.parse(result.text);
@@ -119,7 +162,7 @@ Generate 3-5 comprehensive test cases covering the requested types.`;
119
162
  totalTests: testCases.length,
120
163
  totalAssertions: testCases.reduce((sum, tc) => sum + (tc.assertions || 1), 0),
121
164
  generatedAt: new Date().toISOString(),
122
- aiProvider: providerName
165
+ aiProvider: providerName,
123
166
  };
124
167
  return {
125
168
  success: true,
@@ -128,15 +171,15 @@ Generate 3-5 comprehensive test cases covering the requested types.`;
128
171
  ...result.usage,
129
172
  executionTime,
130
173
  provider: providerName,
131
- model: 'test-case-generator'
174
+ model: "test-case-generator",
132
175
  },
133
176
  metadata: {
134
- toolName: 'generate-test-cases',
135
- serverId: 'neurolink-ai-core',
177
+ toolName: "generate-test-cases",
178
+ serverId: "neurolink-ai-core",
136
179
  sessionId: context.sessionId,
137
180
  timestamp: Date.now(),
138
- executionTime
139
- }
181
+ executionTime,
182
+ },
140
183
  };
141
184
  }
142
185
  catch (error) {
@@ -146,27 +189,27 @@ Generate 3-5 comprehensive test cases covering the requested types.`;
146
189
  success: false,
147
190
  error: errorMessage,
148
191
  metadata: {
149
- toolName: 'generate-test-cases',
150
- serverId: 'neurolink-ai-core',
192
+ toolName: "generate-test-cases",
193
+ serverId: "neurolink-ai-core",
151
194
  sessionId: context.sessionId,
152
195
  timestamp: Date.now(),
153
- executionTime
154
- }
196
+ executionTime,
197
+ },
155
198
  };
156
199
  }
157
- }
200
+ },
158
201
  };
159
202
  /**
160
203
  * Refactor code for improved quality
161
204
  */
162
205
  export const refactorCodeTool = {
163
- name: 'refactor-code',
164
- description: 'AI-powered code refactoring for improved readability, performance, and maintainability',
165
- category: 'ai-workflow',
206
+ name: "refactor-code",
207
+ description: "AI-powered code refactoring for improved readability, performance, and maintainability",
208
+ category: "ai-workflow",
166
209
  inputSchema: refactorCodeSchema,
167
210
  isImplemented: true,
168
- permissions: ['write'],
169
- version: '2.0.0', // Updated version with real AI
211
+ permissions: ["write"],
212
+ version: "2.0.0", // Updated version with real AI
170
213
  execute: async (params, context) => {
171
214
  const startTime = Date.now();
172
215
  try {
@@ -179,7 +222,7 @@ export const refactorCodeTool = {
179
222
  throw new Error(`Failed to create AI provider: ${providerName}`);
180
223
  }
181
224
  // Create structured prompt for code refactoring
182
- const prompt = `Refactor this ${language} code focusing on: ${objectives.join(', ')}
225
+ const prompt = `Refactor this ${language} code focusing on: ${objectives.join(", ")}
183
226
 
184
227
  Original code:
185
228
  \`\`\`${language}
@@ -188,8 +231,8 @@ ${code}
188
231
 
189
232
  Requirements:
190
233
  - Language: ${language}
191
- - Objectives: ${objectives.join(', ')}
192
- - Style guide: ${styleGuide || 'standard best practices'}
234
+ - Objectives: ${objectives.join(", ")}
235
+ - Style guide: ${styleGuide || "standard best practices"}
193
236
  - Preserve functionality: ${preserveFunctionality}
194
237
  - Provide clean, production-ready code
195
238
 
@@ -209,23 +252,23 @@ Focus on real, actionable improvements based on the specified objectives.`;
209
252
  const result = await provider.generateText({
210
253
  prompt,
211
254
  maxTokens: 1000,
212
- temperature: 0.2 // Very low temperature for consistent refactoring
255
+ temperature: 0.2, // Very low temperature for consistent refactoring
213
256
  });
214
257
  if (!result || !result.text) {
215
- throw new Error('AI provider returned no result for code refactoring.');
258
+ throw new Error("AI provider returned no result for code refactoring.");
216
259
  }
217
260
  // Parse AI response
218
261
  const aiResponse = JSON.parse(result.text);
219
262
  const executionTime = Date.now() - startTime;
220
263
  const responseData = {
221
264
  refactoredCode: aiResponse.refactoredCode || code,
222
- changes: aiResponse.changes || ['Code refactored successfully'],
223
- improvements: aiResponse.improvements || objectives.map(obj => `Improved ${obj}`),
265
+ changes: aiResponse.changes || ["Code refactored successfully"],
266
+ improvements: aiResponse.improvements || objectives.map((obj) => `Improved ${obj}`),
224
267
  metrics: {
225
268
  linesReduced: aiResponse.metrics?.linesReduced || 0,
226
269
  complexityReduction: aiResponse.metrics?.complexityReduction || 15,
227
- readabilityScore: aiResponse.metrics?.readabilityScore || 85
228
- }
270
+ readabilityScore: aiResponse.metrics?.readabilityScore || 85,
271
+ },
229
272
  };
230
273
  return {
231
274
  success: true,
@@ -235,21 +278,21 @@ Focus on real, actionable improvements based on the specified objectives.`;
235
278
  language,
236
279
  objectives,
237
280
  generatedAt: new Date().toISOString(),
238
- aiProvider: providerName
281
+ aiProvider: providerName,
239
282
  },
240
283
  usage: {
241
284
  ...result.usage,
242
285
  executionTime,
243
286
  provider: providerName,
244
- model: 'code-refactorer'
287
+ model: "code-refactorer",
245
288
  },
246
289
  metadata: {
247
- toolName: 'refactor-code',
248
- serverId: 'neurolink-ai-core',
290
+ toolName: "refactor-code",
291
+ serverId: "neurolink-ai-core",
249
292
  sessionId: context.sessionId,
250
293
  timestamp: Date.now(),
251
- executionTime
252
- }
294
+ executionTime,
295
+ },
253
296
  };
254
297
  }
255
298
  catch (error) {
@@ -259,32 +302,32 @@ Focus on real, actionable improvements based on the specified objectives.`;
259
302
  success: false,
260
303
  error: errorMessage,
261
304
  metadata: {
262
- toolName: 'refactor-code',
263
- serverId: 'neurolink-ai-core',
305
+ toolName: "refactor-code",
306
+ serverId: "neurolink-ai-core",
264
307
  sessionId: context.sessionId,
265
308
  timestamp: Date.now(),
266
- executionTime
267
- }
309
+ executionTime,
310
+ },
268
311
  };
269
312
  }
270
- }
313
+ },
271
314
  };
272
315
  /**
273
316
  * Generate documentation from code
274
317
  */
275
318
  export const generateDocumentationTool = {
276
- name: 'generate-documentation',
277
- description: 'Automatically generate comprehensive documentation from code',
278
- category: 'ai-workflow',
319
+ name: "generate-documentation",
320
+ description: "Automatically generate comprehensive documentation from code",
321
+ category: "ai-workflow",
279
322
  inputSchema: generateDocumentationSchema,
280
323
  isImplemented: true,
281
- permissions: ['read'],
282
- version: '2.0.0', // Updated version with real AI
324
+ permissions: ["read"],
325
+ version: "2.0.0", // Updated version with real AI
283
326
  execute: async (params, context) => {
284
327
  const startTime = Date.now();
285
328
  try {
286
329
  const validatedParams = generateDocumentationSchema.parse(params);
287
- const { code, language, documentationType, includeExamples, detailLevel } = validatedParams;
330
+ const { code, language, documentationType, includeExamples, detailLevel, } = validatedParams;
288
331
  // Get AI provider for real documentation generation
289
332
  const providerName = await getBestProvider();
290
333
  const provider = await AIProviderFactory.createProvider(providerName);
@@ -309,7 +352,7 @@ Return ONLY a valid JSON object with this exact structure:
309
352
  {
310
353
  "documentation": "formatted documentation string in ${documentationType} format",
311
354
  "sections": ["list of documentation sections included"],
312
- "examples": ${includeExamples ? '["code examples with usage"]' : '[]'},
355
+ "examples": ${includeExamples ? '["code examples with usage"]' : "[]"},
313
356
  "coverage": percentage_number_representing_documentation_completeness
314
357
  }
315
358
 
@@ -317,19 +360,24 @@ Focus on creating accurate, useful documentation that explains the code's purpos
317
360
  const result = await provider.generateText({
318
361
  prompt,
319
362
  maxTokens: 1200,
320
- temperature: 0.3 // Moderate temperature for creative but structured documentation
363
+ temperature: 0.3, // Moderate temperature for creative but structured documentation
321
364
  });
322
365
  if (!result || !result.text) {
323
- throw new Error('AI provider returned no result for documentation generation.');
366
+ throw new Error("AI provider returned no result for documentation generation.");
324
367
  }
325
368
  // Parse AI response
326
369
  const aiResponse = JSON.parse(result.text);
327
370
  const executionTime = Date.now() - startTime;
328
371
  const responseData = {
329
- documentation: aiResponse.documentation || 'Documentation generated successfully',
330
- sections: aiResponse.sections || ['Overview'],
372
+ documentation: aiResponse.documentation || "Documentation generated successfully",
373
+ sections: aiResponse.sections || ["Overview"],
331
374
  examples: aiResponse.examples || [],
332
- coverage: aiResponse.coverage || (detailLevel === 'comprehensive' ? 95 : detailLevel === 'standard' ? 80 : 60)
375
+ coverage: aiResponse.coverage ||
376
+ (detailLevel === "comprehensive"
377
+ ? 95
378
+ : detailLevel === "standard"
379
+ ? 80
380
+ : 60),
333
381
  };
334
382
  return {
335
383
  success: true,
@@ -341,21 +389,21 @@ Focus on creating accurate, useful documentation that explains the code's purpos
341
389
  detailLevel,
342
390
  includeExamples,
343
391
  generatedAt: new Date().toISOString(),
344
- aiProvider: providerName
392
+ aiProvider: providerName,
345
393
  },
346
394
  usage: {
347
395
  ...result.usage,
348
396
  executionTime,
349
397
  provider: providerName,
350
- model: 'documentation-generator'
398
+ model: "documentation-generator",
351
399
  },
352
400
  metadata: {
353
- toolName: 'generate-documentation',
354
- serverId: 'neurolink-ai-core',
401
+ toolName: "generate-documentation",
402
+ serverId: "neurolink-ai-core",
355
403
  sessionId: context.sessionId,
356
404
  timestamp: Date.now(),
357
- executionTime
358
- }
405
+ executionTime,
406
+ },
359
407
  };
360
408
  }
361
409
  catch (error) {
@@ -365,32 +413,32 @@ Focus on creating accurate, useful documentation that explains the code's purpos
365
413
  success: false,
366
414
  error: errorMessage,
367
415
  metadata: {
368
- toolName: 'generate-documentation',
369
- serverId: 'neurolink-ai-core',
416
+ toolName: "generate-documentation",
417
+ serverId: "neurolink-ai-core",
370
418
  sessionId: context.sessionId,
371
419
  timestamp: Date.now(),
372
- executionTime
373
- }
420
+ executionTime,
421
+ },
374
422
  };
375
423
  }
376
- }
424
+ },
377
425
  };
378
426
  /**
379
427
  * Debug AI-generated output
380
428
  */
381
429
  export const debugAIOutputTool = {
382
- name: 'debug-ai-output',
383
- description: 'Analyze and debug AI-generated output to identify issues and suggest improvements',
384
- category: 'ai-workflow',
430
+ name: "debug-ai-output",
431
+ description: "Analyze and debug AI-generated output to identify issues and suggest improvements",
432
+ category: "ai-workflow",
385
433
  inputSchema: debugAIOutputSchema,
386
434
  isImplemented: true,
387
- permissions: ['read', 'analytics'],
388
- version: '2.0.0', // Updated version with real AI
435
+ permissions: ["read", "analytics"],
436
+ version: "2.0.0", // Updated version with real AI
389
437
  execute: async (params, context) => {
390
438
  const startTime = Date.now();
391
439
  try {
392
440
  const validatedParams = debugAIOutputSchema.parse(params);
393
- const { aiOutput, expectedBehavior, context: debugContext, outputType, includeFixSuggestions } = validatedParams;
441
+ const { aiOutput, expectedBehavior, context: debugContext, outputType, includeFixSuggestions, } = validatedParams;
394
442
  // Get AI provider for real output analysis
395
443
  const providerName = await getBestProvider();
396
444
  const provider = await AIProviderFactory.createProvider(providerName);
@@ -408,7 +456,7 @@ ${aiOutput}
408
456
  Expected Behavior:
409
457
  ${expectedBehavior}
410
458
 
411
- Context: ${debugContext || 'None provided'}
459
+ Context: ${debugContext || "None provided"}
412
460
  Output Type: ${outputType}
413
461
  Include Fix Suggestions: ${includeFixSuggestions}
414
462
 
@@ -430,26 +478,31 @@ Return ONLY a valid JSON object with this exact structure:
430
478
  ],
431
479
  "suggestions": ["actionable improvement suggestion 1", "suggestion 2"],
432
480
  "possibleCauses": ["potential cause 1", "potential cause 2"],
433
- "fixedOutput": ${includeFixSuggestions ? '"corrected version if possible"' : 'null'}
481
+ "fixedOutput": ${includeFixSuggestions ? '"corrected version if possible"' : "null"}
434
482
  }
435
483
 
436
484
  Provide thorough, actionable analysis focused on improving AI output quality.`;
437
485
  const result = await provider.generateText({
438
486
  prompt,
439
487
  maxTokens: 1000,
440
- temperature: 0.4 // Moderate temperature for analytical thinking
488
+ temperature: 0.4, // Moderate temperature for analytical thinking
441
489
  });
442
490
  if (!result || !result.text) {
443
- throw new Error('AI provider returned no result for output debugging.');
491
+ throw new Error("AI provider returned no result for output debugging.");
444
492
  }
445
493
  // Parse AI response
446
494
  const aiResponse = JSON.parse(result.text);
447
495
  const executionTime = Date.now() - startTime;
448
496
  const responseData = {
449
497
  issues: aiResponse.issues || [],
450
- suggestions: aiResponse.suggestions || ['Consider refining the prompt for clearer instructions'],
451
- possibleCauses: aiResponse.possibleCauses || ['Prompt clarity', 'Model limitations'],
452
- fixedOutput: aiResponse.fixedOutput || undefined
498
+ suggestions: aiResponse.suggestions || [
499
+ "Consider refining the prompt for clearer instructions",
500
+ ],
501
+ possibleCauses: aiResponse.possibleCauses || [
502
+ "Prompt clarity",
503
+ "Model limitations",
504
+ ],
505
+ fixedOutput: aiResponse.fixedOutput || undefined,
453
506
  };
454
507
  return {
455
508
  success: true,
@@ -460,21 +513,21 @@ Provide thorough, actionable analysis focused on improving AI output quality.`;
460
513
  outputType,
461
514
  analysisContext: debugContext,
462
515
  generatedAt: new Date().toISOString(),
463
- aiProvider: providerName
516
+ aiProvider: providerName,
464
517
  },
465
518
  usage: {
466
519
  ...result.usage,
467
520
  executionTime,
468
521
  provider: providerName,
469
- model: 'ai-output-debugger'
522
+ model: "ai-output-debugger",
470
523
  },
471
524
  metadata: {
472
- toolName: 'debug-ai-output',
473
- serverId: 'neurolink-ai-core',
525
+ toolName: "debug-ai-output",
526
+ serverId: "neurolink-ai-core",
474
527
  sessionId: context.sessionId,
475
528
  timestamp: Date.now(),
476
- executionTime
477
- }
529
+ executionTime,
530
+ },
478
531
  };
479
532
  }
480
533
  catch (error) {
@@ -484,28 +537,30 @@ Provide thorough, actionable analysis focused on improving AI output quality.`;
484
537
  success: false,
485
538
  error: errorMessage,
486
539
  metadata: {
487
- toolName: 'debug-ai-output',
488
- serverId: 'neurolink-ai-core',
540
+ toolName: "debug-ai-output",
541
+ serverId: "neurolink-ai-core",
489
542
  sessionId: context.sessionId,
490
543
  timestamp: Date.now(),
491
- executionTime
492
- }
544
+ executionTime,
545
+ },
493
546
  };
494
547
  }
495
- }
548
+ },
496
549
  };
497
550
  // Helper functions
498
551
  function extractFunctionName(code) {
499
552
  const match = code.match(/function\s+(\w+)|const\s+(\w+)\s*=|(\w+)\s*\(/);
500
- return match ? (match[1] || match[2] || match[3] || 'processData') : 'processData';
553
+ return match
554
+ ? match[1] || match[2] || match[3] || "processData"
555
+ : "processData";
501
556
  }
502
557
  function simulateRefactoring(code, objectives, styleGuide) {
503
558
  // Simulate basic refactoring
504
559
  let refactored = code;
505
- if (objectives.includes('readability')) {
506
- refactored = refactored.replace(/([a-z])([A-Z])/g, '$1 $2');
560
+ if (objectives.includes("readability")) {
561
+ refactored = refactored.replace(/([a-z])([A-Z])/g, "$1 $2");
507
562
  }
508
- if (objectives.includes('dry-principle')) {
563
+ if (objectives.includes("dry-principle")) {
509
564
  refactored = `// Extracted common functionality\nconst CONSTANTS = { MAX_RETRIES: 3, TIMEOUT: 5000 };\n\n${refactored}`;
510
565
  }
511
566
  return refactored;
@@ -515,12 +570,12 @@ export const aiWorkflowTools = [
515
570
  generateTestCasesTool,
516
571
  refactorCodeTool,
517
572
  generateDocumentationTool,
518
- debugAIOutputTool
573
+ debugAIOutputTool,
519
574
  ];
520
575
  // Export schemas for external validation
521
576
  export const workflowToolSchemas = {
522
- 'generate-test-cases': generateTestCasesSchema,
523
- 'refactor-code': refactorCodeSchema,
524
- 'generate-documentation': generateDocumentationSchema,
525
- 'debug-ai-output': debugAIOutputSchema
577
+ "generate-test-cases": generateTestCasesSchema,
578
+ "refactor-code": refactorCodeSchema,
579
+ "generate-documentation": generateDocumentationSchema,
580
+ "debug-ai-output": debugAIOutputSchema,
526
581
  };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * NeuroLink Utility Server
3
+ * Provides general utility tools following Lighthouse patterns
4
+ */
5
+ /**
6
+ * Utility Server - General utility tools
7
+ */
8
+ export declare const utilityServer: import("../../factory.js").NeuroLinkMCPServer;