mcp-adr-analysis-server 1.1.0 → 2.0.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.
- package/README.md +367 -150
- package/dist/src/config/ai-config.d.ts +81 -0
- package/dist/src/config/ai-config.d.ts.map +1 -0
- package/dist/src/config/ai-config.js +134 -0
- package/dist/src/config/ai-config.js.map +1 -0
- package/dist/src/index.d.ts +97 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2430 -186
- package/dist/src/index.js.map +1 -1
- package/dist/src/prompts/adr-suggestion-prompts.d.ts +2 -2
- package/dist/src/prompts/adr-suggestion-prompts.d.ts.map +1 -1
- package/dist/src/prompts/adr-suggestion-prompts.js +25 -17
- package/dist/src/prompts/adr-suggestion-prompts.js.map +1 -1
- package/dist/src/prompts/analysis-prompts.js +1 -1
- package/dist/src/prompts/analysis-prompts.js.map +1 -1
- package/dist/src/resources/index.d.ts +1 -1
- package/dist/src/resources/index.d.ts.map +1 -1
- package/dist/src/resources/index.js +52 -44
- package/dist/src/resources/index.js.map +1 -1
- package/dist/src/templates/domain-knowledge-templates.d.ts +36 -0
- package/dist/src/templates/domain-knowledge-templates.d.ts.map +1 -0
- package/dist/src/templates/domain-knowledge-templates.js +376 -0
- package/dist/src/templates/domain-knowledge-templates.js.map +1 -0
- package/dist/src/tools/adr-suggestion-tool.d.ts +8 -3
- package/dist/src/tools/adr-suggestion-tool.d.ts.map +1 -1
- package/dist/src/tools/adr-suggestion-tool.js +561 -172
- package/dist/src/tools/adr-suggestion-tool.js.map +1 -1
- package/dist/src/tools/content-masking-tool.d.ts.map +1 -1
- package/dist/src/tools/content-masking-tool.js +168 -22
- package/dist/src/tools/content-masking-tool.js.map +1 -1
- package/dist/src/tools/deployment-analysis-tool.d.ts.map +1 -1
- package/dist/src/tools/deployment-analysis-tool.js +64 -27
- package/dist/src/tools/deployment-analysis-tool.js.map +1 -1
- package/dist/src/tools/environment-analysis-tool.d.ts.map +1 -1
- package/dist/src/tools/environment-analysis-tool.js +65 -29
- package/dist/src/tools/environment-analysis-tool.js.map +1 -1
- package/dist/src/tools/research-question-tool.d.ts.map +1 -1
- package/dist/src/tools/research-question-tool.js +150 -49
- package/dist/src/tools/research-question-tool.js.map +1 -1
- package/dist/src/tools/rule-generation-tool.d.ts.map +1 -1
- package/dist/src/tools/rule-generation-tool.js +328 -143
- package/dist/src/tools/rule-generation-tool.js.map +1 -1
- package/dist/src/types/ape-framework.d.ts +566 -0
- package/dist/src/types/ape-framework.d.ts.map +1 -0
- package/dist/src/types/ape-framework.js +98 -0
- package/dist/src/types/ape-framework.js.map +1 -0
- package/dist/src/types/index.d.ts +96 -93
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/knowledge-generation.d.ts +671 -0
- package/dist/src/types/knowledge-generation.d.ts.map +1 -0
- package/dist/src/types/knowledge-generation.js +107 -0
- package/dist/src/types/knowledge-generation.js.map +1 -0
- package/dist/src/types/reflexion-framework.d.ts +652 -0
- package/dist/src/types/reflexion-framework.d.ts.map +1 -0
- package/dist/src/types/reflexion-framework.js +85 -0
- package/dist/src/types/reflexion-framework.js.map +1 -0
- package/dist/src/utils/adr-suggestions.d.ts +1 -1
- package/dist/src/utils/adr-suggestions.d.ts.map +1 -1
- package/dist/src/utils/adr-suggestions.js +8 -50
- package/dist/src/utils/adr-suggestions.js.map +1 -1
- package/dist/src/utils/ai-executor.d.ts +125 -0
- package/dist/src/utils/ai-executor.d.ts.map +1 -0
- package/dist/src/utils/ai-executor.js +292 -0
- package/dist/src/utils/ai-executor.js.map +1 -0
- package/dist/src/utils/automatic-prompt-engineering.d.ts +72 -0
- package/dist/src/utils/automatic-prompt-engineering.d.ts.map +1 -0
- package/dist/src/utils/automatic-prompt-engineering.js +820 -0
- package/dist/src/utils/automatic-prompt-engineering.js.map +1 -0
- package/dist/src/utils/cache.d.ts +54 -22
- package/dist/src/utils/cache.d.ts.map +1 -1
- package/dist/src/utils/cache.js +1234 -143
- package/dist/src/utils/cache.js.map +1 -1
- package/dist/src/utils/config.d.ts +2 -2
- package/dist/src/utils/config.js +3 -3
- package/dist/src/utils/config.js.map +1 -1
- package/dist/src/utils/deployment-analysis.d.ts.map +1 -1
- package/dist/src/utils/deployment-analysis.js +57 -38
- package/dist/src/utils/deployment-analysis.js.map +1 -1
- package/dist/src/utils/environment-analysis.d.ts.map +1 -1
- package/dist/src/utils/environment-analysis.js +113 -100
- package/dist/src/utils/environment-analysis.js.map +1 -1
- package/dist/src/utils/file-system.d.ts +42 -13
- package/dist/src/utils/file-system.d.ts.map +1 -1
- package/dist/src/utils/file-system.js +795 -89
- package/dist/src/utils/file-system.js.map +1 -1
- package/dist/src/utils/index.d.ts +9 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/index.js +13 -0
- package/dist/src/utils/index.js.map +1 -0
- package/dist/src/utils/knowledge-generation.d.ts +79 -0
- package/dist/src/utils/knowledge-generation.d.ts.map +1 -0
- package/dist/src/utils/knowledge-generation.js +646 -0
- package/dist/src/utils/knowledge-generation.js.map +1 -0
- package/dist/src/utils/output-masking.d.ts.map +1 -1
- package/dist/src/utils/output-masking.js +2 -1
- package/dist/src/utils/output-masking.js.map +1 -1
- package/dist/src/utils/prompt-composition.d.ts +234 -0
- package/dist/src/utils/prompt-composition.d.ts.map +1 -0
- package/dist/src/utils/prompt-composition.js +379 -0
- package/dist/src/utils/prompt-composition.js.map +1 -0
- package/dist/src/utils/prompt-execution.d.ts +88 -0
- package/dist/src/utils/prompt-execution.d.ts.map +1 -0
- package/dist/src/utils/prompt-execution.js +227 -0
- package/dist/src/utils/prompt-execution.js.map +1 -0
- package/dist/src/utils/reflexion.d.ts +92 -0
- package/dist/src/utils/reflexion.d.ts.map +1 -0
- package/dist/src/utils/reflexion.js +1100 -0
- package/dist/src/utils/reflexion.js.map +1 -0
- package/dist/src/utils/research-integration.d.ts.map +1 -1
- package/dist/src/utils/research-integration.js +156 -100
- package/dist/src/utils/research-integration.js.map +1 -1
- package/dist/src/utils/research-questions.d.ts.map +1 -1
- package/dist/src/utils/research-questions.js +85 -24
- package/dist/src/utils/research-questions.js.map +1 -1
- package/dist/src/utils/rule-generation.d.ts.map +1 -1
- package/dist/src/utils/rule-generation.js +92 -108
- package/dist/src/utils/rule-generation.js.map +1 -1
- package/package.json +9 -3
package/dist/src/index.js
CHANGED
|
@@ -23,7 +23,7 @@ const SERVER_INFO = {
|
|
|
23
23
|
/**
|
|
24
24
|
* Main server class
|
|
25
25
|
*/
|
|
26
|
-
class McpAdrAnalysisServer {
|
|
26
|
+
export class McpAdrAnalysisServer {
|
|
27
27
|
server;
|
|
28
28
|
maskingConfig;
|
|
29
29
|
config;
|
|
@@ -75,7 +75,7 @@ class McpAdrAnalysisServer {
|
|
|
75
75
|
tools: [
|
|
76
76
|
{
|
|
77
77
|
name: 'analyze_project_ecosystem',
|
|
78
|
-
description: '
|
|
78
|
+
description: 'Comprehensive recursive project ecosystem analysis with advanced prompting techniques (Knowledge Generation + Reflexion)',
|
|
79
79
|
inputSchema: {
|
|
80
80
|
type: 'object',
|
|
81
81
|
properties: {
|
|
@@ -87,6 +87,48 @@ class McpAdrAnalysisServer {
|
|
|
87
87
|
type: 'array',
|
|
88
88
|
items: { type: 'string' },
|
|
89
89
|
description: 'File patterns to include in analysis'
|
|
90
|
+
},
|
|
91
|
+
enhancedMode: {
|
|
92
|
+
type: 'boolean',
|
|
93
|
+
description: 'Enable advanced prompting features (Knowledge Generation + Reflexion)',
|
|
94
|
+
default: true
|
|
95
|
+
},
|
|
96
|
+
knowledgeEnhancement: {
|
|
97
|
+
type: 'boolean',
|
|
98
|
+
description: 'Enable Knowledge Generation for technology-specific insights',
|
|
99
|
+
default: true
|
|
100
|
+
},
|
|
101
|
+
learningEnabled: {
|
|
102
|
+
type: 'boolean',
|
|
103
|
+
description: 'Enable Reflexion learning from past analysis outcomes',
|
|
104
|
+
default: true
|
|
105
|
+
},
|
|
106
|
+
technologyFocus: {
|
|
107
|
+
type: 'array',
|
|
108
|
+
items: { type: 'string' },
|
|
109
|
+
description: 'Specific technologies to focus analysis on (auto-detected if not provided)'
|
|
110
|
+
},
|
|
111
|
+
analysisDepth: {
|
|
112
|
+
type: 'string',
|
|
113
|
+
enum: ['basic', 'detailed', 'comprehensive'],
|
|
114
|
+
description: 'Depth of ecosystem analysis',
|
|
115
|
+
default: 'comprehensive'
|
|
116
|
+
},
|
|
117
|
+
includeEnvironment: {
|
|
118
|
+
type: 'boolean',
|
|
119
|
+
description: 'Automatically include comprehensive environment analysis (default: true)',
|
|
120
|
+
default: true
|
|
121
|
+
},
|
|
122
|
+
recursiveDepth: {
|
|
123
|
+
type: 'string',
|
|
124
|
+
description: 'Depth of recursive project analysis',
|
|
125
|
+
enum: ['shallow', 'moderate', 'deep', 'comprehensive'],
|
|
126
|
+
default: 'comprehensive'
|
|
127
|
+
},
|
|
128
|
+
analysisScope: {
|
|
129
|
+
type: 'array',
|
|
130
|
+
items: { type: 'string' },
|
|
131
|
+
description: 'Specific analysis areas to focus on (e.g., ["security", "performance", "architecture", "dependencies"])'
|
|
90
132
|
}
|
|
91
133
|
},
|
|
92
134
|
required: []
|
|
@@ -94,7 +136,7 @@ class McpAdrAnalysisServer {
|
|
|
94
136
|
},
|
|
95
137
|
{
|
|
96
138
|
name: 'get_architectural_context',
|
|
97
|
-
description: 'Get detailed architectural context for specific files or the entire project',
|
|
139
|
+
description: 'Get detailed architectural context for specific files or the entire project, automatically sets up ADR infrastructure if missing, and provides outcome-focused workflow for project success',
|
|
98
140
|
inputSchema: {
|
|
99
141
|
type: 'object',
|
|
100
142
|
properties: {
|
|
@@ -112,7 +154,7 @@ class McpAdrAnalysisServer {
|
|
|
112
154
|
},
|
|
113
155
|
{
|
|
114
156
|
name: 'generate_adrs_from_prd',
|
|
115
|
-
description: 'Generate Architectural Decision Records from a Product Requirements Document',
|
|
157
|
+
description: 'Generate Architectural Decision Records from a Product Requirements Document with advanced prompting techniques (APE + Knowledge Generation)',
|
|
116
158
|
inputSchema: {
|
|
117
159
|
type: 'object',
|
|
118
160
|
properties: {
|
|
@@ -123,6 +165,27 @@ class McpAdrAnalysisServer {
|
|
|
123
165
|
outputDirectory: {
|
|
124
166
|
type: 'string',
|
|
125
167
|
description: 'Directory to output generated ADRs (optional, uses configured ADR_DIRECTORY if not provided)'
|
|
168
|
+
},
|
|
169
|
+
enhancedMode: {
|
|
170
|
+
type: 'boolean',
|
|
171
|
+
description: 'Enable advanced prompting features (APE + Knowledge Generation)',
|
|
172
|
+
default: true
|
|
173
|
+
},
|
|
174
|
+
promptOptimization: {
|
|
175
|
+
type: 'boolean',
|
|
176
|
+
description: 'Enable Automatic Prompt Engineering for optimized ADR generation',
|
|
177
|
+
default: true
|
|
178
|
+
},
|
|
179
|
+
knowledgeEnhancement: {
|
|
180
|
+
type: 'boolean',
|
|
181
|
+
description: 'Enable Knowledge Generation for domain-specific insights',
|
|
182
|
+
default: true
|
|
183
|
+
},
|
|
184
|
+
prdType: {
|
|
185
|
+
type: 'string',
|
|
186
|
+
enum: ['web-application', 'mobile-app', 'microservices', 'data-platform', 'api-service', 'general'],
|
|
187
|
+
description: 'Type of PRD for optimized knowledge generation',
|
|
188
|
+
default: 'general'
|
|
126
189
|
}
|
|
127
190
|
},
|
|
128
191
|
required: ['prdPath']
|
|
@@ -130,7 +193,7 @@ class McpAdrAnalysisServer {
|
|
|
130
193
|
},
|
|
131
194
|
{
|
|
132
195
|
name: 'generate_adr_todo',
|
|
133
|
-
description: 'Generate
|
|
196
|
+
description: 'Generate TDD-focused todo.md from existing ADRs with two-phase approach: test generation and production code',
|
|
134
197
|
inputSchema: {
|
|
135
198
|
type: 'object',
|
|
136
199
|
properties: {
|
|
@@ -143,6 +206,83 @@ class McpAdrAnalysisServer {
|
|
|
143
206
|
enum: ['all', 'pending', 'in_progress'],
|
|
144
207
|
description: 'Scope of tasks to include',
|
|
145
208
|
default: 'all'
|
|
209
|
+
},
|
|
210
|
+
phase: {
|
|
211
|
+
type: 'string',
|
|
212
|
+
enum: ['both', 'test', 'production'],
|
|
213
|
+
description: 'TDD phase: both (default), test (mock test generation), production (implementation after tests)',
|
|
214
|
+
default: 'both'
|
|
215
|
+
},
|
|
216
|
+
linkAdrs: {
|
|
217
|
+
type: 'boolean',
|
|
218
|
+
description: 'Link all ADRs to create comprehensive system test coverage',
|
|
219
|
+
default: true
|
|
220
|
+
},
|
|
221
|
+
includeRules: {
|
|
222
|
+
type: 'boolean',
|
|
223
|
+
description: 'Include architectural rules validation in TDD tasks',
|
|
224
|
+
default: true
|
|
225
|
+
},
|
|
226
|
+
ruleSource: {
|
|
227
|
+
type: 'string',
|
|
228
|
+
enum: ['adrs', 'patterns', 'both'],
|
|
229
|
+
description: 'Source for architectural rules (only used if includeRules is true)',
|
|
230
|
+
default: 'both'
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: 'compare_adr_progress',
|
|
237
|
+
description: 'Compare TODO.md progress against ADRs and current environment to validate implementation status',
|
|
238
|
+
inputSchema: {
|
|
239
|
+
type: 'object',
|
|
240
|
+
properties: {
|
|
241
|
+
todoPath: {
|
|
242
|
+
type: 'string',
|
|
243
|
+
description: 'Path to TODO.md file to analyze',
|
|
244
|
+
default: 'TODO.md'
|
|
245
|
+
},
|
|
246
|
+
adrDirectory: {
|
|
247
|
+
type: 'string',
|
|
248
|
+
description: 'Directory containing ADR files',
|
|
249
|
+
default: 'docs/adrs'
|
|
250
|
+
},
|
|
251
|
+
projectPath: {
|
|
252
|
+
type: 'string',
|
|
253
|
+
description: 'Path to project root for environment analysis',
|
|
254
|
+
default: '.'
|
|
255
|
+
},
|
|
256
|
+
validationType: {
|
|
257
|
+
type: 'string',
|
|
258
|
+
enum: ['full', 'todo-only', 'adr-only', 'environment-only'],
|
|
259
|
+
description: 'Type of validation to perform',
|
|
260
|
+
default: 'full'
|
|
261
|
+
},
|
|
262
|
+
includeFileChecks: {
|
|
263
|
+
type: 'boolean',
|
|
264
|
+
description: 'Include file existence and implementation checks',
|
|
265
|
+
default: true
|
|
266
|
+
},
|
|
267
|
+
includeRuleValidation: {
|
|
268
|
+
type: 'boolean',
|
|
269
|
+
description: 'Include architectural rule compliance validation',
|
|
270
|
+
default: true
|
|
271
|
+
},
|
|
272
|
+
deepCodeAnalysis: {
|
|
273
|
+
type: 'boolean',
|
|
274
|
+
description: 'Perform deep code analysis to distinguish mock from production implementations',
|
|
275
|
+
default: true
|
|
276
|
+
},
|
|
277
|
+
functionalValidation: {
|
|
278
|
+
type: 'boolean',
|
|
279
|
+
description: 'Validate that code actually functions according to ADR goals, not just exists',
|
|
280
|
+
default: true
|
|
281
|
+
},
|
|
282
|
+
strictMode: {
|
|
283
|
+
type: 'boolean',
|
|
284
|
+
description: 'Enable strict validation mode with reality-check mechanisms against overconfident assessments',
|
|
285
|
+
default: true
|
|
146
286
|
}
|
|
147
287
|
}
|
|
148
288
|
}
|
|
@@ -313,7 +453,7 @@ class McpAdrAnalysisServer {
|
|
|
313
453
|
},
|
|
314
454
|
{
|
|
315
455
|
name: 'suggest_adrs',
|
|
316
|
-
description: 'Suggest
|
|
456
|
+
description: 'Suggest architectural decisions with advanced prompting techniques (Knowledge Generation + Reflexion)',
|
|
317
457
|
inputSchema: {
|
|
318
458
|
type: 'object',
|
|
319
459
|
properties: {
|
|
@@ -349,6 +489,21 @@ class McpAdrAnalysisServer {
|
|
|
349
489
|
type: 'array',
|
|
350
490
|
items: { type: 'string' },
|
|
351
491
|
description: 'List of existing ADR titles to avoid duplication'
|
|
492
|
+
},
|
|
493
|
+
enhancedMode: {
|
|
494
|
+
type: 'boolean',
|
|
495
|
+
description: 'Enable advanced prompting features (Knowledge Generation + Reflexion)',
|
|
496
|
+
default: true
|
|
497
|
+
},
|
|
498
|
+
learningEnabled: {
|
|
499
|
+
type: 'boolean',
|
|
500
|
+
description: 'Enable Reflexion learning from past experiences',
|
|
501
|
+
default: true
|
|
502
|
+
},
|
|
503
|
+
knowledgeEnhancement: {
|
|
504
|
+
type: 'boolean',
|
|
505
|
+
description: 'Enable Knowledge Generation for domain-specific insights',
|
|
506
|
+
default: true
|
|
352
507
|
}
|
|
353
508
|
}
|
|
354
509
|
}
|
|
@@ -889,6 +1044,100 @@ class McpAdrAnalysisServer {
|
|
|
889
1044
|
}
|
|
890
1045
|
}
|
|
891
1046
|
}
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
name: 'check_ai_execution_status',
|
|
1050
|
+
description: 'Check AI execution configuration and status for debugging prompt-only mode issues',
|
|
1051
|
+
inputSchema: {
|
|
1052
|
+
type: 'object',
|
|
1053
|
+
properties: {},
|
|
1054
|
+
required: []
|
|
1055
|
+
}
|
|
1056
|
+
},
|
|
1057
|
+
{
|
|
1058
|
+
name: 'get_workflow_guidance',
|
|
1059
|
+
description: 'Get intelligent workflow guidance and tool recommendations based on your goals and project context to achieve expected outcomes efficiently',
|
|
1060
|
+
inputSchema: {
|
|
1061
|
+
type: 'object',
|
|
1062
|
+
properties: {
|
|
1063
|
+
goal: {
|
|
1064
|
+
type: 'string',
|
|
1065
|
+
description: 'What you want to accomplish (e.g., "analyze new project", "document existing decisions", "security audit", "modernize legacy system")'
|
|
1066
|
+
},
|
|
1067
|
+
projectContext: {
|
|
1068
|
+
type: 'string',
|
|
1069
|
+
description: 'Current state of your project (e.g., "new project", "existing project with ADRs", "legacy codebase", "greenfield development")',
|
|
1070
|
+
enum: ['new_project', 'existing_with_adrs', 'existing_without_adrs', 'legacy_codebase', 'greenfield', 'maintenance_mode', 'unknown']
|
|
1071
|
+
},
|
|
1072
|
+
availableAssets: {
|
|
1073
|
+
type: 'array',
|
|
1074
|
+
items: { type: 'string' },
|
|
1075
|
+
description: 'What assets you already have (e.g., ["PRD.md", "existing ADRs", "codebase", "documentation", "test suite"])'
|
|
1076
|
+
},
|
|
1077
|
+
timeframe: {
|
|
1078
|
+
type: 'string',
|
|
1079
|
+
description: 'Available time/effort level',
|
|
1080
|
+
enum: ['quick_analysis', 'thorough_review', 'comprehensive_audit', 'ongoing_process']
|
|
1081
|
+
},
|
|
1082
|
+
primaryConcerns: {
|
|
1083
|
+
type: 'array',
|
|
1084
|
+
items: { type: 'string' },
|
|
1085
|
+
description: 'Main areas of concern (e.g., ["security", "performance", "maintainability", "scalability", "compliance"])'
|
|
1086
|
+
}
|
|
1087
|
+
},
|
|
1088
|
+
required: ['goal', 'projectContext']
|
|
1089
|
+
}
|
|
1090
|
+
},
|
|
1091
|
+
{
|
|
1092
|
+
name: 'get_development_guidance',
|
|
1093
|
+
description: 'Get comprehensive development guidance that translates architectural decisions and workflow recommendations into specific coding tasks, implementation patterns, and development roadmap',
|
|
1094
|
+
inputSchema: {
|
|
1095
|
+
type: 'object',
|
|
1096
|
+
properties: {
|
|
1097
|
+
developmentPhase: {
|
|
1098
|
+
type: 'string',
|
|
1099
|
+
description: 'Current development phase',
|
|
1100
|
+
enum: ['planning', 'setup', 'implementation', 'testing', 'deployment', 'maintenance', 'refactoring']
|
|
1101
|
+
},
|
|
1102
|
+
adrsToImplement: {
|
|
1103
|
+
type: 'array',
|
|
1104
|
+
items: { type: 'string' },
|
|
1105
|
+
description: 'List of ADR titles or file paths that need to be implemented in code'
|
|
1106
|
+
},
|
|
1107
|
+
technologyStack: {
|
|
1108
|
+
type: 'array',
|
|
1109
|
+
items: { type: 'string' },
|
|
1110
|
+
description: 'Current technology stack (e.g., ["TypeScript", "React", "Node.js", "PostgreSQL", "Docker"])'
|
|
1111
|
+
},
|
|
1112
|
+
currentProgress: {
|
|
1113
|
+
type: 'string',
|
|
1114
|
+
description: 'What has already been implemented or current state of development'
|
|
1115
|
+
},
|
|
1116
|
+
teamContext: {
|
|
1117
|
+
type: 'object',
|
|
1118
|
+
properties: {
|
|
1119
|
+
size: {
|
|
1120
|
+
type: 'string',
|
|
1121
|
+
enum: ['solo', 'small_team', 'medium_team', 'large_team']
|
|
1122
|
+
},
|
|
1123
|
+
experienceLevel: {
|
|
1124
|
+
type: 'string',
|
|
1125
|
+
enum: ['junior', 'mixed', 'senior', 'expert']
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
},
|
|
1129
|
+
timeline: {
|
|
1130
|
+
type: 'string',
|
|
1131
|
+
description: 'Development timeline or deadline constraints'
|
|
1132
|
+
},
|
|
1133
|
+
focusAreas: {
|
|
1134
|
+
type: 'array',
|
|
1135
|
+
items: { type: 'string' },
|
|
1136
|
+
description: 'Specific areas to focus on (e.g., ["API design", "database schema", "testing strategy", "deployment pipeline"])'
|
|
1137
|
+
}
|
|
1138
|
+
},
|
|
1139
|
+
required: ['developmentPhase']
|
|
1140
|
+
}
|
|
892
1141
|
}
|
|
893
1142
|
]
|
|
894
1143
|
};
|
|
@@ -911,6 +1160,9 @@ class McpAdrAnalysisServer {
|
|
|
911
1160
|
case 'generate_adr_todo':
|
|
912
1161
|
response = await this.generateAdrTodo(args);
|
|
913
1162
|
break;
|
|
1163
|
+
case 'compare_adr_progress':
|
|
1164
|
+
response = await this.compareAdrProgress(args);
|
|
1165
|
+
break;
|
|
914
1166
|
case 'analyze_content_security':
|
|
915
1167
|
response = await this.analyzeContentSecurity(args);
|
|
916
1168
|
break;
|
|
@@ -968,6 +1220,15 @@ class McpAdrAnalysisServer {
|
|
|
968
1220
|
case 'analyze_deployment_progress':
|
|
969
1221
|
response = await this.analyzeDeploymentProgress(args);
|
|
970
1222
|
break;
|
|
1223
|
+
case 'check_ai_execution_status':
|
|
1224
|
+
response = await this.checkAIExecutionStatus(args);
|
|
1225
|
+
break;
|
|
1226
|
+
case 'get_workflow_guidance':
|
|
1227
|
+
response = await this.getWorkflowGuidance(args);
|
|
1228
|
+
break;
|
|
1229
|
+
case 'get_development_guidance':
|
|
1230
|
+
response = await this.getDevelopmentGuidance(args);
|
|
1231
|
+
break;
|
|
971
1232
|
default:
|
|
972
1233
|
throw new McpAdrError(`Unknown tool: ${name}`, 'UNKNOWN_TOOL');
|
|
973
1234
|
}
|
|
@@ -1073,226 +1334,1983 @@ class McpAdrAnalysisServer {
|
|
|
1073
1334
|
/**
|
|
1074
1335
|
* Tool implementations
|
|
1075
1336
|
*/
|
|
1076
|
-
async
|
|
1077
|
-
// Use configured project path if not provided in args
|
|
1078
|
-
const projectPath = args.projectPath || this.config.projectPath;
|
|
1079
|
-
this.logger.info(`Analyzing project ecosystem at: ${projectPath}`);
|
|
1337
|
+
async checkAIExecutionStatus(_args) {
|
|
1080
1338
|
try {
|
|
1081
|
-
|
|
1082
|
-
const
|
|
1083
|
-
const { generateAnalysisContext, generateComprehensiveAnalysisPrompt } = await import('./prompts/analysis-prompts.js');
|
|
1084
|
-
// Analyze project structure
|
|
1085
|
-
const projectStructure = await analyzeProjectStructure(projectPath);
|
|
1086
|
-
// Read key files for context
|
|
1087
|
-
let packageJsonContent;
|
|
1088
|
-
try {
|
|
1089
|
-
packageJsonContent = await readFileContent(`${projectPath}/package.json`);
|
|
1090
|
-
}
|
|
1091
|
-
catch {
|
|
1092
|
-
// package.json might not exist
|
|
1093
|
-
}
|
|
1094
|
-
// Generate analysis context
|
|
1095
|
-
const analysisContext = generateAnalysisContext(projectStructure);
|
|
1096
|
-
// Generate comprehensive analysis prompt
|
|
1097
|
-
const analysisPrompt = generateComprehensiveAnalysisPrompt(analysisContext, packageJsonContent);
|
|
1339
|
+
const { getAIExecutionStatus } = await import('./utils/prompt-execution.js');
|
|
1340
|
+
const status = getAIExecutionStatus();
|
|
1098
1341
|
return {
|
|
1099
1342
|
content: [
|
|
1100
1343
|
{
|
|
1101
1344
|
type: 'text',
|
|
1102
|
-
text:
|
|
1345
|
+
text: `# AI Execution Status Diagnostic
|
|
1346
|
+
|
|
1347
|
+
## Current Configuration
|
|
1348
|
+
- **AI Execution Enabled**: ${status.isEnabled ? '✅ YES' : '❌ NO'}
|
|
1349
|
+
- **Has API Key**: ${status.hasApiKey ? '✅ YES' : '❌ NO'}
|
|
1350
|
+
- **Execution Mode**: ${status.executionMode}
|
|
1351
|
+
- **AI Model**: ${status.model}
|
|
1352
|
+
|
|
1353
|
+
${status.reason ? `## ⚠️ Issue Detected
|
|
1354
|
+
**Problem**: ${status.reason}
|
|
1355
|
+
|
|
1356
|
+
## Solution
|
|
1357
|
+
${!status.hasApiKey ? `
|
|
1358
|
+
1. Get an OpenRouter API key from https://openrouter.ai/keys
|
|
1359
|
+
2. Add it to your MCP configuration:
|
|
1360
|
+
\`\`\`json
|
|
1361
|
+
{
|
|
1362
|
+
"mcpServers": {
|
|
1363
|
+
"adr-analysis": {
|
|
1364
|
+
"command": "mcp-adr-analysis-server",
|
|
1365
|
+
"env": {
|
|
1366
|
+
"OPENROUTER_API_KEY": "your_api_key_here",
|
|
1367
|
+
"EXECUTION_MODE": "full",
|
|
1368
|
+
"AI_MODEL": "anthropic/claude-3-sonnet"
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
\`\`\`
|
|
1374
|
+
3. Restart your MCP client (Claude Desktop, etc.)
|
|
1375
|
+
` : status.executionMode !== 'full' ? `
|
|
1376
|
+
1. Update your MCP configuration to set EXECUTION_MODE to "full":
|
|
1377
|
+
\`\`\`json
|
|
1378
|
+
{
|
|
1379
|
+
"mcpServers": {
|
|
1380
|
+
"adr-analysis": {
|
|
1381
|
+
"env": {
|
|
1382
|
+
"EXECUTION_MODE": "full"
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
\`\`\`
|
|
1388
|
+
2. Restart your MCP client
|
|
1389
|
+
` : ''}` : `## ✅ Configuration Looks Good!
|
|
1390
|
+
|
|
1391
|
+
AI execution is properly configured. Tools should return actual results instead of prompts.
|
|
1392
|
+
|
|
1393
|
+
If you're still seeing prompts instead of results, try:
|
|
1394
|
+
1. Restart your MCP client
|
|
1395
|
+
2. Check your OpenRouter API key has sufficient credits
|
|
1396
|
+
3. Verify network connectivity to OpenRouter.ai`}
|
|
1397
|
+
|
|
1398
|
+
## Environment Variables Expected
|
|
1399
|
+
- **OPENROUTER_API_KEY**: Your OpenRouter API key
|
|
1400
|
+
- **EXECUTION_MODE**: Set to "full" for AI execution
|
|
1401
|
+
- **AI_MODEL**: AI model to use (optional, defaults to claude-3-sonnet)
|
|
1402
|
+
|
|
1403
|
+
## Testing
|
|
1404
|
+
After fixing the configuration, try calling \`suggest_adrs\` - it should return actual ADR suggestions instead of prompts.
|
|
1405
|
+
`
|
|
1103
1406
|
}
|
|
1104
1407
|
]
|
|
1105
1408
|
};
|
|
1106
1409
|
}
|
|
1107
1410
|
catch (error) {
|
|
1108
|
-
throw new McpAdrError(`Failed to analyze project ecosystem: ${error instanceof Error ? error.message : String(error)}`, 'ANALYSIS_ERROR');
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
async getArchitecturalContext(args) {
|
|
1112
|
-
const { filePath } = args;
|
|
1113
|
-
try {
|
|
1114
|
-
const { analyzeProjectStructure } = await import('./utils/file-system.js');
|
|
1115
|
-
const { generateAnalysisContext, generatePatternDetectionPrompt } = await import('./prompts/analysis-prompts.js');
|
|
1116
|
-
// Determine project path
|
|
1117
|
-
const projectPath = filePath ? filePath.split('/').slice(0, -1).join('/') : process.cwd();
|
|
1118
|
-
// Analyze project structure
|
|
1119
|
-
const projectStructure = await analyzeProjectStructure(projectPath);
|
|
1120
|
-
const analysisContext = generateAnalysisContext(projectStructure);
|
|
1121
|
-
// Generate pattern detection prompt
|
|
1122
|
-
const patternPrompt = generatePatternDetectionPrompt(analysisContext);
|
|
1123
1411
|
return {
|
|
1124
1412
|
content: [
|
|
1125
1413
|
{
|
|
1126
1414
|
type: 'text',
|
|
1127
|
-
text:
|
|
1415
|
+
text: `# AI Execution Status Check Failed
|
|
1416
|
+
|
|
1417
|
+
**Error**: ${error instanceof Error ? error.message : String(error)}
|
|
1418
|
+
|
|
1419
|
+
This diagnostic tool helps identify why tools return prompts instead of actual results.
|
|
1420
|
+
|
|
1421
|
+
## Manual Check
|
|
1422
|
+
Verify these environment variables are set in your MCP configuration:
|
|
1423
|
+
- OPENROUTER_API_KEY
|
|
1424
|
+
- EXECUTION_MODE=full
|
|
1425
|
+
- AI_MODEL (optional)
|
|
1426
|
+
`
|
|
1128
1427
|
}
|
|
1129
1428
|
]
|
|
1130
1429
|
};
|
|
1131
1430
|
}
|
|
1132
|
-
catch (error) {
|
|
1133
|
-
throw new McpAdrError(`Failed to get architectural context: ${error instanceof Error ? error.message : String(error)}`, 'ANALYSIS_ERROR');
|
|
1134
|
-
}
|
|
1135
1431
|
}
|
|
1136
|
-
async
|
|
1137
|
-
const {
|
|
1138
|
-
const outputDirectory = args.outputDirectory || this.config.adrDirectory;
|
|
1139
|
-
this.logger.info(`Generating ADRs from PRD: ${prdPath} to ${outputDirectory}`);
|
|
1432
|
+
async getWorkflowGuidance(args) {
|
|
1433
|
+
const { goal, projectContext, availableAssets = [], timeframe = 'thorough_review', primaryConcerns = [] } = args;
|
|
1140
1434
|
try {
|
|
1141
|
-
const
|
|
1142
|
-
|
|
1143
|
-
if (!(await fileExists(prdPath))) {
|
|
1144
|
-
throw new McpAdrError(`PRD file not found: ${prdPath}`, 'FILE_NOT_FOUND');
|
|
1145
|
-
}
|
|
1146
|
-
// Read PRD content
|
|
1147
|
-
const prdContent = await readFileContent(prdPath);
|
|
1148
|
-
// Generate ADR creation prompt
|
|
1149
|
-
const adrPrompt = `
|
|
1150
|
-
# ADR Generation from PRD Request
|
|
1435
|
+
const workflowPrompt = `
|
|
1436
|
+
# Workflow Guidance & Tool Recommendation System
|
|
1151
1437
|
|
|
1152
|
-
|
|
1438
|
+
## User Context Analysis
|
|
1439
|
+
- **Goal**: ${goal}
|
|
1440
|
+
- **Project Context**: ${projectContext}
|
|
1441
|
+
- **Available Assets**: ${availableAssets.length > 0 ? availableAssets.join(', ') : 'None specified'}
|
|
1442
|
+
- **Timeframe**: ${timeframe}
|
|
1443
|
+
- **Primary Concerns**: ${primaryConcerns.length > 0 ? primaryConcerns.join(', ') : 'General analysis'}
|
|
1153
1444
|
|
|
1154
|
-
##
|
|
1155
|
-
\`\`\`markdown
|
|
1156
|
-
${prdContent}
|
|
1157
|
-
\`\`\`
|
|
1445
|
+
## Available MCP Tools (24 Total)
|
|
1158
1446
|
|
|
1159
|
-
|
|
1447
|
+
### 🎯 **Core Analysis Tools** (AI-Powered ✅)
|
|
1448
|
+
1. **analyze_project_ecosystem** - Comprehensive technology and pattern detection
|
|
1449
|
+
2. **get_architectural_context** - Generate intelligent architectural insights + ADR setup
|
|
1450
|
+
3. **generate_adrs_from_prd** - Convert requirements to structured ADRs
|
|
1451
|
+
4. **analyze_content_security** - Detect sensitive information patterns
|
|
1160
1452
|
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1453
|
+
### 📋 **ADR Management Tools** (AI-Powered ✅)
|
|
1454
|
+
5. **suggest_adrs** - Auto-suggest ADRs from implicit decisions
|
|
1455
|
+
6. **generate_adr_from_decision** - Create ADRs from specific decisions
|
|
1456
|
+
7. **discover_existing_adrs** - Intelligent ADR discovery and analysis
|
|
1457
|
+
8. **generate_adr_todo** - Create actionable task lists from ADRs
|
|
1166
1458
|
|
|
1167
|
-
|
|
1459
|
+
### 🔍 **Research & Documentation Tools** (AI-Powered ✅)
|
|
1460
|
+
9. **generate_research_questions** - Create context-aware research questions
|
|
1461
|
+
10. **incorporate_research** - Integrate research findings into decisions
|
|
1462
|
+
11. **create_research_template** - Generate research documentation templates
|
|
1168
1463
|
|
|
1169
|
-
|
|
1170
|
-
|
|
1464
|
+
### 🛡️ **Security & Compliance Tools** (AI-Powered ✅)
|
|
1465
|
+
12. **generate_content_masking** - Intelligent content masking and protection
|
|
1466
|
+
13. **configure_custom_patterns** - Customize security and masking settings
|
|
1467
|
+
14. **apply_basic_content_masking** - Basic content masking (fallback)
|
|
1468
|
+
15. **validate_content_masking** - Validate masking effectiveness
|
|
1171
1469
|
|
|
1172
|
-
**
|
|
1173
|
-
**
|
|
1470
|
+
### 🏗️ **Rule & Governance Tools** (AI-Powered ✅)
|
|
1471
|
+
16. **generate_rules** - Extract architectural rules from ADRs
|
|
1472
|
+
17. **validate_rules** - Validate code against architectural rules
|
|
1473
|
+
18. **create_rule_set** - Create comprehensive rule management systems
|
|
1174
1474
|
|
|
1175
|
-
|
|
1176
|
-
|
|
1475
|
+
### 🚀 **Deployment & Environment Tools** (AI-Powered ✅)
|
|
1476
|
+
19. **analyze_environment** - Environment analysis and optimization
|
|
1477
|
+
20. **analyze_deployment_progress** - Deployment tracking and verification
|
|
1177
1478
|
|
|
1178
|
-
|
|
1179
|
-
|
|
1479
|
+
### ⚙️ **Utility & Management Tools**
|
|
1480
|
+
21. **manage_cache** - Cache management and optimization
|
|
1481
|
+
22. **configure_output_masking** - Configure global output masking
|
|
1482
|
+
23. **request_action_confirmation** - Interactive user confirmation workflows
|
|
1483
|
+
24. **get_workflow_guidance** - This tool - intelligent workflow advisor
|
|
1180
1484
|
|
|
1181
|
-
##
|
|
1182
|
-
[Describe the positive and negative consequences]
|
|
1485
|
+
## Workflow Recommendation Instructions
|
|
1183
1486
|
|
|
1184
|
-
|
|
1185
|
-
[Optional: Steps to implement this decision]
|
|
1186
|
-
\`\`\`
|
|
1487
|
+
Based on the user's goal, project context, available assets, timeframe, and concerns, provide:
|
|
1187
1488
|
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1489
|
+
### 1. **Recommended Tool Sequence**
|
|
1490
|
+
Provide a step-by-step workflow with:
|
|
1491
|
+
- **Tool Name**: Exact tool to call
|
|
1492
|
+
- **Purpose**: Why this tool is needed
|
|
1493
|
+
- **Expected Outcome**: What it will deliver
|
|
1494
|
+
- **Parameters**: Suggested parameters for the tool call
|
|
1495
|
+
- **Success Criteria**: How to know it worked
|
|
1496
|
+
|
|
1497
|
+
### 2. **Alternative Workflows**
|
|
1498
|
+
Provide 2-3 alternative approaches based on:
|
|
1499
|
+
- Different time constraints
|
|
1500
|
+
- Different priorities
|
|
1501
|
+
- Different starting points
|
|
1502
|
+
|
|
1503
|
+
### 3. **Expected Timeline & Effort**
|
|
1504
|
+
For each recommended workflow:
|
|
1505
|
+
- **Estimated Time**: How long each step takes
|
|
1506
|
+
- **Effort Level**: Low/Medium/High effort required
|
|
1507
|
+
- **Dependencies**: Which steps must be completed first
|
|
1508
|
+
|
|
1509
|
+
### 4. **Success Metrics**
|
|
1510
|
+
Define how to measure success:
|
|
1511
|
+
- **Immediate Indicators**: Quick wins and early signals
|
|
1512
|
+
- **Progress Milestones**: Key checkpoints
|
|
1513
|
+
- **Final Outcomes**: Ultimate success criteria
|
|
1514
|
+
|
|
1515
|
+
### 5. **Common Pitfalls & Tips**
|
|
1516
|
+
- **What to Avoid**: Common mistakes in this workflow
|
|
1517
|
+
- **Pro Tips**: Best practices for maximum effectiveness
|
|
1518
|
+
- **Troubleshooting**: What to do if steps fail
|
|
1519
|
+
|
|
1520
|
+
## Common Workflow Patterns
|
|
1521
|
+
|
|
1522
|
+
### **New Project Setup**
|
|
1523
|
+
1. analyze_project_ecosystem → 2. get_architectural_context → 3. suggest_adrs → 4. generate_adr_from_decision
|
|
1524
|
+
|
|
1525
|
+
### **Existing Project Analysis**
|
|
1526
|
+
1. discover_existing_adrs → 2. get_architectural_context → 3. generate_adr_todo → 4. validate_rules
|
|
1527
|
+
|
|
1528
|
+
### **Security Audit**
|
|
1529
|
+
1. analyze_content_security → 2. generate_content_masking → 3. configure_custom_patterns → 4. validate_content_masking
|
|
1530
|
+
|
|
1531
|
+
### **PRD to Implementation**
|
|
1532
|
+
1. generate_adrs_from_prd → 2. generate_adr_todo → 3. analyze_deployment_progress
|
|
1533
|
+
|
|
1534
|
+
### **Legacy Modernization**
|
|
1535
|
+
1. analyze_project_ecosystem → 2. get_architectural_context → 3. suggest_adrs → 4. generate_rules → 5. validate_rules
|
|
1536
|
+
|
|
1537
|
+
## Output Format
|
|
1538
|
+
|
|
1539
|
+
Provide a comprehensive workflow guide that includes:
|
|
1540
|
+
|
|
1541
|
+
1. **🎯 Recommended Primary Workflow** (step-by-step with tool calls)
|
|
1542
|
+
2. **🔄 Alternative Approaches** (2-3 different paths)
|
|
1543
|
+
3. **⏱️ Timeline & Effort Estimates** (realistic expectations)
|
|
1544
|
+
4. **📊 Success Metrics** (how to measure progress)
|
|
1545
|
+
5. **💡 Pro Tips & Best Practices** (maximize effectiveness)
|
|
1546
|
+
6. **⚠️ Common Pitfalls** (what to avoid)
|
|
1547
|
+
|
|
1548
|
+
Make the guidance **actionable, specific, and outcome-focused** so the user can immediately start executing the recommended workflow.
|
|
1193
1549
|
`;
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1550
|
+
// Execute the workflow guidance with AI if enabled
|
|
1551
|
+
const { executePromptWithFallback, formatMCPResponse } = await import('./utils/prompt-execution.js');
|
|
1552
|
+
const executionResult = await executePromptWithFallback(workflowPrompt, 'Analyze the user context and provide intelligent workflow guidance with specific tool recommendations.', {
|
|
1553
|
+
temperature: 0.1,
|
|
1554
|
+
maxTokens: 6000,
|
|
1555
|
+
systemPrompt: `You are an expert workflow advisor for the MCP ADR Analysis Server.
|
|
1556
|
+
Your role is to analyze user goals and project context, then recommend the optimal sequence of tools to achieve their objectives efficiently.
|
|
1557
|
+
Provide specific, actionable guidance with clear tool sequences, expected outcomes, and success criteria.
|
|
1558
|
+
Focus on practical workflows that deliver measurable results.`
|
|
1559
|
+
});
|
|
1560
|
+
if (executionResult.isAIGenerated) {
|
|
1561
|
+
// AI execution successful - return actual workflow guidance
|
|
1562
|
+
return formatMCPResponse({
|
|
1563
|
+
...executionResult,
|
|
1564
|
+
content: `# Workflow Guidance & Tool Recommendations
|
|
1565
|
+
|
|
1566
|
+
## Your Context
|
|
1567
|
+
- **Goal**: ${goal}
|
|
1568
|
+
- **Project Context**: ${projectContext}
|
|
1569
|
+
- **Available Assets**: ${availableAssets.length > 0 ? availableAssets.join(', ') : 'None specified'}
|
|
1570
|
+
- **Timeframe**: ${timeframe}
|
|
1571
|
+
- **Primary Concerns**: ${primaryConcerns.length > 0 ? primaryConcerns.join(', ') : 'General analysis'}
|
|
1572
|
+
|
|
1573
|
+
## AI-Generated Workflow Guidance
|
|
1574
|
+
|
|
1575
|
+
${executionResult.content}
|
|
1576
|
+
|
|
1577
|
+
## Quick Reference: Available Tools
|
|
1578
|
+
|
|
1579
|
+
**Core Analysis**: analyze_project_ecosystem, get_architectural_context, generate_adrs_from_prd, analyze_content_security
|
|
1580
|
+
**ADR Management**: suggest_adrs, generate_adr_from_decision, discover_existing_adrs, generate_adr_todo
|
|
1581
|
+
**Security**: generate_content_masking, configure_custom_patterns, validate_content_masking
|
|
1582
|
+
**Governance**: generate_rules, validate_rules, create_rule_set
|
|
1583
|
+
**Environment**: analyze_environment, analyze_deployment_progress
|
|
1584
|
+
**Utilities**: manage_cache, configure_output_masking, check_ai_execution_status
|
|
1585
|
+
|
|
1586
|
+
## Next Steps
|
|
1587
|
+
|
|
1588
|
+
1. **Start with the recommended primary workflow** above
|
|
1589
|
+
2. **Call the first tool** with the suggested parameters
|
|
1590
|
+
3. **Review the results** and proceed to the next step
|
|
1591
|
+
4. **Track progress** using the success metrics provided
|
|
1592
|
+
5. **Adjust as needed** based on your specific findings
|
|
1593
|
+
|
|
1594
|
+
This guidance is tailored to your specific context and goals for maximum effectiveness!
|
|
1595
|
+
`,
|
|
1596
|
+
});
|
|
1597
|
+
}
|
|
1598
|
+
else {
|
|
1599
|
+
// Fallback to prompt-only mode
|
|
1600
|
+
return {
|
|
1601
|
+
content: [
|
|
1602
|
+
{
|
|
1603
|
+
type: 'text',
|
|
1604
|
+
text: workflowPrompt
|
|
1605
|
+
}
|
|
1606
|
+
]
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1202
1609
|
}
|
|
1203
1610
|
catch (error) {
|
|
1204
|
-
throw new McpAdrError(`Failed to generate
|
|
1611
|
+
throw new McpAdrError(`Failed to generate workflow guidance: ${error instanceof Error ? error.message : String(error)}`, 'WORKFLOW_ERROR');
|
|
1205
1612
|
}
|
|
1206
1613
|
}
|
|
1207
|
-
async
|
|
1208
|
-
const {
|
|
1209
|
-
const adrDirectory = args.adrDirectory || this.config.adrDirectory;
|
|
1210
|
-
this.logger.info(`Generating todo from ADRs in: ${adrDirectory}`);
|
|
1614
|
+
async getDevelopmentGuidance(args) {
|
|
1615
|
+
const { developmentPhase, adrsToImplement = [], technologyStack = [], currentProgress = '', teamContext = { size: 'small_team', experienceLevel: 'mixed' }, timeline = '', focusAreas = [] } = args;
|
|
1211
1616
|
try {
|
|
1617
|
+
// Generate prompts for ADR discovery if ADRs are specified
|
|
1212
1618
|
const { findFiles } = await import('./utils/file-system.js');
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1619
|
+
let adrAnalysisPrompt = '';
|
|
1620
|
+
if (adrsToImplement.length > 0) {
|
|
1621
|
+
const { getAdrDirectoryPath } = await import('./utils/config.js');
|
|
1622
|
+
const absoluteAdrPath = getAdrDirectoryPath(this.config);
|
|
1623
|
+
const adrFileDiscovery = await findFiles(this.config.projectPath, [`${absoluteAdrPath}/**/*.md`], {
|
|
1624
|
+
includeContent: true,
|
|
1625
|
+
});
|
|
1626
|
+
adrAnalysisPrompt = `
|
|
1627
|
+
## ADR Analysis for Implementation
|
|
1628
|
+
|
|
1629
|
+
${adrFileDiscovery.prompt}
|
|
1630
|
+
|
|
1631
|
+
**ADRs to Implement**: ${adrsToImplement.join(', ')}
|
|
1632
|
+
**ADR Directory**: ${absoluteAdrPath}
|
|
1633
|
+
`;
|
|
1217
1634
|
}
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
filename: file.name,
|
|
1221
|
-
path: file.path,
|
|
1222
|
-
content: file.content || ''
|
|
1223
|
-
}));
|
|
1224
|
-
// Generate todo creation prompt
|
|
1225
|
-
const todoPrompt = `
|
|
1226
|
-
# ADR Todo Generation Request
|
|
1635
|
+
const developmentPrompt = `
|
|
1636
|
+
# Development Guidance & Implementation Roadmap
|
|
1227
1637
|
|
|
1228
|
-
|
|
1638
|
+
## Development Context
|
|
1639
|
+
- **Development Phase**: ${developmentPhase}
|
|
1640
|
+
- **Technology Stack**: ${technologyStack.length > 0 ? technologyStack.join(', ') : 'Not specified'}
|
|
1641
|
+
- **Current Progress**: ${currentProgress || 'Starting fresh'}
|
|
1642
|
+
- **Team Size**: ${teamContext.size}
|
|
1643
|
+
- **Team Experience**: ${teamContext.experienceLevel}
|
|
1644
|
+
- **Timeline**: ${timeline || 'Not specified'}
|
|
1645
|
+
- **Focus Areas**: ${focusAreas.length > 0 ? focusAreas.join(', ') : 'General development'}
|
|
1229
1646
|
|
|
1230
|
-
|
|
1231
|
-
${adrContent.map(adr => `
|
|
1232
|
-
### ${adr.filename}
|
|
1233
|
-
\`\`\`markdown
|
|
1234
|
-
${adr.content.slice(0, 1500)}${adr.content.length > 1500 ? '\n... (truncated)' : ''}
|
|
1235
|
-
\`\`\`
|
|
1236
|
-
`).join('')}
|
|
1647
|
+
${adrAnalysisPrompt}
|
|
1237
1648
|
|
|
1238
|
-
##
|
|
1649
|
+
## Development Guidance Instructions
|
|
1239
1650
|
|
|
1240
|
-
|
|
1241
|
-
2. **Categorize**: Group tasks by ADR and priority
|
|
1242
|
-
3. **Status Detection**: Determine task completion status based on:
|
|
1243
|
-
- File existence checks
|
|
1244
|
-
- Code analysis hints
|
|
1245
|
-
- Implementation evidence
|
|
1246
|
-
4. **Progress Tracking**: Calculate overall progress
|
|
1247
|
-
5. **Scope Filter**: ${scope === 'all' ? 'Include all tasks' : `Focus on ${scope} tasks only`}
|
|
1651
|
+
Based on the development context, ADRs to implement, and technology stack, provide comprehensive development guidance including:
|
|
1248
1652
|
|
|
1249
|
-
|
|
1653
|
+
### 1. **Implementation Roadmap**
|
|
1654
|
+
Create a detailed development plan with:
|
|
1655
|
+
- **Phase-by-Phase Breakdown**: Logical development phases
|
|
1656
|
+
- **Task Prioritization**: Order tasks by dependencies and impact
|
|
1657
|
+
- **Milestone Definition**: Clear checkpoints and deliverables
|
|
1658
|
+
- **Risk Assessment**: Potential blockers and mitigation strategies
|
|
1250
1659
|
|
|
1251
|
-
|
|
1252
|
-
|
|
1660
|
+
### 2. **Code Structure & Architecture**
|
|
1661
|
+
Provide specific guidance on:
|
|
1662
|
+
- **Project Structure**: How to organize code files and directories
|
|
1663
|
+
- **Module Architecture**: How to structure components/modules
|
|
1664
|
+
- **Design Patterns**: Which patterns to use and where
|
|
1665
|
+
- **Code Organization**: Separation of concerns and layering
|
|
1253
1666
|
|
|
1254
|
-
**
|
|
1255
|
-
|
|
1667
|
+
### 3. **Implementation Patterns & Best Practices**
|
|
1668
|
+
For each technology in the stack, provide:
|
|
1669
|
+
- **Framework-Specific Patterns**: Best practices for the chosen frameworks
|
|
1670
|
+
- **API Design**: How to structure APIs and endpoints
|
|
1671
|
+
- **Data Layer**: Database schema and data access patterns
|
|
1672
|
+
- **State Management**: How to handle application state
|
|
1673
|
+
- **Error Handling**: Consistent error handling strategies
|
|
1256
1674
|
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
-
|
|
1260
|
-
-
|
|
1261
|
-
-
|
|
1262
|
-
-
|
|
1675
|
+
### 4. **ADR-to-Code Translation**
|
|
1676
|
+
For each ADR to implement:
|
|
1677
|
+
- **Implementation Tasks**: Specific coding tasks derived from the ADR
|
|
1678
|
+
- **Code Examples**: Pseudo-code or pattern examples
|
|
1679
|
+
- **Integration Points**: How this ADR affects other parts of the system
|
|
1680
|
+
- **Validation Criteria**: How to verify the ADR is properly implemented
|
|
1263
1681
|
|
|
1264
|
-
|
|
1682
|
+
### 5. **Testing Strategy**
|
|
1683
|
+
Comprehensive testing approach:
|
|
1684
|
+
- **Unit Testing**: What to test and how
|
|
1685
|
+
- **Integration Testing**: API and component integration tests
|
|
1686
|
+
- **End-to-End Testing**: User workflow testing
|
|
1687
|
+
- **Performance Testing**: Load and performance validation
|
|
1688
|
+
- **Security Testing**: Security validation approaches
|
|
1265
1689
|
|
|
1266
|
-
###
|
|
1267
|
-
-
|
|
1268
|
-
-
|
|
1269
|
-
-
|
|
1690
|
+
### 6. **Development Workflow**
|
|
1691
|
+
Team-specific guidance:
|
|
1692
|
+
- **Git Workflow**: Branching strategy and code review process
|
|
1693
|
+
- **CI/CD Pipeline**: Automated testing and deployment
|
|
1694
|
+
- **Code Quality**: Linting, formatting, and quality gates
|
|
1695
|
+
- **Documentation**: What to document and how
|
|
1696
|
+
|
|
1697
|
+
### 7. **Quality Gates & Checkpoints**
|
|
1698
|
+
Define success criteria:
|
|
1699
|
+
- **Code Quality Metrics**: Coverage, complexity, maintainability
|
|
1700
|
+
- **Performance Benchmarks**: Response times, throughput targets
|
|
1701
|
+
- **Security Checkpoints**: Security validation at each phase
|
|
1702
|
+
- **Architectural Compliance**: Adherence to ADR decisions
|
|
1703
|
+
|
|
1704
|
+
### 8. **Technology-Specific Implementation**
|
|
1705
|
+
For each technology in the stack, provide:
|
|
1706
|
+
- **Setup Instructions**: Environment and tooling setup
|
|
1707
|
+
- **Configuration**: Framework and tool configuration
|
|
1708
|
+
- **Optimization**: Performance and build optimization
|
|
1709
|
+
- **Deployment**: Technology-specific deployment considerations
|
|
1710
|
+
|
|
1711
|
+
## Expected Output Format
|
|
1712
|
+
|
|
1713
|
+
Provide a comprehensive development guide that includes:
|
|
1714
|
+
|
|
1715
|
+
### 📋 **1. Development Roadmap**
|
|
1716
|
+
- **Phase 1-N**: Logical development phases with tasks
|
|
1717
|
+
- **Dependencies**: Task dependencies and critical path
|
|
1718
|
+
- **Timeline**: Estimated effort and duration
|
|
1719
|
+
- **Milestones**: Key deliverables and checkpoints
|
|
1720
|
+
|
|
1721
|
+
### 🏗️ **2. Implementation Guide**
|
|
1722
|
+
- **Code Structure**: Detailed project organization
|
|
1723
|
+
- **Design Patterns**: Specific patterns to implement
|
|
1724
|
+
- **API Design**: Endpoint structure and conventions
|
|
1725
|
+
- **Data Architecture**: Database and data flow design
|
|
1726
|
+
|
|
1727
|
+
### 🧪 **3. Testing & Quality Strategy**
|
|
1728
|
+
- **Test Types**: Unit, integration, e2e testing approach
|
|
1729
|
+
- **Quality Gates**: Code quality and performance criteria
|
|
1730
|
+
- **Automation**: CI/CD and automated testing setup
|
|
1731
|
+
|
|
1732
|
+
### 🚀 **4. Deployment & Operations**
|
|
1733
|
+
- **Environment Setup**: Development, staging, production
|
|
1734
|
+
- **Deployment Pipeline**: Automated deployment process
|
|
1735
|
+
- **Monitoring**: Logging, metrics, and alerting
|
|
1736
|
+
- **Maintenance**: Ongoing maintenance and updates
|
|
1737
|
+
|
|
1738
|
+
### 📊 **5. Progress Tracking**
|
|
1739
|
+
- **Success Metrics**: How to measure development progress
|
|
1740
|
+
- **Quality Indicators**: Code quality and performance metrics
|
|
1741
|
+
- **Milestone Validation**: How to verify milestone completion
|
|
1742
|
+
- **Risk Monitoring**: Early warning signs and mitigation
|
|
1743
|
+
|
|
1744
|
+
### 💡 **6. Team-Specific Recommendations**
|
|
1745
|
+
Based on team size (${teamContext.size}) and experience (${teamContext.experienceLevel}):
|
|
1746
|
+
- **Workflow Adaptations**: Process adjustments for team context
|
|
1747
|
+
- **Skill Development**: Areas for team skill building
|
|
1748
|
+
- **Tool Recommendations**: Development tools and practices
|
|
1749
|
+
- **Communication**: Coordination and documentation practices
|
|
1750
|
+
|
|
1751
|
+
## Integration with Architectural Decisions
|
|
1752
|
+
|
|
1753
|
+
Ensure all development guidance:
|
|
1754
|
+
- **Aligns with ADRs**: Every recommendation supports architectural decisions
|
|
1755
|
+
- **Maintains Consistency**: Consistent patterns across the codebase
|
|
1756
|
+
- **Enables Evolution**: Flexible design for future changes
|
|
1757
|
+
- **Supports Quality**: Built-in quality and maintainability
|
|
1758
|
+
|
|
1759
|
+
Make the guidance **actionable, specific, and immediately implementable** so developers can start coding with confidence and architectural alignment.
|
|
1760
|
+
`;
|
|
1761
|
+
// Execute the development guidance with AI if enabled
|
|
1762
|
+
const { executePromptWithFallback, formatMCPResponse } = await import('./utils/prompt-execution.js');
|
|
1763
|
+
const executionResult = await executePromptWithFallback(developmentPrompt, 'Analyze the development context and provide comprehensive implementation guidance that translates architectural decisions into specific coding tasks and development roadmap.', {
|
|
1764
|
+
temperature: 0.1,
|
|
1765
|
+
maxTokens: 8000,
|
|
1766
|
+
systemPrompt: `You are an expert software development advisor specializing in translating architectural decisions into practical implementation guidance.
|
|
1767
|
+
Your role is to bridge the gap between architectural planning and actual code development.
|
|
1768
|
+
Provide specific, actionable development guidance with clear implementation steps, code patterns, and quality criteria.
|
|
1769
|
+
Focus on practical guidance that ensures architectural decisions are properly implemented in code.
|
|
1770
|
+
Consider team context, technology stack, and development phase to provide tailored recommendations.`
|
|
1771
|
+
});
|
|
1772
|
+
if (executionResult.isAIGenerated) {
|
|
1773
|
+
// AI execution successful - return actual development guidance
|
|
1774
|
+
return formatMCPResponse({
|
|
1775
|
+
...executionResult,
|
|
1776
|
+
content: `# Development Guidance & Implementation Roadmap
|
|
1777
|
+
|
|
1778
|
+
## Your Development Context
|
|
1779
|
+
- **Development Phase**: ${developmentPhase}
|
|
1780
|
+
- **Technology Stack**: ${technologyStack.length > 0 ? technologyStack.join(', ') : 'Not specified'}
|
|
1781
|
+
- **Current Progress**: ${currentProgress || 'Starting fresh'}
|
|
1782
|
+
- **Team Context**: ${teamContext.size} team with ${teamContext.experienceLevel} experience
|
|
1783
|
+
- **Timeline**: ${timeline || 'Not specified'}
|
|
1784
|
+
- **Focus Areas**: ${focusAreas.length > 0 ? focusAreas.join(', ') : 'General development'}
|
|
1785
|
+
- **ADRs to Implement**: ${adrsToImplement.length > 0 ? adrsToImplement.join(', ') : 'None specified'}
|
|
1786
|
+
|
|
1787
|
+
## AI-Generated Development Guidance
|
|
1788
|
+
|
|
1789
|
+
${executionResult.content}
|
|
1790
|
+
|
|
1791
|
+
## Integration with Workflow Tools
|
|
1792
|
+
|
|
1793
|
+
This development guidance works seamlessly with other MCP tools:
|
|
1794
|
+
|
|
1795
|
+
### **Workflow Integration**
|
|
1796
|
+
1. **get_workflow_guidance** → Recommends architectural process
|
|
1797
|
+
2. **get_development_guidance** → Guides implementation (this tool)
|
|
1798
|
+
3. **validate_rules** → Ensures code follows architectural decisions
|
|
1799
|
+
4. **analyze_deployment_progress** → Tracks implementation progress
|
|
1800
|
+
|
|
1801
|
+
### **Quality Assurance Tools**
|
|
1802
|
+
- **generate_rules** → Extract coding standards from ADRs
|
|
1803
|
+
- **validate_rules** → Validate code against architectural rules
|
|
1804
|
+
- **analyze_content_security** → Security validation during development
|
|
1805
|
+
|
|
1806
|
+
### **Documentation Tools**
|
|
1807
|
+
- **generate_adr_todo** → Create implementation task lists
|
|
1808
|
+
- **discover_existing_adrs** → Reference existing architectural decisions
|
|
1809
|
+
|
|
1810
|
+
## Next Steps: From Architecture to Code
|
|
1811
|
+
|
|
1812
|
+
1. **📋 Review the Development Roadmap** above
|
|
1813
|
+
2. **🏗️ Set Up Project Structure** as recommended
|
|
1814
|
+
3. **🧪 Implement Testing Strategy** early in development
|
|
1815
|
+
4. **📊 Track Progress** using the success metrics provided
|
|
1816
|
+
5. **🔄 Iterate and Refine** based on implementation learnings
|
|
1817
|
+
|
|
1818
|
+
This guidance ensures your development work is **architecturally aligned**, **quality-focused**, and **efficiently executed**!
|
|
1819
|
+
`,
|
|
1820
|
+
});
|
|
1821
|
+
}
|
|
1822
|
+
else {
|
|
1823
|
+
// Fallback to prompt-only mode
|
|
1824
|
+
return {
|
|
1825
|
+
content: [
|
|
1826
|
+
{
|
|
1827
|
+
type: 'text',
|
|
1828
|
+
text: developmentPrompt
|
|
1829
|
+
}
|
|
1830
|
+
]
|
|
1831
|
+
};
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
catch (error) {
|
|
1835
|
+
throw new McpAdrError(`Failed to generate development guidance: ${error instanceof Error ? error.message : String(error)}`, 'DEVELOPMENT_ERROR');
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
async analyzeProjectEcosystem(args) {
|
|
1839
|
+
// Use configured project path if not provided in args
|
|
1840
|
+
const projectPath = args.projectPath || this.config.projectPath;
|
|
1841
|
+
const { includePatterns, enhancedMode = true, knowledgeEnhancement = true, learningEnabled = true, technologyFocus = [], analysisDepth = 'comprehensive', includeEnvironment = true, recursiveDepth = 'comprehensive', analysisScope = [] } = args;
|
|
1842
|
+
this.logger.info(`Generating comprehensive ecosystem analysis for project at: ${projectPath}`);
|
|
1843
|
+
this.logger.info(`Analysis configuration - Depth: ${analysisDepth}, Recursive: ${recursiveDepth}, Environment: ${includeEnvironment}`);
|
|
1844
|
+
this.logger.info(`Enhancement features - Knowledge: ${knowledgeEnhancement}, Learning: ${learningEnabled}`);
|
|
1845
|
+
this.logger.info(`Analysis scope: ${analysisScope.length > 0 ? analysisScope.join(', ') : 'Full ecosystem analysis'}`);
|
|
1846
|
+
try {
|
|
1847
|
+
// Import utilities dynamically to avoid circular dependencies
|
|
1848
|
+
const { analyzeProjectStructure } = await import('./utils/file-system.js');
|
|
1849
|
+
// Import advanced prompting utilities if enhanced mode is enabled
|
|
1850
|
+
let generateArchitecturalKnowledge = null;
|
|
1851
|
+
let executeWithReflexion = null;
|
|
1852
|
+
let retrieveRelevantMemories = null;
|
|
1853
|
+
let createToolReflexionConfig = null;
|
|
1854
|
+
if (enhancedMode) {
|
|
1855
|
+
if (knowledgeEnhancement) {
|
|
1856
|
+
const knowledgeModule = await import('./utils/knowledge-generation.js');
|
|
1857
|
+
generateArchitecturalKnowledge = knowledgeModule.generateArchitecturalKnowledge;
|
|
1858
|
+
}
|
|
1859
|
+
if (learningEnabled) {
|
|
1860
|
+
const reflexionModule = await import('./utils/reflexion.js');
|
|
1861
|
+
executeWithReflexion = reflexionModule.executeWithReflexion;
|
|
1862
|
+
retrieveRelevantMemories = reflexionModule.retrieveRelevantMemories;
|
|
1863
|
+
createToolReflexionConfig = reflexionModule.createToolReflexionConfig;
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
// Step 1: Generate technology-specific knowledge if enabled
|
|
1867
|
+
let knowledgeContext = '';
|
|
1868
|
+
if (enhancedMode && knowledgeEnhancement && generateArchitecturalKnowledge) {
|
|
1869
|
+
try {
|
|
1870
|
+
const knowledgeResult = await generateArchitecturalKnowledge({
|
|
1871
|
+
projectPath,
|
|
1872
|
+
technologies: technologyFocus,
|
|
1873
|
+
patterns: [],
|
|
1874
|
+
projectType: 'ecosystem-analysis',
|
|
1875
|
+
existingAdrs: []
|
|
1876
|
+
}, {
|
|
1877
|
+
domains: this.getEcosystemAnalysisDomains(technologyFocus),
|
|
1878
|
+
depth: analysisDepth === 'basic' ? 'basic' : 'intermediate',
|
|
1879
|
+
cacheEnabled: true
|
|
1880
|
+
});
|
|
1881
|
+
knowledgeContext = `
|
|
1882
|
+
## Technology-Specific Knowledge Enhancement
|
|
1883
|
+
|
|
1884
|
+
The following architectural knowledge has been generated to enhance ecosystem analysis:
|
|
1885
|
+
|
|
1886
|
+
${knowledgeResult.prompt}
|
|
1887
|
+
|
|
1888
|
+
---
|
|
1889
|
+
`;
|
|
1890
|
+
}
|
|
1891
|
+
catch (error) {
|
|
1892
|
+
this.logger.warn('Knowledge generation failed:', error);
|
|
1893
|
+
knowledgeContext = '<!-- Knowledge generation unavailable -->\n';
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
// Step 2: Retrieve relevant memories if learning is enabled
|
|
1897
|
+
let reflexionContext = '';
|
|
1898
|
+
if (enhancedMode && learningEnabled && retrieveRelevantMemories) {
|
|
1899
|
+
try {
|
|
1900
|
+
const memoryResult = await retrieveRelevantMemories('ecosystem-analysis', { projectPath, analysisDepth, technologyFocus }, { maxResults: 5, relevanceThreshold: 0.6 });
|
|
1901
|
+
reflexionContext = `
|
|
1902
|
+
## Learning from Past Analyses
|
|
1903
|
+
|
|
1904
|
+
The following insights from past ecosystem analysis tasks will inform this analysis:
|
|
1905
|
+
|
|
1906
|
+
${memoryResult.prompt}
|
|
1907
|
+
|
|
1908
|
+
---
|
|
1909
|
+
`;
|
|
1910
|
+
}
|
|
1911
|
+
catch (error) {
|
|
1912
|
+
this.logger.warn('Reflexion memory retrieval failed:', error);
|
|
1913
|
+
reflexionContext = '<!-- Learning context unavailable -->\n';
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
// Step 3: Generate base project analysis prompt with recursive depth
|
|
1917
|
+
const baseProjectAnalysisPrompt = await analyzeProjectStructure(projectPath);
|
|
1918
|
+
// Step 4: Generate environment analysis if enabled
|
|
1919
|
+
let environmentAnalysisContext = '';
|
|
1920
|
+
if (includeEnvironment) {
|
|
1921
|
+
try {
|
|
1922
|
+
this.logger.info('Including comprehensive environment analysis in ecosystem analysis');
|
|
1923
|
+
const { analyzeEnvironment } = await import('./tools/environment-analysis-tool.js');
|
|
1924
|
+
// Call environment analysis with comprehensive scope
|
|
1925
|
+
const environmentResult = await analyzeEnvironment({
|
|
1926
|
+
projectPath,
|
|
1927
|
+
adrDirectory: this.config.adrDirectory,
|
|
1928
|
+
analysisType: 'comprehensive'
|
|
1929
|
+
});
|
|
1930
|
+
// Extract environment analysis content
|
|
1931
|
+
if (environmentResult.content && environmentResult.content[0]) {
|
|
1932
|
+
environmentAnalysisContext = `
|
|
1933
|
+
## Integrated Environment Analysis
|
|
1934
|
+
|
|
1935
|
+
${environmentResult.content[0].text}
|
|
1936
|
+
|
|
1937
|
+
---
|
|
1938
|
+
`;
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
catch (error) {
|
|
1942
|
+
this.logger.warn('Environment analysis integration failed:', error);
|
|
1943
|
+
environmentAnalysisContext = `
|
|
1944
|
+
## Environment Analysis
|
|
1945
|
+
<!-- Environment analysis unavailable: ${error instanceof Error ? error.message : 'Unknown error'} -->
|
|
1946
|
+
|
|
1947
|
+
---
|
|
1948
|
+
`;
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
// Step 5: Apply Reflexion execution if learning is enabled
|
|
1952
|
+
let enhancedAnalysisPrompt = baseProjectAnalysisPrompt.prompt + environmentAnalysisContext;
|
|
1953
|
+
if (enhancedMode && learningEnabled && executeWithReflexion && createToolReflexionConfig) {
|
|
1954
|
+
try {
|
|
1955
|
+
const reflexionConfig = createToolReflexionConfig('analyze_project_ecosystem', {
|
|
1956
|
+
reflectionDepth: analysisDepth === 'basic' ? 'basic' : 'detailed',
|
|
1957
|
+
evaluationCriteria: ['task-success', 'accuracy', 'completeness'],
|
|
1958
|
+
learningRate: 0.7
|
|
1959
|
+
});
|
|
1960
|
+
const reflexionResult = await executeWithReflexion({
|
|
1961
|
+
prompt: baseProjectAnalysisPrompt.prompt + knowledgeContext + environmentAnalysisContext,
|
|
1962
|
+
instructions: baseProjectAnalysisPrompt.instructions,
|
|
1963
|
+
context: {
|
|
1964
|
+
projectPath,
|
|
1965
|
+
analysisDepth,
|
|
1966
|
+
recursiveDepth,
|
|
1967
|
+
technologyFocus,
|
|
1968
|
+
includePatterns,
|
|
1969
|
+
includeEnvironment,
|
|
1970
|
+
analysisScope,
|
|
1971
|
+
knowledgeEnhanced: knowledgeEnhancement,
|
|
1972
|
+
learningEnabled: true
|
|
1973
|
+
}
|
|
1974
|
+
}, reflexionConfig);
|
|
1975
|
+
enhancedAnalysisPrompt = reflexionResult.prompt;
|
|
1976
|
+
}
|
|
1977
|
+
catch (error) {
|
|
1978
|
+
this.logger.warn('Reflexion execution failed:', error);
|
|
1979
|
+
enhancedAnalysisPrompt = baseProjectAnalysisPrompt.prompt + knowledgeContext + environmentAnalysisContext;
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
else {
|
|
1983
|
+
enhancedAnalysisPrompt = baseProjectAnalysisPrompt.prompt + knowledgeContext + environmentAnalysisContext;
|
|
1984
|
+
}
|
|
1985
|
+
// Execute the analysis with AI if enabled, otherwise return prompt
|
|
1986
|
+
const { executeEcosystemAnalysisPrompt, formatMCPResponse } = await import('./utils/prompt-execution.js');
|
|
1987
|
+
const executionResult = await executeEcosystemAnalysisPrompt(enhancedAnalysisPrompt, baseProjectAnalysisPrompt.instructions, {
|
|
1988
|
+
temperature: 0.1,
|
|
1989
|
+
maxTokens: 6000,
|
|
1990
|
+
});
|
|
1991
|
+
if (executionResult.isAIGenerated) {
|
|
1992
|
+
// AI execution successful - return actual analysis results
|
|
1993
|
+
return formatMCPResponse({
|
|
1994
|
+
...executionResult,
|
|
1995
|
+
content: `# Comprehensive Project Ecosystem Analysis Results
|
|
1996
|
+
|
|
1997
|
+
## Analysis Configuration
|
|
1998
|
+
- **Project Path**: ${projectPath}
|
|
1999
|
+
- **Analysis Depth**: ${analysisDepth}
|
|
2000
|
+
- **Recursive Depth**: ${recursiveDepth}
|
|
2001
|
+
- **Environment Analysis**: ${includeEnvironment ? '✅ Included' : '❌ Excluded'}
|
|
2002
|
+
- **Analysis Scope**: ${analysisScope.length > 0 ? analysisScope.join(', ') : 'Full ecosystem analysis'}
|
|
2003
|
+
|
|
2004
|
+
## Enhancement Features
|
|
2005
|
+
- **Knowledge Generation**: ${enhancedMode && knowledgeEnhancement ? '✅ Enabled' : '❌ Disabled'}
|
|
2006
|
+
- **Reflexion Learning**: ${enhancedMode && learningEnabled ? '✅ Enabled' : '❌ Disabled'}
|
|
2007
|
+
- **Enhanced Mode**: ${enhancedMode ? '✅ Enabled' : '❌ Disabled'}
|
|
2008
|
+
- **Technology Focus**: ${technologyFocus.length > 0 ? technologyFocus.join(', ') : 'Auto-detect'}
|
|
2009
|
+
|
|
2010
|
+
${knowledgeContext}
|
|
2011
|
+
|
|
2012
|
+
${reflexionContext}
|
|
2013
|
+
|
|
2014
|
+
## Comprehensive Ecosystem Analysis Results
|
|
2015
|
+
|
|
2016
|
+
${executionResult.content}
|
|
2017
|
+
|
|
2018
|
+
${includeEnvironment ? `
|
|
2019
|
+
|
|
2020
|
+
## Environment Integration Summary
|
|
2021
|
+
|
|
2022
|
+
The analysis above includes comprehensive environment analysis covering:
|
|
2023
|
+
- **Infrastructure Specifications**: Deployment and runtime environment details
|
|
2024
|
+
- **Containerization**: Docker, Kubernetes, and container orchestration analysis
|
|
2025
|
+
- **Environment Requirements**: Configuration and dependency requirements
|
|
2026
|
+
- **Compliance Assessment**: Security and regulatory compliance evaluation
|
|
2027
|
+
|
|
2028
|
+
This integrated approach provides complete understanding of both codebase patterns AND operational environment.
|
|
2029
|
+
` : ''}
|
|
2030
|
+
|
|
2031
|
+
## Next Steps: Complete Ecosystem Understanding
|
|
2032
|
+
|
|
2033
|
+
Based on the comprehensive analysis above:
|
|
2034
|
+
|
|
2035
|
+
### **Immediate Actions**
|
|
2036
|
+
1. **Review Ecosystem Overview**: Examine the complete technology stack and environment context
|
|
2037
|
+
2. **Assess Integration Points**: Understand how code patterns relate to operational environment
|
|
2038
|
+
3. **Identify Critical Dependencies**: Focus on key dependencies between code and infrastructure
|
|
2039
|
+
|
|
2040
|
+
### **Strategic Planning**
|
|
2041
|
+
4. **Address Architectural Issues**: Prioritize improvements based on both code and environment analysis
|
|
2042
|
+
5. **Plan Environment Optimization**: Optimize deployment and operational configurations
|
|
2043
|
+
6. **Update Documentation**: Document both architectural decisions and environment specifications
|
|
2044
|
+
|
|
2045
|
+
### **Implementation Roadmap**
|
|
2046
|
+
7. **Implement Code Improvements**: Execute code-level architectural enhancements
|
|
2047
|
+
8. **Optimize Environment**: Improve infrastructure and deployment configurations
|
|
2048
|
+
9. **Monitor Integration**: Ensure code and environment changes work together effectively
|
|
2049
|
+
|
|
2050
|
+
This comprehensive ecosystem analysis provides the foundation for informed architectural and operational decisions.
|
|
2051
|
+
`,
|
|
2052
|
+
});
|
|
2053
|
+
}
|
|
2054
|
+
else {
|
|
2055
|
+
// Fallback to prompt-only mode
|
|
2056
|
+
return {
|
|
2057
|
+
content: [
|
|
2058
|
+
{
|
|
2059
|
+
type: 'text',
|
|
2060
|
+
text: `# Comprehensive Project Ecosystem Analysis
|
|
2061
|
+
|
|
2062
|
+
This comprehensive analysis provides deep recursive project understanding with integrated environment analysis.
|
|
2063
|
+
|
|
2064
|
+
## Analysis Configuration
|
|
2065
|
+
- **Project Path**: ${projectPath}
|
|
2066
|
+
- **Analysis Depth**: ${analysisDepth}
|
|
2067
|
+
- **Recursive Depth**: ${recursiveDepth}
|
|
2068
|
+
- **Environment Analysis**: ${includeEnvironment ? '✅ Included' : '❌ Excluded'}
|
|
2069
|
+
- **Analysis Scope**: ${analysisScope.length > 0 ? analysisScope.join(', ') : 'Full ecosystem analysis'}
|
|
2070
|
+
|
|
2071
|
+
## Enhancement Features
|
|
2072
|
+
- **Knowledge Generation**: ${enhancedMode && knowledgeEnhancement ? '✅ Enabled' : '❌ Disabled'}
|
|
2073
|
+
- **Reflexion Learning**: ${enhancedMode && learningEnabled ? '✅ Enabled' : '❌ Disabled'}
|
|
2074
|
+
- **Enhanced Mode**: ${enhancedMode ? '✅ Enabled' : '❌ Disabled'}
|
|
2075
|
+
- **Technology Focus**: ${technologyFocus.length > 0 ? technologyFocus.join(', ') : 'Auto-detect'}
|
|
2076
|
+
- **Include Patterns**: ${includePatterns?.length ? includePatterns.join(', ') : 'Default patterns'}
|
|
2077
|
+
|
|
2078
|
+
${knowledgeContext}
|
|
2079
|
+
|
|
2080
|
+
${reflexionContext}
|
|
2081
|
+
|
|
2082
|
+
## Enhanced Analysis Prompt
|
|
2083
|
+
|
|
2084
|
+
${enhancedAnalysisPrompt}
|
|
2085
|
+
|
|
2086
|
+
## Enhanced Implementation Instructions
|
|
2087
|
+
|
|
2088
|
+
${baseProjectAnalysisPrompt.instructions}
|
|
2089
|
+
|
|
2090
|
+
### Enhancement-Specific Instructions
|
|
2091
|
+
|
|
2092
|
+
${enhancedMode && knowledgeEnhancement ? `
|
|
2093
|
+
#### Knowledge Enhancement
|
|
2094
|
+
- Apply technology-specific knowledge to ecosystem analysis
|
|
2095
|
+
- Use domain expertise to identify patterns and anti-patterns
|
|
2096
|
+
- Leverage architectural best practices for technology stack evaluation
|
|
2097
|
+
` : ''}
|
|
2098
|
+
|
|
2099
|
+
${enhancedMode && learningEnabled ? `
|
|
2100
|
+
#### Learning Integration
|
|
2101
|
+
- Apply lessons learned from past ecosystem analyses
|
|
2102
|
+
- Use memory insights to improve pattern recognition accuracy
|
|
2103
|
+
- Incorporate feedback from previous analysis outcomes
|
|
2104
|
+
` : ''}
|
|
2105
|
+
|
|
2106
|
+
## Expected Enhanced Output
|
|
2107
|
+
|
|
2108
|
+
The enhanced analysis should provide:
|
|
2109
|
+
1. **Technology Stack Analysis** with domain knowledge context
|
|
2110
|
+
2. **Architectural Pattern Detection** informed by past experiences
|
|
2111
|
+
3. **Ecosystem Health Assessment** using learned evaluation criteria
|
|
2112
|
+
4. **Improvement Recommendations** based on domain best practices
|
|
2113
|
+
5. **Learning Insights** for future analysis improvement
|
|
2114
|
+
|
|
2115
|
+
## Quality Assurance
|
|
2116
|
+
|
|
2117
|
+
- Ensure analysis leverages all available enhancement features
|
|
2118
|
+
- Verify technology-specific knowledge is properly applied
|
|
2119
|
+
- Confirm learning insights improve analysis accuracy
|
|
2120
|
+
- Validate recommendations align with domain best practices`
|
|
2121
|
+
}
|
|
2122
|
+
]
|
|
2123
|
+
};
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
catch (error) {
|
|
2127
|
+
throw new McpAdrError(`Failed to analyze project ecosystem: ${error instanceof Error ? error.message : String(error)}`, 'ANALYSIS_ERROR');
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
async getArchitecturalContext(args) {
|
|
2131
|
+
const { filePath, includeCompliance = true } = args;
|
|
2132
|
+
try {
|
|
2133
|
+
const { analyzeProjectStructure, fileExists, ensureDirectory } = await import('./utils/file-system.js');
|
|
2134
|
+
const path = await import('path');
|
|
2135
|
+
// Determine project path
|
|
2136
|
+
const projectPath = filePath ? filePath.split('/').slice(0, -1).join('/') : this.config.projectPath;
|
|
2137
|
+
const adrDirectory = path.join(projectPath, this.config.adrDirectory);
|
|
2138
|
+
// Generate prompts for ADR directory setup
|
|
2139
|
+
const adrDirectoryCheckPrompt = await fileExists(adrDirectory);
|
|
2140
|
+
const adrDirectorySetupPrompt = await ensureDirectory(adrDirectory);
|
|
2141
|
+
// Generate architectural analysis prompt
|
|
2142
|
+
const projectAnalysisPrompt = await analyzeProjectStructure(projectPath);
|
|
2143
|
+
const architecturalPrompt = `
|
|
2144
|
+
# Architectural Context Analysis & Project Setup
|
|
2145
|
+
|
|
2146
|
+
## Project Overview
|
|
2147
|
+
**Project Path**: ${projectPath}
|
|
2148
|
+
**Analysis Scope**: ${filePath ? `Specific file: ${filePath}` : 'Entire project'}
|
|
2149
|
+
**ADR Directory**: ${this.config.adrDirectory}
|
|
2150
|
+
**Include Compliance**: ${includeCompliance ? 'Yes' : 'No'}
|
|
2151
|
+
|
|
2152
|
+
## 🚀 ADR Infrastructure Setup
|
|
2153
|
+
|
|
2154
|
+
This analysis will include setting up ADR infrastructure if needed:
|
|
2155
|
+
|
|
2156
|
+
### ADR Directory Check
|
|
2157
|
+
${adrDirectoryCheckPrompt.prompt}
|
|
2158
|
+
|
|
2159
|
+
### ADR Directory Setup (if needed)
|
|
2160
|
+
${adrDirectorySetupPrompt.prompt}
|
|
2161
|
+
|
|
2162
|
+
## Comprehensive Project Analysis
|
|
2163
|
+
|
|
2164
|
+
${projectAnalysisPrompt.prompt}
|
|
2165
|
+
|
|
2166
|
+
## Enhanced Architectural Focus
|
|
2167
|
+
|
|
2168
|
+
Please provide a **comprehensive, outcome-focused analysis** including:
|
|
2169
|
+
|
|
2170
|
+
### 1. Technology Stack & Infrastructure Analysis
|
|
2171
|
+
- **Core Technologies**: Programming languages, frameworks, runtime environments
|
|
2172
|
+
- **Dependencies**: Package managers, third-party libraries, version constraints
|
|
2173
|
+
- **Build & Deployment**: CI/CD pipelines, build tools, deployment strategies
|
|
2174
|
+
- **Data Layer**: Databases, caching, data storage and retrieval patterns
|
|
2175
|
+
|
|
2176
|
+
### 2. Architectural Pattern & Design Analysis
|
|
2177
|
+
- **System Architecture**: Monolith, microservices, serverless, hybrid patterns
|
|
2178
|
+
- **Code Organization**: Module structure, separation of concerns, layering
|
|
2179
|
+
- **API Design**: REST, GraphQL, RPC patterns and conventions
|
|
2180
|
+
- **Data Flow**: Request/response cycles, event handling, state management
|
|
2181
|
+
${filePath ? `- **File-specific Context**: How ${filePath} fits into the overall architecture` : ''}
|
|
2182
|
+
|
|
2183
|
+
### 3. Quality, Security & Performance Assessment
|
|
2184
|
+
- **Code Quality**: Structure, naming, documentation, testing strategies
|
|
2185
|
+
- **Security Implementation**: Authentication, authorization, data protection
|
|
2186
|
+
- **Performance Patterns**: Caching, optimization, scalability considerations
|
|
2187
|
+
- **Monitoring & Observability**: Logging, metrics, error tracking
|
|
2188
|
+
|
|
2189
|
+
### 4. Architectural Decision Discovery & Documentation
|
|
2190
|
+
- **Explicit Decisions**: Find existing documentation and decision records
|
|
2191
|
+
- **Implicit Decisions**: Identify significant undocumented architectural choices
|
|
2192
|
+
- **Technology Rationale**: Understand selection criteria and trade-offs
|
|
2193
|
+
- **Evolution Path**: How the architecture has changed over time
|
|
2194
|
+
|
|
2195
|
+
${includeCompliance ? `### 5. Compliance & Standards Assessment
|
|
2196
|
+
- **Industry Standards**: Adherence to relevant industry standards and best practices
|
|
2197
|
+
- **Security Compliance**: Security standards compliance (OWASP, SOC2, etc.)
|
|
2198
|
+
- **Code Standards**: Coding standards and style guide compliance
|
|
2199
|
+
- **Architectural Compliance**: Adherence to established architectural principles
|
|
2200
|
+
- **Regulatory Requirements**: Any regulatory compliance requirements (GDPR, HIPAA, etc.)` : ''}
|
|
2201
|
+
|
|
2202
|
+
## Expected Output: Outcome-Focused Architectural Context
|
|
2203
|
+
|
|
2204
|
+
Provide a **comprehensive architectural context** with **clear project outcomes**:
|
|
2205
|
+
|
|
2206
|
+
### 📋 **1. Executive Summary & Project Outcomes**
|
|
2207
|
+
- **Current State**: What the project is and what it does
|
|
2208
|
+
- **Architectural Maturity**: Assessment of current architectural practices
|
|
2209
|
+
- **Key Strengths**: What's working well architecturally
|
|
2210
|
+
- **Critical Gaps**: What needs immediate attention
|
|
2211
|
+
- **Success Metrics**: How to measure architectural improvements
|
|
2212
|
+
|
|
2213
|
+
### 🔧 **2. Technology & Infrastructure Inventory**
|
|
2214
|
+
- **Technology Stack**: Complete inventory with versions and purposes
|
|
2215
|
+
- **Infrastructure Components**: Deployment, monitoring, data storage
|
|
2216
|
+
- **Dependencies**: Critical dependencies and potential risks
|
|
2217
|
+
- **Tool Chain**: Development, testing, and deployment tools
|
|
2218
|
+
|
|
2219
|
+
### 🏗️ **3. Architectural Patterns & Design Decisions**
|
|
2220
|
+
- **System Design**: Overall architectural approach and patterns
|
|
2221
|
+
- **Component Architecture**: How major components interact
|
|
2222
|
+
- **Data Architecture**: How data flows and is managed
|
|
2223
|
+
- **Integration Patterns**: How external systems are integrated
|
|
2224
|
+
|
|
2225
|
+
### 📊 **4. Quality & Compliance Assessment**
|
|
2226
|
+
- **Code Quality Score**: Assessment of current code quality
|
|
2227
|
+
- **Security Posture**: Security implementation and gaps
|
|
2228
|
+
- **Performance Profile**: Current performance characteristics
|
|
2229
|
+
- **Maintainability Index**: How easy the system is to maintain and evolve
|
|
2230
|
+
|
|
2231
|
+
### 🎯 **5. Outcome-Focused Action Plan**
|
|
2232
|
+
Based on the analysis, provide a **clear workflow** with **projected outcomes**:
|
|
2233
|
+
|
|
2234
|
+
#### **Immediate Actions (Next 1-2 weeks)**
|
|
2235
|
+
- **Priority 1**: Most critical architectural issues to address
|
|
2236
|
+
- **Quick Wins**: Low-effort, high-impact improvements
|
|
2237
|
+
- **Documentation**: Essential decisions that need immediate documentation
|
|
2238
|
+
|
|
2239
|
+
#### **Short-term Goals (Next 1-3 months)**
|
|
2240
|
+
- **Architectural Improvements**: Planned enhancements with expected outcomes
|
|
2241
|
+
- **Technical Debt**: Priority technical debt to address
|
|
2242
|
+
- **Process Improvements**: Development workflow enhancements
|
|
2243
|
+
|
|
2244
|
+
#### **Long-term Vision (3-12 months)**
|
|
2245
|
+
- **Strategic Architecture**: Long-term architectural evolution
|
|
2246
|
+
- **Scalability Roadmap**: How to scale the system effectively
|
|
2247
|
+
- **Innovation Opportunities**: Areas for architectural innovation
|
|
2248
|
+
|
|
2249
|
+
### 📈 **6. Success Metrics & Outcomes**
|
|
2250
|
+
Define **measurable outcomes** for architectural improvements:
|
|
2251
|
+
|
|
2252
|
+
- **Performance Metrics**: Response times, throughput, resource utilization
|
|
2253
|
+
- **Quality Metrics**: Code coverage, bug rates, maintainability scores
|
|
2254
|
+
- **Developer Experience**: Build times, deployment frequency, developer satisfaction
|
|
2255
|
+
- **Business Impact**: Feature delivery speed, system reliability, cost efficiency
|
|
2256
|
+
|
|
2257
|
+
### 🏗️ **7. ADR Infrastructure & Documentation Plan**
|
|
2258
|
+
|
|
2259
|
+
If ADR directory doesn't exist, also provide:
|
|
2260
|
+
|
|
2261
|
+
1. **Create Directory Structure**:
|
|
2262
|
+
\`\`\`
|
|
2263
|
+
${this.config.adrDirectory}/
|
|
2264
|
+
├── 0001-record-architecture-decisions.md (template)
|
|
2265
|
+
├── README.md (ADR process guide)
|
|
2266
|
+
└── template.md (ADR template)
|
|
2267
|
+
\`\`\`
|
|
2268
|
+
|
|
2269
|
+
2. **Generate Initial ADRs** for discovered architectural decisions
|
|
2270
|
+
3. **Create ADR Process Guide** for the team
|
|
2271
|
+
4. **Establish ADR Workflow** for future decisions
|
|
2272
|
+
|
|
2273
|
+
### 🔄 **8. Continuous Improvement Workflow**
|
|
2274
|
+
Establish ongoing architectural governance:
|
|
2275
|
+
|
|
2276
|
+
- **Regular Reviews**: Monthly architectural health checks
|
|
2277
|
+
- **Decision Documentation**: Process for documenting new architectural decisions
|
|
2278
|
+
- **Compliance Monitoring**: Ongoing adherence to architectural standards
|
|
2279
|
+
- **Evolution Planning**: Quarterly architectural roadmap updates
|
|
2280
|
+
|
|
2281
|
+
## Next Steps: Grounded Project Workflow
|
|
2282
|
+
|
|
2283
|
+
After this analysis, follow this **outcome-focused workflow**:
|
|
2284
|
+
|
|
2285
|
+
1. **📋 Review Analysis**: Examine the architectural context and recommendations
|
|
2286
|
+
2. **🎯 Set Priorities**: Choose 3-5 most impactful improvements based on outcomes
|
|
2287
|
+
3. **📝 Document Decisions**: Create ADRs for significant architectural choices
|
|
2288
|
+
4. **🔧 Implement Changes**: Execute improvements in priority order
|
|
2289
|
+
5. **📊 Measure Progress**: Track success metrics and outcomes
|
|
2290
|
+
6. **🔄 Iterate**: Regular reviews and continuous improvement
|
|
2291
|
+
|
|
2292
|
+
This approach ensures that architectural work is **grounded in measurable outcomes** and **aligned with project success**.
|
|
2293
|
+
`;
|
|
2294
|
+
// Execute the analysis with AI if enabled, otherwise return prompt
|
|
2295
|
+
const { executeEcosystemAnalysisPrompt, formatMCPResponse } = await import('./utils/prompt-execution.js');
|
|
2296
|
+
const executionResult = await executeEcosystemAnalysisPrompt(architecturalPrompt, projectAnalysisPrompt.instructions, {
|
|
2297
|
+
temperature: 0.1,
|
|
2298
|
+
maxTokens: 5000,
|
|
2299
|
+
systemPrompt: `You are a senior software architect specializing in architectural context analysis.
|
|
2300
|
+
Analyze the provided project to understand its architectural patterns, design decisions, and structural organization.
|
|
2301
|
+
Focus on providing actionable insights about the architecture that can guide development decisions.`
|
|
2302
|
+
});
|
|
2303
|
+
if (executionResult.isAIGenerated) {
|
|
2304
|
+
// AI execution successful - return actual analysis results
|
|
2305
|
+
return formatMCPResponse({
|
|
2306
|
+
...executionResult,
|
|
2307
|
+
content: `# Architectural Context Analysis Results
|
|
2308
|
+
|
|
2309
|
+
${filePath ? `## Target File: ${filePath}` : '## Project-wide Analysis'}
|
|
2310
|
+
|
|
2311
|
+
## Project Information
|
|
2312
|
+
- **Project Path**: ${projectPath}
|
|
2313
|
+
- **Analysis Scope**: ${filePath ? 'File-specific' : 'Project-wide'}
|
|
2314
|
+
- **ADR Directory**: ${this.config.adrDirectory}
|
|
2315
|
+
|
|
2316
|
+
## ADR Infrastructure Setup
|
|
2317
|
+
|
|
2318
|
+
The analysis includes automatic ADR infrastructure setup:
|
|
2319
|
+
|
|
2320
|
+
${adrDirectoryCheckPrompt.instructions}
|
|
2321
|
+
|
|
2322
|
+
${adrDirectorySetupPrompt.instructions}
|
|
2323
|
+
|
|
2324
|
+
## AI Analysis Results
|
|
2325
|
+
|
|
2326
|
+
${executionResult.content}
|
|
2327
|
+
|
|
2328
|
+
## Outcome-Focused Next Steps
|
|
2329
|
+
|
|
2330
|
+
Based on the architectural analysis, follow this **grounded workflow**:
|
|
2331
|
+
|
|
2332
|
+
### **Immediate Actions (This Week)**
|
|
2333
|
+
1. **Review Analysis**: Examine the architectural context and recommendations above
|
|
2334
|
+
2. **Set Up ADRs**: Ensure ADR directory structure is created and ready
|
|
2335
|
+
3. **Identify Quick Wins**: Focus on low-effort, high-impact improvements
|
|
2336
|
+
|
|
2337
|
+
### **Short-term Goals (Next Month)**
|
|
2338
|
+
4. **Document Key Decisions**: Create ADRs for the most significant architectural choices
|
|
2339
|
+
5. **Address Critical Issues**: Tackle the highest-priority architectural concerns
|
|
2340
|
+
6. **Establish Metrics**: Set up measurement for the success metrics identified
|
|
2341
|
+
|
|
2342
|
+
### **Long-term Vision (Next Quarter)**
|
|
2343
|
+
7. **Implement Roadmap**: Execute the architectural improvement plan
|
|
2344
|
+
8. **Monitor Progress**: Track success metrics and adjust approach as needed
|
|
2345
|
+
9. **Continuous Improvement**: Establish regular architectural reviews
|
|
2346
|
+
|
|
2347
|
+
This **outcome-focused approach** ensures architectural work delivers **measurable value** and keeps the project **grounded in clear objectives**.
|
|
2348
|
+
`,
|
|
2349
|
+
});
|
|
2350
|
+
}
|
|
2351
|
+
else {
|
|
2352
|
+
// Fallback to prompt-only mode
|
|
2353
|
+
return {
|
|
2354
|
+
content: [
|
|
2355
|
+
{
|
|
2356
|
+
type: 'text',
|
|
2357
|
+
text: architecturalPrompt
|
|
2358
|
+
}
|
|
2359
|
+
]
|
|
2360
|
+
};
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
catch (error) {
|
|
2364
|
+
throw new McpAdrError(`Failed to get architectural context: ${error instanceof Error ? error.message : String(error)}`, 'ANALYSIS_ERROR');
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
async generateAdrsFromPrd(args) {
|
|
2368
|
+
const { prdPath, enhancedMode = true, promptOptimization = true, knowledgeEnhancement = true, prdType = 'general' } = args;
|
|
2369
|
+
const outputDirectory = args.outputDirectory || this.config.adrDirectory;
|
|
2370
|
+
this.logger.info(`Generating enhanced ADRs from PRD: ${prdPath} to ${outputDirectory}`);
|
|
2371
|
+
this.logger.info(`Enhancement features - APE: ${promptOptimization}, Knowledge: ${knowledgeEnhancement}, Type: ${prdType}`);
|
|
2372
|
+
try {
|
|
2373
|
+
const { readFileContent, fileExists } = await import('./utils/file-system.js');
|
|
2374
|
+
// Import advanced prompting utilities if enhanced mode is enabled
|
|
2375
|
+
let generateArchitecturalKnowledge = null;
|
|
2376
|
+
let optimizePromptWithAPE = null;
|
|
2377
|
+
let createToolAPEConfig = null;
|
|
2378
|
+
if (enhancedMode) {
|
|
2379
|
+
if (knowledgeEnhancement) {
|
|
2380
|
+
const knowledgeModule = await import('./utils/knowledge-generation.js');
|
|
2381
|
+
generateArchitecturalKnowledge = knowledgeModule.generateArchitecturalKnowledge;
|
|
2382
|
+
}
|
|
2383
|
+
if (promptOptimization) {
|
|
2384
|
+
const apeModule = await import('./utils/automatic-prompt-engineering.js');
|
|
2385
|
+
optimizePromptWithAPE = apeModule.optimizePromptWithAPE;
|
|
2386
|
+
createToolAPEConfig = apeModule.createToolAPEConfig;
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
// Generate file existence check prompt
|
|
2390
|
+
const fileExistsPrompt = await fileExists(prdPath);
|
|
2391
|
+
// Generate file content reading prompt
|
|
2392
|
+
const fileContentPrompt = await readFileContent(prdPath);
|
|
2393
|
+
// Step 1: Generate domain-specific knowledge if enabled
|
|
2394
|
+
let knowledgeContext = '';
|
|
2395
|
+
if (enhancedMode && knowledgeEnhancement && generateArchitecturalKnowledge) {
|
|
2396
|
+
try {
|
|
2397
|
+
const knowledgeResult = await generateArchitecturalKnowledge({
|
|
2398
|
+
projectPath: outputDirectory,
|
|
2399
|
+
technologies: [],
|
|
2400
|
+
patterns: [],
|
|
2401
|
+
projectType: prdType,
|
|
2402
|
+
existingAdrs: []
|
|
2403
|
+
}, {
|
|
2404
|
+
domains: this.getPrdTypeDomains(prdType),
|
|
2405
|
+
depth: 'intermediate',
|
|
2406
|
+
cacheEnabled: true
|
|
2407
|
+
});
|
|
2408
|
+
knowledgeContext = `
|
|
2409
|
+
## Domain-Specific Knowledge Enhancement
|
|
2410
|
+
|
|
2411
|
+
The following architectural knowledge has been generated to enhance PRD analysis and ADR creation:
|
|
2412
|
+
|
|
2413
|
+
${knowledgeResult.prompt}
|
|
2414
|
+
|
|
2415
|
+
---
|
|
2416
|
+
`;
|
|
2417
|
+
}
|
|
2418
|
+
catch (error) {
|
|
2419
|
+
this.logger.warn('Knowledge generation failed:', error);
|
|
2420
|
+
knowledgeContext = '<!-- Knowledge generation unavailable -->\n';
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
// Step 2: Create base ADR generation prompt
|
|
2424
|
+
const baseAdrPrompt = this.createBaseAdrPrompt(prdPath, outputDirectory, knowledgeContext);
|
|
2425
|
+
// Step 3: Apply APE optimization if enabled
|
|
2426
|
+
let finalAdrPrompt = baseAdrPrompt;
|
|
2427
|
+
if (enhancedMode && promptOptimization && optimizePromptWithAPE && createToolAPEConfig) {
|
|
2428
|
+
try {
|
|
2429
|
+
const apeConfig = createToolAPEConfig('generate_adrs_from_prd', {
|
|
2430
|
+
candidateCount: 5,
|
|
2431
|
+
evaluationCriteria: ['task-completion', 'clarity', 'specificity'],
|
|
2432
|
+
optimizationRounds: 2,
|
|
2433
|
+
qualityThreshold: 0.75
|
|
2434
|
+
});
|
|
2435
|
+
const apeResult = await optimizePromptWithAPE({
|
|
2436
|
+
prompt: baseAdrPrompt,
|
|
2437
|
+
instructions: 'Generate comprehensive ADRs from PRD analysis',
|
|
2438
|
+
context: { prdPath, outputDirectory, prdType, knowledgeEnhanced: knowledgeEnhancement }
|
|
2439
|
+
}, apeConfig);
|
|
2440
|
+
finalAdrPrompt = apeResult.prompt;
|
|
2441
|
+
}
|
|
2442
|
+
catch (error) {
|
|
2443
|
+
this.logger.warn('APE optimization failed:', error);
|
|
2444
|
+
finalAdrPrompt = baseAdrPrompt;
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
// Generate comprehensive ADR creation prompt that includes file operations
|
|
2448
|
+
const adrPrompt = `
|
|
2449
|
+
# Enhanced ADR Generation from PRD Request
|
|
2450
|
+
|
|
2451
|
+
This is a comprehensive prompt-driven ADR generation process enhanced with advanced prompting techniques.
|
|
2452
|
+
|
|
2453
|
+
## Enhancement Status
|
|
2454
|
+
- **APE Optimization**: ${enhancedMode && promptOptimization ? '✅ Enabled' : '❌ Disabled'}
|
|
2455
|
+
- **Knowledge Generation**: ${enhancedMode && knowledgeEnhancement ? '✅ Enabled' : '❌ Disabled'}
|
|
2456
|
+
- **PRD Type**: ${prdType}
|
|
2457
|
+
- **Enhanced Mode**: ${enhancedMode ? '✅ Enabled' : '❌ Disabled'}
|
|
2458
|
+
|
|
2459
|
+
## Step 1: File Validation
|
|
2460
|
+
${fileExistsPrompt.prompt}
|
|
2461
|
+
|
|
2462
|
+
**Instructions**: First, execute the file existence check above. If the file does not exist, stop the process and report the error. Only proceed to Step 2 if the file exists.
|
|
2463
|
+
|
|
2464
|
+
## Step 2: PRD Content Reading
|
|
2465
|
+
${fileContentPrompt.prompt}
|
|
2466
|
+
|
|
2467
|
+
**Instructions**: Execute the file reading operation above to obtain the PRD content. Use the content from this step for the enhanced ADR generation in Step 3.
|
|
2468
|
+
|
|
2469
|
+
## Step 3: Enhanced ADR Generation
|
|
2470
|
+
|
|
2471
|
+
${enhancedMode && promptOptimization ? `
|
|
2472
|
+
### APE-Optimized Analysis
|
|
2473
|
+
This prompt has been optimized using Automatic Prompt Engineering for superior ADR generation quality.
|
|
2474
|
+
The optimization focused on task completion, clarity, and specificity for PRD analysis.
|
|
2475
|
+
|
|
2476
|
+
` : ''}
|
|
2477
|
+
|
|
2478
|
+
${finalAdrPrompt}
|
|
2479
|
+
|
|
2480
|
+
### File Creation Instructions
|
|
2481
|
+
|
|
2482
|
+
For each generated ADR, create a file creation prompt using the following pattern:
|
|
2483
|
+
- **File Path**: ${outputDirectory}/[number]-[decision-title].md
|
|
2484
|
+
- **Content**: The complete enhanced ADR markdown content
|
|
2485
|
+
- **Action Confirmation**: Require user confirmation before creating files
|
|
2486
|
+
- **Security Validation**: Ensure output directory is safe and authorized
|
|
2487
|
+
|
|
2488
|
+
### Enhanced Quality Assurance
|
|
2489
|
+
|
|
2490
|
+
- Ensure each ADR leverages domain knowledge when available
|
|
2491
|
+
- Verify decisions align with PRD type best practices
|
|
2492
|
+
- Check that enhancement features are properly utilized
|
|
2493
|
+
- Validate that ADR content exceeds baseline quality expectations
|
|
2494
|
+
- Confirm all decisions are traceable back to PRD requirements with domain context
|
|
2495
|
+
`;
|
|
2496
|
+
// Execute the ADR generation with AI if enabled, otherwise return prompt
|
|
2497
|
+
const { executeADRGenerationPrompt, formatMCPResponse } = await import('./utils/prompt-execution.js');
|
|
2498
|
+
const executionResult = await executeADRGenerationPrompt(adrPrompt, 'Generate comprehensive ADRs from PRD analysis with enhanced domain knowledge and optimization', {
|
|
2499
|
+
temperature: 0.1,
|
|
2500
|
+
maxTokens: 8000,
|
|
2501
|
+
systemPrompt: `You are an expert software architect who creates comprehensive Architectural Decision Records (ADRs) from Product Requirements Documents (PRDs).
|
|
2502
|
+
Generate well-structured ADRs that follow best practices and include all necessary sections.
|
|
2503
|
+
Focus on extracting architectural decisions from the PRD and creating actionable ADRs with clear reasoning.`
|
|
2504
|
+
});
|
|
2505
|
+
if (executionResult.isAIGenerated) {
|
|
2506
|
+
// AI execution successful - return actual ADR generation results
|
|
2507
|
+
return formatMCPResponse({
|
|
2508
|
+
...executionResult,
|
|
2509
|
+
content: `# ADR Generation from PRD Results
|
|
2510
|
+
|
|
2511
|
+
## Enhancement Features
|
|
2512
|
+
- **APE Optimization**: ${enhancedMode && promptOptimization ? '✅ Enabled' : '❌ Disabled'}
|
|
2513
|
+
- **Knowledge Generation**: ${enhancedMode && knowledgeEnhancement ? '✅ Enabled' : '❌ Disabled'}
|
|
2514
|
+
- **PRD Type Optimization**: ${prdType}
|
|
2515
|
+
- **Enhanced Mode**: ${enhancedMode ? '✅ Enabled' : '❌ Disabled'}
|
|
2516
|
+
|
|
2517
|
+
## Source Information
|
|
2518
|
+
- **PRD Path**: ${prdPath}
|
|
2519
|
+
- **Output Directory**: ${outputDirectory}
|
|
2520
|
+
|
|
2521
|
+
## Generated ADRs
|
|
2522
|
+
|
|
2523
|
+
${executionResult.content}
|
|
2524
|
+
|
|
2525
|
+
## Next Steps
|
|
2526
|
+
|
|
2527
|
+
1. **Review Generated ADRs**: Examine each ADR for completeness and accuracy
|
|
2528
|
+
2. **Save ADR Files**: Create individual .md files for each ADR in ${outputDirectory}
|
|
2529
|
+
3. **Update ADR Index**: Add new ADRs to your project's ADR catalog
|
|
2530
|
+
4. **Stakeholder Review**: Share ADRs with team for feedback and approval
|
|
2531
|
+
5. **Implementation Planning**: Create tasks for implementing the architectural decisions
|
|
2532
|
+
|
|
2533
|
+
## File Creation Commands
|
|
2534
|
+
|
|
2535
|
+
To save the generated ADRs, create individual files in ${outputDirectory}:
|
|
2536
|
+
|
|
2537
|
+
\`\`\`bash
|
|
2538
|
+
# Create ADR directory if it doesn't exist
|
|
2539
|
+
mkdir -p ${outputDirectory}
|
|
2540
|
+
|
|
2541
|
+
# Save each ADR as a separate file (example)
|
|
2542
|
+
# Replace [NUMBER] and [TITLE] with actual values from generated ADRs
|
|
2543
|
+
# cat > "${outputDirectory}/001-example-decision.md" << 'EOF'
|
|
2544
|
+
# [ADR content here]
|
|
2545
|
+
# EOF
|
|
2546
|
+
\`\`\`
|
|
2547
|
+
`,
|
|
2548
|
+
});
|
|
2549
|
+
}
|
|
2550
|
+
else {
|
|
2551
|
+
// Fallback to prompt-only mode
|
|
2552
|
+
return {
|
|
2553
|
+
content: [
|
|
2554
|
+
{
|
|
2555
|
+
type: 'text',
|
|
2556
|
+
text: `# Enhanced ADR Generation from PRD: ${prdPath}
|
|
2557
|
+
|
|
2558
|
+
## Advanced Prompt-Driven ADR Generation Process
|
|
2559
|
+
|
|
2560
|
+
This tool uses a 100% prompt-driven architecture enhanced with advanced prompting techniques:
|
|
2561
|
+
|
|
2562
|
+
### Enhancement Features
|
|
2563
|
+
- **APE Optimization**: ${enhancedMode && promptOptimization ? '✅ Enabled - Prompts optimized for superior quality' : '❌ Disabled'}
|
|
2564
|
+
- **Knowledge Generation**: ${enhancedMode && knowledgeEnhancement ? '✅ Enabled - Domain knowledge enhanced analysis' : '❌ Disabled'}
|
|
2565
|
+
- **PRD Type Optimization**: ${prdType} - Tailored for specific domain requirements
|
|
2566
|
+
- **Enhanced Mode**: ${enhancedMode ? '✅ Enabled - All advanced features active' : '❌ Disabled - Basic mode'}
|
|
2567
|
+
|
|
2568
|
+
### Enhanced AI Agent Workflow
|
|
2569
|
+
|
|
2570
|
+
1. **Validate PRD file existence** using secure file system operations
|
|
2571
|
+
2. **Read PRD content** safely with proper security validation
|
|
2572
|
+
3. **Apply domain knowledge** to enhance understanding (if enabled)
|
|
2573
|
+
4. **Generate optimized ADRs** using APE-enhanced prompts (if enabled)
|
|
2574
|
+
5. **Create enhanced ADR files** in the specified output directory: ${outputDirectory}
|
|
2575
|
+
|
|
2576
|
+
## Execution Instructions
|
|
2577
|
+
|
|
2578
|
+
Please execute the following enhanced comprehensive prompt:
|
|
2579
|
+
|
|
2580
|
+
${adrPrompt}
|
|
2581
|
+
|
|
2582
|
+
## Advanced Features
|
|
2583
|
+
|
|
2584
|
+
${enhancedMode && knowledgeEnhancement ? `
|
|
2585
|
+
### Knowledge Enhancement
|
|
2586
|
+
- Domain-specific architectural knowledge has been generated
|
|
2587
|
+
- PRD analysis is enhanced with ${prdType} domain expertise
|
|
2588
|
+
- ADR decisions leverage domain best practices and patterns
|
|
2589
|
+
` : ''}
|
|
2590
|
+
|
|
2591
|
+
${enhancedMode && promptOptimization ? `
|
|
2592
|
+
### APE Optimization
|
|
2593
|
+
- Prompts have been automatically optimized for quality
|
|
2594
|
+
- Enhanced evaluation criteria ensure superior ADR generation
|
|
2595
|
+
- Optimization focused on task completion, clarity, and specificity
|
|
2596
|
+
` : ''}
|
|
2597
|
+
|
|
2598
|
+
## Security and Validation
|
|
2599
|
+
|
|
2600
|
+
- All file operations include security validation
|
|
2601
|
+
- Path traversal protection is enabled
|
|
2602
|
+
- System directory access is prevented
|
|
2603
|
+
- User confirmation is required for file creation
|
|
2604
|
+
- Content validation ensures safe enhanced ADR generation
|
|
2605
|
+
|
|
2606
|
+
## Expected Enhanced Workflow
|
|
2607
|
+
|
|
2608
|
+
1. Execute file existence check for: ${prdPath}
|
|
2609
|
+
2. If file exists, read PRD content securely
|
|
2610
|
+
3. Apply domain knowledge to enhance PRD understanding
|
|
2611
|
+
4. Analyze PRD content using optimized prompts
|
|
2612
|
+
5. Generate domain-enhanced individual ADRs for each decision
|
|
2613
|
+
6. Create file creation prompts for each enhanced ADR
|
|
2614
|
+
7. Confirm with user before writing files to: ${outputDirectory}
|
|
2615
|
+
|
|
2616
|
+
The enhanced process maintains full traceability from PRD requirements to generated ADRs while providing superior quality through advanced prompting techniques and ensuring security and user control over file operations.`
|
|
2617
|
+
}
|
|
2618
|
+
]
|
|
2619
|
+
};
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
catch (error) {
|
|
2623
|
+
throw new McpAdrError(`Failed to generate ADR prompts from PRD: ${error instanceof Error ? error.message : String(error)}`, 'PROMPT_GENERATION_ERROR');
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
async generateAdrTodo(args) {
|
|
2627
|
+
const { scope = 'all', phase = 'both', linkAdrs = true, includeRules = true, ruleSource = 'both' } = args;
|
|
2628
|
+
const { getAdrDirectoryPath } = await import('./utils/config.js');
|
|
2629
|
+
const path = await import('path');
|
|
2630
|
+
// Use absolute ADR path relative to project
|
|
2631
|
+
const absoluteAdrPath = args.adrDirectory ?
|
|
2632
|
+
path.resolve(this.config.projectPath, args.adrDirectory) :
|
|
2633
|
+
getAdrDirectoryPath(this.config);
|
|
2634
|
+
// Keep relative path for display purposes
|
|
2635
|
+
const adrDirectory = args.adrDirectory || this.config.adrDirectory;
|
|
2636
|
+
this.logger.info(`Generating TDD-focused todo for ADRs in: ${absoluteAdrPath} (phase: ${phase})`);
|
|
2637
|
+
try {
|
|
2638
|
+
const { findFiles } = await import('./utils/file-system.js');
|
|
2639
|
+
// Generate file discovery prompt for ADR files using project path as base
|
|
2640
|
+
const adrFilesPrompt = await findFiles(this.config.projectPath, [`${absoluteAdrPath}/**/*.md`], { includeContent: true });
|
|
2641
|
+
// For ADR linking, also discover all project structure
|
|
2642
|
+
let projectStructurePrompt = '';
|
|
2643
|
+
if (linkAdrs) {
|
|
2644
|
+
const projectFiles = await findFiles(this.config.projectPath, [
|
|
2645
|
+
'**/*.{ts,js,py,java,cs,go,rb,php,swift,kt,rs,cpp,c,h}',
|
|
2646
|
+
'!node_modules/**',
|
|
2647
|
+
'!dist/**',
|
|
2648
|
+
'!build/**',
|
|
2649
|
+
'!.git/**'
|
|
2650
|
+
], {
|
|
2651
|
+
includeContent: false
|
|
2652
|
+
});
|
|
2653
|
+
projectStructurePrompt = `
|
|
2654
|
+
## Project Structure (for ADR linking)
|
|
2655
|
+
${projectFiles.prompt}
|
|
2656
|
+
`;
|
|
2657
|
+
}
|
|
2658
|
+
// For rules integration, extract architectural rules from ADRs
|
|
2659
|
+
let rulesPrompt = '';
|
|
2660
|
+
if (includeRules) {
|
|
2661
|
+
try {
|
|
2662
|
+
const rulesResult = await this.generateRules({
|
|
2663
|
+
source: ruleSource,
|
|
2664
|
+
adrDirectory: adrDirectory,
|
|
2665
|
+
projectPath: this.config.projectPath,
|
|
2666
|
+
outputFormat: 'json'
|
|
2667
|
+
});
|
|
2668
|
+
if (rulesResult.content) {
|
|
2669
|
+
rulesPrompt = `
|
|
2670
|
+
## Architectural Rules (for compliance validation)
|
|
2671
|
+
The following architectural rules have been extracted from ADRs and should be validated in tests:
|
|
2672
|
+
|
|
2673
|
+
${Array.isArray(rulesResult.content) ? rulesResult.content.map((c) => c.text || c).join('\n') : rulesResult.content}
|
|
2674
|
+
`;
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
catch (error) {
|
|
2678
|
+
this.logger.warn(`Failed to extract rules: ${error instanceof Error ? error.message : String(error)}`);
|
|
2679
|
+
rulesPrompt = `
|
|
2680
|
+
## Architectural Rules (failed to extract)
|
|
2681
|
+
Note: Could not extract architectural rules automatically. Manual rule validation may be needed.
|
|
2682
|
+
`;
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
// Generate TDD-focused todo creation prompt
|
|
2686
|
+
const todoPrompt = `
|
|
2687
|
+
# TDD-Focused ADR Todo Generation Request
|
|
2688
|
+
|
|
2689
|
+
## Step 1: File Discovery
|
|
2690
|
+
${adrFilesPrompt.prompt}
|
|
2691
|
+
${projectStructurePrompt}
|
|
2692
|
+
${rulesPrompt}
|
|
2693
|
+
|
|
2694
|
+
## Step 2: TDD Todo Generation Analysis
|
|
2695
|
+
|
|
2696
|
+
Once you have discovered and read the ADR files, please analyze them and generate a comprehensive TDD-focused todo.md file.
|
|
2697
|
+
|
|
2698
|
+
## TDD Phase: ${phase}
|
|
2699
|
+
${phase === 'test' ? '**Focus on Phase 1: Mock Test Generation Only**' : ''}
|
|
2700
|
+
${phase === 'production' ? '**Focus on Phase 2: Production Code Implementation (assumes tests exist)**' : ''}
|
|
2701
|
+
${phase === 'both' ? '**Generate both Phase 1 (Tests) and Phase 2 (Production) tasks**' : ''}
|
|
2702
|
+
|
|
2703
|
+
## Requirements
|
|
2704
|
+
|
|
2705
|
+
1. **Extract Tasks**: Identify all implementation tasks from ADRs
|
|
2706
|
+
2. **TDD Approach**: For each task, create:
|
|
2707
|
+
- Phase 1: Mock test specifications
|
|
2708
|
+
- Phase 2: Production implementation tasks
|
|
2709
|
+
3. **ADR Linking**: ${linkAdrs ? 'Link related ADRs to create comprehensive system tests' : 'Focus on individual ADR tasks'}
|
|
2710
|
+
4. **Rules Integration**: ${includeRules ? `Include architectural rules validation in tests (source: ${ruleSource})` : 'Skip architectural rules validation'}
|
|
2711
|
+
5. **Categorize**: Group tasks by ADR and testing phase
|
|
2712
|
+
6. **Status Detection**: Determine task completion status
|
|
2713
|
+
7. **Progress Tracking**: Calculate overall progress for both test and implementation phases
|
|
2714
|
+
8. **Scope Filter**: ${scope === 'all' ? 'Include all tasks' : `Focus on ${scope} tasks only`}
|
|
2715
|
+
|
|
2716
|
+
## TDD Todo.md Format
|
|
2717
|
+
|
|
2718
|
+
\`\`\`markdown
|
|
2719
|
+
# TDD-Focused ADR Implementation Progress
|
|
2720
|
+
|
|
2721
|
+
**Last Updated**: [Date]
|
|
2722
|
+
**Overall Progress**: [X]% Complete
|
|
2723
|
+
**Test Coverage**: [X]% Complete
|
|
2724
|
+
**Implementation Coverage**: [X]% Complete
|
|
2725
|
+
|
|
2726
|
+
## Summary
|
|
2727
|
+
- Total ADRs: [count]
|
|
2728
|
+
- Total Tasks: [count] (Tests: [count], Implementation: [count])
|
|
2729
|
+
- Completed: [count]
|
|
2730
|
+
- In Progress: [count]
|
|
2731
|
+
- Pending: [count]
|
|
2732
|
+
|
|
2733
|
+
## System Architecture Overview (from linked ADRs)
|
|
2734
|
+
[Brief summary of how all ADRs connect to form the complete system]
|
|
2735
|
+
|
|
2736
|
+
## Phase 1: Test Generation Tasks
|
|
2737
|
+
|
|
2738
|
+
### ADR-001: [Title]
|
|
2739
|
+
#### Test Specifications
|
|
2740
|
+
- [ ] TEST: Unit test for [component/function]
|
|
2741
|
+
- Mock: [what to mock]
|
|
2742
|
+
- Expected: [expected behavior]
|
|
2743
|
+
- Coverage: [what this tests]
|
|
2744
|
+
- [ ] TEST: Integration test for [feature]
|
|
2745
|
+
- Setup: [test environment]
|
|
2746
|
+
- Scenario: [test scenario]
|
|
2747
|
+
- Assertions: [what to verify]
|
|
2748
|
+
${includeRules ? `- [ ] RULE: Architectural rule validation test for [rule name]
|
|
2749
|
+
- Validation: [what rule to check]
|
|
2750
|
+
- Pattern: [validation pattern/regex]
|
|
2751
|
+
- Expected: [compliant behavior]` : ''}
|
|
2752
|
+
|
|
2753
|
+
### ADR-002: [Title]
|
|
2754
|
+
#### Test Specifications
|
|
2755
|
+
- [ ] TEST: [test description]
|
|
2756
|
+
${includeRules ? '- [ ] RULE: [rule validation test]' : ''}
|
|
2757
|
+
...
|
|
2758
|
+
|
|
2759
|
+
## Phase 2: Production Implementation Tasks
|
|
2760
|
+
|
|
2761
|
+
### ADR-001: [Title]
|
|
2762
|
+
#### Implementation Tasks (after tests pass)
|
|
2763
|
+
- [ ] IMPL: Implement [component/function]
|
|
2764
|
+
- Precondition: Unit test for [component] exists
|
|
2765
|
+
- Definition: [what to implement]
|
|
2766
|
+
- Acceptance: All related tests pass
|
|
2767
|
+
${includeRules ? ` - Compliance: Must pass architectural rule validation` : ''}
|
|
2768
|
+
- [ ] IMPL: [implementation task]
|
|
1270
2769
|
|
|
1271
2770
|
### ADR-002: [Title]
|
|
1272
|
-
|
|
2771
|
+
#### Implementation Tasks
|
|
2772
|
+
- [ ] IMPL: [implementation description]
|
|
2773
|
+
${includeRules ? ' - Compliance: [specific rule requirements]' : ''}
|
|
1273
2774
|
...
|
|
2775
|
+
|
|
2776
|
+
## ADR Dependencies and Links
|
|
2777
|
+
- ADR-001 → ADR-002: [relationship description]
|
|
2778
|
+
- ADR-002 → ADR-003: [relationship description]
|
|
2779
|
+
|
|
2780
|
+
## Test-First Development Workflow
|
|
2781
|
+
1. Complete all Phase 1 tests for a component
|
|
2782
|
+
${includeRules ? '2. Complete architectural rule validation tests' : ''}
|
|
2783
|
+
${includeRules ? '3' : '2'}. Run tests (they should fail)
|
|
2784
|
+
${includeRules ? '4' : '3'}. Implement Phase 2 production code
|
|
2785
|
+
${includeRules ? '5' : '4'}. Run tests (they should pass)
|
|
2786
|
+
${includeRules ? '6. Validate architectural rule compliance' : ''}
|
|
2787
|
+
${includeRules ? '7' : '5'}. Refactor if needed while maintaining rule compliance
|
|
1274
2788
|
\`\`\`
|
|
1275
2789
|
|
|
1276
2790
|
Please provide:
|
|
1277
2791
|
1. Comprehensive task extraction from all ADRs
|
|
1278
|
-
2.
|
|
1279
|
-
3.
|
|
1280
|
-
4.
|
|
1281
|
-
5.
|
|
2792
|
+
2. Test specifications for each implementation task
|
|
2793
|
+
${includeRules ? '3. Architectural rule validation tests and compliance checks' : ''}
|
|
2794
|
+
${includeRules ? '4' : '3'}. Clear separation of test and implementation phases
|
|
2795
|
+
${includeRules ? '5' : '4'}. ADR relationship mapping for system-wide test coverage
|
|
2796
|
+
${includeRules ? '6' : '5'}. TDD workflow recommendations with rule compliance integration
|
|
1282
2797
|
`;
|
|
1283
|
-
return
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
2798
|
+
// Execute the todo generation with AI if enabled, otherwise return prompt
|
|
2799
|
+
const { executePromptWithFallback, formatMCPResponse } = await import('./utils/prompt-execution.js');
|
|
2800
|
+
const executionResult = await executePromptWithFallback(todoPrompt, 'Generate TDD-focused todo.md file from ADR analysis with test-first approach and system-wide coverage', {
|
|
2801
|
+
temperature: 0.1,
|
|
2802
|
+
maxTokens: 8000,
|
|
2803
|
+
systemPrompt: `You are an expert in Test-Driven Development (TDD) and architectural implementation.
|
|
2804
|
+
Analyze the provided ADRs to extract actionable tasks following a strict TDD approach.
|
|
2805
|
+
|
|
2806
|
+
Key responsibilities:
|
|
2807
|
+
1. For each implementation task, FIRST define the test specifications
|
|
2808
|
+
2. Create mock test descriptions that verify the expected behavior
|
|
2809
|
+
3. Link related ADRs to ensure comprehensive system test coverage
|
|
2810
|
+
4. Separate test generation (Phase 1) from production code (Phase 2)
|
|
2811
|
+
5. Ensure every production task has corresponding test coverage
|
|
2812
|
+
6. Map ADR dependencies to identify integration test requirements
|
|
2813
|
+
${includeRules ? '7. Include architectural rule validation in test specifications' : ''}
|
|
2814
|
+
${includeRules ? '8. Create compliance checks for extracted architectural rules' : ''}
|
|
2815
|
+
${includeRules ? '9. Ensure implementation tasks include rule compliance verification' : ''}
|
|
2816
|
+
|
|
2817
|
+
Follow the TDD red-green-refactor cycle:
|
|
2818
|
+
- Red: Write failing tests first (Phase 1)${includeRules ? ' including rule validation tests' : ''}
|
|
2819
|
+
- Green: Implement minimal code to pass tests (Phase 2)
|
|
2820
|
+
- Refactor: Improve code while keeping tests green${includeRules ? ' and maintaining rule compliance' : ''}
|
|
2821
|
+
|
|
2822
|
+
${includeRules ? 'The architectural rules provide constraints and patterns that must be validated in tests and followed in implementation.' : ''}
|
|
2823
|
+
|
|
2824
|
+
The todo.md should serve as the glue connecting all ADRs into a cohesive, testable${includeRules ? ', rule-compliant' : ''} system.`,
|
|
2825
|
+
responseFormat: 'text'
|
|
2826
|
+
});
|
|
2827
|
+
if (executionResult.isAIGenerated) {
|
|
2828
|
+
// AI execution successful - return actual todo generation results
|
|
2829
|
+
return formatMCPResponse({
|
|
2830
|
+
...executionResult,
|
|
2831
|
+
content: `# TDD-Focused ADR Todo Generation Results
|
|
2832
|
+
|
|
2833
|
+
## Analysis Information
|
|
2834
|
+
- **ADR Directory**: ${adrDirectory}
|
|
2835
|
+
- **Scope**: ${scope}
|
|
2836
|
+
- **TDD Phase**: ${phase}
|
|
2837
|
+
- **ADR Linking**: ${linkAdrs ? 'Enabled' : 'Disabled'}
|
|
2838
|
+
- **Rules Integration**: ${includeRules ? `Enabled (${ruleSource})` : 'Disabled'}
|
|
2839
|
+
|
|
2840
|
+
## AI-Generated TDD Todo Results
|
|
2841
|
+
|
|
2842
|
+
${executionResult.content}
|
|
2843
|
+
|
|
2844
|
+
## TDD Implementation Workflow
|
|
2845
|
+
|
|
2846
|
+
### Phase 1: Test Generation (Red Phase)
|
|
2847
|
+
1. **Review Test Specifications**: Examine each test task for completeness
|
|
2848
|
+
2. **Create Mock Tests**: Implement test files with proper mocking
|
|
2849
|
+
3. **Define Assertions**: Ensure tests verify expected behavior
|
|
2850
|
+
4. **Run Tests**: Confirm all tests fail (red phase)
|
|
2851
|
+
|
|
2852
|
+
### Phase 2: Production Implementation (Green Phase)
|
|
2853
|
+
1. **Implement Minimal Code**: Write just enough code to pass tests
|
|
2854
|
+
2. **Run Tests Again**: Verify tests now pass (green phase)
|
|
2855
|
+
3. **Check Coverage**: Ensure all ADR requirements are tested
|
|
2856
|
+
4. **Integration Testing**: Verify ADR interactions work correctly
|
|
2857
|
+
|
|
2858
|
+
### Phase 3: Refactoring (Refactor Phase)
|
|
2859
|
+
1. **Improve Code Quality**: Refactor while keeping tests green
|
|
2860
|
+
2. **Update Documentation**: Keep ADRs and tests in sync
|
|
2861
|
+
3. **Performance Optimization**: Optimize without breaking tests
|
|
2862
|
+
|
|
2863
|
+
## ADR System Integration
|
|
2864
|
+
|
|
2865
|
+
The todo.md serves as the glue connecting all ADRs by:
|
|
2866
|
+
- **Mapping Dependencies**: Shows how ADRs relate to each other
|
|
2867
|
+
- **System-wide Coverage**: Ensures no gaps in test coverage
|
|
2868
|
+
- **Progress Tracking**: Monitors both test and implementation completion
|
|
2869
|
+
- **Working Environment**: Defines the expected system outcome
|
|
2870
|
+
|
|
2871
|
+
## Integration Commands
|
|
2872
|
+
|
|
2873
|
+
### Generate Test Phase Only:
|
|
2874
|
+
\`\`\`json
|
|
2875
|
+
{
|
|
2876
|
+
"tool": "generate_adr_todo",
|
|
2877
|
+
"args": {
|
|
2878
|
+
"adrDirectory": "${adrDirectory}",
|
|
2879
|
+
"phase": "test",
|
|
2880
|
+
"linkAdrs": true,
|
|
2881
|
+
"includeRules": true,
|
|
2882
|
+
"ruleSource": "both"
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
\`\`\`
|
|
2886
|
+
|
|
2887
|
+
### Generate Production Phase Only:
|
|
2888
|
+
\`\`\`json
|
|
2889
|
+
{
|
|
2890
|
+
"tool": "generate_adr_todo",
|
|
2891
|
+
"args": {
|
|
2892
|
+
"adrDirectory": "${adrDirectory}",
|
|
2893
|
+
"phase": "production",
|
|
2894
|
+
"scope": "pending",
|
|
2895
|
+
"includeRules": true
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
\`\`\`
|
|
2899
|
+
|
|
2900
|
+
### Update Full TDD Todo with Rules:
|
|
2901
|
+
\`\`\`json
|
|
2902
|
+
{
|
|
2903
|
+
"tool": "generate_adr_todo",
|
|
2904
|
+
"args": {
|
|
2905
|
+
"adrDirectory": "${adrDirectory}",
|
|
2906
|
+
"phase": "both",
|
|
2907
|
+
"linkAdrs": true,
|
|
2908
|
+
"includeRules": true,
|
|
2909
|
+
"ruleSource": "both"
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
\`\`\`
|
|
2913
|
+
`,
|
|
2914
|
+
});
|
|
2915
|
+
}
|
|
2916
|
+
else {
|
|
2917
|
+
// Fallback to prompt-only mode
|
|
2918
|
+
return {
|
|
2919
|
+
content: [
|
|
2920
|
+
{
|
|
2921
|
+
type: 'text',
|
|
2922
|
+
text: `TDD-focused ADR todo generation for: ${adrDirectory}\n\nPhase: ${phase}\nADR Linking: ${linkAdrs ? 'Enabled' : 'Disabled'}\nRules Integration: ${includeRules ? `Enabled (${ruleSource})` : 'Disabled'}\nScope: ${scope}\n\nPlease generate a TDD-focused todo.md using the following prompt:\n\n${todoPrompt}`
|
|
2923
|
+
}
|
|
2924
|
+
]
|
|
2925
|
+
};
|
|
2926
|
+
}
|
|
1291
2927
|
}
|
|
1292
2928
|
catch (error) {
|
|
1293
2929
|
throw new McpAdrError(`Failed to generate ADR todo: ${error instanceof Error ? error.message : String(error)}`, 'GENERATION_ERROR');
|
|
1294
2930
|
}
|
|
1295
2931
|
}
|
|
2932
|
+
async compareAdrProgress(args) {
|
|
2933
|
+
const { todoPath = 'TODO.md', adrDirectory = this.config.adrDirectory, projectPath = this.config.projectPath, validationType = 'full', includeFileChecks = true, includeRuleValidation = true, deepCodeAnalysis = true, functionalValidation = true, strictMode = true } = args;
|
|
2934
|
+
const { getAdrDirectoryPath } = await import('./utils/config.js');
|
|
2935
|
+
const path = await import('path');
|
|
2936
|
+
// Resolve paths
|
|
2937
|
+
const absoluteTodoPath = path.resolve(projectPath, todoPath);
|
|
2938
|
+
const absoluteAdrPath = adrDirectory ?
|
|
2939
|
+
path.resolve(projectPath, adrDirectory) :
|
|
2940
|
+
getAdrDirectoryPath(this.config);
|
|
2941
|
+
this.logger.info(`Comparing ADR progress: TODO(${absoluteTodoPath}) vs ADRs(${absoluteAdrPath}) vs Environment(${projectPath})`);
|
|
2942
|
+
try {
|
|
2943
|
+
const { findFiles } = await import('./utils/file-system.js');
|
|
2944
|
+
// Step 1: Discover TODO.md file
|
|
2945
|
+
let todoPrompt = '';
|
|
2946
|
+
if (validationType === 'full' || validationType === 'todo-only') {
|
|
2947
|
+
try {
|
|
2948
|
+
const todoContent = await findFiles(projectPath, [todoPath], { includeContent: true });
|
|
2949
|
+
todoPrompt = `
|
|
2950
|
+
## TODO.md Analysis
|
|
2951
|
+
${todoContent.prompt}
|
|
2952
|
+
`;
|
|
2953
|
+
}
|
|
2954
|
+
catch (error) {
|
|
2955
|
+
todoPrompt = `
|
|
2956
|
+
## TODO.md Analysis
|
|
2957
|
+
Error: Could not read TODO.md file at ${absoluteTodoPath}
|
|
2958
|
+
`;
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
// Step 2: Discover ADR files
|
|
2962
|
+
let adrPrompt = '';
|
|
2963
|
+
if (validationType === 'full' || validationType === 'adr-only') {
|
|
2964
|
+
const adrFiles = await findFiles(projectPath, [`${absoluteAdrPath}/**/*.md`], { includeContent: true });
|
|
2965
|
+
adrPrompt = `
|
|
2966
|
+
## ADR Files Analysis
|
|
2967
|
+
${adrFiles.prompt}
|
|
2968
|
+
`;
|
|
2969
|
+
}
|
|
2970
|
+
// Step 3: Discover project environment
|
|
2971
|
+
let environmentPrompt = '';
|
|
2972
|
+
if (validationType === 'full' || validationType === 'environment-only') {
|
|
2973
|
+
const includeContent = deepCodeAnalysis || functionalValidation;
|
|
2974
|
+
const projectFiles = await findFiles(projectPath, [
|
|
2975
|
+
'**/*.{ts,js,py,java,cs,go,rb,php,swift,kt,rs,cpp,c,h,json,yaml,yml,md}',
|
|
2976
|
+
'!node_modules/**',
|
|
2977
|
+
'!dist/**',
|
|
2978
|
+
'!build/**',
|
|
2979
|
+
'!.git/**',
|
|
2980
|
+
'!coverage/**',
|
|
2981
|
+
'!.mcp-adr-cache/**'
|
|
2982
|
+
], { includeContent });
|
|
2983
|
+
environmentPrompt = `
|
|
2984
|
+
## Project Environment Analysis
|
|
2985
|
+
${projectFiles.prompt}
|
|
2986
|
+
`;
|
|
2987
|
+
}
|
|
2988
|
+
// Step 4: Include architectural rules if requested
|
|
2989
|
+
let rulesPrompt = '';
|
|
2990
|
+
if (includeRuleValidation) {
|
|
2991
|
+
try {
|
|
2992
|
+
const rulesResult = await this.generateRules({
|
|
2993
|
+
source: 'both',
|
|
2994
|
+
adrDirectory: adrDirectory,
|
|
2995
|
+
projectPath: projectPath,
|
|
2996
|
+
outputFormat: 'json'
|
|
2997
|
+
});
|
|
2998
|
+
if (rulesResult.content) {
|
|
2999
|
+
rulesPrompt = `
|
|
3000
|
+
## Architectural Rules Validation
|
|
3001
|
+
${Array.isArray(rulesResult.content) ? rulesResult.content.map((c) => c.text || c).join('\n') : rulesResult.content}
|
|
3002
|
+
`;
|
|
3003
|
+
}
|
|
3004
|
+
}
|
|
3005
|
+
catch (error) {
|
|
3006
|
+
this.logger.warn(`Failed to extract rules for validation: ${error instanceof Error ? error.message : String(error)}`);
|
|
3007
|
+
rulesPrompt = `
|
|
3008
|
+
## Architectural Rules Validation
|
|
3009
|
+
Note: Could not extract architectural rules for validation.
|
|
3010
|
+
`;
|
|
3011
|
+
}
|
|
3012
|
+
}
|
|
3013
|
+
// Generate comparison prompt
|
|
3014
|
+
const comparisonPrompt = `
|
|
3015
|
+
# ADR Progress Validation Request
|
|
3016
|
+
|
|
3017
|
+
## Validation Type: ${validationType}
|
|
3018
|
+
${todoPrompt}
|
|
3019
|
+
${adrPrompt}
|
|
3020
|
+
${environmentPrompt}
|
|
3021
|
+
${rulesPrompt}
|
|
3022
|
+
|
|
3023
|
+
## Validation Requirements
|
|
3024
|
+
|
|
3025
|
+
Please perform a comprehensive comparison and validation between the TODO.md, ADRs, and current project environment:
|
|
3026
|
+
|
|
3027
|
+
### 1. TODO vs ADR Alignment
|
|
3028
|
+
- Verify that all tasks in TODO.md correspond to actual ADR requirements
|
|
3029
|
+
- Identify missing tasks that should be in TODO.md based on ADRs
|
|
3030
|
+
- Check for obsolete tasks that no longer align with current ADRs
|
|
3031
|
+
- Validate that task descriptions match ADR specifications
|
|
3032
|
+
|
|
3033
|
+
### 2. Implementation Status Verification
|
|
3034
|
+
${includeFileChecks ? `- Check file existence for tasks marked as completed
|
|
3035
|
+
- Verify that implemented code matches task specifications
|
|
3036
|
+
- Identify discrepancies between TODO status and actual implementation
|
|
3037
|
+
- Validate that file structures align with ADR requirements` : '- File existence checks disabled'}
|
|
3038
|
+
|
|
3039
|
+
${deepCodeAnalysis ? `### 2.1. Deep Code Analysis (Mock vs Production Detection)
|
|
3040
|
+
- **Mock Detection**: Identify placeholder functions, TODO comments, and stub implementations
|
|
3041
|
+
- **Production Readiness**: Verify code has actual business logic, not just interfaces
|
|
3042
|
+
- **Implementation Depth**: Check for proper error handling, edge cases, and real functionality
|
|
3043
|
+
- **Completeness Validation**: Ensure functions do more than return mock data or throw NotImplementedException` : ''}
|
|
3044
|
+
|
|
3045
|
+
${functionalValidation ? `### 2.2. Functional Validation Against ADR Goals
|
|
3046
|
+
- **Goal Alignment**: Verify implementations actually achieve the architectural goals stated in ADRs
|
|
3047
|
+
- **Environment Testing**: Check if code can run in the intended environment described by ADRs
|
|
3048
|
+
- **Integration Verification**: Validate that components work together as architected
|
|
3049
|
+
- **Performance Requirements**: Verify non-functional requirements from ADRs are met` : ''}
|
|
3050
|
+
|
|
3051
|
+
### 3. Environment vs ADR Compliance
|
|
3052
|
+
- Compare current project structure with ADR decisions
|
|
3053
|
+
- Identify technology choices that deviate from ADRs
|
|
3054
|
+
- Verify that architectural patterns are implemented as specified
|
|
3055
|
+
- Check for missing components or files required by ADRs
|
|
3056
|
+
|
|
3057
|
+
${includeRuleValidation ? `### 4. Architectural Rule Compliance
|
|
3058
|
+
- Validate current code against extracted architectural rules
|
|
3059
|
+
- Identify rule violations in the existing codebase
|
|
3060
|
+
- Check if TODO tasks include necessary rule compliance steps
|
|
3061
|
+
- Verify that completed tasks maintain rule compliance` : ''}
|
|
3062
|
+
|
|
3063
|
+
## Expected Output Format
|
|
3064
|
+
|
|
3065
|
+
\`\`\`markdown
|
|
3066
|
+
# ADR Progress Validation Report
|
|
3067
|
+
|
|
3068
|
+
**Validation Date**: [Date]
|
|
3069
|
+
**Validation Type**: ${validationType}
|
|
3070
|
+
**Project Path**: ${projectPath}
|
|
3071
|
+
|
|
3072
|
+
## Summary
|
|
3073
|
+
- **Total ADRs**: [count]
|
|
3074
|
+
- **Total TODO Tasks**: [count]
|
|
3075
|
+
- **Completed Tasks**: [count]
|
|
3076
|
+
- **Alignment Score**: [percentage]%
|
|
3077
|
+
- **Compliance Score**: [percentage]%
|
|
3078
|
+
|
|
3079
|
+
## Alignment Analysis
|
|
3080
|
+
|
|
3081
|
+
### ✅ Properly Aligned Tasks
|
|
3082
|
+
- [Task name]: Correctly implements [ADR reference]
|
|
3083
|
+
- [Task name]: Status verified, implementation complete
|
|
3084
|
+
|
|
3085
|
+
### ⚠️ Misaligned Tasks
|
|
3086
|
+
- [Task name]: Description doesn't match [ADR reference]
|
|
3087
|
+
- [Task name]: Status marked complete but implementation missing
|
|
3088
|
+
|
|
3089
|
+
### ❌ Missing Tasks
|
|
3090
|
+
- [Missing task]: Required by [ADR reference] but not in TODO
|
|
3091
|
+
- [Missing task]: Implementation needed for [specific requirement]
|
|
3092
|
+
|
|
3093
|
+
### 🗑️ Obsolete Tasks
|
|
3094
|
+
- [Task name]: No longer needed due to [ADR change/superseded]
|
|
3095
|
+
|
|
3096
|
+
## Implementation Status
|
|
3097
|
+
|
|
3098
|
+
### File Existence Validation
|
|
3099
|
+
${includeFileChecks ? `- ✅ [filename]: Exists and matches expectations
|
|
3100
|
+
- ❌ [filename]: Missing but marked as implemented
|
|
3101
|
+
- ⚠️ [filename]: Exists but doesn't match specifications` : '- File checks disabled'}
|
|
3102
|
+
|
|
3103
|
+
${deepCodeAnalysis ? `### Mock vs Production Code Analysis
|
|
3104
|
+
- ✅ **Production Ready**: [component] - Full implementation with business logic
|
|
3105
|
+
- ⚠️ **Partial Implementation**: [component] - Some functionality missing or incomplete
|
|
3106
|
+
- ❌ **Mock/Stub Only**: [component] - Contains only placeholders, interfaces, or TODO comments
|
|
3107
|
+
- 🔍 **Requires Verification**: [component] - Implementation exists but needs deeper inspection
|
|
3108
|
+
|
|
3109
|
+
#### Mock Detection Indicators Found:
|
|
3110
|
+
- TODO comments: [count] instances
|
|
3111
|
+
- Placeholder functions: [count] instances
|
|
3112
|
+
- NotImplementedException: [count] instances
|
|
3113
|
+
- Mock return values: [count] instances
|
|
3114
|
+
- Empty function bodies: [count] instances` : ''}
|
|
3115
|
+
|
|
3116
|
+
${functionalValidation ? `### Functional Validation Results
|
|
3117
|
+
- ✅ **ADR Goal Achieved**: [goal] - Implementation fully meets architectural objective
|
|
3118
|
+
- ⚠️ **Partial Goal Achievement**: [goal] - Implementation partially meets requirements
|
|
3119
|
+
- ❌ **Goal Not Met**: [goal] - Implementation doesn't achieve stated ADR objective
|
|
3120
|
+
- 🚫 **Environment Incompatible**: [component] - Code won't run in target environment
|
|
3121
|
+
|
|
3122
|
+
#### Environment Readiness Assessment:
|
|
3123
|
+
- **Dependency Management**: [status] - All required dependencies available
|
|
3124
|
+
- **Configuration**: [status] - Environment-specific config properly handled
|
|
3125
|
+
- **Integration Points**: [status] - External system connections functional
|
|
3126
|
+
- **Performance Criteria**: [status] - Meets ADR performance requirements` : ''}
|
|
3127
|
+
|
|
3128
|
+
### Code Implementation Review
|
|
3129
|
+
- [Component]: Implementation status and quality assessment
|
|
3130
|
+
- [Feature]: Comparison with ADR requirements
|
|
3131
|
+
|
|
3132
|
+
## Environment Compliance
|
|
3133
|
+
|
|
3134
|
+
### Architecture Alignment
|
|
3135
|
+
- ✅ [Decision]: Correctly implemented
|
|
3136
|
+
- ❌ [Decision]: Not implemented or incorrectly implemented
|
|
3137
|
+
- ⚠️ [Decision]: Partially implemented
|
|
3138
|
+
|
|
3139
|
+
### Technology Stack Validation
|
|
3140
|
+
- [Technology]: Usage aligns with [ADR reference]
|
|
3141
|
+
- [Technology]: Deviation from [ADR decision]
|
|
3142
|
+
|
|
3143
|
+
${includeRuleValidation ? `## Rule Compliance Analysis
|
|
3144
|
+
|
|
3145
|
+
### Rule Violations
|
|
3146
|
+
- [Rule name]: [violation description and location]
|
|
3147
|
+
- [Rule name]: [compliance status]
|
|
3148
|
+
|
|
3149
|
+
### Compliance Recommendations
|
|
3150
|
+
- [Recommendation]: Steps to achieve compliance
|
|
3151
|
+
- [Fix]: Specific changes needed` : ''}
|
|
3152
|
+
|
|
3153
|
+
## Recommendations
|
|
3154
|
+
|
|
3155
|
+
### High Priority Actions
|
|
3156
|
+
1. [Action]: [Reason and expected outcome]
|
|
3157
|
+
2. [Action]: [Priority justification]
|
|
3158
|
+
|
|
3159
|
+
### Medium Priority Actions
|
|
3160
|
+
1. [Action]: [Impact and timeline]
|
|
3161
|
+
|
|
3162
|
+
### Low Priority Actions
|
|
3163
|
+
1. [Action]: [Optional improvements]
|
|
3164
|
+
|
|
3165
|
+
## Next Steps
|
|
3166
|
+
1. Address high-priority alignment issues
|
|
3167
|
+
2. Update TODO.md with missing tasks
|
|
3168
|
+
3. Verify implementation of completed tasks
|
|
3169
|
+
4. Resolve rule compliance violations
|
|
3170
|
+
\`\`\`
|
|
3171
|
+
|
|
3172
|
+
Please provide a comprehensive validation report that helps ensure the TODO.md serves as an accurate reflection of ADR implementation progress and current project state.
|
|
3173
|
+
`;
|
|
3174
|
+
// Execute the comparison with AI if enabled, otherwise return prompt
|
|
3175
|
+
const { executePromptWithFallback, formatMCPResponse } = await import('./utils/prompt-execution.js');
|
|
3176
|
+
const executionResult = await executePromptWithFallback(comparisonPrompt, 'Compare TODO.md progress against ADRs and project environment for validation and alignment', {
|
|
3177
|
+
temperature: 0.1,
|
|
3178
|
+
maxTokens: 10000,
|
|
3179
|
+
systemPrompt: `You are an expert project auditor specializing in ADR implementation validation.
|
|
3180
|
+
Your role is to ensure that TODO lists accurately reflect ADR requirements and implementation reality.
|
|
3181
|
+
|
|
3182
|
+
Key responsibilities:
|
|
3183
|
+
1. Cross-reference TODO tasks with ADR specifications
|
|
3184
|
+
2. Verify implementation status against actual project state
|
|
3185
|
+
3. Identify gaps, misalignments, and obsolete items
|
|
3186
|
+
4. Validate architectural rule compliance
|
|
3187
|
+
5. Provide actionable recommendations for improvement
|
|
3188
|
+
|
|
3189
|
+
${strictMode ? `## STRICT VALIDATION MODE ENABLED
|
|
3190
|
+
|
|
3191
|
+
**CRITICAL**: Apply maximum scrutiny to distinguish between mock and production code:
|
|
3192
|
+
|
|
3193
|
+
### Mock Detection (Mark as ❌ or ⚠️):
|
|
3194
|
+
- Functions that only return hardcoded values or throw NotImplementedException
|
|
3195
|
+
- Classes with empty method bodies or only getter/setter stubs
|
|
3196
|
+
- TODO comments indicating incomplete work
|
|
3197
|
+
- Interface definitions without concrete implementations
|
|
3198
|
+
- Test data or placeholder responses instead of real business logic
|
|
3199
|
+
- Comments like "// TODO: implement this" or "// placeholder"
|
|
3200
|
+
|
|
3201
|
+
### Production Verification (Only mark ✅ if ALL criteria met):
|
|
3202
|
+
- Complete business logic implementation with proper error handling
|
|
3203
|
+
- Real data processing, not just mock responses
|
|
3204
|
+
- Proper integration with external systems/databases as specified in ADRs
|
|
3205
|
+
- Environment-specific configuration and dependency management
|
|
3206
|
+
- Performance and security requirements from ADRs actually implemented
|
|
3207
|
+
|
|
3208
|
+
### ADR Goal Achievement (Be highly critical):
|
|
3209
|
+
- Implementation MUST actually solve the architectural problem stated in the ADR
|
|
3210
|
+
- Code MUST run successfully in the intended environment described by ADRs
|
|
3211
|
+
- Non-functional requirements (performance, security, scalability) MUST be demonstrably met
|
|
3212
|
+
- Integration points MUST be functional, not just stubbed
|
|
3213
|
+
|
|
3214
|
+
**DO NOT** be lenient about completion status. If there's ANY doubt about production readiness, mark as incomplete.` : ''}
|
|
3215
|
+
|
|
3216
|
+
Focus on accuracy, completeness, and practical next steps.
|
|
3217
|
+
Be thorough but concise in your analysis.
|
|
3218
|
+
Prioritize findings by impact and urgency.
|
|
3219
|
+
${strictMode ? 'Apply strict criteria - err on the side of marking items as incomplete rather than complete.' : ''}`,
|
|
3220
|
+
responseFormat: 'text'
|
|
3221
|
+
});
|
|
3222
|
+
if (executionResult.isAIGenerated) {
|
|
3223
|
+
// AI execution successful
|
|
3224
|
+
return formatMCPResponse({
|
|
3225
|
+
...executionResult,
|
|
3226
|
+
content: `# ADR Progress Validation Results
|
|
3227
|
+
|
|
3228
|
+
## Validation Information
|
|
3229
|
+
- **TODO Path**: ${todoPath}
|
|
3230
|
+
- **ADR Directory**: ${adrDirectory}
|
|
3231
|
+
- **Project Path**: ${projectPath}
|
|
3232
|
+
- **Validation Type**: ${validationType}
|
|
3233
|
+
- **File Checks**: ${includeFileChecks ? 'Enabled' : 'Disabled'}
|
|
3234
|
+
- **Rule Validation**: ${includeRuleValidation ? 'Enabled' : 'Disabled'}
|
|
3235
|
+
- **Deep Code Analysis**: ${deepCodeAnalysis ? 'Enabled' : 'Disabled'}
|
|
3236
|
+
- **Functional Validation**: ${functionalValidation ? 'Enabled' : 'Disabled'}
|
|
3237
|
+
- **Strict Mode**: ${strictMode ? 'Enabled - High scrutiny for mock vs production' : 'Disabled'}
|
|
3238
|
+
|
|
3239
|
+
## AI-Generated Validation Report
|
|
3240
|
+
|
|
3241
|
+
${executionResult.content}
|
|
3242
|
+
|
|
3243
|
+
## Integration Commands
|
|
3244
|
+
|
|
3245
|
+
### Regenerate TODO after fixes:
|
|
3246
|
+
\`\`\`json
|
|
3247
|
+
{
|
|
3248
|
+
"tool": "generate_adr_todo",
|
|
3249
|
+
"args": {
|
|
3250
|
+
"adrDirectory": "${adrDirectory}",
|
|
3251
|
+
"phase": "both",
|
|
3252
|
+
"linkAdrs": true,
|
|
3253
|
+
"includeRules": ${includeRuleValidation}
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
\`\`\`
|
|
3257
|
+
|
|
3258
|
+
### Validate architectural rules:
|
|
3259
|
+
\`\`\`json
|
|
3260
|
+
{
|
|
3261
|
+
"tool": "validate_rules",
|
|
3262
|
+
"args": {
|
|
3263
|
+
"projectPath": "${projectPath}",
|
|
3264
|
+
"adrDirectory": "${adrDirectory}"
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
\`\`\`
|
|
3268
|
+
|
|
3269
|
+
### Re-run strict validation after updates:
|
|
3270
|
+
\`\`\`json
|
|
3271
|
+
{
|
|
3272
|
+
"tool": "compare_adr_progress",
|
|
3273
|
+
"args": {
|
|
3274
|
+
"todoPath": "${todoPath}",
|
|
3275
|
+
"adrDirectory": "${adrDirectory}",
|
|
3276
|
+
"validationType": "full",
|
|
3277
|
+
"deepCodeAnalysis": true,
|
|
3278
|
+
"functionalValidation": true,
|
|
3279
|
+
"strictMode": true
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
\`\`\`
|
|
3283
|
+
|
|
3284
|
+
### Quick validation (environment only):
|
|
3285
|
+
\`\`\`json
|
|
3286
|
+
{
|
|
3287
|
+
"tool": "compare_adr_progress",
|
|
3288
|
+
"args": {
|
|
3289
|
+
"validationType": "environment-only",
|
|
3290
|
+
"functionalValidation": true,
|
|
3291
|
+
"strictMode": false
|
|
3292
|
+
}
|
|
3293
|
+
}
|
|
3294
|
+
\`\`\`
|
|
3295
|
+
`,
|
|
3296
|
+
});
|
|
3297
|
+
}
|
|
3298
|
+
else {
|
|
3299
|
+
// Fallback to prompt-only mode
|
|
3300
|
+
return {
|
|
3301
|
+
content: [
|
|
3302
|
+
{
|
|
3303
|
+
type: 'text',
|
|
3304
|
+
text: `ADR progress comparison for: ${todoPath}\n\nValidation Type: ${validationType}\nFile Checks: ${includeFileChecks ? 'Enabled' : 'Disabled'}\nRule Validation: ${includeRuleValidation ? 'Enabled' : 'Disabled'}\nDeep Code Analysis: ${deepCodeAnalysis ? 'Enabled' : 'Disabled'}\nFunctional Validation: ${functionalValidation ? 'Enabled' : 'Disabled'}\nStrict Mode: ${strictMode ? 'Enabled' : 'Disabled'}\n\nPlease perform ADR progress validation using the following prompt:\n\n${comparisonPrompt}`
|
|
3305
|
+
}
|
|
3306
|
+
]
|
|
3307
|
+
};
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3310
|
+
catch (error) {
|
|
3311
|
+
throw new McpAdrError(`Failed to compare ADR progress: ${error instanceof Error ? error.message : String(error)}`, 'VALIDATION_ERROR');
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
1296
3314
|
/**
|
|
1297
3315
|
* Content masking tool implementations
|
|
1298
3316
|
*/
|
|
@@ -1322,29 +3340,55 @@ Please provide:
|
|
|
1322
3340
|
const { clearCache, getCacheStats, cleanupCache, invalidateCache } = await import('./utils/cache.js');
|
|
1323
3341
|
switch (action) {
|
|
1324
3342
|
case 'clear': {
|
|
1325
|
-
await clearCache();
|
|
3343
|
+
const clearPrompt = await clearCache();
|
|
1326
3344
|
return {
|
|
1327
3345
|
content: [
|
|
1328
3346
|
{
|
|
1329
3347
|
type: 'text',
|
|
1330
|
-
text:
|
|
3348
|
+
text: `# Cache Clear Operation
|
|
3349
|
+
|
|
3350
|
+
## AI Delegation Required
|
|
3351
|
+
|
|
3352
|
+
Please execute the following cache clearing operation:
|
|
3353
|
+
|
|
3354
|
+
${clearPrompt.prompt}
|
|
3355
|
+
|
|
3356
|
+
## Implementation Instructions
|
|
3357
|
+
|
|
3358
|
+
${clearPrompt.instructions}
|
|
3359
|
+
|
|
3360
|
+
## Expected Result
|
|
3361
|
+
|
|
3362
|
+
After successful execution, all cache entries will be removed while preserving the cache directory structure and metadata.json file.`
|
|
1331
3363
|
}
|
|
1332
3364
|
]
|
|
1333
3365
|
};
|
|
1334
3366
|
}
|
|
1335
3367
|
case 'stats': {
|
|
1336
|
-
const
|
|
3368
|
+
const statsPrompt = await getCacheStats();
|
|
1337
3369
|
return {
|
|
1338
3370
|
content: [
|
|
1339
3371
|
{
|
|
1340
3372
|
type: 'text',
|
|
1341
|
-
text: `# Cache Statistics
|
|
3373
|
+
text: `# Cache Statistics Collection
|
|
1342
3374
|
|
|
1343
|
-
##
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
3375
|
+
## AI Delegation Required
|
|
3376
|
+
|
|
3377
|
+
Please execute the following cache statistics collection operation:
|
|
3378
|
+
|
|
3379
|
+
${statsPrompt.prompt}
|
|
3380
|
+
|
|
3381
|
+
## Implementation Instructions
|
|
3382
|
+
|
|
3383
|
+
${statsPrompt.instructions}
|
|
3384
|
+
|
|
3385
|
+
## Expected Information
|
|
3386
|
+
|
|
3387
|
+
The AI agent will provide:
|
|
3388
|
+
- **Total Entries**: Number of cache files
|
|
3389
|
+
- **Total Size**: Combined size of all cache files
|
|
3390
|
+
- **Oldest Entry**: Cache key of the oldest entry
|
|
3391
|
+
- **Newest Entry**: Cache key of the newest entry
|
|
1348
3392
|
|
|
1349
3393
|
## Cache Directory
|
|
1350
3394
|
\`.mcp-adr-cache/\`
|
|
@@ -1358,19 +3402,32 @@ Please provide:
|
|
|
1358
3402
|
Use \`manage_cache\` tool with different actions:
|
|
1359
3403
|
- \`clear\`: Remove all cache entries
|
|
1360
3404
|
- \`cleanup\`: Remove expired entries only
|
|
1361
|
-
- \`invalidate\`: Remove specific cache entry
|
|
1362
|
-
`
|
|
3405
|
+
- \`invalidate\`: Remove specific cache entry`
|
|
1363
3406
|
}
|
|
1364
3407
|
]
|
|
1365
3408
|
};
|
|
1366
3409
|
}
|
|
1367
3410
|
case 'cleanup': {
|
|
1368
|
-
const
|
|
3411
|
+
const cleanupPrompt = await cleanupCache();
|
|
1369
3412
|
return {
|
|
1370
3413
|
content: [
|
|
1371
3414
|
{
|
|
1372
3415
|
type: 'text',
|
|
1373
|
-
text:
|
|
3416
|
+
text: `# Cache Cleanup Operation
|
|
3417
|
+
|
|
3418
|
+
## AI Delegation Required
|
|
3419
|
+
|
|
3420
|
+
Please execute the following cache cleanup operation:
|
|
3421
|
+
|
|
3422
|
+
${cleanupPrompt.prompt}
|
|
3423
|
+
|
|
3424
|
+
## Implementation Instructions
|
|
3425
|
+
|
|
3426
|
+
${cleanupPrompt.instructions}
|
|
3427
|
+
|
|
3428
|
+
## Expected Result
|
|
3429
|
+
|
|
3430
|
+
The AI agent will remove expired cache entries and provide a count of cleaned files.`
|
|
1374
3431
|
}
|
|
1375
3432
|
]
|
|
1376
3433
|
};
|
|
@@ -1379,12 +3436,28 @@ Use \`manage_cache\` tool with different actions:
|
|
|
1379
3436
|
if (!key) {
|
|
1380
3437
|
throw new McpAdrError('Cache key is required for invalidate action', 'INVALID_INPUT');
|
|
1381
3438
|
}
|
|
1382
|
-
await invalidateCache(key);
|
|
3439
|
+
const invalidatePrompt = await invalidateCache(key);
|
|
1383
3440
|
return {
|
|
1384
3441
|
content: [
|
|
1385
3442
|
{
|
|
1386
3443
|
type: 'text',
|
|
1387
|
-
text:
|
|
3444
|
+
text: `# Cache Invalidation Operation
|
|
3445
|
+
|
|
3446
|
+
## AI Delegation Required
|
|
3447
|
+
|
|
3448
|
+
Please execute the following cache invalidation operation:
|
|
3449
|
+
|
|
3450
|
+
${invalidatePrompt.prompt}
|
|
3451
|
+
|
|
3452
|
+
## Implementation Instructions
|
|
3453
|
+
|
|
3454
|
+
${invalidatePrompt.instructions}
|
|
3455
|
+
|
|
3456
|
+
## Target Cache Entry
|
|
3457
|
+
|
|
3458
|
+
**Cache Key**: ${key}
|
|
3459
|
+
|
|
3460
|
+
The AI agent will safely remove the specified cache entry.`
|
|
1388
3461
|
}
|
|
1389
3462
|
]
|
|
1390
3463
|
};
|
|
@@ -1497,6 +3570,165 @@ ${newConfig.enabled ?
|
|
|
1497
3570
|
throw new McpAdrError(`Output masking configuration failed: ${error instanceof Error ? error.message : String(error)}`, 'CONFIG_ERROR');
|
|
1498
3571
|
}
|
|
1499
3572
|
}
|
|
3573
|
+
/**
|
|
3574
|
+
* Helper method to get domains based on PRD type
|
|
3575
|
+
*/
|
|
3576
|
+
getPrdTypeDomains(prdType) {
|
|
3577
|
+
const domainMap = {
|
|
3578
|
+
'web-application': ['api-design', 'frontend-architecture', 'database-design', 'security'],
|
|
3579
|
+
'mobile-app': ['mobile-architecture', 'api-design', 'performance-optimization', 'security'],
|
|
3580
|
+
'microservices': ['microservices', 'api-design', 'distributed-systems', 'database-design'],
|
|
3581
|
+
'data-platform': ['database-design', 'data-architecture', 'performance-optimization', 'scalability'],
|
|
3582
|
+
'api-service': ['api-design', 'microservices', 'security', 'performance-optimization'],
|
|
3583
|
+
'general': ['api-design', 'database-design', 'security']
|
|
3584
|
+
};
|
|
3585
|
+
return domainMap[prdType] || domainMap['general'] || ['api-design', 'database-design', 'security'];
|
|
3586
|
+
}
|
|
3587
|
+
/**
|
|
3588
|
+
* Helper method to get domains for ecosystem analysis based on technology focus
|
|
3589
|
+
*/
|
|
3590
|
+
getEcosystemAnalysisDomains(technologyFocus) {
|
|
3591
|
+
// Base domains for ecosystem analysis
|
|
3592
|
+
const baseDomains = ['api-design', 'database-design', 'security', 'performance-optimization'];
|
|
3593
|
+
// Technology-specific domain mapping
|
|
3594
|
+
const technologyDomainMap = {
|
|
3595
|
+
'react': ['frontend-architecture', 'web-applications'],
|
|
3596
|
+
'vue': ['frontend-architecture', 'web-applications'],
|
|
3597
|
+
'angular': ['frontend-architecture', 'web-applications'],
|
|
3598
|
+
'node': ['api-design', 'microservices'],
|
|
3599
|
+
'express': ['api-design', 'web-applications'],
|
|
3600
|
+
'fastify': ['api-design', 'performance-optimization'],
|
|
3601
|
+
'nestjs': ['api-design', 'microservices'],
|
|
3602
|
+
'spring': ['api-design', 'microservices'],
|
|
3603
|
+
'django': ['api-design', 'web-applications'],
|
|
3604
|
+
'flask': ['api-design', 'web-applications'],
|
|
3605
|
+
'rails': ['api-design', 'web-applications'],
|
|
3606
|
+
'laravel': ['api-design', 'web-applications'],
|
|
3607
|
+
'docker': ['containerization', 'microservices'],
|
|
3608
|
+
'kubernetes': ['containerization', 'distributed-systems'],
|
|
3609
|
+
'mongodb': ['database-design', 'data-architecture'],
|
|
3610
|
+
'postgresql': ['database-design', 'data-architecture'],
|
|
3611
|
+
'mysql': ['database-design', 'data-architecture'],
|
|
3612
|
+
'redis': ['database-design', 'performance-optimization'],
|
|
3613
|
+
'elasticsearch': ['database-design', 'data-architecture'],
|
|
3614
|
+
'kafka': ['distributed-systems', 'data-architecture'],
|
|
3615
|
+
'rabbitmq': ['distributed-systems', 'microservices'],
|
|
3616
|
+
'aws': ['cloud-architecture', 'scalability'],
|
|
3617
|
+
'azure': ['cloud-architecture', 'scalability'],
|
|
3618
|
+
'gcp': ['cloud-architecture', 'scalability'],
|
|
3619
|
+
'terraform': ['infrastructure-as-code', 'cloud-architecture'],
|
|
3620
|
+
'ansible': ['infrastructure-as-code', 'automation'],
|
|
3621
|
+
'jenkins': ['ci-cd', 'automation'],
|
|
3622
|
+
'github-actions': ['ci-cd', 'automation'],
|
|
3623
|
+
'gitlab-ci': ['ci-cd', 'automation']
|
|
3624
|
+
};
|
|
3625
|
+
// Collect domains based on technology focus
|
|
3626
|
+
const technologyDomains = new Set();
|
|
3627
|
+
for (const tech of technologyFocus) {
|
|
3628
|
+
const techLower = tech.toLowerCase();
|
|
3629
|
+
const domains = technologyDomainMap[techLower];
|
|
3630
|
+
if (domains) {
|
|
3631
|
+
domains.forEach(domain => technologyDomains.add(domain));
|
|
3632
|
+
}
|
|
3633
|
+
}
|
|
3634
|
+
// Combine base domains with technology-specific domains
|
|
3635
|
+
const allDomains = [...baseDomains, ...Array.from(technologyDomains)];
|
|
3636
|
+
// Remove duplicates and limit to reasonable number
|
|
3637
|
+
const uniqueDomains = [...new Set(allDomains)];
|
|
3638
|
+
// Return up to 6 most relevant domains
|
|
3639
|
+
return uniqueDomains.slice(0, 6);
|
|
3640
|
+
}
|
|
3641
|
+
/**
|
|
3642
|
+
* Helper method to create base ADR generation prompt
|
|
3643
|
+
*/
|
|
3644
|
+
createBaseAdrPrompt(prdPath, outputDirectory, knowledgeContext) {
|
|
3645
|
+
return `
|
|
3646
|
+
# Enhanced ADR Generation from PRD Request
|
|
3647
|
+
|
|
3648
|
+
This is a comprehensive prompt-driven ADR generation process enhanced with domain knowledge and optimized prompting.
|
|
3649
|
+
|
|
3650
|
+
${knowledgeContext}
|
|
3651
|
+
|
|
3652
|
+
## Step 1: File Validation
|
|
3653
|
+
Please verify that the PRD file exists at: ${prdPath}
|
|
3654
|
+
|
|
3655
|
+
## Step 2: PRD Content Reading
|
|
3656
|
+
Read and analyze the PRD content from: ${prdPath}
|
|
3657
|
+
|
|
3658
|
+
## Step 3: Enhanced ADR Generation and Creation
|
|
3659
|
+
|
|
3660
|
+
Once you have successfully read the PRD content, analyze it using the domain knowledge above and generate Architectural Decision Records (ADRs).
|
|
3661
|
+
|
|
3662
|
+
### Enhanced Analysis Requirements
|
|
3663
|
+
|
|
3664
|
+
1. **Extract Key Decisions**: Identify all architectural decisions implied or stated in the PRD
|
|
3665
|
+
2. **Apply Domain Knowledge**: Use the generated domain knowledge to enhance decision analysis
|
|
3666
|
+
3. **Decision Categorization**: Group decisions by:
|
|
3667
|
+
- Technology stack choices (informed by domain best practices)
|
|
3668
|
+
- Architectural patterns (leveraging domain-specific patterns)
|
|
3669
|
+
- Infrastructure decisions (considering domain requirements)
|
|
3670
|
+
- Security considerations (applying domain security knowledge)
|
|
3671
|
+
- Performance requirements (using domain performance insights)
|
|
3672
|
+
- Integration approaches (following domain integration patterns)
|
|
3673
|
+
|
|
3674
|
+
### Enhanced ADR Generation Requirements
|
|
3675
|
+
|
|
3676
|
+
1. **Follow ADR Format**: Use standard ADR template with domain-enhanced content
|
|
3677
|
+
2. **Number Sequentially**: Use format 001-decision-title.md, 002-next-decision.md, etc.
|
|
3678
|
+
3. **Output Directory**: Place ADRs in ${outputDirectory}/
|
|
3679
|
+
4. **Domain Context**: Include relevant domain knowledge in each ADR
|
|
3680
|
+
5. **File Creation**: Generate file creation prompts for each ADR
|
|
3681
|
+
|
|
3682
|
+
### Enhanced ADR Template Format
|
|
3683
|
+
|
|
3684
|
+
\`\`\`markdown
|
|
3685
|
+
# [Number]. [Title]
|
|
3686
|
+
|
|
3687
|
+
**Status**: [Proposed/Accepted/Deprecated/Superseded]
|
|
3688
|
+
**Date**: [YYYY-MM-DD]
|
|
3689
|
+
**Domain**: [Relevant domain from knowledge enhancement]
|
|
3690
|
+
|
|
3691
|
+
## Context
|
|
3692
|
+
[Describe the context and problem statement from PRD, enhanced with domain knowledge]
|
|
3693
|
+
|
|
3694
|
+
## Decision
|
|
3695
|
+
[Describe the architectural decision, informed by domain best practices]
|
|
3696
|
+
|
|
3697
|
+
## Consequences
|
|
3698
|
+
[Describe positive and negative consequences, considering domain-specific implications]
|
|
3699
|
+
|
|
3700
|
+
## Domain Considerations
|
|
3701
|
+
[Specific considerations from the domain knowledge that influenced this decision]
|
|
3702
|
+
|
|
3703
|
+
## Implementation Plan
|
|
3704
|
+
[Steps to implement this decision, leveraging domain expertise]
|
|
3705
|
+
|
|
3706
|
+
## Related PRD Sections
|
|
3707
|
+
[Reference specific sections from the PRD that led to this decision]
|
|
3708
|
+
|
|
3709
|
+
## Domain References
|
|
3710
|
+
[References to domain knowledge that informed this decision]
|
|
3711
|
+
\`\`\`
|
|
3712
|
+
|
|
3713
|
+
### Expected Enhanced Output
|
|
3714
|
+
|
|
3715
|
+
Please provide:
|
|
3716
|
+
1. **File Validation Results**: Confirmation that PRD file exists and is readable
|
|
3717
|
+
2. **PRD Content Summary**: Brief summary enhanced with domain context
|
|
3718
|
+
3. **Domain Analysis**: How domain knowledge applies to this PRD
|
|
3719
|
+
4. **Identified Decisions**: List of all architectural decisions with domain context
|
|
3720
|
+
5. **Generated ADRs**: Complete enhanced ADR content for each decision
|
|
3721
|
+
6. **File Creation Plan**: File names, directory structure, and creation order
|
|
3722
|
+
7. **Implementation Priority**: Recommended order considering domain best practices
|
|
3723
|
+
|
|
3724
|
+
### Quality Assurance with Domain Enhancement
|
|
3725
|
+
|
|
3726
|
+
- Ensure each ADR leverages relevant domain knowledge
|
|
3727
|
+
- Verify decisions align with domain best practices
|
|
3728
|
+
- Check that domain considerations are properly documented
|
|
3729
|
+
- Validate that ADR content is enhanced beyond basic analysis
|
|
3730
|
+
`;
|
|
3731
|
+
}
|
|
1500
3732
|
/**
|
|
1501
3733
|
* ADR suggestion tool implementations
|
|
1502
3734
|
*/
|
|
@@ -1572,16 +3804,16 @@ ${newConfig.enabled ?
|
|
|
1572
3804
|
}
|
|
1573
3805
|
catch (error) {
|
|
1574
3806
|
// If masking fails, log warning and return original response
|
|
1575
|
-
|
|
3807
|
+
// Log to stderr to avoid corrupting MCP protocol
|
|
3808
|
+
console.error('[WARN] Output masking failed:', error);
|
|
1576
3809
|
return response;
|
|
1577
3810
|
}
|
|
1578
3811
|
}
|
|
1579
3812
|
/**
|
|
1580
|
-
* Read MCP resource with caching
|
|
3813
|
+
* Read MCP resource with prompt-driven caching
|
|
1581
3814
|
*/
|
|
1582
3815
|
async readResource(uri) {
|
|
1583
3816
|
try {
|
|
1584
|
-
const { getCachedOrGenerate } = await import('./utils/cache.js');
|
|
1585
3817
|
// Parse URI to determine resource type and parameters
|
|
1586
3818
|
const url = new globalThis.URL(uri);
|
|
1587
3819
|
const resourceType = url.pathname.replace('/', '');
|
|
@@ -1590,7 +3822,8 @@ ${newConfig.enabled ?
|
|
|
1590
3822
|
case 'architectural_knowledge_graph': {
|
|
1591
3823
|
const { generateArchitecturalKnowledgeGraph } = await import('./resources/index.js');
|
|
1592
3824
|
const projectPath = params['projectPath'] || process.cwd();
|
|
1593
|
-
|
|
3825
|
+
// Generate resource directly (caching is now handled through AI delegation)
|
|
3826
|
+
const result = await generateArchitecturalKnowledgeGraph(projectPath);
|
|
1594
3827
|
return {
|
|
1595
3828
|
contents: [
|
|
1596
3829
|
{
|
|
@@ -1605,7 +3838,8 @@ ${newConfig.enabled ?
|
|
|
1605
3838
|
const { generateAnalysisReport } = await import('./resources/index.js');
|
|
1606
3839
|
const projectPath = params['projectPath'] || process.cwd();
|
|
1607
3840
|
const focusAreas = params['focusAreas'] ? params['focusAreas'].split(',') : undefined;
|
|
1608
|
-
|
|
3841
|
+
// Generate resource directly (caching is now handled through AI delegation)
|
|
3842
|
+
const result = await generateAnalysisReport(projectPath, focusAreas);
|
|
1609
3843
|
return {
|
|
1610
3844
|
contents: [
|
|
1611
3845
|
{
|
|
@@ -1618,8 +3852,14 @@ ${newConfig.enabled ?
|
|
|
1618
3852
|
}
|
|
1619
3853
|
case 'adr_list': {
|
|
1620
3854
|
const { generateAdrList } = await import('./resources/index.js');
|
|
1621
|
-
const
|
|
1622
|
-
const
|
|
3855
|
+
const { getAdrDirectoryPath } = await import('./utils/config.js');
|
|
3856
|
+
const path = await import('path');
|
|
3857
|
+
// Use absolute ADR path relative to project
|
|
3858
|
+
const absoluteAdrPath = params['adrDirectory'] ?
|
|
3859
|
+
path.resolve(this.config.projectPath, params['adrDirectory']) :
|
|
3860
|
+
getAdrDirectoryPath(this.config);
|
|
3861
|
+
// Generate resource directly (caching is now handled through AI delegation)
|
|
3862
|
+
const result = await generateAdrList(absoluteAdrPath, this.config.projectPath);
|
|
1623
3863
|
return {
|
|
1624
3864
|
contents: [
|
|
1625
3865
|
{
|
|
@@ -1713,7 +3953,11 @@ Examples:
|
|
|
1713
3953
|
}
|
|
1714
3954
|
}
|
|
1715
3955
|
// Start the server if this file is run directly
|
|
1716
|
-
|
|
3956
|
+
// Jest-compatible check: avoid import.meta.url which Jest cannot handle
|
|
3957
|
+
// Handle both direct execution and npm global package symlinks
|
|
3958
|
+
if (process.argv[1] && (process.argv[1].endsWith('index.js') ||
|
|
3959
|
+
process.argv[1].endsWith('index.ts') ||
|
|
3960
|
+
process.argv[1].endsWith('mcp-adr-analysis-server'))) {
|
|
1717
3961
|
main().catch((error) => {
|
|
1718
3962
|
console.error('Unhandled error:', error);
|
|
1719
3963
|
process.exit(1);
|