@echomem/mcp 1.3.2 → 1.4.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.
@@ -0,0 +1,1254 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <title>I scanned your AI coding city — Echo</title>
6
+ <style>
7
+ :root{
8
+ --ink:#1b1c1f; --muted:#8b8d94; --line:#ececef;
9
+ --mono:"IBM Plex Mono","SFMono-Regular",ui-monospace,Menlo,monospace;
10
+ --sans:"Avenir Next","Helvetica Neue","Segoe UI",system-ui,-apple-system,sans-serif;
11
+ --blue:#2f6df0; --red:#e8473f; --amber:#f0a83f;
12
+ }
13
+ *{margin:0;padding:0;box-sizing:border-box;}
14
+ html,body{background:#eef0f3;}
15
+ body{display:flex;justify-content:center;align-items:center;height:100vh;overflow:hidden;
16
+ font-family:var(--sans);color:var(--ink);}
17
+
18
+ /* ===== the whole shareable card ===== */
19
+ .share-card{position:relative;width:920px;height:1180px;background:#ffffff;border-radius:26px;
20
+ box-shadow:0 30px 90px rgba(20,24,40,.16);overflow:hidden;transform-origin:center center;}
21
+
22
+ /* ===== central repo visualizer (WebGL clay city) — full-bleed background ===== */
23
+ #repo-visualizer{position:absolute;inset:0;width:100%;height:100%;display:block;cursor:grab;z-index:0;}
24
+ #repo-visualizer:active{cursor:grabbing;}
25
+
26
+ /* overlay zones float above the visualizer (non-interactive → whole city stays draggable) */
27
+ .card-zone{position:absolute;z-index:5;pointer-events:none;}
28
+ body:not(.setup-mode) .compute-cost,
29
+ body:not(.setup-mode) .tool-split,
30
+ body:not(.setup-mode) .persona-card,
31
+ body:not(.setup-mode) .dirty-context,
32
+ body:not(.setup-mode) .counterfactual,
33
+ body:not(.setup-mode) .card-footer{display:none;}
34
+
35
+ /* v7 mirror-first card chrome: keep the WebGL city, replace the old poster furniture */
36
+ .v7-z{position:absolute;z-index:8;}
37
+ .v7-persona{left:56px;top:48px;width:330px;cursor:help;}
38
+ .v7-head{right:56px;top:48px;width:410px;text-align:right;}
39
+ .v7-eyebrow{font-family:var(--mono);font-size:12px;font-weight:800;letter-spacing:.16em;text-transform:uppercase;color:#9aa0aa;}
40
+ .v7-title{font-size:34px;font-weight:800;letter-spacing:-.02em;line-height:1.05;margin-top:8px;}
41
+ .v7-personaName{font-size:64px;font-weight:800;letter-spacing:-.035em;line-height:.9;margin-top:8px;text-transform:lowercase;}
42
+ .v7-rank{margin-top:12px;font-family:var(--mono);font-size:12px;font-weight:800;letter-spacing:.16em;text-transform:uppercase;color:#8d929c;}
43
+ .v7-combo{display:flex;gap:8px;flex-wrap:wrap;margin-top:16px;}
44
+ .v7-combo .ct{font-family:var(--mono);font-size:11px;letter-spacing:.02em;color:#3a3c43;border:1px solid var(--line);
45
+ border-radius:999px;padding:5px 11px;background:rgba(255,255,255,.82);}
46
+ .v7-personaHover{position:absolute;left:0;top:calc(100% + 12px);width:360px;background:rgba(255,255,255,.98);
47
+ border:1px solid var(--line);border-radius:16px;padding:15px 17px;box-shadow:0 18px 46px rgba(20,24,40,.18);
48
+ opacity:0;visibility:hidden;transform:translateY(-4px);transition:opacity .14s ease,transform .14s ease;
49
+ pointer-events:none;z-index:32;}
50
+ .v7-persona:hover .v7-personaHover,
51
+ .v7-persona:focus-within .v7-personaHover{opacity:1;visibility:visible;transform:none;}
52
+ .v7-personaHover .ph-line{font-size:13.5px;line-height:1.5;color:#42444b;margin-bottom:9px;}
53
+ .v7-personaHover .ph-line:last-of-type{margin-bottom:0;}
54
+ .v7-personaHover .ph-line b{color:var(--ink);font-weight:800;}
55
+ .v7-personaHover .ph-meta{font-size:12px;line-height:1.45;color:#73767e;margin-top:9px;
56
+ padding-top:9px;border-top:1px solid var(--line);}
57
+ .v7-personaHover .ph-meta b{color:var(--blue);font-weight:700;}
58
+ .v7-statline{margin-top:16px;display:flex;gap:22px;flex-wrap:wrap;justify-content:flex-end;}
59
+ .v7-stat .v{font-size:23px;font-weight:800;letter-spacing:-.01em;line-height:1;}
60
+ .v7-stat .k{font-family:var(--mono);font-size:11px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:#9296a0;margin-top:4px;}
61
+ .v7-band{left:90px;right:90px;bottom:250px;text-align:center;}
62
+ .v7-band .eyebrow{font-family:var(--mono);font-size:12px;font-weight:800;letter-spacing:.2em;text-transform:uppercase;color:#a4a7af;}
63
+ .v7-band .bignum{font-size:64px;font-weight:800;letter-spacing:-.03em;line-height:.9;margin-top:10px;color:var(--red);
64
+ min-height:64px;transition:opacity .52s ease,transform .52s ease;}
65
+ .v7-band .bignum.is-swapping,.v7-band .say.is-swapping{opacity:0;transform:translateY(6px);}
66
+ #v7-metric-value{font-size:64px;font-weight:800;color:var(--red);letter-spacing:-.03em;}
67
+ #v7-metric-label{font-size:27px;font-weight:700;margin-left:12px;color:var(--ink);letter-spacing:-.01em;}
68
+ .v7-infoBtn{display:inline-flex;align-items:center;justify-content:center;width:30px;height:30px;margin-left:10px;
69
+ border:1px solid #f3cfcc;border-radius:50%;background:rgba(255,255,255,.96);color:#b03a33;
70
+ font-family:var(--mono);font-size:15px;font-weight:800;line-height:1;vertical-align:middle;cursor:pointer;
71
+ box-shadow:0 8px 22px rgba(176,58,51,.10);transition:transform .15s ease,box-shadow .15s ease,background .15s ease;}
72
+ .v7-infoBtn:hover,.v7-infoBtn:focus-visible{background:#fff;box-shadow:0 10px 26px rgba(176,58,51,.18);transform:translateY(-1px);outline:none;}
73
+ .v7-band .say{font-size:18px;color:#46484f;margin:15px auto 0;line-height:1.55;max-width:680px;
74
+ min-height:56px;transition:opacity .52s ease,transform .52s ease;}
75
+ .v7-band .say b{color:var(--ink);font-weight:700;}
76
+ .v7-ctaWrap{left:0;right:0;bottom:112px;text-align:center;}
77
+ .v7-ctaWrap .pre{font-family:var(--mono);font-size:12px;font-weight:800;letter-spacing:.06em;text-transform:uppercase;color:#9296a0;margin-bottom:15px;}
78
+ .v7-cta{display:inline-flex;align-items:center;gap:11px;background:#1a3a8f;color:#fff;border:0;border-radius:15px;
79
+ font-family:var(--mono);font-size:17px;font-weight:800;letter-spacing:.08em;text-transform:uppercase;padding:21px 48px;
80
+ box-shadow:0 20px 46px rgba(26,58,143,.32);cursor:pointer;transition:background .18s ease,transform .18s ease;}
81
+ .v7-cta:hover,.v7-cta:focus-visible{background:#223f9b;transform:translateY(-2px);outline:none;}
82
+ .v7-ctaWrap .micro{font-size:13px;color:#8b8d94;margin-top:14px;line-height:1.5;}
83
+ .v7-foot{left:60px;right:60px;bottom:26px;display:flex;justify-content:space-between;
84
+ font-family:var(--mono);font-size:10px;letter-spacing:.14em;color:#b6b8bd;text-transform:uppercase;}
85
+ .v7-infoSheet{position:absolute;inset:0;z-index:60;display:none;background:rgba(20,24,40,.42);}
86
+ .v7-infoSheet.open{display:block;}
87
+ .v7-infoCard{position:absolute;left:0;right:0;bottom:0;background:#fff;border-radius:28px 28px 26px 26px;
88
+ padding:34px 46px 40px;box-shadow:0 -26px 70px rgba(20,24,40,.26);transform:translateY(18px);
89
+ transition:transform .28s ease;}
90
+ .v7-infoSheet.open .v7-infoCard{transform:translateY(0);}
91
+ .v7-infoClose{position:absolute;right:30px;top:26px;width:38px;height:38px;border-radius:50%;
92
+ border:1px solid var(--line);background:#fff;font-size:22px;line-height:1;color:#8d909c;cursor:pointer;}
93
+ .v7-infoClose:hover,.v7-infoClose:focus-visible{color:var(--ink);outline:none;}
94
+ .v7-infoTitle{font-size:26px;font-weight:800;letter-spacing:-.01em;margin-bottom:6px;}
95
+ .v7-infoSub{font-size:14px;color:#8b8d94;margin-bottom:22px;}
96
+ .v7-infoRow{display:grid;grid-template-columns:150px 1fr;gap:24px;padding:15px 0;border-top:1px solid var(--line);}
97
+ .v7-infoRow .sk{font-family:var(--mono);font-size:13px;font-weight:800;letter-spacing:.04em;color:#1b1c1f;text-transform:uppercase;}
98
+ .v7-infoRow .sv{font-size:15.5px;color:#46484f;line-height:1.55;}
99
+ .v7-infoRow .sv b{color:var(--ink);font-weight:700;}
100
+ .v7-infoNote{margin-top:20px;font-family:var(--mono);font-size:12px;letter-spacing:.04em;color:#9296a0;}
101
+
102
+ /* compute cost (headline $) */
103
+ .compute-cost{right:46px;top:42px;width:400px;text-align:right;}
104
+ .compute-cost .label{font-family:var(--mono);font-size:11px;letter-spacing:.2em;color:#a4a7af;text-transform:uppercase;}
105
+ .compute-cost .amount{font-size:60px;font-weight:800;letter-spacing:-.02em;color:var(--ink);line-height:.96;margin-top:4px;}
106
+ .compute-cost .detail{font-size:14px;color:#56585f;margin-top:10px;line-height:1.5;}
107
+ .compute-cost .detail b{color:var(--ink);}
108
+
109
+ /* tool split (Codex vs Claude chips) */
110
+ .tool-split{right:46px;top:212px;display:flex;gap:12px;justify-content:flex-end;}
111
+ .tool-chip{display:flex;align-items:center;gap:10px;border:1px solid var(--line);border-radius:14px;
112
+ padding:10px 14px;background:#fff;box-shadow:0 6px 18px rgba(20,24,40,.05);}
113
+ .tool-chip svg{width:22px;height:22px;display:block;}
114
+ .tool-chip .pct{font-size:20px;font-weight:800;letter-spacing:-.01em;}
115
+ .tool-chip .name{font-family:var(--mono);font-size:10px;letter-spacing:.1em;color:#80838c;text-transform:uppercase;line-height:1.3;}
116
+
117
+ /* persona card */
118
+ .persona-card{left:46px;top:38px;width:300px;background:#fff;border:1px solid var(--line);border-radius:20px;
119
+ box-shadow:0 18px 44px rgba(20,24,40,.12);padding:16px 18px 18px;}
120
+ /* big mascot: grows UP out of the card (negative top), bottom margin cancels the extra
121
+ height so the name/header below does NOT move. head can overflow the card's top edge. */
122
+ .persona-card .avatar-rive{width:280px;height:280px;display:block;margin:-129px 0 -63px -100px;
123
+ background:transparent;position:relative;z-index:6;pointer-events:none;}
124
+ .persona-card .name{font-size:34px;font-weight:800;color:var(--ink);letter-spacing:-.01em;line-height:1;text-transform:lowercase;}
125
+ /* Coding Persona Card: primary handle + rank·rhythm + side chips + one funny verdict */
126
+ .persona-card .rankrhythm{font-family:var(--mono);font-size:11px;letter-spacing:.16em;color:#9296a0;text-transform:uppercase;margin-top:8px;}
127
+ .persona-card .combo{display:flex;flex-wrap:wrap;gap:7px;margin-top:14px;padding-top:15px;border-top:1px solid var(--line);}
128
+ .persona-card .ct{font-family:var(--mono);font-size:11px;letter-spacing:.02em;color:#3a3c43;
129
+ border:1px solid var(--line);border-radius:999px;padding:5px 11px;background:#fafafb;}
130
+ .persona-card .verdict{font-size:14px;color:#42444b;margin-top:13px;line-height:1.55;}
131
+ .persona-card .verdict b{color:var(--ink);font-weight:800;}
132
+
133
+ /* dirty-context callout — 85% dirty → ~5% with Echo */
134
+ .dirty-context{left:46px;top:850px;width:430px;}
135
+ .dirty-context .pct{font-size:58px;font-weight:800;color:var(--red);letter-spacing:-.02em;line-height:.95;
136
+ min-height:58px;transition:opacity .52s ease,transform .52s ease;}
137
+ .dirty-context .pct.is-swapping,.dirty-context .desc.is-swapping{opacity:0;transform:translateY(6px);}
138
+ .dirty-context .pct .word{font-size:26px;font-weight:700;margin-left:8px;}
139
+ .dirty-context .desc{font-size:15px;color:#42444b;margin-top:12px;line-height:1.5;max-width:380px;
140
+ min-height:48px;transition:opacity .52s ease,transform .52s ease;}
141
+ .dirty-context .desc b{color:var(--ink);}
142
+
143
+ /* counterfactual — one line: the 18-days payoff */
144
+ .counterfactual{left:46px;top:1026px;width:828px;display:flex;align-items:center;gap:24px;}
145
+ .counterfactual .cal-icon{width:62px;height:65px;display:block;flex:none;
146
+ filter:drop-shadow(0 4px 9px rgba(20,24,40,.14));}
147
+ .cf-hero{font-size:38px;font-weight:800;letter-spacing:-.015em;color:var(--ink);line-height:1.04;}
148
+ .cf-hero b{color:var(--ink);font-weight:800;}
149
+ .cf-say{font-size:15px;color:#56585f;margin-top:8px;line-height:1.5;}
150
+ .cf-say b{color:var(--ink);font-weight:700;}
151
+
152
+ /* footer */
153
+ .card-footer{left:46px;right:46px;bottom:22px;display:flex;justify-content:space-between;
154
+ font-family:var(--mono);font-size:10px;letter-spacing:.14em;color:#b6b8bd;text-transform:uppercase;}
155
+
156
+ /* setup flow CTA: hidden in share-card export, visible only in ?setup=1 mode */
157
+ .setup-connect{display:none;position:absolute;z-index:20;right:46px;top:930px;width:238px;min-height:58px;
158
+ border:1px solid #1a3a8f;border-radius:12px;background:#1a3a8f;color:#fff;align-items:center;justify-content:center;
159
+ font-family:var(--mono);font-size:13px;font-weight:800;letter-spacing:.08em;text-transform:uppercase;
160
+ box-shadow:0 16px 36px rgba(20,24,40,.18);cursor:pointer;}
161
+ .setup-connect:hover{background:#223f9b;}
162
+ body.setup-mode{background:#fff;}
163
+ body.setup-mode .share-card{width:100vw;height:100vh;border-radius:0;box-shadow:none;overflow:hidden;}
164
+ body.setup-mode .compute-cost,
165
+ body.setup-mode .tool-split,
166
+ body.setup-mode .persona-card,
167
+ body.setup-mode .dirty-context,
168
+ body.setup-mode .counterfactual,
169
+ body.setup-mode .setup-connect,
170
+ body.setup-mode .setup-header,
171
+ body.setup-mode .card-footer{display:none;}
172
+ /* bottom-left: dirty-context score */
173
+ body.setup-mode .dirty-context{left:clamp(28px,5vw,72px);top:auto;bottom:clamp(30px,6vh,64px);width:min(440px,42vw);}
174
+ body.setup-mode .dirty-context .pct{font-size:clamp(64px,8vw,116px);line-height:.82;}
175
+ body.setup-mode .dirty-context .pct .word{font-size:clamp(26px,3.4vw,46px);}
176
+ body.setup-mode .dirty-context .desc{font-size:clamp(13px,1.1vw,16px);max-width:min(420px,42vw);}
177
+ /* bottom-right: the "Echo saves you X days" payoff stacked directly above the Connect Echo CTA */
178
+ body.setup-mode .setup-connect{display:flex;left:auto;right:clamp(28px,5vw,64px);top:auto;bottom:clamp(30px,5vh,56px);}
179
+ body.setup-mode .counterfactual{left:auto;right:clamp(28px,5vw,64px);top:auto;
180
+ bottom:calc(clamp(30px,5vh,56px) + 78px);width:min(440px,46vw);justify-content:flex-end;gap:16px;}
181
+ body.setup-mode .counterfactual .cf-body{text-align:right;}
182
+ body.setup-mode .counterfactual .cal-icon{width:54px;height:56px;}
183
+ body.setup-mode .cf-hero{font-size:clamp(26px,2.5vw,36px);}
184
+ body.setup-mode .cf-say{font-size:clamp(13px,1vw,15px);}
185
+ .setup-header{display:none;}
186
+ body.setup-mode .setup-header{position:absolute;z-index:18;left:clamp(34px,5vw,86px);right:clamp(34px,5vw,86px);
187
+ top:clamp(26px,4.8vh,58px);display:flex;align-items:flex-start;justify-content:space-between;gap:28px;pointer-events:none;}
188
+ .setup-eyebrow{font-family:var(--mono);font-size:12px;font-weight:800;letter-spacing:.14em;text-transform:uppercase;color:#9aa0aa;}
189
+ .setup-persona-name{margin-top:8px;font-size:clamp(42px,5.8vw,86px);font-weight:800;letter-spacing:-.02em;line-height:.88;color:var(--ink);}
190
+ .setup-rank{margin-top:11px;font-family:var(--mono);font-size:12px;font-weight:700;letter-spacing:.16em;text-transform:uppercase;color:#8d929c;}
191
+ .setup-combo{display:flex;gap:8px;flex-wrap:wrap;margin-top:15px;}
192
+ .setup-combo .ct{font-family:var(--mono);font-size:11px;letter-spacing:.02em;color:#3a3c43;border:1px solid var(--line);
193
+ border-radius:999px;padding:5px 11px;background:rgba(255,255,255,.82);}
194
+ .setup-stats{text-align:right;max-width:430px;}
195
+ .setup-stats .amount{margin-top:7px;font-size:clamp(46px,5.2vw,78px);font-weight:800;letter-spacing:-.02em;line-height:.9;color:var(--ink);}
196
+ .setup-stats .detail{margin-top:10px;font-size:15px;color:#56585f;}
197
+ .setup-split{display:flex;justify-content:flex-end;gap:10px;margin-top:16px;}
198
+ .setup-split span{border:1px solid var(--line);border-radius:12px;background:rgba(255,255,255,.82);padding:8px 11px;
199
+ font-family:var(--mono);font-size:11px;font-weight:800;letter-spacing:.08em;text-transform:uppercase;color:#646a74;}
200
+ /* persona hover: derived coding-personality card revealed on hover/focus of the top-left persona */
201
+ body.setup-mode .setup-persona{pointer-events:auto;position:relative;cursor:help;}
202
+ body.setup-mode .persona-cue{margin-top:11px;font-family:var(--mono);font-size:10px;font-weight:700;
203
+ letter-spacing:.12em;text-transform:uppercase;color:#b0b4bd;}
204
+ body.setup-mode .persona-cue::after{content:" \2193";}
205
+ body.setup-mode .persona-hover{position:absolute;left:0;top:calc(100% + 10px);width:min(380px,80vw);
206
+ background:rgba(255,255,255,.98);border:1px solid var(--line);border-radius:16px;padding:15px 17px;
207
+ box-shadow:0 18px 46px rgba(20,24,40,.18);opacity:0;visibility:hidden;transform:translateY(-4px);
208
+ transition:opacity .14s ease,transform .14s ease;z-index:30;pointer-events:none;}
209
+ body.setup-mode .setup-persona:hover .persona-hover,
210
+ body.setup-mode .setup-persona:focus-within .persona-hover{opacity:1;visibility:visible;transform:none;}
211
+ body.setup-mode .persona-hover .ph-line{font-size:13.5px;line-height:1.5;color:#42444b;margin-bottom:9px;}
212
+ body.setup-mode .persona-hover .ph-line:last-of-type{margin-bottom:0;}
213
+ body.setup-mode .persona-hover .ph-line b{color:var(--ink);font-weight:800;}
214
+ body.setup-mode .persona-hover .ph-meta{font-size:12px;line-height:1.45;color:#73767e;margin-top:9px;
215
+ padding-top:9px;border-top:1px solid var(--line);}
216
+ body.setup-mode .persona-hover .ph-meta b{color:var(--blue);font-weight:700;}
217
+ /* short viewports (e.g. 1366×768 laptops): shrink the headline numbers so nothing crowds the edges */
218
+ @media (max-height:760px){
219
+ body.setup-mode .setup-persona-name{font-size:clamp(34px,7vh,60px);}
220
+ body.setup-mode .setup-stats .amount{font-size:clamp(38px,7vh,60px);}
221
+ body.setup-mode .dirty-context .pct{font-size:clamp(52px,11vh,92px);}
222
+ body.setup-mode .counterfactual{bottom:calc(clamp(24px,4vh,48px) + 70px);}
223
+ body.setup-mode .setup-connect{bottom:clamp(24px,4vh,48px);}
224
+ }
225
+ body.setup-mode .setup-header,
226
+ body.setup-mode .dirty-context,
227
+ body.setup-mode .counterfactual,
228
+ body.setup-mode .setup-connect{display:none;}
229
+ body.setup-mode .v7-persona{left:clamp(48px,5vw,86px);top:clamp(42px,5vh,72px);width:min(360px,32vw);}
230
+ body.setup-mode .v7-personaName{font-size:clamp(54px,5.3vw,86px);}
231
+ body.setup-mode .v7-head{right:clamp(48px,5vw,86px);top:clamp(42px,5vh,72px);width:min(520px,38vw);}
232
+ body.setup-mode .v7-head .v7-eyebrow{font-size:clamp(10px,.72vw,12px);}
233
+ body.setup-mode .v7-title{font-size:clamp(28px,2.1vw,40px);}
234
+ body.setup-mode .v7-statline{gap:clamp(16px,1.55vw,26px);}
235
+ body.setup-mode .v7-stat .v{font-size:clamp(20px,1.45vw,28px);}
236
+ body.setup-mode .v7-stat .k{font-size:clamp(9px,.72vw,11px);}
237
+ body.setup-mode .v7-band{left:clamp(48px,5vw,86px);right:auto;bottom:clamp(82px,8vh,130px);
238
+ width:min(570px,38vw);text-align:left;}
239
+ body.setup-mode .v7-band .eyebrow{display:none;}
240
+ body.setup-mode .v7-band .bignum{display:flex;align-items:baseline;gap:10px;flex-wrap:wrap;
241
+ margin-top:0;min-height:0;line-height:.96;}
242
+ body.setup-mode #v7-metric-value{font-size:clamp(38px,4vw,62px);}
243
+ body.setup-mode #v7-metric-label{font-size:clamp(17px,1.45vw,24px);margin-left:0;}
244
+ body.setup-mode .v7-infoBtn{width:30px;height:30px;margin-left:0;flex:none;}
245
+ body.setup-mode .v7-band .say{margin:14px 0 0;max-width:520px;font-size:clamp(15px,1.05vw,18px);
246
+ min-height:58px;}
247
+ body.setup-mode .v7-ctaWrap{left:auto;right:clamp(48px,5vw,86px);bottom:clamp(86px,8vh,132px);
248
+ width:min(430px,31vw);text-align:right;}
249
+ body.setup-mode .v7-cta{padding:20px 48px;font-size:clamp(14px,1.1vw,17px);}
250
+ body.setup-mode .v7-ctaWrap .micro{max-width:430px;margin-left:auto;}
251
+ body.setup-mode .v7-foot{left:clamp(48px,5vw,86px);right:clamp(48px,5vw,86px);}
252
+ @media (max-height:820px){
253
+ body.setup-mode .v7-personaName{font-size:clamp(44px,6vh,62px);}
254
+ body.setup-mode .v7-title{font-size:clamp(30px,5vh,44px);}
255
+ body.setup-mode .v7-band{bottom:58px;width:min(500px,40vw);}
256
+ body.setup-mode .v7-ctaWrap{bottom:58px;width:min(390px,32vw);}
257
+ body.setup-mode .v7-foot{display:none;}
258
+ }
259
+
260
+ /* ===== in-canvas scan loader (setup mode) — loading lives inside the report, matches its type ===== */
261
+ .scan-loading{position:absolute;inset:0;z-index:6;display:flex;flex-direction:column;align-items:center;justify-content:center;
262
+ text-align:center;gap:14px;padding:24px;opacity:1;transition:opacity .5s ease;pointer-events:none;}
263
+ body:not(.scanning) .scan-loading{opacity:0;visibility:hidden;}
264
+ .scan-loading .eyebrow{font-family:var(--mono);font-size:12px;letter-spacing:.2em;text-transform:uppercase;color:#a4a7af;}
265
+ .scan-loading .title{font-family:var(--sans);font-weight:800;font-size:clamp(28px,4.4vw,46px);letter-spacing:-.02em;color:var(--ink);}
266
+ .scan-loading .bar{width:min(360px,60vw);height:6px;border-radius:999px;background:#e2e4ea;overflow:hidden;margin-top:10px;}
267
+ .scan-loading .bar i{display:block;height:100%;width:36%;border-radius:999px;background:var(--blue);animation:scanIndet 1.3s ease-in-out infinite;}
268
+ @keyframes scanIndet{0%{transform:translateX(-115%)}100%{transform:translateX(330%)}}
269
+ .scan-loading .count{font-family:var(--mono);font-size:12px;letter-spacing:.04em;color:#8b8d94;min-height:15px;margin-top:8px;}
270
+ /* during scan: hide the city + the value-bearing chrome (so demo numbers never flash), then fade in together */
271
+ #repo-visualizer{transition:opacity .7s ease;}
272
+ body.scanning #repo-visualizer{opacity:0;}
273
+ .setup-header,.dirty-context,.counterfactual,.setup-connect,.v7-z{transition:opacity .6s ease;}
274
+ body.scanning .setup-header,body.scanning .dirty-context,body.scanning .counterfactual,body.scanning .setup-connect,body.scanning .v7-z{opacity:0;pointer-events:none;}
275
+ body.setup-mode:not(.scanning) #repo-visualizer,
276
+ body.setup-mode:not(.scanning) .v7-z{opacity:1;}
277
+
278
+ /* hover-to-preview repo detail (interaction overlay, not part of the static export) */
279
+ #repo-detail{position:fixed;display:none;z-index:50;width:286px;background:rgba(255,255,255,.96);
280
+ border:1px solid rgba(197,203,214,.78);border-radius:18px;box-shadow:0 18px 46px rgba(20,24,40,.20);
281
+ padding:17px 18px 15px;pointer-events:none;backdrop-filter:blur(10px);}
282
+ #repo-detail .rd-kicker{font-family:var(--mono);font-size:10px;font-weight:800;letter-spacing:.18em;
283
+ text-transform:uppercase;color:#969aa4;margin-bottom:7px;}
284
+ #repo-detail .rd-name{font-family:var(--sans);font-weight:800;font-size:21px;color:var(--blue);
285
+ word-break:break-word;line-height:1.08;letter-spacing:-.01em;margin-bottom:14px;}
286
+ #repo-detail .rd-metrics{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-bottom:13px;}
287
+ #repo-detail .rd-label{font-family:var(--mono);font-size:9px;font-weight:800;letter-spacing:.12em;
288
+ text-transform:uppercase;color:#9a9da6;margin-bottom:6px;}
289
+ #repo-detail .rd-value{font-family:var(--mono);font-size:21px;font-weight:800;letter-spacing:.01em;
290
+ color:#1f2024;white-space:nowrap;}
291
+ #repo-detail .rd-meta{font-family:var(--mono);font-size:10.5px;font-weight:700;letter-spacing:.04em;
292
+ color:#858994;margin:1px 0 12px;}
293
+ #repo-detail .rd-split{height:8px;border-radius:999px;overflow:hidden;background:#edf0f3;display:flex;
294
+ box-shadow:inset 0 0 0 1px rgba(20,24,40,.04);}
295
+ #repo-detail .rd-seg{height:100%;min-width:0;}
296
+ #repo-detail .rd-seg.claude{background:#d97757;} #repo-detail .rd-seg.codex{background:#10a37f;}
297
+ #repo-detail .rd-legend{display:flex;justify-content:space-between;gap:12px;margin-top:11px;
298
+ font-family:var(--mono);font-size:12px;font-weight:800;letter-spacing:.02em;}
299
+ #repo-detail .rd-legend .claude{color:#d97757;} #repo-detail .rd-legend .codex{color:#10a37f;text-align:right;}
300
+ </style>
301
+ </head>
302
+ <body>
303
+ <script>try{const p=new URLSearchParams(location.search);if(p.get('setup')==='1'){document.body.classList.add('setup-mode');if(p.get('nonce'))document.body.classList.add('scanning');}}catch(e){}</script>
304
+ <div class="share-card">
305
+ <canvas id="repo-visualizer"></canvas>
306
+
307
+ <div class="v7-z v7-persona" tabindex="0" aria-describedby="v7-persona-hover">
308
+ <div class="v7-eyebrow">AI Coding City</div>
309
+ <div class="v7-personaName">{{personaPrimary}}</div>
310
+ <div class="v7-rank">{{personaRankRhythm}}</div>
311
+ <div class="v7-combo">{{personaSides}}</div>
312
+ <div class="v7-personaHover" id="v7-persona-hover" role="tooltip"></div>
313
+ </div>
314
+ <div class="v7-z v7-head">
315
+ <div class="v7-eyebrow">Echo scanned your AI coding city</div>
316
+ <div class="v7-title">Here's what you built.</div>
317
+ <div class="v7-statline">
318
+ <div class="v7-stat"><div class="v" id="v7-repo-count">13</div><div class="k">repos</div></div>
319
+ <div class="v7-stat"><div class="v" id="v7-attention">{{attentionHours}}h</div><div class="k">attention</div></div>
320
+ <div class="v7-stat"><div class="v" id="v7-cost">{{computeCost}}</div><div class="k">API-equiv</div></div>
321
+ <div class="v7-stat"><div class="v" id="v7-total-tokens">7.49B</div><div class="k">tokens</div></div>
322
+ </div>
323
+ </div>
324
+ <div class="v7-z v7-band">
325
+ <div class="eyebrow">What we found</div>
326
+ <div class="bignum" id="v7-metric"><span id="v7-metric-value">{{dirtyPct}}%</span><span id="v7-metric-label">repeated reads</span><button class="v7-infoBtn" id="v7-info-btn" type="button" aria-label="How we read your city" aria-expanded="false" aria-controls="v7-info-sheet">i</button></div>
327
+ <div class="say" id="v7-metric-say">Your agents re-load context they've already seen — unchanged files, the same rules, stale maps — every session. That's context rot. It's <b>how coding agents work today</b>, and it's the haze on your city.</div>
328
+ </div>
329
+ <div class="v7-z v7-ctaWrap">
330
+ <div class="pre">Ready when you are</div>
331
+ <button class="v7-cta" id="v7-connect" type="button">Connect Echo →</button>
332
+ <div class="micro">Clears the dirty context, so agents stop relearning your workspace.</div>
333
+ </div>
334
+ <div class="v7-z v7-foot"><span>Generated by Echo · No transcripts shown</span><span>Local scan · Share-safe city mode</span></div>
335
+ <div class="v7-infoSheet" id="v7-info-sheet" aria-hidden="true">
336
+ <div class="v7-infoCard" role="dialog" aria-modal="true" aria-labelledby="v7-info-title">
337
+ <button class="v7-infoClose" id="v7-info-close" type="button" aria-label="Close">×</button>
338
+ <div class="v7-infoTitle" id="v7-info-title">How we read your city</div>
339
+ <div class="v7-infoSub">Every number comes from your local Codex + Claude Code logs. Nothing here is an estimate of you — it's a readout of the tools.</div>
340
+ <div class="v7-infoRow"><div class="sk">Dirty context</div><div class="sv">Agents re-read files they've already seen — unchanged code, the same rules, stale maps — every new session. Nothing new is learned; it's re-remembering. That build-up is <b>context rot</b>.</div></div>
341
+ <div class="v7-infoRow"><div class="sk">The {{dirtyPct}}%</div><div class="sv">Share of your agents' total reads that were <b>repeats</b> of context already loaded earlier, across your sessions.</div></div>
342
+ <div class="v7-infoRow"><div class="sk">{{computeCost}}</div><div class="sv"><b>API-equivalent</b> — what this usage would cost at list API rates. Most of it is cache / input reads, so it's a measure of <b>volume, not a bill you paid</b>.</div></div>
343
+ <div class="v7-infoRow"><div class="sk">{{cfDaysEarlier}} days</div><div class="sv">With the repeated context cleared, the same workspace state is reached <b>~{{cfDaysEarlier}} days sooner</b> — derived from your attention hours vs. the re-read overhead.</div></div>
344
+ <div class="v7-infoNote">Computed locally · no transcripts leave your machine.</div>
345
+ </div>
346
+ </div>
347
+
348
+ <!-- in-canvas loading state (setup mode): the report loads in place, no separate page -->
349
+ <div class="scan-loading" id="scan-loading">
350
+ <div class="eyebrow">Local scan</div>
351
+ <div class="title">Reading your local history</div>
352
+ <div class="bar"><i></i></div>
353
+ <div class="count" id="scan-count"></div>
354
+ </div>
355
+
356
+ <div class="setup-header">
357
+ <div class="setup-persona" tabindex="0" aria-describedby="persona-hover">
358
+ <div class="setup-eyebrow">AI Coding City</div>
359
+ <div class="setup-persona-name">{{personaPrimary}}</div>
360
+ <div class="setup-rank">{{personaRankRhythm}}</div>
361
+ <div class="setup-combo">{{personaSides}}</div>
362
+ <div class="persona-cue">hover for the read</div>
363
+ <div class="persona-hover" id="persona-hover" role="tooltip"></div>
364
+ </div>
365
+ <div class="setup-stats">
366
+ <div class="setup-eyebrow">API-equivalent compute spent</div>
367
+ <div class="amount">{{computeCost}}</div>
368
+ <div class="detail">You spent <b>{{attentionHours}}h</b> of AI coding.</div>
369
+ <div class="setup-split">
370
+ <span>{{codexPct}}% Codex</span>
371
+ <span>{{claudePct}}% Claude</span>
372
+ </div>
373
+ </div>
374
+ </div>
375
+
376
+ <!-- compute cost -->
377
+ <div class="card-zone compute-cost">
378
+ <div class="label">API-equivalent compute spent</div>
379
+ <div class="amount">{{computeCost}}</div>
380
+ <div class="detail">You spent <b>{{attentionHours}}h</b> of AI coding.</div>
381
+ </div>
382
+
383
+ <!-- tool split chips -->
384
+ <div class="card-zone tool-split" id="tool-split"></div>
385
+
386
+ <!-- persona -->
387
+ <div class="card-zone persona-card">
388
+ <canvas class="avatar-rive" id="persona-mascot"></canvas>
389
+ <div class="name">{{personaPrimary}}</div>
390
+ <div class="rankrhythm">{{personaRankRhythm}}</div>
391
+ <div class="combo">{{personaSides}}</div>
392
+ <div class="verdict">{{personaVerdict}}</div>
393
+ </div>
394
+
395
+ <!-- dirty context -->
396
+ <div class="card-zone dirty-context">
397
+ <div class="pct" id="setup-metric"><span id="setup-metric-value">{{dirtyPct}}%</span><span class="word" id="setup-metric-label">repeated reads</span><button class="v7-infoBtn" id="setup-info-btn" type="button" aria-label="How we read your city" aria-expanded="false" aria-controls="v7-info-sheet">i</button></div>
398
+ <div class="desc" id="setup-metric-say">Your agents re-load context they've already seen — unchanged files, the same rules, stale maps — every session. That's context rot.</div>
399
+ </div>
400
+
401
+ <!-- counterfactual: one line — 18 days saved -->
402
+ <div class="card-zone counterfactual">
403
+ <svg class="cal-icon" viewBox="0 0 80 84" xmlns="http://www.w3.org/2000/svg">
404
+ <rect x="24" y="2" width="5" height="13" rx="2.5" fill="#1b1c1f"/>
405
+ <rect x="51" y="2" width="5" height="13" rx="2.5" fill="#1b1c1f"/>
406
+ <rect x="8" y="10" width="64" height="66" rx="12" fill="#ffffff" stroke="#e3e4e7" stroke-width="2"/>
407
+ <path d="M8 22 a12 12 0 0 1 12 -12 h40 a12 12 0 0 1 12 12 v8 H8 Z" fill="#1b1c1f"/>
408
+ <text x="40" y="24" text-anchor="middle" font-family="'IBM Plex Mono', monospace" font-size="11" font-weight="700" fill="#ffffff" letter-spacing="1.2">{{cfReachMonth}}</text>
409
+ <text x="40" y="64" text-anchor="middle" font-family="'Avenir Next', sans-serif" font-size="36" font-weight="800" fill="#1b1c1f">{{cfReachDay}}</text>
410
+ </svg>
411
+ <div class="cf-body">
412
+ <div class="cf-hero">Echo saves you <b>{{cfDaysEarlier}} days</b></div>
413
+ <div class="cf-say">You'd have reached today's workspace on <b>{{cfReachDate}}</b>, not {{cfInsteadOf}}.</div>
414
+ </div>
415
+ </div>
416
+
417
+ <button id="setup-connect" class="setup-connect" type="button">Connect Echo</button>
418
+
419
+ <div class="card-zone card-footer">
420
+ <span>Generated by Echo · No transcripts shown</span>
421
+ <span>Local scan · Share-safe city mode</span>
422
+ </div>
423
+ </div>
424
+
425
+ <div id="repo-detail"></div>
426
+
427
+ <script type="importmap">
428
+ { "imports": { "three": "./vendor/three.module.min.js" } }
429
+ </script>
430
+ <script type="module">
431
+ import * as THREE from 'three';
432
+ import { RoundedBoxGeometry } from './vendor/RoundedBoxGeometry.js';
433
+ import { OrbitControls } from './vendor/OrbitControls.js';
434
+
435
+ const pageParams=new URLSearchParams(location.search);
436
+ const setupMode=pageParams.get('setup')==='1';
437
+ if(setupMode) document.body.classList.add('setup-mode');
438
+ let VIZ_W=setupMode ? window.innerWidth : 920;
439
+ let VIZ_H=setupMode ? window.innerHeight : 1180; // repo-visualizer canvas = full card in share mode, viewport in setup mode
440
+ const TRAY_COL = 0xece5d3; // warm IVORY — not pure white, not cool grey; separates from the white card
441
+ const TOOL = { codex:0x10a37f, claude:0xd97757 }; // ONLY two cube colours — exact OpenAI / Claude chip-icon hexes
442
+
443
+ // ── volume normalization ─────────────────────────────────────────────────────
444
+ // Each cube's VOLUME is proportional to that repo's token usage, measured in a fixed unit so
445
+ // city size is comparable across users. 1 unit = one "coding-day": ~2h of agentic AI coding,
446
+ // which drives ≈80M total tokens (anchored on 7.49B tokens / 191.1h ≈ 39M tok/h, corroborated).
447
+ const TOKENS_PER_UNIT = 80e6; // tokens in one standard 2h coding-day = 1 volume unit
448
+ const MIN_TOKENS = 4e6; // hide repos below ~0.05 coding-days (declutter the long tail)
449
+ const BASE_EDGE = 36; // footprint of a 1-unit cube (world units)
450
+ const TOWER = 1.4; // gentle tower: height = TOWER × base, volume preserved
451
+ const COST_SCALE = 13689/19043; // reconcile forensic per-repo $ (sum ≈ $19,043) to the $13,689 headline
452
+ const LABEL_MIN_BASE = 24; // cubes with footprint ≥ this get a top-face label; smaller ones are click-only
453
+ const fmtTok=(n)=> n>=1e9?`${(n/1e9).toFixed(2)}B` : n>=1e6?`${Math.round(n/1e6)}M` : `${Math.round(n/1e3)}K`;
454
+ const money=(n)=>'$'+Math.round(Number(n)||0).toLocaleString('en-US');
455
+ const oneDec=(n)=>Number(n||0).toFixed(1).replace(/\.0$/,'');
456
+ const monthDay=(iso)=>{
457
+ const d=new Date(iso);
458
+ if(Number.isNaN(d.getTime())) return {month:'JUN', day:'2', label:'Jun 2'};
459
+ const month=d.toLocaleString('en-US',{month:'short', timeZone:'UTC'});
460
+ return {month:month.toUpperCase(), day:String(d.getUTCDate()), label:`${month} ${d.getUTCDate()}`};
461
+ };
462
+ function providerSplit(report){
463
+ let codex=0, claude=0;
464
+ for(const [model, v] of Object.entries(report?.cost?.byModel || {})){
465
+ const tok=Number(v?.total)||0;
466
+ if(/claude|opus|sonnet|haiku|anthropic/i.test(model)) claude+=tok;
467
+ else if(/gpt|codex|openai|o\d/i.test(model)) codex+=tok;
468
+ }
469
+ const total=codex+claude || 1;
470
+ const codexPct=Math.round(codex/total*100);
471
+ return {codexPct, claudePct:100-codexPct, dominant:codex>=claude?'codex':'claude'};
472
+ }
473
+ // ---- coding-persona engine (Phase 1: only signals the scan actually has — no commits / accept-all yet) ----
474
+ const PERSONA_TRAITS={
475
+ loopy:{label:'loopy', blurb:"opened the same file 14 times and still doesn't know what's in it. it's not working, it's re-remembering. context rot undefeated — and the bill's yours. 🗿"},
476
+ lusty:{label:'lusty', blurb:"burned a car payment in tokens for demos that'll never ship. zero regrets. Anthropic's about to send a thank-you card. 💸"},
477
+ maxxy:{label:'maxxy', blurb:"Opus to rename a variable, Opus to fix a typo. the small models are right there — but you don't do small models, you do consequences."},
478
+ tabby:{label:'tabby', blurb:"tabs everywhere, half-built features, breadth over depth. your brain is a browser with a memory leak. 🫠"},
479
+ bossy:{label:'bossy', blurb:"you don't write code anymore — you run a daycare for agents who never sleep and occasionally lie. wanted a helper, became a dad."},
480
+ ghosty:{label:'ghosty', blurb:"opened three files, made eight edits, then simply vanished. another one for the graveyard, abandoned at exactly 73%. we don't talk about that branch. 🧍"},
481
+ };
482
+ const PERSONA_RANKS={
483
+ tourist:{label:'vibe tourist', blurb:"accepts all on blind faith, googles the error the agent already explained two lines up. bless — we all start here."},
484
+ agent:{label:'agent-pilled', blurb:"saw it one-shot something once and never looked back. drives one agent, still watches its every move."},
485
+ high:{label:'high-agency', blurb:"fluent with the fleet, right-sizes the model, takes the wheel back when it matters."},
486
+ architect:{label:'the architect', blurb:"runs the whole system from above — agents in parallel worktrees, just nods and merges."},
487
+ enlightened:{label:'enlightened', blurb:"transcended the keyboard. hasn't hand-written a line in months and the code's never been cleaner. 🗿"},
488
+ };
489
+ const PERSONA_RHYTHMS={
490
+ marathoner:{label:'marathoner', blurb:"locked in since noon, sun set and rose, did not move. shipped though."},
491
+ raider:{label:'raider', blurb:"25-minute strikes, then gone to think about it in the shower. the breaks are the method."},
492
+ streak:{label:'the streak', blurb:"here every single day, small commits, never misses. the graph must stay green."},
493
+ binger:{label:'binger', blurb:"dark for a week, then a whole app in one unhinged weekend. not a routine — episodes."},
494
+ nightowl:{label:'night owl', blurb:"unreachable at 9am, unstoppable at 1am. the moon is my standup. 🌙"},
495
+ };
496
+ function daysBetween(a,b){ const x=Date.parse(a), y=Date.parse(b); if(isNaN(x)||isNaN(y)) return 1; return Math.max(1, Math.round((y-x)/86400000)+1); }
497
+ function derivePersona(report){
498
+ const cost=report?.cost||{}, scale=report?.scale||{}, uwh=report?.userWorkingHours||{}, rh=report?.rhythm||{}, cl=report?.cleanliness||{};
499
+ const repos=Array.isArray(report?.repos)?report.repos:[];
500
+ const totalTok=Number(scale.totalTokens)||1;
501
+ let opusTok=0; for(const [m,v] of Object.entries(cost.byModel||{})){ if(/opus/i.test(m)) opusTok+=Number(v?.total)||0; }
502
+ const opusShare=opusTok/totalTok;
503
+ const assistant=repos.reduce((s,r)=>s+(Number(r.assistantMessages)||0),0);
504
+ const turns=Math.max(1, Number(uwh.realUserTurns)||0);
505
+ const autonomy=assistant/turns; // AI turns per human prompt → how hands-off you run
506
+ const repoCount=Number(scale.repoCount)||repos.length;
507
+ const stale=Number(cl.staleReadSharePct)||0, spend=Number(cost.total)||0;
508
+ // Phase-2 git signal: commits landed vs building activity. Gated on commits>0 so a missing git pass can't false-fire ghosty.
509
+ const commits=Number(scale.totalCommits)||0, attention=Number(uwh.userAttentionHours)||0;
510
+ const activeDaysG=Number(uwh.activeAttentionDays)||0;
511
+ const commitsPerDay=activeDaysG>0?commits/activeDaysG:0;
512
+ const ghostyOn=commits>0 && attention>=8 && commitsPerDay<0.5;
513
+ // measurable traits only — primary = strongest firing signal, sides = the next few
514
+ const scored=[
515
+ {key:'loopy', on:stale>=45, s:stale/100},
516
+ {key:'lusty', on:spend>=1500, s:Math.min(1,spend/12000)},
517
+ {key:'maxxy', on:opusShare>=0.5, s:opusShare},
518
+ {key:'bossy', on:autonomy>=5, s:Math.min(1,autonomy/20)},
519
+ {key:'tabby', on:repoCount>=10, s:Math.min(1,repoCount/30)},
520
+ {key:'ghosty', on:ghostyOn, s:ghostyOn?Math.min(0.8, 1-Math.min(1,commitsPerDay/0.5)):0},
521
+ ].sort((a,b)=>b.s-a.s);
522
+ const primaryKey=scored[0].key; // most characteristic trait (highest signal)
523
+ const sideKeys=scored.filter(t=>t.on && t.key!==primaryKey).slice(0,3).map(t=>t.key);
524
+ // rank — rough proxy from autonomy + breadth (the true rank signals like re-roll aren't scanned yet)
525
+ let rankKey='tourist';
526
+ if(autonomy>=14&&repoCount>=12) rankKey='enlightened';
527
+ else if(autonomy>=8) rankKey='architect';
528
+ else if(autonomy>=4) rankKey='high';
529
+ else if(autonomy>=2) rankKey='agent';
530
+ // rhythm — fully measurable from work blocks + active-day density + late-night share
531
+ const lateShare=Number(rh.lateNightShare)||0;
532
+ const avgBlock=(Number(uwh.userAttentionHours)||0)/Math.max(1,Number(uwh.workBlocks)||0);
533
+ const density=(Number(uwh.activeAttentionDays)||0)/daysBetween(report?.scanStartDate, report?.scanEndDate);
534
+ const maxDay=Number(uwh.maxDailyAttentionHours)||0;
535
+ let rhythmKey='marathoner';
536
+ if(lateShare>=25) rhythmKey='nightowl';
537
+ else if(density<=0.35&&maxDay>=6) rhythmKey='binger';
538
+ else if(density>=0.6) rhythmKey='streak';
539
+ else if(avgBlock<=0.75) rhythmKey='raider';
540
+ return { primary:PERSONA_TRAITS[primaryKey], sides:sideKeys.map(k=>PERSONA_TRAITS[k]),
541
+ rank:PERSONA_RANKS[rankKey], rhythm:PERSONA_RHYTHMS[rhythmKey] };
542
+ }
543
+ function renderPersonaHover(persona){
544
+ const host=document.getElementById('persona-hover');
545
+ if(!host) return;
546
+ const esc=(t)=>String(t).replace(/[&<>]/g,(c)=>({'&':'&amp;','<':'&lt;','>':'&gt;'}[c]));
547
+ const line=(t)=>`<div class="ph-line"><b>${esc(t.label)}</b> — ${esc(t.blurb)}</div>`;
548
+ host.innerHTML = line(persona.primary) + persona.sides.map(line).join('') +
549
+ `<div class="ph-meta"><b>${esc(persona.rank.label)}</b> · ${esc(persona.rank.blurb)}</div>` +
550
+ `<div class="ph-meta"><b>${esc(persona.rhythm.label)}</b> · ${esc(persona.rhythm.blurb)}</div>`;
551
+ }
552
+ function renderV7PersonaHover(persona){
553
+ const host=document.getElementById('v7-persona-hover');
554
+ if(!host) return;
555
+ const esc=(t)=>String(t).replace(/[&<>]/g,(c)=>({'&':'&amp;','<':'&lt;','>':'&gt;'}[c]));
556
+ const line=(t)=>t?`<div class="ph-line"><b>${esc(t.label)}</b> — ${esc(t.blurb)}</div>`:'';
557
+ if(!persona){
558
+ const byLabel=(table,label)=>Object.values(table).find((v)=>v.label.toLowerCase()===String(label||'').trim().toLowerCase());
559
+ const rankBits=String(document.querySelector('.v7-rank')?.textContent||'').split('·').map((s)=>s.trim());
560
+ persona={
561
+ primary:byLabel(PERSONA_TRAITS, document.querySelector('.v7-personaName')?.textContent),
562
+ sides:Array.from(document.querySelectorAll('.v7-combo .ct')).map((el)=>byLabel(PERSONA_TRAITS, el.textContent)).filter(Boolean),
563
+ rank:byLabel(PERSONA_RANKS, rankBits[0]),
564
+ rhythm:byLabel(PERSONA_RHYTHMS, rankBits[1]),
565
+ };
566
+ }
567
+ host.innerHTML = line(persona.primary) + (persona.sides||[]).map(line).join('') +
568
+ (persona.rank?`<div class="ph-meta"><b>${esc(persona.rank.label)}</b> · ${esc(persona.rank.blurb)}</div>`:'') +
569
+ (persona.rhythm?`<div class="ph-meta"><b>${esc(persona.rhythm.label)}</b> · ${esc(persona.rhythm.blurb)}</div>`:'');
570
+ }
571
+ function buildSetupRepos(report){
572
+ const split=providerSplit(report);
573
+ const source=Array.isArray(report?.repos) ? report.repos : [];
574
+ const usable=source
575
+ .filter((repo)=>Number(repo?.tokens)>0)
576
+ .sort((a,b)=>(Number(b.tokens)||0)-(Number(a.tokens)||0))
577
+ .slice(0, 18);
578
+ return usable.map((repo, i)=>{
579
+ let x, z;
580
+ if(i===0){ x=-36; z=-58; }
581
+ else if(i===1){ x=128; z=-12; }
582
+ else {
583
+ const angle=i*2.399963229728653;
584
+ const radius=72+Math.sqrt(i)*42;
585
+ x=Math.cos(angle)*radius;
586
+ z=Math.sin(angle)*radius+28;
587
+ }
588
+ const cxTok=Number(repo.codexTokens)||0, clTok=Number(repo.claudeTokens)||0, tTok=cxTok+clTok;
589
+ const codexPct = tTok ? Math.round(cxTok/tTok*100) : ((repo.dominantProvider==='codex')?100:0);
590
+ return {
591
+ name:String(repo.name || `Repo ${i+1}`),
592
+ x, z,
593
+ tool:(repo.dominantProvider==='codex'||repo.dominantProvider==='claude')?repo.dominantProvider:split.dominant,
594
+ tokens:Number(repo.tokens)||0,
595
+ cost:Number(repo.cost)||0,
596
+ days:Number(repo.equivalentFocusDays)||0,
597
+ hours:Number(repo.attentionHours)||0,
598
+ sessions:Number(repo.sessions)||0,
599
+ codexPct, claudePct:100-codexPct,
600
+ pin:i<2,
601
+ };
602
+ });
603
+ }
604
+ function applySetupReport(report){
605
+ if(!setupMode || !report) return;
606
+ const split=providerSplit(report);
607
+ const persona=derivePersona(report);
608
+ const cost=money(report?.cost?.total);
609
+ const attention=oneDec(report?.userWorkingHours?.userAttentionHours);
610
+ const dirty=oneDec(report?.cleanliness?.staleReadSharePct);
611
+ const cf=report?.counterfactual || {};
612
+ const reach=monthDay(cf.counterfactualDate);
613
+ const instead=monthDay(report?.scanEndDate).label;
614
+ const days=Math.max(1, Math.round(Number(cf.daysGained)||0));
615
+ document.querySelectorAll('.setup-persona-name,.persona-card .name,.v7-personaName').forEach((el)=>{ el.textContent=persona.primary.label; });
616
+ document.querySelectorAll('.setup-rank,.persona-card .rankrhythm,.v7-rank').forEach((el)=>{ el.textContent=`${persona.rank.label} · ${persona.rhythm.label}`; });
617
+ document.querySelectorAll('.setup-combo,.persona-card .combo,.v7-combo').forEach((el)=>{ el.innerHTML=persona.sides.map((s)=>`<span class="ct">${s.label}</span>`).join(''); });
618
+ renderPersonaHover(persona);
619
+ renderV7PersonaHover(persona);
620
+ document.querySelectorAll('.setup-stats .amount,.compute-cost .amount').forEach((el)=>{ el.textContent=cost; });
621
+ document.querySelectorAll('.setup-stats .detail,.compute-cost .detail').forEach((el)=>{ el.innerHTML=`You spent <b>${attention}h</b> of AI coding.`; });
622
+ const v7Cost=document.getElementById('v7-cost'); if(v7Cost) v7Cost.textContent=cost;
623
+ const v7Attention=document.getElementById('v7-attention'); if(v7Attention) v7Attention.textContent=`${attention}h`;
624
+ const repoCount=Number(report?.scale?.repoCount) || (Array.isArray(report?.repos) ? report.repos.length : 0);
625
+ const v7RepoCount=document.getElementById('v7-repo-count'); if(v7RepoCount && repoCount) v7RepoCount.textContent=String(repoCount);
626
+ const v7Tokens=document.getElementById('v7-total-tokens'); if(v7Tokens) v7Tokens.textContent=fmtTok(Number(report?.scale?.totalTokens)||0);
627
+ const v7MetricValue=document.getElementById('v7-metric-value'); if(v7MetricValue) v7MetricValue.textContent=`${dirty}%`;
628
+ const v7MetricLabel=document.getElementById('v7-metric-label'); if(v7MetricLabel) v7MetricLabel.textContent='repeated reads';
629
+ const v7MetricSay=document.getElementById('v7-metric-say');
630
+ if(v7MetricSay) v7MetricSay.innerHTML="Your agents re-load context they've already seen — unchanged files, the same rules, stale maps — every session. That's context rot. It's <b>how coding agents work today</b>, and it's the haze on your city.";
631
+ const splitHtml=`<span>${split.codexPct}% Codex</span><span>${split.claudePct}% Claude</span>`;
632
+ const setupSplit=document.querySelector('.setup-split'); if(setupSplit) setupSplit.innerHTML=splitHtml;
633
+ const dirtyPct=document.querySelector('.dirty-context .pct');
634
+ if(dirtyPct) dirtyPct.innerHTML=`<span id="setup-metric-value">${dirty}%</span><span class="word" id="setup-metric-label">repeated reads</span><button class="v7-infoBtn" id="setup-info-btn" type="button" aria-label="How we read your city" aria-expanded="false" aria-controls="v7-info-sheet">i</button>`;
635
+ const dirtyDesc=document.querySelector('.dirty-context .desc');
636
+ if(dirtyDesc) dirtyDesc.id='setup-metric-say';
637
+ const monthEl=document.querySelector('.counterfactual text:first-of-type'); if(monthEl) monthEl.textContent=reach.month;
638
+ const dayEl=document.querySelector('.counterfactual text:last-of-type'); if(dayEl) dayEl.textContent=reach.day;
639
+ const cfHero=document.querySelector('.cf-hero'); if(cfHero) cfHero.innerHTML=`Echo saves you <b>${days} days</b>`;
640
+ const cfSay=document.querySelector('.cf-say'); if(cfSay) cfSay.innerHTML=`You'd have reached today's workspace on <b>${reach.label}</b>, not ${instead}.`;
641
+ signpostTokens=fmtTok(Number(report?.scale?.totalTokens)||0);
642
+ const inputPct=Number(report?.scale?.totalTokens) ? (Number(report.scale.totalInputTokens||0)/Number(report.scale.totalTokens)*100).toFixed(2) : '0.00';
643
+ signpostInputPct=`${inputPct}% INPUT`;
644
+ }
645
+ async function loadSetupReport(){
646
+ const nonce=pageParams.get('nonce');
647
+ if(!setupMode || !nonce) return null;
648
+ const countEl=document.getElementById('scan-count');
649
+ for(let i=0;i<80;i++){
650
+ try{
651
+ const res=await fetch(`/report?nonce=${encodeURIComponent(nonce)}`, {credentials:'omit', cache:'no-store'});
652
+ if(res.status===200) return await res.json();
653
+ if(res.status!==202) return null;
654
+ // 202 = still scanning. Surface live "read N / M sessions" so heavy histories never look frozen.
655
+ try{ const p=await res.json(); if(countEl && p && Number(p.total)>0){ countEl.textContent=`read ${Number(p.scanned||0).toLocaleString()} / ${Number(p.total).toLocaleString()} sessions`; } }catch(_){}
656
+ }catch(_){ return null; }
657
+ await new Promise((resolve)=>setTimeout(resolve, 500));
658
+ }
659
+ return null;
660
+ }
661
+ let signpostTokens='7.49B';
662
+ let signpostInputPct='99.39% INPUT';
663
+ const setupReport=await loadSetupReport();
664
+ applySetupReport(setupReport);
665
+ renderV7PersonaHover();
666
+
667
+ const renderer = new THREE.WebGLRenderer({canvas:document.getElementById('repo-visualizer'), antialias:true, alpha:true});
668
+ renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
669
+ renderer.setSize(VIZ_W,VIZ_H,false);
670
+ renderer.setClearColor(0xffffff,0); // transparent → card white shows through
671
+ renderer.shadowMap.enabled=true;
672
+ renderer.shadowMap.type=THREE.PCFSoftShadowMap;
673
+ renderer.outputColorSpace=THREE.SRGBColorSpace;
674
+ renderer.toneMapping=THREE.ACESFilmicToneMapping; // soft highlight roll-off — stops light surfaces clipping to flat white
675
+ renderer.toneMappingExposure=1.05; // master brightness for the whole city
676
+
677
+ const scene = new THREE.Scene();
678
+
679
+ // soft studio environment (image-based lighting) — gives the frosted glass its
680
+ // translucent sheen + the bright internal highlight; generated once, no external HDRI.
681
+ function buildEnv(){
682
+ const c=document.createElement('canvas'); c.width=512; c.height=256;
683
+ const g=c.getContext('2d');
684
+ const grd=g.createLinearGradient(0,0,0,256);
685
+ grd.addColorStop(0,'#ffffff'); grd.addColorStop(0.5,'#eef1f6'); grd.addColorStop(1,'#d2d7e0');
686
+ g.fillStyle=grd; g.fillRect(0,0,512,256);
687
+ const spot=g.createRadialGradient(150,62,8,150,62,150);
688
+ spot.addColorStop(0,'rgba(255,255,255,0.95)'); spot.addColorStop(1,'rgba(255,255,255,0)');
689
+ g.fillStyle=spot; g.fillRect(0,0,512,256);
690
+ const tex=new THREE.CanvasTexture(c); tex.mapping=THREE.EquirectangularReflectionMapping; tex.colorSpace=THREE.SRGBColorSpace;
691
+ const pm=new THREE.PMREMGenerator(renderer); pm.compileEquirectangularShader();
692
+ const env=pm.fromEquirectangular(tex).texture; tex.dispose(); pm.dispose();
693
+ return env;
694
+ }
695
+ scene.environment = buildEnv();
696
+
697
+ // real per-repo token usage (from city-data.json); x/z layout + tool colour stay hand-tuned, sizes are derived.
698
+ let REPOS=[
699
+ {name:'WebPageReactVersion', x:-30, z:-60, tool:'claude', pin:true, tokens:3436946364, cost:8896, days:18.6, hours:92.8, sessions:74},
700
+ {name:'EchoMem-Chrome', x:140, z:-14, tool:'claude', pin:true, tokens:2863590896, cost:6959, days:14.0, hours:70.1, sessions:38},
701
+ {name:'echo-design-system', x:30, z:30, tool:'codex', tokens:382642012, cost:1106, days:4.2, hours:21.2, sessions:29},
702
+ {name:'sleepy-merkle-3d0470',x:90, z:88, tool:'codex', tokens:307339018, cost:651, days:0.8, hours:3.8, sessions:1},
703
+ {name:'DG-Web', x:-128,z:6, tool:'claude', tokens:253239297, cost:621, days:1.4, hours:6.8, sessions:4},
704
+ {name:'Kobe Life', x:182, z:80, tool:'codex', tokens:122566296, cost:336, days:1.9, hours:9.6, sessions:12},
705
+ {name:'public', x:-66, z:96, tool:'claude', tokens:102828178, cost:290, days:0.4, hours:1.9, sessions:1},
706
+ {name:'EchoMemory_log', x:40, z:150, tool:'claude', tokens:43937440, cost:111, days:0.4, hours:1.8, sessions:8},
707
+ {name:'production-prompt', x:-188,z:64, tool:'claude', tokens:11092185, cost:19, days:0, hours:0, sessions:1},
708
+ {name:'brands', x:-140,z:120, tool:'codex', tokens:8010799, cost:18, days:0, hours:0.1, sessions:1},
709
+ {name:'components', x:-6, z:190, tool:'claude', tokens:7978639, cost:13, days:0, hours:0, sessions:1},
710
+ {name:'dist', x:-210,z:118, tool:'claude', tokens:4550877, cost:8, days:0, hours:0, sessions:2},
711
+ {name:'Daimler Engineering', x:-168,z:160, tool:'codex', tokens:4439902, cost:15, days:0, hours:0.2, sessions:2},
712
+ ];
713
+ // per-repo codex/claude split (frozen poster values from city-data.json) → drives the stacked two-colour buildings
714
+ const REPO_SPLIT={'WebPageReactVersion':[31,69],'EchoMem-Chrome':[19,81],'echo-design-system':[44,56],'sleepy-merkle-3d0470':[0,100],'DG-Web':[0,100],'Kobe Life':[100,0],'public':[0,100],'EchoMemory_log':[63,37],'production-prompt':[0,100],'brands':[0,100],'components':[0,100],'dist':[0,100],'Daimler Engineering':[100,0]};
715
+ for(const o of REPOS){ const s=REPO_SPLIT[o.name]; if(s){ o.codexPct=s[0]; o.claudePct=s[1]; } else { o.codexPct=o.tool==='codex'?100:0; o.claudePct=100-o.codexPct; } }
716
+ if(setupMode && setupReport){
717
+ const liveRepos=buildSetupRepos(setupReport);
718
+ if(liveRepos.length) REPOS=liveRepos;
719
+ window.__ECHOMEM_CITY_REPORT_REPO_COUNT=Array.isArray(setupReport?.repos) ? setupReport.repos.length : -1;
720
+ window.__ECHOMEM_CITY_REPOS=REPOS.map(({name,tokens,cost,hours,sessions,tool})=>({name,tokens,cost,hours,sessions,tool}));
721
+ }
722
+ // VOLUME ∝ tokens: units = tokens/TOKENS_PER_UNIT; volume = units·BASE_EDGE³; edge = cbrt(volume) (kept sane),
723
+ // reshaped into a gentle tower (height = TOWER·base) with the volume preserved.
724
+ for(const o of REPOS){
725
+ const units=o.tokens/TOKENS_PER_UNIT;
726
+ const base=Math.cbrt(units*BASE_EDGE*BASE_EDGE*BASE_EDGE/TOWER);
727
+ o.w=base; o.d=base; o.h=base*TOWER;
728
+ }
729
+ const all=REPOS.filter(o=>o.tokens>=MIN_TOKENS); // drop the negligible long tail
730
+
731
+ const GAP=16;
732
+ function separate(items, iters=400){
733
+ for(let k=0;k<iters;k++){ let moved=false;
734
+ for(let i=0;i<items.length;i++) for(let j=i+1;j<items.length;j++){
735
+ const a=items[i], b=items[j];
736
+ const hx=(a.w+b.w)/2+GAP, hz=(a.d+b.d)/2+GAP;
737
+ const dx=b.x-a.x, dz=b.z-a.z;
738
+ const ox=hx-Math.abs(dx), oz=hz-Math.abs(dz);
739
+ if(ox>0 && oz>0){ moved=true;
740
+ if(ox<oz){ const s=(dx<0?-1:1);
741
+ if(a.pin&&b.pin){} else if(a.pin){ b.x+=ox*s; } else if(b.pin){ a.x-=ox*s; } else { a.x-=ox*0.5*s; b.x+=ox*0.5*s; }
742
+ }else{ const s=(dz<0?-1:1);
743
+ if(a.pin&&b.pin){} else if(a.pin){ b.z+=oz*s; } else if(b.pin){ a.z-=oz*s; } else { a.z-=oz*0.5*s; b.z+=oz*0.5*s; }
744
+ }
745
+ }
746
+ }
747
+ if(!moved) break;
748
+ }
749
+ }
750
+ separate(all);
751
+
752
+ let minX=1e9,maxX=-1e9,minZ=1e9,maxZ=-1e9;
753
+ for(const o of all){ minX=Math.min(minX,o.x-o.w/2); maxX=Math.max(maxX,o.x+o.w/2);
754
+ minZ=Math.min(minZ,o.z-o.d/2); maxZ=Math.max(maxZ,o.z+o.d/2); }
755
+ const MARGIN=56;
756
+ const CX=(minX+maxX)/2, CZ=(minZ+maxZ)/2;
757
+ const traySize=Math.max(maxX-minX, maxZ-minZ)+2*MARGIN;
758
+ const trayW=traySize, trayD=traySize; // SQUARE footprint — reads as a square, not a skewed rectangle
759
+
760
+ const TRAY_TOP=25; // tray slab thickness — declared early so the setup-mode auto-fit can size the city
761
+ const Vh = 620; // share-card mode: zoom out for the v7 chrome
762
+ const PAN_X = 0.10, PAN_Y = -0.18; // share-card mode pan: keep city clear of the diagnosis band
763
+ const SETUP_PAN_Y = -0.08; // setup mode: lift the city slightly above optical center
764
+ const camera = new THREE.OrthographicCamera(-1,1,1,-1, 1, 6000);
765
+ const TARGET = new THREE.Vector3(CX, 78, CZ);
766
+ const OFFSET = new THREE.Vector3(760, 660, 760); // symmetric 45° azimuth → clean isometric square (was skewed → looked like a trapezoid)
767
+ camera.position.copy(TARGET).add(OFFSET);
768
+ if(setupMode) camera.lookAt(TARGET); // setup mode only: orient before the auto-fit. Share-card path left untouched — OrbitControls sets this same angle at update().
769
+ // Setup mode: frame the WHOLE city so no cube or label is ever clipped, at any viewport size or
770
+ // repo count. Project the city's world bounding box into camera space and size the orthographic
771
+ // window to contain it (plus padding), instead of a fixed zoom that only fits the frozen demo.
772
+ const FIT_PAD = 1.16; // breathing room so cubes never touch the viewport edge
773
+ function cityFit(){
774
+ camera.updateMatrixWorld(true);
775
+ camera.matrixWorldInverse.copy(camera.matrixWorld).invert();
776
+ const inv = camera.matrixWorldInverse;
777
+ const halfT = traySize / 2;
778
+ const maxH = all.length ? Math.max.apply(null, all.map(function(o){ return o.h; })) : 60;
779
+ const topY = TRAY_TOP + maxH + 150; // headroom for the token/$ labels that fly above each cube
780
+ const xs=[CX-halfT, CX+halfT], ys=[0, topY], zs=[CZ-halfT, CZ+halfT];
781
+ let minXc=1e9,maxXc=-1e9,minYc=1e9,maxYc=-1e9; const v=new THREE.Vector3();
782
+ for(const x of xs) for(const y of ys) for(const z of zs){
783
+ v.set(x,y,z).applyMatrix4(inv);
784
+ if(v.x<minXc)minXc=v.x; if(v.x>maxXc)maxXc=v.x;
785
+ if(v.y<minYc)minYc=v.y; if(v.y>maxYc)maxYc=v.y;
786
+ }
787
+ return {cx:(minXc+maxXc)/2, cy:(minYc+maxYc)/2, halfW:(maxXc-minXc)/2, halfH:(maxYc-minYc)/2};
788
+ }
789
+ function frame(){
790
+ const aspect = VIZ_W/VIZ_H;
791
+ if(setupMode){
792
+ const f = cityFit();
793
+ const half = Math.max(f.halfH, f.halfW/aspect) * FIT_PAD;
794
+ const Vw = half*aspect;
795
+ const cy = f.cy + half*SETUP_PAN_Y;
796
+ camera.left = f.cx - Vw; camera.right = f.cx + Vw;
797
+ camera.top = cy + half; camera.bottom = cy - half;
798
+ camera.updateProjectionMatrix();
799
+ return;
800
+ }
801
+ const Vw=Vh*aspect, px=Vw*PAN_X, py=Vh*PAN_Y;
802
+ camera.left=-Vw-px; camera.right=Vw-px; camera.top=Vh+py; camera.bottom=-Vh+py;
803
+ camera.updateProjectionMatrix();
804
+ }
805
+ frame();
806
+
807
+ scene.add(new THREE.HemisphereLight(0xffffff, 0xdadce2, 0.7));
808
+ scene.add(new THREE.AmbientLight(0xffffff, 0.2));
809
+ const key = new THREE.DirectionalLight(0xffffff, 2.3);
810
+ key.position.set(CX-360, 560, CZ+360); key.target.position.copy(TARGET);
811
+ key.castShadow=true; key.shadow.mapSize.set(4096,4096); key.shadow.radius=16; key.shadow.bias=-0.0004;
812
+ const shalf=Math.max(trayW,trayD)*0.8+140; const sc=key.shadow.camera;
813
+ sc.left=-shalf; sc.right=shalf; sc.top=shalf; sc.bottom=-shalf; sc.near=100; sc.far=1800;
814
+ key.shadow.autoUpdate=false; key.shadow.needsUpdate=true;
815
+ scene.add(key); scene.add(key.target);
816
+ const fill = new THREE.DirectionalLight(0xffffff, 0.4); fill.position.set(CX+420, 300, CZ+260); scene.add(fill);
817
+
818
+ const floor = new THREE.Mesh(new THREE.PlaneGeometry(6000,6000), new THREE.ShadowMaterial({opacity:0.22}));
819
+ floor.rotation.x=-Math.PI/2; floor.position.y=0; floor.receiveShadow=true; scene.add(floor);
820
+
821
+ // frosted clay-glass: colour comes from inside the volume (attenuation), not a flat surface
822
+ function clayGlass(hex){
823
+ const c=new THREE.Color(hex);
824
+ return new THREE.MeshPhysicalMaterial({
825
+ color:c,
826
+ roughness:0.42, metalness:0.0,
827
+ transmission:0.85, ior:1.34, thickness:70,
828
+ attenuationColor:c.clone(), attenuationDistance:95,
829
+ clearcoat:0.28, clearcoatRoughness:0.45,
830
+ envMapIntensity:1.05, transparent:true,
831
+ });
832
+ }
833
+ function selectiveRoundedBoxGeometry(width, height, depth, segments=8, radius=0.1, opts={}){
834
+ const roundTop=opts.roundTop!==false, roundBottom=opts.roundBottom!==false;
835
+ const s=segments*2+1;
836
+ const r=Math.min(width/2, height/2, depth/2, radius);
837
+ const base=new THREE.BoxGeometry(1,1,1,s,s,s);
838
+ const geo=base.toNonIndexed(); base.dispose();
839
+ const positions=geo.attributes.position.array;
840
+ const normals=geo.attributes.normal.array;
841
+ const pos=new THREE.Vector3();
842
+ const n=new THREE.Vector3();
843
+ const faceSpan=positions.length/6;
844
+ const halfStep=0.5/s;
845
+ const bx=width/2-r, by=height/2-r, bz=depth/2-r;
846
+ for(let i=0;i<positions.length;i+=3){
847
+ pos.fromArray(positions,i);
848
+ const sx=Math.sign(pos.x)||1, sy=Math.sign(pos.y)||1, sz=Math.sign(pos.z)||1;
849
+ const side=Math.floor(i/faceSpan);
850
+ const roundY=sy>0 ? roundTop : roundBottom;
851
+ n.copy(pos);
852
+ n.x-=sx*halfStep;
853
+ n.z-=sz*halfStep;
854
+ if(roundY) n.y-=sy*halfStep; else n.y=0;
855
+ if(n.lengthSq()>0) n.normalize();
856
+ positions[i]=bx*sx+n.x*r;
857
+ positions[i+1]=roundY ? by*sy+n.y*r : height/2*sy;
858
+ positions[i+2]=bz*sz+n.z*r;
859
+ if(!roundY && (side===2 || side===3)){
860
+ normals[i]=0; normals[i+1]=sy; normals[i+2]=0;
861
+ }else{
862
+ normals[i]=n.x; normals[i+1]=n.y; normals[i+2]=n.z;
863
+ }
864
+ }
865
+ geo.attributes.position.needsUpdate=true;
866
+ geo.attributes.normal.needsUpdate=true;
867
+ geo.computeBoundingBox();
868
+ geo.computeBoundingSphere();
869
+ return geo;
870
+ }
871
+ function addCube(o){
872
+ const {x,z,w,h,d,tool}=o;
873
+ const r=Math.min(Math.min(w,h,d)*0.12, 12);
874
+ // proportional split: Claude (orange) on the bottom, Codex (green) on top; segment heights ∝ each tool's token share
875
+ let cl=Number(o.claudePct), cx=Number(o.codexPct);
876
+ if(!(cl>=0 && cx>=0 && cl+cx>0)){ cl=tool==='codex'?0:100; cx=100-cl; } // fallback to the dominant tool
877
+ const total=cl+cx, segs=[];
878
+ if(cl>0) segs.push([h*cl/total, TOOL.claude]);
879
+ if(cx>0) segs.push([h*cx/total, TOOL.codex]);
880
+ const group=new THREE.Group();
881
+ let yBase=TRAY_TOP - 3;
882
+ const mixed=segs.length>1;
883
+ for(let i=0;i<segs.length;i++){
884
+ const [hSeg, color] = segs[i];
885
+ const mat=clayGlass(color);
886
+ const geom=mixed
887
+ ? selectiveRoundedBoxGeometry(w,hSeg,d,8,Math.min(r,hSeg*0.45), {roundBottom:i===0, roundTop:i===segs.length-1})
888
+ : new RoundedBoxGeometry(w,hSeg,d,8,Math.min(r,hSeg*0.45));
889
+ const m=new THREE.Mesh(geom, mat);
890
+ m.position.set(x, yBase + hSeg/2, z);
891
+ m.castShadow=true; m.receiveShadow=true; m.userData=o;
892
+ group.add(m);
893
+ yBase+=hSeg;
894
+ }
895
+ group.userData=o; scene.add(group); return group;
896
+ }
897
+ // repo summary as an upright billboard above each bar — white text, ALWAYS faces the camera (never skewed).
898
+ // name = small tag just above the bar top; tokens + $ fly higher above it, clear of the cube.
899
+ function addTopLabel(o){
900
+ const PW=320, PH=280;
901
+ const cv=document.createElement('canvas'); cv.width=PW; cv.height=PH;
902
+ const g=cv.getContext('2d'); g.textAlign='center';
903
+ g.shadowColor='rgba(0,0,0,0.34)'; g.shadowBlur=9; g.shadowOffsetY=1; // subtle contrast over light areas
904
+ // tokens — the headline, flies highest
905
+ g.fillStyle='#ffffff'; g.font=`800 ${Math.round(PW*0.19)}px "IBM Plex Mono", monospace`;
906
+ g.fillText(fmtTok(o.tokens), PW/2, PH*0.18);
907
+ // dollars — just under the tokens, also up high
908
+ g.fillStyle='rgba(255,255,255,0.92)'; g.font=`700 ${Math.round(PW*0.11)}px "IBM Plex Mono", monospace`;
909
+ g.fillText('$'+Math.round(o.cost*(setupMode?1:COST_SCALE)).toLocaleString('en-US'), PW/2, PH*0.40);
910
+ // name — small tag sitting just above the bar top
911
+ g.fillStyle='rgba(255,255,255,0.95)'; g.font=`600 ${Math.round(PW*0.075)}px "IBM Plex Mono", monospace`;
912
+ const fw=g.measureText(o.name).width, maxw=PW*0.94;
913
+ g.save(); g.translate(PW/2, PH*0.86); if(fw>maxw){ const s=maxw/fw; g.scale(s,s); } g.fillText(o.name, 0, 0); g.restore();
914
+ const tex=new THREE.CanvasTexture(cv); tex.colorSpace=THREE.SRGBColorSpace; tex.anisotropy=8;
915
+ const sprite=new THREE.Sprite(new THREE.SpriteMaterial({map:tex, transparent:true, toneMapped:false, depthWrite:false}));
916
+ const wWorld=Math.min(Math.max(o.w*0.95, 42), 128), hWorld=wWorld*PH/PW; // scales with bar size, clamped legible
917
+ sprite.scale.set(wWorld, hWorld, 1);
918
+ sprite.position.set(o.x, TRAY_TOP + o.h - 3 + 6 + 0.36*hWorld, o.z); // name tags the top; tokens/$ fly higher
919
+ scene.add(sprite);
920
+ }
921
+ // fine ivory grain — textures EVERY face (incl. the curved side walls), so the tray isn't flat plastic
922
+ const grain=(function(){
923
+ const S=256; const cv=document.createElement('canvas'); cv.width=cv.height=S;
924
+ const g=cv.getContext('2d'); const img=g.createImageData(S,S); const d=img.data;
925
+ for(let i=0;i<d.length;i+=4){ const n=128+(Math.random()*2-1)*38; d[i]=d[i+1]=d[i+2]=n; d[i+3]=255; }
926
+ g.putImageData(img,0,0);
927
+ const t=new THREE.CanvasTexture(cv); t.wrapS=t.wrapT=THREE.RepeatWrapping; t.anisotropy=8;
928
+ t.generateMipmaps=false; t.minFilter=THREE.LinearFilter; // don't let the grain mip-blur away to flat
929
+ t.repeat.set(trayW/70, trayD/70);
930
+ return t;
931
+ })();
932
+ const trayGeo=new RoundedBoxGeometry(trayW, TRAY_TOP, trayD, 8, 12);
933
+ const tray=new THREE.Mesh(trayGeo, new THREE.MeshPhysicalMaterial({
934
+ color:TRAY_COL, roughness:0.6, metalness:0.0,
935
+ clearcoat:0.3, clearcoatRoughness:0.5, envMapIntensity:0.6,
936
+ bumpMap:grain, bumpScale:0.4,
937
+ }));
938
+ tray.position.set(CX, TRAY_TOP/2, CZ); tray.castShadow=true; tray.receiveShadow=true; scene.add(tray);
939
+ // grid + perimeter border on ONE decal: the grid is CLIPPED to the border's rounded rect, so
940
+ // every line runs right up to the border and stops — no gap, and nothing leaks past it onto the rim.
941
+ (function(){
942
+ const scale=3;
943
+ const W=Math.round(trayW*scale), H=Math.round(trayD*scale);
944
+ const cv=document.createElement('canvas'); cv.width=W; cv.height=H;
945
+ const g=cv.getContext('2d');
946
+ const m=14*scale, rad=26*scale, rw=W-2*m, rh=H-2*m; // border rounded-rect (inset 14, radius 26)
947
+ // grid, clipped to the border shape → fills exactly inside, ending at the border line
948
+ g.save();
949
+ g.beginPath(); g.roundRect(m, m, rw, rh, rad); g.clip();
950
+ const cell=21*scale; // half the previous cell size
951
+ g.strokeStyle='rgba(74,80,96,0.45)'; g.lineWidth=1.8;
952
+ g.beginPath();
953
+ for(let x=m; x<=m+rw+0.5; x+=cell){ g.moveTo(x,m); g.lineTo(x,m+rh); }
954
+ for(let y=m; y<=m+rh+0.5; y+=cell){ g.moveTo(m,y); g.lineTo(m+rw,y); }
955
+ g.stroke();
956
+ g.restore();
957
+ // the border line itself, sitting on the boundary the grid ends at
958
+ g.strokeStyle='rgba(120,126,140,0.24)'; g.lineWidth=0.7*scale; g.lineJoin='round';
959
+ g.beginPath(); g.roundRect(m, m, rw, rh, rad); g.stroke();
960
+ const tex=new THREE.CanvasTexture(cv); tex.colorSpace=THREE.SRGBColorSpace; tex.anisotropy=8;
961
+ const plane=new THREE.Mesh(new THREE.PlaneGeometry(trayW, trayD), new THREE.MeshBasicMaterial({map:tex, transparent:true, depthWrite:false, toneMapped:false}));
962
+ plane.rotation.x=-Math.PI/2; plane.position.set(CX, TRAY_TOP+0.6, CZ); scene.add(plane);
963
+ })();
964
+
965
+ all.forEach(o=>{ o.mesh=addCube(o); o.mesh.userData=o; if(o.w>=LABEL_MIN_BASE) addTopLabel(o); });
966
+
967
+ // bottom-right standing "signpost": tray summary — total tokens + how much is input
968
+ let signpostCanvas=null, signpostTexture=null;
969
+ function drawSignpost(tokenText, bottomText, accent='#e8473f'){
970
+ if(!signpostCanvas) return;
971
+ const W=signpostCanvas.width, H=signpostCanvas.height;
972
+ const g=signpostCanvas.getContext('2d');
973
+ g.clearRect(0,0,W,H);
974
+ g.fillStyle='rgba(244,241,233,0.97)'; g.beginPath(); g.roundRect(8,8,W-16,H-16,30); g.fill();
975
+ g.strokeStyle='rgba(120,126,140,0.30)'; g.lineWidth=3; g.beginPath(); g.roundRect(8,8,W-16,H-16,30); g.stroke();
976
+ g.textAlign='center';
977
+ g.fillStyle='#1a1a1a'; g.font='800 124px "IBM Plex Mono", monospace'; g.fillText(tokenText, W/2, 150);
978
+ g.fillStyle='#6b6b6b'; g.font='600 36px "IBM Plex Mono", monospace'; g.fillText('TOTAL TOKENS', W/2, 204);
979
+ g.fillStyle=accent; g.font='800 62px "IBM Plex Mono", monospace'; g.fillText(bottomText, W/2, 280);
980
+ if(signpostTexture) signpostTexture.needsUpdate=true;
981
+ }
982
+ (function(){
983
+ const W=640, H=320;
984
+ const cv=document.createElement('canvas'); cv.width=W; cv.height=H;
985
+ signpostCanvas=cv;
986
+ const tex=new THREE.CanvasTexture(cv); tex.colorSpace=THREE.SRGBColorSpace; tex.anisotropy=8;
987
+ signpostTexture=tex;
988
+ drawSignpost(signpostTokens, signpostInputPct);
989
+ const SIGN_W=152, SIGN_H=76, SIGN_Y=TRAY_TOP+64;
990
+ const sign=new THREE.Mesh(
991
+ new THREE.PlaneGeometry(SIGN_W, SIGN_H),
992
+ new THREE.MeshBasicMaterial({map:tex, transparent:true, toneMapped:false, depthWrite:false, side:THREE.DoubleSide})
993
+ );
994
+ const sx=CX + trayW*0.48, sz=CZ + trayD*0.48;
995
+ sign.position.set(sx, SIGN_Y, sz);
996
+ sign.rotation.y=Math.PI/4; // fixed in the city, facing the default isometric camera instead of billboarding
997
+ scene.add(sign);
998
+ const POST_OVERLAP=4; // tiny tuck into the board so the pole feels attached, not floating
999
+ const postH=Math.max(4, SIGN_Y - SIGN_H/2 - TRAY_TOP + POST_OVERLAP);
1000
+ const post=new THREE.Mesh(new THREE.CylinderGeometry(2.2,2.2,postH,12),
1001
+ new THREE.MeshStandardMaterial({color:0xddd9cc, roughness:0.7, metalness:0}));
1002
+ post.position.set(sx, TRAY_TOP+postH/2, sz); post.castShadow=true; scene.add(post);
1003
+ })();
1004
+
1005
+ const MINZ=0.4, MAXZ=2.8; // lower floor → can zoom out to ~2/3 of the previous limit
1006
+ const controls=new OrbitControls(camera, renderer.domElement);
1007
+ controls.target.copy(TARGET);
1008
+ controls.enableDamping=true; controls.dampingFactor=0.08; controls.enablePan=false; controls.enableZoom=false;
1009
+ controls.minPolarAngle=0.18; controls.maxPolarAngle=Math.PI*0.47; controls.rotateSpeed=0.85;
1010
+ controls.update();
1011
+ let targetZoom=camera.zoom;
1012
+ renderer.domElement.addEventListener('wheel', (e)=>{
1013
+ e.preventDefault();
1014
+ const dy=e.deltaY * (e.deltaMode===1 ? 16 : 1);
1015
+ targetZoom=Math.min(MAXZ, Math.max(MINZ, targetZoom * Math.pow(0.999, dy)));
1016
+ }, {passive:false});
1017
+
1018
+ let dirty=true;
1019
+ function render(){ renderer.render(scene,camera); }
1020
+ function loop(){ requestAnimationFrame(loop); let need=controls.update();
1021
+ if(Math.abs(targetZoom-camera.zoom) > 0.0006){ camera.zoom += (targetZoom-camera.zoom)*0.16; if(Math.abs(targetZoom-camera.zoom)<0.001) camera.zoom=targetZoom; camera.updateProjectionMatrix(); need=true; }
1022
+ if(need||dirty){ render(); dirty=false; }
1023
+ }
1024
+ loop();
1025
+
1026
+ // ---- scale the whole card to fill the viewport, keeping the visualizer crisp ----
1027
+ const cardEl=document.querySelector('.share-card');
1028
+ function fit(){
1029
+ if(setupMode){
1030
+ VIZ_W=window.innerWidth; VIZ_H=window.innerHeight;
1031
+ cardEl.style.transform='none';
1032
+ renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
1033
+ renderer.setSize(VIZ_W,VIZ_H,false);
1034
+ frame();
1035
+ dirty=true;
1036
+ return;
1037
+ }
1038
+ const contain=Math.min((window.innerWidth-28)/920, (window.innerHeight-28)/1180);
1039
+ const s=contain;
1040
+ cardEl.style.transform=`scale(${s})`;
1041
+ renderer.setPixelRatio(Math.min(Math.max(window.devicePixelRatio*s, 1), 3)); // match displayed res
1042
+ renderer.setSize(VIZ_W,VIZ_H,false);
1043
+ dirty=true;
1044
+ }
1045
+ fit();
1046
+ window.addEventListener('resize', fit);
1047
+
1048
+ // Loading lives inside the report: once the city has rendered + framed, fade the scan loader out and
1049
+ // the city + real chrome in together (one surface, smooth). Runs unconditionally so it never sticks.
1050
+ function finishSetupReveal(){
1051
+ document.body.classList.remove('scanning');
1052
+ }
1053
+ if(setupMode){
1054
+ requestAnimationFrame(()=>requestAnimationFrame(finishSetupReveal));
1055
+ window.setTimeout(finishSetupReveal, 1200);
1056
+ }
1057
+
1058
+ document.querySelectorAll('#setup-connect,#v7-connect').forEach((connectButton)=>{
1059
+ connectButton.addEventListener('click', (event)=>{
1060
+ event.stopPropagation();
1061
+ if(setupMode) window.parent?.postMessage({type:'echomem:connect-click'}, window.location.origin);
1062
+ });
1063
+ });
1064
+
1065
+ // ---- rotating cost-of-forgetting readout: share, time, and API-equivalent waste ----
1066
+ const parseScalar=(value)=>{
1067
+ const match=String(value||'').match(/[0-9][0-9,]*(?:\.[0-9]+)?/);
1068
+ return match ? Number(match[0].replace(/,/g,''))||0 : 0;
1069
+ };
1070
+ const formatWasteMoney=(value)=>`$${Math.round(value).toLocaleString('en-US')}`;
1071
+ function buildMetricSlides(dirtyPct, attentionHours, computeCost){
1072
+ const dirtyShare=Math.max(0, parseScalar(dirtyPct))/100;
1073
+ const wastedHours=Math.max(0, parseScalar(attentionHours))*dirtyShare;
1074
+ const wastedDays=wastedHours/8;
1075
+ const wastedCost=Math.max(0, parseScalar(computeCost))*dirtyShare;
1076
+ return [
1077
+ {
1078
+ value:`${parseScalar(dirtyPct).toFixed(1)}%`,
1079
+ label:'repeated reads',
1080
+ say:"Your agents re-load context they've already seen — unchanged files, the same rules, stale maps — every session. That's context rot. It's <b>how coding agents work today</b>, and it's the haze on your city."
1081
+ },
1082
+ {
1083
+ value:`≈${Math.round(wastedHours)}h`,
1084
+ label:'spent rereading',
1085
+ say:`That is roughly <b>${wastedDays.toFixed(1)} workdays</b> of agent attention spent loading old context again instead of moving the workspace forward.`
1086
+ },
1087
+ {
1088
+ value:`≈${formatWasteMoney(wastedCost)}`,
1089
+ label:'API-equiv waste',
1090
+ say:`At list API-equivalent rates, repeated reads account for about <b>${formatWasteMoney(wastedCost)}</b> of the compute volume shown above. Not your bill — the scale of the waste.`
1091
+ },
1092
+ ];
1093
+ }
1094
+ function bindMetricCarousel({metric,value,label,say,slides}){
1095
+ if(!metric || !value || !label || !say || !slides?.length) return;
1096
+ let index=0;
1097
+ function show(indexToShow){
1098
+ const slide=slides[indexToShow%slides.length];
1099
+ metric.classList.add('is-swapping');
1100
+ say.classList.add('is-swapping');
1101
+ window.setTimeout(()=>{
1102
+ value.textContent=slide.value;
1103
+ label.textContent=slide.label;
1104
+ say.innerHTML=slide.say;
1105
+ metric.classList.remove('is-swapping');
1106
+ say.classList.remove('is-swapping');
1107
+ }, 520);
1108
+ }
1109
+ if(slides.length>1 && !window.matchMedia('(prefers-reduced-motion: reduce)').matches){
1110
+ window.setInterval(()=>{
1111
+ index=(index+1)%slides.length;
1112
+ show(index);
1113
+ }, 6000);
1114
+ }
1115
+ }
1116
+ bindMetricCarousel({
1117
+ metric:document.getElementById('v7-metric'),
1118
+ value:document.getElementById('v7-metric-value'),
1119
+ label:document.getElementById('v7-metric-label'),
1120
+ say:document.getElementById('v7-metric-say'),
1121
+ slides:buildMetricSlides(
1122
+ document.getElementById('v7-metric-value')?.textContent || '{{dirtyPct}}',
1123
+ document.getElementById('v7-attention')?.textContent || '{{attentionHours}}',
1124
+ document.getElementById('v7-cost')?.textContent || '{{computeCost}}'
1125
+ ),
1126
+ });
1127
+
1128
+ // ---- repeated-reads info sheet: v7 "how we read your city" disclosure, moved behind the info button ----
1129
+ const v7InfoBtns=Array.from(document.querySelectorAll('[aria-controls="v7-info-sheet"]'));
1130
+ const v7InfoSheet=document.getElementById('v7-info-sheet');
1131
+ const v7InfoClose=document.getElementById('v7-info-close');
1132
+ function setV7InfoSheet(open){
1133
+ if(!v7InfoSheet) return;
1134
+ v7InfoSheet.classList.toggle('open', open);
1135
+ v7InfoSheet.setAttribute('aria-hidden', String(!open));
1136
+ v7InfoBtns.forEach((button)=>button.setAttribute('aria-expanded', String(open)));
1137
+ }
1138
+ if(v7InfoBtns.length && v7InfoSheet){
1139
+ v7InfoBtns.forEach((button)=>button.addEventListener('click', (event)=>{
1140
+ event.stopPropagation();
1141
+ setV7InfoSheet(!v7InfoSheet.classList.contains('open'));
1142
+ }));
1143
+ v7InfoSheet.addEventListener('click', (event)=>{
1144
+ if(event.target===v7InfoSheet) setV7InfoSheet(false);
1145
+ });
1146
+ v7InfoSheet.querySelector('.v7-infoCard')?.addEventListener('click', (event)=>event.stopPropagation());
1147
+ }
1148
+ if(v7InfoClose) v7InfoClose.addEventListener('click', (event)=>{ event.stopPropagation(); setV7InfoSheet(false); });
1149
+
1150
+ // ---- hover a cube → highlight it + open a clear detail panel (more detail than the top label) ----
1151
+ const detailEl=document.getElementById('repo-detail');
1152
+ const ray=new THREE.Raycaster();
1153
+ let downXY=null, selected=null, activeDetail=null, pointerIsDown=false;
1154
+ function highlight(grp){
1155
+ if(selected) selected.traverse(m=>{ if(m.material && m.material.emissive) m.material.emissive.setHex(0x000000); });
1156
+ selected=grp;
1157
+ if(grp) grp.traverse(m=>{ if(m.material && m.material.emissive) m.material.emissive.copy(m.material.color).multiplyScalar(0.22); });
1158
+ dirty=true;
1159
+ }
1160
+ function repoAtPointer(e){
1161
+ const rect=renderer.domElement.getBoundingClientRect();
1162
+ ray.setFromCamera({x:((e.clientX-rect.left)/rect.width)*2-1, y:-((e.clientY-rect.top)/rect.height)*2+1}, camera);
1163
+ const hits=ray.intersectObjects(all.map(o=>o.mesh), true);
1164
+ return hits.length ? hits[0].object.userData : null;
1165
+ }
1166
+ function updateHoverDetail(e){
1167
+ if(pointerIsDown) return;
1168
+ const repo=repoAtPointer(e);
1169
+ if(repo) showDetail(repo); else hideDetail();
1170
+ }
1171
+ renderer.domElement.addEventListener('pointermove', updateHoverDetail);
1172
+ renderer.domElement.addEventListener('pointerleave', hideDetail);
1173
+ renderer.domElement.addEventListener('pointerdown', e=>{ downXY=[e.clientX,e.clientY]; pointerIsDown=true; hideDetail(); });
1174
+ renderer.domElement.addEventListener('pointerup', e=>{
1175
+ if(!downXY) return;
1176
+ const moved=Math.hypot(e.clientX-downXY[0], e.clientY-downXY[1]); downXY=null;
1177
+ pointerIsDown=false;
1178
+ if(moved>6) return; // it was a drag-to-rotate, not a click
1179
+ const repo=repoAtPointer(e); // tap/click fallback for touch and keyboard-less devices
1180
+ if(repo) showDetail(repo); else hideDetail();
1181
+ });
1182
+ function showDetail(o){
1183
+ if(activeDetail===o && detailEl.style.display==='block') return;
1184
+ activeDetail=o;
1185
+ highlight(o.mesh);
1186
+ const dollars=Math.round(o.cost*(setupMode?1:COST_SCALE)).toLocaleString('en-US');
1187
+ const days=o.days>=0.1 ? `${o.days}` : '<0.1';
1188
+ const cxp=Number(o.codexPct)||0, clp=Number(o.claudePct)||0;
1189
+ const splitTotal=Math.max(1, cxp+clp);
1190
+ const codexW=Math.max(0, Math.min(100, cxp/splitTotal*100));
1191
+ const claudeW=Math.max(0, 100-codexW);
1192
+ const esc=(v)=>String(v).replace(/[&<>"]/g,(c)=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;'}[c]));
1193
+ detailEl.innerHTML=
1194
+ `<div class="rd-kicker">Repository</div>`+
1195
+ `<div class="rd-name">${esc(o.name)}</div>`+
1196
+ `<div class="rd-metrics">`+
1197
+ `<div><div class="rd-label">Total tokens</div><div class="rd-value">${fmtTok(o.tokens)}</div></div>`+
1198
+ `<div><div class="rd-label">API-equiv cost</div><div class="rd-value">$${dollars}</div></div>`+
1199
+ `</div>`+
1200
+ `<div class="rd-meta">${days} focus days · ${Number(o.sessions)||0} sessions</div>`+
1201
+ `<div class="rd-split"><i class="rd-seg claude" style="width:${claudeW}%"></i><i class="rd-seg codex" style="width:${codexW}%"></i></div>`+
1202
+ `<div class="rd-legend"><span class="claude">Claude ${clp}%</span><span class="codex">Codex ${cxp}%</span></div>`;
1203
+ detailEl.style.display='block';
1204
+ const rect=renderer.domElement.getBoundingClientRect();
1205
+ const v=new THREE.Vector3(o.x, TRAY_TOP+o.h-3, o.z).project(camera); // anchor to the cube, not the cursor
1206
+ const cx=rect.left+(v.x*0.5+0.5)*rect.width, cy=rect.top+(-v.y*0.5+0.5)*rect.height;
1207
+ let x=cx+26, y=cy-detailEl.offsetHeight*0.5;
1208
+ if(x+detailEl.offsetWidth>window.innerWidth-8) x=cx-detailEl.offsetWidth-26;
1209
+ if(y<8) y=8; if(y+detailEl.offsetHeight>window.innerHeight-8) y=window.innerHeight-detailEl.offsetHeight-8;
1210
+ detailEl.style.left=x+'px'; detailEl.style.top=y+'px';
1211
+ }
1212
+ function hideDetail(){ activeDetail=null; highlight(null); detailEl.style.display='none'; }
1213
+ window.addEventListener('keydown', e=>{ if(e.key==='Escape'){ setV7InfoSheet(false); hideDetail(); } });
1214
+
1215
+ // ---- tool-split chips (official icons) ----
1216
+ const CLAUDE_SVG='<svg viewBox="0 0 100 100"><path fill="#d97757" d="m19.6 66.5 19.7-11 .3-1-.3-.5h-1l-3.3-.2-11.2-.3L14 53l-9.5-.5-2.4-.5L0 49l.2-1.5 2-1.3 2.9.2 6.3.5 9.5.6 6.9.4L38 49.1h1.6l.2-.7-.5-.4-.4-.4L29 41l-10.6-7-5.6-4.1-3-2-1.5-2-.6-4.2 2.7-3 3.7.3.9.2 3.7 2.9 8 6.1L37 36l1.5 1.2.6-.4.1-.3-.7-1.1L33 25l-6-10.4-2.7-4.3-.7-2.6c-.3-1-.4-2-.4-3l3-4.2L28 0l4.2.6L33.8 2l2.6 6 4.1 9.3L47 29.9l2 3.8 1 3.4.3 1h.7v-.5l.5-7.2 1-8.7 1-11.2.3-3.2 1.6-3.8 3-2L61 2.6l2 2.9-.3 1.8-1.1 7.7L59 27.1l-1.5 8.2h.9l1-1.1 4.1-5.4 6.9-8.6 3-3.5L77 13l2.3-1.8h4.3l3.1 4.7-1.4 4.9-4.4 5.6-3.7 4.7-5.3 7.1-3.2 5.7.3.4h.7l12-2.6 6.4-1.1 7.6-1.3 3.5 1.6.4 1.6-1.4 3.4-8.2 2-9.6 2-14.3 3.3-.2.1.2.3 6.4.6 2.8.2h6.8l12.6 1 3.3 2 1.9 2.7-.3 2-5.1 2.6-6.8-1.6-16-3.8-5.4-1.3h-.8v.4l4.6 4.5 8.3 7.5L89 80.1l.5 2.4-1.3 2-1.4-.2-9.2-7-3.6-3-8-6.8h-.5v.7l1.8 2.7 9.8 14.7.5 4.5-.7 1.4-2.6 1-2.7-.6-5.8-8-6-9-4.7-8.2-.5.4-2.9 30.2-1.3 1.5-3 1.2-2.5-2-1.4-3 1.4-6.2 1.6-8 1.3-6.4 1.2-7.9.7-2.6v-.2H49L43 72l-9 12.3-7.2 7.6-1.7.7-3-1.5.3-2.8L24 86l10-12.8 6-7.9 4-4.6-.1-.5h-.3L17.2 77.4l-4.7.6-2-2 .2-3 1-1 8-5.5Z"/></svg>';
1217
+ const OPENAI_SVG='<svg viewBox="0 0 20 20"><path fill="#10a37f" d="M11.248 18.25q-.825 0-1.568-.314a4.3 4.3 0 0 1-1.32-.874 4 4 0 0 1-1.304.214 4 4 0 0 1-2.046-.544 4.27 4.27 0 0 1-1.518-1.485 4 4 0 0 1-.56-2.095q0-.48.131-1.04A4.4 4.4 0 0 1 2.04 10.71a4.07 4.07 0 0 1 .017-3.4 4.2 4.2 0 0 1 1.056-1.418 3.8 3.8 0 0 1 1.6-.842 3.9 3.9 0 0 1 .76-1.683q.593-.759 1.451-1.188a4.04 4.04 0 0 1 1.832-.429q.825 0 1.567.313.742.314 1.32.875a4 4 0 0 1 1.304-.215q1.106 0 2.046.545a4.14 4.14 0 0 1 1.501 1.485q.578.941.578 2.095 0 .48-.132 1.04.66.61 1.023 1.419.363.792.363 1.666 0 .892-.38 1.717a4.3 4.3 0 0 1-1.072 1.435 3.8 3.8 0 0 1-1.584.825 3.8 3.8 0 0 1-.775 1.683 4.06 4.06 0 0 1-1.436 1.188 4.04 4.04 0 0 1-1.832.429m-4.076-2.062q.825 0 1.435-.347l3.103-1.782a.36.36 0 0 0 .164-.313v-1.42L7.881 14.62a.67.67 0 0 1-.726 0l-3.118-1.798a.5.5 0 0 1-.017.115v.198q0 .841.396 1.551.413.693 1.139 1.089a3.2 3.2 0 0 0 1.617.412m.165-2.69a.4.4 0 0 0 .181.05q.083 0 .165-.05l1.238-.71-3.977-2.31a.7.7 0 0 1-.363-.643v-3.58q-.825.362-1.32 1.122a2.9 2.9 0 0 0-.495 1.65q0 .809.413 1.55.412.743 1.072 1.123zm3.91 3.663q.875 0 1.585-.396a2.96 2.96 0 0 0 1.534-2.64v-3.564a.32.32 0 0 0-.165-.297l-1.254-.726v4.604a.7.7 0 0 1-.363.643l-3.119 1.799a3 3 0 0 0 1.783.577m.627-6.039V8.878L10.01 7.822 8.129 8.878v2.244l1.881 1.056zM7.057 5.859a.7.7 0 0 1 .363-.644l3.119-1.798a3 3 0 0 0-1.782-.578q-.874 0-1.584.396A2.96 2.96 0 0 0 6.05 4.324a3.07 3.07 0 0 0-.396 1.551v3.547q0 .199.165.314l1.237.726zm8.383 7.887q.825-.364 1.303-1.123.495-.758.495-1.65a3.15 3.15 0 0 0-.412-1.55q-.413-.743-1.073-1.123l-3.086-1.782q-.099-.065-.181-.049a.3.3 0 0 0-.165.05l-1.238.692 3.993 2.327a.6.6 0 0 1 .264.264.64.64 0 0 1 .1.363zm-3.317-8.382a.63.63 0 0 1 .726 0l3.135 1.831v-.297q0-.792-.396-1.501a2.86 2.86 0 0 0-1.105-1.155q-.71-.43-1.65-.43-.825 0-1.436.347L8.294 5.941a.36.36 0 0 0-.165.314v1.418z"/></svg>';
1218
+ document.getElementById('tool-split').innerHTML=
1219
+ `<div class="tool-chip">${OPENAI_SVG}<div><div class="pct">{{codexPct}}%</div><div class="name">OpenAI Codex</div></div></div>`+
1220
+ `<div class="tool-chip">${CLAUDE_SVG}<div><div class="pct">{{claudePct}}%</div><div class="name">Claude Code</div></div></div>`;
1221
+ </script>
1222
+
1223
+ <!-- Echo mascot (Rive) — the persona avatar, animated; replaces the old hand-drawn SVG -->
1224
+ <script src="./vendor/rive.js"></script>
1225
+ <script>
1226
+ (function(){
1227
+ if(!window.rive){ console.error('Rive runtime missing'); return; }
1228
+ const { Rive, Layout, Fit, Alignment, RuntimeLoader } = window.rive;
1229
+ RuntimeLoader.setWasmUrl('./vendor/rive.wasm');
1230
+ const canvas = document.getElementById('persona-mascot');
1231
+ if(!canvas) return;
1232
+ const mascot = new Rive({
1233
+ src: './vendor/echo_general-file-21.riv',
1234
+ canvas,
1235
+ autoplay: true,
1236
+ stateMachines: 'SM-General',
1237
+ layout: new Layout({ fit: Fit.Cover, alignment: Alignment.Center }),
1238
+ onLoad: () => {
1239
+ const resize = () => { try { mascot.resizeDrawingSurfaceToCanvas(); } catch(e){} };
1240
+ resize();
1241
+ try {
1242
+ const inputs = mascot.stateMachineInputs('SM-General');
1243
+ const greet = inputs && inputs.find(i => i.name === 'introgreeting');
1244
+ if (greet) greet.fire();
1245
+ } catch(e){}
1246
+ setTimeout(resize, 300);
1247
+ window.addEventListener('resize', resize);
1248
+ },
1249
+ onLoadError: (e) => console.error('Echo mascot failed to load', e),
1250
+ });
1251
+ })();
1252
+ </script>
1253
+ </body>
1254
+ </html>