@vfarcic/dot-ai 0.105.0 → 0.106.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.
@@ -5,48 +5,13 @@
5
5
  * Implements AIProvider interface using Vercel AI SDK.
6
6
  * Supports OpenAI and Google Gemini providers through unified interface.
7
7
  */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
- Object.defineProperty(o, "default", { enumerable: true, value: v });
21
- }) : function(o, v) {
22
- o["default"] = v;
23
- });
24
- var __importStar = (this && this.__importStar) || (function () {
25
- var ownKeys = function(o) {
26
- ownKeys = Object.getOwnPropertyNames || function (o) {
27
- var ar = [];
28
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
- return ar;
30
- };
31
- return ownKeys(o);
32
- };
33
- return function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- })();
41
8
  Object.defineProperty(exports, "__esModule", { value: true });
42
9
  exports.VercelProvider = void 0;
43
10
  const ai_1 = require("ai");
44
11
  const openai_1 = require("@ai-sdk/openai");
45
12
  const google_1 = require("@ai-sdk/google");
46
13
  const anthropic_1 = require("@ai-sdk/anthropic");
47
- const fs = __importStar(require("fs"));
48
- const path = __importStar(require("path"));
49
- const crypto = __importStar(require("crypto"));
14
+ const provider_debug_utils_1 = require("./provider-debug-utils");
50
15
  /**
51
16
  * Provider-specific default models
52
17
  */
@@ -118,61 +83,11 @@ class VercelProvider {
118
83
  isInitialized() {
119
84
  return this.modelInstance !== undefined;
120
85
  }
121
- /**
122
- * Create debug directory if it doesn't exist
123
- */
124
- ensureDebugDirectory() {
125
- const debugDir = path.join(process.cwd(), 'tmp', 'debug-ai');
126
- if (!fs.existsSync(debugDir)) {
127
- fs.mkdirSync(debugDir, { recursive: true });
128
- }
129
- return debugDir;
130
- }
131
- /**
132
- * Generate unique identifier for debug files with operation context
133
- */
134
- generateDebugId(operation) {
135
- const timestamp = new Date().toISOString().replace(/[:.]/g, '').split('T');
136
- const dateTime = timestamp[0] + 'T' + timestamp[1].substring(0, 6);
137
- const randomHex = crypto.randomBytes(4).toString('hex');
138
- return `${dateTime}_${randomHex}_${operation}`;
139
- }
140
- /**
141
- * Save AI interaction for debugging when DEBUG_DOT_AI=true
142
- */
143
- debugLogInteraction(debugId, prompt, response, operation = 'ai_call') {
144
- if (!this.debugMode)
145
- return;
146
- try {
147
- const debugDir = this.ensureDebugDirectory();
148
- // Save prompt with descriptive naming
149
- const promptFile = path.join(debugDir, `${debugId}_prompt.md`);
150
- fs.writeFileSync(promptFile, `# AI Prompt - ${operation}\n\nTimestamp: ${new Date().toISOString()}\nProvider: ${this.providerType}\nModel: ${this.model}\nOperation: ${operation}\n\n---\n\n${prompt}`);
151
- // Save response with matching naming
152
- const responseFile = path.join(debugDir, `${debugId}_response.md`);
153
- const responseContent = `# AI Response - ${operation}
154
-
155
- Timestamp: ${new Date().toISOString()}
156
- Provider: ${this.providerType}
157
- Model: ${this.model}
158
- Operation: ${operation}
159
- Input Tokens: ${response.usage.input_tokens}
160
- Output Tokens: ${response.usage.output_tokens}
161
-
162
- ---
163
-
164
- ${response.content}`;
165
- fs.writeFileSync(responseFile, responseContent);
166
- console.log(`🐛 DEBUG: AI interaction logged to tmp/debug-ai/${debugId}_*.md`);
167
- }
168
- catch (error) {
169
- console.warn('Failed to log AI debug interaction:', error);
170
- }
171
- }
172
86
  async sendMessage(message, operation = 'generic') {
173
87
  if (!this.isInitialized()) {
174
88
  throw new Error(`${this.providerType} provider not initialized`);
175
89
  }
90
+ const startTime = Date.now();
176
91
  try {
177
92
  // Use Vercel AI SDK generateText
178
93
  // Note: maxTokens omitted - let SDK/provider use model-specific optimal defaults
@@ -187,10 +102,12 @@ ${response.content}`;
187
102
  output_tokens: result.usage.outputTokens || 0
188
103
  }
189
104
  };
105
+ const durationMs = Date.now() - startTime;
190
106
  // Debug log the interaction if enabled
191
107
  if (this.debugMode) {
192
- const debugId = this.generateDebugId(operation);
193
- this.debugLogInteraction(debugId, message, response, operation);
108
+ const debugId = (0, provider_debug_utils_1.generateDebugId)(operation);
109
+ (0, provider_debug_utils_1.debugLogInteraction)(debugId, message, response, operation, this.getProviderType(), this.model, this.debugMode);
110
+ (0, provider_debug_utils_1.logMetrics)(operation, this.getProviderType(), response.usage, durationMs, this.debugMode);
194
111
  }
195
112
  return response;
196
113
  }
@@ -198,5 +115,38 @@ ${response.content}`;
198
115
  throw new Error(`${this.providerType} API error: ${error}`);
199
116
  }
200
117
  }
118
+ /**
119
+ * Agentic tool loop - NOT IMPLEMENTED for Vercel provider
120
+ *
121
+ * This method is intentionally not implemented because:
122
+ * 1. toolLoop() is currently NOT USED anywhere in the codebase (see PRD #136)
123
+ * 2. JSON-based agentic loops already provide equivalent functionality
124
+ * 3. No current workflows require SDK-managed tool loops
125
+ *
126
+ * If future requirements necessitate toolLoop() for non-Anthropic providers,
127
+ * this would need to be implemented using Vercel AI SDK's tool calling API.
128
+ *
129
+ * See AnthropicProvider.toolLoop() and PRD #136 for implementation reference.
130
+ */
131
+ async toolLoop(_config) {
132
+ if (!this.isInitialized()) {
133
+ throw new Error(`${this.providerType} provider not initialized`);
134
+ }
135
+ throw new Error(`toolLoop() not implemented for ${this.providerType} provider. Use AnthropicProvider for tool-based workflows, or use JSON-based agentic loops (recommended).`);
136
+ }
137
+ /**
138
+ * Single-shot tool calling - NOT IMPLEMENTED for Vercel provider
139
+ *
140
+ * Same reasoning as toolLoop(): not currently needed in codebase.
141
+ * JSON-based approach achieves same functionality without SDK overhead.
142
+ *
143
+ * See AnthropicProvider.sendMessageWithTools() for reference implementation.
144
+ */
145
+ async sendMessageWithTools(_message, _tools, _toolExecutor, _operation = 'tool-call') {
146
+ if (!this.isInitialized()) {
147
+ throw new Error(`${this.providerType} provider not initialized`);
148
+ }
149
+ throw new Error(`sendMessageWithTools() not implemented for ${this.providerType} provider. Use AnthropicProvider for tool-based workflows, or use JSON-based approach (recommended).`);
150
+ }
201
151
  }
202
152
  exports.VercelProvider = VercelProvider;
@@ -1 +1 @@
1
- {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/interfaces/mcp.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AA8CtC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,UAAU,GAAG,WAAW,CAAC;CACxC;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,gBAAgB,CAAa;IACrC,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,UAAU,CAAC,CAAkC;IACrD,OAAO,CAAC,aAAa,CAAC,CAAgC;IACtD,OAAO,CAAC,YAAY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E,KAAK,EAAE,MAAM,EAAE,eAAe;IAsCjD;;OAEG;IACH,OAAO,CAAC,YAAY;IAsBpB;;OAEG;IACH,OAAO,CAAC,aAAa;IA+HrB;;OAEG;IACH,OAAO,CAAC,eAAe;IAqCvB,OAAO,CAAC,iBAAiB;IAInB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAkBd,mBAAmB;YAMnB,kBAAkB;YAiFlB,gBAAgB;IAexB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB3B,OAAO,IAAI,OAAO;CAGnB"}
@@ -19,7 +19,15 @@ const version_1 = require("../tools/version");
19
19
  const test_docs_1 = require("../tools/test-docs");
20
20
  const organizational_data_1 = require("../tools/organizational-data");
21
21
  const remediate_1 = require("../tools/remediate");
22
- const build_platform_1 = require("../tools/build-platform");
22
+ /*
23
+ // DEVELOPER NOTE: Platform Building tool disabled - imports commented out
24
+ import {
25
+ BUILD_PLATFORM_TOOL_NAME,
26
+ BUILD_PLATFORM_TOOL_DESCRIPTION,
27
+ BUILD_PLATFORM_TOOL_INPUT_SCHEMA,
28
+ handleBuildPlatformTool,
29
+ } from '../tools/build-platform';
30
+ */
23
31
  const prompts_1 = require("../tools/prompts");
24
32
  const rest_registry_1 = require("./rest-registry");
25
33
  const rest_api_1 = require("./rest-api");
@@ -117,12 +125,25 @@ class MCPServer {
117
125
  this.logger.info(`Processing ${remediate_1.REMEDIATE_TOOL_NAME} tool request`, { requestId });
118
126
  return await (0, remediate_1.handleRemediateTool)(args);
119
127
  }, 'Troubleshooting', ['remediation', 'troubleshooting', 'kubernetes', 'analysis']);
128
+ /*
129
+ // DEVELOPER NOTE: buildPlatform tool disabled - under active development with incomplete functionality
120
130
  // Register buildPlatform tool
121
- this.registerTool(build_platform_1.BUILD_PLATFORM_TOOL_NAME, build_platform_1.BUILD_PLATFORM_TOOL_DESCRIPTION, build_platform_1.BUILD_PLATFORM_TOOL_INPUT_SCHEMA, async (args) => {
131
+ this.registerTool(
132
+ BUILD_PLATFORM_TOOL_NAME,
133
+ BUILD_PLATFORM_TOOL_DESCRIPTION,
134
+ BUILD_PLATFORM_TOOL_INPUT_SCHEMA,
135
+ async (args: any) => {
122
136
  const requestId = this.generateRequestId();
123
- this.logger.info(`Processing ${build_platform_1.BUILD_PLATFORM_TOOL_NAME} tool request`, { requestId });
124
- return await (0, build_platform_1.handleBuildPlatformTool)(args, this.dotAI, this.logger, requestId);
125
- }, 'Platform', ['platform', 'kubernetes', 'installation', 'infrastructure']);
137
+ this.logger.info(
138
+ `Processing ${BUILD_PLATFORM_TOOL_NAME} tool request`,
139
+ { requestId }
140
+ );
141
+ return await handleBuildPlatformTool(args, this.dotAI, this.logger, requestId);
142
+ },
143
+ 'Platform',
144
+ ['platform', 'kubernetes', 'installation', 'infrastructure']
145
+ );
146
+ */
126
147
  this.logger.info('Registered all tools with McpServer', {
127
148
  tools: [
128
149
  recommend_1.RECOMMEND_TOOL_NAME,
@@ -130,9 +151,9 @@ class MCPServer {
130
151
  test_docs_1.TESTDOCS_TOOL_NAME,
131
152
  organizational_data_1.ORGANIZATIONAL_DATA_TOOL_NAME,
132
153
  remediate_1.REMEDIATE_TOOL_NAME,
133
- build_platform_1.BUILD_PLATFORM_TOOL_NAME,
154
+ // BUILD_PLATFORM_TOOL_NAME, // Disabled - under development
134
155
  ],
135
- totalTools: 6,
156
+ totalTools: 5,
136
157
  });
137
158
  }
138
159
  /**
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Discover Operations Tool
3
+ *
4
+ * Self-contained tool that fetches raw Nu shell script help output.
5
+ * Returns unprocessed data for AI to parse.
6
+ */
7
+ import { AITool, AIProvider } from '../../core/ai-provider.interface';
8
+ import { Logger } from '../../core/error-handling';
9
+ /**
10
+ * Operation interfaces (re-export for tool consumers)
11
+ */
12
+ export interface OperationCommand {
13
+ name: string;
14
+ command: string[];
15
+ }
16
+ export interface Operation {
17
+ name: string;
18
+ description: string;
19
+ operations: OperationCommand[];
20
+ }
21
+ /**
22
+ * Tool schema for getting Nu script help output
23
+ */
24
+ export declare const discoverOperationsTool: AITool;
25
+ /**
26
+ * Execute get_nu_help_output tool
27
+ *
28
+ * Simple data fetcher - returns raw Nu script help output
29
+ */
30
+ export declare function executeDiscoverOperations(input: any, aiProvider: AIProvider, logger: Logger): Promise<{
31
+ success: boolean;
32
+ helpOutput?: string;
33
+ error?: string;
34
+ }>;
35
+ //# sourceMappingURL=discover-operations.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discover-operations.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/platform/discover-operations.tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAGnD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,gBAAgB,EAAE,CAAC;CAChC;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAUpC,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,GAAG,EACV,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAyBpE"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ /**
3
+ * Discover Operations Tool
4
+ *
5
+ * Self-contained tool that fetches raw Nu shell script help output.
6
+ * Returns unprocessed data for AI to parse.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.discoverOperationsTool = void 0;
43
+ exports.executeDiscoverOperations = executeDiscoverOperations;
44
+ const path = __importStar(require("path"));
45
+ const platform_utils_1 = require("../../core/platform-utils");
46
+ /**
47
+ * Tool schema for getting Nu script help output
48
+ */
49
+ exports.discoverOperationsTool = {
50
+ name: "get_nu_help_output",
51
+ description: `Executes 'nu ./dot.nu --help' and returns the raw help output text.
52
+
53
+ Returns the complete help documentation that lists all available platform
54
+ operations with their commands and descriptions.`,
55
+ inputSchema: {
56
+ type: "object",
57
+ properties: {} // No input needed
58
+ }
59
+ };
60
+ /**
61
+ * Execute get_nu_help_output tool
62
+ *
63
+ * Simple data fetcher - returns raw Nu script help output
64
+ */
65
+ async function executeDiscoverOperations(input, aiProvider, logger) {
66
+ try {
67
+ // Execute Nu script help command
68
+ const scriptPath = path.join((0, platform_utils_1.getScriptsDir)(), 'dot.nu');
69
+ const { stdout, stderr } = await (0, platform_utils_1.execAsync)(`nu "${scriptPath}" --help`);
70
+ if (stderr) {
71
+ logger.warn?.('Nu script help command produced stderr', { stderr });
72
+ }
73
+ logger.info?.('Tool fetched Nu help output', {
74
+ length: stdout.length
75
+ });
76
+ return {
77
+ success: true,
78
+ helpOutput: stdout
79
+ };
80
+ }
81
+ catch (error) {
82
+ logger.error?.('Tool failed to get Nu help output', error);
83
+ return {
84
+ success: false,
85
+ error: error instanceof Error ? error.message : String(error)
86
+ };
87
+ }
88
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vfarcic/dot-ai",
3
- "version": "0.105.0",
3
+ "version": "0.106.0",
4
4
  "description": "AI-powered development productivity platform that enhances software development workflows through intelligent automation and AI-driven assistance",
5
5
  "mcpName": "io.github.vfarcic/dot-ai",
6
6
  "main": "dist/index.js",
@@ -2,17 +2,13 @@
2
2
 
3
3
  You are a specialized parser that extracts available operations from Nushell script help output.
4
4
 
5
- ## Input
6
-
7
- Here is the help output from a Nu shell script:
5
+ ## Task
8
6
 
9
- ```text
10
- {helpOutput}
11
- ```
7
+ Parse the help output below and extract all available tools/resources with their operations into a structured JSON array.
12
8
 
13
- ## Task
9
+ ## Help Output
14
10
 
15
- Parse this help output and extract all available tools/resources with their operations into a structured JSON array.
11
+ {helpOutput}
16
12
 
17
13
  ## Rules
18
14