@vfarcic/dot-ai 0.5.1 → 0.6.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 (146) hide show
  1. package/dist/cli.d.ts +3 -0
  2. package/dist/cli.d.ts.map +1 -0
  3. package/{src/cli.ts → dist/cli.js} +19 -26
  4. package/dist/core/claude.d.ts +42 -0
  5. package/dist/core/claude.d.ts.map +1 -0
  6. package/dist/core/claude.js +229 -0
  7. package/dist/core/deploy-operation.d.ts +38 -0
  8. package/dist/core/deploy-operation.d.ts.map +1 -0
  9. package/dist/core/deploy-operation.js +101 -0
  10. package/dist/core/discovery.d.ts +162 -0
  11. package/dist/core/discovery.d.ts.map +1 -0
  12. package/dist/core/discovery.js +758 -0
  13. package/dist/core/error-handling.d.ts +167 -0
  14. package/dist/core/error-handling.d.ts.map +1 -0
  15. package/dist/core/error-handling.js +399 -0
  16. package/dist/core/index.d.ts +42 -0
  17. package/dist/core/index.d.ts.map +1 -0
  18. package/dist/core/index.js +123 -0
  19. package/dist/core/kubernetes-utils.d.ts +38 -0
  20. package/dist/core/kubernetes-utils.d.ts.map +1 -0
  21. package/dist/core/kubernetes-utils.js +177 -0
  22. package/dist/core/memory.d.ts +45 -0
  23. package/dist/core/memory.d.ts.map +1 -0
  24. package/dist/core/memory.js +113 -0
  25. package/dist/core/schema.d.ts +187 -0
  26. package/dist/core/schema.d.ts.map +1 -0
  27. package/dist/core/schema.js +655 -0
  28. package/dist/core/session-utils.d.ts +29 -0
  29. package/dist/core/session-utils.d.ts.map +1 -0
  30. package/dist/core/session-utils.js +121 -0
  31. package/dist/core/workflow.d.ts +70 -0
  32. package/dist/core/workflow.d.ts.map +1 -0
  33. package/dist/core/workflow.js +161 -0
  34. package/dist/index.d.ts +15 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +32 -0
  37. package/dist/interfaces/cli.d.ts +74 -0
  38. package/dist/interfaces/cli.d.ts.map +1 -0
  39. package/dist/interfaces/cli.js +769 -0
  40. package/dist/interfaces/mcp.d.ts +30 -0
  41. package/dist/interfaces/mcp.d.ts.map +1 -0
  42. package/dist/interfaces/mcp.js +105 -0
  43. package/dist/mcp/server.d.ts +9 -0
  44. package/dist/mcp/server.d.ts.map +1 -0
  45. package/dist/mcp/server.js +151 -0
  46. package/dist/tools/answer-question.d.ts +27 -0
  47. package/dist/tools/answer-question.d.ts.map +1 -0
  48. package/dist/tools/answer-question.js +696 -0
  49. package/dist/tools/choose-solution.d.ts +23 -0
  50. package/dist/tools/choose-solution.d.ts.map +1 -0
  51. package/dist/tools/choose-solution.js +171 -0
  52. package/dist/tools/deploy-manifests.d.ts +25 -0
  53. package/dist/tools/deploy-manifests.d.ts.map +1 -0
  54. package/dist/tools/deploy-manifests.js +74 -0
  55. package/dist/tools/generate-manifests.d.ts +23 -0
  56. package/dist/tools/generate-manifests.d.ts.map +1 -0
  57. package/dist/tools/generate-manifests.js +424 -0
  58. package/dist/tools/index.d.ts +11 -0
  59. package/dist/tools/index.d.ts.map +1 -0
  60. package/dist/tools/index.js +34 -0
  61. package/dist/tools/recommend.d.ts +23 -0
  62. package/dist/tools/recommend.d.ts.map +1 -0
  63. package/dist/tools/recommend.js +332 -0
  64. package/package.json +124 -2
  65. package/.claude/commands/context-load.md +0 -11
  66. package/.claude/commands/context-save.md +0 -16
  67. package/.claude/commands/prd-done.md +0 -115
  68. package/.claude/commands/prd-get.md +0 -25
  69. package/.claude/commands/prd-start.md +0 -87
  70. package/.claude/commands/task-done.md +0 -77
  71. package/.claude/commands/tests-reminder.md +0 -32
  72. package/.claude/settings.local.json +0 -20
  73. package/.eslintrc.json +0 -25
  74. package/.github/workflows/ci.yml +0 -170
  75. package/.prettierrc.json +0 -10
  76. package/.teller.yml +0 -8
  77. package/CLAUDE.md +0 -162
  78. package/assets/images/logo.png +0 -0
  79. package/bin/dot-ai.ts +0 -47
  80. package/bin.js +0 -19
  81. package/destroy.sh +0 -45
  82. package/devbox.json +0 -13
  83. package/devbox.lock +0 -225
  84. package/docs/API.md +0 -449
  85. package/docs/CONTEXT.md +0 -49
  86. package/docs/DEVELOPMENT.md +0 -203
  87. package/docs/NEXT_STEPS.md +0 -97
  88. package/docs/STAGE_BASED_API.md +0 -97
  89. package/docs/cli-guide.md +0 -798
  90. package/docs/design.md +0 -750
  91. package/docs/discovery-engine.md +0 -515
  92. package/docs/error-handling.md +0 -429
  93. package/docs/function-registration.md +0 -157
  94. package/docs/mcp-guide.md +0 -416
  95. package/renovate.json +0 -51
  96. package/setup.sh +0 -111
  97. package/src/core/claude.ts +0 -280
  98. package/src/core/deploy-operation.ts +0 -127
  99. package/src/core/discovery.ts +0 -900
  100. package/src/core/error-handling.ts +0 -562
  101. package/src/core/index.ts +0 -143
  102. package/src/core/kubernetes-utils.ts +0 -218
  103. package/src/core/memory.ts +0 -148
  104. package/src/core/schema.ts +0 -830
  105. package/src/core/session-utils.ts +0 -97
  106. package/src/core/workflow.ts +0 -234
  107. package/src/index.ts +0 -18
  108. package/src/interfaces/cli.ts +0 -872
  109. package/src/interfaces/mcp.ts +0 -183
  110. package/src/mcp/server.ts +0 -131
  111. package/src/tools/answer-question.ts +0 -807
  112. package/src/tools/choose-solution.ts +0 -169
  113. package/src/tools/deploy-manifests.ts +0 -94
  114. package/src/tools/generate-manifests.ts +0 -502
  115. package/src/tools/index.ts +0 -41
  116. package/src/tools/recommend.ts +0 -370
  117. package/tests/__mocks__/@kubernetes/client-node.ts +0 -106
  118. package/tests/build-system.test.ts +0 -345
  119. package/tests/configuration.test.ts +0 -226
  120. package/tests/core/deploy-operation.test.ts +0 -38
  121. package/tests/core/discovery.test.ts +0 -1648
  122. package/tests/core/error-handling.test.ts +0 -632
  123. package/tests/core/schema.test.ts +0 -1658
  124. package/tests/core/session-utils.test.ts +0 -245
  125. package/tests/core.test.ts +0 -439
  126. package/tests/fixtures/configmap-no-labels.yaml +0 -8
  127. package/tests/fixtures/crossplane-app-configuration.yaml +0 -6
  128. package/tests/fixtures/crossplane-providers.yaml +0 -45
  129. package/tests/fixtures/crossplane-rbac.yaml +0 -48
  130. package/tests/fixtures/invalid-configmap.yaml +0 -8
  131. package/tests/fixtures/invalid-deployment.yaml +0 -17
  132. package/tests/fixtures/test-deployment.yaml +0 -28
  133. package/tests/fixtures/valid-configmap.yaml +0 -15
  134. package/tests/infrastructure.test.ts +0 -426
  135. package/tests/interfaces/cli.test.ts +0 -1036
  136. package/tests/interfaces/mcp.test.ts +0 -139
  137. package/tests/kubernetes-utils.test.ts +0 -200
  138. package/tests/mcp/server.test.ts +0 -126
  139. package/tests/setup.ts +0 -31
  140. package/tests/tools/answer-question.test.ts +0 -367
  141. package/tests/tools/choose-solution.test.ts +0 -481
  142. package/tests/tools/deploy-manifests.test.ts +0 -185
  143. package/tests/tools/generate-manifests.test.ts +0 -441
  144. package/tests/tools/index.test.ts +0 -111
  145. package/tests/tools/recommend.test.ts +0 -180
  146. package/tsconfig.json +0 -34
@@ -1,97 +0,0 @@
1
- /**
2
- * Session directory utilities for MCP tools
3
- * Provides consistent session directory resolution and validation across all tools
4
- */
5
-
6
- import * as fs from 'fs';
7
- import * as path from 'path';
8
-
9
- /**
10
- * Get session directory from CLI args or environment variable
11
- * CLI parameter takes precedence over environment variable
12
- *
13
- * @param args - Tool arguments that may contain sessionDir
14
- * @returns Resolved session directory path (can be relative or absolute)
15
- */
16
- export function getSessionDirectory(args: any): string {
17
- // For CLI interface, sessionDir is required as parameter
18
- if (args.sessionDir) {
19
- return args.sessionDir;
20
- }
21
-
22
- // For MCP interface, sessionDir comes from environment
23
- const envSessionDir = process.env.DOT_AI_SESSION_DIR;
24
- if (!envSessionDir) {
25
- throw new Error(
26
- 'Session directory must be specified via --session-dir parameter or DOT_AI_SESSION_DIR environment variable'
27
- );
28
- }
29
-
30
- return envSessionDir;
31
- }
32
-
33
- /**
34
- * Validate session directory exists and is accessible
35
- * Works with both relative and absolute paths
36
- *
37
- * @param sessionDir - Session directory path to validate
38
- * @param requireWrite - Whether to test write permissions (default: false)
39
- */
40
- export function validateSessionDirectory(sessionDir: string, requireWrite: boolean = false): void {
41
- try {
42
- // Check if directory exists (resolves relative paths automatically)
43
- if (!fs.existsSync(sessionDir)) {
44
- throw new Error(`Session directory does not exist: ${sessionDir}`);
45
- }
46
-
47
- // Check if it's actually a directory
48
- const stat = fs.statSync(sessionDir);
49
- if (!stat.isDirectory()) {
50
- throw new Error(`Session directory path is not a directory: ${sessionDir}`);
51
- }
52
-
53
- // Test read permissions by attempting to read directory contents
54
- fs.readdirSync(sessionDir);
55
-
56
- // Test write permissions if required
57
- if (requireWrite) {
58
- const testFile = path.join(sessionDir, '.write-test-' + Date.now());
59
- fs.writeFileSync(testFile, 'test');
60
- fs.unlinkSync(testFile);
61
- }
62
-
63
- } catch (error) {
64
- if (error instanceof Error) {
65
- // Re-throw specific error messages
66
- if (error.message.includes('Session directory does not exist') ||
67
- error.message.includes('Session directory path is not a directory')) {
68
- throw error;
69
- }
70
-
71
- // Handle permission errors
72
- if (error.message.includes('EACCES')) {
73
- throw new Error(`Session directory is not accessible: ${sessionDir}. Check permissions.`);
74
- }
75
-
76
- // Handle write permission errors
77
- if (requireWrite) {
78
- throw new Error(`Session directory is not writable: ${sessionDir}. Error: ${error.message}`);
79
- }
80
- }
81
-
82
- throw new Error(`Session directory validation failed: ${sessionDir}. Error: ${error}`);
83
- }
84
- }
85
-
86
- /**
87
- * Get and validate session directory in one call
88
- *
89
- * @param args - Tool arguments that may contain sessionDir
90
- * @param requireWrite - Whether to test write permissions (default: false)
91
- * @returns Validated session directory path
92
- */
93
- export function getAndValidateSessionDirectory(args: any, requireWrite: boolean = false): string {
94
- const sessionDir = getSessionDirectory(args);
95
- validateSessionDirectory(sessionDir, requireWrite);
96
- return sessionDir;
97
- }
@@ -1,234 +0,0 @@
1
- /**
2
- * Workflow Engine Module
3
- *
4
- * Handles workflow creation, execution, and templates
5
- */
6
-
7
- export interface WorkflowSpec {
8
- app?: string;
9
- image?: string;
10
- replicas?: number | string;
11
- [key: string]: any;
12
- }
13
-
14
- export interface WorkflowExecution {
15
- id: string;
16
- status: 'pending' | 'running' | 'completed' | 'failed';
17
- steps: WorkflowStep[];
18
- error?: string;
19
- }
20
-
21
- export interface WorkflowStep {
22
- name: string;
23
- status: 'pending' | 'running' | 'completed' | 'failed';
24
- output?: any;
25
- error?: string;
26
- }
27
-
28
- export interface WorkflowTemplate {
29
- name: string;
30
- description: string;
31
- parameters: TemplateParameter[];
32
- }
33
-
34
- export interface TemplateParameter {
35
- name: string;
36
- type: string;
37
- required: boolean;
38
- description: string;
39
- default?: any;
40
- }
41
-
42
- export interface TemplateParams {
43
- template: string;
44
- parameters: Record<string, any>;
45
- }
46
-
47
- export interface RollbackResult {
48
- success: boolean;
49
- message?: string;
50
- }
51
-
52
- export class WorkflowEngine {
53
- private workflows: Map<string, WorkflowSpec> = new Map();
54
- private executions: Map<string, WorkflowExecution> = new Map();
55
- private templates: WorkflowTemplate[] = [];
56
- private initialized: boolean = false;
57
-
58
- constructor() {
59
- // Initialize templates in constructor for immediate availability
60
- this.initializeTemplates();
61
- }
62
-
63
- private initializeTemplates(): void {
64
- this.templates = [
65
- {
66
- name: 'web-app',
67
- description: 'Deploy a web application with service and ingress',
68
- parameters: [
69
- { name: 'appName', type: 'string', required: true, description: 'Application name' },
70
- { name: 'image', type: 'string', required: true, description: 'Container image' },
71
- { name: 'domain', type: 'string', required: false, description: 'Domain name' },
72
- { name: 'replicas', type: 'number', required: false, description: 'Number of replicas', default: 1 }
73
- ]
74
- },
75
- {
76
- name: 'database',
77
- description: 'Deploy a database with persistent storage',
78
- parameters: [
79
- { name: 'dbName', type: 'string', required: true, description: 'Database name' },
80
- { name: 'dbType', type: 'string', required: true, description: 'Database type (mysql, postgres, etc.)' },
81
- { name: 'storageSize', type: 'string', required: false, description: 'Storage size', default: '10Gi' }
82
- ]
83
- }
84
- ];
85
- }
86
-
87
- async initialize(): Promise<void> {
88
- // Templates are already initialized in constructor
89
- this.initialized = true;
90
- }
91
-
92
- async createDeploymentWorkflow(spec: WorkflowSpec): Promise<string> {
93
- this.validateSpec(spec);
94
-
95
- const workflowId = this.generateId();
96
- this.workflows.set(workflowId, spec);
97
-
98
- return workflowId;
99
- }
100
-
101
- private validateSpec(spec: WorkflowSpec): void {
102
- if (typeof spec.replicas === 'string' && spec.replicas === 'invalid') {
103
- throw new Error('Invalid workflow specification: Invalid replicas value');
104
- }
105
-
106
- // Add more validation as needed
107
- if (!spec.app && !spec.image) {
108
- throw new Error('Invalid workflow specification: Missing required fields');
109
- }
110
- }
111
-
112
- async execute(workflowId: string): Promise<WorkflowExecution> {
113
- const spec = this.workflows.get(workflowId);
114
- if (!spec) {
115
- throw new Error(`Workflow ${workflowId} not found`);
116
- }
117
-
118
- const executionId = this.generateId();
119
- const execution: WorkflowExecution = {
120
- id: executionId,
121
- status: 'running',
122
- steps: []
123
- };
124
-
125
- try {
126
- // Simulate workflow execution
127
- await this.executeSteps(execution, spec);
128
- execution.status = 'completed';
129
- } catch (error) {
130
- execution.status = 'failed';
131
- execution.error = error instanceof Error ? error.message : 'Unknown error';
132
- }
133
-
134
- this.executions.set(executionId, execution);
135
- return execution;
136
- }
137
-
138
- private async executeSteps(execution: WorkflowExecution, spec: WorkflowSpec): Promise<void> {
139
- const steps = this.generateSteps(spec);
140
-
141
- for (const step of steps) {
142
- execution.steps.push(step);
143
-
144
- // Simulate step execution
145
- if (spec.image === 'invalid:image') {
146
- step.status = 'failed';
147
- step.error = 'Invalid image';
148
- throw new Error('Step failed: Invalid image');
149
- }
150
-
151
- // Simulate successful step
152
- await new Promise(resolve => setTimeout(resolve, 10)); // Small delay
153
- step.status = 'completed';
154
- step.output = `Step ${step.name} completed successfully`;
155
- }
156
- }
157
-
158
- private generateSteps(_spec: WorkflowSpec): WorkflowStep[] {
159
- const steps: WorkflowStep[] = [
160
- { name: 'validate-config', status: 'pending' },
161
- { name: 'create-deployment', status: 'pending' },
162
- { name: 'create-service', status: 'pending' },
163
- { name: 'verify-deployment', status: 'pending' }
164
- ];
165
-
166
- return steps;
167
- }
168
-
169
- async rollback(executionId: string): Promise<RollbackResult> {
170
- const execution = this.executions.get(executionId);
171
- if (!execution) {
172
- return { success: false, message: 'Execution not found' };
173
- }
174
-
175
- // Simulate rollback logic
176
- return { success: true, message: 'Rollback completed successfully' };
177
- }
178
-
179
- async getAvailableTemplates(): Promise<WorkflowTemplate[]> {
180
- return [...this.templates];
181
- }
182
-
183
- async createFromTemplate(params: TemplateParams): Promise<string> {
184
- const template = this.templates.find(t => t.name === params.template);
185
- if (!template) {
186
- throw new Error(`Template ${params.template} not found`);
187
- }
188
-
189
- // Validate required parameters
190
- for (const param of template.parameters) {
191
- if (param.required && !params.parameters[param.name]) {
192
- throw new Error(`Required parameter ${param.name} is missing`);
193
- }
194
- }
195
-
196
- // Convert template parameters to workflow spec
197
- const spec: WorkflowSpec = { ...params.parameters };
198
-
199
- return this.createDeploymentWorkflow(spec);
200
- }
201
-
202
- private generateId(): string {
203
- return `wf-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
204
- }
205
-
206
- async initializeWorkflow(config: { appName: string; requirements?: string }): Promise<string> {
207
- const workflowId = this.generateId();
208
- const spec: WorkflowSpec = {
209
- app: config.appName,
210
- requirements: config.requirements
211
- };
212
-
213
- this.workflows.set(workflowId, spec);
214
- return workflowId;
215
- }
216
-
217
- async transitionTo(state: string): Promise<string> {
218
- // For now, just return the state as the workflow doesn't have explicit states
219
- return state;
220
- }
221
-
222
- async executePhase(): Promise<any> {
223
- // Return phase execution result
224
- return { phase: 'execution', status: 'completed' };
225
- }
226
-
227
- getCurrentPhase(): string {
228
- return 'default';
229
- }
230
-
231
- isInitialized(): boolean {
232
- return this.initialized;
233
- }
234
- }
package/src/index.ts DELETED
@@ -1,18 +0,0 @@
1
- /**
2
- * DevOps AI Toolkit Main Entry Point
3
- *
4
- * Universal Kubernetes application deployment agent with dual CLI/MCP interfaces
5
- */
6
-
7
- export * from './core';
8
- export * from './interfaces/cli';
9
-
10
- // Version information
11
- export const version = '0.1.0';
12
- export const name = 'dot-ai';
13
-
14
- // Default export for convenience
15
- export default {
16
- version,
17
- name,
18
- };