sprag-cli 3.111.0 → 3.113.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprag-cli",
3
- "version": "3.111.0",
3
+ "version": "3.113.0",
4
4
  "description": "The delegation layer for Claude Code and Codex: each task goes to the model and effort that fits it, down to cheaper models for lookups and up to higher effort when a cheaper run would miss, backed by public replay cases, with a live statusline and team rules for Pro and Enterprise.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/brief.js CHANGED
@@ -14,7 +14,8 @@
14
14
  * transcript_path) and the "already briefed" markers are keyed by session_id.
15
15
  *
16
16
  * State: <stateDir>/brief-state.json
17
- * { sessions: { [session_id]: { ts, ctxTier, briefed: [signature] } } }
17
+ * { sessions: { [session_id]: { ts, ctxTier, startedAt, briefed: [signature] } } }
18
+ * startedAt caches the transcript's first timestamp for the session-age warning.
18
19
  * Sessions untouched for 7 days are pruned on every write.
19
20
  *
20
21
  * Division of labor with the SessionStart hook: SessionStart prints the
@@ -169,6 +170,49 @@ function ctxTierOf(pct) {
169
170
 
170
171
  const fmtK = (n) => `${Math.round(n / 1000)}k`;
171
172
 
173
+ // A session left open for days re-reads everything it ever loaded on every
174
+ // request, and each auto-compaction blurs the decisions made early on. Past a
175
+ // day the briefing asks the model to write a handoff and send the user to a
176
+ // new session, once per whole day of age.
177
+ export const SESSION_AGE_DAY_MS = 24 * 60 * 60 * 1000;
178
+ const HEAD_BYTES = 64 * 1024;
179
+
180
+ /**
181
+ * When THIS session started: the first `timestamp` in the transcript head.
182
+ * A resumed session keeps its original messages, so the age counts from the
183
+ * first request rather than from the resume. Falls back to the file's birth
184
+ * time; null when neither is readable.
185
+ */
186
+ export function sessionStartedAt(transcriptPath) {
187
+ let fd;
188
+ try {
189
+ fd = openSync(transcriptPath, 'r');
190
+ const buf = Buffer.alloc(HEAD_BYTES);
191
+ const n = readSync(fd, buf, 0, HEAD_BYTES, 0);
192
+ for (const m of buf.toString('utf8', 0, n).matchAll(/"timestamp"\s*:\s*"([^"]+)"/g)) {
193
+ const t = Date.parse(m[1]);
194
+ if (Number.isFinite(t)) return t;
195
+ }
196
+ } catch {
197
+ return null;
198
+ } finally {
199
+ if (fd !== undefined) try { closeSync(fd); } catch { /* already closed */ }
200
+ }
201
+ try {
202
+ const b = statSync(transcriptPath).birthtimeMs;
203
+ return b > 0 ? b : null;
204
+ } catch {
205
+ return null;
206
+ }
207
+ }
208
+
209
+ const pad2 = (n) => String(n).padStart(2, '0');
210
+ const fmtLocal = (ms) => { const d = new Date(ms); return `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())} ${pad2(d.getHours())}:${pad2(d.getMinutes())}`; };
211
+
212
+ export function sessionAgeMessage(days, startedAt) {
213
+ return `이 세션을 시작한 지 ${days}일이 넘었습니다(시작 ${fmtLocal(startedAt)}). 오래 켜 둔 세션은 요청마다 그동안 쌓인 대화를 다시 읽어 비용이 커집니다. 자동 압축을 거칠 때마다 앞서 정한 내용도 흐려집니다. 사용자에게 이 사실을 알리고 지금 하던 일을 마무리한 뒤 \`sprag handoff\`로 핸드오프 파일을 만들어 빈 칸(한 일, 남은 일, 이어갈 지점, 주의할 점)을 채우십시오. 그다음 사용자에게 새 세션을 열어 "<만든 핸드오프 파일 경로> 핸드오프 이어서 해줘"라고 입력하라고 파일 경로를 넣은 문장 그대로 안내하십시오.`;
214
+ }
215
+
172
216
  /**
173
217
  * Called by the SessionStart hook after it prints the session-start snapshot:
174
218
  * records the signatures it actually briefed so runBrief suppresses exactly
@@ -233,6 +277,19 @@ export async function runBrief({ sessionId, transcriptPath, root = process.cwd()
233
277
  }
234
278
  }
235
279
 
280
+ // ── session age (per-session, once per whole day) ──
281
+ if (s.startedAt == null && transcriptPath) s.startedAt = sessionStartedAt(transcriptPath);
282
+ const ageDays = s.startedAt ? Math.floor((now - s.startedAt) / SESSION_AGE_DAY_MS) : 0;
283
+ if (ageDays >= 1) {
284
+ const sig = `age|${ageDays}`;
285
+ const briefed = new Set(s.briefed || []);
286
+ if (!briefed.has(sig)) {
287
+ briefed.add(sig);
288
+ s.briefed = [...briefed];
289
+ items.push(sessionAgeMessage(ageDays, s.startedAt));
290
+ }
291
+ }
292
+
236
293
  // ── mid-session route-scan / rule-health changes (global state, briefed
237
294
  // at most once per session per signature). Skipped while the routing
238
295
  // master switch is off. ──
@@ -30,8 +30,8 @@ import { bedrockDisplayFromId } from '../stdin-payload.js';
30
30
  import { modelFamily } from '../savings-ledger.js';
31
31
  import { shareLegend } from '../model-share.js';
32
32
  import { STAR_URL } from '../star-note.js';
33
- import { speciesLabel } from '../office-species.js';
34
- import { standingFeedbackShort } from '../team-standing.js';
33
+ import { GRADES, speciesLabel } from '../office-species.js';
34
+ import { scorePctOf, nextOf, nextGradeUp, floorPct } from '../team-standing.js';
35
35
  import { cellWidth } from '../cell-width.js';
36
36
 
37
37
  // The 8-color ANSI defaults (RED=31, GREEN=32, YELLOW=33…) read as garish
@@ -434,15 +434,19 @@ function buildTeamSeg(team, c, mode = 'icon', now = Date.now()) {
434
434
  /**
435
435
  * The team line (multi-line layout): the licensed team this machine belongs
436
436
  * to, on a line of its own so it never blends into the diagnostics chips, and
437
- * what the standing asks of you. Head: plan, organization, team, member id.
438
- * Breakdown: the rank with the animal, then the short feedback from
439
- * src/team-standing.js (people to pass for #1, the next species and what it
440
- * takes). Null for a machine that has not joined; the chip above stands in on
441
- * the single-line layouts.
442
- * icon: "👥 Pro · amazon · AWS-FSI · member-1e500474 | 종합 점수 12명 중 3위, 팀 4명 중 1위 🦊 여우 · 1위까지 2명 · 다음 🐆 치타: 2명 더 (77%부터)"
443
- * text: "Pro · amazon · AWS-FSI · member-1e500474 | overall score #3 of 12, team #1 of 4 Fox · 2 to pass for #1 · next Cheetah: 2 more (77% and up)"
437
+ * where the standing comes from. Head: plan, organization, team, member id.
438
+ * Tail, two groups apart by a gray pipe: the species with a gauge of the score
439
+ * percentile and the species one row up, then the ranks the score is made of
440
+ * (overall, team, spend, delegation, and prompts where capture is on). The only
441
+ * percentages on the line are score percentiles (the gauge and the next
442
+ * species' starting percentile); the two axes are ranks. Null for a machine
443
+ * that has not joined; the chip above stands in on the single-line layouts.
444
+ * icon: "👥 Pro · amazon · AWS-FSI · member-1e500474 | 🦊 여우 ▰▰▰▰▰▰▰▰▰▱▱▱ 75% → 🐆 치타 77% | 종합 3/12위 · 팀 1/4위 · 사용량 2/12위 · 위임률 5/12위"
445
+ * text: "Pro · amazon · AWS-FSI · member-1e500474 | Fox 75% → Cheetah 77% | overall #3/12 · team #1/4 · spend #2/12 · delegation #5/12"
446
+ * Text mode draws no gauge, as the other gauges do not. An older server sends no
447
+ * axis ranks, and the second group then holds the overall rank (and the team's).
444
448
  */
445
- function buildTeamLine(team, c, isIcon, g, mode = 'icon', now = Date.now()) {
449
+ function buildTeamLine(team, c, isIcon, g, mode = 'icon', now = Date.now(), color = true) {
446
450
  if (!team || typeof team !== 'object' || !team.label) return null;
447
451
  const ko = team.lang === 'ko';
448
452
  const emoji = mode === 'icon';
@@ -453,22 +457,58 @@ function buildTeamLine(team, c, isIcon, g, mode = 'icon', now = Date.now()) {
453
457
  const head = `${isIcon && g.team ? `${g.team} ` : ''}${[plan, org, teamName, team.label].filter(Boolean).join(' · ')}`;
454
458
  const st = team.standing;
455
459
  const fresh = st && Number.isFinite(st.fetchedAt) && now - st.fetchedAt <= TEAM_STANDING_MAX_AGE_MS;
456
- const parts = [];
457
- if (fresh) {
458
- const animal = speciesLabel(st.grade, team.lang, { emoji });
459
- const ranked = animal && Number.isInteger(st.rank) && Number.isInteger(st.ranked) && st.rank >= 1 && st.ranked >= st.rank;
460
- if (ranked) {
461
- const inTeam = Number.isInteger(st.teamRank) && Number.isInteger(st.teamRanked)
462
- && st.teamRank >= 1 && st.teamRanked >= st.teamRank && st.teamRanked < st.ranked;
463
- const teamPlace = inTeam ? (ko ? `, 팀 ${st.teamRanked}명 중 ${st.teamRank}위` : `, team #${st.teamRank} of ${st.teamRanked}`) : '';
464
- parts.push(ko ? `종합 점수 ${st.ranked}명 중 ${st.rank}위${teamPlace} ${animal}` : `overall score #${st.rank} of ${st.ranked}${teamPlace} ${animal}`);
465
- } else if (animal) {
466
- parts.push(animal);
460
+ // Groups of items: ' · ' inside a group, ' | ' between groups.
461
+ const groups = [];
462
+ const animal = fresh ? speciesLabel(st.grade, team.lang, { emoji }) : null;
463
+ if (animal) {
464
+ const ranked = Number.isInteger(st.rank) && Number.isInteger(st.ranked) && st.rank >= 1 && st.ranked >= st.rank;
465
+ if (st.grade === 'ghost' || !ranked) {
466
+ groups.push([animal, ko ? '이 기간 업로드 없음' : 'no usage this period']);
467
+ } else if (st.idle === true || st.grade === 'chick') {
468
+ groups.push([animal], [ko ? '지출이 생기면 순위에 오름' : 'spend to enter the standings']);
469
+ } else {
470
+ const sr = scorePctOf(st);
471
+ const pctNow = Math.round(sr * 100);
472
+ // Text mode has no gauge glyph (like every other gauge on the line).
473
+ const bar = isIcon ? `${gaugeColored(sr * 100, c, GRAY, color, mode)} ` : '';
474
+ if (st.ranked === 1) {
475
+ groups.push(
476
+ [`${animal} ${bar}${pctNow}% ${ko ? '혼자라 고정' : 'fixed while alone'}`],
477
+ [ko ? '동료가 참여하면 사용량과 위임률 순위로 등급이 갈림' : 'once a colleague joins, the spend and delegation ranks decide the species'],
478
+ );
479
+ } else {
480
+ const next = nextOf(st, sr);
481
+ const nextRow = next ? GRADES.find((r) => r.key === next.grade) : null;
482
+ const up = nextRow || nextGradeUp(st.grade);
483
+ const first = [];
484
+ let tail = '';
485
+ if (up) {
486
+ const label = speciesLabel(up.key, team.lang, { emoji }) || up.key;
487
+ const floor = up.minSr >= 0 ? ` ${floorPct(up)}%` : '';
488
+ const needDlg = nextRow ? next.needDlg : up.needDlg;
489
+ const rule = needDlg ? (ko ? ' (위임률 중앙값 이상 필요)' : ' (needs median delegation or more)') : '';
490
+ tail = ` → ${label}${floor}${rule}`;
491
+ }
492
+ first.push(`${animal} ${bar}${pctNow}%${tail}`);
493
+ if (!up) first.push(ko ? '도감 최상위' : 'top of the field guide');
494
+ groups.push(first);
495
+
496
+ const inTeam = Number.isInteger(st.teamRank) && Number.isInteger(st.teamRanked)
497
+ && st.teamRank >= 1 && st.teamRanked >= st.teamRank && st.teamRanked < st.ranked;
498
+ const has = (v) => Number.isFinite(v);
499
+ const rk = (koName, enName, r, n) => (ko ? `${koName} ${r}/${n}위` : `${enName} #${r}/${n}`);
500
+ const ranks = [`${st.crown && emoji ? '👑 ' : ''}${rk('종합', 'overall', st.rank, st.ranked)}`];
501
+ if (inTeam) ranks.push(rk('팀', 'team', st.teamRank, st.teamRanked));
502
+ if (has(st.spendRank)) ranks.push(rk('사용량', 'spend', st.spendRank, st.ranked));
503
+ if (has(st.dlgRank)) ranks.push(rk('위임률', 'delegation', st.dlgRank, st.ranked));
504
+ if (has(st.promptRank)) ranks.push(rk('프롬프트', 'prompts', st.promptRank, st.ranked));
505
+ groups.push(ranks);
506
+ }
467
507
  }
468
- parts.push(...standingFeedbackShort(st, team.lang, { emoji }));
469
508
  }
470
- const tail = parts.length
471
- ? ` ${c(GRAY)}|${c(RESET)} ${parts.map((p) => `${c(GRAY)}${p}${c(RESET)}`).join(` ${c(GRAY)}·${c(RESET)} `)}`
509
+ const dot = ` ${c(GRAY)}·${c(RESET)} `;
510
+ const tail = groups.length
511
+ ? ` ${c(GRAY)}|${c(RESET)} ${groups.map((items) => items.map((p) => `${c(GRAY)}${p}${c(RESET)}`).join(dot)).join(` ${c(GRAY)}|${c(RESET)} `)}`
472
512
  : '';
473
513
  return { usd: 0, line: `${c(GRAY)}${c(BOLD)}${head}${c(RESET)}${tail}` };
474
514
  }
@@ -1748,7 +1788,7 @@ export function formatReport(data, { color = true, verbose = false, timer = true
1748
1788
  // these slots, so this is the only place that knows how each chip is built.
1749
1789
  // The team gets a line of its own in the multi-line layout (buildTeamLine),
1750
1790
  // and its chip steps aside; the single-line layout keeps the chip.
1751
- const teamLine = singleLine ? null : buildTeamLine(data.team, c, isIcon, g, mode);
1791
+ const teamLine = singleLine ? null : buildTeamLine(data.team, c, isIcon, g, mode, Date.now(), color);
1752
1792
  const built = {
1753
1793
  capWarn: buildCapWarnSeg(capWarn, c, isIcon, g, color, mode),
1754
1794
  spike: buildSpikeSeg(spikeChip, c),
@@ -78,6 +78,27 @@ export function isSystemPrompt(text) {
78
78
  return SYSTEM_PROMPT_PREFIXES.some((p) => t.startsWith(p));
79
79
  }
80
80
 
81
+ /**
82
+ * A paragraph that opens with a short bracketed label ("[운영 규칙] …",
83
+ * "[리마인더] …") is a standing instruction a wrapper adds to every message,
84
+ * such as a Slack bot's prompt suffix.
85
+ */
86
+ const STANDING_PARA_RE = /^\[[^\]\n]{1,24}\][ \t]/;
87
+
88
+ /**
89
+ * The user's request without the standing-instruction paragraphs a wrapper puts
90
+ * before or after it. A 130-character "[운영 규칙]" suffix on every Slack message
91
+ * made each prompt read as a long spec: over 260 such prompts the delegation hint
92
+ * fired 0 times instead of 24, and the implementation reminder 236 times instead
93
+ * of 21. A prompt that is nothing but such a paragraph is kept as it is.
94
+ */
95
+ export function stripStandingInstructions(text) {
96
+ const paras = String(text || '').trim().split(/\n[ \t]*\n/);
97
+ while (paras.length > 1 && STANDING_PARA_RE.test(paras[paras.length - 1].trim())) paras.pop();
98
+ while (paras.length > 1 && STANDING_PARA_RE.test(paras[0].trim())) paras.shift();
99
+ return paras.join('\n\n').trim();
100
+ }
101
+
81
102
  /** Endings that ask what the model thinks ("좋은가", "괜찮지 않을까", "should we"). */
82
103
  const OPINION_RE = /(?:좋은가|좋을까|좋겠지|좋지\s*않|낫겠|낫지\s*않|나을까|나을\s*듯|괜찮(?:을까|은가|겠|지\s*않)|어때|어떨까|어떤가|맞(?:을까|는\s*건가|는가)|아닐까|아닌가|싶은데|듯\s*한데|생각(?:해|이)|의견|\bshould\s+(?:we|i)\b|\bwhat do you think\b|\bis it (?:better|worth)\b)/i;
83
104
  /** A request verb in the same text turns the opinion ending back into a task ("…아닐까 확인해줘"). */
@@ -148,7 +169,7 @@ export function looksLikeContextOrSpec(text) {
148
169
  * split at prompt time. Harness-written messages and acks are not requests.
149
170
  */
150
171
  export function looksLikeImplementation(text) {
151
- const t = String(text || '').trim();
172
+ const t = stripStandingInstructions(text);
152
173
  if (t.length < MIN_LEN || isSystemPrompt(t)) return false;
153
174
  if (OUTWARD_RE.test(t) || OPEN_RESEARCH_RE.test(t)) return false;
154
175
  return EDIT_RE.test(t) || EDIT_MORE_RE.test(t) || (t.length > SPEC_LEN && !looksPasted(t));
@@ -257,7 +278,7 @@ export function unreachableTiers(env = process.env) {
257
278
  * one this session cannot reach
258
279
  */
259
280
  export function routeMatch(text, { rules, sessionRank = null, root, env = process.env, grade = delegationGrade() } = {}) {
260
- const t = String(text || '').trim();
281
+ const t = stripStandingInstructions(text);
261
282
  if (t.length < MIN_LEN) return null;
262
283
  // A task notification or command echo is not a request, whatever words it holds.
263
284
  if (isSystemPrompt(t)) return null;
@@ -351,7 +372,7 @@ const ACTION_RE = new RegExp(
351
372
  * grade 'quality'), 'action' an irreversible step with no judgement word.
352
373
  */
353
374
  export function judgementMatch(text, { grade = delegationGrade() } = {}) {
354
- const t = String(text || '').trim();
375
+ const t = stripStandingInstructions(text);
355
376
  if (t.length < MIN_LEN || isSystemPrompt(t)) return null;
356
377
  if (ESCALATE_RE.test(t)) {
357
378
  const kind = ESCALATE_RE.test(t.replace(ACTION_RE, ' ')) ? 'escalate' : 'action';
@@ -30,7 +30,7 @@ const pct = (v) => `${Math.round(Number(v) * 100)}%`;
30
30
  /** A weight as a percentage with one decimal where it has one: 0.625 → 62.5%, 0.5 → 50%. */
31
31
  const pctW = (v) => `${Math.round(Number(v) * 1000) / 10}%`;
32
32
  const money = (v) => `$${Number(v).toFixed(2)}`;
33
- const floorPct = (g) => Math.round(g.minSr * 100);
33
+ export const floorPct = (g) => Math.round(g.minSr * 100);
34
34
  /**
35
35
  * Percentage points from the score percentile `sr` up to the floor of species
36
36
  * `g`, at least 1 while the floor is not cleared, 0 when it already is (then
@@ -154,10 +154,16 @@ export function standingGuideLines(st, { lang = 'en', org = null, team = null }
154
154
  // The caller's own figures, when the server sent them.
155
155
  if (has(st.dlg) || has(st.spent) || has(st.scorePct)) {
156
156
  const parts = [];
157
- if (has(st.spent)) parts.push(ko ? `지출 ${money(st.spent)}` : `spent ${money(st.spent)}`);
157
+ // The rank on each axis (server migration 20261109000200), out of the ranked people.
158
+ const axis = (r) => (has(r) ? (ko ? `${r}/${st.ranked}위` : `#${r}/${st.ranked}`) : '');
159
+ if (has(st.spent)) {
160
+ const rk = axis(st.spendRank);
161
+ parts.push(ko ? `지출 ${money(st.spent)}${rk ? ` (${rk})` : ''}` : `spent ${money(st.spent)}${rk ? ` (${rk})` : ''}`);
162
+ }
158
163
  if (has(st.dlg)) {
159
- const med = has(st.medianDlg) ? (ko ? ` (회사 중앙값 ${pct(st.medianDlg)})` : ` (company median ${pct(st.medianDlg)})`) : '';
160
- parts.push(ko ? `위임 비율 ${pct(st.dlg)}${med}` : `delegation share ${pct(st.dlg)}${med}`);
164
+ const rk = axis(st.dlgRank);
165
+ const med = has(st.medianDlg) ? (ko ? `${rk ? ', ' : ' ('}회사 중앙값 ${pct(st.medianDlg)})` : `${rk ? ', ' : ' ('}company median ${pct(st.medianDlg)})`) : (rk ? ')' : '');
166
+ parts.push(ko ? `위임 비율 ${pct(st.dlg)}${rk ? ` (${rk}` : ''}${med}` : `delegation share ${pct(st.dlg)}${rk ? ` (${rk}` : ''}${med}`);
161
167
  }
162
168
  if (has(st.scorePct)) parts.push(ko ? `점수 백분위 ${pct(st.scorePct)}` : `score percentile ${pct(st.scorePct)}`);
163
169
  lines.push(` ${ko ? '이 컴퓨터' : 'This machine'}: ${parts.join(' · ')}`);
@@ -227,67 +233,6 @@ export function standingGuideLines(st, { lang = 'en', org = null, team = null }
227
233
  return lines;
228
234
  }
229
235
 
230
- /**
231
- * The short form for the statusline's team line: where the rank puts you and
232
- * what the next species takes, as two or three phrases. The same facts as the
233
- * block above, without the sentences.
234
- * ['1위까지 2명', '다음 🐆 치타: 2명 더 (77%부터)']
235
- * `emoji: false` keeps the species names bare (narrow and text modes).
236
- */
237
- export function standingFeedbackShort(st, lang = 'en', { emoji = true } = {}) {
238
- if (!st || typeof st !== 'object' || typeof st.grade !== 'string') return [];
239
- const ko = lang === 'ko';
240
- const label = (k) => speciesLabel(k, lang, { emoji }) || k;
241
- const has = (v) => Number.isFinite(v);
242
- const ranked = Number.isInteger(st.rank) && Number.isInteger(st.ranked) && st.rank >= 1 && st.ranked >= st.rank;
243
- if (st.grade === 'ghost' || !ranked) return [ko ? '이 기간 업로드 없음' : 'no usage this period'];
244
- const idle = st.idle === true || st.grade === 'chick';
245
- // Alone in the standings the percentile is 50% by definition and nothing
246
- // moves it, so the line says that and what would: a colleague joining.
247
- if (st.ranked === 1 && !idle) {
248
- return ko
249
- ? ['지금 50%, 혼자라 고정', '동료가 참여하면 순위 시작']
250
- : ['now 50%, fixed while alone', 'standings start when a colleague joins'];
251
- }
252
- const out = [];
253
- if (st.crown) out.push(ko ? `${emoji ? '👑 ' : ''}회사 1위` : `${emoji ? '👑 ' : ''}#1 in the company`);
254
- else if (st.rank === 1 && st.ranked === 1) out.push(ko ? '혼자 순위에 있음' : 'alone in the standings');
255
- else if (st.rank === 1) out.push(ko ? '회사 1위' : '#1 in the company');
256
- else out.push(ko ? `1위까지 ${st.rank - 1}명` : `${st.rank - 1} to pass for #1`);
257
-
258
- const sr = scorePctOf(st);
259
- const next = nextOf(st, sr);
260
- const up = nextGradeUp(st.grade);
261
- const floor = (g) => (g && g.minSr >= 0 ? (ko ? `${floorPct(g)}%부터` : `${floorPct(g)}% and up`) : '');
262
- if (next) {
263
- const s = label(next.grade);
264
- const g = GRADES.find((x) => x.key === next.grade);
265
- const x = Math.max(1, Number(next.pass) || 0);
266
- const c = has(st.medianDlg) ? pct(st.medianDlg) : (ko ? '회사 중앙값' : 'the company median');
267
- const pts = pointsTo(g, sr);
268
- if (pts !== null) {
269
- // With the percentile: where you are and how many points more.
270
- const now = pct(sr);
271
- if (next.needDlg && !(Number(next.pass) > 0)) out.push(ko ? `지금 ${now}, 위임 비율 ${c} 이상이면 ${s}` : `now ${now}, delegation share ${c} or more for ${s}`);
272
- else if (next.needDlg) out.push(ko ? `지금 ${now}, ${pts}%p 더 오르고 위임 비율 ${c} 이상이면 ${s}` : `now ${now}, ${pts} pts more and delegation share ${c} or more for ${s}`);
273
- else out.push(ko ? `지금 ${now}, ${Math.max(1, pts)}%p 더 오르면 ${s} (${x}명 앞지르기)` : `now ${now}, ${Math.max(1, pts)} pts more for ${s} (pass ${x})`);
274
- } else if (next.needDlg && !(Number(next.pass) > 0)) {
275
- out.push(ko ? `다음 ${s}: 위임 비율 ${c} 이상` : `next ${s}: delegation share ${c} or more`);
276
- } else if (next.needDlg) {
277
- out.push(ko ? `다음 ${s}: ${x}명 더, 위임 비율 ${c} 이상` : `next ${s}: ${x} more and delegation share ${c} or more`);
278
- } else {
279
- out.push(ko ? `다음 ${s}: ${x}명 더${floor(g) ? ` (${floor(g)})` : ''}` : `next ${s}: ${x} more${floor(g) ? ` (${floor(g)})` : ''}`);
280
- }
281
- } else if (idle) {
282
- out.push(ko ? '지출이 생기면 순위에 오름' : 'spend to enter the standings');
283
- } else if (!up) {
284
- out.push(ko ? '도감 최상위' : 'top of the field guide');
285
- } else {
286
- out.push(ko ? `다음 ${label(up.key)} (${floor(up)})` : `next ${label(up.key)} (${floor(up)})`);
287
- }
288
- return out;
289
- }
290
-
291
236
  /**
292
237
  * The field guide: every species by tier, best first, with the percentile each
293
238
  * one starts at and a marker on the caller's own. Shared by the ranked and the
package/src/team-sync.js CHANGED
@@ -127,6 +127,9 @@ async function refreshStanding({ memberKey, dir, fetch, now }) {
127
127
  // The same score counted within the member's own team.
128
128
  teamRank: num(r.team_rank), teamRanked: num(r.team_ranked),
129
129
  teamName: typeof r.team_name === 'string' && r.team_name ? r.team_name : null,
130
+ // The two (three, with prompt capture) ranks the overall score adds, each out
131
+ // of `ranked` (server migration 20261109000200). An older server omits them.
132
+ spendRank: num(r.spend_rank), dlgRank: num(r.dlg_rank), promptRank: num(r.prompt_rank),
130
133
  };
131
134
  saveTeamState({
132
135
  ...cur,
@@ -161,13 +164,17 @@ export function readTeamChip({ dir = userDataDir() } = {}) {
161
164
  ? {
162
165
  grade: st.grade, rank: Number.isFinite(st.rank) ? st.rank : null, ranked: Number.isFinite(st.ranked) ? st.ranked : null,
163
166
  teamRank: Number.isFinite(st.teamRank) ? st.teamRank : null, teamRanked: Number.isFinite(st.teamRanked) ? st.teamRanked : null,
164
- // What the team line says about moving up (src/team-standing.js standingFeedbackShort).
167
+ // What the team line shows: the gauge, the next species and the axis ranks (statusline.js buildTeamLine).
165
168
  crown: !!st.crown,
166
169
  next: st.next && typeof st.next === 'object' && typeof st.next.grade === 'string'
167
170
  ? { grade: st.next.grade, pass: Number.isFinite(st.next.pass) ? st.next.pass : 0, needDlg: !!st.next.needDlg }
168
171
  : null,
169
172
  idle: typeof st.idle === 'boolean' ? st.idle : null,
170
173
  medianDlg: Number.isFinite(st.medianDlg) ? st.medianDlg : null,
174
+ scorePct: Number.isFinite(st.scorePct) ? st.scorePct : null,
175
+ spendRank: Number.isFinite(st.spendRank) ? st.spendRank : null,
176
+ dlgRank: Number.isFinite(st.dlgRank) ? st.dlgRank : null,
177
+ promptRank: Number.isFinite(st.promptRank) ? st.promptRank : null,
171
178
  fetchedAt: Number(st.fetchedAt) || 0,
172
179
  }
173
180
  : null,