@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,23 @@
1
+ /**
2
+ * Choose Solution Tool - Select a solution and return its questions
3
+ */
4
+ import { z } from 'zod';
5
+ import { DotAI } from '../core/index';
6
+ import { Logger } from '../core/error-handling';
7
+ export declare const CHOOSESOLUTION_TOOL_NAME = "chooseSolution";
8
+ export declare const CHOOSESOLUTION_TOOL_DESCRIPTION = "Select a solution by ID and return its questions for configuration";
9
+ export declare const CHOOSESOLUTION_TOOL_INPUT_SCHEMA: {
10
+ solutionId: z.ZodString;
11
+ };
12
+ /**
13
+ * Direct MCP tool handler for chooseSolution functionality
14
+ */
15
+ export declare function handleChooseSolutionTool(args: {
16
+ solutionId: string;
17
+ }, dotAI: DotAI, logger: Logger, requestId: string): Promise<{
18
+ content: {
19
+ type: 'text';
20
+ text: string;
21
+ }[];
22
+ }>;
23
+ //# sourceMappingURL=choose-solution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choose-solution.d.ts","sourceRoot":"","sources":["../../src/tools/choose-solution.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;AAMhD,eAAO,MAAM,wBAAwB,mBAAmB,CAAC;AACzD,eAAO,MAAM,+BAA+B,uEAAuE,CAAC;AAGpH,eAAO,MAAM,gCAAgC;;CAE5C,CAAC;AAgCF;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,EAC5B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,CAAC,CA4GxD"}
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ /**
3
+ * Choose Solution Tool - Select a solution and return its questions
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.CHOOSESOLUTION_TOOL_INPUT_SCHEMA = exports.CHOOSESOLUTION_TOOL_DESCRIPTION = exports.CHOOSESOLUTION_TOOL_NAME = void 0;
40
+ exports.handleChooseSolutionTool = handleChooseSolutionTool;
41
+ const zod_1 = require("zod");
42
+ const error_handling_1 = require("../core/error-handling");
43
+ const fs = __importStar(require("fs"));
44
+ const path = __importStar(require("path"));
45
+ const session_utils_1 = require("../core/session-utils");
46
+ // Tool metadata for direct MCP registration
47
+ exports.CHOOSESOLUTION_TOOL_NAME = 'chooseSolution';
48
+ exports.CHOOSESOLUTION_TOOL_DESCRIPTION = 'Select a solution by ID and return its questions for configuration';
49
+ // Zod schema for MCP registration
50
+ exports.CHOOSESOLUTION_TOOL_INPUT_SCHEMA = {
51
+ solutionId: zod_1.z.string().regex(/^sol_[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{6}_[a-f0-9]+$/).describe('The solution ID to choose (e.g., sol_2025-07-01T154349_1e1e242592ff)')
52
+ };
53
+ /**
54
+ * Load solution file by ID
55
+ */
56
+ function loadSolutionFile(solutionId, sessionDir) {
57
+ const solutionPath = path.join(sessionDir, `${solutionId}.json`);
58
+ if (!fs.existsSync(solutionPath)) {
59
+ throw new Error(`Solution file not found: ${solutionPath}. Available files: ${fs.readdirSync(sessionDir).filter(f => f.endsWith('.json')).join(', ')}`);
60
+ }
61
+ try {
62
+ const content = fs.readFileSync(solutionPath, 'utf8');
63
+ const solution = JSON.parse(content);
64
+ // Validate solution structure
65
+ if (!solution.solutionId || !solution.questions) {
66
+ throw new Error(`Invalid solution file structure: ${solutionId}. Missing required fields: solutionId or questions`);
67
+ }
68
+ return solution;
69
+ }
70
+ catch (error) {
71
+ if (error instanceof SyntaxError) {
72
+ throw new Error(`Invalid JSON in solution file: ${solutionId}. ${error.message}`);
73
+ }
74
+ throw error;
75
+ }
76
+ }
77
+ /**
78
+ * Direct MCP tool handler for chooseSolution functionality
79
+ */
80
+ async function handleChooseSolutionTool(args, dotAI, logger, requestId) {
81
+ return await error_handling_1.ErrorHandler.withErrorHandling(async () => {
82
+ logger.debug('Handling chooseSolution request', { requestId, solutionId: args?.solutionId });
83
+ // Input validation is handled automatically by MCP SDK with Zod schema
84
+ // args are already validated and typed when we reach this point
85
+ // Get session directory from environment
86
+ let sessionDir;
87
+ try {
88
+ sessionDir = (0, session_utils_1.getAndValidateSessionDirectory)(args, false); // requireWrite=false
89
+ logger.debug('Session directory resolved and validated', { sessionDir });
90
+ }
91
+ catch (error) {
92
+ throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.VALIDATION, error_handling_1.ErrorSeverity.HIGH, error instanceof Error ? error.message : 'Session directory validation failed', {
93
+ operation: 'session_directory_validation',
94
+ component: 'ChooseSolutionTool',
95
+ requestId,
96
+ suggestedActions: [
97
+ 'Ensure session directory exists and is readable',
98
+ 'Check directory permissions',
99
+ 'Verify the directory path is correct',
100
+ 'Verify DOT_AI_SESSION_DIR environment variable is correctly set'
101
+ ]
102
+ });
103
+ }
104
+ // Load solution file
105
+ let solution;
106
+ try {
107
+ solution = loadSolutionFile(args.solutionId, sessionDir);
108
+ logger.debug('Solution file loaded successfully', {
109
+ solutionId: args.solutionId,
110
+ hasQuestions: !!solution.questions,
111
+ questionCategories: {
112
+ required: solution.questions?.required?.length || 0,
113
+ basic: solution.questions?.basic?.length || 0,
114
+ advanced: solution.questions?.advanced?.length || 0,
115
+ hasOpen: !!solution.questions?.open
116
+ }
117
+ });
118
+ }
119
+ catch (error) {
120
+ throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.STORAGE, error_handling_1.ErrorSeverity.HIGH, error instanceof Error ? error.message : 'Failed to load solution file', {
121
+ operation: 'solution_file_load',
122
+ component: 'ChooseSolutionTool',
123
+ requestId,
124
+ input: { solutionId: args.solutionId, sessionDir },
125
+ suggestedActions: [
126
+ 'Check that the solution ID is correct',
127
+ 'Verify the solution file exists in the session directory',
128
+ 'Ensure the solution was created by a recent recommend tool call',
129
+ 'List available solution files in the session directory'
130
+ ]
131
+ });
132
+ }
133
+ // Prepare response with solution details and questions
134
+ const response = {
135
+ status: 'stage_questions',
136
+ solutionId: solution.solutionId,
137
+ currentStage: 'required',
138
+ questions: solution.questions.required || [],
139
+ nextStage: 'basic',
140
+ message: 'Please provide the required configuration for your application.',
141
+ nextAction: 'answerQuestion',
142
+ guidance: 'Answer questions in this stage or skip to proceed to the next stage. Do NOT try to generate manifests yet.',
143
+ timestamp: new Date().toISOString()
144
+ };
145
+ logger.info('Choose solution completed successfully', {
146
+ solutionId: args.solutionId,
147
+ sessionDir,
148
+ questionCategories: {
149
+ required: solution.questions.required?.length || 0,
150
+ basic: solution.questions.basic?.length || 0,
151
+ advanced: solution.questions.advanced?.length || 0,
152
+ hasOpen: !!solution.questions.open
153
+ },
154
+ totalQuestions: (solution.questions.required?.length || 0) +
155
+ (solution.questions.basic?.length || 0) +
156
+ (solution.questions.advanced?.length || 0) +
157
+ (solution.questions.open ? 1 : 0)
158
+ });
159
+ return {
160
+ content: [{
161
+ type: 'text',
162
+ text: JSON.stringify(response, null, 2)
163
+ }]
164
+ };
165
+ }, {
166
+ operation: 'choose_solution',
167
+ component: 'ChooseSolutionTool',
168
+ requestId,
169
+ input: args
170
+ });
171
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Deploy Manifests Tool - Apply Kubernetes manifests with readiness checking
3
+ */
4
+ import { z } from 'zod';
5
+ import { DotAI } from '../core/index';
6
+ import { Logger } from '../core/error-handling';
7
+ export declare const DEPLOYMANIFESTS_TOOL_NAME = "deployManifests";
8
+ export declare const DEPLOYMANIFESTS_TOOL_DESCRIPTION = "Deploy Kubernetes manifests from generated solution with kubectl apply --wait";
9
+ export declare const DEPLOYMANIFESTS_TOOL_INPUT_SCHEMA: {
10
+ solutionId: z.ZodString;
11
+ timeout: z.ZodOptional<z.ZodNumber>;
12
+ };
13
+ /**
14
+ * Direct MCP tool handler for deployManifests functionality
15
+ */
16
+ export declare function handleDeployManifestsTool(args: {
17
+ solutionId: string;
18
+ timeout?: number;
19
+ }, dotAI: DotAI, logger: Logger, requestId: string): Promise<{
20
+ content: {
21
+ type: 'text';
22
+ text: string;
23
+ }[];
24
+ }>;
25
+ //# sourceMappingURL=deploy-manifests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy-manifests.d.ts","sourceRoot":"","sources":["../../src/tools/deploy-manifests.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGhD,eAAO,MAAM,yBAAyB,oBAAoB,CAAC;AAC3D,eAAO,MAAM,gCAAgC,kFAAkF,CAAC;AAGhI,eAAO,MAAM,iCAAiC;;;CAG7C,CAAC;AAGF;;GAEG;AACH,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAC9C,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,CAAC,CA+DxD"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ /**
3
+ * Deploy Manifests Tool - Apply Kubernetes manifests with readiness checking
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DEPLOYMANIFESTS_TOOL_INPUT_SCHEMA = exports.DEPLOYMANIFESTS_TOOL_DESCRIPTION = exports.DEPLOYMANIFESTS_TOOL_NAME = void 0;
7
+ exports.handleDeployManifestsTool = handleDeployManifestsTool;
8
+ const zod_1 = require("zod");
9
+ const error_handling_1 = require("../core/error-handling");
10
+ const deploy_operation_1 = require("../core/deploy-operation");
11
+ // Tool metadata for direct MCP registration
12
+ exports.DEPLOYMANIFESTS_TOOL_NAME = 'deployManifests';
13
+ exports.DEPLOYMANIFESTS_TOOL_DESCRIPTION = 'Deploy Kubernetes manifests from generated solution with kubectl apply --wait';
14
+ // Zod schema for MCP registration
15
+ exports.DEPLOYMANIFESTS_TOOL_INPUT_SCHEMA = {
16
+ solutionId: zod_1.z.string().regex(/^sol_[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{6}_[a-f0-9]+$/).describe('Solution ID to deploy (e.g., sol_2025-07-01T154349_1e1e242592ff)'),
17
+ timeout: zod_1.z.number().min(1).max(600).optional().describe('Deployment timeout in seconds (default: 30)')
18
+ };
19
+ /**
20
+ * Direct MCP tool handler for deployManifests functionality
21
+ */
22
+ async function handleDeployManifestsTool(args, dotAI, logger, requestId) {
23
+ return await error_handling_1.ErrorHandler.withErrorHandling(async () => {
24
+ logger.debug('Handling deployManifests request', {
25
+ requestId,
26
+ solutionId: args?.solutionId,
27
+ timeout: args?.timeout
28
+ });
29
+ // Input validation is handled automatically by MCP SDK with Zod schema
30
+ // args are already validated and typed when we reach this point
31
+ const deployOp = new deploy_operation_1.DeployOperation();
32
+ const deployOptions = {
33
+ solutionId: args.solutionId,
34
+ timeout: args.timeout || 30
35
+ };
36
+ logger.info('Starting deployment operation', {
37
+ solutionId: args.solutionId,
38
+ timeout: deployOptions.timeout,
39
+ requestId
40
+ });
41
+ const result = await deployOp.deploy(deployOptions);
42
+ logger.info('Deployment operation completed', {
43
+ success: result.success,
44
+ solutionId: result.solutionId,
45
+ manifestPath: result.manifestPath,
46
+ readinessTimeout: result.readinessTimeout,
47
+ requestId
48
+ });
49
+ // Prepare response with deployment status
50
+ const response = {
51
+ success: result.success,
52
+ solutionId: result.solutionId,
53
+ manifestPath: result.manifestPath,
54
+ readinessTimeout: result.readinessTimeout,
55
+ message: result.message,
56
+ kubectlOutput: result.kubectlOutput,
57
+ // Additional deployment status info
58
+ deploymentComplete: result.success && !result.readinessTimeout,
59
+ requiresStatusCheck: result.success && result.readinessTimeout,
60
+ timestamp: new Date().toISOString()
61
+ };
62
+ return {
63
+ content: [{
64
+ type: 'text',
65
+ text: JSON.stringify(response, null, 2)
66
+ }]
67
+ };
68
+ }, {
69
+ operation: 'deploy_manifests',
70
+ component: 'DeployManifestsTool',
71
+ requestId,
72
+ input: args
73
+ });
74
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Generate Manifests Tool - AI-driven manifest generation with validation loop
3
+ */
4
+ import { z } from 'zod';
5
+ import { DotAI } from '../core/index';
6
+ import { Logger } from '../core/error-handling';
7
+ export declare const GENERATEMANIFESTS_TOOL_NAME = "generateManifests";
8
+ export declare const GENERATEMANIFESTS_TOOL_DESCRIPTION = "Generate final Kubernetes manifests from fully configured solution (ONLY after completing ALL stages: required, basic, advanced, and open)";
9
+ export declare const GENERATEMANIFESTS_TOOL_INPUT_SCHEMA: {
10
+ solutionId: z.ZodString;
11
+ };
12
+ /**
13
+ * Direct MCP tool handler for generateManifests functionality
14
+ */
15
+ export declare function handleGenerateManifestsTool(args: {
16
+ solutionId: string;
17
+ }, dotAI: DotAI, logger: Logger, requestId: string): Promise<{
18
+ content: {
19
+ type: 'text';
20
+ text: string;
21
+ }[];
22
+ }>;
23
+ //# sourceMappingURL=generate-manifests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-manifests.d.ts","sourceRoot":"","sources":["../../src/tools/generate-manifests.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAQhD,eAAO,MAAM,2BAA2B,sBAAsB,CAAC;AAC/D,eAAO,MAAM,kCAAkC,+IAA+I,CAAC;AAG/L,eAAO,MAAM,mCAAmC;;CAE/C,CAAC;AAiSF;;GAEG;AACH,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,EAC5B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,CAAC,CAqLxD"}