mumei-dashboard 0.2.1 → 0.2.2
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 +49 -23
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -44714,18 +44714,28 @@ async function latestReview(reviewsDir) {
|
|
|
44714
44714
|
}
|
|
44715
44715
|
}
|
|
44716
44716
|
async function loadCost(args) {
|
|
44717
|
-
|
|
44718
|
-
let totalOutput = 0;
|
|
44719
|
-
let totalCacheRead = 0;
|
|
44717
|
+
const merged = /* @__PURE__ */ new Map();
|
|
44720
44718
|
for (const file of [args.perFeatureFile, args.projectWideFile]) {
|
|
44721
44719
|
for await (const e of readJsonl(file)) {
|
|
44722
44720
|
if (e.phase !== "after") continue;
|
|
44723
44721
|
if (file === args.projectWideFile && e.feature !== args.featureKey) continue;
|
|
44724
|
-
|
|
44725
|
-
|
|
44726
|
-
|
|
44722
|
+
const key = `${e.agent ?? ""} ${e.ts ?? ""}`;
|
|
44723
|
+
const prev = merged.get(key) ?? { input: 0, output: 0, cacheRead: 0 };
|
|
44724
|
+
merged.set(key, {
|
|
44725
|
+
input: Math.max(prev.input, e.input_tokens ?? 0),
|
|
44726
|
+
output: Math.max(prev.output, e.output_tokens ?? 0),
|
|
44727
|
+
cacheRead: Math.max(prev.cacheRead, e.cache_read_input_tokens ?? 0)
|
|
44728
|
+
});
|
|
44727
44729
|
}
|
|
44728
44730
|
}
|
|
44731
|
+
let totalInput = 0;
|
|
44732
|
+
let totalOutput = 0;
|
|
44733
|
+
let totalCacheRead = 0;
|
|
44734
|
+
for (const acc of merged.values()) {
|
|
44735
|
+
totalInput += acc.input;
|
|
44736
|
+
totalOutput += acc.output;
|
|
44737
|
+
totalCacheRead += acc.cacheRead;
|
|
44738
|
+
}
|
|
44729
44739
|
const denom = totalInput + totalCacheRead;
|
|
44730
44740
|
return {
|
|
44731
44741
|
tokens: totalInput + totalOutput,
|
|
@@ -47115,31 +47125,47 @@ function renderBanner(addr) {
|
|
|
47115
47125
|
const mascotW = Math.max(...mascotLines.map((l) => l.length));
|
|
47116
47126
|
const SEP = " ";
|
|
47117
47127
|
const combinedW = logoW + SEP.length + mascotW;
|
|
47118
|
-
const
|
|
47119
|
-
const
|
|
47120
|
-
const mascotTop = Math.floor((totalH - mascotLines.length) / 2);
|
|
47128
|
+
const envCols = Number(process.env.COLUMNS ?? "0");
|
|
47129
|
+
const termW = process.stdout.columns && process.stdout.columns > 0 ? process.stdout.columns : envCols > 0 ? envCols : 80;
|
|
47121
47130
|
const padLine = (arr, top, w, i) => {
|
|
47122
47131
|
const idx = i - top;
|
|
47123
47132
|
const line = idx >= 0 && idx < arr.length ? arr[idx] : void 0;
|
|
47124
47133
|
return (line ?? "").padEnd(w);
|
|
47125
47134
|
};
|
|
47126
|
-
const
|
|
47127
|
-
|
|
47128
|
-
|
|
47129
|
-
|
|
47130
|
-
const l = padLine(logoLines, logoTop, logoW, i);
|
|
47131
|
-
const m = padLine(mascotLines, mascotTop, mascotW, i);
|
|
47132
|
-
rows.push(`${leftPad}${l}${SEP}${m}`.replace(/\s+$/, ""));
|
|
47133
|
-
}
|
|
47135
|
+
const center = (lines, blockW) => {
|
|
47136
|
+
const left = " ".repeat(Math.max(0, Math.floor((termW - blockW) / 2)));
|
|
47137
|
+
return lines.map((l) => `${left}${l}`.replace(/\s+$/, ""));
|
|
47138
|
+
};
|
|
47134
47139
|
const info = [
|
|
47135
|
-
|
|
47136
|
-
|
|
47137
|
-
|
|
47138
|
-
]
|
|
47140
|
+
`Dashboard: ${addr}`,
|
|
47141
|
+
`Project root: ${PROJECT_ROOT}`,
|
|
47142
|
+
`.mumei dir: ${MUMEI_DIR}`
|
|
47143
|
+
];
|
|
47144
|
+
const infoW = Math.max(...info.map((l) => l.length));
|
|
47145
|
+
let drawing;
|
|
47146
|
+
let infoCentered;
|
|
47147
|
+
if (termW >= combinedW + 2) {
|
|
47148
|
+
const totalH = Math.max(logoLines.length, mascotLines.length);
|
|
47149
|
+
const logoTop = Math.floor((totalH - logoLines.length) / 2);
|
|
47150
|
+
const mascotTop = Math.floor((totalH - mascotLines.length) / 2);
|
|
47151
|
+
const rows = [];
|
|
47152
|
+
for (let i = 0; i < totalH; i++) {
|
|
47153
|
+
const l = padLine(logoLines, logoTop, logoW, i);
|
|
47154
|
+
const m = padLine(mascotLines, mascotTop, mascotW, i);
|
|
47155
|
+
rows.push(`${l}${SEP}${m}`);
|
|
47156
|
+
}
|
|
47157
|
+
drawing = center(rows, combinedW);
|
|
47158
|
+
infoCentered = center(info, combinedW);
|
|
47159
|
+
} else {
|
|
47160
|
+
const logoCentered = center(logoLines, logoW);
|
|
47161
|
+
const mascotCentered = center(mascotLines, mascotW);
|
|
47162
|
+
drawing = [...logoCentered, "", ...mascotCentered];
|
|
47163
|
+
infoCentered = center(info, Math.max(infoW, mascotW, logoW));
|
|
47164
|
+
}
|
|
47139
47165
|
return `
|
|
47140
|
-
${
|
|
47166
|
+
${drawing.join("\n")}
|
|
47141
47167
|
|
|
47142
|
-
${
|
|
47168
|
+
${infoCentered.join("\n")}
|
|
47143
47169
|
|
|
47144
47170
|
`;
|
|
47145
47171
|
}
|