fivocell 4.9.0 → 5.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/dist/__tests__/code-health.test.d.ts +2 -0
- package/dist/__tests__/code-health.test.d.ts.map +1 -0
- package/dist/__tests__/code-health.test.js +90 -0
- package/dist/__tests__/code-health.test.js.map +1 -0
- package/dist/__tests__/context-compression.test.d.ts +2 -0
- package/dist/__tests__/context-compression.test.d.ts.map +1 -0
- package/dist/__tests__/context-compression.test.js +77 -0
- package/dist/__tests__/context-compression.test.js.map +1 -0
- package/dist/__tests__/developer-velocity.test.d.ts +2 -0
- package/dist/__tests__/developer-velocity.test.d.ts.map +1 -0
- package/dist/__tests__/developer-velocity.test.js +66 -0
- package/dist/__tests__/developer-velocity.test.js.map +1 -0
- package/dist/__tests__/error-trends.test.d.ts +2 -0
- package/dist/__tests__/error-trends.test.d.ts.map +1 -0
- package/dist/__tests__/error-trends.test.js +61 -0
- package/dist/__tests__/error-trends.test.js.map +1 -0
- package/dist/__tests__/memory-automation.test.d.ts +2 -0
- package/dist/__tests__/memory-automation.test.d.ts.map +1 -0
- package/dist/__tests__/memory-automation.test.js +136 -0
- package/dist/__tests__/memory-automation.test.js.map +1 -0
- package/dist/__tests__/memory-growth.test.d.ts +2 -0
- package/dist/__tests__/memory-growth.test.d.ts.map +1 -0
- package/dist/__tests__/memory-growth.test.js +61 -0
- package/dist/__tests__/memory-growth.test.js.map +1 -0
- package/dist/__tests__/memory-health.test.d.ts +2 -0
- package/dist/__tests__/memory-health.test.d.ts.map +1 -0
- package/dist/__tests__/memory-health.test.js +66 -0
- package/dist/__tests__/memory-health.test.js.map +1 -0
- package/dist/__tests__/smart-recommendations.test.d.ts +2 -0
- package/dist/__tests__/smart-recommendations.test.d.ts.map +1 -0
- package/dist/__tests__/smart-recommendations.test.js +74 -0
- package/dist/__tests__/smart-recommendations.test.js.map +1 -0
- package/dist/walls/06-memory/automation/memory-automation.d.ts +49 -0
- package/dist/walls/06-memory/automation/memory-automation.d.ts.map +1 -0
- package/dist/walls/06-memory/automation/memory-automation.js +396 -0
- package/dist/walls/06-memory/automation/memory-automation.js.map +1 -0
- package/dist/walls/06-memory/stores/code-health.d.ts +40 -0
- package/dist/walls/06-memory/stores/code-health.d.ts.map +1 -0
- package/dist/walls/06-memory/stores/code-health.js +344 -0
- package/dist/walls/06-memory/stores/code-health.js.map +1 -0
- package/dist/walls/06-memory/stores/context-compression.d.ts +33 -0
- package/dist/walls/06-memory/stores/context-compression.d.ts.map +1 -0
- package/dist/walls/06-memory/stores/context-compression.js +265 -0
- package/dist/walls/06-memory/stores/context-compression.js.map +1 -0
- package/dist/walls/06-memory/stores/developer-velocity.d.ts +53 -0
- package/dist/walls/06-memory/stores/developer-velocity.d.ts.map +1 -0
- package/dist/walls/06-memory/stores/developer-velocity.js +225 -0
- package/dist/walls/06-memory/stores/developer-velocity.js.map +1 -0
- package/dist/walls/06-memory/stores/error-trends.d.ts +53 -0
- package/dist/walls/06-memory/stores/error-trends.d.ts.map +1 -0
- package/dist/walls/06-memory/stores/error-trends.js +232 -0
- package/dist/walls/06-memory/stores/error-trends.js.map +1 -0
- package/dist/walls/06-memory/stores/memory-growth.d.ts +34 -0
- package/dist/walls/06-memory/stores/memory-growth.d.ts.map +1 -0
- package/dist/walls/06-memory/stores/memory-growth.js +150 -0
- package/dist/walls/06-memory/stores/memory-growth.js.map +1 -0
- package/dist/walls/06-memory/stores/memory-health.d.ts +32 -0
- package/dist/walls/06-memory/stores/memory-health.d.ts.map +1 -0
- package/dist/walls/06-memory/stores/memory-health.js +221 -0
- package/dist/walls/06-memory/stores/memory-health.js.map +1 -0
- package/dist/walls/06-memory/stores/smart-recommendations.d.ts +30 -0
- package/dist/walls/06-memory/stores/smart-recommendations.d.ts.map +1 -0
- package/dist/walls/06-memory/stores/smart-recommendations.js +222 -0
- package/dist/walls/06-memory/stores/smart-recommendations.js.map +1 -0
- package/dist/walls/06-memory/stores/weekly-report.js +1 -1
- package/dist/walls/07-runtime/cli/cli.js +159 -0
- package/dist/walls/07-runtime/cli/cli.js.map +1 -1
- package/dist/walls/07-runtime/daemon/server.d.ts.map +1 -1
- package/dist/walls/07-runtime/daemon/server.js +61 -0
- package/dist/walls/07-runtime/daemon/server.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface CodeHealthScore {
|
|
2
|
+
project: string;
|
|
3
|
+
overallScore: number;
|
|
4
|
+
grade: 'A+' | 'A' | 'B+' | 'B' | 'C+' | 'C' | 'D' | 'F';
|
|
5
|
+
dimensions: {
|
|
6
|
+
complexity: number;
|
|
7
|
+
duplication: number;
|
|
8
|
+
testCoverage: number;
|
|
9
|
+
documentation: number;
|
|
10
|
+
errorHandling: number;
|
|
11
|
+
modularity: number;
|
|
12
|
+
};
|
|
13
|
+
files: FileHealth[];
|
|
14
|
+
suggestions: string[];
|
|
15
|
+
metrics: CodeMetrics;
|
|
16
|
+
computedAt: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CodeMetrics {
|
|
19
|
+
totalFiles: number;
|
|
20
|
+
totalLines: number;
|
|
21
|
+
avgFileSize: number;
|
|
22
|
+
largestFile: string;
|
|
23
|
+
largestFileSize: number;
|
|
24
|
+
testFiles: number;
|
|
25
|
+
testRatio: number;
|
|
26
|
+
docFiles: number;
|
|
27
|
+
configFiles: number;
|
|
28
|
+
avgComplexity: number;
|
|
29
|
+
highComplexityFiles: number;
|
|
30
|
+
}
|
|
31
|
+
export interface FileHealth {
|
|
32
|
+
path: string;
|
|
33
|
+
lines: number;
|
|
34
|
+
complexity: number;
|
|
35
|
+
health: 'good' | 'warning' | 'critical';
|
|
36
|
+
issues: string[];
|
|
37
|
+
}
|
|
38
|
+
export declare function computeCodeHealth(projectDir: string, project: string): CodeHealthScore;
|
|
39
|
+
export declare function formatCodeHealth(health: CodeHealthScore): string;
|
|
40
|
+
//# sourceMappingURL=code-health.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-health.d.ts","sourceRoot":"","sources":["../../../../src/walls/06-memory/stores/code-health.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IACxD,UAAU,EAAE;QACV,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC;QACtB,aAAa,EAAE,MAAM,CAAC;QACtB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,WAAW,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;IACxC,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,eAAe,CA+EtF;AAwLD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CA+BhE"}
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.computeCodeHealth = computeCodeHealth;
|
|
37
|
+
exports.formatCodeHealth = formatCodeHealth;
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
function computeCodeHealth(projectDir, project) {
|
|
41
|
+
const suggestions = [];
|
|
42
|
+
// Scan files
|
|
43
|
+
const files = scanCodeFiles(projectDir);
|
|
44
|
+
const metrics = computeMetrics(files, projectDir);
|
|
45
|
+
// Complexity analysis (simplified: line count as proxy)
|
|
46
|
+
const complexity = computeComplexityScore(files);
|
|
47
|
+
// Duplication detection (simplified: similar file sizes)
|
|
48
|
+
const duplication = computeDuplicationScore(files);
|
|
49
|
+
// Test coverage (test file ratio)
|
|
50
|
+
const testCoverage = computeTestCoverage(files);
|
|
51
|
+
// Documentation (README, docs)
|
|
52
|
+
const documentation = computeDocumentationScore(projectDir);
|
|
53
|
+
// Error handling (try/catch usage)
|
|
54
|
+
const errorHandling = computeErrorHandlingScore(files);
|
|
55
|
+
// Modularity (avg file size, number of modules)
|
|
56
|
+
const modularity = computeModularityScore(files);
|
|
57
|
+
// Generate suggestions
|
|
58
|
+
if (metrics.testRatio < 0.2) {
|
|
59
|
+
suggestions.push('Add more test files — current test ratio is low');
|
|
60
|
+
}
|
|
61
|
+
if (metrics.highComplexityFiles > 3) {
|
|
62
|
+
suggestions.push('Refactor high-complexity files');
|
|
63
|
+
}
|
|
64
|
+
if (metrics.avgFileSize > 500) {
|
|
65
|
+
suggestions.push('Consider splitting large files');
|
|
66
|
+
}
|
|
67
|
+
if (documentation < 50) {
|
|
68
|
+
suggestions.push('Add README and documentation');
|
|
69
|
+
}
|
|
70
|
+
if (duplication < 60) {
|
|
71
|
+
suggestions.push('Reduce code duplication');
|
|
72
|
+
}
|
|
73
|
+
if (errorHandling < 50) {
|
|
74
|
+
suggestions.push('Improve error handling with try/catch');
|
|
75
|
+
}
|
|
76
|
+
// Overall score
|
|
77
|
+
const overallScore = Math.round(complexity * 0.2 +
|
|
78
|
+
duplication * 0.15 +
|
|
79
|
+
testCoverage * 0.25 +
|
|
80
|
+
documentation * 0.1 +
|
|
81
|
+
errorHandling * 0.15 +
|
|
82
|
+
modularity * 0.15);
|
|
83
|
+
const grade = scoreToGrade(overallScore);
|
|
84
|
+
// Top files by complexity
|
|
85
|
+
const topFiles = files
|
|
86
|
+
.sort((a, b) => b.lines - a.lines)
|
|
87
|
+
.slice(0, 20)
|
|
88
|
+
.map(f => ({
|
|
89
|
+
path: path.relative(projectDir, f.path),
|
|
90
|
+
lines: f.lines,
|
|
91
|
+
complexity: f.complexity,
|
|
92
|
+
health: f.lines > 500 ? 'critical' : f.lines > 200 ? 'warning' : 'good',
|
|
93
|
+
issues: f.lines > 500 ? ['File too large'] : [],
|
|
94
|
+
}));
|
|
95
|
+
return {
|
|
96
|
+
project,
|
|
97
|
+
overallScore,
|
|
98
|
+
grade,
|
|
99
|
+
dimensions: { complexity, duplication, testCoverage, documentation, errorHandling, modularity },
|
|
100
|
+
files: topFiles,
|
|
101
|
+
suggestions,
|
|
102
|
+
metrics,
|
|
103
|
+
computedAt: new Date().toISOString(),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function scanCodeFiles(dir) {
|
|
107
|
+
const files = [];
|
|
108
|
+
const extensions = new Set(['.ts', '.tsx', '.js', '.jsx', '.py', '.go', '.rs', '.java']);
|
|
109
|
+
const ignoreDirs = new Set(['node_modules', '.git', 'dist', 'build', '.cell', '__tests__', '__mocks__']);
|
|
110
|
+
function walk(currentDir) {
|
|
111
|
+
try {
|
|
112
|
+
const entries = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
113
|
+
for (const entry of entries) {
|
|
114
|
+
if (ignoreDirs.has(entry.name))
|
|
115
|
+
continue;
|
|
116
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
117
|
+
if (entry.isDirectory()) {
|
|
118
|
+
walk(fullPath);
|
|
119
|
+
}
|
|
120
|
+
else if (extensions.has(path.extname(entry.name).toLowerCase())) {
|
|
121
|
+
try {
|
|
122
|
+
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
123
|
+
const lines = content.split('\n').length;
|
|
124
|
+
const complexity = estimateComplexity(content);
|
|
125
|
+
const isTest = entry.name.includes('.test.') || entry.name.includes('.spec.') || fullPath.includes('__tests__');
|
|
126
|
+
const isDoc = entry.name.endsWith('.md') || entry.name.endsWith('.txt');
|
|
127
|
+
const isConfig = entry.name.endsWith('.json') || entry.name.endsWith('.yaml') || entry.name.endsWith('.yml');
|
|
128
|
+
files.push({ path: fullPath, lines, complexity, isTest, isDoc, isConfig });
|
|
129
|
+
}
|
|
130
|
+
catch { }
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch { }
|
|
135
|
+
}
|
|
136
|
+
walk(dir);
|
|
137
|
+
return files;
|
|
138
|
+
}
|
|
139
|
+
function estimateComplexity(content) {
|
|
140
|
+
// Simple complexity heuristic: count control flow statements
|
|
141
|
+
let complexity = 1;
|
|
142
|
+
const lines = content.split('\n');
|
|
143
|
+
for (const line of lines) {
|
|
144
|
+
const trimmed = line.trim();
|
|
145
|
+
if (trimmed.startsWith('//') || trimmed.startsWith('*'))
|
|
146
|
+
continue;
|
|
147
|
+
if (/\b(if|else if|else)\b/.test(trimmed))
|
|
148
|
+
complexity++;
|
|
149
|
+
if (/\b(for|while|do)\b/.test(trimmed))
|
|
150
|
+
complexity++;
|
|
151
|
+
if (/\b(switch|case)\b/.test(trimmed))
|
|
152
|
+
complexity++;
|
|
153
|
+
if (/\b(try|catch|finally)\b/.test(trimmed))
|
|
154
|
+
complexity++;
|
|
155
|
+
if (/\b(function|class|=>)\b/.test(trimmed))
|
|
156
|
+
complexity++;
|
|
157
|
+
}
|
|
158
|
+
return complexity;
|
|
159
|
+
}
|
|
160
|
+
function computeMetrics(files, projectDir) {
|
|
161
|
+
const codeFiles = files.filter(f => !f.isDoc && !f.isConfig);
|
|
162
|
+
const testFiles = files.filter(f => f.isTest);
|
|
163
|
+
const docFiles = files.filter(f => f.isDoc);
|
|
164
|
+
const configFiles = files.filter(f => f.isConfig);
|
|
165
|
+
const totalLines = codeFiles.reduce((s, f) => s + f.lines, 0);
|
|
166
|
+
const avgFileSize = codeFiles.length > 0 ? Math.round(totalLines / codeFiles.length) : 0;
|
|
167
|
+
const largest = codeFiles.reduce((max, f) => f.lines > max.lines ? f : max, { path: '', lines: 0 });
|
|
168
|
+
const testRatio = codeFiles.length > 0 ? Math.round(testFiles.length / codeFiles.length * 100) : 0;
|
|
169
|
+
const highComplexityFiles = codeFiles.filter(f => f.complexity > 50).length;
|
|
170
|
+
const avgComplexity = codeFiles.length > 0
|
|
171
|
+
? Math.round(codeFiles.reduce((s, f) => s + f.complexity, 0) / codeFiles.length)
|
|
172
|
+
: 0;
|
|
173
|
+
return {
|
|
174
|
+
totalFiles: codeFiles.length,
|
|
175
|
+
totalLines,
|
|
176
|
+
avgFileSize,
|
|
177
|
+
largestFile: path.relative(projectDir, largest.path),
|
|
178
|
+
largestFileSize: largest.lines,
|
|
179
|
+
testFiles: testFiles.length,
|
|
180
|
+
testRatio,
|
|
181
|
+
docFiles: docFiles.length,
|
|
182
|
+
configFiles: configFiles.length,
|
|
183
|
+
avgComplexity,
|
|
184
|
+
highComplexityFiles,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function computeComplexityScore(files) {
|
|
188
|
+
const codeFiles = files.filter(f => !f.isDoc && !f.isConfig);
|
|
189
|
+
if (codeFiles.length === 0)
|
|
190
|
+
return 50;
|
|
191
|
+
const avgComplexity = codeFiles.reduce((s, f) => s + f.complexity, 0) / codeFiles.length;
|
|
192
|
+
// Lower complexity = higher score
|
|
193
|
+
if (avgComplexity < 10)
|
|
194
|
+
return 95;
|
|
195
|
+
if (avgComplexity < 20)
|
|
196
|
+
return 85;
|
|
197
|
+
if (avgComplexity < 30)
|
|
198
|
+
return 75;
|
|
199
|
+
if (avgComplexity < 50)
|
|
200
|
+
return 60;
|
|
201
|
+
if (avgComplexity < 80)
|
|
202
|
+
return 45;
|
|
203
|
+
return 30;
|
|
204
|
+
}
|
|
205
|
+
function computeDuplicationScore(files) {
|
|
206
|
+
// Simple: check if many files have same line count (proxy for copy-paste)
|
|
207
|
+
const codeFiles = files.filter(f => !f.isDoc && !f.isConfig && f.lines > 10);
|
|
208
|
+
if (codeFiles.length === 0)
|
|
209
|
+
return 80;
|
|
210
|
+
const lineCounts = codeFiles.map(f => f.lines);
|
|
211
|
+
const unique = new Set(lineCounts);
|
|
212
|
+
const ratio = unique.size / lineCounts.length;
|
|
213
|
+
return Math.round(ratio * 100);
|
|
214
|
+
}
|
|
215
|
+
function computeTestCoverage(files) {
|
|
216
|
+
const codeFiles = files.filter(f => !f.isDoc && !f.isConfig);
|
|
217
|
+
const testFiles = files.filter(f => f.isTest);
|
|
218
|
+
if (codeFiles.length === 0)
|
|
219
|
+
return 50;
|
|
220
|
+
const ratio = testFiles.length / codeFiles.length;
|
|
221
|
+
if (ratio > 0.5)
|
|
222
|
+
return 95;
|
|
223
|
+
if (ratio > 0.3)
|
|
224
|
+
return 85;
|
|
225
|
+
if (ratio > 0.2)
|
|
226
|
+
return 70;
|
|
227
|
+
if (ratio > 0.1)
|
|
228
|
+
return 55;
|
|
229
|
+
if (ratio > 0.05)
|
|
230
|
+
return 40;
|
|
231
|
+
return 25;
|
|
232
|
+
}
|
|
233
|
+
function computeDocumentationScore(projectDir) {
|
|
234
|
+
let score = 0;
|
|
235
|
+
const readme = path.join(projectDir, 'README.md');
|
|
236
|
+
if (fs.existsSync(readme))
|
|
237
|
+
score += 40;
|
|
238
|
+
const docsDir = path.join(projectDir, 'docs');
|
|
239
|
+
if (fs.existsSync(docsDir))
|
|
240
|
+
score += 30;
|
|
241
|
+
const changelog = path.join(projectDir, 'CHANGELOG.md');
|
|
242
|
+
if (fs.existsSync(changelog))
|
|
243
|
+
score += 15;
|
|
244
|
+
const license = path.join(projectDir, 'LICENSE');
|
|
245
|
+
if (fs.existsSync(license))
|
|
246
|
+
score += 15;
|
|
247
|
+
return Math.min(100, score);
|
|
248
|
+
}
|
|
249
|
+
function computeErrorHandlingScore(files) {
|
|
250
|
+
let totalFiles = 0;
|
|
251
|
+
let filesWithTry = 0;
|
|
252
|
+
for (const f of files) {
|
|
253
|
+
if (f.isTest || f.isDoc || f.isConfig)
|
|
254
|
+
continue;
|
|
255
|
+
totalFiles++;
|
|
256
|
+
try {
|
|
257
|
+
const content = fs.readFileSync(f.path, 'utf-8');
|
|
258
|
+
if (/\b(try|catch)\b/.test(content))
|
|
259
|
+
filesWithTry++;
|
|
260
|
+
}
|
|
261
|
+
catch { }
|
|
262
|
+
}
|
|
263
|
+
if (totalFiles === 0)
|
|
264
|
+
return 50;
|
|
265
|
+
const ratio = filesWithTry / totalFiles;
|
|
266
|
+
if (ratio > 0.5)
|
|
267
|
+
return 90;
|
|
268
|
+
if (ratio > 0.3)
|
|
269
|
+
return 75;
|
|
270
|
+
if (ratio > 0.15)
|
|
271
|
+
return 60;
|
|
272
|
+
if (ratio > 0.05)
|
|
273
|
+
return 45;
|
|
274
|
+
return 30;
|
|
275
|
+
}
|
|
276
|
+
function computeModularityScore(files) {
|
|
277
|
+
const codeFiles = files.filter(f => !f.isDoc && !f.isConfig);
|
|
278
|
+
if (codeFiles.length === 0)
|
|
279
|
+
return 50;
|
|
280
|
+
const avgSize = codeFiles.reduce((s, f) => s + f.lines, 0) / codeFiles.length;
|
|
281
|
+
// Smaller avg size = better modularity
|
|
282
|
+
if (avgSize < 100)
|
|
283
|
+
return 95;
|
|
284
|
+
if (avgSize < 200)
|
|
285
|
+
return 85;
|
|
286
|
+
if (avgSize < 300)
|
|
287
|
+
return 75;
|
|
288
|
+
if (avgSize < 500)
|
|
289
|
+
return 60;
|
|
290
|
+
if (avgSize < 800)
|
|
291
|
+
return 45;
|
|
292
|
+
return 30;
|
|
293
|
+
}
|
|
294
|
+
function scoreToGrade(score) {
|
|
295
|
+
if (score >= 95)
|
|
296
|
+
return 'A+';
|
|
297
|
+
if (score >= 90)
|
|
298
|
+
return 'A';
|
|
299
|
+
if (score >= 85)
|
|
300
|
+
return 'B+';
|
|
301
|
+
if (score >= 75)
|
|
302
|
+
return 'B';
|
|
303
|
+
if (score >= 70)
|
|
304
|
+
return 'C+';
|
|
305
|
+
if (score >= 60)
|
|
306
|
+
return 'C';
|
|
307
|
+
if (score >= 40)
|
|
308
|
+
return 'D';
|
|
309
|
+
return 'F';
|
|
310
|
+
}
|
|
311
|
+
function formatCodeHealth(health) {
|
|
312
|
+
const lines = [];
|
|
313
|
+
lines.push(`## Code Health — ${health.project}`);
|
|
314
|
+
lines.push(`**Score: ${health.overallScore}/100 (${health.grade})**\n`);
|
|
315
|
+
lines.push(`### Dimensions`);
|
|
316
|
+
lines.push(`| Dimension | Score |`);
|
|
317
|
+
lines.push(`|-----------|-------|`);
|
|
318
|
+
lines.push(`| Complexity | ${health.dimensions.complexity} |`);
|
|
319
|
+
lines.push(`| Duplication | ${health.dimensions.duplication} |`);
|
|
320
|
+
lines.push(`| Test Coverage | ${health.dimensions.testCoverage} |`);
|
|
321
|
+
lines.push(`| Documentation | ${health.dimensions.documentation} |`);
|
|
322
|
+
lines.push(`| Error Handling | ${health.dimensions.errorHandling} |`);
|
|
323
|
+
lines.push(`| Modularity | ${health.dimensions.modularity} |`);
|
|
324
|
+
lines.push('');
|
|
325
|
+
lines.push(`### Metrics`);
|
|
326
|
+
lines.push(`| Metric | Value |`);
|
|
327
|
+
lines.push(`|--------|-------|`);
|
|
328
|
+
lines.push(`| Total files | ${health.metrics.totalFiles} |`);
|
|
329
|
+
lines.push(`| Total lines | ${health.metrics.totalLines} |`);
|
|
330
|
+
lines.push(`| Avg file size | ${health.metrics.avgFileSize} lines |`);
|
|
331
|
+
lines.push(`| Largest file | ${health.metrics.largestFile} (${health.metrics.largestFileSize} lines) |`);
|
|
332
|
+
lines.push(`| Test files | ${health.metrics.testFiles} (${health.metrics.testRatio}% ratio) |`);
|
|
333
|
+
lines.push(`| Doc files | ${health.metrics.docFiles} |`);
|
|
334
|
+
lines.push(`| Avg complexity | ${health.metrics.avgComplexity} |`);
|
|
335
|
+
lines.push(`| High complexity | ${health.metrics.highComplexityFiles} files |`);
|
|
336
|
+
if (health.suggestions.length > 0) {
|
|
337
|
+
lines.push('');
|
|
338
|
+
lines.push(`### Suggestions`);
|
|
339
|
+
for (const s of health.suggestions)
|
|
340
|
+
lines.push(`- ${s}`);
|
|
341
|
+
}
|
|
342
|
+
return lines.join('\n');
|
|
343
|
+
}
|
|
344
|
+
//# sourceMappingURL=code-health.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-health.js","sourceRoot":"","sources":["../../../../src/walls/06-memory/stores/code-health.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,8CA+EC;AAwLD,4CA+BC;AAlVD,uCAAyB;AACzB,2CAA6B;AA2C7B,SAAgB,iBAAiB,CAAC,UAAkB,EAAE,OAAe;IACnE,MAAM,WAAW,GAAa,EAAE,CAAC;IAEjC,aAAa;IACb,MAAM,KAAK,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAElD,wDAAwD;IACxD,MAAM,UAAU,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAEjD,yDAAyD;IACzD,MAAM,WAAW,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;IAEnD,kCAAkC;IAClC,MAAM,YAAY,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAEhD,+BAA+B;IAC/B,MAAM,aAAa,GAAG,yBAAyB,CAAC,UAAU,CAAC,CAAC;IAE5D,mCAAmC;IACnC,MAAM,aAAa,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IAEvD,gDAAg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B,UAAU,CAAC,CAAC;IAChF,IAAI,MAAM,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC9B,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,WAAW;YAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface CompressedContext {
|
|
2
|
+
project: string;
|
|
3
|
+
mode: 'compact' | 'full' | 'topic';
|
|
4
|
+
tokenEstimate: number;
|
|
5
|
+
sections: ContextSection[];
|
|
6
|
+
compressedAt: string;
|
|
7
|
+
summary: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ContextSection {
|
|
10
|
+
type: 'overview' | 'recent' | 'decisions' | 'errors' | 'fixes' | 'patterns' | 'handoff' | 'recommendations' | 'files' | 'topics';
|
|
11
|
+
title: string;
|
|
12
|
+
content: string;
|
|
13
|
+
wordCount: number;
|
|
14
|
+
importance: number;
|
|
15
|
+
compressed: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface CompressionOptions {
|
|
18
|
+
project: string;
|
|
19
|
+
mode?: 'compact' | 'full' | 'topic';
|
|
20
|
+
topic?: string;
|
|
21
|
+
maxWords?: number;
|
|
22
|
+
maxSections?: number;
|
|
23
|
+
includeHandoff?: boolean;
|
|
24
|
+
includeRecommendations?: boolean;
|
|
25
|
+
includeFiles?: boolean;
|
|
26
|
+
days?: number;
|
|
27
|
+
}
|
|
28
|
+
export declare function compressContext(options: CompressionOptions): CompressedContext;
|
|
29
|
+
export declare function compressToMinimal(project: string): CompressedContext;
|
|
30
|
+
export declare function compressForAITool(project: string, tool: string): CompressedContext;
|
|
31
|
+
export declare function formatCompressedContext(ctx: CompressedContext): string;
|
|
32
|
+
export declare function estimateTokens(text: string): number;
|
|
33
|
+
//# sourceMappingURL=context-compression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-compression.d.ts","sourceRoot":"","sources":["../../../../src/walls/06-memory/stores/context-compression.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,iBAAiB,GAAG,OAAO,GAAG,QAAQ,CAAC;IACjI,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,kBAAkB,GAAG,iBAAiB,CA8N9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