semantic-complexity 0.0.7-741984fb → 0.0.15-29c6b296
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__/analyzers.test.d.ts +5 -0
- package/dist/__tests__/analyzers.test.d.ts.map +1 -0
- package/dist/__tests__/analyzers.test.js +357 -0
- package/dist/__tests__/analyzers.test.js.map +1 -0
- package/dist/__tests__/gate.test.d.ts +5 -0
- package/dist/__tests__/gate.test.d.ts.map +1 -0
- package/dist/__tests__/gate.test.js +140 -0
- package/dist/__tests__/gate.test.js.map +1 -0
- package/dist/analyzers/bread.d.ts +63 -0
- package/dist/analyzers/bread.d.ts.map +1 -0
- package/dist/analyzers/bread.js +415 -0
- package/dist/analyzers/bread.js.map +1 -0
- package/dist/analyzers/cheese.d.ts +111 -0
- package/dist/analyzers/cheese.d.ts.map +1 -0
- package/dist/analyzers/cheese.js +881 -0
- package/dist/analyzers/cheese.js.map +1 -0
- package/dist/analyzers/ham.d.ts +33 -0
- package/dist/analyzers/ham.d.ts.map +1 -0
- package/dist/analyzers/ham.js +264 -0
- package/dist/analyzers/ham.js.map +1 -0
- package/dist/analyzers/index.d.ts +7 -0
- package/dist/analyzers/index.d.ts.map +1 -0
- package/dist/analyzers/index.js +7 -0
- package/dist/analyzers/index.js.map +1 -0
- package/dist/budget/index.d.ts +50 -0
- package/dist/budget/index.d.ts.map +1 -0
- package/dist/budget/index.js +138 -0
- package/dist/budget/index.js.map +1 -0
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +103 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/gate/index.d.ts +31 -0
- package/dist/gate/index.d.ts.map +1 -0
- package/dist/gate/index.js +117 -0
- package/dist/gate/index.js.map +1 -0
- package/dist/gate/waiver.d.ts +83 -0
- package/dist/gate/waiver.d.ts.map +1 -0
- package/dist/gate/waiver.js +425 -0
- package/dist/gate/waiver.js.map +1 -0
- package/dist/index.d.ts +8 -34
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -49
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +5 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +351 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/recommend/index.d.ts +32 -0
- package/dist/recommend/index.d.ts.map +1 -0
- package/dist/recommend/index.js +169 -0
- package/dist/recommend/index.js.map +1 -0
- package/dist/simplex/index.d.ts +26 -0
- package/dist/simplex/index.d.ts.map +1 -0
- package/dist/simplex/index.js +100 -0
- package/dist/simplex/index.js.map +1 -0
- package/dist/types/index.d.ts +39 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +27 -52
- package/LICENSE +0 -21
- package/README.md +0 -72
- package/dist/ast/index.d.ts +0 -2
- package/dist/ast/index.d.ts.map +0 -1
- package/dist/ast/index.js +0 -2
- package/dist/ast/index.js.map +0 -1
- package/dist/ast/parser.d.ts +0 -27
- package/dist/ast/parser.d.ts.map +0 -1
- package/dist/ast/parser.js +0 -273
- package/dist/ast/parser.js.map +0 -1
- package/dist/canonical/convergence.d.ts +0 -56
- package/dist/canonical/convergence.d.ts.map +0 -1
- package/dist/canonical/convergence.js +0 -149
- package/dist/canonical/convergence.js.map +0 -1
- package/dist/canonical/index.d.ts +0 -11
- package/dist/canonical/index.d.ts.map +0 -1
- package/dist/canonical/index.js +0 -11
- package/dist/canonical/index.js.map +0 -1
- package/dist/canonical/profiles.d.ts +0 -40
- package/dist/canonical/profiles.d.ts.map +0 -1
- package/dist/canonical/profiles.js +0 -182
- package/dist/canonical/profiles.js.map +0 -1
- package/dist/canonical/types.d.ts +0 -124
- package/dist/canonical/types.d.ts.map +0 -1
- package/dist/canonical/types.js +0 -46
- package/dist/canonical/types.js.map +0 -1
- package/dist/compare.d.ts +0 -31
- package/dist/compare.d.ts.map +0 -1
- package/dist/compare.js +0 -354
- package/dist/compare.js.map +0 -1
- package/dist/context/index.d.ts +0 -41
- package/dist/context/index.d.ts.map +0 -1
- package/dist/context/index.js +0 -253
- package/dist/context/index.js.map +0 -1
- package/dist/gates/delta.d.ts +0 -45
- package/dist/gates/delta.d.ts.map +0 -1
- package/dist/gates/delta.js +0 -260
- package/dist/gates/delta.js.map +0 -1
- package/dist/gates/index.d.ts +0 -9
- package/dist/gates/index.d.ts.map +0 -1
- package/dist/gates/index.js +0 -9
- package/dist/gates/index.js.map +0 -1
- package/dist/gates/types.d.ts +0 -96
- package/dist/gates/types.d.ts.map +0 -1
- package/dist/gates/types.js +0 -59
- package/dist/gates/types.js.map +0 -1
- package/dist/graph/call.d.ts +0 -63
- package/dist/graph/call.d.ts.map +0 -1
- package/dist/graph/call.js +0 -240
- package/dist/graph/call.js.map +0 -1
- package/dist/graph/dependency.d.ts +0 -52
- package/dist/graph/dependency.d.ts.map +0 -1
- package/dist/graph/dependency.js +0 -296
- package/dist/graph/dependency.js.map +0 -1
- package/dist/graph/index.d.ts +0 -3
- package/dist/graph/index.d.ts.map +0 -1
- package/dist/graph/index.js +0 -3
- package/dist/graph/index.js.map +0 -1
- package/dist/metrics/cognitive.d.ts +0 -42
- package/dist/metrics/cognitive.d.ts.map +0 -1
- package/dist/metrics/cognitive.js +0 -204
- package/dist/metrics/cognitive.js.map +0 -1
- package/dist/metrics/cyclomatic.d.ts +0 -31
- package/dist/metrics/cyclomatic.d.ts.map +0 -1
- package/dist/metrics/cyclomatic.js +0 -121
- package/dist/metrics/cyclomatic.js.map +0 -1
- package/dist/metrics/dimensional.d.ts +0 -32
- package/dist/metrics/dimensional.d.ts.map +0 -1
- package/dist/metrics/dimensional.js +0 -560
- package/dist/metrics/dimensional.js.map +0 -1
- package/dist/metrics/index.d.ts +0 -26
- package/dist/metrics/index.d.ts.map +0 -1
- package/dist/metrics/index.js +0 -120
- package/dist/metrics/index.js.map +0 -1
- package/dist/metrics/meta.d.ts +0 -90
- package/dist/metrics/meta.d.ts.map +0 -1
- package/dist/metrics/meta.js +0 -144
- package/dist/metrics/meta.js.map +0 -1
- package/dist/tensor/canonical.d.ts +0 -53
- package/dist/tensor/canonical.d.ts.map +0 -1
- package/dist/tensor/canonical.js +0 -192
- package/dist/tensor/canonical.js.map +0 -1
- package/dist/tensor/index.d.ts +0 -22
- package/dist/tensor/index.d.ts.map +0 -1
- package/dist/tensor/index.js +0 -22
- package/dist/tensor/index.js.map +0 -1
- package/dist/tensor/matrix.d.ts +0 -62
- package/dist/tensor/matrix.d.ts.map +0 -1
- package/dist/tensor/matrix.js +0 -187
- package/dist/tensor/matrix.js.map +0 -1
- package/dist/tensor/scoring.d.ts +0 -82
- package/dist/tensor/scoring.d.ts.map +0 -1
- package/dist/tensor/scoring.js +0 -233
- package/dist/tensor/scoring.js.map +0 -1
- package/dist/tensor/types.d.ts +0 -186
- package/dist/tensor/types.d.ts.map +0 -1
- package/dist/tensor/types.js +0 -15
- package/dist/tensor/types.js.map +0 -1
- package/dist/types.d.ts +0 -341
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -22
- package/dist/types.js.map +0 -1
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simplex - Normalization & Equilibrium
|
|
3
|
+
*
|
|
4
|
+
* Normalizes Bread, Cheese, Ham scores to simplex coordinates
|
|
5
|
+
* and calculates equilibrium state.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Normalize scores to simplex coordinates (sum = 1)
|
|
9
|
+
*/
|
|
10
|
+
export function normalize(bread, cheese, ham) {
|
|
11
|
+
// Convert to raw scores (0-1 range, higher = more issues)
|
|
12
|
+
const breadRaw = calculateBreadRaw(bread);
|
|
13
|
+
const cheeseRaw = calculateCheeseRaw(cheese);
|
|
14
|
+
const hamRaw = calculateHamRaw(ham);
|
|
15
|
+
const total = breadRaw + cheeseRaw + hamRaw;
|
|
16
|
+
if (total === 0) {
|
|
17
|
+
return { bread: 1 / 3, cheese: 1 / 3, ham: 1 / 3 };
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
bread: breadRaw / total,
|
|
21
|
+
cheese: cheeseRaw / total,
|
|
22
|
+
ham: hamRaw / total,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function calculateBreadRaw(bread) {
|
|
26
|
+
let score = 0;
|
|
27
|
+
// Trust boundary
|
|
28
|
+
if (bread.trustBoundaryCount === 0)
|
|
29
|
+
score += 0.3;
|
|
30
|
+
// Auth explicitness
|
|
31
|
+
score += (1 - bread.authExplicitness) * 0.2;
|
|
32
|
+
// Secrets
|
|
33
|
+
const highSecrets = bread.secretPatterns.filter(s => s.severity === 'high').length;
|
|
34
|
+
score += Math.min(highSecrets * 0.15, 0.3);
|
|
35
|
+
// Hidden deps
|
|
36
|
+
score += Math.min(bread.hiddenDeps.total * 0.02, 0.2);
|
|
37
|
+
return Math.min(score, 1.0);
|
|
38
|
+
}
|
|
39
|
+
function calculateCheeseRaw(cheese) {
|
|
40
|
+
let score = 0;
|
|
41
|
+
// Nesting depth (normalized to 0-1, threshold = 4)
|
|
42
|
+
score += Math.min(cheese.maxNesting / 10, 0.3);
|
|
43
|
+
// State×Async×Retry violation
|
|
44
|
+
if (cheese.stateAsyncRetry.violated)
|
|
45
|
+
score += 0.3;
|
|
46
|
+
// Accessibility
|
|
47
|
+
if (!cheese.accessible)
|
|
48
|
+
score += 0.3;
|
|
49
|
+
// Additional violations
|
|
50
|
+
score += Math.min(cheese.violations.length * 0.05, 0.1);
|
|
51
|
+
return Math.min(score, 1.0);
|
|
52
|
+
}
|
|
53
|
+
function calculateHamRaw(ham) {
|
|
54
|
+
// Inverse of coverage (1.0 coverage = 0 raw score)
|
|
55
|
+
return 1 - ham.goldenTestCoverage;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Calculate equilibrium state
|
|
59
|
+
*/
|
|
60
|
+
export function calculateEquilibrium(simplex) {
|
|
61
|
+
const { bread, cheese, ham } = simplex;
|
|
62
|
+
const ideal = 1 / 3;
|
|
63
|
+
// Energy = sum of squared deviations from ideal
|
|
64
|
+
const energy = Math.pow(bread - ideal, 2) +
|
|
65
|
+
Math.pow(cheese - ideal, 2) +
|
|
66
|
+
Math.pow(ham - ideal, 2);
|
|
67
|
+
// Find dominant axis (if any)
|
|
68
|
+
const max = Math.max(bread, cheese, ham);
|
|
69
|
+
const threshold = 0.5; // Dominant if > 50%
|
|
70
|
+
let dominantAxis = null;
|
|
71
|
+
if (max > threshold) {
|
|
72
|
+
if (bread === max)
|
|
73
|
+
dominantAxis = 'bread';
|
|
74
|
+
else if (cheese === max)
|
|
75
|
+
dominantAxis = 'cheese';
|
|
76
|
+
else
|
|
77
|
+
dominantAxis = 'ham';
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
inEquilibrium: energy < 0.1,
|
|
81
|
+
energy,
|
|
82
|
+
dominantAxis,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get label based on dominant axis
|
|
87
|
+
*/
|
|
88
|
+
export function getLabel(simplex) {
|
|
89
|
+
const { bread, cheese, ham } = simplex;
|
|
90
|
+
const max = Math.max(bread, cheese, ham);
|
|
91
|
+
if (max < 0.4) {
|
|
92
|
+
return { label: 'balanced', confidence: 1 - max * 2 };
|
|
93
|
+
}
|
|
94
|
+
if (bread === max)
|
|
95
|
+
return { label: 'bread', confidence: bread };
|
|
96
|
+
if (cheese === max)
|
|
97
|
+
return { label: 'cheese', confidence: cheese };
|
|
98
|
+
return { label: 'ham', confidence: ham };
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/simplex/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH;;GAEG;AACH,MAAM,UAAU,SAAS,CACvB,KAAkB,EAClB,MAAoB,EACpB,GAAc;IAEd,0DAA0D;IAC1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C,CAAC,oBAAoB;IAE3C,IAAI,YAAY,GAAsC,IAAI,CAAC;IAC3D,IAAI,GAAG,GAAG,SAAS,EAAE,CAAC;QACpB,IAAI,KAAK,KAAK,GAAG;YAAE,YAAY,GAAG,OAAO,CAAC;aACrC,IAAI,MAAM,KAAK,GAAG;YAAE,YAAY,GAAG,QAAQ,CAAC;;YAC5C,YAAY,GAAG,KAAK,CAAC;IAC5B,CAAC;IAED,OAAO;QACL,aAAa,EAAE,MAAM,GAAG,GAAG;QAC3B,MAAM;QACN,YAAY;KACb,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,OAA2B;IAIlD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAEzC,IAAI,GAAG,GAAG,GAAG,EAAE,CAAC;QACd,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,CAAC;IACxD,CAAC;IAED,IAAI,KAAK,KAAK,GAAG;QAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IAChE,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;IACnE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for semantic-complexity
|
|
3
|
+
*/
|
|
4
|
+
export type { BreadResult, TrustBoundary, SecretPattern, HiddenDeps, } from '../analyzers/bread.js';
|
|
5
|
+
export type { CheeseResult, FunctionInfo, StateAsyncRetry, AntiPatternPenalty, CognitiveConfig, } from '../analyzers/cheese.js';
|
|
6
|
+
export type { HamResult, CriticalPath, TestInfo, CriticalCategory, TestFramework, } from '../analyzers/ham.js';
|
|
7
|
+
export interface SandwichScore {
|
|
8
|
+
bread: import('../analyzers/bread.js').BreadResult;
|
|
9
|
+
cheese: import('../analyzers/cheese.js').CheeseResult;
|
|
10
|
+
ham: import('../analyzers/ham.js').HamResult;
|
|
11
|
+
simplex: SimplexCoordinates;
|
|
12
|
+
equilibrium: EquilibriumResult;
|
|
13
|
+
}
|
|
14
|
+
export interface SimplexCoordinates {
|
|
15
|
+
bread: number;
|
|
16
|
+
cheese: number;
|
|
17
|
+
ham: number;
|
|
18
|
+
}
|
|
19
|
+
export interface EquilibriumResult {
|
|
20
|
+
inEquilibrium: boolean;
|
|
21
|
+
energy: number;
|
|
22
|
+
dominantAxis: 'bread' | 'cheese' | 'ham' | null;
|
|
23
|
+
}
|
|
24
|
+
export type GateType = 'poc' | 'mvp' | 'production';
|
|
25
|
+
export interface GateResult {
|
|
26
|
+
passed: boolean;
|
|
27
|
+
gateType: GateType;
|
|
28
|
+
violations: GateViolation[];
|
|
29
|
+
waiverApplied: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface GateViolation {
|
|
32
|
+
rule: string;
|
|
33
|
+
actual: number | boolean;
|
|
34
|
+
threshold: number | boolean;
|
|
35
|
+
message: string;
|
|
36
|
+
}
|
|
37
|
+
export type ModuleType = 'api/external' | 'api/internal' | 'lib/domain' | 'lib/util' | 'app';
|
|
38
|
+
export type { EssentialComplexityConfig, ComplexitySignal, ComplexityContext, WaiverResult, } from '../gate/waiver.js';
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,YAAY,EACV,WAAW,EACX,aAAa,EACb,aAAa,EACb,UAAU,GACX,MAAM,uBAAuB,CAAC;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yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,GACb,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/package.json
CHANGED
|
@@ -1,42 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "semantic-complexity",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Multi-dimensional code complexity analyzer",
|
|
3
|
+
"version": "0.0.15-29c6b296",
|
|
4
|
+
"description": "Multi-dimensional code complexity analyzer (Bread-Cheese-Ham sandwich model)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"semantic-complexity": "./dist/cli/index.js"
|
|
10
|
+
},
|
|
8
11
|
"exports": {
|
|
9
12
|
".": {
|
|
10
13
|
"types": "./dist/index.d.ts",
|
|
11
14
|
"import": "./dist/index.js"
|
|
12
15
|
},
|
|
13
|
-
"./
|
|
14
|
-
"types": "./dist/
|
|
15
|
-
"import": "./dist/
|
|
16
|
-
},
|
|
17
|
-
"./metrics": {
|
|
18
|
-
"types": "./dist/metrics/index.d.ts",
|
|
19
|
-
"import": "./dist/metrics/index.js"
|
|
20
|
-
},
|
|
21
|
-
"./graph": {
|
|
22
|
-
"types": "./dist/graph/index.d.ts",
|
|
23
|
-
"import": "./dist/graph/index.js"
|
|
24
|
-
},
|
|
25
|
-
"./context": {
|
|
26
|
-
"types": "./dist/context/index.d.ts",
|
|
27
|
-
"import": "./dist/context/index.js"
|
|
28
|
-
},
|
|
29
|
-
"./canonical": {
|
|
30
|
-
"types": "./dist/canonical/index.d.ts",
|
|
31
|
-
"import": "./dist/canonical/index.js"
|
|
32
|
-
},
|
|
33
|
-
"./gates": {
|
|
34
|
-
"types": "./dist/gates/index.d.ts",
|
|
35
|
-
"import": "./dist/gates/index.js"
|
|
36
|
-
},
|
|
37
|
-
"./tensor": {
|
|
38
|
-
"types": "./dist/tensor/index.d.ts",
|
|
39
|
-
"import": "./dist/tensor/index.js"
|
|
16
|
+
"./mcp": {
|
|
17
|
+
"types": "./dist/mcp/index.d.ts",
|
|
18
|
+
"import": "./dist/mcp/index.js"
|
|
40
19
|
}
|
|
41
20
|
},
|
|
42
21
|
"files": [
|
|
@@ -45,39 +24,35 @@
|
|
|
45
24
|
"keywords": [
|
|
46
25
|
"complexity",
|
|
47
26
|
"cognitive-complexity",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
27
|
+
"static-analysis",
|
|
28
|
+
"code-quality",
|
|
29
|
+
"bread-cheese-ham",
|
|
30
|
+
"mcp"
|
|
52
31
|
],
|
|
32
|
+
"author": "yscha88",
|
|
53
33
|
"license": "MIT",
|
|
54
|
-
"publishConfig": {
|
|
55
|
-
"access": "public"
|
|
56
|
-
},
|
|
57
34
|
"repository": {
|
|
58
35
|
"type": "git",
|
|
59
|
-
"url": "
|
|
60
|
-
"directory": "
|
|
36
|
+
"url": "https://github.com/yscha88/semantic-complexity.git",
|
|
37
|
+
"directory": "src/ts"
|
|
61
38
|
},
|
|
62
|
-
"
|
|
63
|
-
"
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=18.0.0"
|
|
64
41
|
},
|
|
65
42
|
"devDependencies": {
|
|
66
|
-
"@
|
|
67
|
-
"
|
|
68
|
-
"
|
|
43
|
+
"@eslint/js": "^9.39.2",
|
|
44
|
+
"@types/node": "^22.0.0",
|
|
45
|
+
"eslint": "^9.39.2",
|
|
46
|
+
"typescript": "^5.7.2",
|
|
47
|
+
"typescript-eslint": "^8.50.0"
|
|
69
48
|
},
|
|
70
|
-
"
|
|
71
|
-
"
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@modelcontextprotocol/sdk": "^1.0.0"
|
|
72
51
|
},
|
|
73
52
|
"scripts": {
|
|
74
53
|
"build": "tsc",
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"lint": "eslint src",
|
|
79
|
-
"clean": "rimraf dist",
|
|
80
|
-
"compare": "tsx src/compare.ts",
|
|
81
|
-
"guide": "tsx src/compare.ts --guide"
|
|
54
|
+
"test": "node --test dist/**/*.test.js",
|
|
55
|
+
"lint": "eslint src/",
|
|
56
|
+
"clean": "rm -rf dist"
|
|
82
57
|
}
|
|
83
58
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 차요셉
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# semantic-complexity
|
|
2
|
-
|
|
3
|
-
Multi-dimensional code complexity analyzer using algebraic topology and tensor analysis.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install semantic-complexity
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Quick Start
|
|
12
|
-
|
|
13
|
-
```typescript
|
|
14
|
-
import { analyzeSource, calculateTensorScore } from 'semantic-complexity';
|
|
15
|
-
|
|
16
|
-
const source = `
|
|
17
|
-
function example(data) {
|
|
18
|
-
if (data) {
|
|
19
|
-
for (const item of data) {
|
|
20
|
-
console.log(item);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
`;
|
|
25
|
-
|
|
26
|
-
const result = analyzeSource(source);
|
|
27
|
-
console.log(result.functions[0].complexity);
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Features
|
|
31
|
-
|
|
32
|
-
- **Multi-Domain Complexity**: Control, Nesting, State, Async, Coupling
|
|
33
|
-
- **2nd-Order Tensor Scoring**: `score = vᵀMv + ⟨v,w⟩ + ε‖v‖²`
|
|
34
|
-
- **8 Module Types**: api, lib, app, web, data, infra, deploy, unknown
|
|
35
|
-
- **CDR-Inspired Dual Metrics**: Tensor Score + Raw Sum
|
|
36
|
-
|
|
37
|
-
## API
|
|
38
|
-
|
|
39
|
-
### Core Functions
|
|
40
|
-
|
|
41
|
-
```typescript
|
|
42
|
-
// Analyze source code
|
|
43
|
-
analyzeSource(source: string, fileName?: string): FileAnalysisResult
|
|
44
|
-
|
|
45
|
-
// Analyze file path
|
|
46
|
-
analyzeFilePath(filePath: string): FileAnalysisResult
|
|
47
|
-
|
|
48
|
-
// Calculate tensor score
|
|
49
|
-
calculateTensorScore(result: ExtendedComplexityResult, moduleType?: ModuleType): TensorScore
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Tensor Score
|
|
53
|
-
|
|
54
|
-
```typescript
|
|
55
|
-
interface TensorScore {
|
|
56
|
-
linear: number; // ⟨v,w⟩
|
|
57
|
-
quadratic: number; // vᵀMv
|
|
58
|
-
raw: number; // linear + quadratic
|
|
59
|
-
regularized: number; // raw + ε‖v‖²
|
|
60
|
-
rawSum: number; // C + N + S + A + Λ
|
|
61
|
-
rawSumThreshold: number;
|
|
62
|
-
rawSumRatio: number;
|
|
63
|
-
}
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Documentation
|
|
67
|
-
|
|
68
|
-
Full documentation: [GitHub Repository](https://github.com/yscha88/semantic-complexity)
|
|
69
|
-
|
|
70
|
-
## License
|
|
71
|
-
|
|
72
|
-
MIT
|
package/dist/ast/index.d.ts
DELETED
package/dist/ast/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,cAAc,GACf,MAAM,aAAa,CAAC"}
|
package/dist/ast/index.js
DELETED
package/dist/ast/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,cAAc,GACf,MAAM,aAAa,CAAC"}
|
package/dist/ast/parser.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
|
-
import type { FunctionInfo, SourceLocation, ImportInfo, ExportInfo } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* 소스 파일을 파싱하여 AST를 생성
|
|
5
|
-
*/
|
|
6
|
-
export declare function parseSourceFile(filePath: string, content: string): ts.SourceFile;
|
|
7
|
-
/**
|
|
8
|
-
* AST 노드에서 소스 위치 정보 추출
|
|
9
|
-
*/
|
|
10
|
-
export declare function getSourceLocation(node: ts.Node, sourceFile: ts.SourceFile): SourceLocation;
|
|
11
|
-
/**
|
|
12
|
-
* 함수 노드에서 함수 정보 추출
|
|
13
|
-
*/
|
|
14
|
-
export declare function extractFunctionInfo(node: ts.Node, sourceFile: ts.SourceFile, className?: string): FunctionInfo | null;
|
|
15
|
-
/**
|
|
16
|
-
* 모든 함수 노드 추출
|
|
17
|
-
*/
|
|
18
|
-
export declare function extractAllFunctions(sourceFile: ts.SourceFile): FunctionInfo[];
|
|
19
|
-
/**
|
|
20
|
-
* Import 정보 추출
|
|
21
|
-
*/
|
|
22
|
-
export declare function extractImports(sourceFile: ts.SourceFile): ImportInfo[];
|
|
23
|
-
/**
|
|
24
|
-
* Export 정보 추출
|
|
25
|
-
*/
|
|
26
|
-
export declare function extractExports(sourceFile: ts.SourceFile): ExportInfo[];
|
|
27
|
-
//# sourceMappingURL=parser.d.ts.map
|
package/dist/ast/parser.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/ast/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EAEd,UAAU,EAEV,UAAU,EACX,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,EAAE,CAAC,UAAU,CAUf;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,UAAU,EAAE,EAAE,CAAC,UAAU,GACxB,cAAc,CAWhB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,SAAS,CAAC,EAAE,MAAM,GACjB,YAAY,GAAG,IAAI,CA4FrB;AA0BD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,YAAY,EAAE,CAuB7E;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,UAAU,EAAE,CAkDtE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,UAAU,EAAE,CAgEtE"}
|