@aiready/context-analyzer 0.22.15 → 0.22.16

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.
Files changed (46) hide show
  1. package/.turbo/turbo-build.log +17 -17
  2. package/.turbo/turbo-format-check.log +1 -1
  3. package/.turbo/turbo-lint.log +1 -1
  4. package/.turbo/turbo-test.log +348 -26
  5. package/.turbo/turbo-type-check.log +1 -1
  6. package/dist/chunk-2LEHY2GV.mjs +1287 -0
  7. package/dist/chunk-P2ZQGQAO.mjs +1282 -0
  8. package/dist/chunk-QGI23DBA.mjs +1282 -0
  9. package/dist/chunk-QTB4KYCX.mjs +1260 -0
  10. package/dist/chunk-RQ5BQLT6.mjs +102 -0
  11. package/dist/chunk-VYFHSGV6.mjs +1283 -0
  12. package/dist/chunk-WLXLBWDU.mjs +96 -0
  13. package/dist/chunk-XDYPMFCH.mjs +1250 -0
  14. package/dist/cli-action-332WE54N.mjs +95 -0
  15. package/dist/cli-action-7QXG7LHS.mjs +95 -0
  16. package/dist/cli-action-BIX6TYXF.mjs +95 -0
  17. package/dist/cli-action-BUGVCH44.mjs +95 -0
  18. package/dist/cli-action-RO24U52W.mjs +95 -0
  19. package/dist/cli-action-WAZ5KM6X.mjs +95 -0
  20. package/dist/cli-action-XDKINE2R.mjs +95 -0
  21. package/dist/cli-action-Y6VATXMV.mjs +95 -0
  22. package/dist/cli.js +75 -27
  23. package/dist/cli.mjs +1 -1
  24. package/dist/index.d.mts +4 -2
  25. package/dist/index.d.ts +4 -2
  26. package/dist/index.js +71 -25
  27. package/dist/index.mjs +3 -3
  28. package/dist/orchestrator-2KQNMO2L.mjs +10 -0
  29. package/dist/orchestrator-66ZVNOLR.mjs +10 -0
  30. package/dist/orchestrator-KM2OJPZD.mjs +10 -0
  31. package/dist/orchestrator-MKDZPRBA.mjs +10 -0
  32. package/dist/orchestrator-QSHWWBWS.mjs +10 -0
  33. package/dist/orchestrator-WFQPMNSD.mjs +10 -0
  34. package/dist/python-context-H2OLC5JN.mjs +162 -0
  35. package/dist/python-context-OBP7JD5P.mjs +162 -0
  36. package/package.json +5 -3
  37. package/src/__tests__/analyzer.test.ts +4 -3
  38. package/src/__tests__/issue-analyzer.test.ts +4 -2
  39. package/src/classify/file-classifiers.ts +14 -13
  40. package/src/cli-action.ts +6 -3
  41. package/src/graph-builder.ts +43 -8
  42. package/src/issue-analyzer.ts +19 -7
  43. package/src/orchestrator.ts +6 -4
  44. package/src/semantic/domain-inference.ts +1 -1
  45. package/src/types.ts +2 -0
  46. package/src/utils/dependency-graph-utils.ts +22 -13
@@ -76,6 +76,7 @@ function mapNodeToResult(
76
76
  {
77
77
  file,
78
78
  importDepth,
79
+ tokenCost,
79
80
  contextBudget,
80
81
  cohesionScore,
81
82
  fragmentationScore,
@@ -102,8 +103,8 @@ function mapNodeToResult(
102
103
  tokenCost,
103
104
  linesOfCode: node.linesOfCode,
104
105
  importDepth,
105
- dependencyCount: transitiveDeps.length,
106
- dependencyList: transitiveDeps,
106
+ dependencyCount: transitiveDeps.size,
107
+ dependencyList: Array.from(transitiveDeps.keys()),
107
108
  circularDeps,
108
109
  cohesionScore,
109
110
  domains: Array.from(
@@ -166,8 +167,8 @@ export async function analyzeContext(
166
167
  ...scanOptions,
167
168
  exclude:
168
169
  includeNodeModules && scanOptions.exclude
169
- ? scanOptions.exclude.filter(
170
- (pattern) => pattern !== '**/node_modules/**'
170
+ ? (scanOptions.exclude as string[]).filter(
171
+ (pattern: string) => pattern !== '**/node_modules/**'
171
172
  )
172
173
  : scanOptions.exclude,
173
174
  });
@@ -197,6 +198,7 @@ export async function analyzeContext(
197
198
  analyzeIssues({
198
199
  file: metric.file,
199
200
  importDepth: metric.importDepth,
201
+ tokenCost: metric.contextBudget, // For Python, we use the reported budget as self-cost for now
200
202
  contextBudget: metric.contextBudget,
201
203
  cohesionScore: metric.cohesion,
202
204
  fragmentationScore: 0,
@@ -171,7 +171,7 @@ export function extractExports(
171
171
  domainOptions,
172
172
  fileImports
173
173
  );
174
- exports.push({ name, type, inferredDomain } as any);
174
+ exports.push({ name, type, inferredDomain });
175
175
  }
176
176
  });
177
177
 
package/src/types.ts CHANGED
@@ -18,6 +18,8 @@ export interface ContextAnalyzerOptions extends ScanOptions {
18
18
  focus?: 'fragmentation' | 'cohesion' | 'depth' | 'all';
19
19
  /** Whether to include node_modules in the analysis (default: false) */
20
20
  includeNodeModules?: boolean;
21
+ /** Maximum number of results to display in console output (default: 10) */
22
+ maxResults?: number;
21
23
  }
22
24
 
23
25
  /**
@@ -31,24 +31,33 @@ export function getTransitiveDependenciesFromEdges(
31
31
  file: string,
32
32
  edges: Map<string, Set<string>>,
33
33
  visited = new Set<string>()
34
- ): string[] {
35
- if (visited.has(file)) return [];
34
+ ): Map<string, number> {
35
+ const result = new Map<string, number>();
36
+
37
+ function dfs(current: string, depth: number) {
38
+ if (visited.has(current)) {
39
+ const existingDepth = result.get(current);
40
+ if (existingDepth !== undefined && depth < existingDepth) {
41
+ result.set(current, depth);
42
+ }
43
+ return;
44
+ }
45
+ visited.add(current);
36
46
 
37
- const nextVisited = new Set(visited);
38
- nextVisited.add(file);
47
+ if (current !== file) {
48
+ result.set(current, depth);
49
+ }
39
50
 
40
- const dependencies = edges.get(file);
41
- if (!dependencies || dependencies.size === 0) return [];
51
+ const dependencies = edges.get(current);
52
+ if (!dependencies) return;
42
53
 
43
- const allDeps: string[] = [];
44
- for (const dep of dependencies) {
45
- allDeps.push(dep);
46
- allDeps.push(
47
- ...getTransitiveDependenciesFromEdges(dep, edges, nextVisited)
48
- );
54
+ for (const dep of dependencies) {
55
+ dfs(dep, depth + 1);
56
+ }
49
57
  }
50
58
 
51
- return [...new Set(allDeps)];
59
+ dfs(file, 0);
60
+ return result;
52
61
  }
53
62
 
54
63
  export function detectGraphCycles(edges: Map<string, Set<string>>): string[][] {