sprag-cli 3.112.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.112.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": {
@@ -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),
@@ -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,