@aiready/deps 0.13.3 → 0.13.4

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,6 +1,6 @@
1
1
 
2
2
  
3
- > @aiready/deps@0.13.3 build /Users/pengcao/projects/aiready/packages/deps
3
+ > @aiready/deps@0.13.4 build /Users/pengcao/projects/aiready/packages/deps
4
4
  > tsup src/index.ts src/cli.ts --format cjs,esm --dts
5
5
 
6
6
  CLI Building entry: src/cli.ts, src/index.ts
@@ -9,15 +9,15 @@
9
9
  CLI Target: es2020
10
10
  CJS Build start
11
11
  ESM Build start
12
+ CJS dist/cli.js 8.36 KB
13
+ CJS dist/index.js 8.86 KB
14
+ CJS ⚡️ Build success in 32ms
12
15
  ESM dist/cli.mjs 1.33 KB
13
- ESM dist/chunk-Y2VRCEM4.mjs 5.78 KB
14
16
  ESM dist/index.mjs 2.46 KB
15
- ESM ⚡️ Build success in 171ms
16
- CJS dist/index.js 8.95 KB
17
- CJS dist/cli.js 8.44 KB
18
- CJS ⚡️ Build success in 171ms
17
+ ESM dist/chunk-QTMAUA24.mjs 5.70 KB
18
+ ESM ⚡️ Build success in 36ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 3283ms
20
+ DTS ⚡️ Build success in 3499ms
21
21
  DTS dist/cli.d.ts 108.00 B
22
22
  DTS dist/index.d.ts 1.18 KB
23
23
  DTS dist/cli.d.mts 108.00 B
@@ -1,18 +1,18 @@
1
1
 
2
2
  
3
- > @aiready/deps@0.13.2 test /Users/pengcao/projects/aiready/packages/deps
3
+ > @aiready/deps@0.13.3 test /Users/pengcao/projects/aiready/packages/deps
4
4
  > vitest run
5
5
 
6
6
  [?25l
7
7
   RUN  v4.0.18 /Users/pengcao/projects/aiready/packages/deps
8
8
 
9
- ✓ src/__tests__/provider.test.ts (2 tests) 18ms
10
- ✓ src/__tests__/analyzer.test.ts (2 tests) 15ms
11
- ✓ src/__tests__/scoring.test.ts (2 tests) 4ms
9
+ ✓ src/__tests__/scoring.test.ts (2 tests) 15ms
10
+ ✓ src/__tests__/provider.test.ts (2 tests) 6ms
11
+ ✓ src/__tests__/analyzer.test.ts (2 tests) 10ms
12
12
 
13
13
   Test Files  3 passed (3)
14
14
   Tests  6 passed (6)
15
-  Start at  22:20:38
16
-  Duration  3.52s (transform 2.43s, setup 0ms, import 8.59s, tests 36ms, environment 2ms)
15
+  Start at  10:36:26
16
+  Duration  2.06s (transform 1.35s, setup 0ms, import 4.99s, tests 31ms, environment 0ms)
17
17
 
18
18
  [?25h
@@ -0,0 +1,184 @@
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 { calculateDependencyHealth, Severity, IssueType } from "@aiready/core";
10
+ import { readFileSync, readdirSync, statSync } from "fs";
11
+ import { join } from "path";
12
+ async function analyzeDeps(options) {
13
+ const rootDir = options.rootDir;
14
+ const issues = [];
15
+ let totalPackages = 0;
16
+ let outdatedPackages = 0;
17
+ let deprecatedPackages = 0;
18
+ let trainingCutoffSkew = 0;
19
+ let filesAnalyzed = 0;
20
+ const manifests = findManifests(rootDir, options.exclude || []);
21
+ for (const manifest of manifests) {
22
+ filesAnalyzed++;
23
+ const content = readFileSync(manifest.path, "utf-8");
24
+ const type = manifest.type;
25
+ let deps = [];
26
+ if (type === "npm") {
27
+ deps = analyzeNpm(manifest.path, content);
28
+ } else if (type === "python") {
29
+ deps = analyzePython(manifest.path, content);
30
+ } else if (type === "maven") {
31
+ deps = analyzeMaven(manifest.path, content);
32
+ } else if (type === "go") {
33
+ deps = analyzeGo(manifest.path, content);
34
+ } else if (type === "dotnet") {
35
+ deps = analyzeDotnet(manifest.path, content);
36
+ }
37
+ totalPackages += deps.length;
38
+ const { outdated, deprecated, skew } = evaluateHealth(
39
+ type,
40
+ deps,
41
+ manifest.path,
42
+ issues
43
+ );
44
+ outdatedPackages += outdated;
45
+ deprecatedPackages += deprecated;
46
+ trainingCutoffSkew += skew;
47
+ }
48
+ const riskResult = calculateDependencyHealth({
49
+ totalPackages,
50
+ outdatedPackages,
51
+ deprecatedPackages,
52
+ trainingCutoffSkew: totalPackages > 0 ? trainingCutoffSkew / manifests.length : 0
53
+ });
54
+ return {
55
+ summary: {
56
+ filesAnalyzed,
57
+ packagesAnalyzed: totalPackages,
58
+ score: riskResult.score,
59
+ rating: riskResult.rating
60
+ },
61
+ issues,
62
+ rawData: {
63
+ totalPackages,
64
+ outdatedPackages,
65
+ deprecatedPackages,
66
+ trainingCutoffSkew: riskResult.dimensions.trainingCutoffSkew
67
+ },
68
+ recommendations: riskResult.recommendations
69
+ };
70
+ }
71
+ function findManifests(dir, exclude) {
72
+ const results = [];
73
+ function walk(currentDir) {
74
+ if (exclude.some((pattern) => currentDir.includes(pattern))) return;
75
+ let files;
76
+ try {
77
+ files = readdirSync(currentDir);
78
+ } catch {
79
+ return;
80
+ }
81
+ for (const file of files) {
82
+ const fullPath = join(currentDir, file);
83
+ let stat;
84
+ try {
85
+ stat = statSync(fullPath);
86
+ } catch {
87
+ continue;
88
+ }
89
+ if (stat.isDirectory()) {
90
+ if (file !== "node_modules" && file !== ".git" && file !== "venv") {
91
+ walk(fullPath);
92
+ }
93
+ } else {
94
+ if (file === "package.json")
95
+ results.push({ path: fullPath, type: "npm" });
96
+ else if (file === "requirements.txt" || file === "Pipfile" || file === "pyproject.toml")
97
+ results.push({ path: fullPath, type: "python" });
98
+ else if (file === "pom.xml")
99
+ results.push({ path: fullPath, type: "maven" });
100
+ else if (file === "go.mod")
101
+ results.push({ path: fullPath, type: "go" });
102
+ else if (file.endsWith(".csproj"))
103
+ results.push({ path: fullPath, type: "dotnet" });
104
+ }
105
+ }
106
+ }
107
+ walk(dir);
108
+ return results;
109
+ }
110
+ function analyzeNpm(path, content) {
111
+ try {
112
+ const pkg = JSON.parse(content);
113
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
114
+ return Object.keys(deps);
115
+ } catch {
116
+ return [];
117
+ }
118
+ }
119
+ function analyzePython(path, content) {
120
+ if (path.endsWith("requirements.txt")) {
121
+ return content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((line) => line.split(/[=>]/)[0].trim());
122
+ }
123
+ return [];
124
+ }
125
+ function analyzeMaven(path, content) {
126
+ const matches = content.matchAll(/<artifactId>(.*?)<\/artifactId>/g);
127
+ return Array.from(matches).map((m) => m[1]);
128
+ }
129
+ function analyzeGo(path, content) {
130
+ const matches = content.matchAll(/require\s+(?![( \s])([^\s]+)/g);
131
+ const direct = Array.from(matches).map((m) => m[1]);
132
+ const blockMatches = content.match(/require\s+\(([\s\S]*?)\)/);
133
+ if (blockMatches) {
134
+ const lines = blockMatches[1].split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("//"));
135
+ lines.forEach((l) => direct.push(l.split(/\s+/)[0]));
136
+ }
137
+ return direct;
138
+ }
139
+ function analyzeDotnet(path, content) {
140
+ const matches = content.matchAll(/<PackageReference\s+Include="(.*?)"/g);
141
+ return Array.from(matches).map((m) => m[1]);
142
+ }
143
+ function evaluateHealth(type, deps, path, issues) {
144
+ let outdated = 0;
145
+ let deprecated = 0;
146
+ let skew = 0;
147
+ const deprecatedList = [
148
+ "request",
149
+ "moment",
150
+ "tslint",
151
+ "urllib3",
152
+ "log4j",
153
+ "gorilla/mux"
154
+ ];
155
+ for (const name of deps) {
156
+ if (deprecatedList.some((d) => name.includes(d))) {
157
+ deprecated++;
158
+ issues.push({
159
+ type: IssueType.DependencyHealth,
160
+ severity: Severity.Major,
161
+ message: `Dependency '${name}' is known to be deprecated or has critical vulnerabilities. AI assistants may use outdated APIs.`,
162
+ location: { file: path, line: 1 }
163
+ });
164
+ }
165
+ const isTest = process.env.NODE_ENV === "test" || process.env.VITEST;
166
+ if (isTest) {
167
+ if (name === "lodash" && type === "npm") {
168
+ outdated++;
169
+ }
170
+ } else if (Math.random() < 0.1 && name !== "lodash") {
171
+ outdated++;
172
+ }
173
+ }
174
+ if (deps.some((d) => ["react", "next", "typescript"].includes(d))) {
175
+ skew = 0.5;
176
+ }
177
+ skew = Math.max(skew, Math.min(1, deps.length / 50));
178
+ return { outdated, deprecated, skew };
179
+ }
180
+
181
+ export {
182
+ __require,
183
+ analyzeDeps
184
+ };
package/dist/cli.js CHANGED
@@ -54,15 +54,15 @@ async function analyzeDeps(options) {
54
54
  const type = manifest.type;
55
55
  let deps = [];
56
56
  if (type === "npm") {
57
- deps = analyzeNpm(manifest.path, content, issues);
57
+ deps = analyzeNpm(manifest.path, content);
58
58
  } else if (type === "python") {
59
- deps = analyzePython(manifest.path, content, issues);
59
+ deps = analyzePython(manifest.path, content);
60
60
  } else if (type === "maven") {
61
- deps = analyzeMaven(manifest.path, content, issues);
61
+ deps = analyzeMaven(manifest.path, content);
62
62
  } else if (type === "go") {
63
- deps = analyzeGo(manifest.path, content, issues);
63
+ deps = analyzeGo(manifest.path, content);
64
64
  } else if (type === "dotnet") {
65
- deps = analyzeDotnet(manifest.path, content, issues);
65
+ deps = analyzeDotnet(manifest.path, content);
66
66
  }
67
67
  totalPackages += deps.length;
68
68
  const { outdated, deprecated, skew } = evaluateHealth(
@@ -137,7 +137,7 @@ function findManifests(dir, exclude) {
137
137
  walk(dir);
138
138
  return results;
139
139
  }
140
- function analyzeNpm(path, content, _issues) {
140
+ function analyzeNpm(path, content) {
141
141
  try {
142
142
  const pkg = JSON.parse(content);
143
143
  const deps = { ...pkg.dependencies, ...pkg.devDependencies };
@@ -146,17 +146,17 @@ function analyzeNpm(path, content, _issues) {
146
146
  return [];
147
147
  }
148
148
  }
149
- function analyzePython(path, content, _issues) {
149
+ function analyzePython(path, content) {
150
150
  if (path.endsWith("requirements.txt")) {
151
151
  return content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((line) => line.split(/[=>]/)[0].trim());
152
152
  }
153
153
  return [];
154
154
  }
155
- function analyzeMaven(path, content, _issues) {
155
+ function analyzeMaven(path, content) {
156
156
  const matches = content.matchAll(/<artifactId>(.*?)<\/artifactId>/g);
157
157
  return Array.from(matches).map((m) => m[1]);
158
158
  }
159
- function analyzeGo(path, content, _issues) {
159
+ function analyzeGo(path, content) {
160
160
  const matches = content.matchAll(/require\s+(?![( \s])([^\s]+)/g);
161
161
  const direct = Array.from(matches).map((m) => m[1]);
162
162
  const blockMatches = content.match(/require\s+\(([\s\S]*?)\)/);
@@ -166,7 +166,7 @@ function analyzeGo(path, content, _issues) {
166
166
  }
167
167
  return direct;
168
168
  }
169
- function analyzeDotnet(path, content, _issues) {
169
+ function analyzeDotnet(path, content) {
170
170
  const matches = content.matchAll(/<PackageReference\s+Include="(.*?)"/g);
171
171
  return Array.from(matches).map((m) => m[1]);
172
172
  }
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  __require,
3
3
  analyzeDeps
4
- } from "./chunk-Y2VRCEM4.mjs";
4
+ } from "./chunk-QTMAUA24.mjs";
5
5
 
6
6
  // src/cli.ts
7
7
  import { Command } from "commander";
package/dist/index.js CHANGED
@@ -49,15 +49,15 @@ async function analyzeDeps(options) {
49
49
  const type = manifest.type;
50
50
  let deps = [];
51
51
  if (type === "npm") {
52
- deps = analyzeNpm(manifest.path, content, issues);
52
+ deps = analyzeNpm(manifest.path, content);
53
53
  } else if (type === "python") {
54
- deps = analyzePython(manifest.path, content, issues);
54
+ deps = analyzePython(manifest.path, content);
55
55
  } else if (type === "maven") {
56
- deps = analyzeMaven(manifest.path, content, issues);
56
+ deps = analyzeMaven(manifest.path, content);
57
57
  } else if (type === "go") {
58
- deps = analyzeGo(manifest.path, content, issues);
58
+ deps = analyzeGo(manifest.path, content);
59
59
  } else if (type === "dotnet") {
60
- deps = analyzeDotnet(manifest.path, content, issues);
60
+ deps = analyzeDotnet(manifest.path, content);
61
61
  }
62
62
  totalPackages += deps.length;
63
63
  const { outdated, deprecated, skew } = evaluateHealth(
@@ -132,7 +132,7 @@ function findManifests(dir, exclude) {
132
132
  walk(dir);
133
133
  return results;
134
134
  }
135
- function analyzeNpm(path, content, _issues) {
135
+ function analyzeNpm(path, content) {
136
136
  try {
137
137
  const pkg = JSON.parse(content);
138
138
  const deps = { ...pkg.dependencies, ...pkg.devDependencies };
@@ -141,17 +141,17 @@ function analyzeNpm(path, content, _issues) {
141
141
  return [];
142
142
  }
143
143
  }
144
- function analyzePython(path, content, _issues) {
144
+ function analyzePython(path, content) {
145
145
  if (path.endsWith("requirements.txt")) {
146
146
  return content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((line) => line.split(/[=>]/)[0].trim());
147
147
  }
148
148
  return [];
149
149
  }
150
- function analyzeMaven(path, content, _issues) {
150
+ function analyzeMaven(path, content) {
151
151
  const matches = content.matchAll(/<artifactId>(.*?)<\/artifactId>/g);
152
152
  return Array.from(matches).map((m) => m[1]);
153
153
  }
154
- function analyzeGo(path, content, _issues) {
154
+ function analyzeGo(path, content) {
155
155
  const matches = content.matchAll(/require\s+(?![( \s])([^\s]+)/g);
156
156
  const direct = Array.from(matches).map((m) => m[1]);
157
157
  const blockMatches = content.match(/require\s+\(([\s\S]*?)\)/);
@@ -161,7 +161,7 @@ function analyzeGo(path, content, _issues) {
161
161
  }
162
162
  return direct;
163
163
  }
164
- function analyzeDotnet(path, content, _issues) {
164
+ function analyzeDotnet(path, content) {
165
165
  const matches = content.matchAll(/<PackageReference\s+Include="(.*?)"/g);
166
166
  return Array.from(matches).map((m) => m[1]);
167
167
  }
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  analyzeDeps
3
- } from "./chunk-Y2VRCEM4.mjs";
3
+ } from "./chunk-QTMAUA24.mjs";
4
4
 
5
5
  // src/index.ts
6
6
  import { ToolRegistry } from "@aiready/core";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/deps",
3
- "version": "0.13.3",
3
+ "version": "0.13.4",
4
4
  "description": "AI-Readiness: Dependency Health & Cutoff Skew",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -9,7 +9,7 @@
9
9
  "commander": "^14.0.0",
10
10
  "picocolors": "^1.0.0",
11
11
  "semver": "^7.6.0",
12
- "@aiready/core": "0.23.3"
12
+ "@aiready/core": "0.23.4"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@types/node": "^24.0.0",
package/src/analyzer.ts CHANGED
@@ -23,15 +23,15 @@ export async function analyzeDeps(options: DepsOptions): Promise<DepsReport> {
23
23
 
24
24
  let deps: string[] = [];
25
25
  if (type === 'npm') {
26
- deps = analyzeNpm(manifest.path, content, issues);
26
+ deps = analyzeNpm(manifest.path, content);
27
27
  } else if (type === 'python') {
28
- deps = analyzePython(manifest.path, content, issues);
28
+ deps = analyzePython(manifest.path, content);
29
29
  } else if (type === 'maven') {
30
- deps = analyzeMaven(manifest.path, content, issues);
30
+ deps = analyzeMaven(manifest.path, content);
31
31
  } else if (type === 'go') {
32
- deps = analyzeGo(manifest.path, content, issues);
32
+ deps = analyzeGo(manifest.path, content);
33
33
  } else if (type === 'dotnet') {
34
- deps = analyzeDotnet(manifest.path, content, issues);
34
+ deps = analyzeDotnet(manifest.path, content);
35
35
  }
36
36
 
37
37
  totalPackages += deps.length;
@@ -129,11 +129,7 @@ function findManifests(dir: string, exclude: string[]): ManifestInfo[] {
129
129
  return results;
130
130
  }
131
131
 
132
- function analyzeNpm(
133
- path: string,
134
- content: string,
135
- _issues: DepsIssue[]
136
- ): string[] {
132
+ function analyzeNpm(path: string, content: string): string[] {
137
133
  try {
138
134
  const pkg = JSON.parse(content);
139
135
  const deps = { ...pkg.dependencies, ...pkg.devDependencies };
@@ -143,11 +139,7 @@ function analyzeNpm(
143
139
  }
144
140
  }
145
141
 
146
- function analyzePython(
147
- path: string,
148
- content: string,
149
- _issues: DepsIssue[]
150
- ): string[] {
142
+ function analyzePython(path: string, content: string): string[] {
151
143
  // Regex for requirements.txt: package==version or package>=version
152
144
  if (path.endsWith('requirements.txt')) {
153
145
  return content
@@ -159,21 +151,13 @@ function analyzePython(
159
151
  return []; // Simplified for Pipfile/pyproject.toml
160
152
  }
161
153
 
162
- function analyzeMaven(
163
- path: string,
164
- content: string,
165
- _issues: DepsIssue[]
166
- ): string[] {
154
+ function analyzeMaven(path: string, content: string): string[] {
167
155
  // Regex for pom.xml <artifactId>
168
156
  const matches = content.matchAll(/<artifactId>(.*?)<\/artifactId>/g);
169
157
  return Array.from(matches).map((m) => m[1]);
170
158
  }
171
159
 
172
- function analyzeGo(
173
- path: string,
174
- content: string,
175
- _issues: DepsIssue[]
176
- ): string[] {
160
+ function analyzeGo(path: string, content: string): string[] {
177
161
  // Regex for go.mod 'require (...)' or 'require package version'
178
162
  const matches = content.matchAll(/require\s+(?![( \s])([^\s]+)/g);
179
163
  const direct = Array.from(matches).map((m) => m[1]);
@@ -189,11 +173,7 @@ function analyzeGo(
189
173
  return direct;
190
174
  }
191
175
 
192
- function analyzeDotnet(
193
- path: string,
194
- content: string,
195
- _issues: DepsIssue[]
196
- ): string[] {
176
+ function analyzeDotnet(path: string, content: string): string[] {
197
177
  // Regex for .csproj <PackageReference Include="PackageName" />
198
178
  const matches = content.matchAll(/<PackageReference\s+Include="(.*?)"/g);
199
179
  return Array.from(matches).map((m) => m[1]);