coauthored 0.0.0-stage → 1.0.1

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.
Files changed (130) hide show
  1. package/LICENSE +21 -0
  2. package/PRIVACY.md +107 -0
  3. package/README.md +113 -3
  4. package/THIRD_PARTY_LICENSES.md +105 -0
  5. package/dist/cli/analytics/anchors.js +39 -0
  6. package/dist/cli/analytics/archetypes.js +193 -0
  7. package/dist/cli/analytics/content/analyzer.js +945 -0
  8. package/dist/cli/analytics/content/classify.js +115 -0
  9. package/dist/cli/analytics/content/demo-corpus.js +301 -0
  10. package/dist/cli/analytics/content/sketch.js +54 -0
  11. package/dist/cli/analytics/dataset.js +321 -0
  12. package/dist/cli/analytics/demo-fixtures.js +531 -0
  13. package/dist/cli/analytics/fdr.js +183 -0
  14. package/dist/cli/analytics/helicorder.js +66 -0
  15. package/dist/cli/analytics/insights.js +589 -0
  16. package/dist/cli/analytics/models.js +75 -0
  17. package/dist/cli/analytics/pricing.js +121 -0
  18. package/dist/cli/analytics/probable-cause.js +115 -0
  19. package/dist/cli/analytics/report-builder.js +162 -0
  20. package/dist/cli/analytics/statistics.js +91 -0
  21. package/dist/cli/analytics/time.js +252 -0
  22. package/dist/cli/cli/args.js +105 -0
  23. package/dist/cli/cli/browser.js +71 -0
  24. package/dist/cli/cli/index.js +20 -0
  25. package/dist/cli/cli/main.js +520 -0
  26. package/dist/cli/cli/phrase-review.js +78 -0
  27. package/dist/cli/cli/server.js +481 -0
  28. package/dist/cli/cli/terminal.js +363 -0
  29. package/dist/cli/ingest/adapters/aider.js +116 -0
  30. package/dist/cli/ingest/adapters/claude-code.js +139 -0
  31. package/dist/cli/ingest/adapters/cline-roo.js +89 -0
  32. package/dist/cli/ingest/adapters/codex-cli.js +240 -0
  33. package/dist/cli/ingest/adapters/content.js +99 -0
  34. package/dist/cli/ingest/adapters/cursor-ide.js +149 -0
  35. package/dist/cli/ingest/adapters/gemini-cli.js +208 -0
  36. package/dist/cli/ingest/adapters/index.js +18 -0
  37. package/dist/cli/ingest/adapters/opencode.js +203 -0
  38. package/dist/cli/ingest/adapters/pi-agent.js +85 -0
  39. package/dist/cli/ingest/adapters/shared.js +484 -0
  40. package/dist/cli/ingest/content-sink.js +31 -0
  41. package/dist/cli/ingest/discovery.js +50 -0
  42. package/dist/cli/ingest/message-digests.js +61 -0
  43. package/dist/cli/ingest/pipeline.js +155 -0
  44. package/dist/cli/ingest/safe-fs.js +284 -0
  45. package/dist/cli/ingest/sqlite-stage.js +139 -0
  46. package/dist/cli/ingest/time-window.js +34 -0
  47. package/dist/cli/ingest/tool-map.js +24 -0
  48. package/dist/cli/ingest/types.js +1 -0
  49. package/dist/cli/ingest/worker.js +97 -0
  50. package/dist/cli/report/content/emoji-names.js +3956 -0
  51. package/dist/cli/report/content/insights.js +41 -0
  52. package/dist/cli/report/content/lexicons.js +112 -0
  53. package/dist/cli/report/content/policy.js +77 -0
  54. package/dist/cli/report/content/redact.js +164 -0
  55. package/dist/cli/report/content/stopwords.js +8848 -0
  56. package/dist/cli/report/content/suppression.js +2617 -0
  57. package/dist/cli/report/content/validate.js +152 -0
  58. package/dist/cli/report/copy-lint.js +105 -0
  59. package/dist/cli/report/share.js +132 -0
  60. package/dist/cli/report/types.js +1 -0
  61. package/dist/cli/report/validators.js +334 -0
  62. package/dist/web/assets/Archivo-VF-BohoA-Sn.woff2 +0 -0
  63. package/dist/web/assets/DelaGothicOne-subset-CpoJGhTq.woff2 +0 -0
  64. package/dist/web/assets/Film-BkhZFxG9.css +1 -0
  65. package/dist/web/assets/MartianMono-VF-CmJ1nXx9.woff2 +0 -0
  66. package/dist/web/assets/app-Dw1a5h5V.js +38 -0
  67. package/dist/web/assets/bricolage-grotesque-latin-700-normal-gtcctNPv.woff2 +0 -0
  68. package/dist/web/assets/bricolage-grotesque-latin-800-normal-J50vIsBe.woff2 +0 -0
  69. package/dist/web/assets/chorus-D7bfON5Z.ogg +0 -0
  70. package/dist/web/assets/chorus-bass-CBTKpMv_.ogg +0 -0
  71. package/dist/web/assets/chorus-drums-BOzgLSoq.ogg +0 -0
  72. package/dist/web/assets/chorus-harmony-DnJYs_tp.ogg +0 -0
  73. package/dist/web/assets/chorus-lead-CFpg5DC1.ogg +0 -0
  74. package/dist/web/assets/chunk-BNfsY4o8.js +1 -0
  75. package/dist/web/assets/chunk-BSm8IhPY.js +1 -0
  76. package/dist/web/assets/chunk-Bi6EQAkf.js +1 -0
  77. package/dist/web/assets/chunk-D6HyoJCB.js +46 -0
  78. package/dist/web/assets/chunk-DrEayQLY.js +1 -0
  79. package/dist/web/assets/chunk-V3YGpFIw.js +1 -0
  80. package/dist/web/assets/chunk-XGhNFWse.js +1 -0
  81. package/dist/web/assets/dialogue-card-A5zmbNhu.ogg +0 -0
  82. package/dist/web/assets/groove-bass-BFNelLKi.ogg +0 -0
  83. package/dist/web/assets/groove-drums-BY1SBntR.ogg +0 -0
  84. package/dist/web/assets/groove-harmony-C0CrBzu3.ogg +0 -0
  85. package/dist/web/assets/groove-lead-CEYPzm5U.ogg +0 -0
  86. package/dist/web/assets/groove-ln-zQmTb.ogg +0 -0
  87. package/dist/web/assets/guess-high-CL6mF18x.ogg +0 -0
  88. package/dist/web/assets/guess-low-C3UnKayZ.ogg +0 -0
  89. package/dist/web/assets/higher-BevsMIWl.ogg +0 -0
  90. package/dist/web/assets/identity-0EPS3msD.ogg +0 -0
  91. package/dist/web/assets/index-DpT0dtHc.css +1 -0
  92. package/dist/web/assets/intro-DeRh6kUx.ogg +0 -0
  93. package/dist/web/assets/intro-bass-D63IPU0H.ogg +0 -0
  94. package/dist/web/assets/intro-drums-Dt9QO534.ogg +0 -0
  95. package/dist/web/assets/intro-harmony-DBsMG9jJ.ogg +0 -0
  96. package/dist/web/assets/intro-lead-DWcWS1ia.ogg +0 -0
  97. package/dist/web/assets/jar-coin-rtCvspuq.ogg +0 -0
  98. package/dist/web/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  99. package/dist/web/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
  100. package/dist/web/assets/ledger-tick-C1rQgQGX.ogg +0 -0
  101. package/dist/web/assets/night-B_bMOZcf.ogg +0 -0
  102. package/dist/web/assets/night-bass-B-7Ay9ME.ogg +0 -0
  103. package/dist/web/assets/night-drums-zEtqWXX3.ogg +0 -0
  104. package/dist/web/assets/night-harmony-C5Ix2yce.ogg +0 -0
  105. package/dist/web/assets/night-lead-B7KMlRyj.ogg +0 -0
  106. package/dist/web/assets/ourturn-DX78hTEz.ogg +0 -0
  107. package/dist/web/assets/plus-jakarta-sans-latin-400-normal-Dhut76fR.woff2 +0 -0
  108. package/dist/web/assets/plus-jakarta-sans-latin-500-normal-Bf-nb4oT.woff2 +0 -0
  109. package/dist/web/assets/plus-jakarta-sans-latin-600-normal-DLTa1BUW.woff2 +0 -0
  110. package/dist/web/assets/plus-jakarta-sans-latin-700-normal-CfpNZvy6.woff2 +0 -0
  111. package/dist/web/assets/reveal-BmWAGHih.ogg +0 -0
  112. package/dist/web/assets/review-split-Dac4zagw.ogg +0 -0
  113. package/dist/web/assets/shutter-uhz2Y9S9.ogg +0 -0
  114. package/dist/web/assets/soclose-CiUFR5St.ogg +0 -0
  115. package/dist/web/assets/stinger-TnnzHAMN.ogg +0 -0
  116. package/dist/web/assets/stomp-mzIk4cGm.ogg +0 -0
  117. package/dist/web/assets/syne-latin-700-normal-AF3Rs61n.woff2 +0 -0
  118. package/dist/web/assets/syne-latin-800-normal-EehdNYzx.woff2 +0 -0
  119. package/dist/web/assets/tension-BHvWG5ru.ogg +0 -0
  120. package/dist/web/assets/tension-bass-4G-2qA9W.ogg +0 -0
  121. package/dist/web/assets/tension-drums-D7sdehJr.ogg +0 -0
  122. package/dist/web/assets/tension-harmony-FyPldmLb.ogg +0 -0
  123. package/dist/web/assets/tension-lead-C5uoFMR8.ogg +0 -0
  124. package/dist/web/assets/why-clock-Dzs1A_ym.ogg +0 -0
  125. package/dist/web/favicon.svg +1 -0
  126. package/dist/web/index.html +16 -0
  127. package/dist/web/licenses/OFL-Archivo.txt +93 -0
  128. package/dist/web/licenses/OFL-DelaGothic.txt +93 -0
  129. package/dist/web/licenses/OFL-MartianMono.txt +93 -0
  130. package/package.json +63 -6
@@ -0,0 +1,531 @@
1
+ import { buildDemoContent } from './content/demo-corpus.js';
2
+ import { ABSENT, groupBy, HARNESS_NAMES, mulberry32, NEVER_READ } from './dataset.js';
3
+ import { normalizeModelId } from './models.js';
4
+ import { buildWrappedReport } from './report-builder.js';
5
+ import { addDays, localTimestamp, MINUTE_MS } from './time.js';
6
+ const DEMO_GENERATED_AT = '2026-12-03T23:59:00.000Z';
7
+ export const DEMO_PROFILES = [
8
+ { id: 'night-owl', label: 'Night-Owl Power User', description: 'Late prompts, overlapping agents, and a busy compaction channel.' },
9
+ { id: 'polyglot', label: 'Polyglot Switcher', description: 'Four harnesses and a sustained midyear fleet change.' },
10
+ { id: 'starter', label: 'Starter', description: 'Seven early sessions and a preliminary flight recorder.' },
11
+ { id: 'specialist', label: 'Quiet Specialist', description: 'Long work sessions, a read-heavy tool mix, and extensive cache reuse.' },
12
+ { id: 'partial', label: 'Partial Metadata', description: 'A retention cliff, incomplete token coverage, and visible receipt diagnostics.' },
13
+ ];
14
+ const FULL = Object.fromEntries(Object.keys(ABSENT).map((key) => [key, 'present']));
15
+ const YEAR_START = '2026-01-01';
16
+ const plannedHarnesses = {
17
+ 'night-owl': ['claude-code', 'codex-cli'],
18
+ polyglot: ['claude-code', 'codex-cli', 'opencode', 'gemini-cli'],
19
+ starter: ['claude-code'],
20
+ specialist: ['claude-code'],
21
+ partial: ['claude-code', 'cursor-ide'],
22
+ };
23
+ export function getDemoDataset(profileId) {
24
+ const timezone = ({ 'night-owl': 'Asia/Tashkent', polyglot: 'America/New_York', starter: 'America/Los_Angeles',
25
+ specialist: 'Europe/London', partial: 'America/Chicago' })[profileId];
26
+ const random = mulberry32(20261203 + DEMO_PROFILES.findIndex((p) => p.id === profileId) * 997);
27
+ const gauss = () => (random() + random() + random() - 1.5) * 1.15;
28
+ const d = {
29
+ year: 2026, timezone, sessions: [], humanPrompts: [], agentRequests: [], toolCalls: [],
30
+ compactions: [], interrupts: [], summaries: [],
31
+ };
32
+ const harnesses = plannedHarnesses[profileId];
33
+ const candidateId = (harness) => `rec_demo_${harnesses.indexOf(harness) + 1}`;
34
+ const session = (s) => {
35
+ let date = s.date;
36
+ let startMin = Math.round(s.start);
37
+ while (startMin >= 1440) {
38
+ startMin -= 1440;
39
+ date = addDays(date, 1);
40
+ }
41
+ while (startMin < 0) {
42
+ startMin += 1440;
43
+ date = addDays(date, -1);
44
+ }
45
+ if (date < YEAR_START || date > '2026-12-03')
46
+ return;
47
+ const start = localTimestamp(date, startMin, timezone);
48
+ const addSession = (begin, duration, parentSessionId) => {
49
+ const entry = {
50
+ sessionId: `synthetic-${d.sessions.length + 1}`, harness: s.harness, projectHmac: `synthetic-project-${s.project}`,
51
+ sourceCandidateId: candidateId(s.harness), startTsMs: begin, endTsMs: begin + duration * MINUTE_MS,
52
+ isSubagent: parentSessionId !== undefined, ...(parentSessionId ? { parentSessionId } : {}),
53
+ };
54
+ d.sessions.push(entry);
55
+ return entry;
56
+ };
57
+ const parent = addSession(start, s.duration);
58
+ const at = (entry, minute) => ({
59
+ sessionId: entry.sessionId, harness: entry.harness, tsMs: entry.startTsMs + minute * MINUTE_MS,
60
+ });
61
+ const meta = normalizeModelId(s.model);
62
+ const windowSize = meta.contextWindowTokens ?? 200_000;
63
+ const compactionMinutes = [];
64
+ for (let i = 0; i < (s.compactions ?? 0); i++) {
65
+ compactionMinutes.push(Math.floor(s.duration * (0.34 + i * 0.22)));
66
+ }
67
+ const instrument = (entry, duration, compactionsForEntry) => {
68
+ const interval = s.cache === 'high' ? 7 : 5;
69
+ const steps = Math.max(1, Math.floor(duration / interval));
70
+ const noTokens = s.harness === 'cursor-ide';
71
+ const noCache = noTokens || s.cache === 'none';
72
+ const highCache = s.cache === 'high';
73
+ const baseErrorRate = s.errorRate ?? 0.11;
74
+ const unrecoveredShare = s.unrecoveredShare ?? 0.055;
75
+ let pendingRecoveryFamily = null;
76
+ let blockRecoveryCount = 0;
77
+ for (let minute = 0, index = 0; minute <= duration; minute += interval, index++) {
78
+ // Compute phase progress within the current context window (ramping up toward compaction or session end).
79
+ let phaseStart = 0;
80
+ let phaseEnd = Math.max(1, duration);
81
+ for (const cm of compactionsForEntry) {
82
+ if (minute <= cm) {
83
+ phaseEnd = cm;
84
+ break;
85
+ }
86
+ phaseStart = cm;
87
+ }
88
+ const phaseFrac = Math.min(1, Math.max(0, (minute - phaseStart) / Math.max(1, phaseEnd - phaseStart)));
89
+ const hitsCompaction = compactionsForEntry.some((cm) => cm === phaseEnd);
90
+ const peakFillFrac = hitsCompaction
91
+ ? 0.84 + random() * 0.10
92
+ : Math.min(0.76, 0.12 + (duration / 260) * 0.52 + random() * 0.08);
93
+ const fillFrac = (phaseStart > 0 ? 0.18 : 0.05) + phaseFrac * (peakFillFrac - (phaseStart > 0 ? 0.18 : 0.05));
94
+ const totalInput = noTokens ? 0 : Math.max(800, Math.round(windowSize * fillFrac * (0.85 + random() * 0.25)));
95
+ const baseOut = s.output ?? 280;
96
+ const output = noTokens ? 0 : Math.max(60, Math.round(baseOut * (0.65 + random() * 0.85)));
97
+ let uncached = 0;
98
+ let cacheRead = 0;
99
+ let cacheWrite5m = 0;
100
+ if (!noTokens) {
101
+ if (noCache) {
102
+ uncached = totalInput;
103
+ }
104
+ else if (highCache) {
105
+ // Varied 88-95% cache hit rate on specialist sessions (lower on initial prompt turn).
106
+ const hitRatio = index === 0 ? 0.72 + random() * 0.10 : 0.88 + random() * 0.075;
107
+ cacheRead = Math.round(totalInput * hitRatio);
108
+ uncached = Math.max(200, totalInput - cacheRead);
109
+ }
110
+ else {
111
+ const hitRatio = index === 0 ? 0.35 + random() * 0.25 : 0.74 + random() * 0.17;
112
+ cacheRead = Math.round(totalInput * hitRatio);
113
+ const remainder = Math.max(250, totalInput - cacheRead);
114
+ if (meta.provider === 'anthropic' && index % 5 === 0) {
115
+ cacheWrite5m = Math.round(remainder * 0.25);
116
+ uncached = remainder - cacheWrite5m;
117
+ }
118
+ else {
119
+ uncached = remainder;
120
+ }
121
+ }
122
+ }
123
+ d.agentRequests.push({
124
+ ...at(entry, minute), dedupeKey: `synthetic-request-${d.agentRequests.length + 1}`,
125
+ modelId: s.model, modelFamily: meta.family, provider: meta.provider, isSubagent: entry.isSubagent,
126
+ output, reasoning: noTokens ? 0 : Math.floor(output * (0.12 + random() * 0.48)),
127
+ inputUncached: uncached, cacheRead, cacheWrite5m, cacheWrite1h: 0,
128
+ ...(noTokens ? {} : { contextFillTokens: uncached + cacheRead + cacheWrite5m }),
129
+ });
130
+ if (!s.silent && s.tools.length && minute + 1 <= duration) {
131
+ let family;
132
+ let isError = false;
133
+ if (pendingRecoveryFamily) {
134
+ family = pendingRecoveryFamily;
135
+ pendingRecoveryFamily = null;
136
+ isError = false;
137
+ }
138
+ else if (blockRecoveryCount > 0) {
139
+ // Emit non-matching tool family after an unrecovered error so bounce-back stays realistic (~93-96%).
140
+ const alt = s.tools.find((f) => f !== 'execute') ?? 'plan';
141
+ family = alt;
142
+ blockRecoveryCount--;
143
+ isError = false;
144
+ }
145
+ else {
146
+ family = s.tools[(index + Math.floor(random() * 2)) % s.tools.length];
147
+ const hasRoomToRecover = minute + interval + 1 <= duration;
148
+ if (family === 'execute' && random() < baseErrorRate) {
149
+ isError = true;
150
+ if (hasRoomToRecover && random() >= unrecoveredShare) {
151
+ pendingRecoveryFamily = 'execute';
152
+ }
153
+ else {
154
+ blockRecoveryCount = 3;
155
+ }
156
+ }
157
+ else if (family === 'modify' && hasRoomToRecover && random() < baseErrorRate * 0.16) {
158
+ isError = true;
159
+ if (random() >= unrecoveredShare) {
160
+ pendingRecoveryFamily = 'modify';
161
+ }
162
+ }
163
+ }
164
+ d.toolCalls.push({ ...at(entry, minute + 1), toolFamily: family, isError, isSubagentSpawn: false });
165
+ }
166
+ }
167
+ };
168
+ instrument(parent, s.duration, compactionMinutes);
169
+ for (const minute of s.prompts) {
170
+ if (minute <= s.duration)
171
+ d.humanPrompts.push(at(parent, minute));
172
+ }
173
+ for (const cm of compactionMinutes) {
174
+ d.compactions.push({ ...at(parent, cm), trigger: 'auto' });
175
+ }
176
+ if (!s.silent && Number(parent.sessionId.split('-')[1]) % 29 === 0 && s.duration >= 15) {
177
+ d.interrupts.push(at(parent, Math.min(s.duration - 2, 9 + Math.floor(random() * 10))));
178
+ }
179
+ for (let i = 0; i < (s.children ?? 0); i++) {
180
+ const launch = Math.min(Math.max(8, s.duration - 12), 14 + i * 4 + Math.floor(random() * 6));
181
+ const childDuration = Math.max(12, Math.min(s.duration - launch, 52 + Math.floor(random() * 34)));
182
+ if (childDuration < 10)
183
+ continue;
184
+ const child = addSession(start + launch * MINUTE_MS, childDuration, parent.sessionId);
185
+ d.toolCalls.push({ ...at(parent, launch), toolFamily: 'delegate', isError: false, isSubagentSpawn: true });
186
+ instrument(child, childDuration, []);
187
+ }
188
+ };
189
+ switch (profileId) {
190
+ case 'night-owl': {
191
+ // Build an organic 337-day calendar (Jan 1 - Dec 3) with ~235 active days,
192
+ // a 14-day crunch streak in October, and a 7-day breather in August.
193
+ const totalDays = 336;
194
+ const activeDayIndices = [];
195
+ let streak = 0;
196
+ let offRun = 0;
197
+ for (let day = 0; day < totalDays; day++) {
198
+ // Explicit 7-day summer breather (Aug 13-19, days 224..230)
199
+ if (day >= 224 && day <= 230) {
200
+ streak = 0;
201
+ offRun++;
202
+ continue;
203
+ }
204
+ // Explicit 5-day spring breather (Apr 16-20, days 105..109)
205
+ if (day >= 105 && day <= 109) {
206
+ streak = 0;
207
+ offRun++;
208
+ continue;
209
+ }
210
+ // Explicit 14-day October crunch streak (Oct 10-23, days 282..295)
211
+ if (day >= 282 && day <= 295) {
212
+ activeDayIndices.push(day);
213
+ streak++;
214
+ offRun = 0;
215
+ continue;
216
+ }
217
+ // Keep streaks naturally bounded (<= 10 outside the Oct crunch) and rests <= 3 days.
218
+ if (day === 281 || day === 296) {
219
+ streak = 0;
220
+ offRun++;
221
+ continue;
222
+ }
223
+ let work = false;
224
+ if (streak >= 9)
225
+ work = false;
226
+ else if (offRun >= 3)
227
+ work = true;
228
+ else {
229
+ const dow = (day + 3) % 7; // 2026-01-01 is Thursday (3)
230
+ const prob = dow === 5 || dow === 6 ? 0.62 : 0.78;
231
+ work = random() < prob;
232
+ }
233
+ if (work) {
234
+ activeDayIndices.push(day);
235
+ streak++;
236
+ offRun = 0;
237
+ }
238
+ else {
239
+ streak = 0;
240
+ offRun++;
241
+ }
242
+ }
243
+ // Assign 820 sessions with natural weekly volume waves (quiet weeks vs crunch weeks).
244
+ const counts = activeDayIndices.map((day) => {
245
+ const wave = 1 + 0.35 * Math.sin(day / 19) + 0.2 * Math.cos(day / 7);
246
+ return Math.max(1, Math.round((2.6 + random() * 1.8) * wave));
247
+ });
248
+ let sum = counts.reduce((a, b) => a + b, 0);
249
+ let cursor = 0;
250
+ while (sum < 820) {
251
+ counts[cursor % counts.length]++;
252
+ sum++;
253
+ cursor += 7;
254
+ }
255
+ while (sum > 820) {
256
+ const idx = cursor % counts.length;
257
+ if (counts[idx] > 1) {
258
+ counts[idx]--;
259
+ sum--;
260
+ }
261
+ cursor += 5;
262
+ }
263
+ let emitted = 0;
264
+ const marathonIndex = 546;
265
+ for (let dIdx = 0; dIdx < activeDayIndices.length; dIdx++) {
266
+ const day = activeDayIndices[dIdx];
267
+ const date = addDays(YEAR_START, day);
268
+ const sessionsToday = counts[dIdx];
269
+ for (let k = 0; k < sessionsToday; k++) {
270
+ const i = emitted++;
271
+ const isMarathon = i === marathonIndex;
272
+ const codexProb = day < 90 ? 0.22 : day < 210 ? 0.28 : 0.24;
273
+ const harness = !isMarathon && random() < codexProb ? 'codex-cli' : 'claude-code';
274
+ // Realistic late-night circadian spread around 23:35 (resultantR ~ 0.65-0.75).
275
+ const isDaytimeOneOff = !isMarathon && random() < 0.14;
276
+ const start = isMarathon ? 1385
277
+ : isDaytimeOneOff ? 790 + gauss() * 140
278
+ : 1382 + gauss() * 145 + k * 14;
279
+ const duration = isMarathon ? 280 : Math.round(68 + random() * 72);
280
+ const model = harness === 'codex-cli'
281
+ ? (day < 65 ? 'gpt-5.2-codex' : day < 275 ? 'gpt-5.3-codex' : 'gpt-6.1-sol')
282
+ : (day < 55 ? 'claude-opus-4-5' : day < 265 ? 'claude-opus-4-6' : 'claude-opus-5-5');
283
+ const promptCount = isMarathon ? 7 : 3 + Math.floor(random() * 3);
284
+ const prompts = [];
285
+ for (let p = 0; p < promptCount; p++) {
286
+ prompts.push(Math.max(1, Math.round(((p + 0.5) / promptCount) * Math.min(duration - 5, 72) + random() * 6)));
287
+ }
288
+ const children = isMarathon ? 4 : random() < 0.42 ? 3 : random() < 0.78 ? 1 : 0;
289
+ const compactions = isMarathon ? 3 : duration >= 112 && random() < 0.55 ? (duration >= 130 ? 2 : 1) : 0;
290
+ session({
291
+ date, start, duration, harness, model, project: Math.floor(Math.pow(random(), 1.6) * 42),
292
+ prompts: [...new Set(prompts)].sort((a, b) => a - b),
293
+ tools: ['investigate', 'modify', 'execute', 'investigate', 'plan', 'execute', 'modify'],
294
+ children, compactions, output: isMarathon ? 1650 : 680,
295
+ errorRate: 0.13, unrecoveredShare: 0.012,
296
+ });
297
+ }
298
+ }
299
+ break;
300
+ }
301
+ case 'polyglot': {
302
+ // Realistic 46-week cadence (Jan 5 - Nov 22) with a 9-day August vacation,
303
+ // a 19-day October streak, genuine Q2->Q3 migration + turning point, and some subagents.
304
+ const vacationStart = '2026-08-03';
305
+ const vacationEnd = '2026-08-11'; // 9-day break
306
+ const streakStart = '2026-10-05';
307
+ const streakEnd = '2026-10-23'; // 19-day streak
308
+ for (let w = 0; w < 46; w++) {
309
+ const weekMonday = addDays('2026-01-05', w * 7);
310
+ const later = w >= 22;
311
+ // Organic weekly volume: 3-5 pre-turning-point, 8-13 post-turning-point (except vacation week).
312
+ const baseVol = later ? 9 + Math.floor(random() * 4) : 3 + Math.floor(random() * 3);
313
+ // Pick active days for this week with realistic rest days (no 169-day unbroken streak!).
314
+ const weekDays = [];
315
+ for (let dow = 0; dow < 7; dow++) {
316
+ const date = addDays(weekMonday, dow);
317
+ if (date >= vacationStart && date <= vacationEnd)
318
+ continue;
319
+ if (date >= streakStart && date <= streakEnd) {
320
+ weekDays.push(dow);
321
+ continue;
322
+ }
323
+ if (date === addDays(streakStart, -1) || date === addDays(streakEnd, 1))
324
+ continue;
325
+ // Normally work 3-5 days/week (skipping Sunday or Saturday regularly)
326
+ const workProb = later ? (dow === 6 ? 0.35 : dow === 5 ? 0.55 : 0.85) : (dow >= 5 ? 0.25 : 0.62);
327
+ if (random() < workProb)
328
+ weekDays.push(dow);
329
+ }
330
+ if (!weekDays.length)
331
+ continue;
332
+ // Ensure every week outside vacation has a realistic session count.
333
+ const volume = weekMonday >= vacationStart && weekMonday <= vacationEnd ? Math.min(2, weekDays.length) : baseVol;
334
+ for (let i = 0; i < volume; i++) {
335
+ const dow = weekDays[i % weekDays.length];
336
+ const date = addDays(weekMonday, dow);
337
+ const secondToday = i >= weekDays.length;
338
+ // Gradual Q2->Q3 migration around week 22: Claude/Codex -> OpenCode/Gemini CLI.
339
+ let harness;
340
+ if (!later) {
341
+ harness = random() < 0.28 ? 'codex-cli' : 'claude-code';
342
+ }
343
+ else if (w < 24) {
344
+ const r = random();
345
+ harness = r < 0.56 ? 'gemini-cli' : r < 0.80 ? 'opencode' : r < 0.92 ? 'claude-code' : 'codex-cli';
346
+ }
347
+ else {
348
+ const r = random();
349
+ harness = r < 0.62 ? 'gemini-cli' : r < 0.88 ? 'opencode' : r < 0.95 ? 'claude-code' : 'codex-cli';
350
+ }
351
+ // Twilight clock centered around 18:15 (minute 1095) with natural spread.
352
+ const start = 1065 + (secondToday ? 95 : 0) + gauss() * 85;
353
+ const duration = dow >= 5 ? Math.round(62 + random() * 44) : Math.round(28 + random() * 32);
354
+ const model = harness === 'claude-code'
355
+ ? (w < 8 ? 'claude-sonnet-4-5' : 'claude-sonnet-4-6')
356
+ : harness === 'codex-cli'
357
+ ? (w < 12 ? 'gpt-5.2-codex' : 'gpt-5.3-codex')
358
+ : harness === 'opencode'
359
+ ? 'gemini-3.1-pro-preview'
360
+ : 'gemini-3-flash-preview';
361
+ session({
362
+ date, start, duration, harness, model,
363
+ project: Math.floor(Math.pow(random(), 1.4) * 18),
364
+ prompts: [2, Math.min(duration - 4, 12 + Math.floor(random() * 6)), Math.min(duration - 1, 24 + Math.floor(random() * 8))],
365
+ tools: ['modify', 'investigate', 'execute', 'plan', 'execute', 'research'],
366
+ children: later && random() < 0.08 ? 1 : 0,
367
+ output: 510, errorRate: 0.1, unrecoveredShare: 0.06,
368
+ });
369
+ }
370
+ }
371
+ break;
372
+ }
373
+ case 'starter': {
374
+ // 7 realistic daytime/early-evening sessions (all ending before 21:30 -> never mislabeled "late-night")
375
+ // with ~24k-32k output tokens (realistic for 7 starter sessions).
376
+ const plan = [
377
+ { date: '2026-11-18', start: 635, duration: 34, project: 0, prompts: [1, 11, 22] },
378
+ { date: '2026-11-18', start: 940, duration: 23, project: 0, prompts: [2, 12] },
379
+ { date: '2026-11-20', start: 850, duration: 76, project: 1, prompts: [2, 18, 36, 54] },
380
+ { date: '2026-11-24', start: 1090, duration: 29, project: 1, prompts: [1, 10, 21] },
381
+ { date: '2026-11-24', start: 1175, duration: 36, project: 0, prompts: [2, 14, 27] },
382
+ { date: '2026-11-29', start: 710, duration: 25, project: 1, prompts: [1, 13] },
383
+ { date: '2026-11-29', start: 1050, duration: 21, project: 0, prompts: [2, 11] },
384
+ ];
385
+ for (const item of plan) {
386
+ session({
387
+ ...item, harness: 'claude-code', model: 'claude-haiku-4-5',
388
+ tools: ['investigate', 'modify', 'execute'], output: 540,
389
+ });
390
+ }
391
+ break;
392
+ }
393
+ case 'specialist': {
394
+ // Natural 4-6 day workweeks + 12-day July breather across Jan-Nov, 95 long read-heavy sessions,
395
+ // varied 88-95% cache hit rate, and actual occasional execute tool errors.
396
+ const activeDays = [];
397
+ for (let w = 0; w < 46; w++) {
398
+ // Explicit 12-day July breather (Jul 10 - Jul 21: skip Fri of w26, all of w27, Mon-Tue of w28)
399
+ if (w === 27)
400
+ continue;
401
+ const weekMon = addDays('2026-01-05', w * 7);
402
+ let daysThisWeek;
403
+ if (w === 26)
404
+ daysThisWeek = [0, 1, 2, 3]; // ends Thu Jul 9
405
+ else if (w === 28)
406
+ daysThisWeek = [2, 3]; // resumes Wed Jul 22 -> 12 full offline days (Jul 10..21)
407
+ else if (w === 12)
408
+ daysThisWeek = [0, 1, 2, 3, 4]; // 5-day focused week
409
+ else if (w === 36)
410
+ daysThisWeek = [0, 1, 2, 3, 4, 5]; // 6-day focused week
411
+ else if (w % 3 === 0)
412
+ daysThisWeek = [0, 2];
413
+ else if (w % 3 === 1)
414
+ daysThisWeek = [1, 3];
415
+ else
416
+ daysThisWeek = [1];
417
+ for (const dow of daysThisWeek) {
418
+ const date = addDays(weekMon, dow);
419
+ if (date <= '2026-11-26')
420
+ activeDays.push(date);
421
+ }
422
+ }
423
+ // Distribute 95 sessions across all active days from Jan through Nov.
424
+ let emitted = 0;
425
+ const extraDays = Math.max(0, 95 - activeDays.length);
426
+ for (let idx = 0; idx < activeDays.length && emitted < 95; idx++) {
427
+ const date = activeDays[idx];
428
+ const countToday = idx < extraDays ? 2 : 1;
429
+ for (let k = 0; k < countToday && emitted < 95; k++) {
430
+ const i = emitted++;
431
+ const isMarathon = i === 70;
432
+ const start = k === 0 ? 595 + gauss() * 48 : 835 + gauss() * 35;
433
+ const duration = isMarathon ? 245 : Math.round(98 + random() * 82);
434
+ session({
435
+ date, start, duration, harness: 'claude-code',
436
+ model: i < 32 ? 'claude-sonnet-4-5' : 'claude-sonnet-4-6',
437
+ project: i % 4,
438
+ prompts: [2, 26, 48, 72],
439
+ tools: ['investigate', 'investigate', 'investigate', 'investigate', 'investigate', 'investigate', 'investigate', 'modify', 'execute'],
440
+ compactions: isMarathon ? 2 : i % 15 === 0 ? 1 : 0,
441
+ cache: 'high', output: 470, errorRate: 0.22, unrecoveredShare: 0.05,
442
+ });
443
+ }
444
+ }
445
+ break;
446
+ }
447
+ case 'partial': {
448
+ // Cursor IDE (Sept 6 - Nov 7, absent tokens/prompts/tools/cache) +
449
+ // Claude Code (Nov 4 - Dec 3, 30-day retention cliff, absent tools/cache/compactions/subagents).
450
+ // Bursty schedule so Sprinter wins cleanly on timing signals without fake zeros,
451
+ // and Claude-only weeks show real FDR token bars while Cursor weeks stay honestly unmarked.
452
+ const cursorOffsets = [0, 5, 11, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62];
453
+ for (const [i, offset] of cursorOffsets.entries()) {
454
+ session({
455
+ date: addDays('2026-09-06', offset),
456
+ start: 620 + Math.round(gauss() * 90),
457
+ duration: 16 + (i % 3) * 5,
458
+ harness: 'cursor-ide', model: 'gpt-5.4', project: i % 5,
459
+ prompts: [], tools: [], silent: true, cache: 'none', output: 0,
460
+ });
461
+ }
462
+ // 34 Claude Code sessions inside the surviving 30-day retention window (Nov 4 - Dec 3),
463
+ // clustered into a few intense sprint days + lighter days.
464
+ const claudePlan = [
465
+ { offset: 0, count: 2 }, { offset: 1, count: 1 }, { offset: 4, count: 2 },
466
+ { offset: 6, count: 1 }, { offset: 8, count: 3 }, { offset: 11, count: 2 },
467
+ { offset: 14, count: 1 }, { offset: 16, count: 4, sprint: true },
468
+ { offset: 19, count: 2 }, { offset: 21, count: 2 }, { offset: 23, count: 3 },
469
+ { offset: 25, count: 4 }, { offset: 27, count: 3 }, { offset: 28, count: 2 }, { offset: 29, count: 2 },
470
+ ];
471
+ let cIndex = 0;
472
+ for (const dayPlan of claudePlan) {
473
+ const date = addDays('2026-11-04', dayPlan.offset);
474
+ for (let k = 0; k < dayPlan.count; k++) {
475
+ const isSprintPeak = Boolean(dayPlan.sprint && k === 1);
476
+ session({
477
+ date,
478
+ start: isSprintPeak ? 580 : 610 + k * 75 + Math.round(gauss() * 55),
479
+ duration: isSprintPeak ? 310 : 20 + (cIndex % 6) * 4,
480
+ harness: 'claude-code', model: 'claude-sonnet-4-6', project: cIndex % 5,
481
+ prompts: isSprintPeak ? [2, 18, 45, 92, 140, 210] : [2, 8, 16],
482
+ tools: [], silent: true, cache: 'none', output: 330,
483
+ });
484
+ cIndex++;
485
+ }
486
+ }
487
+ break;
488
+ }
489
+ }
490
+ d.summaries = [...groupBy(d.sessions, (s) => s.harness)].map(([harness, sessions]) => {
491
+ const partial = profileId === 'partial';
492
+ const claude = harness === 'claude-code';
493
+ const linesSeen = sessions.length * 150;
494
+ const linesSkipped = partial ? Math.floor(linesSeen * 0.06) : 0;
495
+ const cursor = harness === 'cursor-ide';
496
+ const capabilities = partial ? {
497
+ ...ABSENT, agentRequestTimestamps: 'present', modelIds: 'present',
498
+ ...(claude ? { humanPromptTimestamps: 'present', tokenBreakdown: 'present' } : {}),
499
+ } : { ...FULL };
500
+ return {
501
+ candidateId: candidateId(harness), harness, displayName: HARNESS_NAMES[harness], adapterVersion: 'synthetic-1.0.0',
502
+ snapshotMethod: cursor || harness === 'opencode' ? 'sqlite-quiescent-copy' : 'stream-readonly',
503
+ filesSeen: cursor ? 1 : sessions.length, filesOk: cursor ? 1 : sessions.length, filesQuarantined: 0, linesSeen, linesSkipped,
504
+ bytesRead: linesSeen * 681, earliestEventTsMs: Math.min(...sessions.map((s) => s.startTsMs)),
505
+ latestEventTsMs: Math.max(...sessions.map((s) => s.endTsMs)), likelyRetentionTruncated: partial && claude,
506
+ ...(partial && claude ? { retentionNote: '30-day local retention inferred from the synthetic window.' } : {}),
507
+ capabilities, failureCodes: linesSkipped ? ['MALFORMED_JSON_LINE'] : [],
508
+ };
509
+ });
510
+ return d;
511
+ }
512
+ export function getDemoReport(profileId = 'night-owl') {
513
+ const dataset = getDemoDataset(profileId);
514
+ return buildWrappedReport(dataset, {
515
+ demoProfileId: profileId, generatedAtIso: DEMO_GENERATED_AT, content: buildDemoContent(profileId, dataset.timezone),
516
+ });
517
+ }
518
+ export function getDemoDiscoveryPlan(profileId = 'night-owl') {
519
+ const dataset = getDemoDataset(profileId);
520
+ return {
521
+ planId: `plan_demo_${profileId}`, year: dataset.year, timezone: dataset.timezone, generatedAtIso: DEMO_GENERATED_AT,
522
+ neverReadManifest: [...NEVER_READ],
523
+ candidates: dataset.summaries.map((s, i) => ({
524
+ candidateId: s.candidateId, harness: s.harness, displayName: s.displayName,
525
+ tier: s.harness === 'cursor-ide' ? 2 : 1, channelLabel: `CH${i + 1}`,
526
+ fileCount: s.filesSeen, totalBytes: s.bytesRead, earliestMtimeMs: s.earliestEventTsMs, latestMtimeMs: s.latestEventTsMs,
527
+ snapshotMethod: s.snapshotMethod, notes: s.retentionNote ? [s.retentionNote] : ['Synthetic recorder for the local demo.'],
528
+ hasCredentialRiskWarning: s.harness === 'cursor-ide' || s.harness === 'opencode',
529
+ })),
530
+ };
531
+ }