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/adapters/index.mjs
CHANGED
|
@@ -113,18 +113,44 @@ function* parseJsonl(text, filePath) {
|
|
|
113
113
|
/** Run sqlite3 -json and return parsed rows, or [] on error/unavailability.
|
|
114
114
|
* execFile with an args array — no shell, so dbPath/sql need no quoting/escaping
|
|
115
115
|
* (matches the execFile hardening used in tools.mjs / tokenpull.mjs). */
|
|
116
|
-
async function sqliteJson(dbPath, sql, timeoutMs = 10_000) {
|
|
116
|
+
async function sqliteJson(dbPath, sql, timeoutMs = 10_000, { strict = false } = {}) {
|
|
117
117
|
try {
|
|
118
118
|
const { stdout } = await execFileP("sqlite3", ["-json", dbPath, sql], {
|
|
119
119
|
timeout: timeoutMs,
|
|
120
120
|
maxBuffer: 256 * 1024 * 1024, // 256MB — Devin's sessions.db yields ~15MB JSON
|
|
121
121
|
});
|
|
122
122
|
return JSON.parse(stdout || "[]");
|
|
123
|
-
} catch {
|
|
123
|
+
} catch (e) {
|
|
124
|
+
// strict: "no data" (sqlite3 not installed) stays an empty result, but a
|
|
125
|
+
// timeout / crash / unreadable db is a FAILED read and must be visible —
|
|
126
|
+
// swallowing it made a slow Devin read look like "Devin has no data" and
|
|
127
|
+
// dropped it from the combined total (2026-11-10).
|
|
128
|
+
if (strict && e?.code !== "ENOENT") {
|
|
129
|
+
const full = `${e?.stderr || ""}\n${e?.message || e}`;
|
|
130
|
+
const msg = full.trim().split("\n")[0];
|
|
131
|
+
const why =
|
|
132
|
+
e?.killed || e?.signal
|
|
133
|
+
? `timed out after ${Math.round(timeoutMs / 1000)}s (raise SIGRANK_DEVIN_TIMEOUT_MS)`
|
|
134
|
+
: /locked|busy/i.test(full)
|
|
135
|
+
? "database is locked (transient: try again when the app is closed)"
|
|
136
|
+
: e instanceof SyntaxError
|
|
137
|
+
? "could not parse sqlite output (corrupt or truncated)"
|
|
138
|
+
: msg;
|
|
139
|
+
const err = new Error(`sqlite read of ${dbPath} failed: ${why}`);
|
|
140
|
+
err.code = "SIGRANK_READ_FAILED";
|
|
141
|
+
throw err;
|
|
142
|
+
}
|
|
124
143
|
return [];
|
|
125
144
|
}
|
|
126
145
|
}
|
|
127
146
|
|
|
147
|
+
/** Devin sessions.db read timeout. A large history (>1 min via sqlite3) hit the
|
|
148
|
+
* old fixed 60s cap. Default 5 min; override with SIGRANK_DEVIN_TIMEOUT_MS. */
|
|
149
|
+
export function devinTimeoutMs(env = process.env) {
|
|
150
|
+
const n = Number(env.SIGRANK_DEVIN_TIMEOUT_MS);
|
|
151
|
+
return Number.isFinite(n) && n >= 1000 ? n : 300_000;
|
|
152
|
+
}
|
|
153
|
+
|
|
128
154
|
// ── Env-var helper ────────────────────────────────────────────────────────────
|
|
129
155
|
/** Resolve roots from env var or default. Supports comma-separated list. */
|
|
130
156
|
function roots(envVar, defaultPath) {
|
|
@@ -760,6 +786,7 @@ export const devinAdapter = {
|
|
|
760
786
|
async *records(root) {
|
|
761
787
|
for (const r of roots("DEVIN_HOME", root)) {
|
|
762
788
|
const dbPath = join(r, "sessions.db");
|
|
789
|
+
if (!existsSync(dbPath)) continue; // no Devin db = no local data (not a failure)
|
|
763
790
|
const rows = await sqliteJson(
|
|
764
791
|
dbPath,
|
|
765
792
|
`SELECT row_id, session_id,
|
|
@@ -771,7 +798,8 @@ export const devinAdapter = {
|
|
|
771
798
|
WHERE json_extract(chat_message, '$.role') = 'assistant'
|
|
772
799
|
AND json_extract(chat_message, '$.metadata.metrics.input_tokens') IS NOT NULL
|
|
773
800
|
ORDER BY created_at`,
|
|
774
|
-
|
|
801
|
+
devinTimeoutMs(),
|
|
802
|
+
{ strict: true },
|
|
775
803
|
);
|
|
776
804
|
for (const row of rows) {
|
|
777
805
|
const inputIncl = Number(row.input_tokens || 0);
|
|
@@ -827,9 +855,11 @@ export const otherAdapter = {
|
|
|
827
855
|
async *messages(root) {
|
|
828
856
|
const filePath = root || process.env.SIGRANK_OTHER_PATH;
|
|
829
857
|
if (!filePath) {
|
|
830
|
-
throw new Error(
|
|
858
|
+
throw Object.assign(new Error(
|
|
831
859
|
"other adapter: set SIGRANK_OTHER_PATH to a JSON file with your token pillars. " +
|
|
832
860
|
'Format: { "windows": { "all": { "input": N, "output": N, "cacheCreate": N, "cacheRead": N } } }',
|
|
861
|
+
),
|
|
862
|
+
{ code: "SIGRANK_NO_LOCAL_DATA" },
|
|
833
863
|
);
|
|
834
864
|
}
|
|
835
865
|
let text;
|
package/lib/constants.mjs
CHANGED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// lib/update-check.mjs — "update available" notice for the CLI and TUI.
|
|
2
|
+
//
|
|
3
|
+
// Contract: never delays startup, never throws, silent offline. The registry
|
|
4
|
+
// lookup has a short timeout and its result is cached ~24h in ~/.sigrank-mcp
|
|
5
|
+
// (dir 0700, file 0600 — same conventions as identity/keystore.mjs). Callers
|
|
6
|
+
// show the cached notice synchronously and refresh in the background.
|
|
7
|
+
//
|
|
8
|
+
// Opt out: SIGRANK_NO_UPDATE_CHECK=1 (also honours NO_UPDATE_NOTIFIER and CI).
|
|
9
|
+
// This module is never used by the MCP stdio server.
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
chmodSync,
|
|
13
|
+
existsSync,
|
|
14
|
+
mkdirSync,
|
|
15
|
+
readFileSync,
|
|
16
|
+
writeFileSync,
|
|
17
|
+
} from "node:fs";
|
|
18
|
+
import { homedir } from "node:os";
|
|
19
|
+
import { join } from "node:path";
|
|
20
|
+
|
|
21
|
+
export const REGISTRY_URL = "https://registry.npmjs.org/sigrank/latest";
|
|
22
|
+
export const CHECK_TTL_MS = 24 * 60 * 60 * 1000;
|
|
23
|
+
export const RETRY_AFTER_FAIL_MS = 60 * 60 * 1000;
|
|
24
|
+
export const CHECK_TIMEOUT_MS = 1500;
|
|
25
|
+
|
|
26
|
+
const defaultDir = () => join(homedir(), ".sigrank-mcp");
|
|
27
|
+
const truthy = (v) => v != null && v !== "" && v !== "0" && v !== "false";
|
|
28
|
+
|
|
29
|
+
/** True when the user (or CI) opted out of network update checks. */
|
|
30
|
+
export function updateCheckDisabled(env = process.env) {
|
|
31
|
+
return (
|
|
32
|
+
truthy(env.SIGRANK_NO_UPDATE_CHECK) ||
|
|
33
|
+
truthy(env.NO_UPDATE_NOTIFIER) ||
|
|
34
|
+
truthy(env.CI)
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const parse = (v) => {
|
|
39
|
+
const m = /^(\d+)\.(\d+)\.(\d+)(?:-.+)?$/.exec(String(v || "").trim());
|
|
40
|
+
return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** True when `latest` is a strictly newer release than `current`. */
|
|
44
|
+
export function isNewer(latest, current) {
|
|
45
|
+
const a = parse(latest);
|
|
46
|
+
const b = parse(current);
|
|
47
|
+
if (!a || !b) return false;
|
|
48
|
+
for (let i = 0; i < 3; i++) if (a[i] !== b[i]) return a[i] > b[i];
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function formatUpdateNotice(latest) {
|
|
53
|
+
return `sigrank ${latest} available — npm install -g sigrank@latest`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const cachePath = (dir) => join(dir, "update-check.json");
|
|
57
|
+
|
|
58
|
+
function readCache(dir) {
|
|
59
|
+
try {
|
|
60
|
+
const c = JSON.parse(readFileSync(cachePath(dir), "utf-8"));
|
|
61
|
+
return c && typeof c === "object" ? c : null;
|
|
62
|
+
} catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function writeCache(dir, data) {
|
|
68
|
+
try {
|
|
69
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
70
|
+
const p = cachePath(dir);
|
|
71
|
+
writeFileSync(p, JSON.stringify(data), { mode: 0o600 });
|
|
72
|
+
chmodSync(p, 0o600);
|
|
73
|
+
} catch {
|
|
74
|
+
/* cache is best-effort */
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Synchronous, no network: the notice from the cached result, or null. */
|
|
79
|
+
export function cachedUpdateNotice({
|
|
80
|
+
current,
|
|
81
|
+
env = process.env,
|
|
82
|
+
dir = defaultDir(),
|
|
83
|
+
} = {}) {
|
|
84
|
+
if (updateCheckDisabled(env)) return null;
|
|
85
|
+
const latest = readCache(dir)?.latest;
|
|
86
|
+
return isNewer(latest, current) ? formatUpdateNotice(latest) : null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Refresh from the registry if the cache is stale, and return the notice (or
|
|
91
|
+
* null). Short timeout, fails silent, resolves with whatever is cached on error.
|
|
92
|
+
*/
|
|
93
|
+
export async function checkForUpdate({
|
|
94
|
+
current,
|
|
95
|
+
env = process.env,
|
|
96
|
+
dir = defaultDir(),
|
|
97
|
+
now = Date.now(),
|
|
98
|
+
fetchImpl = globalThis.fetch,
|
|
99
|
+
timeoutMs = CHECK_TIMEOUT_MS,
|
|
100
|
+
} = {}) {
|
|
101
|
+
try {
|
|
102
|
+
if (updateCheckDisabled(env) || typeof fetchImpl !== "function") return null;
|
|
103
|
+
const cache = readCache(dir);
|
|
104
|
+
const fresh =
|
|
105
|
+
cache &&
|
|
106
|
+
Number.isFinite(cache.checkedAt) &&
|
|
107
|
+
now - cache.checkedAt >= 0 &&
|
|
108
|
+
now - cache.checkedAt < CHECK_TTL_MS;
|
|
109
|
+
const coolingDown =
|
|
110
|
+
cache &&
|
|
111
|
+
Number.isFinite(cache.failedAt) &&
|
|
112
|
+
now - cache.failedAt >= 0 &&
|
|
113
|
+
now - cache.failedAt < RETRY_AFTER_FAIL_MS;
|
|
114
|
+
let latest = cache?.latest;
|
|
115
|
+
if (!fresh && !coolingDown) {
|
|
116
|
+
const ac = new AbortController();
|
|
117
|
+
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
118
|
+
timer.unref?.();
|
|
119
|
+
try {
|
|
120
|
+
const res = await fetchImpl(REGISTRY_URL, {
|
|
121
|
+
signal: ac.signal,
|
|
122
|
+
headers: { accept: "application/json" },
|
|
123
|
+
});
|
|
124
|
+
if (!res?.ok) throw new Error(`registry ${res?.status}`);
|
|
125
|
+
const v = (await res.json())?.version;
|
|
126
|
+
if (!parse(v)) throw new Error("bad registry payload");
|
|
127
|
+
latest = v;
|
|
128
|
+
writeCache(dir, { latest, checkedAt: now });
|
|
129
|
+
} catch {
|
|
130
|
+
writeCache(dir, { latest: cache?.latest, checkedAt: cache?.checkedAt, failedAt: now });
|
|
131
|
+
} finally {
|
|
132
|
+
clearTimeout(timer);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return isNewer(latest, current) ? formatUpdateNotice(latest) : null;
|
|
136
|
+
} catch {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
}
|
package/manifest.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/anthropics/mcpb/main/schemas/mcpb-manifest-v0.4.schema.json",
|
|
3
3
|
"manifest_version": "0.4",
|
|
4
4
|
"name": "sigrank",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.49",
|
|
6
6
|
"description": "Ranks AI coding operators by token cascade efficiency (Yield = cache_read \u00d7 output / input\u00b2). 25 tools including SigRank Standard record, yield calculation, local token usage pulls, signed submission, and tokscale-powered analytics (market share, developer profiles, model trends, cost analysis, device profiles, MCP usage, competitive intelligence). Privacy-first: runs locally, only four token counts leave the machine.",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "SunrisesIllNeverSee",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sigrank",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.49",
|
|
4
4
|
"author": "SunrisesIllNeverSee (https://github.com/SunrisesIllNeverSee)",
|
|
5
5
|
"description": "Upsilon measurement engine distributed through the sigrank CLI/MCP compatibility package, with SigRank public leaderboard tools.",
|
|
6
6
|
"mcpName": "io.github.SunrisesIllNeverSee/sigrank-mcp",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"start": "node index.mjs",
|
|
27
|
-
"test": "node test.mjs && node --test __tests__/sign.test.mjs __tests__/cascade.test.mjs __tests__/badges.test.mjs __tests__/tui-input.test.mjs __tests__/standard-record.test.mjs __tests__/standard-cli.test.mjs __tests__/product-architecture.test.mjs __tests__/tteop-delegation.test.mjs __tests__/mcp-stdio.test.mjs",
|
|
27
|
+
"test": "node test.mjs && node --test __tests__/sign.test.mjs __tests__/cascade.test.mjs __tests__/badges.test.mjs __tests__/tui-input.test.mjs __tests__/standard-record.test.mjs __tests__/standard-cli.test.mjs __tests__/product-architecture.test.mjs __tests__/tteop-delegation.test.mjs __tests__/mcp-stdio.test.mjs __tests__/multi-update-scroll.test.mjs",
|
|
28
28
|
"test:packaged": "node scripts/packed-artifact-smoke.mjs",
|
|
29
29
|
"sync:platforms": "node scripts/sync-platforms.mjs"
|
|
30
30
|
},
|
package/presentation/cli.mjs
CHANGED
|
@@ -28,6 +28,8 @@ import { callTool, DEFAULT_API_BASE, pullActivePlatforms } from "../tools.mjs";
|
|
|
28
28
|
import { cascade, classify, CLASS_TIERS, UNCLASSED, tierOf } from "../cascade.mjs";
|
|
29
29
|
import { ALL_PLATFORMS } from "../adapters.mjs";
|
|
30
30
|
import { ensureIdentity, keystorePath } from "../keystore.mjs";
|
|
31
|
+
import { pkgVersion } from "../lib/pkg-version.mjs";
|
|
32
|
+
import { cachedUpdateNotice, checkForUpdate } from "../lib/update-check.mjs";
|
|
31
33
|
import { submitSignedWindow } from "../submit.mjs";
|
|
32
34
|
import {
|
|
33
35
|
LEADERBOARD_METRIC,
|
|
@@ -806,9 +808,15 @@ const WATCH_WINDOWS = ["7d", "30d", "90d", "all"];
|
|
|
806
808
|
// oh-my-pi tree (~46s), so `watch --platform claude` used to scan everything and then
|
|
807
809
|
// display one row — scan longer than refresh interval, permanently saturated.
|
|
808
810
|
// null / '' / 'all' still mean "everything", keeping withTokscaleBlind's omp row.
|
|
809
|
-
export async function
|
|
811
|
+
export async function detectActivePullsDetailed(platform, opts = {}) {
|
|
810
812
|
const scoped = platform && platform !== "all" ? [platform] : undefined;
|
|
811
|
-
return pullActivePlatforms({ platforms: scoped }, opts).catch(() =>
|
|
813
|
+
return pullActivePlatforms({ platforms: scoped }, opts).catch(() => ({
|
|
814
|
+
active: [],
|
|
815
|
+
failed: [],
|
|
816
|
+
}));
|
|
817
|
+
}
|
|
818
|
+
export async function detectActivePulls(platform, opts = {}) {
|
|
819
|
+
return (await detectActivePullsDetailed(platform, opts)).active;
|
|
812
820
|
}
|
|
813
821
|
|
|
814
822
|
async function runWatch({
|
|
@@ -840,7 +848,7 @@ async function runWatch({
|
|
|
840
848
|
const draw = async () => {
|
|
841
849
|
// Re-pull each tick so a platform that just started writing logs appears automatically.
|
|
842
850
|
// Scoped by platFilter, so a focused watch never scans platforms it cannot display.
|
|
843
|
-
const pulls = await
|
|
851
|
+
const { active: pulls, failed: failedReads } = await detectActivePullsDetailed(platFilter);
|
|
844
852
|
|
|
845
853
|
if (lines > 0) write(CURSOR_UP(lines));
|
|
846
854
|
|
|
@@ -859,6 +867,9 @@ async function runWatch({
|
|
|
859
867
|
` ${gold("⊙ SigRank")} ${bold("Watch")} ${dim(`${scopeLabel} · ${ts}`)}`,
|
|
860
868
|
);
|
|
861
869
|
push(` ${dim("─".repeat(w - 4))}`);
|
|
870
|
+
if (failedReads.length) {
|
|
871
|
+
push(` ${red("!")} ${dim(`could not read ${failedReads.map((f) => f.platform).join(", ")} — totals below exclude it (it is not "no data")`)}`);
|
|
872
|
+
}
|
|
862
873
|
|
|
863
874
|
if (pulls.length === 0) {
|
|
864
875
|
push();
|
|
@@ -1461,86 +1472,13 @@ async function runSigRank() {
|
|
|
1461
1472
|
resolve();
|
|
1462
1473
|
return;
|
|
1463
1474
|
}
|
|
1464
|
-
// NOT enrolled →
|
|
1475
|
+
// NOT enrolled → nothing is sent. Publishing is signed-only; the old
|
|
1476
|
+
// codename-only paste POST was removed (the endpoint needs a web session).
|
|
1465
1477
|
writeln();
|
|
1466
1478
|
writeln(
|
|
1467
|
-
` ${dim("Not enrolled — run")} ${bold("npx sigrank enroll")} ${dim("to
|
|
1479
|
+
` ${dim("Not enrolled — run")} ${bold("npx sigrank enroll")} ${dim("to publish as a verified operator, or submit at signalaf.com.")}`,
|
|
1468
1480
|
);
|
|
1469
|
-
|
|
1470
|
-
let codename = "";
|
|
1471
|
-
process.stdin.on("data", async function onData(chunk) {
|
|
1472
|
-
if (chunk === "\r" || chunk === "\n") {
|
|
1473
|
-
process.stdin.removeListener("data", onData);
|
|
1474
|
-
codename = codename.trim();
|
|
1475
|
-
if (!codename) {
|
|
1476
|
-
writeln(red(" ✗ codename required"));
|
|
1477
|
-
resolve();
|
|
1478
|
-
return;
|
|
1479
|
-
}
|
|
1480
|
-
writeln();
|
|
1481
|
-
writeln(
|
|
1482
|
-
` ${dim("Submitting all windows for")} ${cyan(codename)}${dim("…")}`,
|
|
1483
|
-
);
|
|
1484
|
-
write(HIDE_CURSOR);
|
|
1485
|
-
try {
|
|
1486
|
-
for (const d of active) {
|
|
1487
|
-
const apiBase = DEFAULT_API_BASE;
|
|
1488
|
-
const WINDOW_TYPE = {
|
|
1489
|
-
"7d": "7d",
|
|
1490
|
-
"30d": "30d",
|
|
1491
|
-
"90d": "90d",
|
|
1492
|
-
all: "all_time",
|
|
1493
|
-
};
|
|
1494
|
-
for (const ww of d.windows ?? []) {
|
|
1495
|
-
const rawPaste = `${ww.pillars.input} ${ww.pillars.output} ${ww.pillars.cacheCreate} ${ww.pillars.cacheRead}`;
|
|
1496
|
-
const windowType = WINDOW_TYPE[ww.window] || ww.window;
|
|
1497
|
-
const now = new Date();
|
|
1498
|
-
const ddmmyy = `${String(now.getDate()).padStart(2, "0")}${String(now.getMonth() + 1).padStart(2, "0")}${String(now.getFullYear()).slice(-2)}`;
|
|
1499
|
-
const content_hash = `sha256:${codename}|${windowType}|${rawPaste}|${ddmmyy}`;
|
|
1500
|
-
const res = await fetch(`${apiBase}/api/v1/ingest-paste`, {
|
|
1501
|
-
method: "POST",
|
|
1502
|
-
headers: {
|
|
1503
|
-
"content-type": "application/json",
|
|
1504
|
-
accept: "application/json",
|
|
1505
|
-
"user-agent": `node/${process.version} sigrank-mcp/cli`,
|
|
1506
|
-
},
|
|
1507
|
-
body: JSON.stringify({
|
|
1508
|
-
codename,
|
|
1509
|
-
raw_paste: rawPaste,
|
|
1510
|
-
window_type: windowType,
|
|
1511
|
-
telemetry: { platform: { primary: d.platform } },
|
|
1512
|
-
content_hash,
|
|
1513
|
-
submitted_ddmmyy: ddmmyy,
|
|
1514
|
-
submitted_at: now.toISOString(),
|
|
1515
|
-
}),
|
|
1516
|
-
}).catch(() => null);
|
|
1517
|
-
const ok = res?.ok ?? false;
|
|
1518
|
-
const status = ok ? green("✓") : red("✗");
|
|
1519
|
-
writeln(
|
|
1520
|
-
` ${status} ${d.platform} ${ww.window}${!ok ? dim(` HTTP ${res?.status ?? "err"}`) : ""}`,
|
|
1521
|
-
);
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
writeln();
|
|
1525
|
-
writeln(
|
|
1526
|
-
` ${green("✓")} Submitted. Visit ${cyan(`signalaf.com/user/${codename}`)}`,
|
|
1527
|
-
);
|
|
1528
|
-
} catch (e) {
|
|
1529
|
-
writeln(red(` ✗ ${e.message}`));
|
|
1530
|
-
}
|
|
1531
|
-
resolve();
|
|
1532
|
-
} else if (chunk === "\u007f") {
|
|
1533
|
-
// backspace
|
|
1534
|
-
if (codename.length > 0) {
|
|
1535
|
-
codename = codename.slice(0, -1);
|
|
1536
|
-
process.stdout.write("\b \b");
|
|
1537
|
-
}
|
|
1538
|
-
} else {
|
|
1539
|
-
codename += chunk;
|
|
1540
|
-
process.stdout.write(chunk);
|
|
1541
|
-
}
|
|
1542
|
-
});
|
|
1543
|
-
process.stdin.resume();
|
|
1481
|
+
resolve();
|
|
1544
1482
|
}
|
|
1545
1483
|
});
|
|
1546
1484
|
});
|
|
@@ -1795,6 +1733,12 @@ async function runSubmit({ platform = "claude", window } = {}) {
|
|
|
1795
1733
|
return;
|
|
1796
1734
|
}
|
|
1797
1735
|
|
|
1736
|
+
if (out.status === "error" && out.reason === "platform_read_failed") {
|
|
1737
|
+
writeln(red(` ✗ ${out.detail}`));
|
|
1738
|
+
process.exitCode = 1;
|
|
1739
|
+
return;
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1798
1742
|
writeln();
|
|
1799
1743
|
let anyRanked = false;
|
|
1800
1744
|
let anyReceivedNotRanked = false;
|
|
@@ -1832,6 +1776,16 @@ async function runSubmit({ platform = "claude", window } = {}) {
|
|
|
1832
1776
|
}
|
|
1833
1777
|
}
|
|
1834
1778
|
|
|
1779
|
+
/** True when the plain-CLI update notice applies: a short command, both streams a TTY. */
|
|
1780
|
+
export function shouldShowCliUpdateNotice(cmd, flags = {}, proc = process) {
|
|
1781
|
+
const short =
|
|
1782
|
+
cmd === "compare" ||
|
|
1783
|
+
cmd === "submit" ||
|
|
1784
|
+
cmd === "enroll" ||
|
|
1785
|
+
(cmd === "board" && (flags.once === true || flags.once === "true"));
|
|
1786
|
+
return short && !!proc.stderr?.isTTY && !!proc.stdout?.isTTY;
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1835
1789
|
export async function runCli(argv) {
|
|
1836
1790
|
const args = argv.slice(2); // strip 'node' + script path
|
|
1837
1791
|
const cmd = args[0];
|
|
@@ -1880,6 +1834,32 @@ export async function runCli(argv) {
|
|
|
1880
1834
|
flags[key] = val;
|
|
1881
1835
|
}
|
|
1882
1836
|
|
|
1837
|
+
// Update notice (plain CLI): only for SHORT commands that reach printUpdateNotice
|
|
1838
|
+
// below. Interactive/long-running ones (start/run/tui/watch/board without --once)
|
|
1839
|
+
// are skipped: the TUI runs its own check, and two checks would race on
|
|
1840
|
+
// update-check.json. The notice goes to stderr and only on a TTY, so piped
|
|
1841
|
+
// stdout stays clean.
|
|
1842
|
+
const wantNotice = shouldShowCliUpdateNotice(cmd, flags, process);
|
|
1843
|
+
const noticeP = wantNotice
|
|
1844
|
+
? (async () => {
|
|
1845
|
+
const cached = cachedUpdateNotice({ current: pkgVersion() });
|
|
1846
|
+
return cached || (await checkForUpdate({ current: pkgVersion() }));
|
|
1847
|
+
})().catch(() => null)
|
|
1848
|
+
: null;
|
|
1849
|
+
const printUpdateNotice = async () => {
|
|
1850
|
+
if (!noticeP) return;
|
|
1851
|
+
const timer = { t: null };
|
|
1852
|
+
const n = await Promise.race([
|
|
1853
|
+
noticeP,
|
|
1854
|
+
new Promise((r) => {
|
|
1855
|
+
timer.t = setTimeout(() => r(null), 300);
|
|
1856
|
+
timer.t.unref?.();
|
|
1857
|
+
}),
|
|
1858
|
+
]);
|
|
1859
|
+
clearTimeout(timer.t);
|
|
1860
|
+
if (n) process.stderr.write(`\n ${gold("⬆")} ${dim(n)}\n`);
|
|
1861
|
+
};
|
|
1862
|
+
|
|
1883
1863
|
try {
|
|
1884
1864
|
if (cmd === "board") {
|
|
1885
1865
|
await runBoard({
|
|
@@ -1937,6 +1917,7 @@ export async function runCli(argv) {
|
|
|
1937
1917
|
await showHelp();
|
|
1938
1918
|
process.exit(2);
|
|
1939
1919
|
}
|
|
1920
|
+
await printUpdateNotice();
|
|
1940
1921
|
} catch (e) {
|
|
1941
1922
|
write(SHOW_CURSOR);
|
|
1942
1923
|
writeln(red(`\n ✗ ${e.message}`));
|