@vfarcic/dot-ai 0.115.0 → 0.117.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/README.md +21 -18
- package/dist/core/ai-provider-factory.d.ts +4 -2
- package/dist/core/ai-provider-factory.d.ts.map +1 -1
- package/dist/core/ai-provider-factory.js +17 -6
- package/dist/core/capability-operations.js +1 -1
- package/dist/core/generic-session-manager.d.ts +67 -0
- package/dist/core/generic-session-manager.d.ts.map +1 -0
- package/dist/core/generic-session-manager.js +192 -0
- package/dist/core/pattern-operations.js +1 -1
- package/dist/core/providers/noop-provider.d.ts +47 -0
- package/dist/core/providers/noop-provider.d.ts.map +1 -0
- package/dist/core/providers/noop-provider.js +63 -0
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/core/schema.js +13 -13
- package/dist/core/session-utils.d.ts +3 -6
- package/dist/core/session-utils.d.ts.map +1 -1
- package/dist/core/session-utils.js +5 -13
- package/dist/core/shared-prompt-loader.d.ts +15 -3
- package/dist/core/shared-prompt-loader.d.ts.map +1 -1
- package/dist/core/shared-prompt-loader.js +67 -14
- package/dist/core/unified-creation-session.d.ts +3 -10
- package/dist/core/unified-creation-session.d.ts.map +1 -1
- package/dist/core/unified-creation-session.js +34 -75
- package/dist/core/unified-creation-types.d.ts +31 -22
- package/dist/core/unified-creation-types.d.ts.map +1 -1
- package/dist/evaluation/eval-runner.js +12 -3
- package/dist/evaluation/evaluators/base-comparative.d.ts +2 -0
- package/dist/evaluation/evaluators/base-comparative.d.ts.map +1 -1
- package/dist/evaluation/evaluators/base-comparative.js +13 -1
- package/dist/evaluation/graph-generator.d.ts +56 -0
- package/dist/evaluation/graph-generator.d.ts.map +1 -0
- package/dist/evaluation/graph-generator.js +694 -0
- package/dist/evaluation/metadata-loader.d.ts +39 -0
- package/dist/evaluation/metadata-loader.d.ts.map +1 -0
- package/dist/evaluation/metadata-loader.js +74 -0
- package/dist/evaluation/platform-synthesizer.d.ts +5 -1
- package/dist/evaluation/platform-synthesizer.d.ts.map +1 -1
- package/dist/evaluation/platform-synthesizer.js +65 -23
- package/dist/evaluation/run-platform-synthesis.js +22 -5
- package/dist/interfaces/mcp.d.ts.map +1 -1
- package/dist/interfaces/mcp.js +9 -34
- package/dist/tools/answer-question.d.ts.map +1 -1
- package/dist/tools/answer-question.js +12 -12
- package/dist/tools/choose-solution.js +1 -1
- package/dist/tools/generate-manifests.d.ts.map +1 -1
- package/dist/tools/generate-manifests.js +9 -10
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +6 -6
- package/dist/tools/organizational-data.js +12 -12
- package/dist/tools/project-setup/discovery.d.ts +15 -0
- package/dist/tools/project-setup/discovery.d.ts.map +1 -0
- package/dist/tools/project-setup/discovery.js +104 -0
- package/dist/tools/project-setup/generate-scope.d.ts +15 -0
- package/dist/tools/project-setup/generate-scope.d.ts.map +1 -0
- package/dist/tools/project-setup/generate-scope.js +237 -0
- package/dist/tools/project-setup/report-scan.d.ts +15 -0
- package/dist/tools/project-setup/report-scan.d.ts.map +1 -0
- package/dist/tools/project-setup/report-scan.js +156 -0
- package/dist/tools/project-setup/types.d.ts +111 -0
- package/dist/tools/project-setup/types.d.ts.map +1 -0
- package/dist/tools/project-setup/types.js +8 -0
- package/dist/tools/project-setup.d.ts +28 -0
- package/dist/tools/project-setup.d.ts.map +1 -0
- package/dist/tools/project-setup.js +134 -0
- package/dist/tools/recommend.js +1 -1
- package/dist/tools/remediate.js +1 -1
- package/dist/tools/version.d.ts +0 -7
- package/dist/tools/version.d.ts.map +1 -1
- package/dist/tools/version.js +5 -34
- package/package.json +4 -2
- package/prompts/capability-inference.md +2 -2
- package/prompts/infrastructure-trigger-expansion.md +2 -2
- package/prompts/intent-analysis.md +2 -2
- package/prompts/kyverno-generation.md +14 -14
- package/prompts/manifest-generation.md +5 -5
- package/prompts/map-intent-to-operation.md +2 -2
- package/prompts/pattern-complete-error.md +1 -1
- package/prompts/pattern-complete-success.md +4 -4
- package/prompts/pattern-rationale.md +1 -1
- package/prompts/pattern-resources.md +1 -1
- package/prompts/pattern-review.md +5 -5
- package/prompts/policy-complete-apply.md +4 -4
- package/prompts/policy-complete-discard.md +1 -1
- package/prompts/policy-complete-error.md +1 -1
- package/prompts/policy-complete-save.md +4 -4
- package/prompts/policy-complete-success.md +4 -4
- package/prompts/policy-namespace-scope.md +1 -1
- package/prompts/question-generation.md +5 -5
- package/prompts/resource-analysis.md +3 -3
- package/prompts/resource-selection.md +3 -3
- package/prompts/solution-enhancement.md +4 -4
- package/scripts/anthropic.nu +9 -13
- package/scripts/common.nu +31 -33
- package/scripts/ingress.nu +5 -4
- package/scripts/kubernetes.nu +38 -53
- package/dist/core/doc-discovery.d.ts +0 -38
- package/dist/core/doc-discovery.d.ts.map +0 -1
- package/dist/core/doc-discovery.js +0 -231
- package/dist/core/doc-testing-session.d.ts +0 -109
- package/dist/core/doc-testing-session.d.ts.map +0 -1
- package/dist/core/doc-testing-session.js +0 -696
- package/dist/core/doc-testing-types.d.ts +0 -127
- package/dist/core/doc-testing-types.d.ts.map +0 -1
- package/dist/core/doc-testing-types.js +0 -53
- package/dist/core/nushell-runtime.d.ts +0 -39
- package/dist/core/nushell-runtime.d.ts.map +0 -1
- package/dist/core/nushell-runtime.js +0 -103
- package/dist/core/platform-operations.d.ts +0 -70
- package/dist/core/platform-operations.d.ts.map +0 -1
- package/dist/core/platform-operations.js +0 -294
- package/dist/tools/build-platform.d.ts +0 -25
- package/dist/tools/build-platform.d.ts.map +0 -1
- package/dist/tools/build-platform.js +0 -277
- package/dist/tools/test-docs.d.ts +0 -22
- package/dist/tools/test-docs.d.ts.map +0 -1
- package/dist/tools/test-docs.js +0 -351
- package/prompts/doc-testing-done.md +0 -51
- package/prompts/doc-testing-fix.md +0 -120
- package/prompts/doc-testing-scan.md +0 -140
- package/prompts/doc-testing-test-section.md +0 -169
- package/prompts/platform-operations-parse-script-help.md +0 -68
- package/scripts/ack.nu +0 -195
- package/scripts/argo-workflows.nu +0 -47
- package/scripts/argocd.nu +0 -85
- package/scripts/aso.nu +0 -74
- package/scripts/backstage.nu +0 -349
- package/scripts/cert-manager.nu +0 -13
- package/scripts/cnpg.nu +0 -14
- package/scripts/dot.nu +0 -32
- package/scripts/external-secrets.nu +0 -110
- package/scripts/gatekeeper.nu +0 -19
- package/scripts/github.nu +0 -42
- package/scripts/image.nu +0 -67
- package/scripts/kro.nu +0 -11
- package/scripts/kubevela.nu +0 -22
- package/scripts/port.nu +0 -71
- package/scripts/prometheus.nu +0 -21
- package/scripts/registry.nu +0 -55
- package/scripts/storage.nu +0 -210
- package/scripts/tests.nu +0 -12
- package/scripts/velero.nu +0 -45
- package/shared-prompts/validate-docs.md +0 -22
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Platform Operations Discovery
|
|
4
|
-
*
|
|
5
|
-
* Orchestrates tool-based discovery and mapping of Nu shell script operations.
|
|
6
|
-
* All data fetching logic lives in tools, this module handles orchestration.
|
|
7
|
-
*/
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
-
}) : function(o, v) {
|
|
22
|
-
o["default"] = v;
|
|
23
|
-
});
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.discoverOperations = discoverOperations;
|
|
43
|
-
exports.mapIntentToOperation = mapIntentToOperation;
|
|
44
|
-
exports.getOperationParameters = getOperationParameters;
|
|
45
|
-
exports.createSession = createSession;
|
|
46
|
-
exports.loadSession = loadSession;
|
|
47
|
-
exports.executeOperation = executeOperation;
|
|
48
|
-
const fs = __importStar(require("fs"));
|
|
49
|
-
const path = __importStar(require("path"));
|
|
50
|
-
const platform_utils_1 = require("./platform-utils");
|
|
51
|
-
/**
|
|
52
|
-
* Discover available operations from Nu shell scripts
|
|
53
|
-
* Uses tool for data fetching and prompt injection for AI parsing
|
|
54
|
-
*/
|
|
55
|
-
async function discoverOperations(aiProvider, logger) {
|
|
56
|
-
try {
|
|
57
|
-
// Import the tool execution function
|
|
58
|
-
const { executeDiscoverOperations } = await Promise.resolve().then(() => __importStar(require('../tools/platform/discover-operations.tool')));
|
|
59
|
-
// Execute tool directly to get help output
|
|
60
|
-
const toolResult = await executeDiscoverOperations({}, aiProvider, logger);
|
|
61
|
-
if (!toolResult.success || !toolResult.helpOutput) {
|
|
62
|
-
throw new Error(toolResult.error || 'Failed to get Nu script help output');
|
|
63
|
-
}
|
|
64
|
-
// Load the parsing prompt template
|
|
65
|
-
const promptPath = path.join(process.cwd(), 'prompts', 'platform-operations-parse-script-help.md');
|
|
66
|
-
const promptTemplate = fs.readFileSync(promptPath, 'utf8');
|
|
67
|
-
// Inject help output into prompt
|
|
68
|
-
const prompt = promptTemplate.replace('{helpOutput}', toolResult.helpOutput);
|
|
69
|
-
// Single AI call with injected data
|
|
70
|
-
const response = await aiProvider.sendMessage(prompt, 'platform-discover-operations');
|
|
71
|
-
// Parse operations from AI response
|
|
72
|
-
const operations = (0, platform_utils_1.extractJsonFromAIResponse)(response.content);
|
|
73
|
-
logger.info?.('Discovered operations from Nu scripts', {
|
|
74
|
-
count: operations.length
|
|
75
|
-
});
|
|
76
|
-
return operations;
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
logger.error?.('Failed to discover operations', error);
|
|
80
|
-
throw error;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Map user intent to a specific operation using AI
|
|
85
|
-
*/
|
|
86
|
-
async function mapIntentToOperation(intent, operations, aiProvider, logger) {
|
|
87
|
-
try {
|
|
88
|
-
// Load AI prompt template for intent mapping
|
|
89
|
-
const promptPath = path.join(process.cwd(), 'prompts', 'map-intent-to-operation.md');
|
|
90
|
-
const promptTemplate = fs.readFileSync(promptPath, 'utf8');
|
|
91
|
-
// Replace template variables
|
|
92
|
-
const prompt = promptTemplate
|
|
93
|
-
.replace('{intent}', intent)
|
|
94
|
-
.replace('{operations}', JSON.stringify(operations, null, 2));
|
|
95
|
-
// Send to AI provider for AI-powered intent matching
|
|
96
|
-
const response = await aiProvider.sendMessage(prompt, 'platform-map-intent');
|
|
97
|
-
// Extract JSON from AI response with robust parsing
|
|
98
|
-
const mapping = (0, platform_utils_1.extractJsonFromAIResponse)(response.content);
|
|
99
|
-
// Validate that AI returned required fields
|
|
100
|
-
if (mapping.matched && mapping.operation) {
|
|
101
|
-
if (!mapping.operation.command || !Array.isArray(mapping.operation.command)) {
|
|
102
|
-
throw new Error(`AI did not return valid command array. Response: ${JSON.stringify(mapping)}`);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
logger.info?.('Mapped user intent to operation', {
|
|
106
|
-
intent,
|
|
107
|
-
matched: mapping.matched,
|
|
108
|
-
operation: mapping.operation?.tool,
|
|
109
|
-
command: mapping.operation?.command
|
|
110
|
-
});
|
|
111
|
-
return mapping;
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
logger.error?.('Failed to map intent to operation', error);
|
|
115
|
-
throw error;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Get parameters for a specific operation using Nushell's structured JSON output
|
|
120
|
-
*/
|
|
121
|
-
async function getOperationParameters(command, logger) {
|
|
122
|
-
try {
|
|
123
|
-
// Build the full command name that Nushell expects
|
|
124
|
-
const commandName = `main ${command.join(' ')}`;
|
|
125
|
-
// Execute Nu script to get structured command metadata
|
|
126
|
-
const scriptPath = path.join((0, platform_utils_1.getScriptsDir)(), 'dot.nu');
|
|
127
|
-
const nuCommand = `source ${scriptPath}; scope commands | where name == "${commandName}" | to json`;
|
|
128
|
-
const { stdout, stderr } = await (0, platform_utils_1.execAsync)(`nu -c '${nuCommand}'`);
|
|
129
|
-
if (stderr) {
|
|
130
|
-
logger.warn?.('Nu scope commands produced stderr', { stderr });
|
|
131
|
-
}
|
|
132
|
-
// Parse JSON response
|
|
133
|
-
const commands = JSON.parse(stdout);
|
|
134
|
-
if (!commands || commands.length === 0) {
|
|
135
|
-
logger.warn?.('No command metadata found', { commandName });
|
|
136
|
-
return [];
|
|
137
|
-
}
|
|
138
|
-
const commandMetadata = commands[0];
|
|
139
|
-
const signatures = commandMetadata.signatures?.any || [];
|
|
140
|
-
// Filter and transform parameter data
|
|
141
|
-
const parameters = [];
|
|
142
|
-
for (const param of signatures) {
|
|
143
|
-
// Skip input/output parameters
|
|
144
|
-
if (param.parameter_type === 'input' || param.parameter_type === 'output') {
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
147
|
-
// Skip help parameter
|
|
148
|
-
if (param.parameter_name === 'help') {
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
// Map Nushell types to our types
|
|
152
|
-
let type = 'string';
|
|
153
|
-
if (param.syntax_shape === 'bool') {
|
|
154
|
-
type = 'boolean';
|
|
155
|
-
}
|
|
156
|
-
else if (param.syntax_shape === 'int') {
|
|
157
|
-
type = 'number';
|
|
158
|
-
}
|
|
159
|
-
else if (param.syntax_shape === 'string') {
|
|
160
|
-
type = 'string';
|
|
161
|
-
}
|
|
162
|
-
// Determine if required (positional parameters are typically required)
|
|
163
|
-
const required = param.parameter_type === 'positional' && !param.is_optional;
|
|
164
|
-
parameters.push({
|
|
165
|
-
name: param.parameter_name,
|
|
166
|
-
type,
|
|
167
|
-
required,
|
|
168
|
-
description: param.description || '',
|
|
169
|
-
default: param.parameter_default
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
logger.info?.('Retrieved operation parameters', {
|
|
173
|
-
command: commandName,
|
|
174
|
-
parameterCount: parameters.length
|
|
175
|
-
});
|
|
176
|
-
return parameters;
|
|
177
|
-
}
|
|
178
|
-
catch (error) {
|
|
179
|
-
logger.error?.('Failed to get operation parameters', error);
|
|
180
|
-
throw error;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Create and persist a platform session
|
|
185
|
-
*/
|
|
186
|
-
async function createSession(sessionId, intent, matchedOperation, parameters, logger) {
|
|
187
|
-
try {
|
|
188
|
-
const session = {
|
|
189
|
-
sessionId,
|
|
190
|
-
intent,
|
|
191
|
-
matchedOperation,
|
|
192
|
-
parameters,
|
|
193
|
-
answers: {},
|
|
194
|
-
currentStep: 'collectParameters',
|
|
195
|
-
createdAt: new Date().toISOString(),
|
|
196
|
-
updatedAt: new Date().toISOString()
|
|
197
|
-
};
|
|
198
|
-
// Ensure session directory exists
|
|
199
|
-
const sessionDir = path.join(process.cwd(), 'tmp', 'sessions', 'platform');
|
|
200
|
-
if (!fs.existsSync(sessionDir)) {
|
|
201
|
-
fs.mkdirSync(sessionDir, { recursive: true });
|
|
202
|
-
}
|
|
203
|
-
// Write session file
|
|
204
|
-
const sessionPath = path.join(sessionDir, `${sessionId}.json`);
|
|
205
|
-
fs.writeFileSync(sessionPath, JSON.stringify(session, null, 2), 'utf8');
|
|
206
|
-
logger.info?.('Created platform session', { sessionId, intent });
|
|
207
|
-
return session;
|
|
208
|
-
}
|
|
209
|
-
catch (error) {
|
|
210
|
-
logger.error?.('Failed to create platform session', error);
|
|
211
|
-
throw error;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Load a platform session from file
|
|
216
|
-
*/
|
|
217
|
-
function loadSession(sessionId, logger) {
|
|
218
|
-
try {
|
|
219
|
-
const sessionPath = path.join(process.cwd(), 'tmp', 'sessions', 'platform', `${sessionId}.json`);
|
|
220
|
-
if (!fs.existsSync(sessionPath)) {
|
|
221
|
-
logger.warn?.('Session file not found', { sessionId });
|
|
222
|
-
return null;
|
|
223
|
-
}
|
|
224
|
-
const sessionData = fs.readFileSync(sessionPath, 'utf8');
|
|
225
|
-
const session = JSON.parse(sessionData);
|
|
226
|
-
logger.info?.('Loaded platform session', { sessionId });
|
|
227
|
-
return session;
|
|
228
|
-
}
|
|
229
|
-
catch (error) {
|
|
230
|
-
logger.error?.('Failed to load platform session', error);
|
|
231
|
-
throw error;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Execute a platform operation with collected parameters
|
|
236
|
-
*/
|
|
237
|
-
async function executeOperation(session, answers, logger) {
|
|
238
|
-
try {
|
|
239
|
-
// Validate required parameters
|
|
240
|
-
const missingRequired = session.parameters
|
|
241
|
-
.filter(p => p.required && !(p.name in answers))
|
|
242
|
-
.map(p => p.name);
|
|
243
|
-
if (missingRequired.length > 0) {
|
|
244
|
-
return {
|
|
245
|
-
success: false,
|
|
246
|
-
error: `Missing required parameters: ${missingRequired.join(', ')}`,
|
|
247
|
-
missingParameters: missingRequired
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
// Merge answers with defaults for optional parameters
|
|
251
|
-
const finalAnswers = { ...answers };
|
|
252
|
-
for (const param of session.parameters) {
|
|
253
|
-
if (!(param.name in finalAnswers) && param.default !== undefined) {
|
|
254
|
-
finalAnswers[param.name] = param.default;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
// Build Nu script command
|
|
258
|
-
const scriptPath = path.join((0, platform_utils_1.getScriptsDir)(), 'dot.nu');
|
|
259
|
-
const command = session.matchedOperation.command;
|
|
260
|
-
// Build command arguments
|
|
261
|
-
const args = [];
|
|
262
|
-
for (const param of session.parameters) {
|
|
263
|
-
const value = finalAnswers[param.name];
|
|
264
|
-
if (value !== undefined) {
|
|
265
|
-
args.push(`--${param.name}`);
|
|
266
|
-
args.push(String(value));
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
const fullCommand = `nu ${scriptPath} ${command.join(' ')} ${args.join(' ')}`;
|
|
270
|
-
logger.info?.('Executing platform operation', {
|
|
271
|
-
sessionId: session.sessionId,
|
|
272
|
-
command: fullCommand
|
|
273
|
-
});
|
|
274
|
-
const { stdout, stderr } = await (0, platform_utils_1.execAsync)(fullCommand);
|
|
275
|
-
if (stderr) {
|
|
276
|
-
logger.warn?.('Operation produced stderr', { stderr });
|
|
277
|
-
}
|
|
278
|
-
logger.info?.('Platform operation completed', {
|
|
279
|
-
sessionId: session.sessionId,
|
|
280
|
-
stdout: stdout.substring(0, 500) // Log first 500 chars
|
|
281
|
-
});
|
|
282
|
-
return {
|
|
283
|
-
success: true,
|
|
284
|
-
message: `Successfully executed ${session.matchedOperation.tool} ${session.matchedOperation.operation}`
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
catch (error) {
|
|
288
|
-
logger.error?.('Failed to execute platform operation', error);
|
|
289
|
-
return {
|
|
290
|
-
success: false,
|
|
291
|
-
error: error instanceof Error ? error.message : String(error)
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build Platform Tool for MCP Server
|
|
3
|
-
*
|
|
4
|
-
* AI-powered tool that enables users to build and manage Kubernetes platforms
|
|
5
|
-
* through natural language intent. Handles script discovery, parameter collection,
|
|
6
|
-
* and execution transparently.
|
|
7
|
-
*
|
|
8
|
-
* Phase 1: Basic invocation and Nushell runtime validation
|
|
9
|
-
*/
|
|
10
|
-
import { z } from 'zod';
|
|
11
|
-
import { Logger } from '../core/error-handling';
|
|
12
|
-
import { DotAI } from '../core/index';
|
|
13
|
-
export declare const BUILD_PLATFORM_TOOL_NAME = "buildPlatform";
|
|
14
|
-
export declare const BUILD_PLATFORM_TOOL_DESCRIPTION = "AI-powered platform operations tool for building and managing Kubernetes platforms. Use this to: (1) LIST/DISCOVER what tools and operations are available - use stage=\"list\" when user asks \"what can I install\", \"show available tools\", \"list platform capabilities\", (2) INSTALL/CREATE platform components like Argo CD, Crossplane, cert-manager, Kubernetes clusters through natural language intent. Handles tool installation, cluster creation, and platform configuration conversationally.";
|
|
15
|
-
export declare const BUILD_PLATFORM_TOOL_INPUT_SCHEMA: {
|
|
16
|
-
stage: z.ZodOptional<z.ZodString>;
|
|
17
|
-
intent: z.ZodOptional<z.ZodString>;
|
|
18
|
-
sessionId: z.ZodOptional<z.ZodString>;
|
|
19
|
-
answers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Main tool handler - Phase 1 & 2: Script discovery and intent mapping
|
|
23
|
-
*/
|
|
24
|
-
export declare function handleBuildPlatformTool(args: any, dotAI: DotAI, logger: Logger, requestId: string): Promise<any>;
|
|
25
|
-
//# sourceMappingURL=build-platform.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-platform.d.ts","sourceRoot":"","sources":["../../src/tools/build-platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGhD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAItC,eAAO,MAAM,wBAAwB,kBAAkB,CAAC;AACxD,eAAO,MAAM,+BAA+B,mfAA2e,CAAC;AAuBxhB,eAAO,MAAM,gCAAgC;;;;;CAY5C,CAAC;AAEF;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,GAAG,EACT,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,GAAG,CAAC,CAgQd"}
|
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Build Platform Tool for MCP Server
|
|
4
|
-
*
|
|
5
|
-
* AI-powered tool that enables users to build and manage Kubernetes platforms
|
|
6
|
-
* through natural language intent. Handles script discovery, parameter collection,
|
|
7
|
-
* and execution transparently.
|
|
8
|
-
*
|
|
9
|
-
* Phase 1: Basic invocation and Nushell runtime validation
|
|
10
|
-
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.BUILD_PLATFORM_TOOL_INPUT_SCHEMA = exports.BUILD_PLATFORM_TOOL_DESCRIPTION = exports.BUILD_PLATFORM_TOOL_NAME = void 0;
|
|
13
|
-
exports.handleBuildPlatformTool = handleBuildPlatformTool;
|
|
14
|
-
const zod_1 = require("zod");
|
|
15
|
-
const nushell_runtime_1 = require("../core/nushell-runtime");
|
|
16
|
-
const platform_operations_1 = require("../core/platform-operations");
|
|
17
|
-
const crypto_1 = require("crypto");
|
|
18
|
-
// Tool metadata for MCP registration
|
|
19
|
-
exports.BUILD_PLATFORM_TOOL_NAME = 'buildPlatform';
|
|
20
|
-
exports.BUILD_PLATFORM_TOOL_DESCRIPTION = 'AI-powered platform operations tool for building and managing Kubernetes platforms. Use this to: (1) LIST/DISCOVER what tools and operations are available - use stage="list" when user asks "what can I install", "show available tools", "list platform capabilities", (2) INSTALL/CREATE platform components like Argo CD, Crossplane, cert-manager, Kubernetes clusters through natural language intent. Handles tool installation, cluster creation, and platform configuration conversationally.';
|
|
21
|
-
/**
|
|
22
|
-
* Create execution started response (terminal state - no further MCP calls needed)
|
|
23
|
-
*/
|
|
24
|
-
function createExecutionResponse(tool, operation) {
|
|
25
|
-
return {
|
|
26
|
-
content: [{
|
|
27
|
-
type: 'text',
|
|
28
|
-
text: JSON.stringify({
|
|
29
|
-
success: true,
|
|
30
|
-
execution: {
|
|
31
|
-
tool,
|
|
32
|
-
operation,
|
|
33
|
-
status: 'started',
|
|
34
|
-
message: `${tool} ${operation} execution started. Monitor progress using kubectl or other cluster tools. No further action required.`
|
|
35
|
-
}
|
|
36
|
-
}, null, 2)
|
|
37
|
-
}]
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
// Tool input schema
|
|
41
|
-
exports.BUILD_PLATFORM_TOOL_INPUT_SCHEMA = {
|
|
42
|
-
stage: zod_1.z.string().optional()
|
|
43
|
-
.describe('Workflow stage: "list" (discover all operations) or "submitAnswers" (submit answers and execute). Omit when providing intent for the first time.'),
|
|
44
|
-
intent: zod_1.z.string().optional()
|
|
45
|
-
.describe('Natural language intent describing what platform operation to perform (e.g., "Install Argo CD", "Create AWS cluster"). Used when stage is omitted.'),
|
|
46
|
-
sessionId: zod_1.z.string().optional()
|
|
47
|
-
.describe('Session ID for continuing a multi-step workflow (required for submitAnswers stage)'),
|
|
48
|
-
answers: zod_1.z.record(zod_1.z.any()).optional()
|
|
49
|
-
.describe('Parameter answers for submitAnswers stage (e.g., {"host-name": "example.com", "apply-apps": true})')
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Main tool handler - Phase 1 & 2: Script discovery and intent mapping
|
|
53
|
-
*/
|
|
54
|
-
async function handleBuildPlatformTool(args, dotAI, logger, requestId) {
|
|
55
|
-
try {
|
|
56
|
-
const { stage, intent, sessionId, answers } = args;
|
|
57
|
-
logger.info('Processing buildPlatform tool request', {
|
|
58
|
-
requestId,
|
|
59
|
-
stage,
|
|
60
|
-
hasIntent: !!intent,
|
|
61
|
-
hasSessionId: !!sessionId,
|
|
62
|
-
hasAnswers: !!answers
|
|
63
|
-
});
|
|
64
|
-
// Validate required parameters - either stage or intent must be provided
|
|
65
|
-
if (!stage && !intent) {
|
|
66
|
-
logger.warn('buildPlatform request missing both stage and intent parameters', { requestId });
|
|
67
|
-
return {
|
|
68
|
-
content: [{
|
|
69
|
-
type: 'text',
|
|
70
|
-
text: JSON.stringify({
|
|
71
|
-
success: false,
|
|
72
|
-
error: {
|
|
73
|
-
message: 'Either stage or intent parameter is required. Use stage: "list" to discover operations, or provide intent like "Install Argo CD"'
|
|
74
|
-
}
|
|
75
|
-
}, null, 2)
|
|
76
|
-
}]
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
// Validate Nushell runtime availability
|
|
80
|
-
const runtime = new nushell_runtime_1.NushellRuntime();
|
|
81
|
-
const validation = await runtime.validateRuntime();
|
|
82
|
-
if (!validation.ready) {
|
|
83
|
-
logger.warn('Nushell runtime not available', {
|
|
84
|
-
requestId,
|
|
85
|
-
error: validation.message
|
|
86
|
-
});
|
|
87
|
-
return {
|
|
88
|
-
content: [{
|
|
89
|
-
type: 'text',
|
|
90
|
-
text: JSON.stringify({
|
|
91
|
-
success: false,
|
|
92
|
-
error: {
|
|
93
|
-
message: 'Nushell runtime required for platform operations',
|
|
94
|
-
details: validation.message,
|
|
95
|
-
installationUrl: validation.installationUrl
|
|
96
|
-
}
|
|
97
|
-
}, null, 2)
|
|
98
|
-
}]
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
// Phase 2: Handle stage: 'list' - discover all operations
|
|
102
|
-
if (stage === 'list') {
|
|
103
|
-
logger.info('Discovering available operations', { requestId });
|
|
104
|
-
const operations = await (0, platform_operations_1.discoverOperations)(dotAI.ai, logger);
|
|
105
|
-
const result = {
|
|
106
|
-
success: true,
|
|
107
|
-
operations,
|
|
108
|
-
message: `Found ${operations.length} platform tools. Present to user as numbered list showing each tool's available operations (install/delete/create/etc). When user selects (by number or name), convert their selection to natural language intent and call this tool again with the 'intent' parameter (e.g., intent: 'Install Crossplane' or 'Delete ACK').`
|
|
109
|
-
};
|
|
110
|
-
return {
|
|
111
|
-
content: [{
|
|
112
|
-
type: 'text',
|
|
113
|
-
text: JSON.stringify(result, null, 2)
|
|
114
|
-
}]
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
// Phase 3: Handle stage: 'submitAnswers' - execute with collected parameters
|
|
118
|
-
if (stage === 'submitAnswers') {
|
|
119
|
-
if (!sessionId) {
|
|
120
|
-
return {
|
|
121
|
-
content: [{
|
|
122
|
-
type: 'text',
|
|
123
|
-
text: JSON.stringify({
|
|
124
|
-
success: false,
|
|
125
|
-
error: {
|
|
126
|
-
message: 'sessionId is required for submitAnswers stage'
|
|
127
|
-
}
|
|
128
|
-
}, null, 2)
|
|
129
|
-
}]
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
logger.info('Processing submitAnswers stage', { requestId, sessionId });
|
|
133
|
-
// Load session
|
|
134
|
-
const session = (0, platform_operations_1.loadSession)(sessionId, logger);
|
|
135
|
-
if (!session) {
|
|
136
|
-
return {
|
|
137
|
-
content: [{
|
|
138
|
-
type: 'text',
|
|
139
|
-
text: JSON.stringify({
|
|
140
|
-
success: false,
|
|
141
|
-
error: {
|
|
142
|
-
message: `Session ${sessionId} not found`
|
|
143
|
-
}
|
|
144
|
-
}, null, 2)
|
|
145
|
-
}]
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
// Execute operation with answers
|
|
149
|
-
const executionResult = await (0, platform_operations_1.executeOperation)(session, answers || {}, logger);
|
|
150
|
-
if (!executionResult.success) {
|
|
151
|
-
return {
|
|
152
|
-
content: [{
|
|
153
|
-
type: 'text',
|
|
154
|
-
text: JSON.stringify({
|
|
155
|
-
success: false,
|
|
156
|
-
error: {
|
|
157
|
-
message: executionResult.error,
|
|
158
|
-
missingParameters: executionResult.missingParameters
|
|
159
|
-
}
|
|
160
|
-
}, null, 2)
|
|
161
|
-
}]
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
return createExecutionResponse(session.matchedOperation.tool, session.matchedOperation.operation);
|
|
165
|
-
}
|
|
166
|
-
// Phase 3: Intent-based workflow with AI mapping and parameter discovery
|
|
167
|
-
const workflowSessionId = sessionId || `platform-${Date.now()}-${(0, crypto_1.randomUUID)()}`;
|
|
168
|
-
logger.info('Nushell runtime validated, starting intent mapping', {
|
|
169
|
-
requestId,
|
|
170
|
-
sessionId: workflowSessionId,
|
|
171
|
-
intent
|
|
172
|
-
});
|
|
173
|
-
// Discover operations for intent mapping
|
|
174
|
-
const operations = await (0, platform_operations_1.discoverOperations)(dotAI.ai, logger);
|
|
175
|
-
// Map intent to operation using AI
|
|
176
|
-
const mapping = await (0, platform_operations_1.mapIntentToOperation)(intent, operations, dotAI.ai, logger);
|
|
177
|
-
// Handle no match case
|
|
178
|
-
if (!mapping.matched) {
|
|
179
|
-
logger.info('No matching operation found for intent', {
|
|
180
|
-
requestId,
|
|
181
|
-
intent,
|
|
182
|
-
reason: mapping.reason
|
|
183
|
-
});
|
|
184
|
-
return {
|
|
185
|
-
content: [{
|
|
186
|
-
type: 'text',
|
|
187
|
-
text: JSON.stringify({
|
|
188
|
-
success: false,
|
|
189
|
-
error: {
|
|
190
|
-
message: mapping.reason || 'No matching operation found for the given intent',
|
|
191
|
-
suggestion: 'Use stage: \'list\' to see all available operations'
|
|
192
|
-
}
|
|
193
|
-
}, null, 2)
|
|
194
|
-
}]
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
// Get parameters for the matched operation
|
|
198
|
-
const parameters = await (0, platform_operations_1.getOperationParameters)(mapping.operation.command, logger);
|
|
199
|
-
logger.info('Intent mapped and parameters retrieved', {
|
|
200
|
-
requestId,
|
|
201
|
-
tool: mapping.operation.tool,
|
|
202
|
-
parameterCount: parameters.length
|
|
203
|
-
});
|
|
204
|
-
// Create and persist session
|
|
205
|
-
await (0, platform_operations_1.createSession)(workflowSessionId, intent, mapping.operation, parameters, logger);
|
|
206
|
-
// If no parameters, execute immediately (skip to submitAnswers stage)
|
|
207
|
-
if (parameters.length === 0) {
|
|
208
|
-
logger.info('No parameters required, executing immediately', {
|
|
209
|
-
requestId,
|
|
210
|
-
sessionId: workflowSessionId
|
|
211
|
-
});
|
|
212
|
-
// Reuse submitAnswers stage logic with empty answers
|
|
213
|
-
const session = (0, platform_operations_1.loadSession)(workflowSessionId, logger);
|
|
214
|
-
if (!session) {
|
|
215
|
-
return {
|
|
216
|
-
content: [{
|
|
217
|
-
type: 'text',
|
|
218
|
-
text: JSON.stringify({
|
|
219
|
-
success: false,
|
|
220
|
-
error: {
|
|
221
|
-
message: `Session ${workflowSessionId} not found`
|
|
222
|
-
}
|
|
223
|
-
}, null, 2)
|
|
224
|
-
}]
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
const executionResult = await (0, platform_operations_1.executeOperation)(session, {}, logger);
|
|
228
|
-
if (!executionResult.success) {
|
|
229
|
-
return {
|
|
230
|
-
content: [{
|
|
231
|
-
type: 'text',
|
|
232
|
-
text: JSON.stringify({
|
|
233
|
-
success: false,
|
|
234
|
-
error: {
|
|
235
|
-
message: executionResult.error
|
|
236
|
-
}
|
|
237
|
-
}, null, 2)
|
|
238
|
-
}]
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
return createExecutionResponse(session.matchedOperation.tool, session.matchedOperation.operation);
|
|
242
|
-
}
|
|
243
|
-
const result = {
|
|
244
|
-
success: true,
|
|
245
|
-
workflow: {
|
|
246
|
-
sessionId: workflowSessionId,
|
|
247
|
-
intent: intent,
|
|
248
|
-
matchedOperation: mapping.operation,
|
|
249
|
-
parameters,
|
|
250
|
-
nextStep: 'collectParameters',
|
|
251
|
-
message: `Found ${parameters.length} parameters for ${mapping.operation.tool} ${mapping.operation.operation}. Collect answers from user (one at a time or all at once - user decides via client agent), then call this tool again with stage: "submitAnswers", sessionId: "${workflowSessionId}", and answers: {param1: value1, ...}`
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
return {
|
|
255
|
-
content: [{
|
|
256
|
-
type: 'text',
|
|
257
|
-
text: JSON.stringify(result, null, 2)
|
|
258
|
-
}]
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
catch (error) {
|
|
262
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
263
|
-
logger.error('buildPlatform tool request failed', error, { requestId });
|
|
264
|
-
return {
|
|
265
|
-
content: [{
|
|
266
|
-
type: 'text',
|
|
267
|
-
text: JSON.stringify({
|
|
268
|
-
success: false,
|
|
269
|
-
error: {
|
|
270
|
-
message: 'Tool execution failed',
|
|
271
|
-
details: errorMessage
|
|
272
|
-
}
|
|
273
|
-
}, null, 2)
|
|
274
|
-
}]
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test Docs Tool - Documentation testing workflow orchestrator
|
|
3
|
-
*/
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
import { DotAI } from '../core/index';
|
|
6
|
-
import { Logger } from '../core/error-handling';
|
|
7
|
-
export declare const TESTDOCS_TOOL_NAME = "testDocs";
|
|
8
|
-
export declare const TESTDOCS_TOOL_DESCRIPTION = "Test, validate, check, scan, verify, analyze, or review documentation files for accuracy, functionality, broken examples, outdated commands, invalid links, and overall quality. Use this tool whenever the user wants to test docs, validate documentation, check if examples work, scan for issues, verify commands, analyze doc quality, or review documentation content. IMPORTANT: This tool returns a workflow step with a \"prompt\" field - you must execute that prompt immediately to perform the actual documentation analysis.";
|
|
9
|
-
export declare const TESTDOCS_TOOL_INPUT_SCHEMA: {
|
|
10
|
-
filePath: z.ZodOptional<z.ZodString>;
|
|
11
|
-
sessionId: z.ZodOptional<z.ZodString>;
|
|
12
|
-
phase: z.ZodOptional<z.ZodEnum<["scan", "test", "analyze", "fix", "done"]>>;
|
|
13
|
-
sectionId: z.ZodOptional<z.ZodString>;
|
|
14
|
-
results: z.ZodOptional<z.ZodString>;
|
|
15
|
-
filePattern: z.ZodOptional<z.ZodString>;
|
|
16
|
-
interaction_id: z.ZodOptional<z.ZodString>;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Handle test-docs tool request
|
|
20
|
-
*/
|
|
21
|
-
export declare function handleTestDocsTool(args: any, _dotAI: DotAI | null, logger: Logger, requestId: string): Promise<any>;
|
|
22
|
-
//# sourceMappingURL=test-docs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-docs.d.ts","sourceRoot":"","sources":["../../src/tools/test-docs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAOhD,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAC7C,eAAO,MAAM,yBAAyB,+gBAA6gB,CAAC;AAGpjB,eAAO,MAAM,0BAA0B;;;;;;;;CAQtC,CAAC;AAEF;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,KAAK,GAAG,IAAI,EACpB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,GAAG,CAAC,CAkWd"}
|