semantic-complexity 0.0.6-dd9be98d → 0.0.13-2aaf183b
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 +54 -0
- package/dist/gate/waiver.d.ts.map +1 -0
- package/dist/gate/waiver.js +280 -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 +140 -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,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;AAE/B,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EACV,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAM7B,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,OAAO,uBAAuB,EAAE,WAAW,CAAC;IACnD,MAAM,EAAE,OAAO,wBAAwB,EAAE,YAAY,CAAC;IACtD,GAAG,EAAE,OAAO,qBAAqB,EAAE,SAAS,CAAC;IAC7C,OAAO,EAAE,kBAAkB,CAAC;IAC5B,WAAW,EAAE,iBAAiB,CAAC;CAChC;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,IAAI,CAAC;CACjD;AAMD,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,YAAY,CAAC;AAEpD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD,MAAM,MAAM,UAAU,GAClB,cAAc,GACd,cAAc,GACd,YAAY,GACZ,UAAU,GACV,KAAK,CAAC;AAMV,YAAY,EACV,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.13-2aaf183b",
|
|
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"}
|
package/dist/ast/parser.js
DELETED
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
|
-
/**
|
|
3
|
-
* 소스 파일을 파싱하여 AST를 생성
|
|
4
|
-
*/
|
|
5
|
-
export function parseSourceFile(filePath, content) {
|
|
6
|
-
return ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true, filePath.endsWith('.tsx') || filePath.endsWith('.jsx')
|
|
7
|
-
? ts.ScriptKind.TSX
|
|
8
|
-
: ts.ScriptKind.TS);
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* AST 노드에서 소스 위치 정보 추출
|
|
12
|
-
*/
|
|
13
|
-
export function getSourceLocation(node, sourceFile) {
|
|
14
|
-
const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
15
|
-
const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());
|
|
16
|
-
return {
|
|
17
|
-
filePath: sourceFile.fileName,
|
|
18
|
-
startLine: start.line + 1,
|
|
19
|
-
startColumn: start.character + 1,
|
|
20
|
-
endLine: end.line + 1,
|
|
21
|
-
endColumn: end.character + 1,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* 함수 노드에서 함수 정보 추출
|
|
26
|
-
*/
|
|
27
|
-
export function extractFunctionInfo(node, sourceFile, className) {
|
|
28
|
-
if (ts.isFunctionDeclaration(node)) {
|
|
29
|
-
return {
|
|
30
|
-
name: node.name?.getText(sourceFile) ?? '<anonymous>',
|
|
31
|
-
kind: 'function',
|
|
32
|
-
location: getSourceLocation(node, sourceFile),
|
|
33
|
-
isAsync: hasModifier(node, ts.SyntaxKind.AsyncKeyword),
|
|
34
|
-
isGenerator: !!node.asteriskToken,
|
|
35
|
-
isExported: hasModifier(node, ts.SyntaxKind.ExportKeyword),
|
|
36
|
-
parameters: extractParameters(node.parameters, sourceFile),
|
|
37
|
-
returnType: node.type?.getText(sourceFile),
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
if (ts.isMethodDeclaration(node)) {
|
|
41
|
-
return {
|
|
42
|
-
name: node.name.getText(sourceFile),
|
|
43
|
-
kind: 'method',
|
|
44
|
-
location: getSourceLocation(node, sourceFile),
|
|
45
|
-
isAsync: hasModifier(node, ts.SyntaxKind.AsyncKeyword),
|
|
46
|
-
isGenerator: !!node.asteriskToken,
|
|
47
|
-
isExported: false,
|
|
48
|
-
parameters: extractParameters(node.parameters, sourceFile),
|
|
49
|
-
returnType: node.type?.getText(sourceFile),
|
|
50
|
-
className,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {
|
|
54
|
-
const parent = node.parent;
|
|
55
|
-
let name = '<anonymous>';
|
|
56
|
-
if (ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name)) {
|
|
57
|
-
name = parent.name.getText(sourceFile);
|
|
58
|
-
}
|
|
59
|
-
else if (ts.isPropertyAssignment(parent)) {
|
|
60
|
-
name = parent.name.getText(sourceFile);
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
name,
|
|
64
|
-
kind: 'arrow',
|
|
65
|
-
location: getSourceLocation(node, sourceFile),
|
|
66
|
-
isAsync: hasModifier(node, ts.SyntaxKind.AsyncKeyword),
|
|
67
|
-
isGenerator: ts.isFunctionExpression(node) && !!node.asteriskToken,
|
|
68
|
-
isExported: false,
|
|
69
|
-
parameters: extractParameters(node.parameters, sourceFile),
|
|
70
|
-
returnType: node.type?.getText(sourceFile),
|
|
71
|
-
className,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
if (ts.isGetAccessor(node)) {
|
|
75
|
-
return {
|
|
76
|
-
name: node.name.getText(sourceFile),
|
|
77
|
-
kind: 'getter',
|
|
78
|
-
location: getSourceLocation(node, sourceFile),
|
|
79
|
-
isAsync: false,
|
|
80
|
-
isGenerator: false,
|
|
81
|
-
isExported: false,
|
|
82
|
-
parameters: [],
|
|
83
|
-
returnType: node.type?.getText(sourceFile),
|
|
84
|
-
className,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
if (ts.isSetAccessor(node)) {
|
|
88
|
-
return {
|
|
89
|
-
name: node.name.getText(sourceFile),
|
|
90
|
-
kind: 'setter',
|
|
91
|
-
location: getSourceLocation(node, sourceFile),
|
|
92
|
-
isAsync: false,
|
|
93
|
-
isGenerator: false,
|
|
94
|
-
isExported: false,
|
|
95
|
-
parameters: extractParameters(node.parameters, sourceFile),
|
|
96
|
-
className,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
if (ts.isConstructorDeclaration(node)) {
|
|
100
|
-
return {
|
|
101
|
-
name: 'constructor',
|
|
102
|
-
kind: 'constructor',
|
|
103
|
-
location: getSourceLocation(node, sourceFile),
|
|
104
|
-
isAsync: false,
|
|
105
|
-
isGenerator: false,
|
|
106
|
-
isExported: false,
|
|
107
|
-
parameters: extractParameters(node.parameters, sourceFile),
|
|
108
|
-
className,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* 파라미터 정보 추출
|
|
115
|
-
*/
|
|
116
|
-
function extractParameters(params, sourceFile) {
|
|
117
|
-
return params.map((param) => ({
|
|
118
|
-
name: param.name.getText(sourceFile),
|
|
119
|
-
type: param.type?.getText(sourceFile),
|
|
120
|
-
isOptional: !!param.questionToken,
|
|
121
|
-
isRest: !!param.dotDotDotToken,
|
|
122
|
-
hasDefault: !!param.initializer,
|
|
123
|
-
}));
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* 모디파이어 확인
|
|
127
|
-
*/
|
|
128
|
-
function hasModifier(node, kind) {
|
|
129
|
-
const modifiers = ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined;
|
|
130
|
-
return modifiers?.some((mod) => mod.kind === kind) ?? false;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* 모든 함수 노드 추출
|
|
134
|
-
*/
|
|
135
|
-
export function extractAllFunctions(sourceFile) {
|
|
136
|
-
const functions = [];
|
|
137
|
-
function visit(node, className) {
|
|
138
|
-
// 클래스 내부 순회
|
|
139
|
-
if (ts.isClassDeclaration(node) || ts.isClassExpression(node)) {
|
|
140
|
-
const name = node.name?.getText(sourceFile) ?? '<anonymous>';
|
|
141
|
-
node.members.forEach((member) => visit(member, name));
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
// 함수 정보 추출
|
|
145
|
-
const funcInfo = extractFunctionInfo(node, sourceFile, className);
|
|
146
|
-
if (funcInfo) {
|
|
147
|
-
functions.push(funcInfo);
|
|
148
|
-
}
|
|
149
|
-
// 자식 노드 순회 (함수 내부의 중첩 함수도 추출)
|
|
150
|
-
ts.forEachChild(node, (child) => visit(child, className));
|
|
151
|
-
}
|
|
152
|
-
visit(sourceFile);
|
|
153
|
-
return functions;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Import 정보 추출
|
|
157
|
-
*/
|
|
158
|
-
export function extractImports(sourceFile) {
|
|
159
|
-
const imports = [];
|
|
160
|
-
ts.forEachChild(sourceFile, (node) => {
|
|
161
|
-
if (ts.isImportDeclaration(node)) {
|
|
162
|
-
const specifiers = [];
|
|
163
|
-
const clause = node.importClause;
|
|
164
|
-
if (clause) {
|
|
165
|
-
// default import
|
|
166
|
-
if (clause.name) {
|
|
167
|
-
specifiers.push({
|
|
168
|
-
name: clause.name.getText(sourceFile),
|
|
169
|
-
isDefault: true,
|
|
170
|
-
isNamespace: false,
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
// named imports or namespace import
|
|
174
|
-
const bindings = clause.namedBindings;
|
|
175
|
-
if (bindings) {
|
|
176
|
-
if (ts.isNamespaceImport(bindings)) {
|
|
177
|
-
specifiers.push({
|
|
178
|
-
name: bindings.name.getText(sourceFile),
|
|
179
|
-
isDefault: false,
|
|
180
|
-
isNamespace: true,
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
else if (ts.isNamedImports(bindings)) {
|
|
184
|
-
bindings.elements.forEach((element) => {
|
|
185
|
-
specifiers.push({
|
|
186
|
-
name: element.name.getText(sourceFile),
|
|
187
|
-
alias: element.propertyName?.getText(sourceFile),
|
|
188
|
-
isDefault: false,
|
|
189
|
-
isNamespace: false,
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
imports.push({
|
|
196
|
-
source: node.moduleSpecifier.text,
|
|
197
|
-
specifiers,
|
|
198
|
-
isTypeOnly: !!clause?.isTypeOnly,
|
|
199
|
-
location: getSourceLocation(node, sourceFile),
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
return imports;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Export 정보 추출
|
|
207
|
-
*/
|
|
208
|
-
export function extractExports(sourceFile) {
|
|
209
|
-
const exports = [];
|
|
210
|
-
ts.forEachChild(sourceFile, (node) => {
|
|
211
|
-
// export declaration (re-export)
|
|
212
|
-
if (ts.isExportDeclaration(node)) {
|
|
213
|
-
if (node.exportClause && ts.isNamedExports(node.exportClause)) {
|
|
214
|
-
node.exportClause.elements.forEach((element) => {
|
|
215
|
-
exports.push({
|
|
216
|
-
name: element.name.getText(sourceFile),
|
|
217
|
-
kind: 're-export',
|
|
218
|
-
location: getSourceLocation(element, sourceFile),
|
|
219
|
-
source: node.moduleSpecifier
|
|
220
|
-
? node.moduleSpecifier.text
|
|
221
|
-
: undefined,
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
// exported declarations
|
|
228
|
-
if (!hasModifier(node, ts.SyntaxKind.ExportKeyword)) {
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
if (ts.isFunctionDeclaration(node) && node.name) {
|
|
232
|
-
exports.push({
|
|
233
|
-
name: node.name.getText(sourceFile),
|
|
234
|
-
kind: 'function',
|
|
235
|
-
location: getSourceLocation(node, sourceFile),
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
else if (ts.isClassDeclaration(node) && node.name) {
|
|
239
|
-
exports.push({
|
|
240
|
-
name: node.name.getText(sourceFile),
|
|
241
|
-
kind: 'class',
|
|
242
|
-
location: getSourceLocation(node, sourceFile),
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
else if (ts.isVariableStatement(node)) {
|
|
246
|
-
node.declarationList.declarations.forEach((decl) => {
|
|
247
|
-
if (ts.isIdentifier(decl.name)) {
|
|
248
|
-
exports.push({
|
|
249
|
-
name: decl.name.getText(sourceFile),
|
|
250
|
-
kind: 'variable',
|
|
251
|
-
location: getSourceLocation(decl, sourceFile),
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
else if (ts.isInterfaceDeclaration(node)) {
|
|
257
|
-
exports.push({
|
|
258
|
-
name: node.name.getText(sourceFile),
|
|
259
|
-
kind: 'interface',
|
|
260
|
-
location: getSourceLocation(node, sourceFile),
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
else if (ts.isTypeAliasDeclaration(node)) {
|
|
264
|
-
exports.push({
|
|
265
|
-
name: node.name.getText(sourceFile),
|
|
266
|
-
kind: 'type',
|
|
267
|
-
location: getSourceLocation(node, sourceFile),
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
return exports;
|
|
272
|
-
}
|
|
273
|
-
//# sourceMappingURL=parser.js.map
|
package/dist/ast/parser.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/ast/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAU5B;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAgB,EAChB,OAAe;IAEf,OAAO,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I,CAAC;gBACX,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;gBACnC,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,iBAAiB,CAAC,IAAI,EAAE,UAAU,CAAC;aAC9C,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 수렴 분석기 (Convergence Analyzer)
|
|
3
|
-
*
|
|
4
|
-
* 현재 상태에서 정준 상태로의 거리 및 방향을 계산
|
|
5
|
-
*
|
|
6
|
-
* NP-hard가 P로 환원되는 이유:
|
|
7
|
-
* - 모든 가능한 구조를 탐색하지 않음
|
|
8
|
-
* - 타입별 정준형으로의 거리만 측정
|
|
9
|
-
* - 거리 측정: O(n)
|
|
10
|
-
*/
|
|
11
|
-
import type { ModuleType, MetaDimensions, ConvergenceResult, Deviation, Vector3D } from './types.js';
|
|
12
|
-
/**
|
|
13
|
-
* 편차 계산
|
|
14
|
-
*/
|
|
15
|
-
export declare function calculateDeviation(current: MetaDimensions, ideal: MetaDimensions): Deviation;
|
|
16
|
-
/**
|
|
17
|
-
* 수렴 벡터 계산 (정준 상태로의 방향)
|
|
18
|
-
*/
|
|
19
|
-
export declare function calculateConvergenceVector(current: MetaDimensions, ideal: MetaDimensions): Vector3D;
|
|
20
|
-
/**
|
|
21
|
-
* 수렴률 계산 (0-1, 1이면 완전 정준)
|
|
22
|
-
*/
|
|
23
|
-
export declare function calculateConvergenceRate(deviation: Deviation, maxDeviation?: number): number;
|
|
24
|
-
/**
|
|
25
|
-
* 수렴 분석 수행
|
|
26
|
-
*/
|
|
27
|
-
export declare function analyzeConvergence(moduleType: ModuleType, currentMeta: MetaDimensions): ConvergenceResult;
|
|
28
|
-
/**
|
|
29
|
-
* 모든 모듈 타입에 대해 수렴 분석
|
|
30
|
-
* 가장 적합한 모듈 타입 추천에 활용
|
|
31
|
-
*/
|
|
32
|
-
export declare function analyzeAllModuleTypes(currentMeta: MetaDimensions): ConvergenceResult[];
|
|
33
|
-
/**
|
|
34
|
-
* 가장 가까운 정준 상태를 가진 모듈 타입 반환
|
|
35
|
-
*/
|
|
36
|
-
export declare function findBestFitModuleType(currentMeta: MetaDimensions): ConvergenceResult;
|
|
37
|
-
/**
|
|
38
|
-
* 수렴 상태 해석
|
|
39
|
-
*/
|
|
40
|
-
export type ConvergenceStatus = 'canonical' | 'near-canonical' | 'drifting' | 'divergent';
|
|
41
|
-
/**
|
|
42
|
-
* 수렴 상태 판정
|
|
43
|
-
*/
|
|
44
|
-
export declare function getConvergenceStatus(result: ConvergenceResult): ConvergenceStatus;
|
|
45
|
-
/**
|
|
46
|
-
* 개선 제안 생성
|
|
47
|
-
*/
|
|
48
|
-
export interface ConvergenceAdvice {
|
|
49
|
-
dimension: 'security' | 'context' | 'behavior';
|
|
50
|
-
currentValue: number;
|
|
51
|
-
idealValue: number;
|
|
52
|
-
deviation: number;
|
|
53
|
-
suggestion: string;
|
|
54
|
-
}
|
|
55
|
-
export declare function generateConvergenceAdvice(result: ConvergenceResult): ConvergenceAdvice[];
|
|
56
|
-
//# sourceMappingURL=convergence.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convergence.d.ts","sourceRoot":"","sources":["../../src/canonical/convergence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,SAAS,EACT,QAAQ,EACT,MAAM,YAAY,CAAC;AAYpB;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,cAAc,GACpB,SAAS,CAWX;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,cAAc,GACpB,QAAQ,CAkBV;AAED;;GAEG;AACH,wBAAgB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