mcp-adr-analysis-server 2.14.0 → 2.14.2

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.
@@ -1,338 +0,0 @@
1
- /**
2
- * AI Executor Service for OpenRouter.ai Integration
3
- *
4
- * This service handles the execution of prompts using OpenRouter.ai,
5
- * transforming the MCP server from returning prompts to returning actual results.
6
- *
7
- * @deprecated This module is part of the legacy OpenRouter execution path.
8
- * As of CE-MCP Phase 4.4, tools should return OrchestrationDirectives instead
9
- * of using this executor. This module is retained for:
10
- * - Hybrid mode support (CE-MCP with OpenRouter fallback)
11
- *
12
- * For new tools, use the directive-based approach defined in ADR-014.
13
- * @see src/types/ce-mcp.ts for OrchestrationDirective types
14
- * @see docs/adrs/adr-014-ce-mcp-architecture.md
15
- */
16
- import OpenAI from 'openai';
17
- import { loadAIConfig, validateAIConfig, isAIExecutionEnabled, } from '../config/ai-config.js';
18
- /**
19
- * AI Executor Service Class
20
- *
21
- * @description Core service for executing AI prompts through OpenRouter.ai integration.
22
- * Transforms the MCP server from returning prompts to returning actual AI-generated results.
23
- * Includes caching, retry logic, and comprehensive error handling.
24
- *
25
- * @example
26
- * ```typescript
27
- * // Initialize with custom configuration
28
- * const executor = new AIExecutor({
29
- * apiKey: 'your-api-key',
30
- * model: 'anthropic/claude-3-sonnet',
31
- * maxTokens: 4000
32
- * });
33
- *
34
- * // Execute a prompt
35
- * const result = await executor.executePrompt({
36
- * prompt: 'Analyze this ADR...',
37
- * context: { projectPath: '/path/to/project' }
38
- * });
39
- *
40
- * console.log(result.content); // AI-generated analysis
41
- * ```
42
- *
43
- * @example
44
- * ```typescript
45
- * // Use singleton instance
46
- * const executor = getAIExecutor();
47
- * const result = await executor.executePrompt({
48
- * prompt: 'Generate ADR suggestions',
49
- * maxTokens: 2000
50
- * });
51
- * ```
52
- *
53
- * @since 2.0.0
54
- * @category AI
55
- * @category Core
56
- */
57
- export class AIExecutor {
58
- client = null;
59
- config;
60
- cache = new Map();
61
- constructor(config) {
62
- this.config = config || loadAIConfig();
63
- this.initializeClient();
64
- }
65
- /**
66
- * Initialize OpenAI client for OpenRouter
67
- */
68
- initializeClient() {
69
- if (!isAIExecutionEnabled(this.config)) {
70
- // NOTE: All console output goes to stderr to preserve stdout for MCP JSON-RPC
71
- console.error('[AI-Executor] AI execution disabled - running in prompt-only mode');
72
- return;
73
- }
74
- try {
75
- validateAIConfig(this.config);
76
- this.client = new OpenAI({
77
- baseURL: this.config.baseURL,
78
- apiKey: this.config.apiKey,
79
- timeout: this.config.timeout,
80
- maxRetries: this.config.maxRetries,
81
- defaultHeaders: {
82
- 'HTTP-Referer': this.config.siteUrl || '',
83
- 'X-Title': this.config.siteName || '',
84
- },
85
- });
86
- console.error(`[AI-Executor] AI Executor initialized with model: ${this.config.defaultModel}`);
87
- }
88
- catch (error) {
89
- console.error('Failed to initialize AI Executor:', error);
90
- this.client = null;
91
- }
92
- }
93
- /**
94
- * Check if AI execution is available
95
- */
96
- isAvailable() {
97
- // Reload configuration to pick up environment variable changes
98
- this.reloadConfigIfNeeded();
99
- return this.client !== null && isAIExecutionEnabled(this.config);
100
- }
101
- /**
102
- * Reload configuration if environment variables have changed
103
- */
104
- reloadConfigIfNeeded() {
105
- const currentConfig = loadAIConfig();
106
- // Check if key configuration has changed
107
- const configChanged = this.config.apiKey !== currentConfig.apiKey ||
108
- this.config.executionMode !== currentConfig.executionMode ||
109
- this.config.defaultModel !== currentConfig.defaultModel;
110
- if (configChanged) {
111
- console.error('[AI-Executor] AI configuration changed, reinitializing...');
112
- this.config = currentConfig;
113
- this.initializeClient();
114
- }
115
- }
116
- /**
117
- * Execute a prompt and return the AI response
118
- */
119
- async executePrompt(prompt, options = {}) {
120
- // Ensure configuration is up to date before execution
121
- this.reloadConfigIfNeeded();
122
- if (!this.isAvailable()) {
123
- throw this.createError('AI execution not available - check configuration', 'AI_UNAVAILABLE', false);
124
- }
125
- const startTime = Date.now();
126
- const model = options.model || this.config.defaultModel;
127
- const cacheKey = this.generateCacheKey(prompt, model, options);
128
- // Check cache first
129
- if (this.config.cacheEnabled) {
130
- const cached = this.getCachedResult(cacheKey);
131
- if (cached) {
132
- return cached;
133
- }
134
- }
135
- let retryCount = 0;
136
- const maxRetries = this.config.maxRetries;
137
- while (retryCount <= maxRetries) {
138
- try {
139
- const messages = [];
140
- if (options.systemPrompt) {
141
- messages.push({ role: 'system', content: options.systemPrompt });
142
- }
143
- messages.push({ role: 'user', content: prompt });
144
- const completion = await this.client.chat.completions.create({
145
- model,
146
- messages,
147
- temperature: options.temperature ?? this.config.temperature,
148
- max_tokens: options.maxTokens ?? this.config.maxTokens,
149
- });
150
- const result = {
151
- content: completion.choices[0]?.message?.content || '',
152
- model: completion.model,
153
- metadata: {
154
- executionTime: Date.now() - startTime,
155
- cached: false,
156
- retryCount,
157
- timestamp: new Date().toISOString(),
158
- },
159
- };
160
- if (completion.usage) {
161
- result.usage = {
162
- promptTokens: completion.usage.prompt_tokens,
163
- completionTokens: completion.usage.completion_tokens,
164
- totalTokens: completion.usage.total_tokens,
165
- };
166
- }
167
- // Cache the result
168
- if (this.config.cacheEnabled) {
169
- this.setCachedResult(cacheKey, result);
170
- }
171
- return result;
172
- }
173
- catch (error) {
174
- retryCount++;
175
- if (retryCount > maxRetries) {
176
- throw this.createError(`AI execution failed after ${maxRetries} retries: ${error}`, 'AI_EXECUTION_FAILED', false, error);
177
- }
178
- // Wait before retry (exponential backoff)
179
- const delay = Math.min(1000 * Math.pow(2, retryCount - 1), 10000);
180
- await new Promise(resolve => setTimeout(resolve, delay));
181
- }
182
- }
183
- throw this.createError('Unexpected error in AI execution', 'AI_UNEXPECTED_ERROR', false);
184
- }
185
- /**
186
- * Execute a structured prompt that expects JSON response
187
- */
188
- async executeStructuredPrompt(prompt, schema, options = {}) {
189
- const systemPrompt = options.systemPrompt ||
190
- 'You are a helpful assistant that responds with valid JSON. Always return properly formatted JSON that matches the requested schema. Do not wrap the JSON in markdown code blocks.';
191
- const result = await this.executePrompt(prompt, {
192
- ...options,
193
- systemPrompt,
194
- temperature: options.temperature ?? 0.1, // Lower temperature for structured output
195
- });
196
- try {
197
- // Extract JSON from response, handling markdown code blocks
198
- const jsonContent = this.extractJsonFromResponse(result.content);
199
- const data = JSON.parse(jsonContent);
200
- // Basic schema validation if provided
201
- if (schema && typeof schema.parse === 'function') {
202
- schema.parse(data);
203
- }
204
- return { data, raw: result };
205
- }
206
- catch (error) {
207
- throw this.createError(`Failed to parse JSON response: ${error}`, 'AI_JSON_PARSE_ERROR', false, error);
208
- }
209
- }
210
- /**
211
- * Extract JSON content from AI response, handling markdown code blocks
212
- */
213
- extractJsonFromResponse(content) {
214
- // Remove leading/trailing whitespace
215
- content = content.trim();
216
- // Check if content is wrapped in markdown code blocks
217
- const codeBlockMatch = content.match(/^```(?:json)?\s*\n?([\s\S]*?)\n?```$/);
218
- if (codeBlockMatch && codeBlockMatch[1]) {
219
- return codeBlockMatch[1].trim();
220
- }
221
- // Check for inline code blocks
222
- const inlineCodeMatch = content.match(/^`([\s\S]*?)`$/);
223
- if (inlineCodeMatch && inlineCodeMatch[1]) {
224
- return inlineCodeMatch[1].trim();
225
- }
226
- // Try to find JSON object/array in the content
227
- const jsonMatch = content.match(/(\{[\s\S]*\}|\[[\s\S]*\])/);
228
- if (jsonMatch && jsonMatch[1]) {
229
- return jsonMatch[1].trim();
230
- }
231
- // Return as-is if no patterns match
232
- return content;
233
- }
234
- /**
235
- * Generate cache key for a prompt execution
236
- */
237
- generateCacheKey(prompt, model, options) {
238
- const key = JSON.stringify({ prompt, model, options });
239
- return Buffer.from(key).toString('base64').slice(0, 32);
240
- }
241
- /**
242
- * Get cached result if available and not expired
243
- */
244
- getCachedResult(cacheKey) {
245
- const cached = this.cache.get(cacheKey);
246
- if (!cached)
247
- return null;
248
- if (Date.now() > cached.expiry) {
249
- this.cache.delete(cacheKey);
250
- return null;
251
- }
252
- // Mark as cached
253
- const result = { ...cached.result };
254
- result.metadata = { ...result.metadata, cached: true };
255
- return result;
256
- }
257
- /**
258
- * Cache a result
259
- */
260
- setCachedResult(cacheKey, result) {
261
- const expiry = Date.now() + this.config.cacheTTL * 1000;
262
- this.cache.set(cacheKey, { result, expiry });
263
- // Clean up expired entries periodically
264
- if (this.cache.size > 100) {
265
- this.cleanupCache();
266
- }
267
- }
268
- /**
269
- * Clean up expired cache entries
270
- */
271
- cleanupCache() {
272
- const now = Date.now();
273
- for (const [key, value] of this.cache.entries()) {
274
- if (now > value.expiry) {
275
- this.cache.delete(key);
276
- }
277
- }
278
- }
279
- /**
280
- * Create a standardized AI execution error
281
- */
282
- createError(message, code, retryable, originalError) {
283
- const error = new Error(message);
284
- error.code = code;
285
- error.retryable = retryable;
286
- error.originalError = originalError;
287
- return error;
288
- }
289
- /**
290
- * Get current configuration
291
- */
292
- getConfig() {
293
- return { ...this.config };
294
- }
295
- /**
296
- * Update configuration
297
- */
298
- updateConfig(newConfig) {
299
- this.config = { ...this.config, ...newConfig };
300
- this.initializeClient();
301
- }
302
- /**
303
- * Clear cache
304
- */
305
- clearCache() {
306
- this.cache.clear();
307
- }
308
- /**
309
- * Get cache statistics
310
- */
311
- getCacheStats() {
312
- // This is a simplified implementation
313
- return {
314
- size: this.cache.size,
315
- hitRate: 0, // Would need to track hits/misses for accurate calculation
316
- };
317
- }
318
- }
319
- /**
320
- * Global AI executor instance
321
- */
322
- let globalExecutor = null;
323
- /**
324
- * Get or create the global AI executor instance
325
- */
326
- export function getAIExecutor() {
327
- if (!globalExecutor) {
328
- globalExecutor = new AIExecutor();
329
- }
330
- return globalExecutor;
331
- }
332
- /**
333
- * Reset the global AI executor (useful for testing)
334
- */
335
- export function resetAIExecutor() {
336
- globalExecutor = null;
337
- }
338
- //# sourceMappingURL=ai-executor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ai-executor.js","sourceRoot":"","sources":["../../../src/utils/ai-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,MAAM,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AAI,CAAC,gBAAgB,EAAE,CAAC;IAC1B,CAAC;IAED;;OAEG;IACI,UAAU;QACf,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED;;OAEG;IACI,aAAa;QAClB,sCAAsC;QACtC,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;YACrB,OAAO,EAAE,CAAC,EAAE,2DAA2D;SACxE,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,IAAI,cAAc,GAAsB,IAAI,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,cAAc,GAAG,IAAI,UAAU,EAAE,CAAC;IACpC,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,cAAc,GAAG,IAAI,CAAC;AACxB,CAAC"}
@@ -1,116 +0,0 @@
1
- /**
2
- * Prompt Execution Utilities
3
- *
4
- * This module provides utilities for executing prompts with AI when enabled,
5
- * or falling back to returning prompts for external execution.
6
- *
7
- * @deprecated This module contains legacy OpenRouter execution functions.
8
- * As of Phase 4.4 CE-MCP migration, tools should return OrchestrationDirectives
9
- * instead of calling these execution functions. See ADR-014 for details.
10
- *
11
- * Migration guide:
12
- * - Replace executePromptWithFallback() with OrchestrationDirective returns
13
- * - Replace executeADRSuggestionPrompt() with directive-based ADR generation
14
- * - Replace formatMCPResponse() with direct directive returns
15
- *
16
- * These functions remain for backward compatibility during the hybrid transition period.
17
- */
18
- import { AIExecutionResult } from './ai-executor.js';
19
- export interface PromptExecutionOptions {
20
- /** Whether to force prompt-only mode regardless of configuration */
21
- forcePromptOnly?: boolean;
22
- /** Model to use for AI execution */
23
- model?: string;
24
- /** Temperature for AI responses */
25
- temperature?: number;
26
- /** Maximum tokens for AI responses */
27
- maxTokens?: number;
28
- /** System prompt to use */
29
- systemPrompt?: string;
30
- /** Expected response format */
31
- responseFormat?: 'text' | 'json';
32
- /** Schema for JSON validation (if responseFormat is 'json') */
33
- schema?: any;
34
- }
35
- export interface PromptExecutionResult {
36
- /** The result content (either AI response or formatted prompt) */
37
- content: string;
38
- /** Whether the result was generated by AI or is a prompt */
39
- isAIGenerated: boolean;
40
- /** AI execution metadata (if AI was used) */
41
- aiMetadata?: AIExecutionResult['metadata'];
42
- /** Token usage (if AI was used) */
43
- usage?: AIExecutionResult['usage'];
44
- /** Model used (if AI was used) */
45
- model?: string;
46
- }
47
- /**
48
- * Execute a prompt with AI if enabled, otherwise return formatted prompt
49
- *
50
- * @deprecated Use OrchestrationDirective returns instead. This function
51
- * will be removed in a future release. See ADR-014 CE-MCP Architecture.
52
- */
53
- export declare function executePromptWithFallback(prompt: string, instructions: string, options?: PromptExecutionOptions): Promise<PromptExecutionResult>;
54
- /**
55
- * Execute a prompt that expects structured ADR suggestions
56
- *
57
- * @deprecated Use OrchestrationDirective returns instead. See ADR-014.
58
- */
59
- export declare function executeADRSuggestionPrompt(prompt: string, instructions: string, options?: PromptExecutionOptions): Promise<PromptExecutionResult>;
60
- /**
61
- * Execute a prompt that expects to generate actual ADRs
62
- *
63
- * @deprecated Use OrchestrationDirective returns instead. See ADR-014.
64
- */
65
- export declare function executeADRGenerationPrompt(prompt: string, instructions: string, options?: PromptExecutionOptions): Promise<PromptExecutionResult>;
66
- /**
67
- * Execute a prompt for project ecosystem analysis
68
- *
69
- * @deprecated Use OrchestrationDirective returns instead. See ADR-014.
70
- */
71
- export declare function executeEcosystemAnalysisPrompt(prompt: string, instructions: string, options?: PromptExecutionOptions): Promise<PromptExecutionResult>;
72
- /**
73
- * Execute a prompt for research question generation
74
- *
75
- * @deprecated Use OrchestrationDirective returns instead. See ADR-014.
76
- */
77
- export declare function executeResearchPrompt(prompt: string, instructions: string, options?: PromptExecutionOptions): Promise<PromptExecutionResult>;
78
- /**
79
- * Check if AI execution is currently available
80
- */
81
- export declare function isAIExecutionAvailable(): boolean;
82
- /**
83
- * Get AI execution status for debugging
84
- *
85
- * @deprecated Legacy OpenRouter status function. Use isCEMCPEnabled() instead.
86
- */
87
- export declare function getAIExecutionStatus(): {
88
- isEnabled: boolean;
89
- hasApiKey: boolean;
90
- executionMode: string;
91
- model: string;
92
- reason: string | undefined;
93
- };
94
- /**
95
- * Get AI execution status and configuration info
96
- *
97
- * @deprecated Legacy OpenRouter info function. Use isCEMCPEnabled() instead.
98
- */
99
- export declare function getAIExecutionInfo(): {
100
- available: boolean;
101
- mode: 'full' | 'prompt-only';
102
- model?: string;
103
- cacheEnabled?: boolean;
104
- };
105
- /**
106
- * Format execution result for MCP tool response
107
- *
108
- * @deprecated Return OrchestrationDirective directly instead. See ADR-014.
109
- */
110
- export declare function formatMCPResponse(result: PromptExecutionResult): {
111
- content: Array<{
112
- type: 'text';
113
- text: string;
114
- }>;
115
- };
116
- //# sourceMappingURL=prompt-execution.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prompt-execution.d.ts","sourceRoot":"","sources":["../../../src/utils/prompt-execution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAiB,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGpE,MAAM,WAAW,sBAAsB;IACrC,oEAAoE;IACpE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+BAA+B;IAC/B,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,+DAA+D;IAC/D,MAAM,CAAC,EAAE,GAAG,CAAC;CACd;AAED,MAAM,WAAW,qBAAqB;IACpC,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4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