@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.
- package/LICENSE +21 -0
- package/README.md +203 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +51 -0
- package/dist/core/claude.d.ts +42 -0
- package/dist/core/claude.d.ts.map +1 -0
- package/dist/core/claude.js +229 -0
- package/dist/core/deploy-operation.d.ts +38 -0
- package/dist/core/deploy-operation.d.ts.map +1 -0
- package/dist/core/deploy-operation.js +101 -0
- package/dist/core/discovery.d.ts +162 -0
- package/dist/core/discovery.d.ts.map +1 -0
- package/dist/core/discovery.js +758 -0
- package/dist/core/error-handling.d.ts +167 -0
- package/dist/core/error-handling.d.ts.map +1 -0
- package/dist/core/error-handling.js +399 -0
- package/dist/core/index.d.ts +42 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +123 -0
- package/dist/core/kubernetes-utils.d.ts +38 -0
- package/dist/core/kubernetes-utils.d.ts.map +1 -0
- package/dist/core/kubernetes-utils.js +177 -0
- package/dist/core/memory.d.ts +45 -0
- package/dist/core/memory.d.ts.map +1 -0
- package/dist/core/memory.js +113 -0
- package/dist/core/schema.d.ts +187 -0
- package/dist/core/schema.d.ts.map +1 -0
- package/dist/core/schema.js +655 -0
- package/dist/core/session-utils.d.ts +29 -0
- package/dist/core/session-utils.d.ts.map +1 -0
- package/dist/core/session-utils.js +121 -0
- package/dist/core/workflow.d.ts +70 -0
- package/dist/core/workflow.d.ts.map +1 -0
- package/dist/core/workflow.js +161 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/interfaces/cli.d.ts +74 -0
- package/dist/interfaces/cli.d.ts.map +1 -0
- package/dist/interfaces/cli.js +769 -0
- package/dist/interfaces/mcp.d.ts +30 -0
- package/dist/interfaces/mcp.d.ts.map +1 -0
- package/dist/interfaces/mcp.js +105 -0
- package/dist/mcp/server.d.ts +9 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +151 -0
- package/dist/tools/answer-question.d.ts +27 -0
- package/dist/tools/answer-question.d.ts.map +1 -0
- package/dist/tools/answer-question.js +696 -0
- package/dist/tools/choose-solution.d.ts +23 -0
- package/dist/tools/choose-solution.d.ts.map +1 -0
- package/dist/tools/choose-solution.js +171 -0
- package/dist/tools/deploy-manifests.d.ts +25 -0
- package/dist/tools/deploy-manifests.d.ts.map +1 -0
- package/dist/tools/deploy-manifests.js +74 -0
- package/dist/tools/generate-manifests.d.ts +23 -0
- package/dist/tools/generate-manifests.d.ts.map +1 -0
- package/dist/tools/generate-manifests.js +424 -0
- package/dist/tools/index.d.ts +11 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +34 -0
- package/dist/tools/recommend.d.ts +23 -0
- package/dist/tools/recommend.d.ts.map +1 -0
- package/dist/tools/recommend.js +332 -0
- package/package.json +124 -0
- package/prompts/intent-validation.md +65 -0
- package/prompts/manifest-generation.md +79 -0
- package/prompts/question-generation.md +128 -0
- package/prompts/resource-analysis.md +127 -0
- package/prompts/resource-selection.md +55 -0
- package/prompts/resource-solution-ranking.md +77 -0
- package/prompts/solution-enhancement.md +129 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource Schema Parser and Validator
|
|
3
|
+
*
|
|
4
|
+
* Implements comprehensive schema parsing and validation for Kubernetes resources
|
|
5
|
+
* Fetches structured OpenAPI schemas from Kubernetes API server and validates manifests
|
|
6
|
+
*/
|
|
7
|
+
import { ResourceExplanation } from './discovery';
|
|
8
|
+
export interface FieldConstraints {
|
|
9
|
+
minimum?: number;
|
|
10
|
+
maximum?: number;
|
|
11
|
+
minLength?: number;
|
|
12
|
+
maxLength?: number;
|
|
13
|
+
enum?: string[];
|
|
14
|
+
default?: any;
|
|
15
|
+
pattern?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface SchemaField {
|
|
18
|
+
name: string;
|
|
19
|
+
type: string;
|
|
20
|
+
description: string;
|
|
21
|
+
required: boolean;
|
|
22
|
+
default?: any;
|
|
23
|
+
constraints?: FieldConstraints;
|
|
24
|
+
nested: Map<string, SchemaField>;
|
|
25
|
+
}
|
|
26
|
+
export interface ResourceSchema {
|
|
27
|
+
apiVersion: string;
|
|
28
|
+
kind: string;
|
|
29
|
+
group: string;
|
|
30
|
+
version?: string;
|
|
31
|
+
description: string;
|
|
32
|
+
properties: Map<string, SchemaField>;
|
|
33
|
+
required?: string[];
|
|
34
|
+
namespace?: boolean;
|
|
35
|
+
rawExplanation?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface ValidationResult {
|
|
38
|
+
valid: boolean;
|
|
39
|
+
errors: string[];
|
|
40
|
+
warnings: string[];
|
|
41
|
+
}
|
|
42
|
+
export interface ResourceMapping {
|
|
43
|
+
resourceKind: string;
|
|
44
|
+
apiVersion: string;
|
|
45
|
+
group?: string;
|
|
46
|
+
fieldPath: string;
|
|
47
|
+
}
|
|
48
|
+
export interface AnswerSet {
|
|
49
|
+
[questionId: string]: any;
|
|
50
|
+
}
|
|
51
|
+
export interface EnhancedSolution extends ResourceSolution {
|
|
52
|
+
answers: AnswerSet;
|
|
53
|
+
openAnswer: string;
|
|
54
|
+
}
|
|
55
|
+
export interface Question {
|
|
56
|
+
id: string;
|
|
57
|
+
question: string;
|
|
58
|
+
type: 'text' | 'select' | 'multiselect' | 'boolean' | 'number';
|
|
59
|
+
options?: string[];
|
|
60
|
+
placeholder?: string;
|
|
61
|
+
validation?: {
|
|
62
|
+
required?: boolean;
|
|
63
|
+
min?: number;
|
|
64
|
+
max?: number;
|
|
65
|
+
pattern?: string;
|
|
66
|
+
message?: string;
|
|
67
|
+
};
|
|
68
|
+
answer?: any;
|
|
69
|
+
}
|
|
70
|
+
export interface QuestionGroup {
|
|
71
|
+
required: Question[];
|
|
72
|
+
basic: Question[];
|
|
73
|
+
advanced: Question[];
|
|
74
|
+
open: {
|
|
75
|
+
question: string;
|
|
76
|
+
placeholder: string;
|
|
77
|
+
answer?: string;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export interface ResourceSolution {
|
|
81
|
+
type: 'single' | 'combination';
|
|
82
|
+
resources: ResourceSchema[];
|
|
83
|
+
score: number;
|
|
84
|
+
description: string;
|
|
85
|
+
reasons: string[];
|
|
86
|
+
analysis: string;
|
|
87
|
+
questions: QuestionGroup;
|
|
88
|
+
}
|
|
89
|
+
export interface AIRankingConfig {
|
|
90
|
+
claudeApiKey: string;
|
|
91
|
+
}
|
|
92
|
+
export interface DiscoveryFunctions {
|
|
93
|
+
discoverResources: () => Promise<any>;
|
|
94
|
+
explainResource: (resource: string) => Promise<any>;
|
|
95
|
+
}
|
|
96
|
+
export interface ClusterOptions {
|
|
97
|
+
namespaces: string[];
|
|
98
|
+
storageClasses: string[];
|
|
99
|
+
ingressClasses: string[];
|
|
100
|
+
nodeLabels: string[];
|
|
101
|
+
serviceAccounts?: {
|
|
102
|
+
[namespace: string]: string[];
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* SchemaParser converts kubectl explain output to structured ResourceSchema
|
|
107
|
+
*/
|
|
108
|
+
export declare class SchemaParser {
|
|
109
|
+
/**
|
|
110
|
+
* Parse ResourceExplanation from discovery engine into structured schema
|
|
111
|
+
*/
|
|
112
|
+
parseResourceExplanation(explanation: ResourceExplanation): ResourceSchema;
|
|
113
|
+
/**
|
|
114
|
+
* Add nested field to the schema structure
|
|
115
|
+
*/
|
|
116
|
+
private addNestedField;
|
|
117
|
+
/**
|
|
118
|
+
* Normalize field types from kubectl explain output
|
|
119
|
+
*/
|
|
120
|
+
private normalizeType;
|
|
121
|
+
/**
|
|
122
|
+
* Parse field constraints from description text
|
|
123
|
+
*/
|
|
124
|
+
parseFieldConstraints(type: string, description: string): FieldConstraints;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* ManifestValidator validates Kubernetes manifests using kubectl dry-run
|
|
128
|
+
*/
|
|
129
|
+
export declare class ManifestValidator {
|
|
130
|
+
/**
|
|
131
|
+
* Validate a manifest using kubectl dry-run
|
|
132
|
+
* This uses the actual Kubernetes API server validation for accuracy
|
|
133
|
+
*/
|
|
134
|
+
validateManifest(manifestPath: string, config?: {
|
|
135
|
+
kubeconfig?: string;
|
|
136
|
+
dryRunMode?: 'client' | 'server';
|
|
137
|
+
}): Promise<ValidationResult>;
|
|
138
|
+
/**
|
|
139
|
+
* Add best practice warnings
|
|
140
|
+
*/
|
|
141
|
+
private addBestPracticeWarnings;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* ResourceRecommender determines which resources best meet user needs using AI
|
|
145
|
+
*/
|
|
146
|
+
export declare class ResourceRecommender {
|
|
147
|
+
private claudeIntegration;
|
|
148
|
+
private config;
|
|
149
|
+
constructor(config: AIRankingConfig);
|
|
150
|
+
/**
|
|
151
|
+
* Find the best resource solution(s) for user intent using two-phase analysis
|
|
152
|
+
*/
|
|
153
|
+
findBestSolutions(intent: string, discoverResources: () => Promise<any>, explainResource: (resource: string) => Promise<any>): Promise<ResourceSolution[]>;
|
|
154
|
+
/**
|
|
155
|
+
* Phase 1: AI selects promising resource candidates from lightweight list
|
|
156
|
+
*/
|
|
157
|
+
private selectResourceCandidates;
|
|
158
|
+
/**
|
|
159
|
+
* Phase 2: Fetch detailed schemas for selected candidates
|
|
160
|
+
*/
|
|
161
|
+
private fetchDetailedSchemas;
|
|
162
|
+
/**
|
|
163
|
+
* Phase 3: Rank resources with detailed schema information
|
|
164
|
+
*/
|
|
165
|
+
private rankWithDetailedSchemas;
|
|
166
|
+
/**
|
|
167
|
+
* Load and format prompt template from file
|
|
168
|
+
*/
|
|
169
|
+
private loadPromptTemplate;
|
|
170
|
+
/**
|
|
171
|
+
* Parse AI response into solution results
|
|
172
|
+
*/
|
|
173
|
+
private parseAISolutionResponse;
|
|
174
|
+
/**
|
|
175
|
+
* Discover cluster options for dynamic question generation
|
|
176
|
+
*/
|
|
177
|
+
private discoverClusterOptions;
|
|
178
|
+
/**
|
|
179
|
+
* Extract JSON object from AI response with robust parsing
|
|
180
|
+
*/
|
|
181
|
+
private extractJsonFromAIResponse;
|
|
182
|
+
/**
|
|
183
|
+
* Generate contextual questions using AI based on user intent and solution resources
|
|
184
|
+
*/
|
|
185
|
+
private generateQuestionsWithAI;
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/core/schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAOlD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACp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