@aiready/context-analyzer 0.19.11 → 0.19.14
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/.turbo/turbo-build.log +9 -9
- package/.turbo/turbo-test.log +19 -19
- package/dist/chunk-K2WFOBAZ.mjs +1821 -0
- package/dist/cli.js +31 -13
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +31 -13
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
- package/src/graph-builder.ts +41 -15
package/dist/cli.js
CHANGED
|
@@ -661,7 +661,7 @@ function buildDependencyGraph(files, options) {
|
|
|
661
661
|
const edges = /* @__PURE__ */ new Map();
|
|
662
662
|
const autoDetectedKeywords = options?.domainKeywords ?? extractDomainKeywordsFromPaths(files);
|
|
663
663
|
for (const { file, content } of files) {
|
|
664
|
-
const imports = extractImportsFromContent(content);
|
|
664
|
+
const imports = extractImportsFromContent(content, file);
|
|
665
665
|
const exports2 = extractExportsWithAST(
|
|
666
666
|
content,
|
|
667
667
|
file,
|
|
@@ -696,19 +696,37 @@ function buildDependencyGraph(files, options) {
|
|
|
696
696
|
}
|
|
697
697
|
return graph;
|
|
698
698
|
}
|
|
699
|
-
function extractImportsFromContent(content) {
|
|
699
|
+
function extractImportsFromContent(content, filePath) {
|
|
700
700
|
const imports = [];
|
|
701
|
-
const
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
701
|
+
const isPython = filePath?.toLowerCase().endsWith(".py");
|
|
702
|
+
if (isPython) {
|
|
703
|
+
const pythonPatterns = [
|
|
704
|
+
/^\s*import\s+([a-zA-Z0-9_., ]+)/gm,
|
|
705
|
+
/^\s*from\s+([a-zA-Z0-9_.]+)\s+import/gm
|
|
706
|
+
];
|
|
707
|
+
for (const pattern of pythonPatterns) {
|
|
708
|
+
let match;
|
|
709
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
710
|
+
const importPath = match[1];
|
|
711
|
+
if (importPath) {
|
|
712
|
+
const parts = importPath.split(",").map((p) => p.trim().split(/\s+as\s+/)[0]);
|
|
713
|
+
imports.push(...parts);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
} else {
|
|
718
|
+
const patterns = [
|
|
719
|
+
/import\s+.*?\s+from\s+['"](.+?)['"]/g,
|
|
720
|
+
/import\s+['"](.+?)['"]/g,
|
|
721
|
+
/require\(['"](.+?)['"]\)/g
|
|
722
|
+
];
|
|
723
|
+
for (const pattern of patterns) {
|
|
724
|
+
let match;
|
|
725
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
726
|
+
const importPath = match[1];
|
|
727
|
+
if (importPath && !importPath.startsWith("node:")) {
|
|
728
|
+
imports.push(importPath);
|
|
729
|
+
}
|
|
712
730
|
}
|
|
713
731
|
}
|
|
714
732
|
}
|
package/dist/cli.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -143,9 +143,9 @@ declare function buildDependencyGraph(files: FileContent[], options?: {
|
|
|
143
143
|
domainKeywords?: string[];
|
|
144
144
|
}): DependencyGraph;
|
|
145
145
|
/**
|
|
146
|
-
* Extract imports from file content
|
|
146
|
+
* Extract imports from file content
|
|
147
147
|
*/
|
|
148
|
-
declare function extractImportsFromContent(content: string): string[];
|
|
148
|
+
declare function extractImportsFromContent(content: string, filePath?: string): string[];
|
|
149
149
|
/**
|
|
150
150
|
* Calculate the maximum depth of import tree for a file
|
|
151
151
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -143,9 +143,9 @@ declare function buildDependencyGraph(files: FileContent[], options?: {
|
|
|
143
143
|
domainKeywords?: string[];
|
|
144
144
|
}): DependencyGraph;
|
|
145
145
|
/**
|
|
146
|
-
* Extract imports from file content
|
|
146
|
+
* Extract imports from file content
|
|
147
147
|
*/
|
|
148
|
-
declare function extractImportsFromContent(content: string): string[];
|
|
148
|
+
declare function extractImportsFromContent(content: string, filePath?: string): string[];
|
|
149
149
|
/**
|
|
150
150
|
* Calculate the maximum depth of import tree for a file
|
|
151
151
|
*/
|
package/dist/index.js
CHANGED
|
@@ -777,7 +777,7 @@ function buildDependencyGraph(files, options) {
|
|
|
777
777
|
const edges = /* @__PURE__ */ new Map();
|
|
778
778
|
const autoDetectedKeywords = options?.domainKeywords ?? extractDomainKeywordsFromPaths(files);
|
|
779
779
|
for (const { file, content } of files) {
|
|
780
|
-
const imports = extractImportsFromContent(content);
|
|
780
|
+
const imports = extractImportsFromContent(content, file);
|
|
781
781
|
const exports2 = extractExportsWithAST(
|
|
782
782
|
content,
|
|
783
783
|
file,
|
|
@@ -812,19 +812,37 @@ function buildDependencyGraph(files, options) {
|
|
|
812
812
|
}
|
|
813
813
|
return graph;
|
|
814
814
|
}
|
|
815
|
-
function extractImportsFromContent(content) {
|
|
815
|
+
function extractImportsFromContent(content, filePath) {
|
|
816
816
|
const imports = [];
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
817
|
+
const isPython = filePath?.toLowerCase().endsWith(".py");
|
|
818
|
+
if (isPython) {
|
|
819
|
+
const pythonPatterns = [
|
|
820
|
+
/^\s*import\s+([a-zA-Z0-9_., ]+)/gm,
|
|
821
|
+
/^\s*from\s+([a-zA-Z0-9_.]+)\s+import/gm
|
|
822
|
+
];
|
|
823
|
+
for (const pattern of pythonPatterns) {
|
|
824
|
+
let match;
|
|
825
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
826
|
+
const importPath = match[1];
|
|
827
|
+
if (importPath) {
|
|
828
|
+
const parts = importPath.split(",").map((p) => p.trim().split(/\s+as\s+/)[0]);
|
|
829
|
+
imports.push(...parts);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
} else {
|
|
834
|
+
const patterns = [
|
|
835
|
+
/import\s+.*?\s+from\s+['"](.+?)['"]/g,
|
|
836
|
+
/import\s+['"](.+?)['"]/g,
|
|
837
|
+
/require\(['"](.+?)['"]\)/g
|
|
838
|
+
];
|
|
839
|
+
for (const pattern of patterns) {
|
|
840
|
+
let match;
|
|
841
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
842
|
+
const importPath = match[1];
|
|
843
|
+
if (importPath && !importPath.startsWith("node:")) {
|
|
844
|
+
imports.push(importPath);
|
|
845
|
+
}
|
|
828
846
|
}
|
|
829
847
|
}
|
|
830
848
|
}
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiready/context-analyzer",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.14",
|
|
4
4
|
"description": "AI context window cost analysis - detect fragmented code, deep import chains, and expensive context budgets",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"commander": "^14.0.0",
|
|
50
50
|
"chalk": "^5.3.0",
|
|
51
51
|
"prompts": "^2.4.2",
|
|
52
|
-
"@aiready/core": "0.21.
|
|
52
|
+
"@aiready/core": "0.21.14"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/node": "^24.0.0",
|
package/src/graph-builder.ts
CHANGED
|
@@ -89,7 +89,7 @@ export function buildDependencyGraph(
|
|
|
89
89
|
options?.domainKeywords ?? extractDomainKeywordsFromPaths(files);
|
|
90
90
|
|
|
91
91
|
for (const { file, content } of files) {
|
|
92
|
-
const imports = extractImportsFromContent(content);
|
|
92
|
+
const imports = extractImportsFromContent(content, file);
|
|
93
93
|
const exports = extractExportsWithAST(
|
|
94
94
|
content,
|
|
95
95
|
file,
|
|
@@ -132,22 +132,48 @@ export function buildDependencyGraph(
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
|
-
* Extract imports from file content
|
|
135
|
+
* Extract imports from file content
|
|
136
136
|
*/
|
|
137
|
-
export function extractImportsFromContent(
|
|
137
|
+
export function extractImportsFromContent(
|
|
138
|
+
content: string,
|
|
139
|
+
filePath?: string
|
|
140
|
+
): string[] {
|
|
138
141
|
const imports: string[] = [];
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
142
|
+
const isPython = filePath?.toLowerCase().endsWith('.py');
|
|
143
|
+
|
|
144
|
+
if (isPython) {
|
|
145
|
+
const pythonPatterns = [
|
|
146
|
+
/^\s*import\s+([a-zA-Z0-9_., ]+)/gm,
|
|
147
|
+
/^\s*from\s+([a-zA-Z0-9_.]+)\s+import/gm,
|
|
148
|
+
];
|
|
149
|
+
|
|
150
|
+
for (const pattern of pythonPatterns) {
|
|
151
|
+
let match;
|
|
152
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
153
|
+
const importPath = match[1];
|
|
154
|
+
if (importPath) {
|
|
155
|
+
// Handle multiple imports in one line: import os, sys
|
|
156
|
+
const parts = importPath
|
|
157
|
+
.split(',')
|
|
158
|
+
.map((p) => p.trim().split(/\s+as\s+/)[0]);
|
|
159
|
+
imports.push(...parts);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
const patterns = [
|
|
165
|
+
/import\s+.*?\s+from\s+['"](.+?)['"]/g,
|
|
166
|
+
/import\s+['"](.+?)['"]/g,
|
|
167
|
+
/require\(['"](.+?)['"]\)/g,
|
|
168
|
+
];
|
|
169
|
+
|
|
170
|
+
for (const pattern of patterns) {
|
|
171
|
+
let match;
|
|
172
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
173
|
+
const importPath = match[1];
|
|
174
|
+
if (importPath && !importPath.startsWith('node:')) {
|
|
175
|
+
imports.push(importPath);
|
|
176
|
+
}
|
|
151
177
|
}
|
|
152
178
|
}
|
|
153
179
|
}
|