@aiready/visualizer 0.1.22 → 0.1.23

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.
@@ -4,7 +4,7 @@
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>AIReady Visualizer (Dev)</title>
7
- <script type="module" crossorigin src="/assets/index-R1Ga3mzd.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-B4sbK1AD.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-cSvqzd3J.css">
9
9
  </head>
10
10
  <body>
package/web/src/utils.ts CHANGED
@@ -33,7 +33,19 @@ export function transformReportToGraph(report: ReportData): GraphData {
33
33
  }
34
34
 
35
35
  for (const ctx of report.context) {
36
- const issues = fileIssues.get(ctx.file);
36
+ // Try direct match first. If not found, try basename fallback so that
37
+ // pattern entries with different path styles still associate their
38
+ // severity with the context file in consumer reports.
39
+ let issues = fileIssues.get(ctx.file);
40
+ if (!issues) {
41
+ const ctxBase = (ctx.file || '').split('/').pop();
42
+ for (const [k, v] of fileIssues.entries()) {
43
+ if ((k || '').split('/').pop() === ctxBase) {
44
+ issues = v;
45
+ break;
46
+ }
47
+ }
48
+ }
37
49
  const severity = issues?.maxSeverity || ctx.severity || 'default';
38
50
  const tokenCost = ctx.tokenCost || 0;
39
51
 
@@ -109,13 +121,45 @@ export function transformReportToGraph(report: ReportData): GraphData {
109
121
  }
110
122
 
111
123
  for (const related of ctx.relatedFiles || []) {
112
- if (nodeMap.has(related) && related !== ctx.file) {
124
+ let relatedId: string | undefined = related;
125
+
126
+ // If exact match exists, use it. Otherwise try resolving relative paths
127
+ // from the source file's directory and try common extensions. As a
128
+ // final fallback, match by basename (endsWith) similar to dependency
129
+ // heuristics.
130
+ if (!nodeMap.has(relatedId)) {
131
+ const sourceDir = ctx.file.substring(0, ctx.file.lastIndexOf('/'));
132
+ const normalizedRel = related.replace(/^\.\/?/, '');
133
+ const tryPaths = [
134
+ `${sourceDir}/${normalizedRel}.ts`,
135
+ `${sourceDir}/${normalizedRel}.tsx`,
136
+ `${sourceDir}/${normalizedRel}/index.ts`,
137
+ `${sourceDir}/${normalizedRel}/index.tsx`,
138
+ `${sourceDir}/${normalizedRel}`,
139
+ ];
140
+ for (const p of tryPaths) {
141
+ if (nodeMap.has(p)) {
142
+ relatedId = p;
143
+ break;
144
+ }
145
+ }
146
+ }
147
+
148
+ // Fallback: loose basename matching
149
+ if (!nodeMap.has(relatedId)) {
150
+ const relBase = (related.split('/').pop() || related).replace(/\.(ts|tsx|js|jsx)$/, '');
151
+ relatedId = [...nodeMap.keys()].find(k =>
152
+ k.endsWith(`/${relBase}.ts`) || k.endsWith(`/${relBase}.tsx`) || k.endsWith(`/${relBase}/index.ts`) || k.endsWith(`/${relBase}/index.tsx`) || k.endsWith(`/${relBase}`)
153
+ );
154
+ }
155
+
156
+ if (relatedId && nodeMap.has(relatedId) && relatedId !== ctx.file) {
113
157
  const exists = edges.some(
114
158
  e =>
115
- (e.source === ctx.file && e.target === related) ||
116
- (e.source === related && e.target === ctx.file)
159
+ (e.source === ctx.file && e.target === relatedId) ||
160
+ (e.source === relatedId && e.target === ctx.file)
117
161
  );
118
- if (!exists) edges.push({ source: ctx.file, target: related, type: 'related' });
162
+ if (!exists) edges.push({ source: ctx.file, target: relatedId, type: 'related' });
119
163
  }
120
164
  }
121
165
  }