mcp-adr-analysis-server 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +608 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +1722 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/prompts/adr-suggestion-prompts.d.ts +24 -0
- package/dist/src/prompts/adr-suggestion-prompts.d.ts.map +1 -0
- package/dist/src/prompts/adr-suggestion-prompts.js +383 -0
- package/dist/src/prompts/adr-suggestion-prompts.js.map +1 -0
- package/dist/src/prompts/analysis-prompts.d.ts +24 -0
- package/dist/src/prompts/analysis-prompts.d.ts.map +1 -0
- package/dist/src/prompts/analysis-prompts.js +489 -0
- package/dist/src/prompts/analysis-prompts.js.map +1 -0
- package/dist/src/prompts/deployment-analysis-prompts.d.ts +54 -0
- package/dist/src/prompts/deployment-analysis-prompts.d.ts.map +1 -0
- package/dist/src/prompts/deployment-analysis-prompts.js +712 -0
- package/dist/src/prompts/deployment-analysis-prompts.js.map +1 -0
- package/dist/src/prompts/environment-analysis-prompts.d.ts +34 -0
- package/dist/src/prompts/environment-analysis-prompts.d.ts.map +1 -0
- package/dist/src/prompts/environment-analysis-prompts.js +724 -0
- package/dist/src/prompts/environment-analysis-prompts.js.map +1 -0
- package/dist/src/prompts/index.d.ts +43 -0
- package/dist/src/prompts/index.d.ts.map +1 -0
- package/dist/src/prompts/index.js +384 -0
- package/dist/src/prompts/index.js.map +1 -0
- package/dist/src/prompts/research-integration-prompts.d.ts +43 -0
- package/dist/src/prompts/research-integration-prompts.d.ts.map +1 -0
- package/dist/src/prompts/research-integration-prompts.js +398 -0
- package/dist/src/prompts/research-integration-prompts.js.map +1 -0
- package/dist/src/prompts/research-question-prompts.d.ts +75 -0
- package/dist/src/prompts/research-question-prompts.d.ts.map +1 -0
- package/dist/src/prompts/research-question-prompts.js +695 -0
- package/dist/src/prompts/research-question-prompts.js.map +1 -0
- package/dist/src/prompts/rule-generation-prompts.d.ts +63 -0
- package/dist/src/prompts/rule-generation-prompts.d.ts.map +1 -0
- package/dist/src/prompts/rule-generation-prompts.js +630 -0
- package/dist/src/prompts/rule-generation-prompts.js.map +1 -0
- package/dist/src/prompts/security-prompts.d.ts +23 -0
- package/dist/src/prompts/security-prompts.d.ts.map +1 -0
- package/dist/src/prompts/security-prompts.js +287 -0
- package/dist/src/prompts/security-prompts.js.map +1 -0
- package/dist/src/resources/index.d.ts +24 -0
- package/dist/src/resources/index.d.ts.map +1 -0
- package/dist/src/resources/index.js +458 -0
- package/dist/src/resources/index.js.map +1 -0
- package/dist/src/tools/adr-suggestion-tool.d.ts +40 -0
- package/dist/src/tools/adr-suggestion-tool.d.ts.map +1 -0
- package/dist/src/tools/adr-suggestion-tool.js +338 -0
- package/dist/src/tools/adr-suggestion-tool.js.map +1 -0
- package/dist/src/tools/content-masking-tool.d.ts +52 -0
- package/dist/src/tools/content-masking-tool.d.ts.map +1 -0
- package/dist/src/tools/content-masking-tool.js +206 -0
- package/dist/src/tools/content-masking-tool.js.map +1 -0
- package/dist/src/tools/deployment-analysis-tool.d.ts +39 -0
- package/dist/src/tools/deployment-analysis-tool.d.ts.map +1 -0
- package/dist/src/tools/deployment-analysis-tool.js +310 -0
- package/dist/src/tools/deployment-analysis-tool.js.map +1 -0
- package/dist/src/tools/environment-analysis-tool.d.ts +16 -0
- package/dist/src/tools/environment-analysis-tool.d.ts.map +1 -0
- package/dist/src/tools/environment-analysis-tool.js +298 -0
- package/dist/src/tools/environment-analysis-tool.js.map +1 -0
- package/dist/src/tools/research-integration-tool.d.ts +44 -0
- package/dist/src/tools/research-integration-tool.d.ts.map +1 -0
- package/dist/src/tools/research-integration-tool.js +429 -0
- package/dist/src/tools/research-integration-tool.js.map +1 -0
- package/dist/src/tools/research-question-tool.d.ts +55 -0
- package/dist/src/tools/research-question-tool.d.ts.map +1 -0
- package/dist/src/tools/research-question-tool.js +333 -0
- package/dist/src/tools/research-question-tool.js.map +1 -0
- package/dist/src/tools/rule-generation-tool.d.ts +49 -0
- package/dist/src/tools/rule-generation-tool.d.ts.map +1 -0
- package/dist/src/tools/rule-generation-tool.js +432 -0
- package/dist/src/tools/rule-generation-tool.js.map +1 -0
- package/dist/src/types/index.d.ts +531 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +129 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/utils/adr-suggestions.d.ts +104 -0
- package/dist/src/utils/adr-suggestions.d.ts.map +1 -0
- package/dist/src/utils/adr-suggestions.js +228 -0
- package/dist/src/utils/adr-suggestions.js.map +1 -0
- package/dist/src/utils/cache.d.ts +51 -0
- package/dist/src/utils/cache.d.ts.map +1 -0
- package/dist/src/utils/cache.js +243 -0
- package/dist/src/utils/cache.js.map +1 -0
- package/dist/src/utils/config.d.ts +65 -0
- package/dist/src/utils/config.d.ts.map +1 -0
- package/dist/src/utils/config.js +118 -0
- package/dist/src/utils/config.js.map +1 -0
- package/dist/src/utils/content-masking.d.ts +79 -0
- package/dist/src/utils/content-masking.d.ts.map +1 -0
- package/dist/src/utils/content-masking.js +203 -0
- package/dist/src/utils/content-masking.js.map +1 -0
- package/dist/src/utils/deployment-analysis.d.ts +67 -0
- package/dist/src/utils/deployment-analysis.d.ts.map +1 -0
- package/dist/src/utils/deployment-analysis.js +263 -0
- package/dist/src/utils/deployment-analysis.js.map +1 -0
- package/dist/src/utils/environment-analysis.d.ts +76 -0
- package/dist/src/utils/environment-analysis.d.ts.map +1 -0
- package/dist/src/utils/environment-analysis.js +329 -0
- package/dist/src/utils/environment-analysis.js.map +1 -0
- package/dist/src/utils/file-system.d.ts +63 -0
- package/dist/src/utils/file-system.d.ts.map +1 -0
- package/dist/src/utils/file-system.js +189 -0
- package/dist/src/utils/file-system.js.map +1 -0
- package/dist/src/utils/output-masking.d.ts +45 -0
- package/dist/src/utils/output-masking.d.ts.map +1 -0
- package/dist/src/utils/output-masking.js +200 -0
- package/dist/src/utils/output-masking.js.map +1 -0
- package/dist/src/utils/research-documentation.d.ts +58 -0
- package/dist/src/utils/research-documentation.d.ts.map +1 -0
- package/dist/src/utils/research-documentation.js +438 -0
- package/dist/src/utils/research-documentation.js.map +1 -0
- package/dist/src/utils/research-integration.d.ts +89 -0
- package/dist/src/utils/research-integration.d.ts.map +1 -0
- package/dist/src/utils/research-integration.js +432 -0
- package/dist/src/utils/research-integration.js.map +1 -0
- package/dist/src/utils/research-questions.d.ts +97 -0
- package/dist/src/utils/research-questions.d.ts.map +1 -0
- package/dist/src/utils/research-questions.js +319 -0
- package/dist/src/utils/research-questions.js.map +1 -0
- package/dist/src/utils/rule-format.d.ts +76 -0
- package/dist/src/utils/rule-format.d.ts.map +1 -0
- package/dist/src/utils/rule-format.js +257 -0
- package/dist/src/utils/rule-format.js.map +1 -0
- package/dist/src/utils/rule-generation.d.ts +86 -0
- package/dist/src/utils/rule-generation.d.ts.map +1 -0
- package/dist/src/utils/rule-generation.js +330 -0
- package/dist/src/utils/rule-generation.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Resource implementations using prompt-driven approach
|
|
3
|
+
* Generates structured data resources for architectural analysis
|
|
4
|
+
*/
|
|
5
|
+
import { McpAdrError } from '../types/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Generate architectural knowledge graph resource
|
|
8
|
+
*/
|
|
9
|
+
export async function generateArchitecturalKnowledgeGraph(projectPath) {
|
|
10
|
+
try {
|
|
11
|
+
const { analyzeProjectStructure } = await import('../utils/file-system.js');
|
|
12
|
+
const { generateAnalysisContext, generateComprehensiveAnalysisPrompt } = await import('../prompts/analysis-prompts.js');
|
|
13
|
+
// Analyze project structure
|
|
14
|
+
const projectStructure = await analyzeProjectStructure(projectPath);
|
|
15
|
+
const analysisContext = generateAnalysisContext(projectStructure);
|
|
16
|
+
// Generate comprehensive analysis prompt
|
|
17
|
+
const analysisPrompt = generateComprehensiveAnalysisPrompt(analysisContext);
|
|
18
|
+
// Create knowledge graph structure with prompt for AI completion
|
|
19
|
+
const knowledgeGraphPrompt = `
|
|
20
|
+
# Architectural Knowledge Graph Generation
|
|
21
|
+
|
|
22
|
+
Please generate a complete architectural knowledge graph based on the following project analysis.
|
|
23
|
+
|
|
24
|
+
${analysisPrompt}
|
|
25
|
+
|
|
26
|
+
## Required Output Format
|
|
27
|
+
|
|
28
|
+
Please provide the architectural knowledge graph in the following JSON structure:
|
|
29
|
+
|
|
30
|
+
\`\`\`json
|
|
31
|
+
{
|
|
32
|
+
"projectId": "unique-project-identifier",
|
|
33
|
+
"timestamp": "ISO-8601-timestamp",
|
|
34
|
+
"metadata": {
|
|
35
|
+
"name": "project-name",
|
|
36
|
+
"description": "project-description",
|
|
37
|
+
"version": "detected-version",
|
|
38
|
+
"lastAnalyzed": "ISO-8601-timestamp",
|
|
39
|
+
"analysisVersion": "1.0.0",
|
|
40
|
+
"fileCount": ${projectStructure.totalFiles},
|
|
41
|
+
"directoryCount": ${projectStructure.totalDirectories}
|
|
42
|
+
},
|
|
43
|
+
"technologies": [
|
|
44
|
+
{
|
|
45
|
+
"name": "Technology Name",
|
|
46
|
+
"category": "framework|library|database|cloud|devops|language|tool",
|
|
47
|
+
"version": "version-if-detectable",
|
|
48
|
+
"confidence": 0.0-1.0,
|
|
49
|
+
"evidence": ["specific-evidence"],
|
|
50
|
+
"filePaths": ["relevant-file-paths"],
|
|
51
|
+
"description": "brief-description"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"patterns": [
|
|
55
|
+
{
|
|
56
|
+
"name": "Pattern Name",
|
|
57
|
+
"type": "architectural|structural|organizational|communication|testing|data",
|
|
58
|
+
"confidence": 0.0-1.0,
|
|
59
|
+
"description": "pattern-description",
|
|
60
|
+
"evidence": ["specific-evidence"],
|
|
61
|
+
"filePaths": ["relevant-file-paths"],
|
|
62
|
+
"suboptimal": false,
|
|
63
|
+
"recommendations": ["improvement-suggestions"]
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"adrs": [
|
|
67
|
+
{
|
|
68
|
+
"id": "adr-id",
|
|
69
|
+
"title": "ADR Title",
|
|
70
|
+
"status": "proposed|accepted|deprecated|superseded",
|
|
71
|
+
"date": "YYYY-MM-DD",
|
|
72
|
+
"context": "decision-context",
|
|
73
|
+
"decision": "architectural-decision",
|
|
74
|
+
"consequences": "decision-consequences",
|
|
75
|
+
"filePath": "path-to-adr-file",
|
|
76
|
+
"tags": ["relevant-tags"],
|
|
77
|
+
"relatedAdrs": ["related-adr-ids"]
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"rules": [
|
|
81
|
+
{
|
|
82
|
+
"id": "rule-id",
|
|
83
|
+
"name": "Rule Name",
|
|
84
|
+
"description": "rule-description",
|
|
85
|
+
"type": "architectural|coding|security|performance|documentation",
|
|
86
|
+
"severity": "info|warning|error|critical",
|
|
87
|
+
"pattern": "detection-pattern",
|
|
88
|
+
"message": "violation-message",
|
|
89
|
+
"source": "adr|inferred|user_defined",
|
|
90
|
+
"enabled": true
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"relationships": [
|
|
94
|
+
{
|
|
95
|
+
"source": "source-entity-id",
|
|
96
|
+
"target": "target-entity-id",
|
|
97
|
+
"type": "implements|depends_on|conflicts_with|supersedes|relates_to",
|
|
98
|
+
"strength": 0.0-1.0,
|
|
99
|
+
"description": "relationship-description"
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
\`\`\`
|
|
104
|
+
|
|
105
|
+
## Analysis Guidelines
|
|
106
|
+
|
|
107
|
+
1. **Comprehensive Detection**: Identify all technologies, patterns, and architectural decisions
|
|
108
|
+
2. **Evidence-Based**: Provide specific evidence for all detections
|
|
109
|
+
3. **Relationship Mapping**: Identify relationships between components
|
|
110
|
+
4. **Quality Assessment**: Evaluate implementation quality and provide recommendations
|
|
111
|
+
5. **Future-Focused**: Consider scalability and maintainability implications
|
|
112
|
+
|
|
113
|
+
Please generate a complete, accurate architectural knowledge graph.
|
|
114
|
+
`;
|
|
115
|
+
const cacheKey = `knowledge-graph:${Buffer.from(projectPath).toString('base64')}`;
|
|
116
|
+
return {
|
|
117
|
+
data: {
|
|
118
|
+
prompt: knowledgeGraphPrompt,
|
|
119
|
+
instructions: `
|
|
120
|
+
# Architectural Knowledge Graph Resource
|
|
121
|
+
|
|
122
|
+
This resource provides a comprehensive view of the project's architectural landscape.
|
|
123
|
+
|
|
124
|
+
## Usage Instructions
|
|
125
|
+
|
|
126
|
+
1. **Submit the generated prompt** to an AI agent for analysis
|
|
127
|
+
2. **Parse the JSON response** as an ArchitecturalKnowledgeGraph
|
|
128
|
+
3. **Cache the result** for performance optimization
|
|
129
|
+
4. **Use the data** for architectural decision making and analysis
|
|
130
|
+
|
|
131
|
+
## Resource Content
|
|
132
|
+
|
|
133
|
+
The knowledge graph includes:
|
|
134
|
+
- **Technologies**: All detected frameworks, libraries, tools, and platforms
|
|
135
|
+
- **Patterns**: Architectural and design patterns in use
|
|
136
|
+
- **ADRs**: Existing architectural decision records
|
|
137
|
+
- **Rules**: Extracted and inferred architectural rules
|
|
138
|
+
- **Relationships**: Connections between architectural components
|
|
139
|
+
|
|
140
|
+
## Next Steps
|
|
141
|
+
|
|
142
|
+
Submit the prompt to generate the actual knowledge graph data.
|
|
143
|
+
`,
|
|
144
|
+
projectPath,
|
|
145
|
+
analysisContext: JSON.parse(analysisContext),
|
|
146
|
+
},
|
|
147
|
+
contentType: 'application/json',
|
|
148
|
+
lastModified: new Date().toISOString(),
|
|
149
|
+
cacheKey,
|
|
150
|
+
ttl: 3600, // 1 hour cache
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
throw new McpAdrError(`Failed to generate architectural knowledge graph: ${error instanceof Error ? error.message : String(error)}`, 'RESOURCE_GENERATION_ERROR');
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Generate analysis report resource
|
|
159
|
+
*/
|
|
160
|
+
export async function generateAnalysisReport(projectPath, focusAreas) {
|
|
161
|
+
try {
|
|
162
|
+
const { analyzeProjectStructure } = await import('../utils/file-system.js');
|
|
163
|
+
const { generateAnalysisContext } = await import('../prompts/analysis-prompts.js');
|
|
164
|
+
// Analyze project structure
|
|
165
|
+
const projectStructure = await analyzeProjectStructure(projectPath);
|
|
166
|
+
const analysisContext = generateAnalysisContext(projectStructure);
|
|
167
|
+
const reportPrompt = `
|
|
168
|
+
# Project Analysis Report Generation
|
|
169
|
+
|
|
170
|
+
Please generate a comprehensive analysis report for this project.
|
|
171
|
+
|
|
172
|
+
## Project Context
|
|
173
|
+
\`\`\`json
|
|
174
|
+
${analysisContext}
|
|
175
|
+
\`\`\`
|
|
176
|
+
|
|
177
|
+
${focusAreas
|
|
178
|
+
? `## Focus Areas
|
|
179
|
+
${focusAreas.join(', ')}`
|
|
180
|
+
: ''}
|
|
181
|
+
|
|
182
|
+
## Required Report Format
|
|
183
|
+
|
|
184
|
+
Please provide the analysis report in the following JSON structure:
|
|
185
|
+
|
|
186
|
+
\`\`\`json
|
|
187
|
+
{
|
|
188
|
+
"reportId": "unique-report-id",
|
|
189
|
+
"timestamp": "ISO-8601-timestamp",
|
|
190
|
+
"projectSummary": {
|
|
191
|
+
"name": "project-name",
|
|
192
|
+
"type": "web|mobile|api|library|tool|other",
|
|
193
|
+
"description": "project-description",
|
|
194
|
+
"maturityLevel": "prototype|development|production|mature",
|
|
195
|
+
"primaryLanguages": ["detected-languages"],
|
|
196
|
+
"estimatedSize": "small|medium|large|enterprise"
|
|
197
|
+
},
|
|
198
|
+
"executiveSummary": {
|
|
199
|
+
"overallHealth": "excellent|good|fair|poor",
|
|
200
|
+
"keyStrengths": ["identified-strengths"],
|
|
201
|
+
"criticalIssues": ["critical-issues"],
|
|
202
|
+
"recommendedActions": ["priority-actions"],
|
|
203
|
+
"riskLevel": "low|medium|high|critical"
|
|
204
|
+
},
|
|
205
|
+
"technicalAnalysis": {
|
|
206
|
+
"technologyStack": {
|
|
207
|
+
"score": 0.0-1.0,
|
|
208
|
+
"assessment": "technology-stack-assessment",
|
|
209
|
+
"recommendations": ["technology-recommendations"]
|
|
210
|
+
},
|
|
211
|
+
"architecturalPatterns": {
|
|
212
|
+
"score": 0.0-1.0,
|
|
213
|
+
"assessment": "pattern-implementation-assessment",
|
|
214
|
+
"recommendations": ["pattern-recommendations"]
|
|
215
|
+
},
|
|
216
|
+
"codeQuality": {
|
|
217
|
+
"score": 0.0-1.0,
|
|
218
|
+
"assessment": "code-quality-assessment",
|
|
219
|
+
"recommendations": ["quality-recommendations"]
|
|
220
|
+
},
|
|
221
|
+
"security": {
|
|
222
|
+
"score": 0.0-1.0,
|
|
223
|
+
"assessment": "security-posture-assessment",
|
|
224
|
+
"recommendations": ["security-recommendations"]
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
"detailedFindings": [
|
|
228
|
+
{
|
|
229
|
+
"category": "technology|architecture|security|performance|maintainability",
|
|
230
|
+
"title": "finding-title",
|
|
231
|
+
"severity": "low|medium|high|critical",
|
|
232
|
+
"description": "detailed-description",
|
|
233
|
+
"impact": "potential-impact",
|
|
234
|
+
"recommendation": "specific-recommendation",
|
|
235
|
+
"effort": "low|medium|high",
|
|
236
|
+
"priority": "low|medium|high|critical"
|
|
237
|
+
}
|
|
238
|
+
],
|
|
239
|
+
"metrics": {
|
|
240
|
+
"technologiesDetected": 0,
|
|
241
|
+
"patternsIdentified": 0,
|
|
242
|
+
"adrsFound": 0,
|
|
243
|
+
"rulesExtracted": 0,
|
|
244
|
+
"overallScore": 0.0-1.0
|
|
245
|
+
},
|
|
246
|
+
"actionPlan": {
|
|
247
|
+
"immediate": ["urgent-actions"],
|
|
248
|
+
"shortTerm": ["1-3-month-actions"],
|
|
249
|
+
"longTerm": ["6-12-month-actions"],
|
|
250
|
+
"strategic": ["long-term-strategic-actions"]
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
\`\`\`
|
|
254
|
+
|
|
255
|
+
## Analysis Guidelines
|
|
256
|
+
|
|
257
|
+
1. **Holistic Assessment**: Consider all aspects of the project
|
|
258
|
+
2. **Actionable Insights**: Provide specific, implementable recommendations
|
|
259
|
+
3. **Risk Assessment**: Identify and prioritize risks
|
|
260
|
+
4. **Business Impact**: Consider business implications of technical decisions
|
|
261
|
+
5. **Roadmap Planning**: Provide clear action plans with timelines
|
|
262
|
+
|
|
263
|
+
Please generate a comprehensive, actionable analysis report.
|
|
264
|
+
`;
|
|
265
|
+
const cacheKey = `analysis-report:${Buffer.from(projectPath + (focusAreas?.join(',') || '')).toString('base64')}`;
|
|
266
|
+
return {
|
|
267
|
+
data: {
|
|
268
|
+
prompt: reportPrompt,
|
|
269
|
+
instructions: `
|
|
270
|
+
# Analysis Report Resource
|
|
271
|
+
|
|
272
|
+
This resource provides a comprehensive analysis report of the project's current state and recommendations.
|
|
273
|
+
|
|
274
|
+
## Usage Instructions
|
|
275
|
+
|
|
276
|
+
1. **Submit the generated prompt** to an AI agent for analysis
|
|
277
|
+
2. **Parse the JSON response** as an analysis report
|
|
278
|
+
3. **Use the findings** for decision making and planning
|
|
279
|
+
4. **Track progress** against recommended actions
|
|
280
|
+
|
|
281
|
+
## Report Content
|
|
282
|
+
|
|
283
|
+
The analysis report includes:
|
|
284
|
+
- **Executive Summary**: High-level assessment and key findings
|
|
285
|
+
- **Technical Analysis**: Detailed technical evaluation with scores
|
|
286
|
+
- **Detailed Findings**: Specific issues and recommendations
|
|
287
|
+
- **Metrics**: Quantitative assessment data
|
|
288
|
+
- **Action Plan**: Prioritized roadmap for improvements
|
|
289
|
+
|
|
290
|
+
## Next Steps
|
|
291
|
+
|
|
292
|
+
Submit the prompt to generate the actual analysis report.
|
|
293
|
+
`,
|
|
294
|
+
projectPath,
|
|
295
|
+
focusAreas,
|
|
296
|
+
analysisContext: JSON.parse(analysisContext),
|
|
297
|
+
},
|
|
298
|
+
contentType: 'application/json',
|
|
299
|
+
lastModified: new Date().toISOString(),
|
|
300
|
+
cacheKey,
|
|
301
|
+
ttl: 1800, // 30 minutes cache
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
catch (error) {
|
|
305
|
+
throw new McpAdrError(`Failed to generate analysis report: ${error instanceof Error ? error.message : String(error)}`, 'RESOURCE_GENERATION_ERROR');
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Generate ADR list resource
|
|
310
|
+
*/
|
|
311
|
+
export async function generateAdrList(adrDirectory = 'docs/adrs') {
|
|
312
|
+
try {
|
|
313
|
+
const { findFiles } = await import('../utils/file-system.js');
|
|
314
|
+
// Find all ADR files
|
|
315
|
+
const adrFiles = await findFiles(process.cwd(), [`${adrDirectory}/**/*.md`], {
|
|
316
|
+
includeContent: true,
|
|
317
|
+
});
|
|
318
|
+
const adrListPrompt = `
|
|
319
|
+
# ADR List Resource Generation
|
|
320
|
+
|
|
321
|
+
Please analyze the following ADR files and generate a structured ADR list resource.
|
|
322
|
+
|
|
323
|
+
## ADR Files Found
|
|
324
|
+
${adrFiles.length === 0
|
|
325
|
+
? 'No ADR files found in the specified directory.'
|
|
326
|
+
: adrFiles
|
|
327
|
+
.map((file, index) => `
|
|
328
|
+
### ${index + 1}. ${file.name}
|
|
329
|
+
**Path**: ${file.path}
|
|
330
|
+
**Size**: ${file.size} bytes
|
|
331
|
+
|
|
332
|
+
**Content Preview**:
|
|
333
|
+
\`\`\`markdown
|
|
334
|
+
${file.content?.slice(0, 1000) || 'No content available'}${(file.content?.length || 0) > 1000 ? '\n... (truncated)' : ''}
|
|
335
|
+
\`\`\`
|
|
336
|
+
`)
|
|
337
|
+
.join('')}
|
|
338
|
+
|
|
339
|
+
## Required Output Format
|
|
340
|
+
|
|
341
|
+
Please provide the ADR list in the following JSON structure:
|
|
342
|
+
|
|
343
|
+
\`\`\`json
|
|
344
|
+
{
|
|
345
|
+
"listId": "unique-list-id",
|
|
346
|
+
"timestamp": "ISO-8601-timestamp",
|
|
347
|
+
"directory": "${adrDirectory}",
|
|
348
|
+
"summary": {
|
|
349
|
+
"totalAdrs": ${adrFiles.length},
|
|
350
|
+
"statusBreakdown": {
|
|
351
|
+
"proposed": 0,
|
|
352
|
+
"accepted": 0,
|
|
353
|
+
"deprecated": 0,
|
|
354
|
+
"superseded": 0
|
|
355
|
+
},
|
|
356
|
+
"lastModified": "ISO-8601-timestamp",
|
|
357
|
+
"coverage": {
|
|
358
|
+
"hasImplementationPlans": 0,
|
|
359
|
+
"hasConsequences": 0,
|
|
360
|
+
"hasRelatedAdrs": 0
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
"adrs": [
|
|
364
|
+
{
|
|
365
|
+
"id": "extracted-or-generated-id",
|
|
366
|
+
"title": "ADR Title",
|
|
367
|
+
"status": "proposed|accepted|deprecated|superseded",
|
|
368
|
+
"date": "YYYY-MM-DD",
|
|
369
|
+
"context": "decision-context-summary",
|
|
370
|
+
"decision": "architectural-decision-summary",
|
|
371
|
+
"consequences": "decision-consequences-summary",
|
|
372
|
+
"implementationPlan": "implementation-plan-if-present",
|
|
373
|
+
"filePath": "relative-file-path",
|
|
374
|
+
"fileName": "file-name",
|
|
375
|
+
"fileSize": file-size-bytes,
|
|
376
|
+
"tags": ["extracted-tags"],
|
|
377
|
+
"relatedAdrs": ["related-adr-ids"],
|
|
378
|
+
"priority": "low|medium|high|critical",
|
|
379
|
+
"complexity": "low|medium|high",
|
|
380
|
+
"implementationStatus": "not-started|in-progress|completed|blocked"
|
|
381
|
+
}
|
|
382
|
+
],
|
|
383
|
+
"relationships": [
|
|
384
|
+
{
|
|
385
|
+
"sourceAdr": "source-adr-id",
|
|
386
|
+
"targetAdr": "target-adr-id",
|
|
387
|
+
"relationshipType": "supersedes|relates-to|depends-on|conflicts-with",
|
|
388
|
+
"description": "relationship-description"
|
|
389
|
+
}
|
|
390
|
+
],
|
|
391
|
+
"gaps": [
|
|
392
|
+
{
|
|
393
|
+
"area": "missing-decision-area",
|
|
394
|
+
"description": "gap-description",
|
|
395
|
+
"suggestedAdr": "suggested-adr-title",
|
|
396
|
+
"priority": "low|medium|high|critical"
|
|
397
|
+
}
|
|
398
|
+
],
|
|
399
|
+
"recommendations": [
|
|
400
|
+
"specific-recommendations-for-adr-management"
|
|
401
|
+
]
|
|
402
|
+
}
|
|
403
|
+
\`\`\`
|
|
404
|
+
|
|
405
|
+
## Analysis Guidelines
|
|
406
|
+
|
|
407
|
+
1. **Extract Metadata**: Parse ADR structure to extract titles, statuses, dates
|
|
408
|
+
2. **Identify Relationships**: Find connections between ADRs
|
|
409
|
+
3. **Assess Completeness**: Evaluate ADR quality and completeness
|
|
410
|
+
4. **Find Gaps**: Identify missing architectural decisions
|
|
411
|
+
5. **Provide Insights**: Offer recommendations for ADR management
|
|
412
|
+
|
|
413
|
+
Please generate a comprehensive, structured ADR list resource.
|
|
414
|
+
`;
|
|
415
|
+
const cacheKey = `adr-list:${Buffer.from(adrDirectory).toString('base64')}`;
|
|
416
|
+
return {
|
|
417
|
+
data: {
|
|
418
|
+
prompt: adrListPrompt,
|
|
419
|
+
instructions: `
|
|
420
|
+
# ADR List Resource
|
|
421
|
+
|
|
422
|
+
This resource provides a structured view of all Architectural Decision Records in the project.
|
|
423
|
+
|
|
424
|
+
## Usage Instructions
|
|
425
|
+
|
|
426
|
+
1. **Submit the generated prompt** to an AI agent for analysis
|
|
427
|
+
2. **Parse the JSON response** as an ADR list
|
|
428
|
+
3. **Use the data** for ADR management and tracking
|
|
429
|
+
4. **Monitor gaps** and implement missing ADRs
|
|
430
|
+
|
|
431
|
+
## Resource Content
|
|
432
|
+
|
|
433
|
+
The ADR list includes:
|
|
434
|
+
- **Summary**: Overview of ADR status and coverage
|
|
435
|
+
- **Individual ADRs**: Detailed information for each ADR
|
|
436
|
+
- **Relationships**: Connections between ADRs
|
|
437
|
+
- **Gaps**: Missing architectural decisions
|
|
438
|
+
- **Recommendations**: ADR management suggestions
|
|
439
|
+
|
|
440
|
+
## Next Steps
|
|
441
|
+
|
|
442
|
+
Submit the prompt to generate the actual ADR list data.
|
|
443
|
+
`,
|
|
444
|
+
adrDirectory,
|
|
445
|
+
fileCount: adrFiles.length,
|
|
446
|
+
files: adrFiles.map(f => ({ name: f.name, path: f.path, size: f.size })),
|
|
447
|
+
},
|
|
448
|
+
contentType: 'application/json',
|
|
449
|
+
lastModified: new Date().toISOString(),
|
|
450
|
+
cacheKey,
|
|
451
|
+
ttl: 900, // 15 minutes cache
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
catch (error) {
|
|
455
|
+
throw new McpAdrError(`Failed to generate ADR list: ${error instanceof Error ? error.message : String(error)}`, 'RESOURCE_GENERATION_ERROR');
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/resources/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAUhD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mCAAmC,CACvD,WAAmB;IAEnB,IAAI,CAAC;QACH,MAAM,EAAE,uBAAuB,EAAE,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAC;QAC5E,MAAM,EAAE,uBAAuB,EAAE,mCAAmC,EAAE,GAAG,MAAM,MAAM,CACnF,gCAAgC,CACjC,CAAC;QAEF,4BAA4B;QAC5B,MAAM,gBAAgB,GAAG,MAAM,uBAAuB,CAAC,WAAW,CAAC,CAAC;QACpE,MAAM,eAAe,GAAG,uBAAuB,CAAC,gBAAgB,CAAC,CAAC;QAElE,yCAAyC;QACzC,MAAM,cAAc,GAAG,mCAAmC,CAAC,eAAe,CAAC,CAAC;QAE5E,iEAAiE;QACjE,MAAM,oBAAoB,GAAG;;;;;EAK/B,cAAc;;;;;;;;;;;;;;;;mBAgBG,g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aACzE;YACD,WAAW,EAAE,kBAAkB;YAC/B,YAAY,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACtC,QAAQ;YACR,GAAG,EAAE,GAAG,EAAE,mBAAmB;SAC9B,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,WAAW,CACnB,gCAAgC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EACxF,2BAA2B,CAC5B,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tool for ADR suggestions and implicit decision detection
|
|
3
|
+
* Implements prompt-driven ADR recommendation system
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Suggest ADRs based on project analysis
|
|
7
|
+
*/
|
|
8
|
+
export declare function suggestAdrs(args: {
|
|
9
|
+
projectPath?: string;
|
|
10
|
+
analysisType?: 'implicit_decisions' | 'code_changes' | 'comprehensive';
|
|
11
|
+
beforeCode?: string;
|
|
12
|
+
afterCode?: string;
|
|
13
|
+
changeDescription?: string;
|
|
14
|
+
commitMessages?: string[];
|
|
15
|
+
existingAdrs?: string[];
|
|
16
|
+
}): Promise<any>;
|
|
17
|
+
/**
|
|
18
|
+
* Generate ADR from decision data
|
|
19
|
+
*/
|
|
20
|
+
export declare function generateAdrFromDecision(args: {
|
|
21
|
+
decisionData: {
|
|
22
|
+
title: string;
|
|
23
|
+
context: string;
|
|
24
|
+
decision: string;
|
|
25
|
+
consequences: string;
|
|
26
|
+
alternatives?: string[];
|
|
27
|
+
evidence?: string[];
|
|
28
|
+
};
|
|
29
|
+
templateFormat?: 'nygard' | 'madr' | 'custom';
|
|
30
|
+
existingAdrs?: string[];
|
|
31
|
+
adrDirectory?: string;
|
|
32
|
+
}): Promise<any>;
|
|
33
|
+
/**
|
|
34
|
+
* Discover existing ADRs in the project
|
|
35
|
+
*/
|
|
36
|
+
export declare function discoverExistingAdrs(args: {
|
|
37
|
+
adrDirectory?: string;
|
|
38
|
+
includeContent?: boolean;
|
|
39
|
+
}): Promise<any>;
|
|
40
|
+
//# sourceMappingURL=adr-suggestion-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adr-suggestion-tool.d.ts","sourceRoot":"","sources":["../../../src/tools/adr-suggestion-tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,oBAAoB,GAAG,cAAc,GAAG,eAAe,CAAC;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,GAAG,OAAO,CAAC,GAAG,CAAC,CAmLf;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,IAAI,EAAE;IAClD,YAAY,EAAE;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QACxB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;IACF,cAAc,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;IAC9C,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,GAAG,CAAC,CAsFf;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,GAAG,OAAO,CAAC,GAAG,CAAC,CAiHf"}
|