@theihtisham/agent-shadow-brain 5.0.0 → 5.1.1
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 +575 -292
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +1 -0
- package/dist/adapters/index.js.map +1 -1
- package/dist/brain/auto-setup.d.ts +54 -0
- package/dist/brain/auto-setup.d.ts.map +1 -0
- package/dist/brain/auto-setup.js +660 -0
- package/dist/brain/auto-setup.js.map +1 -0
- package/dist/brain/brain-portability.d.ts +81 -0
- package/dist/brain/brain-portability.d.ts.map +1 -0
- package/dist/brain/brain-portability.js +329 -0
- package/dist/brain/brain-portability.js.map +1 -0
- package/dist/brain/code-dna.d.ts +70 -0
- package/dist/brain/code-dna.d.ts.map +1 -0
- package/dist/brain/code-dna.js +611 -0
- package/dist/brain/code-dna.js.map +1 -0
- package/dist/brain/fine-tuning-engine.d.ts +99 -0
- package/dist/brain/fine-tuning-engine.d.ts.map +1 -0
- package/dist/brain/fine-tuning-engine.js +681 -0
- package/dist/brain/fine-tuning-engine.js.map +1 -0
- package/dist/brain/intent-engine.d.ts +64 -0
- package/dist/brain/intent-engine.d.ts.map +1 -0
- package/dist/brain/intent-engine.js +374 -0
- package/dist/brain/intent-engine.js.map +1 -0
- package/dist/brain/lsp-server.d.ts +62 -0
- package/dist/brain/lsp-server.d.ts.map +1 -0
- package/dist/brain/lsp-server.js +480 -0
- package/dist/brain/lsp-server.js.map +1 -0
- package/dist/brain/mcp-server.d.ts +12 -0
- package/dist/brain/mcp-server.d.ts.map +1 -1
- package/dist/brain/mcp-server.js +396 -37
- package/dist/brain/mcp-server.js.map +1 -1
- package/dist/brain/orchestrator.d.ts +13 -0
- package/dist/brain/orchestrator.d.ts.map +1 -1
- package/dist/brain/orchestrator.js +25 -1
- package/dist/brain/orchestrator.js.map +1 -1
- package/dist/brain/plugin-system.d.ts +97 -0
- package/dist/brain/plugin-system.d.ts.map +1 -0
- package/dist/brain/plugin-system.js +404 -0
- package/dist/brain/plugin-system.js.map +1 -0
- package/dist/brain/smart-cache.d.ts +100 -0
- package/dist/brain/smart-cache.d.ts.map +1 -0
- package/dist/brain/smart-cache.js +417 -0
- package/dist/brain/smart-cache.js.map +1 -0
- package/dist/brain/temporal-intelligence.d.ts +89 -0
- package/dist/brain/temporal-intelligence.d.ts.map +1 -0
- package/dist/brain/temporal-intelligence.js +378 -0
- package/dist/brain/temporal-intelligence.js.map +1 -0
- package/dist/cli.js +444 -3
- package/dist/cli.js.map +1 -1
- package/dist/dashboard/server.d.ts +4 -0
- package/dist/dashboard/server.d.ts.map +1 -1
- package/dist/dashboard/server.js +453 -330
- package/dist/dashboard/server.js.map +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +284 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +28 -4
|
@@ -0,0 +1,611 @@
|
|
|
1
|
+
// src/brain/code-dna.ts — Code DNA fingerprinting for style analysis
|
|
2
|
+
// v6.0.0 — Codebase style genome extraction
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import * as crypto from 'crypto';
|
|
6
|
+
const GENE_EXTRACTORS = [
|
|
7
|
+
// Formatting genes
|
|
8
|
+
{
|
|
9
|
+
name: 'indent-spaces',
|
|
10
|
+
category: 'formatting',
|
|
11
|
+
extract: (_content, lines) => {
|
|
12
|
+
const indented = lines.filter(l => /^\s+/.test(l));
|
|
13
|
+
if (indented.length === 0)
|
|
14
|
+
return 0.5;
|
|
15
|
+
const spaces = indented.filter(l => /^ /.test(l)).length;
|
|
16
|
+
return spaces / indented.length;
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'indent-size',
|
|
21
|
+
category: 'formatting',
|
|
22
|
+
extract: (_content, lines) => {
|
|
23
|
+
const indentSizes = [];
|
|
24
|
+
for (const line of lines) {
|
|
25
|
+
const match = line.match(/^( +)/);
|
|
26
|
+
if (match && match[1].length <= 8)
|
|
27
|
+
indentSizes.push(match[1].length);
|
|
28
|
+
}
|
|
29
|
+
if (indentSizes.length === 0)
|
|
30
|
+
return 0.5;
|
|
31
|
+
const avg = indentSizes.reduce((s, v) => s + v, 0) / indentSizes.length;
|
|
32
|
+
return Math.min(1, avg / 8); // Normalize: 2 spaces=0.25, 4=0.5, 8=1.0
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'semicolons',
|
|
37
|
+
category: 'formatting',
|
|
38
|
+
extract: (content) => {
|
|
39
|
+
const statements = (content.match(/[^;{}\n]\s*$/gm) || []).length;
|
|
40
|
+
const withSemicolons = (content.match(/;\s*$/gm) || []).length;
|
|
41
|
+
const total = statements + withSemicolons;
|
|
42
|
+
return total > 0 ? withSemicolons / total : 0.5;
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'single-quotes',
|
|
47
|
+
category: 'formatting',
|
|
48
|
+
extract: (content) => {
|
|
49
|
+
const singles = (content.match(/'/g) || []).length;
|
|
50
|
+
const doubles = (content.match(/(?<!=)"(?!=)/g) || []).length;
|
|
51
|
+
const total = singles + doubles;
|
|
52
|
+
return total > 0 ? singles / total : 0.5;
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'trailing-comma',
|
|
57
|
+
category: 'formatting',
|
|
58
|
+
extract: (content) => {
|
|
59
|
+
const commaBeforeClose = (content.match(/,\s*[\]})\n]/g) || []).length;
|
|
60
|
+
const noCommaBeforeClose = (content.match(/[^,\s]\s*[\]})\n]/g) || []).length;
|
|
61
|
+
const total = commaBeforeClose + noCommaBeforeClose;
|
|
62
|
+
return total > 0 ? commaBeforeClose / total : 0.5;
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'avg-line-length',
|
|
67
|
+
category: 'formatting',
|
|
68
|
+
extract: (_content, lines) => {
|
|
69
|
+
const nonEmpty = lines.filter(l => l.trim().length > 0);
|
|
70
|
+
if (nonEmpty.length === 0)
|
|
71
|
+
return 0.5;
|
|
72
|
+
const avg = nonEmpty.reduce((s, l) => s + l.length, 0) / nonEmpty.length;
|
|
73
|
+
return Math.min(1, avg / 120); // Normalize to 120 char max
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
// Naming genes
|
|
77
|
+
{
|
|
78
|
+
name: 'camel-case-ratio',
|
|
79
|
+
category: 'naming',
|
|
80
|
+
extract: (content) => {
|
|
81
|
+
const camel = (content.match(/\b[a-z][a-zA-Z0-9]*[A-Z][a-zA-Z0-9]*\b/g) || []).length;
|
|
82
|
+
const snake = (content.match(/\b[a-z][a-z0-9]*_[a-z][a-z0-9]*\b/g) || []).length;
|
|
83
|
+
const total = camel + snake;
|
|
84
|
+
return total > 0 ? camel / total : 0.5;
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: 'prefix-bool',
|
|
89
|
+
category: 'naming',
|
|
90
|
+
extract: (content) => {
|
|
91
|
+
const boolNames = (content.match(/\b(?:is|has|can|should|will|did|was)\w+/g) || []).length;
|
|
92
|
+
const allVars = (content.match(/(?:const|let|var)\s+\w+/g) || []).length;
|
|
93
|
+
return allVars > 0 ? Math.min(1, boolNames / (allVars * 0.2)) : 0.5;
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'constant-naming',
|
|
98
|
+
category: 'naming',
|
|
99
|
+
extract: (content) => {
|
|
100
|
+
const screaming = (content.match(/\b[A-Z][A-Z0-9_]{2,}\b/g) || []).length;
|
|
101
|
+
const allConst = (content.match(/const\s+\w+/g) || []).length;
|
|
102
|
+
return allConst > 0 ? Math.min(1, screaming / (allConst * 0.3)) : 0.5;
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
// Structure genes
|
|
106
|
+
{
|
|
107
|
+
name: 'arrow-fn-ratio',
|
|
108
|
+
category: 'structure',
|
|
109
|
+
extract: (content) => {
|
|
110
|
+
const arrow = (content.match(/=>/g) || []).length;
|
|
111
|
+
const regular = (content.match(/function\s+\w+/g) || []).length;
|
|
112
|
+
const total = arrow + regular;
|
|
113
|
+
return total > 0 ? arrow / total : 0.5;
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'destructuring-usage',
|
|
118
|
+
category: 'structure',
|
|
119
|
+
extract: (content) => {
|
|
120
|
+
const destructured = (content.match(/(?:const|let)\s*\{[^}]+\}\s*=/g) || []).length;
|
|
121
|
+
const allDecl = (content.match(/(?:const|let|var)\s+\w+/g) || []).length;
|
|
122
|
+
return allDecl > 0 ? Math.min(1, destructured / (allDecl * 0.3)) : 0;
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: 'optional-chaining',
|
|
127
|
+
category: 'structure',
|
|
128
|
+
extract: (content) => {
|
|
129
|
+
const optChain = (content.match(/\?\./g) || []).length;
|
|
130
|
+
const dotAccess = (content.match(/\.\w+/g) || []).length;
|
|
131
|
+
return dotAccess > 0 ? Math.min(1, optChain / (dotAccess * 0.1)) : 0;
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: 'spread-usage',
|
|
136
|
+
category: 'structure',
|
|
137
|
+
extract: (content) => {
|
|
138
|
+
const spreads = (content.match(/\.{3}\w+/g) || []).length;
|
|
139
|
+
return Math.min(1, spreads / 20);
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: 'export-style',
|
|
144
|
+
category: 'structure',
|
|
145
|
+
extract: (content) => {
|
|
146
|
+
const named = (content.match(/export\s+(?:const|function|class|interface|type|enum)/g) || []).length;
|
|
147
|
+
const defaultExport = (content.match(/export\s+default/g) || []).length;
|
|
148
|
+
const total = named + defaultExport;
|
|
149
|
+
return total > 0 ? named / total : 0.5; // 1 = all named, 0 = all default
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
// Complexity genes
|
|
153
|
+
{
|
|
154
|
+
name: 'avg-fn-length',
|
|
155
|
+
category: 'complexity',
|
|
156
|
+
extract: (_content, lines) => {
|
|
157
|
+
let fnCount = 0;
|
|
158
|
+
let totalFnLines = 0;
|
|
159
|
+
let depth = 0;
|
|
160
|
+
let inFn = false;
|
|
161
|
+
let fnStart = 0;
|
|
162
|
+
for (let i = 0; i < lines.length; i++) {
|
|
163
|
+
if (/(?:function|=>)\s*\{/.test(lines[i]) || /(?:function|=>)/.test(lines[i])) {
|
|
164
|
+
if (!inFn) {
|
|
165
|
+
inFn = true;
|
|
166
|
+
fnStart = i;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
for (const ch of lines[i]) {
|
|
170
|
+
if (ch === '{')
|
|
171
|
+
depth++;
|
|
172
|
+
if (ch === '}') {
|
|
173
|
+
depth--;
|
|
174
|
+
if (depth === 0 && inFn) {
|
|
175
|
+
fnCount++;
|
|
176
|
+
totalFnLines += i - fnStart;
|
|
177
|
+
inFn = false;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (fnCount === 0)
|
|
183
|
+
return 0.5;
|
|
184
|
+
const avg = totalFnLines / fnCount;
|
|
185
|
+
return Math.min(1, avg / 50); // Normalize to 50 lines
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: 'nesting-depth',
|
|
190
|
+
category: 'complexity',
|
|
191
|
+
extract: (_content, lines) => {
|
|
192
|
+
let maxDepth = 0;
|
|
193
|
+
let currentDepth = 0;
|
|
194
|
+
for (const line of lines) {
|
|
195
|
+
for (const ch of line) {
|
|
196
|
+
if (ch === '{') {
|
|
197
|
+
currentDepth++;
|
|
198
|
+
maxDepth = Math.max(maxDepth, currentDepth);
|
|
199
|
+
}
|
|
200
|
+
if (ch === '}')
|
|
201
|
+
currentDepth--;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return Math.min(1, maxDepth / 8);
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
// Documentation genes
|
|
208
|
+
{
|
|
209
|
+
name: 'jsdoc-coverage',
|
|
210
|
+
category: 'documentation',
|
|
211
|
+
extract: (content) => {
|
|
212
|
+
const jsdocs = (content.match(/\/\*\*[\s\S]*?\*\//g) || []).length;
|
|
213
|
+
const functions = (content.match(/(?:function|=>|class)\s/g) || []).length;
|
|
214
|
+
return functions > 0 ? Math.min(1, jsdocs / functions) : 0;
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
name: 'inline-comments',
|
|
219
|
+
category: 'documentation',
|
|
220
|
+
extract: (_content, lines) => {
|
|
221
|
+
const comments = lines.filter(l => /^\s*\/\//.test(l)).length;
|
|
222
|
+
return lines.length > 0 ? Math.min(1, comments / (lines.length * 0.15)) : 0;
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
// Error handling genes
|
|
226
|
+
{
|
|
227
|
+
name: 'try-catch-density',
|
|
228
|
+
category: 'error-handling',
|
|
229
|
+
extract: (content, lines) => {
|
|
230
|
+
const tryCatch = (content.match(/try\s*\{/g) || []).length;
|
|
231
|
+
return lines.length > 0 ? Math.min(1, tryCatch / (lines.length * 0.02)) : 0;
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
name: 'custom-errors',
|
|
236
|
+
category: 'error-handling',
|
|
237
|
+
extract: (content) => {
|
|
238
|
+
const customErr = (content.match(/class\s+\w+Error\s+extends/g) || []).length;
|
|
239
|
+
return Math.min(1, customErr / 3);
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
// Typing genes
|
|
243
|
+
{
|
|
244
|
+
name: 'type-annotation-density',
|
|
245
|
+
category: 'typing',
|
|
246
|
+
extract: (content) => {
|
|
247
|
+
const typeAnnotations = (content.match(/:\s*(?:string|number|boolean|any|unknown|void|never|null|undefined|\w+(?:<[^>]+>)?)\b/g) || []).length;
|
|
248
|
+
const variables = (content.match(/(?:const|let|var|param|return)\s/g) || []).length;
|
|
249
|
+
return variables > 0 ? Math.min(1, typeAnnotations / variables) : 0.5;
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
name: 'generic-usage',
|
|
254
|
+
category: 'typing',
|
|
255
|
+
extract: (content) => {
|
|
256
|
+
const generics = (content.match(/<\s*[A-Z]\w*(?:\s*(?:extends|=)[^>]+)?>/g) || []).length;
|
|
257
|
+
return Math.min(1, generics / 10);
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
// Async patterns
|
|
261
|
+
{
|
|
262
|
+
name: 'async-await-ratio',
|
|
263
|
+
category: 'async-patterns',
|
|
264
|
+
extract: (content) => {
|
|
265
|
+
const awaits = (content.match(/await\s/g) || []).length;
|
|
266
|
+
const thenChains = (content.match(/\.then\s*\(/g) || []).length;
|
|
267
|
+
const total = awaits + thenChains;
|
|
268
|
+
return total > 0 ? awaits / total : 0.5;
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
// Functional vs OOP
|
|
272
|
+
{
|
|
273
|
+
name: 'functional-style',
|
|
274
|
+
category: 'functional',
|
|
275
|
+
extract: (content) => {
|
|
276
|
+
const funcPatterns = (content.match(/\.map\(|\.filter\(|\.reduce\(|\.flatMap\(|\.some\(|\.every\(|\.find\(/g) || []).length;
|
|
277
|
+
const imperativePatterns = (content.match(/for\s*\(|while\s*\(|\.forEach\(/g) || []).length;
|
|
278
|
+
const total = funcPatterns + imperativePatterns;
|
|
279
|
+
return total > 0 ? funcPatterns / total : 0.5;
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
name: 'class-usage',
|
|
284
|
+
category: 'oop',
|
|
285
|
+
extract: (content) => {
|
|
286
|
+
const classes = (content.match(/\bclass\s+\w+/g) || []).length;
|
|
287
|
+
const functions = (content.match(/(?:function\s+\w+|const\s+\w+\s*=\s*(?:async\s+)?\()/g) || []).length;
|
|
288
|
+
const total = classes + functions;
|
|
289
|
+
return total > 0 ? classes / total : 0.5;
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
];
|
|
293
|
+
// ── Code DNA Engine ────────────────────────────────────────────────────────
|
|
294
|
+
export class CodeDNA {
|
|
295
|
+
constructor(projectDir) {
|
|
296
|
+
this.profiles = new Map();
|
|
297
|
+
this.projectDir = projectDir;
|
|
298
|
+
}
|
|
299
|
+
// ── Profile Building ────────────────────────────────────────────────
|
|
300
|
+
async buildProfile(name, dir) {
|
|
301
|
+
const targetDir = dir || this.projectDir;
|
|
302
|
+
const profileName = name || path.basename(targetDir);
|
|
303
|
+
const files = this.collectSourceFiles(targetDir);
|
|
304
|
+
const genes = new Map();
|
|
305
|
+
let totalLines = 0;
|
|
306
|
+
// Initialize genes
|
|
307
|
+
for (const extractor of GENE_EXTRACTORS) {
|
|
308
|
+
genes.set(extractor.name, {
|
|
309
|
+
trait: extractor.name,
|
|
310
|
+
value: 0,
|
|
311
|
+
samples: 0,
|
|
312
|
+
category: extractor.category,
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
// Extract genes from each file
|
|
316
|
+
for (const file of files) {
|
|
317
|
+
try {
|
|
318
|
+
const content = fs.readFileSync(file, 'utf-8');
|
|
319
|
+
const lines = content.split('\n');
|
|
320
|
+
totalLines += lines.length;
|
|
321
|
+
for (const extractor of GENE_EXTRACTORS) {
|
|
322
|
+
const value = extractor.extract(content, lines);
|
|
323
|
+
const gene = genes.get(extractor.name);
|
|
324
|
+
// Running average
|
|
325
|
+
gene.value = (gene.value * gene.samples + value) / (gene.samples + 1);
|
|
326
|
+
gene.samples++;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
catch {
|
|
330
|
+
// Skip unreadable files
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
// Detect dominant language
|
|
334
|
+
const language = this.detectLanguage(files);
|
|
335
|
+
// Calculate fingerprint
|
|
336
|
+
const geneValues = Array.from(genes.values()).map(g => g.value.toFixed(3)).join(':');
|
|
337
|
+
const fingerprint = crypto.createHash('sha256').update(geneValues).digest('hex').slice(0, 16);
|
|
338
|
+
// Calculate self-consistency
|
|
339
|
+
const similarity = this.calculateConsistency(genes);
|
|
340
|
+
const profile = {
|
|
341
|
+
id: crypto.randomUUID(),
|
|
342
|
+
name: profileName,
|
|
343
|
+
createdAt: Date.now(),
|
|
344
|
+
updatedAt: Date.now(),
|
|
345
|
+
genes,
|
|
346
|
+
fingerprint,
|
|
347
|
+
fileCount: files.length,
|
|
348
|
+
totalLines,
|
|
349
|
+
language,
|
|
350
|
+
similarity,
|
|
351
|
+
};
|
|
352
|
+
this.profiles.set(profile.id, profile);
|
|
353
|
+
return profile;
|
|
354
|
+
}
|
|
355
|
+
analyzeFile(filePath, content) {
|
|
356
|
+
const lines = content.split('\n');
|
|
357
|
+
const result = new Map();
|
|
358
|
+
for (const extractor of GENE_EXTRACTORS) {
|
|
359
|
+
result.set(extractor.name, extractor.extract(content, lines));
|
|
360
|
+
}
|
|
361
|
+
return result;
|
|
362
|
+
}
|
|
363
|
+
// ── Comparison ──────────────────────────────────────────────────────
|
|
364
|
+
compare(profileA, profileB) {
|
|
365
|
+
const matchingGenes = [];
|
|
366
|
+
const divergingGenes = [];
|
|
367
|
+
let totalSimilarity = 0;
|
|
368
|
+
let geneCount = 0;
|
|
369
|
+
for (const [name, geneA] of profileA.genes) {
|
|
370
|
+
const geneB = profileB.genes.get(name);
|
|
371
|
+
if (!geneB)
|
|
372
|
+
continue;
|
|
373
|
+
const delta = Math.abs(geneA.value - geneB.value);
|
|
374
|
+
geneCount++;
|
|
375
|
+
if (delta < 0.15) {
|
|
376
|
+
matchingGenes.push(name);
|
|
377
|
+
totalSimilarity += 1 - delta;
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
divergingGenes.push({
|
|
381
|
+
gene: name,
|
|
382
|
+
profileA: geneA.value,
|
|
383
|
+
profileB: geneB.value,
|
|
384
|
+
delta,
|
|
385
|
+
});
|
|
386
|
+
totalSimilarity += 1 - delta;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
const similarity = geneCount > 0 ? totalSimilarity / geneCount : 0;
|
|
390
|
+
divergingGenes.sort((a, b) => b.delta - a.delta);
|
|
391
|
+
let verdict;
|
|
392
|
+
if (similarity >= 0.85)
|
|
393
|
+
verdict = 'same-team';
|
|
394
|
+
else if (similarity >= 0.65)
|
|
395
|
+
verdict = 'similar-style';
|
|
396
|
+
else if (similarity >= 0.4)
|
|
397
|
+
verdict = 'different-style';
|
|
398
|
+
else
|
|
399
|
+
verdict = 'inconsistent';
|
|
400
|
+
return { similarity, matchingGenes, divergingGenes, verdict };
|
|
401
|
+
}
|
|
402
|
+
compareFileToProfile(filePath, content, profileId) {
|
|
403
|
+
const profile = this.profiles.get(profileId);
|
|
404
|
+
if (!profile)
|
|
405
|
+
return null;
|
|
406
|
+
const fileGenes = this.analyzeFile(filePath, content);
|
|
407
|
+
const fileProfile = {
|
|
408
|
+
id: 'temp',
|
|
409
|
+
name: path.basename(filePath),
|
|
410
|
+
createdAt: Date.now(),
|
|
411
|
+
updatedAt: Date.now(),
|
|
412
|
+
genes: new Map(),
|
|
413
|
+
fingerprint: '',
|
|
414
|
+
fileCount: 1,
|
|
415
|
+
totalLines: content.split('\n').length,
|
|
416
|
+
language: path.extname(filePath).slice(1),
|
|
417
|
+
similarity: 1,
|
|
418
|
+
};
|
|
419
|
+
for (const [name, value] of fileGenes) {
|
|
420
|
+
const extractor = GENE_EXTRACTORS.find(e => e.name === name);
|
|
421
|
+
if (extractor) {
|
|
422
|
+
fileProfile.genes.set(name, {
|
|
423
|
+
trait: name,
|
|
424
|
+
value,
|
|
425
|
+
samples: 1,
|
|
426
|
+
category: extractor.category,
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
return this.compare(profile, fileProfile);
|
|
431
|
+
}
|
|
432
|
+
// ── Style Consistency ───────────────────────────────────────────────
|
|
433
|
+
async checkConsistency(dir) {
|
|
434
|
+
const targetDir = dir || this.projectDir;
|
|
435
|
+
const files = this.collectSourceFiles(targetDir);
|
|
436
|
+
// First build the overall profile
|
|
437
|
+
const profile = await this.buildProfile('consistency-check', targetDir);
|
|
438
|
+
const fileScores = [];
|
|
439
|
+
const geneViolations = new Map();
|
|
440
|
+
for (const file of files.slice(0, 200)) {
|
|
441
|
+
try {
|
|
442
|
+
const content = fs.readFileSync(file, 'utf-8');
|
|
443
|
+
const fileGenes = this.analyzeFile(file, content);
|
|
444
|
+
const violations = [];
|
|
445
|
+
let scoreSum = 0;
|
|
446
|
+
let scoreCount = 0;
|
|
447
|
+
for (const [name, value] of fileGenes) {
|
|
448
|
+
const profileGene = profile.genes.get(name);
|
|
449
|
+
if (!profileGene || profileGene.samples < 3)
|
|
450
|
+
continue;
|
|
451
|
+
const delta = Math.abs(value - profileGene.value);
|
|
452
|
+
scoreSum += 1 - delta;
|
|
453
|
+
scoreCount++;
|
|
454
|
+
if (delta > 0.3) {
|
|
455
|
+
violations.push(`${name}: expected ~${profileGene.value.toFixed(2)}, got ${value.toFixed(2)}`);
|
|
456
|
+
if (!geneViolations.has(name)) {
|
|
457
|
+
geneViolations.set(name, { expected: profileGene.value, actuals: [], files: [] });
|
|
458
|
+
}
|
|
459
|
+
const gv = geneViolations.get(name);
|
|
460
|
+
gv.actuals.push(value);
|
|
461
|
+
gv.files.push(path.relative(this.projectDir, file));
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
const score = scoreCount > 0 ? scoreSum / scoreCount : 1;
|
|
465
|
+
fileScores.push({
|
|
466
|
+
file: path.relative(this.projectDir, file),
|
|
467
|
+
score,
|
|
468
|
+
violations,
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
catch {
|
|
472
|
+
// Skip
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
const topViolations = Array.from(geneViolations.entries())
|
|
476
|
+
.map(([gene, data]) => ({
|
|
477
|
+
gene,
|
|
478
|
+
expected: data.expected,
|
|
479
|
+
actual: data.actuals.reduce((s, v) => s + v, 0) / data.actuals.length,
|
|
480
|
+
files: data.files.slice(0, 5),
|
|
481
|
+
}))
|
|
482
|
+
.sort((a, b) => b.files.length - a.files.length)
|
|
483
|
+
.slice(0, 10);
|
|
484
|
+
const overall = fileScores.length > 0
|
|
485
|
+
? fileScores.reduce((s, f) => s + f.score, 0) / fileScores.length
|
|
486
|
+
: 1;
|
|
487
|
+
const recommendations = this.generateRecommendations(topViolations, profile);
|
|
488
|
+
return { overall, fileScores, topViolations, recommendations };
|
|
489
|
+
}
|
|
490
|
+
generateRecommendations(violations, profile) {
|
|
491
|
+
const recs = [];
|
|
492
|
+
for (const v of violations.slice(0, 5)) {
|
|
493
|
+
switch (v.gene) {
|
|
494
|
+
case 'semicolons':
|
|
495
|
+
recs.push(v.expected > 0.7 ? 'Enforce semicolons consistently across all files' : 'Consider removing semicolons to match project style');
|
|
496
|
+
break;
|
|
497
|
+
case 'single-quotes':
|
|
498
|
+
recs.push(v.expected > 0.7 ? 'Use single quotes consistently' : 'Use double quotes consistently');
|
|
499
|
+
break;
|
|
500
|
+
case 'indent-size':
|
|
501
|
+
recs.push(`Standardize indentation to ${Math.round(v.expected * 8)} spaces`);
|
|
502
|
+
break;
|
|
503
|
+
case 'arrow-fn-ratio':
|
|
504
|
+
recs.push(v.expected > 0.7 ? 'Prefer arrow functions over function declarations' : 'Use function declarations for consistency');
|
|
505
|
+
break;
|
|
506
|
+
case 'jsdoc-coverage':
|
|
507
|
+
recs.push('Improve JSDoc coverage to match project standard');
|
|
508
|
+
break;
|
|
509
|
+
case 'try-catch-density':
|
|
510
|
+
recs.push('Add more error handling to match project patterns');
|
|
511
|
+
break;
|
|
512
|
+
case 'type-annotation-density':
|
|
513
|
+
recs.push('Add more type annotations for consistency');
|
|
514
|
+
break;
|
|
515
|
+
default:
|
|
516
|
+
recs.push(`Standardize ${v.gene} across the codebase`);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return recs;
|
|
520
|
+
}
|
|
521
|
+
// ── Helpers ──────────────────────────────────────────────────────────
|
|
522
|
+
calculateConsistency(genes) {
|
|
523
|
+
// Consistency = how close gene values are to 0 or 1 (strong preference vs mixed)
|
|
524
|
+
let totalClarity = 0;
|
|
525
|
+
let count = 0;
|
|
526
|
+
for (const gene of genes.values()) {
|
|
527
|
+
if (gene.samples < 2)
|
|
528
|
+
continue;
|
|
529
|
+
// Distance from 0.5 (ambiguous) — higher = more consistent
|
|
530
|
+
const clarity = Math.abs(gene.value - 0.5) * 2; // 0-1
|
|
531
|
+
totalClarity += clarity;
|
|
532
|
+
count++;
|
|
533
|
+
}
|
|
534
|
+
return count > 0 ? totalClarity / count : 0.5;
|
|
535
|
+
}
|
|
536
|
+
collectSourceFiles(dir, maxFiles = 300) {
|
|
537
|
+
const files = [];
|
|
538
|
+
const extensions = new Set(['.ts', '.tsx', '.js', '.jsx', '.mjs', '.py', '.go', '.rs', '.java', '.kt', '.rb', '.vue', '.svelte']);
|
|
539
|
+
const ignore = new Set(['node_modules', '.git', 'dist', 'build', 'out', '.next', 'coverage', 'vendor']);
|
|
540
|
+
const walk = (d, depth) => {
|
|
541
|
+
if (depth > 6 || files.length >= maxFiles)
|
|
542
|
+
return;
|
|
543
|
+
try {
|
|
544
|
+
const entries = fs.readdirSync(d, { withFileTypes: true });
|
|
545
|
+
for (const entry of entries) {
|
|
546
|
+
if (files.length >= maxFiles)
|
|
547
|
+
break;
|
|
548
|
+
if (entry.isDirectory() && !ignore.has(entry.name) && !entry.name.startsWith('.')) {
|
|
549
|
+
walk(path.join(d, entry.name), depth + 1);
|
|
550
|
+
}
|
|
551
|
+
else if (entry.isFile() && extensions.has(path.extname(entry.name))) {
|
|
552
|
+
files.push(path.join(d, entry.name));
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
catch { /* skip */ }
|
|
557
|
+
};
|
|
558
|
+
walk(dir, 0);
|
|
559
|
+
return files;
|
|
560
|
+
}
|
|
561
|
+
detectLanguage(files) {
|
|
562
|
+
const extCount = new Map();
|
|
563
|
+
for (const file of files) {
|
|
564
|
+
const ext = path.extname(file);
|
|
565
|
+
extCount.set(ext, (extCount.get(ext) || 0) + 1);
|
|
566
|
+
}
|
|
567
|
+
let maxExt = '.ts';
|
|
568
|
+
let maxCount = 0;
|
|
569
|
+
for (const [ext, count] of extCount) {
|
|
570
|
+
if (count > maxCount) {
|
|
571
|
+
maxExt = ext;
|
|
572
|
+
maxCount = count;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
const langMap = {
|
|
576
|
+
'.ts': 'typescript', '.tsx': 'typescript', '.js': 'javascript', '.jsx': 'javascript',
|
|
577
|
+
'.py': 'python', '.go': 'go', '.rs': 'rust', '.java': 'java', '.kt': 'kotlin',
|
|
578
|
+
'.rb': 'ruby', '.vue': 'vue', '.svelte': 'svelte',
|
|
579
|
+
};
|
|
580
|
+
return langMap[maxExt] || 'unknown';
|
|
581
|
+
}
|
|
582
|
+
getProfile(id) {
|
|
583
|
+
return this.profiles.get(id);
|
|
584
|
+
}
|
|
585
|
+
getAllProfiles() {
|
|
586
|
+
return Array.from(this.profiles.values());
|
|
587
|
+
}
|
|
588
|
+
stats() {
|
|
589
|
+
const profiles = Array.from(this.profiles.values());
|
|
590
|
+
const totalGenes = profiles.reduce((s, p) => s + p.genes.size, 0);
|
|
591
|
+
const avgConsistency = profiles.length > 0
|
|
592
|
+
? profiles.reduce((s, p) => s + p.similarity, 0) / profiles.length
|
|
593
|
+
: 0;
|
|
594
|
+
const dominantStyle = {};
|
|
595
|
+
for (const profile of profiles) {
|
|
596
|
+
for (const [name, gene] of profile.genes) {
|
|
597
|
+
if (gene.samples >= 3) {
|
|
598
|
+
dominantStyle[name] = gene.value;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
return {
|
|
603
|
+
profiles: profiles.length,
|
|
604
|
+
totalGenes,
|
|
605
|
+
avgConsistency,
|
|
606
|
+
dominantStyle,
|
|
607
|
+
language: profiles[0]?.language || 'unknown',
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
//# sourceMappingURL=code-dna.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-dna.js","sourceRoot":"","sources":["../../src/brain/code-dna.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,4CAA4C;AAE5C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AA2DjC,MAAM,eAAe,GAAoB;IACvC,mBAAmB;IACnB;QACE,IAAI,EAAE,eAAe;QACrB,QAAQ,EAAE,YAAY;QACtB,OAAO,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;YAC3B,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACnD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,GAAG,CAAC;YACtC,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YACzD,OAAO,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;QAClC,CAAC;KACF;IACD;QACE,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,YAAY;QACtB,OAAO,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;YAC3B,MAAM,WAAW,GAAa,EAAE,CAAC;YACjC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO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