coauthored 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/PRIVACY.md +107 -0
- package/README.md +113 -3
- package/THIRD_PARTY_LICENSES.md +105 -0
- package/dist/cli/analytics/anchors.js +39 -0
- package/dist/cli/analytics/archetypes.js +193 -0
- package/dist/cli/analytics/content/analyzer.js +945 -0
- package/dist/cli/analytics/content/classify.js +115 -0
- package/dist/cli/analytics/content/demo-corpus.js +301 -0
- package/dist/cli/analytics/content/sketch.js +54 -0
- package/dist/cli/analytics/dataset.js +321 -0
- package/dist/cli/analytics/demo-fixtures.js +531 -0
- package/dist/cli/analytics/fdr.js +183 -0
- package/dist/cli/analytics/helicorder.js +66 -0
- package/dist/cli/analytics/insights.js +589 -0
- package/dist/cli/analytics/models.js +75 -0
- package/dist/cli/analytics/pricing.js +121 -0
- package/dist/cli/analytics/probable-cause.js +115 -0
- package/dist/cli/analytics/report-builder.js +162 -0
- package/dist/cli/analytics/statistics.js +91 -0
- package/dist/cli/analytics/time.js +252 -0
- package/dist/cli/cli/args.js +105 -0
- package/dist/cli/cli/browser.js +71 -0
- package/dist/cli/cli/index.js +20 -0
- package/dist/cli/cli/main.js +520 -0
- package/dist/cli/cli/phrase-review.js +78 -0
- package/dist/cli/cli/server.js +481 -0
- package/dist/cli/cli/terminal.js +363 -0
- package/dist/cli/ingest/adapters/aider.js +116 -0
- package/dist/cli/ingest/adapters/claude-code.js +139 -0
- package/dist/cli/ingest/adapters/cline-roo.js +89 -0
- package/dist/cli/ingest/adapters/codex-cli.js +240 -0
- package/dist/cli/ingest/adapters/content.js +99 -0
- package/dist/cli/ingest/adapters/cursor-ide.js +149 -0
- package/dist/cli/ingest/adapters/gemini-cli.js +208 -0
- package/dist/cli/ingest/adapters/index.js +18 -0
- package/dist/cli/ingest/adapters/opencode.js +203 -0
- package/dist/cli/ingest/adapters/pi-agent.js +85 -0
- package/dist/cli/ingest/adapters/shared.js +484 -0
- package/dist/cli/ingest/content-sink.js +31 -0
- package/dist/cli/ingest/discovery.js +50 -0
- package/dist/cli/ingest/message-digests.js +61 -0
- package/dist/cli/ingest/pipeline.js +155 -0
- package/dist/cli/ingest/safe-fs.js +284 -0
- package/dist/cli/ingest/sqlite-stage.js +139 -0
- package/dist/cli/ingest/time-window.js +34 -0
- package/dist/cli/ingest/tool-map.js +24 -0
- package/dist/cli/ingest/types.js +1 -0
- package/dist/cli/ingest/worker.js +97 -0
- package/dist/cli/report/content/emoji-names.js +3956 -0
- package/dist/cli/report/content/insights.js +41 -0
- package/dist/cli/report/content/lexicons.js +112 -0
- package/dist/cli/report/content/policy.js +77 -0
- package/dist/cli/report/content/redact.js +164 -0
- package/dist/cli/report/content/stopwords.js +8848 -0
- package/dist/cli/report/content/suppression.js +2617 -0
- package/dist/cli/report/content/validate.js +152 -0
- package/dist/cli/report/copy-lint.js +105 -0
- package/dist/cli/report/share.js +132 -0
- package/dist/cli/report/types.js +1 -0
- package/dist/cli/report/validators.js +334 -0
- package/dist/web/assets/Archivo-VF-BohoA-Sn.woff2 +0 -0
- package/dist/web/assets/DelaGothicOne-subset-CpoJGhTq.woff2 +0 -0
- package/dist/web/assets/Film-Dq8Xxn7U.css +1 -0
- package/dist/web/assets/MartianMono-VF-CmJ1nXx9.woff2 +0 -0
- package/dist/web/assets/app-DEQgytaq.js +38 -0
- package/dist/web/assets/bricolage-grotesque-latin-700-normal-gtcctNPv.woff2 +0 -0
- package/dist/web/assets/bricolage-grotesque-latin-800-normal-J50vIsBe.woff2 +0 -0
- package/dist/web/assets/chorus-D7bfON5Z.ogg +0 -0
- package/dist/web/assets/chorus-bass-CBTKpMv_.ogg +0 -0
- package/dist/web/assets/chorus-drums-BOzgLSoq.ogg +0 -0
- package/dist/web/assets/chorus-harmony-DnJYs_tp.ogg +0 -0
- package/dist/web/assets/chorus-lead-CFpg5DC1.ogg +0 -0
- package/dist/web/assets/chunk-BNfsY4o8.js +1 -0
- package/dist/web/assets/chunk-BSm8IhPY.js +1 -0
- package/dist/web/assets/chunk-Bi6EQAkf.js +1 -0
- package/dist/web/assets/chunk-BmDwUWlX.js +1 -0
- package/dist/web/assets/chunk-Ds4joAI5.js +46 -0
- package/dist/web/assets/chunk-V3YGpFIw.js +1 -0
- package/dist/web/assets/chunk-XGhNFWse.js +1 -0
- package/dist/web/assets/dialogue-card-A5zmbNhu.ogg +0 -0
- package/dist/web/assets/groove-bass-BFNelLKi.ogg +0 -0
- package/dist/web/assets/groove-drums-BY1SBntR.ogg +0 -0
- package/dist/web/assets/groove-harmony-C0CrBzu3.ogg +0 -0
- package/dist/web/assets/groove-lead-CEYPzm5U.ogg +0 -0
- package/dist/web/assets/groove-ln-zQmTb.ogg +0 -0
- package/dist/web/assets/guess-high-CL6mF18x.ogg +0 -0
- package/dist/web/assets/guess-low-C3UnKayZ.ogg +0 -0
- package/dist/web/assets/higher-BevsMIWl.ogg +0 -0
- package/dist/web/assets/identity-0EPS3msD.ogg +0 -0
- package/dist/web/assets/index-DpT0dtHc.css +1 -0
- package/dist/web/assets/intro-DeRh6kUx.ogg +0 -0
- package/dist/web/assets/intro-bass-D63IPU0H.ogg +0 -0
- package/dist/web/assets/intro-drums-Dt9QO534.ogg +0 -0
- package/dist/web/assets/intro-harmony-DBsMG9jJ.ogg +0 -0
- package/dist/web/assets/intro-lead-DWcWS1ia.ogg +0 -0
- package/dist/web/assets/jar-coin-rtCvspuq.ogg +0 -0
- package/dist/web/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
- package/dist/web/assets/ledger-tick-C1rQgQGX.ogg +0 -0
- package/dist/web/assets/night-B_bMOZcf.ogg +0 -0
- package/dist/web/assets/night-bass-B-7Ay9ME.ogg +0 -0
- package/dist/web/assets/night-drums-zEtqWXX3.ogg +0 -0
- package/dist/web/assets/night-harmony-C5Ix2yce.ogg +0 -0
- package/dist/web/assets/night-lead-B7KMlRyj.ogg +0 -0
- package/dist/web/assets/ourturn-DX78hTEz.ogg +0 -0
- package/dist/web/assets/plus-jakarta-sans-latin-400-normal-Dhut76fR.woff2 +0 -0
- package/dist/web/assets/plus-jakarta-sans-latin-500-normal-Bf-nb4oT.woff2 +0 -0
- package/dist/web/assets/plus-jakarta-sans-latin-600-normal-DLTa1BUW.woff2 +0 -0
- package/dist/web/assets/plus-jakarta-sans-latin-700-normal-CfpNZvy6.woff2 +0 -0
- package/dist/web/assets/reveal-BmWAGHih.ogg +0 -0
- package/dist/web/assets/review-split-Dac4zagw.ogg +0 -0
- package/dist/web/assets/shutter-uhz2Y9S9.ogg +0 -0
- package/dist/web/assets/soclose-CiUFR5St.ogg +0 -0
- package/dist/web/assets/stinger-TnnzHAMN.ogg +0 -0
- package/dist/web/assets/stomp-mzIk4cGm.ogg +0 -0
- package/dist/web/assets/syne-latin-700-normal-AF3Rs61n.woff2 +0 -0
- package/dist/web/assets/syne-latin-800-normal-EehdNYzx.woff2 +0 -0
- package/dist/web/assets/tension-BHvWG5ru.ogg +0 -0
- package/dist/web/assets/tension-bass-4G-2qA9W.ogg +0 -0
- package/dist/web/assets/tension-drums-D7sdehJr.ogg +0 -0
- package/dist/web/assets/tension-harmony-FyPldmLb.ogg +0 -0
- package/dist/web/assets/tension-lead-C5uoFMR8.ogg +0 -0
- package/dist/web/assets/why-clock-Dzs1A_ym.ogg +0 -0
- package/dist/web/favicon.svg +1 -0
- package/dist/web/index.html +16 -0
- package/dist/web/licenses/OFL-Archivo.txt +93 -0
- package/dist/web/licenses/OFL-DelaGothic.txt +93 -0
- package/dist/web/licenses/OFL-MartianMono.txt +93 -0
- package/package.json +63 -6
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { lintText } from '../report/copy-lint.js';
|
|
2
|
+
import { sanitizeShortLabel } from '../report/validators.js';
|
|
3
|
+
import { addDays, calendarWindow, codingDate, computeActiveTime, dailyActiveMinutes, datesBetween, dayDistance, localParts, monday } from './time.js';
|
|
4
|
+
export const HARNESS_NAMES = {
|
|
5
|
+
'claude-code': 'Claude Code', 'codex-cli': 'Codex CLI', opencode: 'OpenCode', 'gemini-cli': 'Gemini CLI',
|
|
6
|
+
'cursor-ide': 'Cursor', cline: 'Cline', 'roo-code': 'Roo Code', 'pi-agent': 'Pi Agent', aider: 'Aider',
|
|
7
|
+
};
|
|
8
|
+
export const ABSENT = {
|
|
9
|
+
humanPromptTimestamps: 'absent', agentRequestTimestamps: 'absent', tokenBreakdown: 'absent', cacheTokens: 'absent',
|
|
10
|
+
reasoningTokens: 'absent', modelIds: 'absent', toolNames: 'absent', toolErrors: 'absent',
|
|
11
|
+
subagentSpawns: 'absent', compactions: 'absent', interrupts: 'absent',
|
|
12
|
+
};
|
|
13
|
+
export const NEVER_READ = ['Prompt text', 'Response text', 'Source code and diffs', 'Tool arguments and results', 'Commit messages', 'Credentials'];
|
|
14
|
+
export function safeLabel(raw, fallback, maxLen = 24) {
|
|
15
|
+
const label = sanitizeShortLabel(raw, fallback, maxLen);
|
|
16
|
+
return /[!]|\b(?:level up|vibe coder|beast mode|10x|shipped|frustrated)\b/i.test(label) || lintText(label, '').length ? fallback : label;
|
|
17
|
+
}
|
|
18
|
+
export function groupBy(items, key) {
|
|
19
|
+
const groups = new Map();
|
|
20
|
+
for (const item of items) {
|
|
21
|
+
const id = key(item);
|
|
22
|
+
const bucket = groups.get(id) ?? [];
|
|
23
|
+
bucket.push(item);
|
|
24
|
+
groups.set(id, bucket);
|
|
25
|
+
}
|
|
26
|
+
return groups;
|
|
27
|
+
}
|
|
28
|
+
export function lowerBound(items, value, key) {
|
|
29
|
+
let lo = 0, hi = items.length;
|
|
30
|
+
while (lo < hi) {
|
|
31
|
+
const mid = (lo + hi) >>> 1;
|
|
32
|
+
if (key(items[mid]) < value)
|
|
33
|
+
lo = mid + 1;
|
|
34
|
+
else
|
|
35
|
+
hi = mid;
|
|
36
|
+
}
|
|
37
|
+
return lo;
|
|
38
|
+
}
|
|
39
|
+
export function fnv1a(text, seed = 0x811c9dc5) {
|
|
40
|
+
for (let i = 0; i < text.length; i++)
|
|
41
|
+
seed = Math.imul(seed ^ text.charCodeAt(i), 0x01000193);
|
|
42
|
+
return seed >>> 0;
|
|
43
|
+
}
|
|
44
|
+
export function mulberry32(seed) {
|
|
45
|
+
return () => {
|
|
46
|
+
seed = (seed + 0x6d2b79f5) | 0;
|
|
47
|
+
let x = Math.imul(seed ^ (seed >>> 15), seed | 1);
|
|
48
|
+
x ^= x + Math.imul(x ^ (x >>> 7), x | 61);
|
|
49
|
+
return ((x ^ (x >>> 14)) >>> 0) / 0x1_0000_0000;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export const pct = (fraction) => `${fraction === 1 ? 100 : Math.min(99, Number((fraction * 100).toFixed(fraction < 0.01 ? 1 : 0)))}%`;
|
|
53
|
+
export function estimate(value) {
|
|
54
|
+
if (!Number.isFinite(value) || value === 0)
|
|
55
|
+
return '0';
|
|
56
|
+
const sign = value < 0 ? '-' : '';
|
|
57
|
+
const abs = Math.abs(value);
|
|
58
|
+
if (abs < 0.0001)
|
|
59
|
+
return `${sign}<0.0001`;
|
|
60
|
+
const rounded = Number(abs.toPrecision(2));
|
|
61
|
+
if (rounded >= 1000)
|
|
62
|
+
return `${sign}${Math.round(rounded).toLocaleString('en-US')}`;
|
|
63
|
+
const decimals = Math.max(0, 1 - Math.floor(Math.log10(rounded)));
|
|
64
|
+
const formatted = rounded.toFixed(decimals);
|
|
65
|
+
return `${sign}${decimals > 0 ? formatted.replace(/(\.\d*?[1-9])0+$|\.0+$/, '$1') : formatted}`;
|
|
66
|
+
}
|
|
67
|
+
export function formatCompactTokens(value) {
|
|
68
|
+
if (!Number.isFinite(value) || value <= 0)
|
|
69
|
+
return '0';
|
|
70
|
+
if (value >= 1_000_000_000)
|
|
71
|
+
return `${(value / 1_000_000_000).toFixed(1).replace(/\.0$/, '')}B`;
|
|
72
|
+
if (value >= 1_000_000)
|
|
73
|
+
return `${(value / 1_000_000).toFixed(1).replace(/\.0$/, '')}M`;
|
|
74
|
+
if (value >= 1_000)
|
|
75
|
+
return `${(value / 1_000).toFixed(1).replace(/\.0$/, '')}K`;
|
|
76
|
+
return Math.round(value).toLocaleString('en-US');
|
|
77
|
+
}
|
|
78
|
+
export function formatDuration(minutes) {
|
|
79
|
+
if (!Number.isFinite(minutes) || minutes <= 0)
|
|
80
|
+
return '0m';
|
|
81
|
+
const total = Math.round(minutes);
|
|
82
|
+
if (total < 60)
|
|
83
|
+
return `${total}m`;
|
|
84
|
+
const h = Math.floor(total / 60);
|
|
85
|
+
const m = total % 60;
|
|
86
|
+
return m ? `${h}h ${m}m` : `${h}h`;
|
|
87
|
+
}
|
|
88
|
+
const SHORT_MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
89
|
+
export function formatShortDate(isoDate) {
|
|
90
|
+
const parts = isoDate.split('-');
|
|
91
|
+
if (parts.length !== 3)
|
|
92
|
+
return isoDate;
|
|
93
|
+
const month = SHORT_MONTHS[Number(parts[1]) - 1];
|
|
94
|
+
const day = Number(parts[2]);
|
|
95
|
+
return month && Number.isFinite(day) ? `${month} ${day}` : isoDate;
|
|
96
|
+
}
|
|
97
|
+
export function formatUsd(usd) {
|
|
98
|
+
if (!Number.isFinite(usd) || usd <= 0)
|
|
99
|
+
return '≈ $0.00';
|
|
100
|
+
if (usd < 100)
|
|
101
|
+
return `≈ $${usd.toFixed(2)}`;
|
|
102
|
+
return `≈ $${estimate(usd)}`;
|
|
103
|
+
}
|
|
104
|
+
export const mean = (values) => values.length ? values.reduce((a, b) => a + b, 0) / values.length : 0;
|
|
105
|
+
export function quantile(values, p) {
|
|
106
|
+
if (!values.length)
|
|
107
|
+
return 0;
|
|
108
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
109
|
+
const i = (sorted.length - 1) * p;
|
|
110
|
+
const lo = Math.floor(i);
|
|
111
|
+
return sorted[lo] + (sorted[Math.ceil(i)] - sorted[lo]) * (i - lo);
|
|
112
|
+
}
|
|
113
|
+
export const median = (values) => quantile(values, 0.5);
|
|
114
|
+
const health = (s) => s.linesSeen > 0 ? s.linesSkipped / s.linesSeen : 0;
|
|
115
|
+
export function prepareDataset(dataset, generatedAtMs) {
|
|
116
|
+
const { year, timezone } = dataset;
|
|
117
|
+
const bounds = calendarWindow(year, timezone);
|
|
118
|
+
const inWindow = (ts) => ts >= bounds.start && ts < bounds.end;
|
|
119
|
+
const sessions = dataset.sessions.filter((s) => s.startTsMs < bounds.end && s.endTsMs >= bounds.start)
|
|
120
|
+
.map((s) => ({ ...s, startTsMs: Math.max(s.startTsMs, bounds.start), endTsMs: Math.min(s.endTsMs, bounds.end - 1) }))
|
|
121
|
+
.sort((a, b) => a.startTsMs - b.startTsMs || a.sessionId.localeCompare(b.sessionId));
|
|
122
|
+
const sessionMap = new Map(sessions.map((s) => [s.sessionId, s]));
|
|
123
|
+
const rootIds = new Map();
|
|
124
|
+
const rootId = (sessionId) => {
|
|
125
|
+
const visited = new Set();
|
|
126
|
+
let id = sessionId;
|
|
127
|
+
while (!visited.has(id)) {
|
|
128
|
+
const cached = rootIds.get(id);
|
|
129
|
+
if (cached !== undefined) {
|
|
130
|
+
id = cached;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
visited.add(id);
|
|
134
|
+
const parent = sessionMap.get(id)?.parentSessionId;
|
|
135
|
+
if (!parent || !sessionMap.has(parent))
|
|
136
|
+
break;
|
|
137
|
+
id = parent;
|
|
138
|
+
}
|
|
139
|
+
for (const child of visited)
|
|
140
|
+
rootIds.set(child, id);
|
|
141
|
+
return id;
|
|
142
|
+
};
|
|
143
|
+
const clip = (items) => items.filter((e) => inWindow(e.tsMs) && sessionMap.has(e.sessionId)).sort((a, b) => a.tsMs - b.tsMs || a.sessionId.localeCompare(b.sessionId));
|
|
144
|
+
const uniqueRequests = new Map();
|
|
145
|
+
for (const request of dataset.agentRequests) {
|
|
146
|
+
if (!request.dedupeKey)
|
|
147
|
+
continue;
|
|
148
|
+
const id = `${request.harness}:${request.dedupeKey}`;
|
|
149
|
+
const prior = uniqueRequests.get(id);
|
|
150
|
+
const rank = (r) => r.output + r.inputUncached + r.cacheRead + r.cacheWrite5m + r.cacheWrite1h;
|
|
151
|
+
if (!prior || rank(request) > rank(prior) ||
|
|
152
|
+
(rank(request) === rank(prior) && (request.tsMs < prior.tsMs ||
|
|
153
|
+
(request.tsMs === prior.tsMs && request.sessionId < prior.sessionId))))
|
|
154
|
+
uniqueRequests.set(id, request);
|
|
155
|
+
}
|
|
156
|
+
const agentRequests = clip([...uniqueRequests.values(), ...dataset.agentRequests.filter((r) => !r.dedupeKey)]);
|
|
157
|
+
const humanPrompts = clip(dataset.humanPrompts).filter((p) => !sessionMap.get(p.sessionId)?.isSubagent);
|
|
158
|
+
const toolCalls = clip(dataset.toolCalls);
|
|
159
|
+
const compactions = clip(dataset.compactions);
|
|
160
|
+
const interrupts = clip(dataset.interrupts);
|
|
161
|
+
const activity = [...humanPrompts, ...agentRequests, ...toolCalls];
|
|
162
|
+
const timed = new Set(activity.map((e) => e.sessionId));
|
|
163
|
+
const sessionStarts = sessions.map((s) => ({ tsMs: s.startTsMs, sessionId: s.sessionId, harness: s.harness }));
|
|
164
|
+
const active = computeActiveTime([...activity, ...sessionStarts.filter((s) => !timed.has(s.sessionId))], bounds);
|
|
165
|
+
const localCache = new Map();
|
|
166
|
+
const local = (ts) => {
|
|
167
|
+
const cached = localCache.get(ts);
|
|
168
|
+
if (cached)
|
|
169
|
+
return cached;
|
|
170
|
+
const value = localParts(ts, timezone);
|
|
171
|
+
if (localCache.size >= 65_536)
|
|
172
|
+
localCache.clear();
|
|
173
|
+
localCache.set(ts, value);
|
|
174
|
+
return value;
|
|
175
|
+
};
|
|
176
|
+
const sourceMap = new Map(dataset.summaries.map((s) => [s.candidateId, [s]]));
|
|
177
|
+
const summariesByHarness = groupBy(dataset.summaries, (s) => s.harness);
|
|
178
|
+
const sources = (session) => sourceMap.get(session.sourceCandidateId) ?? summariesByHarness.get(session.harness) ?? [];
|
|
179
|
+
const inferred = new Map();
|
|
180
|
+
if (dataset.summaries.length === 0 || sessions.some((s) => sources(s).length === 0)) {
|
|
181
|
+
const infer = (events, key) => {
|
|
182
|
+
for (const e of events) {
|
|
183
|
+
const value = inferred.get(e.sessionId) ?? { ...ABSENT };
|
|
184
|
+
value[key] = 'present';
|
|
185
|
+
inferred.set(e.sessionId, value);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
infer(humanPrompts, 'humanPromptTimestamps');
|
|
189
|
+
infer(agentRequests, 'agentRequestTimestamps');
|
|
190
|
+
infer(agentRequests.filter((r) => r.modelId && r.modelId !== 'unknown'), 'modelIds');
|
|
191
|
+
infer(agentRequests.filter((r) => r.inputUncached + r.output + r.cacheRead + r.cacheWrite5m + r.cacheWrite1h > 0), 'tokenBreakdown');
|
|
192
|
+
infer(agentRequests.filter((r) => r.cacheRead + r.cacheWrite5m + r.cacheWrite1h > 0), 'cacheTokens');
|
|
193
|
+
infer(agentRequests.filter((r) => r.reasoning > 0), 'reasoningTokens');
|
|
194
|
+
infer(toolCalls, 'toolNames');
|
|
195
|
+
infer(toolCalls.filter((t) => t.isError !== null), 'toolErrors');
|
|
196
|
+
infer([...toolCalls.filter((t) => t.isSubagentSpawn), ...sessions.filter((s) => s.isSubagent)], 'subagentSpawns');
|
|
197
|
+
infer(compactions, 'compactions');
|
|
198
|
+
infer(interrupts, 'interrupts');
|
|
199
|
+
}
|
|
200
|
+
const capabilityCache = new Map();
|
|
201
|
+
const trendCache = new Map();
|
|
202
|
+
const capability = (id, key) => {
|
|
203
|
+
const session = sessionMap.get(id);
|
|
204
|
+
const summaries = session ? sources(session) : [];
|
|
205
|
+
if (!summaries.length)
|
|
206
|
+
return inferred.get(id)?.[key] ?? 'absent';
|
|
207
|
+
const cacheKey = `${session.sourceCandidateId || session.harness}\0${key}`;
|
|
208
|
+
const cached = capabilityCache.get(cacheKey);
|
|
209
|
+
if (cached !== undefined)
|
|
210
|
+
return cached;
|
|
211
|
+
const flags = summaries.map((s) => s.capabilities[key] === 'present' && health(s) > 0.05 ? 'partial' : s.capabilities[key]);
|
|
212
|
+
const status = flags.every((f) => f === 'present') ? 'present'
|
|
213
|
+
: flags.every((f) => f === 'absent') ? 'absent' : 'partial';
|
|
214
|
+
capabilityCache.set(cacheKey, status);
|
|
215
|
+
return status;
|
|
216
|
+
};
|
|
217
|
+
const trendCovered = (id, key) => {
|
|
218
|
+
const session = sessionMap.get(id);
|
|
219
|
+
if (!session)
|
|
220
|
+
return false;
|
|
221
|
+
const summaries = sources(session);
|
|
222
|
+
if (!summaries.length)
|
|
223
|
+
return (inferred.get(id)?.[key] ?? 'absent') !== 'absent';
|
|
224
|
+
const cacheKey = `${session.sourceCandidateId || session.harness}\0${key}`;
|
|
225
|
+
const cached = trendCache.get(cacheKey);
|
|
226
|
+
if (cached !== undefined)
|
|
227
|
+
return cached;
|
|
228
|
+
const covered = summaries.every((s) => s.capabilities[key] !== 'absent' && health(s) <= 0.25);
|
|
229
|
+
trendCache.set(cacheKey, covered);
|
|
230
|
+
return covered;
|
|
231
|
+
};
|
|
232
|
+
const coverage = (key) => {
|
|
233
|
+
if (!sessions.length)
|
|
234
|
+
return { full: 0, usable: 0 };
|
|
235
|
+
const states = sessions.map((s) => capability(s.sessionId, key));
|
|
236
|
+
return { full: states.filter((s) => s === 'present').length / sessions.length, usable: states.filter((s) => s !== 'absent').length / sessions.length };
|
|
237
|
+
};
|
|
238
|
+
const capabilities = { ...ABSENT };
|
|
239
|
+
for (const key of Object.keys(capabilities)) {
|
|
240
|
+
const { full, usable } = coverage(key);
|
|
241
|
+
capabilities[key] = full >= 0.9 ? 'present' : usable >= 0.1 ? 'partial' : 'absent';
|
|
242
|
+
}
|
|
243
|
+
const events = [...sessionStarts, ...activity, ...compactions, ...interrupts].sort((a, b) => a.tsMs - b.tsMs);
|
|
244
|
+
const eventsByHarness = groupBy(events, (e) => e.harness);
|
|
245
|
+
const sessionsByHarness = groupBy(sessions.filter((s) => !s.isSubagent), (s) => s.harness);
|
|
246
|
+
const stamps = [...events, ...sessions.map((s) => ({ tsMs: s.endTsMs, harness: s.harness }))];
|
|
247
|
+
const runDate = generatedAtMs === undefined ? null : local(generatedAtMs).date;
|
|
248
|
+
const perHarness = [...groupBy(stamps, (e) => e.harness)]
|
|
249
|
+
.sort(([a], [b]) => a.localeCompare(b)).map(([harness, items]) => {
|
|
250
|
+
const dates = [...new Set(items.map((e) => local(e.tsMs).date))].sort();
|
|
251
|
+
const startDate = dates[0], endDate = dates.at(-1);
|
|
252
|
+
const observed = eventsByHarness.get(harness) ?? [];
|
|
253
|
+
const activeDays = new Set(observed.map((e) => local(e.tsMs).date)).size;
|
|
254
|
+
const reported = (summariesByHarness.get(harness) ?? []).some((s) => s.likelyRetentionTruncated);
|
|
255
|
+
const age = runDate ? dayDistance(startDate, runDate) : Infinity;
|
|
256
|
+
const defaultRetention = harness === 'claude-code' && Math.abs(age - 30) <= 3;
|
|
257
|
+
const weeks = datesBetween(startDate, addDays(endDate, -6), 7);
|
|
258
|
+
const weekActivity = weeks.map(() => 0);
|
|
259
|
+
for (const e of observed) {
|
|
260
|
+
const index = Math.floor(dayDistance(startDate, local(e.tsMs).date) / 7);
|
|
261
|
+
if (index < weeks.length)
|
|
262
|
+
weekActivity[index]++;
|
|
263
|
+
}
|
|
264
|
+
const cliff = age <= 45 && age >= 0 && weeks.length >= 4 && activeDays >= 14
|
|
265
|
+
&& median(weekActivity) > 0 && weekActivity[0] >= median(weekActivity) / 2;
|
|
266
|
+
const likelyTruncated = reported || defaultRetention || cliff;
|
|
267
|
+
return {
|
|
268
|
+
harness, displayName: HARNESS_NAMES[harness], startDate, endDate, activeDays,
|
|
269
|
+
sessions: sessionsByHarness.get(harness)?.length ?? 0, likelyTruncated,
|
|
270
|
+
...(likelyTruncated ? { retentionNote: defaultRetention || (reported && harness === 'claude-code' && age > 0 && age <= 45)
|
|
271
|
+
? 'This window starts near the default 30-day Claude Code transcript-retention limit.'
|
|
272
|
+
: 'Earlier records may have been removed by local retention settings.' } : {}),
|
|
273
|
+
};
|
|
274
|
+
});
|
|
275
|
+
const dates = [...new Set(stamps.map((e) => local(e.tsMs).date))].sort();
|
|
276
|
+
const startDate = dates[0] ?? null, endDate = dates.at(-1) ?? null;
|
|
277
|
+
const days = startDate && endDate ? datesBetween(startDate, endDate) : [];
|
|
278
|
+
const isFullYear = startDate === `${year}-01-01` && endDate === `${year}-12-31` && !perHarness.some((h) => h.likelyTruncated);
|
|
279
|
+
const truncated = perHarness.filter((h) => h.likelyTruncated).map((h) => h.displayName);
|
|
280
|
+
const degraded = dataset.summaries.some((s) => health(s) > 0.05);
|
|
281
|
+
const capturedWindow = {
|
|
282
|
+
startDate, endDate, daysSpanned: days.length, activeDays: new Set(events.map((e) => local(e.tsMs).date)).size, isFullYear,
|
|
283
|
+
titleLabel: startDate ? (isFullYear ? `1 JAN – 31 DEC ${year}` : `Captured Window · ${startDate} – ${endDate}`) : 'No recorder recovered',
|
|
284
|
+
disclosure: startDate ? [
|
|
285
|
+
'Counts describe the records recovered for this window.',
|
|
286
|
+
truncated.length ? `Local retention may have shortened the records from ${truncated.join(', ')}.` : '',
|
|
287
|
+
degraded ? 'Some recorder lines were skipped. The data receipt shows the affected sources.' : '',
|
|
288
|
+
].filter(Boolean).join(' ') : 'The absence of data is also data. Check local retention or point --input at a recorder directory.',
|
|
289
|
+
perHarness,
|
|
290
|
+
};
|
|
291
|
+
const parentSessions = sessions.filter((s) => !s.isSubagent);
|
|
292
|
+
const codingMinutes = dailyActiveMinutes(active.wallSpans, timezone, 240);
|
|
293
|
+
const firstWeek = startDate ? monday(startDate) : null;
|
|
294
|
+
const weeks = firstWeek && endDate ? datesBetween(firstWeek, monday(endDate), 7) : [];
|
|
295
|
+
const weekIndexByDate = new Map();
|
|
296
|
+
const weekIndex = (ts) => {
|
|
297
|
+
if (firstWeek === null)
|
|
298
|
+
return 0;
|
|
299
|
+
const date = local(ts).date;
|
|
300
|
+
let idx = weekIndexByDate.get(date);
|
|
301
|
+
if (idx === undefined) {
|
|
302
|
+
idx = dayDistance(firstWeek, monday(date)) / 7;
|
|
303
|
+
weekIndexByDate.set(date, idx);
|
|
304
|
+
}
|
|
305
|
+
return idx;
|
|
306
|
+
};
|
|
307
|
+
let seed = fnv1a(`${year}|${timezone}|${parentSessions.length}|${humanPrompts.length}|${agentRequests.length}|${toolCalls.length}`);
|
|
308
|
+
for (const s of parentSessions)
|
|
309
|
+
seed = fnv1a(`${s.startTsMs}:${s.endTsMs}:${s.harness}`, seed);
|
|
310
|
+
for (const r of agentRequests)
|
|
311
|
+
seed = fnv1a(`${r.tsMs}:${r.output}`, seed);
|
|
312
|
+
for (const c of compactions)
|
|
313
|
+
seed = fnv1a(`${c.tsMs}`, seed);
|
|
314
|
+
for (const i of interrupts)
|
|
315
|
+
seed = fnv1a(`${i.tsMs}`, seed);
|
|
316
|
+
return {
|
|
317
|
+
dataset, year, timezone, bounds, sessions, parentSessions, sessionMap, rootId, humanPrompts, agentRequests, toolCalls,
|
|
318
|
+
compactions, interrupts, active, events, local, capability, coverage, capabilities, trendCovered, capturedWindow,
|
|
319
|
+
days, codingMinutes, codingDate: (ts) => codingDate(local(ts)), weeks, weekIndex, seed,
|
|
320
|
+
};
|
|
321
|
+
}
|