mcp-adr-analysis-server 2.0.6 → 2.0.8
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/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +70 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/tools/smart-git-push-tool.d.ts +24 -0
- package/dist/src/tools/smart-git-push-tool.d.ts.map +1 -0
- package/dist/src/tools/smart-git-push-tool.js +480 -0
- package/dist/src/tools/smart-git-push-tool.js.map +1 -0
- package/dist/src/utils/enhanced-sensitive-detector.d.ts +61 -0
- package/dist/src/utils/enhanced-sensitive-detector.d.ts.map +1 -0
- package/dist/src/utils/enhanced-sensitive-detector.js +437 -0
- package/dist/src/utils/enhanced-sensitive-detector.js.map +1 -0
- package/dist/src/utils/interactive-approval.d.ts +63 -0
- package/dist/src/utils/interactive-approval.d.ts.map +1 -0
- package/dist/src/utils/interactive-approval.js +441 -0
- package/dist/src/utils/interactive-approval.js.map +1 -0
- package/dist/src/utils/llm-artifact-detector.d.ts +76 -0
- package/dist/src/utils/llm-artifact-detector.d.ts.map +1 -0
- package/dist/src/utils/llm-artifact-detector.js +422 -0
- package/dist/src/utils/llm-artifact-detector.js.map +1 -0
- package/dist/src/utils/location-filter.d.ts +79 -0
- package/dist/src/utils/location-filter.d.ts.map +1 -0
- package/dist/src/utils/location-filter.js +327 -0
- package/dist/src/utils/location-filter.js.map +1 -0
- package/dist/src/utils/release-readiness-detector.d.ts +47 -0
- package/dist/src/utils/release-readiness-detector.d.ts.map +1 -0
- package/dist/src/utils/release-readiness-detector.js +413 -0
- package/dist/src/utils/release-readiness-detector.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart Git Push MCP Tool
|
|
3
|
+
*
|
|
4
|
+
* Intelligent git push with sensitive content and LLM artifact filtering
|
|
5
|
+
* Leverages existing content security tools and git CLI integration
|
|
6
|
+
*/
|
|
7
|
+
import { McpAdrError } from '../types/index.js';
|
|
8
|
+
import { execSync } from 'child_process';
|
|
9
|
+
import { readFileSync, existsSync, statSync } from 'fs';
|
|
10
|
+
import { join, basename } from 'path';
|
|
11
|
+
/**
|
|
12
|
+
* Main smart git push function - MCP Safe Version
|
|
13
|
+
*/
|
|
14
|
+
export async function smartGitPush(args) {
|
|
15
|
+
const { branch, message, skipValidation = false, allowedArtifacts = [], sensitivityLevel = 'moderate', dryRun = false, projectPath = process.cwd(), checkReleaseReadiness = false, releaseType = 'minor' } = args;
|
|
16
|
+
try {
|
|
17
|
+
// Step 1: Check release readiness if requested
|
|
18
|
+
let releaseReadinessResult = null;
|
|
19
|
+
if (checkReleaseReadiness) {
|
|
20
|
+
try {
|
|
21
|
+
const { analyzeReleaseReadiness } = await import('../utils/release-readiness-detector.js');
|
|
22
|
+
releaseReadinessResult = await analyzeReleaseReadiness({
|
|
23
|
+
projectPath,
|
|
24
|
+
releaseType,
|
|
25
|
+
includeAnalysis: true
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
console.error('Release readiness analysis failed:', error);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Step 2: Get staged files using git CLI
|
|
33
|
+
const stagedFiles = await getStagedFiles(projectPath);
|
|
34
|
+
if (stagedFiles.length === 0) {
|
|
35
|
+
let responseText = `# Smart Git Push - No Changes
|
|
36
|
+
|
|
37
|
+
## Status
|
|
38
|
+
No staged files found. Use \`git add\` to stage files before pushing.
|
|
39
|
+
|
|
40
|
+
## Available Commands
|
|
41
|
+
- \`git add .\` - Stage all changes
|
|
42
|
+
- \`git add <file>\` - Stage specific file
|
|
43
|
+
- \`git status\` - Check current status
|
|
44
|
+
`;
|
|
45
|
+
// Add release readiness info if checked
|
|
46
|
+
if (releaseReadinessResult) {
|
|
47
|
+
responseText += `
|
|
48
|
+
|
|
49
|
+
## Release Readiness Analysis
|
|
50
|
+
${releaseReadinessResult.summary}
|
|
51
|
+
|
|
52
|
+
### Recommendations
|
|
53
|
+
${releaseReadinessResult.recommendations.map(r => `- ${r}`).join('\n')}
|
|
54
|
+
|
|
55
|
+
${releaseReadinessResult.isReady ?
|
|
56
|
+
'✅ **Project is ready for release!** Consider creating a release after staging files.' :
|
|
57
|
+
'❌ **Project is not ready for release.** Address blockers before proceeding.'}
|
|
58
|
+
`;
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
content: [{
|
|
62
|
+
type: 'text',
|
|
63
|
+
text: responseText
|
|
64
|
+
}]
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
// Step 3: Analyze staged files if validation is enabled
|
|
68
|
+
let validationResults = [];
|
|
69
|
+
if (!skipValidation) {
|
|
70
|
+
validationResults = await validateStagedFiles(stagedFiles, {
|
|
71
|
+
sensitivityLevel,
|
|
72
|
+
allowedArtifacts,
|
|
73
|
+
projectPath
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
// Step 4: Check for blocking conditions (MCP Safe - No Interactive Mode)
|
|
77
|
+
const issues = validationResults.filter(r => r.issues.length > 0);
|
|
78
|
+
// Check if release readiness should block push
|
|
79
|
+
let releaseReadinessBlocked = false;
|
|
80
|
+
if (releaseReadinessResult && !releaseReadinessResult.isReady) {
|
|
81
|
+
const criticalBlockers = releaseReadinessResult.blockers.filter(b => b.severity === 'error');
|
|
82
|
+
if (criticalBlockers.length > 0) {
|
|
83
|
+
releaseReadinessBlocked = true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Check for blocking conditions
|
|
87
|
+
const hasBlockingErrors = issues.some(issue => issue.issues.some(i => i.severity === 'error'));
|
|
88
|
+
const shouldBlock = hasBlockingErrors || releaseReadinessBlocked;
|
|
89
|
+
if (shouldBlock && !dryRun) {
|
|
90
|
+
let cancelText = `# Smart Git Push - Blocked
|
|
91
|
+
|
|
92
|
+
## Validation Issues
|
|
93
|
+
Push blocked due to critical issues that must be resolved.
|
|
94
|
+
|
|
95
|
+
## Issues Found
|
|
96
|
+
${issues.map(issue => `
|
|
97
|
+
|
|
98
|
+
### ${issue.file}
|
|
99
|
+
${issue.issues.map(i => `- **${i.severity.toUpperCase()}**: ${i.message}`).join('\n')}
|
|
100
|
+
|
|
101
|
+
**Suggestions:**
|
|
102
|
+
${issue.suggestions.map(s => `- ${s}`).join('\n')}
|
|
103
|
+
`).join('\n')}
|
|
104
|
+
`;
|
|
105
|
+
// Add release readiness info if checked and blocked
|
|
106
|
+
if (releaseReadinessResult && releaseReadinessBlocked) {
|
|
107
|
+
cancelText += `
|
|
108
|
+
|
|
109
|
+
## Release Readiness Issues
|
|
110
|
+
${releaseReadinessResult.summary}
|
|
111
|
+
|
|
112
|
+
### Critical Blockers
|
|
113
|
+
${releaseReadinessResult.blockers.filter(b => b.severity === 'error').map(b => `- **${b.type}**: ${b.message}`).join('\n')}
|
|
114
|
+
|
|
115
|
+
### Recommendations
|
|
116
|
+
${releaseReadinessResult.recommendations.map(r => `- ${r}`).join('\n')}
|
|
117
|
+
`;
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
content: [{
|
|
121
|
+
type: 'text',
|
|
122
|
+
text: cancelText
|
|
123
|
+
}]
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
// Step 5: Execute git push if not dry run
|
|
127
|
+
if (!dryRun) {
|
|
128
|
+
const pushResult = await executePush(projectPath, branch, message);
|
|
129
|
+
let successText = `# Smart Git Push - Success ✅
|
|
130
|
+
|
|
131
|
+
## Push Details
|
|
132
|
+
- **Branch**: ${branch || 'current'}
|
|
133
|
+
- **Files**: ${stagedFiles.length} staged files
|
|
134
|
+
- **Validation**: ${skipValidation ? 'Skipped' : 'Completed'}
|
|
135
|
+
- **Issues Found**: ${issues.length}
|
|
136
|
+
- **Sensitivity Level**: ${sensitivityLevel}
|
|
137
|
+
${checkReleaseReadiness ? `- **Release Readiness**: ${releaseReadinessResult?.isReady ? '✅ Ready' : '❌ Not Ready'}` : ''}
|
|
138
|
+
|
|
139
|
+
## Files Pushed
|
|
140
|
+
${stagedFiles.map(f => `- ${f.path} (${f.status})`).join('\n')}
|
|
141
|
+
|
|
142
|
+
${issues.length > 0 ? `
|
|
143
|
+
|
|
144
|
+
## Validation Issues (Auto-Approved)
|
|
145
|
+
${issues.map(issue => `
|
|
146
|
+
|
|
147
|
+
### ${issue.file}
|
|
148
|
+
${issue.issues.map(i => `- **${i.severity.toUpperCase()}**: ${i.message}`).join('\n')}
|
|
149
|
+
`).join('\n')}
|
|
150
|
+
` : ''}
|
|
151
|
+
|
|
152
|
+
${releaseReadinessResult ? `
|
|
153
|
+
|
|
154
|
+
## Release Readiness Analysis
|
|
155
|
+
${releaseReadinessResult.summary}
|
|
156
|
+
|
|
157
|
+
### Post-Push Recommendations
|
|
158
|
+
${releaseReadinessResult.recommendations.map(r => `- ${r}`).join('\n')}
|
|
159
|
+
|
|
160
|
+
${releaseReadinessResult.isReady ?
|
|
161
|
+
'🎉 **Congratulations!** This push completed a release-ready state. Consider creating a release tag.' :
|
|
162
|
+
'📋 **Next Steps**: Address remaining blockers to achieve release readiness.'}
|
|
163
|
+
` : ''}
|
|
164
|
+
|
|
165
|
+
## Git Output
|
|
166
|
+
\`\`\`
|
|
167
|
+
${pushResult.output}
|
|
168
|
+
\`\`\`
|
|
169
|
+
|
|
170
|
+
## Next Steps
|
|
171
|
+
- Monitor CI/CD pipeline for build status
|
|
172
|
+
- Review any deployment processes
|
|
173
|
+
- Check for any post-push hooks or workflows
|
|
174
|
+
${releaseReadinessResult?.isReady ? '- Consider creating a release tag or publishing' : ''}
|
|
175
|
+
`;
|
|
176
|
+
return {
|
|
177
|
+
content: [{
|
|
178
|
+
type: 'text',
|
|
179
|
+
text: successText
|
|
180
|
+
}]
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
// Dry run - show what would happen
|
|
185
|
+
let dryRunText = `# Smart Git Push - Dry Run 🔍
|
|
186
|
+
|
|
187
|
+
## Analysis Complete
|
|
188
|
+
- **Files to Push**: ${stagedFiles.length}
|
|
189
|
+
- **Validation Issues**: ${issues.length}
|
|
190
|
+
- **Sensitivity Level**: ${sensitivityLevel}
|
|
191
|
+
- **Would Push to**: ${branch || 'current branch'}
|
|
192
|
+
${checkReleaseReadiness ? `- **Release Readiness**: ${releaseReadinessResult?.isReady ? '✅ Ready' : '❌ Not Ready'}` : ''}
|
|
193
|
+
|
|
194
|
+
## Staged Files
|
|
195
|
+
${stagedFiles.map(f => `- ${f.path} (${f.status}) - ${f.size} bytes`).join('\n')}
|
|
196
|
+
|
|
197
|
+
${issues.length > 0 ? `
|
|
198
|
+
|
|
199
|
+
## Validation Issues Found
|
|
200
|
+
${issues.map(issue => `
|
|
201
|
+
|
|
202
|
+
### ${issue.file}
|
|
203
|
+
${issue.issues.map(i => `- **${i.severity.toUpperCase()}**: ${i.message}`).join('\n')}
|
|
204
|
+
|
|
205
|
+
**Suggestions:**
|
|
206
|
+
${issue.suggestions.map(s => `- ${s}`).join('\n')}
|
|
207
|
+
`).join('\n')}
|
|
208
|
+
` : '## ✅ No Validation Issues Found'}
|
|
209
|
+
|
|
210
|
+
${releaseReadinessResult ? `
|
|
211
|
+
|
|
212
|
+
## Release Readiness Analysis
|
|
213
|
+
${releaseReadinessResult.summary}
|
|
214
|
+
|
|
215
|
+
### Pre-Push Recommendations
|
|
216
|
+
${releaseReadinessResult.recommendations.map(r => `- ${r}`).join('\n')}
|
|
217
|
+
|
|
218
|
+
${releaseReadinessResult.isReady ?
|
|
219
|
+
'🎉 **Ready for Release!** This push would complete all release requirements.' :
|
|
220
|
+
'📋 **Release Blockers**: Address these issues before considering this a release.'}
|
|
221
|
+
` : ''}
|
|
222
|
+
|
|
223
|
+
## Command to Execute
|
|
224
|
+
\`\`\`bash
|
|
225
|
+
# Run without dry run to actually push
|
|
226
|
+
git push${branch ? ` origin ${branch}` : ''}
|
|
227
|
+
\`\`\`
|
|
228
|
+
|
|
229
|
+
**Note:** This was a dry run. No files were actually pushed.
|
|
230
|
+
`;
|
|
231
|
+
return {
|
|
232
|
+
content: [{
|
|
233
|
+
type: 'text',
|
|
234
|
+
text: dryRunText
|
|
235
|
+
}]
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
throw new McpAdrError(`Smart git push failed: ${error instanceof Error ? error.message : String(error)}`, 'GIT_PUSH_ERROR');
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Get staged files using git CLI
|
|
245
|
+
*/
|
|
246
|
+
async function getStagedFiles(projectPath) {
|
|
247
|
+
try {
|
|
248
|
+
// Get staged files with status
|
|
249
|
+
const gitOutput = execSync('git diff --cached --name-status', {
|
|
250
|
+
cwd: projectPath,
|
|
251
|
+
encoding: 'utf8'
|
|
252
|
+
});
|
|
253
|
+
if (!gitOutput.trim()) {
|
|
254
|
+
return [];
|
|
255
|
+
}
|
|
256
|
+
const files = [];
|
|
257
|
+
const lines = gitOutput.trim().split('\n');
|
|
258
|
+
for (const line of lines) {
|
|
259
|
+
const [status, ...pathParts] = line.split('\t');
|
|
260
|
+
const path = pathParts.join('\t'); // Handle filenames with tabs
|
|
261
|
+
const fullPath = join(projectPath, path);
|
|
262
|
+
let content;
|
|
263
|
+
let size = 0;
|
|
264
|
+
// Read file content if it exists (not for deleted files)
|
|
265
|
+
if (status !== 'D' && existsSync(fullPath)) {
|
|
266
|
+
try {
|
|
267
|
+
const stats = statSync(fullPath);
|
|
268
|
+
size = stats.size;
|
|
269
|
+
// Only read content for small files (< 100KB)
|
|
270
|
+
if (size < 100 * 1024) {
|
|
271
|
+
content = readFileSync(fullPath, 'utf8');
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
catch (err) {
|
|
275
|
+
console.error(`Warning: Could not read file ${path}:`, err);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
files.push({
|
|
279
|
+
path,
|
|
280
|
+
status: mapGitStatus(status || 'M'),
|
|
281
|
+
content: content || '',
|
|
282
|
+
size
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
return files;
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
throw new McpAdrError(`Failed to get staged files: ${error instanceof Error ? error.message : String(error)}`, 'GIT_STATUS_ERROR');
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Map git status codes to readable names
|
|
293
|
+
*/
|
|
294
|
+
function mapGitStatus(status) {
|
|
295
|
+
switch (status) {
|
|
296
|
+
case 'A': return 'added';
|
|
297
|
+
case 'M': return 'modified';
|
|
298
|
+
case 'D': return 'deleted';
|
|
299
|
+
case 'R': return 'renamed';
|
|
300
|
+
default: return 'modified';
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Validate staged files for issues
|
|
305
|
+
*/
|
|
306
|
+
async function validateStagedFiles(files, options) {
|
|
307
|
+
const results = [];
|
|
308
|
+
for (const file of files) {
|
|
309
|
+
const issues = [];
|
|
310
|
+
const suggestions = [];
|
|
311
|
+
// Skip validation for deleted files
|
|
312
|
+
if (file.status === 'deleted') {
|
|
313
|
+
results.push({ file: file.path, issues, suggestions, approved: true });
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
// 1. Check for sensitive content
|
|
317
|
+
if (file.content) {
|
|
318
|
+
const sensitiveIssues = await checkSensitiveContent(file.content, file.path);
|
|
319
|
+
issues.push(...sensitiveIssues);
|
|
320
|
+
}
|
|
321
|
+
// 2. Check for LLM artifacts
|
|
322
|
+
const llmIssues = await checkLLMArtifacts(file.path, file.content);
|
|
323
|
+
issues.push(...llmIssues);
|
|
324
|
+
// 3. Check location rules
|
|
325
|
+
const locationIssues = await checkLocationRules(file.path, options.allowedArtifacts);
|
|
326
|
+
issues.push(...locationIssues);
|
|
327
|
+
// 4. Generate suggestions
|
|
328
|
+
const fileSuggestions = generateSuggestions(file.path, issues);
|
|
329
|
+
suggestions.push(...fileSuggestions);
|
|
330
|
+
results.push({
|
|
331
|
+
file: file.path,
|
|
332
|
+
issues,
|
|
333
|
+
suggestions,
|
|
334
|
+
approved: issues.length === 0 || issues.every(i => i.severity === 'info')
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
return results;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Check for sensitive content using enhanced sensitive detector
|
|
341
|
+
*/
|
|
342
|
+
async function checkSensitiveContent(content, filePath) {
|
|
343
|
+
try {
|
|
344
|
+
// Use enhanced sensitive detector
|
|
345
|
+
const { analyzeSensitiveContent } = await import('../utils/enhanced-sensitive-detector.js');
|
|
346
|
+
const result = await analyzeSensitiveContent(filePath, content);
|
|
347
|
+
// Convert to ValidationIssue format
|
|
348
|
+
const issues = [];
|
|
349
|
+
for (const match of result.matches) {
|
|
350
|
+
issues.push({
|
|
351
|
+
type: 'sensitive-content',
|
|
352
|
+
severity: match.pattern.severity === 'critical' ? 'error' :
|
|
353
|
+
match.pattern.severity === 'high' ? 'error' :
|
|
354
|
+
match.pattern.severity === 'medium' ? 'warning' : 'info',
|
|
355
|
+
message: `${match.pattern.description}: ${match.match}`,
|
|
356
|
+
pattern: match.pattern.name,
|
|
357
|
+
line: match.line
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
return issues;
|
|
361
|
+
}
|
|
362
|
+
catch (error) {
|
|
363
|
+
console.error('Sensitive content check failed:', error);
|
|
364
|
+
return [];
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Check for LLM artifacts using enhanced detector
|
|
369
|
+
*/
|
|
370
|
+
async function checkLLMArtifacts(filePath, content) {
|
|
371
|
+
try {
|
|
372
|
+
// Use enhanced LLM artifact detector
|
|
373
|
+
const { detectLLMArtifacts } = await import('../utils/llm-artifact-detector.js');
|
|
374
|
+
const result = detectLLMArtifacts(filePath, content || '');
|
|
375
|
+
// Convert to ValidationIssue format
|
|
376
|
+
const issues = [];
|
|
377
|
+
for (const match of result.matches) {
|
|
378
|
+
const issue = {
|
|
379
|
+
type: 'llm-artifact',
|
|
380
|
+
severity: match.pattern.severity === 'error' ? 'error' :
|
|
381
|
+
match.pattern.severity === 'warning' ? 'warning' : 'info',
|
|
382
|
+
message: `${match.pattern.description}: ${match.match}`,
|
|
383
|
+
pattern: match.pattern.name
|
|
384
|
+
};
|
|
385
|
+
if (match.line !== undefined) {
|
|
386
|
+
issue.line = match.line;
|
|
387
|
+
}
|
|
388
|
+
issues.push(issue);
|
|
389
|
+
}
|
|
390
|
+
return issues;
|
|
391
|
+
}
|
|
392
|
+
catch (error) {
|
|
393
|
+
console.error('LLM artifact check failed:', error);
|
|
394
|
+
return [];
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Check location rules using enhanced location filter
|
|
399
|
+
*/
|
|
400
|
+
async function checkLocationRules(filePath, allowedArtifacts) {
|
|
401
|
+
try {
|
|
402
|
+
// Use enhanced location filter
|
|
403
|
+
const { validateFileLocation } = await import('../utils/location-filter.js');
|
|
404
|
+
// Skip if explicitly allowed
|
|
405
|
+
if (allowedArtifacts.includes(basename(filePath)) || allowedArtifacts.includes(filePath)) {
|
|
406
|
+
return [];
|
|
407
|
+
}
|
|
408
|
+
const result = validateFileLocation(filePath);
|
|
409
|
+
if (!result.isValid) {
|
|
410
|
+
return [{
|
|
411
|
+
type: 'wrong-location',
|
|
412
|
+
severity: result.severity === 'error' ? 'error' :
|
|
413
|
+
result.severity === 'warning' ? 'warning' : 'info',
|
|
414
|
+
message: result.message,
|
|
415
|
+
pattern: result.rule?.name || 'location-rule'
|
|
416
|
+
}];
|
|
417
|
+
}
|
|
418
|
+
return [];
|
|
419
|
+
}
|
|
420
|
+
catch (error) {
|
|
421
|
+
console.error('Location rule check failed:', error);
|
|
422
|
+
return [];
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Generate suggestions for issues
|
|
427
|
+
*/
|
|
428
|
+
function generateSuggestions(filePath, issues) {
|
|
429
|
+
const suggestions = [];
|
|
430
|
+
const fileName = basename(filePath);
|
|
431
|
+
for (const issue of issues) {
|
|
432
|
+
switch (issue.type) {
|
|
433
|
+
case 'sensitive-content':
|
|
434
|
+
suggestions.push(`Use content masking tool: analyze_content_security`);
|
|
435
|
+
suggestions.push(`Move sensitive data to environment variables`);
|
|
436
|
+
suggestions.push(`Add ${filePath} to .gitignore if it's config`);
|
|
437
|
+
break;
|
|
438
|
+
case 'llm-artifact':
|
|
439
|
+
suggestions.push(`Move ${fileName} to tests/ directory`);
|
|
440
|
+
suggestions.push(`Move ${fileName} to scripts/ directory`);
|
|
441
|
+
suggestions.push(`Add ${filePath} to .gitignore`);
|
|
442
|
+
suggestions.push(`Remove file if it's temporary`);
|
|
443
|
+
break;
|
|
444
|
+
case 'wrong-location':
|
|
445
|
+
suggestions.push(`Move ${fileName} to tests/ directory`);
|
|
446
|
+
suggestions.push(`Move ${fileName} to scripts/ directory`);
|
|
447
|
+
suggestions.push(`Move ${fileName} to tools/ directory`);
|
|
448
|
+
break;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
return [...new Set(suggestions)]; // Remove duplicates
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Execute git push
|
|
455
|
+
*/
|
|
456
|
+
async function executePush(projectPath, branch, message) {
|
|
457
|
+
try {
|
|
458
|
+
let output = '';
|
|
459
|
+
// Commit if there are staged changes and a message is provided
|
|
460
|
+
if (message) {
|
|
461
|
+
const commitOutput = execSync(`git commit -m "${message}"`, {
|
|
462
|
+
cwd: projectPath,
|
|
463
|
+
encoding: 'utf8'
|
|
464
|
+
});
|
|
465
|
+
output += `Commit:\n${commitOutput}\n\n`;
|
|
466
|
+
}
|
|
467
|
+
// Push to the specified branch or current branch
|
|
468
|
+
const pushCommand = branch ? `git push origin ${branch}` : 'git push';
|
|
469
|
+
const pushOutput = execSync(pushCommand, {
|
|
470
|
+
cwd: projectPath,
|
|
471
|
+
encoding: 'utf8'
|
|
472
|
+
});
|
|
473
|
+
output += `Push:\n${pushOutput}`;
|
|
474
|
+
return { output, success: true };
|
|
475
|
+
}
|
|
476
|
+
catch (error) {
|
|
477
|
+
throw new McpAdrError(`Git push failed: ${error instanceof Error ? error.message : String(error)}`, 'GIT_PUSH_FAILED');
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
//# sourceMappingURL=smart-git-push-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smart-git-push-tool.js","sourceRoot":"","sources":["../../../src/tools/smart-git-push-tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAqCtC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAsB;IACvD,MAAM,EACJ,MAAM,EACN,OAAO,EACP,cAAc,GAAG,KAAK,EACtB,gBAAgB,GAAG,EAAE,EACrB,gBAAgB,GAAG,UAAU,EAC7B,MAAM,GAAG,KAAK,EACd,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,EAC3B,qBAAqB,GAAG,KAAK,EAC7B,WAAW,GAAG,OAAO,EACtB,GAAG,IAAI,CAAC;IAET,IAAI,CAAC;QACH,+CAA+C;QAC/C,IAAI,sBAAsB,GAAG,IAAI,CAAC;QAClC,IAAI,qBAAqB,EAAE,CAAC;YAC1B,IAAI,CAAC;gBACH,MAAM,EAAE,uBAAuB,EAAE,GAAG,MAAM,MAAM,CAAC,wCAAwC,CAAC,CAAC;gBAC3F,sBAAsB,GAAG,MAAM,uBAAuB,CAAC;oBACr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AM,CAAC,KAAK,CAAC,EAAE,EAC5E,iBAAiB,CAClB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced sensitive content detector for smart git push
|
|
3
|
+
*
|
|
4
|
+
* Integrates with existing content-masking-tool.ts and adds git-specific patterns
|
|
5
|
+
*/
|
|
6
|
+
export interface SensitivePattern {
|
|
7
|
+
name: string;
|
|
8
|
+
pattern: RegExp;
|
|
9
|
+
description: string;
|
|
10
|
+
category: 'credentials' | 'secrets' | 'personal' | 'infrastructure' | 'development';
|
|
11
|
+
severity: 'critical' | 'high' | 'medium' | 'low';
|
|
12
|
+
falsePositivePatterns?: RegExp[];
|
|
13
|
+
contextRequired?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface SensitiveMatch {
|
|
16
|
+
pattern: SensitivePattern;
|
|
17
|
+
match: string;
|
|
18
|
+
line: number;
|
|
19
|
+
column: number;
|
|
20
|
+
context: string;
|
|
21
|
+
confidence: number;
|
|
22
|
+
suggestions: string[];
|
|
23
|
+
}
|
|
24
|
+
export interface SensitiveContentResult {
|
|
25
|
+
filePath: string;
|
|
26
|
+
hasIssues: boolean;
|
|
27
|
+
matches: SensitiveMatch[];
|
|
28
|
+
summary: {
|
|
29
|
+
criticalCount: number;
|
|
30
|
+
highCount: number;
|
|
31
|
+
mediumCount: number;
|
|
32
|
+
lowCount: number;
|
|
33
|
+
totalCount: number;
|
|
34
|
+
};
|
|
35
|
+
recommendations: string[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Enhanced sensitive patterns for git context
|
|
39
|
+
*/
|
|
40
|
+
export declare const GIT_SENSITIVE_PATTERNS: SensitivePattern[];
|
|
41
|
+
/**
|
|
42
|
+
* Analyze content for sensitive information
|
|
43
|
+
*/
|
|
44
|
+
export declare function analyzeSensitiveContent(filePath: string, content: string, customPatterns?: SensitivePattern[]): Promise<SensitiveContentResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Integration with existing content masking tool
|
|
47
|
+
*/
|
|
48
|
+
export declare function integrateWithContentMasking(filePath: string, content: string): Promise<{
|
|
49
|
+
sensitiveAnalysis: SensitiveContentResult;
|
|
50
|
+
maskingPrompt?: string;
|
|
51
|
+
combinedRecommendations: string[];
|
|
52
|
+
}>;
|
|
53
|
+
/**
|
|
54
|
+
* Quick check for obviously sensitive files
|
|
55
|
+
*/
|
|
56
|
+
export declare function isObviouslySensitive(filePath: string): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Create a custom sensitive pattern
|
|
59
|
+
*/
|
|
60
|
+
export declare function createSensitivePattern(name: string, pattern: string, description: string, category: SensitivePattern['category'], severity: SensitivePattern['severity']): SensitivePattern;
|
|
61
|
+
//# sourceMappingURL=enhanced-sensitive-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enhanced-sensitive-detector.d.ts","sourceRoot":"","sources":["../../../src/utils/enhanced-sensitive-detector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,aAAa,GAAG,SAAS,GAAG,UAAU,GAAG,gBAAgB,GAAG,aAAa,CAAC;IACpF,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACjD,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;IACjC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAA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