@aiready/deps 0.13.2 → 0.13.3

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.2 build /Users/pengcao/projects/aiready/packages/deps
3
+ > @aiready/deps@0.13.3 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
- ESM dist/index.mjs 2.46 KB
13
12
  ESM dist/cli.mjs 1.33 KB
14
- ESM dist/chunk-M52PDCX6.mjs 5.78 KB
15
- ESM ⚡️ Build success in 27ms
13
+ ESM dist/chunk-Y2VRCEM4.mjs 5.78 KB
14
+ ESM dist/index.mjs 2.46 KB
15
+ ESM ⚡️ Build success in 171ms
16
+ CJS dist/index.js 8.95 KB
16
17
  CJS dist/cli.js 8.44 KB
17
- CJS dist/index.js 8.94 KB
18
- CJS ⚡️ Build success in 27ms
18
+ CJS ⚡️ Build success in 171ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 4046ms
20
+ DTS ⚡️ Build success in 3283ms
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,5 +0,0 @@
1
-
2
- 
3
- > @aiready/deps@0.9.5 lint /Users/pengcao/projects/aiready/packages/deps
4
- > eslint src --ext .ts
5
-
@@ -1,18 +1,18 @@
1
1
 
2
2
  
3
- > @aiready/deps@0.13.1 test /Users/pengcao/projects/aiready/packages/deps
3
+ > @aiready/deps@0.13.2 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) 4ms
10
- ✓ src/__tests__/scoring.test.ts (2 tests) 2ms
11
- ✓ src/__tests__/analyzer.test.ts (2 tests) 7ms
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
12
12
 
13
13
   Test Files  3 passed (3)
14
14
   Tests  6 passed (6)
15
-  Start at  02:00:17
16
-  Duration  2.87s (transform 1.32s, setup 0ms, import 5.74s, tests 12ms, environment 0ms)
15
+  Start at  22:20:38
16
+  Duration  3.52s (transform 2.43s, setup 0ms, import 8.59s, tests 36ms, environment 2ms)
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, issues);
28
+ } else if (type === "python") {
29
+ deps = analyzePython(manifest.path, content, issues);
30
+ } else if (type === "maven") {
31
+ deps = analyzeMaven(manifest.path, content, issues);
32
+ } else if (type === "go") {
33
+ deps = analyzeGo(manifest.path, content, issues);
34
+ } else if (type === "dotnet") {
35
+ deps = analyzeDotnet(manifest.path, content, issues);
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, _issues) {
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, _issues) {
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, _issues) {
126
+ const matches = content.matchAll(/<artifactId>(.*?)<\/artifactId>/g);
127
+ return Array.from(matches).map((m) => m[1]);
128
+ }
129
+ function analyzeGo(path, content, _issues) {
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, _issues) {
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
@@ -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, _issues) {
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, _issues) {
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, _issues) {
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, _issues) {
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, _issues) {
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-M52PDCX6.mjs";
4
+ } from "./chunk-Y2VRCEM4.mjs";
5
5
 
6
6
  // src/cli.ts
7
7
  import { Command } from "commander";
package/dist/index.js CHANGED
@@ -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, _issues) {
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, _issues) {
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, _issues) {
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, _issues) {
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, _issues) {
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-M52PDCX6.mjs";
3
+ } from "./chunk-Y2VRCEM4.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.2",
3
+ "version": "0.13.3",
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.2"
12
+ "@aiready/core": "0.23.3"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@types/node": "^24.0.0",
package/src/analyzer.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { calculateDependencyHealth, Severity, IssueType } from '@aiready/core';
2
2
  import type { DepsOptions, DepsReport, DepsIssue } from './types';
3
- import { readFileSync, existsSync, readdirSync, statSync } from 'fs';
4
- import { join, basename, extname } from 'path';
3
+ import { readFileSync, readdirSync, statSync } from 'fs';
4
+ import { join } from 'path';
5
5
 
6
6
  export async function analyzeDeps(options: DepsOptions): Promise<DepsReport> {
7
7
  const rootDir = options.rootDir;
@@ -132,7 +132,7 @@ function findManifests(dir: string, exclude: string[]): ManifestInfo[] {
132
132
  function analyzeNpm(
133
133
  path: string,
134
134
  content: string,
135
- issues: DepsIssue[]
135
+ _issues: DepsIssue[]
136
136
  ): string[] {
137
137
  try {
138
138
  const pkg = JSON.parse(content);
@@ -146,7 +146,7 @@ function analyzeNpm(
146
146
  function analyzePython(
147
147
  path: string,
148
148
  content: string,
149
- issues: DepsIssue[]
149
+ _issues: DepsIssue[]
150
150
  ): string[] {
151
151
  // Regex for requirements.txt: package==version or package>=version
152
152
  if (path.endsWith('requirements.txt')) {
@@ -162,7 +162,7 @@ function analyzePython(
162
162
  function analyzeMaven(
163
163
  path: string,
164
164
  content: string,
165
- issues: DepsIssue[]
165
+ _issues: DepsIssue[]
166
166
  ): string[] {
167
167
  // Regex for pom.xml <artifactId>
168
168
  const matches = content.matchAll(/<artifactId>(.*?)<\/artifactId>/g);
@@ -172,7 +172,7 @@ function analyzeMaven(
172
172
  function analyzeGo(
173
173
  path: string,
174
174
  content: string,
175
- issues: DepsIssue[]
175
+ _issues: DepsIssue[]
176
176
  ): string[] {
177
177
  // Regex for go.mod 'require (...)' or 'require package version'
178
178
  const matches = content.matchAll(/require\s+(?![( \s])([^\s]+)/g);
@@ -192,7 +192,7 @@ function analyzeGo(
192
192
  function analyzeDotnet(
193
193
  path: string,
194
194
  content: string,
195
- issues: DepsIssue[]
195
+ _issues: DepsIssue[]
196
196
  ): string[] {
197
197
  // Regex for .csproj <PackageReference Include="PackageName" />
198
198
  const matches = content.matchAll(/<PackageReference\s+Include="(.*?)"/g);