openkrak-mcp 1.0.4 → 1.0.5
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/dist/index.js +39 -25
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -244914,46 +244914,60 @@ async function handleGetMahadata(args) {
|
|
|
244914
244914
|
const repo = m.repository;
|
|
244915
244915
|
const hotspots = m.hotspots ?? [];
|
|
244916
244916
|
const blastRadius = m.blast_radius ?? [];
|
|
244917
|
+
const findings = m.findings ?? [];
|
|
244917
244918
|
if (!brief) {
|
|
244918
244919
|
return {
|
|
244919
244920
|
content: [{ type: "text", text: "OpenKrak: no execution_brief generated." }],
|
|
244920
244921
|
isError: true
|
|
244921
244922
|
};
|
|
244922
244923
|
}
|
|
244924
|
+
const totalFiles = Number(repo?.total_files ?? 0);
|
|
244925
|
+
const hotspotLimit = totalFiles < 50 ? 3 : totalFiles < 200 ? 5 : totalFiles < 500 ? 8 : 12;
|
|
244926
|
+
const blastLimit = totalFiles < 50 ? 3 : totalFiles < 200 ? 5 : 8;
|
|
244927
|
+
const findingLimit = totalFiles < 50 ? 3 : totalFiles < 200 ? 5 : 10;
|
|
244923
244928
|
const ctx = brief.critical_context ?? [];
|
|
244924
|
-
const ph = brief.priority_hotspots ?? [];
|
|
244925
244929
|
const ep = brief.recommended_entry_points ?? [];
|
|
244926
244930
|
const constraints = brief.constraints ?? [];
|
|
244927
|
-
const blockers =
|
|
244928
|
-
const warnings =
|
|
244929
|
-
const topHotspots = hotspots.slice(0, 3).map((h) => {
|
|
244930
|
-
const hs = h;
|
|
244931
|
-
return `${hs.path}[${hs.risk_level},${Number(hs.score).toFixed(2)}]`;
|
|
244932
|
-
});
|
|
244933
|
-
const topBlast = blastRadius.slice(0, 3).map((b) => {
|
|
244934
|
-
const br = b;
|
|
244935
|
-
return `${br.trigger_file}\u2192${br.total_affected_files}files`;
|
|
244936
|
-
});
|
|
244931
|
+
const blockers = threat?.blockers ?? [];
|
|
244932
|
+
const warnings = threat?.warnings ?? [];
|
|
244937
244933
|
const lines = [
|
|
244938
|
-
`[MAHADATA
|
|
244939
|
-
`
|
|
244940
|
-
`objective
|
|
244941
|
-
`summary
|
|
244934
|
+
`[MAHADATA] repo:${repo?.name ?? args.path}`,
|
|
244935
|
+
`lang:${repo?.primary_language ?? "?"} | files:${repo?.total_files ?? "?"} | loc:${repo?.total_loc ?? "?"} | framework:${repo?.framework ?? "none"}`,
|
|
244936
|
+
`objective: ${brief.objective}`,
|
|
244937
|
+
`summary: ${brief.repository_summary}`,
|
|
244942
244938
|
``,
|
|
244943
|
-
`
|
|
244939
|
+
`CONTEXT:`,
|
|
244940
|
+
...ctx.map((c) => ` ${c.key}: ${c.value}`),
|
|
244944
244941
|
``,
|
|
244945
|
-
`HOTSPOTS(
|
|
244946
|
-
|
|
244942
|
+
`HOTSPOTS (${hotspots.length} total, top ${Math.min(hotspotLimit, hotspots.length)}):`,
|
|
244943
|
+
...hotspots.slice(0, hotspotLimit).map((h) => {
|
|
244944
|
+
const hs = h;
|
|
244945
|
+
const reasons = hs.reasons ?? [];
|
|
244946
|
+
return ` [${hs.risk_level}] ${hs.path} score:${Number(hs.score).toFixed(2)} changes:${hs.change_frequency} \u2014 ${reasons.map((r) => r.type).join(", ")}`;
|
|
244947
|
+
}),
|
|
244947
244948
|
``,
|
|
244948
|
-
`
|
|
244949
|
-
...
|
|
244949
|
+
`BLAST RADIUS (top ${Math.min(blastLimit, blastRadius.length)}):`,
|
|
244950
|
+
...blastRadius.slice(0, blastLimit).map((b) => {
|
|
244951
|
+
const br = b;
|
|
244952
|
+
return ` ${br.trigger_file} \u2192 affects ${br.total_affected_files} files, ${br.total_affected_modules} modules (risk:${Number(br.risk_score).toFixed(2)})`;
|
|
244953
|
+
}),
|
|
244950
244954
|
``,
|
|
244951
|
-
`
|
|
244952
|
-
|
|
244955
|
+
`ENTRY POINTS:`,
|
|
244956
|
+
...ep.map((e) => ` ${e.path}${e.symbol ? `::${e.symbol}` : ""} \u2014 ${e.reason}`),
|
|
244953
244957
|
``,
|
|
244954
|
-
`
|
|
244955
|
-
|
|
244956
|
-
|
|
244958
|
+
`CONSTRAINTS: ${constraints.join(" | ")}`,
|
|
244959
|
+
``,
|
|
244960
|
+
`THREAT: overall_risk=${Number(threat?.overall_risk_score ?? 0).toFixed(2)} | ${threat?.risk_summary ?? ""}`,
|
|
244961
|
+
blockers.length > 0 ? `BLOCKERS (${blockers.length}): ${blockers.slice(0, 3).map((b) => b.description ?? b).join(" | ")}` : `BLOCKERS: none`,
|
|
244962
|
+
warnings.length > 0 ? `WARNINGS (${warnings.length}): ${warnings.slice(0, 5).map((w) => w.description ?? w).join(" | ")}` : `WARNINGS: none`,
|
|
244963
|
+
``,
|
|
244964
|
+
findings.length > 0 ? `FINDINGS (${findings.length} total, top ${Math.min(findingLimit, findings.length)}):` : null,
|
|
244965
|
+
...findings.slice(0, findingLimit).map((f) => {
|
|
244966
|
+
const fi = f;
|
|
244967
|
+
return ` [${fi.severity ?? fi.type}] ${fi.file ?? fi.path} \u2014 ${fi.message ?? fi.description ?? ""}`;
|
|
244968
|
+
})
|
|
244969
|
+
].filter((l) => l !== null);
|
|
244970
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
244957
244971
|
}
|
|
244958
244972
|
|
|
244959
244973
|
// src/license/check.ts
|