sprag-cli 3.103.1 β†’ 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.
@@ -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
@@ -399,10 +400,12 @@ function buildVersionSeg(version, update, c, isIcon, verbose, g) {
399
400
  const TEAM_STANDING_MAX_AGE_MS = 24 * 60 * 60 * 1000;
400
401
 
401
402
  /**
402
- * Team chip: the member id and, once the server has told us, the animal that
403
- * member is in the team's virtual office and the rank (`member-1e500474 🦊 Fox #3 of 12`). Renders only
403
+ * Team chip: the member id, the organization and, once the server has told us,
404
+ * the overall-score rank and the animal that member is in the team's virtual
405
+ * office (`member-1e500474 amazon overall score #3 of 12 🦊 Fox`). Renders only
404
406
  * for a joined machine. A missing, unknown or day-old standing leaves just the
405
- * member label. Gray like the other identity chips; the emoji brings its own colour.
407
+ * member label (and the organization, when known). The office page calls the
408
+ * ranked figure the overall score (spend rank, delegation rank, prompt rank). Gray like the other identity chips; the emoji brings its own colour.
406
409
  * The emoji draws only in icon mode: narrow (the IntelliJ default, whose font has
407
410
  * no animal emoji) and text keep the animal's name and the rank.
408
411
  */
@@ -413,8 +416,60 @@ function buildTeamSeg(team, c, mode = 'icon', now = Date.now()) {
413
416
  const animal = fresh ? speciesLabel(st.grade, team.lang, { emoji: mode === 'icon' }) : null;
414
417
  // The rank among the ranked people, the same standing the office drawer shows; a ghost has none.
415
418
  const ranked = animal && Number.isInteger(st.rank) && Number.isInteger(st.ranked) && st.rank >= 1 && st.ranked >= st.rank;
416
- const place = ranked ? (team.lang === 'ko' ? ` ${st.ranked}λͺ… 쀑 ${st.rank}μœ„` : ` #${st.rank} of ${st.ranked}`) : '';
417
- return `${c(GRAY)}${team.label}${animal ? ` ${animal}${place}` : ''}${c(RESET)}`;
419
+ // The rank within the person's own team rides behind the organization rank,
420
+ // only when the team is a strict part of the ranked people: in a one-team
421
+ // organization the two are the same number.
422
+ const inTeam = ranked && Number.isInteger(st.teamRank) && Number.isInteger(st.teamRanked)
423
+ && st.teamRank >= 1 && st.teamRanked >= st.teamRank && st.teamRanked < st.ranked && typeof team.team === 'string' && team.team;
424
+ const teamPlace = inTeam ? (team.lang === 'ko' ? `, ${team.team} νŒ€ ${st.teamRanked}λͺ… 쀑 ${st.teamRank}μœ„` : `, team ${team.team} #${st.teamRank} of ${st.teamRanked}`) : '';
425
+ const place = ranked ? (team.lang === 'ko' ? ` μ’…ν•© 점수 ${st.ranked}λͺ… 쀑 ${st.rank}μœ„${teamPlace}` : ` overall score #${st.rank} of ${st.ranked}${teamPlace}`) : '';
426
+ const org = typeof team.org === 'string' && team.org ? ` ${team.org}` : '';
427
+ // The plan leads (`Pro`, `Enterprise`): the chip describes a licensed team, so
428
+ // the license is the first thing it says, and the standing follows.
429
+ const plan = typeof team.plan === 'string' && team.plan ? `${team.plan[0].toUpperCase()}${team.plan.slice(1)} ` : '';
430
+ return `${c(GRAY)}${plan}${team.label}${org}${animal ? `${place} ${animal}` : ''}${c(RESET)}`;
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}` };
418
473
  }
419
474
 
420
475
  /**
@@ -1147,13 +1202,29 @@ function buildDelegatedSeg(data, singleLine, c, isIcon, verbose, g) {
1147
1202
  const delegateExtra = savingsChip && delegationSaved === 0 ? unresolvedSeg : null;
1148
1203
 
1149
1204
  // Sonnet delegations the guard ran at high effort because the call passed
1150
- // none. Gray, since it is a cost and not a saving: the savings beside it are
1151
- // already net of it, and `sprag saved` prints what the runs cost.
1152
- // icon: "πŸ”¬β†‘3" | text: "effort↑3" | verbose: "effort raised Γ—3"
1153
- const raised = Number(data.effortRaises && data.effortRaises.count) || 0;
1154
- const raisedSeg = raised > 0
1155
- ? `${c(GRAY)}${verbose ? `effort raised Γ—${raised}` : isIcon ? `${g.effort}↑${raised}` : `effort↑${raised}`}${c(RESET)}`
1156
- : null;
1205
+ // none, in the shape of the other two savings: "Effort saved" is the routing
1206
+ // saving those raised runs produced (a part of Routing saved, never added to
1207
+ // it), and the raise count rides as the breakdown. A raise with no measured
1208
+ // saving (no registered rule routed the run) keeps the gray count chip, as a
1209
+ // bare document count does for Doc2md. `sprag saved` prints what the runs cost.
1210
+ // icon: "πŸ”¬ $12.4" verbose: "πŸ”¬ Effort saved $12.4 Β· 3 raised"
1211
+ // text: "Effort saved $12.4"
1212
+ // no saving measured: icon "πŸ”¬β†‘3" | text "effort↑3" | verbose "effort raised Γ—3"
1213
+ const raisedInfo = data.effortRaises;
1214
+ const raised = Number(raisedInfo && raisedInfo.count) || 0;
1215
+ const keptUsd = Number(raisedInfo && raisedInfo.kept) || 0;
1216
+ const keptRuns = Number(raisedInfo && raisedInfo.keptRuns) || 0;
1217
+ const hasKept = raised > 0 && keptRuns > 0 && keptUsd !== 0;
1218
+ const keptTone = keptUsd < 0 ? RED : GREEN;
1219
+ const raisedSince = formatSince(raisedInfo && raisedInfo.since);
1220
+ const effortLabel = isIcon ? (verbose ? `${g.effort} Effort saved` : g.effort) : 'Effort saved';
1221
+ let raisedSeg = null;
1222
+ if (hasKept) {
1223
+ raisedSeg = `${c(keptTone)}${effortLabel}${c(RESET)} ${formatMoney(keptUsd)}${sinceInline(raisedSince)}`
1224
+ + (verbose ? ` ${c(GRAY)}Β· ${raised} raised${c(RESET)}` : '');
1225
+ } else if (raised > 0) {
1226
+ raisedSeg = `${c(GRAY)}${verbose ? `effort raised Γ—${raised}` : isIcon ? `${g.effort}↑${raised}` : `effort↑${raised}`}${c(RESET)}`;
1227
+ }
1157
1228
 
1158
1229
  // Routing-savings headline line (multi-line layout). The lifetime sum from
1159
1230
  // the delegation ledger β€” the number the whole tool exists to grow, so it
@@ -1198,16 +1269,38 @@ function buildDelegatedSeg(data, singleLine, c, isIcon, verbose, g) {
1198
1269
  (pairText ? ` ${c(GRAY)}|${c(RESET)} ${pairText}` : '');
1199
1270
  }
1200
1271
 
1272
+ // The Effort saved line (multi-line layout), under the savings lines and in
1273
+ // their anatomy: the figure, the same reset mark as Routing saved, then the
1274
+ // breakdown, where the raise count sits as `medium→high ×N $X` (Claude
1275
+ // Code's default effort to the one the guard set). Raises that no rule
1276
+ // routed have no saving to show and are counted as `no rule Γ—N (n/a)`, as
1277
+ // Doc2md counts a format with no baseline. Built only beside a Routing saved
1278
+ // line and only with a measured saving; a bare count stays a chip.
1279
+ // icon: "πŸ”¬ Effort saved $12.4 since 11/1 | mediumβ†’high Γ—2 $12.4 Β· no rule Γ—1 (n/a)"
1280
+ // text: "Effort saved $12.4 since 11/1 | medium→high ×2 $12.4 · no rule ×1 (n/a)"
1281
+ let raisedLine = null;
1282
+ if (totalsLine && hasKept) {
1283
+ const head = isIcon ? `${g.effort} Effort saved` : 'Effort saved';
1284
+ const parts = [`${c(GRAY)}medium→high ×${keptRuns} ${formatMoney(keptUsd)}${c(RESET)}`];
1285
+ if (raised > keptRuns) parts.push(`${c(GRAY)}no rule Γ—${raised - keptRuns} ${verbose ? '(no saving measured)' : '(n/a)'}${c(RESET)}`);
1286
+ raisedLine =
1287
+ `${c(keptTone)}${c(BOLD)}${head}${c(RESET)} ` +
1288
+ `${c(keptTone)}${formatMoney(keptUsd)}${c(RESET)}` +
1289
+ sinceWord(raisedSince) +
1290
+ ` ${c(GRAY)}|${c(RESET)} ${parts.join(` ${c(GRAY)}Β·${c(RESET)} `)}`;
1291
+ }
1292
+
1201
1293
  return {
1202
1294
  // Dropped when the same story already owns a headline line above, which
1203
1295
  // would otherwise repeat it on line 2. The unresolved-runs chip survives the
1204
1296
  // headline when that headline is a dated zero, since a zero is exactly when
1205
- // the dropped runs matter.
1206
- // The raise count is not part of that story, so it stays on line 2 either way.
1297
+ // the dropped runs matter. The raise chip steps aside for its own line the
1298
+ // same way, and stays on line 2 while there is no line to carry it.
1207
1299
  chips: totalsLine
1208
- ? (totalsNum === 0 ? [unresolvedSeg, raisedSeg] : [raisedSeg])
1300
+ ? (totalsNum === 0 ? [unresolvedSeg, raisedLine ? null : raisedSeg] : [raisedLine ? null : raisedSeg])
1209
1301
  : [delegateSeg, raisedSeg, delegateExtra],
1210
1302
  headline: totalsLine ? { usd: Number(totals && totals.total) || 0, line: totalsLine } : null,
1303
+ raisedHeadline: raisedLine ? { usd: keptUsd, line: raisedLine } : null,
1211
1304
  };
1212
1305
  }
1213
1306
 
@@ -1481,7 +1574,7 @@ function arrangeSegments(order, s) {
1481
1574
  /**
1482
1575
  * The headline lines that sit above the chips, as one string of `line\n` pairs.
1483
1576
  */
1484
- 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) {
1485
1578
  // Each savings source that earned real money gets a headline line, ordered
1486
1579
  // biggest saver first β€” the top line is the one the eye lands on, so it
1487
1580
  // goes to whichever habit is actually paying for the tool. The diagnostics
@@ -1490,6 +1583,11 @@ function buildHeadlines(delegated, doc2md, want, eol, columns = 0, c = (v) => v)
1490
1583
  if (delegated.headline && want('delegated')) headlines.push(delegated.headline);
1491
1584
  if (doc2md.headline && want('doc2md')) headlines.push(doc2md.headline);
1492
1585
  headlines.sort((a, b) => b.usd - a.usd);
1586
+ // The effort-raise line closes the savings lines rather than competing with
1587
+ // them: its figure is a part of Routing saved, not a saver of its own.
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);
1493
1591
  const rows = columns
1494
1592
  ? headlines.flatMap((h) => wrapHeadline(h.line, availWidth(columns), c))
1495
1593
  : headlines.map((h) => h.line);
@@ -1549,6 +1647,9 @@ export function formatReport(data, { color = true, verbose = false, timer = true
1549
1647
 
1550
1648
  // One slot per chip; segmentsNamed() maps the names in the segment list onto
1551
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);
1552
1653
  const built = {
1553
1654
  capWarn: buildCapWarnSeg(capWarn, c, isIcon, g, color, mode),
1554
1655
  spike: buildSpikeSeg(spikeChip, c),
@@ -1585,7 +1686,8 @@ export function formatReport(data, { color = true, verbose = false, timer = true
1585
1686
  // check β€” this render path never touches the network.
1586
1687
  version: buildVersionSeg(options.version, data.update, c, isIcon, verbose, g),
1587
1688
  // Member id and office animal, from team.json; null unless this machine joined a team.
1588
- 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),
1589
1691
  // Delegation-rule registry (`rules 10 Β· ⚠1`), opt-in through `--segments`.
1590
1692
  rules: buildRulesSeg(data.ruleStats, c, g),
1591
1693
  };
@@ -1598,8 +1700,8 @@ export function formatReport(data, { color = true, verbose = false, timer = true
1598
1700
  // "erase from cursor to EOL" CSI. Only emitted when color (i.e. ANSI) is
1599
1701
  // allowed β€” --no-color/NO_COLOR consumers expect escape-free output.
1600
1702
  const eol = color ? '\x1b[K' : '';
1601
- if (singleLine || !columns) return buildHeadlines(delegated, doc2md, want, eol) + segs.join(' Β· ') + eol;
1602
- 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);
1603
1705
 
1604
1706
  // The chips that stop the work: layoutChips drops from the tail when the
1605
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
package/src/installer.js CHANGED
@@ -1097,10 +1097,11 @@ export function removeDoc2mdHook() {
1097
1097
  // timeout is safe and catches a hung read fast. The size lives in that one
1098
1098
  // constant; quoting a number here is only ever a stale copy of it.
1099
1099
  //
1100
- // Installed by `delegate on`, removed by `delegate off`. Idempotent. Not part
1101
- // of `installAll()` β€” this feature rewrites tool input on every delegation,
1102
- // which is exactly the kind of silent-by-default behavior install.js's other
1103
- // opt-in features (doc2md, korean, cohesion) avoid shipping without being asked.
1100
+ // Installed by `sprag install` (on by default since v3.104.0) and by
1101
+ // `delegate on`, removed by `delegate off`. Idempotent. Kept out of
1102
+ // `installAll()` because install.js has to read the user's choice first: an
1103
+ // explicit `delegate off` must survive an upgrade, and the install prints what
1104
+ // the hook appends before the first delegation it rewrites.
1104
1105
  const DELEGATION_GUARD_HOOK_COMMAND = `${CLI} delegate --hook`;
1105
1106
  // Install, remove and the status readout all judge a command through
1106
1107
  // isDelegationGuardHookCommand() below, which compares whole tokens.
@@ -1327,17 +1328,17 @@ export function uninstallAll({ purge = false } = {}) {
1327
1328
  // The state directory stays so a reinstall keeps ledgers and preferences,
1328
1329
  // with one exception carved out just below.
1329
1330
  result.kept.push('state directory (savings ledgers, config, cache) β€” remove with --purge');
1330
- // delegate.enabled is not a preference, it is an assertion that a hook is
1331
- // registered β€” and the hooks were just removed above. `delegate on` goes
1332
- // out of its way to hold the invariant "flag on implies hook registered",
1333
- // installing first and leaving the flag alone when that fails; leaving the
1334
- // flag set here breaks the same invariant from the other side and makes
1335
- // status report `delegate: on, hook not registered` after a clean
1336
- // uninstall. Config it does not own is left untouched.
1331
+ // An explicit `delegate.enabled: true` is not a preference, it is an
1332
+ // assertion that a hook is registered, and the hooks were just removed
1333
+ // above. Dropping the key returns the guard to its default, so a later
1334
+ // reinstall registers it again the way a fresh install would. An explicit
1335
+ // `false` is the user's choice and is kept. Config it does not own is left
1336
+ // untouched.
1337
1337
  try {
1338
1338
  const cfg = loadConfig();
1339
- if (cfg?.delegate?.enabled) {
1340
- cfg.delegate = { ...cfg.delegate, enabled: false };
1339
+ if (cfg?.delegate?.enabled === true) {
1340
+ const { enabled: _dropped, ...rest } = cfg.delegate;
1341
+ cfg.delegate = rest;
1341
1342
  saveConfig(cfg);
1342
1343
  result.removed.push('delegate flag');
1343
1344
  }
@@ -42,6 +42,35 @@ export const SPECIES = {
42
42
  ghost: { emoji: 'πŸ‘»', en: 'Ghost', ko: '유령' },
43
43
  };
44
44
 
45
+ /**
46
+ * The species ladder, best first: the overall-score percentile a species starts
47
+ * at (`minSr`), its tier, and whether it also needs the delegation share at or
48
+ * above the company median (`needDlg`). `gt` marks a strict floor. Copied from
49
+ * GRADES in site/assets/scene/office-scene.js, and test/office-species.test.js
50
+ * pins the two, so `sprag team status` and the office page show one ladder.
51
+ * The chick is the idle row (no spend in the period) and has no floor.
52
+ */
53
+ const row = (key, minSr, tier, needDlg = false, gt = false) => ({ key, minSr, tier, needDlg, gt });
54
+ export const GRADES = [
55
+ row('dragon', 0.98, 'power', true), row('unicorn', 0.95, 'power', true), row('lion', 0.92, 'power', true),
56
+ row('tiger', 0.89, 'power', true), row('eagle', 0.85, 'power', true), row('wolf', 0.8, 'power', true),
57
+ row('cheetah', 0.77, 'active'), row('fox', 0.74, 'active'), row('owl', 0.71, 'active'), row('husky', 0.68, 'active'),
58
+ row('panda', 0.65, 'active'), row('koala', 0.62, 'active'), row('penguin', 0.58, 'active'), row('raccoon', 0.54, 'active'),
59
+ row('cat', 0.5, 'active'),
60
+ row('dog', 0.47, 'normal'), row('bear', 0.44, 'normal'), row('monkey', 0.41, 'normal'), row('deer', 0.38, 'normal'),
61
+ row('elephant', 0.35, 'normal'), row('pig', 0.32, 'normal'), row('sheep', 0.29, 'normal'), row('rabbit', 0.25, 'normal', false, true),
62
+ row('duck', 0.22, 'low'), row('hedgehog', 0.19, 'low'), row('squirrel', 0.16, 'low'), row('hamster', 0.12, 'low'),
63
+ row('frog', 0.08, 'low'), row('mouse', 0.04, 'low'), row('chick', -1, 'low'),
64
+ ];
65
+
66
+ /** Tier names as the office page shows them (`of.tier.<tier>` in site/team/index.html). */
67
+ export const TIER_NAMES = {
68
+ power: { en: 'AI power user', ko: 'AI νŒŒμ›Œ μœ μ €' },
69
+ active: { en: 'Active', ko: 'ν™œλ°œ' },
70
+ normal: { en: 'Normal', ko: '보톡' },
71
+ low: { en: 'Getting started', ko: 'ν™œμš© μž₯λ € ν•„μš”' },
72
+ };
73
+
45
74
  /**
46
75
  * `"<emoji> <name>"` for a grade key in the given language, or null for an unknown key.
47
76
  * `emoji: false` leaves just the name, for terminals whose font has no animal emoji (IntelliJ).
package/src/route-scan.js CHANGED
@@ -725,11 +725,14 @@ export async function runRouteScan({ days = 14, trace = null } = {}) {
725
725
  let unresolvedRuns = 0; // delegated runs dropped for an unpriceable model id
726
726
  const unresolvedModels = new Set();
727
727
  // Sonnet delegations the guard ran at high effort because the call passed
728
- // none (src/delegation-guard.js). Counted whether or not a rule covers the
729
- // run: the raise is sprag's own action, so its price is shown even where no
730
- // saving is claimed. The figure is what those runs cost on their own model,
731
- // priced the way the ledger prices `cost`; the savings already include it.
732
- const effortRaises = { count: 0, cost: 0, since: null };
728
+ // none (src/delegation-guard.js). Collected whether or not a rule covers the
729
+ // run: the raise is sprag's own action, so its cost is shown even where no
730
+ // saving is claimed. Each run becomes an event in the effort-raise ledger
731
+ // (src/effort-raise-ledger.js), which is read live with the routing reset
732
+ // mark, like the savings ledger. The cost is what the run cost on its own
733
+ // model, priced the way the ledger prices `cost`; the savings already
734
+ // include it.
735
+ const raiseEvents = [];
733
736
  // `sprag saved reset routing` zeroes the money, not the rule-health sample:
734
737
  // see tallyDelegatedRun. readResetMarks never throws (no file = no reset).
735
738
  const routingMark = readResetMarks(userDataDir()).routing;
@@ -773,15 +776,17 @@ export async function runRouteScan({ days = 14, trace = null } = {}) {
773
776
  for (const [sessionPath, index] of runIndexBySession) {
774
777
  // Every run of the session, not only those joined to a categorized episode
775
778
  // and past the tier gate: a sonnet run under a sonnet main session saves
776
- // nothing, yet the guard raised it all the same. The reset mark applies as
777
- // it does to savings (tallyDelegatedRun).
779
+ // nothing, yet the guard raised it all the same. The reset mark is not
780
+ // applied here: the ledger is evidence, and the mark applies when it is read
781
+ // (as savings-ledger does), so a reset zeroes the count without a rescan.
778
782
  for (const run of index.all) {
779
- if (!run.effortRaised || isBeforeReset(run.endedAt ?? run.startedAt, routingMark)) continue;
780
- effortRaises.count += 1;
781
- const cost = isRecognizedModelId(run.model) ? exactCost(runTotals(run), run.model, { at: runTime(run) }) : null;
782
- if (Number.isFinite(cost)) effortRaises.cost += cost;
783
- const at = run.startedAt ?? run.endedAt;
784
- if (Number.isFinite(at) && (effortRaises.since === null || at < effortRaises.since)) effortRaises.since = at;
783
+ if (!run.effortRaised) continue;
784
+ raiseEvents.push({
785
+ key: run.path,
786
+ ts: run.endedAt ?? run.startedAt ?? null,
787
+ cost: isRecognizedModelId(run.model) ? exactCost(runTotals(run), run.model, { at: runTime(run) }) : null,
788
+ model: run.model,
789
+ });
785
790
  }
786
791
  const used = new Set();
787
792
  const eps = all.filter((x) => x.sessionPath === sessionPath);
@@ -927,8 +932,6 @@ export async function runRouteScan({ days = 14, trace = null } = {}) {
927
932
  resolved: [...resolved],
928
933
  unresolvedRuns,
929
934
  unresolvedModels: [...unresolvedModels].slice(0, 5),
930
- // `since` is the earliest counted run (ms), so a reader can date the count.
931
- effortRaises: { ...effortRaises, cost: Math.round(effortRaises.cost * 100) / 100 },
932
935
  };
933
936
  try {
934
937
  const dir = stateDir();
@@ -1027,6 +1030,13 @@ export async function runRouteScan({ days = 14, trace = null } = {}) {
1027
1030
  } catch {
1028
1031
  // ledger write failure only delays the statusline totals, never the scan
1029
1032
  }
1033
+ // Its own try so a failure here never blocks the savings ledger above.
1034
+ try {
1035
+ const { recordEffortRaises } = await import('./effort-raise-ledger.js');
1036
+ recordEffortRaises(raiseEvents);
1037
+ } catch {
1038
+ // the effort-raise chip just stays stale until the next scan
1039
+ }
1030
1040
 
1031
1041
  return cache;
1032
1042
  }