@vfarcic/dot-ai 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +203 -0
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +51 -0
  6. package/dist/core/claude.d.ts +42 -0
  7. package/dist/core/claude.d.ts.map +1 -0
  8. package/dist/core/claude.js +229 -0
  9. package/dist/core/deploy-operation.d.ts +38 -0
  10. package/dist/core/deploy-operation.d.ts.map +1 -0
  11. package/dist/core/deploy-operation.js +101 -0
  12. package/dist/core/discovery.d.ts +162 -0
  13. package/dist/core/discovery.d.ts.map +1 -0
  14. package/dist/core/discovery.js +758 -0
  15. package/dist/core/error-handling.d.ts +167 -0
  16. package/dist/core/error-handling.d.ts.map +1 -0
  17. package/dist/core/error-handling.js +399 -0
  18. package/dist/core/index.d.ts +42 -0
  19. package/dist/core/index.d.ts.map +1 -0
  20. package/dist/core/index.js +123 -0
  21. package/dist/core/kubernetes-utils.d.ts +38 -0
  22. package/dist/core/kubernetes-utils.d.ts.map +1 -0
  23. package/dist/core/kubernetes-utils.js +177 -0
  24. package/dist/core/memory.d.ts +45 -0
  25. package/dist/core/memory.d.ts.map +1 -0
  26. package/dist/core/memory.js +113 -0
  27. package/dist/core/schema.d.ts +187 -0
  28. package/dist/core/schema.d.ts.map +1 -0
  29. package/dist/core/schema.js +655 -0
  30. package/dist/core/session-utils.d.ts +29 -0
  31. package/dist/core/session-utils.d.ts.map +1 -0
  32. package/dist/core/session-utils.js +121 -0
  33. package/dist/core/workflow.d.ts +70 -0
  34. package/dist/core/workflow.d.ts.map +1 -0
  35. package/dist/core/workflow.js +161 -0
  36. package/dist/index.d.ts +15 -0
  37. package/dist/index.d.ts.map +1 -0
  38. package/dist/index.js +32 -0
  39. package/dist/interfaces/cli.d.ts +74 -0
  40. package/dist/interfaces/cli.d.ts.map +1 -0
  41. package/dist/interfaces/cli.js +769 -0
  42. package/dist/interfaces/mcp.d.ts +30 -0
  43. package/dist/interfaces/mcp.d.ts.map +1 -0
  44. package/dist/interfaces/mcp.js +105 -0
  45. package/dist/mcp/server.d.ts +9 -0
  46. package/dist/mcp/server.d.ts.map +1 -0
  47. package/dist/mcp/server.js +151 -0
  48. package/dist/tools/answer-question.d.ts +27 -0
  49. package/dist/tools/answer-question.d.ts.map +1 -0
  50. package/dist/tools/answer-question.js +696 -0
  51. package/dist/tools/choose-solution.d.ts +23 -0
  52. package/dist/tools/choose-solution.d.ts.map +1 -0
  53. package/dist/tools/choose-solution.js +171 -0
  54. package/dist/tools/deploy-manifests.d.ts +25 -0
  55. package/dist/tools/deploy-manifests.d.ts.map +1 -0
  56. package/dist/tools/deploy-manifests.js +74 -0
  57. package/dist/tools/generate-manifests.d.ts +23 -0
  58. package/dist/tools/generate-manifests.d.ts.map +1 -0
  59. package/dist/tools/generate-manifests.js +424 -0
  60. package/dist/tools/index.d.ts +11 -0
  61. package/dist/tools/index.d.ts.map +1 -0
  62. package/dist/tools/index.js +34 -0
  63. package/dist/tools/recommend.d.ts +23 -0
  64. package/dist/tools/recommend.d.ts.map +1 -0
  65. package/dist/tools/recommend.js +332 -0
  66. package/package.json +124 -0
  67. package/prompts/intent-validation.md +65 -0
  68. package/prompts/manifest-generation.md +79 -0
  69. package/prompts/question-generation.md +128 -0
  70. package/prompts/resource-analysis.md +127 -0
  71. package/prompts/resource-selection.md +55 -0
  72. package/prompts/resource-solution-ranking.md +77 -0
  73. package/prompts/solution-enhancement.md +129 -0
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ /**
3
+ * Core Intelligence Module
4
+ *
5
+ * Shared intelligence for both CLI and MCP interfaces
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.ResourceRecommender = exports.ManifestValidator = exports.SchemaParser = exports.ClaudeIntegration = exports.WorkflowEngine = exports.MemorySystem = exports.KubernetesDiscovery = exports.DotAI = void 0;
9
+ const discovery_1 = require("./discovery");
10
+ const memory_1 = require("./memory");
11
+ const workflow_1 = require("./workflow");
12
+ const claude_1 = require("./claude");
13
+ const schema_1 = require("./schema");
14
+ class DotAI {
15
+ config;
16
+ initialized = false;
17
+ discovery;
18
+ memory;
19
+ workflow;
20
+ claude;
21
+ schema;
22
+ constructor(config = {}) {
23
+ this.validateConfig(config);
24
+ // Centralize environment variable reading
25
+ this.config = {
26
+ kubernetesConfig: config.kubernetesConfig || process.env.KUBECONFIG,
27
+ anthropicApiKey: config.anthropicApiKey || process.env.ANTHROPIC_API_KEY
28
+ };
29
+ // Initialize modules
30
+ this.discovery = new discovery_1.KubernetesDiscovery({
31
+ kubeconfigPath: this.config.kubernetesConfig
32
+ });
33
+ this.memory = new memory_1.MemorySystem();
34
+ this.workflow = new workflow_1.WorkflowEngine();
35
+ this.claude = new claude_1.ClaudeIntegration(this.config.anthropicApiKey || 'test-key');
36
+ // Initialize schema components
37
+ const parser = new schema_1.SchemaParser();
38
+ const validator = new schema_1.ManifestValidator();
39
+ const ranker = this.config.anthropicApiKey ?
40
+ new schema_1.ResourceRecommender({ claudeApiKey: this.config.anthropicApiKey }) :
41
+ null;
42
+ this.schema = {
43
+ parser,
44
+ validator,
45
+ ranker,
46
+ parseResource: async (resourceName) => {
47
+ // Get raw resource explanation from discovery
48
+ const explanation = await this.discovery.explainResource(resourceName);
49
+ // Parse GROUP, KIND, VERSION from kubectl explain output
50
+ const lines = explanation.split('\n');
51
+ const groupLine = lines.find((line) => line.startsWith('GROUP:'));
52
+ const kindLine = lines.find((line) => line.startsWith('KIND:'));
53
+ const versionLine = lines.find((line) => line.startsWith('VERSION:'));
54
+ const group = groupLine ? groupLine.replace('GROUP:', '').trim() : '';
55
+ const kind = kindLine ? kindLine.replace('KIND:', '').trim() : resourceName;
56
+ const version = versionLine ? versionLine.replace('VERSION:', '').trim() : 'v1';
57
+ // Build apiVersion from group and version
58
+ const apiVersion = group ? `${group}/${version}` : version;
59
+ // Return raw explanation for AI processing
60
+ return {
61
+ kind: kind,
62
+ rawExplanation: explanation,
63
+ apiVersion: apiVersion,
64
+ group: group,
65
+ description: explanation.split('\n').find((line) => line.startsWith('DESCRIPTION:'))?.replace('DESCRIPTION:', '').trim() || '',
66
+ properties: new Map() // Raw explanation contains all field info for AI
67
+ };
68
+ },
69
+ rankResources: async (intent) => {
70
+ if (!ranker) {
71
+ throw new Error('ResourceRanker not available. ANTHROPIC_API_KEY is required for AI-powered ranking.');
72
+ }
73
+ // Create discovery functions with proper binding
74
+ const discoverResourcesFn = async () => await this.discovery.discoverResources();
75
+ const explainResourceFn = async (resource) => await this.discovery.explainResource(resource);
76
+ return await ranker.findBestSolutions(intent, discoverResourcesFn, explainResourceFn);
77
+ }
78
+ };
79
+ }
80
+ validateConfig(config) {
81
+ if (config.anthropicApiKey === '') {
82
+ throw new Error('Invalid configuration: Empty API key provided');
83
+ }
84
+ }
85
+ async initialize() {
86
+ try {
87
+ // Initialize all modules
88
+ await this.discovery.connect();
89
+ await this.memory.initialize();
90
+ await this.workflow.initialize();
91
+ this.initialized = true;
92
+ }
93
+ catch (error) {
94
+ this.initialized = false;
95
+ throw error;
96
+ }
97
+ }
98
+ isInitialized() {
99
+ return this.initialized;
100
+ }
101
+ getVersion() {
102
+ return '0.1.0';
103
+ }
104
+ getAnthropicApiKey() {
105
+ return this.config.anthropicApiKey;
106
+ }
107
+ }
108
+ exports.DotAI = DotAI;
109
+ // Re-export all modules for convenience
110
+ var discovery_2 = require("./discovery");
111
+ Object.defineProperty(exports, "KubernetesDiscovery", { enumerable: true, get: function () { return discovery_2.KubernetesDiscovery; } });
112
+ var memory_2 = require("./memory");
113
+ Object.defineProperty(exports, "MemorySystem", { enumerable: true, get: function () { return memory_2.MemorySystem; } });
114
+ var workflow_2 = require("./workflow");
115
+ Object.defineProperty(exports, "WorkflowEngine", { enumerable: true, get: function () { return workflow_2.WorkflowEngine; } });
116
+ var claude_2 = require("./claude");
117
+ Object.defineProperty(exports, "ClaudeIntegration", { enumerable: true, get: function () { return claude_2.ClaudeIntegration; } });
118
+ var schema_2 = require("./schema");
119
+ Object.defineProperty(exports, "SchemaParser", { enumerable: true, get: function () { return schema_2.SchemaParser; } });
120
+ Object.defineProperty(exports, "ManifestValidator", { enumerable: true, get: function () { return schema_2.ManifestValidator; } });
121
+ Object.defineProperty(exports, "ResourceRecommender", { enumerable: true, get: function () { return schema_2.ResourceRecommender; } });
122
+ // Default export
123
+ exports.default = DotAI;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Shared Kubernetes Utilities
3
+ *
4
+ * Common functions for interacting with Kubernetes clusters
5
+ */
6
+ export interface KubectlConfig {
7
+ context?: string;
8
+ namespace?: string;
9
+ kubeconfig?: string;
10
+ timeout?: number;
11
+ }
12
+ /**
13
+ * Execute kubectl command with proper configuration
14
+ */
15
+ export declare function executeKubectl(args: string[], config?: KubectlConfig): Promise<string>;
16
+ /**
17
+ * Build kubectl command string with proper flags
18
+ */
19
+ export declare function buildKubectlCommand(args: string[], config?: KubectlConfig): string;
20
+ export declare class ErrorClassifier {
21
+ static classifyError(error: Error): {
22
+ type: string;
23
+ enhancedMessage: string;
24
+ };
25
+ private static isNetworkError;
26
+ private static isAuthenticationError;
27
+ private static isAuthorizationError;
28
+ private static isAPIAvailabilityError;
29
+ private static isKubeconfigError;
30
+ private static isVersionCompatibilityError;
31
+ private static enhanceNetworkError;
32
+ private static enhanceAuthenticationError;
33
+ private static enhanceAuthorizationError;
34
+ private static enhanceAPIAvailabilityError;
35
+ private static enhanceKubeconfigError;
36
+ private static enhanceVersionCompatibilityError;
37
+ }
38
+ //# sourceMappingURL=kubernetes-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kubernetes-utils.d.ts","sourceRoot":"","sources":["../../src/core/kubernetes-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAsB5F;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,MAAM,CAiBlF;AAGD,qBAAa,eAAe;IAC1B,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE;IA0D7E,OAAO,CAAC,MAAM,CAAC,cAAc;IAI7B,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAIpC,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAInC,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAIrC,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAMhC,OAAO,CAAC,MAAM,CAAC,2BAA2B;IAI1C,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAYlC,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAgBzC,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAYxC,OAAO,CAAC,MAAM,CAAC,2BAA2B;IAQ1C,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAYrC,OAAO,CAAC,MAAM,CAAC,gCAAgC;CAGhD"}
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ /**
3
+ * Shared Kubernetes Utilities
4
+ *
5
+ * Common functions for interacting with Kubernetes clusters
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.ErrorClassifier = void 0;
9
+ exports.executeKubectl = executeKubectl;
10
+ exports.buildKubectlCommand = buildKubectlCommand;
11
+ const child_process_1 = require("child_process");
12
+ const util_1 = require("util");
13
+ const execAsync = (0, util_1.promisify)(child_process_1.exec);
14
+ /**
15
+ * Execute kubectl command with proper configuration
16
+ */
17
+ async function executeKubectl(args, config) {
18
+ const command = buildKubectlCommand(args, config);
19
+ const timeout = config?.timeout || 30000;
20
+ try {
21
+ const { stdout, stderr } = await execAsync(command, {
22
+ timeout,
23
+ maxBuffer: 100 * 1024 * 1024 // 100MB buffer for large clusters with 1000+ CRDs
24
+ });
25
+ if (stderr && !stderr.includes('Warning')) {
26
+ throw new Error(`kubectl command failed: ${stderr}`);
27
+ }
28
+ return stdout.trim();
29
+ }
30
+ catch (error) {
31
+ if (error.code === 'ENOENT') {
32
+ throw new Error('kubectl binary not found. Please install kubectl and ensure it\'s in your PATH.');
33
+ }
34
+ // Use error classification for better error messages
35
+ const classified = ErrorClassifier.classifyError(error);
36
+ throw new Error(classified.enhancedMessage);
37
+ }
38
+ }
39
+ /**
40
+ * Build kubectl command string with proper flags
41
+ */
42
+ function buildKubectlCommand(args, config) {
43
+ let command = 'kubectl';
44
+ if (config?.kubeconfig) {
45
+ command += ` --kubeconfig=${config.kubeconfig}`;
46
+ }
47
+ if (config?.context) {
48
+ command += ` --context=${config.context}`;
49
+ }
50
+ if (config?.namespace) {
51
+ command += ` --namespace=${config.namespace}`;
52
+ }
53
+ command += ` ${args.join(' ')}`;
54
+ return command;
55
+ }
56
+ // Enhanced Error Classification System
57
+ class ErrorClassifier {
58
+ static classifyError(error) {
59
+ const originalMessage = error.message;
60
+ // Connection and Network Errors
61
+ if (this.isNetworkError(originalMessage)) {
62
+ return {
63
+ type: 'network',
64
+ enhancedMessage: this.enhanceNetworkError(originalMessage)
65
+ };
66
+ }
67
+ // Authentication Errors
68
+ if (this.isAuthenticationError(originalMessage)) {
69
+ return {
70
+ type: 'authentication',
71
+ enhancedMessage: this.enhanceAuthenticationError(originalMessage)
72
+ };
73
+ }
74
+ // Authorization/RBAC Errors
75
+ if (this.isAuthorizationError(originalMessage)) {
76
+ return {
77
+ type: 'authorization',
78
+ enhancedMessage: this.enhanceAuthorizationError(originalMessage)
79
+ };
80
+ }
81
+ // API Availability Errors
82
+ if (this.isAPIAvailabilityError(originalMessage)) {
83
+ return {
84
+ type: 'api-availability',
85
+ enhancedMessage: this.enhanceAPIAvailabilityError(originalMessage)
86
+ };
87
+ }
88
+ // Kubeconfig Validation Errors
89
+ if (this.isKubeconfigError(originalMessage)) {
90
+ return {
91
+ type: 'kubeconfig',
92
+ enhancedMessage: this.enhanceKubeconfigError(originalMessage)
93
+ };
94
+ }
95
+ // Version Compatibility Errors
96
+ if (this.isVersionCompatibilityError(originalMessage)) {
97
+ return {
98
+ type: 'version',
99
+ enhancedMessage: this.enhanceVersionCompatibilityError(originalMessage)
100
+ };
101
+ }
102
+ // Default: return original message with basic enhancement
103
+ return {
104
+ type: 'unknown',
105
+ enhancedMessage: `${originalMessage}\n\nTroubleshooting steps:\n- Run 'kubectl cluster-info' to verify cluster connectivity\n- Check your kubeconfig with 'kubectl config view'\n- Verify cluster endpoint accessibility`
106
+ };
107
+ }
108
+ static isNetworkError(message) {
109
+ return /getaddrinfo ENOTFOUND|timeout|ECONNREFUSED|ENOTFOUND|network|unreachable/i.test(message);
110
+ }
111
+ static isAuthenticationError(message) {
112
+ return /unauthorized|invalid bearer token|certificate|auth|authentication/i.test(message);
113
+ }
114
+ static isAuthorizationError(message) {
115
+ return /forbidden|cannot list|cannot get|cannot create|RBAC|permission denied/i.test(message);
116
+ }
117
+ static isAPIAvailabilityError(message) {
118
+ return /server could not find|resource type.*not found|doesn't have a resource type|no matches for kind/i.test(message);
119
+ }
120
+ static isKubeconfigError(message) {
121
+ // Be more specific - don't match "path does not exist" errors which are about manifest files
122
+ return /context.*does not exist|kubeconfig.*not found|invalid.*kubeconfig|config.*not found|no Auth Provider/i.test(message) &&
123
+ !/the path.*does not exist/.test(message);
124
+ }
125
+ static isVersionCompatibilityError(message) {
126
+ return /server version|version.*old|unsupported.*version|api.*version/i.test(message);
127
+ }
128
+ static enhanceNetworkError(message) {
129
+ if (message.includes('getaddrinfo ENOTFOUND')) {
130
+ return `DNS resolution failed: Cannot resolve cluster endpoint hostname.\n\nTroubleshooting steps:\n- Check cluster endpoint in kubeconfig: kubectl config view\n- Verify network connectivity and DNS settings\n- Confirm cluster is running and accessible\n- Check VPN connection if using private cluster\n\nOriginal error: ${message}`;
131
+ }
132
+ if (message.includes('timeout')) {
133
+ return `Connection timeout: Unable to reach cluster within timeout period.\n\nTroubleshooting steps:\n- Check network latency to cluster endpoint\n- Increase timeout value if needed\n- Verify cluster is responsive: kubectl get nodes\n- Check firewall and proxy settings\n\nOriginal error: ${message}`;
134
+ }
135
+ return `Network connectivity issue detected.\n\nTroubleshooting steps:\n- Verify cluster endpoint accessibility\n- Run 'kubectl cluster-info' to test connectivity\n- Check network and firewall settings\n- Confirm cluster is running\n\nOriginal error: ${message}`;
136
+ }
137
+ static enhanceAuthenticationError(message) {
138
+ if (message.includes('invalid bearer token')) {
139
+ return `Token may be expired: Bearer token authentication failed.\n\nTroubleshooting steps:\n- Token may be expired - refresh credentials\n- Check token format in kubeconfig\n- Re-authenticate with cluster: kubectl auth login\n- Verify service account token if applicable\n\nOriginal error: ${message}`;
140
+ }
141
+ if (message.includes('certificate')) {
142
+ return `Certificate authentication failed: Client certificate validation error.\n\nTroubleshooting steps:\n- Verify certificate path in kubeconfig\n- Check certificate expiration date\n- Ensure certificate authority (CA) bundle is correct\n- Re-generate client certificates if needed\n\nOriginal error: ${message}`;
143
+ }
144
+ if (message.includes('no Auth Provider found')) {
145
+ return `Authentication provider not available: Required auth plugin missing.\n\nTroubleshooting steps:\n- Install required authentication plugin (e.g., OIDC)\n- Check kubectl config for auth provider configuration\n- Verify authentication method compatibility\n- Consult cluster administrator for auth setup\n\nOriginal error: ${message}`;
146
+ }
147
+ return `Authentication failed: Invalid or missing credentials.\n\nTroubleshooting steps:\n- Verify credentials in kubeconfig\n- Re-authenticate with cluster\n- Check authentication method configuration\n- Contact cluster administrator if needed\n\nOriginal error: ${message}`;
148
+ }
149
+ static enhanceAuthorizationError(message) {
150
+ if (message.includes('customresourcedefinitions')) {
151
+ return `CRD discovery requires cluster-level permissions: Insufficient RBAC permissions.\n\nTroubleshooting steps:\n- CRD discovery requires admin privileges\n- Request cluster-admin role or CRD read permissions\n- Contact cluster administrator for permission escalation\n- Use 'kubectl auth can-i list customresourcedefinitions' to check permissions\n\nOriginal error: ${message}`;
152
+ }
153
+ if (message.includes('forbidden')) {
154
+ return `Insufficient permissions: RBAC restrictions prevent this operation.\n\nTroubleshooting steps:\n- RBAC role required for resource access\n- Request appropriate permissions from cluster administrator\n- Check current permissions: kubectl auth can-i list <resource>\n- Consider using cluster-admin role for discovery operations\n\nOriginal error: ${message}`;
155
+ }
156
+ return `Permission denied: Insufficient RBAC permissions for cluster access.\n\nTroubleshooting steps:\n- Request appropriate RBAC permissions\n- Check current access: kubectl auth can-i list <resource>\n- Contact cluster administrator for role assignment\n- Verify service account permissions if applicable\n\nOriginal error: ${message}`;
157
+ }
158
+ static enhanceAPIAvailabilityError(message) {
159
+ if (message.includes('apps/v1beta1')) {
160
+ return `API version not supported: Cluster doesn't support requested API version.\n\nTroubleshooting steps:\n- Try different API version (e.g., apps/v1 instead of apps/v1beta1)\n- Check available API versions: kubectl api-versions\n- Verify Kubernetes cluster version compatibility\n- Consult API migration guides for version changes\n\nOriginal error: ${message}`;
161
+ }
162
+ return `API resource not available: Requested resource type not found in cluster.\n\nTroubleshooting steps:\n- Check available resources: kubectl api-resources\n- Verify cluster supports required resource types\n- Check Kubernetes version compatibility\n- Confirm cluster configuration and enabled APIs\n\nOriginal error: ${message}`;
163
+ }
164
+ static enhanceKubeconfigError(message) {
165
+ if (message.includes('context') && message.includes('does not exist')) {
166
+ return `Context not found: Specified context doesn't exist in kubeconfig.\n\nTroubleshooting steps:\n- List available contexts: kubectl config get-contexts\n- Set correct context: kubectl config use-context <context-name>\n- Verify kubeconfig file contains required context\n- Check context name spelling and case sensitivity\n\nOriginal error: ${message}`;
167
+ }
168
+ if (message.includes('not found')) {
169
+ return `Kubeconfig file not found: Cannot locate configuration file.\n\nTroubleshooting steps:\n- Check file path exists and is accessible\n- Verify kubeconfig file permissions\n- Set KUBECONFIG environment variable if needed\n- Create kubeconfig file or copy from cluster administrator\n\nOriginal error: ${message}`;
170
+ }
171
+ return `Invalid kubeconfig format: Configuration file has syntax or format errors.\n\nTroubleshooting steps:\n- Validate YAML syntax in kubeconfig file\n- Check file structure: kubectl config view\n- Restore from backup or re-download from cluster\n- Verify all required sections (clusters, contexts, users)\n\nOriginal error: ${message}`;
172
+ }
173
+ static enhanceVersionCompatibilityError(message) {
174
+ return `Kubernetes version compatibility issue: Version mismatch detected.\n\nTroubleshooting steps:\n- Check cluster and client versions: kubectl version\n- Verify supported Kubernetes versions for this tool\n- Update kubectl client if needed\n- Consult compatibility matrix for version support\n\nOriginal error: ${message}`;
175
+ }
176
+ }
177
+ exports.ErrorClassifier = ErrorClassifier;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Memory System Module
3
+ *
4
+ * Handles learning, context management, and recommendation storage
5
+ */
6
+ export interface SuccessPattern {
7
+ type: string;
8
+ config: any;
9
+ timestamp: Date;
10
+ }
11
+ export interface FailurePattern {
12
+ type: string;
13
+ config: any;
14
+ error: string;
15
+ timestamp: Date;
16
+ }
17
+ export interface Recommendation {
18
+ suggestion: string;
19
+ confidence: number;
20
+ based_on: string[];
21
+ }
22
+ export declare class MemorySystem {
23
+ private storage;
24
+ private successPatterns;
25
+ private failurePatterns;
26
+ private context;
27
+ private initialized;
28
+ initialize(): Promise<void>;
29
+ store(key: string, data: any): Promise<void>;
30
+ retrieve(key: string): Promise<any>;
31
+ learnSuccess(type: string, config: any): Promise<void>;
32
+ learnFailure(type: string, config: any, error: string): Promise<void>;
33
+ getSuccessPatterns(type: string): Promise<SuccessPattern[]>;
34
+ getFailurePatterns(type: string): Promise<FailurePattern[]>;
35
+ getRecommendations(type: string, partialConfig: any): Promise<Recommendation[]>;
36
+ storePattern(type: string, pattern: any): Promise<void>;
37
+ retrievePattern(type: string): Promise<any[]>;
38
+ storeLessons(type: string, lessons: any): Promise<void>;
39
+ private calculateSimilarity;
40
+ setContext(key: string, value: any): Promise<void>;
41
+ getContext(): Promise<Record<string, any>>;
42
+ clearContext(key?: string): Promise<void>;
43
+ isInitialized(): boolean;
44
+ }
45
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/core/memory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;IACZ,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,eAAe,CAA4C;IACnE,OAAO,CAAC,eAAe,CAA4C;IACnE,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,WAAW,CAAkB;IAE/B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3B,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAInC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAYtD,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAarE,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAI3D,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAI3D,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAmB/E,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAKvD,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAK7C,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7D,OAAO,CAAC,mBAAmB;IAYrB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAQ1C,YAAY,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ/C,aAAa,IAAI,OAAO;CAGzB"}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ /**
3
+ * Memory System Module
4
+ *
5
+ * Handles learning, context management, and recommendation storage
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.MemorySystem = void 0;
9
+ class MemorySystem {
10
+ storage = new Map();
11
+ successPatterns = new Map();
12
+ failurePatterns = new Map();
13
+ context = new Map();
14
+ initialized = false;
15
+ async initialize() {
16
+ // Initialize storage (in production, this would connect to persistent storage)
17
+ this.initialized = true;
18
+ }
19
+ async store(key, data) {
20
+ this.storage.set(key, data);
21
+ }
22
+ async retrieve(key) {
23
+ return this.storage.get(key) || null;
24
+ }
25
+ async learnSuccess(type, config) {
26
+ const pattern = {
27
+ type,
28
+ config,
29
+ timestamp: new Date()
30
+ };
31
+ const existing = this.successPatterns.get(type) || [];
32
+ existing.push(pattern);
33
+ this.successPatterns.set(type, existing);
34
+ }
35
+ async learnFailure(type, config, error) {
36
+ const pattern = {
37
+ type,
38
+ config,
39
+ error,
40
+ timestamp: new Date()
41
+ };
42
+ const existing = this.failurePatterns.get(type) || [];
43
+ existing.push(pattern);
44
+ this.failurePatterns.set(type, existing);
45
+ }
46
+ async getSuccessPatterns(type) {
47
+ return this.successPatterns.get(type) || [];
48
+ }
49
+ async getFailurePatterns(type) {
50
+ return this.failurePatterns.get(type) || [];
51
+ }
52
+ async getRecommendations(type, partialConfig) {
53
+ const successPatterns = await this.getSuccessPatterns(type);
54
+ const recommendations = [];
55
+ // Simple recommendation algorithm
56
+ for (const pattern of successPatterns) {
57
+ const similarity = this.calculateSimilarity(partialConfig, pattern.config);
58
+ if (similarity >= 0.5) {
59
+ recommendations.push({
60
+ suggestion: `Consider using configuration similar to successful ${type}`,
61
+ confidence: similarity,
62
+ based_on: [`Success pattern from ${pattern.timestamp.toISOString()}`]
63
+ });
64
+ }
65
+ }
66
+ return recommendations;
67
+ }
68
+ async storePattern(type, pattern) {
69
+ // Store pattern as a success by default
70
+ await this.learnSuccess(type, pattern);
71
+ }
72
+ async retrievePattern(type) {
73
+ const patterns = await this.getSuccessPatterns(type);
74
+ return patterns.map(p => p.config);
75
+ }
76
+ async storeLessons(type, lessons) {
77
+ // Store lessons in the general storage
78
+ await this.store(`lessons-${type}`, lessons);
79
+ }
80
+ calculateSimilarity(config1, config2) {
81
+ // Simple similarity calculation
82
+ const keys1 = Object.keys(config1);
83
+ const keys2 = Object.keys(config2);
84
+ const commonKeys = keys1.filter(key => keys2.includes(key));
85
+ if (keys1.length === 0 && keys2.length === 0)
86
+ return 1;
87
+ if (keys1.length === 0 || keys2.length === 0)
88
+ return 0;
89
+ return commonKeys.length / Math.max(keys1.length, keys2.length);
90
+ }
91
+ async setContext(key, value) {
92
+ this.context.set(key, value);
93
+ }
94
+ async getContext() {
95
+ const result = {};
96
+ for (const [key, value] of this.context.entries()) {
97
+ result[key] = value;
98
+ }
99
+ return result;
100
+ }
101
+ async clearContext(key) {
102
+ if (key) {
103
+ this.context.delete(key);
104
+ }
105
+ else {
106
+ this.context.clear();
107
+ }
108
+ }
109
+ isInitialized() {
110
+ return this.initialized;
111
+ }
112
+ }
113
+ exports.MemorySystem = MemorySystem;