brakit 0.10.0 → 0.10.1
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/api.d.ts +6 -5
- package/dist/api.js +23 -15
- package/dist/bin/brakit.js +120 -25
- package/dist/dashboard-client.global.js +470 -424
- package/dist/dashboard.html +558 -472
- package/dist/mcp/server.js +98 -22
- package/dist/runtime/index.js +361 -269
- package/package.json +1 -1
package/dist/mcp/server.js
CHANGED
|
@@ -31,14 +31,10 @@ var DASHBOARD_API_GRAPH = `${DASHBOARD_PREFIX}/api/graph`;
|
|
|
31
31
|
var VALID_TABS_TUPLE = [
|
|
32
32
|
"overview",
|
|
33
33
|
"actions",
|
|
34
|
-
"
|
|
35
|
-
"fetches",
|
|
36
|
-
"queries",
|
|
37
|
-
"errors",
|
|
38
|
-
"logs",
|
|
34
|
+
"insights",
|
|
39
35
|
"performance",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
36
|
+
"graph",
|
|
37
|
+
"explorer"
|
|
42
38
|
];
|
|
43
39
|
var VALID_TABS = new Set(VALID_TABS_TUPLE);
|
|
44
40
|
|
|
@@ -53,7 +49,7 @@ var MAX_DISCOVERY_DEPTH = 5;
|
|
|
53
49
|
var MAX_TIMELINE_EVENTS = 20;
|
|
54
50
|
var MAX_RESOLVED_DISPLAY = 5;
|
|
55
51
|
var ENRICHMENT_SEVERITY_FILTER = ["critical", "warning"];
|
|
56
|
-
var MCP_SERVER_VERSION = "0.10.
|
|
52
|
+
var MCP_SERVER_VERSION = "0.10.1";
|
|
57
53
|
var RECOVERY_WINDOW_MS = 5 * 60 * 1e3;
|
|
58
54
|
var PORT_MIN = 1;
|
|
59
55
|
var PORT_MAX = 65535;
|
|
@@ -263,10 +259,27 @@ async function enrichFindings(client) {
|
|
|
263
259
|
if (reqData.requests.length > 0) {
|
|
264
260
|
const req = reqData.requests[0];
|
|
265
261
|
if (req.id) {
|
|
266
|
-
const activity = await
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
262
|
+
const [activity, queries, fetches] = await Promise.all([
|
|
263
|
+
client.getActivity(req.id),
|
|
264
|
+
client.getQueries(req.id),
|
|
265
|
+
client.getFetches(req.id)
|
|
266
|
+
]);
|
|
267
|
+
const lines = [`Request took ${req.durationMs}ms.`];
|
|
268
|
+
if (queries.entries.length > 0) {
|
|
269
|
+
lines.push(`DB Queries (${queries.entries.length}):`);
|
|
270
|
+
for (const q of queries.entries.slice(0, 5)) {
|
|
271
|
+
const sql = q.sql ?? `${q.operation ?? ""} ${q.table ?? q.model ?? ""}`;
|
|
272
|
+
lines.push(` [${q.durationMs}ms] ${sql}`);
|
|
273
|
+
}
|
|
274
|
+
if (queries.entries.length > 5) lines.push(` ... and ${queries.entries.length - 5} more`);
|
|
275
|
+
}
|
|
276
|
+
if (fetches.entries.length > 0) {
|
|
277
|
+
lines.push(`Fetches (${fetches.entries.length}):`);
|
|
278
|
+
for (const f of fetches.entries.slice(0, 3)) {
|
|
279
|
+
lines.push(` [${f.durationMs}ms] ${f.method} ${f.url} \u2192 ${f.statusCode}`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return lines.join("\n");
|
|
270
283
|
}
|
|
271
284
|
}
|
|
272
285
|
} catch {
|
|
@@ -382,6 +395,9 @@ var getFindings = {
|
|
|
382
395
|
return { content: [{ type: "text", text: `Invalid state "${state}". Use: open, fixing, resolved, stale, regressed.` }], isError: true };
|
|
383
396
|
}
|
|
384
397
|
let findings = await enrichFindings(client);
|
|
398
|
+
if (!state) {
|
|
399
|
+
findings = findings.filter((f) => f.aiStatus !== "wont_fix");
|
|
400
|
+
}
|
|
385
401
|
if (severity) {
|
|
386
402
|
findings = findings.filter((f) => f.severity === severity);
|
|
387
403
|
}
|
|
@@ -393,21 +409,25 @@ var getFindings = {
|
|
|
393
409
|
if (findings.length === 0) {
|
|
394
410
|
return { content: [{ type: "text", text: "No findings detected. The application looks healthy." }] };
|
|
395
411
|
}
|
|
396
|
-
const lines = [
|
|
397
|
-
`
|
|
412
|
+
const lines = [
|
|
413
|
+
`Found ${findings.length} issue(s). Full context included below \u2014 no need to call get_request_detail separately.`,
|
|
414
|
+
`After fixing, call report_fixes ONCE with all results.
|
|
415
|
+
`
|
|
416
|
+
];
|
|
398
417
|
for (const f of findings) {
|
|
399
418
|
lines.push(`[${f.severity.toUpperCase()}] ${f.title}`);
|
|
400
419
|
lines.push(` ID: ${f.findingId}`);
|
|
401
420
|
lines.push(` Endpoint: ${f.endpoint}`);
|
|
402
421
|
lines.push(` Issue: ${f.description}`);
|
|
403
|
-
if (f.context)
|
|
422
|
+
if (f.context) {
|
|
423
|
+
for (const ctxLine of f.context.split("\n")) {
|
|
424
|
+
lines.push(` ${ctxLine}`);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
404
427
|
lines.push(` Fix: ${f.hint}`);
|
|
405
428
|
if (f.aiStatus === "fixed") {
|
|
406
429
|
lines.push(` AI Status: fixed (awaiting verification)`);
|
|
407
430
|
if (f.aiNotes) lines.push(` AI Notes: ${f.aiNotes}`);
|
|
408
|
-
} else if (f.aiStatus === "wont_fix") {
|
|
409
|
-
lines.push(` AI Status: won't fix`);
|
|
410
|
-
if (f.aiNotes) lines.push(` AI Notes: ${f.aiNotes}`);
|
|
411
431
|
}
|
|
412
432
|
lines.push("");
|
|
413
433
|
}
|
|
@@ -752,9 +772,65 @@ var reportFix = {
|
|
|
752
772
|
}
|
|
753
773
|
};
|
|
754
774
|
|
|
775
|
+
// src/mcp/tools/report-fixes.ts
|
|
776
|
+
var reportFixes = {
|
|
777
|
+
name: "report_fixes",
|
|
778
|
+
description: "Report results for multiple findings in a single call. Use this instead of calling report_fix repeatedly \u2014 it's faster and requires only one confirmation. Pass a JSON array string where each item has finding_id, status ('fixed' or 'wont_fix'), and summary.",
|
|
779
|
+
inputSchema: {
|
|
780
|
+
type: "object",
|
|
781
|
+
properties: {
|
|
782
|
+
fixes: {
|
|
783
|
+
type: "string",
|
|
784
|
+
description: 'JSON array of fix reports. Example: [{"finding_id":"abc123","status":"fixed","summary":"Added input validation"}]'
|
|
785
|
+
}
|
|
786
|
+
},
|
|
787
|
+
required: ["fixes"]
|
|
788
|
+
},
|
|
789
|
+
async handler(client, args) {
|
|
790
|
+
let fixes;
|
|
791
|
+
try {
|
|
792
|
+
const raw = typeof args.fixes === "string" ? JSON.parse(args.fixes) : args.fixes;
|
|
793
|
+
if (!Array.isArray(raw) || raw.length === 0) {
|
|
794
|
+
return { content: [{ type: "text", text: "fixes must be a non-empty JSON array." }], isError: true };
|
|
795
|
+
}
|
|
796
|
+
fixes = raw.filter(
|
|
797
|
+
(item) => typeof item === "object" && item !== null && typeof item.finding_id === "string" && typeof item.status === "string" && typeof item.summary === "string"
|
|
798
|
+
);
|
|
799
|
+
if (fixes.length === 0) {
|
|
800
|
+
return { content: [{ type: "text", text: "No valid fix entries found. Each entry needs finding_id, status, and summary." }], isError: true };
|
|
801
|
+
}
|
|
802
|
+
} catch {
|
|
803
|
+
return { content: [{ type: "text", text: "fixes must be valid JSON." }], isError: true };
|
|
804
|
+
}
|
|
805
|
+
const results = [];
|
|
806
|
+
let errors = 0;
|
|
807
|
+
for (const fix of fixes) {
|
|
808
|
+
if (!fix.finding_id || !isValidAiFixStatus(fix.status) || !fix.summary) {
|
|
809
|
+
results.push(`\u2717 Invalid entry: ${fix.finding_id || "missing ID"}`);
|
|
810
|
+
errors++;
|
|
811
|
+
continue;
|
|
812
|
+
}
|
|
813
|
+
const ok = await client.reportFix(fix.finding_id, fix.status, fix.summary);
|
|
814
|
+
if (ok) {
|
|
815
|
+
const label = fix.status === "fixed" ? "fixed" : "won't fix";
|
|
816
|
+
results.push(`\u2713 ${fix.finding_id} \u2192 ${label}`);
|
|
817
|
+
} else {
|
|
818
|
+
results.push(`\u2717 ${fix.finding_id} \u2192 not found`);
|
|
819
|
+
errors++;
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
const errorSuffix = errors > 0 ? ` (${errors} error${errors !== 1 ? "s" : ""})` : "";
|
|
823
|
+
const summary = `Processed ${fixes.length} finding(s)${errorSuffix}. Dashboard updated.`;
|
|
824
|
+
return {
|
|
825
|
+
content: [{ type: "text", text: summary + "\n\n" + results.join("\n") }],
|
|
826
|
+
...errors > 0 ? { isError: true } : {}
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
|
|
755
831
|
// src/mcp/tools/index.ts
|
|
756
832
|
var TOOL_MAP = new Map(
|
|
757
|
-
[getFindings, getEndpoints, getRequestDetail, verifyFix, getReport, clearFindings, reportFix].map((t) => [t.name, t])
|
|
833
|
+
[getFindings, getEndpoints, getRequestDetail, verifyFix, getReport, clearFindings, reportFix, reportFixes].map((t) => [t.name, t])
|
|
758
834
|
);
|
|
759
835
|
function getToolDefinitions() {
|
|
760
836
|
return [...TOOL_MAP.values()].map((t) => ({
|
|
@@ -775,7 +851,7 @@ function handleToolCall(client, name, args) {
|
|
|
775
851
|
}
|
|
776
852
|
|
|
777
853
|
// src/mcp/prompts.ts
|
|
778
|
-
var SERVER_INSTRUCTIONS = "Brakit is a dev tool that monitors your running app for security vulnerabilities, performance issues, and query problems. IMPORTANT: After fixing
|
|
854
|
+
var SERVER_INSTRUCTIONS = "Brakit is a dev tool that monitors your running app for security vulnerabilities, performance issues, and query problems. IMPORTANT: After fixing brakit findings, call report_fixes (batch) with all results at once instead of calling report_fix individually. This is faster and requires only one confirmation.";
|
|
779
855
|
var PROMPTS = [
|
|
780
856
|
{
|
|
781
857
|
name: "check-app",
|
|
@@ -787,8 +863,8 @@ var PROMPTS = [
|
|
|
787
863
|
}
|
|
788
864
|
];
|
|
789
865
|
var PROMPT_MESSAGES = {
|
|
790
|
-
"check-app": "Check my running app for security and performance issues using brakit. First get all findings, then get the endpoint summary. For any critical or warning findings, get the request detail to understand the root cause. Give me a clear report of what's wrong and offer to fix each issue. After fixing
|
|
791
|
-
"fix-findings": "Get all open brakit findings. For each finding:\n1. Get the request detail to understand the exact issue\n2. Find the source code responsible and fix it\n3.
|
|
866
|
+
"check-app": "Check my running app for security and performance issues using brakit. First get all findings, then get the endpoint summary. For any critical or warning findings, get the request detail to understand the root cause. Give me a clear report of what's wrong and offer to fix each issue. After fixing issues, call report_fixes once with all results.",
|
|
867
|
+
"fix-findings": "Get all open brakit findings. For each finding:\n1. Get the request detail to understand the exact issue\n2. Find the source code responsible and fix it\n3. Track the finding_id, status ('fixed' or 'wont_fix'), and a brief summary\n\nAfter processing ALL findings, call report_fixes ONCE with the full array of results. Do not call report_fix individually for each finding.\n\nAfter reporting, ask me to re-trigger the endpoints so brakit can verify the fixes."
|
|
792
868
|
};
|
|
793
869
|
|
|
794
870
|
// src/mcp/server.ts
|