@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.
- package/CHANGELOG.md +193 -7
- package/README.md +100 -17
- package/dist/agent/direct-tools.d.ts +1203 -0
- package/dist/agent/direct-tools.js +387 -0
- package/dist/cli/commands/agent-generate.d.ts +2 -0
- package/dist/cli/commands/agent-generate.js +70 -0
- package/dist/cli/commands/config.d.ts +6 -6
- package/dist/cli/commands/config.js +326 -273
- package/dist/cli/commands/mcp.d.ts +2 -1
- package/dist/cli/commands/mcp.js +874 -146
- package/dist/cli/commands/ollama.d.ts +1 -1
- package/dist/cli/commands/ollama.js +153 -143
- package/dist/cli/index.js +589 -323
- package/dist/cli/utils/complete-setup.d.ts +19 -0
- package/dist/cli/utils/complete-setup.js +81 -0
- package/dist/cli/utils/env-manager.d.ts +44 -0
- package/dist/cli/utils/env-manager.js +226 -0
- package/dist/cli/utils/interactive-setup.d.ts +48 -0
- package/dist/cli/utils/interactive-setup.js +302 -0
- package/dist/core/dynamic-models.d.ts +208 -0
- package/dist/core/dynamic-models.js +250 -0
- package/dist/core/factory.d.ts +13 -6
- package/dist/core/factory.js +176 -61
- package/dist/core/types.d.ts +4 -2
- package/dist/core/types.js +4 -4
- package/dist/index.d.ts +16 -16
- package/dist/index.js +16 -16
- package/dist/lib/agent/direct-tools.d.ts +1203 -0
- package/dist/lib/agent/direct-tools.js +387 -0
- package/dist/lib/core/dynamic-models.d.ts +208 -0
- package/dist/lib/core/dynamic-models.js +250 -0
- package/dist/lib/core/factory.d.ts +13 -6
- package/dist/lib/core/factory.js +176 -61
- package/dist/lib/core/types.d.ts +4 -2
- package/dist/lib/core/types.js +4 -4
- package/dist/lib/index.d.ts +16 -16
- package/dist/lib/index.js +16 -16
- package/dist/lib/mcp/auto-discovery.d.ts +120 -0
- package/dist/lib/mcp/auto-discovery.js +793 -0
- package/dist/lib/mcp/client.d.ts +66 -0
- package/dist/lib/mcp/client.js +245 -0
- package/dist/lib/mcp/config.d.ts +31 -0
- package/dist/lib/mcp/config.js +74 -0
- package/dist/lib/mcp/context-manager.d.ts +4 -4
- package/dist/lib/mcp/context-manager.js +24 -18
- package/dist/lib/mcp/factory.d.ts +28 -11
- package/dist/lib/mcp/factory.js +36 -29
- package/dist/lib/mcp/function-calling.d.ts +51 -0
- package/dist/lib/mcp/function-calling.js +510 -0
- package/dist/lib/mcp/index.d.ts +190 -0
- package/dist/lib/mcp/index.js +156 -0
- package/dist/lib/mcp/initialize-tools.d.ts +28 -0
- package/dist/lib/mcp/initialize-tools.js +209 -0
- package/dist/lib/mcp/initialize.d.ts +17 -0
- package/dist/lib/mcp/initialize.js +51 -0
- package/dist/lib/mcp/logging.d.ts +71 -0
- package/dist/lib/mcp/logging.js +183 -0
- package/dist/lib/mcp/manager.d.ts +67 -0
- package/dist/lib/mcp/manager.js +176 -0
- package/dist/lib/mcp/neurolink-mcp-client.d.ts +96 -0
- package/dist/lib/mcp/neurolink-mcp-client.js +417 -0
- package/dist/lib/mcp/orchestrator.d.ts +3 -3
- package/dist/lib/mcp/orchestrator.js +46 -43
- package/dist/lib/mcp/registry.d.ts +2 -2
- package/dist/lib/mcp/registry.js +42 -33
- package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.d.ts +1 -1
- package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.js +204 -65
- package/dist/lib/mcp/servers/ai-providers/ai-core-server.js +142 -102
- package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.d.ts +6 -6
- package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.js +197 -142
- package/dist/lib/mcp/servers/utilities/utility-server.d.ts +8 -0
- package/dist/lib/mcp/servers/utilities/utility-server.js +326 -0
- package/dist/lib/mcp/tool-integration.d.ts +67 -0
- package/dist/lib/mcp/tool-integration.js +179 -0
- package/dist/lib/mcp/unified-registry.d.ts +269 -0
- package/dist/lib/mcp/unified-registry.js +1411 -0
- package/dist/lib/neurolink.d.ts +68 -6
- package/dist/lib/neurolink.js +304 -42
- package/dist/lib/providers/agent-enhanced-provider.d.ts +59 -0
- package/dist/lib/providers/agent-enhanced-provider.js +242 -0
- package/dist/lib/providers/amazonBedrock.d.ts +3 -3
- package/dist/lib/providers/amazonBedrock.js +54 -50
- package/dist/lib/providers/anthropic.d.ts +2 -2
- package/dist/lib/providers/anthropic.js +92 -84
- package/dist/lib/providers/azureOpenAI.d.ts +2 -2
- package/dist/lib/providers/azureOpenAI.js +97 -86
- package/dist/lib/providers/function-calling-provider.d.ts +70 -0
- package/dist/lib/providers/function-calling-provider.js +359 -0
- package/dist/lib/providers/googleAIStudio.d.ts +10 -5
- package/dist/lib/providers/googleAIStudio.js +60 -38
- package/dist/lib/providers/googleVertexAI.d.ts +3 -3
- package/dist/lib/providers/googleVertexAI.js +96 -86
- package/dist/lib/providers/huggingFace.d.ts +3 -3
- package/dist/lib/providers/huggingFace.js +70 -63
- package/dist/lib/providers/index.d.ts +11 -11
- package/dist/lib/providers/index.js +18 -18
- package/dist/lib/providers/mcp-provider.d.ts +62 -0
- package/dist/lib/providers/mcp-provider.js +183 -0
- package/dist/lib/providers/mistralAI.d.ts +3 -3
- package/dist/lib/providers/mistralAI.js +42 -36
- package/dist/lib/providers/ollama.d.ts +4 -4
- package/dist/lib/providers/ollama.js +113 -98
- package/dist/lib/providers/openAI.d.ts +7 -3
- package/dist/lib/providers/openAI.js +45 -33
- package/dist/lib/utils/logger.js +2 -2
- package/dist/lib/utils/providerUtils.js +53 -31
- package/dist/mcp/auto-discovery.d.ts +120 -0
- package/dist/mcp/auto-discovery.js +794 -0
- package/dist/mcp/client.d.ts +66 -0
- package/dist/mcp/client.js +245 -0
- package/dist/mcp/config.d.ts +31 -0
- package/dist/mcp/config.js +74 -0
- package/dist/mcp/context-manager.d.ts +4 -4
- package/dist/mcp/context-manager.js +24 -18
- package/dist/mcp/factory.d.ts +28 -11
- package/dist/mcp/factory.js +36 -29
- package/dist/mcp/function-calling.d.ts +51 -0
- package/dist/mcp/function-calling.js +510 -0
- package/dist/mcp/index.d.ts +190 -0
- package/dist/mcp/index.js +156 -0
- package/dist/mcp/initialize-tools.d.ts +28 -0
- package/dist/mcp/initialize-tools.js +210 -0
- package/dist/mcp/initialize.d.ts +17 -0
- package/dist/mcp/initialize.js +51 -0
- package/dist/mcp/logging.d.ts +71 -0
- package/dist/mcp/logging.js +183 -0
- package/dist/mcp/manager.d.ts +67 -0
- package/dist/mcp/manager.js +176 -0
- package/dist/mcp/neurolink-mcp-client.d.ts +96 -0
- package/dist/mcp/neurolink-mcp-client.js +417 -0
- package/dist/mcp/orchestrator.d.ts +3 -3
- package/dist/mcp/orchestrator.js +46 -43
- package/dist/mcp/registry.d.ts +2 -2
- package/dist/mcp/registry.js +42 -33
- package/dist/mcp/servers/ai-providers/ai-analysis-tools.d.ts +1 -1
- package/dist/mcp/servers/ai-providers/ai-analysis-tools.js +204 -65
- package/dist/mcp/servers/ai-providers/ai-core-server.js +142 -102
- package/dist/mcp/servers/ai-providers/ai-workflow-tools.d.ts +6 -6
- package/dist/mcp/servers/ai-providers/ai-workflow-tools.js +197 -142
- package/dist/mcp/servers/utilities/utility-server.d.ts +8 -0
- package/dist/mcp/servers/utilities/utility-server.js +326 -0
- package/dist/mcp/tool-integration.d.ts +67 -0
- package/dist/mcp/tool-integration.js +179 -0
- package/dist/mcp/unified-registry.d.ts +269 -0
- package/dist/mcp/unified-registry.js +1411 -0
- package/dist/neurolink.d.ts +68 -6
- package/dist/neurolink.js +304 -42
- package/dist/providers/agent-enhanced-provider.d.ts +59 -0
- package/dist/providers/agent-enhanced-provider.js +242 -0
- package/dist/providers/amazonBedrock.d.ts +3 -3
- package/dist/providers/amazonBedrock.js +54 -50
- package/dist/providers/anthropic.d.ts +2 -2
- package/dist/providers/anthropic.js +92 -84
- package/dist/providers/azureOpenAI.d.ts +2 -2
- package/dist/providers/azureOpenAI.js +97 -86
- package/dist/providers/function-calling-provider.d.ts +70 -0
- package/dist/providers/function-calling-provider.js +359 -0
- package/dist/providers/googleAIStudio.d.ts +10 -5
- package/dist/providers/googleAIStudio.js +60 -38
- package/dist/providers/googleVertexAI.d.ts +3 -3
- package/dist/providers/googleVertexAI.js +96 -86
- package/dist/providers/huggingFace.d.ts +3 -3
- package/dist/providers/huggingFace.js +70 -63
- package/dist/providers/index.d.ts +11 -11
- package/dist/providers/index.js +18 -18
- package/dist/providers/mcp-provider.d.ts +62 -0
- package/dist/providers/mcp-provider.js +183 -0
- package/dist/providers/mistralAI.d.ts +3 -3
- package/dist/providers/mistralAI.js +42 -36
- package/dist/providers/ollama.d.ts +4 -4
- package/dist/providers/ollama.js +113 -98
- package/dist/providers/openAI.d.ts +7 -3
- package/dist/providers/openAI.js +45 -33
- package/dist/utils/logger.js +2 -2
- package/dist/utils/providerUtils.js +53 -31
- 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
|
|
6
|
-
import { AIProviderFactory } from
|
|
7
|
-
import { getBestProvider } from
|
|
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
|
|
11
|
-
|
|
10
|
+
codeFunction: z
|
|
11
|
+
.string()
|
|
12
12
|
.min(1)
|
|
13
|
-
.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
.
|
|
17
|
-
.
|
|
18
|
-
|
|
19
|
-
|
|
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(
|
|
23
|
-
language: z
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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(
|
|
38
|
-
language: z
|
|
39
|
-
|
|
40
|
-
.default(
|
|
41
|
-
.describe(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
.
|
|
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(
|
|
48
|
-
expectedBehavior: z
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
.
|
|
53
|
-
|
|
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:
|
|
60
|
-
description:
|
|
61
|
-
category:
|
|
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: [
|
|
65
|
-
version:
|
|
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(
|
|
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(
|
|
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:
|
|
174
|
+
model: "test-case-generator",
|
|
132
175
|
},
|
|
133
176
|
metadata: {
|
|
134
|
-
toolName:
|
|
135
|
-
serverId:
|
|
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:
|
|
150
|
-
serverId:
|
|
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:
|
|
164
|
-
description:
|
|
165
|
-
category:
|
|
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: [
|
|
169
|
-
version:
|
|
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 ||
|
|
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(
|
|
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 || [
|
|
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:
|
|
287
|
+
model: "code-refactorer",
|
|
245
288
|
},
|
|
246
289
|
metadata: {
|
|
247
|
-
toolName:
|
|
248
|
-
serverId:
|
|
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:
|
|
263
|
-
serverId:
|
|
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:
|
|
277
|
-
description:
|
|
278
|
-
category:
|
|
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: [
|
|
282
|
-
version:
|
|
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(
|
|
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 ||
|
|
330
|
-
sections: aiResponse.sections || [
|
|
372
|
+
documentation: aiResponse.documentation || "Documentation generated successfully",
|
|
373
|
+
sections: aiResponse.sections || ["Overview"],
|
|
331
374
|
examples: aiResponse.examples || [],
|
|
332
|
-
coverage: aiResponse.coverage ||
|
|
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:
|
|
398
|
+
model: "documentation-generator",
|
|
351
399
|
},
|
|
352
400
|
metadata: {
|
|
353
|
-
toolName:
|
|
354
|
-
serverId:
|
|
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:
|
|
369
|
-
serverId:
|
|
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:
|
|
383
|
-
description:
|
|
384
|
-
category:
|
|
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: [
|
|
388
|
-
version:
|
|
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 ||
|
|
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"' :
|
|
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(
|
|
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 || [
|
|
451
|
-
|
|
452
|
-
|
|
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:
|
|
522
|
+
model: "ai-output-debugger",
|
|
470
523
|
},
|
|
471
524
|
metadata: {
|
|
472
|
-
toolName:
|
|
473
|
-
serverId:
|
|
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:
|
|
488
|
-
serverId:
|
|
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
|
|
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(
|
|
506
|
-
refactored = refactored.replace(/([a-z])([A-Z])/g,
|
|
560
|
+
if (objectives.includes("readability")) {
|
|
561
|
+
refactored = refactored.replace(/([a-z])([A-Z])/g, "$1 $2");
|
|
507
562
|
}
|
|
508
|
-
if (objectives.includes(
|
|
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
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
577
|
+
"generate-test-cases": generateTestCasesSchema,
|
|
578
|
+
"refactor-code": refactorCodeSchema,
|
|
579
|
+
"generate-documentation": generateDocumentationSchema,
|
|
580
|
+
"debug-ai-output": debugAIOutputSchema,
|
|
526
581
|
};
|