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.
- package/README.ko.md +25 -4
- package/README.md +38 -10
- package/bin/cli.js +17 -4
- package/evals/README.md +101 -0
- package/evals/SUMMARY.md +18 -0
- package/evals/summary.json +224 -0
- package/package.json +13 -2
- package/presets/delegation/bounds.md +4 -3
- package/src/commands/delegate.js +12 -9
- package/src/commands/install.js +40 -0
- package/src/commands/proof.js +80 -0
- package/src/commands/saved.js +26 -19
- package/src/commands/team.js +6 -2
- package/src/delegation-guard.js +42 -7
- package/src/effort-raise-ledger.js +117 -0
- package/src/formatters/statusline.js +121 -19
- package/src/glyphs.js +3 -0
- package/src/installer.js +14 -13
- package/src/office-species.js +29 -0
- package/src/route-scan.js +25 -15
- package/src/team-standing.js +255 -0
- package/src/team-sync.js +37 -2
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* team-standing — the lines `sprag team status` prints about the member's
|
|
3
|
+
* standing in the organization's virtual office, what moving up takes, and the
|
|
4
|
+
* field guide of species to climb through.
|
|
5
|
+
*
|
|
6
|
+
* The statusline chip says `Pro member-1e500474 amazon 종합 점수 12명 중 3위
|
|
7
|
+
* 🦊 여우` and no more. This answers the questions that chip raises: how many
|
|
8
|
+
* people stand ahead, whether the rank is earned by spending more tokens or by
|
|
9
|
+
* using them better, which species is next and what the whole ladder looks
|
|
10
|
+
* like. The score adds the spend rank and the delegation-share rank (and the
|
|
11
|
+
* prompt-count rank where prompt capture is on), so the spend rank rises with
|
|
12
|
+
* more tokens and the delegation rank rises by handing a larger share of the
|
|
13
|
+
* same spend to cheaper models. The species follow the score's percentile
|
|
14
|
+
* (GRADES in office-species.js), and the six species from the wolf up also
|
|
15
|
+
* need the delegation share at or above the company median.
|
|
16
|
+
*
|
|
17
|
+
* The personal figures come from the server's member_standing (team-sync.js
|
|
18
|
+
* refreshStanding): `dlg`, `medianDlg`, `scorePct`, `spent`, `weights`, `idle`
|
|
19
|
+
* and `next` ({ grade, pass, needDlg }). An older server sends none of them;
|
|
20
|
+
* the block then names the next species from the ladder and says where the
|
|
21
|
+
* distance will come from. Pure: no I/O, so the tests pin every wording.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { GRADES, TIER_NAMES, speciesLabel } from './office-species.js';
|
|
25
|
+
|
|
26
|
+
const pct = (v) => `${Math.round(Number(v) * 100)}%`;
|
|
27
|
+
const money = (v) => `$${Number(v).toFixed(2)}`;
|
|
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
|
+
}
|
|
40
|
+
/** The species one row up the ladder, or null on the top row and for unknown keys. */
|
|
41
|
+
export function nextGradeUp(key) {
|
|
42
|
+
const i = GRADES.findIndex((g) => g.key === key);
|
|
43
|
+
return i > 0 ? GRADES[i - 1] : null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @param {object|null|undefined} st team.json `standing`
|
|
48
|
+
* @param {{ lang?: 'ko'|'en', org?: string|null }} [opts]
|
|
49
|
+
* @returns {string[]} lines; empty when there is no standing on record
|
|
50
|
+
*/
|
|
51
|
+
export function standingGuideLines(st, { lang = 'en', org = null, team = null } = {}) {
|
|
52
|
+
if (!st || typeof st !== 'object' || typeof st.grade !== 'string') return [];
|
|
53
|
+
const ko = lang === 'ko';
|
|
54
|
+
const label = (k) => speciesLabel(k, lang, { emoji: true }) || k;
|
|
55
|
+
const animal = label(st.grade);
|
|
56
|
+
const ranked = Number.isInteger(st.rank) && Number.isInteger(st.ranked) && st.rank >= 1 && st.ranked >= st.rank;
|
|
57
|
+
const period = st.rangeFrom && st.rangeTo ? ` (${st.rangeFrom} ${ko ? '~' : 'to'} ${st.rangeTo})` : '';
|
|
58
|
+
const where = org ? `${org} ` : '';
|
|
59
|
+
const has = (v) => Number.isFinite(v);
|
|
60
|
+
// The rank within the team, when the team is a strict part of the ranked people.
|
|
61
|
+
const teamName = team || st.teamName || null;
|
|
62
|
+
const inTeam = ranked && Number.isInteger(st.teamRank) && Number.isInteger(st.teamRanked)
|
|
63
|
+
&& st.teamRank >= 1 && st.teamRanked >= st.teamRank && st.teamRanked < st.ranked && teamName;
|
|
64
|
+
const teamPlace = inTeam ? (ko ? ` · ${teamName} 팀 ${st.teamRanked}명 중 ${st.teamRank}위` : ` · team ${teamName} #${st.teamRank} of ${st.teamRanked}`) : '';
|
|
65
|
+
const lines = [];
|
|
66
|
+
|
|
67
|
+
if (st.grade === 'ghost' || !ranked) {
|
|
68
|
+
lines.push(ko
|
|
69
|
+
? `순위: ${where}${animal}${period}. 이 기간에 올라온 사용 기록이 없어 순위 밖입니다. 지출이 올라오면 아래 도감의 한 종이 됩니다.`
|
|
70
|
+
: `Standing: ${where}${animal}${period}. No usage uploaded in this period, so no rank yet; once spend comes in you become one of the species below.`);
|
|
71
|
+
lines.push(...fieldGuideLines(null, lang));
|
|
72
|
+
return lines;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
lines.push(ko
|
|
76
|
+
? `순위: ${where}종합 점수 ${st.ranked}명 중 ${st.rank}위${teamPlace} · ${animal}${period}`
|
|
77
|
+
: `Standing: ${where}overall score #${st.rank} of ${st.ranked}${teamPlace} · ${animal}${period}`);
|
|
78
|
+
|
|
79
|
+
// Where that rank puts you: the people ahead, or the crown.
|
|
80
|
+
if (st.crown) {
|
|
81
|
+
lines.push(ko ? ' 이번 기간 회사 1위입니다 👑' : ' #1 in the company this period 👑');
|
|
82
|
+
} else if (st.rank === 1 && st.ranked === 1) {
|
|
83
|
+
lines.push(ko
|
|
84
|
+
? ' 지금은 순위에 혼자 올라 있습니다. 동료가 참여하면 경쟁이 시작됩니다.'
|
|
85
|
+
: ' You are the only one in the standings so far; the race starts when a colleague joins.');
|
|
86
|
+
} else if (st.rank === 1) {
|
|
87
|
+
lines.push(ko ? ' 회사 1위입니다.' : ' #1 in the company.');
|
|
88
|
+
} else {
|
|
89
|
+
lines.push(ko
|
|
90
|
+
? ` 앞에 ${st.rank - 1}명이 있습니다. 1위에 오르면 👑 왕관을 씁니다.`
|
|
91
|
+
: ` ${st.rank - 1} ahead of you; reach #1 and you wear the crown 👑.`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// What the score is made of. The weights are the server's when it sent them;
|
|
95
|
+
// otherwise both known sets are stated.
|
|
96
|
+
const w = Array.isArray(st.weights) && st.weights.length >= 2 ? st.weights : null;
|
|
97
|
+
if (w) {
|
|
98
|
+
const parts = ko
|
|
99
|
+
? [`기간 지출 순위 ${pct(w[0])}`, `위임 비율 순위 ${pct(w[1])}`, ...(w[2] > 0 ? [`프롬프트 수 순위 ${pct(w[2])}`] : [])]
|
|
100
|
+
: [`the spend rank (${pct(w[0])})`, `the delegation-share rank (${pct(w[1])})`, ...(w[2] > 0 ? [`the prompt-count rank (${pct(w[2])})`] : [])];
|
|
101
|
+
lines.push(ko
|
|
102
|
+
? ` 종합 점수는 ${parts.slice(0, -1).join(', ')}${parts.length > 1 ? '와 ' : ''}${parts[parts.length - 1]}를 더한 값입니다.`
|
|
103
|
+
: ` The overall score adds ${parts.slice(0, -1).join(', ')}${parts.length > 1 ? ' and ' : ''}${parts[parts.length - 1]}.`);
|
|
104
|
+
} else {
|
|
105
|
+
lines.push(ko
|
|
106
|
+
? ' 종합 점수는 기간 지출 순위 62.5%와 위임 비율 순위 37.5%를 더한 값입니다. 프롬프트 수집을 켠 Enterprise 조직은 50%, 30%, 20%로 프롬프트 수 순위까지 더합니다.'
|
|
107
|
+
: ' The overall score adds the spend rank (62.5%) and the delegation-share rank (37.5%). An Enterprise organization with prompt capture on uses 50%, 30% and 20%, with the prompt-count rank as the third.');
|
|
108
|
+
}
|
|
109
|
+
lines.push(ko
|
|
110
|
+
? ` 지출 순위는 토큰을 더 써야 오르고 위임 비율 순위는 같은 지출에서 싼 모델에 맡기는 몫을 늘려야 오릅니다. ${speciesLabel('wolf', 'ko', { emoji: false })} 이상 여섯 종은 위임 비율이 회사 중앙값 이상이어야 합니다.`
|
|
111
|
+
: ` The spend rank rises with more tokens; the delegation rank rises by handing a larger share of the same spend to cheaper models. The six species from ${speciesLabel('wolf', 'en', { emoji: false })} up also need a delegation share at or above the company median.`);
|
|
112
|
+
|
|
113
|
+
// The caller's own figures, when the server sent them.
|
|
114
|
+
if (has(st.dlg) || has(st.spent) || has(st.scorePct)) {
|
|
115
|
+
const parts = [];
|
|
116
|
+
if (has(st.spent)) parts.push(ko ? `지출 ${money(st.spent)}` : `spent ${money(st.spent)}`);
|
|
117
|
+
if (has(st.dlg)) {
|
|
118
|
+
const med = has(st.medianDlg) ? (ko ? ` (회사 중앙값 ${pct(st.medianDlg)})` : ` (company median ${pct(st.medianDlg)})`) : '';
|
|
119
|
+
parts.push(ko ? `위임 비율 ${pct(st.dlg)}${med}` : `delegation share ${pct(st.dlg)}${med}`);
|
|
120
|
+
}
|
|
121
|
+
if (has(st.scorePct)) parts.push(ko ? `점수 백분위 ${pct(st.scorePct)}` : `score percentile ${pct(st.scorePct)}`);
|
|
122
|
+
lines.push(` ${ko ? '이 컴퓨터' : 'This machine'}: ${parts.join(' · ')}`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// The next species up, as the office drawer says it, with the percentile it
|
|
126
|
+
// starts at; the ladder alone when the server sent no distance.
|
|
127
|
+
const next = st.next && typeof st.next === 'object' && typeof st.next.grade === 'string' ? st.next : null;
|
|
128
|
+
const up = nextGradeUp(st.grade);
|
|
129
|
+
const floorNote = (g) => (g && g.minSr >= 0
|
|
130
|
+
? (ko
|
|
131
|
+
? ` (백분위 ${has(st.scorePct) ? `지금 ${pct(st.scorePct)}, ` : ''}${floorPct(g)}%부터)`
|
|
132
|
+
: ` (percentile ${has(st.scorePct) ? `now ${pct(st.scorePct)}, ` : ''}${floorPct(g)}% and up)`)
|
|
133
|
+
: '');
|
|
134
|
+
if (next) {
|
|
135
|
+
const s = label(next.grade);
|
|
136
|
+
const g = GRADES.find((r) => r.key === next.grade);
|
|
137
|
+
const x = Math.max(1, Number(next.pass) || 0);
|
|
138
|
+
const c = has(st.medianDlg) ? pct(st.medianDlg) : (ko ? '알 수 없음' : 'unknown');
|
|
139
|
+
const pts = pointsTo(g, st.scorePct);
|
|
140
|
+
let text;
|
|
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)}`;
|
|
160
|
+
} else if (next.needDlg) {
|
|
161
|
+
text = `${ko ? `${x}명을 더 앞지르고 위임 비율이 회사 중앙값(${c}) 이상이면 ${s}` : `pass ${x} more and reach the company median delegation share (${c}) to become ${s}`}${floorNote(g)}`;
|
|
162
|
+
} else {
|
|
163
|
+
text = `${ko ? `${x}명을 더 앞지르면 ${s}` : `pass ${x} more to become ${s}`}${floorNote(g)}`;
|
|
164
|
+
}
|
|
165
|
+
lines.push(` ${ko ? '다음 등급' : 'Next species'}: ${text}`);
|
|
166
|
+
} else if (st.idle === true || st.grade === 'chick') {
|
|
167
|
+
lines.push(ko ? ' 다음 등급: 이 기간에 지출이 생기면 순위에 오릅니다.' : ' Next species: spend in this period puts you in the standings.');
|
|
168
|
+
} else if (!up) {
|
|
169
|
+
lines.push(ko ? ' 다음 등급: 도감에서 가장 높은 종입니다.' : ' Next species: the top species in the field guide.');
|
|
170
|
+
} else {
|
|
171
|
+
// An older server: the ladder names the species, the distance is not known.
|
|
172
|
+
lines.push(ko
|
|
173
|
+
? ` 다음 등급: ${label(up.key)}${floorNote(up)}. 몇 명을 더 앞질러야 하는지는 팀 서버가 갱신되면 나옵니다.`
|
|
174
|
+
: ` Next species: ${label(up.key)}${floorNote(up)}. How many people to pass appears once the team server is updated.`);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
lines.push(...fieldGuideLines(st.grade, lang));
|
|
178
|
+
return lines;
|
|
179
|
+
}
|
|
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
|
+
|
|
233
|
+
/**
|
|
234
|
+
* The field guide: every species by tier, best first, with the percentile each
|
|
235
|
+
* one starts at and a marker on the caller's own. Shared by the ranked and the
|
|
236
|
+
* unranked block, so a newcomer sees what there is to climb.
|
|
237
|
+
*/
|
|
238
|
+
export function fieldGuideLines(grade, lang = 'en') {
|
|
239
|
+
const ko = lang === 'ko';
|
|
240
|
+
const lines = [ko
|
|
241
|
+
? '동물 도감: 종합 점수 백분위로 30종을 나눕니다. 종 옆 숫자는 그 종이 시작되는 백분위이고 ▶ 가 지금 등급입니다.'
|
|
242
|
+
: 'Field guide: 30 species by overall-score percentile. The number after a species is the percentile it starts at; ▶ marks yours.'];
|
|
243
|
+
for (const tier of ['power', 'active', 'normal', 'low']) {
|
|
244
|
+
const items = GRADES.filter((g) => g.tier === tier).map((g) => {
|
|
245
|
+
const mark = g.key === grade ? '▶ ' : '';
|
|
246
|
+
const floor = g.minSr >= 0 ? ` ${floorPct(g)}` : (ko ? ' (지출 없음)' : ' (no spend)');
|
|
247
|
+
return `${mark}${speciesLabel(g.key, lang, { emoji: true })}${floor}`;
|
|
248
|
+
});
|
|
249
|
+
const rule = tier === 'power'
|
|
250
|
+
? (ko ? ' (위임 비율이 회사 중앙값 이상이어야 함)' : ' (needs a delegation share at or above the company median)')
|
|
251
|
+
: '';
|
|
252
|
+
lines.push(` ${TIER_NAMES[tier][lang]}${rule}: ${items.join(' · ')}`);
|
|
253
|
+
}
|
|
254
|
+
return lines;
|
|
255
|
+
}
|
package/src/team-sync.js
CHANGED
|
@@ -108,9 +108,27 @@ async function refreshStanding({ memberKey, dir, fetch, now }) {
|
|
|
108
108
|
if (!r || typeof r !== 'object' || typeof r.grade !== 'string') return;
|
|
109
109
|
const cur = loadTeamState(dir);
|
|
110
110
|
if (!isJoined(cur) || cur.memberKey !== memberKey) return;
|
|
111
|
+
const num = (v) => (Number.isFinite(v) ? v : null);
|
|
112
|
+
// What the rank is made of and what the next species takes (server migration
|
|
113
|
+
// 20261107000100). An older server sends none of it, and `sprag team status`
|
|
114
|
+
// then prints the formula alone.
|
|
115
|
+
const guide = {
|
|
116
|
+
dlg: num(r.dlg), medianDlg: num(r.median_dlg), scorePct: num(r.score_pct), spent: num(r.spent),
|
|
117
|
+
idle: typeof r.idle === 'boolean' ? r.idle : null,
|
|
118
|
+
hasPrompts: typeof r.has_prompts === 'boolean' ? r.has_prompts : null,
|
|
119
|
+
weights: Array.isArray(r.weights) && r.weights.every(Number.isFinite) ? r.weights : null,
|
|
120
|
+
next: r.next && typeof r.next === 'object' && typeof r.next.grade === 'string'
|
|
121
|
+
? { grade: r.next.grade, pass: num(r.next.pass) ?? 0, needDlg: !!r.next.need_dlg }
|
|
122
|
+
: null,
|
|
123
|
+
rangeFrom: typeof r.range_from === 'string' ? r.range_from : null,
|
|
124
|
+
rangeTo: typeof r.range_to === 'string' ? r.range_to : null,
|
|
125
|
+
// The same score counted within the member's own team.
|
|
126
|
+
teamRank: num(r.team_rank), teamRanked: num(r.team_ranked),
|
|
127
|
+
teamName: typeof r.team_name === 'string' && r.team_name ? r.team_name : null,
|
|
128
|
+
};
|
|
111
129
|
saveTeamState({
|
|
112
130
|
...cur,
|
|
113
|
-
standing: { grade: r.grade, tier: r.tier ?? null, rank:
|
|
131
|
+
standing: { grade: r.grade, tier: r.tier ?? null, rank: num(r.rank), ranked: num(r.ranked), crown: !!r.crown, fetchedAt: now, ...guide },
|
|
114
132
|
}, dir);
|
|
115
133
|
} catch (e) {
|
|
116
134
|
debug('team-sync', e); // PGRST202 "Could not find the function": an older server, ignore
|
|
@@ -130,9 +148,26 @@ export function readTeamChip({ dir = userDataDir() } = {}) {
|
|
|
130
148
|
const st = state.standing;
|
|
131
149
|
return {
|
|
132
150
|
label,
|
|
151
|
+
// The standing is ranked across the organization, so its name says whose standings these are.
|
|
152
|
+
org: String(state.orgName || state.teamName || '').trim() || null,
|
|
153
|
+
// The license the team runs under (`pro`, `enterprise`), which leads the chip.
|
|
154
|
+
plan: typeof state.plan === 'string' && state.plan.trim() ? state.plan.trim() : null,
|
|
155
|
+
// The team, for the rank within it.
|
|
156
|
+
team: String(state.teamName || '').trim() || null,
|
|
133
157
|
lang: userLanguage(),
|
|
134
158
|
standing: st && typeof st.grade === 'string'
|
|
135
|
-
? {
|
|
159
|
+
? {
|
|
160
|
+
grade: st.grade, rank: Number.isFinite(st.rank) ? st.rank : null, ranked: Number.isFinite(st.ranked) ? st.ranked : null,
|
|
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,
|
|
169
|
+
fetchedAt: Number(st.fetchedAt) || 0,
|
|
170
|
+
}
|
|
136
171
|
: null,
|
|
137
172
|
};
|
|
138
173
|
} catch (e) { debug('team-sync', e); return null; }
|