sprag-cli 3.104.0 β†’ 3.105.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.104.0",
3
+ "version": "3.105.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": {
@@ -31,6 +31,7 @@ import { modelFamily } from '../savings-ledger.js';
31
31
  import { shareLegend } from '../model-share.js';
32
32
  import { STAR_URL } from '../star-note.js';
33
33
  import { speciesLabel } from '../office-species.js';
34
+ import { standingFeedbackShort } from '../team-standing.js';
34
35
  import { cellWidth } from '../cell-width.js';
35
36
 
36
37
  // The 8-color ANSI defaults (RED=31, GREEN=32, YELLOW=33…) read as garish
@@ -429,6 +430,48 @@ function buildTeamSeg(team, c, mode = 'icon', now = Date.now()) {
429
430
  return `${c(GRAY)}${plan}${team.label}${org}${animal ? `${place} ${animal}` : ''}${c(RESET)}`;
430
431
  }
431
432
 
433
+ /**
434
+ * The team line (multi-line layout): the licensed team this machine belongs
435
+ * to, on a line of its own so it never blends into the diagnostics chips, and
436
+ * what the standing asks of you. Head: plan, organization, team, member id.
437
+ * Breakdown: the rank with the animal, then the short feedback from
438
+ * src/team-standing.js (people to pass for #1, the next species and what it
439
+ * takes). Null for a machine that has not joined; the chip above stands in on
440
+ * the single-line layouts.
441
+ * icon: "πŸ‘₯ Pro Β· amazon Β· AWS-FSI Β· member-1e500474 | μ’…ν•© 점수 12λͺ… 쀑 3μœ„, νŒ€ 4λͺ… 쀑 1μœ„ 🦊 μ—¬μš° Β· 1μœ„κΉŒμ§€ 2λͺ… Β· λ‹€μŒ πŸ† μΉ˜νƒ€: 2λͺ… 더 (77%λΆ€ν„°)"
442
+ * 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)"
443
+ */
444
+ function buildTeamLine(team, c, isIcon, g, mode = 'icon', now = Date.now()) {
445
+ if (!team || typeof team !== 'object' || !team.label) return null;
446
+ const ko = team.lang === 'ko';
447
+ const emoji = mode === 'icon';
448
+ const plan = typeof team.plan === 'string' && team.plan ? `${team.plan[0].toUpperCase()}${team.plan.slice(1)}` : null;
449
+ const org = typeof team.org === 'string' && team.org ? team.org : null;
450
+ const teamName = typeof team.team === 'string' && team.team && team.team !== org ? team.team : null;
451
+ // Narrow has no verified glyph for the team, so its head starts with the words.
452
+ const head = `${isIcon && g.team ? `${g.team} ` : ''}${[plan, org, teamName, team.label].filter(Boolean).join(' Β· ')}`;
453
+ const st = team.standing;
454
+ const fresh = st && Number.isFinite(st.fetchedAt) && now - st.fetchedAt <= TEAM_STANDING_MAX_AGE_MS;
455
+ const parts = [];
456
+ if (fresh) {
457
+ const animal = speciesLabel(st.grade, team.lang, { emoji });
458
+ const ranked = animal && Number.isInteger(st.rank) && Number.isInteger(st.ranked) && st.rank >= 1 && st.ranked >= st.rank;
459
+ if (ranked) {
460
+ const inTeam = Number.isInteger(st.teamRank) && Number.isInteger(st.teamRanked)
461
+ && st.teamRank >= 1 && st.teamRanked >= st.teamRank && st.teamRanked < st.ranked;
462
+ const teamPlace = inTeam ? (ko ? `, νŒ€ ${st.teamRanked}λͺ… 쀑 ${st.teamRank}μœ„` : `, team #${st.teamRank} of ${st.teamRanked}`) : '';
463
+ parts.push(ko ? `μ’…ν•© 점수 ${st.ranked}λͺ… 쀑 ${st.rank}μœ„${teamPlace} ${animal}` : `overall score #${st.rank} of ${st.ranked}${teamPlace} ${animal}`);
464
+ } else if (animal) {
465
+ parts.push(animal);
466
+ }
467
+ parts.push(...standingFeedbackShort(st, team.lang, { emoji }));
468
+ }
469
+ const tail = parts.length
470
+ ? ` ${c(GRAY)}|${c(RESET)} ${parts.map((p) => `${c(GRAY)}${p}${c(RESET)}`).join(` ${c(GRAY)}Β·${c(RESET)} `)}`
471
+ : '';
472
+ return { usd: 0, line: `${c(GRAY)}${c(BOLD)}${head}${c(RESET)}${tail}` };
473
+ }
474
+
432
475
  /**
433
476
  * Harness πŸ…· segment builder β€” shared by the full report and the no-session
434
477
  * fallback line. Best-effort: never throws into the statusline (corrupted
@@ -1531,7 +1574,7 @@ function arrangeSegments(order, s) {
1531
1574
  /**
1532
1575
  * The headline lines that sit above the chips, as one string of `line\n` pairs.
1533
1576
  */
1534
- function buildHeadlines(delegated, doc2md, want, eol, columns = 0, c = (v) => v) {
1577
+ function buildHeadlines(delegated, doc2md, want, eol, columns = 0, c = (v) => v, teamLine = null) {
1535
1578
  // Each savings source that earned real money gets a headline line, ordered
1536
1579
  // biggest saver first β€” the top line is the one the eye lands on, so it
1537
1580
  // goes to whichever habit is actually paying for the tool. The diagnostics
@@ -1543,6 +1586,8 @@ function buildHeadlines(delegated, doc2md, want, eol, columns = 0, c = (v) => v)
1543
1586
  // The effort-raise line closes the savings lines rather than competing with
1544
1587
  // them: its figure is a part of Routing saved, not a saver of its own.
1545
1588
  if (delegated.raisedHeadline && want('delegated')) headlines.push(delegated.raisedHeadline);
1589
+ // The team line comes last: identity and standing, after the money.
1590
+ if (teamLine && want('team')) headlines.push(teamLine);
1546
1591
  const rows = columns
1547
1592
  ? headlines.flatMap((h) => wrapHeadline(h.line, availWidth(columns), c))
1548
1593
  : headlines.map((h) => h.line);
@@ -1602,6 +1647,9 @@ export function formatReport(data, { color = true, verbose = false, timer = true
1602
1647
 
1603
1648
  // One slot per chip; segmentsNamed() maps the names in the segment list onto
1604
1649
  // these slots, so this is the only place that knows how each chip is built.
1650
+ // The team gets a line of its own in the multi-line layout (buildTeamLine),
1651
+ // and its chip steps aside; the single-line layout keeps the chip.
1652
+ const teamLine = singleLine ? null : buildTeamLine(data.team, c, isIcon, g, mode);
1605
1653
  const built = {
1606
1654
  capWarn: buildCapWarnSeg(capWarn, c, isIcon, g, color, mode),
1607
1655
  spike: buildSpikeSeg(spikeChip, c),
@@ -1638,7 +1686,8 @@ export function formatReport(data, { color = true, verbose = false, timer = true
1638
1686
  // check β€” this render path never touches the network.
1639
1687
  version: buildVersionSeg(options.version, data.update, c, isIcon, verbose, g),
1640
1688
  // Member id and office animal, from team.json; null unless this machine joined a team.
1641
- team: buildTeamSeg(data.team, c, mode),
1689
+ // Null when the team line carries it (multi-line layout), so no empty slot is drawn.
1690
+ team: teamLine ? null : buildTeamSeg(data.team, c, mode),
1642
1691
  // Delegation-rule registry (`rules 10 Β· ⚠1`), opt-in through `--segments`.
1643
1692
  rules: buildRulesSeg(data.ruleStats, c, g),
1644
1693
  };
@@ -1651,8 +1700,8 @@ export function formatReport(data, { color = true, verbose = false, timer = true
1651
1700
  // "erase from cursor to EOL" CSI. Only emitted when color (i.e. ANSI) is
1652
1701
  // allowed β€” --no-color/NO_COLOR consumers expect escape-free output.
1653
1702
  const eol = color ? '\x1b[K' : '';
1654
- if (singleLine || !columns) return buildHeadlines(delegated, doc2md, want, eol) + segs.join(' Β· ') + eol;
1655
- const headlines = buildHeadlines(delegated, doc2md, want, eol, columns, c);
1703
+ if (singleLine || !columns) return buildHeadlines(delegated, doc2md, want, eol, 0, c, teamLine) + segs.join(' Β· ') + eol;
1704
+ const headlines = buildHeadlines(delegated, doc2md, want, eol, columns, c, teamLine);
1656
1705
 
1657
1706
  // The chips that stop the work: layoutChips drops from the tail when the
1658
1707
  // terminal is narrow, and these must survive that.
package/src/glyphs.js CHANGED
@@ -56,6 +56,8 @@ const ICON = {
56
56
  hit: '🧠',
57
57
  ttl: '⏳',
58
58
  month: 'πŸ’΅',
59
+ // Team: the people this machine is ranked among. U+1F465, East Asian Width W.
60
+ team: 'πŸ‘₯',
59
61
  ctx: 'πŸ“¦',
60
62
  saved: 'πŸ’°',
61
63
  used: 'πŸ“Š',
@@ -87,6 +89,7 @@ const NARROW = {
87
89
  hit: 'β—‰', // bullseye: a cache hit
88
90
  ttl: 'β—”', // a partly elapsed dial
89
91
  month: 'βˆ‘', // a running total
92
+ team: '', // no glyph verified in the font yet; the team line's own words lead it
90
93
  ctx: 'β—§', // a box filling up
91
94
  saved: 'βœ“',
92
95
  used: 'β—©', // a split square: what the spend is made of
@@ -26,6 +26,17 @@ import { GRADES, TIER_NAMES, speciesLabel } from './office-species.js';
26
26
  const pct = (v) => `${Math.round(Number(v) * 100)}%`;
27
27
  const money = (v) => `$${Number(v).toFixed(2)}`;
28
28
  const floorPct = (g) => Math.round(g.minSr * 100);
29
+ /**
30
+ * Percentage points from the score percentile `sr` up to the floor of species
31
+ * `g`, at least 1 while the floor is not cleared, 0 when it already is (then
32
+ * only the delegation rule stands in the way). Null without a percentile or a
33
+ * floor (the idle row has none).
34
+ */
35
+ export function pointsTo(g, sr) {
36
+ if (!g || !(g.minSr >= 0) || !Number.isFinite(sr)) return null;
37
+ const pts = Math.ceil((g.minSr - sr) * 100 - 1e-9);
38
+ return pts <= 0 ? 0 : pts;
39
+ }
29
40
  /** The species one row up the ladder, or null on the top row and for unknown keys. */
30
41
  export function nextGradeUp(key) {
31
42
  const i = GRADES.findIndex((g) => g.key === key);
@@ -122,17 +133,36 @@ export function standingGuideLines(st, { lang = 'en', org = null, team = null }
122
133
  : '');
123
134
  if (next) {
124
135
  const s = label(next.grade);
136
+ const g = GRADES.find((r) => r.key === next.grade);
125
137
  const x = Math.max(1, Number(next.pass) || 0);
126
138
  const c = has(st.medianDlg) ? pct(st.medianDlg) : (ko ? 'μ•Œ 수 μ—†μŒ' : 'unknown');
139
+ const pts = pointsTo(g, st.scorePct);
127
140
  let text;
128
- if (next.needDlg && !(Number(next.pass) > 0)) {
129
- text = ko ? `μœ„μž„ λΉ„μœ¨μ„ νšŒμ‚¬ 쀑앙값(${c}) μ΄μƒμœΌλ‘œ 올리면 ${s}` : `raise the delegation share to the company median (${c}) to become ${s}`;
141
+ if (pts !== null) {
142
+ // With the percentile on record: where you are, how many points more,
143
+ // and the people that amounts to.
144
+ const now = pct(st.scorePct);
145
+ if (next.needDlg && !(Number(next.pass) > 0)) {
146
+ text = ko
147
+ ? `${s}. λ°±λΆ„μœ„λŠ” 이미 ${floorPct(g)}%λ₯Ό λ„˜μ—ˆκ³  μœ„μž„ λΉ„μœ¨μ„ νšŒμ‚¬ 쀑앙값(${c}) μ΄μƒμœΌλ‘œ 올리면 λ©λ‹ˆλ‹€.`
148
+ : `${s}. Your percentile already clears ${floorPct(g)}%; raise the delegation share to the company median (${c}).`;
149
+ } else if (next.needDlg) {
150
+ text = ko
151
+ ? `${s}. μ§€κΈˆ λ°±λΆ„μœ„ ${now}, ${pts}%p 더 였λ₯΄κ³ (${x}λͺ… μ•žμ§€λ₯΄κΈ°) μœ„μž„ λΉ„μœ¨μ΄ νšŒμ‚¬ 쀑앙값(${c}) 이상이면 λ©λ‹ˆλ‹€.`
152
+ : `${s}. Percentile now ${now}; ${pts} pts more (pass ${x}) and a delegation share at or above the company median (${c}).`;
153
+ } else {
154
+ text = ko
155
+ ? `${s}. μ§€κΈˆ λ°±λΆ„μœ„ ${now}, ${Math.max(1, pts)}%p 더 였λ₯΄λ©΄ λ©λ‹ˆλ‹€ (${x}λͺ… μ•žμ§€λ₯΄κΈ°).`
156
+ : `${s}. Percentile now ${now}; ${Math.max(1, pts)} pts more and you are there (pass ${x}).`;
157
+ }
158
+ } else if (next.needDlg && !(Number(next.pass) > 0)) {
159
+ text = `${ko ? `μœ„μž„ λΉ„μœ¨μ„ νšŒμ‚¬ 쀑앙값(${c}) μ΄μƒμœΌλ‘œ 올리면 ${s}` : `raise the delegation share to the company median (${c}) to become ${s}`}${floorNote(g)}`;
130
160
  } else if (next.needDlg) {
131
- text = ko ? `${x}λͺ…을 더 μ•žμ§€λ₯΄κ³  μœ„μž„ λΉ„μœ¨μ΄ νšŒμ‚¬ 쀑앙값(${c}) 이상이면 ${s}` : `pass ${x} more and reach the company median delegation share (${c}) to become ${s}`;
161
+ text = `${ko ? `${x}λͺ…을 더 μ•žμ§€λ₯΄κ³  μœ„μž„ λΉ„μœ¨μ΄ νšŒμ‚¬ 쀑앙값(${c}) 이상이면 ${s}` : `pass ${x} more and reach the company median delegation share (${c}) to become ${s}`}${floorNote(g)}`;
132
162
  } else {
133
- text = ko ? `${x}λͺ…을 더 μ•žμ§€λ₯΄λ©΄ ${s}` : `pass ${x} more to become ${s}`;
163
+ text = `${ko ? `${x}λͺ…을 더 μ•žμ§€λ₯΄λ©΄ ${s}` : `pass ${x} more to become ${s}`}${floorNote(g)}`;
134
164
  }
135
- lines.push(` ${ko ? 'λ‹€μŒ λ“±κΈ‰' : 'Next species'}: ${text}${floorNote(GRADES.find((g) => g.key === next.grade))}`);
165
+ lines.push(` ${ko ? 'λ‹€μŒ λ“±κΈ‰' : 'Next species'}: ${text}`);
136
166
  } else if (st.idle === true || st.grade === 'chick') {
137
167
  lines.push(ko ? ' λ‹€μŒ λ“±κΈ‰: 이 기간에 μ§€μΆœμ΄ 생기면 μˆœμœ„μ— μ˜€λ¦…λ‹ˆλ‹€.' : ' Next species: spend in this period puts you in the standings.');
138
168
  } else if (!up) {
@@ -148,6 +178,58 @@ export function standingGuideLines(st, { lang = 'en', org = null, team = null }
148
178
  return lines;
149
179
  }
150
180
 
181
+ /**
182
+ * The short form for the statusline's team line: where the rank puts you and
183
+ * what the next species takes, as two or three phrases. The same facts as the
184
+ * block above, without the sentences.
185
+ * ['1μœ„κΉŒμ§€ 2λͺ…', 'λ‹€μŒ πŸ† μΉ˜νƒ€: 2λͺ… 더 (77%λΆ€ν„°)']
186
+ * `emoji: false` keeps the species names bare (narrow and text modes).
187
+ */
188
+ export function standingFeedbackShort(st, lang = 'en', { emoji = true } = {}) {
189
+ if (!st || typeof st !== 'object' || typeof st.grade !== 'string') return [];
190
+ const ko = lang === 'ko';
191
+ const label = (k) => speciesLabel(k, lang, { emoji }) || k;
192
+ const has = (v) => Number.isFinite(v);
193
+ const ranked = Number.isInteger(st.rank) && Number.isInteger(st.ranked) && st.rank >= 1 && st.ranked >= st.rank;
194
+ if (st.grade === 'ghost' || !ranked) return [ko ? '이 κΈ°κ°„ μ—…λ‘œλ“œ μ—†μŒ' : 'no usage this period'];
195
+ const out = [];
196
+ if (st.crown) out.push(ko ? `${emoji ? 'πŸ‘‘ ' : ''}νšŒμ‚¬ 1μœ„` : `${emoji ? 'πŸ‘‘ ' : ''}#1 in the company`);
197
+ else if (st.rank === 1 && st.ranked === 1) out.push(ko ? '혼자 μˆœμœ„μ— 있음' : 'alone in the standings');
198
+ else if (st.rank === 1) out.push(ko ? 'νšŒμ‚¬ 1μœ„' : '#1 in the company');
199
+ else out.push(ko ? `1μœ„κΉŒμ§€ ${st.rank - 1}λͺ…` : `${st.rank - 1} to pass for #1`);
200
+
201
+ const next = st.next && typeof st.next === 'object' && typeof st.next.grade === 'string' ? st.next : null;
202
+ const up = nextGradeUp(st.grade);
203
+ const floor = (g) => (g && g.minSr >= 0 ? (ko ? `${floorPct(g)}%λΆ€ν„°` : `${floorPct(g)}% and up`) : '');
204
+ if (next) {
205
+ const s = label(next.grade);
206
+ const g = GRADES.find((x) => x.key === next.grade);
207
+ const x = Math.max(1, Number(next.pass) || 0);
208
+ const c = has(st.medianDlg) ? pct(st.medianDlg) : (ko ? 'νšŒμ‚¬ 쀑앙값' : 'the company median');
209
+ const pts = pointsTo(g, st.scorePct);
210
+ if (pts !== null) {
211
+ // With the percentile on record: where you are and how many points more.
212
+ const now = pct(st.scorePct);
213
+ if (next.needDlg && !(Number(next.pass) > 0)) out.push(ko ? `μ§€κΈˆ ${now}, μœ„μž„ λΉ„μœ¨ ${c} 이상이면 ${s}` : `now ${now}, delegation share ${c} or more for ${s}`);
214
+ 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}`);
215
+ else out.push(ko ? `μ§€κΈˆ ${now}, ${Math.max(1, pts)}%p 더 였λ₯΄λ©΄ ${s} (${x}λͺ… μ•žμ§€λ₯΄κΈ°)` : `now ${now}, ${Math.max(1, pts)} pts more for ${s} (pass ${x})`);
216
+ } else if (next.needDlg && !(Number(next.pass) > 0)) {
217
+ out.push(ko ? `λ‹€μŒ ${s}: μœ„μž„ λΉ„μœ¨ ${c} 이상` : `next ${s}: delegation share ${c} or more`);
218
+ } else if (next.needDlg) {
219
+ out.push(ko ? `λ‹€μŒ ${s}: ${x}λͺ… 더, μœ„μž„ λΉ„μœ¨ ${c} 이상` : `next ${s}: ${x} more and delegation share ${c} or more`);
220
+ } else {
221
+ out.push(ko ? `λ‹€μŒ ${s}: ${x}λͺ… 더${floor(g) ? ` (${floor(g)})` : ''}` : `next ${s}: ${x} more${floor(g) ? ` (${floor(g)})` : ''}`);
222
+ }
223
+ } else if (st.idle === true || st.grade === 'chick') {
224
+ out.push(ko ? 'μ§€μΆœμ΄ 생기면 μˆœμœ„μ— μ˜€λ¦„' : 'spend to enter the standings');
225
+ } else if (!up) {
226
+ out.push(ko ? '도감 μ΅œμƒμœ„' : 'top of the field guide');
227
+ } else {
228
+ out.push(ko ? `λ‹€μŒ ${label(up.key)} (${floor(up)})` : `next ${label(up.key)} (${floor(up)})`);
229
+ }
230
+ return out;
231
+ }
232
+
151
233
  /**
152
234
  * The field guide: every species by tier, best first, with the percentile each
153
235
  * one starts at and a marker on the caller's own. Shared by the ranked and the
package/src/team-sync.js CHANGED
@@ -159,6 +159,13 @@ export function readTeamChip({ dir = userDataDir() } = {}) {
159
159
  ? {
160
160
  grade: st.grade, rank: Number.isFinite(st.rank) ? st.rank : null, ranked: Number.isFinite(st.ranked) ? st.ranked : null,
161
161
  teamRank: Number.isFinite(st.teamRank) ? st.teamRank : null, teamRanked: Number.isFinite(st.teamRanked) ? st.teamRanked : null,
162
+ // What the team line says about moving up (src/team-standing.js standingFeedbackShort).
163
+ crown: !!st.crown,
164
+ next: st.next && typeof st.next === 'object' && typeof st.next.grade === 'string'
165
+ ? { grade: st.next.grade, pass: Number.isFinite(st.next.pass) ? st.next.pass : 0, needDlg: !!st.next.needDlg }
166
+ : null,
167
+ idle: typeof st.idle === 'boolean' ? st.idle : null,
168
+ medianDlg: Number.isFinite(st.medianDlg) ? st.medianDlg : null,
162
169
  fetchedAt: Number(st.fetchedAt) || 0,
163
170
  }
164
171
  : null,