project-customization-mcp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +373 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +29 -0
- package/build/index.js.map +1 -0
- package/build/prompts.d.ts +30 -0
- package/build/prompts.js +98 -0
- package/build/prompts.js.map +1 -0
- package/build/resources.d.ts +47 -0
- package/build/resources.js +173 -0
- package/build/resources.js.map +1 -0
- package/build/server.d.ts +12 -0
- package/build/server.js +288 -0
- package/build/server.js.map +1 -0
- package/build/tools.d.ts +23 -0
- package/build/tools.js +133 -0
- package/build/tools.js.map +1 -0
- package/build/types.d.ts +62 -0
- package/build/types.js +5 -0
- package/build/types.js.map +1 -0
- package/build/utils/bestPractices.d.ts +16 -0
- package/build/utils/bestPractices.js +230 -0
- package/build/utils/bestPractices.js.map +1 -0
- package/build/utils/fileHandler.d.ts +46 -0
- package/build/utils/fileHandler.js +144 -0
- package/build/utils/fileHandler.js.map +1 -0
- package/build/utils/logger.d.ts +20 -0
- package/build/utils/logger.js +42 -0
- package/build/utils/logger.js.map +1 -0
- package/build/utils/projectScanner.d.ts +26 -0
- package/build/utils/projectScanner.js +182 -0
- package/build/utils/projectScanner.js.map +1 -0
- package/build/utils/validator.d.ts +115 -0
- package/build/utils/validator.js +120 -0
- package/build/utils/validator.js.map +1 -0
- package/package.json +50 -0
package/build/types.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript interfaces and types for the MCP server
|
|
3
|
+
*/
|
|
4
|
+
export interface ProjectMetadata {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
projectRoot: string;
|
|
8
|
+
projectType: 'nodejs' | 'python' | 'dotnet' | 'unknown';
|
|
9
|
+
hasGitHub: boolean;
|
|
10
|
+
hasPackageJson: boolean;
|
|
11
|
+
hasPythonProject: boolean;
|
|
12
|
+
hasReadme: boolean;
|
|
13
|
+
hasCopilotInstructions: boolean;
|
|
14
|
+
frameworks: string[];
|
|
15
|
+
programmingLanguages: string[];
|
|
16
|
+
}
|
|
17
|
+
export interface ProjectStructure {
|
|
18
|
+
root: string;
|
|
19
|
+
folders: FolderInfo[];
|
|
20
|
+
files: FileInfo[];
|
|
21
|
+
totalFiles: number;
|
|
22
|
+
keyDirectories: string[];
|
|
23
|
+
}
|
|
24
|
+
export interface FolderInfo {
|
|
25
|
+
path: string;
|
|
26
|
+
name: string;
|
|
27
|
+
depth: number;
|
|
28
|
+
fileCount: number;
|
|
29
|
+
}
|
|
30
|
+
export interface FileInfo {
|
|
31
|
+
path: string;
|
|
32
|
+
name: string;
|
|
33
|
+
extension: string;
|
|
34
|
+
size: number;
|
|
35
|
+
}
|
|
36
|
+
export interface AnalysisResult {
|
|
37
|
+
metadata: ProjectMetadata;
|
|
38
|
+
structure: ProjectStructure;
|
|
39
|
+
issues: ProjectIssue[];
|
|
40
|
+
recommendations: Recommendation[];
|
|
41
|
+
}
|
|
42
|
+
export interface ProjectIssue {
|
|
43
|
+
severity: 'low' | 'medium' | 'high';
|
|
44
|
+
category: 'missing' | 'outdated' | 'inconsistent';
|
|
45
|
+
message: string;
|
|
46
|
+
}
|
|
47
|
+
export interface Recommendation {
|
|
48
|
+
title: string;
|
|
49
|
+
description: string;
|
|
50
|
+
category: 'documentation' | 'guidelines' | 'structure' | 'best-practices';
|
|
51
|
+
priority: 'low' | 'medium' | 'high';
|
|
52
|
+
action: string;
|
|
53
|
+
}
|
|
54
|
+
export interface GeneratedContent {
|
|
55
|
+
filename: string;
|
|
56
|
+
content: string;
|
|
57
|
+
description: string;
|
|
58
|
+
}
|
|
59
|
+
export interface ToolInput {
|
|
60
|
+
projectPath?: string;
|
|
61
|
+
options?: Record<string, any>;
|
|
62
|
+
}
|
package/build/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VS Code customization best practices and templates
|
|
3
|
+
*/
|
|
4
|
+
import { ProjectMetadata } from '../types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Generate Copilot Instructions based on project metadata
|
|
7
|
+
*/
|
|
8
|
+
export declare function generateCopilotInstructions(metadata: ProjectMetadata): string;
|
|
9
|
+
/**
|
|
10
|
+
* Generate README content with guidelines
|
|
11
|
+
*/
|
|
12
|
+
export declare function generateReadmeContent(metadata: ProjectMetadata, additionalGuidelines?: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Generate recommendations based on project analysis
|
|
15
|
+
*/
|
|
16
|
+
export declare function generateRecommendations(metadata: ProjectMetadata): any[];
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VS Code customization best practices and templates
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Generate Copilot Instructions based on project metadata
|
|
6
|
+
*/
|
|
7
|
+
export function generateCopilotInstructions(metadata) {
|
|
8
|
+
const sections = [];
|
|
9
|
+
sections.push('# Copilot Custom Instructions');
|
|
10
|
+
sections.push('');
|
|
11
|
+
sections.push(`*Auto-generated for ${metadata.name}*`);
|
|
12
|
+
sections.push('');
|
|
13
|
+
// Project Overview
|
|
14
|
+
sections.push('## Project Overview');
|
|
15
|
+
sections.push(`- **Project Name**: ${metadata.name}`);
|
|
16
|
+
if (metadata.description) {
|
|
17
|
+
sections.push(`- **Description**: ${metadata.description}`);
|
|
18
|
+
}
|
|
19
|
+
sections.push(`- **Type**: ${metadata.projectType}`);
|
|
20
|
+
if (metadata.frameworks.length > 0) {
|
|
21
|
+
sections.push(`- **Frameworks**: ${metadata.frameworks.join(', ')}`);
|
|
22
|
+
}
|
|
23
|
+
if (metadata.programmingLanguages.length > 0) {
|
|
24
|
+
sections.push(`- **Languages**: ${metadata.programmingLanguages.join(', ')}`);
|
|
25
|
+
}
|
|
26
|
+
sections.push('');
|
|
27
|
+
// Code Style and Standards
|
|
28
|
+
sections.push('## Code Style and Standards');
|
|
29
|
+
sections.push('');
|
|
30
|
+
if (metadata.frameworks.some((f) => f.includes('React') || f.includes('TypeScript'))) {
|
|
31
|
+
sections.push('### TypeScript/React Standards');
|
|
32
|
+
sections.push('- Use functional components with hooks');
|
|
33
|
+
sections.push('- Maintain strict TypeScript types (no `any`)');
|
|
34
|
+
sections.push('- Use ESLint and Prettier for code formatting');
|
|
35
|
+
sections.push('- Follow naming conventions: camelCase for variables/functions, PascalCase for components');
|
|
36
|
+
sections.push('');
|
|
37
|
+
}
|
|
38
|
+
if (metadata.frameworks.some((f) => f.includes('Node.js') || f.includes('Backend'))) {
|
|
39
|
+
sections.push('### Backend Standards');
|
|
40
|
+
sections.push('- Use async/await for asynchronous operations');
|
|
41
|
+
sections.push('- Implement proper error handling with try/catch');
|
|
42
|
+
sections.push('- Write unit tests for all utility functions');
|
|
43
|
+
sections.push('- Follow RESTful API design principles');
|
|
44
|
+
sections.push('');
|
|
45
|
+
}
|
|
46
|
+
// Project Structure
|
|
47
|
+
sections.push('## Project Structure');
|
|
48
|
+
sections.push('');
|
|
49
|
+
sections.push('The project should maintain the following directory structure:');
|
|
50
|
+
sections.push('');
|
|
51
|
+
if (metadata.frameworks.some((f) => f.includes('React'))) {
|
|
52
|
+
sections.push('```');
|
|
53
|
+
sections.push('src/');
|
|
54
|
+
sections.push(' ├── components/ # React components');
|
|
55
|
+
sections.push(' ├── pages/ # Page components');
|
|
56
|
+
sections.push(' ├── utils/ # Utility functions');
|
|
57
|
+
sections.push(' ├── hooks/ # Custom hooks');
|
|
58
|
+
sections.push(' ├── types/ # TypeScript types');
|
|
59
|
+
sections.push(' └── App.tsx # Main app component');
|
|
60
|
+
sections.push('```');
|
|
61
|
+
}
|
|
62
|
+
else if (metadata.projectType === 'nodejs') {
|
|
63
|
+
sections.push('```');
|
|
64
|
+
sections.push('src/');
|
|
65
|
+
sections.push(' ├── routes/ # API routes');
|
|
66
|
+
sections.push(' ├── controllers/ # Request handlers');
|
|
67
|
+
sections.push(' ├── services/ # Business logic');
|
|
68
|
+
sections.push(' ├── utils/ # Utility functions');
|
|
69
|
+
sections.push(' └── types/ # TypeScript types');
|
|
70
|
+
sections.push('```');
|
|
71
|
+
}
|
|
72
|
+
sections.push('');
|
|
73
|
+
// Documentation Requirements
|
|
74
|
+
sections.push('## Documentation');
|
|
75
|
+
sections.push('');
|
|
76
|
+
sections.push('- Maintain an up-to-date README.md with setup instructions');
|
|
77
|
+
sections.push('- Document API endpoints with examples');
|
|
78
|
+
sections.push('- Include JSDoc comments for complex functions');
|
|
79
|
+
sections.push('- Add comments for non-obvious logic');
|
|
80
|
+
sections.push('');
|
|
81
|
+
// Git Workflow
|
|
82
|
+
sections.push('## Git Workflow');
|
|
83
|
+
sections.push('');
|
|
84
|
+
sections.push('- Use descriptive commit messages following conventional commits');
|
|
85
|
+
sections.push('- Create feature branches for new features (feature/*)');
|
|
86
|
+
sections.push('- Create bugfix branches for fixes (bugfix/*)');
|
|
87
|
+
sections.push('- Request code review before merging to main');
|
|
88
|
+
sections.push('');
|
|
89
|
+
// Testing
|
|
90
|
+
sections.push('## Testing');
|
|
91
|
+
sections.push('');
|
|
92
|
+
sections.push('- Write unit tests for all utility functions');
|
|
93
|
+
sections.push('- Maintain test coverage above 80%');
|
|
94
|
+
sections.push('- Use descriptive test names that explain what is being tested');
|
|
95
|
+
sections.push('- Mock external dependencies in tests');
|
|
96
|
+
sections.push('');
|
|
97
|
+
// Performance
|
|
98
|
+
sections.push('## Performance');
|
|
99
|
+
sections.push('');
|
|
100
|
+
sections.push('- Optimize bundle size for frontend projects');
|
|
101
|
+
sections.push('- Use lazy loading for components when appropriate');
|
|
102
|
+
sections.push('- Implement proper caching strategies');
|
|
103
|
+
sections.push('- Monitor and log performance metrics');
|
|
104
|
+
sections.push('');
|
|
105
|
+
// Security
|
|
106
|
+
sections.push('## Security');
|
|
107
|
+
sections.push('');
|
|
108
|
+
sections.push('- Never commit secrets or API keys');
|
|
109
|
+
sections.push('- Use environment variables for sensitive configuration');
|
|
110
|
+
sections.push('- Validate and sanitize user inputs');
|
|
111
|
+
sections.push('- Keep dependencies up-to-date');
|
|
112
|
+
sections.push('');
|
|
113
|
+
return sections.join('\n');
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Generate README content with guidelines
|
|
117
|
+
*/
|
|
118
|
+
export function generateReadmeContent(metadata, additionalGuidelines) {
|
|
119
|
+
const sections = [];
|
|
120
|
+
sections.push(`# ${metadata.name}`);
|
|
121
|
+
sections.push('');
|
|
122
|
+
if (metadata.description) {
|
|
123
|
+
sections.push(metadata.description);
|
|
124
|
+
sections.push('');
|
|
125
|
+
}
|
|
126
|
+
sections.push('## Getting Started');
|
|
127
|
+
sections.push('');
|
|
128
|
+
if (metadata.projectType === 'nodejs') {
|
|
129
|
+
sections.push('### Prerequisites');
|
|
130
|
+
sections.push('- Node.js (v16 or higher)');
|
|
131
|
+
sections.push('- npm or yarn');
|
|
132
|
+
sections.push('');
|
|
133
|
+
sections.push('### Installation');
|
|
134
|
+
sections.push('');
|
|
135
|
+
sections.push('```bash');
|
|
136
|
+
sections.push('npm install');
|
|
137
|
+
sections.push('```');
|
|
138
|
+
sections.push('');
|
|
139
|
+
sections.push('### Running the Project');
|
|
140
|
+
sections.push('');
|
|
141
|
+
sections.push('```bash');
|
|
142
|
+
sections.push('npm run dev');
|
|
143
|
+
sections.push('```');
|
|
144
|
+
sections.push('');
|
|
145
|
+
}
|
|
146
|
+
else if (metadata.projectType === 'python') {
|
|
147
|
+
sections.push('### Prerequisites');
|
|
148
|
+
sections.push('- Python 3.8 or higher');
|
|
149
|
+
sections.push('- pip or conda');
|
|
150
|
+
sections.push('');
|
|
151
|
+
sections.push('### Installation');
|
|
152
|
+
sections.push('');
|
|
153
|
+
sections.push('```bash');
|
|
154
|
+
sections.push('pip install -r requirements.txt');
|
|
155
|
+
sections.push('```');
|
|
156
|
+
sections.push('');
|
|
157
|
+
}
|
|
158
|
+
if (additionalGuidelines) {
|
|
159
|
+
sections.push('## Development Guidelines');
|
|
160
|
+
sections.push('');
|
|
161
|
+
sections.push(additionalGuidelines);
|
|
162
|
+
sections.push('');
|
|
163
|
+
}
|
|
164
|
+
sections.push('## Contributing');
|
|
165
|
+
sections.push('');
|
|
166
|
+
sections.push('Please read our contributing guidelines before submitting pull requests.');
|
|
167
|
+
sections.push('');
|
|
168
|
+
sections.push('## License');
|
|
169
|
+
sections.push('');
|
|
170
|
+
sections.push('This project is licensed under the MIT License.');
|
|
171
|
+
sections.push('');
|
|
172
|
+
return sections.join('\n');
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Generate recommendations based on project analysis
|
|
176
|
+
*/
|
|
177
|
+
export function generateRecommendations(metadata) {
|
|
178
|
+
const recommendations = [];
|
|
179
|
+
// Missing documentation
|
|
180
|
+
if (!metadata.hasReadme) {
|
|
181
|
+
recommendations.push({
|
|
182
|
+
priority: 'high',
|
|
183
|
+
title: 'Missing README.md',
|
|
184
|
+
description: 'Add a comprehensive README.md file to document the project',
|
|
185
|
+
category: 'documentation',
|
|
186
|
+
action: 'Create README.md with project overview, setup instructions, and development guidelines',
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
// Missing copilot instructions
|
|
190
|
+
if (!metadata.hasCopilotInstructions) {
|
|
191
|
+
recommendations.push({
|
|
192
|
+
priority: 'high',
|
|
193
|
+
title: 'Missing Copilot Instructions',
|
|
194
|
+
description: 'Create .github/copilot-instructions.md to guide Copilot behavior',
|
|
195
|
+
category: 'guidelines',
|
|
196
|
+
action: 'Generate copilot-instructions.md with project-specific guidelines',
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
// Missing GitHub configuration
|
|
200
|
+
if (!metadata.hasGitHub) {
|
|
201
|
+
recommendations.push({
|
|
202
|
+
priority: 'medium',
|
|
203
|
+
title: 'Initialize Git Repository',
|
|
204
|
+
description: 'Initialize a Git repository to enable version control',
|
|
205
|
+
category: 'structure',
|
|
206
|
+
action: 'Run git init and set up .gitignore',
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
// Framework-specific recommendations
|
|
210
|
+
if (metadata.frameworks.some((f) => f.includes('TypeScript'))) {
|
|
211
|
+
recommendations.push({
|
|
212
|
+
priority: 'medium',
|
|
213
|
+
title: 'TypeScript Configuration',
|
|
214
|
+
description: 'Ensure strict TypeScript configuration is enabled',
|
|
215
|
+
category: 'best-practices',
|
|
216
|
+
action: 'Update tsconfig.json with strict mode enabled',
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
if (metadata.frameworks.some((f) => f.includes('React'))) {
|
|
220
|
+
recommendations.push({
|
|
221
|
+
priority: 'medium',
|
|
222
|
+
title: 'React Best Practices',
|
|
223
|
+
description: 'Follow React best practices and hooks patterns',
|
|
224
|
+
category: 'guidelines',
|
|
225
|
+
action: 'Ensure use of functional components and hooks throughout the project',
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
return recommendations;
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=bestPractices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bestPractices.js","sourceRoot":"","sources":["../../src/utils/bestPractices.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,MAAM,UAAU,2BAA2B,CAAC,QAAyB;IACnE,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,QAAQ,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;IAC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,IAAI,CAAC,uBAAuB,QAAQ,CAAC,IAAI,GAAG,CAAC,CAAC;IACvD,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAElB,mBAAmB;IACnB,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACrC,QAAQ,CA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AI,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC;QAC9D,eAAe,CAAC,IAAI,CAAC;YACnB,QAAQ,EAAE,QAAiB;YAC3B,KAAK,EAAE,0BAA0B;YACjC,WAAW,EAAE,mDAAmD;YAChE,QAAQ,EAAE,gBAAyB;YACnC,MAAM,EAAE,+CAA+C;SACxD,CAAC,CAAC;IACL,CAAC;IAED,IAAI,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;QACzD,eAAe,CAAC,IAAI,CAAC;YACnB,QAAQ,EAAE,QAAiB;YAC3B,KAAK,EAAE,sBAAsB;YAC7B,WAAW,EAAE,gDAAgD;YAC7D,QAAQ,EAAE,YAAqB;YAC/B,MAAM,EAAE,sEAAsE;SAC/E,CAAC,CAAC;IACL,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File I/O operations utility
|
|
3
|
+
*/
|
|
4
|
+
import * as fs from 'fs';
|
|
5
|
+
export declare class FileHandler {
|
|
6
|
+
/**
|
|
7
|
+
* Read a file asynchronously
|
|
8
|
+
*/
|
|
9
|
+
static readFile(filePath: string): Promise<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Write content to a file asynchronously
|
|
12
|
+
*/
|
|
13
|
+
static writeFile(filePath: string, content: string): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Append content to a file
|
|
16
|
+
*/
|
|
17
|
+
static appendFile(filePath: string, content: string): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Check if file exists
|
|
20
|
+
*/
|
|
21
|
+
static fileExists(filePath: string): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* Check if path is a directory
|
|
24
|
+
*/
|
|
25
|
+
static isDirectory(dirPath: string): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* List files in a directory
|
|
28
|
+
*/
|
|
29
|
+
static listFiles(dirPath: string, recursive?: boolean): Promise<string[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Get file stats
|
|
32
|
+
*/
|
|
33
|
+
static getFileStats(filePath: string): Promise<fs.Stats | null>;
|
|
34
|
+
/**
|
|
35
|
+
* Check if folder should be ignored
|
|
36
|
+
*/
|
|
37
|
+
private static isIgnoredFolder;
|
|
38
|
+
/**
|
|
39
|
+
* Find git root directory
|
|
40
|
+
*/
|
|
41
|
+
static findGitRoot(startPath: string): Promise<string | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Get project root (git root or starting directory)
|
|
44
|
+
*/
|
|
45
|
+
static getProjectRoot(startPath?: string): Promise<string>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File I/O operations utility
|
|
3
|
+
*/
|
|
4
|
+
import * as fs from 'fs';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
import { logger } from './logger.js';
|
|
7
|
+
export class FileHandler {
|
|
8
|
+
/**
|
|
9
|
+
* Read a file asynchronously
|
|
10
|
+
*/
|
|
11
|
+
static async readFile(filePath) {
|
|
12
|
+
try {
|
|
13
|
+
return await fs.promises.readFile(filePath, 'utf-8');
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
logger.error(`Failed to read file: ${filePath}`, error);
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Write content to a file asynchronously
|
|
22
|
+
*/
|
|
23
|
+
static async writeFile(filePath, content) {
|
|
24
|
+
try {
|
|
25
|
+
const dir = path.dirname(filePath);
|
|
26
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
27
|
+
await fs.promises.writeFile(filePath, content, 'utf-8');
|
|
28
|
+
logger.info(`File written successfully: ${filePath}`);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
logger.error(`Failed to write file: ${filePath}`, error);
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Append content to a file
|
|
37
|
+
*/
|
|
38
|
+
static async appendFile(filePath, content) {
|
|
39
|
+
try {
|
|
40
|
+
const dir = path.dirname(filePath);
|
|
41
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
42
|
+
await fs.promises.appendFile(filePath, content, 'utf-8');
|
|
43
|
+
logger.info(`Content appended to file: ${filePath}`);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
logger.error(`Failed to append to file: ${filePath}`, error);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Check if file exists
|
|
52
|
+
*/
|
|
53
|
+
static async fileExists(filePath) {
|
|
54
|
+
try {
|
|
55
|
+
await fs.promises.access(filePath);
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Check if path is a directory
|
|
64
|
+
*/
|
|
65
|
+
static async isDirectory(dirPath) {
|
|
66
|
+
try {
|
|
67
|
+
const stats = await fs.promises.stat(dirPath);
|
|
68
|
+
return stats.isDirectory();
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* List files in a directory
|
|
76
|
+
*/
|
|
77
|
+
static async listFiles(dirPath, recursive = false) {
|
|
78
|
+
try {
|
|
79
|
+
const files = [];
|
|
80
|
+
const traverse = async (currentPath, relativePath = '') => {
|
|
81
|
+
const entries = await fs.promises.readdir(currentPath);
|
|
82
|
+
for (const entry of entries) {
|
|
83
|
+
const fullPath = path.join(currentPath, entry);
|
|
84
|
+
const relPath = relativePath ? `${relativePath}/${entry}` : entry;
|
|
85
|
+
const stat = await fs.promises.stat(fullPath);
|
|
86
|
+
if (stat.isDirectory()) {
|
|
87
|
+
if (recursive && !this.isIgnoredFolder(relPath)) {
|
|
88
|
+
await traverse(fullPath, relPath);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
files.push(relPath);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
await traverse(dirPath);
|
|
97
|
+
return files;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
logger.error(`Failed to list files in ${dirPath}`, error);
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Get file stats
|
|
106
|
+
*/
|
|
107
|
+
static async getFileStats(filePath) {
|
|
108
|
+
try {
|
|
109
|
+
return await fs.promises.stat(filePath);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Check if folder should be ignored
|
|
117
|
+
*/
|
|
118
|
+
static isIgnoredFolder(folderName) {
|
|
119
|
+
const ignoredFolders = ['node_modules', '.git', 'dist', 'build', '.next', '__pycache__', '.venv', 'venv'];
|
|
120
|
+
return ignoredFolders.some((ignored) => folderName.includes(ignored));
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Find git root directory
|
|
124
|
+
*/
|
|
125
|
+
static async findGitRoot(startPath) {
|
|
126
|
+
let currentPath = startPath;
|
|
127
|
+
while (currentPath !== path.dirname(currentPath)) {
|
|
128
|
+
const gitPath = path.join(currentPath, '.git');
|
|
129
|
+
if (await this.fileExists(gitPath)) {
|
|
130
|
+
return currentPath;
|
|
131
|
+
}
|
|
132
|
+
currentPath = path.dirname(currentPath);
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Get project root (git root or starting directory)
|
|
138
|
+
*/
|
|
139
|
+
static async getProjectRoot(startPath = process.cwd()) {
|
|
140
|
+
const gitRoot = await this.findGitRoot(startPath);
|
|
141
|
+
return gitRoot || startPath;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=fileHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileHandler.js","sourceRoot":"","sources":["../../src/utils/fileHandler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,OAAO,WAAW;IACtB;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAgB;QACpC,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACvD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,wBAAwB,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC;YACxD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,QAAgB,EAAE,OAAe;QACtD,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACnC,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAClD,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YACxD,MAAM,CAAC,IAAI,CAAC,8BAA8B,Q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|
|
|
1
|
+
/**
|
|
2
|
+
* Logging utility for MCP server
|
|
3
|
+
*/
|
|
4
|
+
export declare enum LogLevel {
|
|
5
|
+
DEBUG = "DEBUG",
|
|
6
|
+
INFO = "INFO",
|
|
7
|
+
WARN = "WARN",
|
|
8
|
+
ERROR = "ERROR"
|
|
9
|
+
}
|
|
10
|
+
declare class Logger {
|
|
11
|
+
private level;
|
|
12
|
+
setLevel(level: LogLevel): void;
|
|
13
|
+
private shouldLog;
|
|
14
|
+
debug(message: string, data?: any): void;
|
|
15
|
+
info(message: string, data?: any): void;
|
|
16
|
+
warn(message: string, data?: any): void;
|
|
17
|
+
error(message: string, error?: Error | any): void;
|
|
18
|
+
}
|
|
19
|
+
export declare const logger: Logger;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logging utility for MCP server
|
|
3
|
+
*/
|
|
4
|
+
export var LogLevel;
|
|
5
|
+
(function (LogLevel) {
|
|
6
|
+
LogLevel["DEBUG"] = "DEBUG";
|
|
7
|
+
LogLevel["INFO"] = "INFO";
|
|
8
|
+
LogLevel["WARN"] = "WARN";
|
|
9
|
+
LogLevel["ERROR"] = "ERROR";
|
|
10
|
+
})(LogLevel || (LogLevel = {}));
|
|
11
|
+
class Logger {
|
|
12
|
+
level = LogLevel.INFO;
|
|
13
|
+
setLevel(level) {
|
|
14
|
+
this.level = level;
|
|
15
|
+
}
|
|
16
|
+
shouldLog(messageLevel) {
|
|
17
|
+
const levels = [LogLevel.DEBUG, LogLevel.INFO, LogLevel.WARN, LogLevel.ERROR];
|
|
18
|
+
return levels.indexOf(messageLevel) >= levels.indexOf(this.level);
|
|
19
|
+
}
|
|
20
|
+
debug(message, data) {
|
|
21
|
+
if (this.shouldLog(LogLevel.DEBUG)) {
|
|
22
|
+
console.log(`[${LogLevel.DEBUG}]`, message, data ? JSON.stringify(data, null, 2) : '');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
info(message, data) {
|
|
26
|
+
if (this.shouldLog(LogLevel.INFO)) {
|
|
27
|
+
console.log(`[${LogLevel.INFO}]`, message, data ? JSON.stringify(data, null, 2) : '');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
warn(message, data) {
|
|
31
|
+
if (this.shouldLog(LogLevel.WARN)) {
|
|
32
|
+
console.warn(`[${LogLevel.WARN}]`, message, data ? JSON.stringify(data, null, 2) : '');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
error(message, error) {
|
|
36
|
+
if (this.shouldLog(LogLevel.ERROR)) {
|
|
37
|
+
console.error(`[${LogLevel.ERROR}]`, message, error);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export const logger = new Logger();
|
|
42
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAN,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,2BAAe,CAAA;IACf,yBAAa,CAAA;IACb,yBAAa,CAAA;IACb,2BAAe,CAAA;AACjB,CAAC,EALW,QAAQ,KAAR,QAAQ,QAKnB;AAED,MAAM,MAAM;IACF,KAAK,GAAa,QAAQ,CAAC,IAAI,CAAC;IAExC,QAAQ,CAAC,KAAe;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAEO,SAAS,CAAC,YAAsB;QACtC,MAAM,MAAM,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC9E,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpE,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,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AAG,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project analysis and scanning utility
|
|
3
|
+
*/
|
|
4
|
+
import { ProjectMetadata, ProjectStructure } from '../types.js';
|
|
5
|
+
export declare class ProjectScanner {
|
|
6
|
+
/**
|
|
7
|
+
* Detect project type based on files
|
|
8
|
+
*/
|
|
9
|
+
static detectProjectType(projectRoot: string): Promise<'nodejs' | 'python' | 'dotnet' | 'unknown'>;
|
|
10
|
+
/**
|
|
11
|
+
* Detect frameworks and languages
|
|
12
|
+
*/
|
|
13
|
+
static detectFrameworks(projectRoot: string): Promise<string[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Detect programming languages in the project
|
|
16
|
+
*/
|
|
17
|
+
static detectLanguages(projectRoot: string): Promise<string[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Scan project structure
|
|
20
|
+
*/
|
|
21
|
+
static scanProjectStructure(projectRoot: string, maxDepth?: number): Promise<ProjectStructure>;
|
|
22
|
+
/**
|
|
23
|
+
* Collect project metadata
|
|
24
|
+
*/
|
|
25
|
+
static getProjectMetadata(projectRoot: string): Promise<ProjectMetadata>;
|
|
26
|
+
}
|