@aiready/core 0.9.30 → 0.9.32
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/README.md +25 -110
- package/dist/chunk-CWRCDSKZ.mjs +408 -0
- package/dist/chunk-KI7XORTN.mjs +408 -0
- package/dist/client.d.mts +13 -12
- package/dist/client.d.ts +13 -12
- package/dist/client.js +11 -11
- package/dist/client.mjs +1 -1
- package/dist/index.d.mts +31 -11
- package/dist/index.d.ts +31 -11
- package/dist/index.js +70 -27
- package/dist/index.mjs +58 -16
- package/package.json +2 -2
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
// src/types/language.ts
|
|
2
|
+
var Language = /* @__PURE__ */ ((Language2) => {
|
|
3
|
+
Language2["TypeScript"] = "typescript";
|
|
4
|
+
Language2["JavaScript"] = "javascript";
|
|
5
|
+
Language2["Python"] = "python";
|
|
6
|
+
Language2["Java"] = "java";
|
|
7
|
+
Language2["Go"] = "go";
|
|
8
|
+
Language2["Rust"] = "rust";
|
|
9
|
+
Language2["CSharp"] = "csharp";
|
|
10
|
+
return Language2;
|
|
11
|
+
})(Language || {});
|
|
12
|
+
var LANGUAGE_EXTENSIONS = {
|
|
13
|
+
".ts": "typescript" /* TypeScript */,
|
|
14
|
+
".tsx": "typescript" /* TypeScript */,
|
|
15
|
+
".js": "javascript" /* JavaScript */,
|
|
16
|
+
".jsx": "javascript" /* JavaScript */,
|
|
17
|
+
".py": "python" /* Python */,
|
|
18
|
+
".java": "java" /* Java */,
|
|
19
|
+
".go": "go" /* Go */,
|
|
20
|
+
".rs": "rust" /* Rust */,
|
|
21
|
+
".cs": "csharp" /* CSharp */
|
|
22
|
+
};
|
|
23
|
+
var ParseError = class extends Error {
|
|
24
|
+
constructor(message, filePath, loc) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.filePath = filePath;
|
|
27
|
+
this.loc = loc;
|
|
28
|
+
this.name = "ParseError";
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// src/scoring.ts
|
|
33
|
+
var DEFAULT_TOOL_WEIGHTS = {
|
|
34
|
+
"pattern-detect": 40,
|
|
35
|
+
"context-analyzer": 35,
|
|
36
|
+
"consistency": 25,
|
|
37
|
+
"ai-signal-clarity": 20,
|
|
38
|
+
"agent-grounding": 18,
|
|
39
|
+
"testability": 18,
|
|
40
|
+
"doc-drift": 15,
|
|
41
|
+
"deps": 12
|
|
42
|
+
};
|
|
43
|
+
var TOOL_NAME_MAP = {
|
|
44
|
+
"patterns": "pattern-detect",
|
|
45
|
+
"context": "context-analyzer",
|
|
46
|
+
"consistency": "consistency",
|
|
47
|
+
"AI signal clarity": "ai-signal-clarity",
|
|
48
|
+
"ai-signal-clarity": "ai-signal-clarity",
|
|
49
|
+
"grounding": "agent-grounding",
|
|
50
|
+
"agent-grounding": "agent-grounding",
|
|
51
|
+
"testability": "testability",
|
|
52
|
+
"tests": "testability",
|
|
53
|
+
"doc-drift": "doc-drift",
|
|
54
|
+
"docs": "doc-drift",
|
|
55
|
+
"deps": "deps"
|
|
56
|
+
};
|
|
57
|
+
var CONTEXT_TIER_THRESHOLDS = {
|
|
58
|
+
compact: { idealTokens: 3e3, criticalTokens: 1e4, idealDepth: 4 },
|
|
59
|
+
standard: { idealTokens: 5e3, criticalTokens: 15e3, idealDepth: 5 },
|
|
60
|
+
extended: { idealTokens: 15e3, criticalTokens: 5e4, idealDepth: 7 },
|
|
61
|
+
frontier: { idealTokens: 5e4, criticalTokens: 15e4, idealDepth: 10 }
|
|
62
|
+
};
|
|
63
|
+
var SIZE_ADJUSTED_THRESHOLDS = {
|
|
64
|
+
"xs": 80,
|
|
65
|
+
// < 50 files
|
|
66
|
+
"small": 75,
|
|
67
|
+
// 50-200 files
|
|
68
|
+
"medium": 70,
|
|
69
|
+
// 200-500 files
|
|
70
|
+
"large": 65,
|
|
71
|
+
// 500-2000 files
|
|
72
|
+
"enterprise": 58
|
|
73
|
+
// 2000+ files
|
|
74
|
+
};
|
|
75
|
+
function getProjectSizeTier(fileCount) {
|
|
76
|
+
if (fileCount < 50) return "xs";
|
|
77
|
+
if (fileCount < 200) return "small";
|
|
78
|
+
if (fileCount < 500) return "medium";
|
|
79
|
+
if (fileCount < 2e3) return "large";
|
|
80
|
+
return "enterprise";
|
|
81
|
+
}
|
|
82
|
+
function getRecommendedThreshold(fileCount, modelTier = "standard") {
|
|
83
|
+
const sizeTier = getProjectSizeTier(fileCount);
|
|
84
|
+
const base = SIZE_ADJUSTED_THRESHOLDS[sizeTier];
|
|
85
|
+
const modelBonus = modelTier === "frontier" ? -3 : modelTier === "extended" ? -2 : 0;
|
|
86
|
+
return base + modelBonus;
|
|
87
|
+
}
|
|
88
|
+
function normalizeToolName(shortName) {
|
|
89
|
+
return TOOL_NAME_MAP[shortName] || shortName;
|
|
90
|
+
}
|
|
91
|
+
function getToolWeight(toolName, toolConfig, cliOverride) {
|
|
92
|
+
if (cliOverride !== void 0) {
|
|
93
|
+
return cliOverride;
|
|
94
|
+
}
|
|
95
|
+
if (toolConfig?.scoreWeight !== void 0) {
|
|
96
|
+
return toolConfig.scoreWeight;
|
|
97
|
+
}
|
|
98
|
+
return DEFAULT_TOOL_WEIGHTS[toolName] || 10;
|
|
99
|
+
}
|
|
100
|
+
function parseWeightString(weightStr) {
|
|
101
|
+
const weights = /* @__PURE__ */ new Map();
|
|
102
|
+
if (!weightStr) {
|
|
103
|
+
return weights;
|
|
104
|
+
}
|
|
105
|
+
const pairs = weightStr.split(",");
|
|
106
|
+
for (const pair of pairs) {
|
|
107
|
+
const [toolShortName, weightStr2] = pair.split(":");
|
|
108
|
+
if (toolShortName && weightStr2) {
|
|
109
|
+
const toolName = normalizeToolName(toolShortName.trim());
|
|
110
|
+
const weight = parseInt(weightStr2.trim(), 10);
|
|
111
|
+
if (!isNaN(weight) && weight > 0) {
|
|
112
|
+
weights.set(toolName, weight);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return weights;
|
|
117
|
+
}
|
|
118
|
+
function calculateOverallScore(toolOutputs, config, cliWeights) {
|
|
119
|
+
if (toolOutputs.size === 0) {
|
|
120
|
+
throw new Error("No tool outputs provided for scoring");
|
|
121
|
+
}
|
|
122
|
+
const weights = /* @__PURE__ */ new Map();
|
|
123
|
+
for (const [toolName] of toolOutputs.entries()) {
|
|
124
|
+
const cliWeight = cliWeights?.get(toolName);
|
|
125
|
+
const configWeight = config?.tools?.[toolName]?.scoreWeight;
|
|
126
|
+
const weight = cliWeight ?? configWeight ?? DEFAULT_TOOL_WEIGHTS[toolName] ?? 10;
|
|
127
|
+
weights.set(toolName, weight);
|
|
128
|
+
}
|
|
129
|
+
let weightedSum = 0;
|
|
130
|
+
let totalWeight = 0;
|
|
131
|
+
const breakdown = [];
|
|
132
|
+
const toolsUsed = [];
|
|
133
|
+
const calculationWeights = {};
|
|
134
|
+
for (const [toolName, output] of toolOutputs.entries()) {
|
|
135
|
+
const weight = weights.get(toolName) || 10;
|
|
136
|
+
const weightedScore = output.score * weight;
|
|
137
|
+
weightedSum += weightedScore;
|
|
138
|
+
totalWeight += weight;
|
|
139
|
+
toolsUsed.push(toolName);
|
|
140
|
+
calculationWeights[toolName] = weight;
|
|
141
|
+
breakdown.push(output);
|
|
142
|
+
}
|
|
143
|
+
const overall = Math.round(weightedSum / totalWeight);
|
|
144
|
+
const rating = getRating(overall);
|
|
145
|
+
const formulaParts = Array.from(toolOutputs.entries()).map(([name, output]) => {
|
|
146
|
+
const w = weights.get(name) || 10;
|
|
147
|
+
return `(${output.score} \xD7 ${w})`;
|
|
148
|
+
});
|
|
149
|
+
const formulaStr = `[${formulaParts.join(" + ")}] / ${totalWeight} = ${overall}`;
|
|
150
|
+
return {
|
|
151
|
+
overall,
|
|
152
|
+
rating,
|
|
153
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
154
|
+
toolsUsed,
|
|
155
|
+
breakdown,
|
|
156
|
+
calculation: {
|
|
157
|
+
formula: formulaStr,
|
|
158
|
+
weights: calculationWeights,
|
|
159
|
+
normalized: formulaStr
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function getRating(score) {
|
|
164
|
+
if (score >= 90) return "Excellent";
|
|
165
|
+
if (score >= 75) return "Good";
|
|
166
|
+
if (score >= 60) return "Fair";
|
|
167
|
+
if (score >= 40) return "Needs Work";
|
|
168
|
+
return "Critical";
|
|
169
|
+
}
|
|
170
|
+
function getRatingWithContext(score, fileCount, modelTier = "standard") {
|
|
171
|
+
const threshold = getRecommendedThreshold(fileCount, modelTier);
|
|
172
|
+
const normalized = score - threshold + 70;
|
|
173
|
+
return getRating(normalized);
|
|
174
|
+
}
|
|
175
|
+
function getRatingDisplay(rating) {
|
|
176
|
+
switch (rating) {
|
|
177
|
+
case "Excellent":
|
|
178
|
+
return { emoji: "\u2705", color: "green" };
|
|
179
|
+
case "Good":
|
|
180
|
+
return { emoji: "\u{1F44D}", color: "blue" };
|
|
181
|
+
case "Fair":
|
|
182
|
+
return { emoji: "\u26A0\uFE0F", color: "yellow" };
|
|
183
|
+
case "Needs Work":
|
|
184
|
+
return { emoji: "\u{1F528}", color: "orange" };
|
|
185
|
+
case "Critical":
|
|
186
|
+
return { emoji: "\u274C", color: "red" };
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function formatScore(result) {
|
|
190
|
+
const { emoji, color } = getRatingDisplay(result.rating);
|
|
191
|
+
return `${result.overall}/100 (${result.rating}) ${emoji}`;
|
|
192
|
+
}
|
|
193
|
+
function formatToolScore(output) {
|
|
194
|
+
let result = ` Score: ${output.score}/100
|
|
195
|
+
|
|
196
|
+
`;
|
|
197
|
+
if (output.factors && output.factors.length > 0) {
|
|
198
|
+
result += ` Factors:
|
|
199
|
+
`;
|
|
200
|
+
output.factors.forEach((factor) => {
|
|
201
|
+
const impactSign = factor.impact > 0 ? "+" : "";
|
|
202
|
+
result += ` \u2022 ${factor.name}: ${impactSign}${factor.impact} - ${factor.description}
|
|
203
|
+
`;
|
|
204
|
+
});
|
|
205
|
+
result += "\n";
|
|
206
|
+
}
|
|
207
|
+
if (output.recommendations && output.recommendations.length > 0) {
|
|
208
|
+
result += ` Recommendations:
|
|
209
|
+
`;
|
|
210
|
+
output.recommendations.forEach((rec, i) => {
|
|
211
|
+
const priorityIcon = rec.priority === "high" ? "\u{1F534}" : rec.priority === "medium" ? "\u{1F7E1}" : "\u{1F535}";
|
|
212
|
+
result += ` ${i + 1}. ${priorityIcon} ${rec.action}
|
|
213
|
+
`;
|
|
214
|
+
result += ` Impact: +${rec.estimatedImpact} points
|
|
215
|
+
|
|
216
|
+
`;
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
return result;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// src/utils/visualization.ts
|
|
223
|
+
function generateHTML(graph) {
|
|
224
|
+
const payload = JSON.stringify(graph, null, 2);
|
|
225
|
+
return `<!doctype html>
|
|
226
|
+
<html>
|
|
227
|
+
<head>
|
|
228
|
+
<meta charset="utf-8" />
|
|
229
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
230
|
+
<title>AIReady Visualization</title>
|
|
231
|
+
<style>
|
|
232
|
+
html,body { height: 100%; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #0f172a; color: #e2e8f0 }
|
|
233
|
+
#container { display:flex; height:100vh }
|
|
234
|
+
#panel { width: 320px; padding: 16px; background: #071130; box-shadow: -2px 0 8px rgba(0,0,0,0.3); overflow:auto }
|
|
235
|
+
#canvasWrap { flex:1; display:flex; align-items:center; justify-content:center }
|
|
236
|
+
canvas { background: #0b1220; border-radius:8px }
|
|
237
|
+
.stat { margin-bottom:12px }
|
|
238
|
+
</style>
|
|
239
|
+
</head>
|
|
240
|
+
<body>
|
|
241
|
+
<div id="container">
|
|
242
|
+
<div id="canvasWrap"><canvas id="canvas" width="1200" height="800"></canvas></div>
|
|
243
|
+
<div id="panel">
|
|
244
|
+
<h2>AIReady Visualization</h2>
|
|
245
|
+
<div class="stat"><strong>Files:</strong> <span id="stat-files"></span></div>
|
|
246
|
+
<div class="stat"><strong>Dependencies:</strong> <span id="stat-deps"></span></div>
|
|
247
|
+
<div class="stat"><strong>Legend</strong></div>
|
|
248
|
+
<div style="font-size:13px;line-height:1.3;color:#cbd5e1;margin-top:8px">
|
|
249
|
+
<div style="margin-bottom:8px"><span style="display:inline-block;width:12px;height:12px;background:#ff4d4f;margin-right:8px;border:1px solid rgba(255,255,255,0.06)"></span><strong>Critical</strong>: highest severity issues.</div>
|
|
250
|
+
<div style="margin-bottom:8px"><span style="display:inline-block;width:12px;height:12px;background:#ff9900;margin-right:8px;border:1px solid rgba(255,255,255,0.06)"></span><strong>Major</strong>: important issues.</div>
|
|
251
|
+
<div style="margin-bottom:8px"><span style="display:inline-block;width:12px;height:12px;background:#ffd666;margin-right:8px;border:1px solid rgba(255,255,255,0.06)"></span><strong>Minor</strong>: low priority issues.</div>
|
|
252
|
+
<div style="margin-bottom:8px"><span style="display:inline-block;width:12px;height:12px;background:#91d5ff;margin-right:8px;border:1px solid rgba(255,255,255,0.06)"></span><strong>Info</strong>: informational notes.</div>
|
|
253
|
+
<div style="margin-top:10px;color:#94a3b8"><strong>Node size</strong>: larger = higher token cost, more issues or dependency weight.</div>
|
|
254
|
+
<div style="margin-top:6px;color:#94a3b8"><strong>Proximity</strong>: nodes that are spatially close are more contextually related; relatedness is represented by distance and size rather than explicit edges.</div>
|
|
255
|
+
<div style="margin-top:6px;color:#94a3b8"><strong>Edge colors</strong>: <span style="color:#fb7e81">Similarity</span>, <span style="color:#84c1ff">Dependency</span>, <span style="color:#ffa500">Reference</span>, default <span style="color:#334155">Other</span>.</div>
|
|
256
|
+
</div>
|
|
257
|
+
</div>
|
|
258
|
+
</div>
|
|
259
|
+
|
|
260
|
+
<script>
|
|
261
|
+
const graphData = ${payload};
|
|
262
|
+
document.getElementById('stat-files').textContent = graphData.metadata.totalFiles;
|
|
263
|
+
document.getElementById('stat-deps').textContent = graphData.metadata.totalDependencies;
|
|
264
|
+
|
|
265
|
+
const canvas = document.getElementById('canvas');
|
|
266
|
+
const ctx = canvas.getContext('2d');
|
|
267
|
+
|
|
268
|
+
const nodes = graphData.nodes.map((n, i) => ({
|
|
269
|
+
...n,
|
|
270
|
+
x: canvas.width / 2 + Math.cos(i / graphData.nodes.length * Math.PI * 2) * (Math.min(canvas.width, canvas.height) / 3),
|
|
271
|
+
y: canvas.height / 2 + Math.sin(i / graphData.nodes.length * Math.PI * 2) * (Math.min(canvas.width, canvas.height) / 3),
|
|
272
|
+
}));
|
|
273
|
+
|
|
274
|
+
function draw() {
|
|
275
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
276
|
+
|
|
277
|
+
graphData.edges.forEach(edge => {
|
|
278
|
+
const s = nodes.find(n => n.id === edge.source);
|
|
279
|
+
const t = nodes.find(n => n.id === edge.target);
|
|
280
|
+
if (!s || !t) return;
|
|
281
|
+
if (edge.type === 'related') return;
|
|
282
|
+
if (edge.type === 'similarity') {
|
|
283
|
+
ctx.strokeStyle = '#fb7e81';
|
|
284
|
+
ctx.lineWidth = 1.2;
|
|
285
|
+
} else if (edge.type === 'dependency') {
|
|
286
|
+
ctx.strokeStyle = '#84c1ff';
|
|
287
|
+
ctx.lineWidth = 1.0;
|
|
288
|
+
} else if (edge.type === 'reference') {
|
|
289
|
+
ctx.strokeStyle = '#ffa500';
|
|
290
|
+
ctx.lineWidth = 0.9;
|
|
291
|
+
} else {
|
|
292
|
+
ctx.strokeStyle = '#334155';
|
|
293
|
+
ctx.lineWidth = 0.8;
|
|
294
|
+
}
|
|
295
|
+
ctx.beginPath();
|
|
296
|
+
ctx.moveTo(s.x, s.y);
|
|
297
|
+
ctx.lineTo(t.x, t.y);
|
|
298
|
+
ctx.stroke();
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
const groups = {};
|
|
302
|
+
nodes.forEach(n => {
|
|
303
|
+
const g = n.group || '__default';
|
|
304
|
+
if (!groups[g]) groups[g] = { minX: n.x, minY: n.y, maxX: n.x, maxY: n.y };
|
|
305
|
+
groups[g].minX = Math.min(groups[g].minX, n.x);
|
|
306
|
+
groups[g].minY = Math.min(groups[g].minY, n.y);
|
|
307
|
+
groups[g].maxX = Math.max(groups[g].maxX, n.x);
|
|
308
|
+
groups[g].maxY = Math.max(groups[g].maxY, n.y);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
const groupRelations = {};
|
|
312
|
+
graphData.edges.forEach(edge => {
|
|
313
|
+
const sNode = nodes.find(n => n.id === edge.source);
|
|
314
|
+
const tNode = nodes.find(n => n.id === edge.target);
|
|
315
|
+
if (!sNode || !tNode) return;
|
|
316
|
+
const g1 = sNode.group || '__default';
|
|
317
|
+
const g2 = tNode.group || '__default';
|
|
318
|
+
if (g1 === g2) return;
|
|
319
|
+
const key = g1 < g2 ? g1 + '::' + g2 : g2 + '::' + g1;
|
|
320
|
+
groupRelations[key] = (groupRelations[key] || 0) + 1;
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
Object.keys(groupRelations).forEach(k => {
|
|
324
|
+
const count = groupRelations[k];
|
|
325
|
+
const [ga, gb] = k.split('::');
|
|
326
|
+
if (!groups[ga] || !groups[gb]) return;
|
|
327
|
+
const ax = (groups[ga].minX + groups[ga].maxX) / 2;
|
|
328
|
+
const ay = (groups[ga].minY + groups[ga].maxY) / 2;
|
|
329
|
+
const bx = (groups[gb].minX + groups[gb].maxX) / 2;
|
|
330
|
+
const by = (groups[gb].minY + groups[gb].maxY) / 2;
|
|
331
|
+
ctx.beginPath();
|
|
332
|
+
ctx.strokeStyle = 'rgba(148,163,184,0.25)';
|
|
333
|
+
ctx.lineWidth = Math.min(6, 0.6 + Math.sqrt(count));
|
|
334
|
+
ctx.moveTo(ax, ay);
|
|
335
|
+
ctx.lineTo(bx, by);
|
|
336
|
+
ctx.stroke();
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
Object.keys(groups).forEach(g => {
|
|
340
|
+
if (g === '__default') return;
|
|
341
|
+
const box = groups[g];
|
|
342
|
+
const pad = 16;
|
|
343
|
+
const x = box.minX - pad;
|
|
344
|
+
const y = box.minY - pad;
|
|
345
|
+
const w = (box.maxX - box.minX) + pad * 2;
|
|
346
|
+
const h = (box.maxY - box.minY) + pad * 2;
|
|
347
|
+
ctx.save();
|
|
348
|
+
ctx.fillStyle = 'rgba(30,64,175,0.04)';
|
|
349
|
+
ctx.strokeStyle = 'rgba(30,64,175,0.12)';
|
|
350
|
+
ctx.lineWidth = 1.2;
|
|
351
|
+
const r = 8;
|
|
352
|
+
ctx.beginPath();
|
|
353
|
+
ctx.moveTo(x + r, y);
|
|
354
|
+
ctx.arcTo(x + w, y, x + w, y + h, r);
|
|
355
|
+
ctx.arcTo(x + w, y + h, x, y + h, r);
|
|
356
|
+
ctx.arcTo(x, y + h, x, y, r);
|
|
357
|
+
ctx.arcTo(x, y, x + w, y, r);
|
|
358
|
+
ctx.closePath();
|
|
359
|
+
ctx.fill();
|
|
360
|
+
ctx.stroke();
|
|
361
|
+
ctx.restore();
|
|
362
|
+
ctx.fillStyle = '#94a3b8';
|
|
363
|
+
ctx.font = '11px sans-serif';
|
|
364
|
+
ctx.fillText(g, x + 8, y + 14);
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
nodes.forEach(n => {
|
|
368
|
+
const sizeVal = (n.size || n.value || 1);
|
|
369
|
+
const r = 6 + (sizeVal / 2);
|
|
370
|
+
ctx.beginPath();
|
|
371
|
+
ctx.fillStyle = n.color || '#60a5fa';
|
|
372
|
+
ctx.arc(n.x, n.y, r, 0, Math.PI * 2);
|
|
373
|
+
ctx.fill();
|
|
374
|
+
|
|
375
|
+
ctx.fillStyle = '#e2e8f0';
|
|
376
|
+
ctx.font = '11px sans-serif';
|
|
377
|
+
ctx.textAlign = 'center';
|
|
378
|
+
ctx.fillText(n.label || n.id.split('/').slice(-1)[0], n.x, n.y + r + 12);
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
draw();
|
|
383
|
+
</script>
|
|
384
|
+
</body>
|
|
385
|
+
</html>`;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export {
|
|
389
|
+
Language,
|
|
390
|
+
LANGUAGE_EXTENSIONS,
|
|
391
|
+
ParseError,
|
|
392
|
+
DEFAULT_TOOL_WEIGHTS,
|
|
393
|
+
TOOL_NAME_MAP,
|
|
394
|
+
CONTEXT_TIER_THRESHOLDS,
|
|
395
|
+
SIZE_ADJUSTED_THRESHOLDS,
|
|
396
|
+
getProjectSizeTier,
|
|
397
|
+
getRecommendedThreshold,
|
|
398
|
+
normalizeToolName,
|
|
399
|
+
getToolWeight,
|
|
400
|
+
parseWeightString,
|
|
401
|
+
calculateOverallScore,
|
|
402
|
+
getRating,
|
|
403
|
+
getRatingWithContext,
|
|
404
|
+
getRatingDisplay,
|
|
405
|
+
formatScore,
|
|
406
|
+
formatToolScore,
|
|
407
|
+
generateHTML
|
|
408
|
+
};
|
package/dist/client.d.mts
CHANGED
|
@@ -10,7 +10,7 @@ interface Issue {
|
|
|
10
10
|
location: Location;
|
|
11
11
|
suggestion?: string;
|
|
12
12
|
}
|
|
13
|
-
type IssueType = 'duplicate-pattern' | 'context-fragmentation' | 'doc-drift' | 'dependency-health' | 'naming-inconsistency' | 'naming-quality' | 'pattern-inconsistency' | 'architecture-inconsistency' | 'dead-code' | 'circular-dependency' | 'missing-types' | '
|
|
13
|
+
type IssueType = 'duplicate-pattern' | 'context-fragmentation' | 'doc-drift' | 'dependency-health' | 'naming-inconsistency' | 'naming-quality' | 'pattern-inconsistency' | 'architecture-inconsistency' | 'dead-code' | 'circular-dependency' | 'missing-types' | 'ai-signal-clarity' | 'low-testability' | 'agent-navigation-failure' | 'ambiguous-api' | 'magic-literal' | 'boolean-trap' | 'change-amplification';
|
|
14
14
|
interface Location {
|
|
15
15
|
file: string;
|
|
16
16
|
line: number;
|
|
@@ -27,7 +27,7 @@ interface Metrics {
|
|
|
27
27
|
estimatedDeveloperHours?: number;
|
|
28
28
|
comprehensionDifficultyIndex?: number;
|
|
29
29
|
/** Probability (0-100) that AI will hallucinate in this file/module */
|
|
30
|
-
|
|
30
|
+
aiSignalClarityScore?: number;
|
|
31
31
|
/** How well an agent can navigate to/from this file unaided (0-100) */
|
|
32
32
|
agentGroundingScore?: number;
|
|
33
33
|
/** Whether AI-generated changes to this file can be safely verified (0-100) */
|
|
@@ -488,23 +488,24 @@ interface ScoringConfig {
|
|
|
488
488
|
saveTo?: string;
|
|
489
489
|
}
|
|
490
490
|
/**
|
|
491
|
-
* Default weights for known tools.
|
|
492
|
-
*
|
|
491
|
+
* Default weights for known tools. Weights sum to 100 and read directly as
|
|
492
|
+
* percentage contribution to the overall score.
|
|
493
|
+
* New tools get weight of 5 if not specified.
|
|
493
494
|
*
|
|
494
495
|
* Weight philosophy:
|
|
495
|
-
* - pattern-detect (
|
|
496
|
+
* - pattern-detect (22%): Semantic duplication directly wastes token budget and
|
|
496
497
|
* confuses AI with contradictory in-context examples.
|
|
497
|
-
* - context-analyzer (
|
|
498
|
+
* - context-analyzer (19%): Context limits are the primary hard constraint on
|
|
498
499
|
* AI effectiveness regardless of model size.
|
|
499
|
-
* - consistency (
|
|
500
|
+
* - consistency (14%): Naming/pattern inconsistency degrades AI intent understanding
|
|
500
501
|
* proportionally to codebase size.
|
|
501
|
-
* -
|
|
502
|
+
* - ai-signal-clarity (11%): Code patterns empirically causing AI to generate
|
|
502
503
|
* confidently wrong outputs — critical for agentic use cases.
|
|
503
|
-
* - agent-grounding (
|
|
504
|
+
* - agent-grounding (10%): How well an autonomous agent can navigate unaided —
|
|
504
505
|
* increasingly important as agentic workflows grow.
|
|
505
|
-
* - testability (
|
|
506
|
-
* - doc-drift (
|
|
507
|
-
* - deps (
|
|
506
|
+
* - testability (10%): AI changes without verifiability create hidden risk.
|
|
507
|
+
* - doc-drift (8%): Stale docs actively mislead AI; planned spoke.
|
|
508
|
+
* - deps (6%): Dependency health affects AI suggestion accuracy; planned spoke.
|
|
508
509
|
*/
|
|
509
510
|
declare const DEFAULT_TOOL_WEIGHTS: Record<string, number>;
|
|
510
511
|
/**
|
package/dist/client.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ interface Issue {
|
|
|
10
10
|
location: Location;
|
|
11
11
|
suggestion?: string;
|
|
12
12
|
}
|
|
13
|
-
type IssueType = 'duplicate-pattern' | 'context-fragmentation' | 'doc-drift' | 'dependency-health' | 'naming-inconsistency' | 'naming-quality' | 'pattern-inconsistency' | 'architecture-inconsistency' | 'dead-code' | 'circular-dependency' | 'missing-types' | '
|
|
13
|
+
type IssueType = 'duplicate-pattern' | 'context-fragmentation' | 'doc-drift' | 'dependency-health' | 'naming-inconsistency' | 'naming-quality' | 'pattern-inconsistency' | 'architecture-inconsistency' | 'dead-code' | 'circular-dependency' | 'missing-types' | 'ai-signal-clarity' | 'low-testability' | 'agent-navigation-failure' | 'ambiguous-api' | 'magic-literal' | 'boolean-trap' | 'change-amplification';
|
|
14
14
|
interface Location {
|
|
15
15
|
file: string;
|
|
16
16
|
line: number;
|
|
@@ -27,7 +27,7 @@ interface Metrics {
|
|
|
27
27
|
estimatedDeveloperHours?: number;
|
|
28
28
|
comprehensionDifficultyIndex?: number;
|
|
29
29
|
/** Probability (0-100) that AI will hallucinate in this file/module */
|
|
30
|
-
|
|
30
|
+
aiSignalClarityScore?: number;
|
|
31
31
|
/** How well an agent can navigate to/from this file unaided (0-100) */
|
|
32
32
|
agentGroundingScore?: number;
|
|
33
33
|
/** Whether AI-generated changes to this file can be safely verified (0-100) */
|
|
@@ -488,23 +488,24 @@ interface ScoringConfig {
|
|
|
488
488
|
saveTo?: string;
|
|
489
489
|
}
|
|
490
490
|
/**
|
|
491
|
-
* Default weights for known tools.
|
|
492
|
-
*
|
|
491
|
+
* Default weights for known tools. Weights sum to 100 and read directly as
|
|
492
|
+
* percentage contribution to the overall score.
|
|
493
|
+
* New tools get weight of 5 if not specified.
|
|
493
494
|
*
|
|
494
495
|
* Weight philosophy:
|
|
495
|
-
* - pattern-detect (
|
|
496
|
+
* - pattern-detect (22%): Semantic duplication directly wastes token budget and
|
|
496
497
|
* confuses AI with contradictory in-context examples.
|
|
497
|
-
* - context-analyzer (
|
|
498
|
+
* - context-analyzer (19%): Context limits are the primary hard constraint on
|
|
498
499
|
* AI effectiveness regardless of model size.
|
|
499
|
-
* - consistency (
|
|
500
|
+
* - consistency (14%): Naming/pattern inconsistency degrades AI intent understanding
|
|
500
501
|
* proportionally to codebase size.
|
|
501
|
-
* -
|
|
502
|
+
* - ai-signal-clarity (11%): Code patterns empirically causing AI to generate
|
|
502
503
|
* confidently wrong outputs — critical for agentic use cases.
|
|
503
|
-
* - agent-grounding (
|
|
504
|
+
* - agent-grounding (10%): How well an autonomous agent can navigate unaided —
|
|
504
505
|
* increasingly important as agentic workflows grow.
|
|
505
|
-
* - testability (
|
|
506
|
-
* - doc-drift (
|
|
507
|
-
* - deps (
|
|
506
|
+
* - testability (10%): AI changes without verifiability create hidden risk.
|
|
507
|
+
* - doc-drift (8%): Stale docs actively mislead AI; planned spoke.
|
|
508
|
+
* - deps (6%): Dependency health affects AI suggestion accuracy; planned spoke.
|
|
508
509
|
*/
|
|
509
510
|
declare const DEFAULT_TOOL_WEIGHTS: Record<string, number>;
|
|
510
511
|
/**
|
package/dist/client.js
CHANGED
|
@@ -75,21 +75,21 @@ var ParseError = class extends Error {
|
|
|
75
75
|
|
|
76
76
|
// src/scoring.ts
|
|
77
77
|
var DEFAULT_TOOL_WEIGHTS = {
|
|
78
|
-
"pattern-detect":
|
|
79
|
-
"context-analyzer":
|
|
80
|
-
"consistency":
|
|
81
|
-
"
|
|
82
|
-
"agent-grounding":
|
|
83
|
-
"testability":
|
|
84
|
-
"doc-drift":
|
|
85
|
-
"deps":
|
|
78
|
+
"pattern-detect": 22,
|
|
79
|
+
"context-analyzer": 19,
|
|
80
|
+
"consistency": 14,
|
|
81
|
+
"ai-signal-clarity": 11,
|
|
82
|
+
"agent-grounding": 10,
|
|
83
|
+
"testability": 10,
|
|
84
|
+
"doc-drift": 8,
|
|
85
|
+
"deps": 6
|
|
86
86
|
};
|
|
87
87
|
var TOOL_NAME_MAP = {
|
|
88
88
|
"patterns": "pattern-detect",
|
|
89
89
|
"context": "context-analyzer",
|
|
90
90
|
"consistency": "consistency",
|
|
91
|
-
"
|
|
92
|
-
"
|
|
91
|
+
"AI signal clarity": "ai-signal-clarity",
|
|
92
|
+
"ai-signal-clarity": "ai-signal-clarity",
|
|
93
93
|
"grounding": "agent-grounding",
|
|
94
94
|
"agent-grounding": "agent-grounding",
|
|
95
95
|
"testability": "testability",
|
|
@@ -139,7 +139,7 @@ function getToolWeight(toolName, toolConfig, cliOverride) {
|
|
|
139
139
|
if (toolConfig?.scoreWeight !== void 0) {
|
|
140
140
|
return toolConfig.scoreWeight;
|
|
141
141
|
}
|
|
142
|
-
return DEFAULT_TOOL_WEIGHTS[toolName] ||
|
|
142
|
+
return DEFAULT_TOOL_WEIGHTS[toolName] || 5;
|
|
143
143
|
}
|
|
144
144
|
function parseWeightString(weightStr) {
|
|
145
145
|
const weights = /* @__PURE__ */ new Map();
|