mcp-adr-analysis-server 2.0.24 → 2.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/README.md +94 -839
- package/dist/.tsbuildinfo +1 -1
- package/dist/src/config/ai-config.d.ts.map +1 -1
- package/dist/src/config/ai-config.js +9 -9
- package/dist/src/config/ai-config.js.map +1 -1
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +218 -60
- package/dist/src/index.js.map +1 -1
- package/dist/src/prompts/analysis-prompts.d.ts +4 -1
- package/dist/src/prompts/analysis-prompts.d.ts.map +1 -1
- package/dist/src/prompts/analysis-prompts.js +61 -30
- package/dist/src/prompts/analysis-prompts.js.map +1 -1
- package/dist/src/prompts/index.d.ts +17 -1
- package/dist/src/prompts/index.d.ts.map +1 -1
- package/dist/src/prompts/index.js +325 -1
- package/dist/src/prompts/index.js.map +1 -1
- package/dist/src/prompts/rule-generation-prompts.d.ts +5 -1
- package/dist/src/prompts/rule-generation-prompts.d.ts.map +1 -1
- package/dist/src/prompts/rule-generation-prompts.js +5 -1
- package/dist/src/prompts/rule-generation-prompts.js.map +1 -1
- package/dist/src/prompts/security-prompts.d.ts +6 -1
- package/dist/src/prompts/security-prompts.d.ts.map +1 -1
- package/dist/src/prompts/security-prompts.js +6 -1
- package/dist/src/prompts/security-prompts.js.map +1 -1
- package/dist/src/prompts/todo-prompts.d.ts +49 -0
- package/dist/src/prompts/todo-prompts.d.ts.map +1 -0
- package/dist/src/prompts/todo-prompts.js +824 -0
- package/dist/src/prompts/todo-prompts.js.map +1 -0
- package/dist/src/resources/index.d.ts.map +1 -1
- package/dist/src/resources/index.js +9 -7
- package/dist/src/resources/index.js.map +1 -1
- package/dist/src/tools/adr-bootstrap-validation-tool.d.ts +47 -0
- package/dist/src/tools/adr-bootstrap-validation-tool.d.ts.map +1 -0
- package/dist/src/tools/adr-bootstrap-validation-tool.js +979 -0
- package/dist/src/tools/adr-bootstrap-validation-tool.js.map +1 -0
- package/dist/src/tools/adr-suggestion-tool.d.ts +1 -0
- package/dist/src/tools/adr-suggestion-tool.d.ts.map +1 -1
- package/dist/src/tools/adr-suggestion-tool.js +298 -2
- package/dist/src/tools/adr-suggestion-tool.js.map +1 -1
- package/dist/src/tools/content-masking-tool.d.ts +1 -0
- package/dist/src/tools/content-masking-tool.d.ts.map +1 -1
- package/dist/src/tools/content-masking-tool.js +100 -0
- package/dist/src/tools/content-masking-tool.js.map +1 -1
- package/dist/src/tools/deployment-readiness-tool.d.ts.map +1 -1
- package/dist/src/tools/deployment-readiness-tool.js +298 -36
- package/dist/src/tools/deployment-readiness-tool.js.map +1 -1
- package/dist/src/tools/interactive-adr-planning-tool.d.ts.map +1 -1
- package/dist/src/tools/interactive-adr-planning-tool.js +270 -108
- package/dist/src/tools/interactive-adr-planning-tool.js.map +1 -1
- package/dist/src/tools/mcp-planning-tool.d.ts.map +1 -1
- package/dist/src/tools/mcp-planning-tool.js +18 -10
- package/dist/src/tools/mcp-planning-tool.js.map +1 -1
- package/dist/src/tools/research-integration-tool.d.ts +4 -1
- package/dist/src/tools/research-integration-tool.d.ts.map +1 -1
- package/dist/src/tools/research-integration-tool.js +5 -1
- package/dist/src/tools/research-integration-tool.js.map +1 -1
- package/dist/src/tools/review-existing-adrs-tool.d.ts +19 -0
- package/dist/src/tools/review-existing-adrs-tool.d.ts.map +1 -0
- package/dist/src/tools/review-existing-adrs-tool.js +1204 -0
- package/dist/src/tools/review-existing-adrs-tool.js.map +1 -0
- package/dist/src/tools/rule-generation-tool.d.ts +2 -0
- package/dist/src/tools/rule-generation-tool.d.ts.map +1 -1
- package/dist/src/tools/rule-generation-tool.js +274 -33
- package/dist/src/tools/rule-generation-tool.js.map +1 -1
- package/dist/src/tools/smart-git-push-tool-v2.d.ts +4 -0
- package/dist/src/tools/smart-git-push-tool-v2.d.ts.map +1 -1
- package/dist/src/tools/smart-git-push-tool-v2.js +423 -229
- package/dist/src/tools/smart-git-push-tool-v2.js.map +1 -1
- package/dist/src/tools/smart-git-push-tool.d.ts.map +1 -1
- package/dist/src/tools/smart-git-push-tool.js +65 -13
- package/dist/src/tools/smart-git-push-tool.js.map +1 -1
- package/dist/src/tools/tool-chain-orchestrator.d.ts +2 -2
- package/dist/src/tools/tool-chain-orchestrator.d.ts.map +1 -1
- package/dist/src/tools/tool-chain-orchestrator.js +152 -93
- package/dist/src/tools/tool-chain-orchestrator.js.map +1 -1
- package/dist/src/tools/troubleshoot-guided-workflow-tool.d.ts +6 -6
- package/dist/src/tools/troubleshoot-guided-workflow-tool.d.ts.map +1 -1
- package/dist/src/tools/troubleshoot-guided-workflow-tool.js +154 -6
- package/dist/src/tools/troubleshoot-guided-workflow-tool.js.map +1 -1
- package/dist/src/types/ape-framework.d.ts +93 -0
- package/dist/src/types/ape-framework.d.ts.map +1 -1
- package/dist/src/types/ape-framework.js +10 -10
- package/dist/src/types/ape-framework.js.map +1 -1
- package/dist/src/types/index.d.ts +129 -3
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js +15 -0
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/knowledge-generation.d.ts +78 -0
- package/dist/src/types/knowledge-generation.d.ts.map +1 -1
- package/dist/src/types/knowledge-generation.js +10 -6
- package/dist/src/types/knowledge-generation.js.map +1 -1
- package/dist/src/types/memory-entities.d.ts +36 -36
- package/dist/src/types/reflexion-framework.d.ts +44 -0
- package/dist/src/types/reflexion-framework.d.ts.map +1 -1
- package/dist/src/types/reflexion-framework.js +7 -7
- package/dist/src/types/reflexion-framework.js.map +1 -1
- package/dist/src/types/tool-arguments.d.ts +224 -0
- package/dist/src/types/tool-arguments.d.ts.map +1 -0
- package/dist/src/types/tool-arguments.js +6 -0
- package/dist/src/types/tool-arguments.js.map +1 -0
- package/dist/src/utils/actual-file-operations.d.ts.map +1 -1
- package/dist/src/utils/actual-file-operations.js +25 -9
- package/dist/src/utils/actual-file-operations.js.map +1 -1
- package/dist/src/utils/adr-discovery.d.ts +33 -1
- package/dist/src/utils/adr-discovery.d.ts.map +1 -1
- package/dist/src/utils/adr-discovery.js +14 -9
- package/dist/src/utils/adr-discovery.js.map +1 -1
- package/dist/src/utils/adr-suggestions.d.ts +72 -0
- package/dist/src/utils/adr-suggestions.d.ts.map +1 -1
- package/dist/src/utils/adr-suggestions.js +6 -0
- package/dist/src/utils/adr-suggestions.js.map +1 -1
- package/dist/src/utils/cache.d.ts.map +1 -1
- package/dist/src/utils/cache.js +22 -19
- package/dist/src/utils/cache.js.map +1 -1
- package/dist/src/utils/chain-of-thought-template.d.ts +13 -1
- package/dist/src/utils/chain-of-thought-template.d.ts.map +1 -1
- package/dist/src/utils/chain-of-thought-template.js +31 -22
- package/dist/src/utils/chain-of-thought-template.js.map +1 -1
- package/dist/src/utils/config.d.ts.map +1 -1
- package/dist/src/utils/config.js +1 -0
- package/dist/src/utils/config.js.map +1 -1
- package/dist/src/utils/directory-compat.js +1 -1
- package/dist/src/utils/directory-compat.js.map +1 -1
- package/dist/src/utils/file-system.d.ts +182 -34
- package/dist/src/utils/file-system.d.ts.map +1 -1
- package/dist/src/utils/file-system.js +648 -774
- package/dist/src/utils/file-system.js.map +1 -1
- package/dist/src/utils/gitleaks-detector.d.ts +50 -0
- package/dist/src/utils/gitleaks-detector.d.ts.map +1 -0
- package/dist/src/utils/gitleaks-detector.js +334 -0
- package/dist/src/utils/gitleaks-detector.js.map +1 -0
- package/dist/src/utils/interactive-approval.d.ts.map +1 -1
- package/dist/src/utils/interactive-approval.js +2 -1
- package/dist/src/utils/interactive-approval.js.map +1 -1
- package/dist/src/utils/json-safe.d.ts.map +1 -1
- package/dist/src/utils/json-safe.js +9 -6
- package/dist/src/utils/json-safe.js.map +1 -1
- package/dist/src/utils/knowledge-graph-manager.d.ts +14 -0
- package/dist/src/utils/knowledge-graph-manager.d.ts.map +1 -1
- package/dist/src/utils/knowledge-graph-manager.js +18 -1
- package/dist/src/utils/knowledge-graph-manager.js.map +1 -1
- package/dist/src/utils/location-filter.d.ts +35 -10
- package/dist/src/utils/location-filter.d.ts.map +1 -1
- package/dist/src/utils/location-filter.js +360 -94
- package/dist/src/utils/location-filter.js.map +1 -1
- package/dist/src/utils/mcp-response-validator.d.ts.map +1 -1
- package/dist/src/utils/mcp-response-validator.js +34 -19
- package/dist/src/utils/mcp-response-validator.js.map +1 -1
- package/dist/src/utils/memory-entity-manager.d.ts.map +1 -1
- package/dist/src/utils/memory-entity-manager.js +5 -2
- package/dist/src/utils/memory-entity-manager.js.map +1 -1
- package/dist/src/utils/memory-migration-manager.d.ts.map +1 -1
- package/dist/src/utils/memory-migration-manager.js +15 -7
- package/dist/src/utils/memory-migration-manager.js.map +1 -1
- package/dist/src/utils/memory-relationship-mapper.d.ts.map +1 -1
- package/dist/src/utils/memory-relationship-mapper.js +2 -1
- package/dist/src/utils/memory-relationship-mapper.js.map +1 -1
- package/dist/src/utils/memory-rollback-manager.d.ts +12 -0
- package/dist/src/utils/memory-rollback-manager.d.ts.map +1 -1
- package/dist/src/utils/memory-rollback-manager.js +36 -3
- package/dist/src/utils/memory-rollback-manager.js.map +1 -1
- package/dist/src/utils/output-masking.d.ts +12 -0
- package/dist/src/utils/output-masking.d.ts.map +1 -1
- package/dist/src/utils/output-masking.js +5 -0
- package/dist/src/utils/output-masking.js.map +1 -1
- package/dist/src/utils/release-readiness-detector.d.ts.map +1 -1
- package/dist/src/utils/release-readiness-detector.js +43 -42
- package/dist/src/utils/release-readiness-detector.js.map +1 -1
- package/dist/src/utils/research-integration.d.ts.map +1 -1
- package/dist/src/utils/research-integration.js +73 -44
- 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 +40 -14
- package/dist/src/utils/research-questions.js.map +1 -1
- package/dist/src/utils/ripgrep-wrapper.d.ts +84 -0
- package/dist/src/utils/ripgrep-wrapper.d.ts.map +1 -0
- package/dist/src/utils/ripgrep-wrapper.js +255 -0
- package/dist/src/utils/ripgrep-wrapper.js.map +1 -0
- package/dist/src/utils/rule-generation.d.ts.map +1 -1
- package/dist/src/utils/rule-generation.js +26 -15
- package/dist/src/utils/rule-generation.js.map +1 -1
- package/dist/src/utils/tree-sitter-analyzer.d.ts +185 -0
- package/dist/src/utils/tree-sitter-analyzer.d.ts.map +1 -0
- package/dist/src/utils/tree-sitter-analyzer.js +885 -0
- package/dist/src/utils/tree-sitter-analyzer.js.map +1 -0
- package/package.json +31 -6
- package/dist/src/utils/enhanced-sensitive-detector.d.ts +0 -61
- package/dist/src/utils/enhanced-sensitive-detector.d.ts.map +0 -1
- package/dist/src/utils/enhanced-sensitive-detector.js +0 -437
- package/dist/src/utils/enhanced-sensitive-detector.js.map +0 -1
|
@@ -23,11 +23,14 @@ import { z } from 'zod';
|
|
|
23
23
|
import { McpAdrError } from '../types/index.js';
|
|
24
24
|
import { execSync } from 'child_process';
|
|
25
25
|
import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs';
|
|
26
|
-
import { join } from 'path';
|
|
26
|
+
import { join, basename } from 'path';
|
|
27
|
+
import * as os from 'os';
|
|
27
28
|
import { validateMcpResponse } from '../utils/mcp-response-validator.js';
|
|
28
29
|
import { jsonSafeError } from '../utils/json-safe.js';
|
|
29
30
|
import { MemoryEntityManager } from '../utils/memory-entity-manager.js';
|
|
30
31
|
import { EnhancedLogger } from '../utils/enhanced-logging.js';
|
|
32
|
+
import { TreeSitterAnalyzer } from '../utils/tree-sitter-analyzer.js';
|
|
33
|
+
import { findFiles, findRelatedCode } from '../utils/file-system.js';
|
|
31
34
|
// Core schemas
|
|
32
35
|
const DeploymentReadinessSchema = z.object({
|
|
33
36
|
operation: z
|
|
@@ -94,6 +97,15 @@ const DeploymentReadinessSchema = z.object({
|
|
|
94
97
|
.boolean()
|
|
95
98
|
.default(false)
|
|
96
99
|
.describe('Migrate existing deployment history to memory'),
|
|
100
|
+
// Tree-sitter Analysis
|
|
101
|
+
enableTreeSitterAnalysis: z
|
|
102
|
+
.boolean()
|
|
103
|
+
.default(true)
|
|
104
|
+
.describe('Use tree-sitter for enhanced code analysis'),
|
|
105
|
+
treeSitterLanguages: z
|
|
106
|
+
.array(z.string())
|
|
107
|
+
.default(['typescript', 'javascript', 'python', 'yaml', 'hcl'])
|
|
108
|
+
.describe('Languages to analyze with tree-sitter'),
|
|
97
109
|
});
|
|
98
110
|
/**
|
|
99
111
|
* Deployment Memory Manager for tracking deployment assessments and patterns
|
|
@@ -569,7 +581,8 @@ export async function deploymentReadiness(args) {
|
|
|
569
581
|
const validatedArgs = DeploymentReadinessSchema.parse(args);
|
|
570
582
|
// Initialize paths and cache
|
|
571
583
|
const projectPath = validatedArgs.projectPath || process.cwd();
|
|
572
|
-
const
|
|
584
|
+
const projectName = basename(projectPath);
|
|
585
|
+
const cacheDir = join(os.tmpdir(), projectName, 'cache');
|
|
573
586
|
const deploymentHistoryPath = join(cacheDir, 'deployment-history.json');
|
|
574
587
|
const readinessCachePath = join(cacheDir, 'deployment-readiness-cache.json');
|
|
575
588
|
// Ensure cache directory exists
|
|
@@ -722,13 +735,7 @@ async function performTestValidation(args, projectPath) {
|
|
|
722
735
|
isDeploymentReady: testBlockers.length === 0,
|
|
723
736
|
overallScore: calculateTestScore(testResult, args),
|
|
724
737
|
confidence: 85,
|
|
725
|
-
codeQualityAnalysis:
|
|
726
|
-
qualityScore: 75,
|
|
727
|
-
productionIndicators: 10,
|
|
728
|
-
mockIndicators: 2,
|
|
729
|
-
failingFiles: [],
|
|
730
|
-
recommendations: [],
|
|
731
|
-
},
|
|
738
|
+
codeQualityAnalysis: await analyzeCodeQualityWithTreeSitter(args.projectPath || process.cwd(), args.enableTreeSitterAnalysis, args.treeSitterLanguages),
|
|
732
739
|
testValidationResult: testResult,
|
|
733
740
|
deploymentHistoryAnalysis: {
|
|
734
741
|
recentDeployments: [],
|
|
@@ -895,7 +902,7 @@ async function checkTestCoverage(projectPath) {
|
|
|
895
902
|
}
|
|
896
903
|
}
|
|
897
904
|
}
|
|
898
|
-
catch
|
|
905
|
+
catch {
|
|
899
906
|
// Coverage not available
|
|
900
907
|
}
|
|
901
908
|
return 0; // Default to 0 if coverage cannot be determined
|
|
@@ -947,13 +954,7 @@ async function performDeploymentHistoryAnalysis(args, historyPath) {
|
|
|
947
954
|
isDeploymentReady: historyBlockers.length === 0,
|
|
948
955
|
overallScore: Math.min(analysis.successRate, 100 - analysis.rollbackRate),
|
|
949
956
|
confidence: 80,
|
|
950
|
-
codeQualityAnalysis:
|
|
951
|
-
qualityScore: 75,
|
|
952
|
-
productionIndicators: 10,
|
|
953
|
-
mockIndicators: 2,
|
|
954
|
-
failingFiles: [],
|
|
955
|
-
recommendations: [],
|
|
956
|
-
},
|
|
957
|
+
codeQualityAnalysis: await analyzeCodeQualityWithTreeSitter(args.projectPath || process.cwd(), args.enableTreeSitterAnalysis, args.treeSitterLanguages),
|
|
957
958
|
testValidationResult: {
|
|
958
959
|
testSuitesExecuted: [],
|
|
959
960
|
overallTestStatus: 'not_run',
|
|
@@ -993,7 +994,7 @@ function loadDeploymentHistory(historyPath) {
|
|
|
993
994
|
const content = readFileSync(historyPath, 'utf8');
|
|
994
995
|
return JSON.parse(content);
|
|
995
996
|
}
|
|
996
|
-
catch
|
|
997
|
+
catch {
|
|
997
998
|
return { deployments: [] };
|
|
998
999
|
}
|
|
999
1000
|
}
|
|
@@ -1053,6 +1054,108 @@ async function performFullAudit(args, projectPath, historyPath) {
|
|
|
1053
1054
|
// Combine all validations
|
|
1054
1055
|
const testResult = await performTestValidation(args, projectPath);
|
|
1055
1056
|
const historyResult = await performDeploymentHistoryAnalysis(args, historyPath);
|
|
1057
|
+
// Smart Code Linking - Enhanced deployment readiness with ADR analysis
|
|
1058
|
+
let smartCodeAnalysis = '';
|
|
1059
|
+
let adrComplianceResult = testResult.adrComplianceResult;
|
|
1060
|
+
if (args.requireAdrCompliance) {
|
|
1061
|
+
try {
|
|
1062
|
+
// Discover ADRs in the project
|
|
1063
|
+
const { discoverAdrsInDirectory } = await import('../utils/adr-discovery.js');
|
|
1064
|
+
const adrDirectory = 'docs/adrs';
|
|
1065
|
+
const discoveryResult = await discoverAdrsInDirectory(adrDirectory, true, projectPath);
|
|
1066
|
+
if (discoveryResult.adrs.length > 0) {
|
|
1067
|
+
// Combine all ADR content for Smart Code Linking analysis
|
|
1068
|
+
const combinedAdrContent = discoveryResult.adrs
|
|
1069
|
+
.map(adr => `# ${adr.title}\n${adr.content || ''}`)
|
|
1070
|
+
.join('\n\n');
|
|
1071
|
+
const relatedCodeResult = await findRelatedCode('deployment-readiness-analysis', combinedAdrContent, projectPath, {
|
|
1072
|
+
useAI: true,
|
|
1073
|
+
useRipgrep: true,
|
|
1074
|
+
maxFiles: 25,
|
|
1075
|
+
includeContent: false,
|
|
1076
|
+
});
|
|
1077
|
+
// Enhanced ADR compliance analysis with related code context
|
|
1078
|
+
const deploymentCriticalFiles = relatedCodeResult.relatedFiles.filter(file => {
|
|
1079
|
+
const deploymentKeywords = [
|
|
1080
|
+
'deploy',
|
|
1081
|
+
'config',
|
|
1082
|
+
'env',
|
|
1083
|
+
'docker',
|
|
1084
|
+
'k8s',
|
|
1085
|
+
'terraform',
|
|
1086
|
+
'ci',
|
|
1087
|
+
'cd',
|
|
1088
|
+
];
|
|
1089
|
+
return deploymentKeywords.some(keyword => file.path.toLowerCase().includes(keyword) ||
|
|
1090
|
+
file.directory.toLowerCase().includes(keyword));
|
|
1091
|
+
});
|
|
1092
|
+
adrComplianceResult = {
|
|
1093
|
+
score: Math.min(100, 70 + relatedCodeResult.confidence * 30),
|
|
1094
|
+
compliantAdrs: discoveryResult.adrs.length,
|
|
1095
|
+
totalAdrs: discoveryResult.adrs.length,
|
|
1096
|
+
missingImplementations: deploymentCriticalFiles.length === 0
|
|
1097
|
+
? ['Deployment-specific implementations not found in related code']
|
|
1098
|
+
: [],
|
|
1099
|
+
recommendations: [
|
|
1100
|
+
...(deploymentCriticalFiles.length > 0
|
|
1101
|
+
? [`Found ${deploymentCriticalFiles.length} deployment-critical files linked to ADRs`]
|
|
1102
|
+
: ['Consider documenting deployment procedures in ADRs']),
|
|
1103
|
+
...(relatedCodeResult.relatedFiles.length > 10
|
|
1104
|
+
? ['High code-ADR linkage indicates good architectural documentation']
|
|
1105
|
+
: ['Consider improving ADR-to-code traceability']),
|
|
1106
|
+
...(relatedCodeResult.confidence > 0.8
|
|
1107
|
+
? ['Strong architectural alignment detected between ADRs and implementation']
|
|
1108
|
+
: ['Review ADR implementation alignment before deployment']),
|
|
1109
|
+
],
|
|
1110
|
+
};
|
|
1111
|
+
smartCodeAnalysis = `
|
|
1112
|
+
|
|
1113
|
+
## 🔗 Smart Code Linking - Deployment Analysis
|
|
1114
|
+
|
|
1115
|
+
**ADR Discovery**: Found ${discoveryResult.adrs.length} architectural decision records
|
|
1116
|
+
**Related Code Files**: ${relatedCodeResult.relatedFiles.length} files linked to ADRs
|
|
1117
|
+
**Deployment-Critical Files**: ${deploymentCriticalFiles.length} files identified
|
|
1118
|
+
|
|
1119
|
+
### Deployment-Critical Code Analysis
|
|
1120
|
+
${deploymentCriticalFiles.length > 0
|
|
1121
|
+
? deploymentCriticalFiles
|
|
1122
|
+
.slice(0, 5)
|
|
1123
|
+
.map((file, index) => `${index + 1}. **${file.path}** - ${file.extension} file (${file.size} bytes)`)
|
|
1124
|
+
.join('\n')
|
|
1125
|
+
: '*No deployment-specific files found in ADR-related code*'}
|
|
1126
|
+
|
|
1127
|
+
### Architectural Alignment
|
|
1128
|
+
- **ADR-Code Confidence**: ${(relatedCodeResult.confidence * 100).toFixed(1)}%
|
|
1129
|
+
- **Keywords Used**: ${relatedCodeResult.keywords.join(', ')}
|
|
1130
|
+
- **Implementation Coverage**: ${relatedCodeResult.relatedFiles.length > 0 ? 'Adequate' : 'Needs Review'}
|
|
1131
|
+
|
|
1132
|
+
**Deployment Impact**: ${deploymentCriticalFiles.length > 0
|
|
1133
|
+
? 'ADR-guided deployment files found - architectural decisions are implemented'
|
|
1134
|
+
: 'Limited deployment-specific code found - verify manual deployment procedures'}
|
|
1135
|
+
`;
|
|
1136
|
+
}
|
|
1137
|
+
else {
|
|
1138
|
+
smartCodeAnalysis = `
|
|
1139
|
+
|
|
1140
|
+
## 🔗 Smart Code Linking - Deployment Analysis
|
|
1141
|
+
|
|
1142
|
+
**Status**: No ADRs found in project
|
|
1143
|
+
**Recommendation**: Consider creating ADRs to document deployment architecture and decisions
|
|
1144
|
+
**Impact**: Proceeding with deployment readiness check without architectural guidance
|
|
1145
|
+
`;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
catch (error) {
|
|
1149
|
+
console.warn('[WARNING] Smart Code Linking for deployment analysis failed:', error);
|
|
1150
|
+
smartCodeAnalysis = `
|
|
1151
|
+
|
|
1152
|
+
## 🔗 Smart Code Linking - Deployment Analysis
|
|
1153
|
+
|
|
1154
|
+
**Status**: ⚠️ ADR analysis failed - continuing with standard deployment checks
|
|
1155
|
+
**Error**: ${error instanceof Error ? error.message : 'Unknown error'}
|
|
1156
|
+
`;
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1056
1159
|
const allBlockers = [
|
|
1057
1160
|
...testResult.criticalBlockers,
|
|
1058
1161
|
...testResult.testFailureBlockers,
|
|
@@ -1060,14 +1163,14 @@ async function performFullAudit(args, projectPath, historyPath) {
|
|
|
1060
1163
|
];
|
|
1061
1164
|
const overallScore = (testResult.overallScore + historyResult.overallScore) / 2;
|
|
1062
1165
|
const isReady = allBlockers.length === 0;
|
|
1063
|
-
|
|
1166
|
+
const result = {
|
|
1064
1167
|
isDeploymentReady: isReady,
|
|
1065
1168
|
overallScore,
|
|
1066
1169
|
confidence: Math.min(testResult.confidence, historyResult.confidence),
|
|
1067
1170
|
codeQualityAnalysis: testResult.codeQualityAnalysis,
|
|
1068
1171
|
testValidationResult: testResult.testValidationResult,
|
|
1069
1172
|
deploymentHistoryAnalysis: historyResult.deploymentHistoryAnalysis,
|
|
1070
|
-
adrComplianceResult
|
|
1173
|
+
adrComplianceResult,
|
|
1071
1174
|
criticalBlockers: allBlockers.filter(b => b.severity === 'critical'),
|
|
1072
1175
|
testFailureBlockers: testResult.testFailureBlockers,
|
|
1073
1176
|
deploymentHistoryBlockers: historyResult.deploymentHistoryBlockers,
|
|
@@ -1076,7 +1179,9 @@ async function performFullAudit(args, projectPath, historyPath) {
|
|
|
1076
1179
|
healthScoreUpdate: {},
|
|
1077
1180
|
gitPushStatus: isReady ? 'allowed' : 'blocked',
|
|
1078
1181
|
overrideStatus: {},
|
|
1182
|
+
smartCodeAnalysis, // Include Smart Code Linking analysis
|
|
1079
1183
|
};
|
|
1184
|
+
return result;
|
|
1080
1185
|
}
|
|
1081
1186
|
/**
|
|
1082
1187
|
* Perform emergency override
|
|
@@ -1092,7 +1197,9 @@ async function performEmergencyOverride(args, projectPath) {
|
|
|
1092
1197
|
environment: args.targetEnvironment,
|
|
1093
1198
|
overriddenBy: process.env['USER'] || 'unknown',
|
|
1094
1199
|
};
|
|
1095
|
-
const
|
|
1200
|
+
const projectName = basename(projectPath);
|
|
1201
|
+
const cacheDir = join(os.tmpdir(), projectName, 'cache');
|
|
1202
|
+
const overridePath = join(cacheDir, 'emergency-overrides.json');
|
|
1096
1203
|
const overrides = existsSync(overridePath) ? JSON.parse(readFileSync(overridePath, 'utf8')) : [];
|
|
1097
1204
|
overrides.push(overrideRecord);
|
|
1098
1205
|
writeFileSync(overridePath, JSON.stringify(overrides, null, 2));
|
|
@@ -1100,13 +1207,7 @@ async function performEmergencyOverride(args, projectPath) {
|
|
|
1100
1207
|
isDeploymentReady: true,
|
|
1101
1208
|
overallScore: 100,
|
|
1102
1209
|
confidence: 50, // Lower confidence for overrides
|
|
1103
|
-
codeQualityAnalysis:
|
|
1104
|
-
qualityScore: 100,
|
|
1105
|
-
productionIndicators: 0,
|
|
1106
|
-
mockIndicators: 0,
|
|
1107
|
-
failingFiles: [],
|
|
1108
|
-
recommendations: ['Emergency override active - review post-deployment'],
|
|
1109
|
-
},
|
|
1210
|
+
codeQualityAnalysis: createDefaultCodeQualityAnalysis(100, 0, 0),
|
|
1110
1211
|
testValidationResult: {
|
|
1111
1212
|
testSuitesExecuted: [],
|
|
1112
1213
|
overallTestStatus: 'not_run',
|
|
@@ -1248,6 +1349,7 @@ function generateSuccessResponse(result, args) {
|
|
|
1248
1349
|
- **Readiness Score**: ${result.overallScore}%
|
|
1249
1350
|
- **Confidence**: ${result.confidence}%
|
|
1250
1351
|
- **Target Environment**: ${args.targetEnvironment}
|
|
1352
|
+
- **Fast File Discovery**: ✅ Enhanced with fast-glob
|
|
1251
1353
|
|
|
1252
1354
|
## 🧪 Test Validation
|
|
1253
1355
|
- **Test Status**: ✅ ${result.testValidationResult.overallTestStatus.toUpperCase()}
|
|
@@ -1260,6 +1362,13 @@ function generateSuccessResponse(result, args) {
|
|
|
1260
1362
|
- **Rollback Rate**: ${result.deploymentHistoryAnalysis.rollbackRate}%
|
|
1261
1363
|
- **Environment Stability**: ${result.deploymentHistoryAnalysis.environmentStability.riskLevel}
|
|
1262
1364
|
|
|
1365
|
+
## 🏛️ ADR Compliance
|
|
1366
|
+
- **Compliance Score**: ${result.adrComplianceResult.score}%
|
|
1367
|
+
- **ADRs Analyzed**: ${result.adrComplianceResult.compliantAdrs}/${result.adrComplianceResult.totalAdrs}
|
|
1368
|
+
- **Missing Implementations**: ${result.adrComplianceResult.missingImplementations.length} items
|
|
1369
|
+
|
|
1370
|
+
${result.smartCodeAnalysis || ''}
|
|
1371
|
+
|
|
1263
1372
|
## 🚀 Deployment Approved
|
|
1264
1373
|
${args.triggerSmartGitPush ? 'Triggering smart git push...' : 'Ready to proceed with deployment'}
|
|
1265
1374
|
|
|
@@ -1280,13 +1389,15 @@ function generateBlockedResponse(result, args) {
|
|
|
1280
1389
|
content: [
|
|
1281
1390
|
{
|
|
1282
1391
|
type: 'text',
|
|
1283
|
-
text:
|
|
1392
|
+
text: `# 🚨 DEPLOYMENT BLOCKED - Critical Issues Detected
|
|
1284
1393
|
|
|
1285
|
-
##
|
|
1286
|
-
- **
|
|
1287
|
-
- **Readiness Score**: ${result.overallScore}%
|
|
1394
|
+
## ⚠️ Deployment Readiness: ${result.isDeploymentReady ? '✅ READY' : '❌ BLOCKED'}
|
|
1395
|
+
- **Overall Score**: ${result.overallScore}/100
|
|
1288
1396
|
- **Confidence**: ${result.confidence}%
|
|
1289
1397
|
- **Target Environment**: ${args.targetEnvironment}
|
|
1398
|
+
- **Tree-sitter Analysis**: ${args.enableTreeSitterAnalysis ? '✅ Enhanced' : '❌ Basic'}
|
|
1399
|
+
- **Fast File Discovery**: ✅ Enhanced with fast-glob
|
|
1400
|
+
- **Smart Code Linking**: ${args.requireAdrCompliance ? '✅ ADR Analysis Enabled' : '❌ Disabled'}
|
|
1290
1401
|
|
|
1291
1402
|
## 🧪 Test Validation Issues
|
|
1292
1403
|
${result.testFailureBlockers.length > 0
|
|
@@ -1310,6 +1421,8 @@ ${result.deploymentHistoryAnalysis.failurePatterns.map(p => `- **${p.pattern}**:
|
|
|
1310
1421
|
`
|
|
1311
1422
|
: '✅ Deployment history stable'}
|
|
1312
1423
|
|
|
1424
|
+
${result.smartCodeAnalysis || ''}
|
|
1425
|
+
|
|
1313
1426
|
## 🚨 Critical Blockers (Must Fix Before Deployment)
|
|
1314
1427
|
${result.criticalBlockers
|
|
1315
1428
|
.map(blocker => `
|
|
@@ -1344,15 +1457,164 @@ npm run test:coverage
|
|
|
1344
1457
|
deployment_readiness --operation full_audit --target-environment ${args.targetEnvironment}
|
|
1345
1458
|
\`\`\`
|
|
1346
1459
|
|
|
1347
|
-
|
|
1348
|
-
For critical fixes only:
|
|
1460
|
+
### 3. Emergency Override (If Justified)
|
|
1349
1461
|
\`\`\`bash
|
|
1350
|
-
|
|
1462
|
+
# Only if business critical and approved
|
|
1463
|
+
npm run deploy:emergency -- --justification="Critical security fix"
|
|
1351
1464
|
\`\`\`
|
|
1352
1465
|
|
|
1353
|
-
|
|
1466
|
+
**⚠️ WARNING**: Emergency overrides bypass safety checks. Use only when absolutely necessary.
|
|
1467
|
+
`,
|
|
1354
1468
|
},
|
|
1355
1469
|
],
|
|
1356
1470
|
});
|
|
1357
1471
|
}
|
|
1472
|
+
/**
|
|
1473
|
+
* Create default CodeQualityAnalysis structure
|
|
1474
|
+
*/
|
|
1475
|
+
function createDefaultCodeQualityAnalysis(qualityScore = 75, productionIndicators = 10, mockIndicators = 2) {
|
|
1476
|
+
return {
|
|
1477
|
+
qualityScore,
|
|
1478
|
+
productionIndicators,
|
|
1479
|
+
mockIndicators,
|
|
1480
|
+
failingFiles: [],
|
|
1481
|
+
recommendations: [],
|
|
1482
|
+
securityIssues: [],
|
|
1483
|
+
architecturalViolations: [],
|
|
1484
|
+
codeComplexity: {
|
|
1485
|
+
averageComplexity: 0,
|
|
1486
|
+
highComplexityFiles: [],
|
|
1487
|
+
totalFunctions: 0,
|
|
1488
|
+
},
|
|
1489
|
+
dependencyAnalysis: {
|
|
1490
|
+
dangerousImports: [],
|
|
1491
|
+
frameworksDetected: [],
|
|
1492
|
+
securityLibraries: [],
|
|
1493
|
+
},
|
|
1494
|
+
};
|
|
1495
|
+
}
|
|
1496
|
+
/**
|
|
1497
|
+
* Perform tree-sitter enhanced code quality analysis
|
|
1498
|
+
*/
|
|
1499
|
+
async function analyzeCodeQualityWithTreeSitter(projectPath, enableTreeSitter, _languages) {
|
|
1500
|
+
const baseAnalysis = createDefaultCodeQualityAnalysis();
|
|
1501
|
+
if (!enableTreeSitter) {
|
|
1502
|
+
return baseAnalysis;
|
|
1503
|
+
}
|
|
1504
|
+
try {
|
|
1505
|
+
const analyzer = new TreeSitterAnalyzer();
|
|
1506
|
+
// Use fast-glob based file discovery for enhanced performance
|
|
1507
|
+
const findResult = await findFiles(projectPath, ['**/*.{ts,js,py,yml,yaml,tf,hcl,sh}']);
|
|
1508
|
+
// Analyze files (limit to first 20 for performance)
|
|
1509
|
+
const sourceFiles = findResult.files.map(f => f.path);
|
|
1510
|
+
const filesToAnalyze = sourceFiles.slice(0, 20);
|
|
1511
|
+
let totalComplexity = 0;
|
|
1512
|
+
let totalFunctions = 0;
|
|
1513
|
+
const highComplexityFiles = [];
|
|
1514
|
+
for (const filePath of filesToAnalyze) {
|
|
1515
|
+
try {
|
|
1516
|
+
const analysis = await analyzer.analyzeFile(filePath);
|
|
1517
|
+
// Security issues
|
|
1518
|
+
if (analysis.hasSecrets && analysis.secrets.length > 0) {
|
|
1519
|
+
analysis.secrets.forEach(secret => {
|
|
1520
|
+
baseAnalysis.securityIssues.push({
|
|
1521
|
+
type: secret.type,
|
|
1522
|
+
severity: secret.confidence > 0.8 ? 'high' : secret.confidence > 0.6 ? 'medium' : 'low',
|
|
1523
|
+
message: `${secret.type} detected: ${secret.context}`,
|
|
1524
|
+
file: filePath,
|
|
1525
|
+
line: secret.location.line,
|
|
1526
|
+
});
|
|
1527
|
+
});
|
|
1528
|
+
}
|
|
1529
|
+
// Security issues from general analysis
|
|
1530
|
+
if (analysis.securityIssues && analysis.securityIssues.length > 0) {
|
|
1531
|
+
analysis.securityIssues.forEach(issue => {
|
|
1532
|
+
baseAnalysis.securityIssues.push({
|
|
1533
|
+
type: issue.type,
|
|
1534
|
+
severity: issue.severity,
|
|
1535
|
+
message: issue.message,
|
|
1536
|
+
file: filePath,
|
|
1537
|
+
line: issue.location.line,
|
|
1538
|
+
});
|
|
1539
|
+
});
|
|
1540
|
+
}
|
|
1541
|
+
// Dangerous imports
|
|
1542
|
+
if (analysis.imports) {
|
|
1543
|
+
analysis.imports.forEach(imp => {
|
|
1544
|
+
if (imp.isDangerous) {
|
|
1545
|
+
baseAnalysis.dependencyAnalysis.dangerousImports.push({
|
|
1546
|
+
module: imp.module,
|
|
1547
|
+
file: filePath,
|
|
1548
|
+
reason: imp.reason || 'Potentially dangerous import',
|
|
1549
|
+
});
|
|
1550
|
+
}
|
|
1551
|
+
// Detect frameworks
|
|
1552
|
+
const frameworks = ['express', 'react', 'vue', 'angular', 'fastapi', 'django', 'flask'];
|
|
1553
|
+
frameworks.forEach(framework => {
|
|
1554
|
+
if (imp.module.toLowerCase().includes(framework) &&
|
|
1555
|
+
!baseAnalysis.dependencyAnalysis.frameworksDetected.includes(framework)) {
|
|
1556
|
+
baseAnalysis.dependencyAnalysis.frameworksDetected.push(framework);
|
|
1557
|
+
}
|
|
1558
|
+
});
|
|
1559
|
+
// Detect security libraries
|
|
1560
|
+
const securityLibs = ['bcrypt', 'crypto', 'jwt', 'passport', 'helmet'];
|
|
1561
|
+
securityLibs.forEach(lib => {
|
|
1562
|
+
if (imp.module.toLowerCase().includes(lib) &&
|
|
1563
|
+
!baseAnalysis.dependencyAnalysis.securityLibraries.includes(lib)) {
|
|
1564
|
+
baseAnalysis.dependencyAnalysis.securityLibraries.push(lib);
|
|
1565
|
+
}
|
|
1566
|
+
});
|
|
1567
|
+
});
|
|
1568
|
+
}
|
|
1569
|
+
// Function complexity analysis
|
|
1570
|
+
if (analysis.functions) {
|
|
1571
|
+
analysis.functions.forEach(func => {
|
|
1572
|
+
totalFunctions++;
|
|
1573
|
+
totalComplexity += func.complexity;
|
|
1574
|
+
if (func.complexity > 10) {
|
|
1575
|
+
highComplexityFiles.push(`${filePath}:${func.name} (complexity: ${func.complexity})`);
|
|
1576
|
+
}
|
|
1577
|
+
});
|
|
1578
|
+
}
|
|
1579
|
+
// Architectural violations (basic detection)
|
|
1580
|
+
if (analysis.architecturalViolations && analysis.architecturalViolations.length > 0) {
|
|
1581
|
+
analysis.architecturalViolations.forEach(violation => {
|
|
1582
|
+
baseAnalysis.architecturalViolations.push(`${filePath}: ${violation.message}`);
|
|
1583
|
+
});
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
catch (error) {
|
|
1587
|
+
// Skip files that can't be analyzed
|
|
1588
|
+
console.warn(`Could not analyze file ${filePath}:`, error);
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
// Update complexity metrics
|
|
1592
|
+
baseAnalysis.codeComplexity = {
|
|
1593
|
+
averageComplexity: totalFunctions > 0 ? totalComplexity / totalFunctions : 0,
|
|
1594
|
+
highComplexityFiles: highComplexityFiles.slice(0, 10), // Limit to top 10
|
|
1595
|
+
totalFunctions,
|
|
1596
|
+
};
|
|
1597
|
+
// Calculate enhanced quality score
|
|
1598
|
+
let qualityScore = 85; // Base score
|
|
1599
|
+
// Deduct for security issues
|
|
1600
|
+
const criticalSecurity = baseAnalysis.securityIssues.filter(i => i.severity === 'critical').length;
|
|
1601
|
+
const highSecurity = baseAnalysis.securityIssues.filter(i => i.severity === 'high').length;
|
|
1602
|
+
qualityScore -= criticalSecurity * 20 + highSecurity * 10;
|
|
1603
|
+
// Deduct for dangerous imports
|
|
1604
|
+
qualityScore -= Math.min(baseAnalysis.dependencyAnalysis.dangerousImports.length * 5, 20);
|
|
1605
|
+
// Deduct for high complexity
|
|
1606
|
+
qualityScore -= Math.min(highComplexityFiles.length * 2, 15);
|
|
1607
|
+
// Bonus for security libraries
|
|
1608
|
+
qualityScore += Math.min(baseAnalysis.dependencyAnalysis.securityLibraries.length * 2, 10);
|
|
1609
|
+
baseAnalysis.qualityScore = Math.max(0, Math.min(100, qualityScore));
|
|
1610
|
+
// Update production/mock indicators based on analysis
|
|
1611
|
+
baseAnalysis.productionIndicators = Math.max(10, baseAnalysis.qualityScore - 20);
|
|
1612
|
+
baseAnalysis.mockIndicators = Math.max(0, 100 - baseAnalysis.qualityScore) / 10;
|
|
1613
|
+
return baseAnalysis;
|
|
1614
|
+
}
|
|
1615
|
+
catch (error) {
|
|
1616
|
+
console.warn('Tree-sitter analysis failed, using basic analysis:', error);
|
|
1617
|
+
return baseAnalysis;
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1358
1620
|
//# sourceMappingURL=deployment-readiness-tool.js.map
|