wrapped-agents 1.0.0 → 1.2.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.md +9 -3
- package/SKILL.md +7 -5
- package/package.json +10 -3
- package/page/story.html +213 -83
- package/src/cli.mjs +18 -2
- package/src/readers/_sqlite.mjs +43 -0
- package/src/readers/_util.mjs +21 -0
- package/src/readers/cursor.mjs +325 -0
- package/src/readers/gemini-cli.mjs +323 -0
- package/src/readers/index.mjs +6 -2
- package/src/readers/opencode.mjs +343 -0
- package/src/readers/qwen-code.mjs +8 -0
- package/src/site.mjs +5 -4
- package/src/stats/awards.mjs +12 -1
- package/src/stats/compare.mjs +24 -0
- package/src/stats/index.mjs +29 -5
- package/src/stats/roast.mjs +1 -1
- package/src/stats/tiers.mjs +11 -8
- package/src/stats/twin.mjs +2 -2
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
// OpenCode reader (anomalyco/opencode, formerly sst/opencode). Beta: built from OpenCode's source, not yet verified on real data.
|
|
2
|
+
//
|
|
3
|
+
// Data dir = $XDG_DATA_HOME/opencode, else ~/.local/share/opencode on every OS (xdg-basedir / util/global-roots.ts):
|
|
4
|
+
// https://github.com/anomalyco/opencode/blob/dev/packages/util/src/global-roots.ts
|
|
5
|
+
// Three storage generations, read newest first and de-duplicated by session id:
|
|
6
|
+
// 1. opencode.db (or opencode-<channel>.db, opencode-next.db), "v2" tables (2026-06 →):
|
|
7
|
+
// session_v2(id, parent_id, directory, version, summary_additions, summary_deletions, time_created, time_updated, …)
|
|
8
|
+
// session_message(id, session_id, type, seq, time_created, data JSON) type: user | assistant | compaction | idle | skill | …
|
|
9
|
+
// session_part(message_id, session_id, ordinal, type, call_id, time_created, data JSON) assistant content rows (2026-10 →)
|
|
10
|
+
// https://github.com/anomalyco/opencode/blob/dev/packages/core/src/session/sql.ts
|
|
11
|
+
// https://github.com/anomalyco/opencode/blob/dev/packages/schema/src/session-message.ts
|
|
12
|
+
// 2. the same db, "v1" tables (2026-01 →, kept after the v2 migration): session / message / part with `data` JSON
|
|
13
|
+
// https://github.com/anomalyco/opencode/blob/dev/packages/core/src/database/migration/20260127222353_familiar_lady_ursula.ts
|
|
14
|
+
// https://github.com/anomalyco/opencode/blob/dev/packages/schema/src/v1/session.ts
|
|
15
|
+
// 3. JSON files (≤ 2025): storage/session/<projectID>/<sessionID>.json, storage/message/<sessionID>/<msgID>.json,
|
|
16
|
+
// storage/part/<msgID>/<partID>.json — same v1 shapes. https://github.com/anomalyco/opencode/blob/v1.0.0/packages/opencode/src/storage/storage.ts
|
|
17
|
+
// Theme: `theme` (string, or { name, mode }) in ~/.config/opencode/{opencode,tui}.json[c] or ~/.local/state/opencode/kv.json;
|
|
18
|
+
// custom themes are ~/.config/opencode/themes/<name>.json ({ defs, theme: { key: hex | def | { dark, light } } }).
|
|
19
|
+
import path from 'node:path';
|
|
20
|
+
import fsp from 'node:fs/promises';
|
|
21
|
+
import {
|
|
22
|
+
readJSON, readText, isDir, localDate, windowOf, basename, maxConcurrent, gitUndoKinds, emptyUndos, phraseCounts,
|
|
23
|
+
emptyAssistant, addPhrases, inc, addTok, emptyFacts, day, countPromptTime, finishCoverage, longestSession, mostResumed,
|
|
24
|
+
realEnv, parseJSONC, parse,
|
|
25
|
+
} from './_util.mjs';
|
|
26
|
+
import { PromptStats } from './_prompts.mjs';
|
|
27
|
+
import { sqlite, openRO, rows, tables, close, NEEDS_NODE } from './_sqlite.mjs';
|
|
28
|
+
|
|
29
|
+
export const id = 'opencode';
|
|
30
|
+
export const label = 'OpenCode';
|
|
31
|
+
export const BETA = "beta reader (built from OpenCode's source, not yet verified on real data)";
|
|
32
|
+
|
|
33
|
+
const uniq = a => [...new Set(a.filter(Boolean))];
|
|
34
|
+
const dataDirs = env => uniq([realEnv(env, 'XDG_DATA_HOME') && path.join(realEnv(env, 'XDG_DATA_HOME'), 'opencode'), path.join(env.home, '.local', 'share', 'opencode')]);
|
|
35
|
+
const configDirs = env => uniq([realEnv(env, 'OPENCODE_CONFIG_DIR'), realEnv(env, 'XDG_CONFIG_HOME') && path.join(realEnv(env, 'XDG_CONFIG_HOME'), 'opencode'), path.join(env.home, '.config', 'opencode')]);
|
|
36
|
+
const stateDirs = env => uniq([realEnv(env, 'XDG_STATE_HOME') && path.join(realEnv(env, 'XDG_STATE_HOME'), 'opencode'), path.join(env.home, '.local', 'state', 'opencode')]);
|
|
37
|
+
|
|
38
|
+
async function dbFiles(dir) {
|
|
39
|
+
let names = []; try { names = await fsp.readdir(dir); } catch {}
|
|
40
|
+
return names.filter(n => /^opencode(-[\w.-]+)?\.db$/.test(n)).sort((a, b) => (a === 'opencode.db' ? -1 : b === 'opencode.db' ? 1 : a.localeCompare(b))).map(n => path.join(dir, n));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function detect(env) {
|
|
44
|
+
const roots = [];
|
|
45
|
+
for (const d of dataDirs(env)) {
|
|
46
|
+
for (const f of await dbFiles(d)) roots.push(f);
|
|
47
|
+
if (await isDir(path.join(d, 'storage', 'session'))) roots.push(path.join(d, 'storage'));
|
|
48
|
+
}
|
|
49
|
+
return { found: roots.length > 0, roots };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const RATE = /\b429\b|rate.?limit|too many requests|quota|overloaded/i;
|
|
53
|
+
const isImage = m => /^image\//i.test(String(m || ''));
|
|
54
|
+
|
|
55
|
+
/** everything one read collects, shared by the three storage generations */
|
|
56
|
+
class Acc {
|
|
57
|
+
constructor(w) {
|
|
58
|
+
this.w = w; this.f = emptyFacts(id, label); this.ps = new PromptStats();
|
|
59
|
+
this.seen = new Set(); this.sessions = new Map(); this.bySession = new Map(); this.concEv = [];
|
|
60
|
+
this.undos = emptyUndos(); this.assistant = emptyAssistant(); this.lines = { added: 0, removed: 0 };
|
|
61
|
+
this.rlDays = new Set(); this.rlHits = 0; this.interrupts = 0; this.compactions = 0; this.subagents = 0;
|
|
62
|
+
this.version = null; this.versionAt = -Infinity; this.toolKeys = new Set();
|
|
63
|
+
}
|
|
64
|
+
in(ms) { return ms >= this.w.start && ms < this.w.end; }
|
|
65
|
+
/** register a session once (newest storage wins); false if already read from a newer store */
|
|
66
|
+
session(s) {
|
|
67
|
+
if (!s.id || this.seen.has(s.id)) return false;
|
|
68
|
+
this.seen.add(s.id);
|
|
69
|
+
const created = +s.created || 0;
|
|
70
|
+
if (s.version && (+s.updated || created) > this.versionAt) { this.version = String(s.version); this.versionAt = +s.updated || created; }
|
|
71
|
+
if (s.parent) { if (this.in(created)) this.subagents++; }
|
|
72
|
+
else if (this.in(created)) { this.lines.added += +s.additions || 0; this.lines.removed += +s.deletions || 0; }
|
|
73
|
+
this.cur = { id: s.id, child: !!s.parent, project: basename(s.dir) };
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
time(ms) {
|
|
77
|
+
if (!this.in(ms) || this.cur.child) return;
|
|
78
|
+
const s = this.sessions.get(this.cur.id) || { t: [], project: this.cur.project }; s.t.push(ms); this.sessions.set(this.cur.id, s);
|
|
79
|
+
}
|
|
80
|
+
prompt(ms, text, images) {
|
|
81
|
+
if (!this.in(ms) || this.cur.child) return;
|
|
82
|
+
const sid = this.cur.id, proj = this.cur.project;
|
|
83
|
+
this.ps.add(text, { images }); countPromptTime(this.f, ms); this.concEv.push([ms, sid]); this.time(ms);
|
|
84
|
+
if (proj) inc(this.f.projects, proj);
|
|
85
|
+
const b = this.bySession.get(sid) || { days: new Set(), project: proj }; b.days.add(localDate(ms)); this.bySession.set(sid, b);
|
|
86
|
+
}
|
|
87
|
+
tokens(model, provider, ms, t) {
|
|
88
|
+
if (!this.in(ms) || !t) return;
|
|
89
|
+
const c = t.cache || {};
|
|
90
|
+
const i = +t.input || 0, o = (+t.output || 0) + (+t.reasoning || 0), cr = +c.read || 0, cw = +c.write || 0;
|
|
91
|
+
this.time(ms);
|
|
92
|
+
if (!(i + o + cr + cw)) return;
|
|
93
|
+
const key = model || '?';
|
|
94
|
+
addTok(this.f.models, key, ms, i, o, cr, cw);
|
|
95
|
+
if (provider && !this.f.models[key].provider) this.f.models[key].provider = provider;
|
|
96
|
+
day(this.f, localDate(ms)).tokens += i + o + cr + cw;
|
|
97
|
+
}
|
|
98
|
+
tool(key, name, input) {
|
|
99
|
+
if (key) { if (this.toolKeys.has(key)) return; this.toolKeys.add(key); }
|
|
100
|
+
inc(this.f.tools, name || '?');
|
|
101
|
+
if (/^skill$/i.test(name) && input && typeof input.name === 'string') inc(this.f.skills, input.name);
|
|
102
|
+
if (/^(bash|shell)$/i.test(name) && input) { const u = gitUndoKinds(String(input.command || '')); if (u) for (const k of u) this.undos[k]++; }
|
|
103
|
+
}
|
|
104
|
+
error(ms, err) {
|
|
105
|
+
if (!err || !this.in(ms)) return;
|
|
106
|
+
const s = JSON.stringify(err);
|
|
107
|
+
if (/MessageAbortedError|"aborted"|interrupted/i.test(s)) this.interrupts++;
|
|
108
|
+
else if (RATE.test(s) || err.statusCode === 429 || (err.data && err.data.statusCode === 429)) { this.rlHits++; this.rlDays.add(localDate(ms)); }
|
|
109
|
+
}
|
|
110
|
+
phrases(text) { addPhrases(this.assistant, phraseCounts(text)); }
|
|
111
|
+
|
|
112
|
+
finish() {
|
|
113
|
+
const f = this.f;
|
|
114
|
+
for (const [, s] of this.sessions) {
|
|
115
|
+
let mn = Infinity; for (const t of s.t) { if (t < mn) mn = t; day(f, localDate(t)); }
|
|
116
|
+
day(f, localDate(mn)).sessions++; f.sessions.count++;
|
|
117
|
+
}
|
|
118
|
+
f.sessions.longest = longestSession(this.sessions);
|
|
119
|
+
f.sessions.mostResumed = mostResumed(this.bySession);
|
|
120
|
+
f.sessions.maxConcurrent = maxConcurrent(this.concEv);
|
|
121
|
+
f.prompts = this.ps.toJSON(); f.slash = this.ps.slash;
|
|
122
|
+
f.subagents = this.subagents; f.interrupts = this.interrupts; f.compactions = this.compactions;
|
|
123
|
+
f.rateLimits = { hits: this.rlHits, days: this.rlDays.size };
|
|
124
|
+
f.lines = this.lines; f.gitUndos = this.undos; f.assistant = this.assistant; f.rewinds = null; // no rewind log, only the current revert point
|
|
125
|
+
f.version = this.version;
|
|
126
|
+
f.projects = Object.fromEntries(Object.entries(f.projects).sort((a, b) => b[1] - a[1]).slice(0, 20));
|
|
127
|
+
return f;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** one v1 message (JSON storage or v1 table) with its parts */
|
|
132
|
+
function v1Message(acc, m, parts) {
|
|
133
|
+
const ms = +(m.time && m.time.created) || 0;
|
|
134
|
+
if (m.role === 'user') {
|
|
135
|
+
if (parts.some(p => p.type === 'compaction')) { if (acc.in(ms)) acc.compactions++; return; }
|
|
136
|
+
const texts = parts.filter(p => p.type === 'text' && !p.synthetic && !p.ignored && p.text);
|
|
137
|
+
const images = parts.filter(p => p.type === 'file' && isImage(p.mime)).length;
|
|
138
|
+
if (!texts.length && !images) { acc.time(ms); return; } // subtask-only / synthetic turns are not the user's
|
|
139
|
+
acc.prompt(ms, texts.map(p => p.text).join(' '), images);
|
|
140
|
+
} else if (m.role === 'assistant') {
|
|
141
|
+
const end = +(m.time && m.time.completed) || ms;
|
|
142
|
+
acc.tokens(m.modelID, m.providerID, ms, m.tokens); if (end > ms) acc.time(end);
|
|
143
|
+
acc.error(ms, m.error);
|
|
144
|
+
if (!acc.in(ms)) return;
|
|
145
|
+
for (const p of parts) {
|
|
146
|
+
if (p.type === 'tool') acc.tool(`${m.id}:${p.callID || p.id}`, p.tool, (p.state && p.state.input) || null);
|
|
147
|
+
else if (p.type === 'text' && !m.summary) acc.phrases(p.text);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** v2 session_message row (+ its session_part rows) */
|
|
153
|
+
function v2Message(acc, row, data, parts) {
|
|
154
|
+
const ms = +row.time_created || +(data.time && data.time.created) || 0;
|
|
155
|
+
switch (row.type) {
|
|
156
|
+
case 'user': {
|
|
157
|
+
const images = (Array.isArray(data.files) ? data.files : []).filter(x => x && isImage(x.mime)).length;
|
|
158
|
+
acc.prompt(ms, String(data.text || ''), images); break;
|
|
159
|
+
}
|
|
160
|
+
case 'assistant': {
|
|
161
|
+
const model = data.model || {};
|
|
162
|
+
acc.tokens(model.id, model.providerID, ms, data.tokens);
|
|
163
|
+
const done = +(data.time && data.time.completed) || 0; if (done > ms) acc.time(done);
|
|
164
|
+
acc.error(ms, data.error);
|
|
165
|
+
if (!acc.in(ms)) break;
|
|
166
|
+
const content = [...(Array.isArray(data.content) ? data.content : []), ...parts];
|
|
167
|
+
for (const c of content) {
|
|
168
|
+
if (!c || typeof c !== 'object') continue;
|
|
169
|
+
if (c.type === 'tool') acc.tool(`${row.id}:${c.id}`, c.name, (c.state && c.state.input && typeof c.state.input === 'object') ? c.state.input : null);
|
|
170
|
+
else if (c.type === 'text') acc.phrases(c.text);
|
|
171
|
+
}
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
case 'compaction': if (acc.in(ms) && data.status !== 'failed') acc.compactions++; acc.time(ms); break;
|
|
175
|
+
case 'idle': if (acc.in(ms) && data.outcome === 'interrupted') acc.interrupts++; break;
|
|
176
|
+
case 'skill': if (acc.in(ms) && data.name) inc(acc.f.skills, String(data.name)); break;
|
|
177
|
+
default: break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const json = s => (typeof s === 'string' ? parse(s) : s && typeof s === 'object' ? s : undefined);
|
|
182
|
+
|
|
183
|
+
function readV2(acc, db) {
|
|
184
|
+
const { start, end } = acc.w;
|
|
185
|
+
const sess = new Map();
|
|
186
|
+
for (const r of rows(db, 'select id, parent_id, directory, version, summary_additions, summary_deletions, time_created, time_updated from session_v2')) sess.set(r.id, r);
|
|
187
|
+
const t = tables(db);
|
|
188
|
+
const partsOf = new Map();
|
|
189
|
+
if (t.has('session_part')) {
|
|
190
|
+
for (const p of rows(db, "select message_id, data from session_part where type = 'tool' and time_created >= ? and time_created < ?", start, end)) {
|
|
191
|
+
const d = json(p.data); if (!d) continue;
|
|
192
|
+
const a = partsOf.get(p.message_id) || []; a.push(d); partsOf.set(p.message_id, a);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
let cur = null;
|
|
196
|
+
const order = 'select id, session_id, type, time_created, data from session_message where time_created >= ? and time_created < ? order by session_id, seq';
|
|
197
|
+
for (const r of rows(db, order, start, end)) {
|
|
198
|
+
if (r.session_id !== cur) {
|
|
199
|
+
cur = r.session_id; const s = sess.get(cur);
|
|
200
|
+
if (!s || !acc.session({ id: s.id, parent: s.parent_id, dir: s.directory, version: s.version, created: s.time_created, updated: s.time_updated, additions: s.summary_additions, deletions: s.summary_deletions })) { cur = '\0skip:' + cur; }
|
|
201
|
+
sess.delete(r.session_id);
|
|
202
|
+
}
|
|
203
|
+
if (cur.startsWith('\0skip:')) continue;
|
|
204
|
+
const d = json(r.data); if (!d) continue;
|
|
205
|
+
v2Message(acc, r, d, partsOf.get(r.id) || []);
|
|
206
|
+
}
|
|
207
|
+
// sessions with no message this year still count for version / subagents / lines
|
|
208
|
+
for (const [, s] of sess) acc.session({ id: s.id, parent: s.parent_id, dir: s.directory, version: s.version, created: s.time_created, updated: s.time_updated, additions: s.summary_additions, deletions: s.summary_deletions });
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function readV1Tables(acc, db) {
|
|
212
|
+
const { start } = acc.w;
|
|
213
|
+
const list = [...rows(db, 'select id, parent_id, directory, version, summary_additions, summary_deletions, time_created, time_updated from session')];
|
|
214
|
+
for (const s of list) {
|
|
215
|
+
if (!acc.session({ id: s.id, parent: s.parent_id, dir: s.directory, version: s.version, created: s.time_created, updated: s.time_updated, additions: s.summary_additions, deletions: s.summary_deletions })) continue;
|
|
216
|
+
if (+s.time_updated < start) continue;
|
|
217
|
+
const parts = new Map();
|
|
218
|
+
for (const p of rows(db, 'select id, message_id, data from part where session_id = ?', s.id)) {
|
|
219
|
+
const d = json(p.data); if (!d) continue; d.id = p.id;
|
|
220
|
+
const a = parts.get(p.message_id) || []; a.push(d); parts.set(p.message_id, a);
|
|
221
|
+
}
|
|
222
|
+
for (const m of rows(db, 'select id, time_created, data from message where session_id = ? order by time_created', s.id)) {
|
|
223
|
+
const d = json(m.data); if (!d) continue; d.id = m.id; d.time = d.time || { created: m.time_created };
|
|
224
|
+
v1Message(acc, d, (parts.get(m.id) || []).sort((a, b) => String(a.id).localeCompare(String(b.id))));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
async function readJSONStorage(acc, storage) {
|
|
230
|
+
const sdir = path.join(storage, 'session');
|
|
231
|
+
let projects = []; try { projects = await fsp.readdir(sdir); } catch { return 0; }
|
|
232
|
+
let n = 0;
|
|
233
|
+
for (const pid of projects) {
|
|
234
|
+
let files = []; try { files = (await fsp.readdir(path.join(sdir, pid))).filter(x => x.endsWith('.json')); } catch { continue; }
|
|
235
|
+
for (const fn of files) {
|
|
236
|
+
const s = await readJSON(path.join(sdir, pid, fn)); if (!s || !s.id) continue;
|
|
237
|
+
const tm = s.time || {}; const sum = s.summary || {};
|
|
238
|
+
if (!acc.session({ id: s.id, parent: s.parentID, dir: s.directory, version: s.version, created: tm.created, updated: tm.updated, additions: sum.additions, deletions: sum.deletions })) continue;
|
|
239
|
+
n++;
|
|
240
|
+
if ((+tm.updated || +tm.created || 0) < acc.w.start) continue;
|
|
241
|
+
const mdir = path.join(storage, 'message', s.id);
|
|
242
|
+
let mfiles = []; try { mfiles = (await fsp.readdir(mdir)).filter(x => x.endsWith('.json')).sort(); } catch {}
|
|
243
|
+
for (const mf of mfiles) {
|
|
244
|
+
const m = await readJSON(path.join(mdir, mf)); if (!m || !m.role) continue;
|
|
245
|
+
const pdir = path.join(storage, 'part', m.id || mf.slice(0, -5));
|
|
246
|
+
let pfiles = []; try { pfiles = (await fsp.readdir(pdir)).filter(x => x.endsWith('.json')).sort(); } catch {}
|
|
247
|
+
const parts = [];
|
|
248
|
+
for (const pf of pfiles) { const p = await readJSON(path.join(pdir, pf)); if (p) parts.push(p); }
|
|
249
|
+
v1Message(acc, m, parts);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return n;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export async function read(env, opts = {}) {
|
|
257
|
+
const w = windowOf(env, opts); const progress = opts.onProgress || (() => {});
|
|
258
|
+
const acc = new Acc(w); const f = acc.f;
|
|
259
|
+
f.coverage.notes.push(BETA);
|
|
260
|
+
const dirs = dataDirs(env);
|
|
261
|
+
const dbs = []; for (const d of dirs) dbs.push(...await dbFiles(d));
|
|
262
|
+
if (dbs.length && !(await sqlite())) f.coverage.notes.push(`${NEEDS_NODE} OpenCode's database (opencode.db)`);
|
|
263
|
+
else {
|
|
264
|
+
for (const file of dbs) {
|
|
265
|
+
progress(`OpenCode: ${path.basename(file)}`);
|
|
266
|
+
const db = await openRO(file);
|
|
267
|
+
if (!db) { f.coverage.notes.push(`could not open ${path.basename(file)}`); continue; }
|
|
268
|
+
try {
|
|
269
|
+
const t = tables(db);
|
|
270
|
+
if (t.has('session_v2') && t.has('session_message')) { readV2(acc, db); f.coverage.sources.push(path.basename(file) + ' (session_v2)'); }
|
|
271
|
+
if (t.has('session') && t.has('message') && t.has('part')) { readV1Tables(acc, db); f.coverage.sources.push(path.basename(file) + ' (session/message/part)'); }
|
|
272
|
+
} finally { close(db); }
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
for (const d of dirs) {
|
|
276
|
+
const storage = path.join(d, 'storage');
|
|
277
|
+
if (await isDir(path.join(storage, 'session'))) {
|
|
278
|
+
progress('OpenCode: storage/*.json');
|
|
279
|
+
const n = await readJSONStorage(acc, storage);
|
|
280
|
+
if (n) f.coverage.sources.push('storage/{session,message,part}/*.json');
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
acc.finish();
|
|
284
|
+
const local = await localProviders(env);
|
|
285
|
+
for (const m of Object.values(f.models)) if (m.provider && local(m.provider)) m.local = true;
|
|
286
|
+
f.theme = await readTheme(env);
|
|
287
|
+
f.coverage.notes.push('tokens as OpenCode recorded them (output includes reasoning); lines = session diff summaries');
|
|
288
|
+
return finishCoverage(f);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** provider id -> served on this machine? (config baseURL on localhost, or a known local runtime name) */
|
|
292
|
+
async function localProviders(env) {
|
|
293
|
+
const byUrl = {};
|
|
294
|
+
for (const dir of configDirs(env)) for (const fn of ['opencode.jsonc', 'opencode.json', 'config.json']) {
|
|
295
|
+
const cfg = parseJSONC(await readText(path.join(dir, fn)));
|
|
296
|
+
for (const [name, p] of Object.entries((cfg && cfg.provider) || {})) if (!(name in byUrl)) byUrl[name] = String((p && p.options && (p.options.baseURL || p.options.baseUrl)) || '');
|
|
297
|
+
}
|
|
298
|
+
const LOCAL_URL = /^https?:\/\/(localhost|127\.|0\.0\.0\.0|\[::1\]|192\.168\.|10\.|host\.docker\.internal)/i;
|
|
299
|
+
const LOCAL_NAME = /^(ollama|lmstudio|lm-studio|llama\.?cpp|llamacpp|vllm|mlx|local)/i;
|
|
300
|
+
return prov => (byUrl[prov] ? LOCAL_URL.test(byUrl[prov]) : LOCAL_NAME.test(prov));
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// ------------------------------------------------------------------ theme
|
|
304
|
+
const BUILTIN = new Set(['system', 'opencode', 'opencode-classic', 'aura', 'ayu', 'carbonfox', 'catppuccin', 'catppuccin-frappe', 'catppuccin-macchiato',
|
|
305
|
+
'cobalt2', 'cursor', 'dracula', 'everforest', 'flexoki', 'github', 'gruvbox', 'kanagawa', 'lucent-orng', 'material', 'matrix', 'mercury', 'monokai',
|
|
306
|
+
'nightowl', 'nord', 'one-dark', 'orng', 'osaka-jade', 'palenight', 'rosepine', 'solarized', 'synthwave84', 'tokyonight', 'vercel', 'vesper', 'zenburn']);
|
|
307
|
+
|
|
308
|
+
export async function readTheme(env) {
|
|
309
|
+
let name = null, mode = 'dark';
|
|
310
|
+
for (const dir of configDirs(env)) {
|
|
311
|
+
for (const fn of ['tui.jsonc', 'tui.json', 'opencode.jsonc', 'opencode.json', 'config.json']) {
|
|
312
|
+
const cfg = parseJSONC(await readText(path.join(dir, fn))); const t = cfg && cfg.theme;
|
|
313
|
+
if (typeof t === 'string' && t) { name = t; break; }
|
|
314
|
+
if (t && typeof t === 'object' && typeof t.name === 'string') { name = t.name; if (t.mode === 'light') mode = 'light'; break; }
|
|
315
|
+
}
|
|
316
|
+
if (name) break;
|
|
317
|
+
}
|
|
318
|
+
if (!name) for (const dir of stateDirs(env)) {
|
|
319
|
+
const kv = await readJSON(path.join(dir, 'kv.json'));
|
|
320
|
+
if (kv && typeof kv.theme === 'string') { name = kv.theme; if (kv.theme_mode === 'light') mode = 'light'; break; }
|
|
321
|
+
}
|
|
322
|
+
if (!name) return null;
|
|
323
|
+
let file = null;
|
|
324
|
+
for (const dir of configDirs(env)) { file = await readJSON(path.join(dir, 'themes', name + '.json')); if (file) break; }
|
|
325
|
+
if (!file) return { name, builtin: BUILTIN.has(name), colors: null };
|
|
326
|
+
const defs = file.defs || {}; const th = file.theme || {};
|
|
327
|
+
const resolve = (v, depth = 0) => {
|
|
328
|
+
if (depth > 8 || v == null) return null;
|
|
329
|
+
if (typeof v === 'object') return resolve(v[mode] ?? v.dark ?? v.light, depth + 1);
|
|
330
|
+
if (typeof v !== 'string') return null;
|
|
331
|
+
if (/^#[0-9a-f]{3,8}$/i.test(v)) return v.toLowerCase();
|
|
332
|
+
if (v in defs) return resolve(defs[v], depth + 1);
|
|
333
|
+
if (v in th) return resolve(th[v], depth + 1);
|
|
334
|
+
return null;
|
|
335
|
+
};
|
|
336
|
+
const pick = (...ks) => { for (const k of ks) { const c = resolve(th[k]); if (c) return c; } return null; };
|
|
337
|
+
const colors = {
|
|
338
|
+
background: pick('background'), foreground: pick('text'), primary: pick('primary'), accent: pick('accent', 'primary'),
|
|
339
|
+
surface: pick('backgroundPanel', 'backgroundElement'), success: pick('success'),
|
|
340
|
+
};
|
|
341
|
+
for (const [k, src] of [['secondary', 'secondary'], ['muted', 'textMuted'], ['surfaceAlt', 'backgroundElement'], ['error', 'error'], ['warning', 'warning']]) { const c = pick(src); if (c) colors[k] = c; }
|
|
342
|
+
return { name, builtin: false, colors: Object.values(colors).some(Boolean) ? colors : null };
|
|
343
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Qwen Code reader: ~/.qwen (or $QWEN_HOME / $QWEN_RUNTIME_DIR). Shares gemini-cli.mjs, which documents both formats and sources.
|
|
2
|
+
import { makeReader } from './gemini-cli.mjs';
|
|
3
|
+
|
|
4
|
+
const qwen = makeReader({ id: 'qwen-code', label: 'Qwen Code', tool: 'Qwen Code', dir: '.qwen', homeEnv: 'QWEN_HOME', qwen: true });
|
|
5
|
+
export const id = qwen.id;
|
|
6
|
+
export const label = qwen.label;
|
|
7
|
+
export const detect = qwen.detect;
|
|
8
|
+
export const read = qwen.read;
|
package/src/site.mjs
CHANGED
|
@@ -34,7 +34,7 @@ const page = (id, name, where, note) => `<!doctype html><html lang="en"><head><m
|
|
|
34
34
|
<p>Your year with ${name}: prompts, tokens, streak, model of the year, how often you said please and how often it said “you’re right”, your agentic age, and a roast written by your own agent.</p>
|
|
35
35
|
<p>Run it in a terminal, or paste it into ${name}:</p><code>npx wrapped-agents</code>
|
|
36
36
|
<p>It reads <b>${where}</b>, read-only. ${note} Your usage data never leaves your machine.</p>
|
|
37
|
-
<p><a href="./">See a demo wrap →</a> · <a href="https://github.com/
|
|
37
|
+
<p><a href="./">See a demo wrap →</a> · <a href="https://github.com/LeonardoDaviti/agent-wrapped">GitHub</a></p></body></html>`;
|
|
38
38
|
for (const h of HARNESS) fs.writeFileSync(path.join(SITE, `${h[0]}-wrapped.html`), page(...h));
|
|
39
39
|
|
|
40
40
|
fs.writeFileSync(path.join(SITE, 'privacy.html'), `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Privacy · Agent Wrapped</title>
|
|
@@ -49,10 +49,11 @@ fs.writeFileSync(path.join(SITE, 'privacy.html'), `<!doctype html><html lang="en
|
|
|
49
49
|
fs.writeFileSync(path.join(SITE, 'llms.txt'), `# Agent Wrapped
|
|
50
50
|
> Year in review ("wrapped") for AI coding agents: Claude Code, Codex, Pi, Mistral Vibe. Runs locally; usage data never leaves the machine.
|
|
51
51
|
|
|
52
|
-
To make a user's wrapped: run \`npx -y wrapped-agents\` (opens the story in the browser). Agents may write the roast themselves: run \`npx -y wrapped-agents --json --no-open\`, read the printed wrapped-<year>.json, then \`npx -y wrapped-agents --from <file> --roast "<≤12 words citing its numbers>"\`. Skill: https://github.com/
|
|
52
|
+
To make a user's wrapped: run \`npx -y wrapped-agents\` (opens the story in the browser). Agents may write the roast themselves: run \`npx -y wrapped-agents --json --no-open\`, read the printed wrapped-<year>.json, then \`npx -y wrapped-agents --from <file> --roast "<≤12 words citing its numbers>"\`. Skill: https://github.com/LeonardoDaviti/agent-wrapped/blob/main/SKILL.md
|
|
53
53
|
|
|
54
|
-
- [
|
|
55
|
-
- [
|
|
54
|
+
- [npm package](https://www.npmjs.com/package/wrapped-agents)
|
|
55
|
+
- [Repository](https://github.com/LeonardoDaviti/agent-wrapped)
|
|
56
|
+
- [SKILL.md](https://github.com/LeonardoDaviti/agent-wrapped/blob/main/SKILL.md)
|
|
56
57
|
- [Privacy](${BASE}privacy.html)
|
|
57
58
|
`);
|
|
58
59
|
fs.writeFileSync(path.join(SITE, 'robots.txt'), `User-agent: *\nAllow: /\nSitemap: ${BASE}sitemap.xml\n`);
|
package/src/stats/awards.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// An award whose data is unknown (null) is omitted, never invented.
|
|
3
3
|
|
|
4
4
|
export const AWARD_IDS = ['harness', 'model', 'tokens', 'spendings', 'prompts', 'sessions', 'streak', 'marathon', 'swarm',
|
|
5
|
-
'peakHour', 'politeness', 'backseat', 'lines', 'mostResumed', 'wordOfYear', 'agentClass', 'tier', 'skill', 'rateLimits',
|
|
5
|
+
'peakHour', 'politeness', 'backseat', 'lines', 'mostResumed', 'wordOfYear', 'agentClass', 'tier', 'skill', 'tool', 'rateLimits',
|
|
6
6
|
'age', 'twin', 'youreRight', 'modelRace', 'caps', 'screenshots', 'compactions', 'prs', 'ctrlZ', 'roast'];
|
|
7
7
|
|
|
8
8
|
export const num = n => Math.round(n).toLocaleString('en-US');
|
|
@@ -83,6 +83,11 @@ export function buildAwards(ctx) {
|
|
|
83
83
|
if (sk) add('skill', 'Skill of the Year', sk[0], `${num(sk[1])} runs`, 'skill calls');
|
|
84
84
|
else if (mcp) add('skill', 'Skill of the Year', mcp[0], `${num(mcp[1])} MCP calls`, 'MCP calls');
|
|
85
85
|
|
|
86
|
+
// Tool of the Year
|
|
87
|
+
const tools = mergeTools(m.tools);
|
|
88
|
+
const tl = top(tools);
|
|
89
|
+
if (tl) add('tool', 'Tool of the Year', tl[0], `${num(tl[1])} calls`, 'tool calls, merged across harnesses');
|
|
90
|
+
|
|
86
91
|
if (m.rateLimits) add('rateLimits', 'Rate limits', `${num(m.rateLimits.hits)} hit${m.rateLimits.hits === 1 ? '' : 's'}`,
|
|
87
92
|
m.rateLimits.days ? `on ${m.rateLimits.days}+ days` : '', 'limit messages');
|
|
88
93
|
|
|
@@ -130,3 +135,9 @@ function top(map) {
|
|
|
130
135
|
for (const [k, v] of Object.entries(map)) if (v > 0 && (!best || v > best[1])) best = [k, v];
|
|
131
136
|
return best;
|
|
132
137
|
}
|
|
138
|
+
|
|
139
|
+
// same tool under different harness names counts once (Bash / exec / bash / run_shell_command …)
|
|
140
|
+
const TOOL = { bash: 'Bash', exec: 'Bash', shell: 'Bash', local_shell: 'Bash', run_shell_command: 'Bash', exec_command: 'Bash', terminal: 'Bash',
|
|
141
|
+
read: 'Read', read_file: 'Read', view: 'Read', edit: 'Edit', multiedit: 'Edit', str_replace: 'Edit', apply_patch: 'Edit', replace: 'Edit', write: 'Write', write_file: 'Write',
|
|
142
|
+
grep: 'Grep', search: 'Grep', glob: 'Glob', websearch: 'WebSearch', web_search: 'WebSearch', webfetch: 'WebFetch', web_fetch: 'WebFetch', agent: 'Agent', task: 'Agent', spawn_agent: 'Agent', send_message: 'SendMessage', sendmessage: 'SendMessage', todowrite: 'TodoWrite', todo_write: 'TodoWrite' };
|
|
143
|
+
export function mergeTools(t) { const out = {}; for (const [k, v] of Object.entries(t || {})) { const n = TOOL[k.toLowerCase()] || k; out[n] = (out[n] || 0) + v; } return out; }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Facts for the tokens slide's comparison line. The joke itself is written by the user's own agent (SKILL.md, --quip);
|
|
2
|
+
// without an agent the page shows a plain factual line. Compares only what was read + written (input + output), never cache.
|
|
3
|
+
// Token counts ≈ words × 1.33 (English prose, modern BPE tokenizers); words from public word counts.
|
|
4
|
+
export const WORKS = [
|
|
5
|
+
['Pride and Prejudice', 122_000], ['The Great Gatsby', 47_000], ['Moby-Dick', 210_000], ['Dune', 188_000],
|
|
6
|
+
['War and Peace', 587_000], ['The Lord of the Rings', 481_000], ['every Harry Potter book', 1_084_000],
|
|
7
|
+
['the complete works of Shakespeare', 884_000], ['the King James Bible', 783_000], ['The Hobbit', 95_000],
|
|
8
|
+
['Frankenstein', 75_000], ['Crime and Punishment', 211_000], ['Don Quixote', 430_000], ['Ulysses', 265_000],
|
|
9
|
+
['The Odyssey', 134_000], ['A Game of Thrones', 298_000], ['Les Misérables', 545_000], ['Alice in Wonderland', 27_000],
|
|
10
|
+
['The Hitchhiker’s Guide to the Galaxy', 46_000], ['1984', 89_000], ['English Wikipedia', 4_900_000_000],
|
|
11
|
+
].map(([name, words]) => ({ name, tokens: Math.round(words * 1.33) }));
|
|
12
|
+
|
|
13
|
+
const fmt = x => x >= 100 ? Math.round(x).toLocaleString('en-US') : x >= 10 ? x.toFixed(0) : x.toFixed(1);
|
|
14
|
+
|
|
15
|
+
/** up to 6 random works whose multiple reads well (3×–200k×), plus a plain factual default line; rnd injectable */
|
|
16
|
+
export function tokenComparison(ioTokens, rnd = Math.random) {
|
|
17
|
+
if (!ioTokens) return null;
|
|
18
|
+
const fits = WORKS.filter(w => { const x = ioTokens / w.tokens; return x >= 3 && x <= 200_000; });
|
|
19
|
+
const pool = (fits.length ? fits : WORKS).slice();
|
|
20
|
+
for (let i = pool.length - 1; i > 0; i--) { const j = Math.floor(rnd() * (i + 1)); [pool[i], pool[j]] = [pool[j], pool[i]]; }
|
|
21
|
+
const options = pool.slice(0, 6).map(w => ({ work: w.name, times: fmt(+(ioTokens / w.tokens).toPrecision(2)) }));
|
|
22
|
+
const o = options[0];
|
|
23
|
+
return { ioTokens, options, text: `That’s ${o.work}, ${o.times} times.`, by: null };
|
|
24
|
+
}
|
package/src/stats/index.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { tokenComparison } from './compare.mjs';
|
|
2
|
+
import { mergeTools } from './awards.mjs';
|
|
1
3
|
// Stats engine: HarnessFacts[] (+ optional Extras) → Wrapped (CONTRACT §4). Pure: no I/O, no network.
|
|
2
4
|
import { spendings, normalizeModel, modelLabel, PRICES } from './spendings.mjs';
|
|
3
5
|
import { tierFor } from './tiers.mjs';
|
|
@@ -5,7 +7,9 @@ import { agenticAge } from './age.mjs';
|
|
|
5
7
|
import { agentTwin } from './twin.mjs';
|
|
6
8
|
import { buildAwards } from './awards.mjs';
|
|
7
9
|
|
|
8
|
-
export const SKINS = ['wrapped', 'anthropic', 'claude-code', 'codex', 'opencode', 'pi', 'hermes', 'mistral-vibe'];
|
|
10
|
+
export const SKINS = ['wrapped', 'anthropic', 'claude-code', 'codex', 'cursor', 'gemini-cli', 'opencode', 'pi', 'hermes', 'mistral-vibe'];
|
|
11
|
+
/** harnesses that wear another harness's skin (Qwen Code forked Gemini CLI) */
|
|
12
|
+
const SKIN_OF = { 'qwen-code': 'gemini-cli' };
|
|
9
13
|
|
|
10
14
|
const isNum = v => typeof v === 'number' && Number.isFinite(v);
|
|
11
15
|
/** sum that stays null when every input is unknown */
|
|
@@ -117,7 +121,8 @@ export function mergedMedian(facts) {
|
|
|
117
121
|
/** default theme rule (CONTRACT §6) + "yours" token mapping (§5) */
|
|
118
122
|
export function pickTheme(topFacts) {
|
|
119
123
|
if (!topFacts) return { skin: 'wrapped', yours: null };
|
|
120
|
-
const
|
|
124
|
+
const h = SKIN_OF[topFacts.harness] || topFacts.harness;
|
|
125
|
+
const skin = SKINS.includes(h) ? h : 'wrapped';
|
|
121
126
|
const th = topFacts.theme;
|
|
122
127
|
if (!th || th.builtin !== false || !th.colors) return { skin, yours: null };
|
|
123
128
|
const c = th.colors, y = {};
|
|
@@ -151,12 +156,13 @@ export function buildWrapped(facts, { year, extras = null, handle = null, now =
|
|
|
151
156
|
const modelIds = Object.keys(m.models);
|
|
152
157
|
const tokens = facts.some(f => f.models) ? modelIds.reduce((a, id) => a + tokSum(m.models[id]), 0) : null;
|
|
153
158
|
const cacheRead = modelIds.reduce((a, id) => a + (m.models[id].cacheRead || 0), 0);
|
|
159
|
+
const io = modelIds.reduce((a, id) => a + (m.models[id].input || 0) + (m.models[id].output || 0), 0);
|
|
154
160
|
// readers report toolCalls incl. counts from before tool names exist (e.g. Claude Code stats-cache); fall back to summing names
|
|
155
161
|
const toolCalls = facts.some(f => f.toolCalls) ? facts.reduce((a, f) => a + (f.toolCalls || (f.tools ? Object.values(f.tools).reduce((x, y) => x + y, 0) : 0)), 0) : (m.tools ? Object.values(m.tools).reduce((a, b) => a + b, 0) : null);
|
|
156
162
|
const totals = {
|
|
157
163
|
prompts: m.prompts, sessions: m.sessions, activeDays: activeDates.length,
|
|
158
164
|
streak: { days: streak.days, from: streak.from, to: streak.to },
|
|
159
|
-
tokens, cacheShare: tokens ? r2(cacheRead / tokens) : null,
|
|
165
|
+
tokens, ioTokens: io || null, cacheShare: tokens ? r2(cacheRead / tokens) : null,
|
|
160
166
|
toolCalls, subagents: m.subagents,
|
|
161
167
|
};
|
|
162
168
|
|
|
@@ -179,8 +185,24 @@ export function buildWrapped(facts, { year, extras = null, handle = null, now =
|
|
|
179
185
|
};
|
|
180
186
|
const raceWinners = raceWinnersOf(series.race);
|
|
181
187
|
|
|
188
|
+
// story extras: busiest day, top 5 lists, "guess your #1 model" quiz
|
|
189
|
+
const dayList = Object.entries(series.days).sort((a, b) => b[1] - a[1]);
|
|
190
|
+
const busiest = dayList.length ? { date: dayList[0][0], prompts: dayList[0][1],
|
|
191
|
+
peakHour: (m.hours || []).indexOf(Math.max(...(m.hours || [0]))) } : null;
|
|
192
|
+
const topN = (o, n = 5) => Object.entries(o || {}).filter(([, v]) => v > 0).sort((a, b) => b[1] - a[1]).slice(0, n);
|
|
193
|
+
const top5 = { tools: topN(mergeTools(m.tools)), skills: topN(m.skills), models: models.slice(0, 5).map(x => [x.label, x.share]) };
|
|
194
|
+
const DECOYS = ['Opus 5.5', 'Sonnet 5.5', 'GPT-6 Astra', 'Gemini 3 Pro', 'Opus 5', 'Devstral 2', 'Qwen3 Coder', 'Haiku 5.5'];
|
|
195
|
+
let quiz = null;
|
|
196
|
+
if (models.length) {
|
|
197
|
+
const answer = models[0].label;
|
|
198
|
+
const pool = [...models.slice(1, 3).map(x => x.label), ...DECOYS].filter((x, i, a) => x !== answer && a.indexOf(x) === i);
|
|
199
|
+
const choices = [answer, ...pool.slice(0, 2)];
|
|
200
|
+
for (let i = choices.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [choices[i], choices[j]] = [choices[j], choices[i]]; }
|
|
201
|
+
quiz = { question: 'Which model did you use most?', choices, answer, share: models[0].share };
|
|
202
|
+
}
|
|
203
|
+
|
|
182
204
|
// tier, age, twin
|
|
183
|
-
const tier = tierFor(m.prompts, totals.activeDays);
|
|
205
|
+
const tier = tierFor(m.prompts, totals.activeDays, totals.tokens);
|
|
184
206
|
const hTot = m.hours ? m.hours.reduce((a, b) => a + b, 0) : 0;
|
|
185
207
|
const wTot = m.weekdays ? m.weekdays.reduce((a, b) => a + b, 0) : 0;
|
|
186
208
|
const shares = {
|
|
@@ -193,7 +215,7 @@ export function buildWrapped(facts, { year, extras = null, handle = null, now =
|
|
|
193
215
|
const ageR = m.prompts ? agenticAge({ ...shares, streakDays: streak.days }) : null;
|
|
194
216
|
const coAuthored = extras && extras.commits ? Object.values(extras.commits.coAuthored || {}).reduce((a, b) => a + b, 0) : null;
|
|
195
217
|
const twin = m.prompts ? agentTwin({
|
|
196
|
-
...shares, agentClass: tier.power,
|
|
218
|
+
...shares, agentClass: tier.power, topTier: tier.top === 1,
|
|
197
219
|
subagentsPerSession: m.subagents != null && m.sessions ? m.subagents / m.sessions : null,
|
|
198
220
|
longestActiveHours: m.longest ? m.longest.activeHours : null,
|
|
199
221
|
harnessShares: harnesses.map(h => h.share), coAuthoredCommits: coAuthored,
|
|
@@ -205,6 +227,8 @@ export function buildWrapped(facts, { year, extras = null, handle = null, now =
|
|
|
205
227
|
|
|
206
228
|
const w = {
|
|
207
229
|
schema: 1, year, generatedAt: now.toISOString(),
|
|
230
|
+
compare: tokenComparison(totals.ioTokens),
|
|
231
|
+
busiest, top5, quiz, dayLine: null,
|
|
208
232
|
handle: h,
|
|
209
233
|
coverage: facts.map(f => ({ harness: f.harness, label: f.label, from: f.coverage?.from ?? null, to: f.coverage?.to ?? null, notes: f.coverage?.notes || [] })),
|
|
210
234
|
theme: pickTheme(top),
|
package/src/stats/roast.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The roast is written by the user's own agent (see SKILL.md). We only check it cites numbers that exist in this wrap.
|
|
2
2
|
export function roastNumbersOk(w, roast) {
|
|
3
|
-
const hay = JSON.stringify(w.awards || []) + JSON.stringify(w.totals || {});
|
|
3
|
+
const hay = JSON.stringify(w.awards || []) + JSON.stringify(w.totals || {}) + JSON.stringify(w.compare?.options || []) + JSON.stringify(w.busiest || {}) + JSON.stringify(w.top5 || {});
|
|
4
4
|
const nums = String(roast || '').match(/\d[\d,.]*/g) || [];
|
|
5
5
|
return nums.every(n => { const t = n.replace(/[.,]$/, ''); return hay.includes(t) || hay.includes(t.replace(/[,.]/g, '')); });
|
|
6
6
|
}
|
package/src/stats/tiers.mjs
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
// Top X%: fixed tiers on score = prompts × active days (spec §16). Thresholds are published, not percentiles.
|
|
2
2
|
export const TIERS = [
|
|
3
|
-
{ top: 1, min: 1_000_000, power: '
|
|
4
|
-
{ top: 5, min: 300_000, power: '
|
|
5
|
-
{ top: 10, min: 100_000, power: '
|
|
6
|
-
{ top: 25, min: 20_000, power: '
|
|
7
|
-
{ top: 50, min: 3_000, power: '
|
|
8
|
-
{ top: 80, min: 0, power: '
|
|
3
|
+
{ top: 1, min: 1_000_000, power: 'Tokenmaxxer', line: 'Limits are a suggestion.' },
|
|
4
|
+
{ top: 5, min: 300_000, power: 'Vibe Engineer', line: 'Vibes, but with tests.' },
|
|
5
|
+
{ top: 10, min: 100_000, power: 'Cracked Vibecoder', line: 'Ships first, reads the diff later.' },
|
|
6
|
+
{ top: 25, min: 20_000, power: 'Vibecoder', line: 'Accept all. Pray.' },
|
|
7
|
+
{ top: 50, min: 3_000, power: 'Prompt Enjoyer', line: 'Two heads, one keyboard.' },
|
|
8
|
+
{ top: 80, min: 0, power: 'Vibe Tourist', line: 'Just here for the vibes.' },
|
|
9
9
|
];
|
|
10
|
+
// past this many tokens (all of them, cache included) the class is the meme itself
|
|
11
|
+
export const UNLIMITED = { tokens: 200_000_000_000, power: 'Unlimited Tokens', line: 'Rate limits fear you.' };
|
|
10
12
|
|
|
11
13
|
/** → { score, top, label, power } (line is extra, used by the agentClass award, not in wrapped.tier) */
|
|
12
|
-
export function tierFor(prompts, activeDays) {
|
|
14
|
+
export function tierFor(prompts, activeDays, tokens = 0) {
|
|
13
15
|
const score = Math.max(0, Math.round((prompts || 0) * (activeDays || 0)));
|
|
14
16
|
const t = TIERS.find(t => score >= t.min);
|
|
15
|
-
|
|
17
|
+
const c = tokens >= UNLIMITED.tokens ? UNLIMITED : t;
|
|
18
|
+
return { score, top: t.top, label: `Top ${t.top}%`, power: c.power, line: c.line };
|
|
16
19
|
}
|
package/src/stats/twin.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Agent Twin (spec §17, draft archetypes). First match wins; Swarm Conductor is skipped when the
|
|
2
|
-
// agent class
|
|
2
|
+
// agent class is already top tier.
|
|
3
3
|
// Match % = 60 + 10 × (value − threshold) / threshold, rounded, capped at 99 (Tinkerer = 60).
|
|
4
4
|
// Owner 2026: The Marathoner, 60 + 10 × (197.85 − 48) / 48 = 91.2 → 91.
|
|
5
5
|
|
|
@@ -8,7 +8,7 @@ const pct = x => Math.round(x * 100);
|
|
|
8
8
|
const match = (v, t) => Math.min(99, Math.max(60, Math.round(60 + 10 * (v - t) / t)));
|
|
9
9
|
|
|
10
10
|
export const ARCHETYPES = [
|
|
11
|
-
{ name: 'The Swarm Conductor', test: p => !/swarm/i.test(p.agentClass || '') && p.subagentsPerSession != null && p.subagentsPerSession > 2,
|
|
11
|
+
{ name: 'The Swarm Conductor', test: p => !p.topTier && !/swarm/i.test(p.agentClass || '') && p.subagentsPerSession != null && p.subagentsPerSession > 2,
|
|
12
12
|
match: p => match(p.subagentsPerSession, 2), why: p => `${p.subagentsPerSession.toFixed(1)} subagents per session` },
|
|
13
13
|
{ name: 'The Night Architect', test: p => p.lateShare != null && p.lateShare > 0.30,
|
|
14
14
|
match: p => match(p.lateShare, 0.30), why: p => `${pct(p.lateShare)}% after 22:00` },
|