sigrank 1.0.47 → 1.0.49
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/CHANGELOG.md +12 -0
- package/MCP_SERVER_DESCRIPTION.md +3 -3
- package/README.md +90 -424
- package/adapters/index.mjs +34 -4
- package/lib/constants.mjs +3 -0
- package/lib/update-check.mjs +139 -0
- package/manifest.json +1 -1
- package/package.json +2 -2
- package/presentation/cli.mjs +61 -80
- package/presentation/tui.mjs +175 -109
- package/resources/privacy-model.md +4 -4
- package/tools/_multi.mjs +64 -0
- package/tools/index.mjs +12 -1
- package/tools/submit-verified.mjs +3 -15
- package/tools/tokenpull-submit.mjs +3 -15
- package/tools/tokenpull.mjs +3 -15
- package/tools/watch-tokenpull.mjs +14 -3
package/presentation/tui.mjs
CHANGED
|
@@ -24,12 +24,18 @@ import os from "os";
|
|
|
24
24
|
import path from "path";
|
|
25
25
|
import { pathToFileURL } from "node:url";
|
|
26
26
|
import { pkgVersion } from "../lib/pkg-version.mjs";
|
|
27
|
+
import { cachedUpdateNotice, checkForUpdate } from "../lib/update-check.mjs";
|
|
27
28
|
import { LEADERBOARD_METRIC } from "../lib/constants.mjs";
|
|
28
29
|
|
|
29
30
|
// Version read from the shared pkg-version helper (single source of truth —
|
|
30
31
|
// matches cli.mjs; never hardcode, that's what caused the version drift).
|
|
31
32
|
const VERSION = pkgVersion();
|
|
32
33
|
|
|
34
|
+
// "sigrank X available" text for the header; null unless runTui found a newer
|
|
35
|
+
// release (cached result at launch, registry refresh in the background).
|
|
36
|
+
let _updateNotice = null;
|
|
37
|
+
const _updateVersion = () => (_updateNotice ? _updateNotice.split(" ")[1] : null);
|
|
38
|
+
|
|
33
39
|
// Expensive platform readers that the Dashboard only runs on explicit user
|
|
34
40
|
// request. They remain in ALL_PLATFORMS and are still available to me, watch,
|
|
35
41
|
// Compare, and MCP tool calls when the caller explicitly selects the platform.
|
|
@@ -438,9 +444,11 @@ async function loadDashboardData({ includeOmp = false, onPrimary } = {}) {
|
|
|
438
444
|
// primary platform (claude) FAST, then fill the rest in fillDashboardRest. This is the SAME loader
|
|
439
445
|
// `me` and `watch` use, so the three views can't drift apart. (Verifier comparison still runs
|
|
440
446
|
// FRESH + on-demand in the Compare tab — see loadCompareData — never on this Dashboard path.)
|
|
441
|
-
const
|
|
442
|
-
() => [],
|
|
447
|
+
const first = await pullActivePlatforms({ platforms: ["claude"] }).catch(
|
|
448
|
+
() => ({ active: [], failed: [{ platform: "claude", error: "read failed" }] }),
|
|
443
449
|
);
|
|
450
|
+
const active = first.active;
|
|
451
|
+
const failedReads = [...first.failed];
|
|
444
452
|
// PERF: hand the primary platform to the TUI the moment it lands, so Trends (and the cascade)
|
|
445
453
|
// can paint without waiting on the board/batched fetches (up to 5s each) below. The batched
|
|
446
454
|
// "all" override further down mutates these same objects in place.
|
|
@@ -478,6 +486,7 @@ async function loadDashboardData({ includeOmp = false, onPrimary } = {}) {
|
|
|
478
486
|
|
|
479
487
|
return {
|
|
480
488
|
active,
|
|
489
|
+
failed: failedReads,
|
|
481
490
|
verifierMap: {},
|
|
482
491
|
tdPillars: null,
|
|
483
492
|
boardData,
|
|
@@ -496,9 +505,20 @@ async function loadDashboardData({ includeOmp = false, onPrimary } = {}) {
|
|
|
496
505
|
const dashboardPlatformRank = (p) =>
|
|
497
506
|
p === "claude" ? -2 : p === "codex" ? -1 : ALL_PLATFORMS.indexOf(p);
|
|
498
507
|
|
|
508
|
+
// Replace one platform's failure state on every read: a later good read clears it.
|
|
509
|
+
function recordPlatformFailures(dashData, platform, failed) {
|
|
510
|
+
dashData.failed = [
|
|
511
|
+
...(dashData.failed || []).filter((f) => f.platform !== platform),
|
|
512
|
+
...(failed || []).filter((f) => f.platform === platform),
|
|
513
|
+
];
|
|
514
|
+
}
|
|
515
|
+
export const _applyPlatformReadForTest = (dashData, platform, { failed }) =>
|
|
516
|
+
recordPlatformFailures(dashData, platform, failed);
|
|
517
|
+
|
|
499
518
|
async function pullDashboardPlatform(dashData, platform) {
|
|
500
519
|
try {
|
|
501
|
-
const active = await pullActivePlatforms({ platforms: [platform] });
|
|
520
|
+
const { active, failed } = await pullActivePlatforms({ platforms: [platform] });
|
|
521
|
+
recordPlatformFailures(dashData, platform, failed);
|
|
502
522
|
for (const d of active) {
|
|
503
523
|
if (!dashData.active.find((a) => a.platform === d.platform)) {
|
|
504
524
|
// Apply the same batched "all" override as loadDashboardData so
|
|
@@ -749,7 +769,15 @@ function renderTabBar(activeIdx) {
|
|
|
749
769
|
? `${c.bgCyan}${c.boldCyan}${lbl}${c.reset}`
|
|
750
770
|
: `${c.bgDim}${c.dim}${lbl}${c.reset}`;
|
|
751
771
|
}).join("");
|
|
772
|
+
const upd = _updateVersion();
|
|
752
773
|
const rights = [
|
|
774
|
+
...(upd
|
|
775
|
+
? [
|
|
776
|
+
dim(`${gold("v" + VERSION)}${c.reset}${c.dim} · `) + gold(`⬆ ${_updateNotice}`),
|
|
777
|
+
dim(`${gold("v" + VERSION)}${c.reset}${c.dim} `) + gold(`⬆ ${upd} available`),
|
|
778
|
+
dim(`${gold("v" + VERSION)}${c.reset}${c.dim} `) + gold(`⬆ ${upd}`),
|
|
779
|
+
]
|
|
780
|
+
: []),
|
|
753
781
|
right,
|
|
754
782
|
dim(`${gold("v" + VERSION)}${c.reset}${c.dim} · signalaf.com`),
|
|
755
783
|
gold("v" + VERSION),
|
|
@@ -1031,34 +1059,55 @@ function metricSpark(d, pick, fmt) {
|
|
|
1031
1059
|
|
|
1032
1060
|
const DASH_WINS = ["7d", "30d", "90d", "all"];
|
|
1033
1061
|
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
)
|
|
1062
|
+
/**
|
|
1063
|
+
* Pure scroll-window layout for the cascade table. `rows` is the full ordered
|
|
1064
|
+
* row list ({ platform, notes }: notes = extra lines printed after that
|
|
1065
|
+
* platform's last visible row). `lineBudget` is the number of TERMINAL LINES the
|
|
1066
|
+
* table may use, so ▲/▼ markers, blank separators and notes are all counted —
|
|
1067
|
+
* the old row-count budget overflowed the frame and cut the lower sections off.
|
|
1068
|
+
* Returns the clamped offset, how many rows fit from there, and the exact
|
|
1069
|
+
* above/below counts the hints print.
|
|
1070
|
+
*/
|
|
1071
|
+
export function cascadeWindow(rows, offset, lineBudget) {
|
|
1072
|
+
const n = rows.length;
|
|
1073
|
+
const linesFor = (o, k) => {
|
|
1074
|
+
let lines = (o > 0 ? 1 : 0) + 1 + k + (o + k < n ? 1 : 0); // ▲ + trailing blank + rows + ▼
|
|
1075
|
+
let prev = null;
|
|
1076
|
+
for (let i = o; i < o + k; i++) {
|
|
1077
|
+
const p = rows[i].platform;
|
|
1078
|
+
if (prev !== null && p !== prev) lines += 1 + (rows[i - 1].notes || 0); // blank + note of the group that ended
|
|
1079
|
+
prev = p;
|
|
1080
|
+
}
|
|
1081
|
+
if (k > 0) lines += rows[o + k - 1].notes || 0; // note of the last visible group
|
|
1082
|
+
return lines;
|
|
1083
|
+
};
|
|
1084
|
+
const fit = (o) => {
|
|
1085
|
+
let k = 0;
|
|
1086
|
+
while (o + k < n && linesFor(o, k + 1) <= lineBudget) k++;
|
|
1087
|
+
return Math.max(1, Math.min(k, n - o));
|
|
1088
|
+
};
|
|
1089
|
+
let maxOffset = Math.max(0, n - 1);
|
|
1090
|
+
for (let o = 0; o < n; o++) {
|
|
1091
|
+
if (o + fit(o) >= n) {
|
|
1092
|
+
maxOffset = o;
|
|
1093
|
+
break;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
const eff = Math.max(0, Math.min(Number.isFinite(offset) ? offset : 0, maxOffset));
|
|
1097
|
+
const count = n === 0 ? 0 : fit(eff);
|
|
1098
|
+
return { offset: eff, count, maxOffset, above: eff, below: n - eff - count, total: n };
|
|
1046
1099
|
}
|
|
1047
1100
|
|
|
1048
|
-
//
|
|
1049
|
-
//
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
const platformCount = active.length;
|
|
1053
|
-
const barLines = 4 + platformCount + (platformCount > 1 ? 1 : 0);
|
|
1054
|
-
const boardLines = 17;
|
|
1055
|
-
const sectionsBelow = barLines + boardLines;
|
|
1056
|
-
// used before cascade = header(2) + blank(1) + title(1) + blank(1) + col-header(1) + separator(1) = 7
|
|
1057
|
-
const usedBeforeCascade = 7;
|
|
1058
|
-
return Math.max(8, budget - usedBeforeCascade - sectionsBelow);
|
|
1059
|
-
}
|
|
1101
|
+
// Layout of the last rendered Dashboard cascade (set by renderDashboard) — the key
|
|
1102
|
+
// handler and footer hint read this so they use the SAME numbers as the frame.
|
|
1103
|
+
let _cascadeLayout = { total: 0, count: 0, maxOffset: 0, offset: 0 };
|
|
1104
|
+
const cascadeCanScroll = () => _cascadeLayout.maxOffset > 0;
|
|
1060
1105
|
|
|
1061
|
-
function renderDashboard(data, status = "",
|
|
1106
|
+
function renderDashboard(data, status = "", scrollState = 0) {
|
|
1107
|
+
// scrollState: a number (plain offset) or a { offset, anchor } object the caller
|
|
1108
|
+
// keeps — anchor is the "platform:window" key of the top visible row, so async
|
|
1109
|
+
// loads that insert rows above don't make the view jump.
|
|
1110
|
+
const scroll = typeof scrollState === "object" && scrollState ? scrollState : { offset: scrollState, anchor: null };
|
|
1062
1111
|
const w = W();
|
|
1063
1112
|
const budget = H() - 4; // 2 tab bar + 2 footer
|
|
1064
1113
|
const WINS = ["7d", "30d", "90d", "all"];
|
|
@@ -1212,8 +1261,6 @@ function renderDashboard(data, status = "", scrollOffset = 0) {
|
|
|
1212
1261
|
// +2: "Where you sit" line. Two-column layout (≥130 cols) needs fewer rows.
|
|
1213
1262
|
const boardLines = w >= 130 ? 20 : 26;
|
|
1214
1263
|
const sectionsBelow = barLines + boardLines;
|
|
1215
|
-
const gapNotes = active.filter((d) => gapNote(d.platform)).length;
|
|
1216
|
-
const maxCascadeRows = Math.max(8, budget - used - sectionsBelow - gapNotes);
|
|
1217
1264
|
|
|
1218
1265
|
// SCROLL-VIEW (2026-06-27): Build the full list of cascade rows first, then
|
|
1219
1266
|
// slice by [scrollOffset, scrollOffset + maxCascadeRows]. This gives a real
|
|
@@ -1239,24 +1286,50 @@ function renderDashboard(data, status = "", scrollOffset = 0) {
|
|
|
1239
1286
|
}
|
|
1240
1287
|
}
|
|
1241
1288
|
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1289
|
+
// Combined row(s) are part of the scrollable list (they used to be a separate
|
|
1290
|
+
// block that vanished whenever the cascade filled the viewport).
|
|
1291
|
+
if (active.length > 1) {
|
|
1292
|
+
const lbl = active.map((d) => d.platform).join("+");
|
|
1293
|
+
const hasEst = active.some((d) => d.estimated);
|
|
1294
|
+
for (const wk of WINS) {
|
|
1295
|
+
const cp = { input: 0, output: 0, cacheCreate: 0, cacheRead: 0 };
|
|
1296
|
+
let any = false;
|
|
1297
|
+
for (const d of active) {
|
|
1298
|
+
const wd = d.windows?.find((x) => x.window === wk);
|
|
1299
|
+
if (!wd || wd.pillars.input + wd.pillars.output === 0) continue;
|
|
1300
|
+
cp.input += wd.pillars.input ?? 0;
|
|
1301
|
+
cp.output += wd.pillars.output ?? 0;
|
|
1302
|
+
cp.cacheCreate += wd.pillars.cacheCreate ?? 0;
|
|
1303
|
+
cp.cacheRead += wd.pillars.cacheRead ?? 0;
|
|
1304
|
+
any = true;
|
|
1305
|
+
}
|
|
1306
|
+
if (!any) continue;
|
|
1307
|
+
allCascadeRows.push({ platform: lbl, winKey: wk, pillars: cp, estimated: hasEst, combined: true });
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
const combinedFirst = allCascadeRows.find((r) => r.combined)?.winKey;
|
|
1311
|
+
const rowKey = (r) => `${r.combined ? "multi" : r.platform}:${r.winKey}`; // combined label changes as platforms load
|
|
1312
|
+
for (const r of allCascadeRows) r.notes = r.combined || !gapNote(r.platform) ? 0 : 1;
|
|
1313
|
+
|
|
1314
|
+
// Keep the view anchored on the same row when rows load in asynchronously.
|
|
1315
|
+
let want = scroll.offset || 0;
|
|
1316
|
+
if (scroll.anchor) {
|
|
1317
|
+
const idx = allCascadeRows.findIndex((r) => rowKey(r) === scroll.anchor);
|
|
1318
|
+
if (idx >= 0) want = idx;
|
|
1319
|
+
}
|
|
1320
|
+
const lineBudget = Math.max(8, budget - used - sectionsBelow);
|
|
1321
|
+
const win = cascadeWindow(allCascadeRows, want, lineBudget);
|
|
1322
|
+
scroll.offset = win.offset;
|
|
1323
|
+
scroll.anchor = win.offset > 0 ? rowKey(allCascadeRows[win.offset]) : null;
|
|
1324
|
+
_cascadeLayout = win;
|
|
1325
|
+
const visibleRows = allCascadeRows.slice(win.offset, win.offset + win.count);
|
|
1251
1326
|
|
|
1252
1327
|
// ▲ indicator: rows above the current viewport
|
|
1253
|
-
if (
|
|
1254
|
-
emit(
|
|
1255
|
-
` ${dim(` ▲ ${effectiveOffset} row${effectiveOffset > 1 ? "s" : ""} above`)}`,
|
|
1256
|
-
);
|
|
1328
|
+
if (win.above > 0) {
|
|
1329
|
+
emit(` ${dim(` ▲ ${win.above} row${win.above > 1 ? "s" : ""} above · ↑↓ scroll`)}`);
|
|
1257
1330
|
}
|
|
1258
1331
|
|
|
1259
|
-
// Render the visible slice — group by platform (
|
|
1332
|
+
// Render the visible slice — group by platform (blank line between groups)
|
|
1260
1333
|
let lastPlatform = null;
|
|
1261
1334
|
for (const row of visibleRows) {
|
|
1262
1335
|
if (lastPlatform !== null && row.platform !== lastPlatform) {
|
|
@@ -1267,6 +1340,7 @@ function renderDashboard(data, status = "", scrollOffset = 0) {
|
|
|
1267
1340
|
renderRow(
|
|
1268
1341
|
row.platform,
|
|
1269
1342
|
(s) => {
|
|
1343
|
+
if (row.combined) return row.winKey === combinedFirst ? bold(cyan(s)) : dim(s);
|
|
1270
1344
|
const pc = platformColor(row.platform);
|
|
1271
1345
|
return row.winKey === firstWin[row.platform] ? bold(pc(s)) : dim(s);
|
|
1272
1346
|
},
|
|
@@ -1283,37 +1357,12 @@ function renderDashboard(data, status = "", scrollOffset = 0) {
|
|
|
1283
1357
|
if (visibleRows.length > 0) emit();
|
|
1284
1358
|
|
|
1285
1359
|
// ▼ indicator: rows below the current viewport
|
|
1286
|
-
|
|
1287
|
-
if (canScroll && rowsBelow > 0) {
|
|
1360
|
+
if (win.below > 0) {
|
|
1288
1361
|
emit(
|
|
1289
|
-
` ${dim(` ▼ ${
|
|
1362
|
+
` ${dim(` ▼ ${win.below} row${win.below > 1 ? "s" : ""} below · ↑↓ scroll`)}${win.offset > 0 ? dim(` · ${win.offset}/${win.maxOffset}`) : ""}`,
|
|
1290
1363
|
);
|
|
1291
1364
|
}
|
|
1292
1365
|
|
|
1293
|
-
// combined
|
|
1294
|
-
if (active.length > 1 && used < budget - sectionsBelow) {
|
|
1295
|
-
const lbl = active.map((d) => d.platform).join("+");
|
|
1296
|
-
const hasEst = active.some((d) => d.estimated);
|
|
1297
|
-
let fst = true;
|
|
1298
|
-
for (const wk of WINS) {
|
|
1299
|
-
const cp = { input: 0, output: 0, cacheCreate: 0, cacheRead: 0 };
|
|
1300
|
-
let any = false;
|
|
1301
|
-
for (const d of active) {
|
|
1302
|
-
const wd = d.windows?.find((x) => x.window === wk);
|
|
1303
|
-
if (!wd || wd.pillars.input + wd.pillars.output === 0) continue;
|
|
1304
|
-
cp.input += wd.pillars.input ?? 0;
|
|
1305
|
-
cp.output += wd.pillars.output ?? 0;
|
|
1306
|
-
cp.cacheCreate += wd.pillars.cacheCreate ?? 0;
|
|
1307
|
-
cp.cacheRead += wd.pillars.cacheRead ?? 0;
|
|
1308
|
-
any = true;
|
|
1309
|
-
}
|
|
1310
|
-
if (!any) continue;
|
|
1311
|
-
renderRow(lbl, (s) => (fst ? bold(cyan(s)) : dim(s)), wk, cp, hasEst);
|
|
1312
|
-
fst = false;
|
|
1313
|
-
}
|
|
1314
|
-
emit();
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
1366
|
// (Υ Trend moved to the dedicated Trends tab [2] — every metric, with sub-views.)
|
|
1318
1367
|
|
|
1319
1368
|
// ── Token Composition — lifetime per platform (owner 2026-10-15: "combine token
|
|
@@ -2735,7 +2784,14 @@ function renderSubmitPreview(dashData, id, page = 0) {
|
|
|
2735
2784
|
return { pages: 0 };
|
|
2736
2785
|
}
|
|
2737
2786
|
const blocks = active.map((d) => ({ platform: d.platform, windows: d.windows }));
|
|
2738
|
-
|
|
2787
|
+
const failedReads = dashData?.failed ?? [];
|
|
2788
|
+
if (failedReads.length) {
|
|
2789
|
+
emit();
|
|
2790
|
+
emit(
|
|
2791
|
+
` ${red("!")} ${dim(`could not read ${failedReads.map((f) => f.platform).join(", ")} — the combined total will NOT be submitted until it reads (press [R]; Devin: SIGRANK_DEVIN_TIMEOUT_MS)`)}`,
|
|
2792
|
+
);
|
|
2793
|
+
}
|
|
2794
|
+
if (active.length >= 2 && !failedReads.length) {
|
|
2739
2795
|
const multi = WINS.map((wk) => {
|
|
2740
2796
|
const sum = { input: 0, output: 0, cacheCreate: 0, cacheRead: 0 };
|
|
2741
2797
|
let messages = 0;
|
|
@@ -3104,7 +3160,7 @@ export async function runTui({
|
|
|
3104
3160
|
let previewPages = 0;
|
|
3105
3161
|
let boardYouOnly = false; // FIX I2: [Y] toggles the Board to "just me" (hybrid model)
|
|
3106
3162
|
let boardUnique = false; // [U] Board: every submission (default, unchanged) ↔ best row per operator
|
|
3107
|
-
|
|
3163
|
+
const cascadeScroll = { offset: 0, anchor: null }; // cascade scroll state (Dashboard only); anchor = top row key, keeps the view put while rows load
|
|
3108
3164
|
let ompEnabled = false; // Session-only Dashboard toggle; deliberately OFF on every launch.
|
|
3109
3165
|
|
|
3110
3166
|
// ── Redraw (buffered: renders into memory, then paints as a locked frame)
|
|
@@ -3158,9 +3214,8 @@ export async function runTui({
|
|
|
3158
3214
|
}
|
|
3159
3215
|
// SCROLL-VIEW: show ↑↓ hint only when there are cascade rows to scroll
|
|
3160
3216
|
const scrollHint =
|
|
3161
|
-
dashData && Array.isArray(dashData.active) &&
|
|
3162
|
-
|
|
3163
|
-
? [{ k: "↑↓", label: "scroll cascade", pri: 2 }]
|
|
3217
|
+
dashData && Array.isArray(dashData.active) && cascadeCanScroll()
|
|
3218
|
+
? [{ k: "↑↓/PgUp/PgDn", label: "scroll cascade", pri: 2 }]
|
|
3164
3219
|
: [];
|
|
3165
3220
|
const ompHint = !dashData?._ompAvailable
|
|
3166
3221
|
? []
|
|
@@ -3308,6 +3363,18 @@ export async function runTui({
|
|
|
3308
3363
|
if (activeTab === 2) await redraw();
|
|
3309
3364
|
};
|
|
3310
3365
|
|
|
3366
|
+
// Update notice: show the cached result at once (no network), refresh from the
|
|
3367
|
+
// registry in the background (1.5s cap, silent offline, cached ~24h). Never awaited.
|
|
3368
|
+
_updateNotice = cachedUpdateNotice({ current: VERSION });
|
|
3369
|
+
checkForUpdate({ current: VERSION })
|
|
3370
|
+
.then((n) => {
|
|
3371
|
+
if (n && n !== _updateNotice) {
|
|
3372
|
+
_updateNotice = n;
|
|
3373
|
+
redraw().catch(() => {});
|
|
3374
|
+
}
|
|
3375
|
+
})
|
|
3376
|
+
.catch(() => {});
|
|
3377
|
+
|
|
3311
3378
|
// ── Initial data load
|
|
3312
3379
|
const loadAll = async () => {
|
|
3313
3380
|
// A2 (2026-06-27): paint the frame + a clear "reading your cascade…" status IMMEDIATELY,
|
|
@@ -3630,7 +3697,8 @@ export async function runTui({
|
|
|
3630
3697
|
let totalVerified = 0,
|
|
3631
3698
|
totalReceived = 0,
|
|
3632
3699
|
hadFail = false,
|
|
3633
|
-
didMulti = false
|
|
3700
|
+
didMulti = false,
|
|
3701
|
+
multiAbort = null;
|
|
3634
3702
|
for (const p of platforms) {
|
|
3635
3703
|
try {
|
|
3636
3704
|
const out = await callTool("submit_verified", { platform: p, confirm: true });
|
|
@@ -3655,6 +3723,10 @@ export async function runTui({
|
|
|
3655
3723
|
platform: "multi",
|
|
3656
3724
|
confirm: true,
|
|
3657
3725
|
});
|
|
3726
|
+
if (out.status === "error" && out.reason === "platform_read_failed") {
|
|
3727
|
+
// A platform read failed: the combined total was NOT submitted.
|
|
3728
|
+
multiAbort = (out.failed_platforms || []).map((f) => f.platform).join(", ") || "a platform";
|
|
3729
|
+
}
|
|
3658
3730
|
const ws = out.windows || [];
|
|
3659
3731
|
const received = ws.filter((w) => w.status === "received");
|
|
3660
3732
|
const verified = received.filter(
|
|
@@ -3669,7 +3741,14 @@ export async function runTui({
|
|
|
3669
3741
|
hadFail = true;
|
|
3670
3742
|
}
|
|
3671
3743
|
}
|
|
3672
|
-
if (
|
|
3744
|
+
if (multiAbort) {
|
|
3745
|
+
const outcome = totalReceived
|
|
3746
|
+
? hadFail
|
|
3747
|
+
? `per-platform: ${totalVerified}/${totalReceived} verified (sign in again [C] if rejected)`
|
|
3748
|
+
: `per-platform: ${totalVerified}/${totalReceived} verified`
|
|
3749
|
+
: "per-platform: nothing received";
|
|
3750
|
+
submitMsg = `${red("✗")} combined total NOT submitted: could not read ${multiAbort} · ${outcome} · press [R] and retry`;
|
|
3751
|
+
} else if (totalReceived && !hadFail && totalVerified === totalReceived) {
|
|
3673
3752
|
submitMsg = `${green("✓")} submitted · ${totalVerified} window${totalVerified > 1 ? "s" : ""} across ${platforms.length} platform${platforms.length > 1 ? "s" : ""}${didMulti ? " + combined" : ""} · verified`;
|
|
3674
3753
|
} else if (hadFail && totalReceived) {
|
|
3675
3754
|
submitMsg = `${red("✗")} device not verified — sign in again ([C])`;
|
|
@@ -3763,35 +3842,21 @@ export async function runTui({
|
|
|
3763
3842
|
// SCROLL-VIEW (2026-06-27): ↑/↓ (or j/k) scroll the cascade section on the
|
|
3764
3843
|
// Dashboard tab ONLY. The rest of the dashboard stays pinned. Only active
|
|
3765
3844
|
// when there are more cascade rows than fit in the viewport.
|
|
3766
|
-
if (activeTab === 0 && dashData && Array.isArray(dashData.active)) {
|
|
3767
|
-
const
|
|
3768
|
-
const
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
return;
|
|
3782
|
-
}
|
|
3783
|
-
if (key === "\x1b[5~") {
|
|
3784
|
-
// PageUp → scroll up by viewport
|
|
3785
|
-
cascadeScroll = Math.max(0, cascadeScroll - maxRows);
|
|
3786
|
-
await redraw();
|
|
3787
|
-
return;
|
|
3788
|
-
}
|
|
3789
|
-
if (key === "\x1b[6~") {
|
|
3790
|
-
// PageDown → scroll down by viewport
|
|
3791
|
-
cascadeScroll = Math.min(maxOff, cascadeScroll + maxRows);
|
|
3792
|
-
await redraw();
|
|
3793
|
-
return;
|
|
3794
|
-
}
|
|
3845
|
+
if (activeTab === 0 && dashData && Array.isArray(dashData.active) && cascadeCanScroll()) {
|
|
3846
|
+
const { maxOffset, count } = _cascadeLayout;
|
|
3847
|
+
const cur = cascadeScroll.offset;
|
|
3848
|
+
let next = null;
|
|
3849
|
+
if (key === "\x1b[A" || k === "k") next = cur - 1; // ↑ / k
|
|
3850
|
+
else if (key === "\x1b[B" || k === "j") next = cur + 1; // ↓ / j
|
|
3851
|
+
else if (key === "\x1b[5~") next = cur - Math.max(1, count - 1); // PageUp
|
|
3852
|
+
else if (key === "\x1b[6~") next = cur + Math.max(1, count - 1); // PageDown
|
|
3853
|
+
else if (key === "\x1b[H" || key === "\x1b[1~" || key === "\x1bOH") next = 0; // Home
|
|
3854
|
+
else if (key === "\x1b[F" || key === "\x1b[4~" || key === "\x1bOF") next = maxOffset; // End
|
|
3855
|
+
if (next !== null) {
|
|
3856
|
+
cascadeScroll.offset = Math.max(0, Math.min(maxOffset, next));
|
|
3857
|
+
cascadeScroll.anchor = null; // user moved: re-derive the anchor on render
|
|
3858
|
+
await redraw();
|
|
3859
|
+
return;
|
|
3795
3860
|
}
|
|
3796
3861
|
}
|
|
3797
3862
|
|
|
@@ -3835,7 +3900,7 @@ export async function runTui({
|
|
|
3835
3900
|
} // [C] → Connect from any read tab
|
|
3836
3901
|
|
|
3837
3902
|
// SCROLL-VIEW: reset cascade scroll when leaving the Dashboard tab
|
|
3838
|
-
if (switched && activeTab !== 0) cascadeScroll = 0;
|
|
3903
|
+
if (switched && activeTab !== 0) { cascadeScroll.offset = 0; cascadeScroll.anchor = null; }
|
|
3839
3904
|
|
|
3840
3905
|
// #9 (2026-06-27): Compare loads its FRESH verifier pull ON-DEMAND when the tab opens
|
|
3841
3906
|
// (NOT on the Dashboard load path — that pull is a 5–60s scan). Paint the "pulling fresh
|
|
@@ -3962,7 +4027,8 @@ export async function runTui({
|
|
|
3962
4027
|
return;
|
|
3963
4028
|
}
|
|
3964
4029
|
status = "refreshing…";
|
|
3965
|
-
cascadeScroll = 0; // SCROLL-VIEW: reset scroll on refresh
|
|
4030
|
+
cascadeScroll.offset = 0; // SCROLL-VIEW: reset scroll on refresh
|
|
4031
|
+
cascadeScroll.anchor = null;
|
|
3966
4032
|
// #9: on the Compare tab, [R] re-runs the FRESH verifier pull for the current platform
|
|
3967
4033
|
// (loadAll no longer touches Compare). Clearing compareData shows the spinner first.
|
|
3968
4034
|
if (activeTab === 2) {
|
|
@@ -19,14 +19,14 @@ It does not persist that content or send it to the SigRank service; it appends
|
|
|
19
19
|
only provider-reported token counts, model/backend metadata, and timestamps to
|
|
20
20
|
`~/.sigrank-mcp/proxy-sessions.jsonl`.
|
|
21
21
|
|
|
22
|
-
- **Signed path** (`submit_verified`, `watch_tokenpull` with `submit:true`): the four numbers travel with the device's public key, codename, window, and an ed25519 signature. The board verifies the signature without seeing your data.
|
|
23
|
-
- **
|
|
22
|
+
- **Signed path** (`submit_verified`, `watch_tokenpull` with `submit:true`; both require `confirm:true`, so nothing publishes without your approval): the four numbers travel with the device's public key, codename, window, and an ed25519 signature. The board verifies the signature without seeing your data.
|
|
23
|
+
- **Preview tools** (`submit_paste`, `tokenpull_submit`): compute your cascade locally and send nothing. They do not publish to the board; publishing goes through the signed path or the signalaf.com web UI.
|
|
24
24
|
|
|
25
25
|
## How it works
|
|
26
26
|
|
|
27
27
|
1. **Local-first:** All token pulling happens on your machine. Upsilon reads usage metadata from session logs in ~/.claude, ~/.codex, ~/.local/share/amp, etc. The optional proxy also runs only on loopback and only when manually started.
|
|
28
|
-
2. **Token-only persistence:** Local-log adapters extract integer counts from log metadata without reading conversation content. The optional proxy forwards request/response bytes transiently but persists only usage metadata.
|
|
29
|
-
3. **Signed submission:** Ranked submissions (`submit_verified`, `watch_tokenpull` with `submit:true`) are ed25519-signed with a device-bound key generated locally at enrollment. The board verifies the signature without seeing your data.
|
|
28
|
+
2. **Token-only persistence:** Local-log adapters extract integer counts from log metadata without reading conversation content. The optional proxy forwards request/response bytes transiently but persists only usage metadata. Paste parsing (`submit_paste`, `rank_paste`) happens locally and nothing is transmitted.
|
|
29
|
+
3. **Signed submission:** Ranked submissions (`submit_verified`, `watch_tokenpull` with `submit:true`) are ed25519-signed with a device-bound key generated locally at enrollment. The board verifies the signature without seeing your data. `submit_paste` and `tokenpull_submit` are preview-only and never submit.
|
|
30
30
|
4. **Read tools need no auth:** No API keys, no OAuth, no account needed to read the leaderboard or operator profiles. **Enrollment requires a connect code** from signalaf.com → Settings → New key (the code binds your device's public key to your operator server-side); a codename alone is not enough for the signed/ranked path.
|
|
31
31
|
|
|
32
32
|
## What the Upsilon service can NOT see
|
package/tools/_multi.mjs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tools/_multi.mjs — shared collector for the combined ("multi") cascade.
|
|
3
|
+
*
|
|
4
|
+
* "No local data" (empty read, platform not set up) is fine to skip. A platform
|
|
5
|
+
* whose read THROWS or times out is a FAILED read: dropping it silently submits
|
|
6
|
+
* a too-small combined total (2026-11-10: Devin timed out and the all-time
|
|
7
|
+
* total went out as 7.7B instead of 61.5B). Callers must abort on `failed`.
|
|
8
|
+
*/
|
|
9
|
+
import { ALL_PLATFORMS } from "../adapters/index.mjs";
|
|
10
|
+
import { pullByPlatform } from "./_helpers.mjs";
|
|
11
|
+
|
|
12
|
+
const hasTokens = (r) =>
|
|
13
|
+
!!r &&
|
|
14
|
+
(r.windows || []).some(
|
|
15
|
+
(w) =>
|
|
16
|
+
(w.pillars?.input || 0) +
|
|
17
|
+
(w.pillars?.output || 0) +
|
|
18
|
+
(w.pillars?.cacheCreate || 0) +
|
|
19
|
+
(w.pillars?.cacheRead || 0) >
|
|
20
|
+
0,
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
// Test-only reader override. Deliberately NOT reachable through ctx.opts, so a
|
|
24
|
+
// caller of the (signed) submit path cannot swap the real platform reader.
|
|
25
|
+
let _testPull = null;
|
|
26
|
+
export function _setMultiPullForTest(fn) {
|
|
27
|
+
_testPull = fn || null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Pull every platform. Returns { detected, failed:[{platform,error}] }. */
|
|
31
|
+
export async function collectMultiPlatforms(opts = {}, platforms = ALL_PLATFORMS) {
|
|
32
|
+
const detected = [];
|
|
33
|
+
const failed = [];
|
|
34
|
+
const pull = _testPull ?? pullByPlatform;
|
|
35
|
+
for (const p of platforms) {
|
|
36
|
+
let r;
|
|
37
|
+
try {
|
|
38
|
+
r = await pull(p, opts);
|
|
39
|
+
} catch (e) {
|
|
40
|
+
// Allow-list of abort conditions: only a real read failure of a store that
|
|
41
|
+
// exists (timeout, locked/corrupt db) aborts. Anything else (adapter not
|
|
42
|
+
// set up, stale SIGRANK_OTHER_PATH, no data) is "no data" and is skipped.
|
|
43
|
+
if (e?.code !== "SIGRANK_READ_FAILED") continue;
|
|
44
|
+
failed.push({ platform: p, error: String(e?.message || e) });
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (hasTokens(r)) detected.push(r);
|
|
48
|
+
}
|
|
49
|
+
return { detected, failed };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The result handlers return (and submit nothing) when a platform read failed. */
|
|
53
|
+
export function multiAbortResult(failed, extra = {}) {
|
|
54
|
+
const names = failed.map((f) => f.platform).join(", ");
|
|
55
|
+
return {
|
|
56
|
+
platform: "multi",
|
|
57
|
+
...extra,
|
|
58
|
+
status: "error",
|
|
59
|
+
reason: "platform_read_failed",
|
|
60
|
+
failed_platforms: failed,
|
|
61
|
+
detail: `multi aborted: could not read ${names} (${failed.map((f) => `${f.platform}: ${f.error}`).join("; ")}). Nothing was submitted, because a combined total without ${names} would be too small. Fix or retry (Devin: raise SIGRANK_DEVIN_TIMEOUT_MS).`,
|
|
62
|
+
windows: [],
|
|
63
|
+
};
|
|
64
|
+
}
|
package/tools/index.mjs
CHANGED
|
@@ -122,6 +122,7 @@ export function withTokscaleBlind(detected) {
|
|
|
122
122
|
* opts.callTool overrides the per-platform pull for tests (same opts-injection
|
|
123
123
|
* convention as opts.adapter in pullByPlatform) so the target-set logic is
|
|
124
124
|
* assertable without a real filesystem scan. */
|
|
125
|
+
const READ_FAILED = "SIGRANK_READ_FAILED";
|
|
125
126
|
async function _pullExplicit(platforms, opts = {}) {
|
|
126
127
|
const pull = opts.callTool || callTool;
|
|
127
128
|
const settled = await Promise.allSettled(
|
|
@@ -138,8 +139,17 @@ async function _pullExplicit(platforms, opts = {}) {
|
|
|
138
139
|
const rank = (p) =>
|
|
139
140
|
p === "claude" ? -2 : p === "codex" ? -1 : ALL_PLATFORMS.indexOf(p);
|
|
140
141
|
active.sort((a, b) => rank(a.platform) - rank(b.platform));
|
|
141
|
-
|
|
142
|
+
// Platforms whose read FAILED (SIGRANK_READ_FAILED: timeout, locked/corrupt db on
|
|
143
|
+
// an existing store) — not "no data". Callers building a combined total must
|
|
144
|
+
// refuse to show/submit a too-small one. Any other rejection (adapter not set up,
|
|
145
|
+
// unconfigured path) is treated as no data, as before.
|
|
146
|
+
const failed = settled
|
|
147
|
+
.map((r, i) => ({ r, platform: platforms[i] }))
|
|
148
|
+
.filter(({ r }) => r.status === "rejected" && r.reason?.code === READ_FAILED)
|
|
149
|
+
.map(({ r, platform }) => ({ platform, error: String(r.reason?.message || r.reason) }));
|
|
150
|
+
return { active, failed };
|
|
142
151
|
}
|
|
152
|
+
export const _pullExplicitForTest = (platforms, opts) => _pullExplicit(platforms, opts);
|
|
143
153
|
|
|
144
154
|
// ── Shared active-platform loader ───────────────────────────────────────────
|
|
145
155
|
// THE single data path for "show my cascade across platforms" — used by `me`,
|
|
@@ -147,6 +157,7 @@ async function _pullExplicit(platforms, opts = {}) {
|
|
|
147
157
|
// target platform via the tokenpull tool (enriched: pillars + cascade + card),
|
|
148
158
|
// keeps only platforms with real local data, and sorts claude → codex → rest.
|
|
149
159
|
// Pass `platforms` to scope it (e.g. ['claude'] for a fast first paint).
|
|
160
|
+
// Returns { active, failed }: failed = platforms whose read FAILED (not "no data").
|
|
150
161
|
export async function pullActivePlatforms({ platforms } = {}, opts = {}) {
|
|
151
162
|
// If the caller specified explicit platforms, use those.
|
|
152
163
|
if (platforms && platforms.length) {
|
|
@@ -6,6 +6,7 @@ import { ALL_PLATFORMS } from "../adapters/index.mjs";
|
|
|
6
6
|
import { ensureIdentity } from "../identity/keystore.mjs";
|
|
7
7
|
import { submitSignedWindow } from "../submit/index.mjs";
|
|
8
8
|
import { SUBMIT_OUTPUT, ANNOTATIONS } from "./_schemas.mjs";
|
|
9
|
+
import { collectMultiPlatforms, multiAbortResult } from "./_multi.mjs";
|
|
9
10
|
import { pullByPlatform, WINDOW_TYPE } from "./_helpers.mjs";
|
|
10
11
|
import { _computeReportBlock } from "./_report.mjs";
|
|
11
12
|
|
|
@@ -72,21 +73,8 @@ export async function handleSubmitVerified(args, ctx) {
|
|
|
72
73
|
// per window and publish as platform='multi' = the operator's TOTAL usage. Empty
|
|
73
74
|
// windows are skipped so a no-activity window never lands as a degenerate row.
|
|
74
75
|
if (platform === "multi") {
|
|
75
|
-
const detected =
|
|
76
|
-
|
|
77
|
-
const r = await pullByPlatform(p, ctx.opts).catch(() => null);
|
|
78
|
-
const live =
|
|
79
|
-
r &&
|
|
80
|
-
(r.windows || []).some(
|
|
81
|
-
(w) =>
|
|
82
|
-
w.pillars.input +
|
|
83
|
-
w.pillars.output +
|
|
84
|
-
w.pillars.cacheCreate +
|
|
85
|
-
w.pillars.cacheRead >
|
|
86
|
-
0,
|
|
87
|
-
);
|
|
88
|
-
if (live) detected.push(r);
|
|
89
|
-
}
|
|
76
|
+
const { detected, failed } = await collectMultiPlatforms(ctx.opts);
|
|
77
|
+
if (failed.length) return multiAbortResult(failed, { codename: id.codename, operator_id: id.operator_id });
|
|
90
78
|
if (detected.length < 2) {
|
|
91
79
|
return {
|
|
92
80
|
platform: "multi",
|
|
@@ -6,6 +6,7 @@ import { cascade } from "../analytics/cascade.mjs";
|
|
|
6
6
|
import { narrate } from "../presentation/narrate.mjs";
|
|
7
7
|
import { ALL_PLATFORMS } from "../adapters/index.mjs";
|
|
8
8
|
import { SUBMIT_OUTPUT, ANNOTATIONS } from "./_schemas.mjs";
|
|
9
|
+
import { collectMultiPlatforms, multiAbortResult } from "./_multi.mjs";
|
|
9
10
|
import {
|
|
10
11
|
pullByPlatform,
|
|
11
12
|
} from "./_helpers.mjs";
|
|
@@ -55,21 +56,8 @@ export async function handleTokenpullSubmit(args, ctx) {
|
|
|
55
56
|
// (cloud, via tokscale). Aggregate every locally-detected platform's pillars per
|
|
56
57
|
// window.
|
|
57
58
|
if (platform === "multi") {
|
|
58
|
-
const detected =
|
|
59
|
-
|
|
60
|
-
const r = await pullByPlatform(p, ctx.opts).catch(() => null);
|
|
61
|
-
const live =
|
|
62
|
-
r &&
|
|
63
|
-
(r.windows || []).some(
|
|
64
|
-
(w) =>
|
|
65
|
-
w.pillars.input +
|
|
66
|
-
w.pillars.output +
|
|
67
|
-
w.pillars.cacheCreate +
|
|
68
|
-
w.pillars.cacheRead >
|
|
69
|
-
0,
|
|
70
|
-
);
|
|
71
|
-
if (live) detected.push(r);
|
|
72
|
-
}
|
|
59
|
+
const { detected, failed } = await collectMultiPlatforms(ctx.opts);
|
|
60
|
+
if (failed.length) return multiAbortResult(failed, { codename: codename || undefined });
|
|
73
61
|
if (detected.length < 2) {
|
|
74
62
|
return {
|
|
75
63
|
platform: "multi",
|