@vfarcic/dot-ai 0.50.0 → 0.51.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/dist/core/capabilities.d.ts +1 -1
- package/dist/core/capabilities.d.ts.map +1 -1
- package/dist/core/capabilities.js +7 -14
- package/dist/core/discovery.d.ts +0 -13
- package/dist/core/discovery.d.ts.map +1 -1
- package/dist/core/discovery.js +0 -24
- package/dist/tools/organizational-data.d.ts.map +1 -1
- package/dist/tools/organizational-data.js +82 -41
- package/package.json +1 -1
- package/prompts/capability-inference.md +42 -41
|
@@ -39,7 +39,7 @@ export declare class CapabilityInferenceEngine {
|
|
|
39
39
|
* @param resourceName - Full resource name (e.g., "resourcegroups.azure.upbound.io")
|
|
40
40
|
* @throws Error if capability inference fails for any reason
|
|
41
41
|
*/
|
|
42
|
-
inferCapabilities(resourceName: string,
|
|
42
|
+
inferCapabilities(resourceName: string, resourceDefinition?: string): Promise<ResourceCapability>;
|
|
43
43
|
/**
|
|
44
44
|
* Use AI to infer capabilities from all available resource context
|
|
45
45
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../src/core/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAK7C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAEjC,YAAY,EAAE,MAAM,CAAC;IAGrB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IAGtC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAGhB,SAAS,CAAC,EAAE,MAA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IG;YACW,oBAAoB;IA0BlC;;;;OAIG;IACH,OAAO,CAAC,uBAAuB;IAwD/B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAyB/B;;;OAGG;IACH,MAAM,CAAC,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;CAQ1D"}
|
|
@@ -63,16 +63,15 @@ class CapabilityInferenceEngine {
|
|
|
63
63
|
* @param resourceName - Full resource name (e.g., "resourcegroups.azure.upbound.io")
|
|
64
64
|
* @throws Error if capability inference fails for any reason
|
|
65
65
|
*/
|
|
66
|
-
async inferCapabilities(resourceName,
|
|
66
|
+
async inferCapabilities(resourceName, resourceDefinition) {
|
|
67
67
|
const requestId = `capability-inference-${Date.now()}`;
|
|
68
68
|
this.logger.info('Starting capability inference', {
|
|
69
69
|
requestId,
|
|
70
70
|
resource: resourceName,
|
|
71
|
-
|
|
72
|
-
hasMetadata: !!metadata
|
|
71
|
+
hasDefinition: !!resourceDefinition
|
|
73
72
|
});
|
|
74
73
|
// Use AI to analyze all available information
|
|
75
|
-
const aiResult = await this.inferWithAI(resourceName,
|
|
74
|
+
const aiResult = await this.inferWithAI(resourceName, resourceDefinition, requestId);
|
|
76
75
|
// Convert AI result to final capability structure
|
|
77
76
|
const finalCapability = this.buildResourceCapability(resourceName, aiResult);
|
|
78
77
|
this.logger.info('Capability inference completed', {
|
|
@@ -90,9 +89,9 @@ class CapabilityInferenceEngine {
|
|
|
90
89
|
*
|
|
91
90
|
* @throws Error if AI inference fails
|
|
92
91
|
*/
|
|
93
|
-
async inferWithAI(resourceName,
|
|
92
|
+
async inferWithAI(resourceName, resourceDefinition, requestId) {
|
|
94
93
|
try {
|
|
95
|
-
const prompt = await this.buildInferencePrompt(resourceName,
|
|
94
|
+
const prompt = await this.buildInferencePrompt(resourceName, resourceDefinition);
|
|
96
95
|
const response = await this.claudeIntegration.sendMessage(prompt);
|
|
97
96
|
return this.parseCapabilitiesFromAI(response.content);
|
|
98
97
|
}
|
|
@@ -109,7 +108,7 @@ class CapabilityInferenceEngine {
|
|
|
109
108
|
*
|
|
110
109
|
* @throws Error if prompt template cannot be loaded
|
|
111
110
|
*/
|
|
112
|
-
async buildInferencePrompt(resourceName,
|
|
111
|
+
async buildInferencePrompt(resourceName, resourceDefinition) {
|
|
113
112
|
// Load prompt template using standard pattern from existing codebase
|
|
114
113
|
const promptPath = path.join(__dirname, '..', '..', 'prompts', 'capability-inference.md');
|
|
115
114
|
if (!fs.existsSync(promptPath)) {
|
|
@@ -123,15 +122,9 @@ class CapabilityInferenceEngine {
|
|
|
123
122
|
throw new Error(`Failed to read capability inference prompt: ${error instanceof Error ? error.message : String(error)}`);
|
|
124
123
|
}
|
|
125
124
|
// Replace template variables using standard pattern
|
|
126
|
-
const analysisContext = schema && metadata ?
|
|
127
|
-
'Schema and metadata available' :
|
|
128
|
-
schema ? 'Schema only' :
|
|
129
|
-
metadata ? 'Metadata only' : 'Limited context';
|
|
130
125
|
const finalPrompt = template
|
|
131
126
|
.replace(/\{resourceName\}/g, resourceName)
|
|
132
|
-
.replace(/\{
|
|
133
|
-
.replace(/\{schema\}/g, schema || 'No schema provided')
|
|
134
|
-
.replace(/\{metadata\}/g, metadata ? JSON.stringify(metadata, null, 2) : 'No metadata provided');
|
|
127
|
+
.replace(/\{resourceDefinition\}/g, resourceDefinition || 'No resource definition provided');
|
|
135
128
|
return finalPrompt;
|
|
136
129
|
}
|
|
137
130
|
/**
|
package/dist/core/discovery.d.ts
CHANGED
|
@@ -13,18 +13,6 @@ export interface ResourceMap {
|
|
|
13
13
|
resources: EnhancedResource[];
|
|
14
14
|
custom: EnhancedCRD[];
|
|
15
15
|
}
|
|
16
|
-
export interface CRD {
|
|
17
|
-
name: string;
|
|
18
|
-
group: string;
|
|
19
|
-
version: string;
|
|
20
|
-
schema: any;
|
|
21
|
-
metadata?: {
|
|
22
|
-
labels: any;
|
|
23
|
-
annotations: any;
|
|
24
|
-
description: string;
|
|
25
|
-
categories: string[];
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
16
|
export interface EnhancedCRD {
|
|
29
17
|
name: string;
|
|
30
18
|
group: string;
|
|
@@ -132,7 +120,6 @@ export declare class KubernetesDiscovery {
|
|
|
132
120
|
discoverCRDs(options?: {
|
|
133
121
|
group?: string;
|
|
134
122
|
}): Promise<EnhancedCRD[]>;
|
|
135
|
-
discoverCRDDetails(): Promise<CRD[]>;
|
|
136
123
|
getAPIResources(options?: {
|
|
137
124
|
group?: string;
|
|
138
125
|
}): Promise<EnhancedResource[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/core/discovery.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAEL,aAAa,EAEd,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/core/discovery.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAEL,aAAa,EAEd,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAKD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE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CAAC,WAAW,EAAE,CAAC;IAkDlE,eAAe,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAuD1E,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBhF,kBAAkB,IAAI,OAAO,CAAC,kBAAkB,CAAC;YA2FzC,iBAAiB;YAwBjB,iBAAiB;YAwBjB,eAAe;YA8Bf,cAAc;IAwB5B,OAAO,CAAC,aAAa;IAWf,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAiBnE,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAalC,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAS1D;;OAEG;YACW,uBAAuB;IAsDrC;;OAEG;YACW,8BAA8B;IAkB5C;;OAEG;YACW,8BAA8B;IAiE5C;;OAEG;IACH,OAAO,CAAC,wBAAwB;CAgBjC"}
|
package/dist/core/discovery.js
CHANGED
|
@@ -305,30 +305,6 @@ class KubernetesDiscovery {
|
|
|
305
305
|
throw new Error(classified.enhancedMessage);
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
|
-
async discoverCRDDetails() {
|
|
309
|
-
if (!this.connected) {
|
|
310
|
-
throw new Error('Not connected to cluster');
|
|
311
|
-
}
|
|
312
|
-
try {
|
|
313
|
-
const apiExtensions = this.kc.makeApiClient(k8s.ApiextensionsV1Api);
|
|
314
|
-
const crdList = await apiExtensions.listCustomResourceDefinition();
|
|
315
|
-
return crdList.items.map((crd) => ({
|
|
316
|
-
name: crd.metadata?.name || '',
|
|
317
|
-
group: crd.spec.group,
|
|
318
|
-
version: crd.spec.versions[0]?.name || '',
|
|
319
|
-
schema: crd.spec.versions[0]?.schema || {},
|
|
320
|
-
metadata: {
|
|
321
|
-
labels: crd.metadata?.labels || {},
|
|
322
|
-
annotations: crd.metadata?.annotations || {},
|
|
323
|
-
description: crd.spec.versions[0]?.schema?.openAPIV3Schema?.description || '',
|
|
324
|
-
categories: crd.spec.names?.categories || []
|
|
325
|
-
}
|
|
326
|
-
}));
|
|
327
|
-
}
|
|
328
|
-
catch (error) {
|
|
329
|
-
return [];
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
308
|
async getAPIResources(options) {
|
|
333
309
|
if (!this.connected) {
|
|
334
310
|
throw new Error('Not connected to cluster');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organizational-data.d.ts","sourceRoot":"","sources":["../../src/tools/organizational-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAUhD,eAAO,MAAM,6BAA6B,kBAAkB,CAAC;AAC7D,eAAO,MAAM,oCAAoC,8aAA0a,CAAC;AAG5d,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;CAwBjD,CAAC;
|
|
1
|
+
{"version":3,"file":"organizational-data.d.ts","sourceRoot":"","sources":["../../src/tools/organizational-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAUhD,eAAO,MAAM,6BAA6B,kBAAkB,CAAC;AAC7D,eAAO,MAAM,oCAAoC,8aAA0a,CAAC;AAG5d,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;CAwBjD,CAAC;AAg4EF;;GAEG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,KAAK,GAAG,IAAI,EACpB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,GAAG,CAAC,CAsHd"}
|
|
@@ -1120,6 +1120,26 @@ async function handleProcessingMode(session, args, logger, requestId, capability
|
|
|
1120
1120
|
// Begin actual capability scanning - clear response from previous step
|
|
1121
1121
|
return await handleScanning(session, { ...args, response: undefined }, logger, requestId, capabilityService);
|
|
1122
1122
|
}
|
|
1123
|
+
/**
|
|
1124
|
+
* Create user-friendly error message for resource definition failures
|
|
1125
|
+
*/
|
|
1126
|
+
function createResourceDefinitionErrorMessage(resourceName, error) {
|
|
1127
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1128
|
+
let userFriendlyMessage = `Cannot analyze resource '${resourceName}': `;
|
|
1129
|
+
if (errorMessage.includes('not found') || errorMessage.includes('NotFound')) {
|
|
1130
|
+
userFriendlyMessage += `Resource does not exist in cluster. Please ensure the CRD is installed.`;
|
|
1131
|
+
}
|
|
1132
|
+
else if (errorMessage.includes('connection refused') || errorMessage.includes('timeout')) {
|
|
1133
|
+
userFriendlyMessage += `Cannot connect to Kubernetes cluster. Please check cluster connectivity.`;
|
|
1134
|
+
}
|
|
1135
|
+
else if (errorMessage.includes('forbidden') || errorMessage.includes('Forbidden')) {
|
|
1136
|
+
userFriendlyMessage += `Insufficient permissions to read resource definitions. Please check RBAC settings.`;
|
|
1137
|
+
}
|
|
1138
|
+
else {
|
|
1139
|
+
userFriendlyMessage += `${errorMessage}`;
|
|
1140
|
+
}
|
|
1141
|
+
return userFriendlyMessage;
|
|
1142
|
+
}
|
|
1123
1143
|
/**
|
|
1124
1144
|
* Handle scanning step (actual capability analysis)
|
|
1125
1145
|
*/
|
|
@@ -1285,40 +1305,44 @@ async function handleScanning(session, args, logger, requestId, capabilityServic
|
|
|
1285
1305
|
else {
|
|
1286
1306
|
throw new Error('Invalid selectedResources in session state');
|
|
1287
1307
|
}
|
|
1288
|
-
// Get
|
|
1289
|
-
let
|
|
1290
|
-
let resourceMetadata;
|
|
1308
|
+
// Get complete resource definition for comprehensive analysis
|
|
1309
|
+
let resourceDefinition;
|
|
1291
1310
|
try {
|
|
1292
|
-
// Import and connect to discovery engine
|
|
1311
|
+
// Import and connect to discovery engine for kubectl access
|
|
1293
1312
|
const { KubernetesDiscovery } = await Promise.resolve().then(() => __importStar(require('../core/discovery')));
|
|
1294
1313
|
const discovery = new KubernetesDiscovery();
|
|
1295
1314
|
await discovery.connect();
|
|
1296
|
-
// Get CRD definition
|
|
1315
|
+
// Get complete CRD definition if it's a custom resource
|
|
1297
1316
|
if (resourceName.includes('.')) {
|
|
1298
|
-
const
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1317
|
+
const crdOutput = await discovery.executeKubectl(['get', 'crd', resourceName, '-o', 'yaml']);
|
|
1318
|
+
resourceDefinition = crdOutput;
|
|
1319
|
+
logger.info('Found complete CRD definition for capability analysis', {
|
|
1320
|
+
requestId,
|
|
1321
|
+
sessionId: session.sessionId,
|
|
1322
|
+
resource: resourceName,
|
|
1323
|
+
hasDefinition: !!resourceDefinition,
|
|
1324
|
+
definitionSize: resourceDefinition?.length || 0
|
|
1325
|
+
});
|
|
1326
|
+
}
|
|
1327
|
+
else {
|
|
1328
|
+
// For core resources, use kubectl explain to get schema information
|
|
1329
|
+
const explainOutput = await discovery.explainResource(resourceName);
|
|
1330
|
+
resourceDefinition = explainOutput;
|
|
1331
|
+
logger.info('Found core resource explanation for capability analysis', {
|
|
1332
|
+
requestId,
|
|
1333
|
+
sessionId: session.sessionId,
|
|
1334
|
+
resource: resourceName,
|
|
1335
|
+
hasDefinition: !!resourceDefinition
|
|
1336
|
+
});
|
|
1313
1337
|
}
|
|
1314
1338
|
}
|
|
1315
1339
|
catch (error) {
|
|
1316
|
-
logger.
|
|
1340
|
+
logger.error('Failed to retrieve resource definition for capability analysis', error, {
|
|
1317
1341
|
requestId,
|
|
1318
1342
|
sessionId: session.sessionId,
|
|
1319
|
-
resource: resourceName
|
|
1320
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1343
|
+
resource: resourceName
|
|
1321
1344
|
});
|
|
1345
|
+
throw new Error(createResourceDefinitionErrorMessage(resourceName, error));
|
|
1322
1346
|
}
|
|
1323
1347
|
logger.info('Analyzing resource for capability inference', {
|
|
1324
1348
|
requestId,
|
|
@@ -1328,7 +1352,7 @@ async function handleScanning(session, args, logger, requestId, capabilityServic
|
|
|
1328
1352
|
});
|
|
1329
1353
|
if (session.processingMode === 'manual') {
|
|
1330
1354
|
// Manual mode: Show capability data for user review
|
|
1331
|
-
const capability = await engine.inferCapabilities(resourceName,
|
|
1355
|
+
const capability = await engine.inferCapabilities(resourceName, resourceDefinition);
|
|
1332
1356
|
const capabilityId = CapabilityInferenceEngine.generateCapabilityId(resourceName);
|
|
1333
1357
|
return {
|
|
1334
1358
|
success: true,
|
|
@@ -1411,21 +1435,19 @@ async function handleScanning(session, args, logger, requestId, capabilityServic
|
|
|
1411
1435
|
progress: progressData
|
|
1412
1436
|
}, args);
|
|
1413
1437
|
};
|
|
1414
|
-
//
|
|
1415
|
-
let
|
|
1438
|
+
// Setup kubectl access for getting complete resource definitions
|
|
1439
|
+
let discovery;
|
|
1416
1440
|
try {
|
|
1417
1441
|
const { KubernetesDiscovery } = await Promise.resolve().then(() => __importStar(require('../core/discovery')));
|
|
1418
|
-
|
|
1442
|
+
discovery = new KubernetesDiscovery();
|
|
1419
1443
|
await discovery.connect();
|
|
1420
|
-
|
|
1421
|
-
logger.info('Retrieved CRD definitions for batch processing', {
|
|
1444
|
+
logger.info('Connected to Kubernetes for batch resource definition retrieval', {
|
|
1422
1445
|
requestId,
|
|
1423
|
-
sessionId: session.sessionId
|
|
1424
|
-
totalCRDs: availableCRDs.length
|
|
1446
|
+
sessionId: session.sessionId
|
|
1425
1447
|
});
|
|
1426
1448
|
}
|
|
1427
1449
|
catch (error) {
|
|
1428
|
-
logger.warn('Could not
|
|
1450
|
+
logger.warn('Could not connect to Kubernetes for batch processing, falling back to name-based inference', {
|
|
1429
1451
|
requestId,
|
|
1430
1452
|
sessionId: session.sessionId,
|
|
1431
1453
|
error: error instanceof Error ? error.message : String(error)
|
|
@@ -1434,14 +1456,33 @@ async function handleScanning(session, args, logger, requestId, capabilityServic
|
|
|
1434
1456
|
// Process each resource in the batch with progress tracking
|
|
1435
1457
|
for (let i = 0; i < resources.length; i++) {
|
|
1436
1458
|
const currentResource = resources[i];
|
|
1437
|
-
// Get
|
|
1438
|
-
let
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1459
|
+
// Get complete resource definition for this resource
|
|
1460
|
+
let currentResourceDefinition;
|
|
1461
|
+
if (discovery) {
|
|
1462
|
+
try {
|
|
1463
|
+
if (currentResource.includes('.')) {
|
|
1464
|
+
// Get complete CRD definition
|
|
1465
|
+
currentResourceDefinition = await discovery.executeKubectl(['get', 'crd', currentResource, '-o', 'yaml']);
|
|
1466
|
+
}
|
|
1467
|
+
else {
|
|
1468
|
+
// Get core resource explanation
|
|
1469
|
+
currentResourceDefinition = await discovery.explainResource(currentResource);
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
catch (error) {
|
|
1473
|
+
logger.error(`Failed to get resource definition for ${currentResource}`, error, {
|
|
1474
|
+
requestId,
|
|
1475
|
+
sessionId: session.sessionId,
|
|
1476
|
+
resource: currentResource
|
|
1477
|
+
});
|
|
1478
|
+
// Add to errors array and skip processing this resource
|
|
1479
|
+
errors.push({
|
|
1480
|
+
resource: currentResource,
|
|
1481
|
+
error: createResourceDefinitionErrorMessage(currentResource, error),
|
|
1482
|
+
timestamp: new Date().toISOString()
|
|
1483
|
+
});
|
|
1484
|
+
// Skip processing this resource
|
|
1485
|
+
continue;
|
|
1445
1486
|
}
|
|
1446
1487
|
}
|
|
1447
1488
|
// Update progress before processing
|
|
@@ -1453,7 +1494,7 @@ async function handleScanning(session, args, logger, requestId, capabilityServic
|
|
|
1453
1494
|
resource: currentResource,
|
|
1454
1495
|
percentage: Math.round(((i + 1) / totalResources) * 100)
|
|
1455
1496
|
});
|
|
1456
|
-
const capability = await engine.inferCapabilities(currentResource,
|
|
1497
|
+
const capability = await engine.inferCapabilities(currentResource, currentResourceDefinition);
|
|
1457
1498
|
const capabilityId = CapabilityInferenceEngine.generateCapabilityId(currentResource);
|
|
1458
1499
|
// Store capability in Vector DB
|
|
1459
1500
|
await capabilityService.storeCapability(capability);
|
package/package.json
CHANGED
|
@@ -1,56 +1,57 @@
|
|
|
1
|
-
# Capability
|
|
1
|
+
# Generic Kubernetes Resource Capability Analysis
|
|
2
2
|
|
|
3
|
-
Analyze this Kubernetes resource and identify its capabilities for semantic
|
|
3
|
+
Analyze this Kubernetes resource and identify its capabilities for semantic matching and AI recommendations.
|
|
4
4
|
|
|
5
5
|
## Resource Information
|
|
6
6
|
- **Resource**: {resourceName}
|
|
7
|
-
- **Analysis Context**: {analysisContext}
|
|
8
7
|
|
|
9
|
-
## Resource
|
|
8
|
+
## Resource Definition
|
|
10
9
|
```yaml
|
|
11
|
-
{
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## Resource Metadata
|
|
15
|
-
```json
|
|
16
|
-
{metadata}
|
|
10
|
+
{resourceDefinition}
|
|
17
11
|
```
|
|
18
12
|
|
|
19
13
|
## Analysis Instructions
|
|
20
14
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
### 1.
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
- **Specific**: azure, aws, gcp, digitalocean, etc.
|
|
37
|
-
- **Multi-cloud**: if it works across multiple providers
|
|
38
|
-
- **On-premises**: if it supports on-prem deployments
|
|
15
|
+
Analyze the provided resource definition to understand what this resource does and extract its capabilities. Use only information present in the definition - do not guess or assume.
|
|
16
|
+
|
|
17
|
+
### 1. Functional Capabilities
|
|
18
|
+
From the resource definition, identify what this resource enables users to do:
|
|
19
|
+
- Look at schema properties, descriptions, and field names
|
|
20
|
+
- Identify the core functionality (e.g., "database", "storage", "networking")
|
|
21
|
+
- Be specific about technologies (e.g., "postgresql" vs generic "database")
|
|
22
|
+
- Extract capabilities from field names, descriptions, and structure
|
|
23
|
+
|
|
24
|
+
### 2. Provider/Platform Support
|
|
25
|
+
Identify what platforms or providers this resource works with:
|
|
26
|
+
- Look for provider-specific configuration sections or fields
|
|
27
|
+
- Check for multi-provider abstractions vs single-provider resources
|
|
28
|
+
- Identify on-premises vs cloud-only resources
|
|
29
|
+
- Only list providers explicitly mentioned or configured in the definition
|
|
39
30
|
|
|
40
31
|
### 3. Abstraction Level
|
|
41
|
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
32
|
+
Determine what abstractions this resource provides:
|
|
33
|
+
- High-level managed services with minimal configuration
|
|
34
|
+
- Infrastructure abstractions (auto-scaling, high availability, etc.)
|
|
35
|
+
- Integration capabilities (backup, monitoring, security features)
|
|
36
|
+
- Look at required vs optional fields to gauge abstraction level
|
|
37
|
+
|
|
38
|
+
### 4. User Experience Complexity
|
|
39
|
+
Assess complexity considering both configuration and assembly requirements:
|
|
40
|
+
|
|
41
|
+
**Configuration Complexity:**
|
|
42
|
+
- Number and difficulty of required fields
|
|
43
|
+
- Technical knowledge needed for the resource itself
|
|
44
|
+
- Clarity of purpose and abstractions provided
|
|
45
|
+
|
|
46
|
+
**Assembly Complexity:**
|
|
47
|
+
- **Standalone**: Resource works independently, creates/manages all dependencies
|
|
48
|
+
- **Coordinated**: Requires 2-3 other resources to be functional
|
|
49
|
+
- **Orchestrated**: Needs many resources and complex relationships to work
|
|
50
|
+
|
|
51
|
+
**Final Complexity Rating:**
|
|
52
|
+
- **Low**: Simple configuration AND works standalone or with minimal dependencies
|
|
53
|
+
- **Medium**: Moderate configuration OR needs some coordination with other resources
|
|
54
|
+
- **High**: Complex configuration OR requires orchestrating many resources OR both
|
|
54
55
|
|
|
55
56
|
## Response Format
|
|
56
57
|
|