@0x1f320.sh/why-did-you-render-mcp 1.0.0-dev.11 → 1.0.0-dev.13
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/server/index.js +46 -11
- package/package.json +3 -4
package/dist/server/index.js
CHANGED
|
@@ -276,6 +276,18 @@ var RenderStore = class {
|
|
|
276
276
|
}
|
|
277
277
|
return summary;
|
|
278
278
|
}
|
|
279
|
+
getSummaryByCommit(projectId) {
|
|
280
|
+
const renders = this.getAllRenders(projectId);
|
|
281
|
+
const summary = {};
|
|
282
|
+
for (const r of renders) {
|
|
283
|
+
if (r.commitId == null) continue;
|
|
284
|
+
summary[r.project] ??= {};
|
|
285
|
+
summary[r.project][r.commitId] ??= {};
|
|
286
|
+
const commit = summary[r.project][r.commitId];
|
|
287
|
+
commit[r.displayName] = (commit[r.displayName] ?? 0) + 1;
|
|
288
|
+
}
|
|
289
|
+
return summary;
|
|
290
|
+
}
|
|
279
291
|
bufferKey(projectId, commitId) {
|
|
280
292
|
return `${projectId}\0${commitId ?? NOCOMMIT}`;
|
|
281
293
|
}
|
|
@@ -388,21 +400,44 @@ function register$3(server) {
|
|
|
388
400
|
function register$2(server) {
|
|
389
401
|
server.registerTool("get_render_summary", {
|
|
390
402
|
title: "Get Render Summary",
|
|
391
|
-
description: "Returns a summary of re-renders grouped by component name with counts. If multiple projects are active and no project is specified, the tool will ask you to disambiguate.",
|
|
392
|
-
inputSchema: {
|
|
393
|
-
|
|
403
|
+
description: "Returns a summary of re-renders grouped by component name with counts. Use groupBy: 'commit' to get per-commit breakdowns instead of a single aggregate. If multiple projects are active and no project is specified, the tool will ask you to disambiguate.",
|
|
404
|
+
inputSchema: {
|
|
405
|
+
project: z.string().optional().describe("Project identifier (the browser's origin URL, e.g. http://localhost:3000). Omit to auto-detect."),
|
|
406
|
+
groupBy: z.enum(["commit"]).optional().describe("Group results by commit. When set to 'commit', returns per-commit render summaries instead of a single aggregate.")
|
|
407
|
+
}
|
|
408
|
+
}, async ({ project, groupBy }) => {
|
|
394
409
|
const resolved = resolveProject(project);
|
|
395
410
|
if (resolved.error) return textResult(resolved.error);
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
const lines = [];
|
|
399
|
-
for (const [projectId, components] of Object.entries(summary)) {
|
|
400
|
-
lines.push(`[${projectId}]`);
|
|
401
|
-
for (const [name, count] of Object.entries(components)) lines.push(` ${name}: ${count} re-render(s)`);
|
|
402
|
-
}
|
|
403
|
-
return textResult(`Re-render summary:\n\n${lines.join("\n")}`);
|
|
411
|
+
if (groupBy === "commit") return commitSummary(resolved.projectId);
|
|
412
|
+
return aggregateSummary(resolved.projectId);
|
|
404
413
|
});
|
|
405
414
|
}
|
|
415
|
+
function aggregateSummary(projectId) {
|
|
416
|
+
const summary = store.getSummary(projectId);
|
|
417
|
+
if (Object.keys(summary).length === 0) return textResult("No renders recorded yet.");
|
|
418
|
+
const lines = [];
|
|
419
|
+
for (const [proj, components] of Object.entries(summary)) {
|
|
420
|
+
lines.push(`[${proj}]`);
|
|
421
|
+
for (const [name, count] of Object.entries(components)) lines.push(` ${name}: ${count} re-render(s)`);
|
|
422
|
+
}
|
|
423
|
+
return textResult(`Re-render summary:\n\n${lines.join("\n")}`);
|
|
424
|
+
}
|
|
425
|
+
function commitSummary(projectId) {
|
|
426
|
+
const summary = store.getSummaryByCommit(projectId);
|
|
427
|
+
if (Object.keys(summary).length === 0) return textResult("No renders with commit IDs recorded yet.");
|
|
428
|
+
const lines = [];
|
|
429
|
+
for (const [proj, commits] of Object.entries(summary)) {
|
|
430
|
+
lines.push(`[${proj}]`);
|
|
431
|
+
const sortedCommitIds = Object.keys(commits).map(Number).sort((a, b) => a - b);
|
|
432
|
+
for (const commitId of sortedCommitIds) {
|
|
433
|
+
const components = commits[commitId];
|
|
434
|
+
const total = Object.values(components).reduce((s, c) => s + c, 0);
|
|
435
|
+
lines.push(` Commit #${commitId} (${total} re-render(s)):`);
|
|
436
|
+
for (const [name, count] of Object.entries(components)) lines.push(` ${name}: ${count}`);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return textResult(`Re-render summary (by commit):\n\n${lines.join("\n")}`);
|
|
440
|
+
}
|
|
406
441
|
//#endregion
|
|
407
442
|
//#region src/server/tools/get-renders-by-commit.ts
|
|
408
443
|
function register$1(server) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0x1f320.sh/why-did-you-render-mcp",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "MCP server that collects why-did-you-render data from browser and exposes it to coding agents",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,9 +34,7 @@
|
|
|
34
34
|
"require": "./dist/client/index.cjs"
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
"files": [
|
|
38
|
-
"dist"
|
|
39
|
-
],
|
|
37
|
+
"files": ["dist"],
|
|
40
38
|
"scripts": {
|
|
41
39
|
"build": "tsdown",
|
|
42
40
|
"dev": "tsdown --watch",
|
|
@@ -56,6 +54,7 @@
|
|
|
56
54
|
"devDependencies": {
|
|
57
55
|
"@biomejs/biome": "^1.9.4",
|
|
58
56
|
"@semantic-release/changelog": "^6.0.3",
|
|
57
|
+
"@semantic-release/exec": "^7.1.0",
|
|
59
58
|
"@semantic-release/git": "^10.0.1",
|
|
60
59
|
"@types/node": "^22.14.1",
|
|
61
60
|
"@types/ws": "^8.18.0",
|