@aiready/change-amplification 0.14.8 → 0.14.11

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.
@@ -1,128 +0,0 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
- // src/analyzer.ts
9
- import * as fs from "fs";
10
- import * as path from "path";
11
- import {
12
- scanFiles,
13
- calculateChangeAmplification,
14
- getParser,
15
- Severity,
16
- IssueType
17
- } from "@aiready/core";
18
- async function analyzeChangeAmplification(options) {
19
- const files = await scanFiles({
20
- ...options,
21
- include: options.include || ["**/*.{ts,tsx,js,jsx,py,go}"]
22
- });
23
- const dependencyGraph = /* @__PURE__ */ new Map();
24
- const reverseGraph = /* @__PURE__ */ new Map();
25
- for (const file of files) {
26
- dependencyGraph.set(file, []);
27
- reverseGraph.set(file, []);
28
- }
29
- let processed = 0;
30
- for (const file of files) {
31
- processed++;
32
- options.onProgress?.(
33
- processed,
34
- files.length,
35
- `change-amplification: analyzing files`
36
- );
37
- try {
38
- const parser = getParser(file);
39
- if (!parser) continue;
40
- const content = fs.readFileSync(file, "utf8");
41
- const parseResult = parser.parse(content, file);
42
- const dependencies = parseResult.imports.map((i) => i.source);
43
- for (const dep of dependencies) {
44
- const depDir = path.dirname(file);
45
- const resolvedPath = files.find((f) => {
46
- if (dep.startsWith(".")) {
47
- return f.startsWith(path.resolve(depDir, dep));
48
- } else {
49
- return f.includes(dep);
50
- }
51
- });
52
- if (resolvedPath) {
53
- dependencyGraph.get(file)?.push(resolvedPath);
54
- reverseGraph.get(resolvedPath)?.push(file);
55
- }
56
- }
57
- } catch (err) {
58
- void err;
59
- }
60
- }
61
- const fileMetrics = files.map((file) => {
62
- const fanOut = dependencyGraph.get(file)?.length || 0;
63
- const fanIn = reverseGraph.get(file)?.length || 0;
64
- return { file, fanOut, fanIn };
65
- });
66
- const riskResult = calculateChangeAmplification({ files: fileMetrics });
67
- const results = [];
68
- const getLevel = (s) => {
69
- const map = {
70
- [Severity.Critical]: 4,
71
- [Severity.Major]: 3,
72
- [Severity.Minor]: 2,
73
- [Severity.Info]: 1,
74
- critical: 4,
75
- major: 3,
76
- minor: 2,
77
- info: 1
78
- };
79
- if (map[s] !== void 0) return map[s];
80
- const lower = String(s).toLowerCase();
81
- return map[lower] ?? 0;
82
- };
83
- for (const hotspot of riskResult.hotspots) {
84
- const issues = [];
85
- if (hotspot.amplificationFactor > 20) {
86
- issues.push({
87
- type: IssueType.ChangeAmplification,
88
- severity: hotspot.amplificationFactor > 40 ? Severity.Critical : Severity.Major,
89
- message: `High change amplification detected (Factor: ${hotspot.amplificationFactor}). Changes here cascade heavily.`,
90
- location: { file: hotspot.file, line: 1 },
91
- suggestion: `Reduce coupling. Fan-out is ${hotspot.fanOut}, Fan-in is ${hotspot.fanIn}.`
92
- });
93
- }
94
- if (hotspot.amplificationFactor > 5) {
95
- results.push({
96
- fileName: hotspot.file,
97
- issues,
98
- metrics: {
99
- aiSignalClarityScore: 100 - hotspot.amplificationFactor
100
- // Just a rough score
101
- }
102
- });
103
- }
104
- }
105
- return {
106
- summary: {
107
- totalFiles: files.length,
108
- totalIssues: results.reduce((sum, r) => sum + r.issues.length, 0),
109
- criticalIssues: results.reduce(
110
- (sum, r) => sum + r.issues.filter((i) => getLevel(i.severity) === 4).length,
111
- 0
112
- ),
113
- majorIssues: results.reduce(
114
- (sum, r) => sum + r.issues.filter((i) => getLevel(i.severity) === 3).length,
115
- 0
116
- ),
117
- score: riskResult.score,
118
- rating: riskResult.rating,
119
- recommendations: riskResult.recommendations
120
- },
121
- results
122
- };
123
- }
124
-
125
- export {
126
- __require,
127
- analyzeChangeAmplification
128
- };
@@ -1,114 +0,0 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
- // src/analyzer.ts
9
- import * as fs from "fs";
10
- import * as path from "path";
11
- import { globSync } from "glob";
12
- import { calculateChangeAmplification } from "@aiready/core";
13
- import { getParser } from "@aiready/core";
14
- function collectFiles(dir, options) {
15
- const includePatterns = options.include && options.include.length > 0 ? options.include : ["**/*.{ts,tsx,js,jsx,py,go}"];
16
- const excludePatterns = options.exclude && options.exclude.length > 0 ? options.exclude : ["**/node_modules/**", "**/dist/**", "**/.git/**"];
17
- let matchedFiles = [];
18
- for (const pattern of includePatterns) {
19
- const files = globSync(pattern, {
20
- cwd: dir,
21
- ignore: excludePatterns,
22
- absolute: true
23
- });
24
- matchedFiles = matchedFiles.concat(files);
25
- }
26
- return [...new Set(matchedFiles)];
27
- }
28
- async function analyzeChangeAmplification(options) {
29
- const rootDir = path.resolve(options.rootDir || ".");
30
- const files = collectFiles(rootDir, options);
31
- const dependencyGraph = /* @__PURE__ */ new Map();
32
- const reverseGraph = /* @__PURE__ */ new Map();
33
- for (const file of files) {
34
- dependencyGraph.set(file, []);
35
- reverseGraph.set(file, []);
36
- }
37
- for (const file of files) {
38
- try {
39
- const parser = getParser(file);
40
- if (!parser) continue;
41
- const content = fs.readFileSync(file, "utf8");
42
- const parseResult = parser.parse(content, file);
43
- const dependencies = parseResult.imports.map((i) => i.source);
44
- for (const dep of dependencies) {
45
- const depDir = path.dirname(file);
46
- const resolvedPath = files.find((f) => {
47
- if (dep.startsWith(".")) {
48
- return f.startsWith(path.resolve(depDir, dep));
49
- } else {
50
- return f.includes(dep);
51
- }
52
- });
53
- if (resolvedPath) {
54
- dependencyGraph.get(file)?.push(resolvedPath);
55
- reverseGraph.get(resolvedPath)?.push(file);
56
- }
57
- }
58
- } catch (err) {
59
- void err;
60
- }
61
- }
62
- const fileMetrics = files.map((file) => {
63
- const fanOut = dependencyGraph.get(file)?.length || 0;
64
- const fanIn = reverseGraph.get(file)?.length || 0;
65
- return { file, fanOut, fanIn };
66
- });
67
- const riskResult = calculateChangeAmplification({ files: fileMetrics });
68
- const results = [];
69
- for (const hotspot of riskResult.hotspots) {
70
- const issues = [];
71
- if (hotspot.amplificationFactor > 20) {
72
- issues.push({
73
- type: "change-amplification",
74
- severity: hotspot.amplificationFactor > 40 ? "critical" : "major",
75
- message: `High change amplification detected (Factor: ${hotspot.amplificationFactor}). Changes here cascade heavily.`,
76
- location: { file: hotspot.file, line: 1 },
77
- suggestion: `Reduce coupling. Fan-out is ${hotspot.fanOut}, Fan-in is ${hotspot.fanIn}.`
78
- });
79
- }
80
- if (hotspot.amplificationFactor > 5) {
81
- results.push({
82
- fileName: hotspot.file,
83
- issues,
84
- metrics: {
85
- aiSignalClarityScore: 100 - hotspot.amplificationFactor
86
- // Just a rough score
87
- }
88
- });
89
- }
90
- }
91
- return {
92
- summary: {
93
- totalFiles: files.length,
94
- totalIssues: results.reduce((sum, r) => sum + r.issues.length, 0),
95
- criticalIssues: results.reduce(
96
- (sum, r) => sum + r.issues.filter((i) => i.severity === "critical").length,
97
- 0
98
- ),
99
- majorIssues: results.reduce(
100
- (sum, r) => sum + r.issues.filter((i) => i.severity === "major").length,
101
- 0
102
- ),
103
- score: riskResult.score,
104
- rating: riskResult.rating,
105
- recommendations: riskResult.recommendations
106
- },
107
- results
108
- };
109
- }
110
-
111
- export {
112
- __require,
113
- analyzeChangeAmplification
114
- };
@@ -1,100 +0,0 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
- // src/analyzer.ts
9
- import * as fs from "fs";
10
- import * as path from "path";
11
- import { globSync } from "glob";
12
- import { calculateChangeAmplification } from "@aiready/core";
13
- import { parseDependencies } from "@aiready/core";
14
- function collectFiles(dir, options) {
15
- const includePatterns = options.include && options.include.length > 0 ? options.include : ["**/*.{ts,tsx,js,jsx,py,go}"];
16
- const excludePatterns = options.exclude && options.exclude.length > 0 ? options.exclude : ["**/node_modules/**", "**/dist/**", "**/.git/**"];
17
- let matchedFiles = [];
18
- for (const pattern of includePatterns) {
19
- const files = globSync(pattern, { cwd: dir, ignore: excludePatterns, absolute: true });
20
- matchedFiles = matchedFiles.concat(files);
21
- }
22
- return [...new Set(matchedFiles)];
23
- }
24
- async function analyzeChangeAmplification(options) {
25
- const rootDir = path.resolve(options.rootDir || ".");
26
- const files = collectFiles(rootDir, options);
27
- const dependencyGraph = /* @__PURE__ */ new Map();
28
- const reverseGraph = /* @__PURE__ */ new Map();
29
- for (const file of files) {
30
- dependencyGraph.set(file, []);
31
- reverseGraph.set(file, []);
32
- }
33
- for (const file of files) {
34
- try {
35
- const content = fs.readFileSync(file, "utf8");
36
- const dependencies = parseDependencies(content);
37
- for (const dep of dependencies) {
38
- const depDir = path.dirname(file);
39
- const resolvedPath = files.find((f) => {
40
- if (dep.startsWith(".")) {
41
- return f.startsWith(path.resolve(depDir, dep));
42
- } else {
43
- return f.includes(dep);
44
- }
45
- });
46
- if (resolvedPath) {
47
- dependencyGraph.get(file)?.push(resolvedPath);
48
- reverseGraph.get(resolvedPath)?.push(file);
49
- }
50
- }
51
- } catch (err) {
52
- }
53
- }
54
- const fileMetrics = files.map((file) => {
55
- const fanOut = dependencyGraph.get(file)?.length || 0;
56
- const fanIn = reverseGraph.get(file)?.length || 0;
57
- return { file, fanOut, fanIn };
58
- });
59
- const riskResult = calculateChangeAmplification({ files: fileMetrics });
60
- const results = [];
61
- for (const hotspot of riskResult.hotspots) {
62
- const issues = [];
63
- if (hotspot.amplificationFactor > 20) {
64
- issues.push({
65
- type: "change-amplification",
66
- severity: hotspot.amplificationFactor > 40 ? "critical" : "major",
67
- message: `High change amplification detected (Factor: ${hotspot.amplificationFactor}). Changes here cascade heavily.`,
68
- location: { file: hotspot.file, line: 1 },
69
- suggestion: `Reduce coupling. Fan-out is ${hotspot.fanOut}, Fan-in is ${hotspot.fanIn}.`
70
- });
71
- }
72
- if (hotspot.amplificationFactor > 5) {
73
- results.push({
74
- fileName: hotspot.file,
75
- issues,
76
- metrics: {
77
- aiSignalClarityScore: 100 - hotspot.amplificationFactor
78
- // Just a rough score
79
- }
80
- });
81
- }
82
- }
83
- return {
84
- summary: {
85
- totalFiles: files.length,
86
- totalIssues: results.reduce((sum, r) => sum + r.issues.length, 0),
87
- criticalIssues: results.reduce((sum, r) => sum + r.issues.filter((i) => i.severity === "critical").length, 0),
88
- majorIssues: results.reduce((sum, r) => sum + r.issues.filter((i) => i.severity === "major").length, 0),
89
- score: riskResult.score,
90
- rating: riskResult.rating,
91
- recommendations: riskResult.recommendations
92
- },
93
- results
94
- };
95
- }
96
-
97
- export {
98
- __require,
99
- analyzeChangeAmplification
100
- };
@@ -1,120 +0,0 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
- // src/analyzer.ts
9
- import * as fs from "fs";
10
- import * as path from "path";
11
- import {
12
- scanFiles,
13
- calculateChangeAmplification,
14
- getParser,
15
- Severity,
16
- IssueType
17
- } from "@aiready/core";
18
- async function analyzeChangeAmplification(options) {
19
- const files = await scanFiles({
20
- ...options,
21
- include: options.include || ["**/*.{ts,tsx,js,jsx,py,go}"]
22
- });
23
- const dependencyGraph = /* @__PURE__ */ new Map();
24
- const reverseGraph = /* @__PURE__ */ new Map();
25
- for (const file of files) {
26
- dependencyGraph.set(file, []);
27
- reverseGraph.set(file, []);
28
- }
29
- let processed = 0;
30
- for (const file of files) {
31
- processed++;
32
- options.onProgress?.(
33
- processed,
34
- files.length,
35
- `change-amplification: analyzing files`
36
- );
37
- try {
38
- const parser = getParser(file);
39
- if (!parser) continue;
40
- const content = fs.readFileSync(file, "utf8");
41
- const parseResult = parser.parse(content, file);
42
- const dependencies = parseResult.imports.map((i) => i.source);
43
- for (const dep of dependencies) {
44
- const depDir = path.dirname(file);
45
- const resolvedPath = files.find((f) => {
46
- if (dep.startsWith(".")) {
47
- return f.startsWith(path.resolve(depDir, dep));
48
- } else {
49
- return f.includes(dep);
50
- }
51
- });
52
- if (resolvedPath) {
53
- dependencyGraph.get(file)?.push(resolvedPath);
54
- reverseGraph.get(resolvedPath)?.push(file);
55
- }
56
- }
57
- } catch (err) {
58
- void err;
59
- }
60
- }
61
- const fileMetrics = files.map((file) => {
62
- const fanOut = dependencyGraph.get(file)?.length || 0;
63
- const fanIn = reverseGraph.get(file)?.length || 0;
64
- return { file, fanOut, fanIn };
65
- });
66
- const riskResult = calculateChangeAmplification({ files: fileMetrics });
67
- const results = [];
68
- const getLevel = (s) => {
69
- if (s === Severity.Critical || s === "critical") return 4;
70
- if (s === Severity.Major || s === "major") return 3;
71
- if (s === Severity.Minor || s === "minor") return 2;
72
- if (s === Severity.Info || s === "info") return 1;
73
- return 0;
74
- };
75
- for (const hotspot of riskResult.hotspots) {
76
- const issues = [];
77
- if (hotspot.amplificationFactor > 20) {
78
- issues.push({
79
- type: IssueType.ChangeAmplification,
80
- severity: hotspot.amplificationFactor > 40 ? Severity.Critical : Severity.Major,
81
- message: `High change amplification detected (Factor: ${hotspot.amplificationFactor}). Changes here cascade heavily.`,
82
- location: { file: hotspot.file, line: 1 },
83
- suggestion: `Reduce coupling. Fan-out is ${hotspot.fanOut}, Fan-in is ${hotspot.fanIn}.`
84
- });
85
- }
86
- if (hotspot.amplificationFactor > 5) {
87
- results.push({
88
- fileName: hotspot.file,
89
- issues,
90
- metrics: {
91
- aiSignalClarityScore: 100 - hotspot.amplificationFactor
92
- // Just a rough score
93
- }
94
- });
95
- }
96
- }
97
- return {
98
- summary: {
99
- totalFiles: files.length,
100
- totalIssues: results.reduce((sum, r) => sum + r.issues.length, 0),
101
- criticalIssues: results.reduce(
102
- (sum, r) => sum + r.issues.filter((i) => getLevel(i.severity) === 4).length,
103
- 0
104
- ),
105
- majorIssues: results.reduce(
106
- (sum, r) => sum + r.issues.filter((i) => getLevel(i.severity) === 3).length,
107
- 0
108
- ),
109
- score: riskResult.score,
110
- rating: riskResult.rating,
111
- recommendations: riskResult.recommendations
112
- },
113
- results
114
- };
115
- }
116
-
117
- export {
118
- __require,
119
- analyzeChangeAmplification
120
- };
@@ -1,112 +0,0 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
- // src/analyzer.ts
9
- import * as fs from "fs";
10
- import * as path from "path";
11
- import {
12
- scanFiles,
13
- calculateChangeAmplification,
14
- getParser
15
- } from "@aiready/core";
16
- async function analyzeChangeAmplification(options) {
17
- const rootDir = path.resolve(options.rootDir || ".");
18
- const files = await scanFiles({
19
- ...options,
20
- include: options.include || ["**/*.{ts,tsx,js,jsx,py,go}"]
21
- });
22
- const dependencyGraph = /* @__PURE__ */ new Map();
23
- const reverseGraph = /* @__PURE__ */ new Map();
24
- for (const file of files) {
25
- dependencyGraph.set(file, []);
26
- reverseGraph.set(file, []);
27
- }
28
- let processed = 0;
29
- for (const file of files) {
30
- processed++;
31
- options.onProgress?.(
32
- processed,
33
- files.length,
34
- `change-amplification: analyzing files`
35
- );
36
- try {
37
- const parser = getParser(file);
38
- if (!parser) continue;
39
- const content = fs.readFileSync(file, "utf8");
40
- const parseResult = parser.parse(content, file);
41
- const dependencies = parseResult.imports.map((i) => i.source);
42
- for (const dep of dependencies) {
43
- const depDir = path.dirname(file);
44
- const resolvedPath = files.find((f) => {
45
- if (dep.startsWith(".")) {
46
- return f.startsWith(path.resolve(depDir, dep));
47
- } else {
48
- return f.includes(dep);
49
- }
50
- });
51
- if (resolvedPath) {
52
- dependencyGraph.get(file)?.push(resolvedPath);
53
- reverseGraph.get(resolvedPath)?.push(file);
54
- }
55
- }
56
- } catch (err) {
57
- void err;
58
- }
59
- }
60
- const fileMetrics = files.map((file) => {
61
- const fanOut = dependencyGraph.get(file)?.length || 0;
62
- const fanIn = reverseGraph.get(file)?.length || 0;
63
- return { file, fanOut, fanIn };
64
- });
65
- const riskResult = calculateChangeAmplification({ files: fileMetrics });
66
- const results = [];
67
- for (const hotspot of riskResult.hotspots) {
68
- const issues = [];
69
- if (hotspot.amplificationFactor > 20) {
70
- issues.push({
71
- type: "change-amplification",
72
- severity: hotspot.amplificationFactor > 40 ? "critical" : "major",
73
- message: `High change amplification detected (Factor: ${hotspot.amplificationFactor}). Changes here cascade heavily.`,
74
- location: { file: hotspot.file, line: 1 },
75
- suggestion: `Reduce coupling. Fan-out is ${hotspot.fanOut}, Fan-in is ${hotspot.fanIn}.`
76
- });
77
- }
78
- if (hotspot.amplificationFactor > 5) {
79
- results.push({
80
- fileName: hotspot.file,
81
- issues,
82
- metrics: {
83
- aiSignalClarityScore: 100 - hotspot.amplificationFactor
84
- // Just a rough score
85
- }
86
- });
87
- }
88
- }
89
- return {
90
- summary: {
91
- totalFiles: files.length,
92
- totalIssues: results.reduce((sum, r) => sum + r.issues.length, 0),
93
- criticalIssues: results.reduce(
94
- (sum, r) => sum + r.issues.filter((i) => i.severity === "critical").length,
95
- 0
96
- ),
97
- majorIssues: results.reduce(
98
- (sum, r) => sum + r.issues.filter((i) => i.severity === "major").length,
99
- 0
100
- ),
101
- score: riskResult.score,
102
- rating: riskResult.rating,
103
- recommendations: riskResult.recommendations
104
- },
105
- results
106
- };
107
- }
108
-
109
- export {
110
- __require,
111
- analyzeChangeAmplification
112
- };